Other Agda modules in this section (76)

Complete compiler-highlighted source. Follow a symbol to its declaration.

Corresponding book passages
# Checking equivalences on mapping animae

The recognition argument uses only the two test categories appearing in
the proof: the source and the target of the functor. This also makes the
anima-only variant immediate when both categories are animae.

```agda
{-# OPTIONS --safe --without-K #-}
open import Agda.Primitive using (Level)
open import SCT.VolumeI.Chapter01.Theory using (Theory)
import SCT.VolumeI.Chapter01.Section04.Setup as Setup
import SCT.VolumeI.Chapter01.Section04.MappingAnimae as Mapping
import SCT.VolumeI.Chapter01.Section04.Currying as Currying
import SCT.VolumeI.Chapter01.Section04.Points as Points
import SCT.VolumeI.Chapter01.Section04.Functoriality as Functoriality

module SCT.VolumeI.Chapter01.Section04.EquivalenceDetection
  {c m a : Level} (𝒯 : Theory c m a) (M : Mapping.MappingAnimae 𝒯) where

open Setup 𝒯
open Mapping.MappingAnimae M
open Currying 𝒯 M
open Points 𝒯 M
open Functoriality 𝒯 M

unnamedIso : {C D : CAT} {f g : MAP C D}
  β†’ (nameMap f) =₁ (nameMap g) β†’ f =₁ g
unnamedIso {f = f} {g} Ξ± = decode-name g βˆ™ (decodeMapIso Ξ± βˆ™ (decode-name f) ⁻¹)

mapPost-name : {B C D : CAT} (f : MAP C D) (g : MAP B C)
  β†’ (mapPost f ∘ nameMap g) =₁ (nameMap (f ∘ g))
mapPost-name f g = mapReflect one-isAn _ _
  ((mapCurry-Ξ² one-isAn ((f ∘ g) ∘ prβ‚‚)) ⁻¹ βˆ™
  ((comp-assoc prβ‚‚ g f) ⁻¹ βˆ™
  ((f ◁ mapCurry-Ξ² one-isAn (g ∘ prβ‚‚)) βˆ™ mapPost-uncurry f (nameMap g))))

mapPre-name : {B C D : CAT} (f : MAP B C) (g : MAP C D)
  β†’ (mapPre f ∘ nameMap g) =₁ (nameMap (g ∘ f))
mapPre-name f g = mapReflect one-isAn _ _
  ((mapCurry-Ξ² one-isAn ((g ∘ f) ∘ prβ‚‚)) ⁻¹ βˆ™
  ((comp-assoc prβ‚‚ f g) ⁻¹ βˆ™
  ((g ◁ pair-Ξ²β‚‚ (id One ∘ pr₁) (f ∘ prβ‚‚)) βˆ™
  (comp-assoc (productMap (id One) f) prβ‚‚ g βˆ™
  ((mapCurry-Ξ² one-isAn (g ∘ prβ‚‚) β–· productMap (id One) f) βˆ™
     mapPre-uncurry f (nameMap g))))))
```

An equivalence on a mapping anima reflects the isomorphisms between named
functors. The named comparisons above transport the endpoints; no strict
identification of a functor with its representing point is used.

```agda
mapPost-reflect : {B C D : CAT} (f : MAP C D)
  β†’ IsEquiv (mapPost {C = B} f)
  β†’ (g h : MAP B C) β†’ (f ∘ g) =₁ (f ∘ h) β†’ g =₁ h
mapPost-reflect f e g h Ξ± = unnamedIso (equiv-reflect e (nameMap g) (nameMap h)
  ((mapPost-name f h) ⁻¹ βˆ™ (nameMapIso Ξ± βˆ™ mapPost-name f g)))

mapPre-reflect : {B C D : CAT} (f : MAP B C)
  β†’ IsEquiv (mapPre {D = D} f)
  β†’ (g h : MAP C D) β†’ (g ∘ f) =₁ (h ∘ f) β†’ g =₁ h
mapPre-reflect f e g h Ξ± = unnamedIso (equiv-reflect e (nameMap g) (nameMap h)
  ((mapPre-name f h) ⁻¹ βˆ™ (nameMapIso Ξ± βˆ™ mapPre-name f g)))

mapPost-section : {C D : CAT} (f : MAP C D)
  β†’ IsEquiv (mapPost {C = D} f) β†’ Section f
mapPost-section {D = D} f e = record
  { section = decodeMap point
  ; comparison = unnamedIso
      (FunctorLift.comparison chosen βˆ™
        ((mapPost f ◁ name-decode point) βˆ™ (mapPost-name f (decodeMap point)) ⁻¹))
  }
  where
  chosen : FunctorLift (mapPost f) (nameMap (id D))
  chosen = equiv-lift e (nameMap (id D))
  point = FunctorLift.lift chosen

mapPre-retraction : {C D : CAT} (f : MAP C D)
  β†’ IsEquiv (mapPre {D = C} f) β†’ Retraction f
mapPre-retraction {C} f e = record
  { retraction = decodeMap point
  ; comparison = (unnamedIso
      (FunctorLift.comparison chosen βˆ™
        ((mapPre f ◁ name-decode point) βˆ™ (mapPre-name f (decodeMap point)) ⁻¹))) ⁻¹
  }
  where
  chosen : FunctorLift (mapPre f) (nameMap (id C))
  chosen = equiv-lift e (nameMap (id C))
  point = FunctorLift.lift chosen
```

