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