Back to index

Chapter 7. Homotopy n-types

module Chapter7.Book where

open import Chapter6.Exercises public

7.1. Definition of n-types

-- Definition 7.1.1.
-- Note that this is really the property of being an n-2 type.
isNType : (n : ) (A : 𝒰 𝒾)  𝒰 𝒾
isNType 0 A        = isContr A
isNType (succ n) A = (x y : A)  isNType n (x  y)

-- Example 7.1.3.
is-1Type⇒isProp : {X : 𝒰 𝒾}  isNType 1 X  isProp X
is-1Type⇒isProp f = isContr-≡⇒isProp f

isProp⇒is-1Type : {X : 𝒰 𝒾}  isProp X  isNType 1 X
isProp⇒is-1Type f = isProp⇒isContr-≡ f

is0Type⇒isSet : {X : 𝒰 𝒾}  isNType 2 X  isSet X
is0Type⇒isSet f = is-1Type⇒isProp (f _ _)

isSet⇒is0Type : {X : 𝒰 𝒾}  isSet X  isNType 2 X
isSet⇒is0Type f x y = isProp⇒is-1Type f

-- Theorem 7.1.4.
◁-isNType⇒isNType : (n : ) {A : 𝒰 𝒾} {B : 𝒰 𝒿}  (A  B)
                          isNType n B
                          isNType n A
◁-isNType⇒isNType 0 s f = retraction-isContr⇒isContr s f
◁-isNType⇒isNType (succ n) rs f a₁ a₂ =
  ◁-isNType⇒isNType n ret (f (s a₁) (s a₂))
 where
  r = retraction rs
  s = section rs
  ε = retract-equation rs
  t : (s a₁  s a₂)  (a₁  a₂)
  t q = (ε a₁)⁻¹  ap r q  ε a₂
  ret : (a₁  a₂)  (s a₁  s a₂)
  ret = t , ap s , htpy
   where
    htpy : t  ap s  id
    htpy p = begin
     ((ε a₁)⁻¹  ap r (ap s p))  ε a₂  ≡⟨ ∙-assoc _ 
     (ε a₁)⁻¹  (ap r (ap s p)  ε a₂)  ≡˘⟨ ap  -  (ε a₁)⁻¹  (-  ε a₂))
                                               (ap-∘ _ _ _) 
     (ε a₁)⁻¹  ((ap (r  s) p)  ε a₂) ≡˘⟨ ap ((ε a₁)⁻¹ ∙_)
                                               (∼-naturality _ _ ε) 
     (ε a₁)⁻¹  (ε a₁  ap id p)        ≡⟨ ap  -  (ε a₁)⁻¹  (ε a₁  -))
                                              (ap-id _) 
     (ε a₁)⁻¹  (ε a₁  p)              ≡˘⟨ ∙-assoc _ 
     ((ε a₁)⁻¹  ε a₁)  p              ≡⟨ ap (_∙ p) (⁻¹-left∙ _) 
     (refl a₁)  p                      ≡⟨ refl-left 
     p 

-- Corollary 7.1.5.
≃-isNType⇒isNType : (n : ) {A : 𝒰 𝒾} {B : 𝒰 𝒿}
                   (A  B)
                   isNType n A
                   isNType n B
≃-isNType⇒isNType n eqv f =
  ◁-isNType⇒isNType n (≃-→ eqv , ≃-← eqv , ≃-ε eqv) f

-- Theorem 7.1.6.
isEmbedding-isNType⇒isNType :
                (n : ) {X : 𝒰 𝒾} {Y : 𝒰 𝒿}
               (f : X  Y)
               isEmbedding f
               isNType (succ n) Y
               isNType (succ n) X
isEmbedding-isNType⇒isNType n f e p x y =
  ≃-isNType⇒isNType n (≃-sym (ap f , e x y)) (p (f x) (f y))

-- Theorem 7.1.7.
cumul-isNType : (n : ) {A : 𝒰 𝒾}
              isNType n A
              isNType (succ n) A
cumul-isNType 0 (c , p) x y = ((p x)⁻¹  (p y)) , contraction
  where
    contraction : (q : x  y)  p x ⁻¹  p y  q
    contraction (refl x) = ⁻¹-left∙ _
