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