src/HOL/Lambda/Type.thy
author haftmann
Wed, 20 May 2009 10:37:37 +0200
changeset 31207 7eb05fc49b45
parent 25974 0cb35fa9c6fa
child 36319 8feb2c4bef1a
permissions -rw-r--r--
added generator for type copies (records)
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
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
     7
header {* Simply-typed lambda terms *}
9114
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
     8
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 15236
diff changeset
     9
theory Type imports ListApplication begin
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
    10
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
    11
11946
wenzelm
parents: 11945
diff changeset
    12
subsection {* Environments *}
wenzelm
parents: 11945
diff changeset
    13
19086
1b3780be6cc2 new-style definitions/abbreviations;
wenzelm
parents: 18257
diff changeset
    14
definition
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
    15
  shift :: "(nat \<Rightarrow> 'a) \<Rightarrow> nat \<Rightarrow> 'a \<Rightarrow> nat \<Rightarrow> 'a"  ("_<_:_>" [90, 0, 0] 91) where
19086
1b3780be6cc2 new-style definitions/abbreviations;
wenzelm
parents: 18257
diff changeset
    16
  "e<i:a> = (\<lambda>j. if j < i then e j else if j = i then a else e (j - 1))"
19363
667b5ea637dd refined 'abbreviation';
wenzelm
parents: 19086
diff changeset
    17
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 20503
diff changeset
    18
notation (xsymbols)
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19380
diff changeset
    19
  shift  ("_\<langle>_:_\<rangle>" [90, 0, 0] 91)
19363
667b5ea637dd refined 'abbreviation';
wenzelm
parents: 19086
diff changeset
    20
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 20503
diff changeset
    21
notation (HTML output)
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19380
diff changeset
    22
  shift  ("_\<langle>_:_\<rangle>" [90, 0, 0] 91)
11946
wenzelm
parents: 11945
diff changeset
    23
wenzelm
parents: 11945
diff changeset
    24
lemma shift_eq [simp]: "i = j \<Longrightarrow> (e\<langle>i:T\<rangle>) j = T"
wenzelm
parents: 11945
diff changeset
    25
  by (simp add: shift_def)
wenzelm
parents: 11945
diff changeset
    26
wenzelm
parents: 11945
diff changeset
    27
lemma shift_gt [simp]: "j < i \<Longrightarrow> (e\<langle>i:T\<rangle>) j = e j"
wenzelm
parents: 11945
diff changeset
    28
  by (simp add: shift_def)
wenzelm
parents: 11945
diff changeset
    29
wenzelm
parents: 11945
diff changeset
    30
lemma shift_lt [simp]: "i < j \<Longrightarrow> (e\<langle>i:T\<rangle>) j = e (j - 1)"
wenzelm
parents: 11945
diff changeset
    31
  by (simp add: shift_def)
wenzelm
parents: 11945
diff changeset
    32
wenzelm
parents: 11945
diff changeset
    33
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
    34
  apply (rule ext)
wenzelm
parents: 11945
diff changeset
    35
  apply (case_tac x)
wenzelm
parents: 11945
diff changeset
    36
   apply simp
wenzelm
parents: 11945
diff changeset
    37
  apply (case_tac nat)
wenzelm
parents: 11945
diff changeset
    38
   apply (simp_all add: shift_def)
wenzelm
parents: 11945
diff changeset
    39
  done
wenzelm
parents: 11945
diff changeset
    40
wenzelm
parents: 11945
diff changeset
    41
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
    42
subsection {* Types and typing rules *}
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
    43
9641
wenzelm
parents: 9622
diff changeset
    44
datatype type =
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
    45
    Atom nat
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
    46
  | Fun type type    (infixr "\<Rightarrow>" 200)
9114
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    47
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 23464
diff changeset
    48
