When debugging a perplexing problem in Alloy, I've used the evaluator to do 3 > 10
and get the result true
. Am I missing something?!
相关问题
- Univ signature appears magically when module is em
- Alloy integer comparison semantics using “Forbid O
- Experiences with using Alloy in real-world project
- How to use String in Alloy?
- The util/ordering module and ordered subsignatures
相关文章
- Experiences with using Alloy in real-world project
- How to use String in Alloy?
- The util/ordering module and ordered subsignatures
- Why does Alloy tell me that 3 >= 10?
- Alloy - Generate .xml instance from .als
- Alloy - Can't find unsat core
- 合金:定义关系只正整数(Alloy: define relation to only positiv
- 运行在合金命令范围(run command scope in alloy)
Alloy integers are typically very narrow by normal standards, and they normally have a sort of 'wraparound' semantics. In the default scope, in Alloy 4.2 Int ranges from -8 to 7, and literal 8, 9, 10 are indistinguishable from literal -8, -7, -6. (The use of out-of-range values like literal 10 cannot be detected statically, because in principle Alloy models can be infinite; the size of Int is not known statically. It is known dynamically, so it ought to be possible for literals outside the range of Int to raise a dynamic error; I do not know why they don't. It would certainly make life less confusing for some users if they did.)
If you want a constraint like
#x > 10
, you'll want to specify a larger scope for Int. N.B. the scope given for Int or int specifies the bitwidth used for the twos-complement representation of integers, not the number of Int atoms in the universe.There is a Forbid Overflow option, which may help (but see this question, which suggests possible complications).
When contemplating using integers in Alloy, it's worthwhile to think about what Jackson says in Software abstractions (discussion following sec. 2.3.2):
And (discussion after 4.8):
Good luck.