module Cat.Diagram.Coproduct {o h} (C : Precategory o h) where
open import Cat.Reasoning C
private variable
: Ob A B
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 β h) 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 β h) 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.
module _ where
open Coproduct
: (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 define a module for working with them.
: Type _
has-coproducts = β a b β Coproduct a b
has-coproducts
module Binary-coproducts (all-coproducts : has-coproducts) where
module _ {a b} where open Coproduct (all-coproducts a b) renaming (unique to []-unique) hiding (coapex) public
module _ a b where open Coproduct (all-coproducts a b) renaming (coapex to infixr 7 _ββ_) using () public
open Functor
infix 50 _ββ_
_ββ_ : β {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 []βΞΉβ)
: β {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
: is-natural-transformation (β-functor Fβ Catβ¨ Id , Id β©) Id Ξ» _ β β
β-natural = uniqueβ
β-natural x y f (pullr []βΞΉβ β cancell []βΞΉβ) (pullr []βΞΉβ β cancell []βΞΉβ)
(cancelr []βΞΉβ) (cancelr []βΞΉβ)
: β {a} β β β coswap β‘ β {a}
β-coswap = []-unique (pullr []βΞΉβ β []βΞΉβ) (pullr []βΞΉβ β []βΞΉβ)
β-coswap
: β {a} β β {a} β (β {a} ββ id) β β-assoc β‘ β β (id ββ β)
β-assoc = uniqueβ
β-assoc (pullr (pullr []βΞΉβ) β (reflβ©ββ¨ pulll []βΞΉβ) β pulll (pulll []βΞΉβ) β pullr []βΞΉβ)
(pullr (pullr []βΞΉβ) β []-unique
(pullr (pullr []βΞΉβ) β extend-inner []βΞΉβ β cancell []βΞΉβ β []βΞΉβ)
(pullr (pullr []βΞΉβ) β (reflβ©ββ¨ []βΞΉβ) β cancell []βΞΉβ))
(pullr []βΞΉβ β pulll []βΞΉβ)
(pullr []βΞΉβ β cancell []βΞΉβ)