Ian Ray, 2 June 2024 Modification by Martin Escardo and Tom de Jong 12th September 2024. Minor modifications by Tom de Jong on 4 September 2024 We develop n-types, or n-truncated types, as defined in the HoTT book. In this file we will assume function extensionality globally but not univalence. The final result of the file will be proved in the local presence of univalence. \begin{code} {-# OPTIONS --safe --without-K #-} open import UF.FunExt module UF.TruncatedTypes (fe : Fun-Ext) where open import MLTT.Spartan hiding (_+_) open import Naturals.Order open import Notation.Order open import UF.Embeddings open import UF.Equiv open import UF.EquivalenceExamples open import UF.Retracts open import UF.Singleton-Properties open import UF.Subsingletons open import UF.Subsingletons-FunExt open import UF.Subsingletons-Properties open import UF.TruncationLevels open import UF.Univalence private fe' : FunExt fe' π€ π₯ = fe {π€} {π₯} _is_truncated : π€ Μ β βββ β π€ Μ X is β2 truncated = is-contr X X is (succ n) truncated = (x x' : X) β (x οΌ x') is n truncated being-truncated-is-prop : {π€ : Universe} {n : βββ} {X : π€ Μ } β is-prop (X is n truncated) being-truncated-is-prop {π€} {β2} = being-singleton-is-prop fe being-truncated-is-prop {π€} {succ n} = Ξ β-is-prop fe (Ξ» x x' β being-truncated-is-prop) _is_truncated-map : {X : π€ Μ} {Y : π₯ Μ} β (f : X β Y) β βββ β π€ β π₯ Μ f is n truncated-map = each-fiber-of f (Ξ» - β - is n truncated) \end{code} Being -1-truncated is equivalent to being a proposition. \begin{code} is-prop' : (X : π€ Μ) β π€ Μ is-prop' X = X is β1 truncated being-prop'-is-prop : (X : π€ Μ) β is-prop (is-prop' X) being-prop'-is-prop X = being-truncated-is-prop is-prop-implies-is-prop' : {X : π€ Μ} β is-prop X β is-prop' X is-prop-implies-is-prop' X-is-prop x x' = pointed-props-are-singletons (X-is-prop x x') (props-are-sets X-is-prop) is-prop'-implies-is-prop : {X : π€ Μ} β is-prop' X β is-prop X is-prop'-implies-is-prop X-is-prop' x x' = center (X-is-prop' x x') is-prop-equiv-is-prop' : {X : π€ Μ} β is-prop X β is-prop' X is-prop-equiv-is-prop' {π€} {X} = logically-equivalent-props-are-equivalent (being-prop-is-prop fe) (being-prop'-is-prop X) is-prop-implies-is-prop' is-prop'-implies-is-prop \end{code} Truncation levels are upper closed. \begin{code} contractible-types-are-props' : {X : π€ Μ} β is-contr X β is-prop' X contractible-types-are-props' = is-prop-implies-is-prop' β singletons-are-props truncation-levels-are-upper-closed : {n : βββ} {X : π€ Μ } β X is n truncated β X is (n + 1) truncated truncation-levels-are-upper-closed {π€} {β2} = contractible-types-are-props' truncation-levels-are-upper-closed {π€} {succ n} t x x' = truncation-levels-are-upper-closed (t x x') truncation-levels-closed-under-Id : {n : βββ} {X : π€ Μ } β X is n truncated β (x x' : X) β (x οΌ x') is n truncated truncation-levels-closed-under-Id {π€} {β2} = contractible-types-are-props' truncation-levels-closed-under-Id {π€} {succ n} t x x' = truncation-levels-are-upper-closed (t x x') \end{code} We will now give some closure results about truncation levels. \begin{code} truncated-types-are-closed-under-retracts : {n : βββ} {X : π€ Μ } {Y : π₯ Μ } β retract X of Y β Y is n truncated β X is n truncated truncated-types-are-closed-under-retracts {π€} {π₯} {β2} {X} {Y} = singleton-closed-under-retract X Y truncated-types-are-closed-under-retracts {π€} {π₯} {succ n} (r , s , H) t x x' = truncated-types-are-closed-under-retracts (οΌ-retract s (r , H) x x') (t (s x) (s x')) truncated-types-closed-under-equiv : {n : βββ} {X : π€ Μ } {Y : π₯ Μ } β X β Y β Y is n truncated β X is n truncated truncated-types-closed-under-equiv e = truncated-types-are-closed-under-retracts (β-gives-β e) \end{code} We can prove closure under embeddings as a consequence of the previous result. \begin{code} truncated-types-closed-under-embeddingβΊ : {n : βββ} {X : π€ Μ } {Y : π₯ Μ } β X βͺ Y β Y is (n + 1) truncated β X is (n + 1) truncated truncated-types-closed-under-embeddingβΊ {π€} {π₯} (e , is-emb) t x x' = truncated-types-closed-under-equiv (ap e , embedding-gives-embedding' e is-emb x x') (t (e x) (e x')) truncated-types-closed-under-embedding : {n : βββ} β n β₯ β1 β {X : π€ Μ } {Y : π₯ Μ } β X βͺ Y β Y is n truncated β X is n truncated truncated-types-closed-under-embedding {π€} {π₯} {succ n} _ = truncated-types-closed-under-embeddingβΊ \end{code} Using closure under equivalence we can show closure under Ξ£ and Ξ . \begin{code} truncated-types-closed-under-Ξ£ : {n : βββ} {X : π€ Μ } (Y : X β π₯ Μ ) β X is n truncated β ((x : X) β (Y x) is n truncated) β (Ξ£ Y) is n truncated truncated-types-closed-under-Ξ£ {π€} {π₯} {β2} Y = Ξ£-is-singleton truncated-types-closed-under-Ξ£ {π€} {π₯} {succ n} Y l m (x , y) (x' , y') = truncated-types-closed-under-equiv Ξ£-οΌ-β (truncated-types-closed-under-Ξ£ (Ξ» p β transport Y p y οΌ y') (l x x') (Ξ» p β m x' (transport Y p y) y')) truncated-types-closed-under-Ξ : {n : βββ} {X : π€ Μ } (Y : X β π₯ Μ ) β ((x : X) β (Y x) is n truncated) β (Ξ Y) is n truncated truncated-types-closed-under-Ξ {π€} {π₯} {β2} Y = Ξ -is-singleton fe truncated-types-closed-under-Ξ {π€} {π₯} {succ n} Y m f g = truncated-types-closed-under-equiv (happly-β fe) (truncated-types-closed-under-Ξ (Ξ» x β f x οΌ g x) (Ξ» x β m x (f x) (g x))) truncated-types-closed-under-β : {n : βββ} {X : π€ Μ } {Y : π₯ Μ } β Y is n truncated β (X β Y) is n truncated truncated-types-closed-under-β {π€} {π₯} {n} {X} {Y} m = truncated-types-closed-under-Ξ (Ξ» - β Y) (Ξ» - β m) \end{code} The subuniverse of types of n truncated types is defined as follows. \begin{code} π : βββ β (π€ : Universe) β π€ βΊ Μ π n π€ = Ξ£ X κ π€ Μ , X is n truncated \end{code} From univalence we can show that π n is n + 1 truncated, for all n : βββ. \begin{code} truncation-levels-closed-under-ββΊ : {n : βββ} {X : π€ Μ } {Y : π₯ Μ } β Y is (n + 1) truncated β (X β Y) is (n + 1) truncated truncation-levels-closed-under-ββΊ {π€} {π₯} {n} {X} {Y} tY = truncated-types-closed-under-embedding β (equiv-embeds-into-function fe') (truncated-types-closed-under-Ξ (Ξ» _ β Y) (Ξ» _ β tY)) truncation-levels-closed-under-β : {n : βββ} {X : π€ Μ } {Y : π₯ Μ } β X is n truncated β Y is n truncated β (X β Y) is n truncated truncation-levels-closed-under-β {π€} {π₯} {β2} = β-is-singleton fe' truncation-levels-closed-under-β {π€} {π₯} {succ n} tX = truncation-levels-closed-under-ββΊ π-is-of-next-truncation-level : {n : βββ} {π€ : Universe} β is-univalent π€ β (π n π€) is (n + 1) truncated π-is-of-next-truncation-level ua (X , l) (Y , l') = truncated-types-closed-under-equiv I (truncation-levels-closed-under-β l l') where I = ((X , l) οΌ (Y , l')) ββ¨ II β© (X οΌ Y) ββ¨ univalence-β ua X Y β© (X β Y) β where II = β-sym (to-subtype-οΌ-β (Ξ» _ β being-truncated-is-prop)) \end{code}