module Cat.Bi.Base where
Prebicategoriesπ
open _=>_
module _ where
open Functor
compose-assocΛ‘: β {o β β'} {O : Type o} {H : O β O β Precategory β β'}
β (C : β {A B C} β Functor (H B C ΓαΆ H A B) (H A C))
β β {A B C D}
β Functor (H C D ΓαΆ H B C ΓαΆ H A B) (H A D)
.Fβ (F , G , H) = C .Fβ (C .Fβ (F , G) , H)
compose-assocΛ‘ C .Fβ (f , g , h) = C .Fβ (C .Fβ (f , g) , h)
compose-assocΛ‘ C .F-id = ap (C .Fβ) (Ξ£-pathp (C .F-id) refl) β C .F-id
compose-assocΛ‘ C .F-β f g = ap (C .Fβ) (Ξ£-pathp (C .F-β _ _) refl) β C .F-β _ _
compose-assocΛ‘ C
compose-assocΚ³: β {o β β'} {O : Type o} {H : O β O β Precategory β β'}
β (C : β {A B C} β Functor (H B C ΓαΆ H A B) (H A C))
β β {A B C D}
β Functor (H C D ΓαΆ H B C ΓαΆ H A B) (H A D)
.Fβ (F , G , H) = C .Fβ (F , C .Fβ (G , H))
compose-assocΚ³ C .Fβ (f , g , h) = C .Fβ (f , C .Fβ (g , h))
compose-assocΚ³ C .F-id = ap (C .Fβ) (Ξ£-pathp refl (C .F-id)) β C .F-id
compose-assocΚ³ C .F-β f g = ap (C .Fβ) (Ξ£-pathp refl (C .F-β _ _)) β C .F-β _ _
compose-assocΚ³ C
private variable o β β' oβ ββ ββ' : Level
A (pre)bicategory is the natural higher-dimensional generalisation of a (pre)category. Whereas a precategory has sets, a prebicategory has While this generalisation might seem simple, in reality, we must be very careful when setting up the resulting structure: The key observation is that precategories have no notion of equality of objects, so everything which was an equation in the definition of precategories must be replaced with (sufficiently coherent) specified isomorphisms.
The data of a prebicategory consists of a type of objects and for each a precategory We refer to the type of objects of by and call its inhabitants maps or 1-cells; In the second dimension, between each pair of maps we have a set of 2-cells (sometimes homotopies), written
The composition operation of called vertical composition, will be written As for why itβs called vertical composition, note that it reduces pasting diagrams of the form
record Prebicategory o β β' : Type (lsuc (o β β β β')) where
no-eta-equality
field
: Type o
Ob : Ob β Ob β Precategory β β'
Hom
module Hom {A} {B} = Cr (Hom A B)
Zooming out to consider the whole bicategory, we see that each object has a specified identity 1-cell as in the case for ordinary categories, but the composition operation, rather than being a function, is a functor. This, intuitively, makes sense: since we have replaced our with we should replace our maps of sets for maps of precategories, i.e., functors.
field
: β {A} β β Hom A A β
id : β {A B C} β Functor (Hom B C ΓαΆ Hom A B) (Hom A C)
compose
module compose {a} {b} {c} = Fr (compose {a} {b} {c})
Before moving on to the isomorphisms witnessing identity and associativity, we introduce a bunch of notation for the different classes of maps and all the composition operations. Observe that the action of the composition functor on homotopies reduces βhorizontalβ pasting diagrams like
whence the name horizontal composition.
_β¦_ : Ob β Ob β Type β
= β Hom A B β
A β¦ B
_β_ : β {A B} (f g : A β¦ B) β Type β'
_β_ {A} {B} f g = Hom.Hom f g
-- 1-cell composition
_β_ : β {A B C} (f : B β¦ C) (g : A β¦ B) β A β¦ C
= compose # (f , g)
f β g
-- vertical 2-cell composition
_β_ : β {A B} {f g h : A β¦ B} β g β h β f β g β f β h
_β_ {A} {B} = Hom._β_
-- horizontal 2-cell composition
_β_ : β {A B C} {fβ fβ : B β¦ C} (Ξ² : fβ β fβ) {gβ gβ : A β¦ B} (Ξ± : gβ β gβ)
β (fβ β gβ) β (fβ β gβ)
_β_ Ξ² Ξ± = compose .Functor.Fβ (Ξ² , Ξ±)
infixr 30 _β_
infixr 25 _β_
infix 35 _β_ _βΆ_
-- whiskering on the right
_βΆ_ : β {A B C} (f : B β¦ C) {a b : A β¦ B} (g : a β b) β f β a β f β b
_βΆ_ {A} {B} {C} f g = compose .Functor.Fβ (Hom.id , g)
-- whiskering on the left
_β_ : β {A B C} {a b : B β¦ C} (g : a β b) (f : A β¦ B) β a β f β b β f
_β_ {A} {B} {C} g f = compose .Functor.Fβ (g , Hom.id)
We now move onto the invertible 2-cells witnessing that the chosen identity map is a left- and right- unit element for the composition functor, and that composition is associative. In reality, to get a fully coherent structure, we need these invertible 2-cells to be given as natural isomorphisms, e.g.Β which witnesses that the functor βcompose with the identity 1-cell on the leftβ is naturally isomorphic to the identity functor.
field
: β {A B} β Cr._β
_ Cat[ Hom A B , Hom A B ] Id (Bi.Right compose id)
unitor-l : β {A B} β Cr._β
_ Cat[ Hom A B , Hom A B ] Id (Bi.Left compose id)
unitor-r
associator: β {A B C D}
β Cr._β
_ Cat[ Hom C D ΓαΆ Hom B C ΓαΆ Hom A B , Hom A D ]
(compose-assocΛ‘ {H = Hom} compose)
(compose-assocΚ³ {H = Hom} compose)
Itβs traditional to refer to the left unitor as to the right unitor as and to the associator as so we set up those abbreviations here too:
: β {A B} (f : A β¦ B) β id β f β f
Ξ»β = unitor-l .Cr._β
_.from .Ξ·
Ξ»β
: β {A B} (f : A β¦ B) β f β id β f
Ξ»β = unitor-l .Cr._β
_.to .Ξ·
Ξ»β
: β {A B} (f : A β¦ B) β f β id β f
Οβ = unitor-r .Cr._β
_.from .Ξ·
Οβ
: β {A B} (f : A β¦ B) β f β f β id
Οβ = unitor-r .Cr._β
_.to .Ξ·
Οβ
: β {A B} {f f' : A β¦ B} (Ξ² : f β f')
Οβnat β Path ((f β id) β f') (Οβ _ β (Ξ² β id)) (Ξ² β Οβ _)
{A} {B} {f} {f'} Ξ² = unitor-r .Cr.from .is-natural f f' Ξ²
Οβnat
: β {A B} {f f' : A β¦ B} (Ξ² : f β f')
Ξ»βnat β Path ((id β f) β f') (Ξ»β _ β (id βΆ Ξ²)) (Ξ² β Ξ»β _)
{A} {B} {f} {f'} Ξ² = unitor-l .Cr.from .is-natural f f' Ξ²
Ξ»βnat
: β {A B} {f f' : A β¦ B} (Ξ² : f β f')
Οβnat β Path (f β f' β id) (Οβ _ β Ξ²) ((Ξ² β id) β Οβ _)
{A} {B} {f} {f'} Ξ² = unitor-r .Cr.to .is-natural f f' Ξ²
Οβnat
: β {A B} {f f' : A β¦ B} (Ξ² : f β f')
Ξ»βnat β Path (f β id β f') (Ξ»β _ β Ξ²) ((id βΆ Ξ²) β Ξ»β _)
{A} {B} {f} {f'} Ξ² = unitor-l .Cr.to .is-natural f f' Ξ²
Ξ»βnat
: β {A B C D} (f : C β¦ D) (g : B β¦ C) (h : A β¦ B)
Ξ±β β (f β g) β h β f β (g β h)
= associator .Cr._β
_.to .Ξ· (f , g , h)
Ξ±β f g h
: β {A B C D} (f : C β¦ D) (g : B β¦ C) (h : A β¦ B)
Ξ±β β f β (g β h) β (f β g) β h
= associator .Cr._β
_.from .Ξ· (f , g , h)
Ξ±β f g h
: β {A B C D} {f f' : C β¦ D} {g g' : B β¦ C} {h h' : A β¦ B}
Ξ±βnat β (Ξ² : f β f') (Ξ³ : g β g') (Ξ΄ : h β h')
β Path (f β g β h β ((f' β g') β h'))
(Ξ±β _ _ _ β (Ξ² β (Ξ³ β Ξ΄))) (((Ξ² β Ξ³) β Ξ΄) β Ξ±β _ _ _)
{A} {B} {C} {D} {f} {f'} {g} {g'} {h} {h'} Ξ² Ξ³ Ξ΄ =
Ξ±βnat .Cr._β
_.from .is-natural (f , g , h) (f' , g' , h') (Ξ² , Ξ³ , Ξ΄)
associator
: β {A B C D} {f f' : C β¦ D} {g g' : B β¦ C} {h h' : A β¦ B}
Ξ±βnat β (Ξ² : f β f') (Ξ³ : g β g') (Ξ΄ : h β h')
β Path ((f β g) β h β (f' β g' β h'))
(Ξ±β _ _ _ β ((Ξ² β Ξ³) β Ξ΄))
((Ξ² β (Ξ³ β Ξ΄)) β Ξ±β _ _ _)
{A} {B} {C} {D} {f} {f'} {g} {g'} {h} {h'} Ξ² Ξ³ Ξ΄ =
Ξ±βnat .Cr._β
_.to .is-natural (f , g , h) (f' , g' , h') (Ξ² , Ξ³ , Ξ΄) associator
The final data we need are coherences relating the left and right
unitors (the triangle identity, nothing to do with
adjunctions), and one for reducing sequences of associators, the
pentagon identity. As for where the name βpentagonβ
comes from, the path pentagon
witnesses commutativity of the diagram
field
triangle: β {A B C} (f : B β¦ C) (g : A β¦ B)
β (Οβ f β g) β Ξ±β f id g β‘ f βΆ Ξ»β g
pentagon: β {A B C D E} (f : D β¦ E) (g : C β¦ D) (h : B β¦ C) (i : A β¦ B)
β (Ξ±β f g h β i) β Ξ±β f (g β h) i β (f βΆ Ξ±β g h i)
(f β g) h i β Ξ±β f g (h β i) β‘ Ξ±β
Our coherence diagrams for bicategorical data are taken from (Leinster 1998), which contains all the diagrams we have omitted. However, we do not adopt their (dated) terminology of βhomomorphismβ and βstrict homomorphismβ. In contrast with our convention for 1-categories, we refer to bicategories using bold capital letters:
module _ (B : Prebicategory o β β') where
open Prebicategory B
open Functor
: β {a b c} (f : a β¦ b) β Functor (Hom c a) (Hom c b)
postaction .Fβ g = f β g
postaction f .Fβ g = f βΆ g
postaction f .F-id = compose.F-id
postaction f .F-β g h =
postaction f (g β h) β‘Λβ¨ ap (_β g β h) (Hom.idl Hom.id) β©
f βΆ (Hom.id β Hom.id) β (g β h) β‘β¨ compose.F-β _ _ β©
(f βΆ g) β (f βΆ h) β
: β {a b c} (f : a β¦ b) β Functor (Hom b c) (Hom a c)
preaction .Fβ g = g β f
preaction f .Fβ g = g β f
preaction f .F-id = compose.F-id
preaction f .F-β g h =
preaction f (g β h) β f β‘Λβ¨ ap (g β h β_) (Hom.idl Hom.id) β©
(g β h) β (Hom.id β Hom.id) β‘β¨ compose.F-β _ _ β©
(g β f) β (h β f) β
The bicategory of categoriesπ
Just like the prototypal example of categories is the category of sets, the prototypal example of bicategory is the bicategory of categories. We observe that, without a bound of h-level on the spaces of objects (strict categories), the collection of categories of a given universe level does not form a category, but it does form a bicategory.
{-# TERMINATING #-}
: β o β β Prebicategory (lsuc o β lsuc β) (o β β) (o β β)
Cat = pb where
Cat o β open Prebicategory
open Functor
: Prebicategory _ _ _
pb .Ob = Precategory o β
pb .Hom = Cat[_,_]
pb .id = Id pb
The first thing we must compute is that the functor composition operator extends to a functor composition functor, which we have already done (but off-screen, since its construction is very straightforward).
.compose = Fβ-functor pb
The unitors and associator are almost, but not quite, given by the identity 2-cells, since componentwise the functor composition evaporates, leaving only behind. Unfortunately, this equation is not definitional, so we can not use the identity natural isomorphism directly:
.unitor-r {B = B} = to-natural-iso ni where
pb module B = Cr B
: make-natural-iso {D = Cat[ _ , _ ]} _ _
ni .make-natural-iso.eta x = NT (Ξ» _ β B.id) Ξ» _ _ _ β B.id-comm-sym
ni .make-natural-iso.inv x = NT (Ξ» _ β B.id) Ξ» _ _ _ β B.id-comm-sym
ni .make-natural-iso.etaβinv x = ext Ξ» _ β B.idl _
ni .make-natural-iso.invβeta x = ext Ξ» _ β B.idl _
ni .make-natural-iso.natural x y f =
ni Ξ» _ β B.idr _ β ap (B._β _) (y .F-id)
ext
.unitor-l {B = B} = to-natural-iso ni where
pb module B = Cr B
: make-natural-iso {D = Cat[ _ , _ ]} _ _
ni .make-natural-iso.eta x = NT (Ξ» _ β B.id) Ξ» _ _ _ β B.id-comm-sym
ni .make-natural-iso.inv x = NT (Ξ» _ β B.id) Ξ» _ _ _ β B.id-comm-sym
ni .make-natural-iso.etaβinv x = ext Ξ» _ β B.idl _
ni .make-natural-iso.invβeta x = ext Ξ» _ β B.idl _
ni .make-natural-iso.natural x y f = ext Ξ» _ β B.idr _ β B.id-comm
ni
.associator {A} {B} {C} {D} = to-natural-iso ni where
pb module D = Cr D
: make-natural-iso {D = Cat[ _ , _ ]} _ _
ni .make-natural-iso.eta x = NT (Ξ» _ β D.id) Ξ» _ _ _ β D.id-comm-sym
ni .make-natural-iso.inv x = NT (Ξ» _ β D.id) Ξ» _ _ _ β D.id-comm-sym
ni .make-natural-iso.etaβinv x = ext Ξ» _ β D.idl _
ni .make-natural-iso.invβeta x = ext Ξ» _ β D.idl _
ni .make-natural-iso.natural x y f = ext Ξ» _ β
ni .idr _ Β·Β· D.pushl (y .fst .F-β _ _) Β·Β· D.introl refl
D
.triangle {C = C} f g = ext Ξ» _ β Cr.idr C _
pb .pentagon {E = E} f g h i = ext Ξ» _ β apβ E._β_
pb (E.eliml (ap (f .Fβ) (ap (g .Fβ) (h .F-id)) Β·Β· ap (f .Fβ) (g .F-id) Β·Β· f .F-id))
(E.elimr (E.eliml (f .F-id)))
where module E = Cr E
Lax functorsπ
In the same way that the definition of bicategory is obtained by starting with the definition of category and replacing the by (and adding coherence data to make sure the resulting structure is well-behaved), one can start with the definition of functor and replace the function between by functors between
However, when talking about general bicategories, we are faced with a choice: We could generalise the functoriality axioms to natural isomorphisms, keeping with the fact that equations are invertible, but we could also drop this invertibility requirement, and work only with natural transformations When these are not invertible, the resulting structure is called a lax functor; When they are, we talk about pseudofunctors instead.
record
(B : Prebicategory o β β') (C : Prebicategory oβ ββ ββ')
Lax-functor : Type (o β oβ β β β ββ β β' β ββ') where
private
module B = Prebicategory B
module C = Prebicategory C
field
: B.Ob β C.Ob
Pβ : β {A B} β Functor (B.Hom A B) (C.Hom (Pβ A) (Pβ B)) Pβ
The resulting structure has βdirected functorialityβ, witnessed by
the compositor
and unitor
natural transformations, which
have components
and
compositor: β {A B C}
β C.compose Fβ (Pβ {B} {C} FΓ Pβ {A} {B}) => Pβ Fβ B.compose
: β {A} β C.id C.β Pβ .Functor.Fβ (B.id {A = A}) unitor
module Pβ {A} {B} = Functor (Pβ {A} {B})
: B.Ob β C.Ob
β = Pβ
β
: β {a b} β a B.β¦ b β Pβ a C.β¦ Pβ b
β = Pβ.Fβ
β
: β {a b} {f g : a B.β¦ b} β f B.β g β β f C.β β g
β = Pβ.Fβ
β
: β {a b c} (f : b B.β¦ c) (g : a B.β¦ b)
Ξ³β β β f C.β β g C.β β (f B.β g)
= compositor .Ξ· (f , g) Ξ³β f g
Additionally, we require the following three equations to hold,
relating the compositor transformation to the associators, and the three
unitors between themselves. We sketch the diagram which hexagon
witnesses commutativity for, but
leave the right-unit
and left-unit
diagrams undrawn (theyβre
boring commutative squares).
field
hexagon: β {a b c d} (f : c B.β¦ d) (g : b B.β¦ c) (h : a B.β¦ b)
β β (B.Ξ±β f g h) C.β Ξ³β (f B.β g) h C.β (Ξ³β f g C.β β h)
(g B.β h) C.β (β f C.βΆ Ξ³β g h) C.β C.Ξ±β (β f) (β g) (β h)
β‘ Ξ³β f
right-unit: β {a b} (f : a B.β¦ b)
β β (B.Οβ f) C.β Ξ³β f B.id C.β (β f C.βΆ unitor) β‘ C.Οβ (β f)
left-unit: β {a b} (f : a B.β¦ b)
β β (B.Ξ»β f) C.β Ξ³β B.id f C.β (unitor C.β β f) β‘ C.Ξ»β (β f)
Pseudofunctorsπ
As mentioned above, a lax functor with invertible unitors and
compositor is called a pseudofunctor. Every
pseudofunctor has an underlying lax
functor. Since invertibility is a property of 2-cells (rather
than structure on 2-cells), βbeing pseudoβ is a property of lax
functors, not additional structure on lax functors.
record
(B : Prebicategory o β β') (C : Prebicategory oβ ββ ββ')
Pseudofunctor : Type (o β oβ β β β ββ β β' β ββ') where
private
module B = Prebicategory B
module C = Prebicategory C
field
: Lax-functor B C
lax
open Lax-functor lax public
field
unitor-inv: β {a} β C.Hom.is-invertible (unitor {a})
compositor-inv: β {a b c} (f : b B.β¦ c) (g : a B.β¦ b) β C.Hom.is-invertible (Ξ³β f g)
: β {a b c} (f : b B.β¦ c) (g : a B.β¦ b)
Ξ³β β β (f B.β g) C.β β f C.β β g
= compositor-inv f g .Cr.is-invertible.inv
Ξ³β f g
: β {a} β β B.id C.β C.id
Ο
β {a} = unitor-inv {a = a} .Cr.is-invertible.inv Ο
β
Lax transformationsπ
By dropping the invertibility requirement when generalising natural transformations to lax functors, we obtain the type of lax transformations between lax functors. If every 2-cell component of the lax transformation is invertible, we refer to it as a pseudonatural transformation. We omit the word βnaturalβ in βlax natural transformationβ for brevity.
module
_ {B : Prebicategory o β β'} {C : Prebicategory oβ ββ ββ'}
(F : Lax-functor B C) (G : Lax-functor B C)
where
private
module B = Prebicategory B
module C = Prebicategory C
module F = Lax-functor F
module G = Lax-functor G
The transformation which witnesses directed naturality for a lax
transformation is called the naturator
. In components, it witnesses
commutativity of the diagram
and thus consists of a natural family of 2-cells
record Lax-transfor : Type (o β β β ββ β β' β ββ') where
field
: β A β F.β A C.β¦ G.β A
Ο
naturator: β {a b}
β preaction C (Ο b) Fβ G.Pβ => postaction C (Ο a) Fβ F.Pβ
: β {a b} (f : a B.β¦ b) β G.β f C.β Ο a C.β Ο b C.β F.β f
Ξ½β = naturator .Ξ· Ξ½β
The naturator is required to be compatible with the compositor and unitor natural transformations of its source and target functors, which boil down to commutativity of the nightmarish diagrams in (Leinster 1998, sec. 1.2).
field
Ξ½-compositor: β {a b c} (f : b B.β¦ c) (g : a B.β¦ b)
β Ξ½β (f B.β g) C.β (G.Ξ³β f g C.β Ο a)
(Ο c C.βΆ F.Ξ³β f g)
β‘ .β C.Ξ±β (Ο c) (F.β f) (F.β g)
C.β (Ξ½β f C.β F.β g)
C.β C.Ξ±β (G.β f) (Ο b) (F.β g)
C.β (G.β f C.βΆ Ξ½β g)
C.β C.Ξ±β (G.β f) (G.β g) (Ο a)
C
Ξ½-unitor: β {a}
β Ξ½β (B.id {a}) C.β (G.unitor C.β Ο a)
(Ο a C.βΆ F.unitor) C.β C.Οβ (Ο a) C.β C.Ξ»β (Ο a) β‘
A lax transformation with invertible naturator is called a pseudonatural transformation.
record Pseudonatural : Type (o β β β ββ β β' β ββ') where
field
: Lax-transfor
lax
open Lax-transfor lax public
field
: β {a b} (f : a B.β¦ b) β C.Hom.is-invertible (Ξ½β f)
naturator-inv
: β {a b} (f : a B.β¦ b) β Ο b C.β F.β f C.β G.β f C.β Ο a
Ξ½β = naturator-inv f .Cr.is-invertible.inv Ξ½β f
We abbreviate the types of lax- and pseudonatural transformations by
_=>β_
and _=>β_
,
respectively.
_=>β_ = Lax-transfor
_=>β_ = Pseudonatural
Modificationsπ
When dealing with 1-categorical data (categories, functors, and natural transformations), the commutativity in 2-cells is witnessed by equations in a set, which are trivial. When talking about bicategorical data, however, the naturality of a lax transformation is witnessed by a family of non-trivial 2-cells. Therefore, it is fruitful to consider transformations which affect this data: a natural family of 2-cells. This is called a modification between lax (or pseudo) transformations. Since we are directly dealing with sets (the sets of 2-cells), modifications are the simplest bicategorical widget to define.
module
_ {B : Prebicategory o β β'} {C : Prebicategory oβ ββ ββ'}
{F : Lax-functor B C} {G : Lax-functor B C}
(Ο Ο' : F =>β G)
where
private
module B = Prebicategory B
module C = Prebicategory C
module F = Lax-functor F
module G = Lax-functor G
module Ο = Lax-transfor Ο
module Ο' = Lax-transfor Ο'
record Modification : Type (o β β β ββ') where
field
: β a β Ο.Ο a C.β Ο'.Ο a
Ξ
is-natural: β {a b} {f : a B.β¦ b}
β Ο'.Ξ½β f C.β (G.β f C.βΆ Ξ a)
(Ξ b C.β F.β f) C.β Ο.Ξ½β f β‘
In a diagram, we display a modification as a 3-cell, i.e., a morphism (modification) between morphisms (lax transformations) between morphisms (lax functors) between objects (bicategories), and accordingly draw them with super-heavy arrows, as in the diagram below. Fortunately we will not often stumble onto diagrams of bicategories, rather studying diagrams in bicategories, which are (mercifully) limited to 2-cells.
References
- Leinster, Tom. 1998. βBasic Bicategories.β arXiv. https://doi.org/10.48550/ARXIV.MATH/9810017.