src/HOL/Cardinals/Cardinal_Order_Relation.thy
author wenzelm
Fri Oct 27 13:50:08 2017 +0200 (23 months ago)
changeset 66924 b4d4027f743b
parent 66453 cc19f7ca2ed6
child 67613 ce654b0e6d69
permissions -rw-r--r--
more permissive;
blanchet@49310
     1
(*  Title:      HOL/Cardinals/Cardinal_Order_Relation.thy
blanchet@48975
     2
    Author:     Andrei Popescu, TU Muenchen
blanchet@48975
     3
    Copyright   2012
blanchet@48975
     4
blanchet@48975
     5
Cardinal-order relations.
blanchet@48975
     6
*)
blanchet@48975
     7
wenzelm@63167
     8
section \<open>Cardinal-Order Relations\<close>
blanchet@48975
     9
blanchet@48975
    10
theory Cardinal_Order_Relation
wenzelm@66453
    11
imports HOL.BNF_Cardinal_Order_Relation Wellorder_Constructions
blanchet@48975
    12
begin
blanchet@48975
    13
blanchet@48975
    14
declare
blanchet@48975
    15
  card_order_on_well_order_on[simp]
blanchet@48975
    16
  card_of_card_order_on[simp]
blanchet@48975
    17
  card_of_well_order_on[simp]
blanchet@48975
    18
  Field_card_of[simp]
blanchet@48975
    19
  card_of_Card_order[simp]
blanchet@48975
    20
  card_of_Well_order[simp]
blanchet@48975
    21
  card_of_least[simp]
blanchet@48975
    22
  card_of_unique[simp]
blanchet@48975
    23
  card_of_mono1[simp]
blanchet@48975
    24
  card_of_mono2[simp]
blanchet@48975
    25
  card_of_cong[simp]
blanchet@48975
    26
  card_of_Field_ordLess[simp]
blanchet@48975
    27
  card_of_Field_ordIso[simp]
blanchet@48975
    28
  card_of_underS[simp]
blanchet@48975
    29
  ordLess_Field[simp]
blanchet@48975
    30
  card_of_empty[simp]
blanchet@48975
    31
  card_of_empty1[simp]
blanchet@48975
    32
  card_of_image[simp]
blanchet@48975
    33
  card_of_singl_ordLeq[simp]
blanchet@48975
    34
  Card_order_singl_ordLeq[simp]
blanchet@48975
    35
  card_of_Pow[simp]
blanchet@48975
    36
  Card_order_Pow[simp]
blanchet@48975
    37
  card_of_Plus1[simp]
blanchet@48975
    38
  Card_order_Plus1[simp]
blanchet@48975
    39
  card_of_Plus2[simp]
blanchet@48975
    40
  Card_order_Plus2[simp]
blanchet@48975
    41
  card_of_Plus_mono1[simp]
blanchet@48975
    42
  card_of_Plus_mono2[simp]
blanchet@48975
    43
  card_of_Plus_mono[simp]
blanchet@48975
    44
  card_of_Plus_cong2[simp]
blanchet@48975
    45
  card_of_Plus_cong[simp]
blanchet@48975
    46
  card_of_Un_Plus_ordLeq[simp]
blanchet@48975
    47
  card_of_Times1[simp]
blanchet@48975
    48
  card_of_Times2[simp]
blanchet@48975
    49
  card_of_Times3[simp]
blanchet@48975
    50
  card_of_Times_mono1[simp]
blanchet@48975
    51
  card_of_Times_mono2[simp]
blanchet@48975
    52
  card_of_ordIso_finite[simp]
blanchet@48975
    53
  card_of_Times_same_infinite[simp]
blanchet@48975
    54
  card_of_Times_infinite_simps[simp]
blanchet@48975
    55
  card_of_Plus_infinite1[simp]
blanchet@48975
    56
  card_of_Plus_infinite2[simp]
blanchet@48975
    57
  card_of_Plus_ordLess_infinite[simp]
blanchet@48975
    58
  card_of_Plus_ordLess_infinite_Field[simp]
blanchet@48975
    59
  infinite_cartesian_product[simp]
blanchet@48975
    60
  cardSuc_Card_order[simp]
blanchet@48975
    61
  cardSuc_greater[simp]
blanchet@48975
    62
  cardSuc_ordLeq[simp]
blanchet@48975
    63
  cardSuc_ordLeq_ordLess[simp]
blanchet@48975
    64
  cardSuc_mono_ordLeq[simp]
blanchet@48975
    65
  cardSuc_invar_ordIso[simp]
blanchet@48975
    66
  card_of_cardSuc_finite[simp]
blanchet@48975
    67
  cardSuc_finite[simp]
blanchet@48975
    68
  card_of_Plus_ordLeq_infinite_Field[simp]
blanchet@48975
    69
  curr_in[intro, simp]
blanchet@48975
    70
blanchet@48975
    71
wenzelm@63167
    72
subsection \<open>Cardinal of a set\<close>
blanchet@48975
    73
blanchet@48975
    74
lemma card_of_inj_rel: assumes INJ: "!! x y y'. \<lbrakk>(x,y) : R; (x,y') : R\<rbrakk> \<Longrightarrow> y = y'"
blanchet@48975
    75
shows "|{y. EX x. (x,y) : R}| <=o |{x. EX y. (x,y) : R}|"
blanchet@48975
    76
proof-
blanchet@48975
    77
  let ?Y = "{y. EX x. (x,y) : R}"  let ?X = "{x. EX y. (x,y) : R}"
blanchet@48975
    78
  let ?f = "% y. SOME x. (x,y) : R"
traytel@51764
    79
  have "?f ` ?Y <= ?X" by (auto dest: someI)
blanchet@48975
    80
  moreover have "inj_on ?f ?Y"
blanchet@48975
    81
  unfolding inj_on_def proof(auto)
blanchet@48975
    82
    fix y1 x1 y2 x2
blanchet@48975
    83
    assume *: "(x1, y1) \<in> R" "(x2, y2) \<in> R" and **: "?f y1 = ?f y2"
blanchet@48975
    84
    hence "(?f y1,y1) : R" using someI[of "% x. (x,y1) : R"] by auto
blanchet@48975
    85
    moreover have "(?f y2,y2) : R" using * someI[of "% x. (x,y2) : R"] by auto
blanchet@48975
    86
    ultimately show "y1 = y2" using ** INJ by auto
blanchet@48975
    87
  qed
blanchet@48975
    88
  ultimately show "|?Y| <=o |?X|" using card_of_ordLeq by blast
blanchet@48975
    89
qed
blanchet@48975
    90
blanchet@48975
    91
lemma card_of_unique2: "\<lbrakk>card_order_on B r; bij_betw f A B\<rbrakk> \<Longrightarrow> r =o |A|"
blanchet@48975
    92
using card_of_ordIso card_of_unique ordIso_equivalence by blast
blanchet@48975
    93
blanchet@48975
    94
lemma internalize_card_of_ordLess:
blanchet@48975
    95
"( |A| <o r) = (\<exists>B < Field r. |A| =o |B| \<and> |B| <o r)"
blanchet@48975
    96
proof
blanchet@48975
    97
  assume "|A| <o r"
blanchet@48975
    98
  then obtain p where 1: "Field p < Field r \<and> |A| =o p \<and> p <o r"
blanchet@48975
    99
  using internalize_ordLess[of "|A|" r] by blast
blanchet@48975
   100
  hence "Card_order p" using card_of_Card_order Card_order_ordIso2 by blast
blanchet@48975
   101
  hence "|Field p| =o p" using card_of_Field_ordIso by blast
blanchet@48975
   102
  hence "|A| =o |Field p| \<and> |Field p| <o r"
blanchet@48975
   103
  using 1 ordIso_equivalence ordIso_ordLess_trans by blast
blanchet@48975
   104
  thus "\<exists>B < Field r. |A| =o |B| \<and> |B| <o r" using 1 by blast
blanchet@48975
   105
next
blanchet@48975
   106
  assume "\<exists>B < Field r. |A| =o |B| \<and> |B| <o r"
blanchet@48975
   107
  thus "|A| <o r" using ordIso_ordLess_trans by blast
blanchet@48975
   108
qed
blanchet@48975
   109
blanchet@48975
   110
lemma internalize_card_of_ordLess2:
blanchet@48975
   111
"( |A| <o |C| ) = (\<exists>B < C. |A| =o |B| \<and> |B| <o |C| )"
blanchet@48975
   112
using internalize_card_of_ordLess[of "A" "|C|"] Field_card_of[of C] by auto
blanchet@48975
   113
blanchet@48975
   114
lemma Card_order_omax:
blanchet@48975
   115
assumes "finite R" and "R \<noteq> {}" and "\<forall>r\<in>R. Card_order r"
blanchet@48975
   116
shows "Card_order (omax R)"
blanchet@48975
   117
proof-
blanchet@48975
   118
  have "\<forall>r\<in>R. Well_order r"
blanchet@48975
   119
  using assms unfolding card_order_on_def by simp
blanchet@48975
   120
  thus ?thesis using assms apply - apply(drule omax_in) by auto
blanchet@48975
   121
qed
blanchet@48975
   122
blanchet@48975
   123
lemma Card_order_omax2:
blanchet@48975
   124
assumes "finite I" and "I \<noteq> {}"
blanchet@48975
   125
shows "Card_order (omax {|A i| | i. i \<in> I})"
blanchet@48975
   126
proof-
blanchet@48975
   127
  let ?R = "{|A i| | i. i \<in> I}"
blanchet@48975
   128
  have "finite ?R" and "?R \<noteq> {}" using assms by auto
blanchet@48975
   129
  moreover have "\<forall>r\<in>?R. Card_order r"
blanchet@48975
   130
  using card_of_Card_order by auto
blanchet@48975
   131
  ultimately show ?thesis by(rule Card_order_omax)
blanchet@48975
   132
qed
blanchet@48975
   133
blanchet@48975
   134
wenzelm@63167
   135
subsection \<open>Cardinals versus set operations on arbitrary sets\<close>
blanchet@48975
   136
blanchet@54481
   137
lemma card_of_set_type[simp]: "|UNIV::'a set| <o |UNIV::'a set set|"
blanchet@54475
   138
using card_of_Pow[of "UNIV::'a set"] by simp
blanchet@54475
   139
blanchet@54475
   140
lemma card_of_Un1[simp]:
blanchet@54475
   141
shows "|A| \<le>o |A \<union> B| "
blanchet@54475
   142
using inj_on_id[of A] card_of_ordLeq[of A _] by fastforce
blanchet@54475
   143
blanchet@54475
   144
lemma card_of_diff[simp]:
blanchet@54475
   145
shows "|A - B| \<le>o |A|"
blanchet@54475
   146
using inj_on_id[of "A - B"] card_of_ordLeq[of "A - B" _] by fastforce
blanchet@54475
   147
blanchet@48975
   148
lemma subset_ordLeq_strict:
blanchet@48975
   149
assumes "A \<le> B" and "|A| <o |B|"
blanchet@48975
   150
shows "A < B"
blanchet@48975
   151
proof-
blanchet@48975
   152
  {assume "\<not>(A < B)"
blanchet@48975
   153
   hence "A = B" using assms(1) by blast
blanchet@48975
   154
   hence False using assms(2) not_ordLess_ordIso card_of_refl by blast
blanchet@48975
   155
  }
blanchet@48975
   156
  thus ?thesis by blast
blanchet@48975
   157
qed
blanchet@48975
   158
blanchet@48975
   159
corollary subset_ordLeq_diff:
blanchet@48975
   160
assumes "A \<le> B" and "|A| <o |B|"
blanchet@48975
   161
shows "B - A \<noteq> {}"
blanchet@48975
   162
using assms subset_ordLeq_strict by blast
blanchet@48975
   163
blanchet@48975
   164
lemma card_of_empty4:
blanchet@48975
   165
"|{}::'b set| <o |A::'a set| = (A \<noteq> {})"
blanchet@48975
   166
proof(intro iffI notI)
blanchet@48975
   167
  assume *: "|{}::'b set| <o |A|" and "A = {}"
blanchet@48975
   168
  hence "|A| =o |{}::'b set|"
blanchet@48975
   169
  using card_of_ordIso unfolding bij_betw_def inj_on_def by blast
blanchet@48975
   170
  hence "|{}::'b set| =o |A|" using ordIso_symmetric by blast
blanchet@48975
   171
  with * show False using not_ordLess_ordIso[of "|{}::'b set|" "|A|"] by blast
blanchet@48975
   172
next
blanchet@48975
   173
  assume "A \<noteq> {}"
blanchet@48975
   174
  hence "(\<not> (\<exists>f. inj_on f A \<and> f ` A \<subseteq> {}))"
blanchet@48975
   175
  unfolding inj_on_def by blast
blanchet@48975
   176
  thus "| {} | <o | A |"
blanchet@48975
   177
  using card_of_ordLess by blast
blanchet@48975
   178
qed
blanchet@48975
   179
blanchet@48975
   180
lemma card_of_empty5:
blanchet@48975
   181
"|A| <o |B| \<Longrightarrow> B \<noteq> {}"
blanchet@48975
   182
using card_of_empty not_ordLess_ordLeq by blast
blanchet@48975
   183
blanchet@48975
   184
lemma Well_order_card_of_empty:
blanchet@48975
   185
"Well_order r \<Longrightarrow> |{}| \<le>o r" by simp
blanchet@48975
   186
blanchet@48975
   187
lemma card_of_UNIV[simp]:
blanchet@48975
   188
"|A :: 'a set| \<le>o |UNIV :: 'a set|"
blanchet@48975
   189
using card_of_mono1[of A] by simp
blanchet@48975
   190
blanchet@48975
   191
lemma card_of_UNIV2[simp]:
blanchet@48975
   192
"Card_order r \<Longrightarrow> (r :: 'a rel) \<le>o |UNIV :: 'a set|"
blanchet@48975
   193
using card_of_UNIV[of "Field r"] card_of_Field_ordIso
blanchet@48975
   194
      ordIso_symmetric ordIso_ordLeq_trans by blast
blanchet@48975
   195
blanchet@48975
   196
lemma card_of_Pow_mono[simp]:
blanchet@48975
   197
assumes "|A| \<le>o |B|"
blanchet@48975
   198
shows "|Pow A| \<le>o |Pow B|"
blanchet@48975
   199
proof-
blanchet@48975
   200
  obtain f where "inj_on f A \<and> f ` A \<le> B"
blanchet@48975
   201
  using assms card_of_ordLeq[of A B] by auto
blanchet@48975
   202
  hence "inj_on (image f) (Pow A) \<and> (image f) ` (Pow A) \<le> (Pow B)"
blanchet@48975
   203
  by (auto simp add: inj_on_image_Pow image_Pow_mono)
blanchet@48975
   204
  thus ?thesis using card_of_ordLeq[of "Pow A"] by metis
blanchet@48975
   205
qed
blanchet@48975
   206
blanchet@48975
   207
lemma ordIso_Pow_mono[simp]:
blanchet@48975
   208
assumes "r \<le>o r'"
blanchet@48975
   209
shows "|Pow(Field r)| \<le>o |Pow(Field r')|"
blanchet@48975
   210
using assms card_of_mono2 card_of_Pow_mono by blast
blanchet@48975
   211
blanchet@48975
   212
lemma card_of_Pow_cong[simp]:
blanchet@48975
   213
assumes "|A| =o |B|"
blanchet@48975
   214
shows "|Pow A| =o |Pow B|"
blanchet@48975
   215
proof-
blanchet@48975
   216
  obtain f where "bij_betw f A B"
blanchet@48975
   217
  using assms card_of_ordIso[of A B] by auto
blanchet@48975
   218
  hence "bij_betw (image f) (Pow A) (Pow B)"
blanchet@48975
   219
  by (auto simp add: bij_betw_image_Pow)
blanchet@48975
   220
  thus ?thesis using card_of_ordIso[of "Pow A"] by auto
blanchet@48975
   221
qed
blanchet@48975
   222
blanchet@48975
   223
lemma ordIso_Pow_cong[simp]:
blanchet@48975
   224
assumes "r =o r'"
blanchet@48975
   225
shows "|Pow(Field r)| =o |Pow(Field r')|"
blanchet@48975
   226
using assms card_of_cong card_of_Pow_cong by blast
blanchet@48975
   227
blanchet@48975
   228
corollary Card_order_Plus_empty1:
blanchet@48975
   229
"Card_order r \<Longrightarrow> r =o |(Field r) <+> {}|"
blanchet@48975
   230
using card_of_Plus_empty1 card_of_Field_ordIso ordIso_equivalence by blast
blanchet@48975
   231
blanchet@48975
   232
corollary Card_order_Plus_empty2:
blanchet@48975
   233
"Card_order r \<Longrightarrow> r =o |{} <+> (Field r)|"
blanchet@48975
   234
using card_of_Plus_empty2 card_of_Field_ordIso ordIso_equivalence by blast
blanchet@48975
   235
blanchet@48975
   236
lemma Card_order_Un1:
blanchet@48975
   237
shows "Card_order r \<Longrightarrow> |Field r| \<le>o |(Field r) \<union> B| "
blanchet@48975
   238
using card_of_Un1 card_of_Field_ordIso ordIso_symmetric ordIso_ordLeq_trans by auto
blanchet@48975
   239
blanchet@48975
   240
lemma card_of_Un2[simp]:
blanchet@48975
   241
shows "|A| \<le>o |B \<union> A|"
blanchet@48975
   242
using inj_on_id[of A] card_of_ordLeq[of A _] by fastforce
blanchet@48975
   243
blanchet@48975
   244
lemma Card_order_Un2:
blanchet@48975
   245
shows "Card_order r \<Longrightarrow> |Field r| \<le>o |A \<union> (Field r)| "
blanchet@48975
   246
using card_of_Un2 card_of_Field_ordIso ordIso_symmetric ordIso_ordLeq_trans by auto
blanchet@48975
   247
blanchet@48975
   248
lemma Un_Plus_bij_betw:
blanchet@48975
   249
assumes "A Int B = {}"
blanchet@48975
   250
shows "\<exists>f. bij_betw f (A \<union> B) (A <+> B)"
blanchet@48975
   251
proof-
blanchet@48975
   252
  let ?f = "\<lambda> c. if c \<in> A then Inl c else Inr c"
blanchet@48975
   253
  have "bij_betw ?f (A \<union> B) (A <+> B)"
blanchet@48975
   254
  using assms by(unfold bij_betw_def inj_on_def, auto)
blanchet@48975
   255
  thus ?thesis by blast
blanchet@48975
   256
qed
blanchet@48975
   257
blanchet@48975
   258
lemma card_of_Un_Plus_ordIso:
blanchet@48975
   259
assumes "A Int B = {}"
blanchet@48975
   260
