Commit 7422c99a authored by Adam Chlipala's avatar Adam Chlipala

Templatize Impure

parent 20dc1def
...@@ -67,6 +67,7 @@ Module impredicative. ...@@ -67,6 +67,7 @@ Module impredicative.
-> eval (c2 v1) v2 -> eval (c2 v1) v2
-> eval (Bind c1 c2) v2. -> eval (Bind c1 c2) v2.
(* begin thide *)
Fixpoint termDenote (e : term dynamic) : computation dynamic := Fixpoint termDenote (e : term dynamic) : computation dynamic :=
match e with match e with
| Var v => Return v | Var v => Return v
...@@ -78,6 +79,7 @@ Module impredicative. ...@@ -78,6 +79,7 @@ Module impredicative.
| Unit => Return (Dyn tt) | Unit => Return (Dyn tt)
end. end.
(* end thide *)
Definition TermDenote (E : Term) := termDenote (E _). Definition TermDenote (E : Term) := termDenote (E _).
...@@ -87,15 +89,18 @@ Module impredicative. ...@@ -87,15 +89,18 @@ Module impredicative.
Eval compute in TermDenote ident_unit. Eval compute in TermDenote ident_unit.
Theorem eval_ident_unit : eval (TermDenote ident_unit) (Dyn tt). Theorem eval_ident_unit : eval (TermDenote ident_unit) (Dyn tt).
(* begin thide *)
compute. compute.
repeat econstructor. repeat econstructor.
simpl. simpl.
constructor. constructor.
Qed. Qed.
(* end thide *)
Theorem invert_ident : forall (E : Term) d, Theorem invert_ident : forall (E : Term) d,
eval (TermDenote (fun _ => ident _ @ E _)) d eval (TermDenote (fun _ => ident _ @ E _)) d
-> eval (TermDenote E) d. -> eval (TermDenote E) d.
(* begin thide *)
inversion 1. inversion 1.
crush. crush.
...@@ -106,6 +111,7 @@ Module impredicative. ...@@ -106,6 +111,7 @@ Module impredicative.
simpl in H0. simpl in H0.
(** [injection H0.] *) (** [injection H0.] *)
Abort. Abort.
(* end thide *)
End impredicative. End impredicative.
...@@ -147,6 +153,7 @@ Module predicative. ...@@ -147,6 +153,7 @@ Module predicative.
-> eval ds (f d2) ds' d3 -> eval ds (f d2) ds' d3
-> eval ds (CApp (Func i) d2) ds' d3. -> eval ds (CApp (Func i) d2) ds' d3.
(* begin thide *)
Fixpoint termDenote (e : term val) : computation := Fixpoint termDenote (e : term val) : computation :=
match e with match e with
| Var v => Return v | Var v => Return v
...@@ -157,6 +164,7 @@ Module predicative. ...@@ -157,6 +164,7 @@ Module predicative.
| Unit => Return VUnit | Unit => Return VUnit
end. end.
(* end thide *)
Definition TermDenote (E : Term) := termDenote (E _). Definition TermDenote (E : Term) := termDenote (E _).
...@@ -166,6 +174,7 @@ Module predicative. ...@@ -166,6 +174,7 @@ Module predicative.
Eval compute in TermDenote ident_unit. Eval compute in TermDenote ident_unit.
Theorem eval_ident_unit : exists ds, eval nil (TermDenote ident_unit) ds VUnit. Theorem eval_ident_unit : exists ds, eval nil (TermDenote ident_unit) ds VUnit.
(* begin thide *)
compute. compute.
repeat econstructor. repeat econstructor.
simpl. simpl.
...@@ -207,10 +216,12 @@ Module predicative. ...@@ -207,10 +216,12 @@ Module predicative.
| [ |- context[if ?E then _ else _] ] => destruct E | [ |- context[if ?E then _ else _] ] => destruct E
end; crush. end; crush.
Qed. Qed.
(* end thide *)
Theorem invert_ident : forall (E : Term) ds ds' d, Theorem invert_ident : forall (E : Term) ds ds' d,
eval ds (TermDenote (fun _ => ident _ @ E _)) ds' d eval ds (TermDenote (fun _ => ident _ @ E _)) ds' d
-> eval ((fun x => Return x) :: ds) (TermDenote E) ds' d. -> eval ((fun x => Return x) :: ds) (TermDenote E) ds' d.
(* begin thide *)
inversion 1; subst. inversion 1; subst.
clear H. clear H.
inversion H3; clear H3; subst. inversion H3; clear H3; subst.
...@@ -222,5 +233,6 @@ Module predicative. ...@@ -222,5 +233,6 @@ Module predicative.
inversion H7; clear H7; subst. inversion H7; clear H7; subst.
assumption. assumption.
Qed. Qed.
(* end thide *)
End predicative. End predicative.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment