| author | wenzelm | 
| Thu, 08 Aug 2002 23:51:24 +0200 | |
| changeset 13486 | 54464ea94d6f | 
| parent 13357 | 6f54e992777e | 
| child 13534 | ca6debb89d77 | 
| permissions | -rw-r--r-- | 
| 13165 | 1  | 
(* Title: ZF/WF.thy  | 
| 0 | 2  | 
ID: $Id$  | 
| 1478 | 3  | 
Author: Tobias Nipkow and Lawrence C Paulson  | 
| 435 | 4  | 
Copyright 1994 University of Cambridge  | 
| 0 | 5  | 
|
| 13165 | 6  | 
Derived first for transitive relations, and finally for arbitrary WF relations  | 
7  | 
via wf_trancl and trans_trancl.  | 
|
8  | 
||
9  | 
It is difficult to derive this general case directly, using r^+ instead of  | 
|
10  | 
r. In is_recfun, the two occurrences of the relation must have the same  | 
|
11  | 
form. Inserting r^+ in the_recfun or wftrec yields a recursion rule with  | 
|
12  | 
r^+ -`` {a} instead of r-``{a}.  This recursion rule is stronger in
 | 
|
13  | 
principle, but harder to use, especially to prove wfrec_eclose_eq in  | 
|
14  | 
epsilon.ML. Expanding out the definition of wftrec in wfrec would yield  | 
|
15  | 
a mess.  | 
|
| 0 | 16  | 
*)  | 
17  | 
||
| 13356 | 18  | 
header{*Well-Founded Recursion*}
 | 
19  | 
||
| 13357 | 20  | 
theory WF = Trancl:  | 
| 13165 | 21  | 
|
22  | 
constdefs  | 
|
23  | 
wf :: "i=>o"  | 
|
24  | 
(*r is a well-founded relation*)  | 
|
25  | 
"wf(r) == ALL Z. Z=0 | (EX x:Z. ALL y. <y,x>:r --> ~ y:Z)"  | 
|
26  | 
||
27  | 
  wf_on        :: "[i,i]=>o"                      ("wf[_]'(_')")
 | 
|
28  | 
(*r is well-founded on A*)  | 
|
29  | 
"wf_on(A,r) == wf(r Int A*A)"  | 
|
30  | 
||
31  | 
is_recfun :: "[i, i, [i,i]=>i, i] =>o"  | 
|
32  | 
    "is_recfun(r,a,H,f) == (f = (lam x: r-``{a}. H(x, restrict(f, r-``{x}))))"
 | 
|
33  | 
||
34  | 
the_recfun :: "[i, i, [i,i]=>i] =>i"  | 
|
35  | 
"the_recfun(r,a,H) == (THE f. is_recfun(r,a,H,f))"  | 
|
36  | 
||
37  | 
wftrec :: "[i, i, [i,i]=>i] =>i"  | 
|
38  | 
"wftrec(r,a,H) == H(a, the_recfun(r,a,H))"  | 
|
39  | 
||
40  | 
wfrec :: "[i, i, [i,i]=>i] =>i"  | 
|
41  | 
(*public version. Does not require r to be transitive*)  | 
|
42  | 
    "wfrec(r,a,H) == wftrec(r^+, a, %x f. H(x, restrict(f,r-``{x})))"
 | 
|
43  | 
||
44  | 
  wfrec_on     :: "[i, i, i, [i,i]=>i] =>i"       ("wfrec[_]'(_,_,_')")
 | 
|
45  | 
"wfrec[A](r,a,H) == wfrec(r Int A*A, a, H)"  | 
|
46  | 
||
47  | 
||
| 13356 | 48  | 
subsection{*Well-Founded Relations*}
 | 
