Tom de Jong, 29 November 2022. In collaboration with Nicolai Kraus, Fredrik Nordvall Forsberg and Chuangjie Xu. Cleaned up on 16 and 19 December 2022. The cumulative hierarchy π with respect to a universe π€ is a large type, meaning it lives in the next universe π€ βΊ. Hence, for elements x, y : π, the identity type x οΌ y of π also lives in π€ βΊ. However, as pointed out in the HoTT Book [Section 10.5, 1], it is possible to define a binary relation on π that takes values in π€ and prove it equivalent to the identity type of π. This makes π an example of a locally π€-small type. The membership relation on π makes use of equality on π, and hence, has values in π€ βΊ too. But, using that π is locally π€-small we can define an equivalent π€-small membership relation. These facts are used in our development relating set theoretic and type theoretic ordinals, see Ordinals/CumulativeHierarchy-Addendum.lagda. References ---------- [1] The Univalent Foundations Program Homotopy Type Theory: Univalent Foundations of Mathematics https://homotopytypetheory.org/book Institute for Advanced Study 2013 \begin{code} {-# OPTIONS --safe --without-K #-} open import UF.FunExt open import UF.PropTrunc open import UF.Subsingletons module UF.CumulativeHierarchy-LocallySmall (pt : propositional-truncations-exist) (fe : Fun-Ext) (pe : Prop-Ext) where open import MLTT.Spartan open import UF.Base hiding (_β_) open import UF.Equiv open import UF.EquivalenceExamples open import UF.Equiv-FunExt open import UF.Logic open import UF.Size open import UF.Sets-Properties open import UF.Subsingletons-FunExt open import UF.SubtypeClassifier open import UF.SubtypeClassifier-Properties open AllCombinators pt fe open PropositionalTruncation pt \end{code} The idea is to have a π€-valued equality relation on π by defining: π-set {A} f οΌβ» π-set {B} g inductively as (Ξ a : A , β b : B , f a οΌβ» g b) Γ (Ξ b : B , β a : A , g b οΌβ» f a). Of course, we need to formally check that this definition respects the π-set-ext constructor of π in both arguments, which is provided by the setup below. \begin{code} open import UF.CumulativeHierarchy pt fe pe module π-is-locally-small {π€ : Universe} (ch : cumulative-hierarchy-exists π€) where open cumulative-hierarchy-exists ch private module _ {A : π€ Μ } (f : A β π) (r : A β π β Ξ© π€) where οΌβ»-auxβ : {B : π€ Μ } β (B β π) β Ξ© π€ οΌβ»-auxβ {B} g = (β±― a κ A , Ζ b κ B , r a (g b) holds) β§ (β±― b κ B , Ζ a κ A , r a (g b) holds) οΌβ»-auxβ-respects-β : {B' B : π€ Μ } (g' : B' β π) (g : B β π) β g' β g β οΌβ»-auxβ g' holds β οΌβ»-auxβ g holds οΌβ»-auxβ-respects-β {B'} {B} g' g (s , t) (u , v) = β¦ 1β¦ , β¦ 2β¦ where β¦ 1β¦ : (a : A) β β b κ B , r a (g b) holds β¦ 1β¦ a = β₯β₯-rec β-is-prop hβ (u a) where hβ : (Ξ£ b' κ B' , r a (g' b') holds) β β b κ B , r a (g b) holds hβ (b' , p) = β₯β₯-functor hβ (s b') where hβ : (Ξ£ b κ B , g b οΌ g' b') β Ξ£ b κ B , r a (g b) holds hβ (b , e) = b , transport (Ξ» - β (r a -) holds) (e β»ΒΉ) p β¦ 2β¦ : (b : B) β β a κ A , r a (g b) holds β¦ 2β¦ b = β₯β₯-rec β-is-prop hβ (t b) where hβ : (Ξ£ b' κ B' , g' b' οΌ g b) β β a κ A , r a (g b) holds hβ (b' , e) = β₯β₯-functor hβ (v b') where hβ : (Ξ£ a κ A , r a (g' b') holds) β Ξ£ a κ A , r a (g b) holds hβ (a , p) = a , transport (Ξ» - β (r a -) holds) e p οΌβ»-auxβ-respects-β' : {B' B : π€ Μ } (g' : B' β π) (g : B β π) β g' β g β οΌβ»-auxβ g' οΌ οΌβ»-auxβ g οΌβ»-auxβ-respects-β' {B'} {B} g' g e = Ξ©-extensionality pe fe (οΌβ»-auxβ-respects-β g' g e) (οΌβ»-auxβ-respects-β g g' (β-sym e)) οΌβ»-auxβ : π β Ξ© π€ οΌβ»-auxβ = π-recursion (Ξ©-is-set fe pe) (Ξ» g _ β οΌβ»-auxβ g) (Ξ» g' g _ _ _ _ e β οΌβ»-auxβ-respects-β' g' g e) οΌβ»-auxβ-behaviour : {B : π€ Μ } (g : B β π) β οΌβ»-auxβ (π-set g) οΌ οΌβ»-auxβ g οΌβ»-auxβ-behaviour g = π-recursion-computes (Ξ©-is-set fe pe) (Ξ» gβ _ β οΌβ»-auxβ gβ) (Ξ» g' g _ _ _ _ e β οΌβ»-auxβ-respects-β' g' g e) g (Ξ» _ β π , π-is-prop) οΌβ»-auxβ-respects-β : {A B : π€ Μ } (f : A β π) (g : B β π) β (rβ : A β π β Ξ© π€) (rβ : B β π β Ξ© π€) β ((a : A) β β b κ B , (f a οΌ g b) Γ (rβ a οΌ rβ b)) β ((b : B) β β a κ A , (g b οΌ f a) Γ (rβ b οΌ rβ a)) β {C : π€ Μ } (h : C β π) β οΌβ»-auxβ f rβ h holds β οΌβ»-auxβ g rβ h holds οΌβ»-auxβ-respects-β {A} {B} f g rβ rβ s t {C} h (u , v) = β¦ 1β¦ , β¦ 2β¦ where β¦ 1β¦ : (b : B) β β c κ C , rβ b (h c) holds β¦ 1β¦ b = β₯β₯-rec β-is-prop m (t b) where m : (Ξ£ a κ A , (g b οΌ f a) Γ (rβ b οΌ rβ a)) β β c κ C , rβ b (h c) holds m (a , _ , q) = β₯β₯-functor n (u a) where n : (Ξ£ c κ C , rβ a (h c) holds) β Ξ£ c κ C , rβ b (h c) holds n (c , w) = c , Idtofun (ap _holds (happly (q β»ΒΉ) (h c))) w β¦ 2β¦ : (c : C) β β b κ B , rβ b (h c) holds β¦ 2β¦ c = β₯β₯-rec β-is-prop n (v c) where n : (Ξ£ a κ A , rβ a (h c) holds) β β b κ B , rβ b (h c) holds n (a , w) = β₯β₯-functor m (s a) where m : (Ξ£ b κ B , (f a οΌ g b) Γ (rβ a οΌ rβ b)) β Ξ£ b κ B , rβ b (h c) holds m (b , _ , q) = b , Idtofun (ap _holds (happly q (h c))) w οΌβ»-auxβ-respects-β' : {A B : π€ Μ } (f : A β π) (g : B β π) (rβ : A β π β Ξ© π€) (rβ : B β π β Ξ© π€) β ((a : A) β β b κ B , (f a οΌ g b) Γ (rβ a οΌ rβ b)) β ((b : B) β β a κ A , (g b οΌ f a) Γ (rβ b οΌ rβ a)) β f β g β οΌβ»-auxβ f rβ οΌ οΌβ»-auxβ g rβ οΌβ»-auxβ-respects-β' {A} {B} f g rβ rβ IHβ IHβ _ = dfunext fe (π-prop-simple-induction (Ξ» x β οΌβ»-auxβ f rβ x οΌ οΌβ»-auxβ g rβ x) (Ξ» _ β Ξ©-is-set fe pe) Ο) where Ο : {C : π€ Μ } (h : C β π) β οΌβ»-auxβ f rβ (π-set h) οΌ οΌβ»-auxβ g rβ (π-set h) Ο h = οΌβ»-auxβ f rβ (π-set h) οΌβ¨ οΌβ»-auxβ-behaviour f rβ h β© οΌβ»-auxβ f rβ h οΌβ¨ e β© οΌβ»-auxβ g rβ h οΌβ¨ (οΌβ»-auxβ-behaviour g rβ h) β»ΒΉ β© οΌβ»-auxβ g rβ (π-set h) β where e = Ξ©-extensionality pe fe (οΌβ»-auxβ-respects-β f g rβ rβ IHβ IHβ h) (οΌβ»-auxβ-respects-β g f rβ rβ IHβ IHβ h) \end{code} We package up the above in the following definition which records the behaviour of the relation on the π-set constructor. \begin{code} οΌβ»[Ξ©]-packaged : Ξ£ Ο κ (π β π β Ξ© π€) , ({A : π€ Μ } (f : A β π) (r : A β π β Ξ© π€) β Ο (π-set f) οΌ οΌβ»-auxβ f r) οΌβ»[Ξ©]-packaged = π-recursion-with-computation (Ξ -is-set fe (Ξ» _ β Ξ©-is-set fe pe)) οΌβ»-auxβ οΌβ»-auxβ-respects-β' _οΌβ»[Ξ©]_ : π β π β Ξ© π€ _οΌβ»[Ξ©]_ = prβ οΌβ»[Ξ©]-packaged _οΌβ»_ : π β π β π€ Μ x οΌβ» y = (x οΌβ»[Ξ©] y) holds οΌβ»-is-prop-valued : {x y : π} β is-prop (x οΌβ» y) οΌβ»-is-prop-valued {x} {y} = holds-is-prop (x οΌβ»[Ξ©] y) \end{code} The following lemma shows that the relation οΌβ» indeed implements the idea announced in the comment above. \begin{code} private οΌβ»-behaviour : {A B : π€ Μ } (f : A β π) (g : B β π) β (π-set f οΌβ» π-set g) οΌ ( ((a : A) β β b κ B , f a οΌβ» g b) Γ ((b : B) β β a κ A , f a οΌβ» g b)) οΌβ»-behaviour {A} {B} f g = (π-set f οΌβ» π-set g) οΌβ¨ β¦ 1β¦ β© (οΌβ»-auxβ f r (π-set g) holds) οΌβ¨ β¦ 2β¦ β© T β where T : π€ Μ T = ((a : A) β β b κ B , f a οΌβ» g b) Γ ((b : B) β β a κ A , f a οΌβ» g b) r : A β π β Ξ© π€ r a y = f a οΌβ»[Ξ©] y β¦ 1β¦ = ap _holds (happly (prβ οΌβ»[Ξ©]-packaged f r) (π-set g)) β¦ 2β¦ = ap _holds (οΌβ»-auxβ-behaviour f r g) \end{code} Finally, we show that οΌβ» and οΌ are equivalent, making π a locally small type. \begin{code} οΌβ»-to-οΌ : {x y : π} β x οΌβ» y β x οΌ y οΌβ»-to-οΌ {x} {y} = π-prop-induction (Ξ» u β ((v : π) β u οΌβ» v β u οΌ v)) (Ξ» _ β Ξ β-is-prop fe (Ξ» _ _ β π-is-large-set)) (Ξ» {A} f r β π-prop-simple-induction _ (Ξ» _ β Ξ -is-prop fe (Ξ» _ β π-is-large-set)) (Ξ» {B} g β h f g r)) x y where h : {A B : π€ Μ } (f : A β π) (g : B β π) β ((a : A) (v : π) β f a οΌβ» v β f a οΌ v) β π-set f οΌβ» π-set g β π-set f οΌ π-set g h {A} {B} f g r e = π-set-ext f g (β¦ 1β¦ , β¦ 2β¦) where u : (a : A) β β b κ B , f a οΌβ» g b u = prβ (Idtofun (οΌβ»-behaviour f g) e) v : (b : B)Β β β a κ A , f a οΌβ» g b v = prβ (Idtofun (οΌβ»-behaviour f g) e) β¦ 1β¦ : (a : A) β β b κ B , g b οΌ f a β¦ 1β¦ a = β₯β₯-functor (Ξ» (b , p) β b , ((r a (g b) p) β»ΒΉ)) (u a) β¦ 2β¦ : (b : B) β β a κ A , f a οΌ g b β¦ 2β¦ b = β₯β₯-functor (Ξ» (a , p) β a , r a (g b) p) (v b) οΌβ»-is-reflexive : {x : π} β x οΌβ» x οΌβ»-is-reflexive {x} = π-prop-induction (Ξ» - β - οΌβ» -) (Ξ» _ β οΌβ»-is-prop-valued) h x where h : {A : π€ Μ } (f : A β π) β ((a : A) β f a οΌβ» f a) β π-set f οΌβ» π-set f h {A} f r = Idtofunβ»ΒΉ (οΌβ»-behaviour f f) ((Ξ» a β β£ a , r a β£) , (Ξ» a β β£ a , r a β£)) οΌ-to-οΌβ» : {x y : π} β x οΌ y β x οΌβ» y οΌ-to-οΌβ» refl = οΌβ»-is-reflexive οΌβ»-β-οΌ : {x y : π} β (x οΌβ» y) β (x οΌ y) οΌβ»-β-οΌ = logically-equivalent-props-are-equivalent οΌβ»-is-prop-valued π-is-large-set οΌβ»-to-οΌ οΌ-to-οΌβ» π-is-locally-small : is-locally-small π π-is-locally-small x y = (x οΌβ» y) , οΌβ»-β-οΌ οΌβ»-is-transitive : {x y z : π} β x οΌβ» y β y οΌβ» z β x οΌβ» z οΌβ»-is-transitive {x} {y} {z} u v = οΌ-to-οΌβ» (οΌβ»-to-οΌ u β οΌβ»-to-οΌ v) οΌβ»-is-symmetric : {x y : π} β x οΌβ» y β y οΌβ» x οΌβ»-is-symmetric {x} {y} e = οΌ-to-οΌβ» ((οΌβ»-to-οΌ e)β»ΒΉ) \end{code} We now make use of the fact that π is locally small by introducing a small-valued membership relation on π. \begin{code} _ββ»[Ξ©]_ : π β π β Ξ© π€ _ββ»[Ξ©]_ x = π-prop-simple-recursion (Ξ» {A} f β (β a κ A , f a οΌβ» x) , β-is-prop) e where e : {A B : π€ Μ } (f : A β π) (g : B β π) β f β² g β (β a κ A , f a οΌβ» x) β (β b κ B , g b οΌβ» x) e {A} {B} f g s = β₯β₯-rec β-is-prop (Ξ» (a , p) β β₯β₯-functor (Ξ» (b , q) β b , οΌ-to-οΌβ» (q β οΌβ»-to-οΌ p)) (s a)) _ββ»_ : π β π β π€ Μ x ββ» y = (x ββ»[Ξ©] y) holds ββ»-for-π-sets : (x : π) {A : π€ Μ } (f : A β π) β (x ββ» π-set f) οΌ (β a κ A , f a οΌβ» x) ββ»-for-π-sets x f = ap prβ (π-prop-simple-recursion-computes _ _ f) ββ»-is-prop-valued : {x y : π} β is-prop (x ββ» y) ββ»-is-prop-valued {x} {y} = holds-is-prop (x ββ»[Ξ©] y) ββ»-β-β : {x y : π} β x ββ» y β x β y ββ»-β-β {x} {y} = π-prop-simple-induction _ (Ξ» _ β β-is-prop (Ξ» _ _ β fe) β-is-prop-valued) h y where h : {A : π€ Μ } (f : A β π) β (x ββ» π-set f) β (x β π-set f) h {A} f = x ββ» π-set f ββ¨ β¦ 1β¦ β© (β a κ A , f a οΌβ» x) ββ¨ β¦ 2β¦ β© (β a κ A , f a οΌ x) ββ¨ β¦ 3β¦ β© x β π-set f β where β¦ 1β¦ = idtoeq _ _ (ββ»-for-π-sets x f) β¦ 2β¦ = β-cong pt (Ξ» a β οΌβ»-β-οΌ) β¦ 3β¦ = idtoeq _ _ ((β-for-π-sets x f) β»ΒΉ) ββ»-to-β : {x y : π} β x ββ» y β x β y ββ»-to-β {x} {y} = β ββ»-β-β β β-to-ββ» : {x y : π} β x β y β x ββ» y β-to-ββ» {x} {y} = β ββ»-β-β ββ»ΒΉ \end{code}