src/HOL/ex/MT.ML
author wenzelm
Mon Nov 03 12:13:18 1997 +0100 (1997-11-03)
changeset 4089 96fba19bcbe2
parent 3842 b55686a7b22c
child 4153 e534c4c32d54
permissions -rw-r--r--
isatool fixclasimp;
clasohm@1465
     1
(*  Title:      HOL/ex/MT.ML
clasohm@969
     2
    ID:         $Id$
clasohm@1465
     3
    Author:     Jacob Frost, Cambridge University Computer Laboratory
clasohm@969
     4
    Copyright   1993  University of Cambridge
clasohm@969
     5
clasohm@969
     6
Based upon the article
clasohm@969
     7
    Robin Milner and Mads Tofte,
clasohm@969
     8
    Co-induction in Relational Semantics,
clasohm@969
     9
    Theoretical Computer Science 87 (1991), pages 209-220.
clasohm@969
    10
clasohm@969
    11
Written up as
clasohm@969
    12
    Jacob Frost, A Case Study of Co-induction in Isabelle/HOL
clasohm@969
    13
    Report 308, Computer Lab, University of Cambridge (1993).
lcp@1047
    14
lcp@1047
    15
NEEDS TO USE INDUCTIVE DEFS PACKAGE
clasohm@969
    16
*)
clasohm@969
    17
clasohm@969
    18
open MT;
clasohm@969
    19
clasohm@969
    20
