module Cat.Diagram.Coproduct where
Coproductsπ
The coproduct of two objects and (if it exists), is the smallest object equipped with βinjectionβ maps It is dual to the product.
We witness this notion of βsmallest objectβ with a universal property; Given any other that also admits injection maps from and we must have a unique map that factors the injections into This is best explained by a commutative diagram:
record is-coproduct {A B P} (ΞΉβ : Hom A P) (ΞΉβ : Hom B P) : Type (o β β) where
field
_,_] : β {Q} (inj0 : Hom A Q) (inj1 : Hom B Q) β Hom P Q
[: β {Q} {inj0 : Hom A Q} {inj1} β [ inj0 , inj1 ] β ΞΉβ β‘ inj0
[]βΞΉβ : β {Q} {inj0 : Hom A Q} {inj1} β [ inj0 , inj1 ] β ΞΉβ β‘ inj1
[]βΞΉβ
: β {Q} {inj0 : Hom A Q} {inj1}
unique β {other : Hom P Q}
β other β ΞΉβ β‘ inj0
β other β ΞΉβ β‘ inj1
β other β‘ [ inj0 , inj1 ]
: β {Q} {inj0 : Hom A Q} {inj1}
uniqueβ β β {o1} (p1 : o1 β ΞΉβ β‘ inj0) (q1 : o1 β ΞΉβ β‘ inj1)
β β {o2} (p2 : o2 β ΞΉβ β‘ inj0) (q2 : o2 β ΞΉβ β‘ inj1)
β o1 β‘ o2
= unique p1 q1 β sym (unique p2 q2) uniqueβ p1 q1 p2 q2
A coproduct of and is an explicit choice of coproduct diagram:
record Coproduct (A B : Ob) : Type (o β β) where
field
: Ob
coapex : Hom A coapex
ΞΉβ : Hom B coapex
ΞΉβ : is-coproduct ΞΉβ ΞΉβ
has-is-coproduct
open is-coproduct has-is-coproduct public
Uniquenessπ
The uniqueness argument presented here is dual to the argument for the product.
: β {A B} (c1 c2 : Coproduct A B) β coapex c1 β
coapex c2
+-Unique = make-iso c1βc2 c2βc1 c1βc2βc1 c2βc1βc2
+-Unique c1 c2 where
module c1 = Coproduct c1
module c2 = Coproduct c2
: Hom (coapex c1) (coapex c2)
c1βc2 = c1.[ c2.ΞΉβ , c2.ΞΉβ ]
c1βc2
: Hom (coapex c2) (coapex c1)
c2βc1 = c2.[ c1.ΞΉβ , c1.ΞΉβ ] c2βc1
: c1βc2 β c2βc1 β‘ id
c1βc2βc1 =
c1βc2βc1 .uniqueβ
c2(pullr c2.[]βΞΉβ β c1.[]βΞΉβ)
(pullr c2.[]βΞΉβ β c1.[]βΞΉβ)
(idl _) (idl _)
: c2βc1 β c1βc2 β‘ id
c2βc1βc2 =
c2βc1βc2 .uniqueβ
c1(pullr c1.[]βΞΉβ β c2.[]βΞΉβ)
(pullr c1.[]βΞΉβ β c2.[]βΞΉβ)
(idl _) (idl _)
Categories with all binary coproductsπ
Categories with all binary coproducts 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-coproduct.[_,_] (coproduct A B) f g
.
record Binary-coproducts {o β} (C : Precategory o β) : Type (o β β) where
no-eta-equality
open Cat.Reasoning C
field
_ββ_ : Ob β Ob β Ob
: β {A B} β Hom A (A ββ B)
ΞΉβ : β {A B} β Hom B (A ββ B)
ΞΉβ _,_] : β {A B X} (inj0 : Hom A X) (inj1 : Hom B X) β Hom (A ββ B) X
[: β {A B X} {inj0 : Hom A X} {inj1 : Hom B X} β [ inj0 , inj1 ] β ΞΉβ β‘ inj0
[]βΞΉβ : β {A B X} {inj0 : Hom A X} {inj1 : Hom B X} β [ inj0 , inj1 ] β ΞΉβ β‘ inj1
[]βΞΉβ
[]-unique: β {A B X} {inj0 : Hom A X} {inj1 : Hom B X}
β {other : Hom (A ββ B) X}
β other β ΞΉβ β‘ inj0
β other β ΞΉβ β‘ inj1
β other β‘ [ inj0 , inj1 ]
infixr 7 _ββ_
infix 50 _ββ_
If a category has all binary coproducts, we can define a bifunctor that sets to their coproduct.
_ββ_ : β {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-sym id-comm-sym
β-functor .F-β (f , g) (h , i) =
β-functor
sym $ []-unique(pullr []βΞΉβ β extendl []βΞΉβ)
(pullr []βΞΉβ β extendl []βΞΉβ)
We also define a handful of common morphisms.
: β {a} β Hom (a ββ a) a
β = [ id , id ]
β
: β {a b} β Hom (a ββ b) (b ββ a)
coswap = [ ΞΉβ , ΞΉβ ]
coswap
: β {a b c} β Hom (a ββ (b ββ c)) ((a ββ b) ββ c)
β-assoc = [ ΞΉβ β ΞΉβ , [ ΞΉβ β ΞΉβ , ΞΉβ ] ] β-assoc