module Cat.Diagram.Product where
Productsπ
The product of two objects and if it exists, is the smallest object equipped with βprojectionβ maps and This situation can be visualised by putting the data of a product into a commutative diagram, as the one below: To express that is the smallest object with projections to and we ask that any other object with projections through and factors uniquely through
In the sense that (univalent) categories generalise posets, the product of and β if it exists β generalises the binary meet Since products are unique when they exist, we may safely denote any product of and by
For a diagram to be a product diagram, it must be able to cough up an arrow given the data of another span which must not only fit into the diagram above but be unique among the arrows that do so.
This factoring is called the pairing of the arrows and since in the special case where is the terminal object (hence the two arrows are global elements of resp. the pairing is a global element of the product
record is-product {A B P} (Οβ : Hom P A) (Οβ : Hom P B) : Type (o β β) where
field
_,_β© : β {Q} (p1 : Hom Q A) (p2 : Hom Q B) β Hom Q P
β¨: β {Q} {p1 : Hom Q _} {p2} β Οβ β β¨ p1 , p2 β© β‘ p1
Οβββ¨β© : β {Q} {p1 : Hom Q _} {p2} β Οβ β β¨ p1 , p2 β© β‘ p2
Οβββ¨β©
: β {Q} {p1 : Hom Q A} {p2}
unique β {other : Hom Q P}
β Οβ β other β‘ p1
β Οβ β other β‘ p2
β other β‘ β¨ p1 , p2 β©
: β {Q} {pr1 : Hom Q A} {pr2}
uniqueβ β β {o1} (p1 : Οβ β o1 β‘ pr1) (q1 : Οβ β o1 β‘ pr2)
β β {o2} (p2 : Οβ β o2 β‘ pr1) (q2 : Οβ β o2 β‘ pr2)
β o1 β‘ o2
= unique p1 q1 β sym (unique p2 q2)
uniqueβ p1 q1 p2 q2
: β {Q R} {p1 : Hom Q A} {p2 : Hom Q B} (f : Hom R Q)
β¨β©β β β¨ p1 , p2 β© β f β‘ β¨ p1 β f , p2 β f β©
= unique (pulll Οβββ¨β©) (pulll Οβββ¨β©)
β¨β©β f
: β¨ Οβ , Οβ β© β‘ id
β¨β©-Ξ· = sym $ unique (idr _) (idr _) β¨β©-Ξ·
A product of and is an explicit choice of product diagram:
record Product (A B : Ob) : Type (o β β) where
no-eta-equality
field
: Ob
apex : Hom apex A
Οβ : Hom apex B
Οβ : is-product Οβ Οβ
has-is-product
open is-product has-is-product public
Uniquenessπ
Products, when they exist, are unique. Itβs easiest to see this with a diagrammatic argument: If we have product diagrams and we can fit them into a βcommutative diamondβ like the one below:
Since both and are products, we know that the dashed arrows in the diagram below exist, so the overall diagram commutes: hence we have an isomorphism
We construct the map as the pairing of the projections from and symmetrically for
: (p1 p2 : Product C A B) β apex p1 β
apex p2
Γ-Unique = make-iso p1βp2 p2βp1 p1βp2βp1 p2βp1βp2
Γ-Unique p1 p2 where
module p1 = Product p1
module p2 = Product p2
: Hom (apex p1) (apex p2)
p1βp2 = p2.β¨ p1.Οβ , p1.Οβ β©
p1βp2
: Hom (apex p2) (apex p1)
p2βp1 = p1.β¨ p2.Οβ , p2.Οβ β© p2βp1
These are unique because they are maps into products which commute with the projections.
: p1βp2 β p2βp1 β‘ id
p1βp2βp1 =
p1βp2βp1 .uniqueβ
p2(assoc _ _ _ Β·Β· ap (_β _) p2.Οβββ¨β© Β·Β· p1.Οβββ¨β©)
(assoc _ _ _ Β·Β· ap (_β _) p2.Οβββ¨β© Β·Β· p1.Οβββ¨β©)
(idr _) (idr _)
: p2βp1 β p1βp2 β‘ id
p2βp1βp2 =
p2βp1βp2 .uniqueβ
p1(assoc _ _ _ Β·Β· ap (_β _) p1.Οβββ¨β© Β·Β· p2.Οβββ¨β©)
(assoc _ _ _ Β·Β· ap (_β _) p1.Οβββ¨β© Β·Β· p2.Οβββ¨β©)
(idr _) (idr _)
is-product-iso: β {A A' B B' P} {Οβ : Hom P A} {Οβ : Hom P B}
{f : Hom A A'} {g : Hom B B'}
β is-invertible f
β is-invertible g
β is-product C Οβ Οβ
β is-product C (f β Οβ) (g β Οβ)
= prod' where
is-product-iso f-iso g-iso prod module fi = is-invertible f-iso
module gi = is-invertible g-iso
open is-product
: is-product _ _ _
prod' .β¨_,_β© qa qb = prod .β¨_,_β© (fi.inv β qa) (gi.inv β qb)
prod' .Οβββ¨β© = pullr (prod .Οβββ¨β©) β cancell fi.invl
prod' .Οβββ¨β© = pullr (prod .Οβββ¨β©) β cancell gi.invl
prod' .unique p q = prod .unique
prod' (sym (ap (_ β_) (sym p) β pulll (cancell fi.invr)))
(sym (ap (_ β_) (sym q) β pulll (cancell gi.invr)))
is-product-iso-apex: β {A B P P'} {Οβ : Hom P A} {Οβ : Hom P B}
{Οβ' : Hom P' A} {Οβ' : Hom P' B}
{f : Hom P' P}
β is-invertible f
β Οβ β f β‘ Οβ'
β Οβ β f β‘ Οβ'
β is-product C Οβ Οβ
β is-product C Οβ' Οβ'
{f = f} f-iso f-Οβ f-Οβ prod = prod' where
is-product-iso-apex module fi = is-invertible f-iso
open is-product
: is-product _ _ _
prod' .β¨_,_β© qa qb = fi.inv β prod .β¨_,_β© qa qb
prod' .Οβββ¨β© = pulll (rswizzle (sym f-Οβ) fi.invl) β prod .Οβββ¨β©
prod' .Οβββ¨β© = pulll (rswizzle (sym f-Οβ) fi.invl) β prod .Οβββ¨β©
prod' .unique p q = sym $ lswizzle
prod' (sym (prod .unique (pulll f-Οβ β p) (pulll f-Οβ β q))) fi.invr
Categories with all binary productsπ
Categories with all binary products are quite common, so we provide
an API for working with them. In order to get better printing in goals,
we define an unnested record where all operations are top-level fields;
this means that goals willl print as β¨ f , g β©
instead of
is-product.β¨_,_β© (product A B) f g
.
record Binary-products {o β} (C : Precategory o β) : Type (o β β) where
no-eta-equality
open Cat.Reasoning C
field
_ββ_ : Ob β Ob β Ob
: β {A B} β Hom (A ββ B) A
Οβ : β {A B} β Hom (A ββ B) B
Οβ _,_β© : β {A B X} β Hom X A β Hom X B β Hom X (A ββ B)
β¨: β {A B X} {p1 : Hom X A} {p2 : Hom X B} β Οβ β β¨ p1 , p2 β© β‘ p1
Οβββ¨β© : β {A B X} {p1 : Hom X A} {p2 : Hom X B} β Οβ β β¨ p1 , p2 β© β‘ p2
Οβββ¨β©
β¨β©-unique: β {A B X}
β {p1 : Hom X A} {p2 : Hom X B}
β {other : Hom X (A ββ B)}
β Οβ β other β‘ p1
β Οβ β other β‘ p2
β other β‘ β¨ p1 , p2 β©
infixr 7 _ββ_
infix 50 _ββ_
If a category has all binary products, we can define a bifunctor that sets to their product.
_ββ_ : β {a b x y} β Hom a x β Hom b y β Hom (a ββ b) (x ββ y)
= β¨ f β Οβ , g β Οβ β©
f ββ g
: Functor (C ΓαΆ C) C
Γ-functor .Fβ (a , b) = a ββ b
Γ-functor .Fβ (f , g) = f ββ g
Γ-functor .F-id = sym $ β¨β©-unique id-comm id-comm
Γ-functor .F-β (f , g) (h , i) =
Γ-functor
sym $ β¨β©-unique(pulll Οβββ¨β© β extendr Οβββ¨β©)
(pulll Οβββ¨β© β extendr Οβββ¨β©)
We also define a handful of common morphisms.
: β {A} β Hom A (A ββ A)
Ξ΄ = β¨ id , id β©
Ξ΄
: β {A B} β Hom (A ββ B) (B ββ A)
swap = β¨ Οβ , Οβ β©
swap
: β {A B C} β Hom (A ββ (B ββ C)) ((A ββ B) ββ C)
Γ-assoc = β¨ β¨ Οβ , Οβ β Οβ β© , Οβ β Οβ β© Γ-assoc
Representability of productsπ
The collection of maps into a product is equivalent to the collection of pairs of maps into and The forward direction of the equivalence is given by postcomposition of the projections, and the reverse direction by the universal property of products.
product-repr: β {a b}
β (prod : Product C a b)
β (x : Ob)
β Hom x (Product.apex prod) β (Hom x a Γ Hom x b)
= IsoβEquiv Ξ» where
product-repr prod x .fst f β Οβ β f , Οβ β f
.snd .is-iso.inv (f , g) β β¨ f , g β©
.snd .is-iso.rinv (f , g) β Οβββ¨β© ,β Οβββ¨β©
.snd .is-iso.linv f β sym (β¨β©β f) β eliml β¨β©-Ξ·
where open Product prod