src/HOL/MiniML/Type.ML
author nipkow
Fri, 17 Jan 1997 18:32:24 +0100
changeset 2523 0ccea141409b
parent 2513 d708d8cdc8e8
child 2525 477c05586286
permissions -rw-r--r--
Updated documentation pointers.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     1
open Type;
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     2
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     3
Addsimps [mgu_eq,mgu_mg,mgu_free];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     4
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     5
(* mgu does not introduce new type variables *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     6
goalw thy [new_tv_def] 
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     7
      "!! n. [|mgu t1 t2 = Ok u; new_tv n t1; new_tv n t2|] ==> \
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     8
\            new_tv n u";
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
     9
by (fast_tac (set_cs addDs [mgu_free]) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    10
qed "mgu_new";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    11
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    12
(* application of id_subst does not change type expression *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    13
goalw thy [id_subst_def]
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
    14
  "$ id_subst = (%t::typ.t)";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    15
by (rtac ext 1);
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
    16
by (typ.induct_tac "t" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    17
by (ALLGOALS Asm_simp_tac);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    18
qed "app_subst_id_te";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    19
Addsimps [app_subst_id_te];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    20
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    21
(* application of id_subst does not change list of type expressions *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    22
goalw thy [app_subst_list]
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
    23
  "$ id_subst = (%ts::typ list.ts)";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    24
by (rtac ext 1); 
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
    25
by (list.induct_tac "ts" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    26
by (ALLGOALS Asm_simp_tac);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    27
qed "app_subst_id_tel";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    28
Addsimps [app_subst_id_tel];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    29
1751
946efd210837 Added thm I_complete_wrt_W to I.
nipkow
parents: 1619
diff changeset
    30
goalw Type.thy [id_subst_def,o_def] "$s o id_subst = s";
2031
03a843f0f447 Ran expandshort
paulson
parents: 1901
diff changeset
    31
by (rtac ext 1);
03a843f0f447 Ran expandshort
paulson
parents: 1901
diff changeset
    32
by (Simp_tac 1);
1751
946efd210837 Added thm I_complete_wrt_W to I.
nipkow
parents: 1619
diff changeset
    33
qed "o_id_subst";
946efd210837 Added thm I_complete_wrt_W to I.
nipkow
parents: 1619
diff changeset
    34
Addsimps[o_id_subst];
946efd210837 Added thm I_complete_wrt_W to I.
nipkow
parents: 1619
diff changeset
    35
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    36
goalw thy [dom_def,id_subst_def,empty_def]
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    37
  "dom id_subst = {}";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    38
by (Simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    39
qed "dom_id_subst";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    40
Addsimps [dom_id_subst];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    41
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    42
goalw thy [cod_def]
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    43
  "cod id_subst = {}";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    44
by (Simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    45
qed "cod_id_subst";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    46
Addsimps [cod_id_subst];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    47
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    48
goalw thy [free_tv_subst]
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    49
  "free_tv id_subst = {}";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    50
by (Simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    51
qed "free_tv_id_subst";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    52
Addsimps [free_tv_id_subst];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    53
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    54
goalw thy [dom_def,cod_def,UNION_def,Bex_def]
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    55
  "!!v. [| v : free_tv(s n); v~=n |] ==> v : cod s";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    56
by (Simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    57
by (safe_tac (empty_cs addSIs [exI,conjI,notI]));
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
    58
by (assume_tac 2);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    59
by (rotate_tac 1 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    60
by (Asm_full_simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    61
qed "cod_app_subst";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    62
Addsimps [cod_app_subst];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    63
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    64
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    65
(* composition of substitutions *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    66
goal thy
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
    67
  "$ g ($ f t::typ) = $ (%x. $ g (f x) ) t";
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
    68
by (typ.induct_tac "t" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    69
by (ALLGOALS Asm_simp_tac);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    70
qed "subst_comp_te";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    71
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    72
goalw thy [app_subst_list]
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
    73
  "$ g ($ f ts::typ list) = $ (%x. $ g (f x)) ts";
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
    74
by (list.induct_tac "ts" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    75
(* case [] *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    76
by (Simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    77
(* case x#xl *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    78
by (asm_full_simp_tac (!simpset addsimps [subst_comp_te]) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    79
qed "subst_comp_tel";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    80
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    81
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    82
(* constructor laws for app_subst *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    83
goalw thy [app_subst_list]
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    84
  "$ s [] = []";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    85
by (Simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    86
qed "app_subst_Nil";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    87
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    88
goalw thy [app_subst_list]
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
    89
  "$ s (t#ts) = ($ s t)#($ s ts)";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    90
by (Simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    91
qed "app_subst_Cons";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    92
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    93
Addsimps [app_subst_Nil,app_subst_Cons];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    94
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    95
(* constructor laws for new_tv *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    96
goalw thy [new_tv_def]
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    97
  "new_tv n (TVar m) = (m<n)";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    98
by (fast_tac (HOL_cs addss !simpset) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    99
qed "new_tv_TVar";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   100
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   101
goalw thy [new_tv_def]
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   102
  "new_tv n (t1 -> t2) = (new_tv n t1 & new_tv n t2)";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   103
by (fast_tac (HOL_cs addss !simpset) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   104
qed "new_tv_Fun";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   105
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   106
goalw thy [new_tv_def]
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   107
  "new_tv n []";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   108
by (Simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   109
qed "new_tv_Nil";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   110
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   111
goalw thy [new_tv_def]
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   112
  "new_tv n (t#ts) = (new_tv n t & new_tv n ts)";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   113
by (fast_tac (HOL_cs addss !simpset) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   114
qed "new_tv_Cons";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   115
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   116
Addsimps [new_tv_TVar,new_tv_Fun,new_tv_Nil,new_tv_Cons];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   117
1751
946efd210837 Added thm I_complete_wrt_W to I.
nipkow
parents: 1619
diff changeset
   118
goalw Type.thy [id_subst_def,new_tv_def,free_tv_subst,dom_def,cod_def]
946efd210837 Added thm I_complete_wrt_W to I.
nipkow
parents: 1619
diff changeset
   119
  "new_tv n id_subst";
2031
03a843f0f447 Ran expandshort
paulson
parents: 1901
diff changeset
   120
by (Simp_tac 1);
1751
946efd210837 Added thm I_complete_wrt_W to I.
nipkow
parents: 1619
diff changeset
   121
qed "new_tv_id_subst";
946efd210837 Added thm I_complete_wrt_W to I.
nipkow
parents: 1619
diff changeset
   122
Addsimps[new_tv_id_subst];
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   123
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   124
goalw thy [new_tv_def]
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   125
  "new_tv n s = ((!m. n <= m --> (s m = TVar m)) & \
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   126
\                (! l. l < n --> new_tv n (s l) ))";
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   127
by (safe_tac HOL_cs );
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   128
(* ==> *)
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   129
by (fast_tac (HOL_cs addDs [leD] addss (!simpset addsimps [free_tv_subst,dom_def])) 1);
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   130
by (subgoal_tac "m:cod s | s l = TVar l" 1);
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   131
by (safe_tac HOL_cs );
2031
03a843f0f447 Ran expandshort
paulson
parents: 1901
diff changeset
   132
by (fast_tac (HOL_cs addDs [UnI2] addss (!simpset addsimps [free_tv_subst])) 1);
03a843f0f447 Ran expandshort
paulson
parents: 1901
diff changeset
   133
by (dres_inst_tac [("P","%x. m:free_tv x")] subst 1 THEN atac 1);
03a843f0f447 Ran expandshort
paulson
parents: 1901
diff changeset
   134
by (Asm_full_simp_tac 1);
03a843f0f447 Ran expandshort
paulson
parents: 1901
diff changeset
   135
by (fast_tac (set_cs addss (!simpset addsimps [free_tv_subst,cod_def,dom_def])) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   136
(* <== *)
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   137
by (rewrite_goals_tac [free_tv_subst,cod_def,dom_def] );
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   138
by (safe_tac set_cs );
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   139
by (cut_inst_tac [("m","m"),("n","n")] less_linear 1);
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   140
by (fast_tac (HOL_cs addSIs [less_or_eq_imp_le]) 1);
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   141
by (cut_inst_tac [("m","ma"),("n","n")] less_linear 1);
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   142
by (fast_tac (HOL_cs addSIs [less_or_eq_imp_le]) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   143
qed "new_tv_subst";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   144
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   145
goal thy 
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   146
  "new_tv n  = list_all (new_tv n)";
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   147
by (rtac ext 1);
2031
03a843f0f447 Ran expandshort
paulson
parents: 1901
diff changeset
   148
by (list.induct_tac "x" 1);
03a843f0f447 Ran expandshort
paulson
parents: 1901
diff changeset
   149
by (ALLGOALS Asm_simp_tac);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   150
qed "new_tv_list";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   151
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   152
(* substitution affects only variables occurring freely *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   153
goal thy
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   154
  "new_tv n (t::typ) --> $(%x. if x=n then t' else s x) t = $s t";
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   155
by (typ.induct_tac "t" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   156
by (ALLGOALS(asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   157
qed "subst_te_new_tv";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   158
Addsimps [subst_te_new_tv];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   159
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   160
goal thy
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   161
  "new_tv n (ts::typ list) --> $(%x. if x=n then t else s x) ts = $s ts";
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   162
by (list.induct_tac "ts" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   163
by (ALLGOALS Asm_full_simp_tac);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   164
qed "subst_tel_new_tv";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   165
Addsimps [subst_tel_new_tv];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   166
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   167
(* all greater variables are also new *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   168
goal thy
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   169
  "n<=m --> new_tv n (t::typ) --> new_tv m t";
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   170
by (typ.induct_tac "t" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   171
(* case TVar n *)
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   172
by (fast_tac (HOL_cs addIs [less_le_trans] addss !simpset) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   173
(* case Fun t1 t2 *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   174
by (Asm_simp_tac 1);
1521
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   175
qed_spec_mp "new_tv_le";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   176
Addsimps [lessI RS less_imp_le RS new_tv_le];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   177
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   178
goal thy 
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   179
  "n<=m --> new_tv n (ts::typ list) --> new_tv m ts";
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   180
by (list.induct_tac "ts" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   181
(* case [] *)
2031
03a843f0f447 Ran expandshort
paulson
parents: 1901
diff changeset
   182
by (Simp_tac 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   183
(* case a#al *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   184
by (fast_tac (HOL_cs addIs [new_tv_le] addss !simpset) 1);
1521
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   185
qed_spec_mp "new_tv_list_le";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   186
Addsimps [lessI RS less_imp_le RS new_tv_list_le];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   187
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   188
goal thy
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   189
  "!! n. [| n<=m; new_tv n (s::subst) |] ==> new_tv m s";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   190
by (asm_full_simp_tac (!simpset addsimps [new_tv_subst]) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   191
by (rtac conjI 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   192
by (slow_tac (HOL_cs addIs [le_trans]) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   193
by (safe_tac HOL_cs );
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   194
by (res_inst_tac [("P","l < n"),("Q","n <= l")] disjE 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   195
by (fast_tac (HOL_cs addss (HOL_ss addsimps [le_def])) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   196
by (ALLGOALS (asm_full_simp_tac (!simpset addsimps [new_tv_le])) );
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   197
qed "new_tv_subst_le";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   198
Addsimps [lessI RS less_imp_le RS new_tv_subst_le];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   199
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   200
(* new_tv property remains if a substitution is applied *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   201
goal thy
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   202
  "!!n. [| n<m; new_tv m (s::subst) |] ==> new_tv m (s n)";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   203
by (asm_full_simp_tac (!simpset addsimps [new_tv_subst]) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   204
qed "new_tv_subst_var";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   205
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   206
goal thy
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   207
  "new_tv n s --> new_tv n (t::typ) --> new_tv n ($ s t)";
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   208
by (typ.induct_tac "t" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   209
by (ALLGOALS(fast_tac (HOL_cs addss (!simpset addsimps [new_tv_subst]))));
1521
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   210
qed_spec_mp "new_tv_subst_te";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   211
Addsimps [new_tv_subst_te];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   212
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   213
goal thy
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   214
  "new_tv n s --> new_tv n (ts::typ list) --> new_tv n ($ s ts)";
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   215
by (simp_tac (!simpset addsimps [new_tv_list]) 1);
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   216
by (list.induct_tac "ts" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   217
by (ALLGOALS(fast_tac (HOL_cs addss (!simpset addsimps [new_tv_subst]))));
1521
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   218
qed_spec_mp "new_tv_subst_tel";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   219
Addsimps [new_tv_subst_tel];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   220
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   221
(* auxilliary lemma *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   222
goal thy
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   223
  "new_tv n ts --> new_tv (Suc n) ((TVar n)#ts)";
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   224
by (simp_tac (!simpset addsimps [new_tv_list]) 1);
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   225
by (list.induct_tac "ts" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   226
by (ALLGOALS Asm_full_simp_tac);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   227
qed "new_tv_Suc_list";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   228
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   229
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   230
(* composition of substitutions preserves new_tv proposition *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   231
goal thy 
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   232
     "!! n. [| new_tv n (s::subst); new_tv n r |] ==> \
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   233
\           new_tv n (($ r) o s)";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   234
by (asm_full_simp_tac (!simpset addsimps [new_tv_subst]) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   235
qed "new_tv_subst_comp_1";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   236
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   237
goal thy
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   238
     "!! n. [| new_tv n (s::subst); new_tv n r |] ==>  \ 
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   239
\     new_tv n (%v.$ r (s v))";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   240
by (asm_full_simp_tac (!simpset addsimps [new_tv_subst]) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   241
qed "new_tv_subst_comp_2";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   242
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   243
Addsimps [new_tv_subst_comp_1,new_tv_subst_comp_2];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   244
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   245
(* new type variables do not occur freely in a type structure *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   246
goalw thy [new_tv_def] 
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   247
      "!!n. new_tv n ts ==> n~:(free_tv ts)";
1619
cb62d89b7adb Now use _irrefl instead of _anti_refl
paulson
parents: 1521
diff changeset
   248
by (fast_tac (HOL_cs addEs [less_irrefl]) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   249
qed "new_tv_not_free_tv";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   250
Addsimps [new_tv_not_free_tv];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   251
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   252
goal thy
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   253
  "(t::typ) mem ts --> free_tv t <= free_tv ts";
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   254
by (list.induct_tac "ts" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   255
(* case [] *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   256
by (Simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   257
(* case x#xl *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   258
by (fast_tac (set_cs addss (!simpset setloop (split_tac [expand_if]))) 1);
1521
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   259
qed_spec_mp "ftv_mem_sub_ftv_list";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   260
Addsimps [ftv_mem_sub_ftv_list];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   261
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   262
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   263
(* if two substitutions yield the same result if applied to a type
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   264
   structure the substitutions coincide on the free type variables
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   265
   occurring in the type structure *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   266
goal thy
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   267
  "$ s1 (t::typ) = $ s2 t --> n:(free_tv t) --> s1 n = s2 n";
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   268
by (typ.induct_tac "t" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   269
(* case TVar n *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   270
by (fast_tac (HOL_cs addss !simpset) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   271
(* case Fun t1 t2 *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   272
by (fast_tac (HOL_cs addss !simpset) 1);
1521
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   273
qed_spec_mp "eq_subst_te_eq_free";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   274
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   275
goal thy
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   276
  "(!n. n:(free_tv t) --> s1 n = s2 n) --> $ s1 (t::typ) = $ s2 t";
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   277
by (typ.induct_tac "t" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   278
(* case TVar n *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   279
by (fast_tac (HOL_cs addss !simpset) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   280
(* case Fun t1 t2 *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   281
by (fast_tac (HOL_cs addss !simpset) 1);
1521
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   282
qed_spec_mp "eq_free_eq_subst_te";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   283
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   284
goal thy
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   285
  "$s1 (ts::typ list) = $s2 ts --> n:(free_tv ts) --> s1 n = s2 n";
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   286
by (list.induct_tac "ts" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   287
(* case [] *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   288
by (fast_tac (HOL_cs addss !simpset) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   289
(* case x#xl *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   290
by (fast_tac (HOL_cs addIs [eq_subst_te_eq_free] addss (!simpset)) 1);
1521
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   291
qed_spec_mp "eq_subst_tel_eq_free";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   292
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   293
goal thy
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   294
  "(!n. n:(free_tv ts) --> s1 n = s2 n) --> $s1 (ts::typ list) = $s2 ts";
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   295
by (list.induct_tac "ts" 1); 
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   296
(* case [] *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   297
by (fast_tac (HOL_cs addss !simpset) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   298
(* case x#xl *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   299
by (fast_tac (HOL_cs addIs [eq_free_eq_subst_te] addss (!simpset)) 1);
1521
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   300
qed_spec_mp "eq_free_eq_subst_tel";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   301
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   302
(* some useful theorems *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   303
goalw thy [free_tv_subst] 
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   304
      "!!v. v : cod s ==> v : free_tv s";
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   305
by (fast_tac set_cs 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   306
qed "codD";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   307
 
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   308
goalw thy [free_tv_subst,dom_def] 
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   309
      "!! x. x ~: free_tv s ==> s x = TVar x";
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   310
by (fast_tac set_cs 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   311
qed "not_free_impl_id";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   312
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   313
goalw thy [new_tv_def] 
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   314
      "!! n. [| new_tv n t; m:free_tv t |] ==> m<n";
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   315
by (fast_tac HOL_cs 1 );
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   316
qed "free_tv_le_new_tv";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   317
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   318
goal thy 
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   319
     "free_tv (s (v::nat)) <= cod s Un {v}";
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   320
by (cut_inst_tac [("P","v:dom s")] excluded_middle 1);
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   321
by (safe_tac (HOL_cs addSIs [subsetI]) );
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   322
by (fast_tac (set_cs addss (!simpset addsimps [dom_def])) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   323
by (fast_tac (set_cs addss (!simpset addsimps [cod_def])) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   324
qed "free_tv_subst_var";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   325
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   326
goal thy 
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   327
     "free_tv ($ s (t::typ)) <= cod s Un free_tv t";
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   328
by (typ.induct_tac "t" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   329
(* case TVar n *)
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   330
by (simp_tac (!simpset addsimps [free_tv_subst_var]) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   331
(* case Fun t1 t2 *)
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   332
by (fast_tac (set_cs addss !simpset) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   333
qed "free_tv_app_subst_te";     
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   334
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   335
goal thy 
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   336
     "free_tv ($ s (ts::typ list)) <= cod s Un free_tv ts";
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   337
by (list.induct_tac "ts" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   338
(* case [] *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   339
by (Simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   340
(* case a#al *)
2513
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   341
by (cut_facts_tac [free_tv_app_subst_te] 1);
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   342
by (fast_tac (set_cs addss !simpset) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   343
qed "free_tv_app_subst_tel";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   344
1521
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   345
goalw thy [free_tv_subst,dom_def]
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   346
     "free_tv (%u::nat. $ s1 (s2 u) :: typ) <=   \
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   347
\     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
   348
by (fast_tac (set_cs addSDs [free_tv_app_subst_te RS subsetD,
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   349
			     free_tv_subst_var RS subsetD] 
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   350
	             addss (!simpset delsimps bex_simps
d708d8cdc8e8 New miniscoping rules for the bounded quantifiers and UN/INT operators
paulson
parents: 2031
diff changeset
   351
				     addsimps [cod_def,dom_def])) 1);
1521
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   352
qed "free_tv_comp_subst";
4ed3004ff75e used qed_spec_mp.
nipkow
parents: 1465
diff changeset
   353