towards absoluteness of wf
authorpaulson
Mon Jun 24 11:57:23 2002 +0200 (2002-06-24)
changeset 13242f96bd927dd37
parent 13241 0ffc4403f811
child 13243 ba53d07d32d5
towards absoluteness of wf
src/ZF/Constructible/WF_absolute.thy
     1.1 --- a/src/ZF/Constructible/WF_absolute.thy	Mon Jun 24 11:56:27 2002 +0200
     1.2 +++ b/src/ZF/Constructible/WF_absolute.thy	Mon Jun 24 11:57:23 2002 +0200
     1.3 @@ -1,19 +1,12 @@
     1.4 -theory WF_absolute = WF_extras + WFrec:
     1.5 -
     1.6 +theory WF_absolute = WFrec:
     1.7  
     1.8  subsection{*Transitive closure without fixedpoints*}
     1.9  
    1.10 -(*Ordinal.thy: just after succ_le_iff?*)
    1.11 -lemma Ord_succ_mem_iff: "Ord(j) ==> succ(i) \<in> succ(j) <-> i\<in>j"
    1.12 -apply (insert succ_le_iff [of i j]) 
    1.13 -apply (simp add: lt_def) 
    1.14 -done
    1.15 -
    1.16  constdefs
    1.17    rtrancl_alt :: "[i,i]=>i"
    1.18      "rtrancl_alt(A,r) == 
    1.19         {p \<in> A*A. \<exists>n\<in>nat. \<exists>f \<in> succ(n) -> A.
    1.20 -                 \<exists>x y. p = <x,y> &  f`0 = x & f`n = y &
    1.21 +                 (\<exists>x y. p = <x,y> &  f`0 = x & f`n = y) &
    1.22                         (\<forall>i\<in>n. <f`i, f`succ(i)> \<in> r)}"
    1.23  
    1.24  lemma alt_rtrancl_lemma1 [rule_format]: 
    1.25 @@ -37,8 +30,7 @@
    1.26  
    1.27  lemma rtrancl_subset_rtrancl_alt: "r^* <= rtrancl_alt(field(r),r)"
    1.28  apply (simp add: rtrancl_alt_def, clarify) 
    1.29 -apply (frule rtrancl_type [THEN subsetD], clarify) 
    1.30 -apply simp 
    1.31 +apply (frule rtrancl_type [THEN subsetD], clarify, simp) 
    1.32  apply (erule rtrancl_induct) 
    1.33   txt{*Base case, trivial*}
    1.34   apply (rule_tac x=0 in bexI) 
    1.35 @@ -60,151 +52,314 @@
    1.36  	  intro: rtrancl_alt_subset_rtrancl rtrancl_subset_rtrancl_alt) 
    1.37  
    1.38  
    1.39 +constdefs
    1.40 +
    1.41 +  rtran_closure :: "[i=>o,i,i] => o"
    1.42 +    "rtran_closure(M,r,s) == 
    1.43 +        \<forall>A. M(A) --> is_field(M,r,A) -->
    1.44 + 	 (\<forall>p. M(p) --> 
    1.45 +          (p \<in> s <-> 
    1.46 +           (\<exists>n\<in>nat. M(n) & 
    1.47 +            (\<exists>n'. M(n') & successor(M,n,n') &
    1.48 +             (\<exists>f. M(f) & typed_function(M,n',A,f) &
    1.49 +              (\<exists>x\<in>A. M(x) & (\<exists>y\<in>A. M(y) & pair(M,x,y,p) &  
    1.50 +                   fun_apply(M,f,0,x) & fun_apply(M,f,n,y))) &
    1.51 +              (\<forall>i\<in>n. M(i) -->
    1.52 +                (\<forall>i'. M(i') --> successor(M,i,i') -->
    1.53 +                 (\<forall>fi. M(fi) --> fun_apply(M,f,i,fi) -->
    1.54 +                  (\<forall>fi'. M(fi') --> fun_apply(M,f,i',fi') -->
    1.55 +                   (\<forall>q. M(q) --> pair(M,fi,fi',q) --> q \<in> r))))))))))"
    1.56 +
    1.57 +  tran_closure :: "[i=>o,i,i] => o"
    1.58 +    "tran_closure(M,r,t) == 
    1.59 +         \<exists>s. M(s) & rtran_closure(M,r,s) & composition(M,r,s,t)"
    1.60 +
    1.61 +
    1.62 +locale M_trancl = M_axioms +
    1.63 +(*THEY NEED RELATIVIZATION*)
    1.64 +  assumes rtrancl_separation:
    1.65 +     "[| M(r); M(A) |] ==>
    1.66 +	separation
    1.67 +	   (M, \<lambda>p. \<exists>n\<in>nat. \<exists>f \<in> succ(n) -> A.
    1.68 +                    (\<exists>x y. p = <x,y> &  f`0 = x & f`n = y) &
    1.69 +                          (\<forall>i\<in>n. <f`i, f`succ(i)> \<in> r))"
    1.70 +      and wellfounded_trancl_separation:
    1.71 +     "[| M(r); M(Z) |] ==> separation (M, \<lambda>x. \<exists>w. M(w) & \<langle>w,x\<rangle> \<in> r^+ & w \<in> Z)"
    1.72 +
    1.73 +
    1.74 +lemma (in M_trancl) rtran_closure_rtrancl: 
    1.75 +     "M(r) ==> rtran_closure(M,r,rtrancl(r))"
    1.76 +apply (simp add: rtran_closure_def rtrancl_alt_eq_rtrancl [symmetric] 
    1.77 +                 rtrancl_alt_def field_closed typed_apply_abs apply_closed
    1.78 +                 Ord_succ_mem_iff M_nat  nat_0_le [THEN ltD], clarify) 
    1.79 +apply (rule iffI) 
    1.80 + apply clarify 
    1.81 + apply simp 
    1.82 + apply (rename_tac n f) 
    1.83 + apply (rule_tac x=n in bexI) 
    1.84 +  apply (rule_tac x=f in exI) 
    1.85 +  apply simp
    1.86 +  apply (blast dest: finite_fun_closed dest: transM)
    1.87 + apply assumption
    1.88 +apply clarify
    1.89 +apply (simp add: nat_0_le [THEN ltD] apply_funtype, blast)  
    1.90 +done
    1.91 +
    1.92 +lemma (in M_trancl) rtrancl_closed [intro,simp]: 
    1.93 +     "M(r) ==> M(rtrancl(r))"
    1.94 +apply (insert rtrancl_separation [of r "field(r)"]) 
    1.95 +apply (simp add: rtrancl_alt_eq_rtrancl [symmetric] 
    1.96 +                 rtrancl_alt_def field_closed typed_apply_abs apply_closed
    1.97 +                 Ord_succ_mem_iff M_nat
    1.98 +                 nat_0_le [THEN ltD] leI [THEN ltD] ltI apply_funtype)
    1.99 +done
   1.100 +
   1.101 +lemma (in M_trancl) rtrancl_abs [simp]: 
   1.102 +     "[| M(r); M(z) |] ==> rtran_closure(M,r,z) <-> z = rtrancl(r)"
   1.103 +apply (rule iffI)
   1.104 + txt{*Proving the right-to-left implication*}
   1.105 + prefer 2 apply (blast intro: rtran_closure_rtrancl) 
   1.106 +apply (rule M_equalityI)
   1.107 +apply (simp add: rtran_closure_def rtrancl_alt_eq_rtrancl [symmetric] 
   1.108 +                 rtrancl_alt_def field_closed typed_apply_abs apply_closed
   1.109 +                 Ord_succ_mem_iff M_nat
   1.110 +                 nat_0_le [THEN ltD] leI [THEN ltD] ltI apply_funtype) 
   1.111 + prefer 2 apply assumption
   1.112 + prefer 2 apply blast
   1.113 +apply (rule iffI, clarify) 
   1.114 +apply (simp add: nat_0_le [THEN ltD]  apply_funtype, blast, clarify)  
   1.115 +apply simp 
   1.116 + apply (rename_tac n f) 
   1.117 + apply (rule_tac x=n in bexI) 
   1.118 +  apply (rule_tac x=f in exI)
   1.119 +  apply (blast dest!: finite_fun_closed, assumption)
   1.120 +done
   1.121 +
   1.122 +
   1.123 +lemma (in M_trancl) trancl_closed [intro,simp]: 
   1.124 +     "M(r) ==> M(trancl(r))"
   1.125 +by (simp add: trancl_def comp_closed rtrancl_closed) 
   1.126 +
   1.127 +lemma (in M_trancl) trancl_abs [simp]: 
   1.128 +     "[| M(r); M(z) |] ==> tran_closure(M,r,z) <-> z = trancl(r)"
   1.129 +by (simp add: tran_closure_def trancl_def) 
   1.130 +
   1.131 +
   1.132 +text{*Alternative proof of @{text wf_on_trancl}; inspiration for the 
   1.133 +      relativized version.  Original version is on theory WF.*}
   1.134 +lemma "[| wf[A](r);  r-``A <= A |] ==> wf[A](r^+)"
   1.135 +apply (simp add: wf_on_def wf_def) 
   1.136 +apply (safe intro!: equalityI)
   1.137 +apply (drule_tac x = "{x\<in>A. \<exists>w. \<langle>w,x\<rangle> \<in> r^+ & w \<in> Z}" in spec) 
   1.138 +apply (blast elim: tranclE) 
   1.139 +done
   1.140 +
   1.141 +
   1.142 +lemma (in M_trancl) wellfounded_on_trancl:
   1.143 +     "[| wellfounded_on(M,A,r);  r-``A <= A; M(r); M(A) |]
   1.144 +      ==> wellfounded_on(M,A,r^+)" 
   1.145 +apply (simp add: wellfounded_on_def) 
   1.146 +apply (safe intro!: equalityI)
   1.147 +apply (rename_tac Z x)
   1.148 +apply (subgoal_tac "M({x\<in>A. \<exists>w. M(w) & \<langle>w,x\<rangle> \<in> r^+ & w \<in> Z})") 
   1.149 + prefer 2 
   1.150 + apply (simp add: wellfounded_trancl_separation) 
   1.151 +apply (drule_tac x = "{x\<in>A. \<exists>w. M(w) & \<langle>w,x\<rangle> \<in> r^+ & w \<in> Z}" in spec) 
   1.152 +apply safe
   1.153 +apply (blast dest: transM, simp) 
   1.154 +apply (rename_tac y w) 
   1.155 +apply (drule_tac x=w in bspec, assumption, clarify)
   1.156 +apply (erule tranclE)
   1.157 +  apply (blast dest: transM)   (*transM is needed to prove M(xa)*)
   1.158 + apply blast 
   1.159 +done
   1.160 +
   1.161 +
   1.162  text{*Relativized to M: Every well-founded relation is a subset of some
   1.163  inverse image of an ordinal.  Key step is the construction (in M) of a 
   1.164  rank function.*}
   1.165  
   1.166  
   1.167  (*NEEDS RELATIVIZATION*)
   1.168 -locale M_recursion = M_axioms +
   1.169 +locale M_recursion = M_trancl +
   1.170    assumes wfrank_separation':
   1.171 -     "[| M(r); M(a); r \<subseteq> A*A |] ==>
   1.172 +     "[| M(r); M(A) |] ==>
   1.173  	separation
   1.174  	   (M, \<lambda>x. x \<in> A --> 
   1.175 -		~(\<exists>f. M(f) \<and> 
   1.176 -		      is_recfun(r, x, %x f. \<Union>y \<in> r-``{x}. succ(f`y), f)))"
   1.177 +		~(\<exists>f. M(f) \<and> is_recfun(r^+, x, %x f. range(f), f)))"
   1.178   and wfrank_strong_replacement':
   1.179 -     "[| M(r); M(a); r \<subseteq> A*A |] ==>
   1.180 -      strong_replacement(M, \<lambda>x z. \<exists>y g. M(y) & M(g) &
   1.181 -		  pair(M,x,y,z) & 
   1.182 -		  is_recfun(r, x, %x f. \<Union>y \<in> r-``{x}. succ(f`y), f) & 
   1.183 -		  y = (\<Union>y \<in> r-``{x}. succ(g`y)))"
   1.184 +     "M(r) ==>
   1.185 +      strong_replacement(M, \<lambda>x z. \<exists>y f. M(y) & M(f) &
   1.186 +		  pair(M,x,y,z) & is_recfun(r^+, x, %x f. range(f), f) & 
   1.187 +		  y = range(f))"
   1.188 + and Ord_wfrank_separation:
   1.189 +     "[| M(r); M(A) |] ==>
   1.190 +      separation (M, \<lambda>x. x \<in> A \<longrightarrow>
   1.191 +                \<not> (\<forall>f. M(f) \<longrightarrow>
   1.192 +                       is_recfun(r^+, x, \<lambda>x. range, f) \<longrightarrow> Ord(range(f))))"
   1.193  
   1.194 -
   1.195 -constdefs (*????????????????NEEDED?*)
   1.196 - is_wfrank_fun :: "[i=>o,i,i,i] => o"
   1.197 -    "is_wfrank_fun(M,r,a,f) == 
   1.198 -       function(f) & domain(f) = r-``{a} & 
   1.199 -       (\<forall>x. M(x) --> <x,a> \<in> r --> f`x = (\<Union>y \<in> r-``{x}. succ(f`y)))"
   1.200 -
   1.201 -
   1.202 -
   1.203 +constdefs 
   1.204 + wellfoundedrank :: "[i=>o,i,i] => i"
   1.205 +    "wellfoundedrank(M,r,A) == 
   1.206 +        {p. x\<in>A, \<exists>y f. M(y) & M(f) & 
   1.207 +                       p = <x,y> & is_recfun(r^+, x, %x f. range(f), f) & 
   1.208 +                       y = range(f)}"
   1.209  
   1.210  lemma (in M_recursion) exists_wfrank:
   1.211      "[| wellfounded(M,r); r \<subseteq> A*A; a\<in>A; M(r); M(A) |]
   1.212 -     ==> \<exists>f. M(f) & is_recfun(r, a, %x g. (\<Union>y \<in> r-``{x}. succ(g`y)), f)"
   1.213 -apply (rule exists_is_recfun [of A r]) 
   1.214 -apply (erule wellfounded_imp_wellfounded_on) 
   1.215 -apply assumption; 
   1.216 -apply (rule trans_Memrel [THEN trans_imp_trans_on], simp)  
   1.217 -apply (rule succI1) 
   1.218 -apply (blast intro: wfrank_separation') 
   1.219 -apply (blast intro: wfrank_strong_replacement') 
   1.220 -apply (simp_all add: Memrel_type Memrel_closed Un_closed image_closed)
   1.221 +     ==> \<exists>f. M(f) & is_recfun(r^+, a, %x f. range(f), f)"
   1.222 +apply (rule wellfounded_exists_is_recfun [of A]) 
   1.223 +apply (blast intro: wellfounded_on_trancl wellfounded_imp_wellfounded_on)
   1.224 +apply (rule trans_trancl [THEN trans_imp_trans_on], assumption+)
   1.225 +apply (simp_all add: trancl_subset_times) 
   1.226  done
   1.227  
   1.228 -lemma (in M_recursion) exists_wfrank_fun:
   1.229 -    "[| Ord(j);  M(i);  M(j) |] ==> \<exists>f. M(f) & is_wfrank_fun(M,i,succ(j),f)"
   1.230 -apply (rule exists_wfrank [THEN exE])
   1.231 -apply (erule Ord_succ, assumption, simp) 
   1.232 -apply (rename_tac f, clarify) 
   1.233 -apply (frule is_recfun_type)
   1.234 -apply (rule_tac x=f in exI) 
   1.235 -apply (simp add: fun_is_function domain_of_fun lt_Memrel apply_recfun lt_def
   1.236 -                 is_wfrank_fun_eq Ord_trans [OF _ succI1])
   1.237 +lemma (in M_recursion) M_wellfoundedrank:
   1.238 +    "[| wellfounded(M,r); r \<subseteq> A*A; M(r); M(A) |] 
   1.239 +     ==> M(wellfoundedrank(M,r,A))"
   1.240 +apply (insert wfrank_strong_replacement' [of r]) 
   1.241 +apply (simp add: wellfoundedrank_def) 
   1.242 +apply (rule strong_replacement_closed) 
   1.243 +   apply assumption+
   1.244 + apply (rule univalent_is_recfun) 
   1.245 +     apply (blast intro: wellfounded_on_trancl wellfounded_imp_wellfounded_on)
   1.246 +    apply (rule trans_on_trancl) 
   1.247 +   apply (simp add: trancl_subset_times) 
   1.248 +  apply blast+
   1.249  done
   1.250  
   1.251 -lemma (in M_recursion) is_wfrank_fun_apply:
   1.252 -    "[| x < j; M(i); M(j); M(f); is_wfrank_fun(M,r,a,f) |] 
   1.253 -     ==> f`x = i Un (\<Union>k\<in>x. {f ` k})"
   1.254 -apply (simp add: is_wfrank_fun_eq lt_Ord2) 
   1.255 -apply (frule lt_closed, simp) 
   1.256 -apply (subgoal_tac "x <= domain(f)")
   1.257 - apply (simp add: Ord_trans [OF _ succI1] image_function)
   1.258 - apply (blast intro: elim:); 
   1.259 -apply (blast intro: dest!: leI [THEN le_imp_subset] ) 
   1.260 -done
   1.261 -
   1.262 -lemma (in M_recursion) is_wfrank_fun_eq_wfrank [rule_format]:
   1.263 -    "[| is_wfrank_fun(M,i,J,f); M(i); M(J); M(f); Ord(i); Ord(j) |] 
   1.264 -     ==> j<J --> f`j = i++j"
   1.265 -apply (erule_tac i=j in trans_induct, clarify) 
   1.266 -apply (subgoal_tac "\<forall>k\<in>x. k<J")
   1.267 - apply (simp (no_asm_simp) add: is_wfrank_def wfrank_unfold is_wfrank_fun_apply)
   1.268 -apply (blast intro: lt_trans ltI lt_Ord) 
   1.269 -done
   1.270 -
   1.271 -lemma (in M_recursion) wfrank_abs_fun_apply_iff:
   1.272 -    "[| M(i); M(J); M(f); M(k); j<J; is_wfrank_fun(M,i,J,f) |] 
   1.273 -     ==> fun_apply(M,f,j,k) <-> f`j = k"
   1.274 -by (auto simp add: lt_def is_wfrank_fun_eq subsetD apply_abs) 
   1.275 -
   1.276 -lemma (in M_recursion) Ord_wfrank_abs:
   1.277 -    "[| M(i); M(j); M(k); Ord(i); Ord(j) |] ==> is_wfrank(M,r,a,k) <-> k = i++j"
   1.278 -apply (simp add: is_wfrank_def wfrank_abs_fun_apply_iff is_wfrank_fun_eq_wfrank)
   1.279 -apply (frule exists_wfrank_fun [of j i], blast+)
   1.280 +lemma (in M_recursion) Ord_wfrank_range [rule_format]:
   1.281 +    "[| wellfounded(M,r); r \<subseteq> A*A; a\<in>A; M(r); M(A) |]
   1.282 +     ==> \<forall>f. M(f) --> is_recfun(r^+, a, %x f. range(f), f) --> Ord(range(f))"
   1.283 +apply (subgoal_tac "wellfounded_on(M, A, r^+)") 
   1.284 + prefer 2
   1.285 + apply (blast intro: wellfounded_on_trancl wellfounded_imp_wellfounded_on)
   1.286 +apply (erule wellfounded_on_induct2, assumption+)
   1.287 +apply (simp add: trancl_subset_times) 
   1.288 +apply (blast intro: Ord_wfrank_separation, clarify)
   1.289 +txt{*The reasoning in both cases is that we get @{term y} such that
   1.290 +   @{term "\<langle>y, x\<rangle> \<in> r^+"}.  We find that 
   1.291 +   @{term "f`y = restrict(f, r^+ -`` {y})"}. *}
   1.292 +apply (rule OrdI [OF _ Ord_is_Transset])
   1.293 + txt{*An ordinal is a transitive set...*}
   1.294 + apply (simp add: Transset_def) 
   1.295 + apply clarify
   1.296 + apply (frule apply_recfun2, assumption) 
   1.297 + apply (force simp add: restrict_iff)
   1.298 +txt{*...of ordinals.  This second case requires the induction hyp.*} 
   1.299 +apply clarify 
   1.300 +apply (rename_tac i y)
   1.301 +apply (frule apply_recfun2, assumption) 
   1.302 +apply (frule is_recfun_imp_in_r, assumption) 
   1.303 +apply (frule is_recfun_restrict) 
   1.304 +    (*simp_all won't work*)
   1.305 +    apply (simp add: trans_on_trancl trancl_subset_times)+  
   1.306 +apply (drule spec [THEN mp], assumption)
   1.307 +apply (subgoal_tac "M(restrict(f, r^+ -`` {y}))")
   1.308 + apply (drule_tac x="restrict(f, r^+ -`` {y})" in spec) 
   1.309 + apply (simp add: function_apply_equality [OF _ is_recfun_imp_function])
   1.310 +apply (blast dest: pair_components_in_M)
   1.311  done
   1.312  
   1.313 -lemma (in M_recursion) wfrank_abs:
   1.314 -    "[| M(i); M(j); M(k) |] ==> is_wfrank(M,r,a,k) <-> k = i++j"
   1.315 -apply (case_tac "Ord(i) & Ord(j)")
   1.316 - apply (simp add: Ord_wfrank_abs)
   1.317 -apply (auto simp add: is_wfrank_def wfrank_eq_if_raw_wfrank)
   1.318 +lemma (in M_recursion) Ord_range_wellfoundedrank:
   1.319 +    "[| wellfounded(M,r); r \<subseteq> A*A;  M(r); M(A) |] 
   1.320 +     ==> Ord (range(wellfoundedrank(M,r,A)))"
   1.321 +apply (subgoal_tac "wellfounded_on(M, A, r^+)") 
   1.322 + prefer 2
   1.323 + apply (blast intro: wellfounded_on_trancl wellfounded_imp_wellfounded_on)
   1.324 +apply (frule trancl_subset_times) 
   1.325 +apply (simp add: wellfoundedrank_def)
   1.326 +apply (rule OrdI [OF _ Ord_is_Transset])
   1.327 + prefer 2
   1.328 + txt{*by our previous result the range consists of ordinals.*} 
   1.329 + apply (blast intro: Ord_wfrank_range) 
   1.330 +txt{*We still must show that the range is a transitive set.*}
   1.331 +apply (simp add: Transset_def, clarify)
   1.332 +apply simp
   1.333 +apply (rename_tac x i f u)   
   1.334 +apply (frule is_recfun_imp_in_r, assumption) 
   1.335 +apply (subgoal_tac "M(u) & M(i) & M(x)") 
   1.336 + prefer 2 apply (blast dest: transM, clarify) 
   1.337 +apply (rule_tac a=u in rangeI) 
   1.338 +apply (rule ReplaceI) 
   1.339 +  apply (rule_tac x=i in exI, simp) 
   1.340 +  apply (rule_tac x="restrict(f, r^+ -`` {u})" in exI)
   1.341 +  apply (blast intro: is_recfun_restrict trans_on_trancl dest: apply_recfun2)
   1.342 + apply blast
   1.343 +txt{*Unicity requirement of Replacement*} 
   1.344 +apply clarify
   1.345 +apply (frule apply_recfun2, assumption) 
   1.346 +apply (simp add: trans_on_trancl is_recfun_cut)+
   1.347  done
   1.348  
   1.349 -lemma (in M_recursion) wfrank_closed [intro]:
   1.350 -    "[| M(i); M(j) |] ==> M(i++j)"
   1.351 -apply (simp add: wfrank_eq_if_raw_wfrank, clarify) 
   1.352 -apply (simp add: raw_wfrank_eq_wfrank) 
   1.353 -apply (frule exists_wfrank_fun [of j i], auto)
   1.354 -apply (simp add: apply_closed is_wfrank_fun_eq_wfrank [symmetric]) 
   1.355 +lemma (in M_recursion) function_wellfoundedrank:
   1.356 +    "[| wellfounded(M,r); r \<subseteq> A*A;  M(r); M(A)|]
   1.357 +     ==> function(wellfoundedrank(M,r,A))"
   1.358 +apply (simp add: wellfoundedrank_def function_def, clarify) 
   1.359 +txt{*Uniqueness: repeated below!*}
   1.360 +apply (drule is_recfun_functional, assumption)
   1.361 +    apply (blast intro: wellfounded_on_trancl wellfounded_imp_wellfounded_on)
   1.362 +    apply (simp_all add: trancl_subset_times 
   1.363 +                         trans_trancl [THEN trans_imp_trans_on]) 
   1.364 +apply (blast dest: transM) 
   1.365  done
   1.366  
   1.367 -
   1.368 -
   1.369 -constdefs
   1.370 -  wfrank :: "[i,i]=>i"
   1.371 -    "wfrank(r,a) == wfrec(r, a, %x f. \<Union>y \<in> r-``{x}. succ(f`y))"
   1.372 -
   1.373 -constdefs
   1.374 -  wftype :: "i=>i"
   1.375 -    "wftype(r) == \<Union>y \<in> range(r). succ(wfrank(r,y))"
   1.376 -
   1.377 -lemma (in M_axioms) wfrank: "wellfounded(M,r) ==> wfrank(r,a) = (\<Union>y \<in> r-``{a}. succ(wfrank(r,y)))"
   1.378 -by (subst wfrank_def [THEN def_wfrec], simp_all)
   1.379 -
   1.380 -lemma (in M_axioms) Ord_wfrank: "wellfounded(M,r) ==> Ord(wfrank(r,a))"
   1.381 -apply (rule_tac a="a" in wf_induct, assumption)
   1.382 -apply (subst wfrank, assumption)
   1.383 -apply (rule Ord_succ [THEN Ord_UN], blast) 
   1.384 +lemma (in M_recursion) domain_wellfoundedrank:
   1.385 +    "[| wellfounded(M,r); r \<subseteq> A*A;  M(r); M(A)|]
   1.386 +     ==> domain(wellfoundedrank(M,r,A)) = A"
   1.387 +apply (simp add: wellfoundedrank_def function_def) 
   1.388 +apply (rule equalityI, auto)
   1.389 +apply (frule transM, assumption)  
   1.390 +apply (frule exists_wfrank, assumption+)
   1.391 +apply clarify 
   1.392 +apply (rule domainI) 
   1.393 +apply (rule ReplaceI)
   1.394 +apply (rule_tac x="range(f)" in exI)
   1.395 +apply simp  
   1.396 +apply (rule_tac x=f in exI, blast)
   1.397 +apply assumption
   1.398 +txt{*Uniqueness (for Replacement): repeated above!*}
   1.399 +apply clarify
   1.400 +apply (drule is_recfun_functional, assumption)
   1.401 +    apply (blast intro: wellfounded_on_trancl wellfounded_imp_wellfounded_on)
   1.402 +    apply (simp_all add: trancl_subset_times 
   1.403 +                         trans_trancl [THEN trans_imp_trans_on]) 
   1.404  done
   1.405  
   1.406 -lemma (in M_axioms) wfrank_lt: "[|wellfounded(M,r); <a,b> \<in> r|] ==> wfrank(r,a) < wfrank(r,b)"
   1.407 -apply (rule_tac a1 = "b" in wfrank [THEN ssubst], assumption)
   1.408 -apply (rule UN_I [THEN ltI])
   1.409 -apply (simp add: Ord_wfrank vimage_iff)+
   1.410 -done
   1.411 -
   1.412 -lemma (in M_axioms) Ord_wftype: "wellfounded(M,r) ==> Ord(wftype(r))"
   1.413 -by (simp add: wftype_def Ord_wfrank)
   1.414 -
   1.415 -lemma (in M_axioms) wftypeI: "\<lbrakk>wellfounded(M,r);  x \<in> field(r)\<rbrakk> \<Longrightarrow> wfrank(r,x) \<in> wftype(r)"
   1.416 -apply (simp add: wftype_def) 
   1.417 -apply (blast intro: wfrank_lt [THEN ltD]) 
   1.418 +lemma (in M_recursion) wellfoundedrank_type:
   1.419 +    "[| wellfounded(M,r); r \<subseteq> A*A;  M(r); M(A)|]
   1.420 +     ==> wellfoundedrank(M,r,A) \<in> A -> range(wellfoundedrank(M,r,A))"
   1.421 +apply (frule function_wellfoundedrank, assumption+) 
   1.422 +apply (frule function_imp_Pi) 
   1.423 + apply (simp add: wellfoundedrank_def relation_def) 
   1.424 + apply blast  
   1.425 +apply (simp add: domain_wellfoundedrank)
   1.426  done
   1.427  
   1.428 +lemma (in M_recursion) Ord_wellfoundedrank:
   1.429 +    "[| wellfounded(M,r); a \<in> A; r \<subseteq> A*A;  M(r); M(A) |] 
   1.430 +     ==> Ord(wellfoundedrank(M,r,A) ` a)"
   1.431 +by (blast intro: apply_funtype [OF wellfoundedrank_type]
   1.432 +                 Ord_in_Ord [OF Ord_range_wellfoundedrank])
   1.433  
   1.434 -lemma (in M_axioms) wf_imp_subset_rvimage:
   1.435 -     "[|wellfounded(M,r); r \<subseteq> A*A|] ==> \<exists>i f. Ord(i) & r <= rvimage(A, f, Memrel(i))"
   1.436 -apply (rule_tac x="wftype(r)" in exI) 
   1.437 -apply (rule_tac x="\<lambda>x\<in>A. wfrank(r,x)" in exI) 
   1.438 -apply (simp add: Ord_wftype, clarify) 
   1.439 -apply (frule subsetD, assumption, clarify) 
   1.440 -apply (simp add: rvimage_iff wfrank_lt [THEN ltD])
   1.441 -apply (blast intro: wftypeI  ) 
   1.442 +lemma (in M_recursion) wellfoundedrank_eq:
   1.443 +     "[| is_recfun(r^+, a, %x. range, f);
   1.444 +         wellfounded(M,r);  a \<in> A; r \<subseteq> A*A;  M(f); M(r); M(A)|] 
   1.445 +      ==> wellfoundedrank(M,r,A) ` a = range(f)"
   1.446 +apply (rule apply_equality) 
   1.447 + prefer 2 apply (blast intro: wellfoundedrank_type ) 
   1.448 +apply (simp add: wellfoundedrank_def)
   1.449 +apply (rule ReplaceI)
   1.450 +  apply (rule_tac x="range(f)" in exI) 
   1.451 +  apply blast 
   1.452 + apply assumption
   1.453 +txt{*Unicity requirement of Replacement*} 
   1.454 +apply clarify
   1.455 +apply (drule is_recfun_functional, assumption)
   1.456 +    apply (blast intro: wellfounded_on_trancl wellfounded_imp_wellfounded_on)
   1.457 +    apply (simp_all add: trancl_subset_times 
   1.458 +                         trans_trancl [THEN trans_imp_trans_on])
   1.459 +apply (blast dest: transM) 
   1.460  done
   1.461  
   1.462 -
   1.463 -
   1.464 -
   1.465  end