src/HOL/BNF_Cardinal_Order_Relation.thy
 author paulson Mon Feb 22 14:37:56 2016 +0000 (2016-02-22) changeset 62379 340738057c8c parent 62343 24106dc44def child 62390 842917225d56 permissions -rw-r--r--
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
1 (*  Title:      HOL/BNF_Cardinal_Order_Relation.thy
2     Author:     Andrei Popescu, TU Muenchen
5 Cardinal-order relations as needed by bounded natural functors.
6 *)
8 section \<open>Cardinal-Order Relations as Needed by Bounded Natural Functors\<close>
10 theory BNF_Cardinal_Order_Relation
11 imports Zorn BNF_Wellorder_Constructions
12 begin
14 text\<open>In this section, we define cardinal-order relations to be minim well-orders
15 on their field.  Then we define the cardinal of a set to be {\em some} cardinal-order
16 relation on that set, which will be unique up to order isomorphism.  Then we study
17 the connection between cardinals and:
18 \begin{itemize}
19 \item standard set-theoretic constructions: products,
20 sums, unions, lists, powersets, set-of finite sets operator;
21 \item finiteness and infiniteness (in particular, with the numeric cardinal operator
22 for finite sets, \<open>card\<close>, from the theory \<open>Finite_Sets.thy\<close>).
23 \end{itemize}
24 %
25 On the way, we define the canonical $\omega$ cardinal and finite cardinals.  We also
26 define (again, up to order isomorphism) the successor of a cardinal, and show that
27 any cardinal admits a successor.
29 Main results of this section are the existence of cardinal relations and the
30 facts that, in the presence of infiniteness,
31 most of the standard set-theoretic constructions (except for the powerset)
32 {\em do not increase cardinality}.  In particular, e.g., the set of words/lists over
33 any infinite set has the same cardinality (hence, is in bijection) with that set.
34 \<close>
37 subsection \<open>Cardinal orders\<close>
39 text\<open>A cardinal order in our setting shall be a well-order {\em minim} w.r.t. the
40 order-embedding relation, \<open>\<le>o\<close> (which is the same as being {\em minimal} w.r.t. the
41 strict order-embedding relation, \<open><o\<close>), among all the well-orders on its field.\<close>
43 definition card_order_on :: "'a set \<Rightarrow> 'a rel \<Rightarrow> bool"
44 where
45 "card_order_on A r \<equiv> well_order_on A r \<and> (\<forall>r'. well_order_on A r' \<longrightarrow> r \<le>o r')"
47 abbreviation "Card_order r \<equiv> card_order_on (Field r) r"
48 abbreviation "card_order r \<equiv> card_order_on UNIV r"
50 lemma card_order_on_well_order_on:
51 assumes "card_order_on A r"
52 shows "well_order_on A r"
53 using assms unfolding card_order_on_def by simp
55 lemma card_order_on_Card_order:
56 "card_order_on A r \<Longrightarrow> A = Field r \<and> Card_order r"
57 unfolding card_order_on_def using well_order_on_Field by blast
59 text\<open>The existence of a cardinal relation on any given set (which will mean
60 that any set has a cardinal) follows from two facts:
61 \begin{itemize}
62 \item Zermelo's theorem (proved in \<open>Zorn.thy\<close> as theorem \<open>well_order_on\<close>),
63 which states that on any given set there exists a well-order;
64 \item The well-founded-ness of \<open><o\<close>, ensuring that then there exists a minimal
65 such well-order, i.e., a cardinal order.
66 \end{itemize}
67 \<close>
69 theorem card_order_on: "\<exists>r. card_order_on A r"
70 proof-
71   obtain R where R_def: "R = {r. well_order_on A r}" by blast
72   have 1: "R \<noteq> {} \<and> (\<forall>r \<in> R. Well_order r)"
73   using well_order_on[of A] R_def well_order_on_Well_order by blast
74   hence "\<exists>r \<in> R. \<forall>r' \<in> R. r \<le>o r'"
75   using  exists_minim_Well_order[of R] by auto
76   thus ?thesis using R_def unfolding card_order_on_def by auto
77 qed
79 lemma card_order_on_ordIso:
80 assumes CO: "card_order_on A r" and CO': "card_order_on A r'"
81 shows "r =o r'"
82 using assms unfolding card_order_on_def
83 using ordIso_iff_ordLeq by blast
85 lemma Card_order_ordIso:
86 assumes CO: "Card_order r" and ISO: "r' =o r"
87 shows "Card_order r'"
88 using ISO unfolding ordIso_def
89 proof(unfold card_order_on_def, auto)
90   fix p' assume "well_order_on (Field r') p'"
91   hence 0: "Well_order p' \<and> Field p' = Field r'"
92   using well_order_on_Well_order by blast
93   obtain f where 1: "iso r' r f" and 2: "Well_order r \<and> Well_order r'"
94   using ISO unfolding ordIso_def by auto
95   hence 3: "inj_on f (Field r') \<and> f  (Field r') = Field r"
96   by (auto simp add: iso_iff embed_inj_on)
97   let ?p = "dir_image p' f"
98   have 4: "p' =o ?p \<and> Well_order ?p"
99   using 0 2 3 by (auto simp add: dir_image_ordIso Well_order_dir_image)
100   moreover have "Field ?p =  Field r"
101   using 0 3 by (auto simp add: dir_image_Field)
102   ultimately have "well_order_on (Field r) ?p" by auto
103   hence "r \<le>o ?p" using CO unfolding card_order_on_def by auto
104   thus "r' \<le>o p'"
105   using ISO 4 ordLeq_ordIso_trans ordIso_ordLeq_trans ordIso_symmetric by blast
106 qed
108 lemma Card_order_ordIso2:
109 assumes CO: "Card_order r" and ISO: "r =o r'"
110 shows "Card_order r'"
111 using assms Card_order_ordIso ordIso_symmetric by blast
114 subsection \<open>Cardinal of a set\<close>
116 text\<open>We define the cardinal of set to be {\em some} cardinal order on that set.
117 We shall prove that this notion is unique up to order isomorphism, meaning
118 that order isomorphism shall be the true identity of cardinals.\<close>
120 definition card_of :: "'a set \<Rightarrow> 'a rel" ("|_|" )
121 where "card_of A = (SOME r. card_order_on A r)"
123 lemma card_of_card_order_on: "card_order_on A |A|"
124 unfolding card_of_def by (auto simp add: card_order_on someI_ex)
126 lemma card_of_well_order_on: "well_order_on A |A|"
127 using card_of_card_order_on card_order_on_def by blast
129 lemma Field_card_of: "Field |A| = A"
130 using card_of_card_order_on[of A] unfolding card_order_on_def
131 using well_order_on_Field by blast
133 lemma card_of_Card_order: "Card_order |A|"
134 by (simp only: card_of_card_order_on Field_card_of)
136 corollary ordIso_card_of_imp_Card_order:
137 "r =o |A| \<Longrightarrow> Card_order r"
138 using card_of_Card_order Card_order_ordIso by blast
140 lemma card_of_Well_order: "Well_order |A|"
141 using card_of_Card_order unfolding card_order_on_def by auto
143 lemma card_of_refl: "|A| =o |A|"
144 using card_of_Well_order ordIso_reflexive by blast
146 lemma card_of_least: "well_order_on A r \<Longrightarrow> |A| \<le>o r"
147 using card_of_card_order_on unfolding card_order_on_def by blast
149 lemma card_of_ordIso:
150 "(\<exists>f. bij_betw f A B) = ( |A| =o |B| )"
151 proof(auto)
152   fix f assume *: "bij_betw f A B"
153   then obtain r where "well_order_on B r \<and> |A| =o r"
154   using Well_order_iso_copy card_of_well_order_on by blast
155   hence "|B| \<le>o |A|" using card_of_least
156   ordLeq_ordIso_trans ordIso_symmetric by blast
157   moreover
158   {let ?g = "inv_into A f"
159    have "bij_betw ?g B A" using * bij_betw_inv_into by blast
160    then obtain r where "well_order_on A r \<and> |B| =o r"
161    using Well_order_iso_copy card_of_well_order_on by blast
162    hence "|A| \<le>o |B|" using card_of_least
163    ordLeq_ordIso_trans ordIso_symmetric by blast
164   }
165   ultimately show "|A| =o |B|" using ordIso_iff_ordLeq by blast
166 next
167   assume "|A| =o |B|"
168   then obtain f where "iso ( |A| ) ( |B| ) f"
169   unfolding ordIso_def by auto
170   hence "bij_betw f A B" unfolding iso_def Field_card_of by simp
171   thus "\<exists>f. bij_betw f A B" by auto
172 qed
174 lemma card_of_ordLeq:
175 "(\<exists>f. inj_on f A \<and> f  A \<le> B) = ( |A| \<le>o |B| )"
176 proof(auto)
177   fix f assume *: "inj_on f A" and **: "f  A \<le> B"
178   {assume "|B| <o |A|"
179    hence "|B| \<le>o |A|" using ordLeq_iff_ordLess_or_ordIso by blast
180    then obtain g where "embed ( |B| ) ( |A| ) g"
181    unfolding ordLeq_def by auto
182    hence 1: "inj_on g B \<and> g  B \<le> A" using embed_inj_on[of "|B|" "|A|" "g"]
183    card_of_Well_order[of "B"] Field_card_of[of "B"] Field_card_of[of "A"]
184    embed_Field[of "|B|" "|A|" g] by auto
185    obtain h where "bij_betw h A B"
186    using * ** 1 Cantor_Bernstein[of f] by fastforce
187    hence "|A| =o |B|" using card_of_ordIso by blast
188    hence "|A| \<le>o |B|" using ordIso_iff_ordLeq by auto
189   }
190   thus "|A| \<le>o |B|" using ordLess_or_ordLeq[of "|B|" "|A|"]
191   by (auto simp: card_of_Well_order)
192 next
193   assume *: "|A| \<le>o |B|"
194   obtain f where "embed ( |A| ) ( |B| ) f"
195   using * unfolding ordLeq_def by auto
196   hence "inj_on f A \<and> f  A \<le> B" using embed_inj_on[of "|A|" "|B|" f]
197   card_of_Well_order[of "A"] Field_card_of[of "A"] Field_card_of[of "B"]
198   embed_Field[of "|A|" "|B|" f] by auto
199   thus "\<exists>f. inj_on f A \<and> f  A \<le> B" by auto
200 qed
202 lemma card_of_ordLeq2:
203 "A \<noteq> {} \<Longrightarrow> (\<exists>g. g  B = A) = ( |A| \<le>o |B| )"
204 using card_of_ordLeq[of A B] inj_on_iff_surj[of A B] by auto
206 lemma card_of_ordLess:
207 "(\<not>(\<exists>f. inj_on f A \<and> f  A \<le> B)) = ( |B| <o |A| )"
208 proof-
209   have "(\<not>(\<exists>f. inj_on f A \<and> f  A \<le> B)) = (\<not> |A| \<le>o |B| )"
210   using card_of_ordLeq by blast
211   also have "\<dots> = ( |B| <o |A| )"
212   using card_of_Well_order[of A] card_of_Well_order[of B]
213         not_ordLeq_iff_ordLess by blast
214   finally show ?thesis .
215 qed
217 lemma card_of_ordLess2:
218 "B \<noteq> {} \<Longrightarrow> (\<not>(\<exists>f. f  A = B)) = ( |A| <o |B| )"
219 using card_of_ordLess[of B A] inj_on_iff_surj[of B A] by auto
221 lemma card_of_ordIsoI:
222 assumes "bij_betw f A B"
223 shows "|A| =o |B|"
224 using assms unfolding card_of_ordIso[symmetric] by auto
226 lemma card_of_ordLeqI:
227 assumes "inj_on f A" and "\<And> a. a \<in> A \<Longrightarrow> f a \<in> B"
228 shows "|A| \<le>o |B|"
229 using assms unfolding card_of_ordLeq[symmetric] by auto
231 lemma card_of_unique:
232 "card_order_on A r \<Longrightarrow> r =o |A|"
233 by (simp only: card_order_on_ordIso card_of_card_order_on)
235 lemma card_of_mono1:
236 "A \<le> B \<Longrightarrow> |A| \<le>o |B|"
237 using inj_on_id[of A] card_of_ordLeq[of A B] by fastforce
239 lemma card_of_mono2:
240 assumes "r \<le>o r'"
241 shows "|Field r| \<le>o |Field r'|"
242 proof-
243   obtain f where
244   1: "well_order_on (Field r) r \<and> well_order_on (Field r) r \<and> embed r r' f"
245   using assms unfolding ordLeq_def
246   by (auto simp add: well_order_on_Well_order)
247   hence "inj_on f (Field r) \<and> f  (Field r) \<le> Field r'"
248   by (auto simp add: embed_inj_on embed_Field)
249   thus "|Field r| \<le>o |Field r'|" using card_of_ordLeq by blast
250 qed
252 lemma card_of_cong: "r =o r' \<Longrightarrow> |Field r| =o |Field r'|"
253 by (simp add: ordIso_iff_ordLeq card_of_mono2)
255 lemma card_of_Field_ordLess: "Well_order r \<Longrightarrow> |Field r| \<le>o r"
256 using card_of_least card_of_well_order_on well_order_on_Well_order by blast
258 lemma card_of_Field_ordIso:
259 assumes "Card_order r"
260 shows "|Field r| =o r"
261 proof-
262   have "card_order_on (Field r) r"
263   using assms card_order_on_Card_order by blast
264   moreover have "card_order_on (Field r) |Field r|"
265   using card_of_card_order_on by blast
266   ultimately show ?thesis using card_order_on_ordIso by blast
267 qed
269 lemma Card_order_iff_ordIso_card_of:
270 "Card_order r = (r =o |Field r| )"
271 using ordIso_card_of_imp_Card_order card_of_Field_ordIso ordIso_symmetric by blast
273 lemma Card_order_iff_ordLeq_card_of:
274 "Card_order r = (r \<le>o |Field r| )"
275 proof-
276   have "Card_order r = (r =o |Field r| )"
277   unfolding Card_order_iff_ordIso_card_of by simp
278   also have "... = (r \<le>o |Field r| \<and> |Field r| \<le>o r)"
279   unfolding ordIso_iff_ordLeq by simp
280   also have "... = (r \<le>o |Field r| )"
281   using card_of_Field_ordLess
282   by (auto simp: card_of_Field_ordLess ordLeq_Well_order_simp)
283   finally show ?thesis .
284 qed
286 lemma Card_order_iff_Restr_underS:
287 assumes "Well_order r"
288 shows "Card_order r = (\<forall>a \<in> Field r. Restr r (underS r a) <o |Field r| )"
289 using assms unfolding Card_order_iff_ordLeq_card_of
290 using ordLeq_iff_ordLess_Restr card_of_Well_order by blast
292 lemma card_of_underS:
293 assumes r: "Card_order r" and a: "a : Field r"
294 shows "|underS r a| <o r"
295 proof-
296   let ?A = "underS r a"  let ?r' = "Restr r ?A"
297   have 1: "Well_order r"
298   using r unfolding card_order_on_def by simp
299   have "Well_order ?r'" using 1 Well_order_Restr by auto
300   moreover have "card_order_on (Field ?r') |Field ?r'|"
301   using card_of_card_order_on .
302   ultimately have "|Field ?r'| \<le>o ?r'"
303   unfolding card_order_on_def by simp
304   moreover have "Field ?r' = ?A"
305   using 1 wo_rel.underS_ofilter Field_Restr_ofilter
306   unfolding wo_rel_def by fastforce
307   ultimately have "|?A| \<le>o ?r'" by simp
308   also have "?r' <o |Field r|"
309   using 1 a r Card_order_iff_Restr_underS by blast
310   also have "|Field r| =o r"
311   using r ordIso_symmetric unfolding Card_order_iff_ordIso_card_of by auto
312   finally show ?thesis .
313 qed
315 lemma ordLess_Field:
316 assumes "r <o r'"
317 shows "|Field r| <o r'"
318 proof-
319   have "well_order_on (Field r) r" using assms unfolding ordLess_def
320   by (auto simp add: well_order_on_Well_order)
321   hence "|Field r| \<le>o r" using card_of_least by blast
322   thus ?thesis using assms ordLeq_ordLess_trans by blast
323 qed
325 lemma internalize_card_of_ordLeq:
326 "( |A| \<le>o r) = (\<exists>B \<le> Field r. |A| =o |B| \<and> |B| \<le>o r)"
327 proof
328   assume "|A| \<le>o r"
329   then obtain p where 1: "Field p \<le> Field r \<and> |A| =o p \<and> p \<le>o r"
330   using internalize_ordLeq[of "|A|" r] by blast
331   hence "Card_order p" using card_of_Card_order Card_order_ordIso2 by blast
332   hence "|Field p| =o p" using card_of_Field_ordIso by blast
333   hence "|A| =o |Field p| \<and> |Field p| \<le>o r"
334   using 1 ordIso_equivalence ordIso_ordLeq_trans by blast
335   thus "\<exists>B \<le> Field r. |A| =o |B| \<and> |B| \<le>o r" using 1 by blast
336 next
337   assume "\<exists>B \<le> Field r. |A| =o |B| \<and> |B| \<le>o r"
338   thus "|A| \<le>o r" using ordIso_ordLeq_trans by blast
339 qed
341 lemma internalize_card_of_ordLeq2:
342 "( |A| \<le>o |C| ) = (\<exists>B \<le> C. |A| =o |B| \<and> |B| \<le>o |C| )"
343 using internalize_card_of_ordLeq[of "A" "|C|"] Field_card_of[of C] by auto
346 subsection \<open>Cardinals versus set operations on arbitrary sets\<close>
348 text\<open>Here we embark in a long journey of simple results showing
349 that the standard set-theoretic operations are well-behaved w.r.t. the notion of
350 cardinal -- essentially, this means that they preserve the cardinal identity"
351 \<open>=o\<close> and are monotonic w.r.t. \<open>\<le>o\<close>.
352 \<close>
354 lemma card_of_empty: "|{}| \<le>o |A|"
355 using card_of_ordLeq inj_on_id by blast
357 lemma card_of_empty1:
358 assumes "Well_order r \<or> Card_order r"
359 shows "|{}| \<le>o r"
360 proof-
361   have "Well_order r" using assms unfolding card_order_on_def by auto
362   hence "|Field r| <=o r"
363   using assms card_of_Field_ordLess by blast
364   moreover have "|{}| \<le>o |Field r|" by (simp add: card_of_empty)
365   ultimately show ?thesis using ordLeq_transitive by blast
366 qed
368 corollary Card_order_empty:
369 "Card_order r \<Longrightarrow> |{}| \<le>o r" by (simp add: card_of_empty1)
371 lemma card_of_empty2:
372 assumes LEQ: "|A| =o |{}|"
373 shows "A = {}"
374 using assms card_of_ordIso[of A] bij_betw_empty2 by blast
376 lemma card_of_empty3:
377 assumes LEQ: "|A| \<le>o |{}|"
378 shows "A = {}"
379 using assms
380 by (simp add: ordIso_iff_ordLeq card_of_empty1 card_of_empty2
381               ordLeq_Well_order_simp)
383 lemma card_of_empty_ordIso:
384 "|{}::'a set| =o |{}::'b set|"
385 using card_of_ordIso unfolding bij_betw_def inj_on_def by blast
387 lemma card_of_image:
388 "|f  A| <=o |A|"
389 proof(cases "A = {}", simp add: card_of_empty)
390   assume "A ~= {}"
391   hence "f  A ~= {}" by auto
392   thus "|f  A| \<le>o |A|"
393   using card_of_ordLeq2[of "f  A" A] by auto
394 qed
396 lemma surj_imp_ordLeq:
397 assumes "B \<subseteq> f  A"
398 shows "|B| \<le>o |A|"
399 proof-
400   have "|B| <=o |f  A|" using assms card_of_mono1 by auto
401   thus ?thesis using card_of_image ordLeq_transitive by blast
402 qed
404 lemma card_of_singl_ordLeq:
405 assumes "A \<noteq> {}"
406 shows "|{b}| \<le>o |A|"
407 proof-
408   obtain a where *: "a \<in> A" using assms by auto
409   let ?h = "\<lambda> b'::'b. if b' = b then a else undefined"
410   have "inj_on ?h {b} \<and> ?h  {b} \<le> A"
411   using * unfolding inj_on_def by auto
412   thus ?thesis unfolding card_of_ordLeq[symmetric] by (intro exI)
413 qed
415 corollary Card_order_singl_ordLeq:
416 "\<lbrakk>Card_order r; Field r \<noteq> {}\<rbrakk> \<Longrightarrow> |{b}| \<le>o r"
417 using card_of_singl_ordLeq[of "Field r" b]
418       card_of_Field_ordIso[of r] ordLeq_ordIso_trans by blast
420 lemma card_of_Pow: "|A| <o |Pow A|"
421 using card_of_ordLess2[of "Pow A" A]  Cantors_paradox[of A]
422       Pow_not_empty[of A] by auto
424 corollary Card_order_Pow:
425 "Card_order r \<Longrightarrow> r <o |Pow(Field r)|"
426 using card_of_Pow card_of_Field_ordIso ordIso_ordLess_trans ordIso_symmetric by blast
428 lemma card_of_Plus1: "|A| \<le>o |A <+> B|"
429 proof-
430   have "Inl  A \<le> A <+> B" by auto
431   thus ?thesis using inj_Inl[of A] card_of_ordLeq by blast
432 qed
434 corollary Card_order_Plus1:
435 "Card_order r \<Longrightarrow> r \<le>o |(Field r) <+> B|"
436 using card_of_Plus1 card_of_Field_ordIso ordIso_ordLeq_trans ordIso_symmetric by blast
438 lemma card_of_Plus2: "|B| \<le>o |A <+> B|"
439 proof-
440   have "Inr  B \<le> A <+> B" by auto
441   thus ?thesis using inj_Inr[of B] card_of_ordLeq by blast
442 qed
444 corollary Card_order_Plus2:
445 "Card_order r \<Longrightarrow> r \<le>o |A <+> (Field r)|"
446 using card_of_Plus2 card_of_Field_ordIso ordIso_ordLeq_trans ordIso_symmetric by blast
448 lemma card_of_Plus_empty1: "|A| =o |A <+> {}|"
449 proof-
450   have "bij_betw Inl A (A <+> {})" unfolding bij_betw_def inj_on_def by auto
451   thus ?thesis using card_of_ordIso by auto
452 qed
454 lemma card_of_Plus_empty2: "|A| =o |{} <+> A|"
455 proof-
456   have "bij_betw Inr A ({} <+> A)" unfolding bij_betw_def inj_on_def by auto
457   thus ?thesis using card_of_ordIso by auto
458 qed
460 lemma card_of_Plus_commute: "|A <+> B| =o |B <+> A|"
461 proof-
462   let ?f = "\<lambda>(c::'a + 'b). case c of Inl a \<Rightarrow> Inr a
463                                    | Inr b \<Rightarrow> Inl b"
464   have "bij_betw ?f (A <+> B) (B <+> A)"
465   unfolding bij_betw_def inj_on_def by force
466   thus ?thesis using card_of_ordIso by blast
467 qed
469 lemma card_of_Plus_assoc:
470 fixes A :: "'a set" and B :: "'b set" and C :: "'c set"
471 shows "|(A <+> B) <+> C| =o |A <+> B <+> C|"
472 proof -
473   def f \<equiv> "\<lambda>(k::('a + 'b) + 'c).
474   case k of Inl ab \<Rightarrow> (case ab of Inl a \<Rightarrow> Inl a
475                                  |Inr b \<Rightarrow> Inr (Inl b))
476            |Inr c \<Rightarrow> Inr (Inr c)"
477   have "A <+> B <+> C \<subseteq> f  ((A <+> B) <+> C)"
478   proof
479     fix x assume x: "x \<in> A <+> B <+> C"
480     show "x \<in> f  ((A <+> B) <+> C)"
481     proof(cases x)
482       case (Inl a)
483       hence "a \<in> A" "x = f (Inl (Inl a))"
484       using x unfolding f_def by auto
485       thus ?thesis by auto
486     next
487       case (Inr bc) note 1 = Inr show ?thesis
488       proof(cases bc)
489         case (Inl b)
490         hence "b \<in> B" "x = f (Inl (Inr b))"
491         using x 1 unfolding f_def by auto
492         thus ?thesis by auto
493       next
494         case (Inr c)
495         hence "c \<in> C" "x = f (Inr c)"
496         using x 1 unfolding f_def by auto
497         thus ?thesis by auto
498       qed
499     qed
500   qed
501   hence "bij_betw f ((A <+> B) <+> C) (A <+> B <+> C)"
502   unfolding bij_betw_def inj_on_def f_def by fastforce
503   thus ?thesis using card_of_ordIso by blast
504 qed
506 lemma card_of_Plus_mono1:
507 assumes "|A| \<le>o |B|"
508 shows "|A <+> C| \<le>o |B <+> C|"
509 proof-
510   obtain f where 1: "inj_on f A \<and> f  A \<le> B"
511   using assms card_of_ordLeq[of A] by fastforce
512   obtain g where g_def:
513   "g = (\<lambda>d. case d of Inl a \<Rightarrow> Inl(f a) | Inr (c::'c) \<Rightarrow> Inr c)" by blast
514   have "inj_on g (A <+> C) \<and> g  (A <+> C) \<le> (B <+> C)"
515   proof-
516     {fix d1 and d2 assume "d1 \<in> A <+> C \<and> d2 \<in> A <+> C" and
517                           "g d1 = g d2"
518      hence "d1 = d2" using 1 unfolding inj_on_def g_def by force
519     }
520     moreover
521     {fix d assume "d \<in> A <+> C"
522      hence "g d \<in> B <+> C"  using 1
523      by(case_tac d, auto simp add: g_def)
524     }
525     ultimately show ?thesis unfolding inj_on_def by auto
526   qed
527   thus ?thesis using card_of_ordLeq by blast
528 qed
530 corollary ordLeq_Plus_mono1:
531 assumes "r \<le>o r'"
532 shows "|(Field r) <+> C| \<le>o |(Field r') <+> C|"
533 using assms card_of_mono2 card_of_Plus_mono1 by blast
535 lemma card_of_Plus_mono2:
536 assumes "|A| \<le>o |B|"
537 shows "|C <+> A| \<le>o |C <+> B|"
538 using assms card_of_Plus_mono1[of A B C]
539       card_of_Plus_commute[of C A]  card_of_Plus_commute[of B C]
540       ordIso_ordLeq_trans[of "|C <+> A|"] ordLeq_ordIso_trans[of "|C <+> A|"]
541 by blast
543 corollary ordLeq_Plus_mono2:
544 assumes "r \<le>o r'"
545 shows "|A <+> (Field r)| \<le>o |A <+> (Field r')|"
546 using assms card_of_mono2 card_of_Plus_mono2 by blast
548 lemma card_of_Plus_mono:
549 assumes "|A| \<le>o |B|" and "|C| \<le>o |D|"
550 shows "|A <+> C| \<le>o |B <+> D|"
551 using assms card_of_Plus_mono1[of A B C] card_of_Plus_mono2[of C D B]
552       ordLeq_transitive[of "|A <+> C|"] by blast
554 corollary ordLeq_Plus_mono:
555 assumes "r \<le>o r'" and "p \<le>o p'"
556 shows "|(Field r) <+> (Field p)| \<le>o |(Field r') <+> (Field p')|"
557 using assms card_of_mono2[of r r'] card_of_mono2[of p p'] card_of_Plus_mono by blast
559 lemma card_of_Plus_cong1:
560 assumes "|A| =o |B|"
561 shows "|A <+> C| =o |B <+> C|"
562 using assms by (simp add: ordIso_iff_ordLeq card_of_Plus_mono1)
564 corollary ordIso_Plus_cong1:
565 assumes "r =o r'"
566 shows "|(Field r) <+> C| =o |(Field r') <+> C|"
567 using assms card_of_cong card_of_Plus_cong1 by blast
569 lemma card_of_Plus_cong2:
570 assumes "|A| =o |B|"
571 shows "|C <+> A| =o |C <+> B|"
572 using assms by (simp add: ordIso_iff_ordLeq card_of_Plus_mono2)
574 corollary ordIso_Plus_cong2:
575 assumes "r =o r'"
576 shows "|A <+> (Field r)| =o |A <+> (Field r')|"
577 using assms card_of_cong card_of_Plus_cong2 by blast
579 lemma card_of_Plus_cong:
580 assumes "|A| =o |B|" and "|C| =o |D|"
581 shows "|A <+> C| =o |B <+> D|"
582 using assms by (simp add: ordIso_iff_ordLeq card_of_Plus_mono)
584 corollary ordIso_Plus_cong:
585 assumes "r =o r'" and "p =o p'"
586 shows "|(Field r) <+> (Field p)| =o |(Field r') <+> (Field p')|"
587 using assms card_of_cong[of r r'] card_of_cong[of p p'] card_of_Plus_cong by blast
589 lemma card_of_Un_Plus_ordLeq:
590 "|A \<union> B| \<le>o |A <+> B|"
591 proof-
592    let ?f = "\<lambda> c. if c \<in> A then Inl c else Inr c"
593    have "inj_on ?f (A \<union> B) \<and> ?f  (A \<union> B) \<le> A <+> B"
594    unfolding inj_on_def by auto
595    thus ?thesis using card_of_ordLeq by blast
596 qed
598 lemma card_of_Times1:
599 assumes "A \<noteq> {}"
600 shows "|B| \<le>o |B \<times> A|"
601 proof(cases "B = {}", simp add: card_of_empty)
602   assume *: "B \<noteq> {}"
603   have "fst (B \<times> A) = B" using assms by auto
604   thus ?thesis using inj_on_iff_surj[of B "B \<times> A"]
605                      card_of_ordLeq[of B "B \<times> A"] * by blast
606 qed
608 lemma card_of_Times_commute: "|A \<times> B| =o |B \<times> A|"
609 proof-
610   let ?f = "\<lambda>(a::'a,b::'b). (b,a)"
611   have "bij_betw ?f (A \<times> B) (B \<times> A)"
612   unfolding bij_betw_def inj_on_def by auto
613   thus ?thesis using card_of_ordIso by blast
614 qed
616 lemma card_of_Times2:
617 assumes "A \<noteq> {}"   shows "|B| \<le>o |A \<times> B|"
618 using assms card_of_Times1[of A B] card_of_Times_commute[of B A]
619       ordLeq_ordIso_trans by blast
621 corollary Card_order_Times1:
622 "\<lbrakk>Card_order r; B \<noteq> {}\<rbrakk> \<Longrightarrow> r \<le>o |(Field r) \<times> B|"
623 using card_of_Times1[of B] card_of_Field_ordIso
624       ordIso_ordLeq_trans ordIso_symmetric by blast
626 corollary Card_order_Times2:
627 "\<lbrakk>Card_order r; A \<noteq> {}\<rbrakk> \<Longrightarrow> r \<le>o |A \<times> (Field r)|"
628 using card_of_Times2[of A] card_of_Field_ordIso
629       ordIso_ordLeq_trans ordIso_symmetric by blast
631 lemma card_of_Times3: "|A| \<le>o |A \<times> A|"
632 using card_of_Times1[of A]
633 by(cases "A = {}", simp add: card_of_empty, blast)
635 lemma card_of_Plus_Times_bool: "|A <+> A| =o |A \<times> (UNIV::bool set)|"
636 proof-
637   let ?f = "\<lambda>c::'a + 'a. case c of Inl a \<Rightarrow> (a,True)
638                                   |Inr a \<Rightarrow> (a,False)"
639   have "bij_betw ?f (A <+> A) (A \<times> (UNIV::bool set))"
640   proof-
641     {fix  c1 and c2 assume "?f c1 = ?f c2"
642      hence "c1 = c2"
643      by(case_tac "c1", case_tac "c2", auto, case_tac "c2", auto)
644     }
645     moreover
646     {fix c assume "c \<in> A <+> A"
647      hence "?f c \<in> A \<times> (UNIV::bool set)"
648      by(case_tac c, auto)
649     }
650     moreover
651     {fix a bl assume *: "(a,bl) \<in> A \<times> (UNIV::bool set)"
652      have "(a,bl) \<in> ?f  ( A <+> A)"
653      proof(cases bl)
654        assume bl hence "?f(Inl a) = (a,bl)" by auto
655        thus ?thesis using * by force
656      next
657        assume "\<not> bl" hence "?f(Inr a) = (a,bl)" by auto
658        thus ?thesis using * by force
659      qed
660     }
661     ultimately show ?thesis unfolding bij_betw_def inj_on_def by auto
662   qed
663   thus ?thesis using card_of_ordIso by blast
664 qed
666 lemma card_of_Times_mono1:
667 assumes "|A| \<le>o |B|"
668 shows "|A \<times> C| \<le>o |B \<times> C|"
669 proof-
670   obtain f where 1: "inj_on f A \<and> f  A \<le> B"
671   using assms card_of_ordLeq[of A] by fastforce
672   obtain g where g_def:
673   "g = (\<lambda>(a,c::'c). (f a,c))" by blast
674   have "inj_on g (A \<times> C) \<and> g  (A \<times> C) \<le> (B \<times> C)"
675   using 1 unfolding inj_on_def using g_def by auto
676   thus ?thesis using card_of_ordLeq by blast
677 qed
679 corollary ordLeq_Times_mono1:
680 assumes "r \<le>o r'"
681 shows "|(Field r) \<times> C| \<le>o |(Field r') \<times> C|"
682 using assms card_of_mono2 card_of_Times_mono1 by blast
684 lemma card_of_Times_mono2:
685 assumes "|A| \<le>o |B|"
686 shows "|C \<times> A| \<le>o |C \<times> B|"
687 using assms card_of_Times_mono1[of A B C]
688       card_of_Times_commute[of C A]  card_of_Times_commute[of B C]
689       ordIso_ordLeq_trans[of "|C \<times> A|"] ordLeq_ordIso_trans[of "|C \<times> A|"]
690 by blast
692 corollary ordLeq_Times_mono2:
693 assumes "r \<le>o r'"
694 shows "|A \<times> (Field r)| \<le>o |A \<times> (Field r')|"
695 using assms card_of_mono2 card_of_Times_mono2 by blast
697 lemma card_of_Sigma_mono1:
698 assumes "\<forall>i \<in> I. |A i| \<le>o |B i|"
699 shows "|SIGMA i : I. A i| \<le>o |SIGMA i : I. B i|"
700 proof-
701   have "\<forall>i. i \<in> I \<longrightarrow> (\<exists>f. inj_on f (A i) \<and> f  (A i) \<le> B i)"
702   using assms by (auto simp add: card_of_ordLeq)
703   with choice[of "\<lambda> i f. i \<in> I \<longrightarrow> inj_on f (A i) \<and> f  (A i) \<le> B i"]
704   obtain F where 1: "\<forall>i \<in> I. inj_on (F i) (A i) \<and> (F i)  (A i) \<le> B i"
705     by atomize_elim (auto intro: bchoice)
706   obtain g where g_def: "g = (\<lambda>(i,a::'b). (i,F i a))" by blast
707   have "inj_on g (Sigma I A) \<and> g  (Sigma I A) \<le> (Sigma I B)"
708   using 1 unfolding inj_on_def using g_def by force
709   thus ?thesis using card_of_ordLeq by blast
710 qed
712 lemma card_of_UNION_Sigma:
713 "|\<Union>i \<in> I. A i| \<le>o |SIGMA i : I. A i|"
714 using Ex_inj_on_UNION_Sigma [of A I] card_of_ordLeq by blast
716 lemma card_of_bool:
717 assumes "a1 \<noteq> a2"
718 shows "|UNIV::bool set| =o |{a1,a2}|"
719 proof-
720   let ?f = "\<lambda> bl. case bl of True \<Rightarrow> a1 | False \<Rightarrow> a2"
721   have "bij_betw ?f UNIV {a1,a2}"
722   proof-
723     {fix bl1 and bl2 assume "?f  bl1 = ?f bl2"
724      hence "bl1 = bl2" using assms by (case_tac bl1, case_tac bl2, auto)
725     }
726     moreover
727     {fix bl have "?f bl \<in> {a1,a2}" by (case_tac bl, auto)
728     }
729     moreover
730     {fix a assume *: "a \<in> {a1,a2}"
731      have "a \<in> ?f  UNIV"
732      proof(cases "a = a1")
733        assume "a = a1"
734        hence "?f True = a" by auto  thus ?thesis by blast
735      next
736        assume "a \<noteq> a1" hence "a = a2" using * by auto
737        hence "?f False = a" by auto  thus ?thesis by blast
738      qed
739     }
740     ultimately show ?thesis unfolding bij_betw_def inj_on_def by blast
741   qed
742   thus ?thesis using card_of_ordIso by blast
743 qed
745 lemma card_of_Plus_Times_aux:
746 assumes A2: "a1 \<noteq> a2 \<and> {a1,a2} \<le> A" and
747         LEQ: "|A| \<le>o |B|"
748 shows "|A <+> B| \<le>o |A \<times> B|"
749 proof-
750   have 1: "|UNIV::bool set| \<le>o |A|"
751   using A2 card_of_mono1[of "{a1,a2}"] card_of_bool[of a1 a2]
752         ordIso_ordLeq_trans[of "|UNIV::bool set|"] by blast
753   (*  *)
754   have "|A <+> B| \<le>o |B <+> B|"
755   using LEQ card_of_Plus_mono1 by blast
756   moreover have "|B <+> B| =o |B \<times> (UNIV::bool set)|"
757   using card_of_Plus_Times_bool by blast
758   moreover have "|B \<times> (UNIV::bool set)| \<le>o |B \<times> A|"
759   using 1 by (simp add: card_of_Times_mono2)
760   moreover have " |B \<times> A| =o |A \<times> B|"
761   using card_of_Times_commute by blast
762   ultimately show "|A <+> B| \<le>o |A \<times> B|"
763   using ordLeq_ordIso_trans[of "|A <+> B|" "|B <+> B|" "|B \<times> (UNIV::bool set)|"]
764         ordLeq_transitive[of "|A <+> B|" "|B \<times> (UNIV::bool set)|" "|B \<times> A|"]
765         ordLeq_ordIso_trans[of "|A <+> B|" "|B \<times> A|" "|A \<times> B|"]
766   by blast
767 qed
769 lemma card_of_Plus_Times:
770 assumes A2: "a1 \<noteq> a2 \<and> {a1,a2} \<le> A" and
771         B2: "b1 \<noteq> b2 \<and> {b1,b2} \<le> B"
772 shows "|A <+> B| \<le>o |A \<times> B|"
773 proof-
774   {assume "|A| \<le>o |B|"
775    hence ?thesis using assms by (auto simp add: card_of_Plus_Times_aux)
776   }
777   moreover
778   {assume "|B| \<le>o |A|"
779    hence "|B <+> A| \<le>o |B \<times> A|"
780    using assms by (auto simp add: card_of_Plus_Times_aux)
781    hence ?thesis
782    using card_of_Plus_commute card_of_Times_commute
783          ordIso_ordLeq_trans ordLeq_ordIso_trans by blast
784   }
785   ultimately show ?thesis
786   using card_of_Well_order[of A] card_of_Well_order[of B]
787         ordLeq_total[of "|A|"] by blast
788 qed
790 lemma card_of_Times_Plus_distrib:
791   "|A \<times> (B <+> C)| =o |A \<times> B <+> A \<times> C|" (is "|?RHS| =o |?LHS|")
792 proof -
793   let ?f = "\<lambda>(a, bc). case bc of Inl b \<Rightarrow> Inl (a, b) | Inr c \<Rightarrow> Inr (a, c)"
794   have "bij_betw ?f ?RHS ?LHS" unfolding bij_betw_def inj_on_def by force
795   thus ?thesis using card_of_ordIso by blast
796 qed
798 lemma card_of_ordLeq_finite:
799 assumes "|A| \<le>o |B|" and "finite B"
800 shows "finite A"
801 using assms unfolding ordLeq_def
802 using embed_inj_on[of "|A|" "|B|"]  embed_Field[of "|A|" "|B|"]
803       Field_card_of[of "A"] Field_card_of[of "B"] inj_on_finite[of _ "A" "B"] by fastforce
805 lemma card_of_ordLeq_infinite:
806 assumes "|A| \<le>o |B|" and "\<not> finite A"
807 shows "\<not> finite B"
808 using assms card_of_ordLeq_finite by auto
810 lemma card_of_ordIso_finite:
811 assumes "|A| =o |B|"
812 shows "finite A = finite B"
813 using assms unfolding ordIso_def iso_def[abs_def]
814 by (auto simp: bij_betw_finite Field_card_of)
816 lemma card_of_ordIso_finite_Field:
817 assumes "Card_order r" and "r =o |A|"
818 shows "finite(Field r) = finite A"
819 using assms card_of_Field_ordIso card_of_ordIso_finite ordIso_equivalence by blast
822 subsection \<open>Cardinals versus set operations involving infinite sets\<close>
824 text\<open>Here we show that, for infinite sets, most set-theoretic constructions
825 do not increase the cardinality.  The cornerstone for this is
826 theorem \<open>Card_order_Times_same_infinite\<close>, which states that self-product
827 does not increase cardinality -- the proof of this fact adapts a standard
828 set-theoretic argument, as presented, e.g., in the proof of theorem 1.5.11
829 at page 47 in @{cite "card-book"}. Then everything else follows fairly easily.\<close>
831 lemma infinite_iff_card_of_nat:
832 "\<not> finite A \<longleftrightarrow> ( |UNIV::nat set| \<le>o |A| )"
833 unfolding infinite_iff_countable_subset card_of_ordLeq ..
835 text\<open>The next two results correspond to the ZF fact that all infinite cardinals are
836 limit ordinals:\<close>
838 lemma Card_order_infinite_not_under:
839 assumes CARD: "Card_order r" and INF: "\<not>finite (Field r)"
840 shows "\<not> (\<exists>a. Field r = under r a)"
841 proof(auto)
842   have 0: "Well_order r \<and> wo_rel r \<and> Refl r"
843   using CARD unfolding wo_rel_def card_order_on_def order_on_defs by auto
844   fix a assume *: "Field r = under r a"
845   show False
846   proof(cases "a \<in> Field r")
847     assume Case1: "a \<notin> Field r"
848     hence "under r a = {}" unfolding Field_def under_def by auto
849     thus False using INF *  by auto
850   next
851     let ?r' = "Restr r (underS r a)"
852     assume Case2: "a \<in> Field r"
853     hence 1: "under r a = underS r a \<union> {a} \<and> a \<notin> underS r a"
854     using 0 Refl_under_underS[of r a] underS_notIn[of a r] by blast
855     have 2: "wo_rel.ofilter r (underS r a) \<and> underS r a < Field r"
856     using 0 wo_rel.underS_ofilter * 1 Case2 by fast
857     hence "?r' <o r" using 0 using ofilter_ordLess by blast
858     moreover
859     have "Field ?r' = underS r a \<and> Well_order ?r'"
860     using  2 0 Field_Restr_ofilter[of r] Well_order_Restr[of r] by blast
861     ultimately have "|underS r a| <o r" using ordLess_Field[of ?r'] by auto
862     moreover have "|under r a| =o r" using * CARD card_of_Field_ordIso[of r] by auto
863     ultimately have "|underS r a| <o |under r a|"
864     using ordIso_symmetric ordLess_ordIso_trans by blast
865     moreover
866     {have "\<exists>f. bij_betw f (under r a) (underS r a)"
867      using infinite_imp_bij_betw[of "Field r" a] INF * 1 by auto
868      hence "|under r a| =o |underS r a|" using card_of_ordIso by blast
869     }
870     ultimately show False using not_ordLess_ordIso ordIso_symmetric by blast
871   qed
872 qed
874 lemma infinite_Card_order_limit:
875 assumes r: "Card_order r" and "\<not>finite (Field r)"
876 and a: "a : Field r"
877 shows "EX b : Field r. a \<noteq> b \<and> (a,b) : r"
878 proof-
879   have "Field r \<noteq> under r a"
880   using assms Card_order_infinite_not_under by blast
881   moreover have "under r a \<le> Field r"
882   using under_Field .
883   ultimately have "under r a < Field r" by blast
884   then obtain b where 1: "b : Field r \<and> ~ (b,a) : r"
885   unfolding under_def by blast
886   moreover have ba: "b \<noteq> a"
887   using 1 r unfolding card_order_on_def well_order_on_def
888   linear_order_on_def partial_order_on_def preorder_on_def refl_on_def by auto
889   ultimately have "(a,b) : r"
890   using a r unfolding card_order_on_def well_order_on_def linear_order_on_def
891   total_on_def by blast
892   thus ?thesis using 1 ba by auto
893 qed
895 theorem Card_order_Times_same_infinite:
896 assumes CO: "Card_order r" and INF: "\<not>finite(Field r)"
897 shows "|Field r \<times> Field r| \<le>o r"
898 proof-
899   obtain phi where phi_def:
900   "phi = (\<lambda>r::'a rel. Card_order r \<and> \<not>finite(Field r) \<and>
901                       \<not> |Field r \<times> Field r| \<le>o r )" by blast
902   have temp1: "\<forall>r. phi r \<longrightarrow> Well_order r"
903   unfolding phi_def card_order_on_def by auto
904   have Ft: "\<not>(\<exists>r. phi r)"
905   proof
906     assume "\<exists>r. phi r"
907     hence "{r. phi r} \<noteq> {} \<and> {r. phi r} \<le> {r. Well_order r}"
908     using temp1 by auto
909     then obtain r where 1: "phi r" and 2: "\<forall>r'. phi r' \<longrightarrow> r \<le>o r'" and
910                    3: "Card_order r \<and> Well_order r"
911     using exists_minim_Well_order[of "{r. phi r}"] temp1 phi_def by blast
912     let ?A = "Field r"  let ?r' = "bsqr r"
913     have 4: "Well_order ?r' \<and> Field ?r' = ?A \<times> ?A \<and> |?A| =o r"
914     using 3 bsqr_Well_order Field_bsqr card_of_Field_ordIso by blast
915     have 5: "Card_order |?A \<times> ?A| \<and> Well_order |?A \<times> ?A|"
916     using card_of_Card_order card_of_Well_order by blast
917     (*  *)
918     have "r <o |?A \<times> ?A|"
919     using 1 3 5 ordLess_or_ordLeq unfolding phi_def by blast
920     moreover have "|?A \<times> ?A| \<le>o ?r'"
921     using card_of_least[of "?A \<times> ?A"] 4 by auto
922     ultimately have "r <o ?r'" using ordLess_ordLeq_trans by auto
923     then obtain f where 6: "embed r ?r' f" and 7: "\<not> bij_betw f ?A (?A \<times> ?A)"
924     unfolding ordLess_def embedS_def[abs_def]
925     by (auto simp add: Field_bsqr)
926     let ?B = "f  ?A"
927     have "|?A| =o |?B|"
928     using 3 6 embed_inj_on inj_on_imp_bij_betw card_of_ordIso by blast
929     hence 8: "r =o |?B|" using 4 ordIso_transitive ordIso_symmetric by blast
930     (*  *)
931     have "wo_rel.ofilter ?r' ?B"
932     using 6 embed_Field_ofilter 3 4 by blast
933     hence "wo_rel.ofilter ?r' ?B \<and> ?B \<noteq> ?A \<times> ?A \<and> ?B \<noteq> Field ?r'"
934     using 7 unfolding bij_betw_def using 6 3 embed_inj_on 4 by auto
935     hence temp2: "wo_rel.ofilter ?r' ?B \<and> ?B < ?A \<times> ?A"
936     using 4 wo_rel_def[of ?r'] wo_rel.ofilter_def[of ?r' ?B] by blast
937     have "\<not> (\<exists>a. Field r = under r a)"
938     using 1 unfolding phi_def using Card_order_infinite_not_under[of r] by auto
939     then obtain A1 where temp3: "wo_rel.ofilter r A1 \<and> A1 < ?A" and 9: "?B \<le> A1 \<times> A1"
940     using temp2 3 bsqr_ofilter[of r ?B] by blast
941     hence "|?B| \<le>o |A1 \<times> A1|" using card_of_mono1 by blast
942     hence 10: "r \<le>o |A1 \<times> A1|" using 8 ordIso_ordLeq_trans by blast
943     let ?r1 = "Restr r A1"
944     have "?r1 <o r" using temp3 ofilter_ordLess 3 by blast
945     moreover
946     {have "well_order_on A1 ?r1" using 3 temp3 well_order_on_Restr by blast
947      hence "|A1| \<le>o ?r1" using 3 Well_order_Restr card_of_least by blast
948     }
949     ultimately have 11: "|A1| <o r" using ordLeq_ordLess_trans by blast
950     (*  *)
951     have "\<not> finite (Field r)" using 1 unfolding phi_def by simp
952     hence "\<not> finite ?B" using 8 3 card_of_ordIso_finite_Field[of r ?B] by blast
953     hence "\<not> finite A1" using 9 finite_cartesian_product finite_subset by blast
954     moreover have temp4: "Field |A1| = A1 \<and> Well_order |A1| \<and> Card_order |A1|"
955     using card_of_Card_order[of A1] card_of_Well_order[of A1]
956     by (simp add: Field_card_of)
957     moreover have "\<not> r \<le>o | A1 |"
958     using temp4 11 3 using not_ordLeq_iff_ordLess by blast
959     ultimately have "\<not> finite(Field |A1| ) \<and> Card_order |A1| \<and> \<not> r \<le>o | A1 |"
960     by (simp add: card_of_card_order_on)
961     hence "|Field |A1| \<times> Field |A1| | \<le>o |A1|"
962     using 2 unfolding phi_def by blast
963     hence "|A1 \<times> A1 | \<le>o |A1|" using temp4 by auto
964     hence "r \<le>o |A1|" using 10 ordLeq_transitive by blast
965     thus False using 11 not_ordLess_ordLeq by auto
966   qed
967   thus ?thesis using assms unfolding phi_def by blast
968 qed
970 corollary card_of_Times_same_infinite:
971 assumes "\<not>finite A"
972 shows "|A \<times> A| =o |A|"
973 proof-
974   let ?r = "|A|"
975   have "Field ?r = A \<and> Card_order ?r"
976   using Field_card_of card_of_Card_order[of A] by fastforce
977   hence "|A \<times> A| \<le>o |A|"
978   using Card_order_Times_same_infinite[of ?r] assms by auto
979   thus ?thesis using card_of_Times3 ordIso_iff_ordLeq by blast
980 qed
982 lemma card_of_Times_infinite:
983 assumes INF: "\<not>finite A" and NE: "B \<noteq> {}" and LEQ: "|B| \<le>o |A|"
984 shows "|A \<times> B| =o |A| \<and> |B \<times> A| =o |A|"
985 proof-
986   have "|A| \<le>o |A \<times> B| \<and> |A| \<le>o |B \<times> A|"
987   using assms by (simp add: card_of_Times1 card_of_Times2)
988   moreover
989   {have "|A \<times> B| \<le>o |A \<times> A| \<and> |B \<times> A| \<le>o |A \<times> A|"
990    using LEQ card_of_Times_mono1 card_of_Times_mono2 by blast
991    moreover have "|A \<times> A| =o |A|" using INF card_of_Times_same_infinite by blast
992    ultimately have "|A \<times> B| \<le>o |A| \<and> |B \<times> A| \<le>o |A|"
993    using ordLeq_ordIso_trans[of "|A \<times> B|"] ordLeq_ordIso_trans[of "|B \<times> A|"] by auto
994   }
995   ultimately show ?thesis by (simp add: ordIso_iff_ordLeq)
996 qed
998 corollary Card_order_Times_infinite:
999 assumes INF: "\<not>finite(Field r)" and CARD: "Card_order r" and
1000         NE: "Field p \<noteq> {}" and LEQ: "p \<le>o r"
1001 shows "| (Field r) \<times> (Field p) | =o r \<and> | (Field p) \<times> (Field r) | =o r"
1002 proof-
1003   have "|Field r \<times> Field p| =o |Field r| \<and> |Field p \<times> Field r| =o |Field r|"
1004   using assms by (simp add: card_of_Times_infinite card_of_mono2)
1005   thus ?thesis
1006   using assms card_of_Field_ordIso[of r]
1007         ordIso_transitive[of "|Field r \<times> Field p|"]
1008         ordIso_transitive[of _ "|Field r|"] by blast
1009 qed
1011 lemma card_of_Sigma_ordLeq_infinite:
1012 assumes INF: "\<not>finite B" and
1013         LEQ_I: "|I| \<le>o |B|" and LEQ: "\<forall>i \<in> I. |A i| \<le>o |B|"
1014 shows "|SIGMA i : I. A i| \<le>o |B|"
1015 proof(cases "I = {}", simp add: card_of_empty)
1016   assume *: "I \<noteq> {}"
1017   have "|SIGMA i : I. A i| \<le>o |I \<times> B|"
1018   using card_of_Sigma_mono1[OF LEQ] by blast
1019   moreover have "|I \<times> B| =o |B|"
1020   using INF * LEQ_I by (auto simp add: card_of_Times_infinite)
1021   ultimately show ?thesis using ordLeq_ordIso_trans by blast
1022 qed
1024 lemma card_of_Sigma_ordLeq_infinite_Field:
1025 assumes INF: "\<not>finite (Field r)" and r: "Card_order r" and
1026         LEQ_I: "|I| \<le>o r" and LEQ: "\<forall>i \<in> I. |A i| \<le>o r"
1027 shows "|SIGMA i : I. A i| \<le>o r"
1028 proof-
1029   let ?B  = "Field r"
1030   have 1: "r =o |?B| \<and> |?B| =o r" using r card_of_Field_ordIso
1031   ordIso_symmetric by blast
1032   hence "|I| \<le>o |?B|"  "\<forall>i \<in> I. |A i| \<le>o |?B|"
1033   using LEQ_I LEQ ordLeq_ordIso_trans by blast+
1034   hence  "|SIGMA i : I. A i| \<le>o |?B|" using INF LEQ
1035   card_of_Sigma_ordLeq_infinite by blast
1036   thus ?thesis using 1 ordLeq_ordIso_trans by blast
1037 qed
1039 lemma card_of_Times_ordLeq_infinite_Field:
1040 "\<lbrakk>\<not>finite (Field r); |A| \<le>o r; |B| \<le>o r; Card_order r\<rbrakk>
1041  \<Longrightarrow> |A \<times> B| \<le>o r"
1042 by(simp add: card_of_Sigma_ordLeq_infinite_Field)
1044 lemma card_of_Times_infinite_simps:
1045 "\<lbrakk>\<not>finite A; B \<noteq> {}; |B| \<le>o |A|\<rbrakk> \<Longrightarrow> |A \<times> B| =o |A|"
1046 "\<lbrakk>\<not>finite A; B \<noteq> {}; |B| \<le>o |A|\<rbrakk> \<Longrightarrow> |A| =o |A \<times> B|"
1047 "\<lbrakk>\<not>finite A; B \<noteq> {}; |B| \<le>o |A|\<rbrakk> \<Longrightarrow> |B \<times> A| =o |A|"
1048 "\<lbrakk>\<not>finite A; B \<noteq> {}; |B| \<le>o |A|\<rbrakk> \<Longrightarrow> |A| =o |B \<times> A|"
1049 by (auto simp add: card_of_Times_infinite ordIso_symmetric)
1051 lemma card_of_UNION_ordLeq_infinite:
1052 assumes INF: "\<not>finite B" and
1053         LEQ_I: "|I| \<le>o |B|" and LEQ: "\<forall>i \<in> I. |A i| \<le>o |B|"
1054 shows "|\<Union>i \<in> I. A i| \<le>o |B|"
1055 proof(cases "I = {}", simp add: card_of_empty)
1056   assume *: "I \<noteq> {}"
1057   have "|\<Union>i \<in> I. A i| \<le>o |SIGMA i : I. A i|"
1058   using card_of_UNION_Sigma by blast
1059   moreover have "|SIGMA i : I. A i| \<le>o |B|"
1060   using assms card_of_Sigma_ordLeq_infinite by blast
1061   ultimately show ?thesis using ordLeq_transitive by blast
1062 qed
1064 corollary card_of_UNION_ordLeq_infinite_Field:
1065 assumes INF: "\<not>finite (Field r)" and r: "Card_order r" and
1066         LEQ_I: "|I| \<le>o r" and LEQ: "\<forall>i \<in> I. |A i| \<le>o r"
1067 shows "|\<Union>i \<in> I. A i| \<le>o r"
1068 proof-
1069   let ?B  = "Field r"
1070   have 1: "r =o |?B| \<and> |?B| =o r" using r card_of_Field_ordIso
1071   ordIso_symmetric by blast
1072   hence "|I| \<le>o |?B|"  "\<forall>i \<in> I. |A i| \<le>o |?B|"
1073   using LEQ_I LEQ ordLeq_ordIso_trans by blast+
1074   hence  "|\<Union>i \<in> I. A i| \<le>o |?B|" using INF LEQ
1075   card_of_UNION_ordLeq_infinite by blast
1076   thus ?thesis using 1 ordLeq_ordIso_trans by blast
1077 qed
1079 lemma card_of_Plus_infinite1:
1080 assumes INF: "\<not>finite A" and LEQ: "|B| \<le>o |A|"
1081 shows "|A <+> B| =o |A|"
1082 proof(cases "B = {}", simp add: card_of_Plus_empty1 card_of_Plus_empty2 ordIso_symmetric)
1083   let ?Inl = "Inl::'a \<Rightarrow> 'a + 'b"  let ?Inr = "Inr::'b \<Rightarrow> 'a + 'b"
1084   assume *: "B \<noteq> {}"
1085   then obtain b1 where 1: "b1 \<in> B" by blast
1086   show ?thesis
1087   proof(cases "B = {b1}")
1088     assume Case1: "B = {b1}"
1089     have 2: "bij_betw ?Inl A ((?Inl  A))"
1090     unfolding bij_betw_def inj_on_def by auto
1091     hence 3: "\<not>finite (?Inl  A)"
1092     using INF bij_betw_finite[of ?Inl A] by blast
1093     let ?A' = "?Inl  A \<union> {?Inr b1}"
1094     obtain g where "bij_betw g (?Inl  A) ?A'"
1095     using 3 infinite_imp_bij_betw2[of "?Inl  A"] by auto
1096     moreover have "?A' = A <+> B" using Case1 by blast
1097     ultimately have "bij_betw g (?Inl  A) (A <+> B)" by simp
1098     hence "bij_betw (g o ?Inl) A (A <+> B)"
1099     using 2 by (auto simp add: bij_betw_trans)
1100     thus ?thesis using card_of_ordIso ordIso_symmetric by blast
1101   next
1102     assume Case2: "B \<noteq> {b1}"
1103     with * 1 obtain b2 where 3: "b1 \<noteq> b2 \<and> {b1,b2} \<le> B" by fastforce
1104     obtain f where "inj_on f B \<and> f  B \<le> A"
1105     using LEQ card_of_ordLeq[of B] by fastforce
1106     with 3 have "f b1 \<noteq> f b2 \<and> {f b1, f b2} \<le> A"
1107     unfolding inj_on_def by auto
1108     with 3 have "|A <+> B| \<le>o |A \<times> B|"
1109     by (auto simp add: card_of_Plus_Times)
1110     moreover have "|A \<times> B| =o |A|"
1111     using assms * by (simp add: card_of_Times_infinite_simps)
1112     ultimately have "|A <+> B| \<le>o |A|" using ordLeq_ordIso_trans by blast
1113     thus ?thesis using card_of_Plus1 ordIso_iff_ordLeq by blast
1114   qed
1115 qed
1117 lemma card_of_Plus_infinite2:
1118 assumes INF: "\<not>finite A" and LEQ: "|B| \<le>o |A|"
1119 shows "|B <+> A| =o |A|"
1120 using assms card_of_Plus_commute card_of_Plus_infinite1
1121 ordIso_equivalence by blast
1123 lemma card_of_Plus_infinite:
1124 assumes INF: "\<not>finite A" and LEQ: "|B| \<le>o |A|"
1125 shows "|A <+> B| =o |A| \<and> |B <+> A| =o |A|"
1126 using assms by (auto simp: card_of_Plus_infinite1 card_of_Plus_infinite2)
1128 corollary Card_order_Plus_infinite:
1129 assumes INF: "\<not>finite(Field r)" and CARD: "Card_order r" and
1130         LEQ: "p \<le>o r"
1131 shows "| (Field r) <+> (Field p) | =o r \<and> | (Field p) <+> (Field r) | =o r"
1132 proof-
1133   have "| Field r <+> Field p | =o | Field r | \<and>
1134         | Field p <+> Field r | =o | Field r |"
1135   using assms by (simp add: card_of_Plus_infinite card_of_mono2)
1136   thus ?thesis
1137   using assms card_of_Field_ordIso[of r]
1138         ordIso_transitive[of "|Field r <+> Field p|"]
1139         ordIso_transitive[of _ "|Field r|"] by blast
1140 qed
1143 subsection \<open>The cardinal $\omega$ and the finite cardinals\<close>
1145 text\<open>The cardinal $\omega$, of natural numbers, shall be the standard non-strict
1146 order relation on
1147 \<open>nat\<close>, that we abbreviate by \<open>natLeq\<close>.  The finite cardinals
1148 shall be the restrictions of these relations to the numbers smaller than
1149 fixed numbers \<open>n\<close>, that we abbreviate by \<open>natLeq_on n\<close>.\<close>
1151 definition "(natLeq::(nat * nat) set) \<equiv> {(x,y). x \<le> y}"
1152 definition "(natLess::(nat * nat) set) \<equiv> {(x,y). x < y}"
1154 abbreviation natLeq_on :: "nat \<Rightarrow> (nat * nat) set"
1155 where "natLeq_on n \<equiv> {(x,y). x < n \<and> y < n \<and> x \<le> y}"
1157 lemma infinite_cartesian_product:
1158 assumes "\<not>finite A" "\<not>finite B"
1159 shows "\<not>finite (A \<times> B)"
1160 proof
1161   assume "finite (A \<times> B)"
1162   from assms(1) have "A \<noteq> {}" by auto
1163   with \<open>finite (A \<times> B)\<close> have "finite B" using finite_cartesian_productD2 by auto
1164   with assms(2) show False by simp
1165 qed
1168 subsubsection \<open>First as well-orders\<close>
1170 lemma Field_natLeq: "Field natLeq = (UNIV::nat set)"
1171 by(unfold Field_def natLeq_def, auto)
1173 lemma natLeq_Refl: "Refl natLeq"
1174 unfolding refl_on_def Field_def natLeq_def by auto
1176 lemma natLeq_trans: "trans natLeq"
1177 unfolding trans_def natLeq_def by auto
1179 lemma natLeq_Preorder: "Preorder natLeq"
1180 unfolding preorder_on_def
1181 by (auto simp add: natLeq_Refl natLeq_trans)
1183 lemma natLeq_antisym: "antisym natLeq"
1184 unfolding antisym_def natLeq_def by auto
1186 lemma natLeq_Partial_order: "Partial_order natLeq"
1187 unfolding partial_order_on_def
1188 by (auto simp add: natLeq_Preorder natLeq_antisym)
1190 lemma natLeq_Total: "Total natLeq"
1191 unfolding total_on_def natLeq_def by auto
1193 lemma natLeq_Linear_order: "Linear_order natLeq"
1194 unfolding linear_order_on_def
1195 by (auto simp add: natLeq_Partial_order natLeq_Total)
1197 lemma natLeq_natLess_Id: "natLess = natLeq - Id"
1198 unfolding natLeq_def natLess_def by auto
1200 lemma natLeq_Well_order: "Well_order natLeq"
1201 unfolding well_order_on_def
1202 using natLeq_Linear_order wf_less natLeq_natLess_Id natLeq_def natLess_def by auto
1204 lemma Field_natLeq_on: "Field (natLeq_on n) = {x. x < n}"
1205 unfolding Field_def by auto
1207 lemma natLeq_underS_less: "underS natLeq n = {x. x < n}"
1208 unfolding underS_def natLeq_def by auto
1210 lemma Restr_natLeq: "Restr natLeq {x. x < n} = natLeq_on n"
1211 unfolding natLeq_def by force
1213 lemma Restr_natLeq2:
1214 "Restr natLeq (underS natLeq n) = natLeq_on n"
1215 by (auto simp add: Restr_natLeq natLeq_underS_less)
1217 lemma natLeq_on_Well_order: "Well_order(natLeq_on n)"
1218 using Restr_natLeq[of n] natLeq_Well_order
1219       Well_order_Restr[of natLeq "{x. x < n}"] by auto
1221 corollary natLeq_on_well_order_on: "well_order_on {x. x < n} (natLeq_on n)"
1222 using natLeq_on_Well_order Field_natLeq_on by auto
1224 lemma natLeq_on_wo_rel: "wo_rel(natLeq_on n)"
1225 unfolding wo_rel_def using natLeq_on_Well_order .
1228 subsubsection \<open>Then as cardinals\<close>
1230 lemma natLeq_Card_order: "Card_order natLeq"
1231 proof(auto simp add: natLeq_Well_order
1232       Card_order_iff_Restr_underS Restr_natLeq2, simp add:  Field_natLeq)
1233   fix n have "finite(Field (natLeq_on n))" by (auto simp: Field_def)
1234   moreover have "\<not>finite(UNIV::nat set)" by auto
1235   ultimately show "natLeq_on n <o |UNIV::nat set|"
1236   using finite_ordLess_infinite[of "natLeq_on n" "|UNIV::nat set|"]
1237         Field_card_of[of "UNIV::nat set"]
1238         card_of_Well_order[of "UNIV::nat set"] natLeq_on_Well_order[of n] by auto
1239 qed
1241 corollary card_of_Field_natLeq:
1242 "|Field natLeq| =o natLeq"
1243 using Field_natLeq natLeq_Card_order Card_order_iff_ordIso_card_of[of natLeq]
1244       ordIso_symmetric[of natLeq] by blast
1246 corollary card_of_nat:
1247 "|UNIV::nat set| =o natLeq"
1248 using Field_natLeq card_of_Field_natLeq by auto
1250 corollary infinite_iff_natLeq_ordLeq:
1251 "\<not>finite A = ( natLeq \<le>o |A| )"
1252 using infinite_iff_card_of_nat[of A] card_of_nat
1253       ordIso_ordLeq_trans ordLeq_ordIso_trans ordIso_symmetric by blast
1255 corollary finite_iff_ordLess_natLeq:
1256 "finite A = ( |A| <o natLeq)"
1257 using infinite_iff_natLeq_ordLeq not_ordLeq_iff_ordLess
1258       card_of_Well_order natLeq_Well_order by blast
1261 subsection \<open>The successor of a cardinal\<close>
1263 text\<open>First we define \<open>isCardSuc r r'\<close>, the notion of \<open>r'\<close>
1264 being a successor cardinal of \<open>r\<close>. Although the definition does
1265 not require \<open>r\<close> to be a cardinal, only this case will be meaningful.\<close>
1267 definition isCardSuc :: "'a rel \<Rightarrow> 'a set rel \<Rightarrow> bool"
1268 where
1269 "isCardSuc r r' \<equiv>
1270  Card_order r' \<and> r <o r' \<and>
1271  (\<forall>(r''::'a set rel). Card_order r'' \<and> r <o r'' \<longrightarrow> r' \<le>o r'')"
1273 text\<open>Now we introduce the cardinal-successor operator \<open>cardSuc\<close>,
1274 by picking {\em some} cardinal-order relation fulfilling \<open>isCardSuc\<close>.
1275 Again, the picked item shall be proved unique up to order-isomorphism.\<close>
1277 definition cardSuc :: "'a rel \<Rightarrow> 'a set rel"
1278 where
1279 "cardSuc r \<equiv> SOME r'. isCardSuc r r'"
1281 lemma exists_minim_Card_order:
1282 "\<lbrakk>R \<noteq> {}; \<forall>r \<in> R. Card_order r\<rbrakk> \<Longrightarrow> \<exists>r \<in> R. \<forall>r' \<in> R. r \<le>o r'"
1283 unfolding card_order_on_def using exists_minim_Well_order by blast
1285 lemma exists_isCardSuc:
1286 assumes "Card_order r"
1287 shows "\<exists>r'. isCardSuc r r'"
1288 proof-
1289   let ?R = "{(r'::'a set rel). Card_order r' \<and> r <o r'}"
1290   have "|Pow(Field r)| \<in> ?R \<and> (\<forall>r \<in> ?R. Card_order r)" using assms
1291   by (simp add: card_of_Card_order Card_order_Pow)
1292   then obtain r where "r \<in> ?R \<and> (\<forall>r' \<in> ?R. r \<le>o r')"
1293   using exists_minim_Card_order[of ?R] by blast
1294   thus ?thesis unfolding isCardSuc_def by auto
1295 qed
1297 lemma cardSuc_isCardSuc:
1298 assumes "Card_order r"
1299 shows "isCardSuc r (cardSuc r)"
1300 unfolding cardSuc_def using assms
1301 by (simp add: exists_isCardSuc someI_ex)
1303 lemma cardSuc_Card_order:
1304 "Card_order r \<Longrightarrow> Card_order(cardSuc r)"
1305 using cardSuc_isCardSuc unfolding isCardSuc_def by blast
1307 lemma cardSuc_greater:
1308 "Card_order r \<Longrightarrow> r <o cardSuc r"
1309 using cardSuc_isCardSuc unfolding isCardSuc_def by blast
1311 lemma cardSuc_ordLeq:
1312 "Card_order r \<Longrightarrow> r \<le>o cardSuc r"
1313 using cardSuc_greater ordLeq_iff_ordLess_or_ordIso by blast
1315 text\<open>The minimality property of \<open>cardSuc\<close> originally present in its definition
1316 is local to the type \<open>'a set rel\<close>, i.e., that of \<open>cardSuc r\<close>:\<close>
1318 lemma cardSuc_least_aux:
1319 "\<lbrakk>Card_order (r::'a rel); Card_order (r'::'a set rel); r <o r'\<rbrakk> \<Longrightarrow> cardSuc r \<le>o r'"
1320 using cardSuc_isCardSuc unfolding isCardSuc_def by blast
1322 text\<open>But from this we can infer general minimality:\<close>
1324 lemma cardSuc_least:
1325 assumes CARD: "Card_order r" and CARD': "Card_order r'" and LESS: "r <o r'"
1326 shows "cardSuc r \<le>o r'"
1327 proof-
1328   let ?p = "cardSuc r"
1329   have 0: "Well_order ?p \<and> Well_order r'"
1330   using assms cardSuc_Card_order unfolding card_order_on_def by blast
1331   {assume "r' <o ?p"
1332    then obtain r'' where 1: "Field r'' < Field ?p" and 2: "r' =o r'' \<and> r'' <o ?p"
1333    using internalize_ordLess[of r' ?p] by blast
1334    (*  *)
1335    have "Card_order r''" using CARD' Card_order_ordIso2 2 by blast
1336    moreover have "r <o r''" using LESS 2 ordLess_ordIso_trans by blast
1337    ultimately have "?p \<le>o r''" using cardSuc_least_aux CARD by blast
1338    hence False using 2 not_ordLess_ordLeq by blast
1339   }
1340   thus ?thesis using 0 ordLess_or_ordLeq by blast
1341 qed
1343 lemma cardSuc_ordLess_ordLeq:
1344 assumes CARD: "Card_order r" and CARD': "Card_order r'"
1345 shows "(r <o r') = (cardSuc r \<le>o r')"
1346 proof(auto simp add: assms cardSuc_least)
1347   assume "cardSuc r \<le>o r'"
1348   thus "r <o r'" using assms cardSuc_greater ordLess_ordLeq_trans by blast
1349 qed
1351 lemma cardSuc_ordLeq_ordLess:
1352 assumes CARD: "Card_order r" and CARD': "Card_order r'"
1353 shows "(r' <o cardSuc r) = (r' \<le>o r)"
1354 proof-
1355   have "Well_order r \<and> Well_order r'"
1356   using assms unfolding card_order_on_def by auto
1357   moreover have "Well_order(cardSuc r)"
1358   using assms cardSuc_Card_order card_order_on_def by blast
1359   ultimately show ?thesis
1360   using assms cardSuc_ordLess_ordLeq[of r r']
1361   not_ordLeq_iff_ordLess[of r r'] not_ordLeq_iff_ordLess[of r' "cardSuc r"] by blast
1362 qed
1364 lemma cardSuc_mono_ordLeq:
1365 assumes CARD: "Card_order r" and CARD': "Card_order r'"
1366 shows "(cardSuc r \<le>o cardSuc r') = (r \<le>o r')"
1367 using assms cardSuc_ordLeq_ordLess cardSuc_ordLess_ordLeq cardSuc_Card_order by blast
1369 lemma cardSuc_invar_ordIso:
1370 assumes CARD: "Card_order r" and CARD': "Card_order r'"
1371 shows "(cardSuc r =o cardSuc r') = (r =o r')"
1372 proof-
1373   have 0: "Well_order r \<and> Well_order r' \<and> Well_order(cardSuc r) \<and> Well_order(cardSuc r')"
1374   using assms by (simp add: card_order_on_well_order_on cardSuc_Card_order)
1375   thus ?thesis
1376   using ordIso_iff_ordLeq[of r r'] ordIso_iff_ordLeq
1377   using cardSuc_mono_ordLeq[of r r'] cardSuc_mono_ordLeq[of r' r] assms by blast
1378 qed
1380 lemma card_of_cardSuc_finite:
1381 "finite(Field(cardSuc |A| )) = finite A"
1382 proof
1383   assume *: "finite (Field (cardSuc |A| ))"
1384   have 0: "|Field(cardSuc |A| )| =o cardSuc |A|"
1385   using card_of_Card_order cardSuc_Card_order card_of_Field_ordIso by blast
1386   hence "|A| \<le>o |Field(cardSuc |A| )|"
1387   using card_of_Card_order[of A] cardSuc_ordLeq[of "|A|"] ordIso_symmetric
1388   ordLeq_ordIso_trans by blast
1389   thus "finite A" using * card_of_ordLeq_finite by blast
1390 next
1391   assume "finite A"
1392   then have "finite ( Field |Pow A| )" unfolding Field_card_of by simp
1393   then show "finite (Field (cardSuc |A| ))"
1394   proof (rule card_of_ordLeq_finite[OF card_of_mono2, rotated])
1395     show "cardSuc |A| \<le>o |Pow A|"
1396       by (rule iffD1[OF cardSuc_ordLess_ordLeq card_of_Pow]) (simp_all add: card_of_Card_order)
1397   qed
1398 qed
1400 lemma cardSuc_finite:
1401 assumes "Card_order r"
1402 shows "finite (Field (cardSuc r)) = finite (Field r)"
1403 proof-
1404   let ?A = "Field r"
1405   have "|?A| =o r" using assms by (simp add: card_of_Field_ordIso)
1406   hence "cardSuc |?A| =o cardSuc r" using assms
1407   by (simp add: card_of_Card_order cardSuc_invar_ordIso)
1408   moreover have "|Field (cardSuc |?A| ) | =o cardSuc |?A|"
1409   by (simp add: card_of_card_order_on Field_card_of card_of_Field_ordIso cardSuc_Card_order)
1410   moreover
1411   {have "|Field (cardSuc r) | =o cardSuc r"
1412    using assms by (simp add: card_of_Field_ordIso cardSuc_Card_order)
1413    hence "cardSuc r =o |Field (cardSuc r) |"
1414    using ordIso_symmetric by blast
1415   }
1416   ultimately have "|Field (cardSuc |?A| ) | =o |Field (cardSuc r) |"
1417   using ordIso_transitive by blast
1418   hence "finite (Field (cardSuc |?A| )) = finite (Field (cardSuc r))"
1419   using card_of_ordIso_finite by blast
1420   thus ?thesis by (simp only: card_of_cardSuc_finite)
1421 qed
1423 lemma card_of_Plus_ordLess_infinite:
1424 assumes INF: "\<not>finite C" and
1425         LESS1: "|A| <o |C|" and LESS2: "|B| <o |C|"
1426 shows "|A <+> B| <o |C|"
1427 proof(cases "A = {} \<or> B = {}")
1428   assume Case1: "A = {} \<or> B = {}"
1429   hence "|A| =o |A <+> B| \<or> |B| =o |A <+> B|"
1430   using card_of_Plus_empty1 card_of_Plus_empty2 by blast
1431   hence "|A <+> B| =o |A| \<or> |A <+> B| =o |B|"
1432   using ordIso_symmetric[of "|A|"] ordIso_symmetric[of "|B|"] by blast
1433   thus ?thesis using LESS1 LESS2
1434        ordIso_ordLess_trans[of "|A <+> B|" "|A|"]
1435        ordIso_ordLess_trans[of "|A <+> B|" "|B|"] by blast
1436 next
1437   assume Case2: "\<not>(A = {} \<or> B = {})"
1438   {assume *: "|C| \<le>o |A <+> B|"
1439    hence "\<not>finite (A <+> B)" using INF card_of_ordLeq_finite by blast
1440    hence 1: "\<not>finite A \<or> \<not>finite B" using finite_Plus by blast
1441    {assume Case21: "|A| \<le>o |B|"
1442     hence "\<not>finite B" using 1 card_of_ordLeq_finite by blast
1443     hence "|A <+> B| =o |B|" using Case2 Case21
1444     by (auto simp add: card_of_Plus_infinite)
1445     hence False using LESS2 not_ordLess_ordLeq * ordLeq_ordIso_trans by blast
1446    }
1447    moreover
1448    {assume Case22: "|B| \<le>o |A|"
1449     hence "\<not>finite A" using 1 card_of_ordLeq_finite by blast
1450     hence "|A <+> B| =o |A|" using Case2 Case22
1451     by (auto simp add: card_of_Plus_infinite)
1452     hence False using LESS1 not_ordLess_ordLeq * ordLeq_ordIso_trans by blast
1453    }
1454    ultimately have False using ordLeq_total card_of_Well_order[of A]
1455    card_of_Well_order[of B] by blast
1456   }
1457   thus ?thesis using ordLess_or_ordLeq[of "|A <+> B|" "|C|"]
1458   card_of_Well_order[of "A <+> B"] card_of_Well_order[of "C"] by auto
1459 qed
1461 lemma card_of_Plus_ordLess_infinite_Field:
1462 assumes INF: "\<not>finite (Field r)" and r: "Card_order r" and
1463         LESS1: "|A| <o r" and LESS2: "|B| <o r"
1464 shows "|A <+> B| <o r"
1465 proof-
1466   let ?C  = "Field r"
1467   have 1: "r =o |?C| \<and> |?C| =o r" using r card_of_Field_ordIso
1468   ordIso_symmetric by blast
1469   hence "|A| <o |?C|"  "|B| <o |?C|"
1470   using LESS1 LESS2 ordLess_ordIso_trans by blast+
1471   hence  "|A <+> B| <o |?C|" using INF
1472   card_of_Plus_ordLess_infinite by blast
1473   thus ?thesis using 1 ordLess_ordIso_trans by blast
1474 qed
1476 lemma card_of_Plus_ordLeq_infinite_Field:
1477 assumes r: "\<not>finite (Field r)" and A: "|A| \<le>o r" and B: "|B| \<le>o r"
1478 and c: "Card_order r"
1479 shows "|A <+> B| \<le>o r"
1480 proof-
1481   let ?r' = "cardSuc r"
1482   have "Card_order ?r' \<and> \<not>finite (Field ?r')" using assms
1483   by (simp add: cardSuc_Card_order cardSuc_finite)
1484   moreover have "|A| <o ?r'" and "|B| <o ?r'" using A B c
1485   by (auto simp: card_of_card_order_on Field_card_of cardSuc_ordLeq_ordLess)
1486   ultimately have "|A <+> B| <o ?r'"
1487   using card_of_Plus_ordLess_infinite_Field by blast
1488   thus ?thesis using c r
1489   by (simp add: card_of_card_order_on Field_card_of cardSuc_ordLeq_ordLess)
1490 qed
1492 lemma card_of_Un_ordLeq_infinite_Field:
1493 assumes C: "\<not>finite (Field r)" and A: "|A| \<le>o r" and B: "|B| \<le>o r"
1494 and "Card_order r"
1495 shows "|A Un B| \<le>o r"
1496 using assms card_of_Plus_ordLeq_infinite_Field card_of_Un_Plus_ordLeq
1497 ordLeq_transitive by fast
1500 subsection \<open>Regular cardinals\<close>
1502 definition cofinal where
1503 "cofinal A r \<equiv>
1504  ALL a : Field r. EX b : A. a \<noteq> b \<and> (a,b) : r"
1506 definition regularCard where
1507 "regularCard r \<equiv>
1508  ALL K. K \<le> Field r \<and> cofinal K r \<longrightarrow> |K| =o r"
1510 definition relChain where
1511 "relChain r As \<equiv>
1512  ALL i j. (i,j) \<in> r \<longrightarrow> As i \<le> As j"
1514 lemma regularCard_UNION:
1515 assumes r: "Card_order r"   "regularCard r"
1516 and As: "relChain r As"
1517 and Bsub: "B \<le> (UN i : Field r. As i)"
1518 and cardB: "|B| <o r"
1519 shows "EX i : Field r. B \<le> As i"
1520 proof-
1521   let ?phi = "%b j. j : Field r \<and> b : As j"
1522   have "ALL b : B. EX j. ?phi b j" using Bsub by blast
1523   then obtain f where f: "!! b. b : B \<Longrightarrow> ?phi b (f b)"
1524   using bchoice[of B ?phi] by blast
1525   let ?K = "f  B"
1526   {assume 1: "!! i. i : Field r \<Longrightarrow> ~ B \<le> As i"
1527    have 2: "cofinal ?K r"
1528    unfolding cofinal_def proof auto
1529      fix i assume i: "i : Field r"
1530      with 1 obtain b where b: "b : B \<and> b \<notin> As i" by blast
1531      hence "i \<noteq> f b \<and> ~ (f b,i) : r"
1532      using As f unfolding relChain_def by auto
1533      hence "i \<noteq> f b \<and> (i, f b) : r" using r
1534      unfolding card_order_on_def well_order_on_def linear_order_on_def
1535      total_on_def using i f b by auto
1536      with b show "\<exists>b\<in>B. i \<noteq> f b \<and> (i, f b) \<in> r" by blast
1537    qed
1538    moreover have "?K \<le> Field r" using f by blast
1539    ultimately have "|?K| =o r" using 2 r unfolding regularCard_def by blast
1540    moreover
1541    {
1542     have "|?K| <=o |B|" using card_of_image .
1543     hence "|?K| <o r" using cardB ordLeq_ordLess_trans by blast
1544    }
1545    ultimately have False using not_ordLess_ordIso by blast
1546   }
1547   thus ?thesis by blast
1548 qed
1550 lemma infinite_cardSuc_regularCard:
1551 assumes r_inf: "\<not>finite (Field r)" and r_card: "Card_order r"
1552 shows "regularCard (cardSuc r)"
1553 proof-
1554   let ?r' = "cardSuc r"
1555   have r': "Card_order ?r'"
1556   "!! p. Card_order p \<longrightarrow> (p \<le>o r) = (p <o ?r')"
1557   using r_card by (auto simp: cardSuc_Card_order cardSuc_ordLeq_ordLess)
1558   show ?thesis
1559   unfolding regularCard_def proof auto
1560     fix K assume 1: "K \<le> Field ?r'" and 2: "cofinal K ?r'"
1561     hence "|K| \<le>o |Field ?r'|" by (simp only: card_of_mono1)
1562     also have 22: "|Field ?r'| =o ?r'"
1563     using r' by (simp add: card_of_Field_ordIso[of ?r'])
1564     finally have "|K| \<le>o ?r'" .
1565     moreover
1566     {let ?L = "UN j : K. underS ?r' j"
1567      let ?J = "Field r"
1568      have rJ: "r =o |?J|"
1569      using r_card card_of_Field_ordIso ordIso_symmetric by blast
1570      assume "|K| <o ?r'"
1571      hence "|K| <=o r" using r' card_of_Card_order[of K] by blast
1572      hence "|K| \<le>o |?J|" using rJ ordLeq_ordIso_trans by blast
1573      moreover
1574      {have "ALL j : K. |underS ?r' j| <o ?r'"
1575       using r' 1 by (auto simp: card_of_underS)
1576       hence "ALL j : K. |underS ?r' j| \<le>o r"
1577       using r' card_of_Card_order by blast
1578       hence "ALL j : K. |underS ?r' j| \<le>o |?J|"
1579       using rJ ordLeq_ordIso_trans by blast
1580      }
1581      ultimately have "|?L| \<le>o |?J|"
1582      using r_inf card_of_UNION_ordLeq_infinite by blast
1583      hence "|?L| \<le>o r" using rJ ordIso_symmetric ordLeq_ordIso_trans by blast
1584      hence "|?L| <o ?r'" using r' card_of_Card_order by blast
1585      moreover
1586      {
1587       have "Field ?r' \<le> ?L"
1588       using 2 unfolding underS_def cofinal_def by auto
1589       hence "|Field ?r'| \<le>o |?L|" by (simp add: card_of_mono1)
1590       hence "?r' \<le>o |?L|"
1591       using 22 ordIso_ordLeq_trans ordIso_symmetric by blast
1592      }
1593      ultimately have "|?L| <o |?L|" using ordLess_ordLeq_trans by blast
1594      hence False using ordLess_irreflexive by blast
1595     }
1596     ultimately show "|K| =o ?r'"
1597     unfolding ordLeq_iff_ordLess_or_ordIso by blast
1598   qed
1599 qed
1601 lemma cardSuc_UNION:
1602 assumes r: "Card_order r" and "\<not>finite (Field r)"
1603 and As: "relChain (cardSuc r) As"
1604 and Bsub: "B \<le> (UN i : Field (cardSuc r). As i)"
1605 and cardB: "|B| <=o r"
1606 shows "EX i : Field (cardSuc r). B \<le> As i"
1607 proof-
1608   let ?r' = "cardSuc r"
1609   have "Card_order ?r' \<and> |B| <o ?r'"
1610   using r cardB cardSuc_ordLeq_ordLess cardSuc_Card_order
1611   card_of_Card_order by blast
1612   moreover have "regularCard ?r'"
1613   using assms by(simp add: infinite_cardSuc_regularCard)
1614   ultimately show ?thesis
1615   using As Bsub cardB regularCard_UNION by blast
1616 qed
1619 subsection \<open>Others\<close>
1621 lemma card_of_Func_Times:
1622 "|Func (A \<times> B) C| =o |Func A (Func B C)|"
1623 unfolding card_of_ordIso[symmetric]
1624 using bij_betw_curr by blast
1626 lemma card_of_Pow_Func:
1627 "|Pow A| =o |Func A (UNIV::bool set)|"
1628 proof-
1629   def F \<equiv> "\<lambda> A' a. if a \<in> A then (if a \<in> A' then True else False)
1630                             else undefined"
1631   have "bij_betw F (Pow A) (Func A (UNIV::bool set))"
1632   unfolding bij_betw_def inj_on_def proof (intro ballI impI conjI)
1633     fix A1 A2 assume "A1 \<in> Pow A" "A2 \<in> Pow A" "F A1 = F A2"
1634     thus "A1 = A2" unfolding F_def Pow_def fun_eq_iff by (auto split: split_if_asm)
1635   next
1636     show "F  Pow A = Func A UNIV"
1637     proof safe
1638       fix f assume f: "f \<in> Func A (UNIV::bool set)"
1639       show "f \<in> F  Pow A" unfolding image_def mem_Collect_eq proof(intro bexI)
1640         let ?A1 = "{a \<in> A. f a = True}"
1641         show "f = F ?A1" unfolding F_def apply(rule ext)
1642         using f unfolding Func_def mem_Collect_eq by auto
1643       qed auto
1644     qed(unfold Func_def mem_Collect_eq F_def, auto)
1645   qed
1646   thus ?thesis unfolding card_of_ordIso[symmetric] by blast
1647 qed
1649 lemma card_of_Func_UNIV:
1650 "|Func (UNIV::'a set) (B::'b set)| =o |{f::'a \<Rightarrow> 'b. range f \<subseteq> B}|"
1651 apply(rule ordIso_symmetric) proof(intro card_of_ordIsoI)
1652   let ?F = "\<lambda> f (a::'a). ((f a)::'b)"
1653   show "bij_betw ?F {f. range f \<subseteq> B} (Func UNIV B)"
1654   unfolding bij_betw_def inj_on_def proof safe
1655     fix h :: "'a \<Rightarrow> 'b" assume h: "h \<in> Func UNIV B"
1656     hence "\<forall> a. \<exists> b. h a = b" unfolding Func_def by auto
1657     then obtain f where f: "\<forall> a. h a = f a" by blast
1658     hence "range f \<subseteq> B" using h unfolding Func_def by auto
1659     thus "h \<in> (\<lambda>f a. f a)  {f. range f \<subseteq> B}" using f by auto
1660   qed(unfold Func_def fun_eq_iff, auto)
1661 qed
1663 lemma Func_Times_Range:
1664   "|Func A (B \<times> C)| =o |Func A B \<times> Func A C|" (is "|?LHS| =o |?RHS|")
1665 proof -
1666   let ?F = "\<lambda>fg. (\<lambda>x. if x \<in> A then fst (fg x) else undefined,
1667                   \<lambda>x. if x \<in> A then snd (fg x) else undefined)"
1668   let ?G = "\<lambda>(f, g) x. if x \<in> A then (f x, g x) else undefined"
1669   have "bij_betw ?F ?LHS ?RHS" unfolding bij_betw_def inj_on_def
1670   proof (intro conjI impI ballI equalityI subsetI)
1671     fix f g assume *: "f \<in> Func A (B \<times> C)" "g \<in> Func A (B \<times> C)" "?F f = ?F g"
1672     show "f = g"
1673     proof
1674       fix x from * have "fst (f x) = fst (g x) \<and> snd (f x) = snd (g x)"
1675         by (case_tac "x \<in> A") (auto simp: Func_def fun_eq_iff split: if_splits)
1676       then show "f x = g x" by (subst (1 2) surjective_pairing) simp
1677     qed
1678   next
1679     fix fg assume "fg \<in> Func A B \<times> Func A C"
1680     thus "fg \<in> ?F ` Func A (B \<times> C)"
1681       by (intro image_eqI[of _ _ "?G fg"]) (auto simp: Func_def)
1682   qed (auto simp: Func_def fun_eq_iff)
1683   thus ?thesis using card_of_ordIso by blast
1684 qed
1686 end