# HG changeset patch # User paulson # Date 1548341092 0 # Node ID 8230dca028ebf844b5e9fc0483a18d7f40935c77 # Parent 6d158fd15b85602d316b2a9a8934718c9bd46801 the theory of Equipollence, and moving Fpow from Cardinals into Main diff -r 6d158fd15b85 -r 8230dca028eb src/HOL/Cardinals/Cardinal_Order_Relation.thy --- a/src/HOL/Cardinals/Cardinal_Order_Relation.thy Thu Jan 24 10:04:32 2019 +0100 +++ b/src/HOL/Cardinals/Cardinal_Order_Relation.thy Thu Jan 24 14:44:52 2019 +0000 @@ -886,22 +886,7 @@ using lists_UNIV by auto -subsection \Cardinals versus the set-of-finite-sets operator\ - -definition Fpow :: "'a set \ 'a set set" -where "Fpow A \ {X. X \ A \ finite X}" - -lemma Fpow_mono: "A \ B \ Fpow A \ Fpow B" -unfolding Fpow_def by auto - -lemma empty_in_Fpow: "{} \ Fpow A" -unfolding Fpow_def by auto - -lemma Fpow_not_empty: "Fpow A \ {}" -using empty_in_Fpow by blast - -lemma Fpow_subset_Pow: "Fpow A \ Pow A" -unfolding Fpow_def by auto +subsection \Cardinals versus the finite powerset operator\ lemma card_of_Fpow[simp]: "|A| \o |Fpow A|" proof- @@ -914,20 +899,6 @@ lemma Card_order_Fpow: "Card_order r \ r \o |Fpow(Field r) |" using card_of_Fpow card_of_Field_ordIso ordIso_ordLeq_trans ordIso_symmetric by blast -lemma Fpow_Pow_finite: "Fpow A = Pow A Int {A. finite A}" -unfolding Fpow_def Pow_def by blast - -lemma inj_on_image_Fpow: -assumes "inj_on f A" -shows "inj_on (image f) (Fpow A)" -using assms Fpow_subset_Pow[of A] subset_inj_on[of "image f" "Pow A"] - inj_on_image_Pow by blast - -lemma image_Fpow_mono: -assumes "f ` A \ B" -shows "(image f) ` (Fpow A) \ Fpow B" -using assms by(unfold Fpow_def, auto) - lemma image_Fpow_surjective: assumes "f ` A = B" shows "(image f) ` (Fpow A) = Fpow B" diff -r 6d158fd15b85 -r 8230dca028eb src/HOL/Cardinals/Fun_More.thy --- a/src/HOL/Cardinals/Fun_More.thy Thu Jan 24 10:04:32 2019 +0100 +++ b/src/HOL/Cardinals/Fun_More.thy Thu Jan 24 14:44:52 2019 +0000 @@ -58,32 +58,6 @@ subsection \Properties involving finite and infinite sets\ -(*3*)lemma inj_on_image_Pow: -assumes "inj_on f A" -shows "inj_on (image f) (Pow A)" -unfolding Pow_def inj_on_def proof(clarsimp) - fix X Y assume *: "X \ A" and **: "Y \ A" and - ***: "f ` X = f ` Y" - show "X = Y" - proof(auto) - fix x assume ****: "x \ X" - with *** obtain y where "y \ Y \ f x = f y" by blast - with **** * ** assms show "x \ Y" - unfolding inj_on_def by auto - next - fix y assume ****: "y \ Y" - with *** obtain x where "x \ X \ f x = f y" by atomize_elim force - with **** * ** assms show "y \ X" - unfolding inj_on_def by auto - qed -qed - -(*2*)lemma bij_betw_image_Pow: -assumes "bij_betw f A B" -shows "bij_betw (image f) (Pow A) (Pow B)" -using assms unfolding bij_betw_def -by (auto simp add: inj_on_image_Pow image_Pow_surj) - (* unused *) (*1*)lemma bij_betw_inv_into_RIGHT: assumes BIJ: "bij_betw f A A'" and SUB: "B' \ A'" diff -r 6d158fd15b85 -r 8230dca028eb src/HOL/Finite_Set.thy --- a/src/HOL/Finite_Set.thy Thu Jan 24 10:04:32 2019 +0100 +++ b/src/HOL/Finite_Set.thy Thu Jan 24 14:44:52 2019 +0000 @@ -2182,4 +2182,35 @@ for S :: "'a::linordered_ring set" by (rule ccontr) (auto simp: abs_eq_iff vimage_def dest: inf_img_fin_dom) +subsection \The finite powerset operator\ + +definition Fpow :: "'a set \ 'a set set" +where "Fpow A \ {X. X \ A \ finite X}" + +lemma Fpow_mono: "A \ B \ Fpow A \ Fpow B" +unfolding Fpow_def by auto + +lemma empty_in_Fpow: "{} \ Fpow A" +unfolding Fpow_def by auto + +lemma Fpow_not_empty: "Fpow A \ {}" +using empty_in_Fpow by blast + +lemma Fpow_subset_Pow: "Fpow A \ Pow A" +unfolding Fpow_def by auto + +lemma Fpow_Pow_finite: "Fpow A = Pow A Int {A. finite A}" +unfolding Fpow_def Pow_def by blast + +lemma inj_on_image_Fpow: + assumes "inj_on f A" + shows "inj_on (image f) (Fpow A)" + using assms Fpow_subset_Pow[of A] subset_inj_on[of "image f" "Pow A"] + inj_on_image_Pow by blast + +lemma image_Fpow_mono: + assumes "f ` A \ B" + shows "(image f) ` (Fpow A) \ Fpow B" + using assms by(unfold Fpow_def, auto) + end diff -r 6d158fd15b85 -r 8230dca028eb src/HOL/Fun.thy --- a/src/HOL/Fun.thy Thu Jan 24 10:04:32 2019 +0100 +++ b/src/HOL/Fun.thy Thu Jan 24 14:44:52 2019 +0000 @@ -292,6 +292,13 @@ by (rule linorder_cases) (auto dest: assms simp: that) qed + +lemma inj_on_image_Pow: "inj_on f A \inj_on (image f) (Pow A)" + unfolding Pow_def inj_on_def by blast + +lemma bij_betw_image_Pow: "bij_betw f A B \ bij_betw (image f) (Pow A) (Pow B)" + by (auto simp add: bij_betw_def inj_on_image_Pow image_Pow_surj) + lemma surj_def: "surj f \ (\y. \x. y = f x)" by auto diff -r 6d158fd15b85 -r 8230dca028eb src/HOL/Library/Equipollence.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Library/Equipollence.thy Thu Jan 24 14:44:52 2019 +0000 @@ -0,0 +1,345 @@ +section \Equipollence and Other Relations Connected with Cardinality\ + +theory "Equipollence" + imports FuncSet +begin + +subsection\Eqpoll\ + +definition eqpoll :: "'a set \ 'b set \ bool" (infixl "\" 50) + where "eqpoll A B \ \f. bij_betw f A B" + +definition lepoll :: "'a set \ 'b set \ bool" (infixl "\" 50) + where "lepoll A B \ \f. inj_on f A \ f ` A \ B" + +definition lesspoll :: "'a set \ 'b set \ bool" (infixl \\\ 50) + where "A \ B == A \ B \ ~(A \ B)" + +lemma lepoll_empty_iff_empty [simp]: "A \ {} \ A = {}" + by (auto simp: lepoll_def) + +lemma eqpoll_iff_card_of_ordIso: "A \ B \ ordIso2 (card_of A) (card_of B)" + by (simp add: card_of_ordIso eqpoll_def) + +lemma eqpoll_finite_iff: "A \ B \ finite A \ finite B" + by (meson bij_betw_finite eqpoll_def) + +lemma eqpoll_iff_card: + assumes "finite A" "finite B" + shows "A \ B \ card A = card B" + using assms by (auto simp: bij_betw_iff_card eqpoll_def) + +lemma lepoll_antisym: + assumes "A \ B" "B \ A" shows "A \ B" + using assms unfolding eqpoll_def lepoll_def by (metis Schroeder_Bernstein) + +lemma lepoll_trans [trans]: "\A \ B; B \ C\ \ A \ C" + apply (clarsimp simp: lepoll_def) + apply (rename_tac f g) + apply (rule_tac x="g \ f" in exI) + apply (auto simp: image_subset_iff inj_on_def) + done + +lemma lepoll_trans1 [trans]: "\A \ B; B \ C\ \ A \ C" + by (meson card_of_ordLeq eqpoll_iff_card_of_ordIso lepoll_def lepoll_trans ordIso_iff_ordLeq) + +lemma lepoll_trans2 [trans]: "\A \ B; B \ C\ \ A \ C" + apply (clarsimp simp: eqpoll_def lepoll_def bij_betw_def) + apply (rename_tac f g) + apply (rule_tac x="g \ f" in exI) + apply (auto simp: image_subset_iff inj_on_def) + done + +lemma eqpoll_sym: "A \ B \ B \ A" + unfolding eqpoll_def + using bij_betw_the_inv_into by auto + +lemma eqpoll_trans [trans]: "\A \ B; B \ C\ \ A \ C" + unfolding eqpoll_def using bij_betw_trans by blast + +lemma eqpoll_imp_lepoll: "A \ B \ A \ B" + unfolding eqpoll_def lepoll_def by (metis bij_betw_def order_refl) + +lemma subset_imp_lepoll: "A \ B \ A \ B" + by (force simp: lepoll_def) + +lemma lepoll_iff: "A \ B \ (\g. A \ g ` B)" + unfolding lepoll_def +proof safe + fix g assume "A \ g ` B" + then show "\f. inj_on f A \ f ` A \ B" + by (rule_tac x="inv_into B g" in exI) (auto simp: inv_into_into inj_on_inv_into) +qed (metis image_mono the_inv_into_onto) + +lemma subset_image_lepoll: "B \ f ` A \ B \ A" + by (auto simp: lepoll_iff) + +lemma image_lepoll: "f ` A \ A" + by (auto simp: lepoll_iff) + +lemma infinite_le_lepoll: "infinite A \ (UNIV::nat set) \ A" +apply (auto simp: lepoll_def) + apply (simp add: infinite_countable_subset) + using infinite_iff_countable_subset by blast + + +lemma bij_betw_iff_bijections: + "bij_betw f A B \ (\g. (\x \ A. f x \ B \ g(f x) = x) \ (\y \ B. g y \ A \ f(g y) = y))" + (is "?lhs = ?rhs") +proof + assume L: ?lhs + then show ?rhs + apply (rule_tac x="the_inv_into A f" in exI) + apply (auto simp: bij_betw_def f_the_inv_into_f the_inv_into_f_f the_inv_into_into) + done +next + assume ?rhs + then show ?lhs + by (auto simp: bij_betw_def inj_on_def image_def; metis) +qed + +lemma eqpoll_iff_bijections: + "A \ B \ (\f g. (\x \ A. f x \ B \ g(f x) = x) \ (\y \ B. g y \ A \ f(g y) = y))" + by (auto simp: eqpoll_def bij_betw_iff_bijections) + +lemma lepoll_restricted_funspace: + "{f. f ` A \ B \ {x. f x \ k x} \ A \ finite {x. f x \ k x}} \ Fpow (A \ B)" +proof - + have *: "\U \ Fpow (A \ B). f = (\x. if \y. (x, y) \ U then SOME y. (x,y) \ U else k x)" + if "f ` A \ B" "{x. f x \ k x} \ A" "finite {x. f x \ k x}" for f + apply (rule_tac x="(\x. (x, f x)) ` {x. f x \ k x}" in bexI) + using that by (auto simp: image_def Fpow_def) + show ?thesis + apply (rule subset_image_lepoll [where f = "\U x. if \y. (x,y) \ U then @y. (x,y) \ U else k x"]) + using * by (auto simp: image_def) +qed + +subsection\The strict relation\ + + +lemma lesspoll_not_refl [iff]: "~ (i \ i)" + by (simp add: lepoll_antisym lesspoll_def) + +lemma lesspoll_imp_lepoll: "A \ B ==> A \ B" +by (unfold lesspoll_def, blast) + +lemma lepoll_iff_leqpoll: "A \ B \ A \ B | A \ B" + using eqpoll_imp_lepoll lesspoll_def by blast + +lemma lesspoll_trans [trans]: "\X \ Y; Y \ Z\ \ X \ Z" + by (meson eqpoll_sym lepoll_antisym lepoll_trans lepoll_trans1 lesspoll_def) + +lemma lesspoll_trans1 [trans]: "\X \ Y; Y \ Z\ \ X \ Z" + by (meson eqpoll_sym lepoll_antisym lepoll_trans lepoll_trans1 lesspoll_def) + +lemma lesspoll_trans2 [trans]: "\X \ Y; Y \ Z\ \ X \ Z" + by (meson eqpoll_imp_lepoll eqpoll_sym lepoll_antisym lepoll_trans lesspoll_def) + +lemma eq_lesspoll_trans [trans]: "\X \ Y; Y \ Z\ \ X \ Z" + using eqpoll_imp_lepoll lesspoll_trans1 by blast + +lemma lesspoll_eq_trans [trans]: "\X \ Y; Y \ Z\ \ X \ Z" + using eqpoll_imp_lepoll lesspoll_trans2 by blast + +subsection\Cartesian products\ + +lemma PiE_sing_eqpoll_self: "({a} \\<^sub>E B) \ B" +proof - + have 1: "x = y" + if "x \ {a} \\<^sub>E B" "y \ {a} \\<^sub>E B" "x a = y a" for x y + by (metis IntD2 PiE_def extensionalityI singletonD that) + have 2: "x \ (\h. h a) ` ({a} \\<^sub>E B)" if "x \ B" for x + using that by (rule_tac x="\z\{a}. x" in image_eqI) auto + show ?thesis + unfolding eqpoll_def bij_betw_def inj_on_def + by (force intro: 1 2) +qed + +lemma lepoll_funcset_right: + "B \ B' \ A \\<^sub>E B \ A \\<^sub>E B'" + apply (auto simp: lepoll_def inj_on_def) + apply (rule_tac x = "\g. \z \ A. f(g z)" in exI) + apply (auto simp: fun_eq_iff) + apply (metis PiE_E) + by blast + +lemma lepoll_funcset_left: + assumes "B \ {}" "A \ A'" + shows "A \\<^sub>E B \ A' \\<^sub>E B" +proof - + obtain b where "b \ B" + using assms by blast + obtain f where "inj_on f A" and fim: "f ` A \ A'" + using assms by (auto simp: lepoll_def) + then obtain h where h: "\x. x \ A \ h (f x) = x" + using the_inv_into_f_f by fastforce + let ?F = "\g. \u \ A'. if h u \ A then g(h u) else b" + show ?thesis + unfolding lepoll_def inj_on_def + proof (intro exI conjI ballI impI ext) + fix k l x + assume k: "k \ A \\<^sub>E B" and l: "l \ A \\<^sub>E B" and "?F k = ?F l" + then have "?F k (f x) = ?F l (f x)" + by simp + then show "k x = l x" + apply (auto simp: h split: if_split_asm) + apply (metis PiE_arb h k l) + apply (metis (full_types) PiE_E h k l) + using fim k l by fastforce + next + show "?F ` (A \\<^sub>E B) \ A' \\<^sub>E B" + using \b \ B\ by force + qed +qed + +lemma lepoll_funcset: + "\B \ {}; A \ A'; B \ B'\ \ A \\<^sub>E B \ A' \\<^sub>E B'" + by (rule lepoll_trans [OF lepoll_funcset_right lepoll_funcset_left]) auto + +lemma lepoll_PiE: + assumes "\i. i \ A \ B i \ C i" + shows "PiE A B \ PiE A C" +proof - + obtain f where f: "\i. i \ A \ inj_on (f i) (B i) \ (f i) ` B i \ C i" + using assms unfolding lepoll_def by metis + then show ?thesis + unfolding lepoll_def + apply (rule_tac x = "\g. \i \ A. f i (g i)" in exI) + apply (auto simp: inj_on_def) + apply (rule PiE_ext, auto) + apply (metis (full_types) PiE_mem restrict_apply') + by blast +qed + + +lemma card_le_PiE_subindex: + assumes "A \ A'" "Pi\<^sub>E A' B \ {}" + shows "PiE A B \ PiE A' B" +proof - + have "\x. x \ A' \ \y. y \ B x" + using assms by blast + then obtain g where g: "\x. x \ A' \ g x \ B x" + by metis + let ?F = "\f x. if x \ A then f x else if x \ A' then g x else undefined" + have "Pi\<^sub>E A B \ (\f. restrict f A) ` Pi\<^sub>E A' B" + proof + show "f \ Pi\<^sub>E A B \ f \ (\f. restrict f A) ` Pi\<^sub>E A' B" for f + using \A \ A'\ + by (rule_tac x="?F f" in image_eqI) (auto simp: g fun_eq_iff) + qed + then have "Pi\<^sub>E A B \ (\f. \i \ A. f i) ` Pi\<^sub>E A' B" + by (simp add: subset_imp_lepoll) + also have "\ \ PiE A' B" + by (rule image_lepoll) + finally show ?thesis . +qed + + +lemma finite_restricted_funspace: + assumes "finite A" "finite B" + shows "finite {f. f ` A \ B \ {x. f x \ k x} \ A}" (is "finite ?F") +proof (rule finite_subset) + show "finite ((\U x. if \y. (x,y) \ U then @y. (x,y) \ U else k x) ` Pow(A \ B))" (is "finite ?G") + using assms by auto + show "?F \ ?G" + proof + fix f + assume "f \ ?F" + then show "f \ ?G" + by (rule_tac x="(\x. (x,f x)) ` {x. f x \ k x}" in image_eqI) (auto simp: fun_eq_iff image_def) + qed +qed + + +proposition finite_PiE_iff: + "finite(PiE I S) \ PiE I S = {} \ finite {i \ I. ~(\a. S i \ {a})} \ (\i \ I. finite(S i))" + (is "?lhs = ?rhs") +proof (cases "PiE I S = {}") + case False + define J where "J \ {i \ I. \a. S i \ {a}}" + show ?thesis + proof + assume L: ?lhs + have "infinite (Pi\<^sub>E I S)" if "infinite J" + proof - + have "(UNIV::nat set) \ (UNIV::(nat\bool) set)" + proof - + have "\N::nat set. inj_on (=) N" + by (simp add: inj_on_def) + then show ?thesis + by (meson infinite_iff_countable_subset infinite_le_lepoll top.extremum) + qed + also have "\ = (UNIV::nat set) \\<^sub>E (UNIV::bool set)" + by auto + also have "\ \ J \\<^sub>E (UNIV::bool set)" + apply (rule lepoll_funcset_left) + using infinite_le_lepoll that by auto + also have "\ \ Pi\<^sub>E J S" + proof - + have *: "(UNIV::bool set) \ S i" if "i \ I" and "\a. \ S i \ {a}" for i + proof - + obtain a b where "{a,b} \ S i" "a \ b" + by (metis \\a. \ S i \ {a}\ all_not_in_conv empty_subsetI insertCI insert_subset set_eq_subset subsetI) + then show ?thesis + apply (clarsimp simp: lepoll_def inj_on_def) + apply (rule_tac x="\x. if x then a else b" in exI, auto) + done + qed + show ?thesis + by (auto simp: * J_def intro: lepoll_PiE) + qed + also have "\ \ Pi\<^sub>E I S" + using False by (auto simp: J_def intro: card_le_PiE_subindex) + finally have "(UNIV::nat set) \ Pi\<^sub>E I S" . + then show ?thesis + by (simp add: infinite_le_lepoll) + qed + moreover have "finite (S i)" if "i \ I" for i + proof (rule finite_subset) + obtain f where f: "f \ PiE I S" + using False by blast + show "S i \ (\f. f i) ` Pi\<^sub>E I S" + proof + show "s \ (\f. f i) ` Pi\<^sub>E I S" if "s \ S i" for s + using that f \i \ I\ + by (rule_tac x="\j. if j = i then s else f j" in image_eqI) auto + qed + next + show "finite ((\x. x i) ` Pi\<^sub>E I S)" + using L by blast + qed + ultimately show ?rhs + using L + by (auto simp: J_def False) + next + assume R: ?rhs + have "\i \ I - J. \a. S i = {a}" + using False J_def by blast + then obtain a where a: "\i \ I - J. S i = {a i}" + by metis + let ?F = "{f. f ` J \ (\i \ J. S i) \ {i. f i \ (if i \ I then a i else undefined)} \ J}" + have *: "finite (Pi\<^sub>E I S)" + if "finite J" and "\i\I. finite (S i)" + proof (rule finite_subset) + show "Pi\<^sub>E I S \ ?F" + apply safe + using J_def apply blast + by (metis DiffI PiE_E a singletonD) + show "finite ?F" + proof (rule finite_restricted_funspace [OF \finite J\]) + show "finite (\ (S ` J))" + using that J_def by blast + qed + qed + show ?lhs + using R by (auto simp: * J_def) + qed +qed auto + + +corollary finite_funcset_iff: + "finite(I \\<^sub>E S) \ (\a. S \ {a}) \ I = {} \ finite I \ finite S" + apply (auto simp: finite_PiE_iff PiE_eq_empty_iff dest: not_finite_existsD) + using finite.simps by auto + +end diff -r 6d158fd15b85 -r 8230dca028eb src/HOL/Library/Library.thy --- a/src/HOL/Library/Library.thy Thu Jan 24 10:04:32 2019 +0100 +++ b/src/HOL/Library/Library.thy Thu Jan 24 14:44:52 2019 +0000 @@ -23,6 +23,7 @@ Discrete Disjoint_Sets Dlist + Equipollence Extended Extended_Nat Extended_Nonnegative_Real