| author | nipkow | 
| Mon, 29 Nov 2004 11:23:48 +0100 | |
| changeset 15339 | a7b603bbc1e6 | 
| parent 14065 | 8abaf978c9c2 | 
| child 16417 | 9bc16273c2d4 | 
| permissions | -rw-r--r-- | 
| 1269 | 1 | (* Title: HOL/Lambda/Lambda.thy | 
| 1120 | 2 | ID: $Id$ | 
| 3 | Author: Tobias Nipkow | |
| 4 | Copyright 1995 TU Muenchen | |
| 5 | *) | |
| 6 | ||
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 7 | header {* Basic definitions of Lambda-calculus *}
 | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 8 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 9 | theory Lambda = Main: | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 10 | |
| 1120 | 11 | |
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 12 | subsection {* Lambda-terms in de Bruijn notation and substitution *}
 | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 13 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 14 | datatype dB = | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 15 | Var nat | 
| 12011 | 16 | | App dB dB (infixl "\<degree>" 200) | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 17 | | Abs dB | 
| 1120 | 18 | |
| 19 | consts | |
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 20 |   subst :: "[dB, dB, nat] => dB"  ("_[_'/_]" [300, 0, 0] 300)
 | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 21 | lift :: "[dB, nat] => dB" | 
| 1153 | 22 | |
| 5184 | 23 | primrec | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 24 | "lift (Var i) k = (if i < k then Var i else Var (i + 1))" | 
| 12011 | 25 | "lift (s \<degree> t) k = lift s k \<degree> lift t k" | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 26 | "lift (Abs s) k = Abs (lift s (k + 1))" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 27 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 28 | primrec (* FIXME base names *) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 29 | subst_Var: "(Var i)[s/k] = | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 30 | (if k < i then Var (i - 1) else if i = k then s else Var i)" | 
| 12011 | 31 | subst_App: "(t \<degree> u)[s/k] = t[s/k] \<degree> u[s/k]" | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 32 | subst_Abs: "(Abs t)[s/k] = Abs (t[lift s 0 / k+1])" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 33 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 34 | declare subst_Var [simp del] | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 35 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 36 | text {* Optimized versions of @{term subst} and @{term lift}. *}
 | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 37 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 38 | consts | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 39 | substn :: "[dB, dB, nat] => dB" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 40 | liftn :: "[nat, dB, nat] => dB" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 41 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 42 | primrec | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 43 | "liftn n (Var i) k = (if i < k then Var i else Var (i + n))" | 
| 12011 | 44 | "liftn n (s \<degree> t) k = liftn n s k \<degree> liftn n t k" | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 45 | "liftn n (Abs s) k = Abs (liftn n s (k + 1))" | 
| 1120 | 46 | |
| 5184 | 47 | primrec | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 48 | "substn (Var i) s k = | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 49 | (if k < i then Var (i - 1) else if i = k then liftn k s 0 else Var i)" | 
| 12011 | 50 | "substn (t \<degree> u) s k = substn t s k \<degree> substn u s k" | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 51 | "substn (Abs t) s k = Abs (substn t s (k + 1))" | 
| 1120 | 52 | |
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 53 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 54 | subsection {* Beta-reduction *}
 | 
