author | paulson |
Wed, 15 Jul 1998 14:19:02 +0200 | |
changeset 5148 | 74919e8f221c |
parent 5143 | b94cd208f073 |
child 5278 | a903b66822e2 |
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); |
|
4089 | 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); |
|
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 |
|
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); |
4089 | 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 |
||
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 |
||
75 |
val wfr::_ = goalw WF.thy [wf_def] |
|
76 |
"wf r ==> x:Q --> (? z:Q. ! y. (y,z):r --> y~:Q)"; |
|
77 |
by (rtac (wfr RS spec RS mp RS spec) 1); |
|
78 |
by (Blast_tac 1); |
|
79 |
val lemma1 = result(); |
|
80 |
||
5069 | 81 |
Goalw [wf_def] |
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5143
diff
changeset
|
82 |
"(! Q x. x:Q --> (? z:Q. ! y. (y,z):r --> y~:Q)) ==> wf r"; |
3708 | 83 |
by (Clarify_tac 1); |
3198 | 84 |
by (dres_inst_tac [("x", "{x. ~ P x}")] spec 1); |
85 |
by (Blast_tac 1); |
|
86 |
val lemma2 = result(); |
|
87 |
||
5069 | 88 |
Goal "wf r = (! Q x. x:Q --> (? z:Q. ! y. (y,z):r --> y~:Q))"; |
4089 | 89 |
by (blast_tac (claset() addSIs [lemma1, lemma2]) 1); |
3198 | 90 |
qed "wf_eq_minimal"; |
91 |
||
3413
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 |
* Wellfoundedness of subsets |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
94 |
*---------------------------------------------------------------------------*) |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
95 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
96 |
Goal "[| wf(r); p<=r |] ==> wf(p)"; |
4089 | 97 |
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
|
98 |
by (Fast_tac 1); |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
99 |
qed "wf_subset"; |
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 |
(*--------------------------------------------------------------------------- |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
102 |
* Wellfoundedness of the empty relation. |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
103 |
*---------------------------------------------------------------------------*) |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
104 |
|
5069 | 105 |
Goal "wf({})"; |
4089 | 106 |
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
|
107 |
qed "wf_empty"; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
108 |
AddSIs [wf_empty]; |
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 |
(*--------------------------------------------------------------------------- |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
111 |
* Wellfoundedness of `insert' |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
112 |
*---------------------------------------------------------------------------*) |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
113 |
|
5069 | 114 |
Goal "wf(insert (y,x) r) = (wf(r) & (x,y) ~: r^*)"; |
3457 | 115 |
by (rtac iffI 1); |
4350
1983e4054fd8
updated for latest Blast_tac, which treats equality differently
paulson
parents:
4153
diff
changeset
|
116 |
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
|
117 |
addIs [rtrancl_into_trancl1,wf_subset,impOfSubs rtrancl_mono]) 1); |
4089 | 118 |
by (asm_full_simp_tac (simpset() addsimps [wf_eq_minimal]) 1); |
4153 | 119 |
by Safe_tac; |
3457 | 120 |
by (EVERY1[rtac allE, atac, etac impE, Blast_tac]); |
121 |
by (etac bexE 1); |
|
122 |
by (rename_tac "a" 1); |
|
123 |
by (case_tac "a = x" 1); |
|
124 |
by (res_inst_tac [("x","a")]bexI 2); |
|
125 |
by (assume_tac 3); |
|
126 |
by (Blast_tac 2); |
|
127 |
by (case_tac "y:Q" 1); |
|
128 |
by (Blast_tac 2); |
|
4059 | 129 |
by (res_inst_tac [("x","{z. z:Q & (z,y) : r^*}")] allE 1); |
3457 | 130 |
by (assume_tac 1); |
4059 | 131 |
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
|
132 |
(*Blast_tac with new substOccur fails*) |
1983e4054fd8
updated for latest Blast_tac, which treats equality differently
paulson
parents:
4153
diff
changeset
|
133 |
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
|
134 |
qed "wf_insert"; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
135 |
AddIffs [wf_insert]; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
136 |
|
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
137 |
(*** acyclic ***) |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
138 |
|
4750 | 139 |
val acyclicI = prove_goalw WF.thy [acyclic_def] |
140 |
"!!r. !x. (x, x) ~: r^+ ==> acyclic r" (K [atac 1]); |
|
141 |
||
5069 | 142 |
Goalw [acyclic_def] |
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5143
diff
changeset
|
143 |
"wf r ==> acyclic r"; |
4089 | 144 |
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
|
145 |
qed "wf_acyclic"; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
146 |
|
5069 | 147 |
Goalw [acyclic_def] |
3413
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
148 |
"acyclic(insert (y,x) r) = (acyclic r & (x,y) ~: r^*)"; |
4089 | 149 |
by (simp_tac (simpset() addsimps [trancl_insert]) 1); |
150 |
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
|
151 |
qed "acyclic_insert"; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
152 |
AddIffs [acyclic_insert]; |
c1f63cc3a768
Finite.ML Finite.thy: Replaced `finite subset of' by mere `finite'.
nipkow
parents:
3320
diff
changeset
|
153 |
|
5069 | 154 |
Goalw [acyclic_def] "acyclic(r^-1) = acyclic r"; |
4746 | 155 |
by (simp_tac (simpset() addsimps [trancl_converse]) 1); |
156 |
qed "acyclic_converse"; |
|
3198 | 157 |
|
923 | 158 |
(** cut **) |
159 |
||
160 |
(*This rewrite rule works upon formulae; thus it requires explicit use of |
|
161 |
H_cong to expose the equality*) |
|
5069 | 162 |
Goalw [cut_def] |
972
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents:
950
diff
changeset
|
163 |
"(cut f r x = cut g r x) = (!y. (y,x):r --> f(y)=g(y))"; |
4686 | 164 |
by (simp_tac (HOL_ss addsimps [expand_fun_eq]) 1); |
1475 | 165 |
qed "cuts_eq"; |
923 | 166 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5132
diff
changeset
|
167 |
Goalw [cut_def] "(x,a):r ==> (cut f r a)(x) = f(x)"; |
1552 | 168 |
by (asm_simp_tac HOL_ss 1); |
923 | 169 |
qed "cut_apply"; |
170 |
||
171 |
(*** is_recfun ***) |
|
172 |
||
5069 | 173 |
Goalw [is_recfun_def,cut_def] |
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5143
diff
changeset
|
174 |
"[| is_recfun r H a f; ~(b,a):r |] ==> f(b) = arbitrary"; |
923 | 175 |
by (etac ssubst 1); |
1552 | 176 |
by (asm_simp_tac HOL_ss 1); |
923 | 177 |
qed "is_recfun_undef"; |
178 |
||
179 |
(*** NOTE! some simplifications need a different finish_tac!! ***) |
|
180 |
fun indhyp_tac hyps = |
|
181 |
(cut_facts_tac hyps THEN' |
|
182 |
DEPTH_SOLVE_1 o (ares_tac [TrueI] ORELSE' |
|
1465 | 183 |
eresolve_tac [transD, mp, allE])); |
2637
e9b203f854ae
reflecting my recent changes of the simplifier and classical reasoner
oheimb
parents:
2031
diff
changeset
|
184 |
val wf_super_ss = HOL_ss addSolver indhyp_tac; |
923 | 185 |
|
186 |
val prems = goalw WF.thy [is_recfun_def,cut_def] |
|
1475 | 187 |
"[| 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
|
188 |
\ (x,a):r --> (x,b):r --> f(x)=g(x)"; |
923 | 189 |
by (cut_facts_tac prems 1); |
190 |
by (etac wf_induct 1); |
|
191 |
by (REPEAT (rtac impI 1 ORELSE etac ssubst 1)); |
|
192 |
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
|
193 |
qed_spec_mp "is_recfun_equal"; |
923 | 194 |
|
195 |
||
196 |
val prems as [wfr,transr,recfa,recgb,_] = goalw WF.thy [cut_def] |
|
197 |
"[| wf(r); trans(r); \ |
|
1475 | 198 |
\ is_recfun r H a f; is_recfun r H b g; (b,a):r |] ==> \ |
923 | 199 |
\ cut f r b = g"; |
200 |
val gundef = recgb RS is_recfun_undef |
|
201 |
and fisg = recgb RS (recfa RS (transr RS (wfr RS is_recfun_equal))); |
|
202 |
by (cut_facts_tac prems 1); |
|
203 |
by (rtac ext 1); |
|
4686 | 204 |
by (asm_simp_tac (wf_super_ss addsimps [gundef,fisg]) 1); |
923 | 205 |
qed "is_recfun_cut"; |
206 |
||
207 |
(*** Main Existence Lemma -- Basic Properties of the_recfun ***) |
|
208 |
||
209 |
val prems = goalw WF.thy [the_recfun_def] |
|
1475 | 210 |
"is_recfun r H a f ==> is_recfun r H a (the_recfun r H a)"; |
211 |
by (res_inst_tac [("P", "is_recfun r H a")] selectI 1); |
|
923 | 212 |
by (resolve_tac prems 1); |
213 |
qed "is_the_recfun"; |
|
214 |
||
215 |
val prems = goal WF.thy |
|
4821 | 216 |
"!!r. [| wf(r); trans(r) |] ==> is_recfun r H a (the_recfun r H a)"; |
217 |
by (wf_ind_tac "a" prems 1); |
|
218 |
by (res_inst_tac [("f","cut (%y. H (the_recfun r H y) y) r a1")] |
|
219 |
is_the_recfun 1); |
|
220 |
by (rewtac is_recfun_def); |
|
221 |
by (stac cuts_eq 1); |
|
222 |
by (Clarify_tac 1); |
|
223 |
by (rtac (refl RSN (2,H_cong)) 1); |
|
224 |
by (subgoal_tac |
|
1475 | 225 |
"the_recfun r H y = cut(%x. H(cut(the_recfun r H y) r x) x) r y" 1); |
4821 | 226 |
by (etac allE 2); |
227 |
by (dtac impE 2); |
|
228 |
by (atac 2); |
|
1475 | 229 |
by (atac 3); |
4821 | 230 |
by (atac 2); |
231 |
by (etac ssubst 1); |
|
232 |
by (simp_tac (HOL_ss addsimps [cuts_eq]) 1); |
|
233 |
by (Clarify_tac 1); |
|
234 |
by (stac cut_apply 1); |
|
5132 | 235 |
by (fast_tac (claset() addDs [transD]) 1); |
4821 | 236 |
by (rtac (refl RSN (2,H_cong)) 1); |
237 |
by (fold_tac [is_recfun_def]); |
|
238 |
by (asm_simp_tac (wf_super_ss addsimps[is_recfun_cut]) 1); |
|
923 | 239 |
qed "unfold_the_recfun"; |
240 |
||
1475 | 241 |
val unwind1_the_recfun = rewrite_rule[is_recfun_def] unfold_the_recfun; |
923 | 242 |
|
1475 | 243 |
(*--------------Old proof----------------------------------------------------- |
923 | 244 |
val prems = goal WF.thy |
1475 | 245 |
"[| wf(r); trans(r) |] ==> is_recfun r H a (the_recfun r H a)"; |
246 |
by (cut_facts_tac prems 1); |
|
247 |
by (wf_ind_tac "a" prems 1); |
|
248 |
by (res_inst_tac [("f", "cut (%y. wftrec r H y) r a1")] is_the_recfun 1); |
|
249 |
by (rewrite_goals_tac [is_recfun_def, wftrec_def]); |
|
2031 | 250 |
by (stac cuts_eq 1); |
1475 | 251 |
(*Applying the substitution: must keep the quantified assumption!!*) |
3708 | 252 |
by (EVERY1 [Clarify_tac, rtac H_cong1, rtac allE, atac, |
1475 | 253 |
etac (mp RS ssubst), atac]); |
254 |
by (fold_tac [is_recfun_def]); |
|
255 |
by (asm_simp_tac (wf_super_ss addsimps[cut_apply,is_recfun_cut,cuts_eq]) 1); |
|
256 |
qed "unfold_the_recfun"; |
|
257 |
---------------------------------------------------------------------------*) |
|
923 | 258 |
|
259 |
(** Removal of the premise trans(r) **) |
|
1475 | 260 |
val th = rewrite_rule[is_recfun_def] |
261 |
(trans_trancl RSN (2,(wf_trancl RS unfold_the_recfun))); |
|
923 | 262 |
|
5069 | 263 |
Goalw [wfrec_def] |
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5143
diff
changeset
|
264 |
"wf(r) ==> wfrec r H a = H (cut (wfrec r H) r a) a"; |
1475 | 265 |
by (rtac H_cong 1); |
266 |
by (rtac refl 2); |
|
267 |
by (simp_tac (HOL_ss addsimps [cuts_eq]) 1); |
|
268 |
by (rtac allI 1); |
|
269 |
by (rtac impI 1); |
|
270 |
by (simp_tac(HOL_ss addsimps [wfrec_def]) 1); |
|
271 |
by (res_inst_tac [("a1","a")] (th RS ssubst) 1); |
|
272 |
by (atac 1); |
|
273 |
by (forward_tac[wf_trancl] 1); |
|
274 |
by (forward_tac[r_into_trancl] 1); |
|
275 |
by (asm_simp_tac (HOL_ss addsimps [cut_apply]) 1); |
|
276 |
by (rtac H_cong 1); (*expose the equality of cuts*) |
|
277 |
by (rtac refl 2); |
|
278 |
by (simp_tac (HOL_ss addsimps [cuts_eq, cut_apply, r_into_trancl]) 1); |
|
3708 | 279 |
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
|
280 |
by (res_inst_tac [("r","r^+")] is_recfun_equal 1); |
1475 | 281 |
by (atac 1); |
282 |
by (rtac trans_trancl 1); |
|
283 |
by (rtac unfold_the_recfun 1); |
|
284 |
by (atac 1); |
|
285 |
by (rtac trans_trancl 1); |
|
286 |
by (rtac unfold_the_recfun 1); |
|
287 |
by (atac 1); |
|
288 |
by (rtac trans_trancl 1); |
|
289 |
by (rtac transD 1); |
|
290 |
by (rtac trans_trancl 1); |
|
4762 | 291 |
by (forw_inst_tac [("p","(ya,y)")] r_into_trancl 1); |
1475 | 292 |
by (atac 1); |
293 |
by (atac 1); |
|
4762 | 294 |
by (forw_inst_tac [("p","(ya,y)")] r_into_trancl 1); |
1475 | 295 |
by (atac 1); |
296 |
qed "wfrec"; |
|
297 |
||
298 |
(*--------------Old proof----------------------------------------------------- |
|
5069 | 299 |
Goalw [wfrec_def] |
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5143
diff
changeset
|
300 |
"wf(r) ==> wfrec r H a = H (cut (wfrec r H) r a) a"; |
923 | 301 |
by (etac (wf_trancl RS wftrec RS ssubst) 1); |
302 |
by (rtac trans_trancl 1); |
|
303 |
by (rtac (refl RS H_cong) 1); (*expose the equality of cuts*) |
|
1475 | 304 |
by (simp_tac (HOL_ss addsimps [cuts_eq, cut_apply, r_into_trancl]) 1); |
923 | 305 |
qed "wfrec"; |
1475 | 306 |
---------------------------------------------------------------------------*) |
923 | 307 |
|
1475 | 308 |
(*--------------------------------------------------------------------------- |
309 |
* This form avoids giant explosions in proofs. NOTE USE OF == |
|
310 |
*---------------------------------------------------------------------------*) |
|
923 | 311 |
val rew::prems = goal WF.thy |
1475 | 312 |
"[| f==wfrec r H; wf(r) |] ==> f(a) = H (cut f r a) a"; |
923 | 313 |
by (rewtac rew); |
314 |
by (REPEAT (resolve_tac (prems@[wfrec]) 1)); |
|
315 |
qed "def_wfrec"; |
|
1475 | 316 |
|
3198 | 317 |
|
318 |
(**** TFL variants ****) |
|
319 |
||
5069 | 320 |
Goal |
3198 | 321 |
"!R. wf R --> (!P. (!x. (!y. (y,x):R --> P y) --> P x) --> (!x. P x))"; |
3708 | 322 |
by (Clarify_tac 1); |
3198 | 323 |
by (res_inst_tac [("r","R"),("P","P"), ("a","x")] wf_induct 1); |
324 |
by (assume_tac 1); |
|
325 |
by (Blast_tac 1); |
|
326 |
qed"tfl_wf_induct"; |
|
327 |
||
5069 | 328 |
Goal "!f R. (x,a):R --> (cut f R a)(x) = f(x)"; |
3708 | 329 |
by (Clarify_tac 1); |
3198 | 330 |
by (rtac cut_apply 1); |
331 |
by (assume_tac 1); |
|
332 |
qed"tfl_cut_apply"; |
|
333 |
||
5069 | 334 |
Goal "!M R f. (f=wfrec R M) --> wf R --> (!x. f x = M (cut f R x) x)"; |
3708 | 335 |
by (Clarify_tac 1); |
4153 | 336 |
by (etac wfrec 1); |
3198 | 337 |
qed "tfl_wfrec"; |