(* Edited by Jon Barwise, Handbook of mathematical logic, part B. Set Theory *) (* Стараемся использовать только auto и metis. Иногда приходится также "..", "step", "rule" и последовательное применение нескольких методов, скажем, step, insert и auto *) theory zfc_in_hol imports Metis (* HOL содержит THE и undefined, но не содержит Hilbert choice *) begin no_notation Set.union ("op \") and Set.union (infixl "\" 65) no_notation Set.subset ("op \") and Set.subset ("(_/ \ _)" [51, 51] 50) and Set.subset_eq ("op \") and Set.subset_eq ("(_/ \ _)" [51, 51] 50) no_translations "{x, xs}" \ "CONST insert x {xs}" "{x}" \ "CONST insert x {}" no_syntax "_Finset" :: "args \ 'a set" ("{(_)}") no_translations "\x\A. P" \ "CONST Ball A (\x. P)" "\x\A. P" \ "CONST Bex A (\x. P)" "\!x\A. P" \ "\!x. x \ A \ P" "LEAST x:A. P" \ "LEAST x. x \ A \ P" no_notation Set.not_member ("op \") and Set.not_member ("(_/ \ _)" [51, 51] 50) no_notation Set.member ("op \") and Set.member ("(_/ \ _)" [51, 51] 50) no_notation Groups.zero_class.zero ("0") typedecl set axiomatization elem :: "set \ set \ bool" (infixl "\" 50) abbreviation not_elem :: "set \ set \ bool" (infixl "\" 50) where "(x \ y) \ \ (x \ y)" abbreviation bounded_all :: "set \ (set \ bool) \ bool" where "bounded_all A P \ (\ x. x \ A \ P x)" abbreviation bounded_ex :: "set \ (set \ bool) \ bool" where "bounded_ex A P \ (\ x. x \ A \ P x)" syntax "_Ball" :: "[pttrn, set, bool] \ bool" "_Bex" :: "[pttrn, set, bool] \ bool" translations "\x\A. P" \ "CONST bounded_all A (\x. P)" "\x\A. P" \ "CONST bounded_ex A (\x. P)" (* B.1 Axioms of Set Theory *) (* 3. The axioms *) (* Аксиомы, которые будем потом употреблять непосредственно, называем коротко. Если же будем использовать более удобные следствия, называем длинно *) axiomatization where ext: "(\ z. z \ x \ z \ y) \ x = y" and separation_axiom: "(\ x. \ x \ x \ y) \ (\ z. \ t. t \ z \ \ t)" and union_axiom: "\ t. \ z. z \ t \ (\ y \ x. z \ y)" definition subset :: "set \ set \ bool" (infixl "\" 50) where subset_def: "x \ y \ (\ z \ x. z \ y)" axiomatization where power_set_axiom: "\ z. \ y. y \ z \ y \ x" and replacement_axiom: "\ t. \ z. z \ t \ (\ y \ x. z = F y)" and infinity_axiom: "\ x. (\ y \ x. \ z. z \ y) \ (\ y \ x. \ z \ x. \ w. w \ z \ (w \ y \ w = y))" and regularity_axiom: "y \ x \ (\ y \ x. \ z \ y. z \ x)" (* Все аксиомы, кроме аксиомы выбора, введены. Больше никаких axiomatization, кроме аксиомы выбора *) (* 4. Development of set theory *) lemma ext_iff: "x = y \ (\ z. z \ x \ z \ y)" using ext by auto lemma the_set: assumes "\ y. y \ x \ P y" shows "(THE z. \ y. y \ z \ P y) = x" by (step, insert assms ext, auto) definition all :: "set \ (set \ bool) \ set" where all_def: "all A P = (THE x. \ y. y \ x \ (y \ A \ P y))" syntax "_Collect" :: "[pttrn, set, bool] \ set" translations "{x\A. P}" \ "CONST all A (\ x. P)" lemma all_prop: "y \ all A P \ (y \ A \ P y)" proof - define \ where phi_def: "\ y = (y \ A \ P y)" for y hence "\ y. \ y \ y \ A" by auto hence "\ x. \ y. y \ x \ \ y" using separation_axiom by auto then obtain x where "\ y. y \ x \ \ y" by auto hence 1: "\ y. y \ x \ (y \ A \ P y)" using phi_def by auto thus ?thesis using the_set and all_def by auto qed lemma all_subset: "all A P \ A" unfolding subset_def and all_prop by auto definition empty :: set ("0") where empty_def: "0 = {x \ undefined. False}" lemma empty_prop: "x \ 0" unfolding empty_def using all_prop by auto lemma empty_false: "x \ 0 \ False" using empty_prop by auto lemma empty_iff: "x = 0 \ (\ y. y \ x)" proof assume "x = 0" thus "\ y. y \ x" using empty_prop by auto next assume "\ y. y \ x" thus "x = 0" using ext empty_prop by auto qed lemma reg: assumes "x \ 0" shows "\ y \ x. \ z \ y. z \ x" using empty_iff and regularity_axiom and assms by auto definition powerset :: "set \ set" where powerset_def: "powerset x = (THE y. \ z. z \ y \ z \ x)" lemma powerset_prop: "z \ powerset x \ z \ x" proof - obtain y where "\ z. z \ y \ z \ x" using power_set_axiom by auto thus ?thesis unfolding powerset_def using the_set by auto qed lemma empty_in_powerset: "0 \ powerset x" unfolding powerset_prop and subset_def using empty_prop by auto lemma x_in_powerset: "x \ powerset x" unfolding powerset_prop and subset_def by auto definition replace :: "(set \ set) \ set \ set" where "replace F x = (THE t. \ z. z \ t \ (\ y \ x. z = F y))" lemma replace_prop: "z \ replace F x \ (\ y \ x. z = F y)" proof - obtain t where "\ z. z \ t \ (\ y \ x. z = F y)" using replacement_axiom .. thus ?thesis unfolding replace_def using the_set by auto qed lemma in_replace: assumes "y \ x" shows "F y \ replace F x" unfolding replace_prop using assms by auto definition two :: "set \ set \ set" where two_def: "two x y = (THE z. \ t. t \ z \ (t = x \ t = y))" lemma two_prop: "t \ two x y \ (t = x \ t = y)" proof - define z where "z = replace (% w. if w = 0 then x else y) (powerset (powerset 0))" have "0 \ powerset (powerset 0)" using empty_in_powerset by auto hence "(% w. if w = 0 then x else y) 0 \ z" unfolding z_def by (rule in_replace) hence 1: "x \ z" by auto have "powerset 0 \ powerset (powerset 0)" using x_in_powerset by auto hence "(% w. if w = 0 then x else y) (powerset 0) \ z" unfolding z_def using in_replace by metis moreover have "0 \ powerset 0" using empty_in_powerset by auto hence "powerset 0 \ 0" using empty_prop by metis ultimately have 2: "y \ z" by auto have "\ t. t \ z \ (t = x \ t = y)" unfolding z_def and replace_prop by auto hence "\ t. t \ z \ (t = x \ t = y)" using 1 and 2 by auto thus ?thesis unfolding two_def using the_set by auto qed definition union_all :: "set \ set" where union_all_def: "union_all x = (THE t. \ z. z \ t \ (\ y \ x. z \ y))" lemma union_all_prop: "z \ union_all x \ (\ y \ x. z \ y)" proof - obtain t where "\ z. z \ t \ (\ y \ x. z \ y)" using union_axiom .. thus ?thesis unfolding union_all_def using the_set by auto qed definition union :: "set \ set \ set" (infixl "\" 65) where union_def: "x \ y = union_all (two x y)" lemma union_prop: "z \ x \ y \ (z \ x \ z \ y)" unfolding union_def using union_all_prop and two_prop by auto definition cons :: "set \ set \ set" where "cons x y = two x x \ y" lemma cons_prop: "z \ cons x y \ z = x \ z \ y" unfolding cons_def and two_prop and union_prop by auto nonterminal "is" syntax "" :: "set \ is" ("_") "_Enum" :: "[set, is] \ is" ("_,/ _") "_Finset" :: "is \ set" ("{(_)}") translations "{x, xs}" == "CONST cons x {xs}" "{x}" == "CONST cons x 0" lemma x_cons_x: "cons x (cons x y) = cons x y" by (rule ext, unfold cons_prop, auto) lemma x_eq_y: assumes "{x} = {y}" shows "x = y" using assms [unfolded ext_iff, unfolded cons_prop, unfolded empty_false] by auto lemma x_cons_y_eq_z: assumes "{x, y} = {z}" shows "x = z" and "y = z" using assms [unfolded ext_iff, unfolded cons_prop, unfolded empty_false] by auto definition pair :: "set \ set \ set" where "pair x y = {{x}, {x, y}}" lemma pair_lemma: assumes "pair x x = pair z t" shows "x = z" and "x = t" proof - have "pair x x = {{x}}" unfolding pair_def and x_cons_x by auto hence "{{x}} = {{z}, {z, t}}" unfolding assms unfolding pair_def by auto hence "{z, t} = {x}" using x_cons_y_eq_z by metis thus "x = z" and "x = t" using x_cons_y_eq_z by metis+ qed lemma two_lemma: assumes "{x, y} = {z, t}" shows "(x = z \ y = t) \ (x = t \ y = z)" using assms [unfolded ext_iff, unfolded cons_prop empty_false] by metis lemma pair_prop: "pair x y = pair z t \ (x = z \ y = t)" proof assume 1: "pair x y = pair z t" hence "z = t \ (x = z \ y = t)" using pair_lemma by metis moreover { have "{x} = {z} \ {x, y} = {z, t} \ {x} = {z, t} \ {x, y} = {z}" using 1 and two_lemma and pair_def by auto moreover assume "z \ t" hence "{x} \ {z, t}" using x_cons_y_eq_z by metis ultimately have 2: "{x} = {z} \ {x, y} = {z, t}" by auto hence "x = z" using x_eq_y by auto hence "x = z \ y = t" using 2 and two_lemma by auto } ultimately show "x = z \ y = t" by auto qed auto definition sc_def: "Sc x = x \ {x}" (* 5. Ordinals *) definition transitive :: "set \ bool" where transitive_def: "transitive x \ (\ y \ x. y \ x)" definition ordinal :: "set \ bool" where ordinal_def: "ordinal x \ transitive x \ (\ y \ x. transitive y)" lemma zero_ordinal: "ordinal 0" unfolding ordinal_def and transitive_def and subset_def using empty_prop by auto lemma next_ordinal: assumes "ordinal x" shows "ordinal (Sc x)" proof (unfold ordinal_def, step) have "transitive x" using assms unfolding ordinal_def by auto thus "transitive (Sc x)" unfolding transitive_def and sc_def and subset_def and union_prop and cons_prop using empty_prop by auto next fix y assume "y \ Sc x" hence "y = x \ y \ x" unfolding sc_def and union_prop and cons_prop using empty_prop by auto thus "transitive y" proof assume "y = x" thus "transitive y" using `ordinal x` unfolding ordinal_def by auto next assume "y \ x" thus "transitive y" using `ordinal x` unfolding ordinal_def by auto qed qed lemma ordinal_elem_is_ordinal: assumes "ordinal x" and "y \ x" shows "ordinal y" proof (unfold ordinal_def, step) show "transitive y" using assms unfolding ordinal_def by auto fix z assume "z \ y" show "transitive z" proof (unfold transitive_def, step) fix t assume "t \ z" moreover have "z \ x" using `ordinal x` unfolding ordinal_def and transitive_def and subset_def using `z \ y` and `y \ x` by metis hence "transitive z" using `ordinal x` unfolding ordinal_def by auto ultimately show "t \ z" unfolding transitive_def by auto qed qed lemma x_not_in_x: "x \ x" proof - have "x \ {x}" using cons_prop by auto hence "{x} \ 0" using empty_prop by auto then obtain y where y_def: "y \ {x} \ (\ z \ y. z \ {x})" using reg by auto hence "y = x" unfolding cons_prop using empty_prop by auto hence "\ z \ x. z \ {x}" using y_def by auto hence "\ z \ x. z \ x" unfolding cons_prop by auto thus "x \ x" by auto qed lemma ordinals_transitive: assumes "a \ b" assumes "b \ c" assumes "ordinal c" shows "a \ c" using assms unfolding ordinal_def and transitive_def and subset_def by metis (* 5.3. Theorem *) (* Это трансфинитная индукция для всего класса ординалов целиком. Но тем не менее мы пока не доказали, что для любого множества есть биективный ему ординал, т. е. пока возможно, что все ординалы "маленькие", просто для этих "маленьких" ординалов мы что-то умеем доказывать по индукции *) theorem th5_3: assumes "\ a. ordinal a \ ((\ b \ a. \ b) \ \ a)" assumes "ordinal a0" shows "\ a0" proof (rule ccontr) assume "\ \ a0" define x where "x = {c \ a0. \ \ c}" { assume "x = 0" hence "\ c. c \ x" using empty_prop by auto hence "\ c \ a0. \ c" unfolding x_def and all_prop by auto hence "\ a0" using assms by auto hence False using `\ \ a0` by auto } then obtain a where a_def: "a \ x \ (\ z \ a. z \ x)" using reg by auto { fix b assume "b \ a" moreover have "x \ a0" using x_def and all_subset by auto hence "a \ a0" using a_def and subset_def by auto ultimately have "b \ a0" using ordinals_transitive and assms by blast moreover have "b \ x" using `b \ a` and a_def by auto ultimately have "\ b" unfolding x_def unfolding all_prop by auto } moreover have "ordinal a" using a_def unfolding x_def unfolding all_prop using `ordinal a0` and ordinal_elem_is_ordinal by auto ultimately have "\ a" using assms by auto thus False using a_def unfolding x_def and all_prop by auto qed