Merge branch 'upgrade_proofs_coq_8_11_to_8_16' into 'master'
[why3.git] / bench / check-ce / maps_mono.mlw
blob8151df51f880d2117e9bbaa89d19c185e2fc53cc
1 module MapIntInt
3   type mapintint = int -> int
5   let function get (f: mapintint) (x: int) : int = f x
7   let ghost function set (f: mapintint) (x: int) (v: int) : mapintint =
8     fun y -> if pure {y = x} then v else f y
10 end
12 module MapIntBool
14   type mapintbool = int -> bool
16   let function get (f: mapintbool) (x: int) : bool = f x
18   let ghost function set (f: mapintbool) (x: int) (v: bool) : mapintbool =
19     fun y -> if pure {y = x} then v else f y
21 end
23 module MapMulti
25   use MapIntInt
27   type mapmulti = int -> mapintint
29   let function get (f: mapmulti) (x: int) : mapintint = f x
31   let ghost function set (f: mapmulti) (x: int) (v: mapintint) : mapmulti =
32     fun y -> if pure {y = x} then v else f y
34 end
36 module M
38   use int.Int
39   use ref.Ref
40   use MapIntInt
41   use MapIntBool
42   use MapMulti
44   let ghost test_map (ghost x : ref mapintint) : unit
45     ensures { MapIntInt.get !x 0 <> MapIntInt.get !x 1 }
46   =
47     x := MapIntInt.set !x 0 3
49   (* Multi-dimensional maps *)
50   let ghost test_map_multidim1 (ghost x : ref mapmulti) : unit
51     ensures { MapIntInt.get (MapMulti.get !x 0) 0 <> MapIntInt.get (MapMulti.get !x 1) 1 }
52   =
53     x := MapMulti.set !x 0 (MapMulti.get !x 1)
55   let ghost test_map_multidim2 (ghost x : ref mapmulti) : unit
56     ensures { MapIntInt.get (MapMulti.get !x 0) 0 <> MapIntInt.get (MapMulti.get !x 1) 1 }
57   =
58     let x0 = MapMulti.get !x 0 in
59     let x0 = MapIntInt.set x0 0 3 in
60     x := MapMulti.set !x 0 x0
62   let ghost proj_map_test1 (ghost x : ref mapintint) : unit
63     ensures { MapIntInt.get !x 0 <> MapIntInt.get !x 1 }
64   =
65     x := MapIntInt.set !x 0 3
67   let ghost proj_map_test2 (ghost x : ref mapintbool) : unit
68     ensures { MapIntBool.get !x 0 <> MapIntBool.get !x 1 }
69   =
70     x := MapIntBool.set !x 0 true
72 end
74 theory ModelMap
76 use MapIntInt
78 goal t1 : forall t:mapintint, i : int.
79    get (set t 0 42) i = get t i
81 end