111 apply blast |
111 apply blast |
112 apply blast |
112 apply blast |
113 done |
113 done |
114 |
114 |
115 lemma types_snoc: "e \<tturnstile> ts : Ts \<Longrightarrow> e \<turnstile> t : T \<Longrightarrow> e \<tturnstile> ts @ [t] : Ts @ [T]" |
115 lemma types_snoc: "e \<tturnstile> ts : Ts \<Longrightarrow> e \<turnstile> t : T \<Longrightarrow> e \<tturnstile> ts @ [t] : Ts @ [T]" |
116 apply (induct ts fixing: Ts) |
116 apply (induct ts arbitrary: Ts) |
117 apply simp |
117 apply simp |
118 apply (case_tac Ts) |
118 apply (case_tac Ts) |
119 apply simp+ |
119 apply simp+ |
120 done |
120 done |
121 |
121 |
122 lemma types_snoc_eq: "e \<tturnstile> ts @ [t] : Ts @ [T] = |
122 lemma types_snoc_eq: "e \<tturnstile> ts @ [t] : Ts @ [T] = |
123 (e \<tturnstile> ts : Ts \<and> e \<turnstile> t : T)" |
123 (e \<tturnstile> ts : Ts \<and> e \<turnstile> t : T)" |
124 apply (induct ts fixing: Ts) |
124 apply (induct ts arbitrary: Ts) |
125 apply (case_tac Ts) |
125 apply (case_tac Ts) |
126 apply simp+ |
126 apply simp+ |
127 apply (case_tac Ts) |
127 apply (case_tac Ts) |
128 apply (case_tac "ts @ [t]") |
128 apply (case_tac "ts @ [t]") |
129 apply simp+ |
129 apply simp+ |
159 |
159 |
160 subsection {* n-ary function types *} |
160 subsection {* n-ary function types *} |
161 |
161 |
162 lemma list_app_typeD: |
162 lemma list_app_typeD: |
163 "e \<turnstile> t \<degree>\<degree> ts : T \<Longrightarrow> \<exists>Ts. e \<turnstile> t : Ts \<Rrightarrow> T \<and> e \<tturnstile> ts : Ts" |
163 "e \<turnstile> t \<degree>\<degree> ts : T \<Longrightarrow> \<exists>Ts. e \<turnstile> t : Ts \<Rrightarrow> T \<and> e \<tturnstile> ts : Ts" |
164 apply (induct ts fixing: t T) |
164 apply (induct ts arbitrary: t T) |
165 apply simp |
165 apply simp |
166 apply atomize |
166 apply atomize |
167 apply simp |
167 apply simp |
168 apply (erule_tac x = "t \<degree> a" in allE) |
168 apply (erule_tac x = "t \<degree> a" in allE) |
169 apply (erule_tac x = T in allE) |
169 apply (erule_tac x = T in allE) |
179 "e \<turnstile> t \<degree>\<degree> ts : T \<Longrightarrow> (\<And>Ts. e \<turnstile> t : Ts \<Rrightarrow> T \<Longrightarrow> e \<tturnstile> ts : Ts \<Longrightarrow> C) \<Longrightarrow> C" |
179 "e \<turnstile> t \<degree>\<degree> ts : T \<Longrightarrow> (\<And>Ts. e \<turnstile> t : Ts \<Rrightarrow> T \<Longrightarrow> e \<tturnstile> ts : Ts \<Longrightarrow> C) \<Longrightarrow> C" |
180 by (insert list_app_typeD) fast |
180 by (insert list_app_typeD) fast |
181 |
181 |
182 lemma list_app_typeI: |
182 lemma list_app_typeI: |
183 "e \<turnstile> t : Ts \<Rrightarrow> T \<Longrightarrow> e \<tturnstile> ts : Ts \<Longrightarrow> e \<turnstile> t \<degree>\<degree> ts : T" |
183 "e \<turnstile> t : Ts \<Rrightarrow> T \<Longrightarrow> e \<tturnstile> ts : Ts \<Longrightarrow> e \<turnstile> t \<degree>\<degree> ts : T" |
184 apply (induct ts fixing: t T Ts) |
184 apply (induct ts arbitrary: t T Ts) |
185 apply simp |
185 apply simp |
186 apply atomize |
186 apply atomize |
187 apply (case_tac Ts) |
187 apply (case_tac Ts) |
188 apply simp |
188 apply simp |
189 apply simp |
189 apply simp |
204 for program extraction. |
204 for program extraction. |
205 *} |
205 *} |
206 |
206 |
207 theorem var_app_type_eq: |
207 theorem var_app_type_eq: |
208 "e \<turnstile> Var i \<degree>\<degree> ts : T \<Longrightarrow> e \<turnstile> Var i \<degree>\<degree> ts : U \<Longrightarrow> T = U" |
208 "e \<turnstile> Var i \<degree>\<degree> ts : T \<Longrightarrow> e \<turnstile> Var i \<degree>\<degree> ts : U \<Longrightarrow> T = U" |
209 apply (induct ts fixing: T U rule: rev_induct) |
209 apply (induct ts arbitrary: T U rule: rev_induct) |
210 apply simp |
210 apply simp |
211 apply (ind_cases "e \<turnstile> Var i : T") |
211 apply (ind_cases "e \<turnstile> Var i : T") |
212 apply (ind_cases "e \<turnstile> Var i : T") |
212 apply (ind_cases "e \<turnstile> Var i : T") |
213 apply simp |
213 apply simp |
214 apply simp |
214 apply simp |
224 apply simp |
224 apply simp |
225 done |
225 done |
226 |
226 |
227 lemma var_app_types: "e \<turnstile> Var i \<degree>\<degree> ts \<degree>\<degree> us : T \<Longrightarrow> e \<tturnstile> ts : Ts \<Longrightarrow> |
227 lemma var_app_types: "e \<turnstile> Var i \<degree>\<degree> ts \<degree>\<degree> us : T \<Longrightarrow> e \<tturnstile> ts : Ts \<Longrightarrow> |
228 e \<turnstile> Var i \<degree>\<degree> ts : U \<Longrightarrow> \<exists>Us. U = Us \<Rrightarrow> T \<and> e \<tturnstile> us : Us" |
228 e \<turnstile> Var i \<degree>\<degree> ts : U \<Longrightarrow> \<exists>Us. U = Us \<Rrightarrow> T \<and> e \<tturnstile> us : Us" |
229 apply (induct us fixing: ts Ts U) |
229 apply (induct us arbitrary: ts Ts U) |
230 apply simp |
230 apply simp |
231 apply (erule var_app_type_eq) |
231 apply (erule var_app_type_eq) |
232 apply assumption |
232 apply assumption |
233 apply simp |
233 apply simp |
234 apply atomize |
234 apply atomize |
291 |
291 |
292 |
292 |
293 subsection {* Lifting preserves well-typedness *} |
293 subsection {* Lifting preserves well-typedness *} |
294 |
294 |
295 lemma lift_type [intro!]: "e \<turnstile> t : T \<Longrightarrow> e\<langle>i:U\<rangle> \<turnstile> lift t i : T" |
295 lemma lift_type [intro!]: "e \<turnstile> t : T \<Longrightarrow> e\<langle>i:U\<rangle> \<turnstile> lift t i : T" |
296 by (induct fixing: i U set: typing) auto |
296 by (induct arbitrary: i U set: typing) auto |
297 |
297 |
298 lemma lift_types: |
298 lemma lift_types: |
299 "e \<tturnstile> ts : Ts \<Longrightarrow> e\<langle>i:U\<rangle> \<tturnstile> (map (\<lambda>t. lift t i) ts) : Ts" |
299 "e \<tturnstile> ts : Ts \<Longrightarrow> e\<langle>i:U\<rangle> \<tturnstile> (map (\<lambda>t. lift t i) ts) : Ts" |
300 apply (induct ts fixing: Ts) |
300 apply (induct ts arbitrary: Ts) |
301 apply simp |
301 apply simp |
302 apply (case_tac Ts) |
302 apply (case_tac Ts) |
303 apply auto |
303 apply auto |
304 done |
304 done |
305 |
305 |
306 |
306 |
307 subsection {* Substitution lemmas *} |
307 subsection {* Substitution lemmas *} |
308 |
308 |
309 lemma subst_lemma: |
309 lemma subst_lemma: |
310 "e \<turnstile> t : T \<Longrightarrow> e' \<turnstile> u : U \<Longrightarrow> e = e'\<langle>i:U\<rangle> \<Longrightarrow> e' \<turnstile> t[u/i] : T" |
310 "e \<turnstile> t : T \<Longrightarrow> e' \<turnstile> u : U \<Longrightarrow> e = e'\<langle>i:U\<rangle> \<Longrightarrow> e' \<turnstile> t[u/i] : T" |
311 apply (induct fixing: e' i U u set: typing) |
311 apply (induct arbitrary: e' i U u set: typing) |
312 apply (rule_tac x = x and y = i in linorder_cases) |
312 apply (rule_tac x = x and y = i in linorder_cases) |
313 apply auto |
313 apply auto |
314 apply blast |
314 apply blast |
315 done |
315 done |
316 |
316 |
317 lemma substs_lemma: |
317 lemma substs_lemma: |
318 "e \<turnstile> u : T \<Longrightarrow> e\<langle>i:T\<rangle> \<tturnstile> ts : Ts \<Longrightarrow> |
318 "e \<turnstile> u : T \<Longrightarrow> e\<langle>i:T\<rangle> \<tturnstile> ts : Ts \<Longrightarrow> |
319 e \<tturnstile> (map (\<lambda>t. t[u/i]) ts) : Ts" |
319 e \<tturnstile> (map (\<lambda>t. t[u/i]) ts) : Ts" |
320 apply (induct ts fixing: Ts) |
320 apply (induct ts arbitrary: Ts) |
321 apply (case_tac Ts) |
321 apply (case_tac Ts) |
322 apply simp |
322 apply simp |
323 apply simp |
323 apply simp |
324 apply atomize |
324 apply atomize |
325 apply (case_tac Ts) |
325 apply (case_tac Ts) |