inductive typing :: "(nat \<Rightarrow> type) \<Rightarrow> dB \<Rightarrow> type \<Rightarrow> bool"  ("_ \<turnstile> _ : _" [50, 50, 50] 50)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    49
  where
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    50
    Var [intro!]: "env x = T \<Longrightarrow> env \<turnstile> Var x : T"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    51
  | Abs [intro!]: "env\<langle>0:T\<rangle> \<turnstile> t : U \<Longrightarrow> env \<turnstile> Abs t : (T \<Rightarrow> U)"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    52
  | App [intro!]: "env \<turnstile> s : T \<Rightarrow> U \<Longrightarrow> env \<turnstile> t : T \<Longrightarrow> env \<turnstile> (s \<degree> t) : U"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    53
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 23464
diff changeset
    54
inductive_cases typing_elims [elim!]:
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    55
  "e \<turnstile> Var i : T"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    56
  "e \<turnstile> t \<degree> u : T"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    57
  "e \<turnstile> Abs t : T"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    58
25974
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    59
primrec
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
    60
  typings :: "(nat \<Rightarrow> type) \<Rightarrow> dB list \<Rightarrow> type list \<Rightarrow> bool"
25974
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    61
where
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    62
    "typings e [] Ts = (Ts = [])"
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    63
  | "typings e (t # ts) Ts =
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    64
      (case Ts of
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    65
        [] \<Rightarrow> False
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    66
      | T # Ts \<Rightarrow> e \<turnstile> t : T \<and> typings e ts Ts)"
19086
1b3780be6cc2 new-style definitions/abbreviations;
wenzelm
parents: 18257
diff changeset
    67
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
    68
abbreviation
19086
1b3780be6cc2 new-style definitions/abbreviations;
wenzelm
parents: 18257
diff changeset
    69
  typings_rel :: "(nat \<Rightarrow> type) \<Rightarrow> dB list \<Rightarrow> type list \<Rightarrow> bool"
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
    70
    ("_ ||- _ : _" [50, 50, 50] 50) where
19363
667b5ea637dd refined 'abbreviation';
wenzelm
parents: 19086
diff changeset
    71
  "env ||- ts : Ts == typings env ts Ts"
19086
1b3780be6cc2 new-style definitions/abbreviations;
wenzelm
parents: 18257
diff changeset
    72
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 20503
diff changeset
    73
notation (latex)
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19380
diff changeset
    74
  typings_rel  ("_ \<tturnstile> _ : _" [50, 50, 50] 50)
9114
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    75
25974
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    76
abbreviation
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    77
  funs :: "type list \<Rightarrow> type \<Rightarrow> type"  (infixr "=>>" 200) where
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    78
  "Ts =>> T == foldr Fun Ts T"
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    79
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    80
notation (latex)
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    81
  funs  (infixr "\<Rrightarrow>" 200)
9114
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    82
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
    83
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
    84
subsection {* Some examples *}
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
    85
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
    86
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
    87
  by force
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
    88
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
    89
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
    90
  by force
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
    91
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
    92
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
    93
subsection {* Lists of types *}
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
    94
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
    95
lemma lists_typings:
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    96
    "e \<tturnstile> ts : Ts \<Longrightarrow> listsp (\<lambda>t. \<exists>T. e \<turnstile> t : T) ts"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20369
diff changeset
    97
  apply (induct ts arbitrary: Ts)
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
    98
   apply (case_tac Ts)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
    99
     apply simp
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   100
     apply (rule listsp.Nil)
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   101
    apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   102
  apply (case_tac Ts)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   103
   apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   104
  apply simp
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   105
  apply (rule listsp.Cons)
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   106
   apply blast
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   107
  apply blast
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   108
  done
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   109
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 17589
diff changeset
   110
lemma types_snoc: "e \<tturnstile> ts : Ts \<Longrightarrow> e \<turnstile> t : T \<Longrightarrow> e \<tturnstile> ts @ [t] : Ts @ [T]"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20369
diff changeset
   111
  apply (induct ts arbitrary: Ts)
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   112
  apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   113
  apply (case_tac Ts)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   114
  apply simp+
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   115
  done
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   116
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 17589
diff changeset
   117
lemma types_snoc_eq: "e \<tturnstile> ts @ [t] : Ts @ [T] =
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   118
  (e \<tturnstile> ts : Ts \<and> e \<turnstile> t : T)"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20369
diff changeset
   119
  apply (induct ts arbitrary: Ts)
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   120
  apply (case_tac Ts)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   121
  apply simp+
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   122
  apply (case_tac Ts)
15236
f289e8ba2bb3 Proofs needed to be updated because induction now preserves name of
nipkow
parents: 14565
diff changeset
   123
  apply (case_tac "ts @ [t]")
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   124
  apply simp+
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   125
  done
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   126
25974
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
   127
lemma rev_exhaust2 [extraction_expand]:
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
   128
  obtains (Nil) "xs = []"  |  (snoc) ys y where "xs = ys @ [y]"
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   129
  -- {* Cannot use @{text rev_exhaust} from the @{text List}
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   130
    theory, since it is not constructive *}
25974
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
   131
  apply (subgoal_tac "\<forall>ys. xs = rev ys \<longrightarrow> thesis")
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   132
  apply (erule_tac x="rev xs" in allE)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   133
  apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   134
  apply (rule allI)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   135
  apply (rule impI)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   136
  apply (case_tac ys)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   137
  apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   138
  apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   139
  apply atomize
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   140
  apply (erule allE)+
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   141
  apply (erule mp, rule conjI)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   142
  apply (rule refl)+
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   143
  done
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   144
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   145
lemma types_snocE: "e \<tturnstile> ts @ [t] : Ts \<Longrightarrow>
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   146
  (\<And>Us U. Ts = Us @ [U] \<Longrightarrow> e \<tturnstile> ts : Us \<Longrightarrow> e \<turnstile> t : U \<Longrightarrow> P) \<Longrightarrow> P"
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   147
  apply (cases Ts rule: rev_exhaust2)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   148
  apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   149
  apply (case_tac "ts @ [t]")
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   150
  apply (simp add: types_snoc_eq)+
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 16417
diff changeset
   151
  apply iprover
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   152
  done
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   153
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   154
11950
9bd6e8e62a06 Eliminated occurrence of rule_format.
berghofe
parents: 11947
diff changeset
   155
subsection {* n-ary function types *}
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   156
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   157
lemma list_app_typeD:
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 17589
diff changeset
   158
    "e \<turnstile> t \<degree>\<degree> ts : T \<Longrightarrow> \<exists>Ts. e \<turnstile> t : Ts \<Rrightarrow> T \<and> e \<tturnstile> ts : Ts"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20369
diff changeset
   159
  apply (induct ts arbitrary: t T)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   160
   apply simp
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   161
  apply atomize
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   162
  apply simp
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   163
  apply (erule_tac x = "t \<degree> a" in allE)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   164
  apply (erule_tac x = T in allE)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   165
  apply (erule impE)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   166
   apply assumption
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   167
  apply (elim exE conjE)
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 23464
diff changeset
   168
  apply (ind_cases "e \<turnstile> t \<degree> u : T" for t u T)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   169
  apply (rule_tac x = "Ta # Ts" in exI)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   170
  apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   171
  done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   172
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   173
lemma list_app_typeE:
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   174
  "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
   175
  by (insert list_app_typeD) fast
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   176
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   177
lemma list_app_typeI:
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 17589
diff changeset
   178
    "e \<turnstile> t : Ts \<Rrightarrow> T \<Longrightarrow> e \<tturnstile> ts : Ts \<Longrightarrow> e \<turnstile> t \<degree>\<degree> ts : T"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20369
diff changeset
   179
  apply (induct ts arbitrary: t T Ts)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   180
   apply simp
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11950
diff changeset
   181
  apply atomize
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   182
  apply (case_tac Ts)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   183
   apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   184
  apply simp
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   185
  apply (erule_tac x = "t \<degree> a" in allE)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   186
  apply (erule_tac x = T in allE)
15236
f289e8ba2bb3 Proofs needed to be updated because induction now preserves name of
nipkow
parents: 14565
diff changeset
   187
  apply (erule_tac x = list in allE)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   188
  apply (erule impE)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   189
   apply (erule conjE)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   190
   apply (erule typing.App)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   191
   apply assumption
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   192
  apply blast
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   193
  done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   194
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   195
text {*
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   196
For the specific case where the head of the term is a variable,
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   197
the following theorems allow to infer the types of the arguments
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   198
without analyzing the typing derivation. This is crucial
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   199
for program extraction.
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   200
*}
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   201
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   202
theorem var_app_type_eq:
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 17589
diff changeset
   203
  "e \<turnstile> Var i \<degree>\<degree> ts : T \<Longrightarrow> e \<turnstile> Var i \<degree>\<degree> ts : U \<Longrightarrow> T = U"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20369
diff changeset
   204
  apply (induct ts arbitrary: T U rule: rev_induct)
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   205
  apply simp
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 23464
diff changeset
   206
  apply (ind_cases "e \<turnstile> Var i : T" for T)
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 23464
diff changeset
   207
  apply (ind_cases "e \<turnstile> Var i : T" for T)
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   208
  apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   209
  apply simp
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 23464
diff changeset
   210
  apply (ind_cases "e \<turnstile> t \<degree> u : T" for t u T)
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 23464
diff changeset
   211
  apply (ind_cases "e \<turnstile> t \<degree> u : T" for t u T)
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   212
  apply atomize
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   213
  apply (erule_tac x="Ta \<Rightarrow> T" in allE)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   214
  apply (erule_tac x="Tb \<Rightarrow> U" in allE)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   215
  apply (erule impE)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   216
  apply assumption
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   217
  apply (erule impE)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   218
  apply assumption
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   219
  apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   220
  done
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   221
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 17589
diff changeset
   222
lemma var_app_types: "e \<turnstile> Var i \<degree>\<degree> ts \<degree>\<degree> us : T \<Longrightarrow> e \<tturnstile> ts : Ts \<Longrightarrow>
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   223
  e \<turnstile> Var i \<degree>\<degree> ts : U \<Longrightarrow> \<exists>Us. U = Us \<Rrightarrow> T \<and> e \<tturnstile> us : Us"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20369
diff changeset
   224
  apply (induct us arbitrary: ts Ts U)
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   225
  apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   226
  apply (erule var_app_type_eq)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   227
  apply assumption
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   228
  apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   229
  apply atomize
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   230
  apply (case_tac U)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   231
  apply (rule FalseE)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   232
  apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   233
  apply (erule list_app_typeE)
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 23464
diff changeset
   234
  apply (ind_cases "e \<turnstile> t \<degree> u : T" for t u T)
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   235
  apply (drule_tac T="Atom nat" and U="Ta \<Rightarrow> Tsa \<Rrightarrow> T" in var_app_type_eq)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   236
  apply assumption
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   237
  apply simp
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   238
  apply (erule_tac x="ts @ [a]" in allE)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   239
  apply (erule_tac x="Ts @ [type1]" in allE)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   240
  apply (erule_tac x="type2" in allE)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   241
  apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   242
  apply (erule impE)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   243
  apply (rule types_snoc)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   244
  apply assumption
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   245
  apply (erule list_app_typeE)
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 23464
diff changeset
   246
  apply (ind_cases "e \<turnstile> t \<degree> u : T" for t u T)
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   247
  apply (drule_tac T="type1 \<Rightarrow> type2" and U="Ta \<Rightarrow> Tsa \<Rrightarrow> T" in var_app_type_eq)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   248
  apply assumption
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   249
  apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   250
  apply (erule impE)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   251
  apply (rule typing.App)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   252
  apply assumption
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   253
  apply (erule list_app_typeE)
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 23464
diff changeset
   254
  apply (ind_cases "e \<turnstile> t \<degree> u : T" for t u T)
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   255
  apply (frule_tac T="type1 \<Rightarrow> type2" and U="Ta \<Rightarrow> Tsa \<Rrightarrow> T" in var_app_type_eq)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   256
  apply assumption
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   257
  apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   258
  apply (erule exE)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   259
  apply (rule_tac x="type1 # Us" in exI)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   260
  apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   261
  apply (erule list_app_typeE)
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 23464
diff changeset
   262
  apply (ind_cases "e \<turnstile> t \<degree> u : T" for t u T)
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   263
  apply (frule_tac T="type1 \<Rightarrow> Us \<Rrightarrow> T" and U="Ta \<Rightarrow> Tsa \<Rrightarrow> T" in var_app_type_eq)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   264
  apply assumption
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   265
  apply simp
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   266
  done
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   267
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   268
lemma var_app_typesE: "e \<turnstile> Var i \<degree>\<degree> ts : T \<Longrightarrow>
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   269
  (\<And>Ts. e \<turnstile> Var i : Ts \<Rrightarrow> T \<Longrightarrow> e \<tturnstile> ts : Ts \<Longrightarrow> P) \<Longrightarrow> P"
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   270
  apply (drule var_app_types [of _ _ "[]", simplified])
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 16417
diff changeset
   271
  apply (iprover intro: typing.Var)+
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   272
  done
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   273
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   274
lemma abs_typeE: "e \<turnstile> Abs t : T \<Longrightarrow> (\<And>U V. e\<langle>0:U\<rangle> \<turnstile> t : V \<Longrightarrow> P) \<Longrightarrow> P"
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   275
  apply (cases T)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   276
  apply (rule FalseE)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   277
  apply (erule typing.cases)
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   278
  apply simp_all
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   279
  apply atomize
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   280
  apply (erule_tac x="type1" in allE)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   281
  apply (erule_tac x="type2" in allE)
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   282
  apply (erule mp)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   283
  apply (erule typing.cases)
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   284
  apply simp_all
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   285
  done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   286
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   287
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   288
subsection {* Lifting preserves well-typedness *}
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   289
18257
2124b24454dd tuned induct proofs;
wenzelm
parents: 18241
diff changeset
   290
lemma lift_type [intro!]: "e \<turnstile> t : T \<Longrightarrow> e\<langle>i:U\<rangle> \<turnstile> lift t i : T"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20369
diff changeset
   291
  by (induct arbitrary: i U set: typing) auto
12171
dc87f33db447 tuned inductions;
wenzelm
parents: 12114
diff changeset
   292
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   293
lemma lift_types:
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 17589
diff changeset
   294
  "e \<tturnstile> ts : Ts \<Longrightarrow> e\<langle>i:U\<rangle> \<tturnstile> (map (\<lambda>t. lift t i) ts) : Ts"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20369
diff changeset
   295
  apply (induct ts arbitrary: Ts)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   296
   apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   297
  apply (case_tac Ts)
11946
wenzelm
parents: 11945
diff changeset
   298
   apply auto
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   299
  done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   300
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   301
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
   302
subsection {* Substitution lemmas *}
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   303
11994
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   304
lemma subst_lemma:
18257
2124b24454dd tuned induct proofs;
wenzelm
parents: 18241
diff changeset
   305
    "e \<turnstile> t : T \<Longrightarrow> e' \<turnstile> u : U \<Longrightarrow> e = e'\<langle>i:U\<rangle> \<Longrightarrow> e' \<turnstile> t[u/i] : T"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20369
diff changeset
   306
  apply (induct arbitrary: e' i U u set: typing)
11946
wenzelm
parents: 11945
diff changeset
   307
    apply (rule_tac x = x and y = i in linorder_cases)
wenzelm
parents: 11945
diff changeset
   308
      apply auto
wenzelm
parents: 11945
diff changeset
   309
  apply blast
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   310
  done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   311
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   312
lemma substs_lemma:
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 17589
diff changeset
   313
  "e \<turnstile> u : T \<Longrightarrow> e\<langle>i:T\<rangle> \<tturnstile> ts : Ts \<Longrightarrow>
11943
a9672446b45f tuned notation;
wenzelm
parents: 11935
diff changeset
   314
     e \<tturnstile> (map (\<lambda>t. t[u/i]) ts) : Ts"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20369
diff changeset
   315
  apply (induct ts arbitrary: Ts)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   316
   apply (case_tac Ts)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   317
    apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   318
   apply simp
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   319
  apply atomize
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   320
  apply (case_tac Ts)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   321
   apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   322
  apply simp
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   323
  apply (erule conjE)
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11994
diff changeset
   324
  apply (erule (1) subst_lemma)
11994
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   325
  apply (rule refl)
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   326
  done
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   327
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   328
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 9771
diff changeset
   329
subsection {* Subject reduction *}
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   330
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   331
lemma subject_reduction: "e \<turnstile> t : T \<Longrightarrow> t \<rightarrow>\<^sub>\<beta> t' \<Longrightarrow> e \<turnstile> t' : T"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 20369
diff changeset
   332
  apply (induct arbitrary: t' set: typing)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   333
    apply blast
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   334
   apply blast
11994
319cc9aba0cf (induct set: ...);
wenzelm
parents: 11987
diff changeset
   335
  apply atomize
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 23464
diff changeset
   336
  apply (ind_cases "s \<degree> t \<rightarrow>\<^sub>\<beta> t'" for s t t')
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   337
    apply hypsubst
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 23464
diff changeset
   338
    apply (ind_cases "env \<turnstile> Abs t : T \<Rightarrow> U" for env t T U)
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   339
    apply (rule subst_lemma)
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   340
      apply assumption
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   341
     apply assumption
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   342
    apply (rule ext)
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   343
    apply (case_tac x)
11946
wenzelm
parents: 11945
diff changeset
   344
     apply auto
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   345
  done
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   346
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   347
theorem subject_reduction': "t \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<Longrightarrow> e \<turnstile> t : T \<Longrightarrow> e \<turnstile> t' : T"
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 23464
diff changeset
   348
  by (induct set: rtranclp) (iprover intro: subject_reduction)+
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   349
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   350
14064
35d36f43ba06 Moved strong normalization proof to StrongNorm.thy
berghofe
parents: 13596
diff changeset
   351
subsection {* Alternative induction rule for types *}
9622
d9aa8ca06bc2 converted to new-style theory;
wenzelm
parents: 9114
diff changeset
   352
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   353
lemma type_induct [induct type]:
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 17589
diff changeset
   354
  assumes
11945
1b540afebf4d Rrightarrow;
wenzelm
parents: 11943
diff changeset
   355
  "(\<And>T. (\<And>T1 T2. T = T1 \<Rightarrow> T2 \<Longrightarrow> P T1) \<Longrightarrow>
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 17589
diff changeset
   356
    (\<And>T1 T2. T = T1 \<Rightarrow> T2 \<Longrightarrow> P T2) \<Longrightarrow> P T)"
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 17589
diff changeset
   357
  shows "P T"
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 17589
diff changeset
   358
proof (induct T)
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 17589
diff changeset
   359
  case Atom
23464
bc2563c37b1a tuned proofs -- avoid implicit prems;
wenzelm
parents: 22271
diff changeset
   360
  show ?case by (rule assms) simp_all
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 17589
diff changeset
   361
next
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 17589
diff changeset
   362
  case Fun
23464
bc2563c37b1a tuned proofs -- avoid implicit prems;
wenzelm
parents: 22271
diff changeset
   363
  show ?case by (rule assms) (insert Fun, simp_all)
11935
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   364
qed
cbcba2092d6b Replaced main proof by proper Isar script.
berghofe
parents: 11704
diff changeset
   365
11638
2c3dee321b4b inductive: no collective atts;
wenzelm
parents: 10567
diff changeset
   366
end