src/HOL/Lambda/Type.thy
author nipkow
Mon, 30 Sep 2002 15:44:21 +0200
changeset 13596 ee5f79b210c1
parent 12171 dc87f33db447
child 14064 35d36f43ba06
permissions -rw-r--r--
modified induct method
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9114
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
     1
(*  Title:      HOL/Lambda/Type.thy
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
     2
    ID:         $Id$
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
     3
    Author:     Stefan Berghofer
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
     4
    Copyright   2000 TU Muenchen
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
     5
*)
9114
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
     6
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
     7
header {* Simply-typed lambda terms: subject reduction and strong
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
     8
  normalization *}
9114
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
     9
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
    10
theory Type = InductTermi:
9114
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    11
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
    12
text_raw {*
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
    13
  \footnote{Formalization by Stefan Berghofer.  Partly based on a
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
    14
  paper proof by Ralph Matthes.}
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
    15
*}
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
    16
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
    17
11946
wenzelm
parents: 11945
diff changeset
    18
subsection {* Environments *}
wenzelm
parents: 11945
diff changeset
    19
wenzelm
parents: 11945
diff changeset
    20
constdefs
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
    21
  shift :: "(nat \<Rightarrow> 'a) \<Rightarrow> nat \<Rightarrow> 'a \<Rightarrow> nat \<Rightarrow> 'a"    ("_<_:_>" [90, 0, 0] 91)
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
    22
  "e<i:a> \<equiv> \<lambda>j. if j < i then e j else if j = i then a else e (j - 1)"
12114
a8e860c86252 eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents: 12011
diff changeset
    23
syntax (xsymbols)
11946
wenzelm
parents: 11945
diff changeset
    24
  shift :: "(nat \<Rightarrow> 'a) \<Rightarrow> nat \<Rightarrow> 'a \<Rightarrow> nat \<Rightarrow> 'a"    ("_\<langle>_:_\<rangle>" [90, 0, 0] 91)
wenzelm
parents: 11945
diff changeset
    25
wenzelm
parents: 11945
diff changeset
    26
lemma shift_eq [simp]: "i = j \<Longrightarrow> (e\<langle>i:T\<rangle>) j = T"
wenzelm
parents: 11945
diff changeset
    27
  by (simp add: shift_def)
wenzelm
parents: 11945
diff changeset
    28
wenzelm
parents: 11945
diff changeset
    29
lemma shift_gt [simp]: "j < i \<Longrightarrow> (e\<langle>i:T\<rangle>) j = e j"
wenzelm
parents: 11945
diff changeset
    30
  by (simp add: shift_def)
wenzelm
parents: 11945
diff changeset
    31
wenzelm
parents: 11945
diff changeset
    32
lemma shift_lt [simp]: "i < j \<Longrightarrow> (e\<langle>i:T\<rangle>) j = e (j - 1)"
wenzelm
parents: 11945
diff changeset
    33
  by (simp add: shift_def)
wenzelm
parents: 11945
diff changeset
    34
wenzelm
parents: 11945
diff changeset
    35
lemma shift_commute [simp]: "e\<langle>i:U\<rangle>\<langle>0:T\<rangle> = e\<langle>0:T\<rangle>\<langle>Suc i:U\<rangle>"
wenzelm
parents: 11945
diff changeset
    36
  apply (rule ext)
wenzelm
parents: 11945
diff changeset
    37
  apply (case_tac x)
wenzelm
parents: 11945
diff changeset
    38
   apply simp
wenzelm
parents: 11945
diff changeset
    39
  apply (case_tac nat)
wenzelm
parents: 11945
diff changeset
    40
   apply (simp_all add: shift_def)
wenzelm
parents: 11945
diff changeset
    41
  done
wenzelm
parents: 11945
diff changeset
    42
wenzelm
parents: 11945
diff changeset
    43
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
    44
subsection {* Types and typing rules *}
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
    45
9641
wenzelm
parents: 9622
diff changeset
    46
datatype type =
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
    47
    Atom nat
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
    48
  | Fun type type    (infixr "\<Rightarrow>" 200)
9114
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    49
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    50
consts
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    51
  typing :: "((nat \<Rightarrow> type) \<times> dB \<times> type) set"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    52
  typings :: "(nat \<Rightarrow> type) \<Rightarrow> dB list \<Rightarrow> type list \<Rightarrow> bool"
