author | wenzelm |
Tue, 16 Jul 2002 18:46:59 +0200 | |
changeset 13382 | b37764a46b16 |
parent 13363 | c26eeb000470 |
child 13418 | 7c0ba9dba978 |
permissions | -rw-r--r-- |
13306 | 1 |
header {*Absoluteness for Well-Founded Relations and Well-Founded Recursion*} |
2 |
||
13242 | 3 |
theory WF_absolute = WFrec: |
13223 | 4 |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
5 |
subsection{*Every well-founded relation is a subset of some inverse image of |
13247 | 6 |
an ordinal*} |
7 |
||
8 |
lemma wf_rvimage_Ord: "Ord(i) \<Longrightarrow> wf(rvimage(A, f, Memrel(i)))" |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
9 |
by (blast intro: wf_rvimage wf_Memrel) |
13247 | 10 |
|
11 |
||
12 |
constdefs |
|
13 |
wfrank :: "[i,i]=>i" |
|
14 |
"wfrank(r,a) == wfrec(r, a, %x f. \<Union>y \<in> r-``{x}. succ(f`y))" |
|
15 |
||
16 |
constdefs |
|
17 |
wftype :: "i=>i" |
|
18 |
"wftype(r) == \<Union>y \<in> range(r). succ(wfrank(r,y))" |
|
19 |
||
20 |
lemma wfrank: "wf(r) ==> wfrank(r,a) = (\<Union>y \<in> r-``{a}. succ(wfrank(r,y)))" |
|
21 |
by (subst wfrank_def [THEN def_wfrec], simp_all) |
|
22 |
||
23 |
lemma Ord_wfrank: "wf(r) ==> Ord(wfrank(r,a))" |
|
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
13324
diff
changeset
|
24 |
apply (rule_tac a=a in wf_induct, assumption) |
13247 | 25 |
apply (subst wfrank, assumption) |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
26 |
apply (rule Ord_succ [THEN Ord_UN], blast) |
13247 | 27 |
done |
28 |
||
29 |
lemma wfrank_lt: "[|wf(r); <a,b> \<in> r|] ==> wfrank(r,a) < wfrank(r,b)" |
|
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
13324
diff
changeset
|
30 |
apply (rule_tac a1 = b in wfrank [THEN ssubst], assumption) |
13247 | 31 |
apply (rule UN_I [THEN ltI]) |
32 |
apply (simp add: Ord_wfrank vimage_iff)+ |
|
33 |
done |
|
34 |
||
35 |
lemma Ord_wftype: "wf(r) ==> Ord(wftype(r))" |
|
36 |
by (simp add: wftype_def Ord_wfrank) |
|
37 |
||
38 |
lemma wftypeI: "\<lbrakk>wf(r); x \<in> field(r)\<rbrakk> \<Longrightarrow> wfrank(r,x) \<in> wftype(r)" |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
39 |
apply (simp add: wftype_def) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
40 |
apply (blast intro: wfrank_lt [THEN ltD]) |
13247 | 41 |
done |
42 |
||
43 |
||
44 |
lemma wf_imp_subset_rvimage: |
|
45 |
"[|wf(r); r \<subseteq> A*A|] ==> \<exists>i f. Ord(i) & r <= rvimage(A, f, Memrel(i))" |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
46 |
apply (rule_tac x="wftype(r)" in exI) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
47 |
apply (rule_tac x="\<lambda>x\<in>A. wfrank(r,x)" in exI) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
48 |
apply (simp add: Ord_wftype, clarify) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
49 |
apply (frule subsetD, assumption, clarify) |
13247 | 50 |
apply (simp add: rvimage_iff wfrank_lt [THEN ltD]) |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
51 |
apply (blast intro: wftypeI) |
13247 | 52 |
done |
53 |
||
54 |
theorem wf_iff_subset_rvimage: |
|
55 |
"relation(r) ==> wf(r) <-> (\<exists>i f A. Ord(i) & r <= rvimage(A, f, Memrel(i)))" |
|
56 |
by (blast dest!: relation_field_times_field wf_imp_subset_rvimage |
|
57 |
intro: wf_rvimage_Ord [THEN wf_subset]) |
|
58 |
||
59 |
||
13223 | 60 |
subsection{*Transitive closure without fixedpoints*} |
61 |
||
62 |
constdefs |
|
63 |
rtrancl_alt :: "[i,i]=>i" |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
64 |
"rtrancl_alt(A,r) == |
13223 | 65 |
{p \<in> A*A. \<exists>n\<in>nat. \<exists>f \<in> succ(n) -> A. |
13242 | 66 |
(\<exists>x y. p = <x,y> & f`0 = x & f`n = y) & |
13223 | 67 |
(\<forall>i\<in>n. <f`i, f`succ(i)> \<in> r)}" |
68 |
||
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
69 |
lemma alt_rtrancl_lemma1 [rule_format]: |
13223 | 70 |
"n \<in> nat |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
71 |
==> \<forall>f \<in> succ(n) -> field(r). |
13223 | 72 |
(\<forall>i\<in>n. \<langle>f`i, f ` succ(i)\<rangle> \<in> r) --> \<langle>f`0, f`n\<rangle> \<in> r^*" |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
73 |
apply (induct_tac n) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
74 |
apply (simp_all add: apply_funtype rtrancl_refl, clarify) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
75 |
apply (rename_tac n f) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
76 |
apply (rule rtrancl_into_rtrancl) |
13223 | 77 |
prefer 2 apply assumption |
78 |
apply (drule_tac x="restrict(f,succ(n))" in bspec) |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
79 |
apply (blast intro: restrict_type2) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
80 |
apply (simp add: Ord_succ_mem_iff nat_0_le [THEN ltD] leI [THEN ltD] ltI) |
13223 | 81 |
done |
82 |
||
83 |
lemma rtrancl_alt_subset_rtrancl: "rtrancl_alt(field(r),r) <= r^*" |
|
84 |
apply (simp add: rtrancl_alt_def) |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
85 |
apply (blast intro: alt_rtrancl_lemma1) |
13223 | 86 |
done |
87 |
||
88 |
lemma rtrancl_subset_rtrancl_alt: "r^* <= rtrancl_alt(field(r),r)" |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
89 |
apply (simp add: rtrancl_alt_def, clarify) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
90 |
apply (frule rtrancl_type [THEN subsetD], clarify, simp) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
91 |
apply (erule rtrancl_induct) |
13223 | 92 |
txt{*Base case, trivial*} |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
93 |
apply (rule_tac x=0 in bexI) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
94 |
apply (rule_tac x="lam x:1. xa" in bexI) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
95 |
apply simp_all |
13223 | 96 |
txt{*Inductive step*} |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
97 |
apply clarify |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
98 |
apply (rename_tac n f) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
99 |
apply (rule_tac x="succ(n)" in bexI) |
13223 | 100 |
apply (rule_tac x="lam i:succ(succ(n)). if i=succ(n) then z else f`i" in bexI) |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
101 |
apply (simp add: Ord_succ_mem_iff nat_0_le [THEN ltD] leI [THEN ltD] ltI) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
102 |
apply (blast intro: mem_asym) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
103 |
apply typecheck |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
104 |
apply auto |
13223 | 105 |
done |
106 |
||
107 |
lemma rtrancl_alt_eq_rtrancl: "rtrancl_alt(field(r),r) = r^*" |
|
108 |
by (blast del: subsetI |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
109 |
intro: rtrancl_alt_subset_rtrancl rtrancl_subset_rtrancl_alt) |
13223 | 110 |
|
111 |
||
13242 | 112 |
constdefs |
113 |
||
13324 | 114 |
rtran_closure_mem :: "[i=>o,i,i,i] => o" |
115 |
--{*The property of belonging to @{text "rtran_closure(r)"}*} |
|
116 |
"rtran_closure_mem(M,A,r,p) == |
|
117 |
\<exists>nnat[M]. \<exists>n[M]. \<exists>n'[M]. |
|
118 |
omega(M,nnat) & n\<in>nnat & successor(M,n,n') & |
|
119 |
(\<exists>f[M]. typed_function(M,n',A,f) & |
|
120 |
(\<exists>x[M]. \<exists>y[M]. \<exists>zero[M]. pair(M,x,y,p) & empty(M,zero) & |
|
121 |
fun_apply(M,f,zero,x) & fun_apply(M,f,n,y)) & |
|
122 |
(\<forall>j[M]. j\<in>n --> |
|
123 |
(\<exists>fj[M]. \<exists>sj[M]. \<exists>fsj[M]. \<exists>ffp[M]. |
|
124 |
fun_apply(M,f,j,fj) & successor(M,j,sj) & |
|
125 |
fun_apply(M,f,sj,fsj) & pair(M,fj,fsj,ffp) & ffp \<in> r)))" |
|
126 |
||
13242 | 127 |
rtran_closure :: "[i=>o,i,i] => o" |
13324 | 128 |
"rtran_closure(M,r,s) == |
129 |
\<forall>A[M]. is_field(M,r,A) --> |
|
130 |
(\<forall>p[M]. p \<in> s <-> rtran_closure_mem(M,A,r,p))" |
|
13242 | 131 |
|
132 |
tran_closure :: "[i=>o,i,i] => o" |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
133 |
"tran_closure(M,r,t) == |
13268 | 134 |
\<exists>s[M]. rtran_closure(M,r,s) & composition(M,r,s,t)" |
13242 | 135 |
|
13324 | 136 |
lemma (in M_axioms) rtran_closure_mem_iff: |
137 |
"[|M(A); M(r); M(p)|] |
|
138 |
==> rtran_closure_mem(M,A,r,p) <-> |
|
139 |
(\<exists>n[M]. n\<in>nat & |
|
140 |
(\<exists>f[M]. f \<in> succ(n) -> A & |
|
141 |
(\<exists>x[M]. \<exists>y[M]. p = <x,y> & f`0 = x & f`n = y) & |
|
142 |
(\<forall>i\<in>n. <f`i, f`succ(i)> \<in> r)))" |
|
13352 | 143 |
by (simp add: rtran_closure_mem_def Ord_succ_mem_iff nat_0_le [THEN ltD]) |
144 |
||
13242 | 145 |
|
13382 | 146 |
locale (open) M_trancl = M_axioms + |
13242 | 147 |
assumes rtrancl_separation: |
13324 | 148 |
"[| M(r); M(A) |] ==> separation (M, rtran_closure_mem(M,A,r))" |
13242 | 149 |
and wellfounded_trancl_separation: |
13323
2c287f50c9f3
More relativization, reflection and proofs of separation
paulson
parents:
13306
diff
changeset
|
150 |
"[| M(r); M(Z) |] ==> |
2c287f50c9f3
More relativization, reflection and proofs of separation
paulson
parents:
13306
diff
changeset
|
151 |
separation (M, \<lambda>x. |
2c287f50c9f3
More relativization, reflection and proofs of separation
paulson
parents:
13306
diff
changeset
|
152 |
\<exists>w[M]. \<exists>wx[M]. \<exists>rp[M]. |
2c287f50c9f3
More relativization, reflection and proofs of separation
paulson
parents:
13306
diff
changeset
|
153 |
w \<in> Z & pair(M,w,x,wx) & tran_closure(M,r,rp) & wx \<in> rp)" |
13242 | 154 |
|
155 |
||
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
156 |
lemma (in M_trancl) rtran_closure_rtrancl: |
13242 | 157 |
"M(r) ==> rtran_closure(M,r,rtrancl(r))" |
13324 | 158 |
apply (simp add: rtran_closure_def rtran_closure_mem_iff |
159 |
rtrancl_alt_eq_rtrancl [symmetric] rtrancl_alt_def) |
|
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
13324
diff
changeset
|
160 |
apply (auto simp add: nat_0_le [THEN ltD] apply_funtype) |
13242 | 161 |
done |
162 |
||
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
163 |
lemma (in M_trancl) rtrancl_closed [intro,simp]: |
13242 | 164 |
"M(r) ==> M(rtrancl(r))" |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
165 |
apply (insert rtrancl_separation [of r "field(r)"]) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
166 |
apply (simp add: rtrancl_alt_eq_rtrancl [symmetric] |
13324 | 167 |
rtrancl_alt_def rtran_closure_mem_iff) |
13242 | 168 |
done |
169 |
||
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
170 |
lemma (in M_trancl) rtrancl_abs [simp]: |
13242 | 171 |
"[| M(r); M(z) |] ==> rtran_closure(M,r,z) <-> z = rtrancl(r)" |
172 |
apply (rule iffI) |
|
173 |
txt{*Proving the right-to-left implication*} |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
174 |
prefer 2 apply (blast intro: rtran_closure_rtrancl) |
13242 | 175 |
apply (rule M_equalityI) |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
176 |
apply (simp add: rtran_closure_def rtrancl_alt_eq_rtrancl [symmetric] |
13324 | 177 |
rtrancl_alt_def rtran_closure_mem_iff) |
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
13324
diff
changeset
|
178 |
apply (auto simp add: nat_0_le [THEN ltD] apply_funtype) |
13242 | 179 |
done |
180 |
||
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
181 |
lemma (in M_trancl) trancl_closed [intro,simp]: |
13242 | 182 |
"M(r) ==> M(trancl(r))" |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
183 |
by (simp add: trancl_def comp_closed rtrancl_closed) |
13242 | 184 |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
185 |
lemma (in M_trancl) trancl_abs [simp]: |
13242 | 186 |
"[| M(r); M(z) |] ==> tran_closure(M,r,z) <-> z = trancl(r)" |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
187 |
by (simp add: tran_closure_def trancl_def) |
13242 | 188 |
|
13323
2c287f50c9f3
More relativization, reflection and proofs of separation
paulson
parents:
13306
diff
changeset
|
189 |
lemma (in M_trancl) wellfounded_trancl_separation': |
2c287f50c9f3
More relativization, reflection and proofs of separation
paulson
parents:
13306
diff
changeset
|
190 |
"[| M(r); M(Z) |] ==> separation (M, \<lambda>x. \<exists>w[M]. w \<in> Z & <w,x> \<in> r^+)" |
2c287f50c9f3
More relativization, reflection and proofs of separation
paulson
parents:
13306
diff
changeset
|
191 |
by (insert wellfounded_trancl_separation [of r Z], simp) |
13242 | 192 |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
193 |
text{*Alternative proof of @{text wf_on_trancl}; inspiration for the |
13242 | 194 |
relativized version. Original version is on theory WF.*} |
195 |
lemma "[| wf[A](r); r-``A <= A |] ==> wf[A](r^+)" |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
196 |
apply (simp add: wf_on_def wf_def) |
13242 | 197 |
apply (safe intro!: equalityI) |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
198 |
apply (drule_tac x = "{x\<in>A. \<exists>w. \<langle>w,x\<rangle> \<in> r^+ & w \<in> Z}" in spec) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
199 |
apply (blast elim: tranclE) |
13242 | 200 |
done |
201 |
||
202 |
lemma (in M_trancl) wellfounded_on_trancl: |
|
203 |
"[| wellfounded_on(M,A,r); r-``A <= A; M(r); M(A) |] |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
204 |
==> wellfounded_on(M,A,r^+)" |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
205 |
apply (simp add: wellfounded_on_def) |
13242 | 206 |
apply (safe intro!: equalityI) |
207 |
apply (rename_tac Z x) |
|
13268 | 208 |
apply (subgoal_tac "M({x\<in>A. \<exists>w[M]. w \<in> Z & \<langle>w,x\<rangle> \<in> r^+})") |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
209 |
prefer 2 |
13323
2c287f50c9f3
More relativization, reflection and proofs of separation
paulson
parents:
13306
diff
changeset
|
210 |
apply (blast intro: wellfounded_trancl_separation') |
13299 | 211 |
apply (drule_tac x = "{x\<in>A. \<exists>w[M]. w \<in> Z & \<langle>w,x\<rangle> \<in> r^+}" in rspec, safe) |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
212 |
apply (blast dest: transM, simp) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
213 |
apply (rename_tac y w) |
13242 | 214 |
apply (drule_tac x=w in bspec, assumption, clarify) |
215 |
apply (erule tranclE) |
|
216 |
apply (blast dest: transM) (*transM is needed to prove M(xa)*) |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
217 |
apply blast |
13242 | 218 |
done |
219 |
||
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
220 |
lemma (in M_trancl) wellfounded_trancl: |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
221 |
"[|wellfounded(M,r); M(r)|] ==> wellfounded(M,r^+)" |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
222 |
apply (rotate_tac -1) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
223 |
apply (simp add: wellfounded_iff_wellfounded_on_field) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
224 |
apply (rule wellfounded_on_subset_A, erule wellfounded_on_trancl) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
225 |
apply blast |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
226 |
apply (simp_all add: trancl_type [THEN field_rel_subset]) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
227 |
done |
13242 | 228 |
|
13223 | 229 |
text{*Relativized to M: Every well-founded relation is a subset of some |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
230 |
inverse image of an ordinal. Key step is the construction (in M) of a |
13223 | 231 |
rank function.*} |
232 |
||
233 |
||
13382 | 234 |
locale (open) M_wfrank = M_trancl + |
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
13324
diff
changeset
|
235 |
assumes wfrank_separation: |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
236 |
"M(r) ==> |
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
13324
diff
changeset
|
237 |
separation (M, \<lambda>x. |
13348 | 238 |
\<forall>rplus[M]. tran_closure(M,r,rplus) --> |
13352 | 239 |
~ (\<exists>f[M]. M_is_recfun(M, %x f y. is_range(M,f,y), rplus, x, f)))" |
13348 | 240 |
and wfrank_strong_replacement: |
13242 | 241 |
"M(r) ==> |
13348 | 242 |
strong_replacement(M, \<lambda>x z. |
243 |
\<forall>rplus[M]. tran_closure(M,r,rplus) --> |
|
244 |
(\<exists>y[M]. \<exists>f[M]. pair(M,x,y,z) & |
|
13352 | 245 |
M_is_recfun(M, %x f y. is_range(M,f,y), rplus, x, f) & |
13348 | 246 |
is_range(M,f,y)))" |
13242 | 247 |
and Ord_wfrank_separation: |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
248 |
"M(r) ==> |
13348 | 249 |
separation (M, \<lambda>x. |
250 |
\<forall>rplus[M]. tran_closure(M,r,rplus) --> |
|
251 |
~ (\<forall>f[M]. \<forall>rangef[M]. |
|
252 |
is_range(M,f,rangef) --> |
|
13352 | 253 |
M_is_recfun(M, \<lambda>x f y. is_range(M,f,y), rplus, x, f) --> |
13348 | 254 |
ordinal(M,rangef)))" |
255 |
||
256 |
text{*Proving that the relativized instances of Separation or Replacement |
|
257 |
agree with the "real" ones.*} |
|
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
13324
diff
changeset
|
258 |
|
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
13324
diff
changeset
|
259 |
lemma (in M_wfrank) wfrank_separation': |
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
13324
diff
changeset
|
260 |
"M(r) ==> |
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
13324
diff
changeset
|
261 |
separation |
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
13324
diff
changeset
|
262 |
(M, \<lambda>x. ~ (\<exists>f[M]. is_recfun(r^+, x, %x f. range(f), f)))" |
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
13324
diff
changeset
|
263 |
apply (insert wfrank_separation [of r]) |
13353 | 264 |
apply (simp add: relativize2_def is_recfun_abs [of "%x. range"]) |
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
13324
diff
changeset
|
265 |
done |
13223 | 266 |
|
13348 | 267 |
lemma (in M_wfrank) wfrank_strong_replacement': |
268 |
"M(r) ==> |
|
269 |
strong_replacement(M, \<lambda>x z. \<exists>y[M]. \<exists>f[M]. |
|
270 |
pair(M,x,y,z) & is_recfun(r^+, x, %x f. range(f), f) & |
|
271 |
y = range(f))" |
|
272 |
apply (insert wfrank_strong_replacement [of r]) |
|
13353 | 273 |
apply (simp add: relativize2_def is_recfun_abs [of "%x. range"]) |
13348 | 274 |
done |
275 |
||
276 |
lemma (in M_wfrank) Ord_wfrank_separation': |
|
277 |
"M(r) ==> |
|
278 |
separation (M, \<lambda>x. |
|
279 |
~ (\<forall>f[M]. is_recfun(r^+, x, \<lambda>x. range, f) --> Ord(range(f))))" |
|
280 |
apply (insert Ord_wfrank_separation [of r]) |
|
13353 | 281 |
apply (simp add: relativize2_def is_recfun_abs [of "%x. range"]) |
13348 | 282 |
done |
283 |
||
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
284 |
text{*This function, defined using replacement, is a rank function for |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
285 |
well-founded relations within the class M.*} |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
286 |
constdefs |
13242 | 287 |
wellfoundedrank :: "[i=>o,i,i] => i" |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
288 |
"wellfoundedrank(M,r,A) == |
13268 | 289 |
{p. x\<in>A, \<exists>y[M]. \<exists>f[M]. |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
290 |
p = <x,y> & is_recfun(r^+, x, %x f. range(f), f) & |
13242 | 291 |
y = range(f)}" |
13223 | 292 |
|
13268 | 293 |
lemma (in M_wfrank) exists_wfrank: |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
294 |
"[| wellfounded(M,r); M(a); M(r) |] |
13268 | 295 |
==> \<exists>f[M]. is_recfun(r^+, a, %x f. range(f), f)" |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
296 |
apply (rule wellfounded_exists_is_recfun) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
297 |
apply (blast intro: wellfounded_trancl) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
298 |
apply (rule trans_trancl) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
299 |
apply (erule wfrank_separation') |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
300 |
apply (erule wfrank_strong_replacement') |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
301 |
apply (simp_all add: trancl_subset_times) |
13223 | 302 |
done |
303 |
||
13268 | 304 |
lemma (in M_wfrank) M_wellfoundedrank: |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
305 |
"[| wellfounded(M,r); M(r); M(A) |] ==> M(wellfoundedrank(M,r,A))" |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
306 |
apply (insert wfrank_strong_replacement' [of r]) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
307 |
apply (simp add: wellfoundedrank_def) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
308 |
apply (rule strong_replacement_closed) |
13242 | 309 |
apply assumption+ |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
310 |
apply (rule univalent_is_recfun) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
311 |
apply (blast intro: wellfounded_trancl) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
312 |
apply (rule trans_trancl) |
13254 | 313 |
apply (simp add: trancl_subset_times, blast) |
13223 | 314 |
done |
315 |
||
13268 | 316 |
lemma (in M_wfrank) Ord_wfrank_range [rule_format]: |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
317 |
"[| wellfounded(M,r); a\<in>A; M(r); M(A) |] |
13348 | 318 |
==> \<forall>f[M]. is_recfun(r^+, a, %x f. range(f), f) --> Ord(range(f))" |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
319 |
apply (drule wellfounded_trancl, assumption) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
320 |
apply (rule wellfounded_induct, assumption+) |
13254 | 321 |
apply simp |
13348 | 322 |
apply (blast intro: Ord_wfrank_separation', clarify) |
13242 | 323 |
txt{*The reasoning in both cases is that we get @{term y} such that |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
324 |
@{term "\<langle>y, x\<rangle> \<in> r^+"}. We find that |
13242 | 325 |
@{term "f`y = restrict(f, r^+ -`` {y})"}. *} |
326 |
apply (rule OrdI [OF _ Ord_is_Transset]) |
|
327 |
txt{*An ordinal is a transitive set...*} |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
328 |
apply (simp add: Transset_def) |
13242 | 329 |
apply clarify |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
330 |
apply (frule apply_recfun2, assumption) |
13242 | 331 |
apply (force simp add: restrict_iff) |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
332 |
txt{*...of ordinals. This second case requires the induction hyp.*} |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
333 |
apply clarify |
13242 | 334 |
apply (rename_tac i y) |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
335 |
apply (frule apply_recfun2, assumption) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
336 |
apply (frule is_recfun_imp_in_r, assumption) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
337 |
apply (frule is_recfun_restrict) |
13242 | 338 |
(*simp_all won't work*) |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
339 |
apply (simp add: trans_trancl trancl_subset_times)+ |
13242 | 340 |
apply (drule spec [THEN mp], assumption) |
341 |
apply (subgoal_tac "M(restrict(f, r^+ -`` {y}))") |
|
13348 | 342 |
apply (drule_tac x="restrict(f, r^+ -`` {y})" in rspec) |
343 |
apply assumption |
|
13242 | 344 |
apply (simp add: function_apply_equality [OF _ is_recfun_imp_function]) |
345 |
apply (blast dest: pair_components_in_M) |
|
13223 | 346 |
done |
347 |
||
13268 | 348 |
lemma (in M_wfrank) Ord_range_wellfoundedrank: |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
349 |
"[| wellfounded(M,r); r \<subseteq> A*A; M(r); M(A) |] |
13242 | 350 |
==> Ord (range(wellfoundedrank(M,r,A)))" |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
351 |
apply (frule wellfounded_trancl, assumption) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
352 |
apply (frule trancl_subset_times) |
13242 | 353 |
apply (simp add: wellfoundedrank_def) |
354 |
apply (rule OrdI [OF _ Ord_is_Transset]) |
|
355 |
prefer 2 |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
356 |
txt{*by our previous result the range consists of ordinals.*} |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
357 |
apply (blast intro: Ord_wfrank_range) |
13242 | 358 |
txt{*We still must show that the range is a transitive set.*} |
13247 | 359 |
apply (simp add: Transset_def, clarify, simp) |
13293 | 360 |
apply (rename_tac x i f u) |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
361 |
apply (frule is_recfun_imp_in_r, assumption) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
362 |
apply (subgoal_tac "M(u) & M(i) & M(x)") |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
363 |
prefer 2 apply (blast dest: transM, clarify) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
364 |
apply (rule_tac a=u in rangeI) |
13293 | 365 |
apply (rule_tac x=u in ReplaceI) |
366 |
apply simp |
|
367 |
apply (rule_tac x="restrict(f, r^+ -`` {u})" in rexI) |
|
368 |
apply (blast intro: is_recfun_restrict trans_trancl dest: apply_recfun2) |
|
369 |
apply simp |
|
370 |
apply blast |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
371 |
txt{*Unicity requirement of Replacement*} |
13242 | 372 |
apply clarify |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
373 |
apply (frule apply_recfun2, assumption) |
13293 | 374 |
apply (simp add: trans_trancl is_recfun_cut) |
13223 | 375 |
done |
376 |
||
13268 | 377 |
lemma (in M_wfrank) function_wellfoundedrank: |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
378 |
"[| wellfounded(M,r); M(r); M(A)|] |
13242 | 379 |
==> function(wellfoundedrank(M,r,A))" |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
380 |
apply (simp add: wellfoundedrank_def function_def, clarify) |
13242 | 381 |
txt{*Uniqueness: repeated below!*} |
382 |
apply (drule is_recfun_functional, assumption) |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
383 |
apply (blast intro: wellfounded_trancl) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
384 |
apply (simp_all add: trancl_subset_times trans_trancl) |
13223 | 385 |
done |
386 |
||
13268 | 387 |
lemma (in M_wfrank) domain_wellfoundedrank: |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
388 |
"[| wellfounded(M,r); M(r); M(A)|] |
13242 | 389 |
==> domain(wellfoundedrank(M,r,A)) = A" |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
390 |
apply (simp add: wellfoundedrank_def function_def) |
13242 | 391 |
apply (rule equalityI, auto) |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
392 |
apply (frule transM, assumption) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
393 |
apply (frule_tac a=x in exists_wfrank, assumption+, clarify) |
13293 | 394 |
apply (rule_tac b="range(f)" in domainI) |
395 |
apply (rule_tac x=x in ReplaceI) |
|
396 |
apply simp |
|
13268 | 397 |
apply (rule_tac x=f in rexI, blast, simp_all) |
13242 | 398 |
txt{*Uniqueness (for Replacement): repeated above!*} |
399 |
apply clarify |
|
400 |
apply (drule is_recfun_functional, assumption) |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
401 |
apply (blast intro: wellfounded_trancl) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
402 |
apply (simp_all add: trancl_subset_times trans_trancl) |
13223 | 403 |
done |
404 |
||
13268 | 405 |
lemma (in M_wfrank) wellfoundedrank_type: |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
406 |
"[| wellfounded(M,r); M(r); M(A)|] |
13242 | 407 |
==> wellfoundedrank(M,r,A) \<in> A -> range(wellfoundedrank(M,r,A))" |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
408 |
apply (frule function_wellfoundedrank [of r A], assumption+) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
409 |
apply (frule function_imp_Pi) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
410 |
apply (simp add: wellfoundedrank_def relation_def) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
411 |
apply blast |
13242 | 412 |
apply (simp add: domain_wellfoundedrank) |
13223 | 413 |
done |
414 |
||
13268 | 415 |
lemma (in M_wfrank) Ord_wellfoundedrank: |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
416 |
"[| wellfounded(M,r); a \<in> A; r \<subseteq> A*A; M(r); M(A) |] |
13242 | 417 |
==> Ord(wellfoundedrank(M,r,A) ` a)" |
418 |
by (blast intro: apply_funtype [OF wellfoundedrank_type] |
|
419 |
Ord_in_Ord [OF Ord_range_wellfoundedrank]) |
|
13223 | 420 |
|
13268 | 421 |
lemma (in M_wfrank) wellfoundedrank_eq: |
13242 | 422 |
"[| is_recfun(r^+, a, %x. range, f); |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
423 |
wellfounded(M,r); a \<in> A; M(f); M(r); M(A)|] |
13242 | 424 |
==> wellfoundedrank(M,r,A) ` a = range(f)" |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
425 |
apply (rule apply_equality) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
426 |
prefer 2 apply (blast intro: wellfoundedrank_type) |
13242 | 427 |
apply (simp add: wellfoundedrank_def) |
428 |
apply (rule ReplaceI) |
|
13268 | 429 |
apply (rule_tac x="range(f)" in rexI) |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
430 |
apply blast |
13268 | 431 |
apply simp_all |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
432 |
txt{*Unicity requirement of Replacement*} |
13242 | 433 |
apply clarify |
434 |
apply (drule is_recfun_functional, assumption) |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
435 |
apply (blast intro: wellfounded_trancl) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
436 |
apply (simp_all add: trancl_subset_times trans_trancl) |
13223 | 437 |
done |
438 |
||
13247 | 439 |
|
13268 | 440 |
lemma (in M_wfrank) wellfoundedrank_lt: |
13247 | 441 |
"[| <a,b> \<in> r; |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
442 |
wellfounded(M,r); r \<subseteq> A*A; M(r); M(A)|] |
13247 | 443 |
==> wellfoundedrank(M,r,A) ` a < wellfoundedrank(M,r,A) ` b" |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
444 |
apply (frule wellfounded_trancl, assumption) |
13247 | 445 |
apply (subgoal_tac "a\<in>A & b\<in>A") |
446 |
prefer 2 apply blast |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
447 |
apply (simp add: lt_def Ord_wellfoundedrank, clarify) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
448 |
apply (frule exists_wfrank [of concl: _ b], assumption+, clarify) |
13247 | 449 |
apply (rename_tac fb) |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
450 |
apply (frule is_recfun_restrict [of concl: "r^+" a]) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
451 |
apply (rule trans_trancl, assumption) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
452 |
apply (simp_all add: r_into_trancl trancl_subset_times) |
13247 | 453 |
txt{*Still the same goal, but with new @{text is_recfun} assumptions.*} |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
454 |
apply (simp add: wellfoundedrank_eq) |
13247 | 455 |
apply (frule_tac a=a in wellfoundedrank_eq, assumption+) |
456 |
apply (simp_all add: transM [of a]) |
|
457 |
txt{*We have used equations for wellfoundedrank and now must use some |
|
458 |
for @{text is_recfun}. *} |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
459 |
apply (rule_tac a=a in rangeI) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
460 |
apply (simp add: is_recfun_type [THEN apply_iff] vimage_singleton_iff |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
461 |
r_into_trancl apply_recfun r_into_trancl) |
13247 | 462 |
done |
463 |
||
464 |
||
13268 | 465 |
lemma (in M_wfrank) wellfounded_imp_subset_rvimage: |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
466 |
"[|wellfounded(M,r); r \<subseteq> A*A; M(r); M(A)|] |
13247 | 467 |
==> \<exists>i f. Ord(i) & r <= rvimage(A, f, Memrel(i))" |
468 |
apply (rule_tac x="range(wellfoundedrank(M,r,A))" in exI) |
|
469 |
apply (rule_tac x="wellfoundedrank(M,r,A)" in exI) |
|
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
470 |
apply (simp add: Ord_range_wellfoundedrank, clarify) |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
471 |
apply (frule subsetD, assumption, clarify) |
13247 | 472 |
apply (simp add: rvimage_iff wellfoundedrank_lt [THEN ltD]) |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
473 |
apply (blast intro: apply_rangeI wellfoundedrank_type) |
13247 | 474 |
done |
475 |
||
13268 | 476 |
lemma (in M_wfrank) wellfounded_imp_wf: |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
477 |
"[|wellfounded(M,r); relation(r); M(r)|] ==> wf(r)" |
13247 | 478 |
by (blast dest!: relation_field_times_field wellfounded_imp_subset_rvimage |
479 |
intro: wf_rvimage_Ord [THEN wf_subset]) |
|
480 |
||
13268 | 481 |
lemma (in M_wfrank) wellfounded_on_imp_wf_on: |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
482 |
"[|wellfounded_on(M,A,r); relation(r); M(r); M(A)|] ==> wf[A](r)" |
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
483 |
apply (simp add: wellfounded_on_iff_wellfounded wf_on_def) |
13247 | 484 |
apply (rule wellfounded_imp_wf) |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
485 |
apply (simp_all add: relation_def) |
13247 | 486 |
done |
487 |
||
488 |
||
13268 | 489 |
theorem (in M_wfrank) wf_abs [simp]: |
13247 | 490 |
"[|relation(r); M(r)|] ==> wellfounded(M,r) <-> wf(r)" |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
491 |
by (blast intro: wellfounded_imp_wf wf_imp_relativized) |
13247 | 492 |
|
13268 | 493 |
theorem (in M_wfrank) wf_on_abs [simp]: |
13247 | 494 |
"[|relation(r); M(r); M(A)|] ==> wellfounded_on(M,A,r) <-> wf[A](r)" |
13251
74cb2af8811e
new treatment of wfrec, replacing wf[A](r) by wf(r)
paulson
parents:
13247
diff
changeset
|
495 |
by (blast intro: wellfounded_on_imp_wf_on wf_on_imp_relativized) |
13247 | 496 |
|
13254 | 497 |
|
498 |
text{*absoluteness for wfrec-defined functions.*} |
|
499 |
||
500 |
(*first use is_recfun, then M_is_recfun*) |
|
501 |
||
502 |
lemma (in M_trancl) wfrec_relativize: |
|
503 |
"[|wf(r); M(a); M(r); |
|
13268 | 504 |
strong_replacement(M, \<lambda>x z. \<exists>y[M]. \<exists>g[M]. |
13254 | 505 |
pair(M,x,y,z) & |
506 |
is_recfun(r^+, x, \<lambda>x f. H(x, restrict(f, r -`` {x})), g) & |
|
507 |
y = H(x, restrict(g, r -`` {x}))); |
|
508 |
\<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g))|] |
|
509 |
==> wfrec(r,a,H) = z <-> |
|
13268 | 510 |
(\<exists>f[M]. is_recfun(r^+, a, \<lambda>x f. H(x, restrict(f, r -`` {x})), f) & |
13254 | 511 |
z = H(a,restrict(f,r-``{a})))" |
512 |
apply (frule wf_trancl) |
|
513 |
apply (simp add: wftrec_def wfrec_def, safe) |
|
514 |
apply (frule wf_exists_is_recfun |
|
515 |
[of concl: "r^+" a "\<lambda>x f. H(x, restrict(f, r -`` {x}))"]) |
|
516 |
apply (simp_all add: trans_trancl function_restrictI trancl_subset_times) |
|
13268 | 517 |
apply (clarify, rule_tac x=x in rexI) |
13254 | 518 |
apply (simp_all add: the_recfun_eq trans_trancl trancl_subset_times) |
519 |
done |
|
520 |
||
521 |
||
522 |
text{*Assuming @{term r} is transitive simplifies the occurrences of @{text H}. |
|
523 |
The premise @{term "relation(r)"} is necessary |
|
524 |
before we can replace @{term "r^+"} by @{term r}. *} |
|
525 |
theorem (in M_trancl) trans_wfrec_relativize: |
|
526 |
"[|wf(r); trans(r); relation(r); M(r); M(a); |
|
13353 | 527 |
wfrec_replacement(M,MH,r); relativize2(M,MH,H); |
13254 | 528 |
\<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g))|] |
13268 | 529 |
==> wfrec(r,a,H) = z <-> (\<exists>f[M]. is_recfun(r,a,H,f) & z = H(a,f))" |
13353 | 530 |
apply (frule wfrec_replacement', assumption+) |
531 |
apply (simp cong: is_recfun_cong |
|
532 |
add: wfrec_relativize trancl_eq_r |
|
533 |
is_recfun_restrict_idem domain_restrict_idem) |
|
534 |
done |
|
13254 | 535 |
|
13353 | 536 |
theorem (in M_trancl) trans_wfrec_abs: |
537 |
"[|wf(r); trans(r); relation(r); M(r); M(a); M(z); |
|
538 |
wfrec_replacement(M,MH,r); relativize2(M,MH,H); |
|
539 |
\<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g))|] |
|
540 |
==> is_wfrec(M,MH,r,a,z) <-> z=wfrec(r,a,H)" |
|
541 |
apply (simp add: trans_wfrec_relativize [THEN iff_sym] is_wfrec_abs, blast) |
|
542 |
done |
|
13254 | 543 |
|
544 |
lemma (in M_trancl) trans_eq_pair_wfrec_iff: |
|
545 |
"[|wf(r); trans(r); relation(r); M(r); M(y); |
|
13353 | 546 |
wfrec_replacement(M,MH,r); relativize2(M,MH,H); |
13254 | 547 |
\<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g))|] |
548 |
==> y = <x, wfrec(r, x, H)> <-> |
|
13268 | 549 |
(\<exists>f[M]. is_recfun(r,x,H,f) & y = <x, H(x,f)>)" |
13293 | 550 |
apply safe |
551 |
apply (simp add: trans_wfrec_relativize [THEN iff_sym, of concl: _ x]) |
|
13254 | 552 |
txt{*converse direction*} |
553 |
apply (rule sym) |
|
554 |
apply (simp add: trans_wfrec_relativize, blast) |
|
555 |
done |
|
556 |
||
557 |
||
558 |
subsection{*M is closed under well-founded recursion*} |
|
559 |
||
560 |
text{*Lemma with the awkward premise mentioning @{text wfrec}.*} |
|
13268 | 561 |
lemma (in M_wfrank) wfrec_closed_lemma [rule_format]: |
13254 | 562 |
"[|wf(r); M(r); |
563 |
strong_replacement(M, \<lambda>x y. y = \<langle>x, wfrec(r, x, H)\<rangle>); |
|
564 |
\<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g)) |] |
|
565 |
==> M(a) --> M(wfrec(r,a,H))" |
|
566 |
apply (rule_tac a=a in wf_induct, assumption+) |
|
567 |
apply (subst wfrec, assumption, clarify) |
|
568 |
apply (drule_tac x1=x and x="\<lambda>x\<in>r -`` {x}. wfrec(r, x, H)" |
|
569 |
in rspec [THEN rspec]) |
|
570 |
apply (simp_all add: function_lam) |
|
571 |
apply (blast intro: dest: pair_components_in_M ) |
|
572 |
done |
|
573 |
||
574 |
text{*Eliminates one instance of replacement.*} |
|
13268 | 575 |
lemma (in M_wfrank) wfrec_replacement_iff: |
13353 | 576 |
"strong_replacement(M, \<lambda>x z. |
577 |
\<exists>y[M]. pair(M,x,y,z) & (\<exists>g[M]. is_recfun(r,x,H,g) & y = H(x,g))) <-> |
|
13254 | 578 |
strong_replacement(M, |
13268 | 579 |
\<lambda>x y. \<exists>f[M]. is_recfun(r,x,H,f) & y = <x, H(x,f)>)" |
13254 | 580 |
apply simp |
581 |
apply (rule strong_replacement_cong, blast) |
|
582 |
done |
|
583 |
||
584 |
text{*Useful version for transitive relations*} |
|
13268 | 585 |
theorem (in M_wfrank) trans_wfrec_closed: |
13254 | 586 |
"[|wf(r); trans(r); relation(r); M(r); M(a); |
13353 | 587 |
wfrec_replacement(M,MH,r); relativize2(M,MH,H); |
13254 | 588 |
\<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g)) |] |
589 |
==> M(wfrec(r,a,H))" |
|
13353 | 590 |
apply (frule wfrec_replacement', assumption+) |
13254 | 591 |
apply (frule wfrec_replacement_iff [THEN iffD1]) |
592 |
apply (rule wfrec_closed_lemma, assumption+) |
|
593 |
apply (simp_all add: wfrec_replacement_iff trans_eq_pair_wfrec_iff) |
|
594 |
done |
|
595 |
||
596 |
section{*Absoluteness without assuming transitivity*} |
|
597 |
lemma (in M_trancl) eq_pair_wfrec_iff: |
|
598 |
"[|wf(r); M(r); M(y); |
|
13268 | 599 |
strong_replacement(M, \<lambda>x z. \<exists>y[M]. \<exists>g[M]. |
13254 | 600 |
pair(M,x,y,z) & |
601 |
is_recfun(r^+, x, \<lambda>x f. H(x, restrict(f, r -`` {x})), g) & |
|
602 |
y = H(x, restrict(g, r -`` {x}))); |
|
603 |
\<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g))|] |
|
604 |
==> y = <x, wfrec(r, x, H)> <-> |
|
13268 | 605 |
(\<exists>f[M]. is_recfun(r^+, x, \<lambda>x f. H(x, restrict(f, r -`` {x})), f) & |
13254 | 606 |
y = <x, H(x,restrict(f,r-``{x}))>)" |
607 |
apply safe |
|
13293 | 608 |
apply (simp add: wfrec_relativize [THEN iff_sym, of concl: _ x]) |
13254 | 609 |
txt{*converse direction*} |
610 |
apply (rule sym) |
|
611 |
apply (simp add: wfrec_relativize, blast) |
|
612 |
done |
|
613 |
||
614 |
text{*Full version not assuming transitivity, but maybe not very useful.*} |
|
13268 | 615 |
theorem (in M_wfrank) wfrec_closed: |
13254 | 616 |
"[|wf(r); M(r); M(a); |
13353 | 617 |
wfrec_replacement(M,MH,r^+); |
618 |
relativize2(M,MH, \<lambda>x f. H(x, restrict(f, r -`` {x}))); |
|
13254 | 619 |
\<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g)) |] |
620 |
==> M(wfrec(r,a,H))" |
|
13353 | 621 |
apply (frule wfrec_replacement' |
622 |
[of MH "r^+" "\<lambda>x f. H(x, restrict(f, r -`` {x}))"]) |
|
623 |
prefer 4 |
|
624 |
apply (frule wfrec_replacement_iff [THEN iffD1]) |
|
625 |
apply (rule wfrec_closed_lemma, assumption+) |
|
626 |
apply (simp_all add: eq_pair_wfrec_iff func.function_restrictI) |
|
13254 | 627 |
done |
628 |
||
13223 | 629 |
end |