module Cat.Morphism {o h} (C : Precategory o h) where
Morphismsπ
This module defines the three most important classes of morphisms that can be found in a category: monomorphisms, epimorphisms, and isomorphisms.
Monosπ
A morphism is said to be monic when it is left-cancellable. A monomorphism from to , written , is a monic morphism.
is-monic : Hom a b β Type _ is-monic {a = a} f = β {c} β (g h : Hom c a) β f β g β‘ f β h β g β‘ h is-monic-is-prop : β {a b} (f : Hom a b) β is-prop (is-monic f) is-monic-is-prop f x y i {c} g h p = Hom-set _ _ _ _ (x g h p) (y g h p) i record _βͺ_ (a b : Ob) : Type (o β h) where field mor : Hom a b monic : is-monic mor open _βͺ_ public
Conversely, a morphism is said to be epic when it is right-cancellable. An epimorphism from to , written , is an epic morphism.
Episπ
is-epic : Hom a b β Type _ is-epic {b = b} f = β {c} β (g h : Hom b c) β g β f β‘ h β f β g β‘ h is-epic-is-prop : β {a b} (f : Hom a b) β is-prop (is-epic f) is-epic-is-prop f x y i {c} g h p = Hom-set _ _ _ _ (x g h p) (y g h p) i record _β _ (a b : Ob) : Type (o β h) where field mor : Hom a b epic : is-epic mor open _β _ public
Sectionsπ
A morphism is a section of another morphism when . The intuition for this name is that picks out a cross-section of from . For instance, could map animals to their species; a section of this map would have to pick out a canonical representative of each species from the set of all animals.
_section-of_ : (s : Hom b a) (r : Hom a b) β Type _ s section-of r = r β s β‘ id section-of-is-prop : β {s : Hom b a} {r : Hom a b} β is-prop (s section-of r) section-of-is-prop = Hom-set _ _ _ _ record has-section (r : Hom a b) : Type h where constructor make-section field section : Hom b a is-section : section section-of r open has-section public id-has-section : β {a} β has-section (id {a}) id-has-section .section = id id-has-section .is-section = idl _
Retractsπ
A morphism is a retract of another morphism when . Note that this is the same equation involved in the definition of a section; retracts and sections always come in pairs. If sections solve a sort of βcurration problemβ where we are asked to pick out canonical representatives, then retracts solve a sort of βclassification problemβ.
_retract-of_ : (r : Hom a b) (s : Hom b a) β Type _ r retract-of s = r β s β‘ id retract-of-is-prop : β {s : Hom b a} {r : Hom a b} β is-prop (r retract-of s) retract-of-is-prop = Hom-set _ _ _ _ record has-retract (s : Hom b a) : Type h where constructor make-retract field retract : Hom a b is-retract : retract retract-of s open has-retract public id-has-retract : β {a} β has-retract (id {a}) id-has-retract .retract = id id-has-retract .is-retract = idl _
Isosπ
Maps and are inverses when we have and both equal to the identity. A map is invertible (or is an isomorphism) when there exists a for which and are inverses. An isomorphism is a choice of map , together with a specified inverse.
record Inverses (f : Hom a b) (g : Hom b a) : Type h where field invl : f β g β‘ id invr : g β f β‘ id open Inverses record is-invertible (f : Hom a b) : Type h where field inv : Hom b a inverses : Inverses f inv open Inverses inverses public op : is-invertible inv op .inv = f op .inverses .Inverses.invl = invr inverses op .inverses .Inverses.invr = invl inverses record _β _ (a b : Ob) : Type h where field to : Hom a b from : Hom b a inverses : Inverses to from open Inverses inverses public open _β _ public
A given map is invertible in at most one way: If you have with two inverses and , then not only are equal, but the witnesses of these equalities are irrelevant.
Inverses-are-prop : β {f : Hom a b} {g : Hom b a} β is-prop (Inverses f g) Inverses-are-prop x y i .Inverses.invl = Hom-set _ _ _ _ (x .invl) (y .invl) i Inverses-are-prop x y i .Inverses.invr = Hom-set _ _ _ _ (x .invr) (y .invr) i is-invertible-is-prop : β {f : Hom a b} β is-prop (is-invertible f) is-invertible-is-prop {a = a} {b = b} {f = f} g h = p where module g = is-invertible g module h = is-invertible h gβ‘h : g.inv β‘ h.inv gβ‘h = g.inv β‘β¨ sym (idr _) β apβ _β_ refl (sym h.invl) β©β‘ g.inv β f β h.inv β‘β¨ assoc _ _ _ Β·Β· apβ _β_ g.invr refl Β·Β· idl _ β©β‘ h.inv β p : g β‘ h p i .is-invertible.inv = gβ‘h i p i .is-invertible.inverses = is-propβpathp (Ξ» i β Inverses-are-prop {g = gβ‘h i}) g.inverses h.inverses i
We note that the identity morphism is always iso, and that isos compose:
make-inverses : {f : Hom a b} {g : Hom b a} β f β g β‘ id β g β f β‘ id β Inverses f g make-inverses p q .invl = p make-inverses p q .invr = q make-invertible : {f : Hom a b} β (g : Hom b a) β f β g β‘ id β g β f β‘ id β is-invertible f make-invertible g p q .is-invertible.inv = g make-invertible g p q .is-invertible.inverses .invl = p make-invertible g p q .is-invertible.inverses .invr = q make-iso : (f : Hom a b) (g : Hom b a) β f β g β‘ id β g β f β‘ id β a β b make-iso f g p q ._β _.to = f make-iso f g p q ._β _.from = g make-iso f g p q ._β _.inverses .Inverses.invl = p make-iso f g p q ._β _.inverses .Inverses.invr = q instance H-Level-is-invertible : β {f : Hom a b} {n} β H-Level (is-invertible f) (suc n) H-Level-is-invertible = prop-instance is-invertible-is-prop inversesβinvertible : β {f : Hom a b} {g : Hom b a} β Inverses f g β is-invertible f inversesβinvertible x .is-invertible.inv = _ inversesβinvertible x .is-invertible.inverses = x invertibleβiso : (f : Hom a b) β is-invertible f β a β b invertibleβiso f x = record { to = f ; from = x .is-invertible.inv ; inverses = x .is-invertible.inverses } is-invertible-inverse : {f : Hom a b} (g : is-invertible f) β is-invertible (g .is-invertible.inv) is-invertible-inverse g = record { inv = _ ; inverses = record { invl = invr g ; invr = invl g } } where open Inverses (g .is-invertible.inverses) isoβinvertible : (i : a β b) β is-invertible (i ._β _.to) isoβinvertible i = record { inv = i ._β _.from ; inverses = i ._β _.inverses } β -is-set : is-set (a β b) β -is-set x y p q = s where open _β _ open Inverses s : p β‘ q s i j .to = Hom-set _ _ (x .to) (y .to) (ap to p) (ap to q) i j s i j .from = Hom-set _ _ (x .from) (y .from) (ap from p) (ap from q) i j s i j .inverses = is-propβsquarep (Ξ» i j β Inverses-are-prop {f = Hom-set _ _ (x .to) (y .to) (ap to p) (ap to q) i j} {g = Hom-set _ _ (x .from) (y .from) (ap from p) (ap from q) i j}) (Ξ» i β x .inverses) (Ξ» i β p i .inverses) (Ξ» i β q i .inverses) (Ξ» i β y .inverses) i j private β -pathp-internal : (p : a β‘ c) (q : b β‘ d) β {f : a β b} {g : c β d} β PathP (Ξ» i β Hom (p i) (q i)) (f ._β _.to) (g ._β _.to) β PathP (Ξ» i β Hom (q i) (p i)) (f ._β _.from) (g ._β _.from) β PathP (Ξ» i β p i β q i) f g β -pathp-internal p q r s i .to = r i β -pathp-internal p q r s i .from = s i β -pathp-internal p q {f} {g} r s i .inverses = is-propβpathp (Ξ» j β Inverses-are-prop {f = r j} {g = s j}) (f .inverses) (g .inverses) i abstract inverse-unique : {x y : Ob} (p : x β‘ y) {b d : Ob} (q : b β‘ d) {f : x β b} {g : y β d} β PathP (Ξ» i β Hom (p i) (q i)) (f .to) (g .to) β PathP (Ξ» i β Hom (q i) (p i)) (f .from) (g .from) inverse-unique = Jβ² (Ξ» a c p β β {b d} (q : b β‘ d) {f : a β b} {g : c β d} β PathP (Ξ» i β Hom (p i) (q i)) (f .to) (g .to) β PathP (Ξ» i β Hom (q i) (p i)) (f .from) (g .from)) Ξ» x β Jβ² (Ξ» b d q β {f : x β b} {g : x β d} β PathP (Ξ» i β Hom x (q i)) (f .to) (g .to) β PathP (Ξ» i β Hom (q i) x) (f .from) (g .from)) Ξ» y {f} {g} p β f .from β‘Λβ¨ ap (f .from β_) (g .invl) β idr _ β©β‘Λ f .from β g .to β g .from β‘β¨ assoc _ _ _ β©β‘ (f .from β g .to) β g .from β‘β¨ ap (_β g .from) (ap (f .from β_) (sym p) β f .invr) β idl _ β©β‘ g .from β β -pathp : (p : a β‘ c) (q : b β‘ d) {f : a β b} {g : c β d} β PathP (Ξ» i β Hom (p i) (q i)) (f ._β _.to) (g ._β _.to) β PathP (Ξ» i β p i β q i) f g β -pathp p q {f = f} {g = g} r = β -pathp-internal p q r (inverse-unique p q {f = f} {g = g} r) βͺ-pathp : {a : I β Ob} {b : I β Ob} {f : a i0 βͺ b i0} {g : a i1 βͺ b i1} β PathP (Ξ» i β Hom (a i) (b i)) (f .mor) (g .mor) β PathP (Ξ» i β a i βͺ b i) f g βͺ-pathp {a = a} {b} {f} {g} pa = go where go : PathP (Ξ» i β a i βͺ b i) f g go i .mor = pa i go i .monic {c = c} = is-propβpathp (Ξ» i β Ξ -is-hlevel {A = Hom c (a i)} 1 Ξ» g β Ξ -is-hlevel {A = Hom c (a i)} 1 Ξ» h β fun-is-hlevel {A = pa i β g β‘ pa i β h} 1 (Hom-set c (a i) g h)) (f .monic) (g .monic) i β -pathp : {a : I β Ob} {b : I β Ob} {f : a i0 β b i0} {g : a i1 β b i1} β PathP (Ξ» i β Hom (a i) (b i)) (f .mor) (g .mor) β PathP (Ξ» i β a i β b i) f g β -pathp {a = a} {b} {f} {g} pa = go where go : PathP (Ξ» i β a i β b i) f g go i .mor = pa i go i .epic {c = c} = is-propβpathp (Ξ» i β Ξ -is-hlevel {A = Hom (b i) c} 1 Ξ» g β Ξ -is-hlevel {A = Hom (b i) c} 1 Ξ» h β fun-is-hlevel {A = g β pa i β‘ h β pa i} 1 (Hom-set (b i) c g h)) (f .epic) (g .epic) i
id-invertible : β {a} β is-invertible (id {a}) id-invertible .is-invertible.inv = id id-invertible .is-invertible.inverses .invl = idl id id-invertible .is-invertible.inverses .invr = idl id id-iso : a β a id-iso .to = id id-iso .from = id id-iso .inverses .invl = idl id id-iso .inverses .invr = idl id Isomorphism = _β _ Inverses-β : {f : Hom a b} {fβ»ΒΉ : Hom b a} {g : Hom b c} {gβ»ΒΉ : Hom c b} β Inverses f fβ»ΒΉ β Inverses g gβ»ΒΉ β Inverses (g β f) (fβ»ΒΉ β gβ»ΒΉ) Inverses-β {f = f} {fβ»ΒΉ} {g} {gβ»ΒΉ} finv ginv = record { invl = l ; invr = r } where module finv = Inverses finv module ginv = Inverses ginv abstract l : (g β f) β fβ»ΒΉ β gβ»ΒΉ β‘ id l = (g β f) β fβ»ΒΉ β gβ»ΒΉ β‘β¨ cat! C β©β‘ g β (f β fβ»ΒΉ) β gβ»ΒΉ β‘β¨ (Ξ» i β g β finv.invl i β gβ»ΒΉ) β©β‘ g β id β gβ»ΒΉ β‘β¨ cat! C β©β‘ g β gβ»ΒΉ β‘β¨ ginv.invl β©β‘ id β r : (fβ»ΒΉ β gβ»ΒΉ) β g β f β‘ id r = (fβ»ΒΉ β gβ»ΒΉ) β g β f β‘β¨ cat! C β©β‘ fβ»ΒΉ β (gβ»ΒΉ β g) β f β‘β¨ (Ξ» i β fβ»ΒΉ β ginv.invr i β f) β©β‘ fβ»ΒΉ β id β f β‘β¨ cat! C β©β‘ fβ»ΒΉ β f β‘β¨ finv.invr β©β‘ id β _βIso_ : a β b β b β c β a β c (f βIso g) .to = g .to β f .to (f βIso g) .from = f .from β g .from (f βIso g) .inverses = Inverses-β (f .inverses) (g .inverses) invertible-β : β {f : Hom b c} {g : Hom a b} β is-invertible f β is-invertible g β is-invertible (f β g) invertible-β f-inv g-inv = record { inv = g-inv.inv β f-inv.inv ; inverses = Inverses-β g-inv.inverses f-inv.inverses } where module f-inv = is-invertible f-inv module g-inv = is-invertible g-inv _invertibleβ»ΒΉ : β {f : Hom a b} β (f-inv : is-invertible f) β is-invertible (is-invertible.inv f-inv) _invertibleβ»ΒΉ {f = f} f-inv .is-invertible.inv = f _invertibleβ»ΒΉ f-inv .is-invertible.inverses .invl = is-invertible.invr f-inv _invertibleβ»ΒΉ f-inv .is-invertible.inverses .invr = is-invertible.invl f-inv _Isoβ»ΒΉ : a β b β b β a (f Isoβ»ΒΉ) .to = f .from (f Isoβ»ΒΉ) .from = f .to (f Isoβ»ΒΉ) .inverses .invl = f .inverses .invr (f Isoβ»ΒΉ) .inverses .invr = f .inverses .invl
We also note that invertible morphisms are both epic and monic.
invertibleβmonic : is-invertible f β is-monic f invertibleβmonic {f = f} invert g h p = g β‘Λβ¨ idl g β©β‘Λ id β g β‘Λβ¨ ap (_β g) (is-invertible.invr invert) β©β‘Λ (inv β f) β g β‘Λβ¨ assoc inv f g β©β‘Λ inv β (f β g) β‘β¨ ap (inv β_) p β©β‘ inv β (f β h) β‘β¨ assoc inv f h β©β‘ (inv β f) β h β‘β¨ ap (_β h) (is-invertible.invr invert) β©β‘ id β h β‘β¨ idl h β©β‘ h β where open is-invertible invert invertibleβepic : is-invertible f β is-epic f invertibleβepic {f = f} invert g h p = g β‘Λβ¨ idr g β©β‘Λ g β id β‘Λβ¨ ap (g β_) (is-invertible.invl invert) β©β‘Λ g β (f β inv) β‘β¨ assoc g f inv β©β‘ (g β f) β inv β‘β¨ ap (_β inv) p β©β‘ (h β f) β inv β‘Λβ¨ assoc h f inv β©β‘Λ h β (f β inv) β‘β¨ ap (h β_) (is-invertible.invl invert) β©β‘ h β id β‘β¨ idr h β©β‘ h β where open is-invertible invert isoβmonic : (f : a β b) β is-monic (f .to) isoβmonic f = invertibleβmonic (isoβinvertible f) isoβepic : (f : a β b) β is-epic (f .to) isoβepic f = invertibleβepic (isoβinvertible f)
Furthermore, isomorphisms also yield section/retraction pairs.
inversesβto-has-section : β {f : Hom a b} {g : Hom b a} β Inverses f g β has-section 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} β Inverses f g β has-section 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} β Inverses f g β has-retract 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} β Inverses f g β has-retract 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) β has-section (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) β has-section (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) β has-retract (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) β has-retract (f .from) isoβfrom-has-retract f .retract = f .to isoβfrom-has-retract f .is-retract = f .invl