| author | wenzelm | 
| Sat, 07 Jul 2007 18:39:16 +0200 | |
| changeset 23636 | 6f04e0d6809a | 
| parent 23159 | 792ff2490f91 | 
| child 23760 | aca2c7f80e2f | 
| permissions | -rw-r--r-- | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 1 | (* $Id$ *) | 
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 2 | |
| 23159 | 3 | (* Authors: Christian Urban and Mathilde Arnaud *) | 
| 4 | (* *) | |
| 5 | (* A formalisation of the Church-Rosser proof by Masako Takahashi.*) | |
| 6 | (* This formalisation follows with some very slight exceptions *) | |
| 7 | (* the version of this proof given by Randy Pollack in the paper: *) | |
| 8 | (* *) | |
| 9 | (* Polishing Up the Tait-Martin Löf Proof of the *) | |
| 10 | (* Church-Rosser Theorem (1995). *) | |
| 11 | ||
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 12 | theory CR_Takahashi | 
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 13 | imports "../Nominal" | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 14 | begin | 
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 15 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 16 | atom_decl name | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 17 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 18 | nominal_datatype lam = | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 19 | Var "name" | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 20 | | App "lam" "lam" | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 21 |   | Lam "\<guillemotleft>name\<guillemotright>lam" ("Lam [_]._" [100,100] 100)
 | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 22 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 23 | consts subst :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam"  ("_[_::=_]" [100,100,100] 100)
 | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 24 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 25 | nominal_primrec | 
| 23159 | 26 | "(Var x)[y::=s] = (if x=y then s else (Var x))" | 
| 27 | "(App t\<^isub>1 t\<^isub>2)[y::=s] = App (t\<^isub>1[y::=s]) (t\<^isub>2[y::=s])" | |
| 28 | "x\<sharp>(y,s) \<Longrightarrow> (Lam [x].t)[y::=s] = Lam [x].(t[y::=s])" | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 29 | apply(finite_guess)+ | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 30 | apply(rule TrueI)+ | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 31 | apply(simp add: abs_fresh) | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 32 | apply(fresh_guess)+ | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 33 | done | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 34 | |
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22821diff
changeset | 35 | section {* Lemmas about Capture-Avoiding Substitution *}
 | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22821diff
changeset | 36 | |
| 23159 | 37 | lemma subst_eqvt[eqvt]: | 
| 38 | fixes pi::"name prm" | |
| 39 | shows "pi\<bullet>t1[x::=t2] = (pi\<bullet>t1)[(pi\<bullet>x)::=(pi\<bullet>t2)]" | |
| 40 | by (nominal_induct t1 avoiding: x t2 rule: lam.induct) | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 41 | (auto simp add: perm_bij fresh_atm fresh_bij) | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 42 | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 43 | lemma forget: | 
| 23159 | 44 | shows "x\<sharp>t \<Longrightarrow> t[x::=s] = t" | 
| 45 | by (nominal_induct t avoiding: x s rule: lam.induct) | |
| 46 | (auto simp add: abs_fresh fresh_atm) | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 47 | |
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 48 | lemma fresh_fact: | 
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 49 | fixes z::"name" | 
| 23159 | 50 | shows "z\<sharp>(t,s) \<Longrightarrow> z\<sharp>t[y::=s]" | 
| 51 | by (nominal_induct t avoiding: z y s rule: lam.induct) | |
| 52 | (auto simp add: abs_fresh fresh_prod fresh_atm) | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 53 | |
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 54 | lemma fresh_fact': | 
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 55 | fixes x::"name" | 
| 23159 | 56 | shows "x\<sharp>s \<Longrightarrow> x\<sharp>t[x::=s]" | 
| 57 | by (nominal_induct t avoiding: x s rule: lam.induct) | |
| 58 | (auto simp add: abs_fresh fresh_atm) | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 59 | |
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 60 | lemma substitution_lemma: | 
| 23159 | 61 | assumes a: "x\<noteq>y" "x\<sharp>u" | 
| 62 | shows "t[x::=s][y::=u] = t[y::=u][x::=s[y::=u]]" | |
| 63 | using a by (nominal_induct t avoiding: x y s u rule: lam.induct) | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 64 | (auto simp add: fresh_fact forget) | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 65 | |
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22821diff
changeset | 66 | lemma subst_rename: | 
| 23159 | 67 | assumes a: "y\<sharp>t" | 
| 68 | shows "t[x::=s] = ([(y,x)]\<bullet>t)[y::=s]" | |
| 69 | using a by (nominal_induct t avoiding: x y s rule: lam.induct) | |
| 70 | (auto simp add: calc_atm fresh_atm abs_fresh) | |
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22821diff
changeset | 71 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 72 | section {* Beta-Reduction *}
 | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 73 | |