| 13165 | 49  | 
|
50  | 
(** Equivalences between wf and wf_on **)  | 
|
51  | 
||
52  | 
lemma wf_imp_wf_on: "wf(r) ==> wf[A](r)"  | 
|
53  | 
apply (unfold wf_def wf_on_def, clarify) (*needed for blast's efficiency*)  | 
|
54  | 
apply blast  | 
|
55  | 
done  | 
|
56  | 
||
| 13248 | 57  | 
lemma wf_on_imp_wf: "[|wf[A](r); r <= A*A|] ==> wf(r)";  | 
58  | 
by (simp add: wf_on_def subset_Int_iff)  | 
|
59  | 
||
| 13165 | 60  | 
lemma wf_on_field_imp_wf: "wf[field(r)](r) ==> wf(r)"  | 
61  | 
by (unfold wf_def wf_on_def, fast)  | 
|
62  | 
||
63  | 
lemma wf_iff_wf_on_field: "wf(r) <-> wf[field(r)](r)"  | 
|
64  | 
by (blast intro: wf_imp_wf_on wf_on_field_imp_wf)  | 
|
65  | 
||
66  | 
lemma wf_on_subset_A: "[| wf[A](r); B<=A |] ==> wf[B](r)"  | 
|
67  | 
by (unfold wf_on_def wf_def, fast)  | 
|
68  | 
||
69  | 
lemma wf_on_subset_r: "[| wf[A](r); s<=r |] ==> wf[A](s)"  | 
|
70  | 
by (unfold wf_on_def wf_def, fast)  | 
|
71  | 
||
| 13217 | 72  | 
lemma wf_subset: "[|wf(s); r<=s|] ==> wf(r)"  | 
73  | 
by (simp add: wf_def, fast)  | 
|
74  | 
||
| 13165 | 75  | 
(** Introduction rules for wf_on **)  | 
76  | 
||
77  | 
lemma wf_onI:  | 
|
78  | 
(*If every non-empty subset of A has an r-minimal element then wf[A](r).*)  | 
|
79  | 
assumes prem: "!!Z u. [| Z<=A; u:Z; ALL x:Z. EX y:Z. <y,x>:r |] ==> False"  | 
|
80  | 
shows "wf[A](r)"  | 
|
81  | 
apply (unfold wf_on_def wf_def)  | 
|
82  | 
apply (rule equals0I [THEN disjCI, THEN allI])  | 
|
83  | 
apply (rule_tac Z = "Z" in prem, blast+)  | 
|
84  | 
done  | 
|
85  | 
||
86  | 
(*If r allows well-founded induction over A then wf[A](r)  | 
|
87  | 
Premise is equivalent to  | 
|
88  | 
!!B. ALL x:A. (ALL y. <y,x>: r --> y:B) --> x:B ==> A<=B *)  | 
|
89  | 
lemma wf_onI2:  | 
|
90  | 
assumes prem: "!!y B. [| ALL x:A. (ALL y:A. <y,x>:r --> y:B) --> x:B; y:A |]  | 
|
91  | 
==> y:B"  | 
|
92  | 
shows "wf[A](r)"  | 
|
93  | 
apply (rule wf_onI)  | 
|
94  | 
apply (rule_tac c=u in prem [THEN DiffE])  | 
|
95  | 
prefer 3 apply blast  | 
|
96  | 
apply fast+  | 
|
97  | 
done  | 
|
98  | 
||
99  | 
||
100  | 
(** Well-founded Induction **)  | 
|
101  | 
||
| 13252 | 102  | 
(*Consider the least z in domain(r) such that P(z) does not hold...*)  | 
| 13165 | 103  | 
lemma wf_induct:  | 
104  | 
"[| wf(r);  | 
|
105  | 
!!x.[| ALL y. <y,x>: r --> P(y) |] ==> P(x)  | 
|
106  | 
|] ==> P(a)"  | 
|
107  | 
apply (unfold wf_def)  | 
|
| 13252 | 108  | 
apply (erule_tac x = "{z : domain(r). ~ P(z)}" in allE)
 | 
