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