by rwmj · 6y ago · 0 comments
∀a: a+1 > a
if the type of 'a' is 32 bit int. Similarly negate(a) ≠ -a for some numbers. function Increment(A : Integer) return Integer
with Post => Increment'Result = A + 1;
It would find the counterexample for the situation where A is equal to Integer'Last. So you'd need to add a precondition like: function Increment(A : Integer) return Integer
with Pre => A < Integer'Last,
Post => Increment'Result = A + 1;
(doing this from memory and not fluent, so syntax may be off but the idea isn't) /*@ ensures \result > a; */
int increment(int a) {
return a + 1;
}
you would change it to: /*@ requires a < INT_MAX;
ensures \result > a; */
int increment(int a) {
return a + 1;
}
But if this function has N call sites, you now have N problems: At every call site you must prove that the precondition holds."iff a =/= MAXINT"