9114
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    53
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    54
syntax
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
    55
  "_funs" :: "type list \<Rightarrow> type \<Rightarrow> type"    (infixr "=>>" 200)
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    56
  "_typing" :: "(nat \<Rightarrow> type) \<Rightarrow> dB \<Rightarrow> type \<Rightarrow> bool"    ("_ |- _ : _" [50, 50, 50] 50)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    57
  "_typings" :: "(nat \<Rightarrow> type) \<Rightarrow> dB list \<Rightarrow> type list \<Rightarrow> bool"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    58
    ("_ ||- _ : _" [50, 50, 50] 50)
12114
a8e860c86252 eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents: 12011
diff changeset
    59
syntax (xsymbols)
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    60
  "_typing" :: "(nat \<Rightarrow> type) \<Rightarrow> dB \<Rightarrow> type \<Rightarrow> bool"    ("_ \<turnstile> _ : _" [50, 50, 50] 50)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    61
syntax (latex)
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
    62
  "_funs" :: "type list \<Rightarrow> type \<Rightarrow> type"    (infixr "\<Rrightarrow>" 200)
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    63
  "_typings" :: "(nat \<Rightarrow> type) \<Rightarrow> dB list \<Rightarrow> type list \<Rightarrow> bool"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    64
    ("_ \<tturnstile> _ : _" [50, 50, 50] 50)
9114
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    65
translations
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
    66
  "Ts \<Rrightarrow> T" \<rightleftharpoons> "foldr Fun Ts T"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    67
  "env \<turnstile> t : T" \<rightleftharpoons> "(env, t, T) \<in> typing"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    68
  "env \<tturnstile> ts : Ts" \<rightleftharpoons> "typings env ts Ts"
9114
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    69
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    70
inductive typing
11638
2c3dee321b4b inductive: no collective atts;
wenzelm
parents: 10567
diff changeset
    71
  intros
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    72
    Var [intro!]: "env x = T \<Longrightarrow> env \<turnstile> Var x : T"