| 1153 | 55 | |
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 56 | consts | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 57 | beta :: "(dB \<times> dB) set" | 
| 1120 | 58 | |
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 59 | syntax | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 60 | "_beta" :: "[dB, dB] => bool" (infixl "->" 50) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 61 | "_beta_rtrancl" :: "[dB, dB] => bool" (infixl "->>" 50) | 
| 14065 | 62 | syntax (latex) | 
| 63 | "_beta" :: "[dB, dB] => bool" (infixl "\<rightarrow>\<^sub>\<beta>" 50) | |
| 64 | "_beta_rtrancl" :: "[dB, dB] => bool" (infixl "\<rightarrow>\<^sub>\<beta>\<^sup>*" 50) | |
| 1120 | 65 | translations | 
| 14065 | 66 | "s \<rightarrow>\<^sub>\<beta> t" == "(s, t) \<in> beta" | 
| 67 | "s \<rightarrow>\<^sub>\<beta>\<^sup>* t" == "(s, t) \<in> beta^*" | |
| 1120 | 68 | |
| 1789 | 69 | inductive beta | 
| 11638 | 70 | intros | 
| 14065 | 71 | beta [simp, intro!]: "Abs s \<degree> t \<rightarrow>\<^sub>\<beta> s[t/0]" | 
| 72 | appL [simp, intro!]: "s \<rightarrow>\<^sub>\<beta> t ==> s \<degree> u \<rightarrow>\<^sub>\<beta> t \<degree> u" | |
| 73 | appR [simp, intro!]: "s \<rightarrow>\<^sub>\<beta> t ==> u \<degree> s \<rightarrow>\<^sub>\<beta> u \<degree> t" | |
| 74 | abs [simp, intro!]: "s \<rightarrow>\<^sub>\<beta> t ==> Abs s \<rightarrow>\<^sub>\<beta> Abs t" | |
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 75 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 76 | inductive_cases beta_cases [elim!]: | 
| 14065 | 77 | "Var i \<rightarrow>\<^sub>\<beta> t" | 
| 78 | "Abs r \<rightarrow>\<^sub>\<beta> s" | |
| 79 | "s \<degree> t \<rightarrow>\<^sub>\<beta> u" | |
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 80 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 81 | declare if_not_P [simp] not_less_eq [simp] | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 82 |   -- {* don't add @{text "r_into_rtrancl[intro!]"} *}
 | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 83 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 84 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 85 | subsection {* Congruence rules *}
 | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 86 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 87 | lemma rtrancl_beta_Abs [intro!]: | 
| 14065 | 88 | "s \<rightarrow>\<^sub>\<beta>\<^sup>* s' ==> Abs s \<rightarrow>\<^sub>\<beta>\<^sup>* Abs s'" | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 89 | apply (erule rtrancl_induct) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 90 | apply (blast intro: rtrancl_into_rtrancl)+ | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 91 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 92 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 93 | lemma rtrancl_beta_AppL: | 
| 14065 | 94 | "s \<rightarrow>\<^sub>\<beta>\<^sup>* s' ==> s \<degree> t \<rightarrow>\<^sub>\<beta>\<^sup>* s' \<degree> t" | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 95 | apply (erule rtrancl_induct) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 96 | apply (blast intro: rtrancl_into_rtrancl)+ | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 97 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 98 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 99 | lemma rtrancl_beta_AppR: | 
| 14065 | 100 | "t \<rightarrow>\<^sub>\<beta>\<^sup>* t' ==> s \<degree> t \<rightarrow>\<^sub>\<beta>\<^sup>* s \<degree> t'" | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 101 | apply (erule rtrancl_induct) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 102 | apply (blast intro: rtrancl_into_rtrancl)+ | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 103 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 104 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 105 | lemma rtrancl_beta_App [intro]: | 
| 14065 | 106 | "[| s \<rightarrow>\<^sub>\<beta>\<^sup>* s'; t \<rightarrow>\<^sub>\<beta>\<^sup>* t' |] ==> s \<degree> t \<rightarrow>\<^sub>\<beta>\<^sup>* s' \<degree> t'" | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 107 | apply (blast intro!: rtrancl_beta_AppL rtrancl_beta_AppR | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 108 | intro: rtrancl_trans) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 109 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 110 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 111 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 112 | subsection {* Substitution-lemmas *}
 | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 113 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 114 | lemma subst_eq [simp]: "(Var k)[u/k] = u" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 115 | apply (simp add: subst_Var) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 116 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 117 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 118 | lemma subst_gt [simp]: "i < j ==> (Var j)[u/i] = Var (j - 1)" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 119 | apply (simp add: subst_Var) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 120 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 121 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 122 | lemma subst_lt [simp]: "j < i ==> (Var j)[u/i] = Var j" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 123 | apply (simp add: subst_Var) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 124 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 125 | |
| 9941 
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
 wenzelm parents: 
9906diff
changeset | 126 | lemma lift_lift [rule_format]: | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 127 | "\<forall>i k. i < k + 1 --> lift (lift t i) (Suc k) = lift (lift t k) i" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 128 | apply (induct_tac t) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 129 | apply auto | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 130 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 131 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 132 | lemma lift_subst [simp]: | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 133 | "\<forall>i j s. j < i + 1 --> lift (t[s/j]) i = (lift t (i + 1)) [lift s i / j]" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 134 | apply (induct_tac t) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 135 | apply (simp_all add: diff_Suc subst_Var lift_lift split: nat.split) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 136 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 137 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 138 | lemma lift_subst_lt: | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 139 | "\<forall>i j s. i < j + 1 --> lift (t[s/j]) i = (lift t i) [lift s i / j + 1]" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 140 | apply (induct_tac t) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 141 | apply (simp_all add: subst_Var lift_lift) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 142 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 143 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 144 | lemma subst_lift [simp]: | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 145 | "\<forall>k s. (lift t k)[s/k] = t" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 146 | apply (induct_tac t) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 147 | apply simp_all | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 148 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 149 | |
| 9941 
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
 wenzelm parents: 
9906diff
changeset | 150 | lemma subst_subst [rule_format]: | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 151 | "\<forall>i j u v. i < j + 1 --> t[lift v i / Suc j][u[v/j]/i] = t[u/i][v/j]" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 152 | apply (induct_tac t) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 153 | apply (simp_all | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 154 | add: diff_Suc subst_Var lift_lift [symmetric] lift_subst_lt | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 155 | split: nat.split) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 156 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 157 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 158 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 159 | subsection {* Equivalence proof for optimized substitution *}
 | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 160 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 161 | lemma liftn_0 [simp]: "\<forall>k. liftn 0 t k = t" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 162 | apply (induct_tac t) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 163 | apply (simp_all add: subst_Var) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 164 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 165 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 166 | lemma liftn_lift [simp]: | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 167 | "\<forall>k. liftn (Suc n) t k = lift (liftn n t k) k" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 168 | apply (induct_tac t) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 169 | apply (simp_all add: subst_Var) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 170 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 171 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 172 | lemma substn_subst_n [simp]: | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 173 | "\<forall>n. substn t s n = t[liftn n s 0 / n]" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 174 | apply (induct_tac t) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 175 | apply (simp_all add: subst_Var) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 176 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 177 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 178 | theorem substn_subst_0: "substn t s 0 = t[s/0]" | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 179 | apply simp | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 180 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 181 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 182 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 183 | subsection {* Preservation theorems *}
 | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 184 | |
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 185 | text {* Not used in Church-Rosser proof, but in Strong
 | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 186 | Normalization. \medskip *} | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 187 | |
| 13915 
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
 berghofe parents: 
13187diff
changeset | 188 | theorem subst_preserves_beta [simp]: | 
| 14065 | 189 | "r \<rightarrow>\<^sub>\<beta> s ==> (\<And>t i. r[t/i] \<rightarrow>\<^sub>\<beta> s[t/i])" | 
| 13915 
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
 berghofe parents: 
13187diff
changeset | 190 | apply (induct set: beta) | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 191 | apply (simp_all add: subst_subst [symmetric]) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 192 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 193 | |
| 14065 | 194 | theorem subst_preserves_beta': "r \<rightarrow>\<^sub>\<beta>\<^sup>* s ==> r[t/i] \<rightarrow>\<^sub>\<beta>\<^sup>* s[t/i]" | 
| 195 | apply (erule rtrancl.induct) | |
| 196 | apply (rule rtrancl_refl) | |
| 197 | apply (erule rtrancl_into_rtrancl) | |
| 198 | apply (erule subst_preserves_beta) | |
| 199 | done | |
| 200 | ||
| 13915 
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
 berghofe parents: 
13187diff
changeset | 201 | theorem lift_preserves_beta [simp]: | 
| 14065 | 202 | "r \<rightarrow>\<^sub>\<beta> s ==> (\<And>i. lift r i \<rightarrow>\<^sub>\<beta> lift s i)" | 
| 13915 
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
 berghofe parents: 
13187diff
changeset | 203 | by (induct set: beta) auto | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 204 | |
| 14065 | 205 | theorem lift_preserves_beta': "r \<rightarrow>\<^sub>\<beta>\<^sup>* s ==> lift r i \<rightarrow>\<^sub>\<beta>\<^sup>* lift s i" | 
| 206 | apply (erule rtrancl.induct) | |
| 207 | apply (rule rtrancl_refl) | |
| 208 | apply (erule rtrancl_into_rtrancl) | |
| 209 | apply (erule lift_preserves_beta) | |
| 210 | done | |
| 211 | ||
| 13915 
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
 berghofe parents: 
13187diff
changeset | 212 | theorem subst_preserves_beta2 [simp]: | 
| 14065 | 213 | "\<And>r s i. r \<rightarrow>\<^sub>\<beta> s ==> t[r/i] \<rightarrow>\<^sub>\<beta>\<^sup>* t[s/i]" | 
| 13915 
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
 berghofe parents: 
13187diff
changeset | 214 | apply (induct t) | 
| 9811 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 215 | apply (simp add: subst_Var r_into_rtrancl) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 216 | apply (simp add: rtrancl_beta_App) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 217 | apply (simp add: rtrancl_beta_Abs) | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 218 | done | 
| 
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
 wenzelm parents: 
6453diff
changeset | 219 | |
| 14065 | 220 | theorem subst_preserves_beta2': "r \<rightarrow>\<^sub>\<beta>\<^sup>* s ==> t[r/i] \<rightarrow>\<^sub>\<beta>\<^sup>* t[s/i]" | 
| 221 | apply (erule rtrancl.induct) | |
| 222 | apply (rule rtrancl_refl) | |
| 223 | apply (erule rtrancl_trans) | |
| 224 | apply (erule subst_preserves_beta2) | |
| 225 | done | |
| 226 | ||
| 11638 | 227 | end |