| 13165 | 109  | 
apply blast  | 
110  | 
done  | 
|
| 435 | 111  | 
|
| 
13203
 
fac77a839aa2
Tidying up.  Mainly moving proofs from Main.thy to other (Isar) theory files.
 
paulson 
parents: 
13175 
diff
changeset
 | 
112  | 
(*fixed up for induct method*)  | 
| 
 
fac77a839aa2
Tidying up.  Mainly moving proofs from Main.thy to other (Isar) theory files.
 
paulson 
parents: 
13175 
diff
changeset
 | 
113  | 
lemmas wf_induct = wf_induct [induct set: wf]  | 
| 
 
fac77a839aa2
Tidying up.  Mainly moving proofs from Main.thy to other (Isar) theory files.
 
paulson 
parents: 
13175 
diff
changeset
 | 
114  | 
and wf_induct_rule = wf_induct [rule_format, induct set: wf]  | 
| 
 
fac77a839aa2
Tidying up.  Mainly moving proofs from Main.thy to other (Isar) theory files.
 
paulson 
parents: 
13175 
diff
changeset
 | 
115  | 
|
| 13165 | 116  | 
(*The form of this rule is designed to match wfI*)  | 
117  | 
lemma wf_induct2:  | 
|
118  | 
"[| wf(r); a:A; field(r)<=A;  | 
|
119  | 
!!x.[| x: A; ALL y. <y,x>: r --> P(y) |] ==> P(x) |]  | 
|
120  | 
==> P(a)"  | 
|
121  | 
apply (erule_tac P="a:A" in rev_mp)  | 
|
122  | 
apply (erule_tac a=a in wf_induct, blast)  | 
|
123  | 
done  | 
|
124  | 
||
125  | 
lemma field_Int_square: "field(r Int A*A) <= A"  | 
|
126  | 
by blast  | 
|
127  | 
||
128  | 
lemma wf_on_induct:  | 
|
129  | 
"[| wf[A](r); a:A;  | 
|
130  | 
!!x.[| x: A; ALL y:A. <y,x>: r --> P(y) |] ==> P(x)  | 
|
131  | 
|] ==> P(a)"  | 
|
132  | 
apply (unfold wf_on_def)  | 
|
133  | 
apply (erule wf_induct2, assumption)  | 
|
134  | 
apply (rule field_Int_square, blast)  | 
|
135  | 
done  | 
|
136  | 
||
| 
13203
 
fac77a839aa2
Tidying up.  Mainly moving proofs from Main.thy to other (Isar) theory files.
 
paulson 
parents: 
13175 
diff
changeset
 | 
137  | 
(*fixed up for induct method*)  | 
| 
 
fac77a839aa2
Tidying up.  Mainly moving proofs from Main.thy to other (Isar) theory files.
 
paulson 
parents: 
13175 
diff
changeset
 | 
138  | 
lemmas wf_on_induct = wf_on_induct [consumes 2, induct set: wf_on]  | 
| 
 
fac77a839aa2
Tidying up.  Mainly moving proofs from Main.thy to other (Isar) theory files.
 
paulson 
parents: 
13175 
diff
changeset
 | 
139  | 
and wf_on_induct_rule =  | 
| 
 
fac77a839aa2
Tidying up.  Mainly moving proofs from Main.thy to other (Isar) theory files.
 
paulson 
parents: 
13175 
diff
changeset
 | 
140  | 
wf_on_induct [rule_format, consumes 2, induct set: wf_on]  | 
| 
 
fac77a839aa2
Tidying up.  Mainly moving proofs from Main.thy to other (Isar) theory files.
 
paulson 
parents: 
13175 
diff
changeset
 | 
141  | 
|
| 
 
fac77a839aa2
Tidying up.  Mainly moving proofs from Main.thy to other (Isar) theory files.
 
paulson 
parents: 
13175 
diff
changeset
 | 
