src/ZF/Constructible/WFrec.thy
changeset 13268 240509babf00
parent 13254 5146ccaedf42
child 13269 3ba9be497c33
equal deleted inserted replaced
13267:502f69ea6627 13268:240509babf00
   115 apply (blast intro: is_recfun_equal transD dest: transM) 
   115 apply (blast intro: is_recfun_equal transD dest: transM) 
   116 done
   116 done
   117 
   117 
   118 lemma (in M_axioms) is_recfun_functional:
   118 lemma (in M_axioms) is_recfun_functional:
   119      "[|is_recfun(r,a,H,f);  is_recfun(r,a,H,g);  
   119      "[|is_recfun(r,a,H,f);  is_recfun(r,a,H,g);  
   120        wellfounded(M,r); trans(r); 
   120        wellfounded(M,r); trans(r); M(f); M(g); M(r) |] ==> f=g"
   121        M(f); M(g); M(r) |]   
       
   122       ==> f=g"
       
   123 apply (rule fun_extension)
   121 apply (rule fun_extension)
   124 apply (erule is_recfun_type)+
   122 apply (erule is_recfun_type)+
   125 apply (blast intro!: is_recfun_equal dest: transM) 
   123 apply (blast intro!: is_recfun_equal dest: transM) 
   126 done 
   124 done 
   127 
   125 
   181 lemma (in M_axioms) restrict_Y_lemma:
   179 lemma (in M_axioms) restrict_Y_lemma:
   182    "[| wellfounded(M,r); trans(r); M(r);
   180    "[| wellfounded(M,r); trans(r); M(r);
   183        \<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g));  M(Y);
   181        \<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g));  M(Y);
   184        \<forall>b. M(b) -->
   182        \<forall>b. M(b) -->
   185 	   b \<in> Y <->
   183 	   b \<in> Y <->
   186 	   (\<exists>x\<in>r -`` {a1}.
   184 	   (\<exists>x\<in>r -`` {a1}. \<exists>y[M]. \<exists>g[M]. 
   187 	       \<exists>y. M(y) \<and>
   185               b = \<langle>x,y\<rangle> & is_recfun(r,x,H,g) \<and> y = H(x,g));
   188 		   (\<exists>g. M(g) \<and> b = \<langle>x,y\<rangle> \<and> is_recfun(r,x,H,g) \<and> y = H(x,g)));
       
   189           \<langle>x,a1\<rangle> \<in> r; M(f); is_recfun(r,x,H,f) |]
   186           \<langle>x,a1\<rangle> \<in> r; M(f); is_recfun(r,x,H,f) |]
   190        ==> restrict(Y, r -`` {x}) = f"
   187        ==> restrict(Y, r -`` {x}) = f"
   191 apply (subgoal_tac "\<forall>y \<in> r-``{x}. \<forall>z. <y,z>:Y <-> <y,z>:f") 
   188 apply (subgoal_tac "\<forall>y \<in> r-``{x}. \<forall>z. <y,z>:Y <-> <y,z>:f") 
   192  apply (simp (no_asm_simp) add: restrict_def) 
   189  apply (simp (no_asm_simp) add: restrict_def) 
   193  apply (thin_tac "rall(M,?P)")+  --{*essential for efficiency*}
   190  apply (thin_tac "rall(M,?P)")+  --{*essential for efficiency*}
   201 			   apply_recfun is_recfun_cut) 
   198 			   apply_recfun is_recfun_cut) 
   202 txt{*Opposite inclusion: something in f, show in Y*}
   199 txt{*Opposite inclusion: something in f, show in Y*}
   203 apply (frule_tac y="<y,z>" in transM, assumption, simp) 
   200 apply (frule_tac y="<y,z>" in transM, assumption, simp) 
   204 apply (rule_tac x=y in bexI)
   201 apply (rule_tac x=y in bexI)
   205 prefer 2 apply (blast dest: transD)
   202 prefer 2 apply (blast dest: transD)
   206 apply (rule_tac x=z in exI, simp) 
   203 apply (rule_tac x=z in rexI) 
   207 apply (rule_tac x="restrict(f, r -`` {y})" in exI) 
   204 apply (rule_tac x="restrict(f, r -`` {y})" in rexI) 
   208 apply (simp add: vimage_closed restrict_closed is_recfun_restrict
   205 apply (simp_all add: is_recfun_restrict
   209                  apply_recfun is_recfun_type [THEN apply_iff]) 
   206                      apply_recfun is_recfun_type [THEN apply_iff]) 
   210 done
   207 done
   211 
   208 
   212 text{*For typical applications of Replacement for recursive definitions*}
   209 text{*For typical applications of Replacement for recursive definitions*}
   213 lemma (in M_axioms) univalent_is_recfun:
   210 lemma (in M_axioms) univalent_is_recfun:
   214      "[|wellfounded(M,r); trans(r); M(r)|]
   211      "[|wellfounded(M,r); trans(r); M(r)|]
   215       ==> univalent (M, A, \<lambda>x p. \<exists>y. M(y) &
   212       ==> univalent (M, A, \<lambda>x p. 
   216                     (\<exists>f. M(f) & p = \<langle>x, y\<rangle> & is_recfun(r,x,H,f) & y = H(x,f)))"
   213               \<exists>y[M]. \<exists>f[M]. p = \<langle>x, y\<rangle> & is_recfun(r,x,H,f) & y = H(x,f))"
   217 apply (simp add: univalent_def) 
   214 apply (simp add: univalent_def) 
   218 apply (blast dest: is_recfun_functional) 
   215 apply (blast dest: is_recfun_functional) 
   219 done
   216 done
   220 
   217 
   221 text{*Proof of the inductive step for @{text exists_is_recfun}, since
   218 text{*Proof of the inductive step for @{text exists_is_recfun}, since
   222       we must prove two versions.*}
   219       we must prove two versions.*}
   223 lemma (in M_axioms) exists_is_recfun_indstep:
   220 lemma (in M_axioms) exists_is_recfun_indstep:
   224     "[|\<forall>y. \<langle>y, a1\<rangle> \<in> r --> (\<exists>f. M(f) & is_recfun(r, y, H, f)); 
   221     "[|\<forall>y. \<langle>y, a1\<rangle> \<in> r --> (\<exists>f[M]. is_recfun(r, y, H, f)); 
   225        wellfounded(M,r); trans(r); M(r); M(a1);
   222        wellfounded(M,r); trans(r); M(r); M(a1);
   226        strong_replacement(M, \<lambda>x z. \<exists>y g. M(y) & M(g) &
   223        strong_replacement(M, \<lambda>x z. 
   227                    pair(M,x,y,z) & is_recfun(r,x,H,g) & y = H(x,g)); 
   224               \<exists>y[M]. \<exists>g[M]. pair(M,x,y,z) & is_recfun(r,x,H,g) & y = H(x,g)); 
   228        \<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g))|]   
   225        \<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g))|]   
   229       ==> \<exists>f. M(f) & is_recfun(r,a1,H,f)"
   226       ==> \<exists>f[M]. is_recfun(r,a1,H,f)"
   230 apply (drule_tac A="r-``{a1}" in strong_replacementD)
   227 apply (drule_tac A="r-``{a1}" in strong_replacementD)
   231   apply blast 
   228   apply blast 
   232  txt{*Discharge the "univalent" obligation of Replacement*}
   229  txt{*Discharge the "univalent" obligation of Replacement*}
   233  apply (simp add: univalent_is_recfun) 
   230  apply (simp add: univalent_is_recfun) 
   234 txt{*Show that the constructed object satisfies @{text is_recfun}*} 
   231 txt{*Show that the constructed object satisfies @{text is_recfun}*} 
   235 apply clarify 
   232 apply clarify 
   236 apply (rule_tac x=Y in exI)  
   233 apply (rule_tac x=Y in rexI)  
   237 txt{*Unfold only the top-level occurrence of @{term is_recfun}*}
   234 txt{*Unfold only the top-level occurrence of @{term is_recfun}*}
   238 apply (simp (no_asm_simp) add: is_recfun_relativize [of concl: _ a1])
   235 apply (simp (no_asm_simp) add: is_recfun_relativize [of concl: _ a1])
   239 txt{*The big iff-formula defininng @{term Y} is now redundant*}
   236 txt{*The big iff-formula defining @{term Y} is now redundant*}
   240 apply safe 
   237 apply safe 
   241  apply (simp add: vimage_singleton_iff restrict_Y_lemma [of r H]) 
   238  apply (simp add: vimage_singleton_iff restrict_Y_lemma [of r H]) 
   242 txt{*one more case*}
   239 txt{*one more case*}
   243 apply (simp (no_asm_simp) add: Bex_def vimage_singleton_iff)
   240 apply (simp (no_asm_simp) add: Bex_def vimage_singleton_iff)
   244 apply (rename_tac x) 
   241 apply (rename_tac x) 
   245 apply (rule_tac x=x in exI, simp) 
   242 apply (rule_tac x=x in exI, simp) 
   246 apply (rule_tac x="H(x, restrict(Y, r -`` {x}))" in exI) 
   243 apply (rule_tac x="H(x, restrict(Y, r -`` {x}))" in rexI) 
   247 apply (drule_tac x1=x in spec [THEN mp], assumption, clarify) 
   244 apply (drule_tac x1=x in spec [THEN mp], assumption, clarify) 
   248 apply (rule_tac x=f in exI) 
   245 apply (rename_tac f) 
   249 apply (simp add: restrict_Y_lemma [of r H]) 
   246 apply (rule_tac x=f in rexI) 
       
   247 apply (simp add: restrict_Y_lemma [of r H], simp_all)
   250 done
   248 done
   251 
   249 
   252 text{*Relativized version, when we have the (currently weaker) premise
   250 text{*Relativized version, when we have the (currently weaker) premise
   253       @{term "wellfounded(M,r)"}*}
   251       @{term "wellfounded(M,r)"}*}
   254 lemma (in M_axioms) wellfounded_exists_is_recfun:
   252 lemma (in M_axioms) wellfounded_exists_is_recfun:
   255     "[|wellfounded(M,r);  trans(r);  
   253     "[|wellfounded(M,r);  trans(r);  
   256        separation(M, \<lambda>x. ~ (\<exists>f. M(f) \<and> is_recfun(r, x, H, f)));
   254        separation(M, \<lambda>x. ~ (\<exists>f[M]. is_recfun(r, x, H, f)));
   257        strong_replacement(M, \<lambda>x z. \<exists>y g. M(y) & M(g) &
   255        strong_replacement(M, \<lambda>x z. 
   258                    pair(M,x,y,z) & is_recfun(r,x,H,g) & y = H(x,g)); 
   256           \<exists>y[M]. \<exists>g[M]. pair(M,x,y,z) & is_recfun(r,x,H,g) & y = H(x,g)); 
   259        M(r);  M(a);  
   257        M(r);  M(a);  
   260        \<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g)) |]   
   258        \<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g)) |]   
   261       ==> \<exists>f. M(f) & is_recfun(r,a,H,f)"
   259       ==> \<exists>f[M]. is_recfun(r,a,H,f)"
   262 apply (rule wellfounded_induct, assumption+, clarify)
   260 apply (rule wellfounded_induct, assumption+, clarify)
   263 apply (rule exists_is_recfun_indstep, assumption+)
   261 apply (rule exists_is_recfun_indstep, assumption+)
   264 done
   262 done
   265 
   263 
   266 lemma (in M_axioms) wf_exists_is_recfun [rule_format]:
   264 lemma (in M_axioms) wf_exists_is_recfun [rule_format]:
   267     "[|wf(r);  trans(r);  
   265     "[|wf(r);  trans(r);  M(r);  
   268        strong_replacement(M, \<lambda>x z. \<exists>y g. M(y) & M(g) &
   266        strong_replacement(M, \<lambda>x z. 
   269                    pair(M,x,y,z) & is_recfun(r,x,H,g) & y = H(x,g)); 
   267          \<exists>y[M]. \<exists>g[M]. pair(M,x,y,z) & is_recfun(r,x,H,g) & y = H(x,g)); 
   270         M(r);  
       
   271        \<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g)) |]   
   268        \<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g)) |]   
   272       ==> M(a) --> (\<exists>f. M(f) & is_recfun(r,a,H,f))"
   269       ==> M(a) --> (\<exists>f[M]. is_recfun(r,a,H,f))"
   273 apply (rule wf_induct, assumption+)
   270 apply (rule wf_induct, assumption+)
   274 apply (frule wf_imp_relativized)
   271 apply (frule wf_imp_relativized)
   275 apply (intro impI)
   272 apply (intro impI)
   276 apply (rule exists_is_recfun_indstep)
   273 apply (rule exists_is_recfun_indstep) 
   277       apply (blast dest: pair_components_in_M)+
   274       apply (blast dest: transM del: rev_rallE, assumption+)
   278 done
   275 done
   279 
   276 
   280 constdefs
   277 constdefs
   281  M_is_recfun :: "[i=>o, i, i, [i=>o,i,i,i]=>o, i] => o"
   278  M_is_recfun :: "[i=>o, i, i, [i=>o,i,i,i]=>o, i] => o"
   282    "M_is_recfun(M,r,a,MH,f) == 
   279    "M_is_recfun(M,r,a,MH,f) == 
   344 	\<exists>f fj sj. M(f) & M(fj) & M(sj) & 
   341 	\<exists>f fj sj. M(f) & M(fj) & M(sj) & 
   345                   successor(M,j,sj) & is_omult_fun(M,i,sj,f) & 
   342                   successor(M,j,sj) & is_omult_fun(M,i,sj,f) & 
   346                   fun_apply(M,f,j,fj) & fj = k"
   343                   fun_apply(M,f,j,fj) & fj = k"
   347 
   344 
   348 
   345 
   349 locale M_recursion = M_axioms +
   346 locale M_ord_arith = M_axioms +
   350   assumes oadd_strong_replacement:
   347   assumes oadd_strong_replacement:
   351    "[| M(i); M(j) |] ==>
   348    "[| M(i); M(j) |] ==>
   352     strong_replacement(M, 
   349     strong_replacement(M, 
   353          \<lambda>x z. \<exists>y f fx. M(y) & M(f) & M(fx) & 
   350          \<lambda>x z. \<exists>y[M]. \<exists>f[M]. \<exists>fx[M]. pair(M,x,y,z) & is_oadd_fun(M,i,j,x,f) & 
   354 		         pair(M,x,y,z) & is_oadd_fun(M,i,j,x,f) & 
   351 		                      image(M,f,x,fx) & y = i Un fx)" 
   355 		         image(M,f,x,fx) & y = i Un fx)" 
       
   356  and omult_strong_replacement':
   352  and omult_strong_replacement':
   357    "[| M(i); M(j) |] ==>
   353    "[| M(i); M(j) |] ==>
   358     strong_replacement(M, \<lambda>x z. \<exists>y g. M(y) & M(g) &
   354     strong_replacement(M, \<lambda>x z. \<exists>y[M]. \<exists>g[M]. 
   359 	     pair(M,x,y,z) & 
   355 	     z = <x,y> &
   360 	     is_recfun(Memrel(succ(j)),x,%x g. THE z. omult_eqns(i,x,g,z),g) & 
   356 	     is_recfun(Memrel(succ(j)),x,%x g. THE z. omult_eqns(i,x,g,z),g) & 
   361 	     y = (THE z. omult_eqns(i, x, g, z)))" 
   357 	     y = (THE z. omult_eqns(i, x, g, z)))" 
   362 
   358 
   363 
   359 
   364 
   360 
   365 text{*is_oadd_fun: Relating the pure "language of set theory" to Isabelle/ZF*}
   361 text{*is_oadd_fun: Relating the pure "language of set theory" to Isabelle/ZF*}
   366 lemma (in M_recursion) is_oadd_fun_iff:
   362 lemma (in M_ord_arith) is_oadd_fun_iff:
   367    "[| a\<le>j; M(i); M(j); M(a); M(f) |] 
   363    "[| a\<le>j; M(i); M(j); M(a); M(f) |] 
   368     ==> is_oadd_fun(M,i,j,a,f) <->
   364     ==> is_oadd_fun(M,i,j,a,f) <->
   369 	f \<in> a \<rightarrow> range(f) & (\<forall>x. M(x) --> x < a --> f`x = i Un f``x)"
   365 	f \<in> a \<rightarrow> range(f) & (\<forall>x. M(x) --> x < a --> f`x = i Un f``x)"
   370 apply (frule lt_Ord) 
   366 apply (frule lt_Ord) 
   371 apply (simp add: is_oadd_fun_def Memrel_closed Un_closed 
   367 apply (simp add: is_oadd_fun_def Memrel_closed Un_closed 
   375 apply (simp add: lt_def) 
   371 apply (simp add: lt_def) 
   376 apply (blast dest: transM) 
   372 apply (blast dest: transM) 
   377 done
   373 done
   378 
   374 
   379 
   375 
   380 lemma (in M_recursion) oadd_strong_replacement':
   376 lemma (in M_ord_arith) oadd_strong_replacement':
   381     "[| M(i); M(j) |] ==>
   377     "[| M(i); M(j) |] ==>
   382      strong_replacement(M, \<lambda>x z. \<exists>y g. M(y) & M(g) &
   378      strong_replacement(M, \<lambda>x z. \<exists>y[M]. \<exists>g[M].
   383 		  pair(M,x,y,z) & 
   379 		  z = <x,y> &
   384 		  is_recfun(Memrel(succ(j)),x,%x g. i Un g``x,g) & 
   380 		  is_recfun(Memrel(succ(j)),x,%x g. i Un g``x,g) & 
   385 		  y = i Un g``x)" 
   381 		  y = i Un g``x)" 
   386 apply (insert oadd_strong_replacement [of i j]) 
   382 apply (insert oadd_strong_replacement [of i j]) 
   387 apply (simp add: Memrel_closed Un_closed image_closed is_oadd_fun_def
   383 apply (simp add: Memrel_closed Un_closed image_closed is_oadd_fun_def
   388                  is_recfun_iff_M)  
   384                  is_recfun_iff_M)  
   389 done
   385 done
   390 
   386 
   391 
   387 
   392 lemma (in M_recursion) exists_oadd:
   388 lemma (in M_ord_arith) exists_oadd:
   393     "[| Ord(j);  M(i);  M(j) |]
   389     "[| Ord(j);  M(i);  M(j) |]
   394      ==> \<exists>f. M(f) & is_recfun(Memrel(succ(j)), j, %x g. i Un g``x, f)"
   390      ==> \<exists>f[M]. is_recfun(Memrel(succ(j)), j, %x g. i Un g``x, f)"
   395 apply (rule wf_exists_is_recfun [OF wf_Memrel trans_Memrel])
   391 apply (rule wf_exists_is_recfun [OF wf_Memrel trans_Memrel])
   396     apply simp 
   392     apply (simp_all add: Memrel_type oadd_strong_replacement') 
   397    apply (blast intro: oadd_strong_replacement') 
   393 done 
   398   apply (simp_all add: Memrel_type Memrel_closed Un_closed image_closed)
   394 
   399 done
   395 lemma (in M_ord_arith) exists_oadd_fun:
   400 
   396     "[| Ord(j);  M(i);  M(j) |] ==> \<exists>f[M]. is_oadd_fun(M,i,succ(j),succ(j),f)"
   401 lemma (in M_recursion) exists_oadd_fun:
   397 apply (rule exists_oadd [THEN rexE])
   402     "[| Ord(j);  M(i);  M(j) |] 
       
   403      ==> \<exists>f. M(f) & is_oadd_fun(M,i,succ(j),succ(j),f)"
       
   404 apply (rule exists_oadd [THEN exE])
       
   405 apply (erule Ord_succ, assumption, simp) 
   398 apply (erule Ord_succ, assumption, simp) 
   406 apply (rename_tac f, clarify) 
   399 apply (rename_tac f) 
   407 apply (frule is_recfun_type)
   400 apply (frule is_recfun_type)
   408 apply (rule_tac x=f in exI) 
   401 apply (rule_tac x=f in rexI) 
   409 apply (simp add: fun_is_function domain_of_fun lt_Memrel apply_recfun lt_def
   402  apply (simp add: fun_is_function domain_of_fun lt_Memrel apply_recfun lt_def
   410                  is_oadd_fun_iff Ord_trans [OF _ succI1])
   403                   is_oadd_fun_iff Ord_trans [OF _ succI1], assumption)
   411 done
   404 done
   412 
   405 
   413 lemma (in M_recursion) is_oadd_fun_apply:
   406 lemma (in M_ord_arith) is_oadd_fun_apply:
   414     "[| x < j; M(i); M(j); M(f); is_oadd_fun(M,i,j,j,f) |] 
   407     "[| x < j; M(i); M(j); M(f); is_oadd_fun(M,i,j,j,f) |] 
   415      ==> f`x = i Un (\<Union>k\<in>x. {f ` k})"
   408      ==> f`x = i Un (\<Union>k\<in>x. {f ` k})"
   416 apply (simp add: is_oadd_fun_iff lt_Ord2, clarify) 
   409 apply (simp add: is_oadd_fun_iff lt_Ord2, clarify) 
   417 apply (frule lt_closed, simp)
   410 apply (frule lt_closed, simp)
   418 apply (frule leI [THEN le_imp_subset])  
   411 apply (frule leI [THEN le_imp_subset])  
   419 apply (simp add: image_fun, blast) 
   412 apply (simp add: image_fun, blast) 
   420 done
   413 done
   421 
   414 
   422 lemma (in M_recursion) is_oadd_fun_iff_oadd [rule_format]:
   415 lemma (in M_ord_arith) is_oadd_fun_iff_oadd [rule_format]:
   423     "[| is_oadd_fun(M,i,J,J,f); M(i); M(J); M(f); Ord(i); Ord(j) |] 
   416     "[| is_oadd_fun(M,i,J,J,f); M(i); M(J); M(f); Ord(i); Ord(j) |] 
   424      ==> j<J --> f`j = i++j"
   417      ==> j<J --> f`j = i++j"
   425 apply (erule_tac i=j in trans_induct, clarify) 
   418 apply (erule_tac i=j in trans_induct, clarify) 
   426 apply (subgoal_tac "\<forall>k\<in>x. k<J")
   419 apply (subgoal_tac "\<forall>k\<in>x. k<J")
   427  apply (simp (no_asm_simp) add: is_oadd_def oadd_unfold is_oadd_fun_apply)
   420  apply (simp (no_asm_simp) add: is_oadd_def oadd_unfold is_oadd_fun_apply)
   428 apply (blast intro: lt_trans ltI lt_Ord) 
   421 apply (blast intro: lt_trans ltI lt_Ord) 
   429 done
   422 done
   430 
   423 
   431 lemma (in M_recursion) oadd_abs_fun_apply_iff:
   424 lemma (in M_ord_arith) oadd_abs_fun_apply_iff:
   432     "[| M(i); M(J); M(f); M(k); j<J; is_oadd_fun(M,i,J,J,f) |] 
   425     "[| M(i); M(J); M(f); M(k); j<J; is_oadd_fun(M,i,J,J,f) |] 
   433      ==> fun_apply(M,f,j,k) <-> f`j = k"
   426      ==> fun_apply(M,f,j,k) <-> f`j = k"
   434 by (force simp add: lt_def is_oadd_fun_iff subsetD typed_apply_abs) 
   427 by (force simp add: lt_def is_oadd_fun_iff subsetD typed_apply_abs) 
   435 
   428 
   436 lemma (in M_recursion) Ord_oadd_abs:
   429 lemma (in M_ord_arith) Ord_oadd_abs:
   437     "[| M(i); M(j); M(k); Ord(i); Ord(j) |] ==> is_oadd(M,i,j,k) <-> k = i++j"
   430     "[| M(i); M(j); M(k); Ord(i); Ord(j) |] ==> is_oadd(M,i,j,k) <-> k = i++j"
   438 apply (simp add: is_oadd_def oadd_abs_fun_apply_iff is_oadd_fun_iff_oadd)
   431 apply (simp add: is_oadd_def oadd_abs_fun_apply_iff is_oadd_fun_iff_oadd)
   439 apply (frule exists_oadd_fun [of j i], blast+)
   432 apply (frule exists_oadd_fun [of j i], blast+)
   440 done
   433 done
   441 
   434 
   442 lemma (in M_recursion) oadd_abs:
   435 lemma (in M_ord_arith) oadd_abs:
   443     "[| M(i); M(j); M(k) |] ==> is_oadd(M,i,j,k) <-> k = i++j"
   436     "[| M(i); M(j); M(k) |] ==> is_oadd(M,i,j,k) <-> k = i++j"
   444 apply (case_tac "Ord(i) & Ord(j)")
   437 apply (case_tac "Ord(i) & Ord(j)")
   445  apply (simp add: Ord_oadd_abs)
   438  apply (simp add: Ord_oadd_abs)
   446 apply (auto simp add: is_oadd_def oadd_eq_if_raw_oadd)
   439 apply (auto simp add: is_oadd_def oadd_eq_if_raw_oadd)
   447 done
   440 done
   448 
   441 
   449 lemma (in M_recursion) oadd_closed [intro,simp]:
   442 lemma (in M_ord_arith) oadd_closed [intro,simp]:
   450     "[| M(i); M(j) |] ==> M(i++j)"
   443     "[| M(i); M(j) |] ==> M(i++j)"
   451 apply (simp add: oadd_eq_if_raw_oadd, clarify) 
   444 apply (simp add: oadd_eq_if_raw_oadd, clarify) 
   452 apply (simp add: raw_oadd_eq_oadd) 
   445 apply (simp add: raw_oadd_eq_oadd) 
   453 apply (frule exists_oadd_fun [of j i], auto)
   446 apply (frule exists_oadd_fun [of j i], auto)
   454 apply (simp add: apply_closed is_oadd_fun_iff_oadd [symmetric]) 
   447 apply (simp add: apply_closed is_oadd_fun_iff_oadd [symmetric]) 
   488 
   481 
   489 lemma omult_eqns_Not: "~ Ord(x) ==> ~ omult_eqns(i,x,g,z)"
   482 lemma omult_eqns_Not: "~ Ord(x) ==> ~ omult_eqns(i,x,g,z)"
   490 by (simp add: omult_eqns_def)
   483 by (simp add: omult_eqns_def)
   491 
   484 
   492 
   485 
   493 lemma (in M_recursion) the_omult_eqns_closed:
   486 lemma (in M_ord_arith) the_omult_eqns_closed:
   494     "[| M(i); M(x); M(g); function(g) |] 
   487     "[| M(i); M(x); M(g); function(g) |] 
   495      ==> M(THE z. omult_eqns(i, x, g, z))"
   488      ==> M(THE z. omult_eqns(i, x, g, z))"
   496 apply (case_tac "Ord(x)")
   489 apply (case_tac "Ord(x)")
   497  prefer 2 apply (simp add: omult_eqns_Not) --{*trivial, non-Ord case*}
   490  prefer 2 apply (simp add: omult_eqns_Not) --{*trivial, non-Ord case*}
   498 apply (erule Ord_cases) 
   491 apply (erule Ord_cases) 
   499   apply (simp add: omult_eqns_0)
   492   apply (simp add: omult_eqns_0)
   500  apply (simp add: omult_eqns_succ apply_closed oadd_closed) 
   493  apply (simp add: omult_eqns_succ apply_closed oadd_closed) 
   501 apply (simp add: omult_eqns_Limit) 
   494 apply (simp add: omult_eqns_Limit) 
   502 done
   495 done
   503 
   496 
   504 lemma (in M_recursion) exists_omult:
   497 lemma (in M_ord_arith) exists_omult:
   505     "[| Ord(j);  M(i);  M(j) |]
   498     "[| Ord(j);  M(i);  M(j) |]
   506      ==> \<exists>f. M(f) & is_recfun(Memrel(succ(j)), j, %x g. THE z. omult_eqns(i,x,g,z), f)"
   499      ==> \<exists>f[M]. is_recfun(Memrel(succ(j)), j, %x g. THE z. omult_eqns(i,x,g,z), f)"
   507 apply (rule wf_exists_is_recfun [OF wf_Memrel trans_Memrel])
   500 apply (rule wf_exists_is_recfun [OF wf_Memrel trans_Memrel])
   508     apply simp
   501     apply (simp_all add: Memrel_type omult_strong_replacement') 
   509    apply (blast intro: omult_strong_replacement') 
       
   510   apply (simp_all add: Memrel_type Memrel_closed Un_closed image_closed)
       
   511 apply (blast intro: the_omult_eqns_closed) 
   502 apply (blast intro: the_omult_eqns_closed) 
   512 done
   503 done
   513 
   504 
   514 lemma (in M_recursion) exists_omult_fun:
   505 lemma (in M_ord_arith) exists_omult_fun:
   515     "[| Ord(j);  M(i);  M(j) |] ==> \<exists>f. M(f) & is_omult_fun(M,i,succ(j),f)"
   506     "[| Ord(j);  M(i);  M(j) |] ==> \<exists>f[M]. is_omult_fun(M,i,succ(j),f)"
   516 apply (rule exists_omult [THEN exE])
   507 apply (rule exists_omult [THEN rexE])
   517 apply (erule Ord_succ, assumption, simp) 
   508 apply (erule Ord_succ, assumption, simp) 
   518 apply (rename_tac f, clarify) 
   509 apply (rename_tac f) 
   519 apply (frule is_recfun_type)
   510 apply (frule is_recfun_type)
   520 apply (rule_tac x=f in exI) 
   511 apply (rule_tac x=f in rexI) 
   521 apply (simp add: fun_is_function domain_of_fun lt_Memrel apply_recfun lt_def
   512 apply (simp add: fun_is_function domain_of_fun lt_Memrel apply_recfun lt_def
   522                  is_omult_fun_def Ord_trans [OF _ succI1])
   513                  is_omult_fun_def Ord_trans [OF _ succI1])
   523 apply (force dest: Ord_in_Ord' 
   514  apply (force dest: Ord_in_Ord' 
   524              simp add: omult_eqns_def the_omult_eqns_0 the_omult_eqns_succ
   515               simp add: omult_eqns_def the_omult_eqns_0 the_omult_eqns_succ
   525                        the_omult_eqns_Limit) 
   516                         the_omult_eqns_Limit, assumption)
   526 done
   517 done
   527 
   518 
   528 lemma (in M_recursion) is_omult_fun_apply_0:
   519 lemma (in M_ord_arith) is_omult_fun_apply_0:
   529     "[| 0 < j; is_omult_fun(M,i,j,f) |] ==> f`0 = 0"
   520     "[| 0 < j; is_omult_fun(M,i,j,f) |] ==> f`0 = 0"
   530 by (simp add: is_omult_fun_def omult_eqns_def lt_def ball_conj_distrib)
   521 by (simp add: is_omult_fun_def omult_eqns_def lt_def ball_conj_distrib)
   531 
   522 
   532 lemma (in M_recursion) is_omult_fun_apply_succ:
   523 lemma (in M_ord_arith) is_omult_fun_apply_succ:
   533     "[| succ(x) < j; is_omult_fun(M,i,j,f) |] ==> f`succ(x) = f`x ++ i"
   524     "[| succ(x) < j; is_omult_fun(M,i,j,f) |] ==> f`succ(x) = f`x ++ i"
   534 by (simp add: is_omult_fun_def omult_eqns_def lt_def, blast) 
   525 by (simp add: is_omult_fun_def omult_eqns_def lt_def, blast) 
   535 
   526 
   536 lemma (in M_recursion) is_omult_fun_apply_Limit:
   527 lemma (in M_ord_arith) is_omult_fun_apply_Limit:
   537     "[| x < j; Limit(x); M(j); M(f); is_omult_fun(M,i,j,f) |] 
   528     "[| x < j; Limit(x); M(j); M(f); is_omult_fun(M,i,j,f) |] 
   538      ==> f ` x = (\<Union>y\<in>x. f`y)"
   529      ==> f ` x = (\<Union>y\<in>x. f`y)"
   539 apply (simp add: is_omult_fun_def omult_eqns_def domain_closed lt_def, clarify)
   530 apply (simp add: is_omult_fun_def omult_eqns_def domain_closed lt_def, clarify)
   540 apply (drule subset_trans [OF OrdmemD], assumption+)  
   531 apply (drule subset_trans [OF OrdmemD], assumption+)  
   541 apply (simp add: ball_conj_distrib omult_Limit image_function)
   532 apply (simp add: ball_conj_distrib omult_Limit image_function)
   542 done
   533 done
   543 
   534 
   544 lemma (in M_recursion) is_omult_fun_eq_omult:
   535 lemma (in M_ord_arith) is_omult_fun_eq_omult:
   545     "[| is_omult_fun(M,i,J,f); M(J); M(f); Ord(i); Ord(j) |] 
   536     "[| is_omult_fun(M,i,J,f); M(J); M(f); Ord(i); Ord(j) |] 
   546      ==> j<J --> f`j = i**j"
   537      ==> j<J --> f`j = i**j"
   547 apply (erule_tac i=j in trans_induct3)
   538 apply (erule_tac i=j in trans_induct3)
   548 apply (safe del: impCE)
   539 apply (safe del: impCE)
   549   apply (simp add: is_omult_fun_apply_0) 
   540   apply (simp add: is_omult_fun_apply_0) 
   553 apply (subgoal_tac "\<forall>k\<in>x. k<J")
   544 apply (subgoal_tac "\<forall>k\<in>x. k<J")
   554  apply (simp add: is_omult_fun_apply_Limit omult_Limit) 
   545  apply (simp add: is_omult_fun_apply_Limit omult_Limit) 
   555 apply (blast intro: lt_trans ltI lt_Ord) 
   546 apply (blast intro: lt_trans ltI lt_Ord) 
   556 done
   547 done
   557 
   548 
   558 lemma (in M_recursion) omult_abs_fun_apply_iff:
   549 lemma (in M_ord_arith) omult_abs_fun_apply_iff:
   559     "[| M(i); M(J); M(f); M(k); j<J; is_omult_fun(M,i,J,f) |] 
   550     "[| M(i); M(J); M(f); M(k); j<J; is_omult_fun(M,i,J,f) |] 
   560      ==> fun_apply(M,f,j,k) <-> f`j = k"
   551      ==> fun_apply(M,f,j,k) <-> f`j = k"
   561 by (auto simp add: lt_def is_omult_fun_def subsetD apply_abs) 
   552 by (auto simp add: lt_def is_omult_fun_def subsetD apply_abs) 
   562 
   553 
   563 lemma (in M_recursion) omult_abs:
   554 lemma (in M_ord_arith) omult_abs:
   564     "[| M(i); M(j); M(k); Ord(i); Ord(j) |] ==> is_omult(M,i,j,k) <-> k = i**j"
   555     "[| M(i); M(j); M(k); Ord(i); Ord(j) |] ==> is_omult(M,i,j,k) <-> k = i**j"
   565 apply (simp add: is_omult_def omult_abs_fun_apply_iff is_omult_fun_eq_omult)
   556 apply (simp add: is_omult_def omult_abs_fun_apply_iff is_omult_fun_eq_omult)
   566 apply (frule exists_omult_fun [of j i], blast+)
   557 apply (frule exists_omult_fun [of j i], blast+)
   567 done
   558 done
   568 
   559