Skip to content

Why Verus cannot auto infer "j -1" is nat given that j > 0? #1378

Closed Answered by Chris-Hawblitzel
KaminariOS asked this question in Support
Discussion options

You must be logged in to vote

The reason for this is that Verus relies on the standard Rust type checker for types like int and nat, and the Rust type checker does not reason about integer arithmetic when performing type checking (in contrast to Verus verifier, which uses an SMT solver to reason about integer arithmetic when performing verification). Because of this, the typing rules that Verus encodes for operations on int and nat are conservative -- they can assume that adding two nat values produces a nat, but subtracting two nat values might yield a negative number. (I've found that this often makes nat less convenient than int.)

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by utaal
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
3 participants