142  | 
|
| 13165 | 143  | 
(*If r allows well-founded induction then wf(r)*)  | 
144  | 
lemma wfI:  | 
|
145  | 
"[| field(r)<=A;  | 
|
146  | 
!!y B. [| ALL x:A. (ALL y:A. <y,x>:r --> y:B) --> x:B; y:A|]  | 
|
147  | 
==> y:B |]  | 
|
148  | 
==> wf(r)"  | 
|
149  | 
apply (rule wf_on_subset_A [THEN wf_on_field_imp_wf])  | 
|
150  | 
apply (rule wf_onI2)  | 
|
151  | 
prefer 2 apply blast  | 
|
152  | 
apply blast  | 
|
153  | 
done  | 
|
154  | 
||
155  | 
||
| 13356 | 156  | 
subsection{*Basic Properties of Well-Founded Relations*}
 | 
| 13165 | 157  | 
|
158  | 
lemma wf_not_refl: "wf(r) ==> <a,a> ~: r"  | 
|
159  | 
by (erule_tac a=a in wf_induct, blast)  | 
|
160  | 
||
161  | 
lemma wf_not_sym [rule_format]: "wf(r) ==> ALL x. <a,x>:r --> <x,a> ~: r"  | 
|
162  | 
by (erule_tac a=a in wf_induct, blast)  | 
|
163  | 
||
164  | 
(* [| wf(r); <a,x> : r; ~P ==> <x,a> : r |] ==> P *)  | 
|
165  | 
lemmas wf_asym = wf_not_sym [THEN swap, standard]  | 
|
166  | 
||
167  | 
lemma wf_on_not_refl: "[| wf[A](r); a: A |] ==> <a,a> ~: r"  | 
|
| 13269 | 168  | 
by (erule_tac a=a in wf_on_induct, assumption, blast)  | 
| 0 | 169  | 
|
| 13165 | 170  | 
lemma wf_on_not_sym [rule_format]:  | 
171  | 
"[| wf[A](r); a:A |] ==> ALL b:A. <a,b>:r --> <b,a>~:r"  | 
|
| 13269 | 172  | 
apply (erule_tac a=a in wf_on_induct, assumption, blast)  | 
| 13165 | 173  | 
done  | 
174  | 
||
175  | 
lemma wf_on_asym:  | 
|
176  | 
"[| wf[A](r); ~Z ==> <a,b> : r;  | 
|
177  | 
<b,a> ~: r ==> Z; ~Z ==> a : A; ~Z ==> b : A |] ==> Z"  | 
|
| 13269 | 178  | 
by (blast dest: wf_on_not_sym)  | 
| 13165 | 179  | 
|
180  | 
||
181  | 
(*Needed to prove well_ordI. Could also reason that wf[A](r) means  | 
|
182  | 
wf(r Int A*A); thus wf( (r Int A*A)^+ ) and use wf_not_refl *)  | 
|
183  | 
lemma wf_on_chain3:  | 
|
184  | 
"[| wf[A](r); <a,b>:r; <b,c>:r; <c,a>:r; a:A; b:A; c:A |] ==> P"  | 
|
185  | 
apply (subgoal_tac "ALL y:A. ALL z:A. <a,y>:r --> <y,z>:r --> <z,a>:r --> P",  | 
|
186  | 
blast)  | 
|
| 13269 | 187  | 
apply (erule_tac a=a in wf_on_induct, assumption, blast)  | 
| 13165 | 188  | 
done  | 
189  | 
||
190  | 
||
191  | 
||
192  | 
||
193  | 
(*transitive closure of a WF relation is WF provided A is downwards closed*)  | 
|
194  | 
lemma wf_on_trancl:  | 
|
195  | 
"[| wf[A](r); r-``A <= A |] ==> wf[A](r^+)"  | 
|
196  | 
apply (rule wf_onI2)  | 
|
197  | 
apply (frule bspec [THEN mp], assumption+)  | 
|
198  | 
apply (erule_tac a = "y" in wf_on_induct, assumption)  | 
|
199  | 
apply (blast elim: tranclE, blast)  | 
|
200  | 
done  | 
|
201  | 
||
202  | 
lemma wf_trancl: "wf(r) ==> wf(r^+)"  | 
|
203  | 
apply (simp add: wf_iff_wf_on_field)  | 
|
204  | 
apply (rule wf_on_subset_A)  | 
|
205  | 
apply (erule wf_on_trancl)  | 
|
206  | 
apply blast  | 
|
207  | 
apply (rule trancl_type [THEN field_rel_subset])  | 
|
208  | 
done  | 
|
209  | 
||
210  | 
||
211  | 
||
212  | 
(** r-``{a} is the set of everything under a in r **)
 | 
