author | oheimb |
Thu, 24 Sep 1998 17:17:14 +0200 | |
changeset 5553 | ae42b36a50c2 |
parent 5521 | 7970832271cc |
child 5579 | 32f99ca617b7 |
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)*) |
|
5316 | 15 |
val [prem1,prem2] = Goalw [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); |
|
4089 | 22 |
by (best_tac (claset() addSEs [prem1 RS subsetD RS SigmaE2] addIs [prem2]) 1); |
923 | 23 |
qed "wfI"; |
24 |
||
5316 | 25 |
val major::prems = Goalw [wf_def] |
923 | 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); |
|
4089 | 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 |
|
5452 | 39 |
Goal "wf(r) ==> ! x. (a,x):r --> (x,a)~:r"; |
5316 | 40 |
by (wf_ind_tac "a" [] 1); |
2935 | 41 |
by (Blast_tac 1); |
5452 | 42 |
qed_spec_mp "wf_not_sym"; |
43 |
||
44 |
(* [| wf(r); (a,x):r; ~P ==> (x,a):r |] ==> P *) |
|
45 |
bind_thm ("wf_asym", wf_not_sym RS swap); |
|
923 | 46 |
|
5316 | 47 |
Goal "[| wf(r); (a,a): r |] ==> P"; |
48 |
by (blast_tac (claset() addEs [wf_asym]) 1); |
|
1618 | 49 |
qed "wf_irrefl"; |
923 | 50 |
|
1475 | 51 |
(*transitive closure of a wf relation is wf! *) |
5316 | 52 |
Goal "wf(r) ==> wf(r^+)"; |
53 |
by (stac wf_def 1); |
|
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); |
|
5316 | 58 |
by (eres_inst_tac [("a","x")] wf_induct 1); |
923 | 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 |
||
4762 | 66 |
val wf_converse_trancl = prove_goal thy |
67 |
"!!X. wf (r^-1) ==> wf ((r^+)^-1)" (K [ |
|
68 |
stac (trancl_converse RS sym) 1, |
|
69 |
etac wf_trancl 1]); |
|
70 |
||
3198 | 71 |
(*---------------------------------------------------------------------------- |
72 |
* Minimal-element characterization of well-foundedness |
|
73 |
*---------------------------------------------------------------------------*) |
|
74 |
||
5316 | 75 |
Goalw [wf_def] "wf r ==> x:Q --> (? z:Q. ! y. (y,z):r --> y~:Q)"; |
5318 | 76 |
by (dtac spec 1); |
5316 | 77 |
by (etac (mp RS spec) 1); |
3198 | 78 |
by (Blast_tac 1); |
79 |
val lemma1 = result(); |
|
80 |
||
5316 | 81 |
Goalw [wf_def] "(! Q x. x:Q --> (? z:Q. ! y. (y,z):r --> y~:Q)) ==> wf r"; |
3708 | 82 |
by (Clarify_tac 1); |
3198 | 83 |
by (dres_inst_tac [("x", "{x. ~ P x}")] spec 1); |
84 |
by (Blast_tac 1); |
|
85 |
val lemma2 = result(); |
|
86 |
||
5069 | 87 |
Goal "wf r = (! Q x. x:Q --> (? z:Q. ! y. (y,z):r --> y~:Q))"; |
4089 | 88 |
by (blast_tac (claset() addSIs [lemma1, lemma2]) 1); |
3198 | 89 |
qed "wf_eq_minimal"; |
90 |
||
3413
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
91 |
(*--------------------------------------------------------------------------- |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
92 |
* Wellfoundedness of subsets |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
93 |
*---------------------------------------------------------------------------*) |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
94 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
95 |
Goal "[| wf(r); p<=r |] ==> wf(p)"; |
4089 | 96 |
by (full_simp_tac (simpset() addsimps [wf_eq_minimal]) 1); |
3413
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
97 |
by (Fast_tac 1); |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
98 |
qed "wf_subset"; |
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 |
(*--------------------------------------------------------------------------- |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
101 |
* Wellfoundedness of the empty relation. |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
102 |
*---------------------------------------------------------------------------*) |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
103 |
|
5069 | 104 |
Goal "wf({})"; |
4089 | 105 |
by (simp_tac (simpset() addsimps [wf_def]) 1); |
3413
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
106 |
qed "wf_empty"; |
5281 | 107 |
AddIffs [wf_empty]; |
3413
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 |
(*--------------------------------------------------------------------------- |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
110 |
* Wellfoundedness of `insert' |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
111 |
*---------------------------------------------------------------------------*) |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
112 |
|
5069 | 113 |
Goal "wf(insert (y,x) r) = (wf(r) & (x,y) ~: r^*)"; |
3457 | 114 |
by (rtac iffI 1); |
4350
1983e4054fd8
updated for latest Blast_tac, which treats equality differently
paulson
parents:
4153
diff
changeset
|
115 |
by (blast_tac (claset() addEs [wf_trancl RS wf_irrefl] |
1983e4054fd8
updated for latest Blast_tac, which treats equality differently
paulson
parents:
4153
diff
changeset
|
116 |
addIs [rtrancl_into_trancl1,wf_subset,impOfSubs rtrancl_mono]) 1); |
4089 | 117 |
by (asm_full_simp_tac (simpset() addsimps [wf_eq_minimal]) 1); |
4153 | 118 |
by Safe_tac; |
3457 | 119 |
by (EVERY1[rtac allE, atac, etac impE, Blast_tac]); |
120 |
by (etac bexE 1); |
|
121 |
by (rename_tac "a" 1); |
|
122 |
by (case_tac "a = x" 1); |
|
123 |
by (res_inst_tac [("x","a")]bexI 2); |
|
124 |
by (assume_tac 3); |
|
125 |
by (Blast_tac 2); |
|
126 |
by (case_tac "y:Q" 1); |
|
127 |
by (Blast_tac 2); |
|
4059 | 128 |
by (res_inst_tac [("x","{z. z:Q & (z,y) : r^*}")] allE 1); |
3457 | 129 |
by (assume_tac 1); |
4059 | 130 |
by (thin_tac "! Q. (? x. x : Q) --> ?P Q" 1); (*essential for speed*) |
4350
1983e4054fd8
updated for latest Blast_tac, which treats equality differently
paulson
parents:
4153
diff
changeset
|
131 |
(*Blast_tac with new substOccur fails*) |
1983e4054fd8
updated for latest Blast_tac, which treats equality differently
paulson
parents:
4153
diff
changeset
|
132 |
by (best_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
|
133 |
qed "wf_insert"; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
134 |
AddIffs [wf_insert]; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
135 |
|
5281 | 136 |
(*--------------------------------------------------------------------------- |
137 |
* Wellfoundedness of `disjoint union' |
|
138 |
*---------------------------------------------------------------------------*) |
|
139 |
||
5330 | 140 |
(*Intuition behind this proof for the case of binary union: |
141 |
||
142 |
Goal: find an (R u S)-min element of a nonempty subset A. |
|
143 |
by case distinction: |
|
144 |
1. There is a step a -R-> b with a,b : A. |
|
145 |
Pick an R-min element z of the (nonempty) set {a:A | EX b:A. a -R-> b}. |
|
146 |
By definition, there is z':A s.t. z -R-> z'. Because z is R-min in the |
|
147 |
subset, z' must be R-min in A. Because z' has an R-predecessor, it cannot |
|
148 |
have an S-successor and is thus S-min in A as well. |
|
149 |
2. There is no such step. |
|
150 |
Pick an S-min element of A. In this case it must be an R-min |
|
151 |
element of A as well. |
|
152 |
||
153 |
*) |
|
154 |
||
5316 | 155 |
Goal "[| !i:I. wf(r i); \ |
156 |
\ !i:I.!j:I. r i ~= r j --> Domain(r i) Int Range(r j) = {} & \ |
|
157 |
\ Domain(r j) Int Range(r i) = {} \ |
|
158 |
\ |] ==> wf(UN i:I. r i)"; |
|
5318 | 159 |
by (asm_full_simp_tac (HOL_basic_ss addsimps [wf_eq_minimal]) 1); |
160 |
by (Clarify_tac 1); |
|
161 |
by (rename_tac "A a" 1); |
|
162 |
by (case_tac "? i:I. ? a:A. ? b:A. (b,a) : r i" 1); |
|
163 |
by (Clarify_tac 1); |
|
164 |
by (EVERY1[dtac bspec, atac, |
|
5281 | 165 |
eres_inst_tac[("x","{a. a:A & (? b:A. (b,a) : r i)}")]allE]); |
5318 | 166 |
by (EVERY1[etac allE,etac impE]); |
167 |
by (Blast_tac 1); |
|
168 |
by (Clarify_tac 1); |
|
169 |
by (rename_tac "z'" 1); |
|
170 |
by (res_inst_tac [("x","z'")] bexI 1); |
|
171 |
by (assume_tac 2); |
|
172 |
by (Clarify_tac 1); |
|
173 |
by (rename_tac "j" 1); |
|
174 |
by (case_tac "r j = r i" 1); |
|
175 |
by (EVERY1[etac allE,etac impE,atac]); |
|
176 |
by (Asm_full_simp_tac 1); |
|
177 |
by (Blast_tac 1); |
|
178 |
by (blast_tac (claset() addEs [equalityE]) 1); |
|
179 |
by (Asm_full_simp_tac 1); |
|
5521 | 180 |
by (fast_tac (claset() delWrapper "bspec") 1); (*faster than Blast_tac*) |
5281 | 181 |
qed "wf_UN"; |
182 |
||
183 |
Goalw [Union_def] |
|
184 |
"[| !r:R. wf r; \ |
|
185 |
\ !r:R.!s:R. r ~= s --> Domain r Int Range s = {} & \ |
|
186 |
\ Domain s Int Range r = {} \ |
|
187 |
\ |] ==> wf(Union R)"; |
|
5318 | 188 |
by (rtac wf_UN 1); |
189 |
by (Blast_tac 1); |
|
190 |
by (Blast_tac 1); |
|
5281 | 191 |
qed "wf_Union"; |
192 |
||
5316 | 193 |
Goal "[| wf r; wf s; Domain r Int Range s = {}; Domain s Int Range r = {} \ |
194 |
\ |] ==> wf(r Un s)"; |
|
5318 | 195 |
by (rtac (simplify (simpset()) (read_instantiate[("R","{r,s}")]wf_Union)) 1); |
196 |
by (Blast_tac 1); |
|
197 |
by (Blast_tac 1); |
|
5281 | 198 |
qed "wf_Un"; |
199 |
||
200 |
(*--------------------------------------------------------------------------- |
|
201 |
* Wellfoundedness of `image' |
|
202 |
*---------------------------------------------------------------------------*) |
|
203 |
||
204 |
Goal "[| wf r; inj f |] ==> wf(prod_fun f f `` r)"; |
|
5318 | 205 |
by (asm_full_simp_tac (HOL_basic_ss addsimps [wf_eq_minimal]) 1); |
206 |
by (Clarify_tac 1); |
|
207 |
by (case_tac "? p. f p : Q" 1); |
|
208 |
by (eres_inst_tac [("x","{p. f p : Q}")]allE 1); |
|
209 |
by (fast_tac (claset() addDs [injD]) 1); |
|
210 |
by (Blast_tac 1); |
|
5281 | 211 |
qed "wf_prod_fun_image"; |
212 |
||
3413
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
213 |
(*** acyclic ***) |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
214 |
|
4750 | 215 |
val acyclicI = prove_goalw WF.thy [acyclic_def] |
216 |
"!!r. !x. (x, x) ~: r^+ ==> acyclic r" (K [atac 1]); |
|
217 |
||
5069 | 218 |
Goalw [acyclic_def] |
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5143
diff
changeset
|
219 |
"wf r ==> acyclic r"; |
4089 | 220 |
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
|
221 |
qed "wf_acyclic"; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
222 |
|
5452 | 223 |
Goalw [acyclic_def] "acyclic(insert (y,x) r) = (acyclic r & (x,y) ~: r^*)"; |
4089 | 224 |
by (simp_tac (simpset() addsimps [trancl_insert]) 1); |
5452 | 225 |
by (blast_tac (claset() addIs [rtrancl_trans]) 1); |
3413
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
226 |
qed "acyclic_insert"; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
227 |
AddIffs [acyclic_insert]; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
228 |
|
5069 | 229 |
Goalw [acyclic_def] "acyclic(r^-1) = acyclic r"; |
4746 | 230 |
by (simp_tac (simpset() addsimps [trancl_converse]) 1); |
231 |
qed "acyclic_converse"; |
|
3198 | 232 |
|
923 | 233 |
(** cut **) |
234 |
||
235 |
(*This rewrite rule works upon formulae; thus it requires explicit use of |
|
236 |
H_cong to expose the equality*) |
|
5069 | 237 |
Goalw [cut_def] |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
950
diff
changeset
|
238 |
"(cut f r x = cut g r x) = (!y. (y,x):r --> f(y)=g(y))"; |
4686 | 239 |
by (simp_tac (HOL_ss addsimps [expand_fun_eq]) 1); |
1475 | 240 |
qed "cuts_eq"; |
923 | 241 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
242 |
Goalw [cut_def] "(x,a):r ==> (cut f r a)(x) = f(x)"; |
1552 | 243 |
by (asm_simp_tac HOL_ss 1); |
923 | 244 |
qed "cut_apply"; |
245 |
||
246 |
(*** is_recfun ***) |
|
247 |
||
5069 | 248 |
Goalw [is_recfun_def,cut_def] |
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5143
diff
changeset
|
249 |
"[| is_recfun r H a f; ~(b,a):r |] ==> f(b) = arbitrary"; |
923 | 250 |
by (etac ssubst 1); |
1552 | 251 |
by (asm_simp_tac HOL_ss 1); |
923 | 252 |
qed "is_recfun_undef"; |
253 |
||
254 |
(*** NOTE! some simplifications need a different finish_tac!! ***) |
|
255 |
fun indhyp_tac hyps = |
|
256 |
(cut_facts_tac hyps THEN' |
|
257 |
DEPTH_SOLVE_1 o (ares_tac [TrueI] ORELSE' |
|
1465 | 258 |
eresolve_tac [transD, mp, allE])); |
2637
e9b203f854ae
reflecting my recent changes of the simplifier and classical reasoner
oheimb
parents:
2031
diff
changeset
|
259 |
val wf_super_ss = HOL_ss addSolver indhyp_tac; |
923 | 260 |
|
5316 | 261 |
Goalw [is_recfun_def,cut_def] |
1475 | 262 |
"[| 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
|
263 |
\ (x,a):r --> (x,b):r --> f(x)=g(x)"; |
923 | 264 |
by (etac wf_induct 1); |
265 |
by (REPEAT (rtac impI 1 ORELSE etac ssubst 1)); |
|
266 |
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
|
267 |
qed_spec_mp "is_recfun_equal"; |
923 | 268 |
|
269 |
||
270 |
val prems as [wfr,transr,recfa,recgb,_] = goalw WF.thy [cut_def] |
|
271 |
"[| wf(r); trans(r); \ |
|
1475 | 272 |
\ is_recfun r H a f; is_recfun r H b g; (b,a):r |] ==> \ |
923 | 273 |
\ cut f r b = g"; |
274 |
val gundef = recgb RS is_recfun_undef |
|
275 |
and fisg = recgb RS (recfa RS (transr RS (wfr RS is_recfun_equal))); |
|
276 |
by (cut_facts_tac prems 1); |
|
277 |
by (rtac ext 1); |
|
4686 | 278 |
by (asm_simp_tac (wf_super_ss addsimps [gundef,fisg]) 1); |
923 | 279 |
qed "is_recfun_cut"; |
280 |
||
281 |
(*** Main Existence Lemma -- Basic Properties of the_recfun ***) |
|
282 |
||
5316 | 283 |
Goalw [the_recfun_def] |
1475 | 284 |
"is_recfun r H a f ==> is_recfun r H a (the_recfun r H a)"; |
5316 | 285 |
by (eres_inst_tac [("P", "is_recfun r H a")] selectI 1); |
923 | 286 |
qed "is_the_recfun"; |
287 |
||
5316 | 288 |
Goal "[| wf(r); trans(r) |] ==> is_recfun r H a (the_recfun r H a)"; |
289 |
by (wf_ind_tac "a" [] 1); |
|
4821 | 290 |
by (res_inst_tac [("f","cut (%y. H (the_recfun r H y) y) r a1")] |
291 |
is_the_recfun 1); |
|
292 |
by (rewtac is_recfun_def); |
|
293 |
by (stac cuts_eq 1); |
|
294 |
by (Clarify_tac 1); |
|
295 |
by (rtac (refl RSN (2,H_cong)) 1); |
|
296 |
by (subgoal_tac |
|
1475 | 297 |
"the_recfun r H y = cut(%x. H(cut(the_recfun r H y) r x) x) r y" 1); |
4821 | 298 |
by (etac allE 2); |
299 |
by (dtac impE 2); |
|
300 |
by (atac 2); |
|
1475 | 301 |
by (atac 3); |
4821 | 302 |
by (atac 2); |
303 |
by (etac ssubst 1); |
|
304 |
by (simp_tac (HOL_ss addsimps [cuts_eq]) 1); |
|
305 |
by (Clarify_tac 1); |
|
306 |
by (stac cut_apply 1); |
|
5132 | 307 |
by (fast_tac (claset() addDs [transD]) 1); |
4821 | 308 |
by (rtac (refl RSN (2,H_cong)) 1); |
309 |
by (fold_tac [is_recfun_def]); |
|
310 |
by (asm_simp_tac (wf_super_ss addsimps[is_recfun_cut]) 1); |
|
923 | 311 |
qed "unfold_the_recfun"; |
312 |
||
1475 | 313 |
val unwind1_the_recfun = rewrite_rule[is_recfun_def] unfold_the_recfun; |
923 | 314 |
|
1475 | 315 |
(*--------------Old proof----------------------------------------------------- |
5316 | 316 |
val prems = Goal |
1475 | 317 |
"[| wf(r); trans(r) |] ==> is_recfun r H a (the_recfun r H a)"; |
318 |
by (cut_facts_tac prems 1); |
|
319 |
by (wf_ind_tac "a" prems 1); |
|
320 |
by (res_inst_tac [("f", "cut (%y. wftrec r H y) r a1")] is_the_recfun 1); |
|
321 |
by (rewrite_goals_tac [is_recfun_def, wftrec_def]); |
|
2031 | 322 |
by (stac cuts_eq 1); |
1475 | 323 |
(*Applying the substitution: must keep the quantified assumption!!*) |
3708 | 324 |
by (EVERY1 [Clarify_tac, rtac H_cong1, rtac allE, atac, |
1475 | 325 |
etac (mp RS ssubst), atac]); |
326 |
by (fold_tac [is_recfun_def]); |
|
327 |
by (asm_simp_tac (wf_super_ss addsimps[cut_apply,is_recfun_cut,cuts_eq]) 1); |
|
328 |
qed "unfold_the_recfun"; |
|
329 |
---------------------------------------------------------------------------*) |
|
923 | 330 |
|
331 |
(** Removal of the premise trans(r) **) |
|
1475 | 332 |
val th = rewrite_rule[is_recfun_def] |
333 |
(trans_trancl RSN (2,(wf_trancl RS unfold_the_recfun))); |
|
923 | 334 |
|
5069 | 335 |
Goalw [wfrec_def] |
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5143
diff
changeset
|
336 |
"wf(r) ==> wfrec r H a = H (cut (wfrec r H) r a) a"; |
1475 | 337 |
by (rtac H_cong 1); |
338 |
by (rtac refl 2); |
|
339 |
by (simp_tac (HOL_ss addsimps [cuts_eq]) 1); |
|
340 |
by (rtac allI 1); |
|
341 |
by (rtac impI 1); |
|
342 |
by (simp_tac(HOL_ss addsimps [wfrec_def]) 1); |
|
343 |
by (res_inst_tac [("a1","a")] (th RS ssubst) 1); |
|
344 |
by (atac 1); |
|
345 |
by (forward_tac[wf_trancl] 1); |
|
346 |
by (forward_tac[r_into_trancl] 1); |
|
347 |
by (asm_simp_tac (HOL_ss addsimps [cut_apply]) 1); |
|
348 |
by (rtac H_cong 1); (*expose the equality of cuts*) |
|
349 |
by (rtac refl 2); |
|
350 |
by (simp_tac (HOL_ss addsimps [cuts_eq, cut_apply, r_into_trancl]) 1); |
|
3708 | 351 |
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
|
352 |
by (res_inst_tac [("r","r^+")] is_recfun_equal 1); |
1475 | 353 |
by (atac 1); |
354 |
by (rtac trans_trancl 1); |
|
355 |
by (rtac unfold_the_recfun 1); |
|
356 |
by (atac 1); |
|
357 |
by (rtac trans_trancl 1); |
|
358 |
by (rtac unfold_the_recfun 1); |
|
359 |
by (atac 1); |
|
360 |
by (rtac trans_trancl 1); |
|
361 |
by (rtac transD 1); |
|
362 |
by (rtac trans_trancl 1); |
|
4762 | 363 |
by (forw_inst_tac [("p","(ya,y)")] r_into_trancl 1); |
1475 | 364 |
by (atac 1); |
365 |
by (atac 1); |
|
4762 | 366 |
by (forw_inst_tac [("p","(ya,y)")] r_into_trancl 1); |
1475 | 367 |
by (atac 1); |
368 |
qed "wfrec"; |
|
369 |
||
370 |
(*--------------Old proof----------------------------------------------------- |
|
5069 | 371 |
Goalw [wfrec_def] |
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5143
diff
changeset
|
372 |
"wf(r) ==> wfrec r H a = H (cut (wfrec r H) r a) a"; |
923 | 373 |
by (etac (wf_trancl RS wftrec RS ssubst) 1); |
374 |
by (rtac trans_trancl 1); |
|
375 |
by (rtac (refl RS H_cong) 1); (*expose the equality of cuts*) |
|
1475 | 376 |
by (simp_tac (HOL_ss addsimps [cuts_eq, cut_apply, r_into_trancl]) 1); |
923 | 377 |
qed "wfrec"; |
1475 | 378 |
---------------------------------------------------------------------------*) |
923 | 379 |
|
1475 | 380 |
(*--------------------------------------------------------------------------- |
381 |
* This form avoids giant explosions in proofs. NOTE USE OF == |
|
382 |
*---------------------------------------------------------------------------*) |
|
5316 | 383 |
val rew::prems = goal thy |
1475 | 384 |
"[| f==wfrec r H; wf(r) |] ==> f(a) = H (cut f r a) a"; |
923 | 385 |
by (rewtac rew); |
386 |
by (REPEAT (resolve_tac (prems@[wfrec]) 1)); |
|
387 |
qed "def_wfrec"; |
|
1475 | 388 |
|
3198 | 389 |
|
390 |
(**** TFL variants ****) |
|
391 |
||
5278 | 392 |
Goal "!R. wf R --> (!P. (!x. (!y. (y,x):R --> P y) --> P x) --> (!x. P x))"; |
3708 | 393 |
by (Clarify_tac 1); |
3198 | 394 |
by (res_inst_tac [("r","R"),("P","P"), ("a","x")] wf_induct 1); |
395 |
by (assume_tac 1); |
|
396 |
by (Blast_tac 1); |
|
397 |
qed"tfl_wf_induct"; |
|
398 |
||
5069 | 399 |
Goal "!f R. (x,a):R --> (cut f R a)(x) = f(x)"; |
3708 | 400 |
by (Clarify_tac 1); |
3198 | 401 |
by (rtac cut_apply 1); |
402 |
by (assume_tac 1); |
|
403 |
qed"tfl_cut_apply"; |
|
404 |
||
5069 | 405 |
Goal "!M R f. (f=wfrec R M) --> wf R --> (!x. f x = M (cut f R x) x)"; |
3708 | 406 |
by (Clarify_tac 1); |
4153 | 407 |
by (etac wfrec 1); |
3198 | 408 |
qed "tfl_wfrec"; |