Merge branch 'upgrade_proofs_coq_8_11_to_8_16' into 'master'
[why3.git] / bench / check-ce / jlamp_projections.mlw
blob53813fb5beb274d2a00f387b038f818aa53737bd
2 module Abstract
4 use int.Int
6 type byte
7 function to_int byte : int
8 meta "model_projection" function to_int
9 predicate in_range (x : int) = -128 <= x <= 127
10 axiom range_axiom : forall x:byte. in_range (to_int x)
13 val of_int (x:int) : byte
14   requires { in_range x }
15   ensures { to_int result = x }
17 val add (x y : byte) : byte
18   requires { [@expl:integer overflow] in_range (to_int x + to_int y) }
19   ensures { to_int result = to_int x + to_int y }
21 end
23 module AbstractAlone
25 use int.Int
26 use Abstract
28 let p3 (a : byte) : byte =
29   add a (of_int 1)
31 end
35 module AbstractWithRef
37 use int.Int
38 use ref.Ref
39 use Abstract
41 let p3 (a : ref byte) =
42   a := add !a (of_int 1)
44 end
46 module Record
48 use int.Int
49 use Abstract
51 type r = {mutable f : byte; mutable g : bool}
53 let p4 (b : r) =
54   if b.g then b.f <- add b.f (of_int 1)
56 end