src/HOL/MiniML/W.ML
author berghofe
Fri, 24 Jul 1998 13:19:38 +0200
changeset 5184 9b8547a9496a
parent 5118 6b995dad8a9d
child 5348 5f6416d64a94
permissions -rw-r--r--
Adapted to new datatype package.
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
(* Title:     HOL/MiniML/W.ML
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     2
   ID:        $Id$
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     3
   Author:    Dieter Nazareth and Tobias Nipkow
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     4
   Copyright  1995 TU Muenchen
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     5
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     6
Correctness and completeness of type inference algorithm W
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     7
*)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     8
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
     9
open W;
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    10
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    11
Addsimps [diff_add_inverse,diff_add_inverse2,Suc_le_lessD];
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    12
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    13
val has_type_casesE = map(has_type.mk_cases expr.simps)
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    14
        [" A |- Var n :: t"," A |- Abs e :: t","A |- App e1 e2 ::t","A |- LET e1 e2 ::t" ];
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    15
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    16
(* the resulting type variable is always greater or equal than the given one *)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4727
diff changeset
    17
Goal
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    18
        "!A n S t m. W e A n  = Some (S,t,m) --> n<=m";
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 5118
diff changeset
    19
by (induct_tac "e" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    20
(* case Var(n) *)
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4502
diff changeset
    21
by (simp_tac (simpset() addsplits [split_option_bind]) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    22
(* case Abs e *)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
    23
by (simp_tac (simpset() addsplits [split_option_bind]) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    24
by (fast_tac (HOL_cs addDs [Suc_leD]) 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    25
(* case App e1 e2 *)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
    26
by (simp_tac (simpset() addsplits [split_option_bind]) 1);
4423
a129b817b58a expandshort;
wenzelm
parents: 4369
diff changeset
    27
by (blast_tac (claset() addIs [le_SucI,le_trans]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    28
(* case LET e1 e2 *)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
    29
by (simp_tac (simpset() addsplits [split_option_bind]) 1);
4423
a129b817b58a expandshort;
wenzelm
parents: 4369
diff changeset
    30
by (blast_tac (claset() addIs [le_trans]) 1);
1486
7b95d7b49f7a Introduced qed_spec_mp.
nipkow
parents: 1465
diff changeset
    31
qed_spec_mp "W_var_ge";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    32
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    33
Addsimps [W_var_ge];
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    34
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4727
diff changeset
    35
Goal
5118
6b995dad8a9d Removed leading !! in goals.
nipkow
parents: 5069
diff changeset
    36
        "Some (S,t,m) = W e A n ==> n<=m";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
    37
by (asm_full_simp_tac (simpset() addsimps [eq_sym_conv]) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    38
qed "W_var_geD";
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    39
5118
6b995dad8a9d Removed leading !! in goals.
nipkow
parents: 5069
diff changeset
    40
Goal "new_tv n A ==> Some (S,t,m) = W e A n ==> new_tv m A";
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    41
by (dtac W_var_geD 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    42
by (rtac new_scheme_list_le 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
    43
by (assume_tac 1);
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
    44
by (assume_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    45
qed "new_tv_compatible_W";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    46
5118
6b995dad8a9d Removed leading !! in goals.
nipkow
parents: 5069
diff changeset
    47
Goal "new_tv n sch --> new_tv (n + (min_new_bound_tv sch)) (bound_typ_inst (%b. TVar (b + n)) sch)";
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 5118
diff changeset
    48
by (induct_tac "sch" 1);
4727
b820f57a2323 Mod because of new simplifier.
nipkow
parents: 4686
diff changeset
    49
  by (Asm_full_simp_tac 1);
b820f57a2323 Mod because of new simplifier.
nipkow
parents: 4686
diff changeset
    50
 by (asm_full_simp_tac (simpset() addsimps [add_commute]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    51
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    52
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    53
by (etac conjE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    54
by (rtac conjI 1);
4727
b820f57a2323 Mod because of new simplifier.
nipkow
parents: 4686
diff changeset
    55
 by (rtac new_tv_le 1);
b820f57a2323 Mod because of new simplifier.
nipkow
parents: 4686
diff changeset
    56
  by (assume_tac 2);
b820f57a2323 Mod because of new simplifier.
nipkow
parents: 4686
diff changeset
    57
 by (rtac add_le_mono 1);
b820f57a2323 Mod because of new simplifier.
nipkow
parents: 4686
diff changeset
    58
  by (Simp_tac 1);
b820f57a2323 Mod because of new simplifier.
nipkow
parents: 4686
diff changeset
    59
 by (simp_tac (simpset() addsimps [max_def]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    60
by (rtac new_tv_le 1);
4727
b820f57a2323 Mod because of new simplifier.
nipkow
parents: 4686
diff changeset
    61
 by (assume_tac 2);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    62
by (rtac add_le_mono 1);
4727
b820f57a2323 Mod because of new simplifier.
nipkow
parents: 4686
diff changeset
    63
 by (Simp_tac 1);
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4502
diff changeset
    64
by (simp_tac (simpset() addsimps [max_def]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    65
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    66
by (dtac not_leE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    67
by (rtac less_or_eq_imp_le 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    68
by (Fast_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    69
qed_spec_mp "new_tv_bound_typ_inst_sch";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    70
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    71
Addsimps [new_tv_bound_typ_inst_sch];
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    72
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    73
(* resulting type variable is new *)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4727
diff changeset
    74
Goal
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    75
     "!n A S t m. new_tv n A --> W e A n = Some (S,t,m) -->    \
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    76
\                 new_tv m S & new_tv m t";
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 5118
diff changeset
    77
by (induct_tac "e" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    78
(* case Var n *)
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4502
diff changeset
    79
by (simp_tac (simpset() addsplits [split_option_bind]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    80
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    81
by (dtac new_tv_nth_nat_A 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
    82
by (assume_tac 1);
4033
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
    83
by (Asm_simp_tac 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    84
(* case Abs e *)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
    85
by (simp_tac (simpset() addsimps [new_tv_subst,new_tv_Suc_list] 
4072
d0d32dd77440 expand_option_bind -> split_option_bind
nipkow
parents: 4033
diff changeset
    86
    addsplits [split_option_bind]) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    87
by (strip_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    88
by (eres_inst_tac [("x","Suc n")] allE 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    89
by (eres_inst_tac [("x","(FVar n)#A")] allE 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
    90
by (fast_tac (HOL_cs addss (simpset()
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
    91
              addsimps [new_tv_subst,new_tv_Suc_list])) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    92
(* case App e1 e2 *)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
    93
by (simp_tac (simpset() addsplits [split_option_bind]) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    94
by (strip_tac 1);
4033
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
    95
by (rename_tac "S1 t1 n1 S2 t2 n2 S3" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
    96
by (eres_inst_tac [("x","n")] allE 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
    97
by (eres_inst_tac [("x","A")] allE 1);
4033
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
    98
by (eres_inst_tac [("x","S1")] allE 1);
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
    99
by (eres_inst_tac [("x","t1")] allE 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   100
by (eres_inst_tac [("x","n1")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   101
by (eres_inst_tac [("x","n1")] allE 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   102
by (asm_full_simp_tac (simpset() addsimps [eq_sym_conv] delsimps all_simps) 1);
4033
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
   103
by (eres_inst_tac [("x","$S1 A")] allE 1);
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
   104
by (eres_inst_tac [("x","S2")] allE 1);
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
   105
by (eres_inst_tac [("x","t2")] allE 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   106
by (eres_inst_tac [("x","n2")] allE 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   107
by ( asm_full_simp_tac (simpset() addsimps [o_def,rotate_Some]) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   108
by (rtac conjI 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   109
by (rtac new_tv_subst_comp_2 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   110
by (rtac new_tv_subst_comp_2 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   111
by (rtac (lessI RS less_imp_le RS new_tv_le) 1); 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   112
by (res_inst_tac [("n","n1")] new_tv_subst_le 1); 
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   113
by (asm_full_simp_tac (simpset() addsimps [rotate_Some]) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   114
by (Asm_simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   115
by (fast_tac (HOL_cs addDs [W_var_geD] addIs
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   116
     [new_scheme_list_le,new_tv_subst_scheme_list,lessI RS less_imp_le RS new_tv_subst_le])
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   117
    1);
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   118
by (etac (sym RS mgu_new) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   119
by (best_tac (HOL_cs addDs [W_var_geD] addIs [new_tv_subst_te,new_scheme_list_le,
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   120
   new_tv_subst_scheme_list,lessI RS less_imp_le RS new_tv_le,lessI RS less_imp_le RS 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   121
   new_tv_subst_le,new_tv_le]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   122
by (fast_tac (HOL_cs addDs [W_var_geD] addIs
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   123
     [new_scheme_list_le,new_tv_subst_scheme_list,new_tv_le] 
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   124
        addss (simpset())) 1);
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   125
by (rtac (lessI RS new_tv_subst_var) 1);
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   126
by (etac (sym RS mgu_new) 1);
1925
1150f128c7fe Some tidying. This brittle proof depends upon
paulson
parents: 1910
diff changeset
   127
by (best_tac (HOL_cs addSIs [lessI RS less_imp_le RS new_tv_le,new_tv_subst_te]
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   128
   addDs [W_var_geD] addIs
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   129
   [new_scheme_list_le,new_tv_subst_scheme_list,lessI RS less_imp_le RS
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   130
   new_tv_subst_le,new_tv_le] addss simpset()) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   131
by (fast_tac (HOL_cs addDs [W_var_geD] addIs
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   132
     [new_scheme_list_le,new_tv_subst_scheme_list,new_tv_le]
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   133
     addss (simpset())) 1);
4033
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
   134
(* 41: case LET e1 e2 *)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   135
by (simp_tac (simpset() addsplits [split_option_bind]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   136
by (strip_tac 1);
4423
a129b817b58a expandshort;
wenzelm
parents: 4369
diff changeset
   137
by (EVERY1[etac allE,etac allE,etac allE,etac allE,etac allE,mp_tac,mp_tac]);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   138
by (etac conjE 1);
4423
a129b817b58a expandshort;
wenzelm
parents: 4369
diff changeset
   139
by (EVERY[etac allE 1,etac allE 1,etac allE 1,etac allE 1,etac allE 1,
4033
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
   140
         etac impE 1, mp_tac 2]);
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
   141
by (SELECT_GOAL(rewtac new_tv_def)1);
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
   142
by (Asm_simp_tac 1);
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
   143
by (REPEAT(dtac W_var_ge 1));
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
   144
by (rtac allI 1);
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
   145
by (strip_tac 1);
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
   146
by (SELECT_GOAL(rewtac free_tv_subst) 1);
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
   147
by (dtac (free_tv_app_subst_scheme_list RS subsetD) 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   148
by (best_tac (claset() addEs [less_le_trans]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   149
by (etac conjE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   150
by (rtac conjI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   151
by (rtac new_tv_subst_comp_2 1);
4033
43ec35b5054d Updated proofs
nipkow
parents: 3919
diff changeset
   152
by (etac (W_var_ge RS new_tv_subst_le) 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   153
by (assume_tac 1);
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   154
by (assume_tac 1);
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   155
by (assume_tac 1);
1486
7b95d7b49f7a Introduced qed_spec_mp.
nipkow
parents: 1465
diff changeset
   156
qed_spec_mp "new_tv_W";
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   157
5118
6b995dad8a9d Removed leading !! in goals.
nipkow
parents: 5069
diff changeset
   158
Goal "(v ~: free_tv sch) --> (v : free_tv (bound_typ_inst (TVar o S) sch)) --> (? x. v = S x)";
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 5118
diff changeset
   159
by (induct_tac "sch" 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   160
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   161
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   162
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   163
by (rtac exI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   164
by (rtac refl 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   165
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   166
qed_spec_mp "free_tv_bound_typ_inst1";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   167
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   168
Addsimps [free_tv_bound_typ_inst1];
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   169
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4727
diff changeset
   170
Goal
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   171
     "!n A S t m v. W e A n = Some (S,t,m) -->            \
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   172
\         (v:free_tv S | v:free_tv t) --> v<n --> v:free_tv A";
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 5118
diff changeset
   173
by (induct_tac "e" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   174
(* case Var n *)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   175
by (simp_tac (simpset() addsimps
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4502
diff changeset
   176
    [free_tv_subst] addsplits [split_option_bind]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   177
by (strip_tac 1);
4502
337c073de95e nth -> !
nipkow
parents: 4423
diff changeset
   178
by (case_tac "v : free_tv (A!nat)" 1);
2525
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
by (dtac free_tv_bound_typ_inst1 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   181
by (simp_tac (simpset() addsimps [o_def]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   182
by (etac exE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   183
by (rotate_tac 3 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   184
by (Asm_full_simp_tac 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   185
(* case Abs e *)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   186
by (asm_full_simp_tac (simpset() addsimps
4072
d0d32dd77440 expand_option_bind -> split_option_bind
nipkow
parents: 4033
diff changeset
   187
    [free_tv_subst] addsplits [split_option_bind] delsimps all_simps) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   188
by (strip_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   189
by (rename_tac "S t n1 S1 t1 m v" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   190
by (eres_inst_tac [("x","Suc n")] allE 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   191
by (eres_inst_tac [("x","FVar n # A")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   192
by (eres_inst_tac [("x","S")] allE 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   193
by (eres_inst_tac [("x","t")] allE 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   194
by (eres_inst_tac [("x","n1")] allE 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   195
by (eres_inst_tac [("x","v")] allE 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   196
by (best_tac (HOL_cs addIs [cod_app_subst]
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   197
                     addss (simpset() addsimps [less_Suc_eq])) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   198
(* case App e1 e2 *)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   199
by (simp_tac (simpset() addsplits [split_option_bind] delsimps all_simps) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   200
by (strip_tac 1); 
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   201
by (rename_tac "S t n1 S1 t1 n2 S2 S3 t2 m v" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   202
by (eres_inst_tac [("x","n")] allE 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   203
by (eres_inst_tac [("x","A")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   204
by (eres_inst_tac [("x","S")] allE 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   205
by (eres_inst_tac [("x","t")] allE 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   206
by (eres_inst_tac [("x","n1")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   207
by (eres_inst_tac [("x","n1")] allE 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   208
by (eres_inst_tac [("x","v")] allE 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   209
(* second case *)
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   210
by (eres_inst_tac [("x","$ S A")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   211
by (eres_inst_tac [("x","S1")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   212
by (eres_inst_tac [("x","t1")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   213
by (eres_inst_tac [("x","n2")] allE 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   214
by (eres_inst_tac [("x","v")] allE 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   215
by (safe_tac (empty_cs addSIs [conjI,impI] addSEs [conjE]) ); 
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   216
by (asm_full_simp_tac (simpset() addsimps [rotate_Some,o_def]) 1);
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   217
by (dtac W_var_geD 1);
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   218
by (dtac W_var_geD 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   219
by ( (forward_tac [less_le_trans] 1) THEN (assume_tac 1) );
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   220
by (fast_tac (HOL_cs addDs [free_tv_comp_subst RS subsetD,sym RS mgu_free, 
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   221
    codD,free_tv_app_subst_te RS subsetD,free_tv_app_subst_scheme_list RS subsetD,
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   222
    less_le_trans,less_not_refl2,subsetD]
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   223
  addEs [UnE] 
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   224
  addss simpset()) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   225
by (Asm_full_simp_tac 1); 
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   226
by (dtac (sym RS W_var_geD) 1);
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   227
by (dtac (sym RS W_var_geD) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   228
by ( (forward_tac [less_le_trans] 1) THEN (assume_tac 1) );
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   229
by (fast_tac (HOL_cs addDs [mgu_free, codD,free_tv_subst_var RS subsetD,
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   230
    free_tv_app_subst_te RS subsetD,free_tv_app_subst_scheme_list RS subsetD,
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   231
    less_le_trans,subsetD]
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   232
  addEs [UnE]
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   233
  addss simpset()) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   234
(* LET e1 e2 *)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   235
by (simp_tac (simpset() addsplits [split_option_bind] delsimps all_simps) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   236
by (strip_tac 1); 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   237
by (rename_tac "nat A S1 t1 n2 S2 t2 m2 S t m v" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   238
by (eres_inst_tac [("x","nat")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   239
by (eres_inst_tac [("x","A")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   240
by (eres_inst_tac [("x","S1")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   241
by (eres_inst_tac [("x","t1")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   242
by (rotate_tac 1 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   243
by (eres_inst_tac [("x","n2")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   244
by (rotate_tac 4 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   245
by (eres_inst_tac [("x","v")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   246
by (mp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   247
by (EVERY1 [etac allE,etac allE,etac allE,etac allE,etac allE,eres_inst_tac [("x","v")] allE]);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   248
by (mp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   249
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   250
by (rtac conjI 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   251
by (fast_tac (claset() addSDs [codD,free_tv_app_subst_scheme_list RS subsetD,free_tv_o_subst RS subsetD,W_var_ge] 
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   252
              addDs [less_le_trans]) 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   253
by (fast_tac (claset() addSDs [codD,free_tv_app_subst_scheme_list RS subsetD,W_var_ge] 
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   254
              addDs [less_le_trans]) 1);
1486
7b95d7b49f7a Introduced qed_spec_mp.
nipkow
parents: 1465
diff changeset
   255
qed_spec_mp "free_tv_W"; 
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   256
5118
6b995dad8a9d Removed leading !! in goals.
nipkow
parents: 5069
diff changeset
   257
Goal "(!x. x : A --> x ~: B) ==> A Int B = {}";
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   258
by (Fast_tac 1);
2625
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   259
val weaken_A_Int_B_eq_empty = result();
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   260
5118
6b995dad8a9d Removed leading !! in goals.
nipkow
parents: 5069
diff changeset
   261
Goal "x ~: A | x : B ==> x ~: A - B";
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   262
by (Fast_tac 1);
2625
69c1b8a493de Some lemmas changed to valuesd
narasche
parents: 2525
diff changeset
   263
val weaken_not_elem_A_minus_B = result();
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   264
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   265
(* correctness of W with respect to has_type *)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4727
diff changeset
   266
Goal
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   267
        "!A S t m n . new_tv n A --> Some (S,t,m) = W e A n --> $S A |- e :: t";
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 5118
diff changeset
   268
by (induct_tac "e" 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   269
(* case Var n *)
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4502
diff changeset
   270
by (Asm_full_simp_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   271
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   272
by (rtac has_type.VarI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   273
by (Simp_tac 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   274
by (simp_tac (simpset() addsimps [is_bound_typ_instance]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   275
by (rtac exI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   276
by (rtac refl 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   277
(* case Abs e *)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   278
by (asm_full_simp_tac (simpset() addsimps [app_subst_list]
4072
d0d32dd77440 expand_option_bind -> split_option_bind
nipkow
parents: 4033
diff changeset
   279
                        addsplits [split_option_bind]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   280
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   281
by (eres_inst_tac [("x","(mk_scheme (TVar n)) # A")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   282
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   283
by (rtac has_type.AbsI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   284
by (dtac (le_refl RS le_SucI RS new_scheme_list_le) 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   285
by (dtac sym 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   286
by (REPEAT (etac allE 1));
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   287
by (etac impE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   288
by (mp_tac 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   289
by (Asm_simp_tac 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   290
by (assume_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   291
(* case App e1 e2 *)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   292
by (simp_tac (simpset() addsplits [split_option_bind]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   293
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   294
by (rename_tac "S1 t1 n1 S2 t2 n2 S3" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   295
by (res_inst_tac [("t2.0","$ S3 t2")] has_type.AppI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   296
by (res_inst_tac [("S1","S3")] (app_subst_TVar RS subst) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   297
by (rtac (app_subst_Fun RS subst) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   298
by (res_inst_tac [("t","$S3 (t2 -> (TVar n2))"),("s","$S3 ($S2 t1)")] subst 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   299
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   300
by (simp_tac (HOL_ss addsimps [subst_comp_scheme_list RS sym]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   301
by ((rtac (has_type_cl_sub RS spec) 1) THEN (rtac (has_type_cl_sub RS spec) 1));
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   302
by (asm_full_simp_tac (simpset() addsimps [eq_sym_conv]) 1);
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   303
by (asm_full_simp_tac (simpset() addsimps [subst_comp_scheme_list RS sym,o_def,has_type_cl_sub,eq_sym_conv]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   304
by (rtac (has_type_cl_sub RS spec) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   305
by (forward_tac [new_tv_W] 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   306
by (assume_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   307
by (dtac conjunct1 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   308
by (dtac conjunct1 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   309
by (forward_tac [new_tv_subst_scheme_list] 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   310
by (rtac new_scheme_list_le 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   311
by (rtac W_var_ge 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   312
by (assume_tac 1);
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   313
by (assume_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   314
by (etac thin_rl 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   315
by (REPEAT (etac allE 1));
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   316
by (dtac sym 1);
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   317
by (dtac sym 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   318
by (etac thin_rl 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   319
by (etac thin_rl 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   320
by (mp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   321
by (mp_tac 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   322
by (assume_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   323
(* case Let e1 e2 *)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   324
by (simp_tac (simpset() addsplits [split_option_bind]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   325
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   326
by (rename_tac "w q m1 S1 t1 m2 S2 t n2" 1); 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   327
by (res_inst_tac [("t1.0","$ S2 t1")] has_type.LETI 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   328
by (simp_tac (simpset() addsimps [o_def]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   329
by (simp_tac (HOL_ss addsimps [subst_comp_scheme_list RS sym]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   330
by (rtac (has_type_cl_sub RS spec) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   331
by (dres_inst_tac [("x","A")] spec 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   332
by (dres_inst_tac [("x","S1")] spec 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   333
by (dres_inst_tac [("x","t1")] spec 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   334
by (dres_inst_tac [("x","m2")] spec 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   335
by (rotate_tac 4 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   336
by (dres_inst_tac [("x","m1")] spec 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   337
by (mp_tac 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   338
by (asm_full_simp_tac (simpset() addsimps [eq_sym_conv]) 1);
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   339
by (simp_tac (simpset() addsimps [o_def]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   340
by (simp_tac (HOL_ss addsimps [subst_comp_scheme_list RS sym]) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   341
by (rtac (gen_subst_commutes RS sym RS subst) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   342
by (rtac (app_subst_Cons RS subst) 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   343
by (etac thin_rl 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   344
by (dres_inst_tac [("x","gen ($S1 A) t1 # $ S1 A")] spec 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   345
by (dres_inst_tac [("x","S2")] spec 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   346
by (dres_inst_tac [("x","t")] spec 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   347
by (dres_inst_tac [("x","n2")] spec 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   348
by (dres_inst_tac [("x","m2")] spec 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   349
by (forward_tac [new_tv_W] 2);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   350
by (assume_tac 2);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   351
by (dtac conjunct1 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   352
by (dtac conjunct1 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   353
by (forward_tac [new_tv_subst_scheme_list] 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   354
by (rtac new_scheme_list_le 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   355
by (rtac W_var_ge 2);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   356
by (assume_tac 2);
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   357
by (assume_tac 2);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   358
by (etac impE 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   359
by (res_inst_tac [("A","$ S1 A")] new_tv_only_depends_on_free_tv_scheme_list 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   360
by (Simp_tac 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   361
by (Fast_tac 2);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   362
by (assume_tac 2);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   363
by (Asm_full_simp_tac 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   364
by (rtac weaken_A_Int_B_eq_empty 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   365
by (rtac allI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   366
by (strip_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   367
by (rtac weaken_not_elem_A_minus_B 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   368
by (case_tac "x < m2" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   369
by (rtac disjI2 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   370
by (rtac (free_tv_gen_cons RS subst) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   371
by (rtac free_tv_W 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   372
by (assume_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   373
by (Asm_full_simp_tac 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   374
by (assume_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   375
by (rtac disjI1 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   376
by (dtac new_tv_W 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   377
by (assume_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   378
by (dtac conjunct2 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   379
by (dtac conjunct2 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   380
by (rtac new_tv_not_free_tv 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   381
by (rtac new_tv_le 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   382
by (assume_tac 2);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   383
by (asm_full_simp_tac (simpset() addsimps [not_less_iff_le]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   384
qed_spec_mp "W_correct_lemma";
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   385
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   386
(* Completeness of W w.r.t. has_type *)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4727
diff changeset
   387
Goal
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   388
 "!S' A t' n. $S' A |- e :: t' --> new_tv n A -->     \
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   389
\             (? S t. (? m. W e A n = Some (S,t,m)) &  \
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   390
\                     (? R. $S' A = $R ($S A) & t' = $R t))";
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 5118
diff changeset
   391
by (induct_tac "e" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   392
(* case Var n *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   393
by (strip_tac 1);
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4502
diff changeset
   394
by (simp_tac (simpset() addcongs [conj_cong]) 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   395
by (eresolve_tac has_type_casesE 1); 
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   396
by (asm_full_simp_tac (simpset() addsimps [is_bound_typ_instance]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   397
by (etac exE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   398
by (hyp_subst_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   399
by (rename_tac "S" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   400
by (res_inst_tac [("x","%x. (if x < n then S' x else S (x - n))")] exI 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   401
by (rtac conjI 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   402
by (Asm_simp_tac 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   403
by (asm_simp_tac (simpset() addsimps [(bound_typ_inst_composed_subst RS sym),new_tv_nth_nat_A,o_def,nth_subst] 
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   404
                           delsimps [bound_typ_inst_composed_subst]) 1);
2749
2f477a0e690d Deleted steps made redundant by the stronger eq_assume_tac
paulson
parents: 2637
diff changeset
   405
(** LEVEL 12 **)
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   406
(* case Abs e *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   407
by (strip_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   408
by (eresolve_tac has_type_casesE 1);
3842
b55686a7b22c fixed dots;
wenzelm
parents: 3240
diff changeset
   409
by (eres_inst_tac [("x","%x. if x=n then t1 else (S' x)")] allE 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   410
by (eres_inst_tac [("x","(FVar n)#A")] allE 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   411
by (eres_inst_tac [("x","t2")] allE 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   412
by (eres_inst_tac [("x","Suc n")] allE 1);
2749
2f477a0e690d Deleted steps made redundant by the stronger eq_assume_tac
paulson
parents: 2637
diff changeset
   413
by (best_tac (HOL_cs addSDs [mk_scheme_injective] 
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   414
                  addss (simpset() addcongs [conj_cong] 
4072
d0d32dd77440 expand_option_bind -> split_option_bind
nipkow
parents: 4033
diff changeset
   415
                                addsplits [split_option_bind])) 1);
2749
2f477a0e690d Deleted steps made redundant by the stronger eq_assume_tac
paulson
parents: 2637
diff changeset
   416
(** LEVEL 19 **)
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   417
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   418
(* case App e1 e2 *)
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   419
by (strip_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   420
by (eresolve_tac has_type_casesE 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   421
by (eres_inst_tac [("x","S'")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   422
by (eres_inst_tac [("x","A")] allE 1);
1400
5d909faf0e04 Introduced Monad syntax Pat := Val; Cont
nipkow
parents: 1300
diff changeset
   423
by (eres_inst_tac [("x","t2 -> t'")] allE 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   424
by (eres_inst_tac [("x","n")] allE 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   425
by (safe_tac HOL_cs);
2749
2f477a0e690d Deleted steps made redundant by the stronger eq_assume_tac
paulson
parents: 2637
diff changeset
   426
(** LEVEL 26 **)
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   427
by (eres_inst_tac [("x","R")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   428
by (eres_inst_tac [("x","$ S A")] allE 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   429
by (eres_inst_tac [("x","t2")] allE 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   430
by (eres_inst_tac [("x","m")] allE 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   431
by (Asm_full_simp_tac 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   432
by (safe_tac HOL_cs);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   433
by (fast_tac (HOL_cs addIs [sym RS W_var_geD,new_tv_W RS
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   434
        conjunct1,new_scheme_list_le,new_tv_subst_scheme_list]) 1);
2779
9c42ae57b5f4 The contr_tac, which replaces a fast_tac, is needed only because eq_assume_tac
paulson
parents: 2749
diff changeset
   435
(** LEVEL 35 **)
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   436
by (subgoal_tac
3842
b55686a7b22c fixed dots;
wenzelm
parents: 3240
diff changeset
   437
  "$ (%x. if x=ma then t' else (if x:(free_tv t - free_tv Sa) then R x \
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   438
\        else Ra x)) ($ Sa t) = \
3842
b55686a7b22c fixed dots;
wenzelm
parents: 3240
diff changeset
   439
\  $ (%x. if x=ma then t' else (if x:(free_tv t - free_tv Sa) then R x \
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   440
\        else Ra x)) (ta -> (TVar ma))" 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   441
by (res_inst_tac [("t","$ (%x. if x = ma then t' else \
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   442
\   (if x:(free_tv t - free_tv Sa) then R x else Ra x)) ($ Sa t)"),
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   443
    ("s","($ Ra ta) -> t'")] ssubst 2);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   444
by (asm_simp_tac (simpset() addsimps [subst_comp_te]) 2);
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   445
by (rtac eq_free_eq_subst_te 2);  
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   446
by (strip_tac 2);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   447
by (subgoal_tac "na ~=ma" 2);
2749
2f477a0e690d Deleted steps made redundant by the stronger eq_assume_tac
paulson
parents: 2637
diff changeset
   448
by (best_tac (HOL_cs addDs [new_tv_W,sym RS W_var_geD,
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   449
    new_tv_not_free_tv,new_tv_le]) 3);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   450
by (case_tac "na:free_tv Sa" 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   451
(* n1 ~: free_tv S1 *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   452
by (forward_tac [not_free_impl_id] 3);
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4502
diff changeset
   453
by (Asm_simp_tac 3);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   454
(* na : free_tv Sa *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   455
by (dres_inst_tac [("A1","$ S A")] (subst_comp_scheme_list RSN (2,trans)) 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   456
by (dtac eq_subst_scheme_list_eq_free 2);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   457
by (fast_tac (HOL_cs addIs [free_tv_W,free_tv_le_new_tv] addDs [new_tv_W]) 2);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   458
by (Asm_simp_tac 2); 
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   459
by (case_tac "na:dom Sa" 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   460
(* na ~: dom Sa *)
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4502
diff changeset
   461
by (asm_full_simp_tac (simpset() addsimps [dom_def]) 3);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   462
(* na : dom Sa *)
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   463
by (rtac eq_free_eq_subst_te 2);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   464
by (strip_tac 2);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   465
by (subgoal_tac "nb ~= ma" 2);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   466
by ((forward_tac [new_tv_W] 3) THEN (atac 3));
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   467
by (etac conjE 3);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   468
by (dtac new_tv_subst_scheme_list 3);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   469
by (fast_tac (HOL_cs addIs [new_scheme_list_le] addDs [sym RS W_var_geD]) 3);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   470
by (fast_tac (set_cs addDs [new_tv_W,new_tv_not_free_tv] addss 
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   471
    (simpset() addsimps [cod_def,free_tv_subst])) 3);
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4502
diff changeset
   472
by (fast_tac (set_cs addss (simpset() addsimps [cod_def,free_tv_subst])) 2);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   473
by (Simp_tac 2);  
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   474
by (rtac eq_free_eq_subst_te 2);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   475
by (strip_tac 2 );
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   476
by (subgoal_tac "na ~= ma" 2);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   477
by ((forward_tac [new_tv_W] 3) THEN (atac 3));
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   478
by (etac conjE 3);
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   479
by (dtac (sym RS W_var_geD) 3);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   480
by (fast_tac (HOL_cs addDs [new_scheme_list_le,new_tv_subst_scheme_list,new_tv_W,new_tv_not_free_tv]) 3);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   481
by (case_tac "na: free_tv t - free_tv Sa" 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   482
(* case na ~: free_tv t - free_tv Sa *)
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4502
diff changeset
   483
by (Asm_full_simp_tac 3);
2793
b30c41754c86 Modified proofs because simplifier does not eta-contract any longer.
nipkow
parents: 2779
diff changeset
   484
by (Fast_tac 3);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   485
(* case na : free_tv t - free_tv Sa *)
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4502
diff changeset
   486
by (Asm_full_simp_tac 2);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   487
by (dres_inst_tac [("A1","$ S A")] (subst_comp_scheme_list RSN (2,trans)) 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   488
by (dtac eq_subst_scheme_list_eq_free 2);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   489
by (fast_tac (HOL_cs addIs [free_tv_W,free_tv_le_new_tv] addDs [new_tv_W]) 2);
2793
b30c41754c86 Modified proofs because simplifier does not eta-contract any longer.
nipkow
parents: 2779
diff changeset
   490
(** LEVEL 75 **)
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   491
by (asm_full_simp_tac (simpset() addsimps [free_tv_subst,dom_def]) 2);
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   492
by (asm_simp_tac (simpset() addsplits [split_option_bind]) 1); 
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   493
by (safe_tac HOL_cs );
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   494
by (dtac mgu_Some 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   495
by ( fast_tac (HOL_cs addss simpset()) 1);
2793
b30c41754c86 Modified proofs because simplifier does not eta-contract any longer.
nipkow
parents: 2779
diff changeset
   496
(** LEVEL 80 *)
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   497
by ((dtac mgu_mg 1) THEN (atac 1));
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   498
by (etac exE 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   499
by (res_inst_tac [("x","Rb")] exI 1);
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   500
by (rtac conjI 1);
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   501
by (dres_inst_tac [("x","ma")] fun_cong 2);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   502
by ( asm_full_simp_tac (simpset() addsimps [eq_sym_conv]) 2);
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   503
by (simp_tac (simpset() addsimps [subst_comp_scheme_list]) 1);
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   504
by (simp_tac (simpset() addsimps [subst_comp_scheme_list RS sym]) 1);
2793
b30c41754c86 Modified proofs because simplifier does not eta-contract any longer.
nipkow
parents: 2779
diff changeset
   505
by (res_inst_tac [("A2","($ Sa ($ S A))")]
b30c41754c86 Modified proofs because simplifier does not eta-contract any longer.
nipkow
parents: 2779
diff changeset
   506
       ((subst_comp_scheme_list RS sym) RSN (2,trans)) 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   507
by ( asm_full_simp_tac (simpset() addsimps [o_def,eq_sym_conv]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   508
by (rtac eq_free_eq_subst_scheme_list 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   509
by ( safe_tac HOL_cs );
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   510
by (subgoal_tac "ma ~= na" 1);
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   511
by ((forward_tac [new_tv_W] 2) THEN (atac 2));
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   512
by (etac conjE 2);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   513
by (dtac new_tv_subst_scheme_list 2);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   514
by (fast_tac (HOL_cs addIs [new_scheme_list_le] addDs [sym RS W_var_geD]) 2);
2793
b30c41754c86 Modified proofs because simplifier does not eta-contract any longer.
nipkow
parents: 2779
diff changeset
   515
by (forw_inst_tac [("n","m")] new_tv_W 2  THEN  atac 2);
1465
5d7a7e439cec expanded tabs
clasohm
parents: 1400
diff changeset
   516
by (etac conjE 2);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   517
by (dtac (free_tv_app_subst_scheme_list RS subsetD) 2);
2793
b30c41754c86 Modified proofs because simplifier does not eta-contract any longer.
nipkow
parents: 2779
diff changeset
   518
by (fast_tac (set_cs addDs [sym RS W_var_geD,new_scheme_list_le,codD,
1300
c7a8f374339b New theory: type inference for let-free MiniML
nipkow
parents:
diff changeset
   519
    new_tv_not_free_tv]) 2);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   520
by (case_tac "na: free_tv t - free_tv Sa" 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   521
(* case na ~: free_tv t - free_tv Sa *)
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4502
diff changeset
   522
by (Asm_full_simp_tac 2);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   523
(* case na : free_tv t - free_tv Sa *)
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4502
diff changeset
   524
by (Asm_full_simp_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   525
by (dtac (free_tv_app_subst_scheme_list RS subsetD) 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   526
by (fast_tac (set_cs addDs [codD,subst_comp_scheme_list RSN (2,trans),
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   527
    eq_subst_scheme_list_eq_free] addss ((simpset() addsimps 
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   528
    [free_tv_subst,dom_def]))) 1);
2083
b56425a385b9 Tidied some proofs: changed needed for de Morgan laws
paulson
parents: 2058
diff changeset
   529
by (Fast_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   530
(* case Let e1 e2 *)
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   531
by (eresolve_tac has_type_casesE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   532
by (eres_inst_tac [("x","S'")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   533
by (eres_inst_tac [("x","A")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   534
by (eres_inst_tac [("x","t1")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   535
by (eres_inst_tac [("x","n")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   536
by (mp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   537
by (mp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   538
by (safe_tac HOL_cs);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   539
by (Asm_simp_tac 1); 
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   540
by (eres_inst_tac [("x","R")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   541
by (eres_inst_tac [("x","gen ($ S A) t # $ S A")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   542
by (eres_inst_tac [("x","t'")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   543
by (eres_inst_tac [("x","m")] allE 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   544
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   545
by (dtac mp 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   546
by (rtac has_type_le_env 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   547
by (assume_tac 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   548
by (Simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   549
by (rtac gen_bound_typ_instance 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   550
by (dtac mp 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   551
by (forward_tac [new_tv_compatible_W] 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   552
by (rtac sym 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   553
by (assume_tac 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   554
by (fast_tac (claset() addDs [new_tv_compatible_gen,new_tv_subst_scheme_list,new_tv_W]) 1);
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   555
by (safe_tac HOL_cs);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   556
by (Asm_full_simp_tac 1);
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   557
by (res_inst_tac [("x","Ra")] exI 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 4072
diff changeset
   558
by (simp_tac (simpset() addsimps [o_def,subst_comp_scheme_list RS sym]) 1);
1525
d127436567d0 modified priorities in syntax
nipkow
parents: 1486
diff changeset
   559
qed_spec_mp "W_complete_lemma";
d127436567d0 modified priorities in syntax
nipkow
parents: 1486
diff changeset
   560
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4727
diff changeset
   561
Goal
5118
6b995dad8a9d Removed leading !! in goals.
nipkow
parents: 5069
diff changeset
   562
 "[] |- e :: t' ==>  (? S t. (? m. W e [] n = Some(S,t,m)) &  \
2525
477c05586286 The new version of MiniML including "let".
nipkow
parents: 2513
diff changeset
   563
\                                 (? R. t' = $ R t))";
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   564
by (cut_inst_tac [("A","[]"),("S'","id_subst"),("e","e"),("t'","t'")]
1525
d127436567d0 modified priorities in syntax
nipkow
parents: 1486
diff changeset
   565
                W_complete_lemma 1);
3018
e65b60b28341 Ran expandshort
paulson
parents: 3008
diff changeset
   566
by (ALLGOALS Asm_full_simp_tac);
1525
d127436567d0 modified priorities in syntax
nipkow
parents: 1486
diff changeset
   567
qed "W_complete";