Kelton OBrien, 31 May 2024 A proof that the Axiom of Choice implies Zorn's Lemma, as well as relevant definitions. \begin{code} {-# OPTIONS --safe --without-K --exact-split #-} open import MLTT.Spartan open import Ordinals.Equivalence open import Ordinals.Type open import Ordinals.Underlying open import UF.Base open import UF.Choice open import UF.ClassicalLogic open import UF.Embeddings open import UF.Equiv open import UF.EquivalenceExamples open import UF.FunExt open import UF.Logic open import UF.Powerset-MultiUniverse open import UF.PropTrunc open import UF.Size open import UF.Subsingletons open import UF.Subsingletons-FunExt open import UF.SubtypeClassifier open import UF.UA-FunExt open import UF.Univalence open import UF.UniverseEmbedding module OrderedTypes.ZornsLemma {π€ π£ : Universe} (pt : propositional-truncations-exist) (ua : Univalence) {X : π€ Μ} (_βͺ_ : X β X β π£ Μ) where open PropositionalTruncation pt open import Ordinals.BuraliForti ua open import Ordinals.OrdinalOfOrdinals ua open import UF.ImageAndSurjection pt fe : FunExt fe = Univalence-gives-FunExt ua pe : Prop-Ext pe = Univalence-gives-Prop-Ext ua pe' : PropExt pe' π€ = pe {π€} fe' : Fun-Ext fe' {π€} {π₯} = fe π€ π₯ open UF.Choice.ExcludedMiddle pt fe open UF.Choice.Univalent-Choice fe pt open UF.Choice.choice-functions pt pe' fe open UF.Logic.Existential pt open UF.Logic.Universal fe' open import OrderedTypes.Poset fe' open import Ordinals.WellOrderingTaboo fe' pe open inhabited-subsets pt open PosetAxioms open ClassicalWellOrder pt _β_ : X β X β (π€ β π£) Μ a β b = a βͺ b Γ (a β b) is-chain : {π₯ : Universe} β (Y : π {π₯} X ) β (π€ β π£ β π₯) Μ is-chain Y = (x y : X) β x β Y β y β Y β (x βͺ y β¨ y βͺ x) has-maximal-element-strong : (π€ β π£) Μ has-maximal-element-strong = Ξ£ x κ X , ((y : X) β x βͺ y β x οΌ y) has-maximal-element : (π€ β π£) Μ has-maximal-element = β x κ X , ((y : X) β x βͺ y β x οΌ y) all-chains-have-upper-bound : {π₯ : Universe} β (π€ β π£ β (π₯ βΊ)) Μ all-chains-have-upper-bound {π₯} = (Y : π {π₯} X) β (is-chain Y) β Ξ£ x κ X , (β y β y β Y β y βͺ x) \end{code} The following is a formalization ofthe standard transfinite-induction-based proof of Zorn's lemma. The closest informal analog to the proof can be found here: https://math.stackexchange.com/a/2889205. The primary differences between this proof and that proof are just ones of how sets are treated (notice the lack of a particular poset P), additional detail in things that are glossed over in the formal proof, (e.g the proof that the chain allfbs is a chain is not given). The proof idea is the same. We do a proof by contradiction (which is why we have that double negation), where we assume that even though all chains have a least upper bound, the set at hand does not have a maximal element. These assumptions allow us to construct a function `f' from the ordinals to X, which is a set, which preserves order, is therefore left-cancellable, and again in turn an equivalence. `f' being order preserving relies on the fact that there is no maximal element, as otherwise `f' would (as defined) map many ordinals to the maximal element. An equivalence between the ordinals and a set is impossible, so there must (not-not) be a maximum. While this is the core of the proof logic, the final result to be used elsewhere is found below, and takes in more reasonable inputs. \begin{code} choice-function-gives-zorns-lemma : Excluded-Middle β poset-axioms (_βͺ_) β all-chains-have-upper-bound β (Ξ£ Ξ΅ κ (π {π£ β π€} X β X) , ((A : π X) β is-inhabited A β Ξ΅ A β A)) β has-maximal-element choice-function-gives-zorns-lemma lem (X-is-set , βͺ-prop , βͺ-refl , βͺ-trans , βͺ-antisym ) chains (Ξ΅ , Ξ΅-behaviour) = (¬¬Σββ pt dn (Ξ» no-max β absurd no-max)) where dn : {π₯ : Universe } β DNE π₯ dn {π₯} = EM-gives-DNE lem eq-is-¬¬-stable : {x : X} {y : X } β ¬¬-stable (x οΌ y) eq-is-¬¬-stable {x} {y} ¬¬x=y = dn (x οΌ y) (X-is-set) ¬¬x=y βͺ-is-¬¬-stable : {x : X} {y : X} β ¬¬-stable (x βͺ y) βͺ-is-¬¬-stable {x} {y} ¬¬ll = dn (x βͺ y) (βͺ-prop x y) ¬¬ll β-prop : (a : X) β (b : X) β is-prop (a β b) β-prop a b = Γ-is-prop (βͺ-prop a b) (negations-are-props fe') βͺ-trans-β : (x y z : X) β x βͺ y β y β z β x β z βͺ-trans-β x y z xβͺy (yβͺz , yβ z) = βͺ-trans x y z xβͺy yβͺz , Ξ» x=z β yβ z ((βͺ-antisym y z) yβͺz (transport (Ξ» q β q βͺ y) x=z xβͺy)) g : (Ξ± : Ordinal π€) β ( β¨ Ξ± β© β X) β X g Ξ± s = Ξ΅ β x κ X β£ β±― a κ β¨ Ξ± β© , (( s a β x ) , β-prop (s a) x ) β f : Ordinal π€ β X f = transfinite-recursion-on-OO X g A : Ordinal π€ β π { (π€ β π£) } X A Ξ± = β x κ X β£ β±― a κ β¨ Ξ± β© , (f (Ξ± β a) β x , β-prop (f (Ξ± β a)) x ) β f-behaviour : (Ξ± : Ordinal π€) β f Ξ± οΌ Ξ΅ (A Ξ±) f-behaviour = transfinite-recursion-on-OO-behaviour X g β²-is-classical-well-order : is-classical-well-order (_β²_ {π€}) β²-is-classical-well-order = inductive-well-order-is-classical _β²_ lem β²-is-well-order β²-is-trichotomous : {a b : Ordinal π€} β (a β² b) + (a οΌ b) + (b β² a) β²-is-trichotomous {a} {b} = prβ (( prβ (prβ β²-is-classical-well-order)) a b) f-preserves-order : Β¬ has-maximal-element-strong β (Ξ± Ξ² : Ordinal π€) β Ξ² β² Ξ± β f Ξ² β f Ξ± f-preserves-order no-max = transfinite-induction-on-OO P (v no-max) where P : Ordinal π€ β (π€ βΊ β π£) Μ P Ξ± = β Ξ² β Ξ² β² Ξ± β f Ξ² β f Ξ± v : Β¬ has-maximal-element-strong β (Ξ± : Ordinal π€) β ((a : β¨ Ξ± β©) β P (Ξ± β a)) β P Ξ± v no-max Ξ± s Ξ² (a , Ξ²=Ξ±βa) = transportβ»ΒΉ (Ξ» q β f q β f Ξ±) Ξ²=Ξ±βa (transportβ»ΒΉ (Ξ» q β f (Ξ± β a) β q) (f-behaviour Ξ±) (step a)) where allfb : π X allfb = β x κ X β£ Ζ Ξ²' , ((Ξ²' β² Ξ± ) Γ (x οΌ (f Ξ²'))) β untrunc-works : (x y : X) β (Ξ£ Ξ²' κ Ordinal π€ , ((Ξ²' β² Ξ±) Γ (x οΌ f Ξ²'))) β (Ξ£ Ξ²'' κ Ordinal π€ , ((Ξ²'' β² Ξ±) Γ (y οΌ f Ξ²''))) β x βͺ y + y βͺ x untrunc-works x y (Ξ²' , ((b' , Ξ²'=Ξ±βb') , x=fΞ²')) (Ξ²'' , ((b'' , Ξ²''=Ξ±βb'') , y=fΞ²'')) = cases less (cases equal more) β²-is-trichotomous where less : Ξ²'' β² Ξ²' β (x βͺ y + y βͺ x) less b''<b' = inr (transportβ»ΒΉ (Ξ» q β y βͺ q) x=fΞ²' (transportβ»ΒΉ (Ξ» q β q βͺ f Ξ²') y=fΞ²'' (prβ (transportβ»ΒΉ (Ξ» q β f Ξ²'' β f q) Ξ²'=Ξ±βb' ((s b') Ξ²'' (transport (Ξ» q β Ξ²'' β² q) Ξ²'=Ξ±βb' b''<b')))))) equal : Ξ²'' οΌ Ξ²' β (x βͺ y + y βͺ x) equal b''=b' = inr (transport (Ξ» q β y βͺ q) (transportβ»ΒΉ (Ξ» q β y οΌ q) x=fΞ²' (transportβ»ΒΉ (Ξ» q β q οΌ f Ξ²') y=fΞ²'' (ap f b''=b'))) (βͺ-refl y)) more : Ξ²' β² Ξ²'' β (x βͺ y + y βͺ x) more b'<b'' = inl (transportβ»ΒΉ (Ξ» q β x βͺ q) y=fΞ²'' (transportβ»ΒΉ (Ξ» q β q βͺ f Ξ²'') x=fΞ²' (prβ (transportβ»ΒΉ (Ξ» q β f Ξ²' β f q) Ξ²''=Ξ±βb'' ((s b'') Ξ²' (transport (Ξ» q β Ξ²' β² q) Ξ²''=Ξ±βb'' b'<b'')))))) has-max-neg : (x : X) β ¬¬ (Ξ£ y κ X , Β¬ (x βͺ y β x οΌ y)) has-max-neg x = not-Ξ -implies-not-not-Ξ£ (Ξ» z β β-is-¬¬-stable eq-is-¬¬-stable) ((not-Ξ£-implies-Ξ -not no-max) x) allfb-is-chain : is-chain allfb allfb-is-chain x y = β₯β₯-functorβ (untrunc-works x y) allfb-has-ub : Ξ£ x κ X , (β y β y β allfb β y βͺ x) allfb-has-ub = chains allfb allfb-is-chain ub : X ub = prβ allfb-has-ub ub-is-ub : β y β y β allfb β y βͺ ub ub-is-ub = prβ allfb-has-ub ub-is-strict' : (Ξ£ q κ X , (Β¬ ( ub βͺ q β ub οΌ q))) β Ξ£ z κ X , (β y β y β allfb β y β z) ub-is-strict' (q , foo) = q , Ξ» y yin β βͺ-trans-β y ub q (ub-is-ub y yin) ((βͺ-is-¬¬-stable (prβ (negation-of-implication foo))) , (prβ (negation-of-implication foo))) ub-is-strict : β z κ X , (β y β y β allfb β y β z) ub-is-strict = (β₯β₯-functor ub-is-strict') (¬¬Σββ pt dn (has-max-neg ub)) AΞ±-inhabited' : Ξ£ x κ X , (β y β y β allfb β y β x) β Ξ£ x κ X , ((i : β¨ Ξ± β©) β f (Ξ± β i) β x) AΞ±-inhabited' (x , ylt) = x , Ξ» i β ylt (f (Ξ± β i)) β£ (Ξ± β i) , ( ( i , refl )) , refl β£ AΞ±-inhabited : β x κ X , (β y β y β allfb β y β x) β is-inhabited (A Ξ±) AΞ±-inhabited = β₯β₯-functor AΞ±-inhabited' step : (a : β¨ Ξ± β©) β (f (Ξ± β a) β Ξ΅ (A Ξ±)) step a = (Ξ΅-behaviour (A Ξ±) (AΞ±-inhabited (ub-is-strict ))) a f-is-injective : Β¬ has-maximal-element-strong β (a b : Ordinal π€) β a β b β f a β f b f-is-injective no-max a b aβ b = cases (less a b) (cases (equal a b aβ b) (more a b)) β²-is-trichotomous where less : (a b : Ordinal π€) β a β² b β f a β f b less a b a<b = prβ (f-preserves-order no-max b a a<b) more : (a b : Ordinal π€) β b β² a β f a β f b more a b b<a = β -sym (prβ (f-preserves-order no-max a b b<a)) equal : (a b : Ordinal π€) β a β b β a οΌ b β f a β f b equal a b aβ b a=b = unique-from-π (aβ b a=b) f-is-left-cancellable : {a : Ordinal π€} β {b : Ordinal π€} β Β¬ has-maximal-element-strong β f a οΌ f b β a οΌ b f-is-left-cancellable {a} {b} no-max p = dn (a οΌ b) (the-type-of-ordinals-is-a-set (ua π€) fe') ((contrapositive (f-is-injective no-max a b)) (¬¬-intro p)) f-is-embedding : Β¬ has-maximal-element-strong β is-embedding f f-is-embedding no-max = lc-maps-into-sets-are-embeddings f (f-is-left-cancellable no-max) X-is-set X' : π€ βΊ Μ X' = image f f' : Ordinal π€ β X' f' = corestriction f f'-is-equiv : Β¬ has-maximal-element-strong β is-equiv f' f'-is-equiv no-max = corestriction-of-embedding-is-equivalence f (f-is-embedding no-max) B : X β π€ βΊ Μ B x = x βimage f B-is-prop : (x : X) β is-prop (B x) B-is-prop x = being-in-the-image-is-prop x f Ο : Propositional-Resizing Ο = EM-gives-PR lem C : X β π€ Μ C x = resize Ο (B x) (B-is-prop x) Ο : Nat C B Ο x = from-resize Ο (B x) (B-is-prop x) Ο-is-equiv : (x : X) β is-equiv (Ο x) Ο-is-equiv x = from-resize-is-equiv Ο (B x) (B-is-prop x) X'' : π€ Μ X'' = Ξ£ x κ X , C x e : Β¬ has-maximal-element-strong β X'' β Ordinal π€ e no-max = X'' ββ¨ NatΞ£ Ο , NatΞ£-is-equiv C B Ο Ο-is-equiv β© X' ββ¨ β-sym (f' , f'-is-equiv no-max) β© Ordinal π€ β the-type-of-ordinals-is-small : Β¬ has-maximal-element-strong β is-small (Ordinal π€) the-type-of-ordinals-is-small no-max = X'' , (e no-max) absurd : Β¬ has-maximal-element-strong β π absurd no-max = the-type-of-ordinals-is-large (the-type-of-ordinals-is-small no-max) axiom-of-choice-implies-zorns-lemma : Axiom-of-Choice β poset-axioms (_βͺ_) β all-chains-have-upper-bound β has-maximal-element axiom-of-choice-implies-zorns-lemma ac (X-is-set , axioms-rest) = III where em : Excluded-Middle em = Choice-gives-Excluded-Middle pe' ac lifted-cf : β₯ Lift (π€ β π£) X β₯ β β Ξ΅ κ (π (Lift (π€ β π£) X) β (Lift (π€ β π£) X)) , ((A : π (Lift (π€ β π£) X)) β is-inhabited A β Ξ΅ A β A) lifted-cf = Choice-gives-Choiceβ ac (Lift (π€ β π£) X) (Lift-is-set (π€ β π£) X X-is-set) lower-cf : Ξ£ Ξ΅ κ (π (Lift (π€ β π£) X) β (Lift (π€ β π£) X)) , ((A : π (Lift (π€ β π£) X)) β is-inhabited A β Ξ΅ A β A) β Ξ£ Ξ΅ κ (π X β X) , ((A : π X) β is-inhabited A β Ξ΅ A β A) lower-cf (Ο΅ , f) = (Ο΅' , f') where Ο΅' : π X β X Ο΅' S = lower (Ο΅ (S β lower)) inhab-trans : {A' : π X} β is-inhabited A' β is-inhabited (A' β lower) inhab-trans {A'} isA' = isA' >>= Ξ» isA'' β β£ lift (π€ β π£) (prβ isA'') , transport (Ξ» q β (A' q) holds) (Ξ΅-Lift (π€ β π£) (prβ isA'')) (prβ isA'')β£ f' : (A' : π X) β is-inhabited A' β Ο΅' A' β A' f' A' A'-inhab = (f (A' β lower) (inhab-trans {A'} A'-inhab)) choice-function : β₯ X β₯ β β Ξ΅ κ (π X β X) , ((A : π X) β is-inhabited A β Ξ΅ A β A) choice-function isX = β₯β₯-functor lower-cf (lifted-cf (β₯β₯-functor (lift (π€ β π£)) isX)) I' : all-chains-have-upper-bound β β Ξ΅ κ (π X β X) , ((A : π X) β is-inhabited A β Ξ΅ A β A) β has-maximal-element I' chains = β₯β₯-rec (β-is-prop) (choice-function-gives-zorns-lemma em (X-is-set , axioms-rest) chains) I : all-chains-have-upper-bound β β₯ X β₯ β has-maximal-element I chains-have-ub z = I' chains-have-ub (choice-function z) empty-has-no-ub : Β¬ β₯ X β₯ β Β¬ (all-chains-have-upper-bound {π₯}) empty-has-no-ub Ξ½ chains = Ξ½ β£ prβ (chains β Ξ» x y xin yin β unique-from-π (Ξ½ β£ x β£)) β£ II : all-chains-have-upper-bound β Β¬ β₯ X β₯ β has-maximal-element II chains-have-ub Ξ½ = unique-from-π ((empty-has-no-ub Ξ½) chains-have-ub) III : all-chains-have-upper-bound β has-maximal-element III chains-have-ub = cases (I chains-have-ub) (II chains-have-ub) (em β₯ X β₯ β₯β₯-is-prop) \end{code}