src/ZF/AC/DC.thy
changeset 76213 e44d86131648
parent 68847 511d163ab623
child 76214 0c18df79b1c8
equal deleted inserted replaced
76212:f2094906e491 76213:e44d86131648
     6 
     6 
     7 theory DC
     7 theory DC
     8 imports AC_Equiv Hartog Cardinal_aux
     8 imports AC_Equiv Hartog Cardinal_aux
     9 begin
     9 begin
    10 
    10 
    11 lemma RepFun_lepoll: "Ord(a) ==> {P(b). b \<in> a} \<lesssim> a"
    11 lemma RepFun_lepoll: "Ord(a) \<Longrightarrow> {P(b). b \<in> a} \<lesssim> a"
    12 apply (unfold lepoll_def)
    12 apply (unfold lepoll_def)
    13 apply (rule_tac x = "\<lambda>z \<in> RepFun (a,P) . \<mu> i. z=P (i) " in exI)
    13 apply (rule_tac x = "\<lambda>z \<in> RepFun (a,P) . \<mu> i. z=P (i) " in exI)
    14 apply (rule_tac d="%z. P (z)" in lam_injective)
    14 apply (rule_tac d="%z. P (z)" in lam_injective)
    15  apply (fast intro!: Least_in_Ord)
    15  apply (fast intro!: Least_in_Ord)
    16 apply (rule sym) 
    16 apply (rule sym) 
    17 apply (fast intro: LeastI Ord_in_Ord) 
    17 apply (fast intro: LeastI Ord_in_Ord) 
    18 done
    18 done
    19 
    19 
    20 text\<open>Trivial in the presence of AC, but here we need a wellordering of X\<close>
    20 text\<open>Trivial in the presence of AC, but here we need a wellordering of X\<close>
    21 lemma image_Ord_lepoll: "[| f \<in> X->Y; Ord(X) |] ==> f``X \<lesssim> X"
    21 lemma image_Ord_lepoll: "\<lbrakk>f \<in> X->Y; Ord(X)\<rbrakk> \<Longrightarrow> f``X \<lesssim> X"
    22 apply (unfold lepoll_def)
    22 apply (unfold lepoll_def)
    23 apply (rule_tac x = "\<lambda>x \<in> f``X. \<mu> y. f`y = x" in exI)
    23 apply (rule_tac x = "\<lambda>x \<in> f``X. \<mu> y. f`y = x" in exI)
    24 apply (rule_tac d = "%z. f`z" in lam_injective)
    24 apply (rule_tac d = "%z. f`z" in lam_injective)
    25 apply (fast intro!: Least_in_Ord apply_equality, clarify) 
    25 apply (fast intro!: Least_in_Ord apply_equality, clarify) 
    26 apply (rule LeastI) 
    26 apply (rule LeastI) 
    27  apply (erule apply_equality, assumption+) 
    27  apply (erule apply_equality, assumption+) 
    28 apply (blast intro: Ord_in_Ord)
    28 apply (blast intro: Ord_in_Ord)
    29 done
    29 done
    30 
    30 
    31 lemma range_subset_domain: 
    31 lemma range_subset_domain: 
    32       "[| R \<subseteq> X*X;   !!g. g \<in> X ==> \<exists>u. <g,u> \<in> R |] 
    32       "\<lbrakk>R \<subseteq> X*X;   \<And>g. g \<in> X \<Longrightarrow> \<exists>u. <g,u> \<in> R\<rbrakk> 
    33        ==> range(R) \<subseteq> domain(R)"
    33        \<Longrightarrow> range(R) \<subseteq> domain(R)"
    34 by blast 
    34 by blast 
    35 
    35 
    36 lemma cons_fun_type: "g \<in> n->X ==> cons(<n,x>, g) \<in> succ(n) -> cons(x, X)"
    36 lemma cons_fun_type: "g \<in> n->X \<Longrightarrow> cons(<n,x>, g) \<in> succ(n) -> cons(x, X)"
    37 apply (unfold succ_def)
    37 apply (unfold succ_def)
    38 apply (fast intro!: fun_extend elim!: mem_irrefl)
    38 apply (fast intro!: fun_extend elim!: mem_irrefl)
    39 done
    39 done
    40 
    40 
    41 lemma cons_fun_type2:
    41 lemma cons_fun_type2:
    42      "[| g \<in> n->X; x \<in> X |] ==> cons(<n,x>, g) \<in> succ(n) -> X"
    42      "\<lbrakk>g \<in> n->X; x \<in> X\<rbrakk> \<Longrightarrow> cons(<n,x>, g) \<in> succ(n) -> X"
    43 by (erule cons_absorb [THEN subst], erule cons_fun_type)
    43 by (erule cons_absorb [THEN subst], erule cons_fun_type)
    44 
    44 
    45 lemma cons_image_n: "n \<in> nat ==> cons(<n,x>, g)``n = g``n"
    45 lemma cons_image_n: "n \<in> nat \<Longrightarrow> cons(<n,x>, g)``n = g``n"
    46 by (fast elim!: mem_irrefl)
    46 by (fast elim!: mem_irrefl)
    47 
    47 
    48 lemma cons_val_n: "g \<in> n->X ==> cons(<n,x>, g)`n = x"
    48 lemma cons_val_n: "g \<in> n->X \<Longrightarrow> cons(<n,x>, g)`n = x"
    49 by (fast intro!: apply_equality elim!: cons_fun_type)
    49 by (fast intro!: apply_equality elim!: cons_fun_type)
    50 
    50 
    51 lemma cons_image_k: "k \<in> n ==> cons(<n,x>, g)``k = g``k"
    51 lemma cons_image_k: "k \<in> n \<Longrightarrow> cons(<n,x>, g)``k = g``k"
    52 by (fast elim: mem_asym)
    52 by (fast elim: mem_asym)
    53 
    53 
    54 lemma cons_val_k: "[| k \<in> n; g \<in> n->X |] ==> cons(<n,x>, g)`k = g`k"
    54 lemma cons_val_k: "\<lbrakk>k \<in> n; g \<in> n->X\<rbrakk> \<Longrightarrow> cons(<n,x>, g)`k = g`k"
    55 by (fast intro!: apply_equality consI2 elim!: cons_fun_type apply_Pair)
    55 by (fast intro!: apply_equality consI2 elim!: cons_fun_type apply_Pair)
    56 
    56 
    57 lemma domain_cons_eq_succ: "domain(f)=x ==> domain(cons(<x,y>, f)) = succ(x)"
    57 lemma domain_cons_eq_succ: "domain(f)=x \<Longrightarrow> domain(cons(<x,y>, f)) = succ(x)"
    58 by (simp add: domain_cons succ_def)
    58 by (simp add: domain_cons succ_def)
    59 
    59 
    60 lemma restrict_cons_eq: "g \<in> n->X ==> restrict(cons(<n,x>, g), n) = g"
    60 lemma restrict_cons_eq: "g \<in> n->X \<Longrightarrow> restrict(cons(<n,x>, g), n) = g"
    61 apply (simp add: restrict_def Pi_iff)
    61 apply (simp add: restrict_def Pi_iff)
    62 apply (blast intro: elim: mem_irrefl)  
    62 apply (blast intro: elim: mem_irrefl)  
    63 done
    63 done
    64 
    64 
    65 lemma succ_in_succ: "[| Ord(k); i \<in> k |] ==> succ(i) \<in> succ(k)"
    65 lemma succ_in_succ: "\<lbrakk>Ord(k); i \<in> k\<rbrakk> \<Longrightarrow> succ(i) \<in> succ(k)"
    66 apply (rule Ord_linear [of "succ(i)" "succ(k)", THEN disjE])
    66 apply (rule Ord_linear [of "succ(i)" "succ(k)", THEN disjE])
    67 apply (fast elim: Ord_in_Ord mem_irrefl mem_asym)+
    67 apply (fast elim: Ord_in_Ord mem_irrefl mem_asym)+
    68 done
    68 done
    69 
    69 
    70 lemma restrict_eq_imp_val_eq: 
    70 lemma restrict_eq_imp_val_eq: 
    71       "[|restrict(f, domain(g)) = g; x \<in> domain(g)|] 
    71       "\<lbrakk>restrict(f, domain(g)) = g; x \<in> domain(g)\<rbrakk> 
    72        ==> f`x = g`x" 
    72        \<Longrightarrow> f`x = g`x" 
    73 by (erule subst, simp add: restrict)
    73 by (erule subst, simp add: restrict)
    74 
    74 
    75 lemma domain_eq_imp_fun_type: "[| domain(f)=A; f \<in> B->C |] ==> f \<in> A->C"
    75 lemma domain_eq_imp_fun_type: "\<lbrakk>domain(f)=A; f \<in> B->C\<rbrakk> \<Longrightarrow> f \<in> A->C"
    76 by (frule domain_of_fun, fast)
    76 by (frule domain_of_fun, fast)
    77 
    77 
    78 lemma ex_in_domain: "[| R \<subseteq> A * B; R \<noteq> 0 |] ==> \<exists>x. x \<in> domain(R)"
    78 lemma ex_in_domain: "\<lbrakk>R \<subseteq> A * B; R \<noteq> 0\<rbrakk> \<Longrightarrow> \<exists>x. x \<in> domain(R)"
    79 by (fast elim!: not_emptyE)
    79 by (fast elim!: not_emptyE)
    80 
    80 
    81 
    81 
    82 definition
    82 definition
    83   DC  :: "i => o"  where
    83   DC  :: "i => o"  where
    84     "DC(a) == \<forall>X R. R \<subseteq> Pow(X)*X  &
    84     "DC(a) \<equiv> \<forall>X R. R \<subseteq> Pow(X)*X  &
    85                     (\<forall>Y \<in> Pow(X). Y \<prec> a \<longrightarrow> (\<exists>x \<in> X. <Y,x> \<in> R)) 
    85                     (\<forall>Y \<in> Pow(X). Y \<prec> a \<longrightarrow> (\<exists>x \<in> X. <Y,x> \<in> R)) 
    86                     \<longrightarrow> (\<exists>f \<in> a->X. \<forall>b<a. <f``b,f`b> \<in> R)"
    86                     \<longrightarrow> (\<exists>f \<in> a->X. \<forall>b<a. <f``b,f`b> \<in> R)"
    87 
    87 
    88 definition
    88 definition
    89   DC0 :: o  where
    89   DC0 :: o  where
    90     "DC0 == \<forall>A B R. R \<subseteq> A*B & R\<noteq>0 & range(R) \<subseteq> domain(R) 
    90     "DC0 \<equiv> \<forall>A B R. R \<subseteq> A*B & R\<noteq>0 & range(R) \<subseteq> domain(R) 
    91                     \<longrightarrow> (\<exists>f \<in> nat->domain(R). \<forall>n \<in> nat. <f`n,f`succ(n)>:R)"
    91                     \<longrightarrow> (\<exists>f \<in> nat->domain(R). \<forall>n \<in> nat. <f`n,f`succ(n)>:R)"
    92 
    92 
    93 definition
    93 definition
    94   ff  :: "[i, i, i, i] => i"  where
    94   ff  :: "[i, i, i, i] => i"  where
    95     "ff(b, X, Q, R) ==
    95     "ff(b, X, Q, R) \<equiv>
    96            transrec(b, %c r. THE x. first(x, {x \<in> X. <r``c, x> \<in> R}, Q))"
    96            transrec(b, %c r. THE x. first(x, {x \<in> X. <r``c, x> \<in> R}, Q))"
    97 
    97 
    98 
    98 
    99 locale DC0_imp =
    99 locale DC0_imp =
   100   fixes XX and RR and X and R
   100   fixes XX and RR and X and R
   101 
   101 
   102   assumes all_ex: "\<forall>Y \<in> Pow(X). Y \<prec> nat \<longrightarrow> (\<exists>x \<in> X. <Y, x> \<in> R)"
   102   assumes all_ex: "\<forall>Y \<in> Pow(X). Y \<prec> nat \<longrightarrow> (\<exists>x \<in> X. <Y, x> \<in> R)"
   103 
   103 
   104   defines XX_def: "XX == (\<Union>n \<in> nat. {f \<in> n->X. \<forall>k \<in> n. <f``k, f`k> \<in> R})"
   104   defines XX_def: "XX \<equiv> (\<Union>n \<in> nat. {f \<in> n->X. \<forall>k \<in> n. <f``k, f`k> \<in> R})"
   105      and RR_def:  "RR == {<z1,z2>:XX*XX. domain(z2)=succ(domain(z1))  
   105      and RR_def:  "RR \<equiv> {<z1,z2>:XX*XX. domain(z2)=succ(domain(z1))  
   106                                        & restrict(z2, domain(z1)) = z1}"
   106                                        & restrict(z2, domain(z1)) = z1}"
   107 begin
   107 begin
   108 
   108 
   109 (* ********************************************************************** *)
   109 (* ********************************************************************** *)
   110 (* DC ==> DC(omega)                                                       *)
   110 (* DC \<Longrightarrow> DC(omega)                                                       *)
   111 (*                                                                        *)
   111 (*                                                                        *)
   112 (* The scheme of the proof:                                               *)
   112 (* The scheme of the proof:                                               *)
   113 (*                                                                        *)
   113 (*                                                                        *)
   114 (* Assume DC. Let R and X satisfy the premise of DC(omega).               *)
   114 (* Assume DC. Let R and X satisfy the premise of DC(omega).               *)
   115 (*                                                                        *)
   115 (*                                                                        *)
   167              simp add: cons_image_n cons_val_n cons_image_k cons_val_k)
   167              simp add: cons_image_n cons_val_n cons_image_k cons_val_k)
   168 apply (simp add: domain_of_fun succ_def restrict_cons_eq)
   168 apply (simp add: domain_of_fun succ_def restrict_cons_eq)
   169 done
   169 done
   170 
   170 
   171 lemma lemma2:
   171 lemma lemma2:
   172      "[| \<forall>n \<in> nat. <f`n, f`succ(n)> \<in> RR;  f \<in> nat -> XX;  n \<in> nat |]   
   172      "\<lbrakk>\<forall>n \<in> nat. <f`n, f`succ(n)> \<in> RR;  f \<in> nat -> XX;  n \<in> nat\<rbrakk>   
   173       ==> \<exists>k \<in> nat. f`succ(n) \<in> k -> X & n \<in> k   
   173       \<Longrightarrow> \<exists>k \<in> nat. f`succ(n) \<in> k -> X & n \<in> k   
   174                   & <f`succ(n)``n, f`succ(n)`n> \<in> R"
   174                   & <f`succ(n)``n, f`succ(n)`n> \<in> R"
   175 apply (induct_tac "n")
   175 apply (induct_tac "n")
   176 apply (drule apply_type [OF _ nat_1I])
   176 apply (drule apply_type [OF _ nat_1I])
   177 apply (drule bspec [OF _ nat_0I])
   177 apply (drule bspec [OF _ nat_0I])
   178 apply (simp add: XX_def, safe)
   178 apply (simp add: XX_def, safe)
   196 apply (simp add: XX_def RR_def, clarify) 
   196 apply (simp add: XX_def RR_def, clarify) 
   197 apply (blast dest: domain_of_fun [symmetric, THEN trans] )
   197 apply (blast dest: domain_of_fun [symmetric, THEN trans] )
   198 done
   198 done
   199 
   199 
   200 lemma lemma3_1:
   200 lemma lemma3_1:
   201      "[| \<forall>n \<in> nat. <f`n, f`succ(n)> \<in> RR;  f \<in> nat -> XX;  m \<in> nat |]   
   201      "\<lbrakk>\<forall>n \<in> nat. <f`n, f`succ(n)> \<in> RR;  f \<in> nat -> XX;  m \<in> nat\<rbrakk>   
   202       ==>  {f`succ(x)`x. x \<in> m} = {f`succ(m)`x. x \<in> m}"
   202       \<Longrightarrow>  {f`succ(x)`x. x \<in> m} = {f`succ(m)`x. x \<in> m}"
   203 apply (subgoal_tac "\<forall>x \<in> m. f`succ (m) `x = f`succ (x) `x")
   203 apply (subgoal_tac "\<forall>x \<in> m. f`succ (m) `x = f`succ (x) `x")
   204 apply simp
   204 apply simp
   205 apply (induct_tac "m", blast)
   205 apply (induct_tac "m", blast)
   206 apply (rule ballI)
   206 apply (rule ballI)
   207 apply (erule succE)
   207 apply (erule succE)
   219 apply (blast dest!: domain_of_fun 
   219 apply (blast dest!: domain_of_fun 
   220              intro: nat_into_Ord OrdmemD [THEN subsetD])
   220              intro: nat_into_Ord OrdmemD [THEN subsetD])
   221 done
   221 done
   222 
   222 
   223 lemma lemma3:
   223 lemma lemma3:
   224      "[| \<forall>n \<in> nat. <f`n, f`succ(n)> \<in> RR;  f \<in> nat -> XX;  m \<in> nat |]  
   224      "\<lbrakk>\<forall>n \<in> nat. <f`n, f`succ(n)> \<in> RR;  f \<in> nat -> XX;  m \<in> nat\<rbrakk>  
   225       ==> (\<lambda>x \<in> nat. f`succ(x)`x) `` m = f`succ(m)``m"
   225       \<Longrightarrow> (\<lambda>x \<in> nat. f`succ(x)`x) `` m = f`succ(m)``m"
   226 apply (erule natE, simp)
   226 apply (erule natE, simp)
   227 apply (subst image_lam)
   227 apply (subst image_lam)
   228  apply (fast elim!: OrdmemD [OF nat_succI Ord_nat])
   228  apply (fast elim!: OrdmemD [OF nat_succI Ord_nat])
   229 apply (subst lemma3_1, assumption+)
   229 apply (subst lemma3_1, assumption+)
   230  apply fast
   230  apply fast
   232             elim!: image_fun [symmetric, OF _ OrdmemD [OF _ nat_into_Ord]])
   232             elim!: image_fun [symmetric, OF _ OrdmemD [OF _ nat_into_Ord]])
   233 done
   233 done
   234 
   234 
   235 end
   235 end
   236 
   236 
   237 theorem DC0_imp_DC_nat: "DC0 ==> DC(nat)"
   237 theorem DC0_imp_DC_nat: "DC0 \<Longrightarrow> DC(nat)"
   238 apply (unfold DC_def DC0_def, clarify)
   238 apply (unfold DC_def DC0_def, clarify)
   239 apply (elim allE)
   239 apply (elim allE)
   240 apply (erule impE)
   240 apply (erule impE)
   241    (*these three results comprise Lemma 1*)
   241    (*these three results comprise Lemma 1*)
   242 apply (blast intro!: DC0_imp.lemma1_1 [OF DC0_imp.intro] DC0_imp.lemma1_2 [OF DC0_imp.intro] DC0_imp.lemma1_3 [OF DC0_imp.intro])
   242 apply (blast intro!: DC0_imp.lemma1_1 [OF DC0_imp.intro] DC0_imp.lemma1_2 [OF DC0_imp.intro] DC0_imp.lemma1_3 [OF DC0_imp.intro])
   254 apply (force simp add: lt_def) 
   254 apply (force simp add: lt_def) 
   255 done
   255 done
   256 
   256 
   257 
   257 
   258 (* ************************************************************************
   258 (* ************************************************************************
   259    DC(omega) ==> DC                                                       
   259    DC(omega) \<Longrightarrow> DC                                                       
   260                                                                           
   260                                                                           
   261    The scheme of the proof:                                               
   261    The scheme of the proof:                                               
   262                                                                           
   262                                                                           
   263    Assume DC(omega). Let R and x satisfy the premise of DC.               
   263    Assume DC(omega). Let R and x satisfy the premise of DC.               
   264                                                                           
   264                                                                           
   267     XX = (\<Union>n \<in> nat. {f \<in> succ(n)->domain(R). \<forall>k \<in> n. <f`k, f`succ(k)> \<in> R})
   267     XX = (\<Union>n \<in> nat. {f \<in> succ(n)->domain(R). \<forall>k \<in> n. <f`k, f`succ(k)> \<in> R})
   268 
   268 
   269     RR = {<z1,z2>:Fin(XX)*XX. 
   269     RR = {<z1,z2>:Fin(XX)*XX. 
   270            (domain(z2)=succ(\<Union>f \<in> z1. domain(f)) &
   270            (domain(z2)=succ(\<Union>f \<in> z1. domain(f)) &
   271             (\<forall>f \<in> z1. restrict(z2, domain(f)) = f)) |      
   271             (\<forall>f \<in> z1. restrict(z2, domain(f)) = f)) |      
   272            (~ (\<exists>g \<in> XX. domain(g)=succ(\<Union>f \<in> z1. domain(f)) &
   272            (\<not> (\<exists>g \<in> XX. domain(g)=succ(\<Union>f \<in> z1. domain(f)) &
   273                         (\<forall>f \<in> z1. restrict(g, domain(f)) = f)) &           
   273                         (\<forall>f \<in> z1. restrict(g, domain(f)) = f)) &           
   274             z2={<0,x>})}                                          
   274             z2={<0,x>})}                                          
   275                                                                           
   275                                                                           
   276    Then XX and RR satisfy the hypotheses of DC(omega).                    
   276    Then XX and RR satisfy the hypotheses of DC(omega).                    
   277    So applying DC:                                                        
   277    So applying DC:                                                        
   285    is the desired function.                                               
   285    is the desired function.                                               
   286                                                                           
   286                                                                           
   287 ************************************************************************* *)
   287 ************************************************************************* *)
   288 
   288 
   289 lemma singleton_in_funs: 
   289 lemma singleton_in_funs: 
   290  "x \<in> X ==> {<0,x>} \<in> 
   290  "x \<in> X \<Longrightarrow> {<0,x>} \<in> 
   291             (\<Union>n \<in> nat. {f \<in> succ(n)->X. \<forall>k \<in> n. <f`k, f`succ(k)> \<in> R})"
   291             (\<Union>n \<in> nat. {f \<in> succ(n)->X. \<forall>k \<in> n. <f`k, f`succ(k)> \<in> R})"
   292 apply (rule nat_0I [THEN UN_I])
   292 apply (rule nat_0I [THEN UN_I])
   293 apply (force simp add: singleton_0 [symmetric]
   293 apply (force simp add: singleton_0 [symmetric]
   294              intro!: singleton_fun [THEN Pi_type])
   294              intro!: singleton_fun [THEN Pi_type])
   295 done
   295 done
   296 
   296 
   297 
   297 
   298 locale imp_DC0 =
   298 locale imp_DC0 =
   299   fixes XX and RR and x and R and f and allRR
   299   fixes XX and RR and x and R and f and allRR
   300   defines XX_def: "XX == (\<Union>n \<in> nat.
   300   defines XX_def: "XX \<equiv> (\<Union>n \<in> nat.
   301                       {f \<in> succ(n)->domain(R). \<forall>k \<in> n. <f`k, f`succ(k)> \<in> R})"
   301                       {f \<in> succ(n)->domain(R). \<forall>k \<in> n. <f`k, f`succ(k)> \<in> R})"
   302       and RR_def:
   302       and RR_def:
   303          "RR == {<z1,z2>:Fin(XX)*XX. 
   303          "RR \<equiv> {<z1,z2>:Fin(XX)*XX. 
   304                   (domain(z2)=succ(\<Union>f \<in> z1. domain(f))  
   304                   (domain(z2)=succ(\<Union>f \<in> z1. domain(f))  
   305                     & (\<forall>f \<in> z1. restrict(z2, domain(f)) = f))
   305                     & (\<forall>f \<in> z1. restrict(z2, domain(f)) = f))
   306                   | (~ (\<exists>g \<in> XX. domain(g)=succ(\<Union>f \<in> z1. domain(f))  
   306                   | (\<not> (\<exists>g \<in> XX. domain(g)=succ(\<Union>f \<in> z1. domain(f))  
   307                      & (\<forall>f \<in> z1. restrict(g, domain(f)) = f)) & z2={<0,x>})}"
   307                      & (\<forall>f \<in> z1. restrict(g, domain(f)) = f)) & z2={<0,x>})}"
   308       and allRR_def:
   308       and allRR_def:
   309         "allRR == \<forall>b<nat.
   309         "allRR \<equiv> \<forall>b<nat.
   310                    <f``b, f`b> \<in>  
   310                    <f``b, f`b> \<in>  
   311                     {<z1,z2>\<in>Fin(XX)*XX. (domain(z2)=succ(\<Union>f \<in> z1. domain(f))
   311                     {<z1,z2>\<in>Fin(XX)*XX. (domain(z2)=succ(\<Union>f \<in> z1. domain(f))
   312                                     & (\<Union>f \<in> z1. domain(f)) = b  
   312                                     & (\<Union>f \<in> z1. domain(f)) = b  
   313                                     & (\<forall>f \<in> z1. restrict(z2,domain(f)) = f))}"
   313                                     & (\<forall>f \<in> z1. restrict(z2,domain(f)) = f))}"
   314 begin
   314 begin
   315 
   315 
   316 lemma lemma4:
   316 lemma lemma4:
   317      "[| range(R) \<subseteq> domain(R);  x \<in> domain(R) |]   
   317      "\<lbrakk>range(R) \<subseteq> domain(R);  x \<in> domain(R)\<rbrakk>   
   318       ==> RR \<subseteq> Pow(XX)*XX &   
   318       \<Longrightarrow> RR \<subseteq> Pow(XX)*XX &   
   319              (\<forall>Y \<in> Pow(XX). Y \<prec> nat \<longrightarrow> (\<exists>x \<in> XX. <Y,x>:RR))"
   319              (\<forall>Y \<in> Pow(XX). Y \<prec> nat \<longrightarrow> (\<exists>x \<in> XX. <Y,x>:RR))"
   320 apply (rule conjI)
   320 apply (rule conjI)
   321 apply (force dest!: FinD [THEN PowI] simp add: RR_def)
   321 apply (force dest!: FinD [THEN PowI] simp add: RR_def)
   322 apply (rule impI [THEN ballI])
   322 apply (rule impI [THEN ballI])
   323 apply (drule Finite_Fin [OF lesspoll_nat_is_Finite PowD], assumption)
   323 apply (drule Finite_Fin [OF lesspoll_nat_is_Finite PowD], assumption)
   330 apply (rule rev_bexI, erule singleton_in_funs)
   330 apply (rule rev_bexI, erule singleton_in_funs)
   331 apply (simp add: nat_0I [THEN rev_bexI] cons_fun_type2)
   331 apply (simp add: nat_0I [THEN rev_bexI] cons_fun_type2)
   332 done
   332 done
   333 
   333 
   334 lemma UN_image_succ_eq:
   334 lemma UN_image_succ_eq:
   335      "[| f \<in> nat->X; n \<in> nat |] 
   335      "\<lbrakk>f \<in> nat->X; n \<in> nat\<rbrakk> 
   336       ==> (\<Union>x \<in> f``succ(n). P(x)) =  P(f`n) \<union> (\<Union>x \<in> f``n. P(x))"
   336       \<Longrightarrow> (\<Union>x \<in> f``succ(n). P(x)) =  P(f`n) \<union> (\<Union>x \<in> f``n. P(x))"
   337 by (simp add: image_fun OrdmemD) 
   337 by (simp add: image_fun OrdmemD) 
   338 
   338 
   339 lemma UN_image_succ_eq_succ:
   339 lemma UN_image_succ_eq_succ:
   340      "[| (\<Union>x \<in> f``n. P(x)) = y; P(f`n) = succ(y);   
   340      "\<lbrakk>(\<Union>x \<in> f``n. P(x)) = y; P(f`n) = succ(y);   
   341          f \<in> nat -> X; n \<in> nat |] ==> (\<Union>x \<in> f``succ(n). P(x)) = succ(y)"
   341          f \<in> nat -> X; n \<in> nat\<rbrakk> \<Longrightarrow> (\<Union>x \<in> f``succ(n). P(x)) = succ(y)"
   342 by (simp add: UN_image_succ_eq, blast)
   342 by (simp add: UN_image_succ_eq, blast)
   343 
   343 
   344 lemma apply_domain_type:
   344 lemma apply_domain_type:
   345      "[| h \<in> succ(n) -> D;  n \<in> nat; domain(h)=succ(y) |] ==> h`y \<in> D"
   345      "\<lbrakk>h \<in> succ(n) -> D;  n \<in> nat; domain(h)=succ(y)\<rbrakk> \<Longrightarrow> h`y \<in> D"
   346 by (fast elim: apply_type dest!: trans [OF sym domain_of_fun])
   346 by (fast elim: apply_type dest!: trans [OF sym domain_of_fun])
   347 
   347 
   348 lemma image_fun_succ:
   348 lemma image_fun_succ:
   349      "[| h \<in> nat -> X; n \<in> nat |] ==> h``succ(n) = cons(h`n, h``n)"
   349      "\<lbrakk>h \<in> nat -> X; n \<in> nat\<rbrakk> \<Longrightarrow> h``succ(n) = cons(h`n, h``n)"
   350 by (simp add: image_fun OrdmemD) 
   350 by (simp add: image_fun OrdmemD) 
   351 
   351 
   352 lemma f_n_type:
   352 lemma f_n_type:
   353      "[| domain(f`n) = succ(k); f \<in> nat -> XX;  n \<in> nat |]    
   353      "\<lbrakk>domain(f`n) = succ(k); f \<in> nat -> XX;  n \<in> nat\<rbrakk>    
   354       ==> f`n \<in> succ(k) -> domain(R)"
   354       \<Longrightarrow> f`n \<in> succ(k) -> domain(R)"
   355 apply (unfold XX_def)
   355 apply (unfold XX_def)
   356 apply (drule apply_type, assumption)
   356 apply (drule apply_type, assumption)
   357 apply (fast elim: domain_eq_imp_fun_type)
   357 apply (fast elim: domain_eq_imp_fun_type)
   358 done
   358 done
   359 
   359 
   360 lemma f_n_pairs_in_R [rule_format]: 
   360 lemma f_n_pairs_in_R [rule_format]: 
   361      "[| h \<in> nat -> XX;  domain(h`n) = succ(k);  n \<in> nat |]   
   361      "\<lbrakk>h \<in> nat -> XX;  domain(h`n) = succ(k);  n \<in> nat\<rbrakk>   
   362       ==> \<forall>i \<in> k. <h`n`i, h`n`succ(i)> \<in> R"
   362       \<Longrightarrow> \<forall>i \<in> k. <h`n`i, h`n`succ(i)> \<in> R"
   363 apply (unfold XX_def)
   363 apply (unfold XX_def)
   364 apply (drule apply_type, assumption)
   364 apply (drule apply_type, assumption)
   365 apply (elim UN_E CollectE)
   365 apply (elim UN_E CollectE)
   366 apply (drule domain_of_fun [symmetric, THEN trans], assumption, simp)
   366 apply (drule domain_of_fun [symmetric, THEN trans], assumption, simp)
   367 done
   367 done
   368 
   368 
   369 lemma restrict_cons_eq_restrict: 
   369 lemma restrict_cons_eq_restrict: 
   370      "[| restrict(h, domain(u))=u;  h \<in> n->X;  domain(u) \<subseteq> n |]   
   370      "\<lbrakk>restrict(h, domain(u))=u;  h \<in> n->X;  domain(u) \<subseteq> n\<rbrakk>   
   371       ==> restrict(cons(<n, y>, h), domain(u)) = u"
   371       \<Longrightarrow> restrict(cons(<n, y>, h), domain(u)) = u"
   372 apply (unfold restrict_def)
   372 apply (unfold restrict_def)
   373 apply (simp add: restrict_def Pi_iff)
   373 apply (simp add: restrict_def Pi_iff)
   374 apply (erule sym [THEN trans, symmetric])
   374 apply (erule sym [THEN trans, symmetric])
   375 apply (blast elim: mem_irrefl)  
   375 apply (blast elim: mem_irrefl)  
   376 done
   376 done
   377 
   377 
   378 lemma all_in_image_restrict_eq:
   378 lemma all_in_image_restrict_eq:
   379      "[| \<forall>x \<in> f``n. restrict(f`n, domain(x))=x;   
   379      "\<lbrakk>\<forall>x \<in> f``n. restrict(f`n, domain(x))=x;   
   380          f \<in> nat -> XX;   
   380          f \<in> nat -> XX;   
   381          n \<in> nat;  domain(f`n) = succ(n);   
   381          n \<in> nat;  domain(f`n) = succ(n);   
   382          (\<Union>x \<in> f``n. domain(x)) \<subseteq> n |]  
   382          (\<Union>x \<in> f``n. domain(x)) \<subseteq> n\<rbrakk>  
   383       ==> \<forall>x \<in> f``succ(n). restrict(cons(<succ(n),y>, f`n), domain(x)) = x"
   383       \<Longrightarrow> \<forall>x \<in> f``succ(n). restrict(cons(<succ(n),y>, f`n), domain(x)) = x"
   384 apply (rule ballI)
   384 apply (rule ballI)
   385 apply (simp add: image_fun_succ)
   385 apply (simp add: image_fun_succ)
   386 apply (drule f_n_type, assumption+)
   386 apply (drule f_n_type, assumption+)
   387 apply (erule disjE)
   387 apply (erule disjE)
   388  apply (simp add: domain_of_fun restrict_cons_eq) 
   388  apply (simp add: domain_of_fun restrict_cons_eq) 
   389 apply (blast intro!: restrict_cons_eq_restrict)
   389 apply (blast intro!: restrict_cons_eq_restrict)
   390 done
   390 done
   391 
   391 
   392 lemma simplify_recursion: 
   392 lemma simplify_recursion: 
   393      "[| \<forall>b<nat. <f``b, f`b> \<in> RR;   
   393      "\<lbrakk>\<forall>b<nat. <f``b, f`b> \<in> RR;   
   394          f \<in> nat -> XX; range(R) \<subseteq> domain(R); x \<in> domain(R)|]    
   394          f \<in> nat -> XX; range(R) \<subseteq> domain(R); x \<in> domain(R)\<rbrakk>    
   395       ==> allRR"
   395       \<Longrightarrow> allRR"
   396 apply (unfold RR_def allRR_def)
   396 apply (unfold RR_def allRR_def)
   397 apply (rule oallI, drule ltD)
   397 apply (rule oallI, drule ltD)
   398 apply (erule nat_induct)
   398 apply (erule nat_induct)
   399 apply (drule_tac x=0 in ospec, blast intro: Limit_has_0) 
   399 apply (drule_tac x=0 in ospec, blast intro: Limit_has_0) 
   400 apply (force simp add: singleton_fun [THEN domain_of_fun] singleton_in_funs) 
   400 apply (force simp add: singleton_fun [THEN domain_of_fun] singleton_in_funs) 
   401 (*induction step*) (** LEVEL 5 **)
   401 (*induction step*) (** LEVEL 5 **)
   402 (*prevent simplification of ~\<exists> to \<forall>~ *)
   402 (*prevent simplification of \<not>\<exists> to \<forall>\<not> *)
   403 apply (simp only: separation split)
   403 apply (simp only: separation split)
   404 apply (drule_tac x="succ(xa)" in ospec, blast intro: ltI)
   404 apply (drule_tac x="succ(xa)" in ospec, blast intro: ltI)
   405 apply (elim conjE disjE)
   405 apply (elim conjE disjE)
   406 apply (force elim!: trans subst_context
   406 apply (force elim!: trans subst_context
   407              intro!: UN_image_succ_eq_succ)
   407              intro!: UN_image_succ_eq_succ)
   433 apply (simp add: nat_into_Ord [THEN succ_in_succ] succI2 cons_val_k)
   433 apply (simp add: nat_into_Ord [THEN succ_in_succ] succI2 cons_val_k)
   434 done
   434 done
   435 
   435 
   436 
   436 
   437 lemma lemma2: 
   437 lemma lemma2: 
   438      "[| allRR; f \<in> nat->XX; range(R) \<subseteq> domain(R); x \<in> domain(R); n \<in> nat |]
   438      "\<lbrakk>allRR; f \<in> nat->XX; range(R) \<subseteq> domain(R); x \<in> domain(R); n \<in> nat\<rbrakk>
   439       ==> f`n \<in> succ(n) -> domain(R) & (\<forall>i \<in> n. <f`n`i, f`n`succ(i)>:R)"
   439       \<Longrightarrow> f`n \<in> succ(n) -> domain(R) & (\<forall>i \<in> n. <f`n`i, f`n`succ(i)>:R)"
   440 apply (unfold allRR_def)
   440 apply (unfold allRR_def)
   441 apply (drule ospec)
   441 apply (drule ospec)
   442 apply (erule ltI [OF _ Ord_nat])
   442 apply (erule ltI [OF _ Ord_nat])
   443 apply (erule CollectE, simp)
   443 apply (erule CollectE, simp)
   444 apply (rule conjI)
   444 apply (rule conjI)
   446 apply (unfold XX_def)
   446 apply (unfold XX_def)
   447 apply (fast elim!: trans [THEN domain_eq_imp_fun_type] subst_context)
   447 apply (fast elim!: trans [THEN domain_eq_imp_fun_type] subst_context)
   448 done
   448 done
   449 
   449 
   450 lemma lemma3:
   450 lemma lemma3:
   451      "[| allRR; f \<in> nat->XX; n\<in>nat; range(R) \<subseteq> domain(R);  x \<in> domain(R) |]
   451      "\<lbrakk>allRR; f \<in> nat->XX; n\<in>nat; range(R) \<subseteq> domain(R);  x \<in> domain(R)\<rbrakk>
   452       ==> f`n`n = f`succ(n)`n"
   452       \<Longrightarrow> f`n`n = f`succ(n)`n"
   453 apply (frule lemma2 [THEN conjunct1, THEN domain_of_fun], assumption+)
   453 apply (frule lemma2 [THEN conjunct1, THEN domain_of_fun], assumption+)
   454 apply (unfold allRR_def)
   454 apply (unfold allRR_def)
   455 apply (drule ospec) 
   455 apply (drule ospec) 
   456 apply (drule ltI [OF nat_succI Ord_nat], assumption, simp)
   456 apply (drule ltI [OF nat_succI Ord_nat], assumption, simp)
   457 apply (elim conjE ballE)
   457 apply (elim conjE ballE)
   460 done
   460 done
   461 
   461 
   462 end
   462 end
   463 
   463 
   464 
   464 
   465 theorem DC_nat_imp_DC0: "DC(nat) ==> DC0"
   465 theorem DC_nat_imp_DC0: "DC(nat) \<Longrightarrow> DC0"
   466 apply (unfold DC_def DC0_def)
   466 apply (unfold DC_def DC0_def)
   467 apply (intro allI impI)
   467 apply (intro allI impI)
   468 apply (erule asm_rl conjE ex_in_domain [THEN exE] allE)+
   468 apply (erule asm_rl conjE ex_in_domain [THEN exE] allE)+
   469 apply (erule impE [OF _ imp_DC0.lemma4], assumption+)
   469 apply (erule impE [OF _ imp_DC0.lemma4], assumption+)
   470 apply (erule bexE)
   470 apply (erule bexE)
   477        (assumption|erule nat_succI)+)
   477        (assumption|erule nat_succI)+)
   478 apply (drule imp_DC0.lemma3, auto)
   478 apply (drule imp_DC0.lemma3, auto)
   479 done
   479 done
   480 
   480 
   481 (* ********************************************************************** *)
   481 (* ********************************************************************** *)
   482 (* \<forall>K. Card(K) \<longrightarrow> DC(K) ==> WO3                                       *)
   482 (* \<forall>K. Card(K) \<longrightarrow> DC(K) \<Longrightarrow> WO3                                       *)
   483 (* ********************************************************************** *)
   483 (* ********************************************************************** *)
   484 
   484 
   485 lemma fun_Ord_inj:
   485 lemma fun_Ord_inj:
   486       "[| f \<in> a->X;  Ord(a); 
   486       "\<lbrakk>f \<in> a->X;  Ord(a); 
   487           !!b c. [| b<c; c \<in> a |] ==> f`b\<noteq>f`c |]    
   487           \<And>b c. \<lbrakk>b<c; c \<in> a\<rbrakk> \<Longrightarrow> f`b\<noteq>f`c\<rbrakk>    
   488        ==> f \<in> inj(a, X)"
   488        \<Longrightarrow> f \<in> inj(a, X)"
   489 apply (unfold inj_def, simp) 
   489 apply (unfold inj_def, simp) 
   490 apply (intro ballI impI)
   490 apply (intro ballI impI)
   491 apply (rule_tac j=x in Ord_in_Ord [THEN Ord_linear_lt], assumption+)
   491 apply (rule_tac j=x in Ord_in_Ord [THEN Ord_linear_lt], assumption+)
   492 apply (blast intro: Ord_in_Ord, auto) 
   492 apply (blast intro: Ord_in_Ord, auto) 
   493 apply (atomize, blast dest: not_sym) 
   493 apply (atomize, blast dest: not_sym) 
   494 done
   494 done
   495 
   495 
   496 lemma value_in_image: "[| f \<in> X->Y; A \<subseteq> X; a \<in> A |] ==> f`a \<in> f``A"
   496 lemma value_in_image: "\<lbrakk>f \<in> X->Y; A \<subseteq> X; a \<in> A\<rbrakk> \<Longrightarrow> f`a \<in> f``A"
   497 by (fast elim!: image_fun [THEN ssubst])
   497 by (fast elim!: image_fun [THEN ssubst])
   498 
   498 
   499 lemma lesspoll_lemma: "[| ~ A \<prec> B; C \<prec> B |] ==> A - C \<noteq> 0"
   499 lemma lesspoll_lemma: "\<lbrakk>\<not> A \<prec> B; C \<prec> B\<rbrakk> \<Longrightarrow> A - C \<noteq> 0"
   500 apply (unfold lesspoll_def)
   500 apply (unfold lesspoll_def)
   501 apply (fast dest!: Diff_eq_0_iff [THEN iffD1, THEN subset_imp_lepoll]
   501 apply (fast dest!: Diff_eq_0_iff [THEN iffD1, THEN subset_imp_lepoll]
   502             intro!: eqpollI elim: notE
   502             intro!: eqpollI elim: notE
   503             elim!: eqpollE lepoll_trans)
   503             elim!: eqpollE lepoll_trans)
   504 done
   504 done
   505 
   505 
   506 theorem DC_WO3: "(\<forall>K. Card(K) \<longrightarrow> DC(K)) ==> WO3"
   506 theorem DC_WO3: "(\<forall>K. Card(K) \<longrightarrow> DC(K)) \<Longrightarrow> WO3"
   507 apply (unfold DC_def WO3_def)
   507 apply (unfold DC_def WO3_def)
   508 apply (rule allI)
   508 apply (rule allI)
   509 apply (case_tac "A \<prec> Hartog (A)")
   509 apply (case_tac "A \<prec> Hartog (A)")
   510 apply (fast dest!: lesspoll_imp_ex_lt_eqpoll 
   510 apply (fast dest!: lesspoll_imp_ex_lt_eqpoll 
   511             intro!: Ord_Hartog leI [THEN le_imp_subset])
   511             intro!: Ord_Hartog leI [THEN le_imp_subset])
   525 apply (drule ospec)
   525 apply (drule ospec)
   526 apply (blast intro: ltI Ord_Hartog, force) 
   526 apply (blast intro: ltI Ord_Hartog, force) 
   527 done
   527 done
   528 
   528 
   529 (* ********************************************************************** *)
   529 (* ********************************************************************** *)
   530 (* WO1 ==> \<forall>K. Card(K) \<longrightarrow> DC(K)                                       *)
   530 (* WO1 \<Longrightarrow> \<forall>K. Card(K) \<longrightarrow> DC(K)                                       *)
   531 (* ********************************************************************** *)
   531 (* ********************************************************************** *)
   532 
   532 
   533 lemma images_eq:
   533 lemma images_eq:
   534      "[| \<forall>x \<in> A. f`x=g`x; f \<in> Df->Cf; g \<in> Dg->Cg; A \<subseteq> Df; A \<subseteq> Dg |] 
   534      "\<lbrakk>\<forall>x \<in> A. f`x=g`x; f \<in> Df->Cf; g \<in> Dg->Cg; A \<subseteq> Df; A \<subseteq> Dg\<rbrakk> 
   535       ==> f``A = g``A"
   535       \<Longrightarrow> f``A = g``A"
   536 apply (simp (no_asm_simp) add: image_fun)
   536 apply (simp (no_asm_simp) add: image_fun)
   537 done
   537 done
   538 
   538 
   539 lemma lam_images_eq:
   539 lemma lam_images_eq:
   540      "[| Ord(a); b \<in> a |] ==> (\<lambda>x \<in> a. h(x))``b = (\<lambda>x \<in> b. h(x))``b"
   540      "\<lbrakk>Ord(a); b \<in> a\<rbrakk> \<Longrightarrow> (\<lambda>x \<in> a. h(x))``b = (\<lambda>x \<in> b. h(x))``b"
   541 apply (rule images_eq)
   541 apply (rule images_eq)
   542     apply (rule ballI)
   542     apply (rule ballI)
   543     apply (drule OrdmemD [THEN subsetD], assumption+)
   543     apply (drule OrdmemD [THEN subsetD], assumption+)
   544     apply simp
   544     apply simp
   545    apply (fast elim!: RepFunI OrdmemD intro!: lam_type)+
   545    apply (fast elim!: RepFunI OrdmemD intro!: lam_type)+
   547 
   547 
   548 lemma lam_type_RepFun: "(\<lambda>b \<in> a. h(b)) \<in> a -> {h(b). b \<in> a}"
   548 lemma lam_type_RepFun: "(\<lambda>b \<in> a. h(b)) \<in> a -> {h(b). b \<in> a}"
   549 by (fast intro!: lam_type RepFunI)
   549 by (fast intro!: lam_type RepFunI)
   550 
   550 
   551 lemma lemmaX:
   551 lemma lemmaX:
   552      "[| \<forall>Y \<in> Pow(X). Y \<prec> K \<longrightarrow> (\<exists>x \<in> X. <Y, x> \<in> R);   
   552      "\<lbrakk>\<forall>Y \<in> Pow(X). Y \<prec> K \<longrightarrow> (\<exists>x \<in> X. <Y, x> \<in> R);   
   553          b \<in> K; Z \<in> Pow(X); Z \<prec> K |]   
   553          b \<in> K; Z \<in> Pow(X); Z \<prec> K\<rbrakk>   
   554       ==> {x \<in> X. <Z,x> \<in> R} \<noteq> 0"
   554       \<Longrightarrow> {x \<in> X. <Z,x> \<in> R} \<noteq> 0"
   555 by blast
   555 by blast
   556 
   556 
   557 
   557 
   558 lemma WO1_DC_lemma:
   558 lemma WO1_DC_lemma:
   559      "[| Card(K); well_ord(X,Q);   
   559      "\<lbrakk>Card(K); well_ord(X,Q);   
   560          \<forall>Y \<in> Pow(X). Y \<prec> K \<longrightarrow> (\<exists>x \<in> X. <Y, x> \<in> R); b \<in> K |]   
   560          \<forall>Y \<in> Pow(X). Y \<prec> K \<longrightarrow> (\<exists>x \<in> X. <Y, x> \<in> R); b \<in> K\<rbrakk>   
   561       ==> ff(b, X, Q, R) \<in> {x \<in> X. <(\<lambda>c \<in> b. ff(c, X, Q, R))``b, x> \<in> R}"
   561       \<Longrightarrow> ff(b, X, Q, R) \<in> {x \<in> X. <(\<lambda>c \<in> b. ff(c, X, Q, R))``b, x> \<in> R}"
   562 apply (rule_tac P = "b \<in> K" in impE, (erule_tac [2] asm_rl)+)
   562 apply (rule_tac P = "b \<in> K" in impE, (erule_tac [2] asm_rl)+)
   563 apply (rule_tac i=b in Card_is_Ord [THEN Ord_in_Ord, THEN trans_induct], 
   563 apply (rule_tac i=b in Card_is_Ord [THEN Ord_in_Ord, THEN trans_induct], 
   564        assumption+)
   564        assumption+)
   565 apply (rule impI)
   565 apply (rule impI)
   566 apply (rule ff_def [THEN def_transrec, THEN ssubst])
   566 apply (rule ff_def [THEN def_transrec, THEN ssubst])
   569 apply (erule lemmaX, assumption)
   569 apply (erule lemmaX, assumption)
   570  apply (blast intro: Card_is_Ord OrdmemD [THEN subsetD])
   570  apply (blast intro: Card_is_Ord OrdmemD [THEN subsetD])
   571 apply (blast intro: lesspoll_trans1 in_Card_imp_lesspoll RepFun_lepoll)
   571 apply (blast intro: lesspoll_trans1 in_Card_imp_lesspoll RepFun_lepoll)
   572 done
   572 done
   573 
   573 
   574 theorem WO1_DC_Card: "WO1 ==> \<forall>K. Card(K) \<longrightarrow> DC(K)"
   574 theorem WO1_DC_Card: "WO1 \<Longrightarrow> \<forall>K. Card(K) \<longrightarrow> DC(K)"
   575 apply (unfold DC_def WO1_def)
   575 apply (unfold DC_def WO1_def)
   576 apply (rule allI impI)+
   576 apply (rule allI impI)+
   577 apply (erule allE exE conjE)+
   577 apply (erule allE exE conjE)+
   578 apply (rule_tac x = "\<lambda>b \<in> K. ff (b, X, Ra, R) " in bexI)
   578 apply (rule_tac x = "\<lambda>b \<in> K. ff (b, X, Ra, R) " in bexI)
   579  apply (simp add: lam_images_eq [OF Card_is_Ord ltD])
   579  apply (simp add: lam_images_eq [OF Card_is_Ord ltD])