module Cat.Displayed.Morphism
  {o β„“ o' β„“'}
  {ℬ : Precategory o β„“}
  (β„° : Displayed ℬ o' β„“')
  where

Displayed morphismsπŸ”—

This module defines the displayed analogs of monomorphisms, epimorphisms, and isomorphisms.

MonosπŸ”—

Displayed monomorphisms have the the same left-cancellation properties as their non-displayed counterparts. However, they must be displayed over a monomorphism in the base.

is-monic[_]
  : βˆ€ {a' : Ob[ a ]} {b' : Ob[ b ]} {f : Hom a b}
  β†’ is-monic f β†’ Hom[ f ] a' b'
  β†’ Type _
is-monic[_] {a = a} {a' = a'} {f = f} mono f' =
  βˆ€ {c c'} {g h : Hom c a}
  β†’ (g' : Hom[ g ] c' a') (h' : Hom[ h ] c' a')
  β†’ (p : f ∘ g ≑ f ∘ h)
  β†’ f' ∘' g' ≑[ p ] f' ∘' h'
  β†’ g' ≑[ mono g h p ] h'

is-monic[]-is-prop
  : βˆ€ {a' : Ob[ a ]} {b' : Ob[ b ]} {f : Hom a b}
  β†’ (mono : is-monic f) β†’ (f' : Hom[ f ] a' b')
  β†’ is-prop (is-monic[ mono ] f')
is-monic[]-is-prop {a' = a'} mono f' mono[] mono[]' i {c' = c'} g' h' p p' =
  is-set→squarep (λ i j → Hom[ mono _ _ p j ]-set c' a')
    refl (mono[] g' h' p p') (mono[]' g' h' p p') refl i

record _β†ͺ[_]_
  {a b} (a' : Ob[ a ]) (f : a β†ͺ b) (b' : Ob[ b ])
  : Type (o βŠ” β„“ βŠ” o' βŠ” β„“')
  where
  no-eta-equality
  field
    mor' : Hom[ f .mor ] a' b'
    monic' : is-monic[ f .monic ] mor'

open _β†ͺ[_]_ public

Weak monosπŸ”—

When working in a displayed setting, we also have weaker versions of the morphism classes we are familiar with, wherein we can only left/right cancel morphisms that are displayed over the same morphism in the base. We denote these morphisms classes as β€œweak”.

is-weak-monic
  : βˆ€ {a' : Ob[ a ]} {b' : Ob[ b ]} {f : Hom a b}
  β†’ Hom[ f ] a' b'
  β†’ Type _
is-weak-monic {a = a} {a' = a'} {f = f} f' =
  βˆ€ {c c'} {g : Hom c a}
  β†’ (g' g'' : Hom[ g ] c' a')
  β†’ f' ∘' g' ≑ f' ∘' g''
  β†’ g' ≑ g''

is-weak-monic-is-prop
  : βˆ€ {a' : Ob[ a ]} {b' : Ob[ b ]} {f : Hom a b}
  β†’ (f' : Hom[ f ] a' b')
  β†’ is-prop (is-weak-monic f')
is-weak-monic-is-prop f' mono mono' i g' g'' p =
  is-prop→pathp (λ i → Hom[ _ ]-set _ _ g' g'')
    (mono g' g'' p) (mono' g' g'' p) i

record weak-mono-over
  {a b} (f : Hom a b) (a' : Ob[ a ]) (b' : Ob[ b ])
  : Type (o βŠ” β„“ βŠ” o' βŠ” β„“')
  where
  no-eta-equality
  field
    mor' : Hom[ f ] a' b'
    weak-monic : is-weak-monic mor'

open weak-mono-over public

EpisπŸ”—

Displayed epimorphisms are defined in a similar fashion.

is-epic[_]
  : βˆ€ {a' : Ob[ a ]} {b' : Ob[ b ]} {f : Hom a b}
  β†’ is-epic f β†’ Hom[ f ] a' b'
  β†’ Type _
is-epic[_] {b = b} {b' = b'} {f = f} epi f' =
  βˆ€ {c} {c'} {g h : Hom b c}
  β†’ (g' : Hom[ g ] b' c') (h' : Hom[ h ] b' c')
  β†’ (p : g ∘ f ≑ h ∘ f)
  β†’ g' ∘' f' ≑[ p ] h' ∘' f'
  β†’ g' ≑[ epi g h p ] h'

is-epic[]-is-prop
  : βˆ€ {a' : Ob[ a ]} {b' : Ob[ b ]} {f : Hom a b}
  β†’ (epi : is-epic f) β†’ (f' : Hom[ f ] a' b')
  β†’ is-prop (is-epic[ epi ] f')
is-epic[]-is-prop {b' = b'} epi f' epi[] epi[]' i {c' = c'} g' h' p p' =
  is-set→squarep (λ i j → Hom[ epi _ _ p j ]-set b' c')
    refl (epi[] g' h' p p') (epi[]' g' h' p p') refl i

record _β† [_]_
  {a b} (a' : Ob[ a ]) (f : a β†  b) (b' : Ob[ b ])
  : Type (o βŠ” β„“ βŠ” o' βŠ” β„“')
  where
  no-eta-equality
  field
    mor' : Hom[ f .mor ] a' b'
    epic' : is-epic[ f .epic ] mor'

open _β† [_]_ public

Weak episπŸ”—

We can define a weaker notion of epis that is dual to the definition of a weak mono.

is-weak-epic
  : βˆ€ {a' : Ob[ a ]} {b' : Ob[ b ]} {f : Hom a b}
  β†’ Hom[ f ] a' b'
  β†’ Type _
is-weak-epic {b = b} {b' = b'} {f = f} f' =
  βˆ€ {c c'} {g : Hom b c}
  β†’ (g' g'' : Hom[ g ] b' c')
  β†’ g' ∘' f' ≑ g'' ∘' f'
  β†’ g' ≑ g''

is-weak-epic-is-prop
  : βˆ€ {a' : Ob[ a ]} {b' : Ob[ b ]} {f : Hom a b}
  β†’ (f' : Hom[ f ] a' b')
  β†’ is-prop (is-weak-monic f')
is-weak-epic-is-prop f' epi epi' i g' g'' p =
  is-prop→pathp (λ i → Hom[ _ ]-set _ _ g' g'')
    (epi g' g'' p) (epi' g' g'' p) i

record weak-epi-over
  {a b} (f : Hom a b) (a' : Ob[ a ]) (b' : Ob[ b ])
  : Type (o βŠ” β„“ βŠ” o' βŠ” β„“')
  where
  no-eta-equality
  field
    mor' : Hom[ f ] a' b'
    weak-epic : is-weak-epic mor'

open weak-epi-over public

SectionsπŸ”—

Following the same pattern as before, we define a notion of displayed sections.

_section-of[_]_
  : βˆ€ {x y} {s : Hom y x} {r : Hom x y}
  β†’ βˆ€ {x' y'} (s' : Hom[ s ] y' x') β†’ s section-of r β†’ (r' : Hom[ r ] x' y')
  β†’ Type _
s' section-of[ p ] r' = r' ∘' s' ≑[ p ] id'

record has-section[_]
  {x y x' y'} {r : Hom x y} (sect : has-section r) (r' : Hom[ r ] x' y')
  : Type β„“'
  where
  no-eta-equality
  field
    section' : Hom[ sect .section ] y' x'
    is-section' : section' section-of[ sect .is-section ] r'

open has-section[_] public

We also distinguish the sections that are displayed over the identity morphism; these are known as β€œvertical sections”.

_section-of↓_
  : βˆ€ {x} {x' x'' : Ob[ x ]} (s' : Hom[ id ] x'' x') β†’ (r : Hom[ id ] x' x'')
  β†’ Type _
s' section-of↓ r' = s' section-of[ idl id ] r'

has-section↓ : βˆ€ {x} {x' x'' : Ob[ x ]} (r' : Hom[ id ] x' x'') β†’ Type _
has-section↓ r' = has-section[ id-has-section ] r'

RetractsπŸ”—

We can do something similar for retracts.

_retract-of[_]_
  : βˆ€ {x y} {s : Hom y x} {r : Hom x y}
  β†’ βˆ€ {x' y'} (r' : Hom[ r ] x' y') β†’ r retract-of s β†’ (s' : Hom[ s ] y' x')
  β†’ Type _
r' retract-of[ p ] s' = r' ∘' s' ≑[ p ] id'


record has-retract[_]
  {x y x' y'} {s : Hom x y} (ret : has-retract s) (s' : Hom[ s ] x' y')
  : Type β„“'
  where
  no-eta-equality
  field
    retract' : Hom[ ret .retract ] y' x'
    is-retract' : retract' retract-of[ ret .is-retract ] s'

open has-retract[_] public

We also define vertical retracts in a similar manner as before.

_retract-of↓_
  : βˆ€ {x} {x' x'' : Ob[ x ]} (r' : Hom[ id ] x' x'') β†’ (s : Hom[ id ] x'' x')
  β†’ Type _
r' retract-of↓ s' = r' retract-of[ idl id ] s'

has-retract↓ : βˆ€ {x} {x' x'' : Ob[ x ]} (s' : Hom[ id ] x'' x') β†’ Type _
has-retract↓ s' = has-retract[ id-has-retract ] s'

IsosπŸ”—

Displayed isomorphisms must also be defined over isomorphisms in the base.

record Inverses[_]
  {a b a' b'} {f : Hom a b} {g : Hom b a}
  (inv : Inverses f g)
  (f' : Hom[ f ] a' b') (g' : Hom[ g ] b' a')
  : Type β„“'
  where
  no-eta-equality
  field
    invl' : f' ∘' g' ≑[ Inverses.invl inv ] id'
    invr' : g' ∘' f' ≑[ Inverses.invr inv ] id'

record is-invertible[_]
  {a b a' b'} {f : Hom a b}
  (f-inv : is-invertible f)
  (f' : Hom[ f ] a' b')
  : Type β„“'
  where
  no-eta-equality
  field
    inv' : Hom[ is-invertible.inv f-inv ] b' a'
    inverses' : Inverses[ is-invertible.inverses f-inv ] f' inv'

  open Inverses[_] inverses' public

record _β‰…[_]_
  {a b} (a' : Ob[ a ]) (i : a β‰… b) (b' : Ob[ b ])
  : Type β„“'
  where
  no-eta-equality
  field
    to' : Hom[ i .to ] a' b'
    from' : Hom[ i .from ] b' a'
    inverses' : Inverses[ i .inverses ] to' from'

  open Inverses[_] inverses' public

open _β‰…[_]_ public

Since isomorphisms over the identity map will be of particular importance, we also define their own type: they are the vertical isomorphisms.

_≅↓_ : {x : Ob} (A B : Ob[ x ]) β†’ Type β„“'
_≅↓_ = _β‰…[ id-iso ]_

is-invertible↓ : {x : Ob} {x' x'' : Ob[ x ]} β†’ Hom[ id ] x' x'' β†’ Type _
is-invertible↓ = is-invertible[ id-invertible ]

make-invertible↓
  : βˆ€ {x} {x' x'' : Ob[ x ]} {f' : Hom[ id ] x' x''}
  β†’ (g' : Hom[ id ] x'' x')
  β†’ f' ∘' g' ≑[ idl _ ] id'
  β†’ g' ∘' f' ≑[ idl _ ] id'
  β†’ is-invertible↓ f'
make-invertible↓ g' p q .is-invertible[_].inv' = g'
make-invertible↓ g' p q .is-invertible[_].inverses' .Inverses[_].invl' = p
make-invertible↓ g' p q .is-invertible[_].inverses' .Inverses[_].invr' = q

Like their non-displayed counterparts, existence of displayed inverses is a proposition.

Inverses[]-are-prop
  : βˆ€ {a b a' b'} {f : Hom a b} {g : Hom b a}
  β†’ (inv : Inverses f g)
  β†’ (f' : Hom[ f ] a' b') (g' : Hom[ g ] b' a')
  β†’ is-prop (Inverses[ inv ] f' g')
Inverses[]-are-prop inv f' g' inv[] inv[]' i .Inverses[_].invl' =
  is-set→squarep (λ i j → Hom[ Inverses.invl inv j ]-set _ _)
    refl (Inverses[_].invl' inv[]) (Inverses[_].invl' inv[]') refl i
Inverses[]-are-prop inv f' g' inv[] inv[]' i .Inverses[_].invr' =
  is-set→squarep (λ i j → Hom[ Inverses.invr inv j ]-set _ _)
    refl (Inverses[_].invr' inv[]) (Inverses[_].invr' inv[]') refl i

is-invertible[]-is-prop
  : βˆ€ {a b a' b'} {f : Hom a b}
  β†’ (f-inv : is-invertible f)
  β†’ (f' : Hom[ f ] a' b')
  β†’ is-prop (is-invertible[ f-inv ] f')
is-invertible[]-is-prop inv f' p q = path where
  module inv = is-invertible inv
  module p = is-invertible[_] p
  module q = is-invertible[_] q

  inv≑inv' : p.inv' ≑ q.inv'
  inv≑inv' =
    p.inv'                           β‰‘βŸ¨ shiftr (insertr inv.invl) (insertr' _ q.invl') βŸ©β‰‘
    hom[] ((p.inv' ∘' f') ∘' q.inv') β‰‘βŸ¨ weave _ (eliml inv.invr) refl (eliml' _ p.invr') βŸ©β‰‘
    hom[] q.inv'                     β‰‘βŸ¨ liberate _ βŸ©β‰‘
    q.inv' ∎

  path : p ≑ q
  path i .is-invertible[_].inv' = inv≑inv' i
  path i .is-invertible[_].inverses' =
    is-propβ†’pathp (Ξ» i β†’ Inverses[]-are-prop inv.inverses f' (inv≑inv' i))
      p.inverses' q.inverses' i
make-iso[_]
  : βˆ€ {a b a' b'}
  β†’ (iso : a β‰… b)
  β†’ (f' : Hom[ iso .to ] a' b') (g' : Hom[ iso .from ] b' a')
  β†’ f' ∘' g' ≑[ iso .invl ] id'
  β†’ g' ∘' f' ≑[ iso .invr ] id'
  β†’ a' β‰…[ iso ] b'
make-iso[ inv ] f' g' p q .to' = f'
make-iso[ inv ] f' g' p q .from' = g'
make-iso[ inv ] f' g' p q .inverses' .Inverses[_].invl' = p
make-iso[ inv ] f' g' p q .inverses' .Inverses[_].invr' = q

make-vertical-iso
  : βˆ€ {x} {x' x'' : Ob[ x ]}
  β†’ (f' : Hom[ id ] x' x'') (g' : Hom[ id ] x'' x')
  β†’ f' ∘' g' ≑[ idl _ ] id'
  β†’ g' ∘' f' ≑[ idl _ ] id'
  β†’ x' ≅↓ x''
make-vertical-iso = make-iso[ id-iso ]

invertible[]β†’iso[]
  : βˆ€ {a b a' b'} {f : Hom a b} {f' : Hom[ f ] a' b'}
  β†’ {i : is-invertible f}
  β†’ is-invertible[ i ] f'
  → a' ≅[ invertible→iso f i ] b'
invertible[]β†’iso[] {f' = f'} i =
  make-iso[ _ ]
    f'
    (is-invertible[_].inv' i)
    (is-invertible[_].invl' i)
    (is-invertible[_].invr' i)

β‰…[]-path
  : {x y : Ob} {A : Ob[ x ]} {B : Ob[ y ]} {f : x β‰… y}
    {p q : A β‰…[ f ] B}
  β†’ p .to' ≑ q .to'
  β†’ p ≑ q
β‰…[]-path {f = f} {p = p} {q = q} a = it where
  p' : PathP (λ i → is-invertible[ iso→invertible f ] (a i))
    (record { inv' = p .from' ; inverses' = p .inverses' })
    (record { inv' = q .from' ; inverses' = q .inverses' })
  p' = is-prop→pathp (λ i → is-invertible[]-is-prop _ (a i)) _ _

  it : p ≑ q
  it i .to'       = a i
  it i .from'     = p' i .is-invertible[_].inv'
  it i .inverses' = p' i .is-invertible[_].inverses'

instance
  Extensional-β‰…[]
    : βˆ€ {β„“r} {x y : Ob} {x' : Ob[ x ]} {y' : Ob[ y ]} {f : x β‰… y}
    β†’ ⦃ sa : Extensional (Hom[ f .to ] x' y') β„“r ⦄
    β†’ Extensional (x' β‰…[ f ] y') β„“r
  Extensional-β‰…[] ⦃ sa ⦄ = injectionβ†’extensional! β‰…[]-path sa

As in the non-displayed case, the identity isomorphism is always an iso. In fact, it is a vertical iso!

id-iso↓ : βˆ€ {x} {x' : Ob[ x ]} β†’ x' ≅↓ x'
id-iso↓ = make-iso[ id-iso ] id' id' (idl' id') (idl' id')

Isomorphisms are also instances of sections and retracts.

inverses[]β†’to-has-section[]
  : βˆ€ {f : Hom a b} {g : Hom b a}
  β†’ βˆ€ {a' b'} {f' : Hom[ f ] a' b'} {g' : Hom[ g ] b' a'}
  β†’ {inv : Inverses f g} β†’ Inverses[ inv ] f' g'
  → has-section[ inverses→to-has-section inv ] f'
inverses[]β†’to-has-section[] {g' = g'} inv' .section' = g'
inverses[]β†’to-has-section[] inv' .is-section' = Inverses[_].invl' inv'

inverses[]β†’from-has-section[]
  : βˆ€ {f : Hom a b} {g : Hom b a}
  β†’ βˆ€ {a' b'} {f' : Hom[ f ] a' b'} {g' : Hom[ g ] b' a'}
  β†’ {inv : Inverses f g} β†’ Inverses[ inv ] f' g'
  → has-section[ inverses→from-has-section inv ] g'
inverses[]β†’from-has-section[] {f' = f'} inv' .section' = f'
inverses[]β†’from-has-section[] inv' .is-section' = Inverses[_].invr' inv'

inverses[]β†’to-has-retract[]
  : βˆ€ {f : Hom a b} {g : Hom b a}
  β†’ βˆ€ {a' b'} {f' : Hom[ f ] a' b'} {g' : Hom[ g ] b' a'}
  β†’ {inv : Inverses f g} β†’ Inverses[ inv ] f' g'
  → has-retract[ inverses→to-has-retract inv ] f'
inverses[]β†’to-has-retract[] {g' = g'} inv' .retract' = g'
inverses[]β†’to-has-retract[] inv' .is-retract' = Inverses[_].invr' inv'

inverses[]β†’from-has-retract[]
  : βˆ€ {f : Hom a b} {g : Hom b a}
  β†’ βˆ€ {a' b'} {f' : Hom[ f ] a' b'} {g' : Hom[ g ] b' a'}
  β†’ {inv : Inverses f g} β†’ Inverses[ inv ] f' g'
  → has-retract[ inverses→from-has-retract inv ] g'
inverses[]β†’from-has-retract[] {f' = f'} inv' .retract' = f'
inverses[]β†’from-has-retract[] inv' .is-retract' = Inverses[_].invl' inv'

iso[]β†’to-has-section[]
  : {f : a β‰… b} β†’ (f' : a' β‰…[ f ] b')
  → has-section[ iso→to-has-section f ] (f' .to')
iso[]β†’to-has-section[] f' .section' = f' .from'
iso[]β†’to-has-section[] f' .is-section' = f' .invl'

iso[]β†’from-has-section[]
  : {f : a β‰… b} β†’ (f' : a' β‰…[ f ] b')
  → has-section[ iso→from-has-section f ] (f' .from')
iso[]β†’from-has-section[] f' .section' = f' .to'
iso[]β†’from-has-section[] f' .is-section' = f' .invr'

iso[]β†’to-has-retract[]
  : {f : a β‰… b} β†’ (f' : a' β‰…[ f ] b')
  → has-retract[ iso→to-has-retract f ] (f' .to')
iso[]β†’to-has-retract[] f' .retract' = f' .from'
iso[]β†’to-has-retract[] f' .is-retract' = f' .invr'

iso[]β†’from-has-retract[]
  : {f : a β‰… b} β†’ (f' : a' β‰…[ f ] b')
  → has-retract[ iso→from-has-retract f ] (f' .from')
iso[]β†’from-has-retract[] f' .retract' = f' .to'
iso[]β†’from-has-retract[] f' .is-retract' = f' .invl'