@@ -52,6 +52,16 @@ type gbag_pcm_carrier (a:eqtype) =
5252 | P : map a -> gbag_pcm_carrier a
5353 | F : map a -> gbag_pcm_carrier a
5454
55+ let gbag_equal # a ( m1 m2 : gbag_pcm_carrier a ) : Tot prop =
56+ match m1 , m2 with
57+ | P m1' , P m2' -> Map. equal m1' m2'
58+ | F m1' , F m2' -> Map. equal m1' m2'
59+ | _ , _ -> False
60+
61+ let lemma_elim_gbag_equal # a ( m1 m2 : gbag_pcm_carrier a )
62+ : Lemma ( requires gbag_equal m1 m2 ) ( ensures m1 == m2 ) [ SMTPat ( gbag_equal m1 m2 )]
63+ = ()
64+
5565let gbag_pcm_composable # a : symrel ( gbag_pcm_carrier a ) =
5666 fun x y ->
5767 match x , y with
@@ -96,51 +106,44 @@ let gbag_pcm' a : pcm' (gbag_pcm_carrier a) =
96106 one = gbag_pcm_one ;
97107 }
98108
99- # push - options " --warn_error -271"
100- let op_maps_comm a
101- : m1 : map a -> m2 : map a -> Lemma ( op_maps m1 m2 == op_maps m2 m1 ) [ SMTPat ()] =
102- fun m1 m2 ->
103- assert ( Map. equal ( op_maps m1 m2 ) ( op_maps m2 m1 ))
104-
105- let op_maps_assoc_l a
106- : m1 : map a -> m2 : map a -> m3 : map a ->
107- Lemma ( op_maps m1 ( op_maps m2 m3 ) == op_maps ( op_maps m1 m2 ) m3 ) [ SMTPat ()] =
108- fun m1 m2 m3 ->
109- assert ( Map. equal ( op_maps m1 ( op_maps m2 m3 )) ( op_maps ( op_maps m1 m2 ) m3 ))
110-
111- let op_maps_assoc_r a
112- : m1 : map a -> m2 : map a -> m3 : map a ->
113- Lemma ( op_maps m1 ( op_maps m2 m3 ) == op_maps ( op_maps m1 m2 ) m3 ) [ SMTPat ()] =
114- fun m1 m2 m3 ->
115- assert ( Map. equal ( op_maps m1 ( op_maps m2 m3 )) ( op_maps ( op_maps m1 m2 ) m3 ))
116-
117109let gbag_pcm_commutative a : lem_commutative ( gbag_pcm' a ) =
118- let _ = op_maps_comm a in
119- fun _ _ -> ( )
110+ fun m1 m2 ->
111+ assert ( gbag_equal ( gbag_pcm_op m1 m2 ) ( gbag_pcm_op m2 m1 ) )
120112
121- # restart - solver
122- # push - options " --z3rlimit_factor 20 --fuel 0 --ifuel 1 --split_queries no"
113+ # push - options " --split_queries always --z3rlimit 20"
123114let gbag_pcm_assoc_l a : lem_assoc_l ( gbag_pcm' a ) =
124- let _ = op_maps_comm a in
125- let _ = op_maps_assoc_l a in
126- let _ = op_maps_assoc_r a in
127- fun _ _ _ -> ()
115+ fun x y z ->
116+ match x , y , z with
117+ | P m1 , P m2 , P m3
118+ | F m1 , P m2 , P m3
119+ | P m1 , F m2 , P m3
120+ | P m1 , P m2 , F m3 ->
121+ assert ( gbag_pcm_composable x y );
122+ assert ( gbag_pcm_composable ( gbag_pcm_op x y ) z );
123+ assert ( gbag_pcm_op x ( gbag_pcm_op y z ) ` gbag_equal ` gbag_pcm_op ( gbag_pcm_op x y ) z );
124+ ()
125+ | _ -> assert False
128126
129127let gbag_pcm_assoc_r a : lem_assoc_r ( gbag_pcm' a ) =
130- let _ = op_maps_comm a in
131- let _ = op_maps_assoc_l a in
132- let _ = op_maps_assoc_r a in
133- fun _ _ _ -> ()
128+ fun x y z ->
129+ match x , y , z with
130+ | P m1 , P m2 , P m3
131+ | F m1 , P m2 , P m3
132+ | P m1 , F m2 , P m3
133+ | P m1 , P m2 , F m3 ->
134+ assert ( gbag_pcm_composable y z );
135+ assert ( gbag_pcm_composable x ( gbag_pcm_op y z ));
136+ assert ( gbag_pcm_op x ( gbag_pcm_op y z ) ` gbag_equal ` gbag_pcm_op ( gbag_pcm_op x y ) z );
137+ ()
138+ | _ -> assert False
139+ # pop - options
134140
135141let gbag_pcm_is_unit a : lem_is_unit ( gbag_pcm' a ) =
136142 let p = gbag_pcm' a in
137143 fun x ->
138144 assert ( p . composable x p . one );
139- match x with
140- | P m ->
141- assert ( Map. equal ( op_maps m ( Map. const None )) m )
142- | F m ->
143- assert ( Map. equal ( op_maps m ( Map. const None )) m )
145+ assert ( p . op x p . one ` gbag_equal ` x );
146+ ()
144147
145148let gbag_pcm a : pcm ( gbag_pcm_carrier a ) = {
146149 p = gbag_pcm' a ;
@@ -150,8 +153,6 @@ let gbag_pcm a : pcm (gbag_pcm_carrier a) = {
150153 is_unit = gbag_pcm_is_unit a ;
151154 refine = ( fun _ -> True )
152155}
153- # pop - options
154- # pop - options
155156
156157# restart - solver
157158# push - options " --z3rlimit_factor 4 --fuel 0 --ifuel 1 --split_queries no --warn_error -271"
0 commit comments