1 (* Title: ZF/Cardinal.thy |
1 (* Title: ZF/Cardinal.thy |
2 Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
2 Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
3 Copyright 1994 University of Cambridge |
3 Copyright 1994 University of Cambridge |
4 *) |
4 *) |
5 |
5 |
6 section{*Cardinal Numbers Without the Axiom of Choice*} |
6 section\<open>Cardinal Numbers Without the Axiom of Choice\<close> |
7 |
7 |
8 theory Cardinal imports OrderType Finite Nat_ZF Sum begin |
8 theory Cardinal imports OrderType Finite Nat_ZF Sum begin |
9 |
9 |
10 definition |
10 definition |
11 (*least ordinal operator*) |
11 (*least ordinal operator*) |
45 notation (HTML) |
45 notation (HTML) |
46 eqpoll (infixl "\<approx>" 50) and |
46 eqpoll (infixl "\<approx>" 50) and |
47 Least (binder "\<mu>" 10) |
47 Least (binder "\<mu>" 10) |
48 |
48 |
49 |
49 |
50 subsection{*The Schroeder-Bernstein Theorem*} |
50 subsection\<open>The Schroeder-Bernstein Theorem\<close> |
51 text{*See Davey and Priestly, page 106*} |
51 text\<open>See Davey and Priestly, page 106\<close> |
52 |
52 |
53 (** Lemma: Banach's Decomposition Theorem **) |
53 (** Lemma: Banach's Decomposition Theorem **) |
54 |
54 |
55 lemma decomp_bnd_mono: "bnd_mono(X, %W. X - g``(Y - f``W))" |
55 lemma decomp_bnd_mono: "bnd_mono(X, %W. X - g``(Y - f``W))" |
56 by (rule bnd_monoI, blast+) |
56 by (rule bnd_monoI, blast+) |
176 apply (unfold eqpoll_def) |
176 apply (unfold eqpoll_def) |
177 apply (blast intro: bij_disjoint_Un) |
177 apply (blast intro: bij_disjoint_Un) |
178 done |
178 done |
179 |
179 |
180 |
180 |
181 subsection{*lesspoll: contributions by Krzysztof Grabczewski *} |
181 subsection\<open>lesspoll: contributions by Krzysztof Grabczewski\<close> |
182 |
182 |
183 lemma lesspoll_not_refl: "~ (i \<prec> i)" |
183 lemma lesspoll_not_refl: "~ (i \<prec> i)" |
184 by (simp add: lesspoll_def) |
184 by (simp add: lesspoll_def) |
185 |
185 |
186 lemma lesspoll_irrefl [elim!]: "i \<prec> i ==> P" |
186 lemma lesspoll_irrefl [elim!]: "i \<prec> i ==> P" |
274 qed |
274 qed |
275 } |
275 } |
276 thus ?thesis using P . |
276 thus ?thesis using P . |
277 qed |
277 qed |
278 |
278 |
279 text{*The proof is almost identical to the one above!*} |
279 text\<open>The proof is almost identical to the one above!\<close> |
280 lemma Least_le: |
280 lemma Least_le: |
281 assumes P: "P(i)" and i: "Ord(i)" shows "(\<mu> x. P(x)) \<le> i" |
281 assumes P: "P(i)" and i: "Ord(i)" shows "(\<mu> x. P(x)) \<le> i" |
282 proof - |
282 proof - |
283 { from i have "P(i) \<Longrightarrow> (\<mu> x. P(x)) \<le> i" |
283 { from i have "P(i) \<Longrightarrow> (\<mu> x. P(x)) \<le> i" |
284 proof (induct i rule: trans_induct) |
284 proof (induct i rule: trans_induct) |
408 lemma Ord_cardinal [simp,intro!]: "Ord(|A|)" |
408 lemma Ord_cardinal [simp,intro!]: "Ord(|A|)" |
409 apply (unfold cardinal_def) |
409 apply (unfold cardinal_def) |
410 apply (rule Ord_Least) |
410 apply (rule Ord_Least) |
411 done |
411 done |
412 |
412 |
413 text{*The cardinals are the initial ordinals.*} |
413 text\<open>The cardinals are the initial ordinals.\<close> |
414 lemma Card_iff_initial: "Card(K) \<longleftrightarrow> Ord(K) & (\<forall>j. j<K \<longrightarrow> ~ j \<approx> K)" |
414 lemma Card_iff_initial: "Card(K) \<longleftrightarrow> Ord(K) & (\<forall>j. j<K \<longrightarrow> ~ j \<approx> K)" |
415 proof - |
415 proof - |
416 { fix j |
416 { fix j |
417 assume K: "Card(K)" "j \<approx> K" |
417 assume K: "Card(K)" "j \<approx> K" |
418 assume "j < K" |
418 assume "j < K" |
447 |
447 |
448 lemma Card_cardinal [iff]: "Card(|A|)" |
448 lemma Card_cardinal [iff]: "Card(|A|)" |
449 proof (unfold cardinal_def) |
449 proof (unfold cardinal_def) |
450 show "Card(\<mu> i. i \<approx> A)" |
450 show "Card(\<mu> i. i \<approx> A)" |
451 proof (cases "\<exists>i. Ord (i) & i \<approx> A") |
451 proof (cases "\<exists>i. Ord (i) & i \<approx> A") |
452 case False thus ?thesis --{*degenerate case*} |
452 case False thus ?thesis --\<open>degenerate case\<close> |
453 by (simp add: Least_0 Card_0) |
453 by (simp add: Least_0 Card_0) |
454 next |
454 next |
455 case True --{*real case: @{term A} is isomorphic to some ordinal*} |
455 case True --\<open>real case: @{term A} is isomorphic to some ordinal\<close> |
456 then obtain i where i: "Ord(i)" "i \<approx> A" by blast |
456 then obtain i where i: "Ord(i)" "i \<approx> A" by blast |
457 show ?thesis |
457 show ?thesis |
458 proof (rule CardI [OF Ord_Least], rule notI) |
458 proof (rule CardI [OF Ord_Least], rule notI) |
459 fix j |
459 fix j |
460 assume j: "j < (\<mu> i. i \<approx> A)" |
460 assume j: "j < (\<mu> i. i \<approx> A)" |
498 by (rule cardinal_eq_lemma [OF ge ci]) |
498 by (rule cardinal_eq_lemma [OF ge ci]) |
499 finally have "|i| = |j|" . |
499 finally have "|i| = |j|" . |
500 thus ?thesis by simp |
500 thus ?thesis by simp |
501 qed |
501 qed |
502 |
502 |
503 text{*Since we have @{term"|succ(nat)| \<le> |nat|"}, the converse of @{text cardinal_mono} fails!*} |
503 text\<open>Since we have @{term"|succ(nat)| \<le> |nat|"}, the converse of @{text cardinal_mono} fails!\<close> |
504 lemma cardinal_lt_imp_lt: "[| |i| < |j|; Ord(i); Ord(j) |] ==> i < j" |
504 lemma cardinal_lt_imp_lt: "[| |i| < |j|; Ord(i); Ord(j) |] ==> i < j" |
505 apply (rule Ord_linear2 [of i j], assumption+) |
505 apply (rule Ord_linear2 [of i j], assumption+) |
506 apply (erule lt_trans2 [THEN lt_irrefl]) |
506 apply (erule lt_trans2 [THEN lt_irrefl]) |
507 apply (erule cardinal_mono) |
507 apply (erule cardinal_mono) |
508 done |
508 done |
554 apply (drule subset_imp_lepoll [THEN lepoll_cardinal_le]) |
554 apply (drule subset_imp_lepoll [THEN lepoll_cardinal_le]) |
555 apply (auto simp add: lt_def) |
555 apply (auto simp add: lt_def) |
556 apply (blast intro: Ord_trans) |
556 apply (blast intro: Ord_trans) |
557 done |
557 done |
558 |
558 |
559 subsection{*The finite cardinals *} |
559 subsection\<open>The finite cardinals\<close> |
560 |
560 |
561 lemma cons_lepoll_consD: |
561 lemma cons_lepoll_consD: |
562 "[| cons(u,A) \<lesssim> cons(v,B); u\<notin>A; v\<notin>B |] ==> A \<lesssim> B" |
562 "[| cons(u,A) \<lesssim> cons(v,B); u\<notin>A; v\<notin>B |] ==> A \<lesssim> B" |
563 apply (unfold lepoll_def inj_def, safe) |
563 apply (unfold lepoll_def inj_def, safe) |
564 apply (rule_tac x = "\<lambda>x\<in>A. if f`x=v then f`u else f`x" in exI) |
564 apply (rule_tac x = "\<lambda>x\<in>A. if f`x=v then f`u else f`x" in exI) |
589 "m \<in> nat ==> n \<in> nat \<Longrightarrow> m \<lesssim> n \<Longrightarrow> m \<le> n" |
589 "m \<in> nat ==> n \<in> nat \<Longrightarrow> m \<lesssim> n \<Longrightarrow> m \<le> n" |
590 proof (induct m arbitrary: n rule: nat_induct) |
590 proof (induct m arbitrary: n rule: nat_induct) |
591 case 0 thus ?case by (blast intro!: nat_0_le) |
591 case 0 thus ?case by (blast intro!: nat_0_le) |
592 next |
592 next |
593 case (succ m) |
593 case (succ m) |
594 show ?case using `n \<in> nat` |
594 show ?case using \<open>n \<in> nat\<close> |
595 proof (cases rule: natE) |
595 proof (cases rule: natE) |
596 case 0 thus ?thesis using succ |
596 case 0 thus ?thesis using succ |
597 by (simp add: lepoll_def inj_def) |
597 by (simp add: lepoll_def inj_def) |
598 next |
598 next |
599 case (succ n') thus ?thesis using succ.hyps ` succ(m) \<lesssim> n` |
599 case (succ n') thus ?thesis using succ.hyps \<open> succ(m) \<lesssim> n\<close> |
600 by (blast intro!: succ_leI dest!: succ_lepoll_succD) |
600 by (blast intro!: succ_leI dest!: succ_lepoll_succD) |
601 qed |
601 qed |
602 qed |
602 qed |
603 |
603 |
604 lemma nat_eqpoll_iff: "[| m \<in> nat; n \<in> nat |] ==> m \<approx> n \<longleftrightarrow> m = n" |
604 lemma nat_eqpoll_iff: "[| m \<in> nat; n \<in> nat |] ==> m \<approx> n \<longleftrightarrow> m = n" |
680 apply (blast intro: well_ord_Memrel well_ord_cardinal_eqpoll [THEN eqpoll_sym] |
680 apply (blast intro: well_ord_Memrel well_ord_cardinal_eqpoll [THEN eqpoll_sym] |
681 dest: lepoll_well_ord elim!: leE) |
681 dest: lepoll_well_ord elim!: leE) |
682 done |
682 done |
683 |
683 |
684 |
684 |
685 subsection{*The first infinite cardinal: Omega, or nat *} |
685 subsection\<open>The first infinite cardinal: Omega, or nat\<close> |
686 |
686 |
687 (*This implies Kunen's Lemma 10.6*) |
687 (*This implies Kunen's Lemma 10.6*) |
688 lemma lt_not_lepoll: |
688 lemma lt_not_lepoll: |
689 assumes n: "n<i" "n \<in> nat" shows "~ i \<lesssim> n" |
689 assumes n: "n<i" "n \<in> nat" shows "~ i \<lesssim> n" |
690 proof - |
690 proof - |
695 finally have "succ(n) \<lesssim> n" . |
695 finally have "succ(n) \<lesssim> n" . |
696 hence False by (rule succ_lepoll_natE) (rule n) } |
696 hence False by (rule succ_lepoll_natE) (rule n) } |
697 thus ?thesis by auto |
697 thus ?thesis by auto |
698 qed |
698 qed |
699 |
699 |
700 text{*A slightly weaker version of @{text nat_eqpoll_iff}*} |
700 text\<open>A slightly weaker version of @{text nat_eqpoll_iff}\<close> |
701 lemma Ord_nat_eqpoll_iff: |
701 lemma Ord_nat_eqpoll_iff: |
702 assumes i: "Ord(i)" and n: "n \<in> nat" shows "i \<approx> n \<longleftrightarrow> i=n" |
702 assumes i: "Ord(i)" and n: "n \<in> nat" shows "i \<approx> n \<longleftrightarrow> i=n" |
703 using i nat_into_Ord [OF n] |
703 using i nat_into_Ord [OF n] |
704 proof (cases rule: Ord_linear_lt) |
704 proof (cases rule: Ord_linear_lt) |
705 case lt |
705 case lt |
710 thus ?thesis by (simp add: eqpoll_refl) |
710 thus ?thesis by (simp add: eqpoll_refl) |
711 next |
711 next |
712 case gt |
712 case gt |
713 hence "~ i \<lesssim> n" using n by (rule lt_not_lepoll) |
713 hence "~ i \<lesssim> n" using n by (rule lt_not_lepoll) |
714 hence "~ i \<approx> n" using n by (blast intro: eqpoll_imp_lepoll) |
714 hence "~ i \<approx> n" using n by (blast intro: eqpoll_imp_lepoll) |
715 moreover have "i \<noteq> n" using `n<i` by auto |
715 moreover have "i \<noteq> n" using \<open>n<i\<close> by auto |
716 ultimately show ?thesis by blast |
716 ultimately show ?thesis by blast |
717 qed |
717 qed |
718 |
718 |
719 lemma Card_nat: "Card(nat)" |
719 lemma Card_nat: "Card(nat)" |
720 proof - |
720 proof - |
738 |
738 |
739 lemma n_lesspoll_nat: "n \<in> nat ==> n \<prec> nat" |
739 lemma n_lesspoll_nat: "n \<in> nat ==> n \<prec> nat" |
740 by (blast intro: Ord_nat Card_nat ltI lt_Card_imp_lesspoll) |
740 by (blast intro: Ord_nat Card_nat ltI lt_Card_imp_lesspoll) |
741 |
741 |
742 |
742 |
743 subsection{*Towards Cardinal Arithmetic *} |
743 subsection\<open>Towards Cardinal Arithmetic\<close> |
744 (** Congruence laws for successor, cardinal addition and multiplication **) |
744 (** Congruence laws for successor, cardinal addition and multiplication **) |
745 |
745 |
746 (*Congruence law for cons under equipollence*) |
746 (*Congruence law for cons under equipollence*) |
747 lemma cons_lepoll_cong: |
747 lemma cons_lepoll_cong: |
748 "[| A \<lesssim> B; b \<notin> B |] ==> cons(a,A) \<lesssim> cons(b,B)" |
748 "[| A \<lesssim> B; b \<notin> B |] ==> cons(a,A) \<lesssim> cons(b,B)" |
815 apply (simp_all add: inj_is_fun [THEN apply_rangeI]) |
815 apply (simp_all add: inj_is_fun [THEN apply_rangeI]) |
816 apply (blast intro: inj_converse_fun [THEN apply_type])+ |
816 apply (blast intro: inj_converse_fun [THEN apply_type])+ |
817 done |
817 done |
818 |
818 |
819 |
819 |
820 subsection{*Lemmas by Krzysztof Grabczewski*} |
820 subsection\<open>Lemmas by Krzysztof Grabczewski\<close> |
821 |
821 |
822 (*New proofs using cons_lepoll_cons. Could generalise from succ to cons.*) |
822 (*New proofs using cons_lepoll_cons. Could generalise from succ to cons.*) |
823 |
823 |
824 text{*If @{term A} has at most @{term"n+1"} elements and @{term"a \<in> A"} |
824 text\<open>If @{term A} has at most @{term"n+1"} elements and @{term"a \<in> A"} |
825 then @{term"A-{a}"} has at most @{term n}.*} |
825 then @{term"A-{a}"} has at most @{term n}.\<close> |
826 lemma Diff_sing_lepoll: |
826 lemma Diff_sing_lepoll: |
827 "[| a \<in> A; A \<lesssim> succ(n) |] ==> A - {a} \<lesssim> n" |
827 "[| a \<in> A; A \<lesssim> succ(n) |] ==> A - {a} \<lesssim> n" |
828 apply (unfold succ_def) |
828 apply (unfold succ_def) |
829 apply (rule cons_lepoll_consD) |
829 apply (rule cons_lepoll_consD) |
830 apply (rule_tac [3] mem_not_refl) |
830 apply (rule_tac [3] mem_not_refl) |
831 apply (erule cons_Diff [THEN ssubst], safe) |
831 apply (erule cons_Diff [THEN ssubst], safe) |
832 done |
832 done |
833 |
833 |
834 text{*If @{term A} has at least @{term"n+1"} elements then @{term"A-{a}"} has at least @{term n}.*} |
834 text\<open>If @{term A} has at least @{term"n+1"} elements then @{term"A-{a}"} has at least @{term n}.\<close> |
835 lemma lepoll_Diff_sing: |
835 lemma lepoll_Diff_sing: |
836 assumes A: "succ(n) \<lesssim> A" shows "n \<lesssim> A - {a}" |
836 assumes A: "succ(n) \<lesssim> A" shows "n \<lesssim> A - {a}" |
837 proof - |
837 proof - |
838 have "cons(n,n) \<lesssim> A" using A |
838 have "cons(n,n) \<lesssim> A" using A |
839 by (unfold succ_def) |
839 by (unfold succ_def) |
875 apply (rule_tac d = "%z. case (%x. x, %x. x, z)" in lam_bijective) |
875 apply (rule_tac d = "%z. case (%x. x, %x. x, z)" in lam_bijective) |
876 apply auto |
876 apply auto |
877 done |
877 done |
878 |
878 |
879 |
879 |
880 subsection {*Finite and infinite sets*} |
880 subsection \<open>Finite and infinite sets\<close> |
881 |
881 |
882 lemma eqpoll_imp_Finite_iff: "A \<approx> B ==> Finite(A) \<longleftrightarrow> Finite(B)" |
882 lemma eqpoll_imp_Finite_iff: "A \<approx> B ==> Finite(A) \<longleftrightarrow> Finite(B)" |
883 apply (unfold Finite_def) |
883 apply (unfold Finite_def) |
884 apply (blast intro: eqpoll_trans eqpoll_sym) |
884 apply (blast intro: eqpoll_trans eqpoll_sym) |
885 done |
885 done |
1025 Un_upper2 [THEN Fin_mono, THEN subsetD]) |
1025 Un_upper2 [THEN Fin_mono, THEN subsetD]) |
1026 |
1026 |
1027 lemma Finite_Un_iff [simp]: "Finite(A \<union> B) \<longleftrightarrow> (Finite(A) & Finite(B))" |
1027 lemma Finite_Un_iff [simp]: "Finite(A \<union> B) \<longleftrightarrow> (Finite(A) & Finite(B))" |
1028 by (blast intro: subset_Finite Finite_Un) |
1028 by (blast intro: subset_Finite Finite_Un) |
1029 |
1029 |
1030 text{*The converse must hold too.*} |
1030 text\<open>The converse must hold too.\<close> |
1031 lemma Finite_Union: "[| \<forall>y\<in>X. Finite(y); Finite(X) |] ==> Finite(\<Union>(X))" |
1031 lemma Finite_Union: "[| \<forall>y\<in>X. Finite(y); Finite(X) |] ==> Finite(\<Union>(X))" |
1032 apply (simp add: Finite_Fin_iff) |
1032 apply (simp add: Finite_Fin_iff) |
1033 apply (rule Fin_UnionI) |
1033 apply (rule Fin_UnionI) |
1034 apply (erule Fin_induct, simp) |
1034 apply (erule Fin_induct, simp) |
1035 apply (blast intro: Fin.consI Fin_mono [THEN [2] rev_subsetD]) |
1035 apply (blast intro: Fin.consI Fin_mono [THEN [2] rev_subsetD]) |
1083 apply (rule equalityI) |
1083 apply (rule equalityI) |
1084 apply (blast intro: elim: equalityE) |
1084 apply (blast intro: elim: equalityE) |
1085 apply (blast intro: elim: equalityCE) |
1085 apply (blast intro: elim: equalityCE) |
1086 done |
1086 done |
1087 |
1087 |
1088 text{*I don't know why, but if the premise is expressed using meta-connectives |
1088 text\<open>I don't know why, but if the premise is expressed using meta-connectives |
1089 then the simplifier cannot prove it automatically in conditional rewriting.*} |
1089 then the simplifier cannot prove it automatically in conditional rewriting.\<close> |
1090 lemma Finite_RepFun_iff: |
1090 lemma Finite_RepFun_iff: |
1091 "(\<forall>x y. f(x)=f(y) \<longrightarrow> x=y) ==> Finite(RepFun(A,f)) \<longleftrightarrow> Finite(A)" |
1091 "(\<forall>x y. f(x)=f(y) \<longrightarrow> x=y) ==> Finite(RepFun(A,f)) \<longleftrightarrow> Finite(A)" |
1092 by (blast intro: Finite_RepFun Finite_RepFun_iff_lemma [of _ f]) |
1092 by (blast intro: Finite_RepFun Finite_RepFun_iff_lemma [of _ f]) |
1093 |
1093 |
1094 lemma Finite_Pow: "Finite(A) ==> Finite(Pow(A))" |
1094 lemma Finite_Pow: "Finite(A) ==> Finite(Pow(A))" |
1117 proof (induct n rule: nat_induct) |
1117 proof (induct n rule: nat_induct) |
1118 case 0 thus ?case by (blast intro: wf_onI) |
1118 case 0 thus ?case by (blast intro: wf_onI) |
1119 next |
1119 next |
1120 case (succ x) |
1120 case (succ x) |
1121 hence wfx: "\<And>Z. Z = 0 \<or> (\<exists>z\<in>Z. \<forall>y. z \<in> y \<and> z \<in> x \<and> y \<in> x \<and> z \<in> x \<longrightarrow> y \<notin> Z)" |
1121 hence wfx: "\<And>Z. Z = 0 \<or> (\<exists>z\<in>Z. \<forall>y. z \<in> y \<and> z \<in> x \<and> y \<in> x \<and> z \<in> x \<longrightarrow> y \<notin> Z)" |
1122 by (simp add: wf_on_def wf_def) --{*not easy to erase the duplicate @{term"z \<in> x"}!*} |
1122 by (simp add: wf_on_def wf_def) --\<open>not easy to erase the duplicate @{term"z \<in> x"}!\<close> |
1123 show ?case |
1123 show ?case |
1124 proof (rule wf_onI) |
1124 proof (rule wf_onI) |
1125 fix Z u |
1125 fix Z u |
1126 assume Z: "u \<in> Z" "\<forall>z\<in>Z. \<exists>y\<in>Z. \<langle>y, z\<rangle> \<in> converse(Memrel(succ(x)))" |
1126 assume Z: "u \<in> Z" "\<forall>z\<in>Z. \<exists>y\<in>Z. \<langle>y, z\<rangle> \<in> converse(Memrel(succ(x)))" |
1127 show False |
1127 show False |