Getting started with frama-c and decided to prove a trivial bitmask function worked as intended.
/*@ requires width > 0 && width <= 64 ;
assigns \nothing ;
ensures \result > 0 ;
ensures \result == (1 << width) - 1 ;
*/
uint64_t gen_mask(uint64_t width) {
if (width >= 64)
return 0xffffffffffffffff;
else
return ((uint64_t)1 << width) - 1;
}
Unfortunately even the obvious statement that result > 0 times out with both alt-ego and z3 provers.
[wp] [Alt-Ergo 2.4.1] Goal typed_gen_mask_ensures : Timeout (Qed:2ms) (10s)
[wp] [Alt-Ergo 2.4.1] Goal typed_gen_mask_ensures_2 : Timeout (Qed:2ms) (10s)
What's wrong with my specification? The provers only have to check 64 cases even if they brute-force it, so they shouldn't be timing out.