| 23159 | 74 | inductive2 | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 75 |   "Beta" :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>\<beta> _" [80,80] 80)
 | 
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 76 | where | 
| 23159 | 77 | b1[intro]: "t1 \<longrightarrow>\<^isub>\<beta> t2 \<Longrightarrow> App t1 s \<longrightarrow>\<^isub>\<beta> App t2 s" | 
| 78 | | b2[intro]: "s1 \<longrightarrow>\<^isub>\<beta> s2 \<Longrightarrow> App t s1 \<longrightarrow>\<^isub>\<beta> App t s2" | |
| 79 | | b3[intro]: "t1 \<longrightarrow>\<^isub>\<beta> t2 \<Longrightarrow> Lam [x].t1 \<longrightarrow>\<^isub>\<beta> Lam [x].t2" | |
| 80 | | b4[intro]: "App (Lam [x].t) s \<longrightarrow>\<^isub>\<beta> t[x::=s]" | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 81 | |
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22821diff
changeset | 82 | section {* Transitive Closure of Beta *}
 | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22821diff
changeset | 83 | |
| 23159 | 84 | inductive2 | 
| 85 |   "Beta_star" :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>\<beta>\<^sup>* _" [80,80] 80)
 | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 86 | where | 
| 23159 | 87 | bs1[intro]: "t \<longrightarrow>\<^isub>\<beta>\<^sup>* t" | 
| 88 | | bs2[intro]: "t \<longrightarrow>\<^isub>\<beta> s \<Longrightarrow> t \<longrightarrow>\<^isub>\<beta>\<^sup>* s" | |
| 89 | | bs3[intro,trans]: "\<lbrakk>t1\<longrightarrow>\<^isub>\<beta>\<^sup>* t2; t2 \<longrightarrow>\<^isub>\<beta>\<^sup>* t3\<rbrakk> \<Longrightarrow> t1 \<longrightarrow>\<^isub>\<beta>\<^sup>* t3" | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 90 | |
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 91 | section {* One-Reduction *}
 | 
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 92 | |
| 23159 | 93 | inductive2 | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 94 |   One :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>1 _" [80,80] 80)
 | 
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 95 | where | 
| 22855 | 96 | o1[intro]: "Var x\<longrightarrow>\<^isub>1 Var x" | 
| 23159 | 97 | | o2[intro]: "\<lbrakk>t1\<longrightarrow>\<^isub>1t2; s1\<longrightarrow>\<^isub>1s2\<rbrakk> \<Longrightarrow> App t1 s1 \<longrightarrow>\<^isub>1 App t2 s2" | 
| 98 | | o3[intro]: "t1\<longrightarrow>\<^isub>1t2 \<Longrightarrow> Lam [x].t1 \<longrightarrow>\<^isub>1 Lam [x].t2" | |
| 99 | | o4[intro]: "\<lbrakk>x\<sharp>(s1,s2); t1\<longrightarrow>\<^isub>1t2; s1\<longrightarrow>\<^isub>1s2\<rbrakk> \<Longrightarrow> App (Lam [x].t1) s1 \<longrightarrow>\<^isub>1 t2[x::=s2]" | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 100 | |
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 101 | equivariance One | 
| 23159 | 102 | nominal_inductive One | 
| 103 | by (simp_all add: abs_fresh fresh_fact') | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 104 | |
| 22855 | 105 | lemma One_refl: | 
| 23159 | 106 | shows "t \<longrightarrow>\<^isub>1 t" | 
| 107 | by (nominal_induct t rule: lam.induct) (auto) | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 108 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 109 | lemma One_subst: | 
| 23159 | 110 | assumes a: "t1 \<longrightarrow>\<^isub>1 t2" "s1 \<longrightarrow>\<^isub>1 s2" | 
| 111 | shows "t1[x::=s1] \<longrightarrow>\<^isub>1 t2[x::=s2]" | |
| 112 | using a by (nominal_induct t1 t2 avoiding: s1 s2 x rule: One.strong_induct) | |
| 22855 | 113 | (auto simp add: substitution_lemma fresh_atm fresh_fact) | 
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 114 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 115 | lemma better_o4_intro: | 
| 23159 | 116 | assumes a: "t1 \<longrightarrow>\<^isub>1 t2" "s1 \<longrightarrow>\<^isub>1 s2" | 
| 117 | shows "App (Lam [x].t1) s1 \<longrightarrow>\<^isub>1 t2[x::=s2]" | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 118 | proof - | 
| 23159 | 119 | obtain y::"name" where fs: "y\<sharp>(x,t1,s1,t2,s2)" by (rule exists_fresh, rule fin_supp, blast) | 
| 120 | have "App (Lam [x].t1) s1 = App (Lam [y].([(y,x)]\<bullet>t1)) s1" using fs | |
| 121 | by (auto simp add: lam.inject alpha' fresh_prod fresh_atm) | |
| 122 | also have "\<dots> \<longrightarrow>\<^isub>1 ([(y,x)]\<bullet>t2)[y::=s2]" using fs a by (auto simp add: One.eqvt) | |
| 123 | also have "\<dots> = t2[x::=s2]" using fs by (simp add: subst_rename[symmetric]) | |
| 124 | finally show "App (Lam [x].t1) s1 \<longrightarrow>\<^isub>1 t2[x::=s2]" by simp | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 125 | qed | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 126 | |
| 23159 | 127 | lemma One_preserves_fresh: | 
| 128 | fixes x :: "name" | |
| 129 | assumes a: "t \<longrightarrow>\<^isub>1 s" | |
| 130 | shows "x\<sharp>t \<Longrightarrow> x\<sharp>s" | |
| 131 | using a by (nominal_induct t s avoiding: x rule: One.strong_induct) | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 132 | (auto simp add: abs_fresh fresh_atm fresh_fact) | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 133 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 134 | lemma One_Var: | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 135 | assumes a: "Var x \<longrightarrow>\<^isub>1 M" | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 136 | shows "M = Var x" | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 137 | using a by (erule_tac One.cases) (simp_all) | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 138 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 139 | lemma One_Lam: | 
| 23159 | 140 | assumes a: "Lam [x].t \<longrightarrow>\<^isub>1 s" | 
| 141 | shows "\<exists>t'. s = Lam [x].t' \<and> t \<longrightarrow>\<^isub>1 t'" | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 142 | using a | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 143 | apply(erule_tac One.cases) | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 144 | apply(auto simp add: lam.inject alpha) | 
| 23159 | 145 | apply(rule_tac x="[(x,xa)]\<bullet>t2" in exI) | 
| 146 | apply(perm_simp add: fresh_left calc_atm One.eqvt One_preserves_fresh) | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 147 | done | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 148 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 149 | lemma One_App: | 
| 23159 | 150 | assumes a: "App t s \<longrightarrow>\<^isub>1 r" | 
| 151 | shows "(\<exists>t' s'. r = App t' s' \<and> t \<longrightarrow>\<^isub>1 t' \<and> s \<longrightarrow>\<^isub>1 s') \<or> | |
| 152 | (\<exists>x p p' s'. r = p'[x::=s'] \<and> t = Lam [x].p \<and> p \<longrightarrow>\<^isub>1 p' \<and> s \<longrightarrow>\<^isub>1 s' \<and> x\<sharp>(s,s'))" | |
| 153 | using a by (erule_tac One.cases) | |
| 154 | (auto simp add: lam.inject) | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 155 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 156 | lemma One_Redex: | 
| 23159 | 157 | assumes a: "App (Lam [x].t) s \<longrightarrow>\<^isub>1 r" | 
| 158 | shows "(\<exists>t' s'. r = App (Lam [x].t') s' \<and> t \<longrightarrow>\<^isub>1 t' \<and> s \<longrightarrow>\<^isub>1 s') \<or> | |
| 159 | (\<exists>t' s'. r = t'[x::=s'] \<and> t \<longrightarrow>\<^isub>1 t' \<and> s \<longrightarrow>\<^isub>1 s')" | |
| 160 | using a | |
| 161 | apply(erule_tac One.cases, simp_all) | |
| 162 | apply(auto dest: One_Lam simp add: lam.inject)[1] | |
| 163 | apply(rule disjI2) | |
| 164 | apply(auto simp add: lam.inject alpha) | |
| 165 | apply(rule_tac x="[(x,xa)]\<bullet>t2" in exI) | |
| 166 | apply(rule_tac x="s2" in exI) | |
| 167 | apply(simp add: subst_rename One_preserves_fresh One.eqvt) | |
| 168 | done | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 169 | |
| 22829 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22821diff
changeset | 170 | section {* Transitive Closure of One *}
 | 
| 
f1db55c7534d
tuned some proofs and changed variable names in some definitions of Nominal.thy
 urbanc parents: 
22821diff
changeset | 171 | |
| 23159 | 172 | inductive2 | 
| 173 |   "One_star" :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>1\<^sup>* _" [80,80] 80)
 | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 174 | where | 
| 23159 | 175 | os1[intro]: "t \<longrightarrow>\<^isub>1\<^sup>* t" | 
| 176 | | os2[intro]: "t \<longrightarrow>\<^isub>1 s \<Longrightarrow> t \<longrightarrow>\<^isub>1\<^sup>* s" | |
| 177 | | os3[intro]: "\<lbrakk>t1\<longrightarrow>\<^isub>1\<^sup>* t2; t2 \<longrightarrow>\<^isub>1\<^sup>* t3\<rbrakk> \<Longrightarrow> t1 \<longrightarrow>\<^isub>1\<^sup>* t3" | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 178 | |
| 23159 | 179 | section {* Complete Development Reduction *}
 | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 180 | |
| 23159 | 181 | inductive2 | 
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 182 |   Dev :: "lam \<Rightarrow> lam \<Rightarrow> bool" (" _ \<longrightarrow>\<^isub>d _" [80,80]80)
 | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 183 | where | 
| 23159 | 184 | d1[intro]: "Var x \<longrightarrow>\<^isub>d Var x" | 
| 185 | | d2[intro]: "t \<longrightarrow>\<^isub>d s \<Longrightarrow> Lam [x].t \<longrightarrow>\<^isub>d Lam[x].s" | |
| 186 | | d3[intro]: "\<lbrakk>\<not>(\<exists>y t'. t1 = Lam [y].t'); t1 \<longrightarrow>\<^isub>d t2; s1 \<longrightarrow>\<^isub>d s2\<rbrakk> \<Longrightarrow> App t1 s1 \<longrightarrow>\<^isub>d App t2 s2" | |
| 187 | | d4[intro]: "\<lbrakk>x\<sharp>(s1,s2); t1 \<longrightarrow>\<^isub>d t2; s1 \<longrightarrow>\<^isub>d s2\<rbrakk> \<Longrightarrow> App (Lam [x].t1) s1 \<longrightarrow>\<^isub>d t2[x::=s2]" | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 188 | |
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 189 | (* FIXME: needs to be in nominal_inductive *) | 
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 190 | declare perm_pi_simp[eqvt_force] | 
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 191 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 192 | equivariance Dev | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 193 | nominal_inductive Dev by (simp_all add: abs_fresh fresh_fact') | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 194 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 195 | lemma better_d4_intro: | 
| 23159 | 196 | assumes a: "t1 \<longrightarrow>\<^isub>d t2" "s1 \<longrightarrow>\<^isub>d s2" | 
| 197 | shows "App (Lam [x].t1) s1 \<longrightarrow>\<^isub>d t2[x::=s2]" | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 198 | proof - | 
| 23159 | 199 | obtain y::"name" where fs: "y\<sharp>(x,t1,s1,t2,s2)" by (rule exists_fresh, rule fin_supp,blast) | 
| 200 | have "App (Lam [x].t1) s1 = App (Lam [y].([(y,x)]\<bullet>t1)) s1" using fs | |
| 201 | by (auto simp add: lam.inject alpha' fresh_prod fresh_atm) | |
| 202 | also have "\<dots> \<longrightarrow>\<^isub>d ([(y,x)]\<bullet>t2)[y::=s2]" using fs a by (auto simp add: Dev.eqvt) | |
| 203 | also have "\<dots> = t2[x::=s2]" using fs by (simp add: subst_rename[symmetric]) | |
| 204 | finally show "App (Lam [x].t1) s1 \<longrightarrow>\<^isub>d t2[x::=s2]" by simp | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 205 | qed | 
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 206 | |
| 23159 | 207 | lemma Dev_preserves_fresh: | 
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 208 | fixes x::"name" | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 209 | assumes a: "M\<longrightarrow>\<^isub>d N" | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 210 | shows "x\<sharp>M \<Longrightarrow> x\<sharp>N" | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 211 | using a by (induct) (auto simp add: abs_fresh fresh_fact fresh_fact') | 
| 23159 | 212 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 213 | lemma Dev_Lam: | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 214 | assumes a: "Lam [x].M \<longrightarrow>\<^isub>d N" | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 215 | shows "\<exists>N'. N = Lam [x].N' \<and> M \<longrightarrow>\<^isub>d N'" | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 216 | using a | 
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 217 | apply(erule_tac Dev.cases) | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 218 | apply(auto simp add: lam.inject alpha) | 
| 23159 | 219 | apply(rule_tac x="[(x,xa)]\<bullet>s" in exI) | 
| 220 | apply(perm_simp add: fresh_left Dev.eqvt Dev_preserves_fresh) | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 221 | done | 
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 222 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 223 | lemma Development_existence: | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 224 | shows "\<exists>M'. M \<longrightarrow>\<^isub>d M'" | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 225 | by (nominal_induct M rule: lam.induct) | 
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 226 | (auto dest!: Dev_Lam intro: better_d4_intro) | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 227 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 228 | lemma Triangle: | 
| 23159 | 229 | assumes a: "t \<longrightarrow>\<^isub>d t1" "t \<longrightarrow>\<^isub>1 t2" | 
| 230 | shows "t2 \<longrightarrow>\<^isub>1 t1" | |
| 231 | using a by (nominal_induct avoiding: t2 rule: Dev.strong_induct) | |
| 232 | (auto dest!: One_Var One_App One_Redex One_Lam intro: One_subst) | |
| 233 | (* Remark: we could here get away with a normal induction and appealing to One_preserves_fresh *) | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 234 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 235 | lemma Diamond_for_One: | 
| 23159 | 236 | assumes a: "t \<longrightarrow>\<^isub>1 t1" "t \<longrightarrow>\<^isub>1 t2" | 
| 237 | shows "\<exists>t3. t2 \<longrightarrow>\<^isub>1 t3 \<and> t1 \<longrightarrow>\<^isub>1 t3" | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 238 | proof - | 
| 23159 | 239 | obtain tc where "t \<longrightarrow>\<^isub>d tc" using Development_existence by blast | 
| 240 | with a have "t2 \<longrightarrow>\<^isub>1 tc" and "t1 \<longrightarrow>\<^isub>1 tc" by (simp_all add: Triangle) | |
| 241 | then show "\<exists>t3. t2 \<longrightarrow>\<^isub>1 t3 \<and> t1 \<longrightarrow>\<^isub>1 t3" by blast | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 242 | qed | 
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 243 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 244 | lemma Rectangle_for_One: | 
| 23159 | 245 | assumes a: "t \<longrightarrow>\<^isub>1\<^sup>* t1" "t \<longrightarrow>\<^isub>1 t2" | 
| 246 | shows "\<exists>t3. t1 \<longrightarrow>\<^isub>1 t3 \<and> t2 \<longrightarrow>\<^isub>1\<^sup>* t3" | |
| 247 | using a Diamond_for_One by (induct arbitrary: t2) (blast)+ | |
| 248 | ||
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 249 | lemma CR_for_One_star: | 
| 23159 | 250 | assumes a: "t \<longrightarrow>\<^isub>1\<^sup>* t1" "t \<longrightarrow>\<^isub>1\<^sup>* t2" | 
| 251 | shows "\<exists>t3. t2 \<longrightarrow>\<^isub>1\<^sup>* t3 \<and> t1 \<longrightarrow>\<^isub>1\<^sup>* t3" | |
| 252 | using a Rectangle_for_One by (induct arbitrary: t2) (blast)+ | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 253 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 254 | section {* Establishing the Equivalence of Beta-star and One-star *}
 | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 255 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 256 | lemma Beta_Lam_cong: | 
| 23159 | 257 | assumes a: "t1 \<longrightarrow>\<^isub>\<beta>\<^sup>* t2" | 
| 258 | shows "Lam [x].t1 \<longrightarrow>\<^isub>\<beta>\<^sup>* Lam [x].t2" | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 259 | using a by (induct) (blast)+ | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 260 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 261 | lemma Beta_App_congL: | 
| 23159 | 262 | assumes a: "t1 \<longrightarrow>\<^isub>\<beta>\<^sup>* t2" | 
| 263 | shows "App t1 s\<longrightarrow>\<^isub>\<beta>\<^sup>* App t2 s" | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 264 | using a by (induct) (blast)+ | 
| 23159 | 265 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 266 | lemma Beta_App_congR: | 
| 23159 | 267 | assumes a: "s1 \<longrightarrow>\<^isub>\<beta>\<^sup>* s2" | 
| 268 | shows "App t s1 \<longrightarrow>\<^isub>\<beta>\<^sup>* App t s2" | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 269 | using a by (induct) (blast)+ | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 270 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 271 | lemma Beta_App_cong: | 
| 23159 | 272 | assumes a: "t1 \<longrightarrow>\<^isub>\<beta>\<^sup>* t2" "s1 \<longrightarrow>\<^isub>\<beta>\<^sup>* s2" | 
| 273 | shows "App t1 s1 \<longrightarrow>\<^isub>\<beta>\<^sup>* App t2 s2" | |
| 274 | using a by (blast intro: Beta_App_congL Beta_App_congR) | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 275 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 276 | lemmas Beta_congs = Beta_Lam_cong Beta_App_cong | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 277 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 278 | lemma One_implies_Beta_star: | 
| 23159 | 279 | assumes a: "t \<longrightarrow>\<^isub>1 s" | 
| 280 | shows "t \<longrightarrow>\<^isub>\<beta>\<^sup>* s" | |
| 281 | using a by (induct) (auto intro!: Beta_congs) | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 282 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 283 | lemma One_star_Lam_cong: | 
| 23159 | 284 | assumes a: "t1 \<longrightarrow>\<^isub>1\<^sup>* t2" | 
| 285 | shows "Lam [x].t1 \<longrightarrow>\<^isub>1\<^sup>* Lam [x].t2" | |
| 286 | using a by (induct) (auto) | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 287 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 288 | lemma One_star_App_congL: | 
| 23159 | 289 | assumes a: "t1 \<longrightarrow>\<^isub>1\<^sup>* t2" | 
| 290 | shows "App t1 s\<longrightarrow>\<^isub>1\<^sup>* App t2 s" | |
| 291 | using a by (induct) (auto intro: One_refl) | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 292 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 293 | lemma One_star_App_congR: | 
| 23159 | 294 | assumes a: "s1 \<longrightarrow>\<^isub>1\<^sup>* s2" | 
| 295 | shows "App t s1 \<longrightarrow>\<^isub>1\<^sup>* App t s2" | |
| 296 | using a by (induct) (auto intro: One_refl) | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 297 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 298 | lemmas One_congs = One_star_App_congL One_star_App_congR One_star_Lam_cong | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 299 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 300 | lemma Beta_implies_One_star: | 
| 23159 | 301 | assumes a: "t1 \<longrightarrow>\<^isub>\<beta> t2" | 
| 302 | shows "t1 \<longrightarrow>\<^isub>1\<^sup>* t2" | |
| 22855 | 303 | using a by (induct) (auto intro: One_refl One_congs better_o4_intro) | 
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 304 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 305 | lemma Beta_star_equals_One_star: | 
| 23159 | 306 | shows "t1 \<longrightarrow>\<^isub>1\<^sup>* t2 = t1 \<longrightarrow>\<^isub>\<beta>\<^sup>* t2" | 
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 307 | proof | 
| 23159 | 308 | assume "t1 \<longrightarrow>\<^isub>1\<^sup>* t2" | 
| 309 | then show "t1 \<longrightarrow>\<^isub>\<beta>\<^sup>* t2" by (induct) (auto intro: One_implies_Beta_star) | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 310 | next | 
| 23159 | 311 | assume "t1 \<longrightarrow>\<^isub>\<beta>\<^sup>* t2" | 
| 312 | then show "t1 \<longrightarrow>\<^isub>1\<^sup>* t2" by (induct) (auto intro: Beta_implies_One_star) | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 313 | qed | 
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 314 | |
| 22833 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 315 | section {* The Church-Rosser Theorem *}
 | 
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 316 | |
| 
51a16a718820
polished all proofs and made the theory "self-contained"
 urbanc parents: 
22829diff
changeset | 317 | theorem CR_for_Beta_star: | 
| 23159 | 318 | assumes a: "t \<longrightarrow>\<^isub>\<beta>\<^sup>* t1" "t\<longrightarrow>\<^isub>\<beta>\<^sup>* t2" | 
| 319 | shows "\<exists>t3. t1 \<longrightarrow>\<^isub>\<beta>\<^sup>* t3 \<and> t2 \<longrightarrow>\<^isub>\<beta>\<^sup>* t3" | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 320 | proof - | 
| 23159 | 321 | from a have "t \<longrightarrow>\<^isub>1\<^sup>* t1" and "t\<longrightarrow>\<^isub>1\<^sup>* t2" by (simp_all only: Beta_star_equals_One_star) | 
| 322 | then have "\<exists>t3. t1 \<longrightarrow>\<^isub>1\<^sup>* t3 \<and> t2 \<longrightarrow>\<^isub>1\<^sup>* t3" by (rule_tac CR_for_One_star) | |
| 323 | then show "\<exists>t3. t1 \<longrightarrow>\<^isub>\<beta>\<^sup>* t3 \<and> t2 \<longrightarrow>\<^isub>\<beta>\<^sup>* t3" by (simp only: Beta_star_equals_One_star) | |
| 22821 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 324 | qed | 
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 325 | |
| 
15b2e7ec1f3b
alternative and much simpler proof for Church-Rosser of Beta-Reduction
 urbanc parents: diff
changeset | 326 | end |