src/HOL/WF.ML
author clasohm
Fri, 03 Mar 1995 12:02:25 +0100
changeset 923 ff1574a81019
child 950 323f8ca4587a
permissions -rw-r--r--
new version of HOL with curried function application
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     1
(*  Title: 	HOL/wf.ML
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     3
    Author: 	Tobias Nipkow
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     5
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     6
For wf.thy.  Well-founded Recursion
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     9
open WF;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    10
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    11
val H_cong = read_instantiate [("f","H::[?'a, ?'a=>?'b]=>?'b")]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    12
               (standard(refl RS cong RS cong));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    13
val H_cong1 = refl RS H_cong;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
(*Restriction to domain A.  If r is well-founded over A then wf(r)*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    16
val [prem1,prem2] = goalw WF.thy [wf_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    17
 "[| r <= Sigma A (%u.A);  \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
\    !!x P. [| ! x. (! y. <y,x> : r --> P(y)) --> P(x);  x:A |] ==> P(x) |]  \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
\ ==>  wf(r)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
by (strip_tac 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    21
by (rtac allE 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    22
by (assume_tac 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    23
by (best_tac (HOL_cs addSEs [prem1 RS subsetD RS SigmaE2] addIs [prem2]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    24
qed "wfI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    25
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    26
val major::prems = goalw WF.thy [wf_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    27
    "[| wf(r);          \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    28
\       !!x.[| ! y. <y,x>: r --> P(y) |] ==> P(x) \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    29
\    |]  ==>  P(a)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    30
by (rtac (major RS spec RS mp RS spec) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    31
by (fast_tac (HOL_cs addEs prems) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    32
qed "wf_induct";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    33
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    34
(*Perform induction on i, then prove the wf(r) subgoal using prems. *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    35
fun wf_ind_tac a prems i = 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    36
    EVERY [res_inst_tac [("a",a)] wf_induct i,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    37
	   rename_last_tac a ["1"] (i+1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    38
	   ares_tac prems i];
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    39
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    40
val prems = goal WF.thy "[| wf(r);  <a,x>:r;  <x,a>:r |] ==> P";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    41
by (subgoal_tac "! x. <a,x>:r --> <x,a>:r --> P" 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    42
by (fast_tac (HOL_cs addIs prems) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    43
by (wf_ind_tac "a" prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    44
by (fast_tac set_cs 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
qed "wf_asym";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    46
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    47
val prems = goal WF.thy "[| wf(r);  <a,a>: r |] ==> P";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    48
by (rtac wf_asym 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    49
by (REPEAT (resolve_tac prems 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    50
qed "wf_anti_refl";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    51
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    52
(*transitive closure of a WF relation is WF!*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    53
val [prem] = goal WF.thy "wf(r) ==> wf(r^+)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    54
by (rewtac wf_def);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    55
by (strip_tac 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    56
(*must retain the universal formula for later use!*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    57
by (rtac allE 1 THEN assume_tac 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    58
by (etac mp 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    59
by (res_inst_tac [("a","x")] (prem RS wf_induct) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    60
by (rtac (impI RS allI) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    61
by (etac tranclE 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    62
by (fast_tac HOL_cs 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    63
by (fast_tac HOL_cs 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    64
qed "wf_trancl";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    65
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    66
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    67
(** cut **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    68
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    69
(*This rewrite rule works upon formulae; thus it requires explicit use of
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    70
  H_cong to expose the equality*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    71
goalw WF.thy [cut_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    72
    "(cut f r x = cut g r x) = (!y. <y,x>:r --> f(y)=g(y))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    73
by(simp_tac (HOL_ss addsimps [expand_fun_eq]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    74
                    setloop (split_tac [expand_if])) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    75
qed "cut_cut_eq";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    76
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    77
goalw WF.thy [cut_def] "!!x. <x,a>:r ==> (cut f r a)(x) = f(x)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    78
by(asm_simp_tac HOL_ss 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    79
qed "cut_apply";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    80
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    81
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    82
(*** is_recfun ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    83
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    84
goalw WF.thy [is_recfun_def,cut_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    85
    "!!f. [| is_recfun r a H f;  ~<b,a>:r |] ==> f(b) = (@z.True)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    86
by (etac ssubst 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    87
by(asm_simp_tac HOL_ss 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    88
qed "is_recfun_undef";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    89
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    90
(*eresolve_tac transD solves <a,b>:r using transitivity AT MOST ONCE
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    91
  mp amd allE  instantiate induction hypotheses*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    92
fun indhyp_tac hyps =
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    93
    ares_tac (TrueI::hyps) ORELSE' 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    94
    (cut_facts_tac hyps THEN'
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    95
       DEPTH_SOLVE_1 o (ares_tac [TrueI] ORELSE'
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    96
		        eresolve_tac [transD, mp, allE]));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    97
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    98
(*** NOTE! some simplifications need a different finish_tac!! ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    99
fun indhyp_tac hyps =
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   100
    resolve_tac (TrueI::refl::hyps) ORELSE' 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   101
    (cut_facts_tac hyps THEN'
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   102
       DEPTH_SOLVE_1 o (ares_tac [TrueI] ORELSE'
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   103
		        eresolve_tac [transD, mp, allE]));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   104
val wf_super_ss = HOL_ss setsolver indhyp_tac;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   105
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   106
val prems = goalw WF.thy [is_recfun_def,cut_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   107
    "[| wf(r);  trans(r);  is_recfun r a H f;  is_recfun r b H g |] ==> \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   108
    \ <x,a>:r --> <x,b>:r --> f(x)=g(x)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   109
by (cut_facts_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   110
by (etac wf_induct 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   111
by (REPEAT (rtac impI 1 ORELSE etac ssubst 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   112
by (asm_simp_tac (wf_super_ss addcongs [if_cong]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   113
qed "is_recfun_equal_lemma";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   114
bind_thm ("is_recfun_equal", (is_recfun_equal_lemma RS mp RS mp));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   115
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   116
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   117
val prems as [wfr,transr,recfa,recgb,_] = goalw WF.thy [cut_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   118
    "[| wf(r);  trans(r); \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   119
\       is_recfun r a H f;  is_recfun r b H g;  <b,a>:r |] ==> \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   120
\    cut f r b = g";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   121
val gundef = recgb RS is_recfun_undef
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   122
and fisg   = recgb RS (recfa RS (transr RS (wfr RS is_recfun_equal)));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   123
by (cut_facts_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   124
by (rtac ext 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   125
by (asm_simp_tac (wf_super_ss addsimps [gundef,fisg]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   126
                              setloop (split_tac [expand_if])) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   127
qed "is_recfun_cut";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   128
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   129
(*** Main Existence Lemma -- Basic Properties of the_recfun ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   130
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   131
val prems = goalw WF.thy [the_recfun_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   132
    "is_recfun r a H f ==> is_recfun r a H (the_recfun r a H)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   133
by (res_inst_tac [("P", "is_recfun r a H")] selectI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   134
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   135
qed "is_the_recfun";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   136
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   137
val prems = goal WF.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   138
    "[| wf(r);  trans(r) |] ==> is_recfun r a H (the_recfun r a H)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   139
by (cut_facts_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   140
by (wf_ind_tac "a" prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   141
by (res_inst_tac [("f", "cut (%y. wftrec r y H) r a1")] is_the_recfun 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   142
by (rewrite_goals_tac [is_recfun_def, wftrec_def]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   143
by (rtac (cut_cut_eq RS ssubst) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   144
(*Applying the substitution: must keep the quantified assumption!!*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   145
by (EVERY1 [strip_tac, rtac H_cong1, rtac allE, atac,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   146
            etac (mp RS ssubst), atac]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   147
by (fold_tac [is_recfun_def]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   148
by (asm_simp_tac (wf_super_ss addsimps[cut_apply,is_recfun_cut,cut_cut_eq]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   149
qed "unfold_the_recfun";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   150
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   151
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   152
(*Beware incompleteness of unification!*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   153
val prems = goal WF.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   154
    "[| wf(r);  trans(r);  <c,a>:r;  <c,b>:r |] \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   155
\    ==> the_recfun r a H c = the_recfun r b H c";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   156
by (DEPTH_SOLVE (ares_tac (prems@[is_recfun_equal,unfold_the_recfun]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   157
qed "the_recfun_equal";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   158
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   159
val prems = goal WF.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   160
    "[| wf(r); trans(r); <b,a>:r |] \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   161
\    ==> cut (the_recfun r a H) r b = the_recfun r b H";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   162
by (REPEAT (ares_tac (prems@[is_recfun_cut,unfold_the_recfun]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   163
qed "the_recfun_cut";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   164
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   165
(*** Unfolding wftrec ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   166
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   167
goalw WF.thy [wftrec_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   168
    "!!r. [| wf(r);  trans(r) |] ==> \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   169
\    wftrec r a H = H a (cut (%x.wftrec r x H) r a)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   170
by (EVERY1 [stac (rewrite_rule [is_recfun_def] unfold_the_recfun),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   171
	    REPEAT o atac, rtac H_cong1]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   172
by (asm_simp_tac (HOL_ss addsimps [cut_cut_eq,the_recfun_cut]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   173
qed "wftrec";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   174
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   175
(*Unused but perhaps interesting*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   176
val prems = goal WF.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   177
    "[| wf(r);  trans(r);  !!f x. H x (cut f r x) = H x f |] ==> \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   178
\		wftrec r a H = H a (%x.wftrec r x H)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   179
by (rtac (wftrec RS trans) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   180
by (REPEAT (resolve_tac prems 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   181
qed "wftrec2";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   182
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   183
(** Removal of the premise trans(r) **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   184
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   185
goalw WF.thy [wfrec_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   186
    "!!r. wf(r) ==> wfrec r a H = H a (cut (%x.wfrec r x H) r a)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   187
by (etac (wf_trancl RS wftrec RS ssubst) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   188
by (rtac trans_trancl 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   189
by (rtac (refl RS H_cong) 1);    (*expose the equality of cuts*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   190
by (simp_tac (HOL_ss addsimps [cut_cut_eq, cut_apply, r_into_trancl]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   191
qed "wfrec";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   192
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   193
(*This form avoids giant explosions in proofs.  NOTE USE OF == *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   194
val rew::prems = goal WF.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   195
    "[| !!x. f(x)==wfrec r x H;  wf(r) |] ==> f(a) = H a (cut (%x.f(x)) r a)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   196
by (rewtac rew);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   197
by (REPEAT (resolve_tac (prems@[wfrec]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   198
qed "def_wfrec";