Conversation
`usize`, `u32` and `u64` now have `thrust_models::model::UInt` as their model, and a value whose model is `UInt` is refined with `v >= 0`. The fact is an assumption where such a value is read and an obligation where one is produced, so unsigned subtraction that may underflow is now rejected. `TypeBuilder::build` therefore yields a `rty::RefinedType`. The refinement describes the value as a whole: a refinement nested in a type has no counterpart on the value side, where the analyzer keeps the facts about the parts of a value in the formula of a `PlaceType`, so nested positions are left unrefined. Enum variant fields are the exception, as they are related against the field's own value, and `EnumVariantDef` records them as refinement types. In annotations `Int` and `UInt` mix through `model::Integer`, and an `Array` of either integer model is indexed by both through `model::IndexModel`. An annotated refinement is conjoined onto what the model already says about the value rather than replacing it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RiJqqjcQaJoLMyZ5PJZ1dM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
usize,u32andu64now havethrust_models::model::UIntas their model, and a value whose model isUIntis refined withv >= 0. The fact is an assumption where such a value is read and an obligation where one is produced, so unsigned subtraction that may underflow is rejected.Analyzer
TypeBuilder::buildyields arty::RefinedType. The refinement describes the value as a whole: a refinement nested in a type has no counterpart on the value side, where the analyzer keeps the facts about the parts of a value in the formula of aPlaceType, so nested positions are left unrefined. Enum variant fields are the exception, as they are related against the field's own value, andEnumVariantDefrecords them as refinement types.An annotated refinement is conjoined onto what the model already says about the value rather than replacing it.
truncate_outer_fn_paramsasserted that every parameter but the last is unrefined; it now asserts that they carry no predicate variable.Models
In annotations
IntandUIntmix throughmodel::Integer, and anArrayof either integer model is indexed by both throughmodel::IndexModel.Seqis indexed and measured byUInt, soSeq::len()returns one; theghost_constpair used it as a source of anIntand now works overSeq<UInt>.Tests
unsigned_subpins the obligation direction (x - ywithoutrequires(x >= y)isUnsat) andunsigned_loopthe assumption direction (while n > 0 { n -= 1 }ends at0, which does not hold fori32). The UI suite passes: 346 tests.Known gap
The refinement only reaches a value's root, so an unsigned value read out of a nested position has no fact to offer, and one flowing into an unsigned position raises an obligation that cannot be discharged:
&u32/&mut u32Vec<u32>,Seq's lengthThis costs verification of programs that used to pass:
#[thrust::callable] fn get(x: &u32) -> u32 { *x }is nowUnsat, as is returnings.nfrom astruct S { n: u32 }. No test in the suite has such a flow, which is why it is green. Closing the gap needs the unsignedness where a type is rebuilt from aPlaceType, i.e. inrty::Typerather than in a refinement.🤖 Generated with Claude Code
https://claude.ai/code/session_01RiJqqjcQaJoLMyZ5PJZ1dM
Generated by Claude Code