Why Verus cannot auto infer "j -1" is nat given that j > 0? #1378
-
I wrote this: Error says |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
The reason for this is that Verus relies on the standard Rust type checker for types like |
Beta Was this translation helpful? Give feedback.
-
|
@KaminariOS for questions like this, I also recommend asking on Zulip: https://verus-lang.zulipchat.com/login/ |
Beta Was this translation helpful? Give feedback.
The reason for this is that Verus relies on the standard Rust type checker for types like
intandnat, 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 onintandnatare conservative -- they can assume that adding twonatvalues produces anat, but subtracting twonatvalues might yield a negative number. (I've found that this often makesnatless convenient thanint.)