module Cat.Diagram.Coproduct {o h} (C : Precategory o h) 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 β 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 unique : β {Q} {inj0 : Hom A Q} {inj1} β {other : Hom P Q} β other β ΞΉβ β‘ inj0 β other β ΞΉβ β‘ inj1 β other β‘ [ inj0 , inj1 ] uniqueβ : β {Q} {inj0 : Hom A Q} {inj1} β β {o1} (p1 : o1 β ΞΉβ β‘ inj0) (q1 : o1 β ΞΉβ β‘ inj1) β β {o2} (p2 : o2 β ΞΉβ β‘ inj0) (q2 : o2 β ΞΉβ β‘ inj1) β o1 β‘ o2 uniqueβ p1 q1 p2 q2 = unique p1 q1 β sym (unique p2 q2)
A coproduct of and is an explicit choice of coproduct diagram:
record Coproduct (A B : Ob) : Type (o β h) where field coapex : Ob ΞΉβ : Hom A coapex ΞΉβ : Hom B coapex has-is-coproduct : is-coproduct ΞΉβ ΞΉβ open is-coproduct has-is-coproduct public
Uniquenessπ
The uniqueness argument presented here is dual to the argument for the product.
+-Unique : (c1 c2 : Coproduct A B) β coapex c1 β coapex c2 +-Unique c1 c2 = make-iso c1βc2 c2βc1 c1βc2βc1 c2βc1βc2 where module c1 = Coproduct c1 module c2 = Coproduct c2 c1βc2 : Hom (coapex c1) (coapex c2) c1βc2 = c1.[ c2.ΞΉβ , c2.ΞΉβ ] c2βc1 : Hom (coapex c2) (coapex c1) c2βc1 = c2.[ c1.ΞΉβ , c1.ΞΉβ ]
c1βc2βc1 : c1βc2 β c2βc1 β‘ id c1βc2βc1 = c2.uniqueβ (pullr c2.[]βΞΉβ β c1.[]βΞΉβ) (pullr c2.[]βΞΉβ β c1.[]βΞΉβ) (idl _) (idl _) c2βc1βc2 : c2βc1 β c1βc2 β‘ id c2βc1βc2 = c1.uniqueβ (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.
has-coproducts : Type _ has-coproducts = β a b β Coproduct a b 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 : 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) = sym $ []-unique (pullr []βΞΉβ β extendl []βΞΉβ) (pullr []βΞΉβ β extendl []βΞΉβ) β : β {a} β Hom (a ββ a) a β = [ id , id ] coswap : β {a b} β Hom (a ββ b) (b ββ a) coswap = [ ΞΉβ , ΞΉβ ] β-assoc : β {a b c} β Hom (a ββ (b ββ c)) ((a ββ b) ββ c) β-assoc = [ ΞΉβ β ΞΉβ , [ ΞΉβ β ΞΉβ , ΞΉβ ] ]
β-natural : is-natural-transformation (β-functor Fβ Catβ¨ Id , Id β©Cat) Id Ξ» _ β β β-natural x y f = uniqueβ (pullr []βΞΉβ β cancell []βΞΉβ) (pullr []βΞΉβ β cancell []βΞΉβ) (cancelr []βΞΉβ) (cancelr []βΞΉβ) β-coswap : β {a} β β β coswap β‘ β {a} β-coswap = []-unique (pullr []βΞΉβ β []βΞΉβ) (pullr []βΞΉβ β []βΞΉβ) β-assoc : β {a} β β {a} β (β {a} ββ id) β β-assoc β‘ β β (id ββ β) β-assoc = uniqueβ (pullr (pullr []βΞΉβ) β (reflβ©ββ¨ pulll []βΞΉβ) β pulll (pulll []βΞΉβ) β pullr []βΞΉβ) (pullr (pullr []βΞΉβ) β []-unique (pullr (pullr []βΞΉβ) β extend-inner []βΞΉβ β cancell []βΞΉβ β []βΞΉβ) (pullr (pullr []βΞΉβ) β (reflβ©ββ¨ []βΞΉβ) β cancell []βΞΉβ)) (pullr []βΞΉβ β pulll []βΞΉβ) (pullr []βΞΉβ β cancell []βΞΉβ)