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