|
213  | 
||
214  | 
lemmas underI = vimage_singleton_iff [THEN iffD2, standard]  | 
|
215  | 
lemmas underD = vimage_singleton_iff [THEN iffD1, standard]  | 
|
216  | 
||
217  | 
(** is_recfun **)  | 
|
| 0 | 218  | 
|
| 13165 | 219  | 
lemma is_recfun_type: "is_recfun(r,a,H,f) ==> f: r-``{a} -> range(f)"
 | 
220  | 
apply (unfold is_recfun_def)  | 
|
221  | 
apply (erule ssubst)  | 
|
222  | 
apply (rule lamI [THEN rangeI, THEN lam_type], assumption)  | 
|
223  | 
done  | 
|
224  | 
||
| 13269 | 225  | 
lemmas is_recfun_imp_function = is_recfun_type [THEN fun_is_function]  | 
226  | 
||
| 13165 | 227  | 
lemma apply_recfun:  | 
228  | 
    "[| is_recfun(r,a,H,f); <x,a>:r |] ==> f`x = H(x, restrict(f,r-``{x}))"
 | 
|
229  | 
apply (unfold is_recfun_def)  | 
|
| 
13175
 
81082cfa5618
new definition of "apply" and new simprule "beta_if"
 
paulson 
parents: 
13165 
diff
changeset
 | 
230  | 
  txt{*replace f only on the left-hand side*}
 | 
| 
 
81082cfa5618
new definition of "apply" and new simprule "beta_if"
 
paulson 
parents: 
13165 
diff
changeset
 | 
231  | 
apply (erule_tac P = "%x.?t(x) = ?u" in ssubst)  | 
| 13269 | 232  | 
apply (simp add: underI)  | 
| 13165 | 233  | 
done  | 
234  | 
||
235  | 
lemma is_recfun_equal [rule_format]:  | 
|
236  | 
"[| wf(r); trans(r); is_recfun(r,a,H,f); is_recfun(r,b,H,g) |]  | 
|
237  | 
==> <x,a>:r --> <x,b>:r --> f`x=g`x"  | 
|
238  | 
apply (frule_tac f = "f" in is_recfun_type)  | 
|
239  | 
apply (frule_tac f = "g" in is_recfun_type)  | 
|
240  | 
apply (simp add: is_recfun_def)  | 
|
241  | 
apply (erule_tac a=x in wf_induct)  | 
|
242  | 
apply (intro impI)  | 
|
243  | 
apply (elim ssubst)  | 
|
244  | 
apply (simp (no_asm_simp) add: vimage_singleton_iff restrict_def)  | 
|
245  | 
apply (rule_tac t = "%z. H (?x,z) " in subst_context)  | 
|
246  | 
apply (subgoal_tac "ALL y : r-``{x}. ALL z. <y,z>:f <-> <y,z>:g")
 | 
