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