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
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
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
44 let ghost test_map (ghost x : ref mapintint) : unit
45 ensures { MapIntInt.get !x 0 <> MapIntInt.get !x 1 }
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 }
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 }
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 }
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 }
70 x := MapIntBool.set !x 0 true
78 goal t1 : forall t:mapintint, i : int.
79 get (set t 0 42) i = get t i