Repository navigation
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
coeff-aij
added a commit
to coeff-aij/thrust
that referenced
this pull request
Oct 1, 2026
…del as UInt Follows coord-e#268 where the merge departed from it, and extends it to the positions #286 makes reachable. - The unsigned primitive types have model::UInt as their model, Seq::len returns UInt and Enumerate's count is UInt, as in #268, and build_refined conjoins the model's facts to each template again. Specifications that passed a usize where a predicate took Int now name UInt (the rustc_coroutine stages and drafts, derived_ord_newtype, ghost_const). - The type builders place the model's facts on tuple elements, struct fields and the content of shared and mutable references. Subtyping lifts the refinement of an owned or shared pointer's content to the pointer, so a field fact is stated about the field's own term. - On the content of a mutable reference the facts are an invariant of the reference. A mutable borrow takes its invariant from the box it borrows, so the box of a mutable local that the body borrows mutably carries the facts of the local's declared type, and the bound value has to satisfy them. Without this a fresh borrow of a struct local is related to a parameter whose content has the facts with no term for the content, an obligation that cannot be proved. rustc_coroutine: BitMatrix::rows, DenseBitSet::clear_excess_bits and Size::bits verify without #[thrust::trusted]; BitMatrix::range stays trusted because num_words has no contract. map_over_filter_item's fail twin gets 300 s: its refutation takes about 100 s on fptprove 804d76744 and 82865d8c7. UI tests: 858 passed. The 8 failures are the 6 that fail on main 94e10d5 (fold, fold_fn, map_fn, map_no_closure, simple_loop_self_mut_noinv, skip_step) and slice_split_first_loop and traits/multi_params, which time out on the pinned coar:804d76744 and pass on fptprove develop 82865d8c7. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
coeff-aij
referenced
this pull request
in coeff-aij/thrust
Oct 1, 2026
…ields and reference contents, usize and friends model as UInt BitMatrix::rows, DenseBitSet::clear_excess_bits, Size::bits and Size::checked_add in the rustc_coroutine stages verify without #[thrust::trusted]; redundant non-negativity annotations are dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
coeff-aij
referenced
this pull request
in coeff-aij/thrust
Oct 1, 2026
…e growth of unsigned facts as refinements Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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