@@ -7,7 +7,7 @@ Require Import ExtLib.Structures.Proper.
77Require Import ExtLib.Structures.MonadLaws.
88Require Import ExtLib.Data.Option.
99Require Import ExtLib.Data.Monads.OptionMonad.
10- Require Import ExtLib.Tactics.TypeTac.
10+ Require Import ExtLib.Tactics.TypeTac.
1111
1212Set Implicit Arguments .
1313Set Strict Implicit .
@@ -51,7 +51,7 @@ Section Laws.
5151 Proof . do 5 red; eauto. Qed .
5252 End parametric.
5353
54- Theorem equal_match : forall (A B : Type) (eA : type A) (eB : type B),
54+ Theorem equal_match : forall (A B : Type) (eA : type A) (eB : type B),
5555 typeOk eA -> typeOk eB ->
5656 forall (x y : option A) (a b : B) (f g : A -> B),
5757 equal x y ->
@@ -67,11 +67,12 @@ Section Laws.
6767 end .
6868 Proof .
6969 destruct x; destruct y; intros; eauto with typeclass_instances; type_tac.
70+ { inversion H1. assumption. }
7071 { inversion H1. }
7172 { inversion H1. }
7273 Qed .
7374
74- Instance proper_match : forall (A B : Type) (eA : type A) (eB : type B),
75+ Instance proper_match : forall (A B : Type) (eA : type A) (eB : type B),
7576 typeOk eA -> typeOk eB ->
7677 forall (x : option A),
7778 proper x ->
@@ -100,22 +101,23 @@ Section Laws.
100101 simpl; unfold optionT_eq; simpl; intros.
101102 rewrite bind_associativity; eauto with typeclass_instances; intros; type_tac.
102103 destruct x; destruct y; try solve [ inversion H5 ]; type_tac.
104+ inversion H5; assumption.
103105 eapply equal_match; eauto with typeclass_instances; type_tac.
104106 rewrite bind_of_return; eauto with typeclass_instances; type_tac.
105107 eapply equal_match; eauto with typeclass_instances; type_tac.
106108 eapply equal_match; eauto with typeclass_instances; type_tac.
107109 eapply equal_match; eauto with typeclass_instances; type_tac. }
108110 { simpl; unfold optionT_eq; simpl; intros. red; simpl; intros. type_tac. }
109- { simpl; unfold optionT_eq; simpl; intros. red; simpl; intros.
110- red; simpl; intros. type_tac.
111+ { simpl; unfold optionT_eq; simpl; intros. red; simpl; intros.
112+ red; simpl; intros. type_tac.
111113 eapply equal_match; eauto with typeclass_instances; type_tac. }
112114 Qed .
113115
114116(* Theorem equal_match_option : forall T U (tT : type T) (tU : type U),
115117 typeOk tT -> typeOk tU ->
116118 forall (a b : option T) (f g : T -> U) (x y : U),
117119 equal a b -> equal f g -> equal x y ->
118- equal match a with
120+ equal match a with
119121 | Some a => f a
120122 | None => x
121123 end
@@ -136,11 +138,11 @@ Section Laws.
136138 { simpl; unfold lift, optionT_eq; simpl; intros.
137139 unfold liftM.
138140 rewrite bind_associativity; eauto with typeclass_instances; type_tac.
139- rewrite bind_associativity; eauto with typeclass_instances; type_tac.
141+ rewrite bind_associativity; eauto with typeclass_instances; type_tac.
140142 rewrite bind_of_return; eauto with typeclass_instances; type_tac.
141143 eapply equal_match; eauto with typeclass_instances; type_tac.
142144 eapply equal_match; eauto with typeclass_instances; type_tac. }
143- { unfold lift, liftM; simpl; intros. unfold liftM. red; simpl; intros.
145+ { unfold lift, liftM; simpl; intros. unfold liftM. red; simpl; intros.
144146 unfold optionT_eq; simpl. type_tac. }
145147 Qed .
146148
@@ -162,22 +164,23 @@ Section Laws.
162164 type_tac.
163165 apply proper_fun; intros. repeat rewrite local_ret; eauto with typeclass_instances.
164166 type_tac. eauto with typeclass_instances.
165- type_tac. type_tac. }
167+ type_tac. type_tac. }
166168 { simpl. unfold optionT_eq; simpl; intros; unfold liftM.
167169 rewrite local_bind; eauto with typeclass_instances.
168170 type_tac.
169171 destruct x; destruct y; try solve [ inversion H4 ]; type_tac.
172+ inversion H4; assumption.
170173 rewrite local_ret; eauto with typeclass_instances; type_tac.
171174 type_tac. eapply equal_match; eauto with typeclass_instances; type_tac. }
172175 { simpl. unfold optionT_eq; simpl; intros; unfold liftM.
173176 rewrite local_ret; eauto with typeclass_instances; type_tac. }
174177 { simpl. unfold optionT_eq; simpl; intros; unfold liftM.
175178 rewrite local_local; eauto with typeclass_instances; type_tac. }
176- { unfold local; simpl; intros. red. red. intros. red in H0.
179+ { unfold local; simpl; intros. red. red. intros. red in H0.
177180 red; simpl. type_tac. }
178- { Opaque lift. unfold ask; simpl; intros. red. type_tac.
181+ { Opaque lift. unfold ask; simpl; intros. red. type_tac.
179182 eapply lift_proper; eauto with typeclass_instances. Transparent lift. }
180- Qed .
183+ Qed .
181184
182185(*
183186 Global Instance MonadStateLaws_optionT (s : Type) (t : type s) (tT : typeOk t) (Ms : MonadState s m) (MLs : MonadStateLaws Monad_m _ _ Ms) : MonadStateLaws _ _ _ (@State_optionT _ _ _ Ms).
@@ -195,29 +198,29 @@ Section Laws.
195198 instantiate (1 := fun x => ret (Some x)). simpl. type_tac.
196199 type_tac. type_tac. }
197200 { type_tac. rewrite bind_of_return; eauto with typeclass_instances.
198- type_tac. type_tac.
201+ type_tac. type_tac.
199202 eapply equal_match_option; eauto with typeclass_instances; type_tac. }
200203 { eapply equal_match_option; eauto with typeclass_instances; type_tac. } }
201204 { simpl; unfold optionT_eq; simpl; intros; unfold liftM; simpl.
202- repeat rewrite bind_associativity; eauto with typeclass_instances;
205+ repeat rewrite bind_associativity; eauto with typeclass_instances;
203206 try solve [ type_tac; eapply equal_match_option; eauto with typeclass_instances; type_tac ].
204207 rewrite bind_proper; eauto with typeclass_instances.
205208 2: eapply preflexive; eauto with typeclass_instances; type_tac.
206209 instantiate (1 := fun a : unit => bind get (fun x0 : s => ret (Some x0))).
207210 { rewrite <- bind_associativity; eauto with typeclass_instances.
208211 Require Import MonadTac.
209- {
212+ {
210213 Ltac cl := eauto with typeclass_instances.
211214 Ltac tcl := solve [ cl ].
212215Ltac monad_rewrite t :=
213216 first [ t
214- | rewrite bind_rw_0; [ | tcl | tcl | tcl | t | type_tac ]
217+ | rewrite bind_rw_0; [ | tcl | tcl | tcl | t | type_tac ]
215218 | rewrite bind_rw_1 ].
216219monad_rewrite ltac:(eapply put_get; eauto with typeclass_instances).
217220rewrite bind_associativity; cl; try solve_proper.
218221rewrite bind_rw_1; [ | tcl | tcl | tcl | intros | type_tac ].
219222Focus 2.
220- etransitivity. eapply bind_of_return; cl; type_tac.
223+ etransitivity. eapply bind_of_return; cl; type_tac.
221224instantiate (1 := fun _ => ret (Some x)). simpl. type_tac.
222225Add Parametric Morphism (T : Type) (tT : type T) (tokT : typeOk tT) : (@equal _ tT)
223226 with signature (equal ==> equal ==> iff)
@@ -248,7 +251,7 @@ assert (Morphisms.Proper (equal ==> Basics.flip Basics.impl)
248251assert (Morphisms.Proper
249252 (Morphisms.pointwise_relation unit equal ==> equal)
250253 (bind (@put _ _ Ms x))).
251- { red. red. intros. eapply bind_proper; cl. solve_proper.
254+ { red. red. intros. eapply bind_proper; cl. solve_proper.
252255 red; simpl. red in H1. red.
253256
254257assert bind_proper.
@@ -260,7 +263,7 @@ setoid_rewrite bind_of_return.
260263
261264 rewrite bind_rw_0
262265 3: instantiate (1 := (bind (put x) (fun _ : unit => get))).
263-
266+
264267
265268
266269
@@ -271,15 +274,15 @@ setoid_rewrite bind_of_return.
271274 proper y ->
272275 equal (bind x y) (bind z y).
273276 Proof.
274-
277+
275278
276279 }
277280 { type_tac. rewrite bind_of_return; eauto with typeclass_instances; type_tac.
278281 eapply equal_match_option; eauto with typeclass_instances; type_tac. } }
279282
280-
283+
281284 Print MonadStateLaws.
282- *)
285+ *)
283286
284287 Global Instance MonadZeroLaws_optionT : MonadZeroLaws (@Monad_optionT _ Monad_m) type_optionT _.
285288 Proof .
0 commit comments