shows "|A \<union> B| =o |A <+> B|"
blanchet@48975
   261
using assms card_of_ordIso[of "A \<union> B"] Un_Plus_bij_betw[of A B] by auto
blanchet@48975
   262
blanchet@48975
   263
lemma card_of_Un_Plus_ordIso1:
blanchet@48975
   264
"|A \<union> B| =o |A <+> (B - A)|"
blanchet@48975
   265
using card_of_Un_Plus_ordIso[of A "B - A"] by auto
blanchet@48975
   266
blanchet@48975
   267
lemma card_of_Un_Plus_ordIso2:
blanchet@48975
   268
"|A \<union> B| =o |(A - B) <+> B|"
blanchet@48975
   269
using card_of_Un_Plus_ordIso[of "A - B" B] by auto
blanchet@48975
   270
blanchet@48975
   271
lemma card_of_Times_singl1: "|A| =o |A \<times> {b}|"
blanchet@48975
   272
proof-
blanchet@48975
   273
  have "bij_betw fst (A \<times> {b}) A" unfolding bij_betw_def inj_on_def by force
blanchet@48975
   274
  thus ?thesis using card_of_ordIso ordIso_symmetric by blast
blanchet@48975
   275
qed
blanchet@48975
   276
blanchet@48975
   277
corollary Card_order_Times_singl1:
blanchet@48975
   278
"Card_order r \<Longrightarrow> r =o |(Field r) \<times> {b}|"
blanchet@48975
   279
using card_of_Times_singl1[of _ b] card_of_Field_ordIso ordIso_equivalence by blast
blanchet@48975
   280
blanchet@48975
   281
lemma card_of_Times_singl2: "|A| =o |{b} \<times> A|"
blanchet@48975
   282
proof-
blanchet@48975
   283
  have "bij_betw snd ({b} \<times> A) A" unfolding bij_betw_def inj_on_def by force
blanchet@48975
   284
  thus ?thesis using card_of_ordIso ordIso_symmetric by blast
blanchet@48975
   285
qed
blanchet@48975
   286
blanchet@48975
   287
corollary Card_order_Times_singl2:
blanchet@48975
   288
"Card_order r \<Longrightarrow> r =o |{a} \<times> (Field r)|"
blanchet@48975
   289
using card_of_Times_singl2[of _ a] card_of_Field_ordIso ordIso_equivalence by blast
blanchet@48975
   290
blanchet@48975
   291
lemma card_of_Times_assoc: "|(A \<times> B) \<times> C| =o |A \<times> B \<times> C|"
blanchet@48975
   292
proof -
blanchet@48975
   293
  let ?f = "\<lambda>((a,b),c). (a,(b,c))"
blanchet@48975
   294
  have "A \<times> B \<times> C \<subseteq> ?f ` ((A \<times> B) \<times> C)"
blanchet@48975
   295
  proof
blanchet@48975
   296
    fix x assume "x \<in> A \<times> B \<times> C"
blanchet@48975
   297
    then obtain a b c where *: "a \<in> A" "b \<in> B" "c \<in> C" "x = (a, b, c)" by blast
blanchet@48975
   298
    let ?x = "((a, b), c)"
blanchet@48975
   299
    from * have "?x \<in> (A \<times> B) \<times> C" "x = ?f ?x" by auto
blanchet@48975
   300
    thus "x \<in> ?f ` ((A \<times> B) \<times> C)" by blast
blanchet@48975
   301
  qed
blanchet@48975
   302
  hence "bij_betw ?f ((A \<times> B) \<times> C) (A \<times> B \<times> C)"
blanchet@48975
   303
  unfolding bij_betw_def inj_on_def by auto
blanchet@48975
   304
  thus ?thesis using card_of_ordIso by blast
blanchet@48975
   305
qed
blanchet@48975
   306
blanchet@48975
   307
corollary Card_order_Times3:
blanchet@48975
   308
"Card_order r \<Longrightarrow> |Field r| \<le>o |(Field r) \<times> (Field r)|"
traytel@54578
   309
  by (rule card_of_Times3)
blanchet@48975
   310
blanchet@54475
   311
lemma card_of_Times_cong1[simp]:
blanchet@54475
   312
assumes "|A| =o |B|"
blanchet@54475
   313
shows "|A \<times> C| =o |B \<times> C|"
traytel@54578
   314
using assms by (simp add: ordIso_iff_ordLeq)
blanchet@54475
   315
blanchet@54475
   316
lemma card_of_Times_cong2[simp]:
blanchet@54475
   317
assumes "|A| =o |B|"
blanchet@54475
   318
shows "|C \<times> A| =o |C \<times> B|"
traytel@54578
   319
using assms by (simp add: ordIso_iff_ordLeq)
blanchet@54475
   320
blanchet@48975
   321
lemma card_of_Times_mono[simp]:
blanchet@48975
   322
assumes "|A| \<le>o |B|" and "|C| \<le>o |D|"
blanchet@48975
   323
shows "|A \<times> C| \<le>o |B \<times> D|"
blanchet@48975
   324
using assms card_of_Times_mono1[of A B C] card_of_Times_mono2[of C D B]
blanchet@48975
   325
      ordLeq_transitive[of "|A \<times> C|"] by blast
blanchet@48975
   326
blanchet@48975
   327
corollary ordLeq_Times_mono:
blanchet@48975
   328
assumes "r \<le>o r'" and "p \<le>o p'"
blanchet@48975
   329
shows "|(Field r) \<times> (Field p)| \<le>o |(Field r') \<times> (Field p')|"
blanchet@48975
   330
using assms card_of_mono2[of r r'] card_of_mono2[of p p'] card_of_Times_mono by blast
blanchet@48975
   331
blanchet@48975
   332
corollary ordIso_Times_cong1[simp]:
blanchet@48975
   333
assumes "r =o r'"
blanchet@48975
   334
shows "|(Field r) \<times> C| =o |(Field r') \<times> C|"
blanchet@48975
   335
using assms card_of_cong card_of_Times_cong1 by blast
blanchet@48975
   336
blanchet@54475
   337
corollary ordIso_Times_cong2:
blanchet@54475
   338
assumes "r =o r'"
blanchet@54475
   339
shows "|A \<times> (Field r)| =o |A \<times> (Field r')|"
blanchet@54475
   340
using assms card_of_cong card_of_Times_cong2 by blast
blanchet@54475
   341
blanchet@48975
   342
lemma card_of_Times_cong[simp]:
blanchet@48975
   343
assumes "|A| =o |B|" and "|C| =o |D|"
blanchet@48975
   344
shows "|A \<times> C| =o |B \<times> D|"
blanchet@48975
   345
using assms
blanchet@48975
   346
by (auto simp add: ordIso_iff_ordLeq)
blanchet@48975
   347
blanchet@48975
   348
corollary ordIso_Times_cong:
blanchet@48975
   349
assumes "r =o r'" and "p =o p'"
blanchet@48975
   350
shows "|(Field r) \<times> (Field p)| =o |(Field r') \<times> (Field p')|"
blanchet@48975
   351
using assms card_of_cong[of r r'] card_of_cong[of p p'] card_of_Times_cong by blast
blanchet@48975
   352
blanchet@48975
   353
lemma card_of_Sigma_mono2:
blanchet@48975
   354
assumes "inj_on f (I::'i set)" and "f ` I \<le> (J::'j set)"
blanchet@48975
   355
shows "|SIGMA i : I. (A::'j \<Rightarrow> 'a set) (f i)| \<le>o |SIGMA j : J. A j|"
blanchet@48975
   356
proof-
blanchet@48975
   357
  let ?LEFT = "SIGMA i : I. A (f i)"
blanchet@48975
   358
  let ?RIGHT = "SIGMA j : J. A j"
blanchet@48975
   359
  obtain u where u_def: "u = (\<lambda>(i::'i,a::'a). (f i,a))" by blast
blanchet@48975
   360
  have "inj_on u ?LEFT \<and> u `?LEFT \<le> ?RIGHT"
blanchet@48975
   361
  using assms unfolding u_def inj_on_def by auto
blanchet@48975
   362
  thus ?thesis using card_of_ordLeq by blast
blanchet@48975
   363
qed
blanchet@48975
   364
blanchet@48975
   365
lemma card_of_Sigma_mono:
blanchet@48975
   366
assumes INJ: "inj_on f I" and IM: "f ` I \<le> J" and
blanchet@48975
   367
        LEQ: "\<forall>j \<in> J. |A j| \<le>o |B j|"
blanchet@48975
   368
shows "|SIGMA i : I. A (f i)| \<le>o |SIGMA j : J. B j|"
blanchet@48975
   369
proof-
blanchet@48975
   370
  have "\<forall>i \<in> I. |A(f i)| \<le>o |B(f i)|"
blanchet@48975
   371
  using IM LEQ by blast
blanchet@48975
   372
  hence "|SIGMA i : I. A (f i)| \<le>o |SIGMA i : I. B (f i)|"
blanchet@48975
   373
  using card_of_Sigma_mono1[of I] by metis
blanchet@48975
   374
  moreover have "|SIGMA i : I. B (f i)| \<le>o |SIGMA j : J. B j|"
blanchet@48975
   375
  using INJ IM card_of_Sigma_mono2 by blast
blanchet@48975
   376
  ultimately show ?thesis using ordLeq_transitive by blast
blanchet@48975
   377
qed
blanchet@48975
   378
blanchet@48975
   379
lemma ordLeq_Sigma_mono1:
blanchet@48975
   380
assumes "\<forall>i \<in> I. p i \<le>o r i"
blanchet@48975
   381
shows "|SIGMA i : I. Field(p i)| \<le>o |SIGMA i : I. Field(r i)|"
blanchet@48975
   382
using assms by (auto simp add: card_of_Sigma_mono1)
blanchet@48975
   383
blanchet@48975
   384
lemma ordLeq_Sigma_mono:
blanchet@48975
   385
assumes "inj_on f I" and "f ` I \<le> J" and
blanchet@48975
   386
        "\<forall>j \<in> J. p j \<le>o r j"
blanchet@48975
   387
shows "|SIGMA i : I. Field(p(f i))| \<le>o |SIGMA j : J. Field(r j)|"
blanchet@48975
   388
using assms card_of_mono2 card_of_Sigma_mono
blanchet@48975
   389
      [of f I J "\<lambda> i. Field(p i)" "\<lambda> j. Field(r j)"] by metis
blanchet@48975
   390
blanchet@48975
   391
lemma card_of_Sigma_cong1:
blanchet@48975
   392
assumes "\<forall>i \<in> I. |A i| =o |B i|"
blanchet@48975
   393
shows "|SIGMA i : I. A i| =o |SIGMA i : I. B i|"
blanchet@48975
   394
using assms by (auto simp add: card_of_Sigma_mono1 ordIso_iff_ordLeq)
blanchet@48975
   395
blanchet@48975
   396
lemma card_of_Sigma_cong2:
blanchet@48975
   397
assumes "bij_betw f (I::'i set) (J::'j set)"
blanchet@48975
   398
shows "|SIGMA i : I. (A::'j \<Rightarrow> 'a set) (f i)| =o |SIGMA j : J. A j|"
blanchet@48975
   399
proof-
blanchet@48975
   400
  let ?LEFT = "SIGMA i : I. A (f i)"
blanchet@48975
   401
  let ?RIGHT = "SIGMA j : J. A j"
blanchet@48975
   402
  obtain u where u_def: "u = (\<lambda>(i::'i,a::'a). (f i,a))" by blast
blanchet@48975
   403
  have "bij_betw u ?LEFT ?RIGHT"
blanchet@48975
   404
  using assms unfolding u_def bij_betw_def inj_on_def by auto
blanchet@48975
   405
  thus ?thesis using card_of_ordIso by blast
blanchet@48975
   406
qed
blanchet@48975
   407
blanchet@48975
   408
lemma card_of_Sigma_cong:
blanchet@48975
   409
assumes BIJ: "bij_betw f I J" and
blanchet@48975
   410
        ISO: "\<forall>j \<in> J. |A j| =o |B j|"
blanchet@48975
   411
shows "|SIGMA i : I. A (f i)| =o |SIGMA j : J. B j|"
blanchet@48975
   412
proof-
blanchet@48975
   413
  have "\<forall>i \<in> I. |A(f i)| =o |B(f i)|"
blanchet@48975
   414
  using ISO BIJ unfolding bij_betw_def by blast
traytel@54980
   415
  hence "|SIGMA i : I. A (f i)| =o |SIGMA i : I. B (f i)|" by (rule card_of_Sigma_cong1)
blanchet@48975
   416
  moreover have "|SIGMA i : I. B (f i)| =o |SIGMA j : J. B j|"
blanchet@48975
   417
  using BIJ card_of_Sigma_cong2 by blast
blanchet@48975
   418
  ultimately show ?thesis using ordIso_transitive by blast
blanchet@48975
   419
qed
blanchet@48975
   420
blanchet@48975
   421
lemma ordIso_Sigma_cong1:
blanchet@48975
   422
assumes "\<forall>i \<in> I. p i =o r i"
blanchet@48975
   423
shows "|SIGMA i : I. Field(p i)| =o |SIGMA i : I. Field(r i)|"
blanchet@48975
   424
using assms by (auto simp add: card_of_Sigma_cong1)
blanchet@48975
   425
blanchet@48975
   426
lemma ordLeq_Sigma_cong:
blanchet@48975
   427
assumes "bij_betw f I J" and
blanchet@48975
   428
        "\<forall>j \<in> J. p j =o r j"
blanchet@48975
   429
shows "|SIGMA i : I. Field(p(f i))| =o |SIGMA j : J. Field(r j)|"
blanchet@48975
   430
using assms card_of_cong card_of_Sigma_cong
blanchet@48975
   431
      [of f I J "\<lambda> j. Field(p j)" "\<lambda> j. Field(r j)"] by blast
blanchet@48975
   432
blanchet@48975
   433
lemma card_of_UNION_Sigma2:
blanchet@48975
   434
assumes
blanchet@48975
   435
"!! i j. \<lbrakk>{i,j} <= I; i ~= j\<rbrakk> \<Longrightarrow> A i Int A j = {}"
blanchet@48975
   436
shows
blanchet@48975
   437
"|\<Union>i\<in>I. A i| =o |Sigma I A|"
blanchet@48975
   438
proof-
blanchet@48975
   439
  let ?L = "\<Union>i\<in>I. A i"  let ?R = "Sigma I A"
blanchet@48975
   440
  have "|?L| <=o |?R|" using card_of_UNION_Sigma .
blanchet@48975
   441
  moreover have "|?R| <=o |?L|"
blanchet@48975
   442
  proof-
blanchet@48975
   443
    have "inj_on snd ?R"
blanchet@48975
   444
    unfolding inj_on_def using assms by auto
blanchet@48975
   445
    moreover have "snd ` ?R <= ?L" by auto
blanchet@48975
   446
    ultimately show ?thesis using card_of_ordLeq by blast
blanchet@48975
   447
  qed
blanchet@48975
   448
  ultimately show ?thesis by(simp add: ordIso_iff_ordLeq)
blanchet@48975
   449
qed
blanchet@48975
   450
blanchet@48975
   451
corollary Plus_into_Times:
blanchet@48975
   452
assumes A2: "a1 \<noteq> a2 \<and> {a1,a2} \<le> A" and
blanchet@48975
   453
        B2: "b1 \<noteq> b2 \<and> {b1,b2} \<le> B"
blanchet@48975
   454
shows "\<exists>f. inj_on f (A <+> B) \<and> f ` (A <+> B) \<le> A \<times> B"
blanchet@48975
   455
using assms by (auto simp add: card_of_Plus_Times card_of_ordLeq)
blanchet@48975
   456
blanchet@48975
   457
corollary Plus_into_Times_types:
blanchet@48975
   458
assumes A2: "(a1::'a) \<noteq> a2" and  B2: "(b1::'b) \<noteq> b2"
blanchet@48975
   459
shows "\<exists>(f::'a + 'b \<Rightarrow> 'a * 'b). inj f"
blanchet@48975
   460
using assms Plus_into_Times[of a1 a2 UNIV b1 b2 UNIV]
blanchet@48975
   461
by auto
blanchet@48975
   462
blanchet@48975
   463
corollary Times_same_infinite_bij_betw:
traytel@54578
   464
assumes "\<not>finite A"
blanchet@48975
   465
shows "\<exists>f. bij_betw f (A \<times> A) A"
blanchet@48975
   466
using assms by (auto simp add: card_of_ordIso)
blanchet@48975
   467
blanchet@48975
   468
corollary Times_same_infinite_bij_betw_types:
traytel@54578
   469
assumes INF: "\<not>finite(UNIV::'a set)"
blanchet@48975
   470
shows "\<exists>(f::('a * 'a) => 'a). bij f"
blanchet@48975
   471
using assms Times_same_infinite_bij_betw[of "UNIV::'a set"]
blanchet@48975
   472
by auto
blanchet@48975
   473
blanchet@48975
   474
corollary Times_infinite_bij_betw:
traytel@54578
   475
assumes INF: "\<not>finite A" and NE: "B \<noteq> {}" and INJ: "inj_on g B \<and> g ` B \<le> A"
blanchet@48975
   476
shows "(\<exists>f. bij_betw f (A \<times> B) A) \<and> (\<exists>h. bij_betw h (B \<times> A) A)"
blanchet@48975
   477
proof-
blanchet@48975
   478
  have "|B| \<le>o |A|" using INJ card_of_ordLeq by blast
blanchet@48975
   479
  thus ?thesis using INF NE
blanchet@48975
   480
  by (auto simp add: card_of_ordIso card_of_Times_infinite)
blanchet@48975
   481
qed
blanchet@48975
   482
blanchet@48975
   483
corollary Times_infinite_bij_betw_types:
traytel@54578
   484
assumes INF: "\<not>finite(UNIV::'a set)" and
blanchet@48975
   485
        BIJ: "inj(g::'b \<Rightarrow> 'a)"
blanchet@48975
   486
shows "(\<exists>(f::('b * 'a) => 'a). bij f) \<and> (\<exists>(h::('a * 'b) => 'a). bij h)"
blanchet@48975
   487
using assms Times_infinite_bij_betw[of "UNIV::'a set" "UNIV::'b set" g]
blanchet@48975
   488
by auto
blanchet@48975
   489
blanchet@48975
   490
lemma card_of_Times_ordLeq_infinite:
traytel@54578
   491
"\<lbrakk>\<not>finite C; |A| \<le>o |C|; |B| \<le>o |C|\<rbrakk>
wenzelm@61943
   492
 \<Longrightarrow> |A \<times> B| \<le>o |C|"
blanchet@48975
   493
by(simp add: card_of_Sigma_ordLeq_infinite)
blanchet@48975
   494