(* ############################################################ *)
clasohm@969
    21
(* Inference systems                                            *)
clasohm@969
    22
(* ############################################################ *)
clasohm@969
    23
paulson@2935
    24
val infsys_mono_tac = (REPEAT (ares_tac (basic_monos@[allI,impI]) 1));
clasohm@969
    25
clasohm@972
    26
val prems = goal MT.thy "P a b ==> P (fst (a,b)) (snd (a,b))";
wenzelm@4089
    27
by (simp_tac (simpset() addsimps prems) 1);
clasohm@969
    28
qed "infsys_p1";
clasohm@969
    29
lcp@1047
    30
val prems = goal MT.thy "!!a b. P (fst (a,b)) (snd (a,b)) ==> P a b";
clasohm@1266
    31
by (Asm_full_simp_tac 1);
clasohm@969
    32
qed "infsys_p2";
clasohm@969
    33
clasohm@969
    34
val prems = goal MT.thy 
lcp@1047
    35
 "!!a. P a b c ==> P (fst(fst((a,b),c))) (snd(fst ((a,b),c))) (snd ((a,b),c))";
clasohm@1266
    36
by (Asm_full_simp_tac 1);
clasohm@969
    37
qed "infsys_pp1";
clasohm@969
    38
clasohm@969
    39
val prems = goal MT.thy 
lcp@1047
    40
 "!!a. P (fst(fst((a,b),c))) (snd(fst((a,b),c))) (snd((a,b),c)) ==> P a b c";
clasohm@1266
    41
by (Asm_full_simp_tac 1);
clasohm@969
    42
qed "infsys_pp2";
clasohm@969
    43
clasohm@969
    44
(* ############################################################ *)
clasohm@969
    45
(* Fixpoints                                                    *)
clasohm@969
    46
(* ############################################################ *)
clasohm@969
    47
clasohm@969
    48
(* Least fixpoints *)
clasohm@969
    49
clasohm@969
    50
val prems = goal MT.thy "[| mono(f); x:f(lfp(f)) |] ==> x:lfp(f)";
clasohm@969
    51
by (rtac subsetD 1);
clasohm@969
    52
by (rtac lfp_lemma2 1);
lcp@1047
    53
by (resolve_tac prems 1);
lcp@1047
    54
by (resolve_tac prems 1);
clasohm@969
    55
qed "lfp_intro2";
clasohm@969
    56
clasohm@969
    57
val prems = goal MT.thy
clasohm@969
    58
  " [| x:lfp(f); mono(f); !!y. y:f(lfp(f)) ==> P(y) |] ==> \
clasohm@969
    59
\   P(x)";
clasohm@969
    60
by (cut_facts_tac prems 1);
lcp@1047
    61
by (resolve_tac prems 1);
lcp@1047
    62
by (rtac subsetD 1);
lcp@1047
    63
by (rtac lfp_lemma3 1);
lcp@1047
    64
by (assume_tac 1);
lcp@1047
    65
by (assume_tac 1);
clasohm@969
    66
qed "lfp_elim2";
clasohm@969
    67
clasohm@969
    68
val prems = goal MT.thy
wenzelm@3842
    69
  " [| x:lfp(f); mono(f); !!y. y:f(lfp(f) Int {x. P(x)}) ==> P(y) |] ==> \
clasohm@969
    70
\   P(x)";
clasohm@969
    71
by (cut_facts_tac prems 1);
lcp@1047
    72
by (etac induct 1);
lcp@1047
    73
by (assume_tac 1);
clasohm@969
    74
by (eresolve_tac prems 1);
clasohm@969
    75
qed "lfp_ind2";
clasohm@969
    76
clasohm@969
    77
(* Greatest fixpoints *)
clasohm@969
    78
clasohm@969
    79
(* Note : "[| x:S; S <= f(S Un gfp(f)); mono(f) |] ==> x:gfp(f)" *)
clasohm@969
    80
clasohm@969
    81
val [cih,monoh] = goal MT.thy "[| x:f({x} Un gfp(f)); mono(f) |] ==> x:gfp(f)";
clasohm@969
    82
by (rtac (cih RSN (2,gfp_upperbound RS subsetD)) 1);
clasohm@969
    83
by (rtac (monoh RS monoD) 1);
lcp@1047
    84
by (rtac (UnE RS subsetI) 1);
lcp@1047
    85
by (assume_tac 1);
wenzelm@4089
    86
by (blast_tac (claset() addSIs [cih]) 1);
clasohm@969
    87
by (rtac (monoh RS monoD RS subsetD) 1);
clasohm@969
    88
by (rtac Un_upper2 1);
clasohm@969
    89
by (etac (monoh RS gfp_lemma2 RS subsetD) 1);
clasohm@969
    90
qed "gfp_coind2";
clasohm@969
    91
clasohm@969
    92
val [gfph,monoh,caseh] = goal MT.thy 
clasohm@969
    93
  "[| x:gfp(f); mono(f); !! y. y:f(gfp(f)) ==> P(y) |] ==> P(x)";
lcp@1047
    94
by (rtac caseh 1);
lcp@1047
    95
by (rtac subsetD 1);
lcp@1047
    96
by (rtac gfp_lemma2 1);
lcp@1047
    97
by (rtac monoh 1);
lcp@1047
    98
by (rtac gfph 1);
clasohm@969
    99
qed "gfp_elim2";
clasohm@969
   100
clasohm@969
   101
(* ############################################################ *)
clasohm@969
   102
(* Expressions                                                  *)
clasohm@969
   103
(* ############################################################ *)
clasohm@969
   104
clasohm@969
   105
val e_injs = [e_const_inj, e_var_inj, e_fn_inj, e_fix_inj, e_app_inj];
clasohm@969
   106
clasohm@969
   107
val e_disjs = 
clasohm@969
   108
  [ e_disj_const_var, 
clasohm@969
   109
    e_disj_const_fn, 
clasohm@969
   110
    e_disj_const_fix, 
clasohm@969
   111
    e_disj_const_app,
clasohm@969
   112
    e_disj_var_fn, 
clasohm@969
   113
    e_disj_var_fix, 
clasohm@969
   114
    e_disj_var_app, 
clasohm@969
   115
    e_disj_fn_fix, 
clasohm@969
   116
    e_disj_fn_app, 
clasohm@969
   117
    e_disj_fix_app
clasohm@969
   118
  ];
clasohm@969
   119
clasohm@969
   120
val e_disj_si = e_disjs @ (e_disjs RL [not_sym]);
clasohm@969
   121
val e_disj_se = (e_disj_si RL [notE]);
clasohm@969
   122
clasohm@969
   123
fun e_ext_cs cs = cs addSIs e_disj_si addSEs e_disj_se addSDs e_injs;
clasohm@969
   124
clasohm@969
   125
(* ############################################################ *)
clasohm@969
   126
(* Values                                                      *)
clasohm@969
   127
(* ############################################################ *)
clasohm@969
   128
clasohm@969
   129
val v_disjs = [v_disj_const_clos];
clasohm@969
   130
val v_disj_si = v_disjs @ (v_disjs RL [not_sym]);
clasohm@969
   131
val v_disj_se = (v_disj_si RL [notE]);
clasohm@969
   132
clasohm@969
   133
val v_injs = [v_const_inj, v_clos_inj];
clasohm@969
   134
clasohm@969
   135
fun v_ext_cs cs  = cs addSIs v_disj_si addSEs v_disj_se addSDs v_injs;
clasohm@969
   136
clasohm@969
   137
(* ############################################################ *)
clasohm@969
   138
(* Evaluations                                                  *)
clasohm@969
   139
(* ############################################################ *)
clasohm@969
   140
clasohm@969
   141
(* Monotonicity of eval_fun *)
clasohm@969
   142
clasohm@969
   143
goalw MT.thy [mono_def, eval_fun_def] "mono(eval_fun)";
clasohm@969
   144
by infsys_mono_tac;
clasohm@969
   145
qed "eval_fun_mono";
clasohm@969
   146
clasohm@969
   147
(* Introduction rules *)
clasohm@969
   148
clasohm@969
   149
goalw MT.thy [eval_def, eval_rel_def] "ve |- e_const(c) ---> v_const(c)";
clasohm@969
   150
by (rtac lfp_intro2 1);
clasohm@969
   151
by (rtac eval_fun_mono 1);
clasohm@969
   152
by (rewtac eval_fun_def);
paulson@2935
   153
	(*Naughty!  But the quantifiers are nested VERY deeply...*)
wenzelm@4089
   154
by (blast_tac (claset() addSIs [exI]) 1);
clasohm@969
   155
qed "eval_const";
clasohm@969
   156
clasohm@969
   157
val prems = goalw MT.thy [eval_def, eval_rel_def] 
clasohm@969
   158
  "ev:ve_dom(ve) ==> ve |- e_var(ev) ---> ve_app ve ev";
clasohm@969
   159
by (cut_facts_tac prems 1);
clasohm@969
   160
by (rtac lfp_intro2 1);
clasohm@969
   161
by (rtac eval_fun_mono 1);
clasohm@969
   162
by (rewtac eval_fun_def);
wenzelm@4089
   163
by (blast_tac (claset() addSIs [exI]) 1);
clasohm@1266
   164
qed "eval_var2";
clasohm@969
   165
clasohm@969
   166
val prems = goalw MT.thy [eval_def, eval_rel_def] 
clasohm@969
   167
  "ve |- fn ev => e ---> v_clos(<|ev,e,ve|>)";
clasohm@969
   168
by (cut_facts_tac prems 1);
clasohm@969
   169
by (rtac lfp_intro2 1);
clasohm@969
   170
by (rtac eval_fun_mono 1);
clasohm@969
   171
by (rewtac eval_fun_def);
wenzelm@4089
   172
by (blast_tac (claset() addSIs [exI]) 1);
clasohm@969
   173
qed "eval_fn";
clasohm@969
   174
clasohm@969
   175
val prems = goalw MT.thy [eval_def, eval_rel_def] 
clasohm@969
   176
  " cl = <| ev1, e, ve + {ev2 |-> v_clos(cl)} |> ==> \
clasohm@969
   177
\   ve |- fix ev2(ev1) = e ---> v_clos(cl)";
clasohm@969
   178
by (cut_facts_tac prems 1);
clasohm@969
   179
by (rtac lfp_intro2 1);
clasohm@969
   180
by (rtac eval_fun_mono 1);
clasohm@969
   181
by (rewtac eval_fun_def);
wenzelm@4089
   182
by (blast_tac (claset() addSIs [exI]) 1);
clasohm@969
   183
qed "eval_fix";
clasohm@969
   184
clasohm@969
   185
val prems = goalw MT.thy [eval_def, eval_rel_def]
clasohm@969
   186
  " [| ve |- e1 ---> v_const(c1); ve |- e2 ---> v_const(c2) |] ==> \
clasohm@969
   187
\   ve |- e1 @ e2 ---> v_const(c_app c1 c2)";
clasohm@969
   188
by (cut_facts_tac prems 1);
clasohm@969
   189
by (rtac lfp_intro2 1);
clasohm@969
   190
by (rtac eval_fun_mono 1);
clasohm@969
   191
by (rewtac eval_fun_def);
wenzelm@4089
   192
by (blast_tac (claset() addSIs [exI]) 1);
clasohm@969
   193
qed "eval_app1";
clasohm@969
   194
clasohm@969
   195
val prems = goalw MT.thy [eval_def, eval_rel_def] 
clasohm@969
   196
  " [|  ve |- e1 ---> v_clos(<|xm,em,vem|>); \
clasohm@969
   197
\       ve |- e2 ---> v2; \
clasohm@969
   198
\       vem + {xm |-> v2} |- em ---> v \
clasohm@969
   199
\   |] ==> \
clasohm@969
   200
\   ve |- e1 @ e2 ---> v";
clasohm@969
   201
by (cut_facts_tac prems 1);
clasohm@969
   202
by (rtac lfp_intro2 1);
clasohm@969
   203
by (rtac eval_fun_mono 1);
clasohm@969
   204
by (rewtac eval_fun_def);
wenzelm@4089
   205
by (blast_tac (claset() addSIs [disjI2]) 1);
clasohm@969
   206
qed "eval_app2";
clasohm@969
   207
clasohm@969
   208
(* Strong elimination, induction on evaluations *)
clasohm@969
   209
clasohm@969
   210
val prems = goalw MT.thy [eval_def, eval_rel_def]
clasohm@969
   211
  " [| ve |- e ---> v; \
clasohm@972
   212
\      !!ve c. P(((ve,e_const(c)),v_const(c))); \
clasohm@972
   213
\      !!ev ve. ev:ve_dom(ve) ==> P(((ve,e_var(ev)),ve_app ve ev)); \
clasohm@972
   214
\      !!ev ve e. P(((ve,fn ev => e),v_clos(<|ev,e,ve|>))); \
clasohm@969
   215
\      !!ev1 ev2 ve cl e. \
clasohm@969
   216
\        cl = <| ev1, e, ve + {ev2 |-> v_clos(cl)} |> ==> \
clasohm@972
   217
\        P(((ve,fix ev2(ev1) = e),v_clos(cl))); \
clasohm@969
   218
\      !!ve c1 c2 e1 e2. \
clasohm@972
   219
\        [| P(((ve,e1),v_const(c1))); P(((ve,e2),v_const(c2))) |] ==> \
clasohm@972
   220
\        P(((ve,e1 @ e2),v_const(c_app c1 c2))); \
clasohm@969
   221
\      !!ve vem xm e1 e2 em v v2. \
clasohm@972
   222
\        [|  P(((ve,e1),v_clos(<|xm,em,vem|>))); \
clasohm@972
   223
\            P(((ve,e2),v2)); \
clasohm@972
   224
\            P(((vem + {xm |-> v2},em),v)) \
clasohm@969
   225
\        |] ==> \
clasohm@972
   226
\        P(((ve,e1 @ e2),v)) \
clasohm@969
   227
\   |] ==> \
clasohm@972
   228
\   P(((ve,e),v))";
clasohm@969
   229
by (resolve_tac (prems RL [lfp_ind2]) 1);
clasohm@969
   230
by (rtac eval_fun_mono 1);
clasohm@969
   231
by (rewtac eval_fun_def);
clasohm@969
   232
by (dtac CollectD 1);
wenzelm@4089
   233
by (safe_tac (claset()));
clasohm@969
   234
by (ALLGOALS (resolve_tac prems));
paulson@2935
   235
by (ALLGOALS (Blast_tac));
clasohm@969
   236
qed "eval_ind0";
clasohm@969
   237
clasohm@969
   238
val prems = goal MT.thy 
clasohm@969
   239
  " [| ve |- e ---> v; \
clasohm@969
   240
\      !!ve c. P ve (e_const c) (v_const c); \
clasohm@969
   241
\      !!ev ve. ev:ve_dom(ve) ==> P ve (e_var ev) (ve_app ve ev); \
clasohm@969
   242
\      !!ev ve e. P ve (fn ev => e) (v_clos <|ev,e,ve|>); \
clasohm@969
   243
\      !!ev1 ev2 ve cl e. \
clasohm@969
   244
\        cl = <| ev1, e, ve + {ev2 |-> v_clos(cl)} |> ==> \
clasohm@969
   245
\        P ve (fix ev2(ev1) = e) (v_clos cl); \
clasohm@969
   246
\      !!ve c1 c2 e1 e2. \
clasohm@969
   247
\        [| P ve e1 (v_const c1); P ve e2 (v_const c2) |] ==> \
clasohm@969
   248
\        P ve (e1 @ e2) (v_const(c_app c1 c2)); \
clasohm@969
   249
\      !!ve vem evm e1 e2 em v v2. \
clasohm@969
   250
\        [|  P ve e1 (v_clos <|evm,em,vem|>); \
clasohm@969
   251
\            P ve e2 v2; \
clasohm@969
   252
\            P (vem + {evm |-> v2}) em v \
clasohm@969
   253
\        |] ==> P ve (e1 @ e2) v \
clasohm@969
   254
\   |] ==> P ve e v";
clasohm@969
   255
by (res_inst_tac [("P","P")] infsys_pp2 1);
clasohm@969
   256
by (rtac eval_ind0 1);
clasohm@969
   257
by (ALLGOALS (rtac infsys_pp1));
clasohm@969
   258
by (ALLGOALS (resolve_tac prems));
clasohm@969
   259
by (REPEAT ((assume_tac 1) ORELSE (dtac infsys_pp2 1)));
clasohm@969
   260
qed "eval_ind";
clasohm@969
   261
clasohm@969
   262
(* ############################################################ *)
clasohm@969
   263
(* Elaborations                                                 *)
clasohm@969
   264
(* ############################################################ *)
clasohm@969
   265
clasohm@969
   266
goalw MT.thy [mono_def, elab_fun_def] "mono(elab_fun)";
clasohm@969
   267
by infsys_mono_tac;
clasohm@969
   268
qed "elab_fun_mono";
clasohm@969
   269
clasohm@969
   270
(* Introduction rules *)
clasohm@969
   271
paulson@2935
   272
goalw MT.thy [elab_def, elab_rel_def] 
paulson@2935
   273
  "!!te. c isof ty ==> te |- e_const(c) ===> ty";
clasohm@969
   274
by (rtac lfp_intro2 1);
clasohm@969
   275
by (rtac elab_fun_mono 1);
clasohm@969
   276
by (rewtac elab_fun_def);
wenzelm@4089
   277
by (blast_tac (claset() addSIs [exI]) 1);
clasohm@969
   278
qed "elab_const";
clasohm@969
   279
paulson@2935
   280
goalw MT.thy [elab_def, elab_rel_def] 
paulson@2935
   281
  "!!te. x:te_dom(te) ==> te |- e_var(x) ===> te_app te x";
clasohm@969
   282
by (rtac lfp_intro2 1);
clasohm@969
   283
by (rtac elab_fun_mono 1);
clasohm@969
   284
by (rewtac elab_fun_def);
wenzelm@4089
   285
by (blast_tac (claset() addSIs [exI]) 1);
clasohm@969
   286
qed "elab_var";
clasohm@969
   287
paulson@2935
   288
goalw MT.thy [elab_def, elab_rel_def] 
paulson@2935
   289
  "!!te. te + {x |=> ty1} |- e ===> ty2 ==> te |- fn x => e ===> ty1->ty2";
clasohm@969
   290
by (rtac lfp_intro2 1);
clasohm@969
   291
by (rtac elab_fun_mono 1);
clasohm@969
   292
by (rewtac elab_fun_def);
wenzelm@4089
   293
by (blast_tac (claset() addSIs [exI]) 1);
clasohm@969
   294
qed "elab_fn";
clasohm@969
   295
paulson@2935
   296
goalw MT.thy [elab_def, elab_rel_def]
paulson@2935
   297
  "!!te. te + {f |=> ty1->ty2} + {x |=> ty1} |- e ===> ty2 ==> \
paulson@2935
   298
\        te |- fix f(x) = e ===> ty1->ty2";
clasohm@969
   299
by (rtac lfp_intro2 1);
clasohm@969
   300
by (rtac elab_fun_mono 1);
clasohm@969
   301
by (rewtac elab_fun_def);
wenzelm@4089
   302
by (blast_tac (claset() addSIs [exI]) 1);
clasohm@969
   303
qed "elab_fix";
clasohm@969
   304
paulson@2935
   305
goalw MT.thy [elab_def, elab_rel_def] 
paulson@2935
   306
  "!!te. [| te |- e1 ===> ty1->ty2; te |- e2 ===> ty1 |] ==> \
paulson@2935
   307
\        te |- e1 @ e2 ===> ty2";
clasohm@969
   308
by (rtac lfp_intro2 1);
clasohm@969
   309
by (rtac elab_fun_mono 1);
clasohm@969
   310
by (rewtac elab_fun_def);
wenzelm@4089
   311
by (blast_tac (claset() addSIs [disjI2]) 1);
clasohm@969
   312
qed "elab_app";
clasohm@969
   313
clasohm@969
   314
(* Strong elimination, induction on elaborations *)
clasohm@969
   315
clasohm@969
   316
val prems = goalw MT.thy [elab_def, elab_rel_def]
clasohm@969
   317
  " [| te |- e ===> t; \
clasohm@972
   318
\      !!te c t. c isof t ==> P(((te,e_const(c)),t)); \
clasohm@972
   319
\      !!te x. x:te_dom(te) ==> P(((te,e_var(x)),te_app te x)); \
clasohm@969
   320
\      !!te x e t1 t2. \
clasohm@972
   321
\        [| te + {x |=> t1} |- e ===> t2; P(((te + {x |=> t1},e),t2)) |] ==> \
clasohm@972
   322
\        P(((te,fn x => e),t1->t2)); \
clasohm@969
   323
\      !!te f x e t1 t2. \
clasohm@969
   324
\        [| te + {f |=> t1->t2} + {x |=> t1} |- e ===> t2; \
clasohm@972
   325
\           P(((te + {f |=> t1->t2} + {x |=> t1},e),t2)) \
clasohm@969
   326
\        |] ==> \
clasohm@972
   327
\        P(((te,fix f(x) = e),t1->t2)); \
clasohm@969
   328
\      !!te e1 e2 t1 t2. \
clasohm@972
   329
\        [| te |- e1 ===> t1->t2; P(((te,e1),t1->t2)); \
clasohm@972
   330
\           te |- e2 ===> t1; P(((te,e2),t1)) \
clasohm@969
   331
\        |] ==> \
clasohm@972
   332
\        P(((te,e1 @ e2),t2)) \
clasohm@969
   333
\   |] ==> \
clasohm@972
   334
\   P(((te,e),t))";
clasohm@969
   335
by (resolve_tac (prems RL [lfp_ind2]) 1);
clasohm@969
   336
by (rtac elab_fun_mono 1);
clasohm@969
   337
by (rewtac elab_fun_def);
clasohm@969
   338
by (dtac CollectD 1);
wenzelm@4089
   339
by (safe_tac (claset()));
clasohm@969
   340
by (ALLGOALS (resolve_tac prems));
paulson@2935
   341
by (ALLGOALS (Blast_tac));
clasohm@969
   342
qed "elab_ind0";
clasohm@969
   343
clasohm@969
   344
val prems = goal MT.thy
clasohm@969
   345
  " [| te |- e ===> t; \
clasohm@969
   346
\       !!te c t. c isof t ==> P te (e_const c) t; \
clasohm@969
   347
\      !!te x. x:te_dom(te) ==> P te (e_var x) (te_app te x); \
clasohm@969
   348
\      !!te x e t1 t2. \
clasohm@969
   349
\        [| te + {x |=> t1} |- e ===> t2; P (te + {x |=> t1}) e t2 |] ==> \
clasohm@969
   350
\        P te (fn x => e) (t1->t2); \
clasohm@969
   351
\      !!te f x e t1 t2. \
clasohm@969
   352
\        [| te + {f |=> t1->t2} + {x |=> t1} |- e ===> t2; \
clasohm@969
   353
\           P (te + {f |=> t1->t2} + {x |=> t1}) e t2 \
clasohm@969
   354
\        |] ==> \
clasohm@969
   355
\        P te (fix f(x) = e) (t1->t2); \
clasohm@969
   356
\      !!te e1 e2 t1 t2. \
clasohm@969
   357
\        [| te |- e1 ===> t1->t2; P te e1 (t1->t2); \
clasohm@969
   358
\           te |- e2 ===> t1; P te e2 t1 \
clasohm@969
   359
\        |] ==> \
clasohm@969
   360
\        P te (e1 @ e2) t2 \ 
clasohm@969
   361
\   |] ==> \
clasohm@969
   362
\   P te e t";
clasohm@969
   363
by (res_inst_tac [("P","P")] infsys_pp2 1);
clasohm@969
   364
by (rtac elab_ind0 1);
clasohm@969
   365
by (ALLGOALS (rtac infsys_pp1));
clasohm@969
   366
by (ALLGOALS (resolve_tac prems));
clasohm@969
   367
by (REPEAT ((assume_tac 1) ORELSE (dtac infsys_pp2 1)));
clasohm@969
   368
qed "elab_ind";
clasohm@969
   369
clasohm@969
   370
(* Weak elimination, case analysis on elaborations *)
clasohm@969
   371
clasohm@969
   372
val prems = goalw MT.thy [elab_def, elab_rel_def]
clasohm@969
   373
  " [| te |- e ===> t; \
clasohm@972
   374
\      !!te c t. c isof t ==> P(((te,e_const(c)),t)); \
clasohm@972
   375
\      !!te x. x:te_dom(te) ==> P(((te,e_var(x)),te_app te x)); \
clasohm@969
   376
\      !!te x e t1 t2. \
clasohm@972
   377
\        te + {x |=> t1} |- e ===> t2 ==> P(((te,fn x => e),t1->t2)); \
clasohm@969
   378
\      !!te f x e t1 t2. \
clasohm@969
   379
\        te + {f |=> t1->t2} + {x |=> t1} |- e ===> t2 ==> \
clasohm@972
   380
\        P(((te,fix f(x) = e),t1->t2)); \
clasohm@969
   381
\      !!te e1 e2 t1 t2. \
clasohm@969
   382
\        [| te |- e1 ===> t1->t2; te |- e2 ===> t1 |] ==> \
clasohm@972
   383
\        P(((te,e1 @ e2),t2)) \
clasohm@969
   384
\   |] ==> \
clasohm@972
   385
\   P(((te,e),t))";
clasohm@969
   386
by (resolve_tac (prems RL [lfp_elim2]) 1);
clasohm@969
   387
by (rtac elab_fun_mono 1);
clasohm@969
   388
by (rewtac elab_fun_def);
clasohm@969
   389
by (dtac CollectD 1);
wenzelm@4089
   390
by (safe_tac (claset()));
clasohm@969
   391
by (ALLGOALS (resolve_tac prems));
paulson@2935
   392
by (ALLGOALS (Blast_tac));
clasohm@969
   393
qed "elab_elim0";
clasohm@969
   394
clasohm@969
   395
val prems = goal MT.thy
clasohm@969
   396
  " [| te |- e ===> t; \
clasohm@969
   397
\       !!te c t. c isof t ==> P te (e_const c) t; \
clasohm@969
   398
\      !!te x. x:te_dom(te) ==> P te (e_var x) (te_app te x); \
clasohm@969
   399
\      !!te x e t1 t2. \
clasohm@969
   400
\        te + {x |=> t1} |- e ===> t2 ==> P te (fn x => e) (t1->t2); \
clasohm@969
   401
\      !!te f x e t1 t2. \
clasohm@969
   402
\        te + {f |=> t1->t2} + {x |=> t1} |- e ===> t2 ==> \
clasohm@969
   403
\        P te (fix f(x) = e) (t1->t2); \
clasohm@969
   404
\      !!te e1 e2 t1 t2. \
clasohm@969
   405
\        [| te |- e1 ===> t1->t2; te |- e2 ===> t1 |] ==> \
clasohm@969
   406
\        P te (e1 @ e2) t2 \ 
clasohm@969
   407
\   |] ==> \
clasohm@969
   408
\   P te e t";
clasohm@969
   409
by (res_inst_tac [("P","P")] infsys_pp2 1);
clasohm@969
   410
by (rtac elab_elim0 1);
clasohm@969
   411
by (ALLGOALS (rtac infsys_pp1));
clasohm@969
   412
by (ALLGOALS (resolve_tac prems));
clasohm@969
   413
by (REPEAT ((assume_tac 1) ORELSE (dtac infsys_pp2 1)));
clasohm@969
   414
qed "elab_elim";
clasohm@969
   415
clasohm@969
   416
(* Elimination rules for each expression *)
clasohm@969
   417
clasohm@969
   418
fun elab_e_elim_tac p = 
clasohm@969
   419
  ( (rtac elab_elim 1) THEN 
clasohm@969
   420
    (resolve_tac p 1) THEN 
paulson@2935
   421
    (REPEAT (blast_tac (e_ext_cs HOL_cs) 1))
clasohm@969
   422
  );
clasohm@969
   423
clasohm@969
   424
val prems = goal MT.thy "te |- e ===> t ==> (e = e_const(c) --> c isof t)";
clasohm@969
   425
by (elab_e_elim_tac prems);
clasohm@969
   426
qed "elab_const_elim_lem";
clasohm@969
   427
clasohm@969
   428
val prems = goal MT.thy "te |- e_const(c) ===> t ==> c isof t";
clasohm@969
   429
by (cut_facts_tac prems 1);
clasohm@969
   430
by (dtac elab_const_elim_lem 1);
paulson@2935
   431
by (Blast_tac 1);
clasohm@969
   432
qed "elab_const_elim";
clasohm@969
   433
clasohm@969
   434
val prems = goal MT.thy 
clasohm@969
   435
  "te |- e ===> t ==> (e = e_var(x) --> t=te_app te x & x:te_dom(te))";
clasohm@969
   436
by (elab_e_elim_tac prems);
clasohm@969
   437
qed "elab_var_elim_lem";
clasohm@969
   438
clasohm@969
   439
val prems = goal MT.thy 
clasohm@969
   440
  "te |- e_var(ev) ===> t ==> t=te_app te ev & ev : te_dom(te)";
clasohm@969
   441
by (cut_facts_tac prems 1);
clasohm@969
   442
by (dtac elab_var_elim_lem 1);
paulson@2935
   443
by (Blast_tac 1);
clasohm@969
   444
qed "elab_var_elim";
clasohm@969
   445
clasohm@969
   446
val prems = goal MT.thy 
clasohm@969
   447
  " te |- e ===> t ==> \
clasohm@969
   448
\   ( e = fn x1 => e1 --> \
wenzelm@3842
   449
\     (? t1 t2. t=t_fun t1 t2 & te + {x1 |=> t1} |- e1 ===> t2) \
clasohm@969
   450
\   )";
clasohm@969
   451
by (elab_e_elim_tac prems);
clasohm@969
   452
qed "elab_fn_elim_lem";
clasohm@969
   453
clasohm@969
   454
val prems = goal MT.thy 
clasohm@969
   455
  " te |- fn x1 => e1 ===> t ==> \
clasohm@969
   456
\   (? t1 t2. t=t1->t2 & te + {x1 |=> t1} |- e1 ===> t2)";
clasohm@969
   457
by (cut_facts_tac prems 1);
clasohm@969
   458
by (dtac elab_fn_elim_lem 1);
paulson@2935
   459
by (Blast_tac 1);
clasohm@969
   460
qed "elab_fn_elim";
clasohm@969
   461
clasohm@969
   462
val prems = goal MT.thy 
clasohm@969
   463
  " te |- e ===> t ==> \
clasohm@969
   464
\   (e = fix f(x) = e1 --> \
clasohm@969
   465
\   (? t1 t2. t=t1->t2 & te + {f |=> t1->t2} + {x |=> t1} |- e1 ===> t2))"; 
clasohm@969
   466
by (elab_e_elim_tac prems);
clasohm@969
   467
qed "elab_fix_elim_lem";
clasohm@969
   468
clasohm@969
   469
val prems = goal MT.thy 
clasohm@969
   470
  " te |- fix ev1(ev2) = e1 ===> t ==> \
clasohm@969
   471
\   (? t1 t2. t=t1->t2 & te + {ev1 |=> t1->t2} + {ev2 |=> t1} |- e1 ===> t2)";
clasohm@969
   472
by (cut_facts_tac prems 1);
clasohm@969
   473
by (dtac elab_fix_elim_lem 1);
paulson@2935
   474
by (Blast_tac 1);
clasohm@969
   475
qed "elab_fix_elim";
clasohm@969
   476
clasohm@969
   477
val prems = goal MT.thy 
clasohm@969
   478
  " te |- e ===> t2 ==> \
clasohm@969
   479
\   (e = e1 @ e2 --> (? t1 . te |- e1 ===> t1->t2 & te |- e2 ===> t1))"; 
clasohm@969
   480
by (elab_e_elim_tac prems);
clasohm@969
   481
qed "elab_app_elim_lem";
clasohm@969
   482
clasohm@1266
   483
val prems = goal MT.thy
clasohm@1266
   484
 "te |- e1 @ e2 ===> t2 ==> (? t1 . te |- e1 ===> t1->t2 & te |- e2 ===> t1)"; 
clasohm@969
   485
by (cut_facts_tac prems 1);
clasohm@969
   486
by (dtac elab_app_elim_lem 1);
paulson@2935
   487
by (Blast_tac 1);
clasohm@969
   488
qed "elab_app_elim";
clasohm@969
   489
clasohm@969
   490
(* ############################################################ *)
clasohm@969
   491
(* The extended correspondence relation                       *)
clasohm@969
   492
(* ############################################################ *)
clasohm@969
   493
clasohm@969
   494
(* Monotonicity of hasty_fun *)
clasohm@969
   495
clasohm@969
   496
goalw MT.thy [mono_def,MT.hasty_fun_def] "mono(hasty_fun)";
clasohm@969
   497
by infsys_mono_tac;
paulson@2935
   498
by (Blast_tac 1);
paulson@2935
   499
qed "mono_hasty_fun";
clasohm@969
   500
clasohm@969
   501
(* 
clasohm@969
   502
  Because hasty_rel has been defined as the greatest fixpoint of hasty_fun it 
clasohm@969
   503
  enjoys two strong indtroduction (co-induction) rules and an elimination rule.
clasohm@969
   504
*)
clasohm@969
   505
clasohm@969
   506
(* First strong indtroduction (co-induction) rule for hasty_rel *)
clasohm@969
   507
clasohm@1266
   508
val prems =
clasohm@1266
   509
  goalw MT.thy [hasty_rel_def] "c isof t ==> (v_const(c),t) : hasty_rel";
clasohm@969
   510
by (cut_facts_tac prems 1);
clasohm@969
   511
by (rtac gfp_coind2 1);
clasohm@969
   512
by (rewtac MT.hasty_fun_def);
lcp@1047
   513
by (rtac CollectI 1);
lcp@1047
   514
by (rtac disjI1 1);
paulson@2935
   515
by (Blast_tac 1);
clasohm@969
   516
by (rtac mono_hasty_fun 1);
clasohm@969
   517
qed "hasty_rel_const_coind";
clasohm@969
   518
clasohm@969
   519
(* Second strong introduction (co-induction) rule for hasty_rel *)
clasohm@969
   520
clasohm@969
   521
val prems = goalw MT.thy [hasty_rel_def]
clasohm@969
   522
  " [|  te |- fn ev => e ===> t; \
clasohm@969
   523
\       ve_dom(ve) = te_dom(te); \
clasohm@969
   524
\       ! ev1. \
clasohm@969
   525
\         ev1:ve_dom(ve) --> \
clasohm@972
   526
\         (ve_app ve ev1,te_app te ev1) : {(v_clos(<|ev,e,ve|>),t)} Un hasty_rel \
clasohm@969
   527
\   |] ==> \
clasohm@972
   528
\   (v_clos(<|ev,e,ve|>),t) : hasty_rel";
clasohm@969
   529
by (cut_facts_tac prems 1);
clasohm@969
   530
by (rtac gfp_coind2 1);
clasohm@969
   531
by (rewtac hasty_fun_def);
lcp@1047
   532
by (rtac CollectI 1);
lcp@1047
   533
by (rtac disjI2 1);
paulson@2935
   534
by (blast_tac HOL_cs 1);
clasohm@969
   535
by (rtac mono_hasty_fun 1);
clasohm@969
   536
qed "hasty_rel_clos_coind";
clasohm@969
   537
clasohm@969
   538
(* Elimination rule for hasty_rel *)
clasohm@969
   539
clasohm@969
   540
val prems = goalw MT.thy [hasty_rel_def]
wenzelm@3842
   541
  " [| !! c t. c isof t ==> P((v_const(c),t)); \
clasohm@969
   542
\      !! te ev e t ve. \
clasohm@969
   543
\        [| te |- fn ev => e ===> t; \
clasohm@969
   544
\           ve_dom(ve) = te_dom(te); \
wenzelm@3842
   545
\           !ev1. ev1:ve_dom(ve) --> (ve_app ve ev1,te_app te ev1) : hasty_rel \
clasohm@972
   546
\        |] ==> P((v_clos(<|ev,e,ve|>),t)); \
clasohm@972
   547
\      (v,t) : hasty_rel \
clasohm@972
   548
\   |] ==> P((v,t))";
clasohm@969
   549
by (cut_facts_tac prems 1);
clasohm@969
   550
by (etac gfp_elim2 1);
clasohm@969
   551
by (rtac mono_hasty_fun 1);
clasohm@969
   552
by (rewtac hasty_fun_def);
clasohm@969
   553
by (dtac CollectD 1);
clasohm@969
   554
by (fold_goals_tac [hasty_fun_def]);
wenzelm@4089
   555
by (safe_tac (claset()));
paulson@2935
   556
by (REPEAT (ares_tac prems 1));
clasohm@969
   557
qed "hasty_rel_elim0";
clasohm@969
   558
clasohm@969
   559
val prems = goal MT.thy 
clasohm@972
   560
  " [| (v,t) : hasty_rel; \
wenzelm@3842
   561
\      !! c t. c isof t ==> P (v_const c) t; \
clasohm@969
   562
\      !! te ev e t ve. \
clasohm@969
   563
\        [| te |- fn ev => e ===> t; \
clasohm@969
   564
\           ve_dom(ve) = te_dom(te); \
wenzelm@3842
   565
\           !ev1. ev1:ve_dom(ve) --> (ve_app ve ev1,te_app te ev1) : hasty_rel \
clasohm@969
   566
\        |] ==> P (v_clos <|ev,e,ve|>) t \
clasohm@969
   567
\   |] ==> P v t";
clasohm@969
   568
by (res_inst_tac [("P","P")] infsys_p2 1);
clasohm@969
   569
by (rtac hasty_rel_elim0 1);
clasohm@969
   570
by (ALLGOALS (rtac infsys_p1));
clasohm@969
   571
by (ALLGOALS (resolve_tac prems));
clasohm@969
   572
by (REPEAT ((assume_tac 1) ORELSE (dtac infsys_p2 1)));
clasohm@969
   573
qed "hasty_rel_elim";
clasohm@969
   574
clasohm@969
   575
(* Introduction rules for hasty *)
clasohm@969
   576
paulson@2935
   577
goalw MT.thy [hasty_def] "!!c. c isof t ==> v_const(c) hasty t";
paulson@2935
   578
by (etac hasty_rel_const_coind 1);
clasohm@969
   579
qed "hasty_const";
clasohm@969
   580
paulson@2935
   581
goalw MT.thy [hasty_def,hasty_env_def] 
paulson@2935
   582
 "!!t. te |- fn ev => e ===> t & ve hastyenv te ==> v_clos(<|ev,e,ve|>) hasty t";
clasohm@969
   583
by (rtac hasty_rel_clos_coind 1);
wenzelm@4089
   584
by (ALLGOALS (blast_tac (claset() delrules [equalityI])));
clasohm@969
   585
qed "hasty_clos";
clasohm@969
   586
clasohm@969
   587
(* Elimination on constants for hasty *)
clasohm@969
   588
paulson@2935
   589
goalw MT.thy [hasty_def] 
paulson@2935
   590
  "!!v. v hasty t ==> (!c.(v = v_const(c) --> c isof t))";  
clasohm@969
   591
by (rtac hasty_rel_elim 1);
paulson@2935
   592
by (ALLGOALS (blast_tac (v_ext_cs HOL_cs)));
clasohm@969
   593
qed "hasty_elim_const_lem";
clasohm@969
   594
paulson@2935
   595
goal MT.thy "!!c. v_const(c) hasty t ==> c isof t";
paulson@2935
   596
by (dtac hasty_elim_const_lem 1);
paulson@2935
   597
by (Blast_tac 1);
clasohm@969
   598
qed "hasty_elim_const";
clasohm@969
   599
clasohm@969
   600
(* Elimination on closures for hasty *)
clasohm@969
   601
clasohm@969
   602
val prems = goalw MT.thy [hasty_env_def,hasty_def] 
clasohm@969
   603
  " v hasty t ==> \
clasohm@969
   604
\   ! x e ve. \
wenzelm@3842
   605
\     v=v_clos(<|x,e,ve|>) --> (? te. te |- fn x => e ===> t & ve hastyenv te)";
clasohm@969
   606
by (cut_facts_tac prems 1);
clasohm@969
   607
by (rtac hasty_rel_elim 1);
paulson@2935
   608
by (ALLGOALS (blast_tac (v_ext_cs HOL_cs)));
clasohm@969
   609
qed "hasty_elim_clos_lem";
clasohm@969
   610
paulson@2935
   611
goal MT.thy 
paulson@2935
   612
  "!!t. v_clos(<|ev,e,ve|>) hasty t ==>  \
wenzelm@3842
   613
\       ? te. te |- fn ev => e ===> t & ve hastyenv te ";
paulson@2935
   614
by (dtac hasty_elim_clos_lem 1);
paulson@2935
   615
by (Blast_tac 1);
clasohm@969
   616
qed "hasty_elim_clos";
clasohm@969
   617
clasohm@969
   618
(* ############################################################ *)
clasohm@969
   619
(* The pointwise extension of hasty to environments             *)
clasohm@969
   620
(* ############################################################ *)
clasohm@969
   621
lcp@1047
   622
goal MT.thy
lcp@1047
   623
  "!!ve. [| ve hastyenv te; v hasty t |] ==> \
lcp@1047
   624
\        ve + {ev |-> v} hastyenv te + {ev |=> t}";
lcp@1047
   625
by (rewtac hasty_env_def);
wenzelm@4089
   626
by (asm_full_simp_tac (simpset() delsimps mem_simps
clasohm@1266
   627
                                addsimps [ve_dom_owr, te_dom_owr]) 1);
paulson@2935
   628
by (safe_tac HOL_cs);
lcp@1047
   629
by (excluded_middle_tac "ev=x" 1);
wenzelm@4089
   630
by (asm_full_simp_tac (simpset() addsimps [ve_app_owr2, te_app_owr2]) 1);
paulson@2935
   631
by (Blast_tac 1);
wenzelm@4089
   632
by (asm_simp_tac (simpset() addsimps [ve_app_owr1, te_app_owr1]) 1);
clasohm@969
   633
qed "hasty_env1";
clasohm@969
   634
clasohm@969
   635
(* ############################################################ *)
clasohm@969
   636
(* The Consistency theorem                                      *)
clasohm@969
   637
(* ############################################################ *)
clasohm@969
   638
paulson@2935
   639
goal MT.thy 
paulson@2935
   640
  "!!t. [| ve hastyenv te ; te |- e_const(c) ===> t |] ==> v_const(c) hasty t";
clasohm@969
   641
by (dtac elab_const_elim 1);
clasohm@969
   642
by (etac hasty_const 1);
clasohm@969
   643
qed "consistency_const";
clasohm@969
   644
paulson@2935
   645
goalw MT.thy [hasty_env_def]
paulson@2935
   646
  "!!t. [| ev : ve_dom(ve); ve hastyenv te ; te |- e_var(ev) ===> t |] ==> \
paulson@2935
   647
\       ve_app ve ev hasty t";
clasohm@969
   648
by (dtac elab_var_elim 1);
paulson@2935
   649
by (Blast_tac 1);
clasohm@969
   650
qed "consistency_var";
clasohm@969
   651
paulson@2935
   652
goal MT.thy
paulson@2935
   653
  "!!t. [| ve hastyenv te ; te |- fn ev => e ===> t |] ==> \
paulson@2935
   654
\       v_clos(<| ev, e, ve |>) hasty t";
clasohm@969
   655
by (rtac hasty_clos 1);
paulson@2935
   656
by (Blast_tac 1);
clasohm@969
   657
qed "consistency_fn";
clasohm@969
   658
paulson@2935
   659
goalw MT.thy [hasty_env_def,hasty_def]
paulson@2935
   660
  "!!t. [| cl = <| ev1, e, ve + { ev2 |-> v_clos(cl) } |>; \
clasohm@969
   661
\      ve hastyenv te ; \
clasohm@969
   662
\      te |- fix ev2  ev1  = e ===> t \
clasohm@969
   663
\   |] ==> \
clasohm@969
   664
\   v_clos(cl) hasty t";
clasohm@969
   665
by (dtac elab_fix_elim 1);
paulson@2935
   666
by (safe_tac HOL_cs);
lcp@1047
   667
(*Do a single unfolding of cl*)
lcp@1047
   668
by ((forward_tac [ssubst] 1) THEN (assume_tac 2));
lcp@1047
   669
by (rtac hasty_rel_clos_coind 1);
clasohm@969
   670
by (etac elab_fn 1);
wenzelm@4089
   671
by (asm_simp_tac (simpset() addsimps [ve_dom_owr, te_dom_owr]) 1);
clasohm@969
   672
wenzelm@4089
   673
by (asm_simp_tac (simpset() delsimps mem_simps addsimps [ve_dom_owr]) 1);
paulson@2935
   674
by (safe_tac HOL_cs);
lcp@1047
   675
by (excluded_middle_tac "ev2=ev1a" 1);
wenzelm@4089
   676
by (asm_full_simp_tac (simpset() addsimps [ve_app_owr2, te_app_owr2]) 1);
paulson@2935
   677
by (Blast_tac 1);
clasohm@969
   678
wenzelm@4089
   679
by (asm_simp_tac (simpset() delsimps mem_simps
clasohm@1266
   680
                           addsimps [ve_app_owr1, te_app_owr1]) 1);
clasohm@969
   681
by (hyp_subst_tac 1);
clasohm@969
   682
by (etac subst 1);
paulson@2935
   683
by (Blast_tac 1);
clasohm@969
   684
qed "consistency_fix";
clasohm@969
   685
paulson@2935
   686
goal MT.thy 
paulson@2935
   687
  "!!t. [| ! t te. ve hastyenv te --> te |- e1 ===> t --> v_const(c1) hasty t;\
clasohm@969
   688
\      ! t te. ve hastyenv te  --> te |- e2 ===> t --> v_const(c2) hasty t; \
clasohm@969
   689
\      ve hastyenv te ; te |- e1 @ e2 ===> t \
clasohm@969
   690
\   |] ==> \
clasohm@969
   691
\   v_const(c_app c1 c2) hasty t";
clasohm@969
   692
by (dtac elab_app_elim 1);
wenzelm@4089
   693
by (safe_tac (claset()));
clasohm@969
   694
by (rtac hasty_const 1);
clasohm@969
   695
by (rtac isof_app 1);
clasohm@969
   696
by (rtac hasty_elim_const 1);
paulson@2935
   697
by (Blast_tac 1);
clasohm@969
   698
by (rtac hasty_elim_const 1);
paulson@2935
   699
by (Blast_tac 1);
clasohm@969
   700
qed "consistency_app1";
clasohm@969
   701
paulson@2935
   702
goal MT.thy 
paulson@2935
   703
  "!!t.  [| ! t te. \
clasohm@969
   704
\        ve hastyenv te  --> \
clasohm@969
   705
\        te |- e1 ===> t --> v_clos(<|evm, em, vem|>) hasty t; \
clasohm@969
   706
\      ! t te. ve hastyenv te  --> te |- e2 ===> t --> v2 hasty t; \
clasohm@969
   707
\      ! t te. \
clasohm@969
   708
\        vem + { evm |-> v2 } hastyenv te  --> te |- em ===> t --> v hasty t; \
clasohm@969
   709
\      ve hastyenv te ; \
clasohm@969
   710
\      te |- e1 @ e2 ===> t \
clasohm@969
   711
\   |] ==> \
clasohm@969
   712
\   v hasty t";
clasohm@969
   713
by (dtac elab_app_elim 1);
wenzelm@4089
   714
by (safe_tac (claset()));
lcp@1047
   715
by ((etac allE 1) THEN (etac allE 1) THEN (etac impE 1));
lcp@1047
   716
by (assume_tac 1);
lcp@1047
   717
by (etac impE 1);
lcp@1047
   718
by (assume_tac 1);
lcp@1047
   719
by ((etac allE 1) THEN (etac allE 1) THEN (etac impE 1));
lcp@1047
   720
by (assume_tac 1);
lcp@1047
   721
by (etac impE 1);
lcp@1047
   722
by (assume_tac 1);
clasohm@969
   723
by (dtac hasty_elim_clos 1);
wenzelm@4089
   724
by (safe_tac (claset()));
clasohm@969
   725
by (dtac elab_fn_elim 1);
wenzelm@4089
   726
by (blast_tac (claset() addIs [hasty_env1] addSDs [t_fun_inj]) 1);
clasohm@969
   727
qed "consistency_app2";
clasohm@969
   728
lcp@1047
   729
val [major] = goal MT.thy 
lcp@1047
   730
  "ve |- e ---> v ==> \
lcp@1047
   731
\  (! t te. ve hastyenv te --> te |- e ===> t --> v hasty t)";
clasohm@969
   732
clasohm@969
   733
(* Proof by induction on the structure of evaluations *)
clasohm@969
   734
lcp@1047
   735
by (rtac (major RS eval_ind) 1);
wenzelm@4089
   736
by (safe_tac (claset()));
lcp@1047
   737
by (DEPTH_SOLVE 
lcp@1047
   738
    (ares_tac [consistency_const, consistency_var, consistency_fn,
clasohm@1465
   739
               consistency_fix, consistency_app1, consistency_app2] 1));
clasohm@969
   740
qed "consistency";
clasohm@969
   741
clasohm@969
   742
(* ############################################################ *)
clasohm@969
   743
(* The Basic Consistency theorem                                *)
clasohm@969
   744
(* ############################################################ *)
clasohm@969
   745
clasohm@969
   746
val prems = goalw MT.thy [isof_env_def,hasty_env_def] 
clasohm@969
   747
  "ve isofenv te ==> ve hastyenv te";
clasohm@969
   748
by (cut_facts_tac prems 1);
wenzelm@4089
   749
by (safe_tac (claset()));
lcp@1047
   750
by (etac allE 1);
lcp@1047
   751
by (etac impE 1);
lcp@1047
   752
by (assume_tac 1);
lcp@1047
   753
by (etac exE 1);
lcp@1047
   754
by (etac conjE 1);
clasohm@969
   755
by (dtac hasty_const 1);
clasohm@1266
   756
by (Asm_simp_tac 1);
clasohm@969
   757
qed "basic_consistency_lem";
clasohm@969
   758
clasohm@969
   759
val prems = goal MT.thy
clasohm@969
   760
  "[| ve isofenv te; ve |- e ---> v_const(c); te |- e ===> t |] ==> c isof t";
clasohm@969
   761
by (cut_facts_tac prems 1);
clasohm@969
   762
by (rtac hasty_elim_const 1);
clasohm@969
   763
by (dtac consistency 1);
wenzelm@4089
   764
by (blast_tac (claset() addSIs [basic_consistency_lem]) 1);
clasohm@969
   765
qed "basic_consistency";
paulson@1584
   766
paulson@1584
   767
writeln"Reached end of file.";