11946
wenzelm
parents: 11945
diff changeset
    73
    Abs [intro!]: "env\<langle>0:T\<rangle> \<turnstile> t : U \<Longrightarrow> env \<turnstile> Abs t : (T \<Rightarrow> U)"
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
    74
    App [intro!]: "env \<turnstile> s : T \<Rightarrow> U \<Longrightarrow> env \<turnstile> t : T \<Longrightarrow> env \<turnstile> (s \<degree> t) : U"
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
    75
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    76
inductive_cases typing_elims [elim!]:
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    77
  "e \<turnstile> Var i : T"
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
    78
  "e \<turnstile> t \<degree> u : T"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    79
  "e \<turnstile> Abs t : T"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
    80
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    81
primrec
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    82
  "(e \<tturnstile> [] : Ts) = (Ts = [])"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    83
  "(e \<tturnstile> (t # ts) : Ts) =
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    84
    (case Ts of
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    85
      [] \<Rightarrow> False
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    86
    | T # Ts \<Rightarrow> e \<turnstile> t : T \<and> e \<tturnstile> ts : Ts)"
9114
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    87
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
    88
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
    89
subsection {* Some examples *}
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
    90
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
    91
lemma "e \<turnstile> Abs (Abs (Abs (Var 1 \<degree> (Var 2 \<degree> Var 1 \<degree> Var 0)))) : ?T"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
    92
  by force
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
    93
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
    94
lemma "e \<turnstile> Abs (Abs (Abs (Var 2 \<degree> Var 0 \<degree> (Var 1 \<degree> Var 0)))) : ?T"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
    95
  by force
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
    96
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
    97
11950
9bd6e8e62a06 Eliminated occurrence of rule_format.
berghofe
parents: 11947
diff changeset
    98
subsection {* n-ary function types *}
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
    99
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   100
lemma list_app_typeD:
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   101
    "\<And>t T. e \<turnstile> t \<degree>\<degree> ts : T \<Longrightarrow> \<exists>Ts. e \<turnstile> t : Ts \<Rrightarrow> T \<and> e \<tturnstile> ts : Ts"
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   102
  apply (induct ts)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   103
   apply simp
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   104
  apply atomize
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   105
  apply simp
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   106
  apply (erule_tac x = "t \<degree> a" in allE)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   107
  apply (erule_tac x = T in allE)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   108
  apply (erule impE)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   109
   apply assumption
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   110
  apply (elim exE conjE)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   111
  apply (ind_cases "e \<turnstile> t \<degree> u : T")
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   112
  apply (rule_tac x = "Ta # Ts" in exI)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   113
  apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   114
  done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   115
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   116
lemma list_app_typeE:
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   117
  "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"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   118
  by (insert list_app_typeD) fast
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   119
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   120
lemma list_app_typeI:
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   121
    "\<And>t T Ts. e \<turnstile> t : Ts \<Rrightarrow> T \<Longrightarrow> e \<tturnstile> ts : Ts \<Longrightarrow> e \<turnstile> t \<degree>\<degree> ts : T"
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   122
  apply (induct ts)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   123
   apply simp
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   124
  apply atomize
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   125
  apply (case_tac Ts)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   126
   apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   127
  apply simp
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   128
  apply (erule_tac x = "t \<degree> a" in allE)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   129
  apply (erule_tac x = T in allE)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   130
  apply (erule_tac x = lista in allE)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   131
  apply (erule impE)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   132
   apply (erule conjE)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   133
   apply (erule typing.App)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   134
   apply assumption
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   135
  apply blast
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   136
  done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   137
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   138
lemma lists_typings:
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   139
    "\<And>Ts. e \<tturnstile> ts : Ts \<Longrightarrow> ts \<in> lists {t. \<exists>T. e \<turnstile> t : T}"
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   140
  apply (induct ts)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   141
   apply (case_tac Ts)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   142
     apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   143
     apply (rule lists.Nil)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   144
    apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   145
  apply (case_tac Ts)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   146
   apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   147
  apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   148
  apply (rule lists.Cons)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   149
   apply blast
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   150
  apply blast
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   151
  done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   152
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   153
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
   154
subsection {* Lifting preserves termination and well-typedness *}
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   155
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   156
lemma lift_map [simp]:
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   157
    "\<And>t. lift (t \<degree>\<degree> ts) i = lift t i \<degree>\<degree> map (\<lambda>t. lift t i) ts"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   158
  by (induct ts) simp_all
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   159
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   160
lemma subst_map [simp]:
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   161
    "\<And>t. subst (t \<degree>\<degree> ts) u i = subst t u i \<degree>\<degree> map (\<lambda>t. subst t u i) ts"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   162
  by (induct ts) simp_all
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   163
11994
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   164
lemma lift_IT [intro!]: "t \<in> IT \<Longrightarrow> (\<And>i. lift t i \<in> IT)"
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   165
  apply (induct set: IT)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   166
    apply (simp (no_asm))
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   167
    apply (rule conjI)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   168
     apply
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   169
      (rule impI,
9716
9be481b4bc85 Lambda/InductTermi made new-style theory;
wenzelm
parents: 9661
diff changeset
   170
       rule IT.Var,
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   171
       erule lists.induct,
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   172
       simp (no_asm),
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   173
       rule lists.Nil,
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   174
       simp (no_asm),
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   175
       erule IntE,
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   176
       rule lists.Cons,
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   177
       blast,
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   178
       assumption)+
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   179
     apply auto
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   180
   done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   181
11947
wenzelm
parents: 11946
diff changeset
   182
lemma lifts_IT: "ts \<in> lists IT \<Longrightarrow> map (\<lambda>t. lift t 0) ts \<in> lists IT"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   183
  by (induct ts) auto
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   184
12171
dc87f33db447 tuned inductions;
wenzelm
parents: 12114
diff changeset
   185
lemma lift_type [intro!]: "e \<turnstile> t : T \<Longrightarrow> (\<And>i U. e\<langle>i:U\<rangle> \<turnstile> lift t i : T)"
dc87f33db447 tuned inductions;
wenzelm
parents: 12114
diff changeset
   186
  by (induct set: typing) auto
dc87f33db447 tuned inductions;
wenzelm
parents: 12114
diff changeset
   187
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   188
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   189
lemma lift_typings:
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   190
  "\<And>Ts. e \<tturnstile> ts : Ts \<Longrightarrow> e\<langle>i:U\<rangle> \<tturnstile> (map (\<lambda>t. lift t i) ts) : Ts"
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   191
  apply (induct ts)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   192
   apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   193
  apply (case_tac Ts)
11946
wenzelm
parents: 11945
diff changeset
   194
   apply auto
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   195
  done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   196
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   197
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
   198
subsection {* Substitution lemmas *}
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   199
11994
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   200
lemma subst_lemma:
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   201
    "e \<turnstile> t : T \<Longrightarrow> (\<And>e' i U u. e' \<turnstile> u : U \<Longrightarrow> e = e'\<langle>i:U\<rangle> \<Longrightarrow> e' \<turnstile> t[u/i] : T)"
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   202
  apply (induct set: typing)
11946
wenzelm
parents: 11945
diff changeset
   203
    apply (rule_tac x = x and y = i in linorder_cases)
wenzelm
parents: 11945
diff changeset
   204
      apply auto
wenzelm
parents: 11945
diff changeset
   205
  apply blast
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   206
  done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   207
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   208
lemma substs_lemma:
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   209
  "\<And>Ts. e \<turnstile> u : T \<Longrightarrow> e\<langle>i:T\<rangle> \<tturnstile> ts : Ts \<Longrightarrow>
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   210
     e \<tturnstile> (map (\<lambda>t. t[u/i]) ts) : Ts"
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   211
  apply (induct ts)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   212
   apply (case_tac Ts)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   213
    apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   214
   apply simp
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   215
  apply atomize
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   216
  apply (case_tac Ts)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   217
   apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   218
  apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   219
  apply (erule conjE)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   220
  apply (erule (1) subst_lemma)
11994
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   221
  apply (rule refl)
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   222
  done
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   223
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   224
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
   225
subsection {* Subject reduction *}
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   226
11994
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   227
lemma subject_reduction: "e \<turnstile> t : T \<Longrightarrow> (\<And>t'. t -> t' \<Longrightarrow> e \<turnstile> t' : T)"
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   228
  apply (induct set: typing)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   229
    apply blast
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   230
   apply blast
11994
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   231
  apply atomize
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   232
  apply (ind_cases "s \<degree> t -> t'")
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   233
    apply hypsubst
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
   234
    apply (ind_cases "env \<turnstile> Abs t : T \<Rightarrow> U")
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   235
    apply (rule subst_lemma)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   236
      apply assumption
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   237
     apply assumption
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   238
    apply (rule ext)
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   239
    apply (case_tac x)
11946
wenzelm
parents: 11945
diff changeset
   240
     apply auto
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   241
  done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   242
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
   243
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
   244
subsection {* Additional lemmas *}
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   245
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   246
lemma app_last: "(t \<degree>\<degree> ts) \<degree> u = t \<degree>\<degree> (ts @ [u])"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   247
  by simp
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   248
11994
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   249
lemma subst_Var_IT: "r \<in> IT \<Longrightarrow> (\<And>i j. r[Var i/j] \<in> IT)"
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   250
  apply (induct set: IT)
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
   251
    txt {* Case @{term Var}: *}
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   252
    apply (simp (no_asm) add: subst_Var)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   253
    apply
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   254
    ((rule conjI impI)+,
9716
9be481b4bc85 Lambda/InductTermi made new-style theory;
wenzelm
parents: 9661
diff changeset
   255
      rule IT.Var,
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   256
      erule lists.induct,
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   257
      simp (no_asm),
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   258
      rule lists.Nil,
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   259
      simp (no_asm),
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   260
      erule IntE,
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   261
      erule CollectE,
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   262
      rule lists.Cons,
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   263
      fast,
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   264
      assumption)+
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
   265
   txt {* Case @{term Lambda}: *}
11994
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   266
   apply atomize
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   267
   apply simp
9716
9be481b4bc85 Lambda/InductTermi made new-style theory;
wenzelm
parents: 9661
diff changeset
   268
   apply (rule IT.Lambda)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   269
   apply fast
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
   270
  txt {* Case @{term Beta}: *}
11994
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   271
  apply atomize
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   272
  apply (simp (no_asm_use) add: subst_subst [symmetric])
9716
9be481b4bc85 Lambda/InductTermi made new-style theory;
wenzelm
parents: 9661
diff changeset
   273
  apply (rule IT.Beta)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   274
   apply auto
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   275
  done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   276
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   277
lemma Var_IT: "Var n \<in> IT"
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   278
  apply (subgoal_tac "Var n \<degree>\<degree> [] \<in> IT")
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   279
   apply simp
9716
9be481b4bc85 Lambda/InductTermi made new-style theory;
wenzelm
parents: 9661
diff changeset
   280
  apply (rule IT.Var)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   281
  apply (rule lists.Nil)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   282
  done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   283
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   284
lemma app_Var_IT: "t \<in> IT \<Longrightarrow> t \<degree> Var i \<in> IT"
11994
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   285
  apply (induct set: IT)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   286
    apply (subst app_last)
9716
9be481b4bc85 Lambda/InductTermi made new-style theory;
wenzelm
parents: 9661
diff changeset
   287
    apply (rule IT.Var)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   288
    apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   289
    apply (rule lists.Cons)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   290
     apply (rule Var_IT)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   291
    apply (rule lists.Nil)
9906
5c027cca6262 updated attribute names;
wenzelm
parents: 9811
diff changeset
   292
   apply (rule IT.Beta [where ?ss = "[]", unfolded foldl_Nil [THEN eq_reflection]])
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   293
    apply (erule subst_Var_IT)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   294
   apply (rule Var_IT)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   295
  apply (subst app_last)
9716
9be481b4bc85 Lambda/InductTermi made new-style theory;
wenzelm
parents: 9661
diff changeset
   296
  apply (rule IT.Beta)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   297
   apply (subst app_last [symmetric])
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   298
   apply assumption
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   299
  apply assumption
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   300
  done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   301
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   302
lemma type_induct [induct type]:
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
   303
  "(\<And>T. (\<And>T1 T2. T = T1 \<Rightarrow> T2 \<Longrightarrow> P T1) \<Longrightarrow>
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
   304
   (\<And>T1 T2. T = T1 \<Rightarrow> T2 \<Longrightarrow> P T2) \<Longrightarrow> P T) \<Longrightarrow> P T"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   305
