Commit d603fecb authored by Adam Chlipala's avatar Adam Chlipala

Removed G2 everywhere

parent a555abd7
...@@ -113,10 +113,9 @@ Module Concrete. ...@@ -113,10 +113,9 @@ Module Concrete.
induction G' as [ | [x' t'] tl ]; crush; eauto 9. induction G' as [ | [x' t'] tl ]; crush; eauto 9.
Qed. Qed.
Lemma weaken_lookup : forall G2 x t G', Lemma weaken_lookup : forall x t G' G1,
G' # G2 G1 |-v x : t
-> forall G1, G1 ++ G2 |-v x : t -> G1 ++ G' |-v x : t.
-> G1 ++ G' ++ G2 |-v x : t.
Hint Resolve weaken_lookup'. Hint Resolve weaken_lookup'.
induction G1 as [ | [x' t'] tl ]; crush; induction G1 as [ | [x' t'] tl ]; crush;
...@@ -127,27 +126,16 @@ Module Concrete. ...@@ -127,27 +126,16 @@ Module Concrete.
Hint Resolve weaken_lookup. Hint Resolve weaken_lookup.
Lemma hasType_push : forall x t G1 G2 e t',
((x, t) :: G1) ++ G2 |-e e : t'
-> (x, t) :: G1 ++ G2 |-e e : t'.
trivial.
Qed.
Hint Resolve hasType_push.
Theorem weaken_hasType' : forall G' G e t, Theorem weaken_hasType' : forall G' G e t,
G |-e e : t G |-e e : t
-> forall G1 G2, G = G1 ++ G2 -> G ++ G' |-e e : t.
-> G' # G2
-> G1 ++ G' ++ G2 |-e e : t.
induction 1; crush; eauto. induction 1; crush; eauto.
Qed. Qed.
Theorem weaken_hasType : forall G e t, Theorem weaken_hasType : forall e t,
G |-e e : t nil |-e e : t
-> forall G', G' # G -> forall G', G' |-e e : t.
-> G' ++ G |-e e : t. intros; change G' with (nil ++ G');
intros; change (G' ++ G) with (nil ++ G' ++ G);
eapply weaken_hasType'; eauto. eapply weaken_hasType'; eauto.
Qed. Qed.
...@@ -157,15 +145,11 @@ Module Concrete. ...@@ -157,15 +145,11 @@ Module Concrete.
intros; rewrite (app_nil_end G); apply weaken_hasType; auto. intros; rewrite (app_nil_end G); apply weaken_hasType; auto.
Qed. Qed.
Theorem weaken_hasType1 : forall G e t, Theorem weaken_hasType1 : forall e t,
G |-e e : t nil |-e e : t
-> forall x t', x ## G -> forall x t', (x, t') :: nil |-e e : t.
-> (x, t') :: G |-e e : t. intros; change ((x, t') :: nil) with (((x, t') :: nil) ++ nil);
intros; change ((x, t') :: G) with (((x, t') :: nil) ++ G); apply weaken_hasType; crush.
apply weaken_hasType; crush;
match goal with
| [ H : (_, _) = (_, _) |- _ ] => injection H
end; crush; eauto.
Qed. Qed.
Hint Resolve weaken_hasType_closed weaken_hasType1. Hint Resolve weaken_hasType_closed weaken_hasType1.
...@@ -198,10 +182,10 @@ Module Concrete. ...@@ -198,10 +182,10 @@ Module Concrete.
inversion 2; crush; elimtype False; eauto. inversion 2; crush; elimtype False; eauto.
Qed. Qed.
Lemma subst_lookup : forall x' t G2, Lemma subst_lookup : forall x' t,
x <> x' x <> x'
-> forall G1, G1 ++ (x, xt) :: G2 |-v x' : t -> forall G1, G1 ++ (x, xt) :: nil |-v x' : t
-> G1 ++ G2 |-v x' : t. -> G1 |-v x' : t.
induction G1 as [ | [x'' t'] tl ]; crush; induction G1 as [ | [x'' t'] tl ]; crush;
match goal with match goal with
| [ H : _ |-v _ : _ |- _ ] => inversion H | [ H : _ |-v _ : _ |- _ ] => inversion H
...@@ -210,20 +194,22 @@ Module Concrete. ...@@ -210,20 +194,22 @@ Module Concrete.
Hint Resolve subst_lookup. Hint Resolve subst_lookup.
Lemma subst_lookup'' : forall G2 x' t, Lemma subst_lookup'' : forall x' t G1,
x' ## G2 x' ## G1
-> forall G1, x' ## G1 -> G1 ++ (x, xt) :: nil |-v x' : t
-> G1 ++ (x, xt) :: G2 |-v x' : t -> t = xt.
-> t = xt.
Hint Resolve subst_lookup'. Hint Resolve subst_lookup'.
induction G1 as [ | [x'' t'] tl ]; crush; eauto; induction G1 as [ | [x'' t'] tl ]; crush; eauto;
match goal with match goal with
| [ H : _ |-v _ : _ |- _ ] => inversion H | [ H : _ |-v _ : _ |- _ ] => inversion H
end; crush; elimtype False; eauto. end; crush; elimtype False; eauto;
match goal with
| [ H : nil |-v _ : _ |- _ ] => inversion H
end.
Qed. Qed.
Implicit Arguments subst_lookup'' [G2 x' t G1]. Implicit Arguments subst_lookup'' [x' t G1].
Lemma disjoint_cons : forall x x' t (G : ctx), Lemma disjoint_cons : forall x x' t (G : ctx),
x ## G x ## G
...@@ -237,10 +223,10 @@ Module Concrete. ...@@ -237,10 +223,10 @@ Module Concrete.
Hint Resolve disjoint_cons. Hint Resolve disjoint_cons.
Lemma shadow_lookup : forall G2 v t t' G1, Lemma shadow_lookup : forall v t t' G1,
G1 |-v x : t' G1 |-v x : t'
-> G1 ++ (x, xt) :: G2 |-v v : t -> G1 ++ (x, xt) :: nil |-v v : t
-> G1 ++ G2 |-v v : t. -> G1 |-v v : t.
induction G1 as [ | [x'' t''] tl ]; crush; induction G1 as [ | [x'' t''] tl ]; crush;
match goal with match goal with
| [ H : nil |-v _ : _ |- _ ] => inversion H | [ H : nil |-v _ : _ |- _ ] => inversion H
...@@ -249,11 +235,11 @@ Module Concrete. ...@@ -249,11 +235,11 @@ Module Concrete.
end. end.
Qed. Qed.
Lemma shadow_hasType' : forall G2 G e t, Lemma shadow_hasType' : forall G e t,
G |-e e : t G |-e e : t
-> forall G1, G = G1 ++ (x, xt) :: G2 -> forall G1, G = G1 ++ (x, xt) :: nil
-> forall t'', G1 |-v x : t'' -> forall t'', G1 |-v x : t''
-> G1 ++ G2 |-e e : t. -> G1 |-e e : t.
Hint Resolve shadow_lookup. Hint Resolve shadow_lookup.
induction 1; crush; eauto; induction 1; crush; eauto;
...@@ -261,12 +247,12 @@ Module Concrete. ...@@ -261,12 +247,12 @@ Module Concrete.
| [ H : (?x0, _) :: _ ++ (x, _) :: _ |-e _ : _ |- _ ] => | [ H : (?x0, _) :: _ ++ (x, _) :: _ |-e _ : _ |- _ ] =>
destruct (var_eq x0 x); subst; eauto destruct (var_eq x0 x); subst; eauto
end. end.
Qed. Qed.
Lemma shadow_hasType : forall G1 G2 e t t'', Lemma shadow_hasType : forall G1 e t t'',
G1 ++ (x, xt) :: G2 |-e e : t G1 ++ (x, xt) :: nil |-e e : t
-> G1 |-v x : t'' -> G1 |-v x : t''
-> G1 ++ G2 |-e e : t. -> G1 |-e e : t.
intros; eapply shadow_hasType'; eauto. intros; eapply shadow_hasType'; eauto.
Qed. Qed.
...@@ -274,25 +260,23 @@ Module Concrete. ...@@ -274,25 +260,23 @@ Module Concrete.
Theorem subst_hasType : forall G e2 t, Theorem subst_hasType : forall G e2 t,
G |-e e2 : t G |-e e2 : t
-> forall G1 G2, G = G1 ++ (x, xt) :: G2 -> forall G1, G = G1 ++ (x, xt) :: nil
-> x ## G1 -> x ## G1
-> x ## G2 -> G1 |-e subst e2 : t.
-> G1 ++ G2 |-e subst e2 : t.
induction 1; crush; induction 1; crush;
try match goal with try match goal with
| [ |- context[if ?E then _ else _] ] => destruct E | [ |- context[if ?E then _ else _] ] => destruct E
end; crush; eauto 6; end; crush; eauto 6;
match goal with match goal with
| [ H1 : x ## _, H2 : x ## _, H3 : _ |-v x : _ |- _ ] => | [ H1 : x ## _, H2 : _ |-v x : _ |- _ ] =>
rewrite (subst_lookup'' H2 H1 H3) rewrite (subst_lookup'' H1 H2)
end; crush. end; crush.
Qed. Qed.
Theorem subst_hasType_closed : forall e2 t, Theorem subst_hasType_closed : forall e2 t,
(x, xt) :: nil |-e e2 : t (x, xt) :: nil |-e e2 : t
-> nil |-e subst e2 : t. -> nil |-e subst e2 : t.
intros; change (nil ++ nil |-e subst e2 : t); intros; eapply subst_hasType; eauto.
eapply subst_hasType; eauto.
Qed. Qed.
End subst. End subst.
...@@ -323,7 +307,7 @@ Module Concrete. ...@@ -323,7 +307,7 @@ Module Concrete.
Hint Constructors step. Hint Constructors step.
Theorem progress : forall G e t, G |-e e : t Lemma progress' : forall G e t, G |-e e : t
-> G = nil -> G = nil
-> val e \/ exists e', e ==> e'. -> val e \/ exists e', e ==> e'.
induction 1; crush; eauto; induction 1; crush; eauto;
...@@ -335,14 +319,25 @@ Module Concrete. ...@@ -335,14 +319,25 @@ Module Concrete.
end. end.
Qed. Qed.
Theorem preservation : forall G e t, G |-e e : t Theorem progress : forall e t, nil |-e e : t
-> val e \/ exists e', e ==> e'.
intros; eapply progress'; eauto.
Qed.
Lemma preservation' : forall G e t, G |-e e : t
-> G = nil -> G = nil
-> forall e', e ==> e' -> forall e', e ==> e'
-> G |-e e' : t. -> nil |-e e' : t.
induction 1; inversion 2; crush; eauto; induction 1; inversion 2; crush; eauto;
match goal with match goal with
| [ H : _ |-e Abs _ _ : _ |- _ ] => inversion H | [ H : _ |-e Abs _ _ : _ |- _ ] => inversion H
end; eauto. end; eauto.
Qed. Qed.
Theorem preservation : forall e t, nil |-e e : t
-> forall e', e ==> e'
-> nil |-e e' : t.
intros; eapply preservation'; eauto.
Qed.
End Concrete. End Concrete.
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