src/HOL/MiniML/Type.ML
author paulson
Mon, 16 Jun 1997 14:25:33 +0200
changeset 3438 8d63ff01d37e
parent 3385 f59e64fe4058
child 3842 b55686a7b22c
permissions -rw-r--r--
Type constraint added to ensure that "length" refers to lists. Maybe should not be needed, but the translation length->size happens irrespective of types
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
     1
(* Title:     HOL/MiniML/Type.thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
     2
   ID:        $Id$
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
     3
   Author:    Wolfgang Naraschewski and Tobias Nipkow
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
     4
   Copyright  1996 TU Muenchen
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
     5
*)
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     6
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     7
Addsimps [mgu_eq,mgu_mg,mgu_free];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     8
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
     9
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    10
(* lemmata for make scheme *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    11
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    12
goal thy "mk_scheme t = sch1 =-> sch2 --> (? t1 t2. sch1 = mk_scheme t1 & sch2 = mk_scheme t2)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    13
by (typ.induct_tac "t" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    14
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    15
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    16
by (Fast_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    17
qed_spec_mp "mk_scheme_Fun";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    18
2625
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
    19
goal thy "!t'.mk_scheme t = mk_scheme t' --> t=t'";
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    20
by (typ.induct_tac "t" 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
    21
 by (rtac allI 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    22
 by (typ.induct_tac "t'" 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
    23
  by (Simp_tac 1);
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
    24
 by (Asm_full_simp_tac 1);
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
    25
by (rtac allI 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    26
by (typ.induct_tac "t'" 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
    27
 by (Simp_tac 1);
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
    28
by (Asm_full_simp_tac 1);
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
    29
by (Fast_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    30
qed_spec_mp "mk_scheme_injective";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    31
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    32
goal thy "!!t. free_tv (mk_scheme t) = free_tv t";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    33
by (typ.induct_tac "t" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    34
by (ALLGOALS Asm_simp_tac);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    35
qed "free_tv_mk_scheme";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    36
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    37
Addsimps [free_tv_mk_scheme];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    38
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    39
goal thy "!!t. $ S (mk_scheme t) = mk_scheme ($ S t)";
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
    40
by (typ.induct_tac "t" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    41
by (ALLGOALS Asm_simp_tac);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    42
qed "subst_mk_scheme";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    43
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    44
Addsimps [subst_mk_scheme];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    45
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    46
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    47
(* constructor laws for app_subst *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    48
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    49
goalw thy [app_subst_list]
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    50
  "$ S [] = []";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    51
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    52
qed "app_subst_Nil";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    53
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    54
goalw thy [app_subst_list]
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    55
  "$ S (x#l) = ($ S x)#($ S l)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    56
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    57
qed "app_subst_Cons";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    58
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    59
Addsimps [app_subst_Nil,app_subst_Cons];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    60
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    61
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    62
(* constructor laws for new_tv *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    63
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    64
goalw thy [new_tv_def]
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    65
  "new_tv n (TVar m) = (m<n)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    66
by (fast_tac (HOL_cs addss !simpset) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    67
qed "new_tv_TVar";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    68
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    69
goalw thy [new_tv_def]
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    70
  "new_tv n (FVar m) = (m<n)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    71
by (fast_tac (HOL_cs addss !simpset) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    72
qed "new_tv_FVar";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    73
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    74
goalw thy [new_tv_def]
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    75
  "new_tv n (BVar m) = True";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    76
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    77
qed "new_tv_BVar";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    78
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    79
goalw thy [new_tv_def]
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    80
  "new_tv n (t1 -> t2) = (new_tv n t1 & new_tv n t2)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    81
by (fast_tac (HOL_cs addss !simpset) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    82
qed "new_tv_Fun";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    83
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    84
goalw thy [new_tv_def]
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    85
  "new_tv n (t1 =-> t2) = (new_tv n t1 & new_tv n t2)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    86
by (fast_tac (HOL_cs addss !simpset) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    87
qed "new_tv_Fun2";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    88
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    89
goalw thy [new_tv_def]
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    90
  "new_tv n []";
2031
03a843f0f447 Ran expandshort
paulson
parents: 1901
diff changeset
    91
by (Simp_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    92
qed "new_tv_Nil";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    93
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    94
goalw thy [new_tv_def]
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    95
  "new_tv n (x#l) = (new_tv n x & new_tv n l)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    96
by (fast_tac (HOL_cs addss !simpset) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    97
qed "new_tv_Cons";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    98
2625
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
    99
goalw thy [new_tv_def] "!!n. new_tv n TVar";
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   100
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   101
by (asm_full_simp_tac (!simpset addsimps [free_tv_subst,dom_def,cod_def]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   102
qed "new_tv_TVar_subst";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   103
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   104
Addsimps [new_tv_TVar,new_tv_FVar,new_tv_BVar,new_tv_Fun,new_tv_Fun2,new_tv_Nil,new_tv_Cons,new_tv_TVar_subst];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   105
2625
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   106
goalw thy [id_subst_def,new_tv_def,free_tv_subst,dom_def,cod_def]
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   107
  "new_tv n id_subst";
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   108
by (Simp_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   109
qed "new_tv_id_subst";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   110
Addsimps[new_tv_id_subst];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   111
2625
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   112
goal thy "new_tv n (sch::type_scheme) --> \
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   113
\              $(%k.if k<n then S k else S' k) sch = $S sch";
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   114
by (type_scheme.induct_tac "sch" 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   115
by (ALLGOALS Asm_simp_tac);
2625
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   116
qed "new_if_subst_type_scheme";
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   117
Addsimps [new_if_subst_type_scheme];
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   118
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   119
goal thy "new_tv n (A::type_scheme list) --> \
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   120
\              $(%k.if k<n then S k else S' k) A = $S A";
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   121
by (list.induct_tac "A" 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   122
by (ALLGOALS Asm_simp_tac);
2625
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   123
qed "new_if_subst_type_scheme_list";
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   124
Addsimps [new_if_subst_type_scheme_list];
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   125
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   126
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   127
(* constructor laws for dom and cod *)
1751
946efd210837 Added thm I_complete_wrt_W to I.
nipkow
parents: 1619
diff changeset
   128
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   129
goalw thy [dom_def,id_subst_def,empty_def]
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   130
  "dom id_subst = {}";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   131
by (Simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   132
qed "dom_id_subst";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   133
Addsimps [dom_id_subst];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   134
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   135
goalw thy [cod_def]
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   136
  "cod id_subst = {}";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   137
by (Simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   138
qed "cod_id_subst";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   139
Addsimps [cod_id_subst];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   140
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   141
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   142
(* lemmata for free_tv *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   143
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   144
goalw thy [free_tv_subst]
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   145
  "free_tv id_subst = {}";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   146
by (Simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   147
qed "free_tv_id_subst";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   148
Addsimps [free_tv_id_subst];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   149
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   150
goal thy "!!A. !n. n < length A --> x : free_tv (nth n A) --> x : free_tv A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   151
by (list.induct_tac "A" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   152
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   153
by (rtac allI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   154
by (res_inst_tac [("n","n")] nat_induct 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   155
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   156
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   157
qed_spec_mp "free_tv_nth_A_impl_free_tv_A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   158
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   159
Addsimps [free_tv_nth_A_impl_free_tv_A];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   160
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   161
goal thy "!!A. !nat. nat < length A --> x : free_tv (nth nat A) --> x : free_tv A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   162
by (list.induct_tac "A" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   163
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   164
by (rtac allI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   165
by (res_inst_tac [("n","nat")] nat_induct 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   166
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   167
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   168
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   169
qed_spec_mp "free_tv_nth_nat_A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   170
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   171
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   172
(* if two substitutions yield the same result if applied to a type
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   173
   structure the substitutions coincide on the free type variables
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   174
   occurring in the type structure *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   175
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   176
goal thy "!!S S'. (!x:free_tv t. (S x) = (S' x)) --> $ S (t::typ) = $ S' t";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   177
by (typ.induct_tac "t" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   178
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   179
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   180
qed_spec_mp "typ_substitutions_only_on_free_variables";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   181
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   182
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   183
  "!!t. (!n. n:(free_tv t) --> S1 n = S2 n) ==> $ S1 (t::typ) = $ S2 t";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   184
by (rtac typ_substitutions_only_on_free_variables 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   185
by (simp_tac (!simpset addsimps [Ball_def]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   186
qed "eq_free_eq_subst_te";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   187
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   188
goal thy "!!S S'. (!x:free_tv sch. (S x) = (S' x)) --> $ S (sch::type_scheme) = $ S' sch";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   189
by (type_scheme.induct_tac "sch" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   190
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   191
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   192
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   193
qed_spec_mp "scheme_substitutions_only_on_free_variables";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   194
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   195
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   196
  "!!sch. (!n. n:(free_tv sch) --> S1 n = S2 n) ==> $ S1 (sch::type_scheme) = $ S2 sch";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   197
by (rtac scheme_substitutions_only_on_free_variables 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   198
by (simp_tac (!simpset addsimps [Ball_def]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   199
qed "eq_free_eq_subst_type_scheme";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   200
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   201
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   202
  "(!n. n:(free_tv A) --> S1 n = S2 n) --> $S1 (A::type_scheme list) = $S2 A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   203
by (list.induct_tac "A" 1); 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   204
(* case [] *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   205
by (fast_tac (HOL_cs addss !simpset) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   206
(* case x#xl *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   207
by (fast_tac (HOL_cs addIs [eq_free_eq_subst_type_scheme] addss (!simpset)) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   208
qed_spec_mp "eq_free_eq_subst_scheme_list";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   209
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   210
goal thy "!!P Q. ((!x:A. (P x)) --> Q) ==> ((!x:A Un B. (P x)) --> Q)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   211
by (Fast_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   212
val weaken_asm_Un = result ();
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   213
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   214
goal thy "!!S S'. (!x:free_tv A. (S x) = (S' x)) --> $ S (A::type_scheme list) = $ S' A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   215
by (list.induct_tac "A" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   216
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   217
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   218
by (rtac weaken_asm_Un 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   219
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   220
by (etac scheme_substitutions_only_on_free_variables 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   221
qed_spec_mp "scheme_list_substitutions_only_on_free_variables";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   222
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   223
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   224
  "$ S1 (t::typ) = $ S2 t --> n:(free_tv t) --> S1 n = S2 n";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   225
by (typ.induct_tac "t" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   226
(* case TVar n *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   227
by (fast_tac (HOL_cs addss !simpset) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   228
(* case Fun t1 t2 *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   229
by (fast_tac (HOL_cs addss !simpset) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   230
qed_spec_mp "eq_subst_te_eq_free";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   231
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   232
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   233
  "$ S1 (sch::type_scheme) = $ S2 sch --> n:(free_tv sch) --> S1 n = S2 n";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   234
by (type_scheme.induct_tac "sch" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   235
(* case TVar n *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   236
by (Asm_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   237
(* case BVar n *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   238
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   239
by (etac mk_scheme_injective 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   240
by (Asm_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   241
(* case Fun t1 t2 *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   242
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   243
qed_spec_mp "eq_subst_type_scheme_eq_free";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   244
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   245
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   246
  "$S1 (A::type_scheme list) = $S2 A --> n:(free_tv A) --> S1 n = S2 n";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   247
by (list.induct_tac "A" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   248
(* case [] *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   249
by (fast_tac (HOL_cs addss !simpset) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   250
(* case x#xl *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   251
by (fast_tac (HOL_cs addIs [eq_subst_type_scheme_eq_free] addss (!simpset)) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   252
qed_spec_mp "eq_subst_scheme_list_eq_free";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   253
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   254
goalw thy [free_tv_subst] 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   255
      "!!v. v : cod S ==> v : free_tv S";
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   256
by (fast_tac set_cs 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   257
qed "codD";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   258
 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   259
goalw thy [free_tv_subst,dom_def] 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   260
      "!! x. x ~: free_tv S ==> S x = TVar x";
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   261
by (fast_tac set_cs 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   262
qed "not_free_impl_id";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   263
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   264
goalw thy [new_tv_def] 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   265
      "!! n. [| new_tv n t; m:free_tv t |] ==> m<n";
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   266
by (fast_tac HOL_cs 1 );
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   267
qed "free_tv_le_new_tv";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   268
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   269
goalw thy [dom_def,cod_def,UNION_def,Bex_def]
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   270
  "!!v. [| v : free_tv(S n); v~=n |] ==> v : cod S";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   271
by (Simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   272
by (safe_tac (empty_cs addSIs [exI,conjI,notI]));
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   273
by (assume_tac 2);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   274
by (rotate_tac 1 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   275
by (Asm_full_simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   276
qed "cod_app_subst";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   277
Addsimps [cod_app_subst];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   278
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   279
goal thy 
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   280
     "free_tv (S (v::nat)) <= insert v (cod S)";
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   281
by (expand_case_tac "v:dom S" 1);
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   282
by (fast_tac (set_cs addss (!simpset addsimps [cod_def])) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   283
by (fast_tac (set_cs addss (!simpset addsimps [dom_def])) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   284
qed "free_tv_subst_var";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   285
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   286
goal thy 
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   287
     "free_tv ($ S (t::typ)) <= cod S Un free_tv t";
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   288
by (typ.induct_tac "t" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   289
(* case TVar n *)
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   290
by (simp_tac (!simpset addsimps [free_tv_subst_var]) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   291
(* case Fun t1 t2 *)
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   292
by (fast_tac (set_cs addss !simpset) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   293
qed "free_tv_app_subst_te";     
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   294
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   295
goal thy 
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   296
     "free_tv ($ S (sch::type_scheme)) <= cod S Un free_tv sch";
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   297
by (type_scheme.induct_tac "sch" 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   298
(* case FVar n *)
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   299
by (simp_tac (!simpset addsimps [free_tv_subst_var]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   300
(* case BVar n *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   301
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   302
(* case Fun t1 t2 *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   303
by (fast_tac (set_cs addss !simpset) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   304
qed "free_tv_app_subst_type_scheme";  
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   305
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   306
goal thy 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   307
     "free_tv ($ S (A::type_scheme list)) <= cod S Un free_tv A";
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   308
by (list.induct_tac "A" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   309
(* case [] *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   310
by (Simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   311
(* case a#al *)
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   312
by (cut_facts_tac [free_tv_app_subst_type_scheme] 1);
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   313
by (fast_tac (set_cs addss !simpset) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   314
qed "free_tv_app_subst_scheme_list";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   315
1521
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   316
goalw thy [free_tv_subst,dom_def]
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   317
     "free_tv (%u::nat. $ s1 (s2 u) :: typ) <=   \
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   318
\     free_tv s1 Un free_tv s2";
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   319
by (fast_tac (set_cs addSDs [free_tv_app_subst_te RS subsetD,
3008
0a887d5b6718 Ran expandshort
paulson
parents: 2625
diff changeset
   320
                             free_tv_subst_var RS subsetD] 
0a887d5b6718 Ran expandshort
paulson
parents: 2625
diff changeset
   321
                     addss (!simpset delsimps bex_simps
0a887d5b6718 Ran expandshort
paulson
parents: 2625
diff changeset
   322
                                     addsimps [cod_def,dom_def])) 1);
1521
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   323
qed "free_tv_comp_subst";
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   324
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   325
goalw thy [o_def] 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   326
     "free_tv ($ S1 o S2) <= free_tv S1 Un free_tv (S2 :: nat => typ)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   327
by (rtac free_tv_comp_subst 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   328
qed "free_tv_o_subst";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   329
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   330
goal thy "!!n. n : free_tv t --> free_tv (S n) <= free_tv ($ S t::typ)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   331
by (typ.induct_tac "t" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   332
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   333
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   334
by (Fast_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   335
qed_spec_mp "free_tv_of_substitutions_extend_to_types";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   336
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   337
goal thy "!!n. n : free_tv sch --> free_tv (S n) <= free_tv ($ S sch::type_scheme)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   338
by (type_scheme.induct_tac "sch" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   339
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   340
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   341
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   342
by (Fast_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   343
qed_spec_mp "free_tv_of_substitutions_extend_to_schemes";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   344
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   345
goal thy "!!n. n : free_tv A --> free_tv (S n) <= free_tv ($ S A::type_scheme list)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   346
by (list.induct_tac "A" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   347
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   348
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   349
by (fast_tac (!claset addDs [free_tv_of_substitutions_extend_to_schemes]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   350
qed_spec_mp "free_tv_of_substitutions_extend_to_scheme_lists";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   351
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   352
Addsimps [free_tv_of_substitutions_extend_to_scheme_lists];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   353
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   354
goal thy "!!sch::type_scheme. (n : free_tv sch) = (n mem free_tv_ML sch)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   355
by (type_scheme.induct_tac "sch" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   356
by (ALLGOALS (asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   357
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   358
by (Fast_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   359
qed "free_tv_ML_scheme";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   360
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   361
goal thy "!!A::type_scheme list. (n : free_tv A) = (n mem free_tv_ML A)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   362
by (list.induct_tac "A" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   363
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   364
by (asm_simp_tac (!simpset addsimps [free_tv_ML_scheme]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   365
qed "free_tv_ML_scheme_list";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   366
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   367
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   368
(* lemmata for bound_tv *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   369
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   370
goal thy "!!t. bound_tv (mk_scheme t) = {}";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   371
by (typ.induct_tac "t" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   372
by (ALLGOALS Asm_simp_tac);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   373
qed "bound_tv_mk_scheme";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   374
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   375
Addsimps [bound_tv_mk_scheme];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   376
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   377
goal thy "!!sch::type_scheme. bound_tv ($ S sch) = bound_tv sch";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   378
by (type_scheme.induct_tac "sch" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   379
by (ALLGOALS Asm_simp_tac);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   380
qed "bound_tv_subst_scheme";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   381
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   382
Addsimps [bound_tv_subst_scheme];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   383
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   384
goal thy "!!A::type_scheme list. bound_tv ($ S A) = bound_tv A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   385
by (rtac list.induct 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   386
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   387
by (Asm_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   388
qed "bound_tv_subst_scheme_list";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   389
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   390
Addsimps [bound_tv_subst_scheme_list];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   391
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   392
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   393
(* lemmata for new_tv *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   394
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   395
goalw thy [new_tv_def]
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   396
  "new_tv n S = ((!m. n <= m --> (S m = TVar m)) & \
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   397
\                (! l. l < n --> new_tv n (S l) ))";
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   398
by (safe_tac HOL_cs );
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   399
(* ==> *)
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   400
by (fast_tac (HOL_cs addDs [leD] addss (!simpset addsimps [free_tv_subst,dom_def])) 1);
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   401
by (subgoal_tac "m:cod S | S l = TVar l" 1);
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   402
by (safe_tac HOL_cs );
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   403
by (fast_tac (HOL_cs addDs [UnI2] addss (!simpset addsimps [free_tv_subst])) 1);
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   404
by (dres_inst_tac [("P","%x. m:free_tv x")] subst 1 THEN atac 1);
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   405
by (Asm_full_simp_tac 1);
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   406
by (fast_tac (set_cs addss (!simpset addsimps [free_tv_subst,cod_def,dom_def])) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   407
(* <== *)
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   408
by (rewrite_goals_tac [free_tv_subst,cod_def,dom_def] );
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   409
by (safe_tac set_cs );
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   410
by (cut_inst_tac [("m","m"),("n","n")] less_linear 1);
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   411
by (fast_tac (HOL_cs addSIs [less_or_eq_imp_le]) 1);
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   412
by (cut_inst_tac [("m","ma"),("n","n")] less_linear 1);
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   413
by (fast_tac (HOL_cs addSIs [less_or_eq_imp_le]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   414
qed "new_tv_subst";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   415
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   416
goal thy 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   417
  "new_tv n  = list_all (new_tv n)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   418
by (rtac ext 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   419
by (list.induct_tac "x" 1);
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   420
by (ALLGOALS Asm_simp_tac);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   421
qed "new_tv_list";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   422
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   423
(* substitution affects only variables occurring freely *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   424
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   425
  "new_tv n (t::typ) --> $(%x. if x=n then t' else S x) t = $S t";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   426
by (typ.induct_tac "t" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   427
by (ALLGOALS(asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   428
qed "subst_te_new_tv";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   429
Addsimps [subst_te_new_tv];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   430
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   431
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   432
  "new_tv n (sch::type_scheme) --> $(%x. if x=n then sch' else S x) sch = $S sch";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   433
by (type_scheme.induct_tac "sch" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   434
by (ALLGOALS(asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   435
qed_spec_mp "subst_te_new_type_scheme";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   436
Addsimps [subst_te_new_type_scheme];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   437
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   438
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   439
  "new_tv n (A::type_scheme list) --> $(%x. if x=n then t else S x) A = $S A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   440
by (list.induct_tac "A" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   441
by (ALLGOALS Asm_full_simp_tac);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   442
qed_spec_mp "subst_tel_new_scheme_list";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   443
Addsimps [subst_tel_new_scheme_list];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   444
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   445
(* all greater variables are also new *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   446
goalw thy [new_tv_def] 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   447
  "!!n m. n<=m ==> new_tv n t ==> new_tv m t";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   448
by (safe_tac (!claset));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   449
by (dtac spec 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   450
by (mp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   451
by (trans_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   452
qed "new_tv_le";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   453
Addsimps [lessI RS less_imp_le RS new_tv_le];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   454
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   455
goal thy "!!n m. n<=m ==> new_tv n (t::typ) ==> new_tv m t";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   456
by (asm_simp_tac (!simpset addsimps [new_tv_le]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   457
qed "new_tv_typ_le";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   458
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   459
goal thy "!!n m. n<=m ==> new_tv n (A::type_scheme list) ==> new_tv m A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   460
by (asm_simp_tac (!simpset addsimps [new_tv_le]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   461
qed "new_scheme_list_le";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   462
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   463
goal thy "!!n m. n<=m ==> new_tv n (S::subst) ==> new_tv m S";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   464
by (asm_simp_tac (!simpset addsimps [new_tv_le]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   465
qed "new_tv_subst_le";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   466
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   467
(* new_tv property remains if a substitution is applied *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   468
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   469
  "!!n. [| n<m; new_tv m (S::subst) |] ==> new_tv m (S n)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   470
by (asm_full_simp_tac (!simpset addsimps [new_tv_subst]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   471
qed "new_tv_subst_var";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   472
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   473
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   474
  "new_tv n S --> new_tv n (t::typ) --> new_tv n ($ S t)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   475
by (typ.induct_tac "t" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   476
by (ALLGOALS(fast_tac (HOL_cs addss (!simpset addsimps [new_tv_subst]))));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   477
qed_spec_mp "new_tv_subst_te";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   478
Addsimps [new_tv_subst_te];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   479
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   480
goal thy "new_tv n S --> new_tv n (sch::type_scheme) --> new_tv n ($ S sch)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   481
by (type_scheme.induct_tac "sch" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   482
by (ALLGOALS (Asm_full_simp_tac));
3008
0a887d5b6718 Ran expandshort
paulson
parents: 2625
diff changeset
   483
by (rewtac new_tv_def);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   484
by (simp_tac (!simpset addsimps [free_tv_subst,dom_def,cod_def]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   485
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   486
by (case_tac "S nat = TVar nat" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   487
by (rotate_tac 3 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   488
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   489
by (dres_inst_tac [("x","m")] spec 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   490
by (Fast_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   491
qed_spec_mp "new_tv_subst_type_scheme";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   492
Addsimps [new_tv_subst_type_scheme];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   493
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   494
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   495
  "new_tv n S --> new_tv n (A::type_scheme list) --> new_tv n ($ S A)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   496
by (list.induct_tac "A" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   497
by (ALLGOALS(fast_tac (HOL_cs addss (!simpset))));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   498
qed_spec_mp "new_tv_subst_scheme_list";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   499
Addsimps [new_tv_subst_scheme_list];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   500
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   501
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   502
  "new_tv n A --> new_tv (Suc n) ((TVar n)#A)";
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   503
by (simp_tac (!simpset addsimps [new_tv_list]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   504
by (list.induct_tac "A" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   505
by (ALLGOALS Asm_full_simp_tac);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   506
qed "new_tv_Suc_list";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   507
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   508
goalw thy [new_tv_def] "!!sch::type_scheme. (free_tv sch) = (free_tv sch') --> (new_tv n sch --> new_tv n sch')";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   509
by (Asm_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   510
qed_spec_mp "new_tv_only_depends_on_free_tv_type_scheme";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   511
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   512
goalw thy [new_tv_def] "!!A::type_scheme list. (free_tv A) = (free_tv A') --> (new_tv n A --> new_tv n A')";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   513
by (Asm_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   514
qed_spec_mp "new_tv_only_depends_on_free_tv_scheme_list";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   515
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   516
goalw thy [new_tv_def] "!!A. !nat. nat < length A --> new_tv n A --> (new_tv n (nth nat A))";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   517
by (list.induct_tac "A" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   518
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   519
by (rtac allI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   520
by (res_inst_tac [("n","nat")] nat_induct 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   521
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   522
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   523
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   524
qed_spec_mp "new_tv_nth_nat_A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   526
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   527
(* composition of substitutions preserves new_tv proposition *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   528
goal thy 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   529
     "!! n. [| new_tv n (S::subst); new_tv n R |] ==> \
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   530
\           new_tv n (($ R) o S)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   531
by (asm_full_simp_tac (!simpset addsimps [new_tv_subst]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   532
qed "new_tv_subst_comp_1";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   533
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   534
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   535
     "!! n. [| new_tv n (S::subst); new_tv n R |] ==>  \ 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   536
\     new_tv n (%v.$ R (S v))";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   537
by (asm_full_simp_tac (!simpset addsimps [new_tv_subst]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   538
qed "new_tv_subst_comp_2";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   539
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   540
Addsimps [new_tv_subst_comp_1,new_tv_subst_comp_2];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   541
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   542
(* new type variables do not occur freely in a type structure *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   543
goalw thy [new_tv_def] 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   544
      "!!n. new_tv n A ==> n~:(free_tv A)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   545
by (fast_tac (HOL_cs addEs [less_irrefl]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   546
qed "new_tv_not_free_tv";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   547
Addsimps [new_tv_not_free_tv];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   548
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   549
goalw thy [max_def] "!!n::nat. m < n ==> m < max n n'";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   550
by (simp_tac (!simpset setloop (split_tac [expand_if])) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   551
by (safe_tac (!claset));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   552
by (trans_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   553
qed "less_maxL";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   554
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   555
goalw thy [max_def] "!!n::nat. m < n' ==> m < max n n'";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   556
by (simp_tac (!simpset setloop (split_tac [expand_if])) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   557
by (fast_tac (!claset addDs [not_leE] addIs [less_trans]) 1);
2625
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   558
val less_maxR = result();
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   559
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   560
goalw thy [new_tv_def] "!!t::typ. ? n. (new_tv n t)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   561
by (typ.induct_tac "t" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   562
by (res_inst_tac [("x","Suc nat")] exI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   563
by (Asm_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   564
by (REPEAT (etac exE 1));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   565
by (rename_tac "n'" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   566
by (res_inst_tac [("x","max n n'")] exI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   567
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   568
by (fast_tac (!claset addIs [less_maxR,less_maxL]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   569
qed "fresh_variable_types";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   570
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   571
Addsimps [fresh_variable_types];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   572
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   573
goalw thy [new_tv_def] "!!sch::type_scheme. ? n. (new_tv n sch)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   574
by (type_scheme.induct_tac "sch" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   575
by (res_inst_tac [("x","Suc nat")] exI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   576
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   577
by (res_inst_tac [("x","Suc nat")] exI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   578
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   579
by (REPEAT (etac exE 1));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   580
by (rename_tac "n'" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   581
by (res_inst_tac [("x","max n n'")] exI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   582
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   583
by (fast_tac (!claset addIs [less_maxR,less_maxL]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   584
qed "fresh_variable_type_schemes";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   585
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   586
Addsimps [fresh_variable_type_schemes];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   587
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   588
goalw thy [max_def] "!!n::nat. n <= (max n n')";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   589
by (simp_tac (!simpset setloop (split_tac [expand_if])) 1);
2625
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   590
val le_maxL = result();
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   591
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   592
goalw thy [max_def] "!!n'::nat. n' <= (max n n')";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   593
by (simp_tac (!simpset setloop (split_tac [expand_if])) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   594
by (fast_tac (!claset addDs [not_leE] addIs [less_or_eq_imp_le]) 1);
2625
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   595
val le_maxR = result();
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   596
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   597
goal thy "!!A::type_scheme list. ? n. (new_tv n A)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   598
by (list.induct_tac "A" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   599
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   600
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   601
by (etac exE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   602
by (cut_inst_tac [("sch","a")] fresh_variable_type_schemes 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   603
by (etac exE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   604
by (rename_tac "n'" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   605
by (res_inst_tac [("x","(max n n')")] exI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   606
by (subgoal_tac "n <= (max n n')" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   607
by (subgoal_tac "n' <= (max n n')" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   608
by (fast_tac (!claset addDs [new_tv_le]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   609
by (ALLGOALS (simp_tac (!simpset addsimps [le_maxR,le_maxL])));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   610
qed "fresh_variable_type_scheme_lists";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   611
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   612
Addsimps [fresh_variable_type_scheme_lists];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   613
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   614
goal thy "!!x y. [| ? n1. (new_tv n1 x); ? n2. (new_tv n2 y)|] ==> ? n. (new_tv n x) & (new_tv n y)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   615
by (REPEAT (etac exE 1));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   616
by (rename_tac "n1 n2" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   617
by (res_inst_tac [("x","(max n1 n2)")] exI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   618
by (subgoal_tac "n1 <= max n1 n2" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   619
by (subgoal_tac "n2 <= max n1 n2" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   620
by (fast_tac (!claset addDs [new_tv_le]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   621
by (ALLGOALS (simp_tac (!simpset addsimps [le_maxL,le_maxR])));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   622
qed "make_one_new_out_of_two";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   623
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   624
goal thy "!!(A::type_scheme list) (A'::type_scheme list) (t::typ) (t'::typ). \
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   625
\         ? n. (new_tv n A) & (new_tv n A') & (new_tv n t) & (new_tv n t')" ;
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   626
by (cut_inst_tac [("t","t")] fresh_variable_types 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   627
by (cut_inst_tac [("t","t'")] fresh_variable_types 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   628
by (dtac make_one_new_out_of_two 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   629
by (assume_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   630
by (thin_tac "? n. new_tv n t'" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   631
by (cut_inst_tac [("A","A")] fresh_variable_type_scheme_lists 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   632
by (cut_inst_tac [("A","A'")] fresh_variable_type_scheme_lists 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   633
by (rotate_tac 1 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   634
by (dtac make_one_new_out_of_two 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   635
by (assume_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   636
by (thin_tac "? n. new_tv n A'" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   637
by (REPEAT (etac exE 1));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   638
by (rename_tac "n2 n1" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   639
by (res_inst_tac [("x","(max n1 n2)")] exI 1);
3008
0a887d5b6718 Ran expandshort
paulson
parents: 2625
diff changeset
   640
by (rewtac new_tv_def);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   641
by (fast_tac (!claset addIs [less_maxL,less_maxR]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   642
qed "ex_fresh_variable";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   643
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   644
(* mgu does not introduce new type variables *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   645
goalw thy [new_tv_def] 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   646
      "!! n. [|mgu t1 t2 = Some u; new_tv n t1; new_tv n t2|] ==> \
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   647
\            new_tv n u";
3385
f59e64fe4058 New statement and proof of free_tv_subst_var in order to cope with new
paulson
parents: 3018
diff changeset
   648
by (fast_tac (set_cs addDs [mgu_free]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   649
qed "mgu_new";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   650
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   651
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   652
(* lemmata for substitutions *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   653
3438
8d63ff01d37e Type constraint added to ensure that "length" refers to lists. Maybe should
paulson
parents: 3385
diff changeset
   654
goalw Type.thy [app_subst_list] 
8d63ff01d37e Type constraint added to ensure that "length" refers to lists. Maybe should
paulson
parents: 3385
diff changeset
   655
   "!!A:: ('a::type_struct) list. length ($ S A) = length A";
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   656
by (Simp_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   657
qed "length_app_subst_list";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   658
Addsimps [length_app_subst_list];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   659
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   660
goal thy "!!sch::type_scheme. $ TVar sch = sch";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   661
by (type_scheme.induct_tac "sch" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   662
by (ALLGOALS Asm_simp_tac);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   663
qed "subst_TVar_scheme";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   664
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   665
Addsimps [subst_TVar_scheme];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   666
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   667
goal thy "!!A::type_scheme list. $ TVar A = A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   668
by (rtac list.induct 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   669
by (ALLGOALS (asm_full_simp_tac (!simpset addsimps [app_subst_list])));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   670
qed "subst_TVar_scheme_list";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   671
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   672
Addsimps [subst_TVar_scheme_list];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   673
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   674
(* application of id_subst does not change type expression *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   675
goalw thy [id_subst_def]
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   676
  "$ id_subst = (%t::typ.t)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   677
by (rtac ext 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   678
by (typ.induct_tac "t" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   679
by (ALLGOALS Asm_simp_tac);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   680
qed "app_subst_id_te";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   681
Addsimps [app_subst_id_te];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   682
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   683
goalw thy [id_subst_def]
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   684
  "$ id_subst = (%sch::type_scheme.sch)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   685
by (rtac ext 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   686
by (type_scheme.induct_tac "t" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   687
by (ALLGOALS Asm_simp_tac);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   688
qed "app_subst_id_type_scheme";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   689
Addsimps [app_subst_id_type_scheme];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   690
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   691
(* application of id_subst does not change list of type expressions *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   692
goalw thy [app_subst_list]
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   693
  "$ id_subst = (%A::type_scheme list.A)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   694
by (rtac ext 1); 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   695
by (list.induct_tac "A" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   696
by (ALLGOALS Asm_simp_tac);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   697
qed "app_subst_id_tel";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   698
Addsimps [app_subst_id_tel];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   699
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   700
goal thy "!!sch::type_scheme. $ id_subst sch = sch";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   701
by (type_scheme.induct_tac "sch" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   702
by (ALLGOALS (asm_full_simp_tac (!simpset addsimps [id_subst_def])));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   703
qed "id_subst_sch";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   704
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   705
Addsimps [id_subst_sch];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   706
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   707
goal thy "!!A::type_scheme list. $ id_subst A = A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   708
by (list.induct_tac "A" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   709
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   710
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   711
qed "id_subst_A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   712
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   713
Addsimps [id_subst_A];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   714
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   715
(* composition of substitutions *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   716
goalw Type.thy [id_subst_def,o_def] "$S o id_subst = S";
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   717
by (rtac ext 1);
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   718
by (Simp_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   719
qed "o_id_subst";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   720
Addsimps[o_id_subst];
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   721
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   722
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   723
  "$ R ($ S t::typ) = $ (%x. $ R (S x) ) t";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   724
by (typ.induct_tac "t" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   725
by (ALLGOALS Asm_simp_tac);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   726
qed "subst_comp_te";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   727
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   728
goal thy
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   729
  "$ R ($ S sch::type_scheme) = $ (%x. $ R (S x) ) sch";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   730
by (type_scheme.induct_tac "sch" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   731
by (ALLGOALS Asm_full_simp_tac);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   732
qed "subst_comp_type_scheme";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   733
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   734
goalw thy [app_subst_list]
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   735
  "$ R ($ S A::type_scheme list) = $ (%x. $ R (S x)) A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   736
by (list.induct_tac "A" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   737
(* case [] *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   738
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   739
(* case x#xl *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   740
by (asm_full_simp_tac (!simpset addsimps [subst_comp_type_scheme]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   741
qed "subst_comp_scheme_list";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   742
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   743
goal thy "!!A::type_scheme list. !x : free_tv A. S x = (TVar x) ==> $ S A = $ id_subst A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   744
by (rtac scheme_list_substitutions_only_on_free_variables 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   745
by (asm_full_simp_tac (!simpset addsimps [id_subst_def]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   746
qed "subst_id_on_type_scheme_list'";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   747
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   748
goal thy "!!A::type_scheme list. !x : free_tv A. S x = (TVar x) ==> $ S A = A";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   749
by (stac subst_id_on_type_scheme_list' 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   750
by (assume_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   751
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   752
qed "subst_id_on_type_scheme_list";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   753
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   754
goal thy "!!n. !n. n < length A --> nth n ($ S A) = $S (nth n A)";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   755
by (list.induct_tac "A" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   756
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   757
by (rtac allI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   758
by (rename_tac "n1" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   759
by (res_inst_tac[("n","n1")] nat_induct 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   760
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   761
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   762
qed_spec_mp "nth_subst";