cumul-isNType (succ n) f x y = cumul-isNType n (f x y)

-- Theorem 7.1.8.
isNType-Σ : {A : 𝒰 𝒾} {B : A  𝒰 𝒿} (n : )
           isNType n A
           ((a : A)  isNType n (B a))
           isNType n (Σ B)
isNType-Σ 0 (a₀ , p) g =
  (a₀ , pr₁ (g a₀)) , λ (a , b)  pair⁼(p a , ((pr₂ (g a) _)⁻¹  pr₂ (g a) b))
isNType-Σ {B = B} (succ n) f g (a₁ , b₁) (a₂ , b₂) =
  ≃-isNType⇒isNType n (≃-sym paths≃) Σ-isNType
  where
    paths≃ : ((a₁ , b₁)  (a₂ , b₂))  (Σ p  (a₁  a₂) , tr B p b₁  b₂)
    paths≃ = ≡-Σ-≃ _ _
    Σ-isNType : isNType n (Σ p  (a₁  a₂) , tr B p b₁  b₂)
    Σ-isNType = isNType-Σ n (f a₁ a₂) lemma
      where
        lemma : (a : a₁  a₂)  isNType n (tr B a b₁  b₂)
        lemma (refl _) = g a₁ b₁ b₂

-- Theorem 7.1.9.
isNType-Π : {A : 𝒰 𝒾} {B : A  𝒰 𝒿} (n : )
           ((a : A)  isNType n (B a))
           isNType n (Π B)
isNType-Π 0 p = isContr-Π p
isNType-Π (succ n) p f g =
  ≃-isNType⇒isNType n (≃-sym (≡-Π-≃ f g))
    (isNType-Π n λ x  p x (f x) (g x))

-- Theorem 7.1.10.
isProp-isNType : (n : ) (A : 𝒰 𝒾)
                isProp (isNType n A)
isProp-isNType 0 A = isProp-isContr A
isProp-isNType (succ n) A =
  isProp-Π  x  isProp-Π  y  isProp-isNType n (x  y)))

NType𝒰 : (n : ) (𝒾 : Level)  𝒰 (𝒾 )
NType𝒰 n 𝒾 = Σ A  (𝒰 𝒾) , isNType n A

≡-isNType𝒰-≃ : (n : ) (X Y : NType𝒰 n 𝒿)  (X  Y)  (pr₁ X  pr₁ Y)
≡-isNType𝒰-≃ n X Y = (f , invs⇒equivs f ( g , ε , η ))
 where
  f = ap pr₁
  g = λ -  pair⁼(- , isProp-isNType n _ _ _)
  ε = λ -  ≡-Σ-comp₁ _ _
  η : g  f  id
  η p = begin
    pair⁼(ap pr₁ p , isProp-isNType n _ _ _) ≡⟨ i 
    pair⁼(ap pr₁ p , pair⁼⁻¹₂ p)             ≡⟨ ii 
    p 
   where
    i = ap  -  pair⁼(ap pr₁ p , -))
           ((isProp⇒isSet (isProp-isNType n _)) _ _)
    ii = ≃-η (≡-Σ-≃ _ _) p