|
247  | 
apply (blast dest: transD)  | 
|
248  | 
apply (simp add: apply_iff)  | 
|
249  | 
apply (blast dest: transD intro: sym)  | 
|
250  | 
done  | 
|
251  | 
||
252  | 
lemma is_recfun_cut:  | 
|
253  | 
"[| wf(r); trans(r);  | 
|
254  | 
is_recfun(r,a,H,f); is_recfun(r,b,H,g); <b,a>:r |]  | 
|
255  | 
      ==> restrict(f, r-``{b}) = g"
 | 
|
256  | 
apply (frule_tac f = "f" in is_recfun_type)  | 
|
257  | 
apply (rule fun_extension)  | 
|
258  | 
apply (blast dest: transD intro: restrict_type2)  | 
|
259  | 
apply (erule is_recfun_type, simp)  | 
|
260  | 
apply (blast dest: transD intro: is_recfun_equal)  | 
|
261  | 
done  | 
|
262  | 
||
| 13356 | 263  | 
subsection{*Recursion: Main Existence Lemma*}
 | 
| 435 | 264  | 
|
| 13165 | 265  | 
lemma is_recfun_functional:  | 
266  | 
"[| wf(r); trans(r); is_recfun(r,a,H,f); is_recfun(r,a,H,g) |] ==> f=g"  | 
|
267  | 
by (blast intro: fun_extension is_recfun_type is_recfun_equal)  | 
|
268  | 
||
| 13248 | 269  | 
lemma the_recfun_eq:  | 
270  | 
"[| is_recfun(r,a,H,f); wf(r); trans(r) |] ==> the_recfun(r,a,H) = f"  | 
|
271  | 
apply (unfold the_recfun_def)  | 
|
272  | 
apply (blast intro: is_recfun_functional)  | 
|
273  | 
done  | 
|
274  | 
||
| 13165 | 275  | 
(*If some f satisfies is_recfun(r,a,H,-) then so does the_recfun(r,a,H) *)  | 
276  | 
lemma is_the_recfun:  | 
|
277  | 
"[| is_recfun(r,a,H,f); wf(r); trans(r) |]  | 
|
278  | 
==> is_recfun(r, a, H, the_recfun(r,a,H))"  | 
|
| 13248 | 279  | 
by (simp add: the_recfun_eq)  | 
| 13165 | 280  | 
|
281  | 
lemma unfold_the_recfun:  | 
|
282  | 
"[| wf(r); trans(r) |] ==> is_recfun(r, a, H, the_recfun(r,a,H))"  | 
|
283  | 
apply (rule_tac a=a in wf_induct, assumption)  | 
|
284  | 
apply (rename_tac a1)  | 
|
285  | 
apply (rule_tac f = "lam y: r-``{a1}. wftrec (r,y,H)" in is_the_recfun)
 | 
|
286  | 
apply typecheck  | 
|
287  | 
apply (unfold is_recfun_def wftrec_def)  | 
|
288  | 
(*Applying the substitution: must keep the quantified assumption!!*)  | 
|
289  | 
apply (rule lam_cong [OF refl])  | 
|
290  | 
apply (drule underD)  | 
|
291  | 
apply (fold is_recfun_def)  | 
|
292  | 
apply (rule_tac t = "%z. H(?x,z)" in subst_context)  | 
|
293  | 
apply (rule fun_extension)  | 
|
294  | 
apply (blast intro: is_recfun_type)  | 
|
295  | 
apply (rule lam_type [THEN restrict_type2])  | 
|
296  | 
apply blast  | 
|
297  | 
apply (blast dest: transD)  | 
|
298  | 
apply (frule spec [THEN mp], assumption)  | 
|
299  | 
apply (subgoal_tac "<xa,a1> : r")  | 
|
300  | 
apply (drule_tac x1 = "xa" in spec [THEN mp], assumption)  | 
|
| 
13175
 
81082cfa5618
new definition of "apply" and new simprule "beta_if"
 
paulson 
parents: 
13165 
diff
changeset
 | 
