diff --git a/thys/Ordinal_Partitions/Erdos_Milner.thy b/thys/Ordinal_Partitions/Erdos_Milner.thy --- a/thys/Ordinal_Partitions/Erdos_Milner.thy +++ b/thys/Ordinal_Partitions/Erdos_Milner.thy @@ -1,1294 +1,1282 @@ theory Erdos_Milner imports Partitions begin subsection \Erdős-Milner theorem\ text \P. Erdős and E. C. Milner, A Theorem in the Partition Calculus. Canadian Math. Bull. 15:4 (1972), 501-505. Corrigendum, Canadian Math. Bull. 17:2 (1974), 305.\ text \The paper defines strong types as satisfying the criteria below. It remarks that ordinals satisfy those criteria. Here is a (too complicated) proof.\ proposition strong_ordertype_eq: assumes D: "D \ elts \" and "Ord \" obtains L where "\(List.set L) = D" "\X. X \ List.set L \ indecomposable (tp X)" and "\M. \M \ D; \X. X \ List.set L \ tp (M \ X) \ tp X\ \ tp M = tp D" proof - define \ where "\ \ inv_into D (ordermap D VWF)" then have bij_\: "bij_betw \ (elts (tp D)) D" using D bij_betw_inv_into down ordermap_bij by blast have \_cancel_left: "\d. d \ D \ \ (ordermap D VWF d) = d" - by (metis D \_def bij_betw_inv_into_left down_raw ordermap_bij small_iff_range total_on_VWF wf_VWF) + by (metis D \_def bij_betw_inv_into_left down ordermap_bij total_on_VWF wf_VWF) have \_cancel_right: "\\. \ \ elts (tp D) \ ordermap D VWF (\ \) = \" by (metis \_def f_inv_into_f ordermap_surj subsetD) have "small D" "D \ ON" using assms down elts_subset_ON [of \] by auto then have \_less_iff: "\\ \. \\ \ elts (tp D); \ \ elts (tp D)\ \ \ \ < \ \ \ \ < \" - by (metis ON_imp_Ord Ord_linear2 \_def inv_into_ordermap inv_ordermap_VWF_mono_le leD less_V_def) + by (metis \_def inv_ordermap_VWF_mono_iff inv_ordermap_mono_eq less_V_def) obtain \s where "List.set \s \ ON" and "\_dec \s" and tpD_eq: "tp D = \_sum \s" using Ord_ordertype \_nf_exists by blast \ \Cantor normal form of the ordertype\ have ord [simp]: "Ord (\s ! k)" "Ord (\_sum (take k \s))" if "k < length \s" for k using that \list.set \s \ ON\ by (auto simp: dual_order.trans set_take_subset elim: ON_imp_Ord) define E where "E \ \k. lift (\_sum (take k \s)) (\\(\s!k))" define L where "L \ map (\k. \ ` (elts (E k))) [0..s]" have [simp]: "length L = length \s" by (simp add: L_def) - have in_elts_E_less: "x' < x" - if "x' \ elts (E k')" "x \ elts (E k)" "k's" for k k' x' x - \ \The ordinals have been partitioned into disjoint intervals\ + have in_elts_E_less: "elts (E k') \ elts (E k)" if "k's" for k k' + \ \The ordinals have been partitioned into disjoint intervals\ proof - have ord\: "Ord (\ \ \s ! k')" using that by auto from that id_take_nth_drop [of k' "take k \s"] obtain l where "take k \s = take k' \s @ (\s!k') # l" by (simp add: min_def) then show ?thesis - using that by (auto simp: E_def lift_def add.assoc dest!: OrdmemD [OF ord\] intro: less_le_trans) + using that unfolding E_def lift_def less_sets_def + by (auto dest!: OrdmemD [OF ord\] intro: less_le_trans) qed have elts_E: "elts (E k) \ elts (\_sum \s)" if "k < length \s" for k proof - have "\ \ (\s!k) \ \_sum (drop k \s)" by (metis that Cons_nth_drop_Suc \_sum_Cons add_le_cancel_left0) then have "(+) (\_sum (take k \s)) ` elts (\ \ (\s!k)) \ elts (\_sum (take k \s) + \_sum (drop k \s))" by blast also have "\ = elts (\_sum \s)" using \_sum_take_drop by auto finally show ?thesis by (simp add: lift_def E_def) qed have \_sum_in_tpD: "\_sum (take k \s) + \ \ elts (tp D)" if "\ \ elts (\ \ \s!k)" "k < length \s" for \ k using elts_E lift_def that tpD_eq by (auto simp: E_def) have Ord_\: "Ord (\ (\_sum (take k \s) + \))" if "\ \ elts (\ \ \s!k)" "k < length \s" for \ k using \_sum_in_tpD \D \ ON\ bij_\ bij_betw_imp_surj_on that by fastforce define \ where "\ \ \k. ((\y. odiff y (\_sum (take k \s))) \ ordermap D VWF)" \ \mapping the segments of @{term D} into some power of @{term \}\ have bij_\: "bij_betw (\ k) (\ ` elts (E k)) (elts (\ \ (\s!k)))" if "k < length \s" for k using that by (auto simp: bij_betw_def \_def E_def inj_on_def lift_def image_comp \_sum_in_tpD \_cancel_right that) have \_iff: "\ k x < \ k y \ (x,y) \ VWF" if "x \ \ ` elts (E k)" "y \ \ ` elts (E k)" "k < length \s" for k x y using that by (auto simp: \_def E_def lift_def \_sum_in_tpD \_cancel_right Ord_\ \_less_iff) have tp_E_eq [simp]: "tp (\ ` elts (E k)) = \\(\s!k)" if k: "k < length \s" for k - using ordertype_eq_iff \_iff bij_\ that - by (meson Ord_\ Ord_oexp ord(1) ordertype_VWF_eq_iff replacement small_elts) - have tp_L_eq [simp]: "tp (L!k) = \\(\s!k)" - if "k < length \s" for k + by (metis Ord_\ Ord_oexp \_iff bij_\ ord(1) ordertype_VWF_eq_iff replacement small_elts that) + have tp_L_eq [simp]: "tp (L!k) = \\(\s!k)" if "k < length \s" for k by (simp add: L_def that) have UL_eq_D: "\ (list.set L) = D" proof (rule antisym) show "\ (list.set L) \ D" by (force simp: L_def tpD_eq bij_betw_apply [OF bij_\] dest: elts_E) show "D \ \ (list.set L)" proof fix \ assume "\ \ D" then have "ordermap D VWF \ \ elts (\_sum \s)" by (metis \small D\ ordermap_in_ordertype tpD_eq) then show "\ \ \ (list.set L)" using \\ \ D\ \_cancel_left in_elts_\_sum by (fastforce simp: L_def E_def image_iff lift_def) qed qed show thesis proof show "indecomposable (tp X)" if "X \ list.set L" for X using that by (auto simp: L_def indecomposable_\_power) next fix M assume "M \ D" and *: "\X. X \ list.set L \ tp X \ tp (M \ X)" show "tp M = tp D" proof (rule antisym) show "tp M \ tp D" by (simp add: \M \ D\ \small D\ ordertype_VWF_mono) define \ where "\ \ \X. inv_into (M \ X) (ordermap (M \ X) VWF)" \ \The bijection from an @{term \}-power into the appropriate segment of @{term M}\ have bij_\: "bij_betw (\ X) (elts (tp (M \ X))) (M \ X)" for X unfolding \_def - by (metis (no_types) \M \ D\ \small D\ bij_betw_inv_into inf_le1 ordermap_bij subset_iff_less_eq_V total_on_VWF wf_VWF) + by (meson \M \ D\ \small D\ bij_betw_inv_into inf_le1 ordermap_bij smaller_than_small total_on_VWF wf_VWF) have Ord_\: "Ord (\ X \)" if "\ \ elts (tp (M \ X))" for \ X using \D \ ON\ \M \ D\ bij_betw_apply [OF bij_\] that by blast have \_cancel_right: "\\ X. \ \ elts (tp (M \ X)) \ ordermap (M \ X) VWF (\ X \) = \" by (metis \_def f_inv_into_f ordermap_surj subsetD) have smM: "small (M \ X)" for X by (meson \M \ D\ \small D\ inf_le1 subset_iff_less_eq_V) - then have \_less: "\X \ \. \\ < \; \ \ elts (tp (M \ X)); \ \ elts (tp (M \ X))\ - \ \ X \ < \ X \" - using ordermap_mono_less bij_betw_apply [OF bij_\] VWF_iff_Ord_less \_cancel_right trans_VWF wf_VWF - by (metis Ord_\ Ord_linear_lt less_imp_not_less ordermap_mono_less) have "\k < length \s. \ \ elts (E k)" if \: "\ \ elts (tp D)" for \ proof - obtain X where "X \ set L" and X: "\ \ \ X" by (metis UL_eq_D \ Union_iff \_def in_mono inv_into_into ordermap_surj) then have "\k < length \s. \ \ elts (E k) \ X = \ ` elts (E k)" apply (clarsimp simp: L_def) by (metis \ \_cancel_right elts_E in_mono tpD_eq) then show ?thesis by blast qed then obtain K where K: "\\. \ \ elts (tp D) \ K \ < length \s \ \ \ elts (E (K \))" by metis \ \The index from @{term "tp D"} to the appropriate segment number\ define \ where "\ \ \d. \ (L ! K (ordermap D VWF d)) (\ (K (ordermap D VWF d)) d)" show "tp D \ tp M" proof (rule ordertype_inc_le) show "small D" "small M" using \M \ D\ \small D\ subset_iff_less_eq_V by auto next fix d' d assume xy: "d' \ D" "d \ D" and "(d',d) \ VWF" then have "d' < d" using ON_imp_Ord \D \ ON\ by auto define \' where "\' \ ordermap D VWF d'" define \ where "\ \ ordermap D VWF d" have len': "K \' < length \s" and elts': "\' \ elts (E (K \'))" and len: "K \ < length \s" and elts: "\ \ elts (E (K \))" using K \d' \ D\ \d \ D\ by (auto simp: \'_def \_def \small D\ ordermap_in_ordertype) have **: "\X w. \X \ list.set L; w \ elts (tp X)\ \ w \ elts (tp (M \ X))" using "*" by blast have Ord_\L: "Ord (\ (L!k) (\ k d))" if "d \ \ ` elts (E k)" "k < length \s" for k d by (metis "**" Ord_\ \length L = length \s\ bij_\ bij_betw_imp_surj_on imageI nth_mem that tp_L_eq) have "\' < \" - by (metis \'_def \_def \d' < d\ \small D\ \_cancel_left \_less_iff ordermap_in_ordertype xy) + by (simp add: \'_def \_def \(d', d) \ VWF\ \small D\ ordermap_mono_less xy) then have "K \' \ K \" - using elts' elts by (meson in_elts_E_less leI len' less_asym) + using elts' elts in_elts_E_less by (meson leI len' less_asym less_sets_def) then consider (less) "K \' < K \" | (equal) "K \' = K \" by linarith then have "\ (L ! K \') (\ (K \') d') < \ (L ! K \) (\ (K \) d)" proof cases case less obtain \: "\ (L ! K \') (\ (K \') d') \ M \ L ! K \'" "\ (L ! K \) (\ (K \) d) \ M \ L ! K \" using elts' elts len' len unfolding \'_def \_def by (metis "**" \length L = length \s\ \_cancel_left bij_\ bij_\ bij_betw_imp_surj_on imageI nth_mem tp_L_eq xy) then have "ordermap D VWF (\ (L ! K \') (\ (K \') d')) \ elts (E (K \'))" "ordermap D VWF (\ (L ! K \) (\ (K \) d)) \ elts (E (K \))" using len' len elts_E tpD_eq by (fastforce simp: L_def \'_def \_def \_cancel_right)+ then have "ordermap D VWF (\ (L ! K \') (\ (K \') d')) < ordermap D VWF (\ (L ! K \) (\ (K \) d))" - using in_elts_E_less len less by blast + using in_elts_E_less len less by (meson less_sets_def) moreover have "\ (L ! K \') (\ (K \') d') \ D" "\ (L ! K \) (\ (K \) d) \ D" using \M \ D\ \ by auto ultimately show ?thesis by (metis \small D\ \_cancel_left \_less_iff ordermap_in_ordertype) next case equal - show ?thesis + have \_less: "\X \ \. \\ < \; \ \ elts (tp (M \ X)); \ \ elts (tp (M \ X))\ + \ \ X \ < \ X \" + by (metis \D \ ON\ \M \ D\ \_def dual_order.trans inv_ordermap_VWF_strict_mono_iff le_infI1 smM) + have "\ (K \) d' < \ (K \) d" + by (metis equal \'_def \_def \(d', d) \ VWF\ \_cancel_left \_iff elts elts' imageI len xy) + then show ?thesis unfolding equal - proof (rule \_less) - show "\ (K \) d' < \ (K \) d" - by (metis equal \'_def \_def \(d', d) \ VWF\ \_cancel_left \_iff elts elts' imageI len xy) - have "\ (K \) d' \ elts (tp (L ! K \))" "\ (K \) d \ elts (tp (L ! K \))" - using equal \_cancel_left \'_def elts' len' \_def elts len xy - by (force intro: bij_betw_apply [OF bij_\])+ - then show "\ (K \) d' \ elts (tp (M \ L ! K \))" "\ (K \) d \ elts (tp (M \ L ! K \))" - by (simp_all add: "**" len) - qed + by (metis "**" \'_def \_def \length L = length \s\ \_cancel_left \_less bij_\ + bij_betw_imp_surj_on elts elts' image_eqI len local.equal nth_mem tp_L_eq xy) qed moreover have "Ord (\ (L ! K \') (\ (K \') d'))" using Ord_\L \'_def \_cancel_left elts' len' xy(1) by fastforce moreover have "Ord (\ (L ! K \) (\ (K \) d))" using Ord_\L \_def \_cancel_left elts len xy by fastforce ultimately show "(\ d', \ d) \ VWF" by (simp add: \_def \'_def \_def) next show "\ ` D \ M" proof (clarsimp simp: \_def) fix d assume "d \ D" define \ where "\ \ ordermap D VWF d" have len: "K \ < length \s" and elts: "\ \ elts (E (K \))" using K \d \ D\ by (auto simp: \_def \small D\ ordermap_in_ordertype) have "\ (K \) d \ elts (tp (L! (K \)))" using bij_\ [OF len] \d \ D\ - apply (simp add: L_def len) - by (metis \_def \_cancel_left bij_betw_imp_surj_on elts imageI) - then have "\ (L! (K \)) (\ (K \) d) \ M \ (L! (K \))" - using smM bij_betw_imp_surj_on [OF ordermap_bij] \length L = length \s\ - unfolding \_def - by (metis (no_types) "*" inv_into_into len nth_mem vsubsetD total_on_VWF wf_VWF) + by (metis \_def \_cancel_left bij_betw_apply elts imageI len tp_L_eq) then show "\ (L ! K (ordermap D VWF d)) (\ (K (ordermap D VWF d)) d) \ M" - using \_def by blast + using \_def \length L = length \s\ + by (metis "*" Int_iff bij_\ bij_betw_apply len nth_mem vsubsetD) qed qed auto qed qed (simp add: UL_eq_D) qed text \The ``remark'' of Erdős and E. C. Milner, Canad. Math. Bull. Vol. 17 (2), 1974\ proposition indecomposable_imp_Ex_less_sets: assumes indec: "indecomposable \" and "\ > 1" and A: "tp A = \" "small A" "A \ ON" and "x \ A" and A1: "tp A1 = \" "A1 \ A" obtains A2 where "tp A2 = \" "A2 \ A1" "{x} \ A2" proof - have "Ord \" using indec indecomposable_imp_Ord by blast have "Limit \" by (simp add: assms indecomposable_imp_Limit) define \ where "\ \ inv_into A (ordermap A VWF)" then have bij_\: "bij_betw \ (elts \) A" using A bij_betw_inv_into down ordermap_bij by blast have bij_om: "bij_betw (ordermap A VWF) A (elts \)" using A down ordermap_bij by blast define \ where "\ \ ordermap A VWF x" have \: "\ \ elts \" unfolding \_def using A \x \ A\ down by auto then have "Ord \" using Ord_in_Ord \Ord \\ by blast define B where "B \ \ ` (elts (succ \))" have B: "{y \ A. ordermap A VWF y \ ordermap A VWF x} \ B" apply (clarsimp simp add: B_def \_def image_iff \_def) by (metis Ord_linear Ord_ordermap OrdmemD bij_betw_inv_into_left bij_om leD) show thesis proof have "small A1" by (meson \small A\ A1 smaller_than_small) then have "tp (A1 - B) \ tp A1" by (simp add: ordertype_VWF_mono) moreover have "tp (A1 - B) \ \" proof - have "\ (\ \ tp B)" unfolding B_def proof (subst ordertype_VWF_inc_eq) show "elts (succ \) \ ON" by (auto simp: \_def ordertype_VWF_inc_eq intro: Ord_in_Ord) have sub: "elts (succ \) \ elts \" using Ord_trans \ \Ord \\ by auto then show "\ ` elts (succ \) \ ON" using \A \ ON\ bij_\ bij_betw_imp_surj_on by blast have "succ \ \ elts \" using \ Limit_def \Limit \\ by blast with A sub show "\ u < \ v" if "u \ elts (succ \)" and "v \ elts (succ \)" and "u < v" for u v by (metis ON_imp_Ord Ord_linear2 \_def inv_into_ordermap inv_ordermap_VWF_mono_le leD subset_iff that) show "\ \ \ tp (elts (succ \))" by (metis Limit_def Ord_succ \ \Limit \\ \Ord \\ mem_not_refl ordertype_eq_Ord vsubsetD) qed auto then show ?thesis using indecomposable_ordertype_ge [OF indec, of A1 B] \small A1\ A1 by (auto simp: B_def) qed ultimately show "tp (A1 - B) = \" using A1 by blast have "{x} \ (A - B)" using assms B apply (clarsimp simp: less_sets_def \_def subset_iff) by (metis Ord_not_le VWF_iff_Ord_less less_V_def order_refl ordermap_mono_less trans_VWF wf_VWF) with \A1 \ A\ show "{x} \ (A1 - B)" by auto qed auto qed text \the main theorem, from which they derive the headline result\ theorem Erdos_Milner_aux: assumes part: "partn_lst_VWF \ [k, \] 2" and indec: "indecomposable \" and "k > 1" "Ord \" and \: "\ \ elts \1" shows "partn_lst_VWF (\*\) [ord_of_nat (2*k), min \ (\*\)] 2" proof (cases "\\1 \ \=0") case True have "Ord \" using indec indecomposable_def by blast show ?thesis proof (cases "\=0") case True moreover have "min \ 0 = 0" by (simp add: min_def) ultimately show ?thesis by (simp add: partn_lst_triv0 [where i=1]) next case False then consider (0) "\=0" | (1) "\=1" by (metis Ord_0 OrdmemD True \Ord \\ mem_0_Ord one_V_def order.antisym succ_le_iff) then show ?thesis proof cases case 0 with part show ?thesis by (force simp add: partn_lst_def nsets_empty_iff less_Suc_eq) next case 1 then obtain "Ord \" by (meson ON_imp_Ord Ord_\1 True \ elts_subset_ON) then obtain i where "i < Suc (Suc 0)" "[ord_of_nat k, \] ! i \ \" using partn_lst_VWF_nontriv [OF part] 1 by auto then have "\ \ 1" using \\=1\ \k > 1\ by (fastforce simp: less_Suc_eq) then have "min \ (\*\) \ 1" by (metis Ord_1 Ord_\ Ord_linear_le Ord_mult \Ord \\ min_def order_trans) moreover have "elts \ \ {}" using False by auto ultimately show ?thesis by (auto simp: True \Ord \\ \\\0\ \\=1\ intro!: partn_lst_triv1 [where i=1]) qed qed next case False then have "\ > 1" by (meson Ord_1 Ord_not_le indec indecomposable_def) then have "\ \ \" by (simp add: indec indecomposable_imp_Limit omega_le_Limit) have "0 \ elts \" using False Ord_\1 Ord_in_Ord \ mem_0_Ord by blast then have "\ \ 0" by force show ?thesis unfolding partn_lst_def proof clarsimp fix f assume "f \ [elts (\*\)]\<^bsup>2\<^esup> \ {.. [elts (\*\)]\<^bsup>2\<^esup> \ {..<2::nat}" by (simp add: eval_nat_numeral) obtain ord [iff]: "Ord \" "Ord \" "Ord (\*\)" using Ord_\1 Ord_in_Ord \ indec indecomposable_imp_Ord Ord_mult by blast have *: False if i [rule_format]: "\H. tp H = ord_of_nat (2*k) \ H \ elts (\*\) \ \ f ` [H]\<^bsup>2\<^esup> \ {0}" and ii [rule_format]: "\H. tp H = \ \ H \ elts (\*\) \ \ f ` [H]\<^bsup>2\<^esup> \ {1}" and iii [rule_format]: "\H. tp H = (\*\) \ H \ elts (\*\) \ \ f ` [H]\<^bsup>2\<^esup> \ {1}" proof - have Ak0: "\X \ [A]\<^bsup>k\<^esup>. f ` [X]\<^bsup>2\<^esup> \ {0}" \\remark (8) about @{term"A \ S"}\ if A_\\: "A \ elts (\*\)" and ot: "tp A \ \" for A proof - let ?g = "inv_into A (ordermap A VWF)" have "small A" using down that by auto then have inj_g: "inj_on ?g (elts \)" by (meson inj_on_inv_into less_eq_V_def ordermap_surj ot subset_trans) have om_A_less: "\x y. \x \ A; y \ A; x < y\ \ ordermap A VWF x < ordermap A VWF y" using ord by (meson A_\\ Ord_in_Ord VWF_iff_Ord_less \small A\ in_mono ordermap_mono_less trans_VWF wf_VWF) have \_sub: "elts \ \ ordermap A VWF ` A" by (metis \small A\ elts_of_set less_eq_V_def ordertype_def ot replacement) have g: "?g \ elts \ \ elts (\*\)" by (meson A_\\ Pi_I' \_sub inv_into_into subset_eq) then have fg: "f \ (\X. ?g ` X) \ [elts \]\<^bsup>2\<^esup> \ {..<2}" by (rule nsets_compose_image_funcset [OF f _ inj_g]) obtain i H where "i < 2" "H \ elts \" and ot_eq: "tp H = [k,\]!i" "(f \ (\X. ?g ` X)) ` (nsets H 2) \ {i}" using ii partn_lst_E [OF part fg] by (auto simp: eval_nat_numeral) then consider (0) "i=0" | (1) "i=1" by linarith then show ?thesis proof cases case 0 then have "f ` [inv_into A (ordermap A VWF) ` H]\<^bsup>2\<^esup> \ {0}" using ot_eq \H \ elts \\ \_sub by (auto simp: nsets_def [of _ k] inj_on_inv_into elim!: nset_image_obtains) moreover have "finite H \ card H = k" using 0 ot_eq \H \ elts \\ down by (simp add: finite_ordertype_eq_card) then have "inv_into A (ordermap A VWF) ` H \ [A]\<^bsup>k\<^esup>" using \H \ elts \\ \_sub by (auto simp: nsets_def [of _ k] card_image inj_on_inv_into inv_into_into) ultimately show ?thesis by blast next case 1 have gH: "?g ` H \ elts (\*\)" by (metis A_\\ \_sub \H \ elts \\ image_subsetI inv_into_into subset_eq) have g_less: "?g x < ?g y" if "x < y" "x \ elts \" "y \ elts \" for x y using Pi_mem [OF g] ord that by (meson A_\\ Ord_in_Ord Ord_not_le \small A\ dual_order.trans elts_subset_ON inv_ordermap_VWF_mono_le ot vsubsetD) have [simp]: "tp (?g ` H) = tp H" by (meson \H \ elts \\ ord down dual_order.trans elts_subset_ON gH g_less ordertype_VWF_inc_eq subsetD) show ?thesis using ii [of "?g ` H"] subset_inj_on [OF inj_g \H \ elts \\] ot_eq 1 by (auto simp: gH elim!: nset_image_obtains) qed qed define K where "K \ \i x. {y \ elts (\*\). x \ y \ f{x,y} = i}" have small_K: "small (K i x)" for i x by (simp add: K_def) define KI where "KI \ \i X. (\x\X. K i x)" have KI_disj_self: "X \ KI i X = {}" for i X by (auto simp: KI_def K_def) define M where "M \ \D \ x. {\::V. \ \ D \ tp (K 1 x \ \ \) \ \}" have M_sub_D: "M D \ x \ D" for D \ x by (auto simp: M_def) have small_M [simp]: "small (M D \ x)" if "small D" for D \ x by (simp add: M_def that) have 9: "tp {x \ A. tp (M D \ x) \ tp D} \ \" (is "ordertype ?AD _ \ \") if inD: "indecomposable (tp D)" and D: "D \ elts \" and A: "A \ elts (\*\)" and tpA: "tp A = \" and \: "\ \ D \ {X. X \ elts (\*\) \ tp X = \}" for D A \ \\remark (9), assuming an indecomposable order type\ proof (rule ccontr) define A' where "A' \ {x \ A. \ tp (M D \ x) \ tp D}" have small [iff]: "small A" "small D" using A D down by (auto simp: M_def) have small_\: "small (\ \)" if "\ \ D" for \ using that \ by (auto simp: Pi_iff subset_iff_less_eq_V) assume not_\_le: "\ \ \ tp {x \ A. tp (M D \ x) \ tp D}" moreover obtain "small A" "small A'" "A' \ A" and A'_sub: "A' \ elts (\*\)" using A'_def A down by auto moreover have "A' = A - ?AD" by (force simp: A'_def) ultimately have A'_ge: "tp A' \ \" by (metis (no_types, lifting) dual_order.refl indec indecomposable_ordertype_eq mem_Collect_eq subsetI tpA) obtain X where "X \ A'" "finite X" "card X = k" and fX0: "f ` [X]\<^bsup>2\<^esup> \ {0}" using Ak0 [OF A'_sub A'_ge] by (auto simp: nsets_def [of _ k]) then have \: "\ tp (M D \ x) \ tp D" if "x \ X" for x using that by (auto simp: A'_def) obtain x where "x \ X" using \card X = k\ \k>1\ by fastforce have "\ D \ (\ x\X. M D \ x)" proof assume not: "D \ (\x\X. M D \ x)" have "\X\M D \ ` X. tp D \ tp X" proof (rule indecomposable_ordertype_finite_ge [OF inD]) show "M D \ ` X \ {}" using A'_def A'_ge not not_\_le by auto show "small (\ (M D \ ` X))" using \finite X\ by (simp add: finite_imp_small) qed (use \finite X\ not in auto) then show False by (simp add: \) qed then obtain \ where "\ \ D" and \: "\ \ (\ x\X. M D \ x)" by blast define \ where "\ \ {KI 0 X \ \ \, \x\X. K 1 x \ \ \, X \ \ \}" have \\: "X \ elts (\*\)" "\ \ \ elts (\*\)" using A'_sub \X \ A'\ \ \\ \ D\ by auto then have "KI 0 X \ (\x\X. K 1 x) \ X = elts (\*\)" using \x \ X\ f by (force simp: K_def KI_def Pi_iff less_2_cases_iff) with \\ have \\_\: "finite \" "\ \ \ \\" by (auto simp: \_def) then have "\ tp (K 1 x \ \ \) \ \" if "x \ X" for x using that \\ \ D\ \ \k > 1\ \card X = k\ by (fastforce simp: M_def) moreover have sm_K1: "small (\x\X. K 1 x \ \ \)" by (meson Finite_V Int_lower2 \\ \ D\ \finite X\ small_\ small_UN smaller_than_small) ultimately have not1: "\ tp (\x\X. K 1 x \ \ \) \ \" using \finite X\ \x \ X\ indecomposable_ordertype_finite_ge [OF indec, of "(\x. K 1 x \ \ \) ` X"] by blast moreover have "\ tp (X \ \ \) \ \" using \finite X\ \\ \ \\ by (meson finite_Int mem_not_refl ordertype_VWF_\ vsubsetD) moreover have "\ \ tp (\ \)" using \ \\ \ D\ small_\ by fastforce+ moreover have "small (\ \)" using \\ \ D\ small_\ by (fastforce simp: \_def intro: smaller_than_small sm_K1) ultimately have K0\_ge: "tp (KI 0 X \ \ \) \ \" using indecomposable_ordertype_finite_ge [OF indec \\_\] by (auto simp: \_def) have \\: "\ \ \ elts (\*\)" "tp (\ \) = \" using \\ \ D\ \ by blast+ then obtain Y where Ysub: "Y \ KI 0 X \ \ \" and "finite Y" "card Y = k" and fY0: "f ` [Y]\<^bsup>2\<^esup> \ {0}" using Ak0 [OF _ K0\_ge] by (auto simp: nsets_def [of _ k]) have \: "X \ Y = {}" using Ysub KI_disj_self by blast then have "card (X \ Y) = 2*k" by (simp add: \card X = k\ \card Y = k\ \finite X\ \finite Y\ card_Un_disjoint) moreover have "X \ Y \ elts (\*\)" using A'_sub \X \ A'\ \\(1) \Y \ KI 0 X \ \ \\ by auto moreover have "f ` [X \ Y]\<^bsup>2\<^esup> \ {0}" using fX0 fY0 Ysub by (auto simp: \ nsets_disjoint_2 image_Un image_UN KI_def K_def) ultimately show False using i \finite X\ \finite Y\ ordertype_VWF_finite_nat by auto qed have IX: "tp {x \ A. tp (M D \ x) \ tp D} \ \" if D: "D \ elts \" and A: "A \ elts (\*\)" and tpA: "tp A = \" and \: "\ \ D \ {X. X \ elts (\*\) \ tp X = \}" for D A \ \\remark (9) for any order type\ proof - obtain L where UL: "\(List.set L) \ D" and indL: "\X. X \ List.set L \ indecomposable (tp X)" and eqL: "\M. \M \ D; \X. X \ List.set L \ tp (M \ X) \ tp X\ \ tp M = tp D" using ord by (metis strong_ordertype_eq D order_refl) obtain A'' where A'': "A'' \ A" "tp A'' \ \" and "\x X. \x \ A''; X \ List.set L\ \ tp (M D \ x \ X) \ tp X" using UL indL proof (induction L arbitrary: thesis) case (Cons X L) then obtain A'' where A'': "A'' \ A" "tp A'' \ \" and "X \ D" and ge_X: "\x X. \x \ A''; X \ List.set L\ \ tp (M D \ x \ X) \ tp X" by auto then have tp_A'': "tp A'' = \" by (metis A antisym down ordertype_VWF_mono tpA) have ge_\: "tp {x \ A''. tp (M X \ x) \ tp X} \ \" by (rule 9) (use A A'' tp_A'' Cons.prems \D \ elts \\ \X \ D\ \ in auto) let ?A = "{x \ A''. tp (M D \ x \ X) \ tp X}" have M_eq: "M D \ x \ X = M X \ x" if "x \ A''" for x using that \X \ D\ by (auto simp: M_def) show thesis proof (rule Cons.prems) show "\ \ tp ?A" using ge_\ by (simp add: M_eq cong: conj_cong) show "tp Y \ tp (M D \ x \ Y)" if "x \ ?A" "Y \ list.set (X # L)" for x Y using that ge_X by force qed (use A'' in auto) qed (use tpA in auto) then have tp_M_ge: "tp (M D \ x) \ tp D" if "x \ A''" for x using eqL that by (auto simp: M_def) have "\ \ tp A''" by (simp add: A'') also have "\ \ tp {x \ A''. tp (M D \ x) \ tp D}" by (metis (mono_tags, lifting) tp_M_ge eq_iff mem_Collect_eq subsetI) also have "\ \ tp {x \ A. tp D \ tp (M D \ x)}" by (rule ordertype_mono) (use A'' A down in auto) finally show ?thesis . qed have IX': "tp {x \ A'. tp (K 1 x \ A) \ \} \ \" if A: "A \ elts (\*\)" "tp A = \" and A': "A' \ elts (\*\)" "tp A' = \" for A A' proof - have \: "\ \ tp (K 1 t \ A)" if "1 \ tp {\. \ = 0 \ \ \ tp (K 1 t \ A)}" for t using that by (metis Collect_empty_eq less_eq_V_0_iff ordertype_empty zero_neq_one) have "tp {x \ A'. 1 \ tp {\. \ = 0 \ \ \ tp (K 1 x \ A)}} \ tp {x \ A'. \ \ tp (K 1 x \ A)}" by (rule ordertype_mono) (use "\" A' in \auto simp: down\) then show ?thesis using IX [of "{0}" A' "\x. A"] that \0 \ elts \\ by (force simp: M_def) qed have 10: "\x0 \ A. \g \ elts \ \ elts \. strict_mono_on g (elts \) \ (\\ \ F. g \ = \) \ (\\ \ elts \. tp (K 1 x0 \ \ (g \)) \ \)" if F: "finite F" "F \ elts \" and A: "A \ elts (\*\)" "tp A = \" and \: "\ \ elts \ \ {X. X \ elts (\*\) \ tp X = \}" for F A \ proof - define p where "p \ card F" have "\ \ F" using that by auto then obtain \ :: "nat \ V" where bij\: "bij_betw \ {..p} (insert \ F)" and mon\: "strict_mono_on \ {..p}" using ZFC_Cardinals.ex_bij_betw_strict_mono_card [of "insert \ F"] elts_subset_ON \Ord \\ F by (simp add: p_def lessThan_Suc_atMost) blast have less_\_I: "\ k < \ l" if "k < l" "l \ p" for k l using mon\ that by (auto simp: strict_mono_on_def) then have less_\_D: "k < l" if "\ k < \ l" "k \ p" for k l by (metis less_asym linorder_neqE_nat that) have Ord_\: "Ord (\ k)" if "k \ p" for k by (metis (no_types, lifting) ON_imp_Ord atMost_iff insert_subset mem_Collect_eq order_trans \F \ elts \\ bij\ bij_betwE elts_subset_ON \Ord \\ that) have le_\0 [simp]: "\j. j \ p \ \ 0 \ \ j" by (metis eq_refl leI le_0_eq less_\_I less_imp_le) have le_\: "\ i \ \ (j - Suc 0)" if "i < j" "j \ p" for i j proof (cases i) case 0 then show ?thesis using le_\0 that by auto next case (Suc i') then show ?thesis by (metis (no_types, hide_lams) Suc_pred le_less less_Suc_eq less_Suc_eq_0_disj less_\_I not_less_eq that) qed have [simp]: "\ p = \" proof - obtain k where k: "\ k = \" "k \ p" by (meson atMost_iff bij\ bij_betw_iff_bijections insertI1) then have "k = p \ k < p" by linarith then show ?thesis using bij\ ord k that(2) by (metis OrdmemD atMost_iff bij_betw_iff_bijections insert_iff leD less_\_D order_refl subsetD) qed have F_imp_Ex: "\k < p. \ = \ k" if "\ \ F" for \ proof - obtain k where k: "k \ p" "\ = \ k" by (metis \\ \ F\ atMost_iff bij\ bij_betw_def imageE insert_iff) then show ?thesis using \\ \ F\ \\ p = \\ le_imp_less_or_eq that by blast qed have F_imp_ge: "\ \ \ 0" if "\ \ F" for \ using F_imp_Ex [OF that] by (metis dual_order.order_iff_strict le0 less_\_I) define D where "D \ \k. (if k=0 then {..<\ 0} else {\ (k-1)<..<\ k}) \ elts \" have D\: "D k \ elts \" for k by (auto simp: D_def) then have small_D [simp]: "small (D k)" for k by (meson down) have M_Int_D: "M (elts \) \ x \ D k = M (D k) \ x" if "k \ p" for x k using D\ by (auto simp: M_def) have \_le_if_D: "\ k \ \" if "\ \ D (Suc k)" for \ k using that by (simp add: D_def order.order_iff_strict) have mono_D: "D i \ D j" if "i < j" "j \ p" for i j proof (cases j) case (Suc j') with that show ?thesis apply (simp add: less_sets_def D_def Ball_def) by (metis One_nat_def diff_Suc_1 le_\ less_le_trans less_trans) qed (use that in auto) then have disjnt_DD: "disjnt (D i) (D j)" if "i \ j" "i \ p" "j \ p" for i j by (meson disjnt_sym less_linear less_sets_imp_disjnt that) have UN_D_eq: "(\l \ k. D l) = {..<\ k} \ (elts \ - F)" if "k \ p" for k using that proof (induction k) case 0 then show ?case by (auto simp: D_def F_imp_ge leD) next case (Suc k) have "D (Suc k) \ {..<\ k} \ (elts \ - F) = {..<\ (Suc k)} \ (elts \ - F)" (is "?lhs = ?rhs") proof show "?lhs \ ?rhs" using Suc.prems by (auto simp: D_def if_split_mem2 intro: less_\_I less_trans dest!: less_\_D F_imp_Ex) have "\x. \x < \ (Suc k); x \ elts \; x \ F; \ k \ x\ \ \ k < x" using Suc.prems \F \ elts \\ bij\ le_imp_less_or_eq by (fastforce simp: bij_betw_iff_bijections) then show "?rhs \ ?lhs" using Suc.prems by (auto simp: D_def Ord_not_less Ord_in_Ord [OF \Ord \\] Ord_\ if_split_mem2) qed then show ?case using Suc by (simp add: atMost_Suc) qed have \_decomp: "elts \ = F \ (\k \ p. D k)" using \F \ elts \\ OrdmemD [OF \Ord \\] by (auto simp: UN_D_eq) define \idx where "\idx \ \\. @k. \ \ D k \ k \ p" have \idx: "\ \ D (\idx \) \ \idx \ \ p" if "\ \ elts \ - F" for \ using that by (force simp: \idx_def \_decomp intro: someI_ex del: conjI) have any_imp_\idx: "k = \idx \" if "\ \ D k" "k \ p" for k \ proof (rule ccontr) assume non: "k \ \idx \" have "\ \ F" using that UN_D_eq by auto then show False using disjnt_DD [OF non] by (metis D\ Diff_iff \idx disjnt_iff subsetD that) qed have "\A'. A' \ A \ tp A' = \ \ (\x \ A'. F \ M (elts \) \ x)" using F proof induction case (insert \ F) then obtain A' where "A' \ A" and A': "A' \ elts (\*\)" "tp A' = \" and FN: "\x. x \ A' \ F \ M (elts \) \ x" using A(1) by auto define A'' where "A'' \ {x \ A'. \ \ tp (K 1 x \ \ \)}" have "\ \ elts \" "F \ elts \" using insert by auto note ordertype_eq_Ord [OF \Ord \\, simp] show ?case proof (intro exI conjI) show "A'' \ A" using \A' \ A\ by (auto simp: A''_def) have "tp A'' \ \" using \A'' \ A\ down ordertype_VWF_mono A by blast moreover have "\ \ \ elts (\*\)" "tp (\ \) = \" using \ \\ \ elts \\ by auto then have "\ \ tp A''" using IX' [OF _ _ A'] by (simp add: A''_def) ultimately show "tp A'' = \" by (rule antisym) have "\ \ M (elts \) \ x" "F \ M (elts \) \ x" if "x \ A''" for x proof - show "F \ M (elts \) \ x" using A''_def FN that by blast show "\ \ M (elts \) \ x" using \\ \ elts \\ that by (simp add: M_def A''_def) qed then show "\x\A''. insert \ F \ M (elts \) \ x" by blast qed qed (use A in auto) then obtain A' where A': "A' \ A" "tp A' = \" and FN: "\x. x \ A' \ F \ M (elts \) \ x" by metis have False if *: "\x0 g. \x0 \ A; g \ elts \ \ elts \; strict_mono_on g (elts \)\ \ (\\\F. g \ \ \) \ (\\\elts \. tp (K 1 x0 \ \ (g \)) < \)" proof - { fix x \ \construction of the monotone map @{term g} mentioned above\ assume "x \ A'" with A' have "x \ A" by blast have "\k. k \ p \ tp (M (D k) \ x) < tp (D k)" (is "?P") proof (rule ccontr) assume "\ ?P" then have le: "tp (D k) \ tp (M (D k) \ x)" if "k \ p" for k by (meson Ord_linear2 Ord_ordertype that) have "\f\D k \ M (D k) \ x. inj_on f (D k) \ (strict_mono_on f (D k))" if "k \ p" for k using le [OF that] that VWF_iff_Ord_less apply (clarsimp simp: ordertype_le_ordertype strict_mono_on_def) by (metis (full_types) D\ M_sub_D Ord_in_Ord PiE VWF_iff_Ord_less ord(2) subsetD) then obtain h where fun_h: "\k. k \ p \ h k \ D k \ M (D k) \ x" and inj_h: "\k. k \ p \ inj_on (h k) (D k)" and mono_h: "\k x y. k \ p \ strict_mono_on (h k) (D k)" by metis then have fun_hD: "\k. k \ p \ h k \ D k \ D k" by (auto simp: M_def) have h_increasing: "\ \ h k \" if "k \ p" and \: "\ \ D k" for k \ proof (rule Ord_mono_imp_increasing) show "h k \ D k \ D k" by (simp add: fun_hD that(1)) show "D k \ ON" using D\ elts_subset_ON ord(2) by blast qed (auto simp: that mono_h) define g where "g \ \\. if \ \ F then \ else h (\idx \) \" have [simp]: "g \ = \" if "\ \ F" for \ using that by (auto simp: g_def) have fun_g: "g \ elts \ \ elts \" proof (rule Pi_I) fix x assume "x \ elts \" then have "x \ D (\idx x)" "\idx x \ p" if "x \ F" using that by (auto simp: \idx) then show "g x \ elts \" using fun_h D\ M_sub_D \x \ elts \\ by (simp add: g_def) blast qed have h_in_D: "h (\idx \) \ \ D (\idx \)" if "\ \ F" "\ \ elts \" for \ using \idx fun_hD that by fastforce have 1: "\ k < h (\idx \) \" if "k < p" and \: "\ \ F" "\ \ elts \" and "\ k < \" for k \ using that h_in_D [OF \] \idx by (fastforce simp: D_def dest: h_increasing split: if_split_asm) moreover have 2: "h (\idx \) \ < \ k" if \: "\ \ F" "\ \ elts \" and "k < p" "\ < \ k" for \ k proof - have "\idx \ \ k" proof (rule ccontr) assume "\ \idx \ \ k" then have "k < \idx \" by linarith then show False using \_le_if_D \idx by (metis Diff_iff Suc_pred le0 leD le_\ le_less_trans \ \\ < \ k\) qed then show ?thesis using that h_in_D [OF \] by (smt (verit, best) Int_lower1 UN_D_eq UN_I atMost_iff lessThan_iff less_imp_le subset_eq) qed moreover have "h (\idx \) \ < h (\idx \) \" if \: "\ \ F" "\ \ elts \" and \: "\ \ F" "\ \ elts \" and "\ < \" for \ \ proof - have le: "\idx \ \ \idx \" if "\ (\idx \ - Suc 0) < h (\idx \) \" "h (\idx \) \ < \ (\idx \)" by (metis 2 that Diff_iff \idx \ \ \\ < \\ dual_order.strict_implies_order dual_order.strict_trans1 h_increasing leI le_\ less_asym) have "h 0 \ < h 0 \" if "\idx \ = 0" "\idx \ = 0" using that mono_h unfolding strict_mono_on_def by (metis Diff_iff \idx \ \ \\ < \\) moreover have "h 0 \ < h (\idx \) \" if "0 < \idx \" "h 0 \ < \ 0" and "\ (\idx \ - Suc 0) < h (\idx \) \" by (meson DiffI \idx \ le_\ le_less_trans less_le_not_le that) moreover have "\idx \ \ 0" if "0 < \idx \" "h 0 \ < \ 0" "\ (\idx \ - Suc 0) < h (\idx \) \" using le le_0_eq that by fastforce moreover have "h (\idx \) \ < h (\idx \) \" if "\ (\idx \ - Suc 0) < h (\idx \) \" "h (\idx \) \ < \ (\idx \)" "h (\idx \) \ < \ (\idx \)" "\ (\idx \ - Suc 0) < h (\idx \) \" using mono_h unfolding strict_mono_on_def by (metis le Diff_iff \idx \ \ \\ < \\ le_\ le_less le_less_trans that) ultimately show ?thesis using h_in_D [OF \] h_in_D [OF \] by (simp add: D_def split: if_split_asm) qed ultimately have sm_g: "strict_mono_on g (elts \)" by (auto simp: g_def strict_mono_on_def dest!: F_imp_Ex) show False using * [OF \x \ A\ fun_g sm_g] proof safe fix \ assume "\ \ elts \" and \: "tp (K 1 x \ \ (g \)) < \" have FM: "F \ M (elts \) \ x" by (meson FN \x \ A'\) have False if "tp (K (Suc 0) x \ \ \) < \" "\ \ F" using that FM by (auto simp: M_def) moreover have False if "tp (K (Suc 0) x \ \ (g \)) < \" "\ \ D k" "k \ p" "\ \ F" for k proof - have "h (\idx \) \ \ M (D (\idx \)) \ x" using fun_h \idx \\ \ elts \\ \\ \ F\ by auto then show False using that by (simp add: M_def g_def leD) qed ultimately show False using \\ \ elts \\ \ by (force simp: \_decomp) qed auto qed then have "\l. l \ p \ tp (M (elts \) \ x \ D l) < tp (D l)" using M_Int_D by auto } then obtain l where lp: "\x. x \ A'\ l x \ p" and lless: "\x. x \ A'\ tp (M (elts \) \ x \ D (l x)) < tp (D (l x))" by metis obtain A'' L where "A'' \ A'" and A'': "A'' \ elts (\*\)" "tp A'' = \" and lL: "\x. x \ A'' \ l x = L" proof - have eq: "A' = (\i\p. {x \ A'. l x = i})" using lp by auto have "\X\(\i. {x \ A'. l x = i}) ` {..p}. \ \ tp X" proof (rule indecomposable_ordertype_finite_ge [OF indec]) show "small (\i\p. {x \ A'. l x = i})" by (metis A'(1) A(1) eq down smaller_than_small) qed (use A' eq in auto) then show thesis proof fix A'' assume A'': "A'' \ (\i. {x \ A'. l x = i}) ` {..p}" and "\ \ tp A''" then obtain L where L: "\x. x \ A'' \ l x = L" by auto have "A'' \ A'" using A'' by force then have "tp A'' \ tp A'" by (meson A' A down order_trans ordertype_VWF_mono) with \\ \ tp A''\ have "tp A'' = \" using A'(2) by auto moreover have "A'' \ elts (\*\)" using A' A \A'' \ A'\ by auto ultimately show thesis using L that [OF \A'' \ A'\] by blast qed qed have \D: "\ \ D L \ {X. X \ elts (\*\) \ tp X = \}" using \ D\ by blast have "M (elts \) \ x \ D L = M (D L) \ x" for x using D\ by (auto simp: M_def) then have "tp (M (D L) \ x) < tp (D L)" if "x \ A''" for x using lless that \A'' \ A'\ lL by force then have \: "{x \ A''. tp (D L) \ tp (M (D L) \ x)} = {}" using leD by blast have "\ \ tp {x \ A''. tp (D L) \ tp (M (D L) \ x)}" using IX [OF D\ A'' \D] by simp then show False using "\" \1 < \\ by force qed then show ?thesis by (meson Ord_linear2 Ord_ordertype \Ord \\) qed let ?U = "UNIV :: nat set" define \ where "\ \ fst \ from_nat_into (elts \ \ ?U)" define q where "q \ to_nat_on (elts \ \ ?U)" have co_\U: "countable (elts \ \ ?U)" by (simp add: \ less_\1_imp_countable) moreover have "elts \ \ ?U \ {}" using \0 \ elts \\ by blast ultimately have "range (from_nat_into (elts \ \ ?U)) = (elts \ \ ?U)" by (metis range_from_nat_into) then have \_in_\ [simp]: "\ i \ elts \" for i by (metis SigmaE \_def comp_apply fst_conv range_eqI) then have Ord_\ [simp]: "Ord (\ i)" for i using Ord_in_Ord by blast have inf_\U: "infinite (elts \ \ ?U)" using \0 \ elts \\ finite_cartesian_productD2 by auto have 11 [simp]: "\ (q (\,n)) = \" if "\ \ elts \" for \ n by (simp add: \_def q_def that co_\U) have range_\ [simp]: "range \ = elts \" by (auto simp: image_iff) (metis 11) have [simp]: "KI i {} = UNIV" "KI i (insert a X) = K i a \ KI i X" for i a X by (auto simp: KI_def) define \ where "\ \ \n::nat. \\ x. (\\ \ elts \. \ \ \ elts (\*\) \ tp (\ \) = \) \ x ` {.. elts (\*\) \ (\\ \ elts \. \ \) \ KI 1 (x ` {.. strict_mono_sets (elts \) \" define \ where "\ \ \n::nat. \g \ \' xn. g \ elts \ \ elts \ \ strict_mono_on g (elts \) \ (\i\n. g (\ i) = \ i) \ (\\ \ elts \. \' \ \ K 1 xn \ \ (g \)) \ {xn} \ (\' (\ n)) \ xn \ \ (\ n)" let ?\0 = "\\. plus (\ * \) ` elts \" have base: "\ 0 ?\0 x" for x by (auto simp: \_def add_mult_less add_mult_less_add_mult ordertype_image_plus strict_mono_sets_def less_sets_def) have step: "Ex (\(g,\',xn). \ n g \ \' xn \ \ (Suc n) \' (x(n:=xn)))" if "\ n \ x" for n \ x proof - have \: "\\. \ \ elts \ \ \ \ \ elts (\*\) \ tp (\ \) = \" and x: "x ` {.. elts (\*\)" and sub: "\ (\ ` elts \) \ KI (Suc 0) (x ` {..) \" using that by (auto simp: \_def) have \\: "\ ` {..n} \ elts \" and \sub: "\ (\ n) \ elts (\*\)" by (auto simp: \) have \fun: "\ \ elts \ \ {X. X \ elts (\*\) \ tp X = \}" by (simp add: \) then obtain xn g where xn: "xn \ \ (\ n)" and g: "g \ elts \ \ elts \" and sm_g: "strict_mono_on g (elts \)" and g_\: "\\ \ \`{..n}. g \ = \" and g_\: "\\ \ elts \. \ \ tp (K 1 xn \ \ (g \))" using 10 [OF _ \\ \sub _ \fun] by (auto simp: \) have tp1: "tp (K 1 xn \ \ (g \)) = \" if "\ \ elts \" for \ proof (rule antisym) have "tp (K 1 xn \ \ (g \)) \ tp (\ (g \))" proof (rule ordertype_VWF_mono) show "small (\ (g \))" by (metis PiE \ down g that) qed auto also have "\ = \" using \ g that by force finally show "tp (K 1 xn \ \ (g \)) \ \" . qed (use that g_\ in auto) have tp2: "tp (\ (\ n)) = \" by (auto simp: \) obtain "small (\ (\ n))" "\ (\ n) \ ON" by (meson \sub ord down elts_subset_ON subset_trans) then obtain A2 where A2: "tp A2 = \" "A2 \ K 1 xn \ \ (\ n)" "{xn} \ A2" using indecomposable_imp_Ex_less_sets [OF indec \\ > 1\ tp2] by (metis \_in_\ atMost_iff image_eqI inf_le2 le_refl xn tp1 g_\) then have A2_sub: "A2 \ \ (\ n)" by simp let ?\ = "\\. if \ = \ n then A2 else K 1 xn \ \ (g \)" have [simp]: "({.. {x. x \ n}) = ({.. (\x\elts \ \ {\. \ \ \ n}. \ (g x)) \ KI (Suc 0) (x ` {.. KI (Suc 0) (x ` {.. elts (\*\)" using \sub sub A2 by fastforce+ moreover have "xn \ elts (\*\)" using \sub xn by blast moreover have "strict_mono_sets (elts \) ?\" using sm sm_g g g_\ A2_sub unfolding strict_mono_sets_def strict_mono_on_def less_sets_def Pi_iff subset_iff Ball_def Bex_def image_iff by (simp (no_asm_use) add: if_split_mem2) (smt order_refl) ultimately have "\ (Suc n) ?\ (x(n := xn))" using tp1 x A2 by (auto simp: \_def K_def) with A2 show ?thesis by (rule_tac x="(g,?\,xn)" in exI) (simp add: \_def g sm_g g_\ xn) qed define G where "G \ \n \ x. @(g,\',x'). \xn. \ n g \ \' xn \ x' = (x(n:=xn)) \ \ (Suc n) \' x'" have G\: "(\(g,\',x'). \ (Suc n) \' x') (G n \ x)" and G\: "(\(g,\',x'). \ n g \ \' (x' n)) (G n \ x)" if "\ n \ x" for n \ x using step [OF that] by (force simp: G_def dest: some_eq_imp)+ define H where "H \ rec_nat (id,?\0,undefined) (\n (g0,\,x0). G n \ x0)" have H_Suc: "H (Suc n) = (case H n of (g0, xa, xb) \ G n xa xb)" for n by (simp add: H_def) have "(\(g,\,x). \ n \ x) (H n)" for n proof (induction n) case 0 show ?case by (simp add: H_def base) next case (Suc n) then show ?case using G\ by (fastforce simp: H_Suc) qed then have H_imp_\: "\ n \ x" if "H n = (g,\,x)" for g \ x n by (metis case_prodD that) then have H_imp_\: "(\(g,\',x'). let (g0,\,x) = H n in \ n g \ \' (x' n)) (H (Suc n))" for n using G\ by (fastforce simp: H_Suc split: prod.split) define g where "g \ \n. (\(g,\,x). g) (H (Suc n))" have g: "g n \ elts \ \ elts \" and sm_g: "strict_mono_on (g n) (elts \)" and 13: "\i. i\n \ g n (\ i) = \ i" for n using H_imp_\ [of n] by (auto simp: g_def \_def) define \ where "\ \ \n. (\(g,\,x). \) (H n)" define x where "x \ \n. (\(g,\,x). x n) (H (Suc n))" have 14: "\ (Suc n) \ \ K 1 (x n) \ \ n (g n \)" if "\ \ elts \" for \ n using H_imp_\ [of n] that by (force simp: \_def \_def x_def g_def) then have x14: "\ (Suc n) \ \ \ n (g n \)" if "\ \ elts \" for \ n using that by blast have 15: "x n \ \ n (\ n)" and 16: "{x n} \ (\ (Suc n) (\ n))" for n using H_imp_\ [of n] by (force simp: \_def \_def x_def)+ have \_\\: "\ n \ \ elts (\*\)" if "\ \ elts \" for \ n using H_imp_\ [of n] that by (auto simp: \_def \_def split: prod.split) have 12: "strict_mono_sets (elts \) (\ n)" for n using H_imp_\ [of n] that by (auto simp: \_def \_def split: prod.split) have tp_\: "tp (\ n \) = \" if "\ \ elts \" for \ n using H_imp_\ [of n] that by (auto simp: \_def \_def split: prod.split) let ?Z = "range x" have S_dec: "\ (\ (m+k) ` elts \) \ \ (\ m ` elts \)" for k m by (induction k) (use 14 g in \fastforce+\) have "x n \ K 1 (x m)" if "m (\\ \ elts \. \ n \)" by (meson "15" UN_I \_in_\) also have "\ \ (\\ \ elts \. \ (Suc m) \)" using S_dec [of "Suc m"] less_iff_Suc_add that by auto also have "\ \ K 1 (x m)" using 14 by auto finally show ?thesis . qed then have "f{x m, x n} = 1" if "m2\<^esup> \ {1}" by (clarsimp simp: nsets_2_eq) (metis insert_commute less_linear) moreover have Z_sub: "?Z \ elts (\*\)" using "15" \_\\ \_in_\ by blast moreover have "tp ?Z \ \ * \" proof - define \ where "\ \ \i j x. wfrec (measure (\k. j-k)) (\\ k. if k (Suc k)) else x) i" have \: "\ i j x = (if i (Suc i) j x) else x)" for i j x by (simp add: \_def wfrec cut_apply) have 17: "\ k j (\ i) = \ i" if "i \ k" for i j k using wf_measure [of "\k. j-k"] that by (induction k rule: wf_induct_rule) (simp add: "13" \ le_imp_less_Suc) have \_in_\: "\ i j \ \ elts \" if "\ \ elts \" for i j \ using wf_measure [of "\k. j-k"] that proof (induction i rule: wf_induct_rule) case (less i) with g show ?case by (force simp: \ [of i]) qed then have \_fun: "\ i j \ elts \ \ elts \" for i j by simp have sm_\: "strict_mono_on (\ i j) (elts \)" for i j using wf_measure [of "\k. j-k"] proof (induction i rule: wf_induct_rule) case (less i) with sm_g show ?case by (auto simp: \ [of i] strict_mono_on_def \_in_\) qed have *: "\ j (\ j) \ \ i (\ i j (\ j))" if "i < j" for i j using wf_measure [of "\k. j-k"] that proof (induction i rule: wf_induct_rule) case (less i) then have "j - Suc i < j - i" by (metis (no_types) Suc_diff_Suc lessI) with less \_in_\ show ?case by (simp add: \ [of i]) (metis 17 Suc_lessI \_in_\ order_refl order_trans x14) qed have le: "\ i j (\ j) \ \ i \ \ j \ \ i" for i j using sm_\ unfolding strict_mono_on_def by (metis "17" Ord_in_Ord Ord_linear2 \_in_\ leD le_refl less_V_def \Ord \\) then have less: "\ i j (\ j) < \ i \ \ j < \ i" for i j by (metis (no_types, lifting) "17" \_in_\ less_V_def order_refl sm_\ strict_mono_on_def) have eq: "\ i j (\ j) = \ i \ \ j = \ i" for i j by (metis eq_refl le less less_le) have 18: "\ m (\ m) \ \ n (\ n) \ \ m < \ n" for m n proof (cases n m rule: linorder_cases) case less show ?thesis proof (intro iffI) assume "\ m (\ m) \ \ n (\ n)" moreover have "\ \ m (\ m) \ \ n (\ n)" if "\ n = \ m" by (metis "*" "15" eq less less_V_def less_sets_def less_sets_weaken2 that) moreover have "\ \ m (\ m) \ \ n (\ n)" if "\ n < \ m" using that 12 15 * [OF less] apply (clarsimp simp: less_sets_def strict_mono_sets_def) by (metis Ord_in_Ord Ord_linear2 \_in_\ \_in_\ \Ord \\ le leD less_asym subsetD) ultimately show "\ m < \ n" by (meson Ord_in_Ord Ord_linear_lt \_in_\ \Ord \\) next assume "\ m < \ n" then have "\ n (\ n m (\ m)) \ \ n (\ n)" by (metis "12" \_in_\ \_in_\ eq le less_V_def strict_mono_sets_def) then show "\ m (\ m) \ \ n (\ n)" by (meson *[OF less] less_sets_weaken1) qed next case equal with 15 show ?thesis by auto next case greater show ?thesis proof (intro iffI) assume "\ m (\ m) \ \ n (\ n)" moreover have "\ \ m (\ m) \ \ n (\ n)" if "\ n = \ m" by (metis "*" "15" disjnt_iff eq greater in_mono less_sets_imp_disjnt that) moreover have "\ \ m (\ m) \ \ n (\ n)" if "\ n < \ m" using that 12 15 * [OF greater] apply (clarsimp simp: less_sets_def strict_mono_sets_def) by (meson \_in_\ \_in_\ in_mono less less_asym) ultimately show "\ m < \ n" by (meson Ord_\ Ord_linear_lt) next assume "\ m < \ n" then have "\ m (\ m) \ (\ m (\ m n (\ n)))" by (meson 12 Ord_in_Ord Ord_linear2 \_in_\ \_in_\ le leD ord(2) strict_mono_sets_def) then show "\ m (\ m) \ \ n (\ n)" by (meson "*" greater less_sets_weaken2) qed qed have \_increasing_\: "\ n (\ n) \ \ m (\ m)" if "m \ n" "\ m = \ n" for m n by (metis "*" "17" dual_order.order_iff_strict that) moreover have INF: "infinite {n. n \ m \ \ m = \ n}" for m proof - have "infinite (range (\n. q (\ m, n)))" unfolding q_def using to_nat_on_infinite [OF co_\U inf_\U] finite_image_iff by (simp add: finite_image_iff inj_on_def) moreover have "(range (\n. q (\ m, n))) \ {n. \ m = \ n}" using 11 [of "\ m"] by auto ultimately have "infinite {n. \ m = \ n}" using finite_subset by auto then have "infinite ({n. \ m = \ n} - {.. n" "\ p = \ n" "\ m = \ n" "n < p" with 16 [of n] show "x n < x p" by (simp add: less_sets_def) (metis "*" "15" "17" Suc_lessI le_SucI subsetD) qed then have inj_x: "inj_on x (?eqv m)" for m using strict_mono_on_imp_inj_on by blast define ZA where "ZA \ \m. ?Z \ \ m (\ m)" have small_ZA [simp]: "small (ZA m)" for m by (metis ZA_def inf_le1 small_image_nat smaller_than_small) have 19: "tp (ZA m) \ \" for m proof - have "x ` {n. m \ n \ \ m = \ n} \ ZA m" unfolding ZA_def using "15" \_increasing_\ by blast then have "infinite (ZA m)" using INF [of m] finite_image_iff [OF inj_x] by (meson finite_subset) then show ?thesis by (simp add: ordertype_infinite_ge_\) qed have "\f \ elts \ \ ZA m. strict_mono_on f (elts \)" for m proof - obtain Z where "Z \ ZA m" "tp Z = \" by (meson 19 Ord_\ le_ordertype_obtains_subset small_ZA) moreover have "ZA m \ ON" using Ord_in_Ord \_\\ \_in_\ unfolding ZA_def by blast ultimately show ?thesis by (metis strict_mono_on_ordertype Pi_mono small_ZA smaller_than_small subset_iff) qed then obtain \ where \: "\m. \ m \ elts \ \ ZA m" and sm_\: "\m. strict_mono_on (\ m) (elts \)" by metis have "Ex(\(m,\). \ \ elts \ \ \ = \ * \ + ord_of_nat m)" if "\ \ elts (\ * \)" for \ using that by (auto simp: mult [of \ \] lift_def elts_\) then obtain split where split: "\\. \ \ elts (\ * \) \ (\(m,\). \ \ elts \ \ \ = \ * \ + ord_of_nat m)(split \)" by meson have split_eq [simp]: "split (\ * \ + ord_of_nat m) = (m,\)" if "\ \ elts \" for \ m proof - have [simp]: "\ * \ + ord_of_nat m = \ * \ + ord_of_nat n \ \ = \ \ n = m" if "\ \ elts \" for \ n by (metis Ord_\ that Ord_mem_iff_less_TC mult_cancellation_lemma ord_of_nat_\ ord_of_nat_inject) show ?thesis using split [of "\*\ + m"] that by (auto simp: mult [of \ \] lift_def cong: conj_cong) qed define \ where "\ \ \\. (\(m,\). \ (q(\,0)) m)(split \)" have \_Pi: "\ \ elts (\ * \) \ (\m. ZA m)" using \ by (fastforce simp: \_def mult [of \ \] lift_def elts_\) moreover have "(\m. ZA m) \ ON" unfolding ZA_def using \_\\ \_in_\ elts_subset_ON by blast ultimately have Ord_\_Pi: "\ \ elts (\ * \) \ ON" by fastforce show "tp ?Z \ \ * \" proof - have \: "(\m. ZA m) = ?Z" using "15" by (force simp: ZA_def) moreover have "tp (elts (\ * \)) \ tp (\m. ZA m)" proof (rule ordertype_inc_le) show "\ ` elts (\ * \) \ (\m. ZA m)" using \_Pi by blast next fix u v assume x: "u \ elts (\ * \)" and y: "v \ elts (\ * \)" and "(u,v) \ VWF" then have "u Ord_in_Ord Ord_mult VWF_iff_Ord_less ord(2)) moreover obtain m \ n \ where ueq: "u = \ * \ + ord_of_nat m" and \: "\ \ elts \" and veq: "v = \ * \ + ord_of_nat n" and \: "\ \ elts \" using x y by (auto simp: mult [of \ \] lift_def elts_\) ultimately have "\ \ \" by (meson Ord_\ Ord_in_Ord Ord_linear2 \Ord \\ add_mult_less_add_mult less_asym ord_of_nat_\) consider (eq) "\ = \" | (lt) "\ < \" using \\ \ \\ le_neq_trans by blast then have "\ u < \ v" proof cases case eq then have "m < n" using ueq veq \u by simp then have "\ (q (\, 0)) m < \ (q (\, 0)) n" using sm_\ strict_mono_onD by blast then show ?thesis using eq ueq veq \ \m < n\ by (simp add: \_def) next case lt have "\ (q(\,0)) m \ \ (q(\,0)) (\(q(\,0)))" "\ (q (\,0)) n \ \ (q(\,0)) (\(q(\,0)))" using \ unfolding ZA_def by blast+ then show ?thesis using lt ueq veq \ \ 18 [of "q(\,0)" "q(\,0)"] by (simp add: \_def less_sets_def) qed then show "(\ u, \ v) \ VWF" using \_Pi by (metis Ord_\_Pi PiE VWF_iff_Ord_less x y mem_Collect_eq) qed (use \ in auto) ultimately show ?thesis by simp qed qed then obtain Z where "Z \ ?Z" "tp Z = \ * \" by (meson Ord_\ Ord_mult ord Z_sub down le_ordertype_obtains_subset) ultimately show False using iii [of Z] by (meson dual_order.trans image_mono nsets_mono) qed have False if 0: "\H. tp H = ord_of_nat (2*k) \ H \ elts (\*\) \ \ f ` [H]\<^bsup>2\<^esup> \ {0}" and 1: "\H. tp H = min \ (\ * \) \ H \ elts (\*\) \ \ f ` [H]\<^bsup>2\<^esup> \ {1}" proof (cases "\*\ \ \") case True then have \: "\H'\H. tp H' = \ * \" if "tp H = \" "small H" for H by (metis Ord_\ Ord_\1 Ord_in_Ord Ord_mult \ le_ordertype_obtains_subset that) have [simp]: "min \ (\*\) = \*\" by (simp add: min_absorb2 that True) then show ?thesis using * [OF 0] 1 True by simp (meson \ down image_mono nsets_mono subset_trans) next case False then have \: "\H'\H. tp H' = \" if "tp H = \ * \" "small H" for H by (metis Ord_linear_le Ord_ordertype \Ord \\ le_ordertype_obtains_subset that) then have "\ \ \*\" by (meson Ord_\ Ord_\1 Ord_in_Ord Ord_linear_le Ord_mult \ \Ord \\ False) then have [simp]: "min \ (\*\) = \" by (simp add: min_absorb1) then show ?thesis using * [OF 0] 1 False by simp (meson \ down image_mono nsets_mono subset_trans) qed then show "\iH\elts (\*\). tp H = [ord_of_nat (2*k), min \ (\*\)] ! i \ f ` [H]\<^bsup>2\<^esup> \ {i}" by force qed qed theorem Erdos_Milner: assumes \: "\ \ elts \1" shows "partn_lst_VWF (\\(1 + \ * n)) [ord_of_nat (2^n), \\(1+\)] 2" proof (induction n) case 0 then show ?case using partn_lst_VWF_degenerate [of 1 2] by simp next case (Suc n) have "Ord \" using Ord_\1 Ord_in_Ord assms by blast have "1+\ \ \+1" by (simp add: \Ord \\ one_V_def plus_Ord_le) then have [simp]: "min (\ \ (1 + \)) (\ * \ \ \) = \ \ (1+\)" by (simp add: \Ord \\ oexp_add min_def) have ind: "indecomposable (\ \ (1 + \ * ord_of_nat n))" by (simp add: \Ord \\ indecomposable_\_power) show ?case proof (cases "n = 0") case True then show ?thesis using partn_lst_VWF_\_2 \Ord \\ one_V_def by auto next case False then have "Suc 0 < 2 ^ n" using less_2_cases not_less_eq by fastforce then have "partn_lst_VWF (\ \ (1 + \ * n) * \ \ \) [ord_of_nat (2 * 2 ^ n), \ \ (1 + \)] 2" using Erdos_Milner_aux [OF Suc ind, where \ = "\\\"] \Ord \\ \ by (auto simp: countable_oexp) then show ?thesis using \Ord \\ by (simp add: mult_succ mult.assoc oexp_add) qed qed corollary remark_3: "partn_lst_VWF (\\(Suc(4*k))) [4, \\(Suc(2*k))] 2" using Erdos_Milner [of "2*k" 2] apply (simp flip: ord_of_nat_mult ord_of_nat.simps) by (simp add: one_V_def) text \Theorem 3.2 of Jean A. Larson, ibid.\ corollary Theorem_3_2: fixes k n::nat shows "partn_lst_VWF (\\(n*k)) [\\n, ord_of_nat k] 2" proof (cases "n=0 \ k=0") case True then show ?thesis by (auto intro: partn_lst_triv0 [where i=1] partn_lst_triv1 [where i=0]) next case False then have "n > 0" "k > 0" by auto have PV: "partn_lst_VWF (\ \ (1 + ord_of_nat (n-1) * ord_of_nat (k-1))) [ord_of_nat (2 ^ (k-1)), \ \ (1 + ord_of_nat (n-1))] 2" using Erdos_Milner [of "ord_of_nat (n-1)" "k-1"] Ord_\1 Ord_mem_iff_lt less_imp_le by blast have "k+n \ Suc (Suc(k-1) * Suc(n-1))" by simp also have "\ \ Suc (k * n)" using False by auto finally have "1 + (n - 1) * (k - 1) \ n*k" using False by (auto simp: algebra_simps) then have "(1 + ord_of_nat (n - 1) * ord_of_nat (k - 1)) \ ord_of_nat(n*k)" by (metis (mono_tags, lifting) One_nat_def one_V_def ord_of_nat.simps ord_of_nat_add ord_of_nat_mono_iff ord_of_nat_mult) then have x: "\ \ (1 + ord_of_nat (n - 1) * ord_of_nat (k - 1)) \ \\(n*k)" by (simp add: oexp_mono_le) then have "partn_lst_VWF (\\(n*k)) [\ \ (1 + ord_of_nat (n-1)), ord_of_nat (2 ^ (k-1))] 2" by (metis PV partn_lst_two_swap Partitions.partn_lst_greater_resource less_eq_V_def) then have "partn_lst_VWF (\\(n*k)) [\ \ n, ord_of_nat (2 ^ (k-1))] 2" using ord_of_minus_1 [OF \n > 0\] by (simp add: one_V_def) then show ?thesis using power_gt_expt [of 2 "k-1"] by (force simp: less_Suc_eq intro: partn_lst_less) qed end diff --git a/thys/ZFC_in_HOL/Ordinal_Exp.thy b/thys/ZFC_in_HOL/Ordinal_Exp.thy --- a/thys/ZFC_in_HOL/Ordinal_Exp.thy +++ b/thys/ZFC_in_HOL/Ordinal_Exp.thy @@ -1,589 +1,589 @@ section \Exponentiation of ordinals\ theory Ordinal_Exp imports Kirby begin text \Source: Schlöder, Julian. Ordinal Arithmetic; available online at \url{http://www.math.uni-bonn.de/ag/logik/teaching/2012WS/Set%20theory/oa.pdf}\ definition oexp :: "[V,V] \ V" (infixr "\" 80) where "oexp a b \ transrec (\f x. if x=0 then 1 else if Limit x then if a=0 then 0 else SUP \ \ elts x. f \ - else f (\(elts x)) * a) b" + else f (\(elts x)) * a) b" text \@{term "0\\ = 1"} if we don't make a special case for Limit ordinals and zero\ lemma oexp_0_right [simp]: "\\0 = 1" by (simp add: def_transrec [OF oexp_def]) lemma oexp_succ [simp]: "Ord \ \ \\(succ \) = \\\ * \" by (simp add: def_transrec [OF oexp_def]) lemma oexp_Limit: "Limit \ \ \\\ = (if \=0 then 0 else SUP \ \ elts \. \\\)" by (auto simp: def_transrec [OF oexp_def, of _ \]) lemma oexp_1_right [simp]: "\\1 = \" using one_V_def oexp_succ by fastforce lemma oexp_1 [simp]: "Ord \ \ 1\\ = 1" by (induction rule: Ord_induct3) (use Limit_def oexp_Limit in auto) lemma oexp_0 [simp]: "Ord \ \ 0\\ = (if \ = 0 then 1 else 0)" by (induction rule: Ord_induct3) (use Limit_def oexp_Limit in auto) lemma oexp_eq_0_iff [simp]: assumes "Ord \" shows "\\\ = 0 \ \=0 \ \\0" using \Ord \\ proof (induction rule: Ord_induct3) case (Limit \) then show ?case using Limit_def oexp_Limit by auto qed auto lemma oexp_gt_0_iff [simp]: assumes "Ord \" shows "\\\ > 0 \ \>0 \ \=0" by (simp add: assms less_V_def) lemma ord_of_nat_oexp: "ord_of_nat (m^n) = ord_of_nat m\ord_of_nat n" proof (induction n) case (Suc n) then show ?case by (simp add: mult.commute [of m]) (simp add: ord_of_nat_mult) qed auto lemma omega_closed_oexp [intro]: assumes "\ \ elts \" "\ \ elts \" shows "\\\ \ elts \" proof - obtain m n where "\ = ord_of_nat m" "\ = ord_of_nat n" using assms elts_\ by auto then have "\\\ = ord_of_nat (m^n)" by (simp add: ord_of_nat_oexp) then show ?thesis by (simp add: \_def) qed lemma Ord_oexp [simp]: assumes "Ord \" "Ord \" shows "Ord (\\\)" using \Ord \\ proof (induction rule: Ord_induct3) case (Limit \) then show ?case by (auto simp: oexp_Limit image_iff intro: Ord_Sup) qed (auto intro: Ord_mult assms) text \Lemma 3.19\ lemma le_oexp: assumes "Ord \" "Ord \" "\ \ 0" shows "\ \ \\\" using \Ord \\ \\ \ 0\ proof (induction rule: Ord_induct3) case (succ \) then show ?case by simp (metis \Ord \\ le_0 le_mult mult.left_neutral oexp_0_right order_refl order_trans) next case (Limit \) then show ?case by (metis Limit_def Limit_eq_Sup_self ZFC_in_HOL.Sup_upper eq_iff image_eqI image_ident oexp_1_right oexp_Limit replacement small_elts one_V_def) qed auto text \Lemma 3.20\ lemma le_oexp': assumes "Ord \" "1 < \" "Ord \" shows "\ \ \\\" proof (cases "\ = 0") case True then show ?thesis by auto next case False show ?thesis using \Ord \\ proof (induction rule: Ord_induct3) case 0 then show ?case by auto next case (succ \) then have "\\\ * 1 < \\\ * \" using \Ord \\ \1 < \\ by (metis le_mult less_V_def mult.right_neutral mult_cancellation not_less_0 oexp_eq_0_iff succ.hyps) then have " \ < \\succ \" using succ.IH succ.hyps by auto then show ?case using False \Ord \\ \1 < \\ succ by (metis Ord_mem_iff_lt Ord_oexp Ord_succ elts_succ insert_subset less_eq_V_def less_imp_le) next case (Limit \) with False \1 < \\ show ?case by (force simp: Limit_def oexp_Limit intro: elts_succ) qed qed lemma oexp_Limit_le: assumes "\ < \" "Limit \" "Ord \" "\ > 0" shows "\\\ \ \\\" proof - have "Ord \" using Limit_def assms(2) by blast with assms show ?thesis using Ord_mem_iff_lt ZFC_in_HOL.Sup_upper oexp_Limit by auto qed proposition oexp_less: assumes \: "\ \ elts \" and "Ord \" and \: "\ > 1" "Ord \" shows "\\\ < \\\" proof - obtain "\ < \" "Ord \" using Ord_in_Ord OrdmemD assms by auto have gt0: "\\\ > 0" using \Ord \\ \ dual_order.order_iff_strict by auto show ?thesis using \Ord \\ \ proof (induction rule: Ord_induct3) case 0 then show ?case by auto next case (succ \) then consider "\ = \" | "\ < \" using OrdmemD elts_succ by blast then show ?case proof cases case 1 then have "(\\\) * 1 < (\\\) * \" using Ord_1 Ord_oexp \ gt0 mult_cancel_less_iff succ.hyps by metis then show ?thesis by (simp add: succ.hyps) next case 2 then have "(\\\) * 1 < (\\\) * \" by (meson Ord_1 Ord_mem_iff_lt Ord_oexp \Ord \\ \ gt0 less_trans mult_cancel_less_iff succ) with 2 show ?thesis using Ord_mem_iff_lt \Ord \\ succ by auto qed next case (Limit \) then obtain "Ord \" "succ \ < \" using Limit_def Ord_in_Ord OrdmemD assms by auto have "\\\ = (\\\) * 1" by simp also have "\ < (\\\) * \" using Ord_oexp \Ord \\ assms gt0 mult_cancel_less_iff by blast also have "\ = \\succ \" by (simp add: \Ord \\) also have "\ \ (SUP \ \ elts \. \\\)" proof - have "succ \ \ elts \" using Limit.hyps Limit.prems Limit_def by auto then show ?thesis by (simp add: ZFC_in_HOL.Sup_upper) qed finally have "\\\ < (SUP \ \ elts \. \\\)" . then show ?case using Limit.hyps oexp_Limit \\ > 1\ by auto qed qed corollary oexp_less_iff: assumes "\ > 0" "Ord \" "Ord \" "Ord \" shows "\\\ < \\\ \ \ \ elts \ \ \ > 1" proof safe show "\ \ elts \" "1 < \" if "\\\ < \\\" proof - show "\ > 1" proof (rule ccontr) assume "\ \ > 1" then consider "\=0" | "\=1" using \Ord \\ less_V_def mem_0_Ord by fastforce then show False by cases (use that \\ > 0\ \Ord \\ \Ord \\ in \auto split: if_split_asm\) qed show \: "\ \ elts \" proof (rule ccontr) assume "\ \ elts \" then have "\ \ \" by (meson Ord_linear_le Ord_mem_iff_lt assms less_le_not_le) then consider "\ = \" | "\ < \" using less_V_def by blast then show False proof cases case 1 then show ?thesis using that by blast next case 2 with \\ > 1\ have "\\\ < \\\" by (simp add: Ord_mem_iff_lt assms oexp_less) with that show ?thesis by auto qed qed qed show "\\\ < \\\" if "\ \ elts \" "1 < \" using that by (simp add: assms oexp_less) qed lemma \_oexp_iff [simp]: "\Ord \; Ord \\ \ \\\ = \\\ \ \=\" by (metis Ord_\ Ord_linear \_gt1 less_irrefl oexp_less) lemma Limit_oexp: assumes "Limit \" "Ord \" "\ > 1" shows "Limit (\\\)" unfolding Limit_def proof safe show O\\: "Ord (\\\)" using Limit_def Ord_oexp \Limit \\ assms(2) by blast show 0: "0 \ elts (\\\)" using Limit_def oexp_Limit \Limit \\ \\ > 1\ by fastforce have "Ord \" using Limit_def \Limit \\ by blast fix x assume x: "x \ elts (\\\)" with \Limit \\ \\ > 1\ obtain \ where "\ < \" "Ord \" "Ord x" and x\: "x \ elts (\\\)" apply (simp add: oexp_Limit split: if_split_asm) using Ord_in_Ord OrdmemD \Ord \\ O\\ x by blast then have O\\: "Ord (\\\)" using Ord_oexp assms(2) by blast have "\ \ elts \" by (simp add: Ord_mem_iff_lt \Ord \\ \Ord \\ \\ < \\) moreover have "\ \ 0" using \\ > 1\ by blast ultimately have \\\: "\\\ \ \\\" by (simp add: Sup_upper oexp_Limit \Limit \\) have "succ x \ \\\" by (simp add: OrdmemD O\\ \Ord x\ succ_le_iff x\) then consider "succ x < \\\" | "succ x = \\\" using le_neq_trans by blast then show "succ x \ elts (\\\)" proof cases case 1 with \\\ show ?thesis using O\\ Ord_mem_iff_lt \Ord x\ by blast next case 2 then have "succ \ < \" using Limit_def OrdmemD \\ \ elts \\ assms(1) by auto have ge1: "1 \ \\\" by (metis "2" Ord_0 \Ord x\ le_0 le_succ_iff one_V_def) have "succ x < succ (\\\)" using "2" O\\ succ_le_iff by auto also have "\ \ (\\\) + (\\\)" using ge1 by (simp add: succ_eq_add1) also have "\ = (\\\) * succ (succ 0)" by (simp add: mult_succ) also have "\ \ (\\\) * \" using O\\ Ord_succ assms(2) assms(3) one_V_def succ_le_iff by auto also have "\ = \\succ \" by (simp add: \Ord \\) also have "\ \ \\\" by (meson Limit_def \\ \ elts \\ assms dual_order.order_iff_strict oexp_less) finally show ?thesis by (simp add: "2" O\\ O\\ Ord_mem_iff_lt) qed qed lemma oexp_mono: assumes \: "Ord \" "\ \ 0" and \: "Ord \" "\ \ \" shows "\\\ \ \\\" using \ proof (induction rule: Ord_induct3) case 0 then show ?case by simp next case (succ \) with \ le_mult show ?case by (auto simp: le_TC_succ) next case (Limit \) then have "\\\ \ \ ((\) \ ` elts \)" using Limit.hyps Ord_less_TC_mem \\ \ 0\ le_TC_def by (auto simp: oexp_Limit Limit_def) then show ?case using \ by (simp add: oexp_Limit Limit.hyps) qed lemma oexp_mono_le: assumes "\ \ \" "\ \ 0" "Ord \" "Ord \" "Ord \" shows "\\\ \ \\\" by (simp add: assms oexp_mono vle2 vle_iff_le_Ord) lemma oexp_sup: assumes "\ \ 0" "Ord \" "Ord \" "Ord \" shows "\\(\ \ \) = \\\ \ \\\" by (metis Ord_linear_le assms oexp_mono_le sup.absorb2 sup.orderE) lemma oexp_Sup: assumes \: "\ \ 0" "Ord \" and X: "X \ ON" "small X" "X \ {}" shows "\\\ X = \ ((\) \ ` X)" proof (rule order_antisym) show "\ ((\) \ ` X) \ \\\ X" by (metis ON_imp_Ord Ord_Sup ZFC_in_HOL.Sup_upper assms cSUP_least oexp_mono_le) next have "Ord (Sup X)" using Ord_Sup X by auto then show "\\\ X \ \ ((\) \ ` X)" proof (cases rule: Ord_cases) case 0 then show ?thesis using X dual_order.antisym by fastforce next case (succ \) then show ?thesis using ZFC_in_HOL.Sup_upper X succ_in_Sup_Ord by auto next case limit show ?thesis proof (clarsimp simp: assms oexp_Limit limit) fix x y z assume x: "x \ elts (\ \ y)" and "z \ X" "y \ elts z" then have "\ \ y \ \ \ z" by (meson ON_imp_Ord Ord_in_Ord OrdmemD \ \X \ ON\ le_less oexp_mono_le) with x have "x \ elts (\ \ z)" by blast then show "\u\X. x \ elts (\ \ u)" using \z \ X\ by blast qed qed qed lemma omega_le_Limit: assumes "Limit \" shows "\ \ \" proof fix \ assume "\ \ elts \" then obtain n where "\ = ord_of_nat n" using elts_\ by auto have "ord_of_nat n \ elts \" by (induction n) (use Limit_def assms in auto) then show "\ \ elts \" using \\ = ord_of_nat n\ by auto qed lemma finite_omega_power [simp]: assumes "1 < n" "n \ elts \" shows "n\\ = \" proof (rule order_antisym) have "\ ((\) (ord_of_nat k) ` elts \) \ \" for k proof (induction k) case 0 then show ?case by auto next case (Suc k) then show ?case by (metis Ord_\ OrdmemD Sup_eq_0_iff ZFC_in_HOL.SUP_le_iff le_0 le_less omega_closed_oexp ord_of_nat_\) qed then show "n\\ \ \" using assms by (simp add: elts_\ oexp_Limit) metis show "\ \ n\\" using Ord_in_Ord assms le_oexp' by blast qed proposition oexp_add: assumes "Ord \" "Ord \" "Ord \" shows "\\(\ + \) = \\\ * \\\" proof (cases \\ = 0\) case True then show ?thesis using assms by simp next case False show ?thesis using \Ord \\ proof (induction rule: Ord_induct3) case 0 then show ?case by auto next case (succ \) then show ?case using \Ord \\ by (auto simp: plus_V_succ_right mult.assoc) next case (Limit \) have "\\(\ + (SUP \\elts \. \)) = (SUP \\elts (\ + \). \\\)" by (simp add: Limit.hyps oexp_Limit assms False) also have "\ = (SUP \ \ {\. Ord \ \ \ + \ < \ + \}. \\(\ + \))" proof (rule Sup_eq_Sup) show "(\\. \\(\ + \)) ` {\. Ord \ \ \ + \ < \ + \} \ (\) \ ` elts (\ + \)" using Limit.hyps Limit_def Ord_mem_iff_lt imageI by blast fix x assume "x \ (\) \ ` elts (\ + \)" then obtain \ where \: "\ \ elts (\ + \)" and x: "x = \\\" by auto have "\\. Ord \ \ \ < \ \ \\\ \ \\(\ + \)" proof (rule mem_plus_V_E [OF \]) assume "\ \ elts \" then have "\\\ \ \\\" by (meson arg_subset_TC assms False le_TC_def less_TC_def oexp_mono vsubsetD) with zero_less_Limit [OF \Limit \\] show "\\. Ord \ \ \ < \ \ \\\ \ \\(\ + \)" by force next fix \ assume "\ \ elts \" and "\ = \ + \" have "Ord \" using Limit.hyps Limit_def Ord_in_Ord \\ \ elts \\ by blast moreover have "\ < \" using Limit.hyps Limit_def OrdmemD \\ \ elts \\ by auto ultimately show "\\. Ord \ \ \ < \ \ \\\ \ \\(\ + \)" using \\ = \ + \\ by blast qed then show "\y\(\\. \\(\ + \)) ` {\. Ord \ \ \ + \ < \ + \}. x \ y" using x by auto qed auto also have "\ = (SUP \\elts \. \\(\ + \))" using \Limit \\ by (simp add: Ord_Collect_lt Limit_def) also have "\ = (SUP \\elts \. \\\ * \\\)" using Limit.IH by auto also have "\ = \\\ * \\(SUP \\elts \. \)" using \\ \ 0\ Limit.hyps by (simp add: image_image oexp_Limit mult_Sup_distrib) finally show ?case . qed qed proposition oexp_mult: assumes "Ord \" "Ord \" "Ord \" shows "\\(\ * \) = (\\\)\\" proof (cases "\ = 0 \ \ = 0") case True then show ?thesis by (auto simp: \Ord \\ \Ord \\) next case False show ?thesis using \Ord \\ proof (induction rule: Ord_induct3) case 0 then show ?case by auto next case succ then show ?case using assms by (auto simp: mult_succ oexp_add) next case (Limit \) have Lim: "Limit (\ ((*) \ ` elts \))" unfolding Limit_def proof (intro conjI allI impI) show "Ord (\ ((*) \ ` elts \))" using Limit.hyps Limit_def Ord_in_Ord \Ord \\ by (auto intro: Ord_Sup) have "succ 0 \ elts \" using Limit.hyps Limit_def by blast then show "0 \ elts (\ ((*) \ ` elts \))" using False \Ord \\ mem_0_Ord by force show "succ y \ elts (\ ((*) \ ` elts \))" if "y \ elts (\ ((*) \ ` elts \))" for y using that False Limit.hyps apply (clarsimp simp: Limit_def) by (metis Ord_in_Ord Ord_linear Ord_mem_iff_lt Ord_mult Ord_succ assms(2) less_V_def mult_cancellation mult_succ not_add_mem_right succ_le_iff succ_ne_self) qed have "\\(\ * (SUP \\elts \. \)) = \\\ ((*) \ ` elts \)" by (simp add: mult_Sup_distrib) also have "\ = \ (\x\elts \. (\) \ ` elts (\ * x))" using False Lim oexp_Limit by fastforce also have "\ = (SUP x\elts \. \\(\ * x))" proof (rule Sup_eq_Sup) show "(\x. \\(\ * x)) ` elts \ \ (\x\elts \. (\) \ ` elts (\ * x))" using \Ord \\ \Ord \\ False Limit apply clarsimp by (metis Limit_def elts_succ imageI insertI1 mem_0_Ord mult_add_mem_0) show "\y\(\x. \\(\ * x)) ` elts \. x \ y" if "x \ (\x\elts \. (\) \ ` elts (\ * x))" for x using that \Ord \\ \Ord \\ False Limit by clarsimp (metis Limit_def Ord_in_Ord Ord_mult VWO_TC_le mem_imp_VWO oexp_mono) qed auto also have "\ = \ ((\) (\\\) ` elts (SUP \\elts \. \))" using Limit.IH Limit.hyps by auto also have "\ = (\\\)\(SUP \\elts \. \)" using False Limit.hyps oexp_Limit \Ord \\ by auto finally show ?case . qed qed lemma Limit_omega_oexp: assumes "Ord \" "\ \ 0" shows "Limit (\\\)" using assms proof (cases \ rule: Ord_cases) case 0 then show ?thesis using assms(2) by blast next case (succ l) have *: "succ \ \ elts (\\l * n + \\l)" if n: "n \ elts \" and \: "\ \ elts (\\l * n)" for n \ proof - obtain "Ord n" "Ord \" by (meson Ord_\ Ord_in_Ord Ord_mult Ord_oexp \ n succ(1)) obtain oo: "Ord (\\l)" "Ord (\\l * n)" by (simp add: \Ord n\ succ(1)) moreover have f4: "\ < \\l * n" using oo Ord_mem_iff_lt \Ord \\ \\ \ elts (\\l * n)\ by blast moreover have f5: "Ord (succ \)" using \Ord \\ by blast moreover have "\\l \ 0" using oexp_eq_0_iff omega_nonzero succ(1) by blast ultimately show ?thesis by (metis add_less_cancel_left Ord_\ Ord_add Ord_mem_iff_lt OrdmemD \Ord \\ add.right_neutral dual_order.strict_trans2 oexp_gt_0_iff succ(1) succ_le_iff zero_in_omega) qed show ?thesis using succ apply (clarsimp simp: Limit_def mem_0_Ord) apply (simp add: mult_Limit) by (metis * mult_succ succ_in_omega) next case limit then show ?thesis by (metis Limit_oexp Ord_\ OrdmemD one_V_def succ_in_omega zero_in_omega) qed lemma oexp_mult_commute: fixes j::nat assumes "Ord \" shows "(\ \ j) * \ = \ * (\ \ j)" proof - have "(\ \ j) * \ = \ \ (1 + ord_of_nat j)" by (simp add: one_V_def) also have "... = \ * (\ \ j)" by (simp add: assms oexp_add) finally show ?thesis . qed lemma oexp_\_Limit: "Limit \ \ \\\ = (SUP \ \ elts \. \\\)" by (simp add: oexp_Limit) lemma \_power_succ_gtr: "Ord \ \ \ \ \ * ord_of_nat n < \ \ succ \" by (simp add: OrdmemD) lemma countable_oexp: assumes \: "\ \ elts \1" shows "\ \ \ \ elts \1" proof - have "Ord \" using Ord_\1 Ord_in_Ord assms by blast then show ?thesis using assms proof (induction rule: Ord_induct3) case 0 then show ?case by (simp add: Ord_mem_iff_lt) next case (succ \) then have "countable (elts (\ \ \ * \))" by (simp add: succ_in_Limit_iff countable_mult less_\1_imp_countable) then show ?case using Ord_mem_iff_lt countable_iff_less_\1 succ.hyps by auto next case (Limit \) with Ord_\1 have "countable (\\\elts \. elts (\ \ \))" "Ord (\ \ \ (elts \))" by (force simp: Limit_def intro: Ord_trans less_\1_imp_countable)+ then have "\ \ \ (elts \) < \1" using Limit.hyps countable_iff_less_\1 oexp_Limit by fastforce then show ?case using Limit.hyps Limit_def Ord_mem_iff_lt by auto qed qed end diff --git a/thys/ZFC_in_HOL/ZFC_Cardinals.thy b/thys/ZFC_in_HOL/ZFC_Cardinals.thy --- a/thys/ZFC_in_HOL/ZFC_Cardinals.thy +++ b/thys/ZFC_in_HOL/ZFC_Cardinals.thy @@ -1,2526 +1,2541 @@ section \Cartesian products, Disjoint Sums, Ranks, Cardinals\ theory ZFC_Cardinals imports ZFC_in_HOL begin declare [[coercion_enabled]] declare [[coercion "ord_of_nat :: nat \ V"]] subsection \Ordered Pairs\ lemma singleton_eq_iff [iff]: "set {a} = set {b} \ a=b" by simp lemma doubleton_eq_iff: "set {a,b} = set {c,d} \ (a=c \ b=d) \ (a=d \ b=c)" by (simp add: Set.doubleton_eq_iff) definition vpair :: "V \ V \ V" where "vpair a b = set {set {a},set {a,b}}" definition vfst :: "V \ V" where "vfst p \ THE x. \y. p = vpair x y" definition vsnd :: "V \ V" where "vsnd p \ THE y. \x. p = vpair x y" definition vsplit :: "[[V, V] \ 'a, V] \ 'a::{}" \ \for pattern-matching\ where "vsplit c \ \p. c (vfst p) (vsnd p)" nonterminal Vs syntax (ASCII) "_Tuple" :: "[V, Vs] \ V" ("<(_,/ _)>") "_hpattern" :: "[pttrn, patterns] \ pttrn" ("<_,/ _>") syntax "" :: "V \ Vs" ("_") "_Enum" :: "[V, Vs] \ Vs" ("_,/ _") "_Tuple" :: "[V, Vs] \ V" ("\(_,/ _)\") "_hpattern" :: "[pttrn, patterns] \ pttrn" ("\_,/ _\") translations "" \ ">" "" \ "CONST vpair x y" "" \ ">" "\. b" \ "CONST vsplit(\x . b)" "\. b" \ "CONST vsplit(\x y. b)" lemma vpair_def': "vpair a b = set {set {a,a},set {a,b}}" by (simp add: vpair_def) lemma vpair_iff [simp]: "vpair a b = vpair a' b' \ a=a' \ b=b'" unfolding vpair_def' doubleton_eq_iff by auto lemmas vpair_inject = vpair_iff [THEN iffD1, THEN conjE, elim!] lemma vfst_conv [simp]: "vfst \a,b\ = a" by (simp add: vfst_def) lemma vsnd_conv [simp]: "vsnd \a,b\ = b" by (simp add: vsnd_def) lemma vsplit [simp]: "vsplit c \a,b\ = c a b" by (simp add: vsplit_def) lemma vpair_neq_fst: "\a,b\ \ a" by (metis elts_of_set insertI1 mem_not_sym small_upair vpair_def') lemma vpair_neq_snd: "\a,b\ \ b" by (metis elts_of_set insertI1 mem_not_sym small_upair subsetD subset_insertI vpair_def') lemma vpair_nonzero [simp]: "\x,y\ \ 0" by (metis elts_0 elts_of_set empty_not_insert small_upair vpair_def) lemma zero_notin_vpair: "0 \ elts \x,y\" by (auto simp: vpair_def) lemma inj_on_vpair [simp]: "inj_on (\(x, y). \x, y\) A" by (auto simp: inj_on_def) subsection \Generalized Cartesian product\ definition VSigma :: "V \ (V \ V) \ V" where "VSigma A B \ set(\x \ elts A. \y \ elts (B x). {\x,y\})" abbreviation vtimes where "vtimes A B \ VSigma A (\x. B)" definition pairs :: "V \ (V * V)set" where "pairs r \ {(x,y). \x,y\ \ elts r} " lemma pairs_iff_elts: "(x,y) \ pairs z \ \x,y\ \ elts z" by (simp add: pairs_def) lemma VSigma_iff [simp]: "\a,b\ \ elts (VSigma A B) \ a \ elts A \ b \ elts (B a)" by (auto simp: VSigma_def UNION_singleton_eq_range) lemma VSigmaI [intro!]: "\ a \ elts A; b \ elts (B a)\ \ \a,b\ \ elts (VSigma A B)" by simp lemmas VSigmaD1 = VSigma_iff [THEN iffD1, THEN conjunct1] lemmas VSigmaD2 = VSigma_iff [THEN iffD1, THEN conjunct2] text \The general elimination rule\ lemma VSigmaE [elim!]: assumes "c \ elts (VSigma A B)" obtains x y where "x \ elts A" "y \ elts (B x)" "c=\x,y\" using assms by (auto simp: VSigma_def split: if_split_asm) lemma VSigmaE2 [elim!]: assumes "\a,b\ \ elts (VSigma A B)" obtains "a \ elts A" and "b \ elts (B a)" using assms by auto lemma VSigma_empty1 [simp]: "VSigma 0 B = 0" by auto lemma times_iff [simp]: "\a,b\ \ elts (vtimes A B) \ a \ elts A \ b \ elts B" by simp lemma timesI [intro!]: "\a \ elts A; b \ elts B\ \ \a,b\ \ elts (vtimes A B)" by simp lemma times_empty2 [simp]: "vtimes A 0 = 0" using elts_0 by blast lemma times_empty_iff: "VSigma A B = 0 \ A=0 \ (\x \ elts A. B x = 0)" by (metis VSigmaE VSigmaI elts_0 empty_iff trad_foundation) lemma elts_VSigma: "elts (VSigma a b) = (\(x,y). vpair x y) ` Sigma (elts a) (\x. elts (b x))" by auto lemma small_Times [simp]: assumes "small A" "small B" shows "small (A \ B)" proof - obtain f a g b where "inj_on f A" "inj_on g B" and f: "f ` A = elts a" and g: "g ` B = elts b" using assms by (auto simp: small_def) define h where "h \ \(x,y). \f x, g y\" show ?thesis unfolding small_def proof (intro exI conjI) show "inj_on h (A \ B)" using \inj_on f A\ \inj_on g B\ by (simp add: h_def inj_on_def) have "h ` (A \ B) = elts (vtimes a b)" using f g by (fastforce simp: h_def image_iff split: prod.split) then show "h ` (A \ B) \ range elts" by blast qed qed subsection \Disjoint Sum\ definition vsum :: "V \ V \ V" (infixl "\" 65) where "A \ B \ (VSigma (set {0}) (\x. A)) \ (VSigma (set {1}) (\x. B))" definition Inl :: "V\V" where "Inl a \ \0,a\" definition Inr :: "V\V" where "Inr b \ \1,b\" lemmas sum_defs = vsum_def Inl_def Inr_def lemma Inl_nonzero [simp]:"Inl x \ 0" by (metis Inl_def vpair_nonzero) lemma Inr_nonzero [simp]:"Inr x \ 0" by (metis Inr_def vpair_nonzero) subsubsection\Equivalences for the injections and an elimination rule\ lemma Inl_in_sum_iff [iff]: "Inl a \ elts (A \ B) \ a \ elts A" by (auto simp: sum_defs) lemma Inr_in_sum_iff [iff]: "Inr b \ elts (A \ B) \ b \ elts B" by (auto simp: sum_defs) lemma sumE [elim!]: assumes u: "u \ elts (A \ B)" obtains x where "x \ elts A" "u=Inl x" | y where "y \ elts B" "u=Inr y" using u by (auto simp: sum_defs) subsubsection \Injection and freeness equivalences, for rewriting\ lemma Inl_iff [iff]: "Inl a=Inl b \ a=b" by (simp add: sum_defs) lemma Inr_iff [iff]: "Inr a=Inr b \ a=b" by (simp add: sum_defs) lemma inj_on_Inl [simp]: "inj_on Inl A" by (simp add: inj_on_def) lemma inj_on_Inr [simp]: "inj_on Inr A" by (simp add: inj_on_def) lemma Inl_Inr_iff [iff]: "Inl a=Inr b \ False" by (simp add: sum_defs) lemma Inr_Inl_iff [iff]: "Inr b=Inl a \ False" by (simp add: sum_defs) lemma sum_empty [simp]: "0 \ 0 = 0" by auto lemma elts_vsum: "elts (a \ b) = Inl ` (elts a) \ Inr ` (elts b)" by auto lemma sum_iff: "u \ elts (A \ B) \ (\x. x \ elts A \ u=Inl x) \ (\y. y \ elts B \ u=Inr y)" by blast lemma sum_subset_iff: "A\B \ C\D \ A\C \ B\D" by (auto simp: less_eq_V_def) lemma sum_equal_iff: fixes A :: V shows "A\B = C\D \ A=C \ B=D" by (simp add: eq_iff sum_subset_iff) definition is_sum :: "V \ bool" where "is_sum z = (\x. z = Inl x \ z = Inr x)" definition sum_case :: "(V \ 'a) \ (V \ 'a) \ V \ 'a" where "sum_case f g a \ THE z. (\x. a = Inl x \ z = f x) \ (\y. a = Inr y \ z = g y) \ (\ is_sum a \ z = undefined)" lemma sum_case_Inl [simp]: "sum_case f g (Inl x) = f x" by (simp add: sum_case_def is_sum_def) lemma sum_case_Inr [simp]: "sum_case f g (Inr y) = g y" by (simp add: sum_case_def is_sum_def) lemma sum_case_non [simp]: "\ is_sum a \ sum_case f g a = undefined" by (simp add: sum_case_def is_sum_def) lemma is_sum_cases: "(\x. z = Inl x \ z = Inr x) \ \ is_sum z" by (auto simp: is_sum_def) lemma sum_case_split: "P (sum_case f g a) \ (\x. a = Inl x \ P(f x)) \ (\y. a = Inr y \ P(g y)) \ (\ is_sum a \ P undefined)" by (cases "is_sum a") (auto simp: is_sum_def) lemma sum_case_split_asm: "P (sum_case f g a) \ \ ((\x. a = Inl x \ \ P(f x)) \ (\y. a = Inr y \ \ P(g y)) \ (\ is_sum a \ \ P undefined))" by (auto simp: sum_case_split) subsubsection \Applications of disjoint sums and pairs: general union theorems for small sets\ lemma small_Un: assumes X: "small X" and Y: "small Y" shows "small (X \ Y)" proof - obtain f g :: "'a\V" where f: "inj_on f X" and g: "inj_on g Y" by (meson assms small_def) define h where "h \ \z. if z \ X then Inl (f z) else Inr (g z)" show ?thesis unfolding small_def proof (intro exI conjI) show "inj_on h (X \ Y)" using f g by (auto simp add: inj_on_def h_def) show "h ` (X \ Y) \ range elts" by (metis X Y image_Un replacement small_iff_range small_sup_iff) qed qed lemma small_UN [simp,intro]: assumes X: "small X" and B: "\x. x \ X \ small (B x)" shows "small (\x\X. B x)" proof - obtain f :: "'a\V" where f: "inj_on f X" by (meson assms small_def) have "\g. inj_on g (B x) \ g ` (B x) \ range elts" if "x \ X" for x using B small_def that by auto then obtain g::"'a \ 'b \ V" where g: "\x. x \ X \ inj_on (g x) (B x)" by metis define \ where "\ \ \y. @x. x \ X \ y \ B x" have \: "\ y \ X \ y \ B (\ y)" if "y \ (\x\X. B x)" for y unfolding \_def by (metis (mono_tags, lifting) UN_E someI that) define h where "h \ \y. \f (\ y), g (\ y) y\" show ?thesis unfolding small_def proof (intro exI conjI) show "inj_on h (\ (B ` X))" using f g \ unfolding h_def inj_on_def by (metis vpair_inject) have "small (h ` \ (B ` X))" by (simp add: B X image_UN) then show "h ` \ (B ` X) \ range elts" using small_iff_range by blast qed qed lemma small_Union [simp,intro]: assumes "\ \ Collect small" "small \" shows "small (\ \)" using small_UN [of \ "\x. x"] assms by (simp add: subset_iff) subsection\Generalised function space and lambda\ definition VLambda :: "V \ (V \ V) \ V" where "VLambda A b \ set ((\x. \x,b x\) ` elts A)" definition app :: "[V,V] \ V" where "app f x \ THE y. \x,y\ \ elts f" lemma beta [simp]: assumes "x \ elts A" shows "app (VLambda A b) x = b x" using assms by (auto simp: VLambda_def app_def) definition VPi :: "V \ (V \ V) \ V" where "VPi A B \ set {f \ elts (VPow(VSigma A B)). elts A \ Domain (pairs f) \ single_valued (pairs f)}" lemma VPi_I: assumes "\x. x \ elts A \ b x \ elts (B x)" shows "VLambda A b \ elts (VPi A B)" proof (clarsimp simp: VPi_def, intro conjI impI) show "VLambda A b \ VSigma A B" by (auto simp: assms VLambda_def split: if_split_asm) show "elts A \ Domain (pairs (VLambda A b))" by (force simp: VLambda_def pairs_iff_elts) show "single_valued (pairs (VLambda A b))" by (auto simp: VLambda_def single_valued_def pairs_iff_elts) show "small {f. f \ VSigma A B \ elts A \ Domain (pairs f) \ single_valued (pairs f)}" by (metis (mono_tags, lifting) down VPow_iff mem_Collect_eq subsetI) qed lemma apply_pair: assumes f: "f \ elts (VPi A B)" and x: "x \ elts A" shows "\x, app f x\ \ elts f" proof - have "x \ Domain (pairs f)" by (metis (no_types, lifting) VPi_def assms elts_of_set empty_iff mem_Collect_eq subsetD) then obtain y where y: "\x,y\ \ elts f" using pairs_iff_elts by auto show ?thesis unfolding app_def proof (rule theI) show "\x, y\ \ elts f" by (rule y) show "z = y" if "\x, z\ \ elts f" for z using f unfolding VPi_def by (metis (mono_tags, lifting) that elts_of_set empty_iff mem_Collect_eq pairs_iff_elts single_valued_def y) qed qed lemma VPi_D: assumes f: "f \ elts (VPi A B)" and x: "x \ elts A" shows "app f x \ elts (B x)" proof - have "f \ VSigma A B" by (metis (no_types, lifting) VPi_def elts_of_set empty_iff f VPow_iff mem_Collect_eq) then show ?thesis using apply_pair [OF assms] by blast qed lemma VPi_memberD: assumes f: "f \ elts (VPi A B)" and p: "p \ elts f" obtains x where "x \ elts A" "p = \x, app f x\" proof - have "f \ VSigma A B" by (metis (no_types, lifting) VPi_def elts_of_set empty_iff f VPow_iff mem_Collect_eq) then obtain x y where "p = \x,y\" "x \ elts A" using p by blast then have "y = app f x" by (metis (no_types, lifting) VPi_def apply_pair elts_of_set equals0D f mem_Collect_eq p pairs_iff_elts single_valuedD) then show thesis using \p = \x, y\\ \x \ elts A\ that by blast qed lemma fun_ext: assumes "f \ elts (VPi A B)" "g \ elts (VPi A B)" "\x. x \ elts A \ app f x = app g x" shows "f = g" by (metis VPi_memberD V_equalityI apply_pair assms) lemma eta[simp]: assumes "f \ elts (VPi A B)" shows "VLambda A ((app)f) = f" proof (rule fun_ext [OF _ assms]) show "VLambda A (app f) \ elts (VPi A B)" using VPi_D VPi_I assms by auto qed auto lemma fst_pairs_VLambda: "fst ` pairs (VLambda A f) = elts A" by (force simp: VLambda_def pairs_def) lemma snd_pairs_VLambda: "snd ` pairs (VLambda A f) = f ` elts A" by (force simp: VLambda_def pairs_def) lemma VLambda_eq_D1: "VLambda A f = VLambda B g \ A = B" by (metis ZFC_in_HOL.ext fst_pairs_VLambda) lemma VLambda_eq_D2: "\VLambda A f = VLambda A g; x \ elts A\ \ f x = g x" by (metis beta) subsection\Transitive closure of a set\ definition TC :: "V\V" where "TC \ transrec (\f x. x \ \ (f ` elts x))" lemma TC: "TC a = a \ \ (TC ` elts a)" by (metis (no_types, lifting) SUP_cong TC_def restrict_apply' transrec) lemma TC_0 [simp]: "TC 0 = 0" by (metis TC ZFC_in_HOL.Sup_empty elts_0 image_is_empty sup_V_0_left) lemma arg_subset_TC: "a \ TC a" by (metis (no_types) TC sup_ge1) lemma Transset_TC: "Transset(TC a)" proof (induction a rule: eps_induct) case (step x) have 1: "v \ elts (TC x)" if "v \ elts u" "u \ elts x" for u v using that unfolding TC [of x] using arg_subset_TC by fastforce have 2: "v \ elts (TC x)" if "v \ elts u" "\x\elts x. u \ elts (TC x)" for u v using that step unfolding TC [of x] Transset_def by auto show ?case unfolding Transset_def by (subst TC) (force intro: 1 2) qed lemma TC_least: "\Transset x; a\x\ \ TC a \ x" proof (induction a rule: eps_induct) case (step y) show ?case proof (cases "y=0") case True then show ?thesis by auto next case False have "\ (TC ` elts y) \ x" proof (rule cSup_least) show "TC ` elts y \ {}" using False by auto show "z \ x" if "z \ TC ` elts y" for z using that by (metis Transset_def image_iff step.IH step.prems vsubsetD) qed then show ?thesis by (simp add: step TC [of y]) qed qed definition less_TC (infix "\" 50) where "x \ y \ x \ elts (TC y)" definition le_TC (infix "\" 50) where "x \ y \ x \ y \ x=y" lemma less_TC_imp_not_le: "x \ a \ \ a \ x" proof (induction a arbitrary: x rule: eps_induct) case (step a) then show ?case unfolding TC[of a] less_TC_def using Transset_TC Transset_def by force qed lemma non_TC_less_0 [iff]: "\ (x \ 0)" using less_TC_imp_not_le by blast lemma less_TC_iff: "x \ y \ (\z \ elts y. x \ z)" by (auto simp: less_TC_def le_TC_def TC [of y]) lemma nonzero_less_TC: "x \ 0 \ 0 \ x" by (metis eps_induct le_TC_def less_TC_iff trad_foundation) lemma less_irrefl_TC [simp]: "\ x \ x" using less_TC_imp_not_le by blast lemma less_asym_TC: "\x \ y; y \ x\ \ False" by (metis TC_least Transset_TC Transset_def antisym_conv less_TC_def less_TC_imp_not_le order_refl) lemma le_antisym_TC: "\x \ y; y \ x\ \ x = y" using less_asym_TC by blast lemma less_imp_le_TC [iff]: "x \ y \ x \ y" by (simp add: le_TC_def) lemma le_TC_refl [iff]: "x \ x" by (simp add: le_TC_def) lemma less_TC_trans [trans]: "\x \ y; y \ z\ \ x \ z" by (meson TC_least Transset_TC Transset_def less_TC_def less_eq_V_def subsetD) lemma less_le_TC_trans [trans]: "\x \ y; y \ z\ \ x \ z" using le_TC_def less_TC_trans by blast lemma le_less_TC_trans [trans]: "\x \ y; y \ z\ \ x \ z" using le_TC_def less_TC_trans by blast lemma le_TC_trans [trans]: "\x \ y; y \ z\ \ x \ z" using le_TC_def le_less_TC_trans by blast lemma TC_sup_distrib: "TC (x \ y) = TC x \ TC y" by (simp add: Sup_Un_distrib TC [of "x \ y"] TC [of x] TC [of y] image_Un sup.assoc sup_left_commute) lemma TC_Sup_distrib: assumes "small X" shows "TC (\X) = \(TC ` X)" proof - have "\ X \ \ (\x\X. TC ` elts x) \ \ (TC ` X)" using assms apply (auto simp: Sup_le_iff) using arg_subset_TC apply blast by (metis TC_least Transset_TC Transset_def arg_subset_TC vsubsetD) moreover have "\ (TC ` X) \ \ X \ \ (\x\X. TC ` elts x)" proof (clarsimp simp add: Sup_le_iff assms) show "\x\X. y \ elts x" if "x \ X" "y \ elts (TC x)" "\x\X. \u\elts x. y \ elts (TC u)" for x y using that by (auto simp: TC [of x]) qed ultimately show ?thesis using Sup_Un_distrib TC [of "\X"] image_Union assms by (simp add: image_Union inf_sup_aci(5) sup.absorb_iff2) qed lemma TC': "TC x = x \ TC (\ (elts x))" by (simp add: TC [of x] TC_Sup_distrib) lemma TC_eq_0_iff [simp]: "TC x = 0 \ x=0" using arg_subset_TC by fastforce text\A distinctive induction principle\ lemma TC_induct_down_lemma: assumes ab: "a \ b" and base: "b \ d" and step: "\y z. \y \ b; y \ elts d; z \ elts y\ \ z \ elts d" shows "a \ elts d" proof - have "Transset (TC b \ d)" using Transset_TC unfolding Transset_def by (metis inf.bounded_iff less_TC_def less_eq_V_def local.step subsetI vsubsetD) moreover have "b \ TC b \ d" by (simp add: arg_subset_TC base) ultimately show ?thesis using TC_least [THEN vsubsetD] ab unfolding less_TC_def by (meson TC_least le_inf_iff vsubsetD) qed lemma TC_induct_down [consumes 1, case_names base step small]: assumes "a \ b" and "\y. y \ elts b \ P y" and "\y z. \y \ b; P y; z \ elts y\ \ P z" and "small (Collect P)" shows "P a" using TC_induct_down_lemma [of a b "set (Collect P)"] assms by (metis elts_of_set mem_Collect_eq vsubsetI) subsection\Rank of a set\ definition rank :: "V\V" where "rank a \ transrec (\f x. set (\y\elts x. elts (succ(f y)))) a" lemma rank: "rank a = set(\y \ elts a. elts (succ(rank y)))" by (subst rank_def [THEN def_transrec], simp) lemma rank_Sup: "rank a = \((\y. succ(rank y)) ` elts a)" by (metis elts_Sup image_image rank replacement set_of_elts small_elts) lemma Ord_rank [simp]: "Ord(rank a)" proof (induction a rule: eps_induct) case (step x) then show ?case unfolding rank_Sup [of x] by (metis (mono_tags, lifting) Ord_Sup Ord_succ imageE) qed lemma rank_of_Ord: "Ord i \ rank i = i" apply (induction rule: Ord_induct) by (metis (no_types, lifting) Ord_equality SUP_cong rank_Sup) lemma Ord_iff_rank: "Ord x \ rank x = x" using Ord_rank [of x] rank_of_Ord by fastforce lemma rank_lt: "a \ elts b \ rank a < rank b" apply (subst rank [of b]) by (metis (no_types, lifting) Ord_mem_iff_lt Ord_rank small_UN UN_iff elts_of_set elts_succ insert_iff rank small_elts) lemma rank_0 [simp]: "rank 0 = 0" unfolding rank_def using transrec by fastforce lemma rank_succ [simp]: "rank(succ x) = succ(rank x)" proof (rule order_antisym) show "rank (succ x) \ succ (rank x)" apply (subst rank [of "succ x"]) apply (metis (no_types, lifting) Sup_insert elts_of_set elts_succ equals0D image_insert rank small_sup_iff subset_insertI sup.orderE vsubsetI) done show "succ (rank x) \ rank (succ x)" by (metis (mono_tags, lifting) ZFC_in_HOL.Sup_upper elts_succ image_insert insertI1 rank_Sup replacement small_elts) qed lemma rank_mono: "a \ b \ rank a \ rank b" apply (rule vsubsetI) using rank [of a] rank [of b] small_UN by auto lemma VsetI: "rank b \ i \ b \ elts (Vset i)" proof (induction i arbitrary: b rule: eps_induct) case (step x) then consider "rank b \ elts x" | "(\y\elts x. rank b \ elts (TC y))" using le_TC_def less_TC_def less_TC_iff by fastforce then have "\y\elts x. b \ Vset y" proof cases case 1 then have "b \ Vset (rank b)" unfolding less_eq_V_def subset_iff by (meson Ord_mem_iff_lt Ord_rank le_TC_refl less_TC_iff rank_lt step.IH) then show ?thesis using "1" by blast next case 2 then show ?thesis using step.IH unfolding less_eq_V_def subset_iff less_TC_def by (meson Ord_mem_iff_lt Ord_rank Transset_TC Transset_def rank_lt vsubsetD) qed then show ?case by (simp add: Vset [of x]) qed lemma Ord_VsetI: "\Ord i; rank b < i\ \ b \ elts (Vset i)" by (meson Ord_mem_iff_lt Ord_rank VsetI arg_subset_TC less_TC_def vsubsetD) lemma arg_le_Vset_rank: "a \ Vset(rank a)" by (simp add: Ord_VsetI rank_lt vsubsetI) lemma two_in_Vset: obtains \ where "x \ elts (Vset \)" "y \ elts (Vset \)" by (metis Ord_rank Ord_VsetI elts_of_set insert_iff rank_lt small_elts small_insert_iff) lemma rank_eq_0_iff [simp]: "rank x = 0 \ x=0" using arg_le_Vset_rank by fastforce lemma small_ranks_imp_small: assumes "small (rank ` A)" shows "small A" proof - define i where "i \ set (\(elts ` (rank ` A)))" have "Ord i" unfolding i_def using Ord_Union Ord_rank assms imageE by blast have *: "Vset (rank x) \ (Vset i)" if "x \ A" for x unfolding i_def by (metis Ord_rank Sup_V_def ZFC_in_HOL.Sup_upper Vfrom_mono assms imageI le_less that) have "A \ elts (VPow (Vset i))" by (meson "*" VPow_iff arg_le_Vset_rank order.trans subsetI) then show ?thesis using down by blast qed lemma rank_Union: "rank(\ A) = \ (rank ` A)" proof (rule order_antisym) have "elts (SUP y\elts (\ A). succ (rank y)) \ elts (\ (rank ` A))" apply auto(*SLOW*) using Ord_mem_iff_lt Ord_rank rank_lt apply blast by (meson less_le_not_le rank_lt vsubsetD) then show "rank (\ A) \ \ (rank ` A)" by (metis less_eq_V_def rank_Sup) show "\ (rank ` A) \ rank (\ A)" proof (cases "small A") case True then show ?thesis by (metis (mono_tags, lifting) ZFC_in_HOL.Sup_least ZFC_in_HOL.Sup_upper image_iff rank_mono) next case False then have "\ small (rank ` A)" using small_ranks_imp_small by blast then show ?thesis by blast qed qed lemma small_bounded_rank: "small {x. rank x \ elts a}" proof - have "{x. rank x \ elts a} \ {x. rank x \ a}" using less_TC_iff by auto also have "\ \ elts (Vset a)" using VsetI by blast finally show ?thesis using down by simp qed lemma small_bounded_rank_le: "small {x. rank x \ a}" using small_bounded_rank [of "VPow a"] VPow_iff [of _ a] by simp lemma TC_rank_lt: "a \ b \ rank a < rank b" proof (induction rule: TC_induct_down) case (base y) then show ?case by (simp add: rank_lt) next case (step y z) then show ?case using less_trans rank_lt by blast next case small show ?case apply (rule smaller_than_small [OF small_bounded_rank_le [of "rank b"]]) by (simp add: Collect_mono less_V_def) qed lemma TC_rank_mem: "x \ y \ rank x \ elts (rank y)" by (simp add: Ord_mem_iff_lt TC_rank_lt) lemma wf_TC_less: "wf {(x,y). x \ y}" proof (rule wf_subset [OF wf_inv_image [OF foundation, of rank]]) show "{(x, y). x \ y} \ inv_image {(x, y). x \ elts y} rank" by (auto simp: TC_rank_mem inv_image_def) qed lemma less_TC_minimal: assumes "P a" obtains x where "P x" "x \ a" "\y. y \ x \ \ P y" using wfE_min' [OF wf_TC_less, of "{x. P x \ x \ a}"] by simp (metis le_TC_def less_le_TC_trans assms) lemma Vfrom_rank_eq: "Vfrom A (rank(x)) = Vfrom A x" proof (rule order_antisym) show "Vfrom A (rank x) \ Vfrom A x" proof (induction x rule: eps_induct) case (step x) have "(SUP j\elts (rank x). VPow (Vfrom A j)) \ (SUP j\elts x. VPow (Vfrom A j))" apply (rule Sup_least, clarify) apply (simp add: rank [of x]) using step.IH by (metis Ord_rank OrdmemD Vfrom_mono2 dual_order.trans inf_sup_aci(5) less_V_def sup.orderE) then show ?case by (simp add: Vfrom [of _ x] Vfrom [of _ "rank(x)"] sup.coboundedI2) qed show "Vfrom A x \ Vfrom A (rank x)" proof (induction x rule: eps_induct) case (step x) have "(SUP j\elts x. VPow (Vfrom A j)) \ (SUP j\elts (rank x). VPow (Vfrom A j))" using step.IH TC_rank_mem less_TC_iff by force then show ?case by (simp add: Vfrom [of _ x] Vfrom [of _ "rank(x)"] sup.coboundedI2) qed qed lemma Vfrom_succ: "Vfrom A (succ(i)) = A \ VPow(Vfrom A i)" by (metis Ord_rank Vfrom_rank_eq Vfrom_succ_Ord rank_succ) lemma Vset_succ_TC: assumes "x \ elts (Vset (ZFC_in_HOL.succ k))" "u \ x" shows "u \ elts (Vset k)" using assms apply (simp add: Vfrom_succ) using TC_least Transset_Vfrom less_TC_def by auto subsection\Cardinal Numbers\ text\We extend the membership relation to a wellordering\ definition VWO :: "(V \ V) set" where "VWO \ @r. {(x,y). x \ elts y} \ r \ Well_order r \ Field r = UNIV" lemma VWO: "{(x,y). x \ elts y} \ VWO \ Well_order VWO \ Field VWO = UNIV" unfolding VWO_def by (metis (mono_tags, lifting) VWO_def foundation someI_ex total_well_order_extension) lemma wf_VWO: "wf(VWO - Id)" using VWO well_order_on_def by blast lemma wf_Ord_less: "wf {(x, y). Ord y \ x < y}" by (metis (no_types, lifting) Ord_mem_iff_lt eps_induct wfPUNIVI wfP_def) lemma refl_VWO: "refl VWO" using VWO order_on_defs by fastforce lemma trans_VWO: "trans VWO" using VWO by (simp add: VWO wo_rel.TRANS wo_rel_def) lemma antisym_VWO: "antisym VWO" using VWO by (simp add: VWO wo_rel.ANTISYM wo_rel_def) lemma total_VWO: "total VWO" using VWO by (metis wo_rel.TOTAL wo_rel.intro) lemma total_VWOId: "total (VWO-Id)" by (simp add: total_VWO) lemma Linear_order_VWO: "Linear_order VWO" using VWO well_order_on_def by blast lemma wo_rel_VWO: "wo_rel VWO" using VWO wo_rel_def by blast subsubsection \Transitive Closure and VWO\ lemma mem_imp_VWO: "x \ elts y \ (x,y) \ VWO" using VWO by blast lemma less_TC_imp_VWO: "x \ y \ (x,y) \ VWO" unfolding less_TC_def proof (induction y arbitrary: x rule: eps_induct) case (step y' u) then consider "u \ elts y'" | v where "v \ elts y'" "u \ elts (TC v)" by (auto simp: TC [of y']) then show ?case proof cases case 2 then show ?thesis by (meson mem_imp_VWO step.IH transD trans_VWO) qed (use mem_imp_VWO in blast) qed lemma le_TC_imp_VWO: "x \ y \ (x,y) \ VWO" apply (auto simp: le_TC_def less_TC_imp_VWO) by (metis Diff_iff Linear_order_VWO Linear_order_in_diff_Id UNIV_I VWO) lemma le_TC_0_iff [simp]: "x \ 0 \ x = 0" by (simp add: le_TC_def) lemma less_TC_succ: " x \ succ \ \ x \ \ \ x = \" by (metis elts_succ insert_iff le_TC_def less_TC_iff) lemma le_TC_succ: "x \ succ \ \ x \ \ \ x = succ \" by (simp add: le_TC_def less_TC_succ) lemma Transset_TC_eq [simp]: "Transset x \ TC x = x" by (simp add: TC_least arg_subset_TC eq_iff) lemma Ord_TC_less_iff: "\Ord \; Ord \\ \ \ \ \ \ \ < \" by (metis Ord_def Ord_mem_iff_lt Transset_TC_eq less_TC_def) lemma Ord_mem_iff_less_TC: "Ord l \ k \ elts l \ k \ l" by (simp add: Ord_def less_TC_def) lemma le_TC_Ord: "\\ \ \; Ord \\ \ Ord \" by (metis Ord_def Ord_in_Ord Transset_TC_eq le_TC_def less_TC_def) lemma Ord_less_TC_mem: assumes "Ord \" "\ \ \" shows "\ \ elts \" using Ord_def assms less_TC_def by auto lemma VWO_TC_le: "\Ord \; Ord \; (\, \) \ VWO\ \ \ \ \" proof (induct \ arbitrary: \ rule: Ord_induct) case (step \) then show ?case by (metis Diff_iff Linear_order_VWO Linear_order_in_diff_Id Ord_TC_less_iff Ord_linear2 UNIV_I VWO le_TC_def le_less less_TC_imp_VWO pair_in_Id_conv) qed lemma VWO_iff_Ord_le [simp]: "\Ord \; Ord \\ \ (\, \) \ VWO \ \ \ \" by (metis VWO_TC_le Ord_TC_less_iff le_TC_def le_TC_imp_VWO le_less) lemma zero_TC_le [iff]: "0 \ y" using le_TC_def nonzero_less_TC by auto lemma succ_le_TC_iff: "Ord j \ succ i \ j \ i \ j" by (metis Ord_in_Ord Ord_linear Ord_mem_iff_less_TC Ord_succ le_TC_def less_TC_succ less_asym_TC) lemma VWO_0_iff [simp]: "(x,0) \ VWO \ x=0" proof show "x = 0" if "(x, 0) \ VWO" using zero_TC_le [of x] le_TC_imp_VWO that by (metis DiffI Linear_order_VWO Linear_order_in_diff_Id UNIV_I VWO pair_in_Id_conv) qed auto lemma VWO_antisym: assumes "(x,y) \ VWO" "(y,x) \ VWO" shows "x=y" by (metis Diff_iff IdD Linear_order_VWO Linear_order_in_diff_Id UNIV_I VWO assms) subsubsection \Relation VWF\ definition VWF where "VWF \ VWO - Id" lemma wf_VWF [iff]: "wf VWF" by (simp add: VWF_def wf_VWO) lemma trans_VWF [iff]: "trans VWF" by (simp add: VWF_def antisym_VWO trans_VWO trans_diff_Id) lemma asym_VWF [iff]: "asym VWF" by (metis VWF_def asym.intros irrefl_diff_Id wf_VWF wf_not_sym) lemma total_VWF [iff]: "total VWF" using VWF_def total_VWOId by auto lemma total_on_VWF [iff]: "total_on A VWF" by (meson UNIV_I total_VWF total_on_def) lemma VWF_asym: assumes "(x,y) \ VWF" "(y,x) \ VWF" shows False using VWF_def assms wf_VWO wf_not_sym by fastforce lemma VWF_non_refl [iff]: "(x,x) \ VWF" by simp lemma VWF_iff_Ord_less [simp]: "\Ord \; Ord \\ \ (\,\) \ VWF \ \ < \" by (simp add: VWF_def less_V_def) lemma mem_imp_VWF: "x \ elts y \ (x,y) \ VWF" using VWF_def mem_imp_VWO by fastforce subsection\Order types\ definition ordermap :: "'a set \ ('a \ 'a) set \ 'a \ V" where "ordermap A r \ wfrec r (\f x. set (f ` {y \ A. (y,x) \ r}))" definition ordertype :: "'a set \ ('a \ 'a) set \ V" where "ordertype A r \ set (ordermap A r ` A)" lemma ordermap_type: "small A \ ordermap A r \ A \ elts (ordertype A r)" by (simp add: ordertype_def) lemma ordermap_in_ordertype [intro]: "\a \ A; small A\ \ ordermap A r a \ elts (ordertype A r)" by (simp add: ordertype_def) lemma ordermap: "wf r \ ordermap A r a = set (ordermap A r ` {y \ A. (y,a) \ r})" unfolding ordermap_def by (auto simp: wfrec_fixpoint adm_wf_def) lemma wf_Ord_ordermap [iff]: assumes "wf r" "trans r" shows "Ord (ordermap A r x)" using \wf r\ proof (induction x rule: wf_induct_rule) case (less u) have "Transset (set (ordermap A r ` {y \ A. (y, u) \ r}))" proof (clarsimp simp add: Transset_def) show "x \ ordermap A r ` {y \ A. (y, u) \ r}" if "small (ordermap A r ` {y \ A. (y, u) \ r})" and x: "x \ elts (ordermap A r y)" and "y \ A" "(y, u) \ r" for x y proof - have "ordermap A r y = ZFC_in_HOL.set (ordermap A r ` {a \ A. (a, y) \ r})" using ordermap assms(1) by force then have "x \ ordermap A r ` {z \ A. (z, y) \ r}" by (metis (no_types, lifting) elts_of_set empty_iff x) then have "\v. v \ A \ (v, u) \ r \ x = ordermap A r v" using that transD [OF \trans r\] by blast then show ?thesis by blast qed qed moreover have "Ord x" if "x \ elts (set (ordermap A r ` {y \ A. (y, u) \ r}))" for x using that less by (auto simp: split: if_split_asm) ultimately show ?case by (metis (full_types) Ord_def ordermap assms(1)) qed lemma wf_Ord_ordertype: assumes "wf r" "trans r" shows "Ord(ordertype A r)" proof - have "y \ set (ordermap A r ` A)" if "y = ordermap A r x" "x \ A" "small (ordermap A r ` A)" for x y using that by (auto simp: less_eq_V_def ordermap [OF \wf r\, of A x]) moreover have "z \ y" if "y \ ordermap A r ` A" "z \ elts y" for y z by (metis wf_Ord_ordermap OrdmemD assms imageE order.strict_implies_order that) ultimately show ?thesis unfolding ordertype_def Ord_def Transset_def by simp qed lemma Ord_ordertype [simp]: "Ord(ordertype A VWF)" using wf_Ord_ordertype by blast lemma Ord_ordermap [simp]: "Ord (ordermap A VWF x)" by blast lemma ordertype_singleton [simp]: assumes "wf r" shows "ordertype {x} r = 1" proof - have \: "{y. y = x \ (y, x) \ r} = {}" using assms by auto show ?thesis by (auto simp add: ordertype_def assms \ ordermap [where a=x]) qed subsubsection\@{term ordermap} preserves the orderings in both directions\ lemma ordermap_mono: assumes wx: "(w, x) \ r" and "wf r" "w \ A" "small A" shows "ordermap A r w \ elts (ordermap A r x)" proof - have "small {a \ A. (a, x) \ r} \ w \ A \ (w, x) \ r" by (simp add: assms) then show ?thesis using assms ordermap [of r A] by (metis (no_types, lifting) elts_of_set image_eqI mem_Collect_eq replacement) qed lemma converse_ordermap_mono: assumes "ordermap A r y \ elts (ordermap A r x)" "wf r" "total_on A r" "x \ A" "y \ A" "small A" shows "(y, x) \ r" proof (cases "x = y") case True then show ?thesis using assms(1) mem_not_refl by blast next case False then consider "(x,y) \ r" | "(y,x) \ r" using \total_on A r\ assms by (meson UNIV_I total_on_def) then show ?thesis by (meson ordermap_mono assms mem_not_sym) qed +lemma converse_ordermap_mono_iff: + assumes "wf r" "total_on A r" "x \ A" "y \ A" "small A" + shows "ordermap A r y \ elts (ordermap A r x) \ (y, x) \ r" + by (metis assms converse_ordermap_mono ordermap_mono) + lemma ordermap_surj: "elts (ordertype A r) \ ordermap A r ` A" unfolding ordertype_def by simp lemma ordermap_bij: assumes "wf r" "total_on A r" "small A" shows "bij_betw (ordermap A r) A (elts (ordertype A r))" unfolding bij_betw_def proof (intro conjI) show "inj_on (ordermap A r) A" unfolding inj_on_def by (metis assms mem_not_refl ordermap_mono total_on_def) show "ordermap A r ` A = elts (ordertype A r)" by (metis ordertype_def \small A\ elts_of_set replacement) qed lemma ordermap_eq_iff [simp]: "\x \ A; y \ A; wf r; total_on A r; small A\ \ ordermap A r x = ordermap A r y \ x = y" by (metis bij_betw_iff_bijections ordermap_bij) lemma inv_into_ordermap: "\ \ elts (ordertype A r) \ inv_into A (ordermap A r) \ \ A" by (meson in_mono inv_into_into ordermap_surj) lemma ordertype_nat_imp_finite: assumes "ordertype A r = ord_of_nat m" "small A" "wf r" "total_on A r" shows "finite A" proof - have "A \ elts m" using eqpoll_def assms ordermap_bij by fastforce then show ?thesis using eqpoll_finite_iff finite_Ord_omega by blast qed lemma wf_ordertype_eqpoll: assumes "wf r" "total_on A r" "small A" shows "elts (ordertype A r) \ A" using assms eqpoll_def eqpoll_sym ordermap_bij by blast lemma ordertype_eqpoll: assumes "small A" shows "elts (ordertype A VWF) \ A" using assms wf_ordertype_eqpoll total_VWF wf_VWF by (simp add: wf_ordertype_eqpoll total_on_def) subsection \More advanced @{term ordertype} and @{term ordermap} results\ lemma ordermap_VWF_0 [simp]: "ordermap A VWF 0 = 0" by (simp add: ordermap wf_VWO VWF_def) lemma ordertype_empty [simp]: "ordertype {} r = 0" by (simp add: ordertype_def) lemma ordertype_eq_0_iff [simp]: "\small X; wf r\ \ ordertype X r = 0 \ X = {}" by (metis ordertype_def elts_of_set replacement image_is_empty zero_V_def) lemma ordermap_mono_less: assumes "(w, x) \ r" and "wf r" "trans r" and "w \ A" "x \ A" and "small A" shows "ordermap A r w < ordermap A r x" by (simp add: OrdmemD assms ordermap_mono) lemma ordermap_mono_le: assumes "(w, x) \ r \ w=x" and "wf r" "trans r" and "w \ A" "x \ A" and "small A" shows "ordermap A r w \ ordermap A r x" by (metis assms dual_order.strict_implies_order eq_refl ordermap_mono_less) lemma converse_ordermap_le_mono: assumes "ordermap A r y \ ordermap A r x" "wf r" "total r" "x \ A" "small A" shows "(y, x) \ r \ y=x" by (meson UNIV_I assms mem_not_refl ordermap_mono total_on_def vsubsetD) lemma ordertype_mono: assumes "X \ Y" and r: "wf r" "trans r" and "small Y" shows "ordertype X r \ ordertype Y r" proof - have "small X" using assms smaller_than_small by fastforce have *: "ordermap X r x \ ordermap Y r x" for x using \wf r\ proof (induction x rule: wf_induct_rule) case (less x) have "ordermap X r z < ordermap Y r x" if "z \ X" and zx: "(z,x) \ r" for z using less [OF zx] assms by (meson Ord_linear2 OrdmemD wf_Ord_ordermap ordermap_mono in_mono leD that(1) vsubsetD zx) then show ?case by (auto simp add: ordermap [of _ X x] \small X\ Ord_mem_iff_lt set_image_le_iff less_eq_V_def r) qed show ?thesis proof - have "ordermap Y r ` Y = elts (ordertype Y r)" by (metis ordertype_def \small Y\ elts_of_set replacement) then have "ordertype Y r \ ordermap X r ` X" using "*" \X \ Y\ by fastforce then show ?thesis by (metis Ord_linear2 Ord_mem_iff_lt ordertype_def wf_Ord_ordertype \small X\ elts_of_set replacement r) qed qed corollary ordertype_VWF_mono: assumes "X \ Y" "small Y" shows "ordertype X VWF \ ordertype Y VWF" using assms by (simp add: ordertype_mono) lemma ordertype_UNION_ge: assumes "A \ \" "wf r" "trans r" "\ \ Collect small" "small \" shows "ordertype A r \ ordertype (\\) r" by (rule ordertype_mono) (use assms in auto) lemma inv_ordermap_mono_less: assumes "(inv_into M (ordermap M r) \, inv_into M (ordermap M r) \) \ r" and "small M" and \: "\ \ elts (ordertype M r)" and \: "\ \ elts (ordertype M r)" and "wf r" "trans r" shows "\ < \" proof - have "\ = ordermap M r (inv_into M (ordermap M r) \)" by (metis \ f_inv_into_f ordermap_surj subset_eq) also have "\ < ordermap M r (inv_into M (ordermap M r) \)" by (meson \ \ assms in_mono inv_into_into ordermap_mono_less ordermap_surj) also have "\ = \" by (meson \ f_inv_into_f in_mono ordermap_surj) finally show ?thesis . qed lemma inv_ordermap_mono_eq: assumes "inv_into M (ordermap M r) \ = inv_into M (ordermap M r) \" and "\ \ elts (ordertype M r)" "\ \ elts (ordertype M r)" shows "\ = \" by (metis assms f_inv_into_f ordermap_surj subsetD) lemma inv_ordermap_VWF_mono_le: assumes "inv_into M (ordermap M VWF) \ \ inv_into M (ordermap M VWF) \" and "M \ ON" "small M" and \: "\ \ elts (ordertype M VWF)" and \: "\ \ elts (ordertype M VWF)" shows "\ \ \" proof - have "\ = ordermap M VWF (inv_into M (ordermap M VWF) \)" by (metis \ f_inv_into_f ordermap_surj subset_eq) also have "\ \ ordermap M VWF (inv_into M (ordermap M VWF) \)" by (metis ON_imp_Ord VWF_iff_Ord_less assms dual_order.strict_implies_order elts_of_set eq_refl inv_into_into order.not_eq_order_implies_strict ordermap_mono_less ordertype_def replacement trans_VWF wf_VWF) also have "\ = \" by (meson \ f_inv_into_f in_mono ordermap_surj) finally show ?thesis . qed +lemma inv_ordermap_VWF_mono_iff: + assumes "M \ ON" "small M" and "\ \ elts (ordertype M VWF)" and "\ \ elts (ordertype M VWF)" + shows "inv_into M (ordermap M VWF) \ \ inv_into M (ordermap M VWF) \ \ \ \ \" + by (metis ON_imp_Ord Ord_linear_le assms dual_order.eq_iff inv_into_ordermap inv_ordermap_VWF_mono_le) + +lemma inv_ordermap_VWF_strict_mono_iff: + assumes "M \ ON" "small M" and "\ \ elts (ordertype M VWF)" and "\ \ elts (ordertype M VWF)" + shows "inv_into M (ordermap M VWF) \ < inv_into M (ordermap M VWF) \ \ \ < \" + by (simp add: assms inv_ordermap_VWF_mono_iff less_le_not_le) + lemma strict_mono_on_ordertype: assumes "M \ ON" "small M" obtains f where "f \ elts (ordertype M VWF) \ M" "strict_mono_on f (elts (ordertype M VWF))" proof show "inv_into M (ordermap M VWF) \ elts (ordertype M VWF) \ M" by (meson Pi_I' in_mono inv_into_into ordermap_surj) show "strict_mono_on (inv_into M (ordermap M VWF)) (elts (ordertype M VWF))" proof (clarsimp simp: strict_mono_on_def) fix x y assume "x \ elts (ordertype M VWF)" "y \ elts (ordertype M VWF)" "x < y" then show "inv_into M (ordermap M VWF) x < inv_into M (ordermap M VWF) y" using assms by (meson ON_imp_Ord Ord_linear2 inv_into_into inv_ordermap_VWF_mono_le leD ordermap_surj subsetD) qed qed lemma ordermap_inc_eq: assumes "x \ A" "small A" and \: "\x y. \x\A; y\A; (x,y) \ r\ \ (\ x, \ y) \ s" and r: "wf r" "total_on A r" and "wf s" shows "ordermap (\ ` A) s (\ x) = ordermap A r x" using \wf r\ \x \ A\ proof (induction x rule: wf_induct_rule) case (less x) then have 1: "{y \ A. (y, x) \ r} = A \ {y. (y, x) \ r}" using r by auto have 2: "{y \ \ ` A. (y, \ x) \ s} = \ ` A \ {y. (y, \ x) \ s}" by auto have inv\: "\x y. \x\A; y\A; (\ x, \ y) \ s\ \ (x, y) \ r" by (metis \ \wf s\ \total_on A r\ total_on_def wf_not_sym) have eq: "f ` (\ ` A \ {y. (y, \ x) \ s}) = (f \ \) ` (A \ {y. (y, x) \ r})" for f :: "'b \ V" using less by (auto simp: image_subset_iff inv\ \) show ?case using less by (simp add: ordermap [OF \wf r\, of _ x] ordermap [OF \wf s\, of _ "\ x"] 1 2 eq) qed lemma ordertype_inc_eq: assumes "small A" and \: "\x y. \x\A; y\A; (x,y) \ r\ \ (\ x, \ y) \ s" and r: "wf r" "total_on A r" and "wf s" shows "ordertype (\ ` A) s = ordertype A r" proof - have "ordermap (\ ` A) s (\ x) = ordermap A r x" if "x \ A" for x using assms that by (auto simp: ordermap_inc_eq) then show ?thesis unfolding ordertype_def by (metis (no_types, lifting) image_cong image_image) qed lemma ordertype_inc_le: assumes "small A" "small B" and \: "\x y. \x\A; y\A; (x,y) \ r\ \ (\ x, \ y) \ s" and r: "wf r" "total_on A r" and "wf s" "trans s" and "\ ` A \ B" shows "ordertype A r \ ordertype B s" by (metis assms ordertype_inc_eq ordertype_mono) corollary ordertype_VWF_inc_eq: assumes "A \ ON" "\ ` A \ ON" "small A" and "\x y. \x\A; y\A; x \ \ x < \ y" shows "ordertype (\ ` A) VWF = ordertype A VWF" proof (rule ordertype_inc_eq) show "(\ x, \ y) \ VWF" if "x \ A" "y \ A" "(x, y) \ VWF" for x y using that ON_imp_Ord assms by auto show "total_on A VWF" by (meson UNIV_I total_VWF total_on_def) qed (use assms in auto) lemma ordertype_image_ordermap: assumes "small A" "X \ A" "wf r" "trans r" "total_on X r" shows "ordertype (ordermap A r ` X) VWF = ordertype X r" proof (rule ordertype_inc_eq) show "small X" by (meson assms smaller_than_small) show "(ordermap A r x, ordermap A r y) \ VWF" if "x \ X" "y \ X" "(x, y) \ r" for x y by (meson that wf_Ord_ordermap VWF_iff_Ord_less assms ordermap_mono_less subsetD) qed (use assms in auto) lemma ordertype_map_image: assumes "B \ A" "small A" shows "ordertype (ordermap A VWF ` A - ordermap A VWF ` B) VWF = ordertype (A - B) VWF" proof - have "ordermap A VWF ` A - ordermap A VWF ` B = ordermap A VWF ` (A - B)" using assms by auto then have "ordertype (ordermap A VWF ` A - ordermap A VWF ` B) VWF = ordertype (ordermap A VWF ` (A - B)) VWF" by simp also have "\ = ordertype (A - B) VWF" using \small A\ ordertype_image_ordermap by fastforce finally show ?thesis . qed proposition ordertype_le_ordertype: assumes r: "wf r" "total_on A r" and "small A" assumes s: "wf s" "total_on B s" "trans s" and "small B" shows "ordertype A r \ ordertype B s \ (\f \ A \ B. inj_on f A \ (\x \ A. \y \ A. ((x,y) \ r \ (f x, f y) \ s)))" (is "?lhs = ?rhs") proof assume L: ?lhs define f where "f \ inv_into B (ordermap B s) \ ordermap A r" show ?rhs proof (intro bexI conjI ballI impI) have AB: "elts (ordertype A r) \ ordermap B s ` B" by (metis L assms(7) ordertype_def replacement set_of_elts small_elts subset_iff_less_eq_V) have bijA: "bij_betw (ordermap A r) A (elts (ordertype A r))" using ordermap_bij \small A\ r by blast have "inv_into B (ordermap B s) (ordermap A r i) \ B" if "i \ A" for i by (meson L \small A\ inv_into_into ordermap_in_ordertype ordermap_surj subsetD that vsubsetD) then show "f \ A \ B" by (auto simp: Pi_iff f_def) show "inj_on f A" proof (clarsimp simp add: f_def inj_on_def) fix x y assume "x \ A" "y \ A" and "inv_into B (ordermap B s) (ordermap A r x) = inv_into B (ordermap B s) (ordermap A r y)" then have "ordermap A r x = ordermap A r y" by (meson AB \small A\ inv_into_injective ordermap_in_ordertype subsetD) then show "x = y" by (metis \x \ A\ \y \ A\ bijA bij_betw_inv_into_left) qed next fix x y assume "x \ A" "y \ A" and "(x, y) \ r" have \: "ordermap A r y \ ordermap B s ` B" by (meson L \y \ A\ \small A\ in_mono ordermap_in_ordertype ordermap_surj vsubsetD) moreover have \: "\x. inv_into B (ordermap B s) (ordermap A r x) = f x" by (simp add: f_def) then have *: "ordermap B s (f y) = ordermap A r y" using \ by (metis f_inv_into_f) moreover have "ordermap A r x \ ordermap B s ` B" by (meson L \x \ A\ \small A\ in_mono ordermap_in_ordertype ordermap_surj vsubsetD) moreover have "ordermap A r x < ordermap A r y" using * r s by (metis (no_types) wf_Ord_ordermap OrdmemD \(x, y) \ r\ \x \ A\ \small A\ ordermap_mono) ultimately show "(f x, f y) \ s" using \ s by (metis assms(7) f_inv_into_f inv_into_into less_asym ordermap_mono_less total_on_def) qed next assume R: ?rhs then obtain f where f: "f\A \ B" "inj_on f A" "\x\A. \y\A. (x, y) \ r \ (f x, f y) \ s" by blast show ?lhs by (rule ordertype_inc_le [where \=f]) (use f assms in auto) qed lemma iso_imp_ordertype_eq_ordertype: assumes iso: "iso r r' f" and "wf r" and "Total r" and sm: "small (Field r)" shows "ordertype (Field r) r = ordertype (Field r') r'" by (metis (no_types, lifting) iso_forward iso_wf assms iso_Field ordertype_inc_eq sm) lemma ordertype_infinite_ge_\: assumes "infinite A" "small A" shows "ordertype A VWF \ \" proof - have "inj_on (ordermap A VWF) A" by (meson ordermap_bij \small A\ bij_betw_def total_on_VWF wf_VWF) then have "infinite (ordermap A VWF ` A)" using \infinite A\ finite_image_iff by blast then show ?thesis using Ord_ordertype \small A\ infinite_Ord_omega by (auto simp: ordertype_def) qed lemma ordertype_eqI: assumes "wf r" "total_on A r" "small A" "wf s" "bij_betw f A B" "(\x \ A. \y \ A. (f x, f y) \ s \ (x,y) \ r)" shows "ordertype A r = ordertype B s" by (metis assms bij_betw_imp_surj_on ordertype_inc_eq) lemma ordermap_eq_self: assumes "Ord \" and x: "x \ elts \" shows "ordermap (elts \) VWF x = x" using Ord_in_Ord [OF assms] x proof (induction x rule: Ord_induct) case (step x) have 1: "{y \ elts \. (y, x) \ VWF} = elts x" (is "?A = _") proof show "?A \ elts x" using \Ord \\ by clarify (meson Ord_in_Ord Ord_mem_iff_lt VWF_iff_Ord_less step.hyps) show "elts x \ ?A" using \Ord \\ by clarify (meson Ord_in_Ord Ord_trans OrdmemD VWF_iff_Ord_less step.prems) qed show ?case using step by (simp add: ordermap [OF wf_VWF, of _ x] 1 Ord_trans [of _ _ \] step.prems \Ord \\ cong: image_cong) qed lemma ordertype_eq_Ord [simp]: assumes "Ord \" shows "ordertype (elts \) VWF = \" using assms ordermap_eq_self [OF assms] by (simp add: ordertype_def) proposition ordertype_eq_iff: assumes \: "Ord \" and r: "wf r" and "small A" "total_on A r" "trans r" shows "ordertype A r = \ \ (\f. bij_betw f A (elts \) \ (\x \ A. \y \ A. f x < f y \ (x,y) \ r))" (is "?lhs = ?rhs") proof safe assume eq: "\ = ordertype A r" show "\f. bij_betw f A (elts (ordertype A r)) \ (\x\A. \y\A. f x < f y \ ((x, y) \ r))" proof (intro exI conjI ballI) show "bij_betw (ordermap A r) A (elts (ordertype A r))" by (simp add: assms ordermap_bij) then show "ordermap A r x < ordermap A r y \ (x, y) \ r" if "x \ A" "y \ A" for x y using that assms by (metis order.asym ordermap_mono_less total_on_def) qed next fix f assume f: "bij_betw f A (elts \)" "\x\A. \y\A. f x < f y \ (x, y) \ r" have "ordertype A r = ordertype (elts \) VWF" proof (rule ordertype_eqI) show "\x\A. \y\A. ((f x, f y) \ VWF) = ((x, y) \ r)" by (meson Ord_in_Ord VWF_iff_Ord_less \ bij_betwE f) qed (use assms f in auto) then show ?lhs by (simp add: \) qed corollary ordertype_VWF_eq_iff: assumes "Ord \" "small A" shows "ordertype A VWF = \ \ (\f. bij_betw f A (elts \) \ (\x \ A. \y \ A. f x < f y \ (x,y) \ VWF))" by (metis UNIV_I assms ordertype_eq_iff total_VWF total_on_def trans_VWF wf_VWF) lemma ordertype_le_Ord: assumes "Ord \" "X \ elts \" shows "ordertype X VWF \ \" by (metis assms ordertype_VWF_mono ordertype_eq_Ord small_elts) lemma ordertype_inc_le_Ord: assumes "small A" "Ord \" and \: "\x y. \x\A; y\A; (x,y) \ r\ \ \ x < \ y" and "wf r" "total_on A r" and sub: "\ ` A \ elts \" shows "ordertype A r \ \" proof - have "\x y. \x\A; y\A; (x,y) \ r\ \ (\ x, \ y) \ VWF" by (meson Ord_in_Ord VWF_iff_Ord_less \ \Ord \\ sub image_subset_iff) with assms show ?thesis by (metis ordertype_inc_eq ordertype_le_Ord wf_VWF) qed lemma le_ordertype_obtains_subset: assumes \: "\ \ \" "ordertype H VWF = \" and "small H" "Ord \" obtains G where "G \ H" "ordertype G VWF = \" proof (intro exI conjI that) let ?f = "ordermap H VWF" show \: "inv_into H ?f ` elts \ \ H" unfolding image_subset_iff by (metis \ inv_into_into ordermap_surj subsetD vsubsetD) have "\f. bij_betw f (inv_into H ?f ` elts \) (elts \) \ (\x\inv_into H ?f ` elts \. \y\inv_into H ?f ` elts \. (f x < f y) = ((x, y) \ VWF))" proof (intro exI conjI ballI iffI) show "bij_betw ?f (inv_into H ?f ` elts \) (elts \)" using ordermap_bij [OF wf_VWF total_on_VWF \small H\] \ by (metis bij_betw_inv_into_RIGHT bij_betw_subset less_eq_V_def \) next fix x y assume x: "x \ inv_into H ?f ` elts \" and y: "y \ inv_into H ?f ` elts \" show "?f x < ?f y" if "(x,y) \ VWF" using that \ \small H\ in_mono ordermap_mono_less x y by fastforce show "(x,y) \ VWF" if "?f x < ?f y" using that \ \small H\ in_mono ordermap_mono_less [OF _ wf_VWF trans_VWF] x y by (metis UNIV_I less_imp_not_less total_VWF total_on_def) qed then show "ordertype (inv_into H ?f ` elts \) VWF = \" by (subst ordertype_eq_iff) (use assms in auto) qed lemma ordertype_infinite_\: assumes "A \ elts \" "infinite A" shows "ordertype A VWF = \" proof (rule antisym) show "ordertype A VWF \ \" by (simp add: assms ordertype_le_Ord) show "\ \ ordertype A VWF" using assms down ordertype_infinite_ge_\ by auto qed text \For infinite sets of natural numbers\ lemma ordertype_nat_\: assumes "infinite N" shows "ordertype N less_than = \" proof - have "small N" by (meson inj_on_def ord_of_nat_inject small_def small_iff_range small_image_nat_V) have "ordertype (ord_of_nat ` N) VWF = \" by (force simp: assms finite_image_iff inj_on_def intro: ordertype_infinite_\) moreover have "ordertype (ord_of_nat ` N) VWF = ordertype N less_than" by (auto intro: ordertype_inc_eq \small N\) ultimately show ?thesis by simp qed proposition ordertype_eq_ordertype: assumes r: "wf r" "total_on A r" "trans r" and "small A" assumes s: "wf s" "total_on B s" "trans s" and "small B" shows "ordertype A r = ordertype B s \ (\f. bij_betw f A B \ (\x \ A. \y \ A. (f x, f y) \ s \ (x,y) \ r))" (is "?lhs = ?rhs") proof assume L: ?lhs define \ where "\ = ordertype A r" have A: "bij_betw (ordermap A r) A (ordermap A r ` A)" by (meson ordermap_bij assms(4) bij_betw_def r) have B: "bij_betw (ordermap B s) B (ordermap B s ` B)" by (meson ordermap_bij assms(8) bij_betw_def s) define f where "f \ inv_into B (ordermap B s) o ordermap A r" show ?rhs proof (intro exI conjI) have bijA: "bij_betw (ordermap A r) A (elts \)" unfolding \_def using ordermap_bij \small A\ r by blast moreover have bijB: "bij_betw (ordermap B s) B (elts \)" by (simp add: L \_def ordermap_bij \small B\ s) ultimately show bij: "bij_betw f A B" unfolding f_def using bij_betw_comp_iff bij_betw_inv_into by blast have invB: "\\. \ \ elts \ \ ordermap B s (inv_into B (ordermap B s) \) = \" by (meson bijB bij_betw_inv_into_right) have ordermap_A_\: "\a. a \ A \ ordermap A r a \ elts \" using bijA bij_betwE by auto have f_in_B: "\a. a \ A \ f a \ B" using bij bij_betwE by fastforce show "\x\A. \y\A. (f x, f y) \ s \ (x, y) \ r" proof (intro iffI ballI) fix x y assume "x \ A" "y \ A" and ins: "(f x, f y) \ s" then have "ordermap A r x < ordermap A r y" unfolding o_def by (metis (mono_tags, lifting) f_def \small B\ comp_apply f_in_B invB ordermap_A_\ ordermap_mono_less s(1) s(3)) then show "(x, y) \ r" by (metis \x \ A\ \y \ A\ \small A\ order.asym ordermap_mono_less r total_on_def) next fix x y assume "x \ A" "y \ A" and "(x, y) \ r" then have "ordermap A r x < ordermap A r y" by (simp add: \small A\ ordermap_mono_less r) then have "(f y, f x) \ s" by (metis (mono_tags, lifting) \x \ A\ \y \ A\ \small B\ comp_apply f_def f_in_B invB order.asym ordermap_A_\ ordermap_mono_less s(1) s(3)) moreover have "f y \ f x" by (metis \(x, y) \ r\ \x \ A\ \y \ A\ bij bij_betw_inv_into_left r(1) wf_not_sym) ultimately show "(f x, f y) \ s" by (meson \x \ A\ \y \ A\ f_in_B s(2) total_on_def) qed qed next assume ?rhs then show ?lhs using assms ordertype_eqI by blast qed corollary ordertype_eq_ordertype_iso: assumes r: "wf r" "total_on A r" "trans r" and "small A" and FA: "Field r = A" assumes s: "wf s" "total_on B s" "trans s" and "small B" and FB: "Field s = B" shows "ordertype A r = ordertype B s \ (\f. iso r s f)" (is "?lhs = ?rhs") proof assume L: ?lhs then obtain f where "bij_betw f A B" "\x \ A. \y \ A. (f x, f y) \ s \ (x,y) \ r" using assms ordertype_eq_ordertype by blast then show ?rhs using FA FB iso_iff2 by blast next assume ?rhs then show ?lhs using FA FB \small A\ iso_imp_ordertype_eq_ordertype r by blast qed lemma Limit_ordertype_imp_Field_Restr: assumes Lim: "Limit (ordertype A r)" and r: "wf r" "total_on A r" and "small A" shows "Field (Restr r A) = A" proof - have "\y\A. (x,y) \ r" if "x \ A" for x proof - let ?oy = "succ (ordermap A r x)" have \
: "?oy \ elts (ordertype A r)" by (simp add: Lim \small A\ ordermap_in_ordertype succ_in_Limit_iff that) then have A: "inv_into A (ordermap A r) ?oy \ A" by (simp add: inv_into_ordermap) moreover have "(x, inv_into A (ordermap A r) ?oy) \ r" proof - have "ordermap A r x \ elts (ordermap A r (inv_into A (ordermap A r) ?oy))" by (metis "\
" elts_succ f_inv_into_f insert_iff ordermap_surj subsetD) then show ?thesis by (metis \small A\ A converse_ordermap_mono r that) qed ultimately show ?thesis .. qed then have "A \ Field (Restr r A)" by (auto simp: Field_def) then show ?thesis by (simp add: Field_Restr_subset subset_antisym) qed lemma ordertype_Field_Restr: assumes "wf r" "total_on A r" "trans r" "small A" "Field (Restr r A) = A" shows "ordertype (Field (Restr r A)) (Restr r A) = ordertype A r" using assms by (force simp: ordertype_eq_ordertype wf_Restr total_on_def trans_Restr) proposition ordertype_eq_ordertype_iso_Restr: assumes r: "wf r" "total_on A r" "trans r" and "small A" and FA: "Field (Restr r A) = A" assumes s: "wf s" "total_on B s" "trans s" and "small B" and FB: "Field (Restr s B) = B" shows "ordertype A r = ordertype B s \ (\f. iso (Restr r A) (Restr s B) f)" (is "?lhs = ?rhs") proof assume L: ?lhs then obtain f where "bij_betw f A B" "\x \ A. \y \ A. (f x, f y) \ s \ (x,y) \ r" using assms ordertype_eq_ordertype by blast then show ?rhs using FA FB bij_betwE unfolding iso_iff2 by fastforce next assume ?rhs moreover have "ordertype (Field (Restr r A)) (Restr r A) = ordertype A r" using FA \small A\ ordertype_Field_Restr r by blast moreover have "ordertype (Field (Restr s B)) (Restr s B) = ordertype B s" using FB \small B\ ordertype_Field_Restr s by blast ultimately show ?lhs using iso_imp_ordertype_eq_ordertype FA FB \small A\ r by (fastforce intro: total_on_imp_Total_Restr trans_Restr wf_Int1) qed lemma ordermap_insert: assumes "Ord \" and y: "Ord y" "y \ \" and U: "U \ elts \" shows "ordermap (insert \ U) VWF y = ordermap U VWF y" using y proof (induction rule: Ord_induct) case (step y) then have 1: "{u \ U. (u, y) \ VWF} = elts y \ U" apply (simp add: set_eq_iff) by (meson Ord_in_Ord Ord_mem_iff_lt VWF_iff_Ord_less assms subsetD) have 2: "{u \ insert \ U. (u, y) \ VWF} = elts y \ U" apply (simp add: set_eq_iff) by (meson Ord_in_Ord Ord_mem_iff_lt VWF_iff_Ord_less assms leD step.hyps step.prems subsetD) show ?case using step apply (simp only: ordermap [OF wf_VWF, of _ y] 1 2) by (meson Int_lower1 Ord_is_Transset Sup.SUP_cong Transset_def assms(1) in_mono vsubsetD) qed lemma ordertype_insert: assumes "Ord \" and U: "U \ elts \" shows "ordertype (insert \ U) VWF = succ (ordertype U VWF)" proof - have \: "{y \ insert \ U. (y, \) \ VWF} = U" "{y \ U. (y, \) \ VWF} = U" using Ord_in_Ord OrdmemD assms by auto have eq: "\x. x \ U \ ordermap (insert \ U) VWF x = ordermap U VWF x" by (meson Ord_in_Ord Ord_is_Transset Transset_def U assms(1) in_mono ordermap_insert) have "ordertype (insert \ U) VWF = ZFC_in_HOL.set (insert (ordermap U VWF \) (ordermap U VWF ` U))" by (simp add: ordertype_def ordermap_insert assms eq) also have "\ = succ (ZFC_in_HOL.set (ordermap U VWF ` U))" using "\" U by (simp add: ordermap [OF wf_VWF, of _ \] down succ_def vinsert_def) also have "\ = succ (ordertype U VWF)" by (simp add: ordertype_def) finally show ?thesis . qed lemma finite_ordertype_le_card: assumes "finite A" "wf r" "trans r" shows "ordertype A r \ ord_of_nat (card A)" proof - have "Ord (ordertype A r)" by (simp add: wf_Ord_ordertype assms) moreover have "ordermap A r ` A = elts (ordertype A r)" by (simp add: ordertype_def finite_imp_small \finite A\) moreover have "card (ordermap A r ` A) \ card A" using \finite A\ card_image_le by blast ultimately show ?thesis by (metis Ord_linear_le Ord_ord_of_nat \finite A\ card_ord_of_nat card_seteq finite_imageI less_eq_V_def) qed lemma ordertype_VWF_\: assumes "finite A" shows "ordertype A VWF \ elts \" proof - have "finite (ordermap A VWF ` A)" using assms by blast then have "ordertype A VWF < \" by (meson Ord_\ OrdmemD trans_VWF wf_VWF assms finite_ordertype_le_card le_less_trans ord_of_nat_\) then show ?thesis by (simp add: Ord_mem_iff_lt) qed lemma ordertype_VWF_finite_nat: assumes "finite A" shows "ordertype A VWF = ord_of_nat (card A)" by (metis finite_imp_small ordermap_bij total_on_VWF wf_VWF \_def assms bij_betw_same_card card_ord_of_nat elts_of_set f_inv_into_f inf ordertype_VWF_\) lemma finite_ordertype_eq_card: assumes "small A" "wf r" "trans r" "total_on A r" shows "ordertype A r = ord_of_nat m \ finite A \ card A = m" using ordermap_bij [OF \wf r\] proof - have *: "bij_betw (ordermap A r) A (elts (ordertype A r))" by (simp add: assms ordermap_bij) moreover have "card (ordermap A r ` A) = card A" by (meson bij_betw_def * card_image) ultimately show ?thesis using assms bij_betw_finite bij_betw_imp_surj_on finite_Ord_omega ordertype_VWF_finite_nat wf_Ord_ordertype by fastforce qed lemma ex_bij_betw_strict_mono_card: assumes "finite M" "M \ ON" obtains h where "bij_betw h {..finite M\ ordermap_bij ordertype_VWF_finite_nat by fastforce let ?h = "(inv_into M (ordermap M VWF)) \ ord_of_nat" show thesis proof show bijh: "bij_betw ?h {.. elts (ordertype M VWF)" "n \ elts (ordertype M VWF)" using \m < n\ \n < card M\ \finite M\ ordertype_VWF_finite_nat by auto have ord: "Ord (?h m)" "Ord (?h n)" using bijh assms(2) bij_betwE that by fastforce+ moreover assume "\ ?h m < ?h n" ultimately consider "?h m = ?h n" | "?h m > ?h n" using Ord_linear_lt by blast then show False proof cases case 1 then have "m = n" by (metis inv_ordermap_mono_eq mn comp_apply ord_of_nat_inject) with \m < n\ show False by blast next case 2 then have "ord_of_nat n \ ord_of_nat m" by (metis Finite_V mn assms comp_def inv_ordermap_VWF_mono_le less_imp_le) then show ?thesis using leD \m < n\ by blast qed qed with assms show ?thesis by (auto simp: strict_mono_on_def) qed qed qed lemma ordertype_finite_less_than [simp]: assumes "finite A" shows "ordertype A less_than = card A" proof - let ?M = "ord_of_nat ` A" obtain M: "finite ?M" "?M \ ON" using Ord_ord_of_nat assms by blast have "ordertype A less_than = ordertype ?M VWF" by (rule ordertype_inc_eq [symmetric]) (use assms finite_imp_small total_on_def in \force+\) also have "\ = card A" proof (subst ordertype_eq_iff) let ?M = "ord_of_nat ` A" obtain h where bijh: "bij_betw h {.. ord_of_nat \ inv_into {..f. bij_betw f ?M (elts (card A)) \ (\x\?M. \y\?M. f x < f y \ ((x, y) \ VWF))" proof (intro exI conjI ballI) have "bij_betw (ord_of_nat \ inv_into {.. ?M" "y \ ?M" then obtain m n where "x = ord_of_nat m" "y = ord_of_nat n" by auto have "(f x < f y) \ ((h \ inv_into {.. inv_into {.. = (x < y)" using bijh by (simp add: bij_betw_inv_into_right xy) also have "\ \ ((x, y) \ VWF)" using M(2) ON_imp_Ord xy by auto finally show "(f x < f y) \ ((x, y) \ VWF)" . qed qed auto finally show ?thesis . qed subsection\Cardinality of a set\ definition vcard :: "V\V" where "vcard a \ (LEAST i. Ord i \ elts i \ elts a)" definition Card:: "V\bool" where "Card i \ i = vcard i" abbreviation CARD where "CARD \ Collect Card" lemma cardinal_cong: "elts x \ elts y \ vcard x = vcard y" unfolding vcard_def by (meson eqpoll_sym eqpoll_trans) lemma Card_cardinal_eq: "Card \ \ vcard \ = \" by (simp add: Card_def) lemma Card_is_Ord: assumes "Card \" shows "Ord \" proof - obtain \ where "Ord \" "elts \ \ elts \" using Ord_ordertype ordertype_eqpoll by blast then have "Ord (LEAST i. Ord i \ elts i \ elts \)" by (metis Ord_Least) then show ?thesis using Card_def vcard_def assms by auto qed lemma cardinal_eqpoll: "elts (vcard a) \ elts a" unfolding vcard_def using ordertype_eqpoll [of "elts a"] Ord_LeastI by (meson Ord_ordertype small_elts) lemma inj_into_vcard: obtains f where "f \ elts A \ elts (vcard A)" "inj_on f (elts A)" using cardinal_eqpoll [of A] inj_on_the_inv_into the_inv_into_onto by (fastforce simp: Pi_iff bij_betw_def eqpoll_def) lemma cardinal_idem [simp]: "vcard (vcard a) = vcard a" using cardinal_cong cardinal_eqpoll by blast text\every natural number is a (finite) cardinal\ lemma nat_into_Card: assumes "\ \ elts \" shows "Card(\)" proof (unfold Card_def vcard_def, rule sym) obtain n where n: "\ = ord_of_nat n" by (metis \_def assms elts_of_set imageE inf) have "Ord(\)" using assms by auto moreover { fix \ assume "\ < \" "Ord \" "elts \ \ elts \" with n have "elts \ \ {..Ord \\ \\ < \\ \Ord(\)\ by (metis \elts \ \ elts \\ card_seteq eqpoll_finite_iff eqpoll_iff_card finite_lessThan less_eq_V_def less_le_not_le order_refl) } ultimately show "(LEAST i. Ord i \ elts i \ elts \) = \" by (metis (no_types, lifting) Least_equality Ord_linear_le eqpoll_refl less_le_not_le) qed lemma Card_ord_of_nat [simp]: "Card (ord_of_nat n)" by (simp add: \_def nat_into_Card) lemma Card_0 [iff]: "Card 0" by (simp add: nat_into_Card) lemma CardI: "\Ord i; \j. \j < i; Ord j\ \ \ elts j \ elts i\ \ Card i" unfolding Card_def vcard_def by (metis Ord_Least Ord_linear_lt cardinal_eqpoll eqpoll_refl not_less_Ord_Least vcard_def) lemma vcard_0 [simp]: "vcard 0 = 0" using Card_0 Card_def by auto lemma Ord_cardinal [simp,intro!]: "Ord(vcard a)" unfolding vcard_def by (metis Card_def Card_is_Ord cardinal_cong cardinal_eqpoll vcard_def) text\The cardinals are the initial ordinals.\ lemma Card_iff_initial: "Card \ \ Ord \ \ (\\. Ord \ \ \ < \ \ ~ elts \ \ elts \)" proof - { fix j assume \: "Card \" "elts j \ elts \" "Ord j" assume "j < \" also have "\ = (LEAST i. Ord i \ elts i \ elts \)" using \ by (simp add: Card_def vcard_def) finally have "j < (LEAST i. Ord i \ elts i \ elts \)" . hence "False" using \ using not_less_Ord_Least by fastforce } then show ?thesis by (blast intro: CardI Card_is_Ord) qed lemma Card_\ [iff]: "Card \" proof - have "\\ f. \\ \ elts \; bij_betw f (elts \) (elts \)\ \ False" using bij_betw_finite finite_Ord_omega infinite_\ by blast then show ?thesis by (meson CardI Ord_\ Ord_mem_iff_lt eqpoll_def) qed lemma lt_Card_imp_lesspoll: "\i < a; Card a; Ord i\ \ elts i \ elts a" by (meson Card_iff_initial less_eq_V_def less_imp_le lesspoll_def subset_imp_lepoll) lemma lepoll_imp_Card_le: assumes "elts a \ elts b" shows "vcard a \ vcard b" using Ord_cardinal [of a] Ord_cardinal [of b] proof (cases rule: Ord_linear_le) case le thus ?thesis . next case ge have "elts b \ elts (vcard b)" by (simp add: cardinal_eqpoll eqpoll_sym) also have "\ \ elts (vcard a)" by (meson ge less_eq_V_def subset_imp_lepoll) also have "\ \ elts a" by (simp add: cardinal_eqpoll) finally have "elts b \ elts a" . hence "elts a \ elts b" using assms lepoll_antisym by blast hence "vcard a = vcard b" by (rule cardinal_cong) thus ?thesis by simp qed lemma lepoll_cardinal_le: "\elts A \ elts i; Ord i\ \ vcard A \ i" by (metis Ord_Least Ord_linear2 dual_order.trans eqpoll_refl lepoll_imp_Card_le not_less_Ord_Least vcard_def) lemma cardinal_le_lepoll: "vcard A \ \ \ elts A \ elts \" by (meson cardinal_eqpoll eqpoll_sym lepoll_trans1 less_eq_V_def subset_imp_lepoll) lemma lesspoll_imp_Card_less: assumes "elts a \ elts b" shows "vcard a < vcard b" by (metis assms cardinal_eqpoll eqpoll_sym eqpoll_trans le_neq_trans lepoll_imp_Card_le lesspoll_def) lemma Card_Union [simp,intro]: assumes A: "\x. x \ A \ Card(x)" shows "Card(\A)" proof (rule CardI) show "Ord(\A)" using A by (simp add: Card_is_Ord Ord_Sup) next fix j assume j: "j < \A" "Ord j" hence "\c\A. j < c \ Card(c)" using A by (meson Card_is_Ord Ord_linear2 ZFC_in_HOL.Sup_least leD) then obtain c where c: "c\A" "j < c" "Card(c)" by blast hence jls: "elts j \ elts c" using j(2) lt_Card_imp_lesspoll by blast { assume eqp: "elts j \ elts (\A)" have "elts c \ elts (\A)" using c using Sup_V_def ZFC_in_HOL.Sup_upper j(1) less_eq_V_def subset_imp_lepoll by fastforce also have "... \ elts j" by (rule eqpoll_sym [OF eqp]) also have "... \ elts c" by (rule jls) finally have "elts c \ elts c" . hence False by auto } thus "\ elts j \ elts (\A)" by blast qed lemma Card_UN: "(\x. x \ A \ Card(K x)) ==> Card(Sup (K ` A))" by blast subsection\Transfinite recursion for definitions based on the three cases of ordinals\ definition transrec3 :: "[V, [V,V]\V, [V,V\V]\V, V] \ V" where "transrec3 a b c \ transrec (\r x. if x=0 then a else if Limit x then c x (\y \ elts x. r y) else b(pred x) (r (pred x)))" lemma transrec3_0 [simp]: "transrec3 a b c 0 = a" by (simp add: transrec transrec3_def) lemma transrec3_succ [simp]: "transrec3 a b c (succ i) = b i (transrec3 a b c i)" by (simp add: transrec transrec3_def) lemma transrec3_Limit [simp]: "Limit i \ transrec3 a b c i = c i (\j \ elts i. transrec3 a b c j)" unfolding transrec3_def by (subst transrec) auto subsection \Cardinal Addition\ definition cadd :: "[V,V]\V" (infixl \\\ 65) where "\ \ \ \ vcard (\ \ \)" subsubsection\Cardinal addition is commutative\ lemma vsum_commute_eqpoll: "elts (a\b) \ elts (b\a)" proof - have "bij_betw (\z \ elts (a\b). sum_case Inr Inl z) (elts (a\b)) (elts (b\a))" unfolding bij_betw_def proof (intro conjI inj_onI) show "restrict (sum_case Inr Inl) (elts (a \ b)) ` elts (a \ b) = elts (b \ a)" apply auto apply (metis (no_types) imageI sum_case_Inr sum_iff) by (metis Inl_in_sum_iff imageI sum_case_Inl) qed auto then show ?thesis using eqpoll_def by blast qed lemma cadd_commute: "i \ j = j \ i" by (simp add: cadd_def cardinal_cong vsum_commute_eqpoll) subsubsection\Cardinal addition is associative\ lemma sum_assoc_bij: "bij_betw (\z \ elts ((a\b)\c). sum_case(sum_case Inl (\y. Inr(Inl y))) (\y. Inr(Inr y)) z) (elts ((a\b)\c)) (elts (a\(b\c)))" by (rule_tac f' = "sum_case (\x. Inl (Inl x)) (sum_case (\x. Inl (Inr x)) Inr)" in bij_betw_byWitness) auto lemma sum_assoc_eqpoll: "elts ((a\b)\c) \ elts (a\(b\c))" unfolding eqpoll_def by (metis sum_assoc_bij) lemma elts_vcard_vsum_eqpoll: "elts (vcard (i \ j)) \ Inl ` elts i \ Inr ` elts j" proof - have "elts (i \ j) \ Inl ` elts i \ Inr ` elts j" by (simp add: elts_vsum) then show ?thesis using cardinal_eqpoll eqpoll_trans by blast qed lemma cadd_assoc: "(i \ j) \ k = i \ (j \ k)" proof (unfold cadd_def, rule cardinal_cong) have "elts (vcard(i \ j) \ k) \ elts ((i \ j) \ k)" by (auto simp: disjnt_def elts_vsum elts_vcard_vsum_eqpoll intro: Un_eqpoll_cong) also have "\ \ elts (i \ (j \ k))" by (rule sum_assoc_eqpoll) also have "\ \ elts (i \ vcard(j \ k))" by (auto simp: disjnt_def elts_vsum elts_vcard_vsum_eqpoll [THEN eqpoll_sym] intro: Un_eqpoll_cong) finally show "elts (vcard (i \ j) \ k) \ elts (i \ vcard (j \ k))" . qed text\0 is the identity for addition\ lemma vsum_0_eqpoll: "elts (0\a) \ elts a" by (simp add: elts_vsum) lemma cadd_0 [simp]: "Card \ \ 0 \ \ = \" by (metis Card_def cadd_def cardinal_cong vsum_0_eqpoll) lemma cadd_0_right [simp]: "Card \ \ \ \ 0 = \" by (simp add: cadd_commute) lemma vsum_lepoll_self: "elts a \ elts (a\b)" unfolding elts_vsum by (meson Inl_iff Un_upper1 inj_onI lepoll_def) lemma cadd_le_self: assumes \: "Card \" shows "\ \ \ \ a" proof (unfold cadd_def) have "\ \ vcard \" using Card_def \ by auto also have "\ \ vcard (\ \ a)" by (simp add: lepoll_imp_Card_le vsum_lepoll_self) finally show "\ \ vcard (\ \ a)" . qed text\Monotonicity of addition\ lemma cadd_le_mono: "\\' \ \; \' \ \\ \ \' \ \' \ \ \ \" unfolding cadd_def by (metis (no_types) lepoll_imp_Card_le less_eq_V_def subset_imp_lepoll sum_subset_iff) subsection\Cardinal multiplication\ definition cmult :: "[V,V]\V" (infixl \\\ 70) where "\ \ \ \ vcard (VSigma \ (\z. \))" subsubsection\Cardinal multiplication is commutative\ lemma prod_bij: "\bij_betw f A C; bij_betw g B D\ \ bij_betw (\(x, y). (f x, g y)) (A \ B) (C \ D)" apply (rule bij_betw_byWitness [where f' = "\(x,y). (inv_into A f x, inv_into B g y)"]) apply (auto simp: bij_betw_inv_into_left bij_betw_inv_into_right bij_betwE) using bij_betwE bij_betw_inv_into apply blast+ done lemma cmult_commute: "i \ j = j \ i" proof - have "(\(x, y). \x, y\) ` (elts i \ elts j) \ (\(x, y). \x, y\) ` (elts j \ elts i)" by (simp add: inj_on_vpair times_commute_eqpoll) then show ?thesis unfolding cmult_def using cardinal_cong elts_VSigma by auto qed subsubsection\Cardinal multiplication is associative\ lemma elts_vcard_VSigma_eqpoll: "elts (vcard (vtimes i j)) \ elts i \ elts j" proof - have "elts (vtimes i j) \ elts i \ elts j" by (simp add: elts_VSigma) then show ?thesis using cardinal_eqpoll eqpoll_trans by blast qed lemma cmult_assoc: "(i \ j) \ k = i \ (j \ k)" unfolding cmult_def proof (rule cardinal_cong) have "elts (vcard (vtimes i j)) \ elts k \ (elts i \ elts j) \ elts k" by (blast intro: times_eqpoll_cong elts_vcard_VSigma_eqpoll cardinal_eqpoll) also have "\ \ elts i \ (elts j \ elts k)" by (rule times_assoc_eqpoll) also have "\ \ elts i \ elts (vcard (vtimes j k))" by (blast intro: times_eqpoll_cong elts_vcard_VSigma_eqpoll cardinal_eqpoll eqpoll_sym) finally show "elts (VSigma (vcard (vtimes i j)) (\z. k)) \ elts (VSigma i (\z. vcard (vtimes j k)))" by (simp add: elts_VSigma) qed subsubsection\Cardinal multiplication distributes over addition\ lemma cadd_cmult_distrib: "(i \ j) \ k = (i \ k) \ (j \ k)" unfolding cadd_def cmult_def proof (rule cardinal_cong) have "elts (vtimes (vcard (i \ j)) k) \ elts (vcard (vsum i j)) \ elts k" using cardinal_eqpoll elts_vcard_VSigma_eqpoll eqpoll_sym eqpoll_trans by blast also have "\ \ (Inl ` elts i \ Inr ` elts j) \ elts k" using elts_vcard_vsum_eqpoll times_eqpoll_cong by blast also have "\ \ (Inl ` elts i) \ elts k \ (Inr ` elts j) \ elts k" by (simp add: Sigma_Un_distrib1) also have "\ \ elts (vtimes i k \ vtimes j k)" unfolding Plus_def by (auto simp: elts_vsum elts_VSigma disjnt_iff intro!: Un_eqpoll_cong times_eqpoll_cong) also have "\ \ elts (vcard (vtimes i k \ vtimes j k))" by (simp add: cardinal_eqpoll eqpoll_sym) also have "\ \ elts (vcard (vtimes i k) \ vcard (vtimes j k))" by (metis cadd_assoc cadd_def cardinal_cong cardinal_eqpoll vsum_0_eqpoll vsum_commute_eqpoll) finally show "elts (VSigma (vcard (i \ j)) (\z. k)) \ elts (vcard (vtimes i k) \ vcard (vtimes j k))" . qed text\Multiplication by 0 yields 0\ lemma cmult_0 [simp]: "0 \ i = 0" using Card_0 Card_def cmult_def by auto text\1 is the identity for multiplication\ lemma cmult_1 [simp]: assumes "Card \" shows "1 \ \ = \" proof - have "elts (vtimes (set {0}) \) \ elts \" by (auto simp: elts_VSigma intro!: times_singleton_eqpoll) then show ?thesis by (metis Card_def assms cardinal_cong cmult_def elts_1 set_of_elts) qed subsection\Some inequalities for multiplication\ lemma cmult_square_le: assumes "Card \" shows "\ \ \ \ \" proof - have "elts \ \ elts (\ \ \)" using times_square_lepoll [of "elts \"] cmult_def elts_vcard_VSigma_eqpoll eqpoll_sym lepoll_trans2 by fastforce then show ?thesis using Card_def assms cmult_def lepoll_cardinal_le by fastforce qed text\Multiplication by a non-empty set\ lemma cmult_le_self: assumes "Card \" "\ \ 0" shows "\ \ \ \ \" proof - have "\ = vcard \" using Card_def \Card \\ by blast also have "\ \ vcard (vtimes \ \)" apply (rule lepoll_imp_Card_le) apply (simp add: elts_VSigma) by (metis ZFC_in_HOL.ext \\ \ 0\ elts_0 lepoll_times1) also have "\ = \ \ \" by (simp add: cmult_def) finally show ?thesis . qed text\Monotonicity of multiplication\ lemma cmult_le_mono: "\\' \ \; \' \ \\ \ \' \ \' \ \ \ \" unfolding cmult_def by (auto simp: elts_VSigma intro!: lepoll_imp_Card_le times_lepoll_mono subset_imp_lepoll) subsection\The finite cardinals\ lemma succ_lepoll_succD: "elts (succ(m)) \ elts (succ(n)) \ elts m \ elts n" by (simp add: insert_lepoll_insertD) text\Congruence law for @{text succ} under equipollence\ lemma succ_eqpoll_cong: "elts a \ elts b \ elts (succ(a)) \ elts (succ(b))" by (simp add: succ_def insert_eqpoll_cong) lemma sum_succ_eqpoll: "elts (succ a \ b) \ elts (succ(a\b))" unfolding eqpoll_def proof (rule exI) let ?f = "\z. if z=Inl a then a\b else z" let ?g = "\z. if z=a\b then Inl a else z" show "bij_betw ?f (elts (succ a \ b)) (elts (succ (a \ b)))" apply (rule bij_betw_byWitness [where f' = ?g], auto) apply (metis Inl_in_sum_iff mem_not_refl) by (metis Inr_in_sum_iff mem_not_refl) qed lemma cadd_succ: "succ m \ n = vcard (succ(m \ n))" proof (unfold cadd_def) have [intro]: "elts (m \ n) \ elts (vcard (m \ n))" using cardinal_eqpoll eqpoll_sym by blast have "vcard (succ m \ n) = vcard (succ(m \ n))" by (rule sum_succ_eqpoll [THEN cardinal_cong]) also have "\ = vcard (succ(vcard (m \ n)))" by (blast intro: succ_eqpoll_cong cardinal_cong) finally show "vcard (succ m \ n) = vcard (succ(vcard (m \ n)))" . qed lemma nat_cadd_eq_add: "ord_of_nat m \ ord_of_nat n = ord_of_nat (m + n)" proof (induct m) case (Suc m) thus ?case by (metis Card_def Card_ord_of_nat add_Suc cadd_succ ord_of_nat.simps(2)) qed auto lemma vcard_disjoint_sup: assumes "x \ y = 0" shows "vcard (x \ y) = vcard x \ vcard y" proof - have "elts (x \ y) \ elts (x \ y)" unfolding eqpoll_def proof (rule exI) let ?f = "\z. if z \ elts x then Inl z else Inr z" let ?g = "sum_case id id" show "bij_betw ?f (elts (x \ y)) (elts (x \ y))" by (rule bij_betw_byWitness [where f' = ?g]) (use assms V_disjoint_iff in auto) qed then show ?thesis by (metis cadd_commute cadd_def cardinal_cong cardinal_idem vsum_0_eqpoll cadd_assoc) qed subsection\Infinite cardinals\ definition InfCard :: "V\bool" where "InfCard \ \ Card \ \ \ \ \" lemma InfCard_iff: "InfCard \ \ Card \ \ infinite (elts \)" proof (cases "\ \ \") case True then show ?thesis using inj_ord_of_nat lepoll_def less_eq_V_def by (auto simp: InfCard_def \_def infinite_le_lepoll) next case False then show ?thesis using Card_iff_initial InfCard_def infinite_Ord_omega by blast qed lemma InfCard_ge_ord_of_nat: assumes "InfCard \" shows "ord_of_nat n \ \" using InfCard_def assms ord_of_nat_le_omega by blast lemma InfCard_not_0[iff]: "\ InfCard 0" by (simp add: InfCard_iff) definition csucc :: "V\V" where "csucc \ \ LEAST \'. Ord \' \ (Card \' \ \ < \')" lemma less_vcard_VPow: "vcard A < vcard (VPow A)" proof (rule lesspoll_imp_Card_less) show "elts A \ elts (VPow A)" by (simp add: elts_VPow down inj_on_def lesspoll_Pow_self) qed lemma greater_Card: assumes "Card \" shows "\ < vcard (VPow \)" proof - have "\ = vcard \" using Card_def assms by blast also have "\ < vcard (VPow \)" proof (rule lesspoll_imp_Card_less) show "elts \ \ elts (VPow \)" by (simp add: elts_VPow down inj_on_def lesspoll_Pow_self) qed finally show ?thesis . qed lemma assumes "Card \" shows Card_csucc [simp]: "Card (csucc \)" and less_csucc [simp]: "\ < csucc \" proof - have "Card (csucc \) \ \ < csucc \" unfolding csucc_def proof (rule Ord_LeastI2) show "Card (vcard (VPow \)) \ \ < (vcard (VPow \))" using Card_def assms greater_Card by auto qed auto then show "Card (csucc \)" "\ < csucc \" by auto qed lemma le_csucc: assumes "Card \" shows "\ \ csucc \" by (simp add: assms less_csucc less_imp_le) lemma csucc_le: "\Card \; \ \ elts \\ \ csucc \ \ \" unfolding csucc_def by (simp add: Card_is_Ord Ord_Least_le OrdmemD) lemma finite_csucc: "a \ elts \ \ csucc a = succ a" unfolding csucc_def proof (rule Least_equality) show "Ord (ZFC_in_HOL.succ a) \ Card (ZFC_in_HOL.succ a) \ a < ZFC_in_HOL.succ a" if "a \ elts \" using that by (auto simp: less_V_def less_eq_V_def nat_into_Card) show "ZFC_in_HOL.succ a \ y" if "a \ elts \" and "Ord y \ Card y \ a < y" for y :: V using that using Ord_mem_iff_lt dual_order.strict_implies_order by fastforce qed lemma Finite_imp_cardinal_cons [simp]: assumes FA: "finite A" and a: "a \ A" shows "vcard (set (insert a A)) = csucc(vcard (set A))" proof - show ?thesis unfolding csucc_def proof (rule Least_equality [THEN sym]) have "small A" by (simp add: FA Finite_V) then have "\ elts (set A) \ elts (set (insert a A))" using FA a eqpoll_imp_lepoll eqpoll_sym finite_insert_lepoll by fastforce then show "Ord (vcard (set (insert a A))) \ Card (vcard (set (insert a A))) \ vcard (set A) < vcard (set (insert a A))" by (simp add: Card_def lesspoll_imp_Card_less lesspoll_def subset_imp_lepoll subset_insertI) show "vcard (set (insert a A)) \ i" if "Ord i \ Card i \ vcard (set A) < i" for i proof - have "elts (vcard (set A)) \ A" by (metis FA finite_imp_small cardinal_eqpoll elts_of_set) then have less: "A \ elts i" using eq_lesspoll_trans eqpoll_sym lt_Card_imp_lesspoll that by blast show ?thesis using that less by (auto simp: less_imp_insert_lepoll lepoll_cardinal_le) qed qed qed lemma vcard_finite_set: "finite A \ vcard (set A) = ord_of_nat (card A)" by (induction A rule: finite_induct) (auto simp: set_empty \_def finite_csucc) lemma lt_csucc_iff: assumes "Ord \" "Card \" shows "\ < csucc \ \ vcard \ \ \" proof show "vcard \ \ \" if "\ < csucc \" proof - have "vcard \ \ csucc \" by (meson \Ord \\ dual_order.trans lepoll_cardinal_le lepoll_refl less_le_not_le that) then show ?thesis by (metis (no_types) Card_def Card_iff_initial Ord_linear2 Ord_mem_iff_lt assms cardinal_eqpoll cardinal_idem csucc_le eq_iff eqpoll_sym that) qed show "\ < csucc \" if "vcard \ \ \" proof - have "\ csucc \ \ \" using that by (metis Card_csucc Card_def assms(2) le_less_trans lepoll_imp_Card_le less_csucc less_eq_V_def less_le_not_le subset_imp_lepoll) then show ?thesis by (meson Card_csucc Card_is_Ord Ord_linear2 assms) qed qed lemma Card_lt_csucc_iff: "\Card \'; Card \\ \ (\' < csucc \) = (\' \ \)" by (simp add: lt_csucc_iff Card_cardinal_eq Card_is_Ord) lemma InfCard_csucc: "InfCard \ \ InfCard (csucc \)" using InfCard_def le_csucc by auto text\Kunen's Lemma 10.11\ lemma InfCard_is_Limit: assumes "InfCard \" shows "Limit \" proof (rule non_succ_LimitI) show "\ \ 0" using InfCard_def assms mem_not_refl by blast show "Ord \" using Card_is_Ord InfCard_def assms by blast show "ZFC_in_HOL.succ y \ \" for y proof assume "succ y = \" then have "Card (succ y)" using InfCard_def assms by auto moreover have "\ \ y" by (metis InfCard_iff Ord_in_Ord \Ord \\ \ZFC_in_HOL.succ y = \\ assms elts_succ finite_insert infinite_Ord_omega insertI1) moreover have "elts y \ elts (succ y)" using InfCard_iff \ZFC_in_HOL.succ y = \\ assms eqpoll_sym infinite_insert_eqpoll by fastforce ultimately show False by (metis Card_iff_initial Ord_in_Ord OrdmemD elts_succ insertI1) qed qed subsection\Toward's Kunen's Corollary 10.13 (1)\ text\Kunen's Theorem 10.12\ lemma InfCard_csquare_eq: assumes "InfCard(\)" shows "\ \ \ = \" using infinite_times_eqpoll_self [of "elts \"] assms unfolding InfCard_iff Card_def by (metis cardinal_cong cardinal_eqpoll cmult_def elts_vcard_VSigma_eqpoll eqpoll_trans) lemma InfCard_le_cmult_eq: assumes "InfCard \" "\ \ \" "\ \ 0" shows "\ \ \ = \" proof (rule order_antisym) have "\ \ \ \ \ \ \" by (simp add: assms(2) cmult_le_mono) also have "\ \ \" by (simp add: InfCard_csquare_eq assms(1)) finally show "\ \ \ \ \" . show "\ \ \ \ \" using InfCard_def assms(1) assms(3) cmult_le_self by auto qed text\Kunen's Corollary 10.13 (1), for cardinal multiplication\ lemma InfCard_cmult_eq: "\InfCard \; InfCard \\ \ \ \ \ = \ \ \" by (metis Card_is_Ord InfCard_def InfCard_le_cmult_eq Ord_linear_le cmult_commute inf_sup_aci(5) mem_not_refl sup.orderE sup_V_0_right zero_in_omega) lemma cmult_succ: "succ(m) \ n = n \ (m \ n)" unfolding cmult_def cadd_def proof (rule cardinal_cong) have "elts (vtimes (ZFC_in_HOL.succ m) n) \ elts n <+> elts m \ elts n" by (simp add: elts_VSigma prod_insert_eqpoll) also have "\ \ elts (n \ vcard (vtimes m n))" unfolding elts_VSigma elts_vsum Plus_def proof (rule Un_eqpoll_cong) show "(Sum_Type.Inr ` (elts m \ elts n)::(V + V \ V) set) \ Inr ` elts (vcard (vtimes m n))" by (simp add: elts_vcard_VSigma_eqpoll eqpoll_sym) qed (auto simp: disjnt_def) finally show "elts (vtimes (ZFC_in_HOL.succ m) n) \ elts (n \ vcard (vtimes m n))" . qed lemma cmult_2: assumes "Card n" shows "ord_of_nat 2 \ n = n \ n" proof - have "ord_of_nat 2 = succ (succ 0)" by force then show ?thesis by (simp add: cmult_succ assms) qed lemma InfCard_cdouble_eq: assumes "InfCard \" shows "\ \ \ = \" proof - have "\ \ \ = \ \ ord_of_nat 2" using InfCard_def assms cmult_2 cmult_commute by auto also have "\ = \" by (simp add: InfCard_le_cmult_eq InfCard_ge_ord_of_nat assms) finally show ?thesis . qed text\Corollary 10.13 (1), for cardinal addition\ lemma InfCard_le_cadd_eq: "\InfCard \; \ \ \\ \ \ \ \ = \" by (metis InfCard_cdouble_eq InfCard_def antisym cadd_le_mono cadd_le_self) lemma InfCard_cadd_eq: "\InfCard \; InfCard \\ \ \ \ \ = \ \ \" by (metis Card_iff_initial InfCard_def InfCard_le_cadd_eq Ord_linear_le cadd_commute sup.absorb2 sup.orderE) subsection \The Aleph-seqence\ text \This is the well-known transfinite enumeration of the cardinal numbers.\ definition Aleph :: "V \ V" (\\_\ [90] 90) where "Aleph \ transrec3 \ (\x r. csucc(r)) (\i r . \ (r ` elts i))" lemma Card_Aleph [simp, intro]: "Ord \ \ Card(Aleph \)" by (induction \ rule: Ord_induct3) (auto simp: Aleph_def) lemma Aleph_0 [simp]: "\0 = \" by (simp add: Aleph_def) lemma Aleph_succ [simp]: "\(succ x) = csucc (\ x)" by (simp add: Aleph_def) lemma Aleph_Limit: "Limit \ \ \ \ = \ (Aleph ` elts \)" by (simp add: Aleph_def) lemma mem_Aleph_succ: "Ord \ \ \(\) \ elts (\(succ \))" by (simp add: Card_is_Ord Ord_mem_iff_lt) lemma Aleph_increasing: assumes ab: "\ < \" "Ord \" "Ord \" shows "Aleph(\) < Aleph(\)" proof - { fix x have "\Ord x; x \ elts \\ \ Aleph(x) \ elts (Aleph \)" using \Ord \\ proof (induct \ arbitrary: x rule: Ord_induct3) case 0 thus ?case by simp next case (succ \) then consider "x = \" |"x \ elts \" using OrdmemD by auto then show ?case proof cases case 1 then show ?thesis by (simp add: Card_is_Ord Ord_mem_iff_lt succ.hyps(1)) next case 2 with succ show ?thesis by (metis Aleph_succ Card_Aleph le_csucc vsubsetD) qed next case (Limit \) hence sc: "succ x \ elts \" by (simp add: Limit_def Ord_mem_iff_lt) hence "\ x \ elts (\ (Aleph ` elts \))" using Limit by blast thus ?case using Limit by (simp add: Aleph_Limit) qed } thus ?thesis using ab by (simp add: Card_is_Ord Ord_mem_iff_lt) qed lemma countable_iff_le_Aleph0: "countable (elts A) \ vcard A \ \0" proof show "vcard A \ \0" if "countable (elts A)" proof (cases "finite (elts A)") case True then show ?thesis using vcard_finite_set by fastforce next case False then have "elts \ \ elts A" using countableE_infinite [OF that] by (simp add: eqpoll_def \_def) (meson bij_betw_def bij_betw_inv bij_betw_trans inj_ord_of_nat) then show ?thesis using Card_\ Card_def cardinal_cong vcard_def by auto qed show "countable (elts A)" if "vcard A \ \0" proof - have "elts A \ elts \" using cardinal_le_lepoll [OF that] by simp then show ?thesis by (simp add: countable_iff_lepoll \_def inj_ord_of_nat) qed qed subsection \The ordinal @{term "\1"}\ abbreviation "\1 \ Aleph 1" lemma Ord_\1 [simp]: "Ord \1" by (simp add: Card_is_Ord) lemma omega_\1 [iff]: "\ \ elts \1" using mem_Aleph_succ one_V_def by fastforce lemma ord_of_nat_\1 [iff]: "ord_of_nat n \ elts \1" using Ord_\1 Ord_trans by blast lemma countable_iff_less_\1: assumes "Ord \" shows "countable (elts \) \ \ < \1" by (simp add: assms countable_iff_le_Aleph0 lt_csucc_iff one_V_def) lemma less_\1_imp_countable: assumes "\ \ elts \1" shows "countable (elts \)" using Ord_\1 Ord_in_Ord OrdmemD assms countable_iff_less_\1 by blast lemma \1_gt0 [simp]: "\1 > 0" using Ord_\1 Ord_trans OrdmemD by blast lemma \1_gt1 [simp]: "\1 > 1" using Ord_\1 OrdmemD \_gt1 less_trans by blast lemma Limit_\1 [simp]: "Limit \1" by (simp add: InfCard_def InfCard_is_Limit le_csucc one_V_def) end