isEmbedding-pr₁-isNType𝒰-≃ :
     (n : )
     (X X' : NType𝒰 n 𝒾)
    isEmbedding (pr₁ {B =  f  isEquiv {A = pr₁ X} {B = pr₁ X'} f)})
isEmbedding-pr₁-isNType𝒰-≃ n (X , p) (X' , p') (f , equiv-f) (g , equiv-g) =
  invs⇒equivs (ap pr₁) (h , ε , η)
 where
  h : f  g  f , equiv-f  g , equiv-g
  h k = pair⁼(k , isProp-isEquiv g (tr isEquiv k equiv-f) equiv-g)
  ε : (ap pr₁)  h  id
  ε k = ≡-Σ-comp₁ k (isProp-isEquiv g (tr isEquiv k equiv-f) equiv-g)
  η : h  (ap pr₁)  id
  η equiv = begin
    pair⁼(ap pr₁ equiv , isProp-isEquiv g _ equiv-g) ≡⟨ i 
    pair⁼(ap pr₁ equiv , pair⁼⁻¹₂ equiv)             ≡⟨ ii 
    equiv 
   where
    i = ap  -  pair⁼(ap pr₁ equiv , -))
           (isProp⇒isSet (isProp-isEquiv g) _ _)
    ii = ≃-η (≡-Σ-≃ _ _) equiv

-- Theorem 7.1.11.
isNType-isNType : (n : )
                 isNType (succ n) (NType𝒰 n 𝒾)
isNType-isNType 0 (X , p) (X' , p') =
   ≃-isNType⇒isNType 0 (≃-sym (≡-isNType𝒰-≃ 0 (X , p) (X' , p')))
     (≃-isNType⇒isNType 0 (≃-sym (≡-𝒰-≃ X X'))
       (isPointedProp⇒isContr (X  X')
         (≃-trans (isContr⇒≃𝟙 X p) (≃-sym (isContr⇒≃𝟙 X' p')) ,
           f g 
            pair⁼(
              funext  x  isContr⇒isProp X' p' (pr₁ f x) (pr₁ g x)) ,
              isProp-isEquiv _ _ _)))))
 where
  X≃1 = isContr⇒≃𝟙 X p
  X'≃1 = isContr⇒≃𝟙 X' p'
isNType-isNType (succ n) X X' =
   ≃-isNType⇒isNType (succ n) (≃-sym (≡-isNType𝒰-≃ (succ n) X X'))
     (≃-isNType⇒isNType (succ n) (≃-sym (≡-𝒰-≃ (pr₁ X) (pr₁ X')))
       (isEmbedding-isNType⇒isNType n pr₁
         (isEmbedding-pr₁-isNType𝒰-≃ (succ n) X X')
         (isNType-Π (succ n) λ _  (pr₂ X')) ))

7.2. Uniqueness of identity proofs and Hedberg’s theorem

hasAxiomK : 𝒰 𝒾  𝒰 𝒾
hasAxiomK X = {x : X} (p : x  x)  (p  refl x)

-- Theorem 7.2.1.
isSet⇒hasAxiomK : {X : 𝒰 𝒾}  isSet X  hasAxiomK X
isSet⇒hasAxiomK f p = f p (refl _)

hasAxiomK⇒isSet : {X : 𝒰 𝒾}  hasAxiomK X  isSet X
hasAxiomK⇒isSet f p (refl x) = f p

-- Theorem 7.2.2.
mereRelation⇒≡⇒isSet :
       {X : 𝒰 𝒾} (R : mereRelation X 𝒿)
      ((x : X)  pr₁ (R(x , x)))
      ((x y : X)  pr₁ (R(x , y))  x  y)
      isSet X
mereRelation⇒≡⇒isSet R ρ f =
 hasAxiomK⇒isSet  {x} p  ∙-left-cancel (f x x (ρ x)) (begin
  f x x (ρ x)  p                  ≡˘⟨ tr-Homc─ x p (f x x (ρ x)) 
  tr  v  x  v) p (f x x (ρ x)) ≡⟨ ≃-→ (≡-tr-Π-≃ p (f x x) (f x x))
                                          (apd (f x) p) (ρ x) 
  f x x (tr  v  pr₁ (R (x , v)))
            p (ρ x))               ≡⟨ ap (f x x) (pr₂ (R(x , x)) _ _) 
  f x x (ρ x)                      ≡˘⟨ refl-right 
  f x x (ρ x)  refl x             ))

-- Corollary 7.2.3.
hasRAA-Equality⇒isSet :
       {X : 𝒰 𝒾}
      ((x y : X)  ¬¬(x  y)  (x  y))
      isSet X
hasRAA-Equality⇒isSet f =
  mereRelation⇒≡⇒isSet
     (x , y)  ¬¬(x  y)
    , λ g h  funext  -  isProp-𝟘 _ _))
     x  λ p  p (refl x))
    f

-- Lemma 7.2.4.
isDecidable⇒hasRAA :
    {A : 𝒰 𝒾}
   isDecidable A
   hasRAA A
isDecidable⇒hasRAA {A = A} f =
  ⊎-rec (¬¬ A  A)  a -  a)  f g  !𝟘 A (g f) ) f

-- Theorem 7.2.5.
Hedberg : {X : 𝒰 𝒾}
         hasDecidableEquality X
         isSet X
Hedberg f =
  hasRAA-Equality⇒isSet
     x y  isDecidable⇒hasRAA (f x y))

-- Theorem 7.2.6.
hasDecidableEquality-ℕ : hasDecidableEquality 
hasDecidableEquality-ℕ zero zero = inl (refl zero)
hasDecidableEquality-ℕ zero (succ y) = inr (¬0≡succ y)
hasDecidableEquality-ℕ (succ x) zero = inr (¬succ≡0 x)
hasDecidableEquality-ℕ (succ x) (succ y) =
  ⊎-rec (isDecidable (succ x  succ y))
         p  inl(ap succ p))
         f  inr p  f (sm≡sn⇒m≡n p)))
        (hasDecidableEquality-ℕ x y)

-- Lemma 7.2.8.
inhab-isNType⇒isNType : {X : 𝒰 𝒾} (n : )
                       ((x : X)  isNType (succ n) X)
                       isNType (succ n) X
inhab-isNType⇒isNType n f x y = f x x y

-- Theorem 7.2.7.
isNType⇒isNType-Ω : {X : 𝒰 𝒾} (n : )
                  (isNType (succ (succ n)) X)
                  ((x : X)  isNType (succ n) (x  x))
isNType⇒isNType-Ω n p x = p x x

isNType-Ω⇒isNType : {X : 𝒰 𝒾} (n : )
                  ((x : X)  isNType (succ n) (x  x))
                  (isNType (succ (succ n)) X)
isNType-Ω⇒isNType n f x x' = inhab-isNType⇒isNType n lemma
  where
    lemma : x  x'  isNType (succ n) (x  x')
    lemma (refl x) = f x

-- Theorem 7.2.9.
isNType⇒isContr-Ω : {A : 𝒰 𝒾} (n : )
                   isNType (succ n) A
                   ((a : A)  isContr (pr₁ (Ωⁿ n (A , a))))
isNType⇒isContr-Ω 0 f a = isProp⇒inhab→isContr (is-1Type⇒isProp f) a
isNType⇒isContr-Ω 1 f a =
  (refl a , λ p  (isSet⇒hasAxiomK (is0Type⇒isSet f) p)⁻¹)
isNType⇒isContr-Ω (succ (succ n)) f a =
  (isNType⇒isContr-Ω (succ n) (isNType⇒isNType-Ω (succ n) f a)) (refl a)

isContr-Ω⇒isNType : {A : 𝒰 𝒾} (n : )
                   ((a : A)  isContr (pr₁ (Ωⁿ n (A , a))))
                   isNType (succ n) A
isContr-Ω⇒isNType 0 f = isProp⇒is-1Type (inhab→isContr⇒isProp f)
isContr-Ω⇒isNType 1 f =
  isSet⇒is0Type (hasAxiomK⇒isSet λ p  (pr₂ (f _) p)⁻¹  (pr₂ (f _) (refl _)))
isContr-Ω⇒isNType {A = A} (succ (succ n)) f =
  isNType-Ω⇒isNType (succ n)
     a  isContr-Ω⇒isNType (succ n)
              p  tr isContr (ap (pr₁  Ωⁿ n) (lemma a p)) (f a)))
 where
  lemma : (a : A) (p : a  a)
         (Ω ((a  a) , refl a))  (Ω ((a  a) , p))
  lemma a p = (pair⁼(ua eqv , ((≡-𝒰-comp eqv (pr₂ (Ω ((a  a) , p))))
        (ap (_∙ ⁻¹-right∙ p) refl-right )  ⁻¹-left∙ (⁻¹-right∙ p))))⁻¹
   where
    eqv : pr₁ (Ω ((a  a) , p))  pr₁ (Ω ((a  a) , refl a))
    eqv =
     ((_ , isEquiv⇒isEquiv-ap (_∙ p ⁻¹) (invs⇒equivs _ (isQinv-─∙ (p ⁻¹))) p p)
       ≃∙ (_ , invs⇒equivs _ (isQinv-∙─ ((⁻¹-right∙ p)⁻¹)))
       ≃∙ (_ , invs⇒equivs _ (isQinv-─∙ (⁻¹-right∙ p))))