blanchet@48975
   495
corollary Plus_infinite_bij_betw:
traytel@54578
   496
assumes INF: "\<not>finite A" and INJ: "inj_on g B \<and> g ` B \<le> A"
blanchet@48975
   497
shows "(\<exists>f. bij_betw f (A <+> B) A) \<and> (\<exists>h. bij_betw h (B <+> A) A)"
blanchet@48975
   498
proof-
blanchet@48975
   499
  have "|B| \<le>o |A|" using INJ card_of_ordLeq by blast
blanchet@48975
   500
  thus ?thesis using INF
blanchet@48975
   501
  by (auto simp add: card_of_ordIso)
blanchet@48975
   502
qed
blanchet@48975
   503
blanchet@48975
   504
corollary Plus_infinite_bij_betw_types:
traytel@54578
   505
assumes INF: "\<not>finite(UNIV::'a set)" and
blanchet@48975
   506
        BIJ: "inj(g::'b \<Rightarrow> 'a)"
blanchet@48975
   507
shows "(\<exists>(f::('b + 'a) => 'a). bij f) \<and> (\<exists>(h::('a + 'b) => 'a). bij h)"
blanchet@48975
   508
using assms Plus_infinite_bij_betw[of "UNIV::'a set" g "UNIV::'b set"]
blanchet@48975
   509
by auto
blanchet@48975
   510
blanchet@54475
   511
lemma card_of_Un_infinite:
traytel@54578
   512
assumes INF: "\<not>finite A" and LEQ: "|B| \<le>o |A|"
blanchet@54475
   513
shows "|A \<union> B| =o |A| \<and> |B \<union> A| =o |A|"
blanchet@54475
   514
proof-
blanchet@54475
   515
  have "|A \<union> B| \<le>o |A <+> B|" by (rule card_of_Un_Plus_ordLeq)
blanchet@54475
   516
  moreover have "|A <+> B| =o |A|"
blanchet@54475
   517
  using assms by (metis card_of_Plus_infinite)
blanchet@54475
   518
  ultimately have "|A \<union> B| \<le>o |A|" using ordLeq_ordIso_trans by blast
blanchet@54475
   519
  hence "|A \<union> B| =o |A|" using card_of_Un1 ordIso_iff_ordLeq by blast
blanchet@54475
   520
  thus ?thesis using Un_commute[of B A] by auto
blanchet@54475
   521
qed
blanchet@54475
   522
blanchet@48975
   523
lemma card_of_Un_infinite_simps[simp]:
traytel@54578
   524
"\<lbrakk>\<not>finite A; |B| \<le>o |A| \<rbrakk> \<Longrightarrow> |A \<union> B| =o |A|"
traytel@54578
   525
"\<lbrakk>\<not>finite A; |B| \<le>o |A| \<rbrakk> \<Longrightarrow> |B \<union> A| =o |A|"
blanchet@48975
   526
using card_of_Un_infinite by auto
blanchet@48975
   527
blanchet@54475
   528
lemma card_of_Un_diff_infinite:
traytel@54578
   529
assumes INF: "\<not>finite A" and LESS: "|B| <o |A|"
blanchet@54475
   530
shows "|A - B| =o |A|"
blanchet@54475
   531
proof-
blanchet@54475
   532
  obtain C where C_def: "C = A - B" by blast
blanchet@54475
   533
  have "|A \<union> B| =o |A|"
blanchet@54475
   534
  using assms ordLeq_iff_ordLess_or_ordIso card_of_Un_infinite by blast
blanchet@54475
   535
  moreover have "C \<union> B = A \<union> B" unfolding C_def by auto
blanchet@54475
   536
  ultimately have 1: "|C \<union> B| =o |A|" by auto
blanchet@54475
   537
  (*  *)
blanchet@54475
   538
  {assume *: "|C| \<le>o |B|"
blanchet@54475
   539
   moreover
blanchet@54475
   540
   {assume **: "finite B"
blanchet@54475
   541
    hence "finite C"
blanchet@54475
   542
    using card_of_ordLeq_finite * by blast
blanchet@54475
   543
    hence False using ** INF card_of_ordIso_finite 1 by blast
blanchet@54475
   544
   }
traytel@54578
   545
   hence "\<not>finite B" by auto
blanchet@54475
   546
   ultimately have False
blanchet@54475
   547
   using card_of_Un_infinite 1 ordIso_equivalence(1,3) LESS not_ordLess_ordIso by metis
blanchet@54475
   548
  }
blanchet@54475
   549
  hence 2: "|B| \<le>o |C|" using card_of_Well_order ordLeq_total by blast
blanchet@54475
   550
  {assume *: "finite C"
blanchet@54475
   551
    hence "finite B" using card_of_ordLeq_finite 2 by blast
blanchet@54475
   552
    hence False using * INF card_of_ordIso_finite 1 by blast
blanchet@54475
   553
  }
traytel@54578
   554
  hence "\<not>finite C" by auto
blanchet@54475
   555
  hence "|C| =o |A|"
blanchet@54475
   556
  using  card_of_Un_infinite 1 2 ordIso_equivalence(1,3) by metis
blanchet@54475
   557
  thus ?thesis unfolding C_def .
blanchet@54475
   558
qed
blanchet@54475
   559
blanchet@48975
   560
corollary Card_order_Un_infinite:
traytel@54578
   561
assumes INF: "\<not>finite(Field r)" and CARD: "Card_order r" and
blanchet@48975
   562
        LEQ: "p \<le>o r"
blanchet@48975
   563
shows "| (Field r) \<union> (Field p) | =o r \<and> | (Field p) \<union> (Field r) | =o r"
blanchet@48975
   564
proof-
blanchet@48975
   565
  have "| Field r \<union> Field p | =o | Field r | \<and>
blanchet@48975
   566
        | Field p \<union> Field r | =o | Field r |"
blanchet@48975
   567
  using assms by (auto simp add: card_of_Un_infinite)
blanchet@48975
   568
  thus ?thesis
blanchet@48975
   569
  using assms card_of_Field_ordIso[of r]
blanchet@48975
   570
        ordIso_transitive[of "|Field r \<union> Field p|"]
blanchet@48975
   571
        ordIso_transitive[of _ "|Field r|"] by blast
blanchet@48975
   572
qed
blanchet@48975
   573
blanchet@48975
   574
corollary subset_ordLeq_diff_infinite:
traytel@54578
   575
assumes INF: "\<not>finite B" and SUB: "A \<le> B" and LESS: "|A| <o |B|"
traytel@54578
   576
shows "\<not>finite (B - A)"
blanchet@48975
   577
using assms card_of_Un_diff_infinite card_of_ordIso_finite by blast
blanchet@48975
   578
blanchet@48975
   579
lemma card_of_Times_ordLess_infinite[simp]:
traytel@54578
   580
assumes INF: "\<not>finite C" and
blanchet@48975
   581
        LESS1: "|A| <o |C|" and LESS2: "|B| <o |C|"
blanchet@48975
   582
shows "|A \<times> B| <o |C|"
blanchet@48975
   583
proof(cases "A = {} \<or> B = {}")
blanchet@48975
   584
  assume Case1: "A = {} \<or> B = {}"
blanchet@48975
   585
  hence "A \<times> B = {}" by blast
blanchet@48975
   586
  moreover have "C \<noteq> {}" using
blanchet@48975
   587
  LESS1 card_of_empty5 by blast
blanchet@48975
   588
  ultimately show ?thesis by(auto simp add:  card_of_empty4)
blanchet@48975
   589
next
blanchet@48975
   590
  assume Case2: "\<not>(A = {} \<or> B = {})"
blanchet@48975
   591
  {assume *: "|C| \<le>o |A \<times> B|"
traytel@54578
   592
   hence "\<not>finite (A \<times> B)" using INF card_of_ordLeq_finite by blast
traytel@54578
   593
   hence 1: "\<not>finite A \<or> \<not>finite B" using finite_cartesian_product by blast
blanchet@48975
   594
   {assume Case21: "|A| \<le>o |B|"
traytel@54578
   595
    hence "\<not>finite B" using 1 card_of_ordLeq_finite by blast
blanchet@48975
   596
    hence "|A \<times> B| =o |B|" using Case2 Case21
blanchet@48975
   597
    by (auto simp add: card_of_Times_infinite)
blanchet@48975
   598
    hence False using LESS2 not_ordLess_ordLeq * ordLeq_ordIso_trans by blast
blanchet@48975
   599
   }
blanchet@48975
   600
   moreover
blanchet@48975
   601
   {assume Case22: "|B| \<le>o |A|"
traytel@54578
   602
    hence "\<not>finite A" using 1 card_of_ordLeq_finite by blast
blanchet@48975
   603
    hence "|A \<times> B| =o |A|" using Case2 Case22
blanchet@48975
   604
    by (auto simp add: card_of_Times_infinite)
blanchet@48975
   605
    hence False using LESS1 not_ordLess_ordLeq * ordLeq_ordIso_trans by blast
blanchet@48975
   606
   }
blanchet@48975
   607
   ultimately have False using ordLeq_total card_of_Well_order[of A]
blanchet@48975
   608
   card_of_Well_order[of B] by blast
blanchet@48975
   609
  }
blanchet@48975
   610
  thus ?thesis using ordLess_or_ordLeq[of "|A \<times> B|" "|C|"]
blanchet@48975
   611
  card_of_Well_order[of "A \<times> B"] card_of_Well_order[of "C"] by auto
blanchet@48975
   612
qed
blanchet@48975
   613
blanchet@48975
   614
lemma card_of_Times_ordLess_infinite_Field[simp]:
traytel@54578
   615
assumes INF: "\<not>finite (Field r)" and r: "Card_order r" and
blanchet@48975
   616
        LESS1: "|A| <o r" and LESS2: "|B| <o r"
blanchet@48975
   617
shows "|A \<times> B| <o r"
blanchet@48975
   618
proof-
blanchet@48975
   619
  let ?C  = "Field r"
blanchet@48975
   620
  have 1: "r =o |?C| \<and> |?C| =o r" using r card_of_Field_ordIso
blanchet@48975
   621
  ordIso_symmetric by blast
blanchet@48975
   622
  hence "|A| <o |?C|"  "|B| <o |?C|"
blanchet@48975
   623
  using LESS1 LESS2 ordLess_ordIso_trans by blast+
wenzelm@61943
   624
  hence  "|A \<times> B| <o |?C|" using INF
blanchet@48975
   625
  card_of_Times_ordLess_infinite by blast
blanchet@48975
   626
  thus ?thesis using 1 ordLess_ordIso_trans by blast
blanchet@48975
   627
qed
blanchet@48975
   628
blanchet@48975
   629
lemma card_of_Un_ordLess_infinite[simp]:
traytel@54578
   630
assumes INF: "\<not>finite C" and
blanchet@48975
   631
        LESS1: "|A| <o |C|" and LESS2: "|B| <o |C|"
blanchet@48975
   632
shows "|A \<union> B| <o |C|"
blanchet@48975
   633
using assms card_of_Plus_ordLess_infinite card_of_Un_Plus_ordLeq
blanchet@48975
   634
      ordLeq_ordLess_trans by blast
blanchet@48975
   635
blanchet@48975
   636
lemma card_of_Un_ordLess_infinite_Field[simp]:
traytel@54578
   637
assumes INF: "\<not>finite (Field r)" and r: "Card_order r" and
blanchet@48975
   638
        LESS1: "|A| <o r" and LESS2: "|B| <o r"
blanchet@48975
   639
shows "|A Un B| <o r"
blanchet@48975
   640
proof-
blanchet@48975
   641
  let ?C  = "Field r"
blanchet@48975
   642
  have 1: "r =o |?C| \<and> |?C| =o r" using r card_of_Field_ordIso
blanchet@48975
   643
  ordIso_symmetric by blast
blanchet@48975
   644
  hence "|A| <o |?C|"  "|B| <o |?C|"
blanchet@48975
   645
  using LESS1 LESS2 ordLess_ordIso_trans by blast+
blanchet@48975
   646
  hence  "|A Un B| <o |?C|" using INF
blanchet@48975
   647
  card_of_Un_ordLess_infinite by blast
blanchet@48975
   648
  thus ?thesis using 1 ordLess_ordIso_trans by blast
blanchet@48975
   649
qed
blanchet@48975
   650
traytel@55174
   651
lemma ordLeq_finite_Field:
traytel@55174
   652
assumes "r \<le>o s" and "finite (Field s)"
traytel@55174
   653
shows "finite (Field r)"
traytel@55174
   654
by (metis assms card_of_mono2 card_of_ordLeq_infinite)
traytel@55174
   655
traytel@55174
   656
lemma ordIso_finite_Field:
traytel@55174
   657
assumes "r =o s"
traytel@55174
   658
shows "finite (Field r) \<longleftrightarrow> finite (Field s)"
traytel@55174
   659
by (metis assms ordIso_iff_ordLeq ordLeq_finite_Field)
traytel@55174
   660
blanchet@54475
   661
wenzelm@63167
   662
subsection \<open>Cardinals versus set operations involving infinite sets\<close>
blanchet@54475
   663
blanchet@54475
   664
lemma finite_iff_cardOf_nat:
blanchet@54475
   665
"finite A = ( |A| <o |UNIV :: nat set| )"
blanchet@54475
   666
using infinite_iff_card_of_nat[of A]
blanchet@54475
   667
not_ordLeq_iff_ordLess[of "|A|" "|UNIV :: nat set|"]
traytel@54578
   668
by fastforce
blanchet@54475
   669
blanchet@54475
   670
lemma finite_ordLess_infinite2[simp]:
traytel@54578
   671
assumes "finite A" and "\<not>finite B"
blanchet@54475
   672
shows "|A| <o |B|"
blanchet@54475
   673
using assms
blanchet@54475
   674
finite_ordLess_infinite[of "|A|" "|B|"]
blanchet@54475
   675
card_of_Well_order[of A] card_of_Well_order[of B]
blanchet@54475
   676
Field_card_of[of A] Field_card_of[of B] by auto
blanchet@54475
   677
blanchet@54475
   678
lemma infinite_card_of_insert:
traytel@54578
   679
assumes "\<not>finite A"
blanchet@54475
   680
shows "|insert a A| =o |A|"
blanchet@54475
   681
proof-
blanchet@54475
   682
  have iA: "insert a A = A \<union> {a}" by simp
blanchet@54475
   683
  show ?thesis
blanchet@54475
   684
  using infinite_imp_bij_betw2[OF assms] unfolding iA
blanchet@54475
   685
  by (metis bij_betw_inv card_of_ordIso)
blanchet@54475
   686
qed
blanchet@54475
   687
blanchet@48975
   688
lemma card_of_Un_singl_ordLess_infinite1:
traytel@54578
   689
assumes "\<not>finite B" and "|A| <o |B|"
blanchet@48975
   690
shows "|{a} Un A| <o |B|"
blanchet@48975
   691
proof-
blanchet@48975
   692
  have "|{a}| <o |B|" using assms by auto
traytel@51764
   693
  thus ?thesis using assms card_of_Un_ordLess_infinite[of B] by blast
blanchet@48975
   694
qed
blanchet@48975
   695
blanchet@48975
   696
lemma card_of_Un_singl_ordLess_infinite:
traytel@54578
   697
assumes "\<not>finite B"
blanchet@48975
   698
shows "( |A| <o |B| ) = ( |{a} Un A| <o |B| )"
blanchet@48975
   699
using assms card_of_Un_singl_ordLess_infinite1[of B A]
blanchet@48975
   700
proof(auto)
blanchet@48975
   701
  assume "|insert a A| <o |B|"
traytel@51764
   702
  moreover have "|A| <=o |insert a A|" using card_of_mono1[of A "insert a A"] by blast
blanchet@48975
   703
  ultimately show "|A| <o |B|" using ordLeq_ordLess_trans by blast
blanchet@48975
   704
qed
blanchet@48975
   705
blanchet@48975
   706
wenzelm@63167
   707
subsection \<open>Cardinals versus lists\<close>
blanchet@54475
   708
wenzelm@63167
   709
text\<open>The next is an auxiliary operator, which shall be used for inductive
wenzelm@63167
   710
proofs of facts concerning the cardinality of \<open>List\<close> :\<close>
blanchet@54475
   711
blanchet@54475
   712
definition nlists :: "'a set \<Rightarrow> nat \<Rightarrow> 'a list set"
blanchet@54475
   713
where "nlists A n \<equiv> {l. set l \<le> A \<and> length l = n}"
blanchet@54475
   714
blanchet@54475
   715
lemma lists_def2: "lists A = {l. set l \<le> A}"
blanchet@54475
   716
using in_listsI by blast
blanchet@54475
   717
wenzelm@60585
   718
lemma lists_UNION_nlists: "lists A = (\<Union>n. nlists A n)"
blanchet@54475
   719
unfolding lists_def2 nlists_def by blast
blanchet@54475
   720
blanchet@54475
   721
lemma card_of_lists: "|A| \<le>o |lists A|"
blanchet@54475
   722
proof-
blanchet@54475
   723
  let ?h = "\<lambda> a. [a]"
blanchet@54475
   724
  have "inj_on ?h A \<and> ?h ` A \<le> lists A"
blanchet@54475
   725
  unfolding inj_on_def lists_def2 by auto
blanchet@54475
   726
  thus ?thesis by (metis card_of_ordLeq)
blanchet@54475
   727
qed
blanchet@54475
   728
blanchet@54475
   729
lemma nlists_0: "nlists A 0 = {[]}"
blanchet@54475
   730
unfolding nlists_def by auto
blanchet@54475
   731
blanchet@54475
   732
lemma nlists_not_empty:
blanchet@54475
   733
assumes "A \<noteq> {}"
blanchet@54475
   734
shows "nlists A n \<noteq> {}"
blanchet@54475
   735
proof(induct n, simp add: nlists_0)
blanchet@54475
   736
  fix n assume "nlists A n \<noteq> {}"
blanchet@54475
   737
  then obtain a and l where "a \<in> A \<and> l \<in> nlists A n" using assms by auto
blanchet@54475
   738
  hence "a # l \<in> nlists A (Suc n)" unfolding nlists_def by auto
blanchet@54475
   739
  thus "nlists A (Suc n) \<noteq> {}" by auto
blanchet@54475
   740
qed
blanchet@54475
   741
blanchet@54475
   742
lemma Nil_in_lists: "[] \<in> lists A"
blanchet@54475
   743
unfolding lists_def2 by auto
blanchet@54475
   744
blanchet@54475
   745
lemma lists_not_empty: "lists A \<noteq> {}"
blanchet@54475
   746
using Nil_in_lists by blast
blanchet@54475
   747
blanchet@54475
   748
lemma card_of_nlists_Succ: "|nlists A (Suc n)| =o |A \<times> (nlists A n)|"
blanchet@54475
   749
