This is ported from the Midlands Graduate School 2019 lecture notes https://www.cs.bham.ac.uk/~mhe/HoTT-UF.in-Agda-Lecture-Notes/HoTT-UF-Agda.html https://github.com/martinescardo/HoTT-UF.Agda-Lecture-Notes \begin{code} {-# OPTIONS --safe --without-K #-} module MGS.Size where open import MGS.Powerset public open import MGS.Universe-Lifting public open import MGS.Subsingleton-Truncation public _has-size_ : π€ Μ β (π₯ : Universe) β π₯ βΊ β π€ Μ X has-size π₯ = Ξ£ Y κ π₯ Μ , X β Y propositional-resizing : (π€ π₯ : Universe) β (π€ β π₯)βΊ Μ propositional-resizing π€ π₯ = (P : π€ Μ ) β is-subsingleton P β P has-size π₯ resize-up : (X : π€ Μ ) β X has-size (π€ β π₯) resize-up {π€} {π₯} X = (Lift π₯ X , β-Lift X) resize-up-subsingleton : propositional-resizing π€ (π€ β π₯) resize-up-subsingleton {π€} {π₯} P i = resize-up {π€} {π₯} P resize : propositional-resizing π€ π₯ β (P : π€ Μ ) (i : is-subsingleton P) β π₯ Μ resize Ο P i = prβ (Ο P i) resize-is-subsingleton : (Ο : propositional-resizing π€ π₯) (P : π€ Μ ) (i : is-subsingleton P) β is-subsingleton (resize Ο P i) resize-is-subsingleton Ο P i = equiv-to-subsingleton (β-sym (prβ (Ο P i))) i to-resize : (Ο : propositional-resizing π€ π₯) (P : π€ Μ ) (i : is-subsingleton P) β P β resize Ο P i to-resize Ο P i = β prβ (Ο P i) β from-resize : (Ο : propositional-resizing π€ π₯) (P : π€ Μ ) (i : is-subsingleton P) β resize Ο P i β P from-resize Ο P i = β β-sym (prβ (Ο P i)) β Propositional-resizing : π€Ο Propositional-resizing = {π€ π₯ : Universe} β propositional-resizing π€ π₯ EM-gives-PR : EM π€ β propositional-resizing π€ π₯ EM-gives-PR {π€} {π₯} em P i = Q (em P i) , e where Q : P + Β¬ P β π₯ Μ Q (inl p) = Lift π₯ π Q (inr n) = Lift π₯ π j : (d : P + Β¬ P) β is-subsingleton (Q d) j (inl p) = equiv-to-subsingleton (Lift-β π) π-is-subsingleton j (inr n) = equiv-to-subsingleton (Lift-β π) π-is-subsingleton f : (d : P + Β¬ P) β P β Q d f (inl p) p' = lift β f (inr n) p = !π (Lift π₯ π) (n p) g : (d : P + Β¬ P) β Q d β P g (inl p) q = p g (inr n) q = !π P (lower q) e : P β Q (em P i) e = logically-equivalent-subsingletons-are-equivalent P (Q (em P i)) i (j (em P i)) (f (em P i) , g (em P i)) has-size-is-subsingleton : Univalence β (X : π€ Μ ) (π₯ : Universe) β is-subsingleton (X has-size π₯) has-size-is-subsingleton {π€} ua X π₯ = univalenceβ' (ua π₯) (ua (π€ β π₯)) X PR-is-subsingleton : Univalence β is-subsingleton (propositional-resizing π€ π₯) PR-is-subsingleton {π€} {π₯} ua = Ξ -is-subsingleton (univalence-gives-global-dfunext ua) (Ξ» P β Ξ -is-subsingleton (univalence-gives-global-dfunext ua) (Ξ» i β has-size-is-subsingleton ua P π₯)) Impredicativity : (π€ π₯ : Universe) β (π€ β π₯ )βΊ Μ Impredicativity π€ π₯ = (Ξ© π€) has-size π₯ is-impredicative : (π€ : Universe) β π€ βΊ Μ is-impredicative π€ = Impredicativity π€ π€ PR-gives-ImpredicativityβΊ : global-propext β global-dfunext β propositional-resizing π₯ π€ β propositional-resizing π€ π₯ β Impredicativity π€ (π₯ βΊ) PR-gives-ImpredicativityβΊ {π₯} {π€} pe fe Ο Ο = Ξ³ where Ο : Ξ© π₯ β Ξ© π€ Ο (Q , j) = resize Ο Q j , resize-is-subsingleton Ο Q j Ο : Ξ© π€ β Ξ© π₯ Ο (P , i) = resize Ο P i , resize-is-subsingleton Ο P i Ξ· : (p : Ξ© π€) β Ο (Ο p) οΌ p Ξ· (P , i) = Ξ©-ext fe pe a b where Q : π₯ Μ Q = resize Ο P i j : is-subsingleton Q j = resize-is-subsingleton Ο P i a : resize Ο Q j β P a = from-resize Ο P i β from-resize Ο Q j b : P β resize Ο Q j b = to-resize Ο Q j β to-resize Ο P i Ξ΅ : (q : Ξ© π₯) β Ο (Ο q) οΌ q Ξ΅ (Q , j) = Ξ©-ext fe pe a b where P : π€ Μ P = resize Ο Q j i : is-subsingleton P i = resize-is-subsingleton Ο Q j a : resize Ο P i β Q a = from-resize Ο Q j β from-resize Ο P i b : Q β resize Ο P i b = to-resize Ο P i β to-resize Ο Q j Ξ³ : (Ξ© π€) has-size (π₯ βΊ) Ξ³ = Ξ© π₯ , invertibility-gives-β Ο (Ο , Ξ· , Ξ΅) PR-gives-impredicativityβΊ : global-propext β global-dfunext β propositional-resizing (π€ βΊ) π€ β is-impredicative (π€ βΊ) PR-gives-impredicativityβΊ pe fe = PR-gives-ImpredicativityβΊ pe fe (Ξ» P i β resize-up P) PR-gives-impredicativityβ : global-propext β global-dfunext β propositional-resizing π€ π€β β Impredicativity π€ π€β PR-gives-impredicativityβ pe fe = PR-gives-ImpredicativityβΊ pe fe (Ξ» P i β resize-up P) Impredicativity-gives-PR : propext π€ β dfunext π€ π€ β Impredicativity π€ π₯ β propositional-resizing π€ π₯ Impredicativity-gives-PR {π€} {π₯} pe fe (O , e) P i = Q , Ξ΅ where π'' : π€ Μ π'' = Lift π€ π k : is-subsingleton π'' k (lift β) (lift β) = refl (lift β) down : Ξ© π€ β O down = β e β O-is-set : is-set O O-is-set = equiv-to-set (β-sym e) (Ξ©-is-set fe pe) Q : π₯ Μ Q = down (π'' , k) οΌ down (P , i) j : is-subsingleton Q j = O-is-set (down (Lift π€ π , k)) (down (P , i)) Ο : Q β P Ο q = Idβfun (ap _holds (equivs-are-lc down (ββ-is-equiv e) q)) (lift β) Ξ³ : P β Q Ξ³ p = ap down (to-subtype-οΌ (Ξ» _ β being-subsingleton-is-subsingleton fe) (pe k i (Ξ» _ β p) (Ξ» _ β lift β))) Ξ΅ : P β Q Ξ΅ = logically-equivalent-subsingletons-are-equivalent P Q i j (Ξ³ , Ο) PR-gives-existence-of-truncations : global-dfunext β Propositional-resizing β subsingleton-truncations-exist PR-gives-existence-of-truncations fe R = record { β₯_β₯ = Ξ» {π€} X β resize R (is-inhabited X) (inhabitation-is-subsingleton fe X) ; β₯β₯-is-subsingleton = Ξ» {π€} {X} β resize-is-subsingleton R (is-inhabited X) (inhabitation-is-subsingleton fe X) ; β£_β£ = Ξ» {π€} {X} x β to-resize R (is-inhabited X) (inhabitation-is-subsingleton fe X) (inhabited-intro x) ; β₯β₯-recursion = Ξ» {π€} {π₯} {X} {P} i u s β from-resize R P i (inhabited-recursion (resize-is-subsingleton R P i) (to-resize R P i β u) (from-resize R (is-inhabited X) (inhabitation-is-subsingleton fe X) s)) } module powerset-union-existence (pt : subsingleton-truncations-exist) (hfe : global-hfunext) where open basic-truncation-development pt hfe family-union : {X : π€ β π₯ Μ } {I : π₯ Μ } β (I β π X) β π X family-union {π€} {π₯} {X} {I} A = Ξ» x β (β i κ I , x β A i) , β-is-subsingleton ππ : π€ Μ β π€ βΊβΊ Μ ππ X = π (π X) existence-of-unions : (π€ : Universe) β π€ βΊβΊ Μ existence-of-unions π€ = (X : π€ Μ ) (π : ππ X) β Ξ£ B κ π X , ((x : X) β (x β B) β (β A κ π X , (A β π) Γ (x β A))) existence-of-unionsβ : (π€ : Universe) β _ Μ existence-of-unionsβ π€ = (X : π€ Μ ) (π : (X β Ξ© _) β Ξ© _) β Ξ£ B κ (X β Ξ© _) , ((x : X) β (x β B) β (β A κ (X β Ξ© _) , (A β π) Γ (x β A))) existence-of-unionsβ : (π€ : Universe) β π€ βΊβΊ Μ existence-of-unionsβ π€ = (X : π€ Μ ) (π : (X β Ξ© π€) β Ξ© (π€ βΊ)) β Ξ£ B κ (X β Ξ© π€) , ((x : X) β (x β B) β (β A κ (X β Ξ© π€) , (A β π) Γ (x β A))) existence-of-unions-agreement : existence-of-unions π€ οΌ existence-of-unionsβ π€ existence-of-unions-agreement = refl _ existence-of-unions-gives-PR : existence-of-unions π€ β propositional-resizing (π€ βΊ) π€ existence-of-unions-gives-PR {π€} Ξ± = Ξ³ where Ξ³ : (P : π€ βΊ Μ ) β (i : is-subsingleton P) β P has-size π€ Ξ³ P i = Q , e where πα΅€ : π€ Μ πα΅€ = Lift π€ π βα΅€ : πα΅€ βα΅€ = lift β πα΅€-is-subsingleton : is-subsingleton πα΅€ πα΅€-is-subsingleton = equiv-to-subsingleton (Lift-β π) π-is-subsingleton π : ππ πα΅€ π = Ξ» (A : π πα΅€) β P , i B : π πα΅€ B = prβ (Ξ± πα΅€ π) Ο : (x : πα΅€) β (x β B) β (β A κ π πα΅€ , (A β π) Γ (x β A)) Ο = prβ (Ξ± πα΅€ π) Q : π€ Μ Q = βα΅€ β B j : is-subsingleton Q j = β-is-subsingleton B βα΅€ f : P β Q f p = b where a : Ξ£ A κ π πα΅€ , (A β π) Γ (βα΅€ β A) a = (Ξ» (x : πα΅€) β πα΅€ , πα΅€-is-subsingleton) , p , βα΅€ b : βα΅€ β B b = rl-implication (Ο βα΅€) β£ a β£ g : Q β P g q = β₯β₯-recursion i b a where a : β A κ π πα΅€ , (A β π) Γ (βα΅€ β A) a = lr-implication (Ο βα΅€) q b : (Ξ£ A κ π πα΅€ , (A β π) Γ (βα΅€ β A)) β P b (A , m , _) = m e : P β Q e = logically-equivalent-subsingletons-are-equivalent P Q i j (f , g) PR-gives-existence-of-unions : propositional-resizing (π€ βΊ) π€ β existence-of-unions π€ PR-gives-existence-of-unions {π€} Ο X π = B , (Ξ» x β lr x , rl x) where Ξ² : X β π€ βΊ Μ Ξ² x = β A κ π X , (A β π) Γ (x β A) i : (x : X) β is-subsingleton (Ξ² x) i x = β-is-subsingleton B : π X B x = (resize Ο (Ξ² x) (i x) , resize-is-subsingleton Ο (Ξ² x) (i x)) lr : (x : X) β x β B β β A κ π X , (A β π) Γ (x β A) lr x = from-resize Ο (Ξ² x) (i x) rl : (x : X) β (β A κ π X , (A β π) Γ (x β A)) β x β B rl x = to-resize Ο (Ξ² x) (i x) module basic-powerset-development (hfe : global-hfunext) (Ο : Propositional-resizing) where pt : subsingleton-truncations-exist pt = PR-gives-existence-of-truncations (hfunext-gives-dfunext hfe) Ο open basic-truncation-development pt hfe open powerset-union-existence pt hfe β : {X : π€ Μ } β ππ X β π X β π = prβ (PR-gives-existence-of-unions Ο _ π) β-property : {X : π€ Μ } (π : ππ X) β (x : X) β (x β β π) β (β A κ π X , (A β π) Γ (x β A)) β-property π = prβ (PR-gives-existence-of-unions Ο _ π) intersections-exist : (X : π€ Μ ) (π : ππ X) β Ξ£ B κ π X , ((x : X) β (x β B) β ((A : π X) β A β π β x β A)) intersections-exist {π€} X π = B , (Ξ» x β lr x , rl x) where Ξ² : X β π€ βΊ Μ Ξ² x = (A : π X) β A β π β x β A i : (x : X) β is-subsingleton (Ξ² x) i x = Ξ -is-subsingleton hunapply (Ξ» A β Ξ -is-subsingleton hunapply (Ξ» _ β β-is-subsingleton A x)) B : π X B x = (resize Ο (Ξ² x) (i x) , resize-is-subsingleton Ο (Ξ² x) (i x)) lr : (x : X) β x β B β (A : π X) β A β π β x β A lr x = from-resize Ο (Ξ² x) (i x) rl : (x : X) β ((A : π X) β A β π β x β A) β x β B rl x = to-resize Ο (Ξ² x) (i x) β : {X : π€ Μ } β ππ X β π X β {π€} {X} π = prβ (intersections-exist X π) β-property : {X : π€ Μ } (π : ππ X) β (x : X) β (x β β π) β ((A : π X) β A β π β x β A) β-property {π€} {X} π = prβ (intersections-exist X π) β full : {X : π€ Μ } β π X β = Ξ» x β (Lift _ π , equiv-to-subsingleton (Lift-β π) π-is-subsingleton) full = Ξ» x β (Lift _ π , equiv-to-subsingleton (Lift-β π) π-is-subsingleton) β -property : (X : π€ Μ ) β (x : X) β Β¬ (x β β ) β -property X x = lower full-property : (X : π€ Μ ) β (x : X) β x β full full-property X x = lift β _β©_ _βͺ_ : {X : π€ Μ } β π X β π X β π X (A βͺ B) = Ξ» x β ((x β A) β¨ (x β B)) , β¨-is-subsingleton (A β© B) = Ξ» x β ((x β A) Γ (x β B)) , Γ-is-subsingleton (β-is-subsingleton A x) (β-is-subsingleton B x) βͺ-property : {X : π€ Μ } (A B : π X) β (x : X) β x β (A βͺ B) β (x β A) β¨ (x β B) βͺ-property {π€} {X} A B x = id , id β©-property : {X : π€ Μ } (A B : π X) β (x : X) β x β (A β© B) β (x β A) Γ (x β B) β©-property {π€} {X} A B x = id , id infix 20 _β©_ infix 20 _βͺ_ Top : (π€ : Universe) β π€ βΊβΊ Μ Top π€ = Ξ£ X κ π€ Μ , is-set X Γ (Ξ£ π κ ππ X , full β π Γ ((U V : π X) β U β π β V β π β (U β© V) β π) Γ ((π : ππ X) β π β π β β π β π)) \end{code}