src/HOL/Lambda/Type.ML
author wenzelm
Wed, 02 Aug 2000 19:40:14 +0200
changeset 9502 50ec59aff389
parent 9283 04f1b522cb11
child 9555 e8b05a2a4b72
permissions -rw-r--r--
adapted deriv;
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.ML
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
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
     5
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
     6
Subject reduction and strong normalization of simply-typed lambda terms.
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
     7
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
     8
Partly based on a paper proof by Ralph Matthes.
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
     9
*)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    10
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    11
AddSIs IT.intrs;
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    12
AddSIs typing.intrs;
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    13
AddSEs (map typing.mk_cases
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    14
  ["e |- Var i : T", "e |- t $ u : T", "e |- Abs t : T"]);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    15
AddSEs [lists.mk_cases "x # xs : lists S"];
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    16
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    17
(*** test ***)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    18
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    19
Goal "e |- Abs (Abs (Abs (Var 1 $ (Var 2 $ Var 1 $ Var 0)))) : ?T";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    20
by (fast_tac (claset() addss simpset()) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    21
result();
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    22
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    23
Goal "e |- Abs (Abs (Abs (Var 2 $ Var 0 $ (Var 1 $ Var 0)))) : ?T";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    24
by (fast_tac (claset() addss simpset()) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    25
result();
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    26
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    27
(**** n-ary function types ****)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    28
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    29
Goal "ALL t T. \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    30
  \ e |- t $$ ts : T --> (EX Ts. e |- t : Ts =>> T & types e ts Ts)";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    31
by (induct_tac "ts" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    32
by (Simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    33
by (strip_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    34
by (Full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    35
by (eres_inst_tac [("x","t $ a")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    36
by (eres_inst_tac [("x","T")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    37
by (etac impE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    38
by (assume_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    39
by (etac exE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    40
by (etac conjE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    41
by (etac (typing.mk_cases "e |- t $ u : T") 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    42
by (res_inst_tac [("x","Ta # Ts")] exI 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    43
by (Asm_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    44
qed_spec_mp "list_app_typeD";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    45
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    46
Goal "ALL t T Ts. e |- t : Ts =>> T --> types e ts Ts --> e |- t $$ ts : T";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    47
by (induct_tac "ts" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    48
by (strip_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    49
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    50
by (strip_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    51
by (case_tac "Ts" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    52
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    53
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    54
by (eres_inst_tac [("x","t $ a")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    55
by (eres_inst_tac [("x","T")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    56
by (eres_inst_tac [("x","lista")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    57
by (etac impE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    58
by (etac conjE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    59
by (etac typing.APP 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    60
by (assume_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    61
by (Fast_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    62
qed_spec_mp "list_app_typeI";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    63
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    64
Goal "ALL Ts. types e ts Ts --> ts : lists {t. EX T. e |- t : T}";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    65
by (induct_tac "ts" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    66
by (strip_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    67
by (case_tac "Ts" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    68
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    69
by (rtac lists.Nil 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    70
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    71
by (strip_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    72
by (case_tac "Ts" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    73
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    74
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    75
by (rtac lists.Cons 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    76
by (Fast_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    77
by (Fast_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    78
qed_spec_mp "lists_types";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    79
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    80
(**** lifting preserves termination and well-typedness ****)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    81
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    82
Goal "ALL t. lift (t $$ ts) i = lift t i $$ map (%t. lift t i) ts";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    83
by (induct_tac "ts" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    84
by (ALLGOALS Asm_full_simp_tac);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    85
qed_spec_mp "lift_map";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    86
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    87
Goal "ALL t. subst (t $$ ts) u i = subst t u i $$ map (%t. subst t u i) ts";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    88
by (induct_tac "ts" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    89
by (ALLGOALS Asm_full_simp_tac);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    90
qed_spec_mp "subst_map";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    91
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    92
Addsimps [lift_map, subst_map];
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    93
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    94
Goal "t : IT ==> ALL i. lift t i : IT";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    95
by (etac IT.induct 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    96
by (rtac allI 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    97
by (Simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    98
by (rtac conjI 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
    99
by (REPEAT (EVERY
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   100
  [rtac impI 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   101
   rtac IT.VarI 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   102
   etac lists.induct 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   103
   Simp_tac 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   104
   rtac lists.Nil 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   105
   Simp_tac 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   106
   etac IntE 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   107
   rtac lists.Cons 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   108
   Fast_tac 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   109
   atac 1]));
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   110
by (ALLGOALS (fast_tac (claset() addss simpset())));
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   111
qed_spec_mp "lift_IT";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   112
AddSIs [lift_IT];
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   113
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   114
Goal "ts : lists IT --> map (%t. lift t 0) ts : lists IT";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   115
by (induct_tac "ts" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   116
by (ALLGOALS (fast_tac (claset() addss simpset())));
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   117
qed_spec_mp "lifts_IT";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   118
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   119
Goal "nat_case T  \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   120
 \   (%j. if j < i then e j else if j = i then Ua else e (j - 1)) =  \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   121
 \ (%j. if j < Suc i then nat_case T e j else if j = Suc i then Ua  \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   122
 \   else nat_case T e (j - 1))";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   123
by (rtac ext 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   124
by (case_tac "j" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   125
by (Asm_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   126
by (case_tac "nat" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   127
by (ALLGOALS Asm_simp_tac);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   128
qed "shift_env";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   129
Addsimps [shift_env];
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   130
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   131
Goal "e |- t : T ==> ALL i U. \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   132
  \ (%j. if j < i then e j  \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   133
  \     else if j = i then U \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   134
  \     else e (j-1)) |- lift t i : T";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   135
by (etac typing.induct 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   136
by (ALLGOALS (fast_tac (claset() addss simpset())));
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   137
qed_spec_mp "lift_type'";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   138
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   139
Goal "e |- t : T ==> nat_case U e |- lift t 0 : T";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   140
by (subgoal_tac
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   141
  "nat_case U e = (%j. if j < 0 then e j  \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   142
 \  else if j = 0 then U else e (j-1))" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   143
by (etac ssubst 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   144
by (etac lift_type' 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   145
by (rtac ext 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   146
by (case_tac "j" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   147
by (Asm_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   148
by (Asm_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   149
qed "lift_type";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   150
AddSIs [lift_type];
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   151
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   152
Goal "ALL Ts. types e ts Ts -->  \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   153
  \ types (%j. if j < i then e j  \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   154
  \     else if j = i then U \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   155
  \     else e (j-1)) (map (%t. lift t i) ts) Ts";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   156
by (induct_tac "ts" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   157
by (Simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   158
by (strip_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   159
by (case_tac "Ts" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   160
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   161
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   162
by (rtac lift_type' 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   163
by (etac conjunct1 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   164
qed_spec_mp "lift_types";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   165
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   166
(**** substitution lemma ****)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   167
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   168
Goal "e |- t : T ==> ALL e' i U u. \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   169
  \ e = (%j. if j < i then e' j  \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   170
  \      else if j = i then U \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   171
  \      else e' (j-1)) -->  \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   172
  \ e' |- u : U --> e' |- t[u/i] : T";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   173
by (etac typing.induct 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   174
by (strip_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   175
by (case_tac "x=i" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   176
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   177
by (ftac (linorder_neq_iff RS iffD1) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   178
by (etac disjE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   179
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   180
by (rtac typing.VAR 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   181
by (assume_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   182
by (ftac order_less_not_sym 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   183
by (asm_full_simp_tac (HOL_ss addsimps [subst_gt]) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   184
by (rtac typing.VAR 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   185
by (assume_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   186
by (ALLGOALS (fast_tac (claset() addss simpset())));
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   187
qed_spec_mp "subst_lemma";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   188
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   189
Goal "e |- u : T ==> ALL Ts. types (%j. if j < i then e j  \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   190
  \  else if j = i then T else e (j - 1))  \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   191
  \ ts Ts --> types e (map (%t. t[u/i]) ts) Ts";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   192
by (induct_tac "ts" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   193
by (strip_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   194
by (case_tac "Ts" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   195
by (Asm_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   196
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   197
by (strip_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   198
by (case_tac "Ts" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   199
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   200
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   201
by (etac conjE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   202
by (etac subst_lemma 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   203
by (rtac refl 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   204
by (assume_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   205
qed_spec_mp "substs_lemma";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   206
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   207
(**** subject reduction ****)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   208
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   209
Goal "e |- t : T ==> ALL t'. t -> t' --> e |- t' : T";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   210
by (etac typing.induct 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   211
by (Fast_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   212
by (Fast_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   213
by (strip_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   214
by (etac (beta.mk_cases "s $ t -> t'") 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   215
by (hyp_subst_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   216
by (etac (typing.mk_cases "env |- Abs t : T => U") 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   217
by (rtac subst_lemma 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   218
by (assume_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   219
by (assume_tac 2);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   220
by (rtac ext 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   221
by (case_tac "j" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   222
by (Asm_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   223
by (Asm_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   224
by (Fast_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   225
by (Fast_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   226
qed_spec_mp "subject_reduction";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   227
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   228
(**** additional lemmas ****)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   229
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   230
Goal "ALL t. (t $$ ts) $ u = t $$ (ts @ [u])";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   231
by (induct_tac "ts" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   232
by (ALLGOALS Asm_full_simp_tac);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   233
qed_spec_mp "app_last";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   234
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   235
Goal "ALL ys. xs : lists S --> ys : lists S --> xs @ ys : lists S";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   236
by (induct_tac "xs" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   237
by (ALLGOALS (fast_tac (claset() addss simpset())));
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   238
qed_spec_mp "append_lists";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   239
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   240
Goal "r : IT ==> ALL i j. r[Var i/j] : IT";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   241
by (etac IT.induct 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   242
(** Var **)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   243
by (strip_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   244
by (simp_tac (simpset() addsimps [subst_Var]) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   245
by (REPEAT (EVERY
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   246
  [REPEAT (resolve_tac [conjI, impI] 1),
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   247
   rtac IT.VarI 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   248
   etac lists.induct 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   249
   Simp_tac 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   250
   rtac lists.Nil 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   251
   Simp_tac 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   252
   etac IntE 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   253
   etac CollectE 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   254
   rtac lists.Cons 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   255
   Fast_tac 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   256
   atac 1]));
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   257
(** Lambda **)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   258
by (strip_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   259
by (Simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   260
by (rtac IT.LambdaI 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   261
by (Fast_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   262
(** Beta **)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   263
by (strip_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   264
by (full_simp_tac (simpset() addsimps [subst_subst RS sym]) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   265
by (rtac IT.BetaI 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   266
by (Fast_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   267
by (Fast_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   268
qed_spec_mp "subst_Var_IT";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   269
9148
4e06543e8b82 bind_thm;
wenzelm
parents: 9114
diff changeset
   270
bind_thm ("Var_IT", rewrite_rule [mk_meta_eq foldl_Nil] (lists.Nil RS IT.VarI));
9114
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   271
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   272
Goal "t : IT ==> t $ Var i : IT";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   273
by (etac IT.induct 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   274
by (stac app_last 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   275
by (rtac IT.VarI 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   276
by (rtac append_lists 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   277
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   278
by (rtac lists.Cons 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   279
by (rtac Var_IT 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   280
by (rtac lists.Nil 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   281
by (rtac (rewrite_rule [mk_meta_eq foldl_Nil]
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   282
  (read_instantiate [("ss","[]")] IT.BetaI)) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   283
by (etac subst_Var_IT 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   284
by (rtac Var_IT 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   285
by (stac app_last 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   286
by (rtac IT.BetaI 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   287
by (stac (app_last RS sym) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   288
by (assume_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   289
by (assume_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   290
qed "app_Var_IT";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   291
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   292
(**** well-typed substitution preserves termination ****)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   293
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   294
Goal "ALL t. t : IT --> (ALL e T u i. \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   295
  \  (%j. if j < i then e j  \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   296
  \       else if j = i then U  \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   297
  \       else e (j - 1)) |- t : T -->  \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   298
  \  u : IT --> e |- u : U --> t[u/i] : IT)";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   299
by (res_inst_tac [("f","size"),("a","U")] measure_induct 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   300
by (rtac allI 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   301
by (rtac impI 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   302
by (etac IT.induct 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   303
(** Var **)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   304
by (strip_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   305
by (case_tac "n=i" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   306
(** n=i **)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   307
by (case_tac "rs" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   308
by (Asm_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   309
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   310
by (dtac list_app_typeD 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   311
by (REPEAT (eresolve_tac [exE, conjE] 1));
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   312
by (etac (typing.mk_cases "e |- t $ u : T") 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   313
by (etac (typing.mk_cases "e |- Var i : T") 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   314
by (dres_inst_tac [("s","(?T::typ) => ?U")] sym 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   315
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   316
by (subgoal_tac "lift u 0 $ Var 0 : IT" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   317
by (rtac app_Var_IT 2);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   318
by (etac lift_IT 2);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   319
by (subgoal_tac "(lift u 0 $ Var 0)[a[u/i]/0] : IT" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   320
by (Full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   321
by (subgoal_tac "(Var 0 $$ map (%t. lift t 0)  \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   322
  \  (map (%t. t[u/i]) list))[(u $ a[u/i])/0] : IT" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   323
by (full_simp_tac (simpset() delsimps [map_compose] addsimps
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   324
  [map_compose RS sym, o_def]) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   325
by (eres_inst_tac [("x", "Ts =>> T")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   326
by (etac impE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   327
by (Simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   328
by (eres_inst_tac [("x", "Var 0 $$ \
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   329
 \  map (%t. lift t 0) (map (%t. t[u/i]) list)")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   330
by (etac impE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   331
by (rtac IT.VarI 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   332
by (rtac lifts_IT 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   333
by (dtac lists_types 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   334
byev [etac (lists.mk_cases "x # xs : lists (Collect P)") 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   335
  etac (lists_IntI RS lists.induct) 1,
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   336
  atac 1];
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   337
by (fast_tac (claset() addss simpset()) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   338
by (fast_tac (claset() addss simpset()) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   339
by (eres_inst_tac [("x","e")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   340
by (eres_inst_tac [("x","T")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   341
by (eres_inst_tac [("x","u $ a[u/i]")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   342
by (eres_inst_tac [("x","0")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   343
by (fast_tac (claset()
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   344
  addSIs [list_app_typeI, lift_types, subst_lemma, substs_lemma]
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   345
  addss simpset()) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   346
by (eres_inst_tac [("x", "Ta")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   347
by (etac impE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   348
by (Simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   349
by (eres_inst_tac [("x", "lift u 0 $ Var 0")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   350
by (etac impE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   351
by (assume_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   352
by (eres_inst_tac [("x", "e")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   353
by (eres_inst_tac [("x", "Ts =>> T")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   354
by (eres_inst_tac [("x", "a[u/i]")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   355
by (eres_inst_tac [("x", "0")] allE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   356
by (etac impE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   357
by (rtac typing.APP 1);
9283
04f1b522cb11 Tuned proof.
berghofe
parents: 9148
diff changeset
   358
by (etac lift_type' 1);
9114
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   359
by (rtac typing.VAR 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   360
by (Simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   361
by (fast_tac (claset() addSIs [subst_lemma]) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   362
(** n~=i **)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   363
by (dtac list_app_typeD 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   364
by (etac exE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   365
by (etac conjE 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   366
by (dtac lists_types 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   367
by (subgoal_tac "map (%x. x[u/i]) rs : lists IT" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   368
by (asm_simp_tac (simpset() addsimps [subst_Var]) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   369
by (Fast_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   370
by (etac (lists_IntI RS lists.induct) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   371
by (assume_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   372
by (fast_tac (claset() addss simpset()) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   373
by (fast_tac (claset() addss simpset()) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   374
(** Lambda **)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   375
by (fast_tac (claset() addss simpset()) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   376
(** Beta **)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   377
by (strip_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   378
by (Simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   379
by (rtac IT.BetaI 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   380
by (simp_tac (simpset() delsimps [subst_map]
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   381
  addsimps [subst_subst, subst_map RS sym]) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   382
by (dtac subject_reduction 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   383
by (rtac apps_preserves_beta 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   384
by (rtac beta.beta 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   385
by (Fast_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   386
by (dtac list_app_typeD 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   387
by (Fast_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   388
qed_spec_mp "subst_type_IT";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   389
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   390
(**** main theorem: well-typed terms are strongly normalizing ****)
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   391
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   392
Goal "e |- t : T ==> t : IT";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   393
by (etac typing.induct 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   394
by (rtac Var_IT 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   395
by (etac IT.LambdaI 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   396
by (subgoal_tac "(Var 0 $ lift t 0)[s/0] : IT" 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   397
by (Asm_full_simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   398
by (rtac subst_type_IT 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   399
by (rtac (rewrite_rule (map mk_meta_eq [foldl_Nil, foldl_Cons])
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   400
  (lists.Nil RSN (2, lists.Cons RS IT.VarI))) 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   401
by (etac lift_IT 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   402
by (rtac typing.APP 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   403
by (rtac typing.VAR 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   404
by (Simp_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   405
by (etac lift_type' 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   406
by (assume_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   407
by (assume_tac 1);
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   408
qed "type_implies_IT";
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   409
de99e37effda Subject reduction and strong normalization of simply-typed lambda terms.
berghofe
parents:
diff changeset
   410
bind_thm ("type_implies_termi", type_implies_IT RS IT_implies_termi);