proof-
blanchet@54475
   750
  let ?B = "A \<times> (nlists A n)"   let ?h = "\<lambda>(a,l). a # l"
blanchet@54475
   751
  have "inj_on ?h ?B \<and> ?h ` ?B \<le> nlists A (Suc n)"
blanchet@54475
   752
  unfolding inj_on_def nlists_def by auto
blanchet@54475
   753
  moreover have "nlists A (Suc n) \<le> ?h ` ?B"
blanchet@54475
   754
  proof(auto)
blanchet@54475
   755
    fix l assume "l \<in> nlists A (Suc n)"
blanchet@54475
   756
    hence 1: "length l = Suc n \<and> set l \<le> A" unfolding nlists_def by auto
blanchet@54475
   757
    then obtain a and l' where 2: "l = a # l'" by (auto simp: length_Suc_conv)
blanchet@54475
   758
    hence "a \<in> A \<and> set l' \<le> A \<and> length l' = n" using 1 by auto
blanchet@54475
   759
    thus "l \<in> ?h ` ?B"  using 2 unfolding nlists_def by auto
blanchet@54475
   760
  qed
blanchet@54475
   761
  ultimately have "bij_betw ?h ?B (nlists A (Suc n))"
blanchet@54475
   762
  unfolding bij_betw_def by auto
blanchet@54475
   763
  thus ?thesis using card_of_ordIso ordIso_symmetric by blast
blanchet@54475
   764
qed
blanchet@54475
   765
blanchet@54475
   766
lemma card_of_nlists_infinite:
traytel@54578
   767
assumes "\<not>finite A"
blanchet@54475
   768
shows "|nlists A n| \<le>o |A|"
blanchet@54475
   769
proof(induct n)
blanchet@54475
   770
  have "A \<noteq> {}" using assms by auto
traytel@54578
   771
  thus "|nlists A 0| \<le>o |A|" by (simp add: nlists_0)
blanchet@54475
   772
next
blanchet@54475
   773
  fix n assume IH: "|nlists A n| \<le>o |A|"
blanchet@54475
   774
  have "|nlists A (Suc n)| =o |A \<times> (nlists A n)|"
blanchet@54475
   775
  using card_of_nlists_Succ by blast
blanchet@54475
   776
  moreover
blanchet@54475
   777
  {have "nlists A n \<noteq> {}" using assms nlists_not_empty[of A] by blast
blanchet@54475
   778
   hence "|A \<times> (nlists A n)| =o |A|"
blanchet@54475
   779
   using assms IH by (auto simp add: card_of_Times_infinite)
blanchet@54475
   780
  }
blanchet@54475
   781
  ultimately show "|nlists A (Suc n)| \<le>o |A|"
blanchet@54475
   782
  using ordIso_transitive ordIso_iff_ordLeq by blast
blanchet@54475
   783
qed
blanchet@48975
   784
blanchet@48975
   785
lemma Card_order_lists: "Card_order r \<Longrightarrow> r \<le>o |lists(Field r) |"
blanchet@48975
   786
using card_of_lists card_of_Field_ordIso ordIso_ordLeq_trans ordIso_symmetric by blast
blanchet@48975
   787
wenzelm@61952
   788
lemma Union_set_lists: "\<Union>(set ` (lists A)) = A"
wenzelm@61952
   789
  unfolding lists_def2
wenzelm@61952
   790
proof(auto)
blanchet@48975
   791
  fix a assume "a \<in> A"
blanchet@48975
   792
  hence "set [a] \<le> A \<and> a \<in> set [a]" by auto
blanchet@48975
   793
  thus "\<exists>l. set l \<le> A \<and> a \<in> set l" by blast
blanchet@48975
   794
qed
blanchet@48975
   795
blanchet@48975
   796
lemma inj_on_map_lists:
blanchet@48975
   797
assumes "inj_on f A"
blanchet@48975
   798
shows "inj_on (map f) (lists A)"
blanchet@48975
   799
using assms Union_set_lists[of A] inj_on_mapI[of f "lists A"] by auto
blanchet@48975
   800
blanchet@48975
   801
lemma map_lists_mono:
blanchet@48975
   802
assumes "f ` A \<le> B"
blanchet@48975
   803
shows "(map f) ` (lists A) \<le> lists B"
blanchet@48975
   804
using assms unfolding lists_def2 by (auto, blast) (* lethal combination of methods :)  *)
blanchet@48975
   805
blanchet@48975
   806
lemma map_lists_surjective:
blanchet@48975
   807
assumes "f ` A = B"
blanchet@48975
   808
shows "(map f) ` (lists A) = lists B"
blanchet@48975
   809
using assms unfolding lists_def2
blanchet@48975
   810
proof (auto, blast)
blanchet@48975
   811
  fix l' assume *: "set l' \<le> f ` A"
blanchet@48975
   812
  have "set l' \<le> f ` A \<longrightarrow> l' \<in> map f ` {l. set l \<le> A}"