proof -
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   306
  case rule_context
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   307
  show ?thesis
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   308
  proof (induct T)
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   309
    case Atom
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   310
    show ?case by (rule rule_context) simp_all
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   311
  next
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   312
    case Fun
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   313
    show ?case  by (rule rule_context) (insert Fun, simp_all)
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   314
  qed
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   315
qed
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   316
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   317
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
   318
subsection {* Well-typed substitution preserves termination *}
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   319
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   320
lemma subst_type_IT:
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   321
  "\<And>t e T u i. t \<in> IT \<Longrightarrow> e\<langle>i:U\<rangle> \<turnstile> t : T \<Longrightarrow>
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   322
    u \<in> IT \<Longrightarrow> e \<turnstile> u : U \<Longrightarrow> t[u/i] \<in> IT"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   323
  (is "PROP ?P U" is "\<And>t e T u i. _ \<Longrightarrow> PROP ?Q t e T u i U")
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   324
proof (induct U)
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   325
  fix T t
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
   326
  assume MI1: "\<And>T1 T2. T = T1 \<Rightarrow> T2 \<Longrightarrow> PROP ?P T1"
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
   327
  assume MI2: "\<And>T1 T2. T = T1 \<Rightarrow> T2 \<Longrightarrow> PROP ?P T2"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   328
  assume "t \<in> IT"
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   329
  thus "\<And>e T' u i. PROP ?Q t e T' u i T"
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   330
  proof induct
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   331
    fix e T' u i
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   332
    assume uIT: "u \<in> IT"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   333
    assume uT: "e \<turnstile> u : T"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   334
    {
13596
ee5f79b210c1 modified induct method
nipkow
parents: 12171
diff changeset
   335
      case (Var n rs e_ T'_ u_ i_)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   336
      assume nT: "e\<langle>i:T\<rangle> \<turnstile> Var n \<degree>\<degree> rs : T'"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   337
      let ?ty = "{t. \<exists>T'. e\<langle>i:T\<rangle> \<turnstile> t : T'}"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   338
      let ?R = "\<lambda>t. \<forall>e T' u i.
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   339
        e\<langle>i:T\<rangle> \<turnstile> t : T' \<longrightarrow> u \<in> IT \<longrightarrow> e \<turnstile> u : T \<longrightarrow> t[u/i] \<in> IT"
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   340
      show "(Var n \<degree>\<degree> rs)[u/i] \<in> IT"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   341
      proof (cases "n = i")
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   342
        case True
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   343
        show ?thesis
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   344
        proof (cases rs)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   345
          case Nil
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   346
          with uIT True show ?thesis by simp
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   347
        next
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   348
          case (Cons a as)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   349
          with nT have "e\<langle>i:T\<rangle> \<turnstile> Var n \<degree> a \<degree>\<degree> as : T'" by simp
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   350
          then obtain Ts
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   351
              where headT: "e\<langle>i:T\<rangle> \<turnstile> Var n \<degree> a : Ts \<Rrightarrow> T'"
11947
wenzelm
parents: 11946
diff changeset
   352
              and argsT: "e\<langle>i:T\<rangle> \<tturnstile> as : Ts"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   353
            by (rule list_app_typeE)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   354
          from headT obtain T''
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
   355
              where varT: "e\<langle>i:T\<rangle> \<turnstile> Var n : T'' \<Rightarrow> Ts \<Rrightarrow> T'"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   356
              and argT: "e\<langle>i:T\<rangle> \<turnstile> a : T''"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   357
            by cases simp_all
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
   358
          from varT True have T: "T = T'' \<Rightarrow> Ts \<Rrightarrow> T'"
11946
wenzelm
parents: 11945
diff changeset
   359
            by cases auto
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
   360
          with uT have uT': "e \<turnstile> u : T'' \<Rightarrow> Ts \<Rrightarrow> T'" by simp
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   361
          from T have "(Var 0 \<degree>\<degree> map (\<lambda>t. lift t 0)
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   362
            (map (\<lambda>t. t[u/i]) as))[(u \<degree> a[u/i])/0] \<in> IT"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   363
          proof (rule MI2)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   364
            from T have "(lift u 0 \<degree> Var 0)[a[u/i]/0] \<in> IT"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   365
            proof (rule MI1)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   366
              have "lift u 0 \<in> IT" by (rule lift_IT)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   367
              thus "lift u 0 \<degree> Var 0 \<in> IT" by (rule app_Var_IT)
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   368
              show "e\<langle>0:T''\<rangle> \<turnstile> lift u 0 \<degree> Var 0 : Ts \<Rrightarrow> T'"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   369
              proof (rule typing.App)
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
   370
                show "e\<langle>0:T''\<rangle> \<turnstile> lift u 0 : T'' \<Rightarrow> Ts \<Rrightarrow> T'"
11946
wenzelm
parents: 11945
diff changeset
   371
                  by (rule lift_type) (rule uT')
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   372
                show "e\<langle>0:T''\<rangle> \<turnstile> Var 0 : T''"
11946
wenzelm
parents: 11945
diff changeset
   373
                  by (rule typing.Var) simp
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   374
              qed
11950
9bd6e8e62a06 Eliminated occurrence of rule_format.
berghofe
parents: 11947
diff changeset
   375
              from Var have "?R a" by cases (simp_all add: Cons)
9bd6e8e62a06 Eliminated occurrence of rule_format.
berghofe
parents: 11947
diff changeset
   376
              with argT uIT uT show "a[u/i] \<in> IT" by simp
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   377
              from argT uT show "e \<turnstile> a[u/i] : T''"
11946
wenzelm
parents: 11945
diff changeset
   378
                by (rule subst_lemma) simp
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   379
            qed
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   380
            thus "u \<degree> a[u/i] \<in> IT" by simp
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   381
            from Var have "as \<in> lists {t. ?R t}"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   382
              by cases (simp_all add: Cons)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   383
            moreover from argsT have "as \<in> lists ?ty"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   384
              by (rule lists_typings)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   385
            ultimately have "as \<in> lists ({t. ?R t} \<inter> ?ty)"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   386
              by (rule lists_IntI)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   387
            hence "map (\<lambda>t. lift t 0) (map (\<lambda>t. t[u/i]) as) \<in> lists IT"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   388
              (is "(?ls as) \<in> _")
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   389
            proof induct
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   390
              case Nil
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   391
              show ?case by fastsimp
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   392
            next
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   393
              case (Cons b bs)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   394
              hence I: "?R b" by simp
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   395
              from Cons obtain U where "e\<langle>i:T\<rangle> \<turnstile> b : U" by fast
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   396
              with uT uIT I have "b[u/i] \<in> IT" by simp
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   397
              hence "lift (b[u/i]) 0 \<in> IT" by (rule lift_IT)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   398
              hence "lift (b[u/i]) 0 # ?ls bs \<in> lists IT"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   399
                by (rule lists.Cons) (rule Cons)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   400
              thus ?case by simp
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   401
            qed
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   402
            thus "Var 0 \<degree>\<degree> ?ls as \<in> IT" by (rule IT.Var)
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
   403
            have "e\<langle>0:Ts \<Rrightarrow> T'\<rangle> \<turnstile> Var 0 : Ts \<Rrightarrow> T'"
11946
wenzelm
parents: 11945
diff changeset
   404
              by (rule typing.Var) simp
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   405
            moreover from uT argsT have "e \<tturnstile> map (\<lambda>t. t[u/i]) as : Ts"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   406
              by (rule substs_lemma)
11947
wenzelm
parents: 11946
diff changeset
   407
            hence "e\<langle>0:Ts \<Rrightarrow> T'\<rangle> \<tturnstile> ?ls as : Ts"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   408
              by (rule lift_typings)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   409
            ultimately show "e\<langle>0:Ts \<Rrightarrow> T'\<rangle> \<turnstile> Var 0 \<degree>\<degree> ?ls as : T'"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   410
              by (rule list_app_typeI)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   411
            from argT uT have "e \<turnstile> a[u/i] : T''"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   412
              by (rule subst_lemma) (rule refl)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   413
            with uT' show "e \<turnstile> u \<degree> a[u/i] : Ts \<Rrightarrow> T'"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   414
              by (rule typing.App)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   415
          qed
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   416
          with Cons True show ?thesis
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   417
            by (simp add: map_compose [symmetric] o_def)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   418
        qed
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   419
      next
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   420
        case False
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   421
        from Var have "rs \<in> lists {t. ?R t}" by simp
11947
wenzelm
parents: 11946
diff changeset
   422
        moreover from nT obtain Ts where "e\<langle>i:T\<rangle> \<tturnstile> rs : Ts"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   423
          by (rule list_app_typeE)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   424
        hence "rs \<in> lists ?ty" by (rule lists_typings)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   425
        ultimately have "rs \<in> lists ({t. ?R t} \<inter> ?ty)"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   426
          by (rule lists_IntI)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   427
        hence "map (\<lambda>x. x[u/i]) rs \<in> lists IT"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   428
        proof induct
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   429
          case Nil
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   430
          show ?case by fastsimp
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   431
        next
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   432
          case (Cons a as)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   433
          hence I: "?R a" by simp
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   434
          from Cons obtain U where "e\<langle>i:T\<rangle> \<turnstile> a : U" by fast
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   435
          with uT uIT I have "a[u/i] \<in> IT" by simp
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   436
          hence "(a[u/i] # map (\<lambda>t. t[u/i]) as) \<in> lists IT"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   437
            by (rule lists.Cons) (rule Cons)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   438
          thus ?case by simp
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   439
        qed
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   440
        with False show ?thesis by (auto simp add: subst_Var)
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   441
      qed
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   442
    next
13596
ee5f79b210c1 modified induct method
nipkow
parents: 12171
diff changeset
   443
      case (Lambda r e_ T'_ u_ i_)
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   444
      assume "e\<langle>i:T\<rangle> \<turnstile> Abs r : T'"
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   445
        and "\<And>e T' u i. PROP ?Q r e T' u i T"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   446
      with uIT uT show "Abs r[u/i] \<in> IT"
11946
wenzelm
parents: 11945
diff changeset
   447
        by fastsimp
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   448
    next
13596
ee5f79b210c1 modified induct method
nipkow
parents: 12171
diff changeset
   449
      case (Beta r a as e_ T'_ u_ i_)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   450
      assume T: "e\<langle>i:T\<rangle> \<turnstile> Abs r \<degree> a \<degree>\<degree> as : T'"
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   451
      assume SI1: "\<And>e T' u i. PROP ?Q (r[a/0] \<degree>\<degree> as) e T' u i T"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   452
      assume SI2: "\<And>e T' u i. PROP ?Q a e T' u i T"
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   453
      have "Abs (r[lift u 0/Suc i]) \<degree> a[u/i] \<degree>\<degree> map (\<lambda>t. t[u/i]) as \<in> IT"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   454
      proof (rule IT.Beta)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   455
        have "Abs r \<degree> a \<degree>\<degree> as -> r[a/0] \<degree>\<degree> as"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   456
          by (rule apps_preserves_beta) (rule beta.beta)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   457
        with T have "e\<langle>i:T\<rangle> \<turnstile> r[a/0] \<degree>\<degree> as : T'"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   458
          by (rule subject_reduction)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   459
        hence "(r[a/0] \<degree>\<degree> as)[u/i] \<in> IT"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   460
          by (rule SI1)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   461
        thus "r[lift u 0/Suc i][a[u/i]/0] \<degree>\<degree> map (\<lambda>t. t[u/i]) as \<in> IT"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   462
          by (simp del: subst_map add: subst_subst subst_map [symmetric])
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   463
        from T obtain U where "e\<langle>i:T\<rangle> \<turnstile> Abs r \<degree> a : U"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   464
          by (rule list_app_typeE) fast
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   465
        then obtain T'' where "e\<langle>i:T\<rangle> \<turnstile> a : T''" by cases simp_all
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   466
        thus "a[u/i] \<in> IT" by (rule SI2)
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   467
      qed
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   468
      thus "(Abs r \<degree> a \<degree>\<degree> as)[u/i] \<in> IT" by simp
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   469
    }
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   470
  qed
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   471
qed
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   472
12171
dc87f33db447 tuned inductions;
wenzelm
parents: 12114
diff changeset
   473
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   474
subsection {* Well-typed terms are strongly normalizing *}
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   475
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   476
lemma type_implies_IT: "e \<turnstile> t : T \<Longrightarrow> t \<in> IT"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   477
proof -
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   478
  assume "e \<turnstile> t : T"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   479
  thus ?thesis
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   480
  proof induct
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   481
    case Var
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   482
    show ?case by (rule Var_IT)
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   483
  next
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   484
    case Abs
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   485
    show ?case by (rule IT.Lambda)
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   486
  next
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   487
    case (App T U e s t)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   488
    have "(Var 0 \<degree> lift t 0)[s/0] \<in> IT"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   489
    proof (rule subst_type_IT)
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   490
      have "lift t 0 \<in> IT" by (rule lift_IT)
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   491
      hence "[lift t 0] \<in> lists IT" by (rule lists.Cons) (rule lists.Nil)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   492
      hence "Var 0 \<degree>\<degree> [lift t 0] \<in> IT" by (rule IT.Var)
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   493
      also have "Var 0 \<degree>\<degree> [lift t 0] = Var 0 \<degree> lift t 0" by simp
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   494
      finally show "\<dots> \<in> IT" .
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
   495
      have "e\<langle>0:T \<Rightarrow> U\<rangle> \<turnstile> Var 0 : T \<Rightarrow> U"
11946
wenzelm
parents: 11945
diff changeset
   496
        by (rule typing.Var) simp
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
   497
      moreover have "e\<langle>0:T \<Rightarrow> U\<rangle> \<turnstile> lift t 0 : T"
11946
wenzelm
parents: 11945
diff changeset
   498
        by (rule lift_type)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   499
      ultimately show "e\<langle>0:T \<Rightarrow> U\<rangle> \<turnstile> Var 0 \<degree> lift t 0 : U"
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   500
        by (rule typing.App)
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   501
    qed
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   502
    thus ?case by simp
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   503
  qed
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   504
qed
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   505
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   506
theorem type_implies_termi: "e \<turnstile> t : T \<Longrightarrow> t \<in> termi beta"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   507
proof -
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   508
  assume "e \<turnstile> t : T"
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   509
  hence "t \<in> IT" by (rule type_implies_IT)
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   510
  thus ?thesis by (rule IT_implies_termi)
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   511
qed
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   512
11638
2c3dee321b4b inductive: no collective atts;
wenzelm
parents: 10567
diff changeset
   513
end