author | paulson |
Sat, 01 Nov 1997 12:59:06 +0100 | |
changeset 4059 | 59c1422c9da5 |
parent 3919 | c036caebfc75 |
child 4089 | 96fba19bcbe2 |
permissions | -rw-r--r-- |
1475 | 1 |
(* Title: HOL/wf.ML |
923 | 2 |
ID: $Id$ |
1475 | 3 |
Author: Tobias Nipkow, with minor changes by Konrad Slind |
4 |
Copyright 1992 University of Cambridge/1995 TU Munich |
|
923 | 5 |
|
3198 | 6 |
Wellfoundedness, induction, and recursion |
923 | 7 |
*) |
8 |
||
9 |
open WF; |
|
10 |
||
950 | 11 |
val H_cong = read_instantiate [("f","H")] (standard(refl RS cong RS cong)); |
923 | 12 |
val H_cong1 = refl RS H_cong; |
13 |
||
14 |
(*Restriction to domain A. If r is well-founded over A then wf(r)*) |
|
15 |
val [prem1,prem2] = goalw WF.thy [wf_def] |
|
1642 | 16 |
"[| r <= A Times A; \ |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
950
diff
changeset
|
17 |
\ !!x P. [| ! x. (! y. (y,x) : r --> P(y)) --> P(x); x:A |] ==> P(x) |] \ |
923 | 18 |
\ ==> wf(r)"; |
3708 | 19 |
by (Clarify_tac 1); |
923 | 20 |
by (rtac allE 1); |
21 |
by (assume_tac 1); |
|
1786
8a31d85d27b8
best_tac, deepen_tac and safe_tac now also use default claset.
berghofe
parents:
1771
diff
changeset
|
22 |
by (best_tac (!claset addSEs [prem1 RS subsetD RS SigmaE2] addIs [prem2]) 1); |
923 | 23 |
qed "wfI"; |
24 |
||
25 |
val major::prems = goalw WF.thy [wf_def] |
|
26 |
"[| wf(r); \ |
|
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
950
diff
changeset
|
27 |
\ !!x.[| ! y. (y,x): r --> P(y) |] ==> P(x) \ |
923 | 28 |
\ |] ==> P(a)"; |
29 |
by (rtac (major RS spec RS mp RS spec) 1); |
|
2935 | 30 |
by (blast_tac (!claset addIs prems) 1); |
923 | 31 |
qed "wf_induct"; |
32 |
||
33 |
(*Perform induction on i, then prove the wf(r) subgoal using prems. *) |
|
34 |
fun wf_ind_tac a prems i = |
|
35 |
EVERY [res_inst_tac [("a",a)] wf_induct i, |
|
1465 | 36 |
rename_last_tac a ["1"] (i+1), |
37 |
ares_tac prems i]; |
|
923 | 38 |
|
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
950
diff
changeset
|
39 |
val prems = goal WF.thy "[| wf(r); (a,x):r; (x,a):r |] ==> P"; |
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
950
diff
changeset
|
40 |
by (subgoal_tac "! x. (a,x):r --> (x,a):r --> P" 1); |
2935 | 41 |
by (blast_tac (!claset addIs prems) 1); |
923 | 42 |
by (wf_ind_tac "a" prems 1); |
2935 | 43 |
by (Blast_tac 1); |
923 | 44 |
qed "wf_asym"; |
45 |
||
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
950
diff
changeset
|
46 |
val prems = goal WF.thy "[| wf(r); (a,a): r |] ==> P"; |
923 | 47 |
by (rtac wf_asym 1); |
48 |
by (REPEAT (resolve_tac prems 1)); |
|
1618 | 49 |
qed "wf_irrefl"; |
923 | 50 |
|
1475 | 51 |
(*transitive closure of a wf relation is wf! *) |
923 | 52 |
val [prem] = goal WF.thy "wf(r) ==> wf(r^+)"; |
53 |
by (rewtac wf_def); |
|
3708 | 54 |
by (Clarify_tac 1); |
923 | 55 |
(*must retain the universal formula for later use!*) |
56 |
by (rtac allE 1 THEN assume_tac 1); |
|
57 |
by (etac mp 1); |
|
58 |
by (res_inst_tac [("a","x")] (prem RS wf_induct) 1); |
|
59 |
by (rtac (impI RS allI) 1); |
|
60 |
by (etac tranclE 1); |
|
2935 | 61 |
by (Blast_tac 1); |
62 |
by (Blast_tac 1); |
|
923 | 63 |
qed "wf_trancl"; |
64 |
||
65 |
||
3198 | 66 |
(*---------------------------------------------------------------------------- |
67 |
* Minimal-element characterization of well-foundedness |
|
68 |
*---------------------------------------------------------------------------*) |
|
69 |
||
70 |
val wfr::_ = goalw WF.thy [wf_def] |
|
71 |
"wf r ==> x:Q --> (? z:Q. ! y. (y,z):r --> y~:Q)"; |
|
72 |
by (rtac (wfr RS spec RS mp RS spec) 1); |
|
73 |
by (Blast_tac 1); |
|
74 |
val lemma1 = result(); |
|
75 |
||
76 |
goalw WF.thy [wf_def] |
|
77 |
"!!r. (! Q x. x:Q --> (? z:Q. ! y. (y,z):r --> y~:Q)) ==> wf r"; |
|
3708 | 78 |
by (Clarify_tac 1); |
3198 | 79 |
by (dres_inst_tac [("x", "{x. ~ P x}")] spec 1); |
80 |
by (Blast_tac 1); |
|
81 |
val lemma2 = result(); |
|
82 |
||
83 |
goal WF.thy "wf r = (! Q x. x:Q --> (? z:Q. ! y. (y,z):r --> y~:Q))"; |
|
84 |
by (blast_tac (!claset addSIs [lemma1, lemma2]) 1); |
|
85 |
qed "wf_eq_minimal"; |
|
86 |
||
3413
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
87 |
(*--------------------------------------------------------------------------- |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
88 |
* Wellfoundedness of subsets |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
89 |
*---------------------------------------------------------------------------*) |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
90 |
|
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
91 |
goal thy "!!r. [| wf(r); p<=r |] ==> wf(p)"; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
92 |
by (full_simp_tac (!simpset addsimps [wf_eq_minimal]) 1); |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
93 |
by (Fast_tac 1); |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
94 |
qed "wf_subset"; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
95 |
|
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
96 |
(*--------------------------------------------------------------------------- |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
97 |
* Wellfoundedness of the empty relation. |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
98 |
*---------------------------------------------------------------------------*) |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
99 |
|
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
100 |
goal thy "wf({})"; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
101 |
by (simp_tac (!simpset addsimps [wf_def]) 1); |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
102 |
qed "wf_empty"; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
103 |
AddSIs [wf_empty]; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
104 |
|
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
105 |
(*--------------------------------------------------------------------------- |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
106 |
* Wellfoundedness of `insert' |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
107 |
*---------------------------------------------------------------------------*) |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
108 |
|
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
109 |
goal WF.thy "wf(insert (y,x) r) = (wf(r) & (x,y) ~: r^*)"; |
3457 | 110 |
by (rtac iffI 1); |
111 |
by (blast_tac (!claset addEs [wf_trancl RS wf_irrefl] addIs |
|
3413
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
112 |
[rtrancl_into_trancl1,wf_subset,impOfSubs rtrancl_mono]) 1); |
3457 | 113 |
by (asm_full_simp_tac (!simpset addsimps [wf_eq_minimal]) 1); |
114 |
by (safe_tac (!claset)); |
|
115 |
by (EVERY1[rtac allE, atac, etac impE, Blast_tac]); |
|
116 |
by (etac bexE 1); |
|
117 |
by (rename_tac "a" 1); |
|
118 |
by (case_tac "a = x" 1); |
|
119 |
by (res_inst_tac [("x","a")]bexI 2); |
|
120 |
by (assume_tac 3); |
|
121 |
by (Blast_tac 2); |
|
122 |
by (case_tac "y:Q" 1); |
|
123 |
by (Blast_tac 2); |
|
4059 | 124 |
by (res_inst_tac [("x","{z. z:Q & (z,y) : r^*}")] allE 1); |
3457 | 125 |
by (assume_tac 1); |
4059 | 126 |
by (thin_tac "! Q. (? x. x : Q) --> ?P Q" 1); (*essential for speed*) |
127 |
by (blast_tac (!claset addIs [rtrancl_into_rtrancl2]) 1); |
|
3413
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
128 |
qed "wf_insert"; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
129 |
AddIffs [wf_insert]; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
130 |
|
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
131 |
(*** acyclic ***) |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
132 |
|
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
133 |
goalw WF.thy [acyclic_def] |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
134 |
"!!r. wf r ==> acyclic r"; |
3457 | 135 |
by (blast_tac (!claset addEs [wf_trancl RS wf_irrefl]) 1); |
3413
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
136 |
qed "wf_acyclic"; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
137 |
|
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
138 |
goalw WF.thy [acyclic_def] |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
139 |
"acyclic(insert (y,x) r) = (acyclic r & (x,y) ~: r^*)"; |
3457 | 140 |
by (simp_tac (!simpset addsimps [trancl_insert]) 1); |
141 |
by (blast_tac (!claset addEs [make_elim rtrancl_trans]) 1); |
|
3413
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
142 |
qed "acyclic_insert"; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
143 |
AddIffs [acyclic_insert]; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
144 |
|
3439 | 145 |
goalw WF.thy [acyclic_def] "acyclic(r^-1) = acyclic r"; |
3457 | 146 |
by (simp_tac (!simpset addsimps [trancl_inverse]) 1); |
3439 | 147 |
qed "acyclic_inverse"; |
3198 | 148 |
|
923 | 149 |
(** cut **) |
150 |
||
151 |
(*This rewrite rule works upon formulae; thus it requires explicit use of |
|
152 |
H_cong to expose the equality*) |
|
153 |
goalw WF.thy [cut_def] |
|
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
950
diff
changeset
|
154 |
"(cut f r x = cut g r x) = (!y. (y,x):r --> f(y)=g(y))"; |
3919 | 155 |
by (simp_tac (HOL_ss addsimps [expand_fun_eq] addsplits [expand_if]) 1); |
1475 | 156 |
qed "cuts_eq"; |
923 | 157 |
|
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
950
diff
changeset
|
158 |
goalw WF.thy [cut_def] "!!x. (x,a):r ==> (cut f r a)(x) = f(x)"; |
1552 | 159 |
by (asm_simp_tac HOL_ss 1); |
923 | 160 |
qed "cut_apply"; |
161 |
||
162 |
(*** is_recfun ***) |
|
163 |
||
164 |
goalw WF.thy [is_recfun_def,cut_def] |
|
3320 | 165 |
"!!f. [| is_recfun r H a f; ~(b,a):r |] ==> f(b) = arbitrary"; |
923 | 166 |
by (etac ssubst 1); |
1552 | 167 |
by (asm_simp_tac HOL_ss 1); |
923 | 168 |
qed "is_recfun_undef"; |
169 |
||
170 |
(*** NOTE! some simplifications need a different finish_tac!! ***) |
|
171 |
fun indhyp_tac hyps = |
|
172 |
(cut_facts_tac hyps THEN' |
|
173 |
DEPTH_SOLVE_1 o (ares_tac [TrueI] ORELSE' |
|
1465 | 174 |
eresolve_tac [transD, mp, allE])); |
2637
e9b203f854ae
reflecting my recent changes of the simplifier and classical reasoner
oheimb
parents:
2031
diff
changeset
|
175 |
val wf_super_ss = HOL_ss addSolver indhyp_tac; |
923 | 176 |
|
177 |
val prems = goalw WF.thy [is_recfun_def,cut_def] |
|
1475 | 178 |
"[| wf(r); trans(r); is_recfun r H a f; is_recfun r H b g |] ==> \ |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
950
diff
changeset
|
179 |
\ (x,a):r --> (x,b):r --> f(x)=g(x)"; |
923 | 180 |
by (cut_facts_tac prems 1); |
181 |
by (etac wf_induct 1); |
|
182 |
by (REPEAT (rtac impI 1 ORELSE etac ssubst 1)); |
|
183 |
by (asm_simp_tac (wf_super_ss addcongs [if_cong]) 1); |
|
1485
240cc98b94a7
Added qed_spec_mp to avoid renaming of bound vars in 'th RS spec'
nipkow
parents:
1475
diff
changeset
|
184 |
qed_spec_mp "is_recfun_equal"; |
923 | 185 |
|
186 |
||
187 |
val prems as [wfr,transr,recfa,recgb,_] = goalw WF.thy [cut_def] |
|
188 |
"[| wf(r); trans(r); \ |
|
1475 | 189 |
\ is_recfun r H a f; is_recfun r H b g; (b,a):r |] ==> \ |
923 | 190 |
\ cut f r b = g"; |
191 |
val gundef = recgb RS is_recfun_undef |
|
192 |
and fisg = recgb RS (recfa RS (transr RS (wfr RS is_recfun_equal))); |
|
193 |
by (cut_facts_tac prems 1); |
|
194 |
by (rtac ext 1); |
|
195 |
by (asm_simp_tac (wf_super_ss addsimps [gundef,fisg] |
|
3919 | 196 |
addsplits [expand_if]) 1); |
923 | 197 |
qed "is_recfun_cut"; |
198 |
||
199 |
(*** Main Existence Lemma -- Basic Properties of the_recfun ***) |
|
200 |
||
201 |
val prems = goalw WF.thy [the_recfun_def] |
|
1475 | 202 |
"is_recfun r H a f ==> is_recfun r H a (the_recfun r H a)"; |
203 |
by (res_inst_tac [("P", "is_recfun r H a")] selectI 1); |
|
923 | 204 |
by (resolve_tac prems 1); |
205 |
qed "is_the_recfun"; |
|
206 |
||
207 |
val prems = goal WF.thy |
|
1475 | 208 |
"[| wf(r); trans(r) |] ==> is_recfun r H a (the_recfun r H a)"; |
209 |
by (cut_facts_tac prems 1); |
|
210 |
by (wf_ind_tac "a" prems 1); |
|
211 |
by (res_inst_tac [("f","cut (%y. H (the_recfun r H y) y) r a1")] |
|
212 |
is_the_recfun 1); |
|
1552 | 213 |
by (rewtac is_recfun_def); |
2031 | 214 |
by (stac cuts_eq 1); |
1475 | 215 |
by (rtac allI 1); |
216 |
by (rtac impI 1); |
|
217 |
by (res_inst_tac [("f1","H"),("x","y")](arg_cong RS fun_cong) 1); |
|
218 |
by (subgoal_tac |
|
219 |
"the_recfun r H y = cut(%x. H(cut(the_recfun r H y) r x) x) r y" 1); |
|
220 |
by (etac allE 2); |
|
221 |
by (dtac impE 2); |
|
222 |
by (atac 2); |
|
223 |
by (atac 3); |
|
224 |
by (atac 2); |
|
225 |
by (etac ssubst 1); |
|
226 |
by (simp_tac (HOL_ss addsimps [cuts_eq]) 1); |
|
227 |
by (rtac allI 1); |
|
228 |
by (rtac impI 1); |
|
229 |
by (asm_simp_tac (wf_super_ss addsimps[cut_apply,is_recfun_cut,cuts_eq]) 1); |
|
230 |
by (res_inst_tac [("f1","H"),("x","ya")](arg_cong RS fun_cong) 1); |
|
231 |
by (fold_tac [is_recfun_def]); |
|
232 |
by (asm_simp_tac (wf_super_ss addsimps[cut_apply,is_recfun_cut,cuts_eq]) 1); |
|
923 | 233 |
qed "unfold_the_recfun"; |
234 |
||
1475 | 235 |
val unwind1_the_recfun = rewrite_rule[is_recfun_def] unfold_the_recfun; |
923 | 236 |
|
1475 | 237 |
(*--------------Old proof----------------------------------------------------- |
923 | 238 |
val prems = goal WF.thy |
1475 | 239 |
"[| wf(r); trans(r) |] ==> is_recfun r H a (the_recfun r H a)"; |
240 |
by (cut_facts_tac prems 1); |
|
241 |
by (wf_ind_tac "a" prems 1); |
|
242 |
by (res_inst_tac [("f", "cut (%y. wftrec r H y) r a1")] is_the_recfun 1); |
|
243 |
by (rewrite_goals_tac [is_recfun_def, wftrec_def]); |
|
2031 | 244 |
by (stac cuts_eq 1); |
1475 | 245 |
(*Applying the substitution: must keep the quantified assumption!!*) |
3708 | 246 |
by (EVERY1 [Clarify_tac, rtac H_cong1, rtac allE, atac, |
1475 | 247 |
etac (mp RS ssubst), atac]); |
248 |
by (fold_tac [is_recfun_def]); |
|
249 |
by (asm_simp_tac (wf_super_ss addsimps[cut_apply,is_recfun_cut,cuts_eq]) 1); |
|
250 |
qed "unfold_the_recfun"; |
|
251 |
---------------------------------------------------------------------------*) |
|
923 | 252 |
|
253 |
(** Removal of the premise trans(r) **) |
|
1475 | 254 |
val th = rewrite_rule[is_recfun_def] |
255 |
(trans_trancl RSN (2,(wf_trancl RS unfold_the_recfun))); |
|
923 | 256 |
|
257 |
goalw WF.thy [wfrec_def] |
|
1475 | 258 |
"!!r. wf(r) ==> wfrec r H a = H (cut (wfrec r H) r a) a"; |
259 |
by (rtac H_cong 1); |
|
260 |
by (rtac refl 2); |
|
261 |
by (simp_tac (HOL_ss addsimps [cuts_eq]) 1); |
|
262 |
by (rtac allI 1); |
|
263 |
by (rtac impI 1); |
|
264 |
by (simp_tac(HOL_ss addsimps [wfrec_def]) 1); |
|
265 |
by (res_inst_tac [("a1","a")] (th RS ssubst) 1); |
|
266 |
by (atac 1); |
|
267 |
by (forward_tac[wf_trancl] 1); |
|
268 |
by (forward_tac[r_into_trancl] 1); |
|
269 |
by (asm_simp_tac (HOL_ss addsimps [cut_apply]) 1); |
|
270 |
by (rtac H_cong 1); (*expose the equality of cuts*) |
|
271 |
by (rtac refl 2); |
|
272 |
by (simp_tac (HOL_ss addsimps [cuts_eq, cut_apply, r_into_trancl]) 1); |
|
3708 | 273 |
by (Clarify_tac 1); |
1485
240cc98b94a7
Added qed_spec_mp to avoid renaming of bound vars in 'th RS spec'
nipkow
parents:
1475
diff
changeset
|
274 |
by (res_inst_tac [("r","r^+")] is_recfun_equal 1); |
1475 | 275 |
by (atac 1); |
276 |
by (rtac trans_trancl 1); |
|
277 |
by (rtac unfold_the_recfun 1); |
|
278 |
by (atac 1); |
|
279 |
by (rtac trans_trancl 1); |
|
280 |
by (rtac unfold_the_recfun 1); |
|
281 |
by (atac 1); |
|
282 |
by (rtac trans_trancl 1); |
|
283 |
by (rtac transD 1); |
|
284 |
by (rtac trans_trancl 1); |
|
285 |
by (forw_inst_tac [("a","ya")] r_into_trancl 1); |
|
286 |
by (atac 1); |
|
287 |
by (atac 1); |
|
288 |
by (forw_inst_tac [("a","ya")] r_into_trancl 1); |
|
289 |
by (atac 1); |
|
290 |
qed "wfrec"; |
|
291 |
||
292 |
(*--------------Old proof----------------------------------------------------- |
|
293 |
goalw WF.thy [wfrec_def] |
|
294 |
"!!r. wf(r) ==> wfrec r H a = H (cut (wfrec r H) r a) a"; |
|
923 | 295 |
by (etac (wf_trancl RS wftrec RS ssubst) 1); |
296 |
by (rtac trans_trancl 1); |
|
297 |
by (rtac (refl RS H_cong) 1); (*expose the equality of cuts*) |
|
1475 | 298 |
by (simp_tac (HOL_ss addsimps [cuts_eq, cut_apply, r_into_trancl]) 1); |
923 | 299 |
qed "wfrec"; |
1475 | 300 |
---------------------------------------------------------------------------*) |
923 | 301 |
|
1475 | 302 |
(*--------------------------------------------------------------------------- |
303 |
* This form avoids giant explosions in proofs. NOTE USE OF == |
|
304 |
*---------------------------------------------------------------------------*) |
|
923 | 305 |
val rew::prems = goal WF.thy |
1475 | 306 |
"[| f==wfrec r H; wf(r) |] ==> f(a) = H (cut f r a) a"; |
923 | 307 |
by (rewtac rew); |
308 |
by (REPEAT (resolve_tac (prems@[wfrec]) 1)); |
|
309 |
qed "def_wfrec"; |
|
1475 | 310 |
|
3198 | 311 |
|
312 |
(**** TFL variants ****) |
|
313 |
||
314 |
goal WF.thy |
|
315 |
"!R. wf R --> (!P. (!x. (!y. (y,x):R --> P y) --> P x) --> (!x. P x))"; |
|
3708 | 316 |
by (Clarify_tac 1); |
3198 | 317 |
by (res_inst_tac [("r","R"),("P","P"), ("a","x")] wf_induct 1); |
318 |
by (assume_tac 1); |
|
319 |
by (Blast_tac 1); |
|
320 |
qed"tfl_wf_induct"; |
|
321 |
||
322 |
goal WF.thy "!f R. (x,a):R --> (cut f R a)(x) = f(x)"; |
|
3708 | 323 |
by (Clarify_tac 1); |
3198 | 324 |
by (rtac cut_apply 1); |
325 |
by (assume_tac 1); |
|
326 |
qed"tfl_cut_apply"; |
|
327 |
||
328 |
goal WF.thy "!M R f. (f=wfrec R M) --> wf R --> (!x. f x = M (cut f R x) x)"; |
|
3708 | 329 |
by (Clarify_tac 1); |
330 |
be wfrec 1; |
|
3198 | 331 |
qed "tfl_wfrec"; |