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
int
andnat
, 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 onint
andnat
are conservative -- they can assume that adding twonat
values produces anat
, but subtracting twonat
values might yield a negative number. (I've found that this often makesnat
less convenient thanint
.)