301  | 
apply (simp add: vimage_singleton_iff  | 
| 13165 | 302  | 
apply_recfun is_recfun_cut)  | 
303  | 
apply (blast dest: transD)  | 
|
304  | 
done  | 
|
305  | 
||
306  | 
||
| 13356 | 307  | 
subsection{*Unfolding @{term "wftrec(r,a,H)"}*}
 | 
| 13165 | 308  | 
|
309  | 
lemma the_recfun_cut:  | 
|
310  | 
"[| wf(r); trans(r); <b,a>:r |]  | 
|
311  | 
      ==> restrict(the_recfun(r,a,H), r-``{b}) = the_recfun(r,b,H)"
 | 
|
| 13269 | 312  | 
by (blast intro: is_recfun_cut unfold_the_recfun)  | 
| 0 | 313  | 
|
| 13165 | 314  | 
(*NOT SUITABLE FOR REWRITING: it is recursive!*)  | 
315  | 
lemma wftrec:  | 
|
316  | 
"[| wf(r); trans(r) |] ==>  | 
|
317  | 
          wftrec(r,a,H) = H(a, lam x: r-``{a}. wftrec(r,x,H))"
 | 
|
318  | 
apply (unfold wftrec_def)  | 
|
319  | 
apply (subst unfold_the_recfun [unfolded is_recfun_def])  | 
|
320  | 
apply (simp_all add: vimage_singleton_iff [THEN iff_sym] the_recfun_cut)  | 
|
321  | 
done  | 
|
322  | 
||
323  | 
(** Removal of the premise trans(r) **)  | 
|
324  | 
||
325  | 
(*NOT SUITABLE FOR REWRITING: it is recursive!*)  | 
|
326  | 
lemma wfrec:  | 
|
327  | 
    "wf(r) ==> wfrec(r,a,H) = H(a, lam x:r-``{a}. wfrec(r,x,H))"
 | 
|
328  | 
apply (unfold wfrec_def)  | 
|
329  | 
apply (erule wf_trancl [THEN wftrec, THEN ssubst])  | 
|
330  | 
apply (rule trans_trancl)  | 
|
331  | 
apply (rule vimage_pair_mono [THEN restrict_lam_eq, THEN subst_context])  | 
|
332  | 
apply (erule r_into_trancl)  | 
|
333  | 
apply (rule subset_refl)  | 
|
334  | 
done  | 
|
| 0 | 335  | 
|
| 13165 | 336  | 
(*This form avoids giant explosions in proofs. NOTE USE OF == *)  | 
337  | 
lemma def_wfrec:  | 
|
338  | 
"[| !!x. h(x)==wfrec(r,x,H); wf(r) |] ==>  | 
|
339  | 
     h(a) = H(a, lam x: r-``{a}. h(x))"
 | 
|
340  | 
apply simp  | 
|
341  | 
apply (elim wfrec)  | 
|
342  | 
done  | 
|
343  | 
||
344  | 
lemma wfrec_type:  | 
|
345  | 
"[| wf(r); a:A; field(r)<=A;  | 
|
346  | 
        !!x u. [| x: A;  u: Pi(r-``{x}, B) |] ==> H(x,u) : B(x)
 | 
|
347  | 
|] ==> wfrec(r,a,H) : B(a)"  | 
|
348  | 
apply (rule_tac a = "a" in wf_induct2, assumption+)  | 
|
349  | 
apply (subst wfrec, assumption)  | 
|
350  | 
apply (simp add: lam_type underD)  | 
|
351  | 
done  | 
|
352  | 
||
353  | 
||
354  | 
lemma wfrec_on:  | 
|
355  | 
"[| wf[A](r); a: A |] ==>  | 
|
356  | 
         wfrec[A](r,a,H) = H(a, lam x: (r-``{a}) Int A. wfrec[A](r,x,H))"
 | 
