13223
|
1 |
theory WFrec = Wellorderings:
|
|
2 |
|
|
3 |
|
13245
|
4 |
(*FIXME: could move these to WF.thy*)
|
13223
|
5 |
|
|
6 |
lemma is_recfunI:
|
|
7 |
"f = (lam x: r-``{a}. H(x, restrict(f, r-``{x}))) ==> is_recfun(r,a,H,f)"
|
|
8 |
by (simp add: is_recfun_def)
|
|
9 |
|
|
10 |
lemma is_recfun_imp_function: "is_recfun(r,a,H,f) ==> function(f)"
|
|
11 |
apply (simp add: is_recfun_def)
|
|
12 |
apply (erule ssubst)
|
|
13 |
apply (rule function_lam)
|
|
14 |
done
|
|
15 |
|
|
16 |
text{*Expresses @{text is_recfun} as a recursion equation*}
|
|
17 |
lemma is_recfun_iff_equation:
|
|
18 |
"is_recfun(r,a,H,f) <->
|
|
19 |
f \<in> r -`` {a} \<rightarrow> range(f) &
|
|
20 |
(\<forall>x \<in> r-``{a}. f`x = H(x, restrict(f, r-``{x})))"
|
|
21 |
apply (rule iffI)
|
|
22 |
apply (simp add: is_recfun_type apply_recfun Ball_def vimage_singleton_iff,
|
|
23 |
clarify)
|
|
24 |
apply (simp add: is_recfun_def)
|
|
25 |
apply (rule fun_extension)
|
|
26 |
apply assumption
|
|
27 |
apply (fast intro: lam_type, simp)
|
|
28 |
done
|
|
29 |
|
13245
|
30 |
lemma is_recfun_imp_in_r: "[|is_recfun(r,a,H,f); \<langle>x,i\<rangle> \<in> f|] ==> \<langle>x, a\<rangle> \<in> r"
|
|
31 |
by (blast dest: is_recfun_type fun_is_rel)
|
|
32 |
|
|
33 |
lemma apply_recfun2:
|
|
34 |
"[| is_recfun(r,a,H,f); <x,i>:f |] ==> i = H(x, restrict(f,r-``{x}))"
|
|
35 |
apply (frule apply_recfun)
|
|
36 |
apply (blast dest: is_recfun_type fun_is_rel)
|
|
37 |
apply (simp add: function_apply_equality [OF _ is_recfun_imp_function])
|
|
38 |
done
|
|
39 |
|
13223
|
40 |
lemma trans_on_Int_eq [simp]:
|
|
41 |
"[| trans[A](r); <y,x> \<in> r; r \<subseteq> A*A |]
|
|
42 |
==> r -`` {y} \<inter> r -`` {x} = r -`` {y}"
|
|
43 |
by (blast intro: trans_onD)
|
|
44 |
|
|
45 |
lemma trans_on_Int_eq2 [simp]:
|
|
46 |
"[| trans[A](r); <y,x> \<in> r; r \<subseteq> A*A |]
|
|
47 |
==> r -`` {x} \<inter> r -`` {y} = r -`` {y}"
|
|
48 |
by (blast intro: trans_onD)
|
|
49 |
|
|
50 |
|
|
51 |
text{*Stated using @{term "trans[A](r)"} rather than
|
|
52 |
@{term "transitive_rel(M,A,r)"} because the latter rewrites to
|
|
53 |
the former anyway, by @{text transitive_rel_abs}.
|
|
54 |
As always, theorems should be expressed in simplified form.*}
|
|
55 |
lemma (in M_axioms) is_recfun_equal [rule_format]:
|
|
56 |
"[|is_recfun(r,a,H,f); is_recfun(r,b,H,g);
|
|
57 |
wellfounded_on(M,A,r); trans[A](r);
|
|
58 |
M(A); M(f); M(g); M(a); M(b);
|
|
59 |
r \<subseteq> A*A; x\<in>A |]
|
|
60 |
==> <x,a> \<in> r --> <x,b> \<in> r --> f`x=g`x"
|
|
61 |
apply (frule_tac f="f" in is_recfun_type)
|
|
62 |
apply (frule_tac f="g" in is_recfun_type)
|
|
63 |
apply (simp add: is_recfun_def)
|
|
64 |
apply (erule wellfounded_on_induct2, assumption+)
|
|
65 |
apply (force intro: is_recfun_separation, clarify)
|
|
66 |
apply (erule ssubst)+
|
|
67 |
apply (simp (no_asm_simp) add: vimage_singleton_iff restrict_def)
|
|
68 |
apply (rename_tac x1)
|
|
69 |
apply (rule_tac t="%z. H(x1,z)" in subst_context)
|
|
70 |
apply (subgoal_tac "ALL y : r-``{x1}. ALL z. <y,z>:f <-> <y,z>:g")
|
|
71 |
apply (blast intro: trans_onD)
|
|
72 |
apply (simp add: apply_iff)
|
|
73 |
apply (blast intro: trans_onD sym)
|
|
74 |
done
|
|
75 |
|
|
76 |
lemma (in M_axioms) is_recfun_cut:
|
|
77 |
"[|is_recfun(r,a,H,f); is_recfun(r,b,H,g);
|
|
78 |
wellfounded_on(M,A,r); trans[A](r);
|
|
79 |
M(A); M(f); M(g); M(a); M(b);
|
|
80 |
r \<subseteq> A*A; <b,a>\<in>r |]
|
|
81 |
==> restrict(f, r-``{b}) = g"
|
|
82 |
apply (frule_tac f="f" in is_recfun_type)
|
|
83 |
apply (rule fun_extension)
|
|
84 |
apply (blast intro: trans_onD restrict_type2)
|
|
85 |
apply (erule is_recfun_type, simp)
|
|
86 |
apply (blast intro: is_recfun_equal trans_onD)
|
|
87 |
done
|
|
88 |
|
|
89 |
lemma (in M_axioms) is_recfun_functional:
|
|
90 |
"[|is_recfun(r,a,H,f); is_recfun(r,a,H,g);
|
|
91 |
wellfounded_on(M,A,r); trans[A](r);
|
|
92 |
M(A); M(f); M(g); M(a);
|
|
93 |
r \<subseteq> A*A |]
|
|
94 |
==> f=g"
|
|
95 |
apply (rule fun_extension)
|
|
96 |
apply (erule is_recfun_type)+
|
|
97 |
apply (blast intro!: is_recfun_equal)
|
|
98 |
done
|
|
99 |
|
|
100 |
text{*Tells us that is_recfun can (in principle) be relativized.*}
|
|
101 |
lemma (in M_axioms) is_recfun_relativize:
|
|
102 |
"[| M(r); M(a); M(f);
|
|
103 |
\<forall>x g. M(x) & M(g) & function(g) --> M(H(x,g)) |] ==>
|
|
104 |
is_recfun(r,a,H,f) <->
|
|
105 |
(\<forall>z. z \<in> f <-> (\<exists>x y. M(x) & M(y) & z=<x,y> & <x,a> \<in> r &
|
|
106 |
y = H(x, restrict(f, r-``{x}))))";
|
|
107 |
apply (simp add: is_recfun_def vimage_closed restrict_closed lam_def)
|
|
108 |
apply (safe intro!: equalityI)
|
|
109 |
apply (drule equalityD1 [THEN subsetD], assumption)
|
|
110 |
apply clarify
|
|
111 |
apply (rule_tac x=x in exI)
|
|
112 |
apply (blast dest: pair_components_in_M)
|
|
113 |
apply (blast elim!: equalityE dest: pair_components_in_M)
|
|
114 |
apply simp
|
|
115 |
apply blast
|
|
116 |
apply simp
|
|
117 |
apply (subgoal_tac "function(f)")
|
|
118 |
prefer 2
|
|
119 |
apply (simp add: function_def)
|
|
120 |
apply (frule pair_components_in_M, assumption)
|
|
121 |
apply (simp add: is_recfun_imp_function function_restrictI restrict_closed vimage_closed)
|
|
122 |
done
|
|
123 |
|
|
124 |
(* ideas for further weaking the H-closure premise:
|
|
125 |
apply (drule spec [THEN spec])
|
|
126 |
apply (erule mp)
|
|
127 |
apply (intro conjI)
|
|
128 |
apply (blast dest!: pair_components_in_M)
|
|
129 |
apply (blast intro!: function_restrictI dest!: pair_components_in_M)
|
|
130 |
apply (blast intro!: function_restrictI dest!: pair_components_in_M)
|
|
131 |
apply (simp only: subset_iff domain_iff restrict_iff vimage_iff)
|
|
132 |
apply (simp add: vimage_singleton_iff)
|
|
133 |
apply (intro allI impI conjI)
|
|
134 |
apply (blast intro: transM dest!: pair_components_in_M)
|
|
135 |
prefer 4;apply blast
|
|
136 |
*)
|
|
137 |
|
|
138 |
lemma (in M_axioms) is_recfun_restrict:
|
|
139 |
"[| wellfounded_on(M,A,r); trans[A](r); is_recfun(r,x,H,f); \<langle>y,x\<rangle> \<in> r;
|
|
140 |
M(A); M(r); M(f);
|
|
141 |
\<forall>x g. M(x) & M(g) & function(g) --> M(H(x,g)); r \<subseteq> A * A |]
|
|
142 |
==> is_recfun(r, y, H, restrict(f, r -`` {y}))"
|
|
143 |
apply (frule pair_components_in_M, assumption, clarify)
|
13247
|
144 |
apply (simp (no_asm_simp) add: is_recfun_relativize restrict_iff)
|
13223
|
145 |
apply safe
|
|
146 |
apply (simp_all add: vimage_singleton_iff is_recfun_type [THEN apply_iff])
|
|
147 |
apply (frule_tac x=xa in pair_components_in_M, assumption)
|
|
148 |
apply (frule_tac x=xa in apply_recfun, blast intro: trans_onD)
|
13247
|
149 |
apply (simp add: is_recfun_type [THEN apply_iff]
|
|
150 |
is_recfun_imp_function function_restrictI)
|
13223
|
151 |
apply (blast intro: apply_recfun dest: trans_onD)+
|
|
152 |
done
|
|
153 |
|
|
154 |
lemma (in M_axioms) restrict_Y_lemma:
|
|
155 |
"[| wellfounded_on(M,A,r); trans[A](r); M(A); M(r); r \<subseteq> A \<times> A;
|
|
156 |
\<forall>x g. M(x) \<and> M(g) & function(g) --> M(H(x,g)); M(Y);
|
|
157 |
\<forall>b. M(b) -->
|
|
158 |
b \<in> Y <->
|
|
159 |
(\<exists>x\<in>r -`` {a1}.
|
|
160 |
\<exists>y. M(y) \<and>
|
|
161 |
(\<exists>g. M(g) \<and> b = \<langle>x,y\<rangle> \<and> is_recfun(r,x,H,g) \<and> y = H(x,g)));
|
|
162 |
\<langle>x,a1\<rangle> \<in> r; M(f); is_recfun(r,x,H,f) |]
|
|
163 |
==> restrict(Y, r -`` {x}) = f"
|
|
164 |
apply (subgoal_tac "ALL y : r-``{x}. ALL z. <y,z>:Y <-> <y,z>:f")
|
|
165 |
apply (simp (no_asm_simp) add: restrict_def)
|
|
166 |
apply (thin_tac "All(?P)")+ --{*essential for efficiency*}
|
|
167 |
apply (frule is_recfun_type [THEN fun_is_rel], blast)
|
|
168 |
apply (frule pair_components_in_M, assumption, clarify)
|
|
169 |
apply (rule iffI)
|
|
170 |
apply (frule_tac y="<y,z>" in transM, assumption )
|
|
171 |
apply (rotate_tac -1)
|
|
172 |
apply (clarsimp simp add: vimage_singleton_iff is_recfun_type [THEN apply_iff]
|
|
173 |
apply_recfun is_recfun_cut)
|
|
174 |
txt{*Opposite inclusion: something in f, show in Y*}
|
|
175 |
apply (frule_tac y="<y,z>" in transM, assumption, simp)
|
|
176 |
apply (rule_tac x=y in bexI)
|
|
177 |
prefer 2 apply (blast dest: trans_onD)
|
|
178 |
apply (rule_tac x=z in exI, simp)
|
|
179 |
apply (rule_tac x="restrict(f, r -`` {y})" in exI)
|
|
180 |
apply (simp add: vimage_closed restrict_closed is_recfun_restrict
|
|
181 |
apply_recfun is_recfun_type [THEN apply_iff])
|
|
182 |
done
|
|
183 |
|
13245
|
184 |
(*FIXME: use this lemma just below*)
|
|
185 |
text{*For typical applications of Replacement for recursive definitions*}
|
|
186 |
lemma (in M_axioms) univalent_is_recfun:
|
|
187 |
"[|wellfounded_on(M,A,r); trans[A](r); r \<subseteq> A*A; M(r); M(A)|]
|
|
188 |
==> univalent (M, A, \<lambda>x p. \<exists>y. M(y) &
|
|
189 |
(\<exists>f. M(f) & p = \<langle>x, y\<rangle> & is_recfun(r,x,H,f) & y = H(x,f)))"
|
|
190 |
apply (simp add: univalent_def)
|
|
191 |
apply (blast dest: is_recfun_functional)
|
|
192 |
done
|
|
193 |
|
13223
|
194 |
text{*Proof of the inductive step for @{text exists_is_recfun}, since
|
|
195 |
we must prove two versions.*}
|
|
196 |
lemma (in M_axioms) exists_is_recfun_indstep:
|
|
197 |
"[|a1 \<in> A; \<forall>y. \<langle>y, a1\<rangle> \<in> r --> (\<exists>f. M(f) & is_recfun(r, y, H, f));
|
|
198 |
wellfounded_on(M,A,r); trans[A](r);
|
|
199 |
strong_replacement(M, \<lambda>x z. \<exists>y g. M(y) & M(g) &
|
|
200 |
pair(M,x,y,z) & is_recfun(r,x,H,g) & y = H(x,g));
|
|
201 |
M(A); M(r); r \<subseteq> A * A;
|
|
202 |
\<forall>x g. M(x) & M(g) & function(g) --> M(H(x,g))|]
|
|
203 |
==> \<exists>f. M(f) & is_recfun(r,a1,H,f)"
|
|
204 |
apply (frule_tac y=a1 in transM, assumption)
|
|
205 |
apply (drule_tac A="r-``{a1}" in strong_replacementD)
|
|
206 |
apply blast
|
|
207 |
txt{*Discharge the "univalent" obligation of Replacement*}
|
|
208 |
apply (clarsimp simp add: univalent_def)
|
|
209 |
apply (blast dest!: is_recfun_functional)
|
|
210 |
txt{*Show that the constructed object satisfies @{text is_recfun}*}
|
|
211 |
apply clarify
|
|
212 |
apply (rule_tac x=Y in exI)
|
|
213 |
apply (simp (no_asm_simp) add: is_recfun_relativize vimage_closed restrict_closed)
|
|
214 |
(*Tried using is_recfun_iff2 here. Much more simplification takes place
|
|
215 |
because an assumption can kick in. Not sure how to relate the new
|
|
216 |
proof state to the current one.*)
|
|
217 |
apply safe
|
|
218 |
txt{*Show that elements of @{term Y} are in the right relationship.*}
|
|
219 |
apply (frule_tac x=z and P="%b. M(b) --> ?Q(b)" in spec)
|
|
220 |
apply (erule impE, blast intro: transM)
|
|
221 |
txt{*We have an element of @{term Y}, so we have x, y, z*}
|
|
222 |
apply (frule_tac y=z in transM, assumption, clarify)
|
|
223 |
apply (simp add: vimage_closed restrict_closed restrict_Y_lemma [of A r H])
|
|
224 |
txt{*one more case*}
|
|
225 |
apply (simp add: vimage_closed restrict_closed )
|
|
226 |
apply (rule_tac x=x in bexI)
|
|
227 |
prefer 2 apply blast
|
|
228 |
apply (rule_tac x="H(x, restrict(Y, r -`` {x}))" in exI)
|
|
229 |
apply (simp add: vimage_closed restrict_closed )
|
|
230 |
apply (drule_tac x1=x in spec [THEN mp], assumption, clarify)
|
|
231 |
apply (rule_tac x=f in exI)
|
|
232 |
apply (simp add: restrict_Y_lemma [of A r H])
|
|
233 |
done
|
|
234 |
|
|
235 |
|
|
236 |
text{*Relativized version, when we have the (currently weaker) premise
|
|
237 |
@{term "wellfounded_on(M,A,r)"}*}
|
|
238 |
lemma (in M_axioms) wellfounded_exists_is_recfun:
|
|
239 |
"[|wellfounded_on(M,A,r); trans[A](r); a\<in>A;
|
|
240 |
separation(M, \<lambda>x. x \<in> A --> ~ (\<exists>f. M(f) \<and> is_recfun(r, x, H, f)));
|
|
241 |
strong_replacement(M, \<lambda>x z. \<exists>y g. M(y) & M(g) &
|
|
242 |
pair(M,x,y,z) & is_recfun(r,x,H,g) & y = H(x,g));
|
|
243 |
M(A); M(r); r \<subseteq> A*A;
|
|
244 |
\<forall>x g. M(x) & M(g) & function(g) --> M(H(x,g)) |]
|
|
245 |
==> \<exists>f. M(f) & is_recfun(r,a,H,f)"
|
|
246 |
apply (rule wellfounded_on_induct2, assumption+, clarify)
|
|
247 |
apply (rule exists_is_recfun_indstep, assumption+)
|
|
248 |
done
|
|
249 |
|
|
250 |
lemma (in M_axioms) wf_exists_is_recfun:
|
|
251 |
"[|wf[A](r); trans[A](r); a\<in>A;
|
|
252 |
strong_replacement(M, \<lambda>x z. \<exists>y g. M(y) & M(g) &
|
|
253 |
pair(M,x,y,z) & is_recfun(r,x,H,g) & y = H(x,g));
|
|
254 |
M(A); M(r); r \<subseteq> A*A;
|
|
255 |
\<forall>x g. M(x) & M(g) & function(g) --> M(H(x,g)) |]
|
13245
|
256 |
==> \<exists>f. M(f) & is_recfun(r,a,H,f)"
|
13223
|
257 |
apply (rule wf_on_induct2, assumption+)
|
|
258 |
apply (frule wf_on_imp_relativized)
|
|
259 |
apply (rule exists_is_recfun_indstep, assumption+)
|
|
260 |
done
|
|
261 |
|
|
262 |
constdefs
|
|
263 |
M_is_recfun :: "[i=>o, i, i, [i=>o,i,i,i]=>o, i] => o"
|
|
264 |
"M_is_recfun(M,r,a,MH,f) ==
|
|
265 |
\<forall>z. M(z) -->
|
|
266 |
(z \<in> f <->
|
|
267 |
(\<exists>x y xa sx r_sx f_r_sx.
|
|
268 |
M(x) & M(y) & M(xa) & M(sx) & M(r_sx) & M(f_r_sx) &
|
|
269 |
pair(M,x,y,z) & pair(M,x,a,xa) & upair(M,x,x,sx) &
|
|
270 |
pre_image(M,r,sx,r_sx) & restriction(M,f,r_sx,f_r_sx) &
|
|
271 |
xa \<in> r & MH(M, x, f_r_sx, y)))"
|
|
272 |
|
|
273 |
lemma (in M_axioms) is_recfun_iff_M:
|
|
274 |
"[| M(r); M(a); M(f); \<forall>x g. M(x) & M(g) & function(g) --> M(H(x,g));
|
|
275 |
\<forall>x g y. M(x) --> M(g) --> M(y) --> MH(M,x,g,y) <-> y = H(x,g) |] ==>
|
|
276 |
is_recfun(r,a,H,f) <-> M_is_recfun(M,r,a,MH,f)"
|
|
277 |
apply (simp add: vimage_closed restrict_closed M_is_recfun_def is_recfun_relativize)
|
|
278 |
apply (rule all_cong, safe)
|
|
279 |
apply (thin_tac "\<forall>x. ?P(x)")+
|
|
280 |
apply (blast dest: transM) (*or del: allE*)
|
|
281 |
done
|
|
282 |
|
|
283 |
lemma M_is_recfun_cong [cong]:
|
|
284 |
"[| r = r'; a = a'; f = f';
|
|
285 |
!!x g y. [| M(x); M(g); M(y) |] ==> MH(M,x,g,y) <-> MH'(M,x,g,y) |]
|
|
286 |
==> M_is_recfun(M,r,a,MH,f) <-> M_is_recfun(M,r',a',MH',f')"
|
|
287 |
by (simp add: M_is_recfun_def)
|
|
288 |
|
|
289 |
|
|
290 |
constdefs
|
|
291 |
(*This expresses ordinal addition as a formula in the LAST. It also
|
|
292 |
provides an abbreviation that can be used in the instance of strong
|
|
293 |
replacement below. Here j is used to define the relation, namely
|
|
294 |
Memrel(succ(j)), while x determines the domain of f.*)
|
|
295 |
is_oadd_fun :: "[i=>o,i,i,i,i] => o"
|
|
296 |
"is_oadd_fun(M,i,j,x,f) ==
|
|
297 |
(\<forall>sj msj. M(sj) --> M(msj) -->
|
|
298 |
successor(M,j,sj) --> membership(M,sj,msj) -->
|
|
299 |
M_is_recfun(M, msj, x,
|
|
300 |
%M x g y. \<exists>gx. M(gx) & image(M,g,x,gx) & union(M,i,gx,y),
|
|
301 |
f))"
|
|
302 |
|
|
303 |
is_oadd :: "[i=>o,i,i,i] => o"
|
|
304 |
"is_oadd(M,i,j,k) ==
|
|
305 |
(~ ordinal(M,i) & ~ ordinal(M,j) & k=0) |
|
|
306 |
(~ ordinal(M,i) & ordinal(M,j) & k=j) |
|
|
307 |
(ordinal(M,i) & ~ ordinal(M,j) & k=i) |
|
|
308 |
(ordinal(M,i) & ordinal(M,j) &
|
|
309 |
(\<exists>f fj sj. M(f) & M(fj) & M(sj) &
|
|
310 |
successor(M,j,sj) & is_oadd_fun(M,i,sj,sj,f) &
|
|
311 |
fun_apply(M,f,j,fj) & fj = k))"
|
|
312 |
|
|
313 |
(*NEEDS RELATIVIZATION*)
|
|
314 |
omult_eqns :: "[i,i,i,i] => o"
|
|
315 |
"omult_eqns(i,x,g,z) ==
|
|
316 |
Ord(x) &
|
|
317 |
(x=0 --> z=0) &
|
|
318 |
(\<forall>j. x = succ(j) --> z = g`j ++ i) &
|
|
319 |
(Limit(x) --> z = \<Union>(g``x))"
|
|
320 |
|
|
321 |
is_omult_fun :: "[i=>o,i,i,i] => o"
|
|
322 |
"is_omult_fun(M,i,j,f) ==
|
|
323 |
(\<exists>df. M(df) & is_function(M,f) &
|
|
324 |
is_domain(M,f,df) & subset(M, j, df)) &
|
|
325 |
(\<forall>x\<in>j. omult_eqns(i,x,f,f`x))"
|
|
326 |
|
|
327 |
is_omult :: "[i=>o,i,i,i] => o"
|
|
328 |
"is_omult(M,i,j,k) ==
|
|
329 |
\<exists>f fj sj. M(f) & M(fj) & M(sj) &
|
|
330 |
successor(M,j,sj) & is_omult_fun(M,i,sj,f) &
|
|
331 |
fun_apply(M,f,j,fj) & fj = k"
|
|
332 |
|
|
333 |
|
|
334 |
locale M_recursion = M_axioms +
|
|
335 |
assumes oadd_strong_replacement:
|
|
336 |
"[| M(i); M(j) |] ==>
|
|
337 |
strong_replacement(M,
|
|
338 |
\<lambda>x z. \<exists>y f fx. M(y) & M(f) & M(fx) &
|
|
339 |
pair(M,x,y,z) & is_oadd_fun(M,i,j,x,f) &
|
|
340 |
image(M,f,x,fx) & y = i Un fx)"
|
|
341 |
and omult_strong_replacement':
|
|
342 |
"[| M(i); M(j) |] ==>
|
|
343 |
strong_replacement(M, \<lambda>x z. \<exists>y g. M(y) & M(g) &
|
|
344 |
pair(M,x,y,z) &
|
|
345 |
is_recfun(Memrel(succ(j)),x,%x g. THE z. omult_eqns(i,x,g,z),g) &
|
|
346 |
y = (THE z. omult_eqns(i, x, g, z)))"
|
|
347 |
|
|
348 |
|
|
349 |
|
|
350 |
text{*is_oadd_fun: Relating the pure "language of set theory" to Isabelle/ZF*}
|
|
351 |
lemma (in M_recursion) is_oadd_fun_iff:
|
|
352 |
"[| a\<le>j; M(i); M(j); M(a); M(f) |]
|
|
353 |
==> is_oadd_fun(M,i,j,a,f) <->
|
|
354 |
f \<in> a \<rightarrow> range(f) & (\<forall>x. M(x) --> x < a --> f`x = i Un f``x)"
|
|
355 |
apply (frule lt_Ord)
|
|
356 |
apply (simp add: is_oadd_fun_def Memrel_closed Un_closed
|
|
357 |
is_recfun_iff_M [of concl: _ _ "%x g. i Un g``x", THEN iff_sym]
|
|
358 |
image_closed is_recfun_iff_equation
|
|
359 |
Ball_def lt_trans [OF ltI, of _ a] lt_Memrel)
|
|
360 |
apply (simp add: lt_def)
|
|
361 |
apply (blast dest: transM)
|
|
362 |
done
|
|
363 |
|
|
364 |
|
|
365 |
lemma (in M_recursion) oadd_strong_replacement':
|
|
366 |
"[| M(i); M(j) |] ==>
|
|
367 |
strong_replacement(M, \<lambda>x z. \<exists>y g. M(y) & M(g) &
|
|
368 |
pair(M,x,y,z) &
|
|
369 |
is_recfun(Memrel(succ(j)),x,%x g. i Un g``x,g) &
|
|
370 |
y = i Un g``x)"
|
|
371 |
apply (insert oadd_strong_replacement [of i j])
|
|
372 |
apply (simp add: Memrel_closed Un_closed image_closed is_oadd_fun_def
|
|
373 |
is_recfun_iff_M)
|
|
374 |
done
|
|
375 |
|
|
376 |
|
|
377 |
lemma (in M_recursion) exists_oadd:
|
|
378 |
"[| Ord(j); M(i); M(j) |]
|
|
379 |
==> \<exists>f. M(f) & is_recfun(Memrel(succ(j)), j, %x g. i Un g``x, f)"
|
|
380 |
apply (rule wf_exists_is_recfun)
|
|
381 |
apply (rule wf_Memrel [THEN wf_imp_wf_on])
|
|
382 |
apply (rule trans_Memrel [THEN trans_imp_trans_on], simp)
|
|
383 |
apply (rule succI1)
|
|
384 |
apply (blast intro: oadd_strong_replacement')
|
|
385 |
apply (simp_all add: Memrel_type Memrel_closed Un_closed image_closed)
|
|
386 |
done
|
|
387 |
|
|
388 |
lemma (in M_recursion) exists_oadd_fun:
|
|
389 |
"[| Ord(j); M(i); M(j) |]
|
|
390 |
==> \<exists>f. M(f) & is_oadd_fun(M,i,succ(j),succ(j),f)"
|
|
391 |
apply (rule exists_oadd [THEN exE])
|
|
392 |
apply (erule Ord_succ, assumption, simp)
|
|
393 |
apply (rename_tac f, clarify)
|
|
394 |
apply (frule is_recfun_type)
|
|
395 |
apply (rule_tac x=f in exI)
|
|
396 |
apply (simp add: fun_is_function domain_of_fun lt_Memrel apply_recfun lt_def
|
|
397 |
is_oadd_fun_iff Ord_trans [OF _ succI1])
|
|
398 |
done
|
|
399 |
|
|
400 |
lemma (in M_recursion) is_oadd_fun_apply:
|
|
401 |
"[| x < j; M(i); M(j); M(f); is_oadd_fun(M,i,j,j,f) |]
|
|
402 |
==> f`x = i Un (\<Union>k\<in>x. {f ` k})"
|
|
403 |
apply (simp add: is_oadd_fun_iff lt_Ord2, clarify)
|
|
404 |
apply (frule lt_closed, simp)
|
|
405 |
apply (frule leI [THEN le_imp_subset])
|
|
406 |
apply (simp add: image_fun, blast)
|
|
407 |
done
|
|
408 |
|
|
409 |
lemma (in M_recursion) is_oadd_fun_iff_oadd [rule_format]:
|
|
410 |
"[| is_oadd_fun(M,i,J,J,f); M(i); M(J); M(f); Ord(i); Ord(j) |]
|
|
411 |
==> j<J --> f`j = i++j"
|
|
412 |
apply (erule_tac i=j in trans_induct, clarify)
|
|
413 |
apply (subgoal_tac "\<forall>k\<in>x. k<J")
|
|
414 |
apply (simp (no_asm_simp) add: is_oadd_def oadd_unfold is_oadd_fun_apply)
|
|
415 |
apply (blast intro: lt_trans ltI lt_Ord)
|
|
416 |
done
|
|
417 |
|
|
418 |
lemma (in M_recursion) oadd_abs_fun_apply_iff:
|
|
419 |
"[| M(i); M(J); M(f); M(k); j<J; is_oadd_fun(M,i,J,J,f) |]
|
|
420 |
==> fun_apply(M,f,j,k) <-> f`j = k"
|
|
421 |
by (force simp add: lt_def is_oadd_fun_iff subsetD typed_apply_abs)
|
|
422 |
|
|
423 |
lemma (in M_recursion) Ord_oadd_abs:
|
|
424 |
"[| M(i); M(j); M(k); Ord(i); Ord(j) |] ==> is_oadd(M,i,j,k) <-> k = i++j"
|
|
425 |
apply (simp add: is_oadd_def oadd_abs_fun_apply_iff is_oadd_fun_iff_oadd)
|
|
426 |
apply (frule exists_oadd_fun [of j i], blast+)
|
|
427 |
done
|
|
428 |
|
|
429 |
lemma (in M_recursion) oadd_abs:
|
|
430 |
"[| M(i); M(j); M(k) |] ==> is_oadd(M,i,j,k) <-> k = i++j"
|
|
431 |
apply (case_tac "Ord(i) & Ord(j)")
|
|
432 |
apply (simp add: Ord_oadd_abs)
|
|
433 |
apply (auto simp add: is_oadd_def oadd_eq_if_raw_oadd)
|
|
434 |
done
|
|
435 |
|
13245
|
436 |
lemma (in M_recursion) oadd_closed [intro,simp]:
|
13223
|
437 |
"[| M(i); M(j) |] ==> M(i++j)"
|
|
438 |
apply (simp add: oadd_eq_if_raw_oadd, clarify)
|
|
439 |
apply (simp add: raw_oadd_eq_oadd)
|
|
440 |
apply (frule exists_oadd_fun [of j i], auto)
|
|
441 |
apply (simp add: apply_closed is_oadd_fun_iff_oadd [symmetric])
|
|
442 |
done
|
|
443 |
|
|
444 |
|
|
445 |
text{*Ordinal Multiplication*}
|
|
446 |
|
|
447 |
lemma omult_eqns_unique:
|
|
448 |
"[| omult_eqns(i,x,g,z); omult_eqns(i,x,g,z') |] ==> z=z'";
|
|
449 |
apply (simp add: omult_eqns_def, clarify)
|
|
450 |
apply (erule Ord_cases, simp_all)
|
|
451 |
done
|
|
452 |
|
|
453 |
lemma omult_eqns_0: "omult_eqns(i,0,g,z) <-> z=0"
|
|
454 |
by (simp add: omult_eqns_def)
|
|
455 |
|
|
456 |
lemma the_omult_eqns_0: "(THE z. omult_eqns(i,0,g,z)) = 0"
|
|
457 |
by (simp add: omult_eqns_0)
|
|
458 |
|
|
459 |
lemma omult_eqns_succ: "omult_eqns(i,succ(j),g,z) <-> Ord(j) & z = g`j ++ i"
|
|
460 |
by (simp add: omult_eqns_def)
|
|
461 |
|
|
462 |
lemma the_omult_eqns_succ:
|
|
463 |
"Ord(j) ==> (THE z. omult_eqns(i,succ(j),g,z)) = g`j ++ i"
|
|
464 |
by (simp add: omult_eqns_succ)
|
|
465 |
|
|
466 |
lemma omult_eqns_Limit:
|
|
467 |
"Limit(x) ==> omult_eqns(i,x,g,z) <-> z = \<Union>(g``x)"
|
|
468 |
apply (simp add: omult_eqns_def)
|
|
469 |
apply (blast intro: Limit_is_Ord)
|
|
470 |
done
|
|
471 |
|
|
472 |
lemma the_omult_eqns_Limit:
|
|
473 |
"Limit(x) ==> (THE z. omult_eqns(i,x,g,z)) = \<Union>(g``x)"
|
|
474 |
by (simp add: omult_eqns_Limit)
|
|
475 |
|
|
476 |
lemma omult_eqns_Not: "~ Ord(x) ==> ~ omult_eqns(i,x,g,z)"
|
|
477 |
by (simp add: omult_eqns_def)
|
|
478 |
|
|
479 |
|
|
480 |
lemma (in M_recursion) the_omult_eqns_closed:
|
|
481 |
"[| M(i); M(x); M(g); function(g) |]
|
|
482 |
==> M(THE z. omult_eqns(i, x, g, z))"
|
|
483 |
apply (case_tac "Ord(x)")
|
|
484 |
prefer 2 apply (simp add: omult_eqns_Not) --{*trivial, non-Ord case*}
|
|
485 |
apply (erule Ord_cases)
|
|
486 |
apply (simp add: omult_eqns_0)
|
|
487 |
apply (simp add: omult_eqns_succ apply_closed oadd_closed)
|
|
488 |
apply (simp add: omult_eqns_Limit)
|
|
489 |
done
|
|
490 |
|
|
491 |
lemma (in M_recursion) exists_omult:
|
|
492 |
"[| Ord(j); M(i); M(j) |]
|
|
493 |
==> \<exists>f. M(f) & is_recfun(Memrel(succ(j)), j, %x g. THE z. omult_eqns(i,x,g,z), f)"
|
|
494 |
apply (rule wf_exists_is_recfun)
|
|
495 |
apply (rule wf_Memrel [THEN wf_imp_wf_on])
|
|
496 |
apply (rule trans_Memrel [THEN trans_imp_trans_on], simp)
|
|
497 |
apply (rule succI1)
|
|
498 |
apply (blast intro: omult_strong_replacement')
|
|
499 |
apply (simp_all add: Memrel_type Memrel_closed Un_closed image_closed)
|
|
500 |
apply (blast intro: the_omult_eqns_closed)
|
|
501 |
done
|
|
502 |
|
|
503 |
lemma (in M_recursion) exists_omult_fun:
|
|
504 |
"[| Ord(j); M(i); M(j) |] ==> \<exists>f. M(f) & is_omult_fun(M,i,succ(j),f)"
|
|
505 |
apply (rule exists_omult [THEN exE])
|
|
506 |
apply (erule Ord_succ, assumption, simp)
|
|
507 |
apply (rename_tac f, clarify)
|
|
508 |
apply (frule is_recfun_type)
|
|
509 |
apply (rule_tac x=f in exI)
|
|
510 |
apply (simp add: fun_is_function domain_of_fun lt_Memrel apply_recfun lt_def
|
|
511 |
is_omult_fun_def Ord_trans [OF _ succI1])
|
|
512 |
apply (force dest: Ord_in_Ord'
|
|
513 |
simp add: omult_eqns_def the_omult_eqns_0 the_omult_eqns_succ
|
|
514 |
the_omult_eqns_Limit)
|
|
515 |
done
|
|
516 |
|
|
517 |
lemma (in M_recursion) is_omult_fun_apply_0:
|
|
518 |
"[| 0 < j; is_omult_fun(M,i,j,f) |] ==> f`0 = 0"
|
|
519 |
by (simp add: is_omult_fun_def omult_eqns_def lt_def ball_conj_distrib)
|
|
520 |
|
|
521 |
lemma (in M_recursion) is_omult_fun_apply_succ:
|
|
522 |
"[| succ(x) < j; is_omult_fun(M,i,j,f) |] ==> f`succ(x) = f`x ++ i"
|
|
523 |
by (simp add: is_omult_fun_def omult_eqns_def lt_def, blast)
|
|
524 |
|
|
525 |
lemma (in M_recursion) is_omult_fun_apply_Limit:
|
|
526 |
"[| x < j; Limit(x); M(j); M(f); is_omult_fun(M,i,j,f) |]
|
|
527 |
==> f ` x = (\<Union>y\<in>x. f`y)"
|
|
528 |
apply (simp add: is_omult_fun_def omult_eqns_def domain_closed lt_def, clarify)
|
|
529 |
apply (drule subset_trans [OF OrdmemD], assumption+)
|
|
530 |
apply (simp add: ball_conj_distrib omult_Limit image_function)
|
|
531 |
done
|
|
532 |
|
|
533 |
lemma (in M_recursion) is_omult_fun_eq_omult:
|
|
534 |
"[| is_omult_fun(M,i,J,f); M(J); M(f); Ord(i); Ord(j) |]
|
|
535 |
==> j<J --> f`j = i**j"
|
|
536 |
apply (erule_tac i=j in trans_induct3)
|
|
537 |
apply (safe del: impCE)
|
|
538 |
apply (simp add: is_omult_fun_apply_0)
|
|
539 |
apply (subgoal_tac "x<J")
|
|
540 |
apply (simp add: is_omult_fun_apply_succ omult_succ)
|
|
541 |
apply (blast intro: lt_trans)
|
|
542 |
apply (subgoal_tac "\<forall>k\<in>x. k<J")
|
|
543 |
apply (simp add: is_omult_fun_apply_Limit omult_Limit)
|
|
544 |
apply (blast intro: lt_trans ltI lt_Ord)
|
|
545 |
done
|
|
546 |
|
|
547 |
lemma (in M_recursion) omult_abs_fun_apply_iff:
|
|
548 |
"[| M(i); M(J); M(f); M(k); j<J; is_omult_fun(M,i,J,f) |]
|
|
549 |
==> fun_apply(M,f,j,k) <-> f`j = k"
|
|
550 |
by (auto simp add: lt_def is_omult_fun_def subsetD apply_abs)
|
|
551 |
|
|
552 |
lemma (in M_recursion) omult_abs:
|
|
553 |
"[| M(i); M(j); M(k); Ord(i); Ord(j) |] ==> is_omult(M,i,j,k) <-> k = i**j"
|
|
554 |
apply (simp add: is_omult_def omult_abs_fun_apply_iff is_omult_fun_eq_omult)
|
|
555 |
apply (frule exists_omult_fun [of j i], blast+)
|
|
556 |
done
|
|
557 |
|
|
558 |
end
|
|
559 |
|