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