|
357  | 
apply (unfold wf_on_def wfrec_on_def)  | 
|
358  | 
apply (erule wfrec [THEN trans])  | 
|
359  | 
apply (simp add: vimage_Int_square cons_subset_iff)  | 
|
360  | 
done  | 
|
| 0 | 361  | 
|
| 13165 | 362  | 
(*Minimal-element characterization of well-foundedness*)  | 
363  | 
lemma wf_eq_minimal:  | 
|
364  | 
"wf(r) <-> (ALL Q x. x:Q --> (EX z:Q. ALL y. <y,z>:r --> y~:Q))"  | 
|
365  | 
apply (unfold wf_def, blast)  | 
|
366  | 
done  | 
|
367  | 
||
368  | 
ML  | 
|
369  | 
{*
 | 
|
370  | 
val wf_def = thm "wf_def";  | 
|
371  | 
val wf_on_def = thm "wf_on_def";  | 
|
| 0 | 372  | 
|
| 13165 | 373  | 
val wf_imp_wf_on = thm "wf_imp_wf_on";  | 
374  | 
val wf_on_field_imp_wf = thm "wf_on_field_imp_wf";  | 
|
375  | 
val wf_iff_wf_on_field = thm "wf_iff_wf_on_field";  | 
|
376  | 
val wf_on_subset_A = thm "wf_on_subset_A";  | 
|
377  | 
val wf_on_subset_r = thm "wf_on_subset_r";  | 
|
378  | 
val wf_onI = thm "wf_onI";  | 
|
379  | 
val wf_onI2 = thm "wf_onI2";  | 
|
380  | 
val wf_induct = thm "wf_induct";  | 
|
381  | 
val wf_induct2 = thm "wf_induct2";  | 
|
382  | 
val field_Int_square = thm "field_Int_square";  | 
|
383  | 
val wf_on_induct = thm "wf_on_induct";  | 
|
384  | 
val wfI = thm "wfI";  | 
|
385  | 
val wf_not_refl = thm "wf_not_refl";  | 
|
386  | 
val wf_not_sym = thm "wf_not_sym";  | 
|
387  | 
val wf_asym = thm "wf_asym";  | 
|
388  | 
val wf_on_not_refl = thm "wf_on_not_refl";  | 
|
389  | 
val wf_on_not_sym = thm "wf_on_not_sym";  | 
|
390  | 
val wf_on_asym = thm "wf_on_asym";  | 
|
391  | 
val wf_on_chain3 = thm "wf_on_chain3";  | 
|
392  | 
val wf_on_trancl = thm "wf_on_trancl";  | 
|
393  | 
val wf_trancl = thm "wf_trancl";  | 
|
394  | 
val underI = thm "underI";  | 
|
395  | 
val underD = thm "underD";  | 
|
396  | 
val is_recfun_type = thm "is_recfun_type";  | 
|
397  | 
val apply_recfun = thm "apply_recfun";  | 
|
398  | 
val is_recfun_equal = thm "is_recfun_equal";  | 
|
399  | 
val is_recfun_cut = thm "is_recfun_cut";  | 
|
400  | 
val is_recfun_functional = thm "is_recfun_functional";  | 
|
401  | 
val is_the_recfun = thm "is_the_recfun";  | 
|
402  | 
val unfold_the_recfun = thm "unfold_the_recfun";  | 
|
403  | 
val the_recfun_cut = thm "the_recfun_cut";  | 
|
404  | 
val wftrec = thm "wftrec";  | 
|
405  | 
val wfrec = thm "wfrec";  | 
|
406  | 
val def_wfrec = thm "def_wfrec";  | 
|
407  | 
val wfrec_type = thm "wfrec_type";  | 
|
408  | 
val wfrec_on = thm "wfrec_on";  | 
|
409  | 
val wf_eq_minimal = thm "wf_eq_minimal";  | 
|
410  | 
*}  | 
|
| 435 | 411  | 
|
| 0 | 412  | 
end  |