For postcomposition, first lift the identity of the target to obtain a
section, then reflect the other inverse comparison using the source test.
For precomposition the dual argument first obtains a retraction.

```agda
post-tests-isEquiv : {C D : CAT} (f : MAP C D)
  β†’ IsEquiv (mapPost {C = C} f) β†’ IsEquiv (mapPost {C = D} f) β†’ IsEquiv f
post-tests-isEquiv {C} {D} f sourceTest targetTest = record
  { inverse = g
  ; sectionIso = (mapPost-reflect f sourceTest (g ∘ f) (id C)
      ((comp-unitΚ³ f) ⁻¹ βˆ™
        (comp-unitΛ‘ f βˆ™ ((Section.comparison s β–· f) βˆ™ (comp-assoc f g f) ⁻¹)))) ⁻¹
  ; retractionIso = (Section.comparison s) ⁻¹
  }
  where
  s = mapPost-section f targetTest
  g = Section.section s

pre-tests-isEquiv : {C D : CAT} (f : MAP C D)
  β†’ IsEquiv (mapPre {D = C} f) β†’ IsEquiv (mapPre {D = D} f) β†’ IsEquiv f
pre-tests-isEquiv {C} {D} f sourceTest targetTest = record
  { inverse = g
  ; sectionIso = Retraction.comparison r
  ; retractionIso = (mapPre-reflect f targetTest (f ∘ g) (id D)
      ((comp-unitΛ‘ f) ⁻¹ βˆ™
        (comp-unitΚ³ f βˆ™ ((f ◁ (Retraction.comparison r) ⁻¹) βˆ™ comp-assoc f g f)))) ⁻¹
  }
  where
  r = mapPre-retraction f sourceTest
  g = Retraction.retraction r

post-tests-all : {C D : CAT} (f : MAP C D)
  β†’ ((E : CAT) β†’ IsEquiv (mapPost {C = E} f)) β†’ IsEquiv f
post-tests-all {C} {D} f tests = post-tests-isEquiv f (tests C) (tests D)

pre-tests-all : {C D : CAT} (f : MAP C D)
  β†’ ((E : CAT) β†’ IsEquiv (mapPre {D = E} f)) β†’ IsEquiv f
pre-tests-all {C} {D} f tests = pre-tests-isEquiv f (tests C) (tests D)

post-tests-animae : {C D : CAT} β†’ isAn C β†’ isAn D β†’ (f : MAP C D)
  β†’ ((E : CAT) β†’ isAn E β†’ IsEquiv (mapPost {C = E} f)) β†’ IsEquiv f
post-tests-animae {C} {D} cAn dAn f tests = post-tests-isEquiv f (tests C cAn) (tests D dAn)

pre-tests-animae : {C D : CAT} β†’ isAn C β†’ isAn D β†’ (f : MAP C D)
  β†’ ((E : CAT) β†’ isAn E β†’ IsEquiv (mapPre {D = E} f)) β†’ IsEquiv f
pre-tests-animae {C} {D} cAn dAn f tests = pre-tests-isEquiv f (tests C cAn) (tests D dAn)
```

Together with `mapPost-isEquiv` and `mapPre-isEquiv`, these give all
directions of the equivalence-detection proposition.