blanchet@48975
   813
  proof(induct l', auto)
blanchet@48975
   814
    fix l a
blanchet@48975
   815
    assume "a \<in> A" and "set l \<le> A" and
blanchet@48975
   816
           IH: "f ` (set l) \<le> f ` A"
blanchet@48975
   817
    hence "set (a # l) \<le> A" by auto
blanchet@48975
   818
    hence "map f (a # l) \<in> map f ` {l. set l \<le> A}" by blast
blanchet@48975
   819
    thus "f a # map f l \<in> map f ` {l. set l \<le> A}" by auto
blanchet@48975
   820
  qed
blanchet@48975
   821
  thus "l' \<in> map f ` {l. set l \<le> A}" using * by auto
blanchet@48975
   822
qed
blanchet@48975
   823
blanchet@48975
   824
lemma bij_betw_map_lists:
blanchet@48975
   825
assumes "bij_betw f A B"
blanchet@48975
   826
shows "bij_betw (map f) (lists A) (lists B)"
blanchet@48975
   827
using assms unfolding bij_betw_def
blanchet@48975
   828
by(auto simp add: inj_on_map_lists map_lists_surjective)
blanchet@48975
   829
blanchet@48975
   830
lemma card_of_lists_mono[simp]:
blanchet@48975
   831
assumes "|A| \<le>o |B|"
blanchet@48975
   832
shows "|lists A| \<le>o |lists B|"
blanchet@48975
   833
proof-
blanchet@48975
   834
  obtain f where "inj_on f A \<and> f ` A \<le> B"
blanchet@48975
   835
  using assms card_of_ordLeq[of A B] by auto
blanchet@48975
   836
  hence "inj_on (map f) (lists A) \<and> (map f) ` (lists A) \<le> (lists B)"
blanchet@48975
   837
  by (auto simp add: inj_on_map_lists map_lists_mono)
blanchet@48975
   838
  thus ?thesis using card_of_ordLeq[of "lists A"] by metis
blanchet@48975
   839
qed
blanchet@48975
   840
blanchet@48975
   841
lemma ordIso_lists_mono:
blanchet@48975
   842
assumes "r \<le>o r'"
blanchet@48975
   843
shows "|lists(Field r)| \<le>o |lists(Field r')|"
blanchet@48975
   844
using assms card_of_mono2 card_of_lists_mono by blast
blanchet@48975
   845
blanchet@48975
   846
lemma card_of_lists_cong[simp]:
blanchet@48975
   847
assumes "|A| =o |B|"
blanchet@48975
   848
shows "|lists A| =o |lists B|"
blanchet@48975
   849
proof-
blanchet@48975
   850
  obtain f where "bij_betw f A B"
blanchet@48975
   851
  using assms card_of_ordIso[of A B] by auto
blanchet@48975
   852
  hence "bij_betw (map f) (lists A) (lists B)"
blanchet@48975
   853
  by (auto simp add: bij_betw_map_lists)
blanchet@48975
   854
  thus ?thesis using card_of_ordIso[of "lists A"] by auto
blanchet@48975
   855
qed
blanchet@48975
   856
blanchet@54475
   857
lemma card_of_lists_infinite[simp]:
traytel@54578
   858
assumes "\<not>finite A"
blanchet@54475
   859
shows "|lists A| =o |A|"
blanchet@54475
   860
proof-
traytel@54578
   861
  have "|lists A| \<le>o |A|" unfolding lists_UNION_nlists
traytel@54578
   862
  by (rule card_of_UNION_ordLeq_infinite[OF assms _ ballI[OF card_of_nlists_infinite[OF assms]]])
traytel@54578
   863
    (metis infinite_iff_card_of_nat assms)
blanchet@54475
   864
  thus ?thesis using card_of_lists ordIso_iff_ordLeq by blast
blanchet@54475
   865
qed
blanchet@54475
   866
blanchet@54475
   867
lemma Card_order_lists_infinite:
traytel@54578
   868
assumes "Card_order r" and "\<not>finite(Field r)"
blanchet@54475
   869
shows "|lists(Field r)| =o r"
blanchet@54475
   870
using assms card_of_lists_infinite card_of_Field_ordIso ordIso_transitive by blast
blanchet@54475
   871
blanchet@48975
   872
lemma ordIso_lists_cong:
blanchet@48975
   873
assumes "r =o r'"
blanchet@48975
   874
shows "|lists(Field r)| =o |lists(Field r')|"
blanchet@48975
   875
using assms card_of_cong card_of_lists_cong by blast
blanchet@48975
   876
blanchet@48975
   877
corollary lists_infinite_bij_betw:
traytel@54578
   878
assumes "\<not>finite A"
blanchet@48975
   879
shows "\<exists>f. bij_betw f (lists A) A"
blanchet@48975
   880
using assms card_of_lists_infinite card_of_ordIso by blast
blanchet@48975
   881
blanchet@48975
   882
corollary lists_infinite_bij_betw_types:
traytel@54578
   883
assumes "\<not>finite(UNIV :: 'a set)"
blanchet@48975
   884
shows "\<exists>(f::'a list \<Rightarrow> 'a). bij f"
blanchet@48975
   885
using assms assms lists_infinite_bij_betw[of "UNIV::'a set"]
blanchet@48975
   886
using lists_UNIV by auto
blanchet@48975
   887
blanchet@48975
   888
wenzelm@63167
   889
subsection \<open>Cardinals versus the set-of-finite-sets operator\<close>
blanchet@48975
   890
blanchet@48975
   891
definition Fpow :: "'a set \<Rightarrow> 'a set set"
blanchet@48975
   892
where "Fpow A \<equiv> {X. X \<le> A \<and> finite X}"
blanchet@48975
   893
blanchet@48975
   894
lemma Fpow_mono: "A \<le> B \<Longrightarrow> Fpow A \<le> Fpow B"
blanchet@48975
   895
unfolding Fpow_def by auto
blanchet@48975
   896
blanchet@48975
   897
lemma empty_in_Fpow: "{} \<in> Fpow A"
blanchet@48975
   898
unfolding Fpow_def by auto
blanchet@48975
   899
blanchet@48975
   900
lemma Fpow_not_empty: "Fpow A \<noteq> {}"
blanchet@48975
   901
using empty_in_Fpow by blast
blanchet@48975
   902
blanchet@48975
   903
lemma Fpow_subset_Pow: "Fpow A \<le> Pow A"
blanchet@48975
   904
unfolding Fpow_def by auto
blanchet@48975
   905
blanchet@48975
   906
lemma card_of_Fpow[simp]: "|A| \<le>o |Fpow A|"
blanchet@48975
   907
proof-
blanchet@48975
   908
  let ?h = "\<lambda> a. {a}"
blanchet@48975
   909
  have "inj_on ?h A \<and> ?h ` A \<le> Fpow A"
blanchet@48975
   910
  unfolding inj_on_def Fpow_def by auto
blanchet@48975
   911
  thus ?thesis using card_of_ordLeq by metis
blanchet@48975
   912
qed
blanchet@48975
   913
blanchet@48975
   914
lemma Card_order_Fpow: "Card_order r \<Longrightarrow> r \<le>o |Fpow(Field r) |"
blanchet@48975
   915
using card_of_Fpow card_of_Field_ordIso ordIso_ordLeq_trans ordIso_symmetric by blast
blanchet@48975
   916
blanchet@48975
   917
lemma Fpow_Pow_finite: "Fpow A = Pow A Int {A. finite A}"
blanchet@48975
   918
unfolding Fpow_def Pow_def by blast
blanchet@48975
   919
blanchet@48975
   920
lemma inj_on_image_Fpow:
blanchet@48975
   921
assumes "inj_on f A"
blanchet@48975
   922
shows "inj_on (image f) (Fpow A)"
blanchet@48975
   923
using assms Fpow_subset_Pow[of A] subset_inj_on[of "image f" "Pow A"]
blanchet@48975
   924
      inj_on_image_Pow by blast
blanchet@48975
   925
blanchet@48975
   926
lemma image_Fpow_mono:
blanchet@48975
   927
assumes "f ` A \<le> B"
blanchet@48975
   928
shows "(image f) ` (Fpow A) \<le> Fpow B"
blanchet@48975
   929
using assms by(unfold Fpow_def, auto)
blanchet@48975
   930
blanchet@48975
   931
lemma image_Fpow_surjective:
blanchet@48975
   932
assumes "f ` A = B"
blanchet@48975
   933
shows "(image f) ` (Fpow A) = Fpow B"
blanchet@48975
   934
using assms proof(unfold Fpow_def, auto)
blanchet@48975
   935
  fix Y assume *: "Y \<le> f ` A" and **: "finite Y"
blanchet@48975
   936
  hence "\<forall>b \<in> Y. \<exists>a. a \<in> A \<and> f a = b" by auto
blanchet@48975
   937
  with bchoice[of Y "\<lambda>b a. a \<in> A \<and> f a = b"]
blanchet@48975
   938
  obtain g where 1: "\<forall>b \<in> Y. g b \<in> A \<and> f(g b) = b" by blast
blanchet@48975
   939
  obtain X where X_def: "X = g ` Y" by blast
blanchet@48975
   940
  have "f ` X = Y \<and> X \<le> A \<and> finite X"
blanchet@48975
   941
  by(unfold X_def, force simp add: ** 1)
blanchet@48975
   942
  thus "Y \<in> (image f) ` {X. X \<le> A \<and> finite X}" by auto
blanchet@48975
   943
qed
blanchet@48975
   944
blanchet@48975
   945
lemma bij_betw_image_Fpow:
blanchet@48975
   946
assumes "bij_betw f A B"
blanchet@48975
   947
shows "bij_betw (image f) (Fpow A) (Fpow B)"
blanchet@48975
   948
using assms unfolding bij_betw_def
blanchet@48975
   949
by (auto simp add: inj_on_image_Fpow image_Fpow_surjective)
blanchet@48975
   950
blanchet@48975
   951
lemma card_of_Fpow_mono[simp]:
blanchet@48975
   952
assumes "|A| \<le>o |B|"
blanchet@48975
   953
shows "|Fpow A| \<le>o |Fpow B|"
blanchet@48975
   954
proof-
blanchet@48975
   955
  obtain f where "inj_on f A \<and> f ` A \<le> B"
blanchet@48975
   956
  using assms card_of_ordLeq[of A B] by auto
blanchet@48975
   957
  hence "inj_on (image f) (Fpow A) \<and> (image f) ` (Fpow A) \<le> (Fpow B)"
blanchet@48975
   958
  by (auto simp add: inj_on_image_Fpow image_Fpow_mono)
blanchet@48975
   959
  thus ?thesis using card_of_ordLeq[of "Fpow A"] by auto
blanchet@48975
   960
qed
blanchet@48975
   961
blanchet@48975
   962
lemma ordIso_Fpow_mono:
blanchet@48975
   963
assumes "r \<le>o r'"
blanchet@48975
   964
shows "|Fpow(Field r)| \<le>o |Fpow(Field r')|"
blanchet@48975
   965
using assms card_of_mono2 card_of_Fpow_mono by blast
blanchet@48975
   966
blanchet@48975
   967
lemma card_of_Fpow_cong[simp]:
blanchet@48975
   968
assumes "|A| =o |B|"
blanchet@48975
   969
shows "|Fpow A| =o |Fpow B|"
blanchet@48975
   970
proof-
blanchet@48975
   971
  obtain f where "bij_betw f A B"
blanchet@48975
   972
  using assms card_of_ordIso[of A B] by auto
blanchet@48975
   973
  hence "bij_betw (image f) (Fpow A) (Fpow B)"
blanchet@48975
   974
  by (auto simp add: bij_betw_image_Fpow)
blanchet@48975
   975
  thus ?thesis using card_of_ordIso[of "Fpow A"] by auto
blanchet@48975
   976
qed
blanchet@48975
   977
blanchet@48975
   978
lemma ordIso_Fpow_cong:
blanchet@48975
   979
assumes "r =o r'"
blanchet@48975
   980
shows "|Fpow(Field r)| =o |Fpow(Field r')|"
blanchet@48975
   981
using assms card_of_cong card_of_Fpow_cong by blast
blanchet@48975
   982
blanchet@48975
   983
lemma card_of_Fpow_lists: "|Fpow A| \<le>o |lists A|"
blanchet@48975
   984
proof-
blanchet@48975
   985
  have "set ` (lists A) = Fpow A"
blanchet@48975
   986
  unfolding lists_def2 Fpow_def using finite_list finite_set by blast
blanchet@48975
   987
  thus ?thesis using card_of_ordLeq2[of "Fpow A"] Fpow_not_empty[of A] by blast
blanchet@48975
   988
qed
blanchet@48975
   989
blanchet@48975
   990
lemma card_of_Fpow_infinite[simp]:
traytel@54578
   991
assumes "\<not>finite A"
blanchet@48975
   992
shows "|Fpow A| =o |A|"
blanchet@48975
   993
using assms card_of_Fpow_lists card_of_lists_infinite card_of_Fpow
blanchet@48975
   994
      ordLeq_ordIso_trans ordIso_iff_ordLeq by blast
blanchet@48975
   995
blanchet@48975
   996
corollary Fpow_infinite_bij_betw:
traytel@54578
   997
assumes "\<not>finite A"
blanchet@48975
   998
shows "\<exists>f. bij_betw f (Fpow A) A"
blanchet@48975
   999
using assms card_of_Fpow_infinite card_of_ordIso by blast
blanchet@48975
  1000
blanchet@48975
  1001
wenzelm@63167
  1002
subsection \<open>The cardinal $\omega$ and the finite cardinals\<close>
blanchet@48975
  1003
wenzelm@63167
  1004
subsubsection \<open>First as well-orders\<close>
blanchet@48975
  1005
blanchet@48975
  1006
lemma Field_natLess: "Field natLess = (UNIV::nat set)"
traytel@56011
  1007
by(unfold Field_def natLess_def, auto)
blanchet@48975
  1008
blanchet@54475
  1009
lemma natLeq_well_order_on: "well_order_on UNIV natLeq"
blanchet@54475
  1010
using natLeq_Well_order Field_natLeq by auto
blanchet@54475
  1011
blanchet@54475
  1012
lemma natLeq_wo_rel: "wo_rel natLeq"
blanchet@54475
  1013
unfolding wo_rel_def using natLeq_Well_order .
blanchet@54475
  1014
blanchet@48975
  1015
lemma natLeq_ofilter_less: "ofilter natLeq {0 ..< n}"
blanchet@48975
  1016
by(auto simp add: natLeq_wo_rel wo_rel.ofilter_def,
traytel@56011
  1017
   simp add: Field_natLeq, unfold under_def natLeq_def, auto)
blanchet@48975
  1018
blanchet@48975
  1019
lemma natLeq_ofilter_leq: "ofilter natLeq {0 .. n}"
blanchet@48975
  1020
by(auto simp add: natLeq_wo_rel wo_rel.ofilter_def,
traytel@56011
  1021
   simp add: Field_natLeq, unfold under_def natLeq_def, auto)
blanchet@54475
  1022
blanchet@54475
  1023
lemma natLeq_UNIV_ofilter: "wo_rel.ofilter natLeq UNIV"
blanchet@54475
  1024
using natLeq_wo_rel Field_natLeq wo_rel.Field_ofilter[of natLeq] by auto
blanchet@48975
  1025
traytel@54581
  1026
lemma closed_nat_set_iff:
traytel@54581
  1027
assumes "\<forall>(m::nat) n. n \<in> A \<and> m \<le> n \<longrightarrow> m \<in> A"
traytel@54581
  1028
shows "A = UNIV \<or> (\<exists>n. A = {0 ..< n})"
traytel@54581
  1029
proof-
traytel@54581
  1030
  {assume "A \<noteq> UNIV" hence "\<exists>n. n \<notin> A" by blast
traytel@54581
  1031
   moreover obtain n where n_def: "n = (LEAST n. n \<notin> A)" by blast
traytel@54581
  1032
   ultimately have 1: "n \<notin> A \<and> (\<forall>m. m < n \<longrightarrow> m \<in> A)"
traytel@54581
  1033
   using LeastI_ex[of "\<lambda> n. n \<notin> A"] n_def Least_le[of "\<lambda> n. n \<notin> A"] by fastforce
traytel@54581
  1034
   have "A = {0 ..< n}"
traytel@54581
  1035
   proof(auto simp add: 1)
traytel@54581
  1036
     fix m assume *: "m \<in> A"
traytel@54581
  1037
     {assume "n \<le> m" with assms * have "n \<in> A" by blast
traytel@54581
  1038
      hence False using 1 by auto
traytel@54581
  1039
     }
traytel@54581
  1040
     thus "m < n" by fastforce
traytel@54581
  1041
   qed
traytel@54581
  1042
   hence "\<exists>n. A = {0 ..< n}" by blast
traytel@54581
  1043
  }
traytel@54581
  1044
  thus ?thesis by blast
traytel@54581
  1045
qed
traytel@54581
  1046
blanchet@48975
  1047
lemma natLeq_ofilter_iff:
blanchet@48975
  1048
"ofilter natLeq A = (A = UNIV \<or> (\<exists>n. A = {0 ..< n}))"
blanchet@48975
  1049
proof(rule iffI)
blanchet@48975
  1050
  assume "ofilter natLeq A"
traytel@56011
  1051
  hence "\<forall>m n. n \<in> A \<and> m \<le> n \<longrightarrow> m \<in> A" using natLeq_wo_rel
traytel@56011
  1052
  by(auto simp add: natLeq_def wo_rel.ofilter_def under_def)
blanchet@48975
  1053
  thus "A = UNIV \<or> (\<exists>n. A = {0 ..< n})" using closed_nat_set_iff by blast
blanchet@48975
  1054
next
blanchet@48975
  1055
  assume "A = UNIV \<or> (\<exists>n. A = {0 ..< n})"
blanchet@48975
  1056
  thus "ofilter natLeq A"
blanchet@48975
  1057
  by(auto simp add: natLeq_ofilter_less natLeq_UNIV_ofilter)
blanchet@48975
  1058
qed
blanchet@48975
  1059
blanchet@48975
  1060
lemma natLeq_under_leq: "under natLeq n = {0 .. n}"
traytel@56011
  1061
unfolding under_def natLeq_def by auto
blanchet@48975
  1062
traytel@54581
  1063
lemma natLeq_on_ofilter_less_eq:
traytel@54581
  1064
"n \<le> m \<Longrightarrow> wo_rel.ofilter (natLeq_on m) {0 ..< n}"
traytel@54581
  1065
apply (auto simp add: natLeq_on_wo_rel wo_rel.ofilter_def)
traytel@54581
  1066
apply (simp add: Field_natLeq_on)
blanchet@55023
  1067
by (auto simp add: under_def)
traytel@54581
  1068
traytel@54581
  1069
lemma natLeq_on_ofilter_iff:
traytel@54581
  1070
"wo_rel.ofilter (natLeq_on m) A = (\<exists>n \<le> m. A = {0 ..< n})"
traytel@54581
  1071
proof(rule iffI)
traytel@54581
  1072
  assume *: "wo_rel.ofilter (natLeq_on m) A"
traytel@54581
  1073
  hence 1: "A \<le> {0..<m}"
blanchet@55023
  1074
  by (auto simp add: natLeq_on_wo_rel wo_rel.ofilter_def under_def Field_natLeq_on)
traytel@54581
  1075
  hence "\<forall>n1 n2. n2 \<in> A \<and> n1 \<le> n2 \<longrightarrow> n1 \<in> A"
blanchet@55023
  1076
  using * by(fastforce simp add: natLeq_on_wo_rel wo_rel.ofilter_def under_def)
traytel@54581
  1077
  hence "A = UNIV \<or> (\<exists>n. A = {0 ..< n})" using closed_nat_set_iff by blast
traytel@54581
  1078
  thus "\<exists>n \<le> m. A = {0 ..< n}" using 1 atLeastLessThan_less_eq by blast
traytel@54581
  1079
next
traytel@54581
  1080
  assume "(\<exists>n\<le>m. A = {0 ..< n})"
traytel@54581
  1081
  thus "wo_rel.ofilter (natLeq_on m) A" by (auto simp add: natLeq_on_ofilter_less_eq)
traytel@54581
  1082
qed
traytel@54581
  1083
blanchet@48975
  1084
corollary natLeq_on_ofilter:
blanchet@48975
  1085
"ofilter(natLeq_on n) {0 ..< n}"
blanchet@48975
  1086
by (auto simp add: natLeq_on_ofilter_less_eq)
blanchet@48975
  1087
blanchet@48975
  1088
lemma natLeq_on_ofilter_less:
blanchet@48975
  1089
"n < m \<Longrightarrow> ofilter (natLeq_on m) {0 .. n}"
blanchet@48975
  1090
by(auto simp add: natLeq_on_wo_rel wo_rel.ofilter_def,
blanchet@55023
  1091
   simp add: Field_natLeq_on, unfold under_def, auto)
blanchet@48975
  1092
blanchet@48975
  1093
lemma natLeq_on_ordLess_natLeq: "natLeq_on n <o natLeq"
traytel@54578
  1094
using Field_natLeq Field_natLeq_on[of n]
blanchet@48975
  1095
      finite_ordLess_infinite[of "natLeq_on n" natLeq]
blanchet@48975
  1096
      natLeq_Well_order natLeq_on_Well_order[of n] by auto
blanchet@48975
  1097
blanchet@48975
  1098
lemma natLeq_on_injective:
blanchet@48975
  1099
"natLeq_on m = natLeq_on n \<Longrightarrow> m = n"
blanchet@48975
  1100
using Field_natLeq_on[of m] Field_natLeq_on[of n]
traytel@54581
  1101
      atLeastLessThan_injective[of m n, unfolded atLeastLessThan_def] by blast
blanchet@48975
  1102
blanchet@48975
  1103
lemma natLeq_on_injective_ordIso:
blanchet@48975
  1104
"(natLeq_on m =o natLeq_on n) = (m = n)"
blanchet@48975
  1105
proof(auto simp add: natLeq_on_Well_order ordIso_reflexive)
blanchet@48975
  1106
  assume "natLeq_on m =o natLeq_on n"
traytel@54581
  1107
  then obtain f where "bij_betw f {x. x<m} {x. x<n}"
wenzelm@63092
  1108
  using Field_natLeq_on unfolding ordIso_def iso_def[abs_def] by auto
traytel@54581
  1109
  thus "m = n" using atLeastLessThan_injective2[of f m n]
traytel@54581
  1110
    unfolding atLeast_0 atLeastLessThan_def lessThan_def Int_UNIV_left by blast
blanchet@48975
  1111
qed
blanchet@48975
  1112
blanchet@48975
  1113
wenzelm@63167
  1114
subsubsection \<open>Then as cardinals\<close>
blanchet@48975
  1115
blanchet@48975
  1116
lemma ordIso_natLeq_infinite1:
traytel@54578
  1117
"|A| =o natLeq \<Longrightarrow> \<not>finite A"
blanchet@48975
  1118
using ordIso_symmetric ordIso_imp_ordLeq infinite_iff_natLeq_ordLeq by blast
blanchet@48975
  1119
blanchet@48975
  1120
lemma ordIso_natLeq_infinite2:
traytel@54578
  1121
"natLeq =o |A| \<Longrightarrow> \<not>finite A"
blanchet@48975
  1122
using ordIso_imp_ordLeq infinite_iff_natLeq_ordLeq by blast
blanchet@48975
  1123
traytel@54581
  1124
lemma ordIso_natLeq_on_imp_finite:
traytel@54581
  1125
"|A| =o natLeq_on n \<Longrightarrow> finite A"
traytel@54581
  1126
unfolding ordIso_def iso_def[abs_def]
traytel@54581
  1127
by (auto simp: Field_natLeq_on bij_betw_finite)
traytel@54581
  1128
traytel@54581
  1129
lemma natLeq_on_Card_order: "Card_order (natLeq_on n)"
traytel@54581
  1130
proof(unfold card_order_on_def,
traytel@54581
  1131
      auto simp add: natLeq_on_Well_order, simp add: Field_natLeq_on)
traytel@54581
  1132
  fix r assume "well_order_on {x. x < n} r"
traytel@54581
  1133
  thus "natLeq_on n \<le>o r"
traytel@54581
  1134
  using finite_atLeastLessThan natLeq_on_well_order_on
traytel@54581
  1135
        finite_well_order_on_ordIso ordIso_iff_ordLeq by blast
traytel@54581
  1136
qed
traytel@54581
  1137
traytel@54581
  1138
corollary card_of_Field_natLeq_on:
traytel@54581
  1139
"|Field (natLeq_on n)| =o natLeq_on n"
traytel@54581
  1140
using Field_natLeq_on natLeq_on_Card_order
traytel@54581
  1141
      Card_order_iff_ordIso_card_of[of "natLeq_on n"]
traytel@54581
  1142
      ordIso_symmetric[of "natLeq_on n"] by blast
traytel@54581
  1143
traytel@54581
  1144
corollary card_of_less:
traytel@54581
  1145
"|{0 ..< n}| =o natLeq_on n"
traytel@54581
  1146
using Field_natLeq_on card_of_Field_natLeq_on
traytel@54581
  1147
unfolding atLeast_0 atLeastLessThan_def lessThan_def Int_UNIV_left by auto
traytel@54581
  1148
traytel@54581
  1149
lemma natLeq_on_ordLeq_less_eq:
traytel@54581
  1150
"((natLeq_on m) \<le>o (natLeq_on n)) = (m \<le> n)"
traytel@54581
  1151
proof
traytel@54581
  1152
  assume "natLeq_on m \<le>o natLeq_on n"
traytel@54581
  1153
  then obtain f where "inj_on f {x. x < m} \<and> f ` {x. x < m} \<le> {x. x < n}"
traytel@54581
  1154
  unfolding ordLeq_def using
traytel@54581
  1155
    embed_inj_on[OF natLeq_on_Well_order[of m], of "natLeq_on n", unfolded Field_natLeq_on]
traytel@54581
  1156
     embed_Field[OF natLeq_on_Well_order[of m], of "natLeq_on n", unfolded Field_natLeq_on] by blast
traytel@54581
  1157
  thus "m \<le> n" using atLeastLessThan_less_eq2
traytel@54581
  1158
    unfolding atLeast_0 atLeastLessThan_def lessThan_def Int_UNIV_left by blast
traytel@54581
  1159
next
traytel@54581
  1160
  assume "m \<le> n"
traytel@54581
  1161
  hence "inj_on id {0..<m} \<and> id ` {0..<m} \<le> {0..<n}" unfolding inj_on_def by auto
traytel@54581
  1162
  hence "|{0..<m}| \<le>o |{0..<n}|" using card_of_ordLeq by blast
traytel@54581
  1163
  thus "natLeq_on m \<le>o natLeq_on n"
traytel@54581
  1164
  using card_of_less ordIso_ordLeq_trans ordLeq_ordIso_trans ordIso_symmetric by blast
traytel@54581
  1165
qed
traytel@54581
  1166
traytel@54581
  1167
lemma natLeq_on_ordLeq_less:
traytel@54581
  1168
"((natLeq_on m) <o (natLeq_on n)) = (m < n)"
traytel@54980
  1169
using not_ordLeq_iff_ordLess[OF natLeq_on_Well_order natLeq_on_Well_order, of n m]
traytel@54980
  1170
   natLeq_on_ordLeq_less_eq[of n m] by linarith
traytel@54581
  1171
blanchet@48975
  1172
lemma ordLeq_natLeq_on_imp_finite:
blanchet@48975
  1173
assumes "|A| \<le>o natLeq_on n"
blanchet@48975
  1174
shows "finite A"
blanchet@48975
  1175
proof-
blanchet@48975
  1176
  have "|A| \<le>o |{0 ..< n}|"
blanchet@48975
  1177
  using assms card_of_less ordIso_symmetric ordLeq_ordIso_trans by blast
blanchet@48975
  1178
  thus ?thesis by (auto simp add: card_of_ordLeq_finite)
blanchet@48975
  1179
qed
blanchet@48975
  1180
blanchet@48975
  1181
wenzelm@63167
  1182
subsubsection \<open>"Backward compatibility" with the numeric cardinal operator for finite sets\<close>
blanchet@48975
  1183
traytel@54581
  1184
lemma finite_card_of_iff_card2:
traytel@54581
  1185
assumes FIN: "finite A" and FIN': "finite B"
traytel@54581
  1186
shows "( |A| \<le>o |B| ) = (card A \<le> card B)"
traytel@54581
  1187
using assms card_of_ordLeq[of A B] inj_on_iff_card_le[of A B] by blast
traytel@54581
  1188
traytel@54581
  1189
lemma finite_imp_card_of_natLeq_on:
traytel@54581
  1190
assumes "finite A"
traytel@54581
  1191
shows "|A| =o natLeq_on (card A)"
traytel@54581
  1192
proof-
traytel@54581
  1193
  obtain h where "bij_betw h A {0 ..< card A}"
traytel@54581
  1194
  using assms ex_bij_betw_finite_nat by blast
traytel@54581
  1195
  thus ?thesis using card_of_ordIso card_of_less ordIso_equivalence by blast
traytel@54581
  1196
qed
traytel@54581
  1197
traytel@54581
  1198
lemma finite_iff_card_of_natLeq_on:
traytel@54581
  1199
"finite A = (\<exists>n. |A| =o natLeq_on n)"
traytel@54581
  1200
using finite_imp_card_of_natLeq_on[of A]
traytel@54581
  1201
by(auto simp add: ordIso_natLeq_on_imp_finite)
traytel@54581
  1202
blanchet@48975
  1203
lemma finite_card_of_iff_card:
blanchet@48975
  1204
assumes FIN: "finite A" and FIN': "finite B"
blanchet@48975
  1205
shows "( |A| =o |B| ) = (card A = card B)"
blanchet@48975
  1206
using assms card_of_ordIso[of A B] bij_betw_iff_card[of A B] by blast
blanchet@48975
  1207
blanchet@48975
  1208
lemma finite_card_of_iff_card3:
blanchet@48975
  1209
assumes FIN: "finite A" and FIN': "finite B"
blanchet@48975
  1210
shows "( |A| <o |B| ) = (card A < card B)"
blanchet@48975
  1211
proof-
blanchet@48975
  1212
  have "( |A| <o |B| ) = (~ ( |B| \<le>o |A| ))" by simp
blanchet@48975
  1213
  also have "... = (~ (card B \<le> card A))"
blanchet@48975
  1214
  using assms by(simp add: finite_card_of_iff_card2)
blanchet@48975
  1215
  also have "... = (card A < card B)" by auto
blanchet@48975
  1216
  finally show ?thesis .
blanchet@48975
  1217
qed
blanchet@48975
  1218
blanchet@48975
  1219
lemma card_Field_natLeq_on:
blanchet@48975
  1220
"card(Field(natLeq_on n)) = n"
blanchet@48975
  1221
using Field_natLeq_on card_atLeastLessThan by auto
blanchet@48975
  1222
blanchet@48975
  1223
wenzelm@63167
  1224
subsection \<open>The successor of a cardinal\<close>
blanchet@48975
  1225
blanchet@48975
  1226
lemma embed_implies_ordIso_Restr:
blanchet@48975
  1227
assumes WELL: "Well_order r" and WELL': "Well_order r'" and EMB: "embed r' r f"
blanchet@48975
  1228
shows "r' =o Restr r (f ` (Field r'))"
blanchet@48975
  1229
using assms embed_implies_iso_Restr Well_order_Restr unfolding ordIso_def by blast
blanchet@48975
  1230
blanchet@48975
  1231
lemma cardSuc_Well_order[simp]:
blanchet@48975
  1232
"Card_order r \<Longrightarrow> Well_order(cardSuc r)"
blanchet@48975
  1233
using cardSuc_Card_order unfolding card_order_on_def by blast
blanchet@48975
  1234
blanchet@48975
  1235
lemma Field_cardSuc_not_empty:
blanchet@48975
  1236
assumes "Card_order r"
blanchet@48975
  1237
shows "Field (cardSuc r) \<noteq> {}"
blanchet@48975
  1238
proof
blanchet@48975
  1239
  assume "Field(cardSuc r) = {}"
blanchet@48975
  1240
  hence "|Field(cardSuc r)| \<le>o r" using assms Card_order_empty[of r] by auto
blanchet@48975
  1241
  hence "cardSuc r \<le>o r" using assms card_of_Field_ordIso
blanchet@48975
  1242
  cardSuc_Card_order ordIso_symmetric ordIso_ordLeq_trans by blast
blanchet@48975
  1243
  thus False using cardSuc_greater not_ordLess_ordLeq assms by blast
blanchet@48975
  1244
qed
blanchet@48975
  1245
blanchet@48975
  1246
lemma cardSuc_mono_ordLess[simp]:
blanchet@48975
  1247
assumes CARD: "Card_order r" and CARD': "Card_order r'"
blanchet@48975
  1248
shows "(cardSuc r <o cardSuc r') = (r <o r')"
blanchet@48975
  1249
proof-
blanchet@48975
  1250
  have 0: "Well_order r \<and> Well_order r' \<and> Well_order(cardSuc r) \<and> Well_order(cardSuc r')"
blanchet@48975
  1251
  using assms by auto
blanchet@48975
  1252
  thus ?thesis
blanchet@48975
  1253
  using not_ordLeq_iff_ordLess not_ordLeq_iff_ordLess[of r r']
blanchet@48975
  1254
  using cardSuc_mono_ordLeq[of r' r] assms by blast
blanchet@48975
  1255
qed
blanchet@48975
  1256
traytel@54581
  1257
lemma cardSuc_natLeq_on_Suc:
traytel@54581
  1258
"cardSuc(natLeq_on n) =o natLeq_on(Suc n)"
traytel@54581
  1259
proof-
traytel@54581
  1260
  obtain r r' p where r_def: "r = natLeq_on n" and
traytel@54581
  1261
                      r'_def: "r' = cardSuc(natLeq_on n)"  and
traytel@54581
  1262
                      p_def: "p = natLeq_on(Suc n)" by blast
traytel@54581
  1263
  (* Preliminary facts:  *)
traytel@54581
  1264
  have CARD: "Card_order r \<and> Card_order r' \<and> Card_order p" unfolding r_def r'_def p_def
traytel@54581
  1265
  using cardSuc_ordLess_ordLeq natLeq_on_Card_order cardSuc_Card_order by blast
traytel@54581
  1266
  hence WELL: "Well_order r \<and> Well_order r' \<and>  Well_order p"
traytel@54581
  1267
  unfolding card_order_on_def by force
traytel@54581
  1268
  have FIELD: "Field r = {0..<n} \<and> Field p = {0..<(Suc n)}"
traytel@54581
  1269
  unfolding r_def p_def Field_natLeq_on atLeast_0 atLeastLessThan_def lessThan_def by simp
traytel@54581
  1270
  hence FIN: "finite (Field r)" by force
traytel@54581
  1271
  have "r <o r'" using CARD unfolding r_def r'_def using cardSuc_greater by blast
traytel@54581
  1272
  hence "|Field r| <o r'" using CARD card_of_Field_ordIso ordIso_ordLess_trans by blast
traytel@54581
  1273
  hence LESS: "|Field r| <o |Field r'|"
traytel@54581
  1274
  using CARD card_of_Field_ordIso ordLess_ordIso_trans ordIso_symmetric by blast
traytel@54581
  1275
  (* Main proof: *)
traytel@54581
  1276
  have "r' \<le>o p" using CARD unfolding r_def r'_def p_def
traytel@54581
  1277
  using natLeq_on_ordLeq_less cardSuc_ordLess_ordLeq by blast
traytel@54581
  1278
  moreover have "p \<le>o r'"
traytel@54581
  1279
  proof-
traytel@54581
  1280
    {assume "r' <o p"
traytel@54581
  1281
     then obtain f where 0: "embedS r' p f" unfolding ordLess_def by force
traytel@54581
  1282
     let ?q = "Restr p (f ` Field r')"
traytel@54581
  1283
     have 1: "embed r' p f" using 0 unfolding embedS_def by force
traytel@54581
  1284
     hence 2: "f ` Field r' < {0..<(Suc n)}"
traytel@54581
  1285
     using WELL FIELD 0 by (auto simp add: embedS_iff)
traytel@54581
  1286
     have "wo_rel.ofilter p (f ` Field r')" using embed_Field_ofilter 1 WELL by blast
traytel@54581
  1287
     then obtain m where "m \<le> Suc n" and 3: "f ` (Field r') = {0..<m}"
traytel@54581
  1288
     unfolding p_def by (auto simp add: natLeq_on_ofilter_iff)
traytel@54581
  1289
     hence 4: "m \<le> n" using 2 by force
traytel@54581
  1290
     (*  *)
traytel@54581
  1291
     have "bij_betw f (Field r') (f ` (Field r'))"
traytel@54980
  1292
     using WELL embed_inj_on[OF _ 1] unfolding bij_betw_def by blast
traytel@54581
  1293
     moreover have "finite(f ` (Field r'))" using 3 finite_atLeastLessThan[of 0 m] by force
traytel@54581
  1294
     ultimately have 5: "finite (Field r') \<and> card(Field r') = card (f ` (Field r'))"
traytel@54581
  1295
     using bij_betw_same_card bij_betw_finite by metis
traytel@54581
  1296
     hence "card(Field r') \<le> card(Field r)" using 3 4 FIELD by force
traytel@54581
  1297
     hence "|Field r'| \<le>o |Field r|" using FIN 5 finite_card_of_iff_card2 by blast
traytel@54581
  1298
     hence False using LESS not_ordLess_ordLeq by auto
traytel@54581
  1299
    }
traytel@54581
  1300
    thus ?thesis using WELL CARD by fastforce
traytel@54581
  1301
  qed
traytel@54581
  1302
  ultimately show ?thesis using ordIso_iff_ordLeq unfolding r'_def p_def by blast
traytel@54581
  1303
qed
traytel@54581
  1304
blanchet@48975
  1305
lemma card_of_Plus_ordLeq_infinite[simp]:
traytel@54578
  1306
assumes C: "\<not>finite C" and A: "|A| \<le>o |C|" and B: "|B| \<le>o |C|"
blanchet@48975
  1307
shows "|A <+> B| \<le>o |C|"
blanchet@48975
  1308
proof-
blanchet@48975
  1309
  let ?r = "cardSuc |C|"
traytel@54578
  1310
  have "Card_order ?r \<and> \<not>finite (Field ?r)" using assms by simp
blanchet@48975
  1311
  moreover have "|A| <o ?r" and "|B| <o ?r" using A B by auto
blanchet@48975
  1312
  ultimately have "|A <+> B| <o ?r"
blanchet@48975
  1313
  using card_of_Plus_ordLess_infinite_Field by blast
blanchet@48975
  1314
  thus ?thesis using C by simp
blanchet@48975
  1315
qed
blanchet@48975
  1316
blanchet@48975
  1317
lemma card_of_Un_ordLeq_infinite[simp]:
traytel@54578
  1318
assumes C: "\<not>finite C" and A: "|A| \<le>o |C|" and B: "|B| \<le>o |C|"
blanchet@48975
  1319
shows "|A Un B| \<le>o |C|"
blanchet@48975
  1320
using assms card_of_Plus_ordLeq_infinite card_of_Un_Plus_ordLeq
blanchet@48975
  1321
ordLeq_transitive by metis
blanchet@48975
  1322
blanchet@48975
  1323
wenzelm@63167
  1324
subsection \<open>Others\<close>
blanchet@48975
  1325
blanchet@48975
  1326
lemma under_mono[simp]:
blanchet@48975
  1327
assumes "Well_order r" and "(i,j) \<in> r"
blanchet@48975
  1328
shows "under r i \<subseteq> under r j"
blanchet@55023
  1329
using assms unfolding under_def order_on_defs
blanchet@48975
  1330
trans_def by blast
blanchet@48975
  1331
blanchet@48975
  1332
lemma underS_under:
blanchet@48975
  1333
assumes "i \<in> Field r"
blanchet@48975
  1334
shows "underS r i = under r i - {i}"
blanchet@55023
  1335
using assms unfolding underS_def under_def by auto
blanchet@48975
  1336
blanchet@48975
  1337
lemma relChain_under:
blanchet@48975
  1338
assumes "Well_order r"
blanchet@48975
  1339
shows "relChain r (\<lambda> i. under r i)"
blanchet@48975
  1340
using assms unfolding relChain_def by auto
blanchet@48975
  1341
blanchet@54475
  1342
lemma card_of_infinite_diff_finite:
traytel@54578
  1343
assumes "\<not>finite A" and "finite B"
blanchet@54475
  1344
shows "|A - B| =o |A|"
blanchet@54475
  1345
by (metis assms card_of_Un_diff_infinite finite_ordLess_infinite2)
blanchet@54475
  1346
blanchet@48975
  1347
lemma infinite_card_of_diff_singl:
traytel@54578
  1348
assumes "\<not>finite A"
blanchet@48975
  1349
shows "|A - {a}| =o |A|"
traytel@52544
  1350
by (metis assms card_of_infinite_diff_finite finite.emptyI finite_insert)
blanchet@48975
  1351
blanchet@48975
  1352
lemma card_of_vimage:
blanchet@48975
  1353
assumes "B \<subseteq> range f"
blanchet@48975
  1354
shows "|B| \<le>o |f -` B|"
blanchet@48975
  1355
apply(rule surj_imp_ordLeq[of _ f])
blanchet@48975
  1356
using assms by (metis Int_absorb2 image_vimage_eq order_refl)
blanchet@48975
  1357
blanchet@48975
  1358
lemma surj_card_of_vimage:
blanchet@48975
  1359
assumes "surj f"
blanchet@48975
  1360
shows "|B| \<le>o |f -` B|"
blanchet@48975
  1361
by (metis assms card_of_vimage subset_UNIV)
blanchet@48975
  1362
traytel@54794
  1363
lemma infinite_Pow:
traytel@54794
  1364
assumes "\<not> finite A"
traytel@54794
  1365
shows "\<not> finite (Pow A)"
traytel@54794
  1366
proof-
traytel@54794
  1367
  have "|A| \<le>o |Pow A|" by (metis card_of_Pow ordLess_imp_ordLeq)
traytel@54794
  1368
  thus ?thesis by (metis assms finite_Pow_iff)
traytel@54794
  1369
qed
traytel@54794
  1370
blanchet@48975
  1371
(* bounded powerset *)
blanchet@48975
  1372
definition Bpow where
blanchet@48975
  1373
"Bpow r A \<equiv> {X . X \<subseteq> A \<and> |X| \<le>o r}"
blanchet@48975
  1374
blanchet@48975
  1375
lemma Bpow_empty[simp]:
blanchet@48975
  1376
assumes "Card_order r"
blanchet@48975
  1377
shows "Bpow r {} = {{}}"
blanchet@48975
  1378
using assms unfolding Bpow_def by auto
blanchet@48975
  1379
blanchet@48975
  1380
lemma singl_in_Bpow:
blanchet@48975
  1381
assumes rc: "Card_order r"
blanchet@48975
  1382
and r: "Field r \<noteq> {}" and a: "a \<in> A"
blanchet@48975
  1383
shows "{a} \<in> Bpow r A"
blanchet@48975
  1384
proof-
blanchet@48975
  1385
  have "|{a}| \<le>o r" using r rc by auto
blanchet@48975
  1386
  thus ?thesis unfolding Bpow_def using a by auto
blanchet@48975
  1387
qed
blanchet@48975
  1388
blanchet@48975
  1389
lemma ordLeq_card_Bpow:
blanchet@48975
  1390
assumes rc: "Card_order r" and r: "Field r \<noteq> {}"
blanchet@48975
  1391
shows "|A| \<le>o |Bpow r A|"
blanchet@48975
  1392
proof-
blanchet@48975
  1393
  have "inj_on (\<lambda> a. {a}) A" unfolding inj_on_def by auto
blanchet@48975
  1394
  moreover have "(\<lambda> a. {a}) ` A \<subseteq> Bpow r A"
blanchet@48975
  1395
  using singl_in_Bpow[OF assms] by auto
blanchet@48975
  1396
  ultimately show ?thesis unfolding card_of_ordLeq[symmetric] by blast
blanchet@48975
  1397
qed
blanchet@48975
  1398
blanchet@48975
  1399
lemma infinite_Bpow:
blanchet@48975
  1400
assumes rc: "Card_order r" and r: "Field r \<noteq> {}"
traytel@54578
  1401
and A: "\<not>finite A"
traytel@54578
  1402
shows "\<not>finite (Bpow r A)"
blanchet@48975
  1403
using ordLeq_card_Bpow[OF rc r]
blanchet@48975
  1404
by (metis A card_of_ordLeq_infinite)
blanchet@48975
  1405
traytel@52545
  1406
definition Func_option where
traytel@52545
  1407
 "Func_option A B \<equiv>
traytel@52545
  1408
  {f. (\<forall> a. f a \<noteq> None \<longleftrightarrow> a \<in> A) \<and> (\<forall> a \<in> A. case f a of Some b \<Rightarrow> b \<in> B |None \<Rightarrow> True)}"
traytel@52545
  1409
traytel@52545
  1410
lemma card_of_Func_option_Func:
traytel@52545
  1411
"|Func_option A B| =o |Func A B|"
traytel@52545
  1412
proof (rule ordIso_symmetric, unfold card_of_ordIso[symmetric], intro exI)
traytel@52545
  1413
  let ?F = "\<lambda> f a. if a \<in> A then Some (f a) else None"
traytel@52545
  1414
  show "bij_betw ?F (Func A B) (Func_option A B)"
traytel@52545
  1415
  unfolding bij_betw_def unfolding inj_on_def proof(intro conjI ballI impI)
traytel@52545
  1416
    fix f g assume f: "f \<in> Func A B" and g: "g \<in> Func A B" and eq: "?F f = ?F g"
traytel@52545
  1417
    show "f = g"
traytel@52545
  1418
    proof(rule ext)
traytel@52545
  1419
      fix a
traytel@52545
  1420
      show "f a = g a"
traytel@52545
  1421
      proof(cases "a \<in> A")
traytel@52545
  1422
        case True
traytel@52545
  1423
        have "Some (f a) = ?F f a" using True by auto
traytel@52545
  1424
        also have "... = ?F g a" using eq unfolding fun_eq_iff by(rule allE)
traytel@52545
  1425
        also have "... = Some (g a)" using True by auto
traytel@52545
  1426
        finally have "Some (f a) = Some (g a)" .
traytel@52545
  1427
        thus ?thesis by simp
traytel@52545
  1428
      qed(insert f g, unfold Func_def, auto)
traytel@52545
  1429
    qed
traytel@52545
  1430
  next
traytel@52545
  1431
    show "?F ` Func A B = Func_option A B"
traytel@52545
  1432
    proof safe
traytel@52545
  1433
      fix f assume f: "f \<in> Func_option A B"
wenzelm@63040
  1434
      define g where [abs_def]: "g a = (case f a of Some b \<Rightarrow> b | None \<Rightarrow> undefined)" for a
traytel@52545
  1435
      have "g \<in> Func A B"
traytel@52545
  1436
      using f unfolding g_def Func_def Func_option_def by force+
traytel@52545
  1437
      moreover have "f = ?F g"
traytel@52545
  1438
      proof(rule ext)
traytel@52545
  1439
        fix a show "f a = ?F g a"
traytel@52545
  1440
        using f unfolding Func_option_def g_def by (cases "a \<in> A") force+
traytel@52545
  1441
      qed
traytel@52545
  1442
      ultimately show "f \<in> ?F ` (Func A B)" by blast
traytel@52545
  1443
    qed(unfold Func_def Func_option_def, auto)
traytel@52545
  1444
  qed
traytel@52545
  1445
qed
traytel@52545
  1446
traytel@52545
  1447
(* partial-function space: *)
traytel@52545
  1448
definition Pfunc where
traytel@52545
  1449
"Pfunc A B \<equiv>
traytel@52545
  1450
 {f. (\<forall>a. f a \<noteq> None \<longrightarrow> a \<in> A) \<and>
traytel@52545
  1451
     (\<forall>a. case f a of None \<Rightarrow> True | Some b \<Rightarrow> b \<in> B)}"
traytel@52545
  1452
traytel@52545
  1453
lemma Func_Pfunc:
traytel@52545
  1454
"Func_option A B \<subseteq> Pfunc A B"
traytel@52545
  1455
unfolding Func_option_def Pfunc_def by auto
traytel@52545
  1456
traytel@52545
  1457
lemma Pfunc_Func_option:
wenzelm@60585
  1458
"Pfunc A B = (\<Union>A' \<in> Pow A. Func_option A' B)"
traytel@52545
  1459
proof safe
traytel@52545
  1460
  fix f assume f: "f \<in> Pfunc A B"
traytel@52545
  1461
  show "f \<in> (\<Union>A'\<in>Pow A. Func_option A' B)"
traytel@52545
  1462
  proof (intro UN_I)
traytel@52545
  1463
    let ?A' = "{a. f a \<noteq> None}"
traytel@52545
  1464
    show "?A' \<in> Pow A" using f unfolding Pow_def Pfunc_def by auto
traytel@52545
  1465
    show "f \<in> Func_option ?A' B" using f unfolding Func_option_def Pfunc_def by auto
traytel@52545
  1466
  qed
traytel@52545
  1467
next
traytel@52545
  1468
  fix f A' assume "f \<in> Func_option A' B" and "A' \<subseteq> A"
traytel@52545
  1469
  thus "f \<in> Pfunc A B" unfolding Func_option_def Pfunc_def by auto
traytel@52545
  1470
qed
traytel@52545
  1471
blanchet@54475
  1472
lemma card_of_Func_mono:
blanchet@54475
  1473
fixes A1 A2 :: "'a set" and B :: "'b set"
blanchet@54475
  1474
assumes A12: "A1 \<subseteq> A2" and B: "B \<noteq> {}"
blanchet@54475
  1475
shows "|Func A1 B| \<le>o |Func A2 B|"
blanchet@54475
  1476
proof-
blanchet@54475
  1477
  obtain bb where bb: "bb \<in> B" using B by auto
wenzelm@63040
  1478
  define F where [abs_def]: "F f1 a =
wenzelm@63040
  1479
    (if a \<in> A2 then (if a \<in> A1 then f1 a else bb) else undefined)" for f1 :: "'a \<Rightarrow> 'b" and a
blanchet@54475
  1480
  show ?thesis unfolding card_of_ordLeq[symmetric] proof(intro exI[of _ F] conjI)
blanchet@54475
  1481
    show "inj_on F (Func A1 B)" unfolding inj_on_def proof safe
blanchet@54475
  1482
      fix f g assume f: "f \<in> Func A1 B" and g: "g \<in> Func A1 B" and eq: "F f = F g"
blanchet@54475
  1483
      show "f = g"
blanchet@54475
  1484
      proof(rule ext)
blanchet@54475
  1485
        fix a show "f a = g a"
blanchet@54475
  1486
        proof(cases "a \<in> A1")
blanchet@54475
  1487
          case True
blanchet@54475
  1488
          thus ?thesis using eq A12 unfolding F_def fun_eq_iff
blanchet@54475
  1489
          by (elim allE[of _ a]) auto
blanchet@54475
  1490
        qed(insert f g, unfold Func_def, fastforce)
blanchet@54475
  1491
      qed
blanchet@54475
  1492
    qed
blanchet@54475
  1493
  qed(insert bb, unfold Func_def F_def, force)
blanchet@54475
  1494
qed
blanchet@54475
  1495
traytel@52545
  1496
lemma card_of_Func_option_mono:
traytel@52545
  1497
fixes A1 A2 :: "'a set" and B :: "'b set"
traytel@52545
  1498
assumes A12: "A1 \<subseteq> A2" and B: "B \<noteq> {}"
traytel@52545
  1499
shows "|Func_option A1 B| \<le>o |Func_option A2 B|"
traytel@52545
  1500
by (metis card_of_Func_mono[OF A12 B] card_of_Func_option_Func
traytel@52545
  1501
  ordIso_ordLeq_trans ordLeq_ordIso_trans ordIso_symmetric)
traytel@52545
  1502
traytel@52545
  1503
lemma card_of_Pfunc_Pow_Func_option:
traytel@52545
  1504
assumes "B \<noteq> {}"
wenzelm@61943
  1505
shows "|Pfunc A B| \<le>o |Pow A \<times> Func_option A B|"
traytel@52545
  1506
proof-
wenzelm@60585
  1507
  have "|Pfunc A B| =o |\<Union>A' \<in> Pow A. Func_option A' B|" (is "_ =o ?K")
traytel@52545
  1508
    unfolding Pfunc_Func_option by(rule card_of_refl)
traytel@52545
  1509
  also have "?K \<le>o |Sigma (Pow A) (\<lambda> A'. Func_option A' B)|" using card_of_UNION_Sigma .
wenzelm@61943
  1510
  also have "|Sigma (Pow A) (\<lambda> A'. Func_option A' B)| \<le>o |Pow A \<times> Func_option A B|"
traytel@52545
  1511
    apply(rule card_of_Sigma_mono1) using card_of_Func_option_mono[OF _ assms] by auto
traytel@52545
  1512
  finally show ?thesis .
traytel@52545
  1513
qed
traytel@52545
  1514
blanchet@48975
  1515
lemma Bpow_ordLeq_Func_Field:
traytel@54578
  1516
assumes rc: "Card_order r" and r: "Field r \<noteq> {}" and A: "\<not>finite A"
blanchet@48975
  1517
shows "|Bpow r A| \<le>o |Func (Field r) A|"
blanchet@48975
  1518
proof-
traytel@52545
  1519
  let ?F = "\<lambda> f. {x | x a. f a = x \<and> a \<in> Field r}"
blanchet@48975
  1520
  {fix X assume "X \<in> Bpow r A - {{}}"
blanchet@48975
  1521
   hence XA: "X \<subseteq> A" and "|X| \<le>o r"
blanchet@48975
  1522
   and X: "X \<noteq> {}" unfolding Bpow_def by auto
blanchet@48975
  1523
   hence "|X| \<le>o |Field r|" by (metis Field_card_of card_of_mono2)
blanchet@48975
  1524
   then obtain F where 1: "X = F ` (Field r)"
blanchet@48975
  1525
   using card_of_ordLeq2[OF X] by metis
wenzelm@63040
  1526
   define f where [abs_def]: "f i = (if i \<in> Field r then F i else undefined)" for i
blanchet@48975
  1527
   have "\<exists> f \<in> Func (Field r) A. X = ?F f"
blanchet@48975
  1528
   apply (intro bexI[of _ f]) using 1 XA unfolding Func_def f_def by auto
blanchet@48975
  1529
  }
blanchet@48975
  1530
  hence "Bpow r A - {{}} \<subseteq> ?F ` (Func (Field r) A)" by auto
blanchet@48975
  1531
  hence "|Bpow r A - {{}}| \<le>o |Func (Field r) A|"
blanchet@48975
  1532
  by (rule surj_imp_ordLeq)
blanchet@48975
  1533
  moreover
traytel@54578
  1534
  {have 2: "\<not>finite (Bpow r A)" using infinite_Bpow[OF rc r A] .
blanchet@48975
  1535
   have "|Bpow r A| =o |Bpow r A - {{}}|"
traytel@54578
  1536
     by (metis 2 infinite_card_of_diff_singl ordIso_symmetric)
blanchet@48975
  1537
  }
blanchet@48975
  1538
  ultimately show ?thesis by (metis ordIso_ordLeq_trans)
blanchet@48975
  1539
qed
blanchet@48975
  1540
blanchet@48975
  1541
lemma empty_in_Func[simp]:
traytel@52545
  1542
"B \<noteq> {} \<Longrightarrow> (\<lambda>x. undefined) \<in> Func {} B"
blanchet@48975
  1543
unfolding Func_def by auto
blanchet@48975
  1544
blanchet@48975
  1545
lemma Func_mono[simp]:
blanchet@48975
  1546
assumes "B1 \<subseteq> B2"
blanchet@48975
  1547
shows "Func A B1 \<subseteq> Func A B2"
blanchet@48975
  1548
using assms unfolding Func_def by force
blanchet@48975
  1549
blanchet@48975
  1550
lemma Pfunc_mono[simp]:
blanchet@48975
  1551
assumes "A1 \<subseteq> A2" and "B1 \<subseteq> B2"
blanchet@48975
  1552
shows "Pfunc A B1 \<subseteq> Pfunc A B2"
wenzelm@59166
  1553
using assms unfolding Pfunc_def
wenzelm@59166
  1554
apply safe
wenzelm@59166
  1555
apply (case_tac "x a", auto)
wenzelm@59166
  1556
apply (metis in_mono option.simps(5))
wenzelm@59166
  1557
done
blanchet@48975
  1558
blanchet@48975
  1559
lemma card_of_Func_UNIV_UNIV:
blanchet@48975
  1560
"|Func (UNIV::'a set) (UNIV::'b set)| =o |UNIV::('a \<Rightarrow> 'b) set|"
blanchet@48975
  1561
using card_of_Func_UNIV[of "UNIV::'b set"] by auto
blanchet@48975
  1562
blanchet@54475
  1563
lemma ordLeq_Func:
blanchet@54475
  1564
assumes "{b1,b2} \<subseteq> B" "b1 \<noteq> b2"
blanchet@54475
  1565
shows "|A| \<le>o |Func A B|"
blanchet@54475
  1566
unfolding card_of_ordLeq[symmetric] proof(intro exI conjI)
blanchet@54475
  1567
  let ?F = "\<lambda> aa a. if a \<in> A then (if a = aa then b1 else b2) else undefined"
blanchet@54475
  1568
  show "inj_on ?F A" using assms unfolding inj_on_def fun_eq_iff by auto
blanchet@54475
  1569
  show "?F ` A \<subseteq> Func A B" using assms unfolding Func_def by auto
blanchet@54475
  1570
qed
blanchet@54475
  1571
blanchet@54475
  1572
lemma infinite_Func:
traytel@54578
  1573
assumes A: "\<not>finite A" and B: "{b1,b2} \<subseteq> B" "b1 \<noteq> b2"
traytel@54578
  1574
shows "\<not>finite (Func A B)"
blanchet@54475
  1575
using ordLeq_Func[OF B] by (metis A card_of_ordLeq_finite)
blanchet@54475
  1576
blanchet@55102
  1577
wenzelm@63167
  1578
subsection \<open>Infinite cardinals are limit ordinals\<close>
traytel@54980
  1579
traytel@54980
  1580
lemma card_order_infinite_isLimOrd:
traytel@54980
  1581
assumes c: "Card_order r" and i: "\<not>finite (Field r)"
traytel@54980
  1582
shows "isLimOrd r"
traytel@54980
  1583
proof-
traytel@54980
  1584
  have 0: "wo_rel r" and 00: "Well_order r"
traytel@54980
  1585
  using c unfolding card_order_on_def wo_rel_def by auto
traytel@54980
  1586
  hence rr: "Refl r" by (metis wo_rel.REFL)
traytel@54980
  1587
  show ?thesis unfolding wo_rel.isLimOrd_def[OF 0] wo_rel.isSuccOrd_def[OF 0] proof safe
traytel@54980
  1588
    fix j assume j: "j \<in> Field r" and jm: "\<forall>i\<in>Field r. (i, j) \<in> r"
wenzelm@63040
  1589
    define p where "p = Restr r (Field r - {j})"
traytel@54980
  1590
    have fp: "Field p = Field r - {j}"
traytel@54980
  1591
    unfolding p_def apply(rule Refl_Field_Restr2[OF rr]) by auto
traytel@54980
  1592
    have of: "ofilter r (Field p)" unfolding wo_rel.ofilter_def[OF 0] proof safe
traytel@54980
  1593
      fix a x assume a: "a \<in> Field p" and "x \<in> under r a"
blanchet@55023
  1594
      hence x: "(x,a) \<in> r" "x \<in> Field r" unfolding under_def Field_def by auto
traytel@54980
  1595
      moreover have a: "a \<noteq> j" "a \<in> Field r" "(a,j) \<in> r" using a jm  unfolding fp by auto
traytel@54980
  1596
      ultimately have "x \<noteq> j" using j jm  by (metis 0 wo_rel.max2_def wo_rel.max2_equals1)
traytel@54980
  1597
      thus "x \<in> Field p" using x unfolding fp by auto
traytel@54980
  1598
    qed(unfold p_def Field_def, auto)
traytel@54980
  1599
    have "p <o r" using j ofilter_ordLess[OF 00 of] unfolding fp p_def[symmetric] by auto
blanchet@55056
  1600
    hence 2: "|Field p| <o r" using c by (metis BNF_Cardinal_Order_Relation.ordLess_Field)
traytel@54980
  1601
    have "|Field p| =o |Field r|" unfolding fp using i by (metis infinite_card_of_diff_singl)
traytel@54980
  1602
    also have "|Field r| =o r"
traytel@54980
  1603
    using c by (metis card_of_unique ordIso_symmetric)
traytel@54980
  1604
    finally have "|Field p| =o r" .
traytel@54980
  1605
    with 2 show False by (metis not_ordLess_ordIso)
traytel@54980
  1606
  qed
traytel@54980
  1607
qed
traytel@54980
  1608
traytel@54980
  1609
lemma insert_Chain:
traytel@54980
  1610
assumes "Refl r" "C \<in> Chains r" and "i \<in> Field r" and "\<And>j. j \<in> C \<Longrightarrow> (j,i) \<in> r \<or> (i,j) \<in> r"
traytel@54980
  1611
shows "insert i C \<in> Chains r"
traytel@54980
  1612
using assms unfolding Chains_def by (auto dest: refl_onD)
traytel@54980
  1613
traytel@54980
  1614
lemma Collect_insert: "{R j |j. j \<in> insert j1 J} = insert (R j1) {R j |j. j \<in> J}"
traytel@54980
  1615
by auto
traytel@54980
  1616
traytel@54980
  1617
lemma Field_init_seg_of[simp]:
traytel@54980
  1618
"Field init_seg_of = UNIV"
traytel@54980
  1619
unfolding Field_def init_seg_of_def by auto
traytel@54980
  1620
traytel@54980
  1621
lemma refl_init_seg_of[intro, simp]: "refl init_seg_of"
traytel@54980
  1622
unfolding refl_on_def Field_def by auto
traytel@54980
  1623
blanchet@55087
  1624
lemma regularCard_all_ex:
blanchet@55087
  1625
assumes r: "Card_order r"   "regularCard r"
traytel@54980
  1626
and As: "\<And> i j b. b \<in> B \<Longrightarrow> (i,j) \<in> r \<Longrightarrow> P i b \<Longrightarrow> P j b"
traytel@54980
  1627
and Bsub: "\<forall> b \<in> B. \<exists> i \<in> Field r. P i b"
traytel@54980
  1628
and cardB: "|B| <o r"
traytel@54980
  1629
shows "\<exists> i \<in> Field r. \<forall> b \<in> B. P i b"
traytel@54980
  1630
proof-
traytel@54980
  1631
  let ?As = "\<lambda>i. {b \<in> B. P i b}"
traytel@54980
  1632
  have "EX i : Field r. B \<le> ?As i"
blanchet@55087
  1633
  apply(rule regularCard_UNION) using assms unfolding relChain_def by auto
traytel@54980
  1634
  thus ?thesis by auto
traytel@54980
  1635
qed
traytel@54980
  1636
traytel@54980
  1637
lemma relChain_stabilize:
wenzelm@60585
  1638
assumes rc: "relChain r As" and AsB: "(\<Union>i \<in> Field r. As i) \<subseteq> B" and Br: "|B| <o r"
traytel@54980
  1639
and ir: "\<not>finite (Field r)" and cr: "Card_order r"
traytel@54980
  1640
shows "\<exists> i \<in> Field r. As (succ r i) = As i"
traytel@54980
  1641
proof(rule ccontr, auto)
traytel@54980
  1642
  have 0: "wo_rel r" and 00: "Well_order r"
traytel@54980
  1643
  unfolding wo_rel_def by (metis card_order_on_well_order_on cr)+
traytel@54980
  1644
  have L: "isLimOrd r" using ir cr by (metis card_order_infinite_isLimOrd)
wenzelm@60585
  1645
  have AsBs: "(\<Union>i \<in> Field r. As (succ r i)) \<subseteq> B"
traytel@54980
  1646
  using AsB L apply safe by (metis "0" UN_I set_mp wo_rel.isLimOrd_succ)
traytel@54980
  1647
  assume As_s: "\<forall>i\<in>Field r. As (succ r i) \<noteq> As i"
traytel@54980
  1648
  have 1: "\<forall>i j. (i,j) \<in> r \<and> i \<noteq> j \<longrightarrow> As i \<subset> As j"
traytel@54980
  1649
  proof safe
traytel@54980
  1650
    fix i j assume 1: "(i, j) \<in> r" "i \<noteq> j" and Asij: "As i = As j"
traytel@54980
  1651
    hence rij: "(succ r i, j) \<in> r" by (metis "0" wo_rel.succ_smallest)
traytel@54980
  1652
    hence "As (succ r i) \<subseteq> As j" using rc unfolding relChain_def by auto
traytel@54980
  1653
    moreover
traytel@54980
  1654
    {have "(i,succ r i) \<in> r" apply(rule wo_rel.succ_in[OF 0])
blanchet@55023
  1655
     using 1 unfolding aboveS_def by auto
traytel@54980
  1656
     hence "As i \<subset> As (succ r i)" using As_s rc rij unfolding relChain_def Field_def by auto
traytel@54980
  1657
    }
traytel@54980
  1658
    ultimately show False unfolding Asij by auto
traytel@54980
  1659
  qed (insert rc, unfold relChain_def, auto)
traytel@54980
  1660
  hence "\<forall> i \<in> Field r. \<exists> a. a \<in> As (succ r i) - As i"
traytel@54980
  1661
  using wo_rel.succ_in[OF 0] AsB
traytel@54980
  1662
  by(metis 0 card_order_infinite_isLimOrd cr ir psubset_imp_ex_mem
traytel@54980
  1663
            wo_rel.isLimOrd_aboveS wo_rel.succ_diff)
traytel@54980
  1664
  then obtain f where f: "\<forall> i \<in> Field r. f i \<in> As (succ r i) - As i" by metis
traytel@54980
  1665
  have "inj_on f (Field r)" unfolding inj_on_def proof safe
traytel@54980
  1666
    fix i j assume ij: "i \<in> Field r" "j \<in> Field r" and fij: "f i = f j"
traytel@54980
  1667
    show "i = j"
traytel@54980
  1668
    proof(cases rule: wo_rel.cases_Total3[OF 0], safe)
traytel@54980
  1669
      assume "(i, j) \<in> r" and ijd: "i \<noteq> j"
traytel@54980
  1670
      hence rij: "(succ r i, j) \<in> r" by (metis "0" wo_rel.succ_smallest)
traytel@54980
  1671
      hence "As (succ r i) \<subseteq> As j" using rc unfolding relChain_def by auto
traytel@54980
  1672
      thus "i = j" using ij ijd fij f by auto
traytel@54980
  1673
    next
traytel@54980
  1674
      assume "(j, i) \<in> r" and ijd: "i \<noteq> j"
traytel@54980
  1675
      hence rij: "(succ r j, i) \<in> r" by (metis "0" wo_rel.succ_smallest)
traytel@54980
  1676
      hence "As (succ r j) \<subseteq> As i" using rc unfolding relChain_def by auto
traytel@54980
  1677
      thus "j = i" using ij ijd fij f by fastforce
traytel@54980
  1678
    qed(insert ij, auto)
traytel@54980
  1679
  qed
traytel@54980
  1680
  moreover have "f ` (Field r) \<subseteq> B" using f AsBs by auto
traytel@54980
  1681
  moreover have "|B| <o |Field r|" using Br cr by (metis card_of_unique ordLess_ordIso_trans)
traytel@54980
  1682
  ultimately show False unfolding card_of_ordLess[symmetric] by auto
traytel@54980
  1683
qed
traytel@54980
  1684
blanchet@55102
  1685
wenzelm@63167
  1686
subsection \<open>Regular vs. stable cardinals\<close>
traytel@54980
  1687
traytel@54980
  1688
definition stable :: "'a rel \<Rightarrow> bool"
traytel@54980
  1689
where
traytel@54980
  1690
"stable r \<equiv> \<forall>(A::'a set) (F :: 'a \<Rightarrow> 'a set).
traytel@54980
  1691
               |A| <o r \<and> (\<forall>a \<in> A. |F a| <o r)
traytel@54980
  1692
               \<longrightarrow> |SIGMA a : A. F a| <o r"
traytel@54980
  1693
blanchet@55087
  1694
lemma regularCard_stable:
blanchet@55087
  1695
assumes cr: "Card_order r" and ir: "\<not>finite (Field r)" and reg: "regularCard r"
traytel@54980
  1696
shows "stable r"
traytel@54980
  1697
unfolding stable_def proof safe
traytel@54980
  1698
  fix A :: "'a set" and F :: "'a \<Rightarrow> 'a set" assume A: "|A| <o r" and F: "\<forall>a\<in>A. |F a| <o r"
traytel@54980
  1699
  {assume "r \<le>o |Sigma A F|"
traytel@54980
  1700
   hence "|Field r| \<le>o |Sigma A F|" using card_of_Field_ordIso[OF cr]
traytel@54980
  1701
   by (metis Field_card_of card_of_cong ordLeq_iff_ordLess_or_ordIso ordLeq_ordLess_trans)
traytel@54980
  1702
   moreover have Fi: "Field r \<noteq> {}" using ir by auto
traytel@54980
  1703
   ultimately obtain f where f: "f ` Sigma A F = Field r" using card_of_ordLeq2 by metis
traytel@54980
  1704
   have r: "wo_rel r" using cr unfolding card_order_on_def wo_rel_def by auto
traytel@54980
  1705
   {fix a assume a: "a \<in> A"
wenzelm@63040
  1706
    define L where "L = {(a,u) | u. u \<in> F a}"
traytel@54980
  1707
    have fL: "f ` L \<subseteq> Field r" using f a unfolding L_def by auto
traytel@54980
  1708
    have "|L| =o |F a|" unfolding L_def card_of_ordIso[symmetric]
traytel@54980
  1709
    apply(rule exI[of _ snd]) unfolding bij_betw_def inj_on_def by (auto simp: image_def)
traytel@54980
  1710
    hence "|L| <o r" using F a ordIso_ordLess_trans[of "|L|" "|F a|"] unfolding L_def by auto
traytel@54980
  1711
    hence "|f ` L| <o r" using ordLeq_ordLess_trans[OF card_of_image, of "L"] unfolding L_def by auto
blanchet@55087
  1712
    hence "\<not> cofinal (f ` L) r" using reg fL unfolding regularCard_def by (metis not_ordLess_ordIso)
traytel@54980
  1713
    then obtain k where k: "k \<in> Field r" and "\<forall> l \<in> L. \<not> (f l \<noteq> k \<and> (k, f l) \<in> r)"
traytel@54980
  1714
    unfolding cofinal_def image_def by auto
traytel@54980
  1715
    hence "\<exists> k \<in> Field r. \<forall> l \<in> L. (f l, k) \<in> r" using r by (metis fL image_subset_iff wo_rel.in_notinI)
traytel@54980
  1716
    hence "\<exists> k \<in> Field r. \<forall> u \<in> F a. (f (a,u), k) \<in> r" unfolding L_def by auto
traytel@54980
  1717
   }
traytel@54980
  1718
   then obtain gg where gg: "\<forall> a \<in> A. \<forall> u \<in> F a. (f (a,u), gg a) \<in> r" by metis
traytel@54980
  1719
   obtain j0 where j0: "j0 \<in> Field r" using Fi by auto
wenzelm@63040
  1720
   define g where [abs_def]: "g a = (if F a \<noteq> {} then gg a else j0)" for a
traytel@54980
  1721
   have g: "\<forall> a \<in> A. \<forall> u \<in> F a. (f (a,u),g a) \<in> r" using gg unfolding g_def by auto
wenzelm@60585
  1722
   hence 1: "Field r \<subseteq> (\<Union>a \<in> A. under r (g a))"
blanchet@55023
  1723
   using f[symmetric] unfolding under_def image_def by auto
traytel@54980
  1724
   have gA: "g ` A \<subseteq> Field r" using gg j0 unfolding Field_def g_def by auto
traytel@54980
  1725
   moreover have "cofinal (g ` A) r" unfolding cofinal_def proof safe
traytel@54980
  1726
     fix i assume "i \<in> Field r"
traytel@54980
  1727
     then obtain j where ij: "(i,j) \<in> r" "i \<noteq> j" using cr ir by (metis infinite_Card_order_limit)
blanchet@55023
  1728
     hence "j \<in> Field r" by (metis card_order_on_def cr well_order_on_domain)
blanchet@55023
  1729
     then obtain a where a: "a \<in> A" and j: "(j, g a) \<in> r" using 1 unfolding under_def by auto
traytel@54980
  1730
     hence "(i, g a) \<in> r" using ij wo_rel.TRANS[OF r] unfolding trans_def by blast
traytel@54980
  1731
     moreover have "i \<noteq> g a"
traytel@54980
  1732
     using ij j r unfolding wo_rel_def unfolding well_order_on_def linear_order_on_def
traytel@54980
  1733
     partial_order_on_def antisym_def by auto
traytel@54980
  1734
     ultimately show "\<exists>j\<in>g ` A. i \<noteq> j \<and> (i, j) \<in> r" using a by auto
traytel@54980
  1735
   qed
blanchet@55087
  1736
   ultimately have "|g ` A| =o r" using reg unfolding regularCard_def by auto
traytel@54980
  1737
   moreover have "|g ` A| \<le>o |A|" by (metis card_of_image)
traytel@54980
  1738
   ultimately have False using A by (metis not_ordLess_ordIso ordLeq_ordLess_trans)
traytel@54980
  1739
  }
traytel@54980
  1740
  thus "|Sigma A F| <o r"
traytel@54980
  1741
  using cr not_ordLess_iff_ordLeq by (metis card_of_Well_order card_order_on_well_order_on)
traytel@54980
  1742
qed
traytel@54980
  1743
blanchet@55087
  1744
lemma stable_regularCard:
traytel@54980
  1745
assumes cr: "Card_order r" and ir: "\<not>finite (Field r)" and st: "stable r"
blanchet@55087
  1746
shows "regularCard r"
blanchet@55087
  1747
unfolding regularCard_def proof safe
traytel@54980
  1748
  fix K assume K: "K \<subseteq> Field r" and cof: "cofinal K r"
traytel@54980
  1749
  have "|K| \<le>o r" using K by (metis card_of_Field_ordIso card_of_mono1 cr ordLeq_ordIso_trans)
traytel@54980
  1750
  moreover
traytel@54980
  1751
  {assume Kr: "|K| <o r"
traytel@54980
  1752
   then obtain f where "\<forall> a \<in> Field r. f a \<in> K \<and> a \<noteq> f a \<and> (a, f a) \<in> r"
traytel@54980
  1753
   using cof unfolding cofinal_def by metis
wenzelm@60585
  1754
   hence "Field r \<subseteq> (\<Union>a \<in> K. underS r a)" unfolding underS_def by auto
wenzelm@60585
  1755
   hence "r \<le>o |\<Union>a \<in> K. underS r a|" using cr
traytel@54980
  1756
   by (metis Card_order_iff_ordLeq_card_of card_of_mono1 ordLeq_transitive)
wenzelm@60585
  1757
   also have "|\<Union>a \<in> K. underS r a| \<le>o |SIGMA a: K. underS r a|" by (rule card_of_UNION_Sigma)
traytel@54980
  1758
   also
traytel@54980
  1759
   {have "\<forall> a \<in> K. |underS r a| <o r" using K by (metis card_of_underS cr subsetD)
traytel@54980
  1760
    hence "|SIGMA a: K. underS r a| <o r" using st Kr unfolding stable_def by auto
traytel@54980
  1761
   }
traytel@54980
  1762
   finally have "r <o r" .
traytel@54980
  1763
   hence False by (metis ordLess_irreflexive)
traytel@54980
  1764
  }
traytel@54980
  1765
  ultimately show "|K| =o r" by (metis ordLeq_iff_ordLess_or_ordIso)
traytel@54980
  1766
qed
traytel@54980
  1767
traytel@54980
  1768
(* Note that below the types of A and F are now unconstrained: *)
traytel@54980
  1769
lemma stable_elim:
traytel@54980
  1770
assumes ST: "stable r" and A_LESS: "|A| <o r" and
traytel@54980
  1771
        F_LESS: "\<And> a. a \<in> A \<Longrightarrow> |F a| <o r"
traytel@54980
  1772
shows "|SIGMA a : A. F a| <o r"
traytel@54980
  1773
proof-
traytel@54980
  1774
  obtain A' where 1: "A' < Field r \<and> |A'| <o r" and 2: " |A| =o |A'|"
traytel@54980
  1775
  using internalize_card_of_ordLess[of A r] A_LESS by blast
traytel@54980
  1776
  then obtain G where 3: "bij_betw G A' A"
traytel@54980
  1777
  using card_of_ordIso  ordIso_symmetric by blast
traytel@54980
  1778
  (*  *)
traytel@54980
  1779
  {fix a assume "a \<in> A"
traytel@54980
  1780
   hence "\<exists>B'. B' \<le> Field r \<and> |F a| =o |B'| \<and> |B'| <o r"
traytel@54980
  1781
   using internalize_card_of_ordLess[of "F a" r] F_LESS by blast
traytel@54980
  1782
  }
traytel@54980
  1783
  then obtain F' where
traytel@54980
  1784
  temp: "\<forall>a \<in> A. F' a \<le> Field r \<and> |F a| =o |F' a| \<and> |F' a| <o r"
traytel@54980
  1785
  using bchoice[of A "\<lambda> a B'. B' \<le> Field r \<and> |F a| =o |B'| \<and> |B'| <o r"] by blast
traytel@54980
  1786
  hence 4: "\<forall>a \<in> A. F' a \<le> Field r \<and> |F' a| <o r" by auto
traytel@54980
  1787
  have 5: "\<forall>a \<in> A. |F' a| =o |F a|" using temp ordIso_symmetric by auto
traytel@54980
  1788
  (*  *)
traytel@54980
  1789
  have "\<forall>a' \<in> A'. F'(G a') \<le> Field r \<and> |F'(G a')| <o r"
traytel@54980
  1790
  using 3 4 bij_betw_ball[of G A' A] by auto
traytel@54980
  1791
  hence "|SIGMA a' : A'. F'(G a')| <o r"
traytel@54980
  1792
  using ST 1 unfolding stable_def by auto
traytel@54980
  1793
  moreover have "|SIGMA a' : A'. F'(G a')| =o |SIGMA a : A. F a|"
traytel@54980
  1794
  using card_of_Sigma_cong[of G A' A F' F] 5 3 by blast
traytel@54980
  1795
  ultimately show ?thesis using ordIso_symmetric ordIso_ordLess_trans by blast
traytel@54980
  1796
qed
traytel@54980
  1797
traytel@54980
  1798
lemma stable_natLeq: "stable natLeq"
traytel@54980
  1799
proof(unfold stable_def, safe)
traytel@54980
  1800
  fix A :: "'a set" and F :: "'a \<Rightarrow> 'a set"
traytel@54980
  1801
  assume "|A| <o natLeq" and "\<forall>a\<in>A. |F a| <o natLeq"
traytel@54980
  1802
  hence "finite A \<and> (\<forall>a \<in> A. finite(F a))"
traytel@54980
  1803
  by (auto simp add: finite_iff_ordLess_natLeq)
traytel@54980
  1804
  hence "finite(Sigma A F)" by (simp only: finite_SigmaI[of A F])
traytel@54980
  1805
  thus "|Sigma A F | <o natLeq"
traytel@54980
  1806
  by (auto simp add: finite_iff_ordLess_natLeq)
traytel@54980
  1807
qed
traytel@54980
  1808
blanchet@55087
  1809
corollary regularCard_natLeq: "regularCard natLeq"
blanchet@55087
  1810
using stable_regularCard[OF natLeq_Card_order _ stable_natLeq] Field_natLeq by simp
traytel@54980
  1811
traytel@54980
  1812
lemma stable_cardSuc:
traytel@54980
  1813
assumes CARD: "Card_order r" and INF: "\<not>finite (Field r)"
traytel@54980
  1814
shows "stable(cardSuc r)"
blanchet@55087
  1815
using infinite_cardSuc_regularCard regularCard_stable
traytel@54980
  1816
by (metis CARD INF cardSuc_Card_order cardSuc_finite)
traytel@54980
  1817
traytel@54980
  1818
lemma stable_UNION:
traytel@54980
  1819
assumes ST: "stable r" and A_LESS: "|A| <o r" and
traytel@54980
  1820
        F_LESS: "\<And> a. a \<in> A \<Longrightarrow> |F a| <o r"
wenzelm@60585
  1821
shows "|\<Union>a \<in> A. F a| <o r"
traytel@54980
  1822
proof-
wenzelm@60585
  1823
  have "|\<Union>a \<in> A. F a| \<le>o |SIGMA a : A. F a|"
traytel@54980
  1824
  using card_of_UNION_Sigma by blast
traytel@54980
  1825
  thus ?thesis using assms stable_elim ordLeq_ordLess_trans by blast
traytel@54980
  1826
qed
traytel@54980
  1827
traytel@54980
  1828
lemma stable_ordIso1:
traytel@54980
  1829
assumes ST: "stable r" and ISO: "r' =o r"
traytel@54980
  1830
shows "stable r'"
traytel@54980
  1831
proof(unfold stable_def, auto)
traytel@54980
  1832
  fix A::"'b set" and F::"'b \<Rightarrow> 'b set"
traytel@54980
  1833
  assume "|A| <o r'" and "\<forall>a \<in> A. |F a| <o r'"
traytel@54980
  1834
  hence "( |A| <o r) \<and> (\<forall>a \<in> A. |F a| <o r)"
traytel@54980
  1835
  using ISO ordLess_ordIso_trans by blast
traytel@54980
  1836
  hence "|SIGMA a : A. F a| <o r" using assms stable_elim by blast
traytel@54980
  1837
  thus "|SIGMA a : A. F a| <o r'"
traytel@54980
  1838
  using ISO ordIso_symmetric ordLess_ordIso_trans by blast
traytel@54980
  1839
qed
traytel@54980
  1840
traytel@54980
  1841
lemma stable_ordIso2:
traytel@54980
  1842
assumes ST: "stable r" and ISO: "r =o r'"
traytel@54980
  1843
shows "stable r'"
traytel@54980
  1844
using assms stable_ordIso1 ordIso_symmetric by blast
traytel@54980
  1845
traytel@54980
  1846
lemma stable_ordIso:
traytel@54980
  1847
assumes "r =o r'"
traytel@54980
  1848
shows "stable r = stable r'"
traytel@54980
  1849
using assms stable_ordIso1 stable_ordIso2 by blast
traytel@54980
  1850
traytel@54980
  1851
lemma stable_nat: "stable |UNIV::nat set|"
traytel@54980
  1852
using stable_natLeq card_of_nat stable_ordIso by auto
traytel@54980
  1853
wenzelm@63167
  1854
text\<open>Below, the type of "A" is not important -- we just had to choose an appropriate
traytel@54980
  1855
   type to make "A" possible. What is important is that arbitrarily large
wenzelm@63167
  1856
   infinite sets of stable cardinality exist.\<close>
traytel@54980
  1857
traytel@54980
  1858
lemma infinite_stable_exists:
traytel@54980
  1859
assumes CARD: "\<forall>r \<in> R. Card_order (r::'a rel)"
traytel@54980
  1860
shows "\<exists>(A :: (nat + 'a set)set).
traytel@54980
  1861
          \<not>finite A \<and> stable |A| \<and> (\<forall>r \<in> R. r <o |A| )"
traytel@54980
  1862
proof-
traytel@54980
  1863
  have "\<exists>(A :: (nat + 'a set)set).
traytel@54980
  1864
          \<not>finite A \<and> stable |A| \<and> |UNIV::'a set| <o |A|"
traytel@54980
  1865
  proof(cases "finite (UNIV::'a set)")
traytel@54980
  1866
    assume Case1: "finite (UNIV::'a set)"
traytel@54980
  1867
    let ?B = "UNIV::nat set"
traytel@54980
  1868
    have "\<not>finite(?B <+> {})" using finite_Plus_iff by blast
traytel@54980
  1869
    moreover
traytel@54980
  1870
    have "stable |?B|" using stable_natLeq card_of_nat stable_ordIso1 by blast
traytel@54980
  1871
    hence "stable |?B <+> {}|" using stable_ordIso card_of_Plus_empty1 by blast
traytel@54980
  1872
    moreover
traytel@54980
  1873
    have "\<not>finite(Field |?B| ) \<and> finite(Field |UNIV::'a set| )" using Case1 by simp
traytel@54980
  1874
    hence "|UNIV::'a set| <o |?B|" by (simp add: finite_ordLess_infinite)
traytel@54980
  1875
    hence "|UNIV::'a set| <o |?B <+> {}|" using card_of_Plus_empty1 ordLess_ordIso_trans by blast
traytel@54980
  1876
    ultimately show ?thesis by blast
traytel@54980
  1877
  next
traytel@54980
  1878
    assume Case1: "\<not>finite (UNIV::'a set)"
traytel@54980
  1879
    hence *: "\<not>finite(Field |UNIV::'a set| )" by simp
traytel@54980
  1880
    let ?B = "Field(cardSuc |UNIV::'a set| )"
traytel@54980
  1881
    have 0: "|?B| =o |{} <+> ?B|" using card_of_Plus_empty2 by blast
traytel@54980
  1882
    have 1: "\<not>finite ?B" using Case1 card_of_cardSuc_finite by blast
traytel@54980
  1883
    hence 2: "\<not>finite({} <+> ?B)" using 0 card_of_ordIso_finite by blast
traytel@54980
  1884
    have "|?B| =o cardSuc |UNIV::'a set|"
traytel@54980
  1885
    using card_of_Card_order cardSuc_Card_order card_of_Field_ordIso by blast
traytel@54980
  1886
    moreover have "stable(cardSuc |UNIV::'a set| )"
traytel@54980
  1887
    using stable_cardSuc * card_of_Card_order by blast
traytel@54980
  1888
    ultimately have "stable |?B|" using stable_ordIso by blast
traytel@54980
  1889
    hence 3: "stable |{} <+> ?B|" using stable_ordIso 0 by blast
traytel@54980
  1890
    have "|UNIV::'a set| <o cardSuc |UNIV::'a set|"
traytel@54980
  1891
    using card_of_Card_order cardSuc_greater by blast
traytel@54980
  1892
    moreover have "|?B| =o  cardSuc |UNIV::'a set|"
traytel@54980
  1893
    using card_of_Card_order cardSuc_Card_order  card_of_Field_ordIso by blast
traytel@54980
  1894
    ultimately have "|UNIV::'a set| <o |?B|"
traytel@54980
  1895
    using ordIso_symmetric ordLess_ordIso_trans by blast
traytel@54980
  1896
    hence "|UNIV::'a set| <o |{} <+> ?B|" using 0 ordLess_ordIso_trans by blast
traytel@54980
  1897
    thus ?thesis using 2 3 by blast
traytel@54980
  1898
  qed
traytel@54980
  1899
  thus ?thesis using CARD card_of_UNIV2 ordLeq_ordLess_trans by blast
traytel@54980
  1900
qed
traytel@54980
  1901
blanchet@55087
  1902
corollary infinite_regularCard_exists:
traytel@54980
  1903
assumes CARD: "\<forall>r \<in> R. Card_order (r::'a rel)"
traytel@54980
  1904
shows "\<exists>(A :: (nat + 'a set)set).
blanchet@55087
  1905
          \<not>finite A \<and> regularCard |A| \<and> (\<forall>r \<in> R. r <o |A| )"
blanchet@55087
  1906
using infinite_stable_exists[OF CARD] stable_regularCard by (metis Field_card_of card_of_card_order_on)
traytel@54980
  1907
blanchet@48975
  1908
end