7.3. Truncations

postulate -- take care of numbers...
  ∥_∥ₙ : {𝒾 : Level}  (A : 𝒰 𝒾)  (n : )  𝒰 𝒾
  ∣_∣ₙ : {𝒾 : Level}  {A : 𝒰 𝒾}  A  (n : )   A ∥ₙ n
  ∥∥ₙ-hub : {𝒾 : Level} {A : 𝒰 𝒾} (n : )
          (𝕊ⁿ n   A ∥ₙ (succ n))
          ( A ∥ₙ (succ n))
  ∥∥ₙ-spoke : {𝒾 : Level} {A : 𝒰 𝒾} (n : )
             (r : 𝕊ⁿ n   A ∥ₙ (succ n))
             (x : 𝕊ⁿ n)  (r x  ∥∥ₙ-hub n r)
  ∥∥₋₂ : {𝒾 : Level}  (A : 𝒰 𝒾)   A ∥ₙ 0  𝟙

-- Lemma 7.3.1.
isNType-∥∥ₙ : (A : 𝒰 𝒾)  (n : )  isNType n ( A ∥ₙ n)
isNType-∥∥ₙ A zero = ≃𝟙⇒isContr ( A ∥ₙ zero) (∥∥₋₂ A)
isNType-∥∥ₙ A (succ n) =
  isContr-Ω⇒isNType n
     b  ≃-isNType⇒isNType 0 (Map*𝕊ⁿ→-≃Ωⁿ n ( A ∥ₙ (succ n) , b)) (lemma b))
 where
  lemma : (b :  A ∥ₙ (succ n))
         isContr (Map* (𝕊ⁿ n , N𝕊ⁿ n) ( A ∥ₙ (succ n) , b))
  lemma b = (((λ x  b) , refl b) , contr)
   where
    contr : ((r , p) : Map* (𝕊ⁿ n , N𝕊ⁿ n) ( A ∥ₙ (succ n) , b))
           ((λ x  b) , refl b)  (r , p)
    contr (r , p) = pair⁼(funext htpy , (begin
      tr  f  f (N𝕊ⁿ n)  b) (funext htpy) (refl b)  ≡⟨ i 
      (ap  f  f (N𝕊ⁿ n)) (funext htpy))⁻¹  refl b
         ap  _  b) (funext htpy)                   ≡⟨ ii 
      (ap  f  f (N𝕊ⁿ n)) (funext htpy))⁻¹
         ap  _  b) (funext htpy)                   ≡⟨ iii 
      (ap  f  f (N𝕊ⁿ n)) (funext htpy))⁻¹
         refl _ ≡⟨ iv 
      (ap  f  f (N𝕊ⁿ n)) (funext htpy))⁻¹           ≡⟨ v 
      (p ⁻¹  ∥∥ₙ-spoke n r (N𝕊ⁿ n)
         ((∥∥ₙ-spoke n r ((N𝕊ⁿ n)))⁻¹))⁻¹             ≡⟨ vi 
      (p ⁻¹  (∥∥ₙ-spoke n r (N𝕊ⁿ n)
         ((∥∥ₙ-spoke n r ((N𝕊ⁿ n)))⁻¹)))⁻¹            ≡⟨ vii 
      (p ⁻¹  refl _)⁻¹                                ≡⟨ viii 
      (p ⁻¹)⁻¹                                         ≡⟨ ix 
      p ))
     where
      htpy = λ x  p ⁻¹  ∥∥ₙ-spoke n r (N𝕊ⁿ n)  ((∥∥ₙ-spoke n r x)⁻¹)
      i = tr-fx≡gx  f  f (N𝕊ⁿ n))  _  b) _ (refl b)
      ii = ap (_∙ ap  _  b) (funext htpy)) refl-right
      iii = ap ((ap  f  f (N𝕊ⁿ n)) (funext htpy))⁻¹ ∙_) (ap-const _ b)
      iv = refl-right
      v = ap (_⁻¹) (happly (≡-Π-comp htpy) (N𝕊ⁿ n))
      vi = ap (_⁻¹) (∙-assoc (p ⁻¹))
      vii = ap  -  (p ⁻¹  -)⁻¹) (⁻¹-right∙ (∥∥ₙ-spoke n r (N𝕊ⁿ n)))
      viii = ap (_⁻¹) refl-right
      ix = ⁻¹-involutive p