module Cat.Diagram.Coproduct.Indexed {o β} (C : Precategory o β) where
Indexed coproductsπ
Indexed coproducts are the dual notion to indexed products, so see there for motivation and exposition.
record is-indexed-coproduct (F : Idx β C.Ob) (ΞΉ : β i β C.Hom (F i) S) : Type (o β β β level-of Idx) where no-eta-equality field match : β {Y} β (β i β C.Hom (F i) Y) β C.Hom S Y commute : β {i} {Y} {f : β i β C.Hom (F i) Y} β match f C.β ΞΉ i β‘ f i unique : β {Y} {h : C.Hom S Y} (f : β i β C.Hom (F i) Y) β (β i β h C.β ΞΉ i β‘ f i) β h β‘ match f eta : β {Y} (h : C.Hom S Y) β h β‘ match (Ξ» i β h C.β ΞΉ i) eta h = unique _ Ξ» _ β refl uniqueβ : β {Y} {g h : C.Hom S Y} β (β i β g C.β ΞΉ i β‘ h C.β ΞΉ i) β g β‘ h uniqueβ {g = g} {h} eq = eta g β ap match (funext eq) β sym (eta h) hom-iso : β {Y} β C.Hom S Y β (β i β C.Hom (F i) Y) hom-iso = (Ξ» z i β z C.β ΞΉ i) , is-isoβis-equiv Ξ» where .is-iso.inv β match .is-iso.rinv x β funext Ξ» i β commute .is-iso.linv x β sym (unique _ Ξ» _ β refl)
A category admits indexed coproducts (of level if, for any type and family there is an indexed coproduct of
record Indexed-coproduct (F : Idx β C.Ob) : Type (o β β β level-of Idx) where no-eta-equality field {Ξ£F} : C.Ob ΞΉ : β i β C.Hom (F i) Ξ£F has-is-ic : is-indexed-coproduct F ΞΉ open is-indexed-coproduct has-is-ic public
Indexed-coproduct-β : β {β β'} {I : Type β} {J : Type β'} β (e : I β J) β {F : I β C.Ob} β Indexed-coproduct (F β Equiv.from e) β Indexed-coproduct F Indexed-coproduct-β e {F} p = Ξ» where .Ξ£F β p .Ξ£F .ΞΉ j β p .ΞΉ (e.to j) C.β C.from (pathβiso (ap F (e.Ξ· _))) .has-is-ic .match f β p .match (f β e.from) .has-is-ic .commute {f = f} β C.pulll (p .commute) β from-pathp-to (C ^op) _ (ap f (e.Ξ· _)) .has-is-ic .unique f comm β p .unique _ Ξ» j β ap (_ C.β_) (sym (from-pathp-to (C ^op) _ (ap (p .ΞΉ) (e.Ξ΅ j))) β ap (Ξ» z β p .ΞΉ _ C.β C.from (pathβiso (ap F z))) (e.zag j)) β comm (e.from j) where open Indexed-coproduct open is-indexed-coproduct module e = Equiv e Lift-Indexed-coproduct : β {β} β' β {I : Type β} β {F : I β C.Ob} β Indexed-coproduct {Idx = Lift β' I} (F β lower) β Indexed-coproduct F Lift-Indexed-coproduct _ = Indexed-coproduct-β (Lift-β eβ»ΒΉ) is-indexed-coproduct-is-prop : β {β'} {Idx : Type β'} β {F : Idx β C.Ob} {Ξ£F : C.Ob} {ΞΉ : β idx β C.Hom (F idx) Ξ£F} β is-prop (is-indexed-coproduct F ΞΉ) is-indexed-coproduct-is-prop {Idx = Idx} {F} {Ξ£F} {ΞΉ} P Q = path where open is-indexed-coproduct p : β {X} β (f : β i β C.Hom (F i) X) β P .match f β‘ Q .match f p f = Q .unique f (Ξ» i β P .commute) path : P β‘ Q path i .match f = p f i path i .commute {i = idx} {f = f} = is-propβpathp (Ξ» i β C.Hom-set _ _ (p f i C.β ΞΉ idx) (f idx)) (P .commute) (Q .commute) i path i .unique {h = h} f q = is-propβpathp (Ξ» i β C.Hom-set _ _ h (p f i)) (P .unique f q) (Q .unique f q) i module _ {β'} {Idx : Type β'} {F : Idx β C.Ob} {P P' : Indexed-coproduct F} where private module P = Indexed-coproduct P module P' = Indexed-coproduct P' Indexed-coproduct-path : (p : P.Ξ£F β‘ P'.Ξ£F) β (β idx β PathP (Ξ» i β C.Hom (F idx) (p i)) (P.ΞΉ idx) (P'.ΞΉ idx)) β P β‘ P' Indexed-coproduct-path p q i .Indexed-coproduct.Ξ£F = p i Indexed-coproduct-path p q i .Indexed-coproduct.ΞΉ idx = q idx i Indexed-coproduct-path p q i .Indexed-coproduct.has-is-ic = is-propβpathp (Ξ» i β is-indexed-coproduct-is-prop {Ξ£F = p i} {ΞΉ = Ξ» idx β q idx i}) P.has-is-ic P'.has-is-ic i
Uniquenessπ
As universal constructions, indexed coproducts are unique up to isomorphism. The proof follows the usual pattern: we use the universal morphisms to construct morphisms in both directions, and uniqueness ensures that these maps form an isomorphism.
is-indexed-coproductβiso : β {β'} {Idx : Type β'} {F : Idx β C.Ob} β {Ξ£F Ξ£F' : C.Ob} β {ΞΉ : β i β C.Hom (F i) Ξ£F} {ΞΉ' : β i β C.Hom (F i) Ξ£F'} β is-indexed-coproduct F ΞΉ β is-indexed-coproduct F ΞΉ' β Ξ£F C.β Ξ£F' is-indexed-coproductβiso {ΞΉ = ΞΉ} {ΞΉ' = ΞΉ'} Ξ£F-coprod Ξ£F'-coprod = C.make-iso (Ξ£F.match ΞΉ') (Ξ£F'.match ΞΉ) (Ξ£F'.uniqueβ (Ξ» i β C.pullr Ξ£F'.commute β Ξ£F.commute β sym (C.idl _))) (Ξ£F.uniqueβ (Ξ» i β C.pullr Ξ£F.commute β Ξ£F'.commute β sym (C.idl _))) where module Ξ£F = is-indexed-coproduct Ξ£F-coprod module Ξ£F' = is-indexed-coproduct Ξ£F'-coprod
Indexed-coproductβiso : β {β'} {Idx : Type β'} {F : Idx β C.Ob} β (P P' : Indexed-coproduct F) β Indexed-coproduct.Ξ£F P C.β Indexed-coproduct.Ξ£F P' Indexed-coproductβiso P P' = is-indexed-coproductβiso (Indexed-coproduct.has-is-ic P) (Indexed-coproduct.has-is-ic P')
Propertiesπ
Let be a family of objects in If the the indexed coproducts and exists, then they are isomorphic.
The formal statement of this is a bit of a mouthful, but all of these arguments are just required to ensure that the various coproducts actually exist.
is-indexed-coproduct-assoc : β {ΞΊ ΞΊ'} {A : Type ΞΊ} {B : A β Type ΞΊ'} β {X : Ξ£ A B β C.Ob} β {Ξ£α΅α΅X : C.Ob} {Ξ£α΅Ξ£α΅X : C.Ob} {Ξ£α΅X : A β C.Ob} β {ΞΉα΅α΅ : (ab : Ξ£ A B) β C.Hom (X ab) Ξ£α΅α΅X} β {ΞΉα΅ : β a β C.Hom (Ξ£α΅X a) Ξ£α΅Ξ£α΅X} β {ΞΉα΅ : β a β (b : B a) β C.Hom (X (a , b)) (Ξ£α΅X a)} β is-indexed-coproduct X ΞΉα΅α΅ β is-indexed-coproduct Ξ£α΅X ΞΉα΅ β (β a β is-indexed-coproduct (Ξ» b β X (a , b)) (ΞΉα΅ a)) β Ξ£α΅α΅X C.β Ξ£α΅Ξ£α΅X
Luckily, the proof of this fact is easier than the statement! Indexed coproducts are unique up to isomorphism, so it suffices to show that is an indexed product over which follows almost immediately from our hypotheses.
is-indexed-coproduct-assoc {A = A} {B} {X} {Ξ£α΅Ξ£α΅X = Ξ£α΅Ξ£α΅X} {ΞΉα΅ = ΞΉα΅} {ΞΉα΅} Ξ£α΅α΅ Ξ£α΅Ξ£α΅ Ξ£α΅ = is-indexed-coproductβiso Ξ£α΅α΅ Ξ£α΅α΅' where open is-indexed-coproduct ΞΉα΅α΅' : β (ab : Ξ£ A B) β C.Hom (X ab) Ξ£α΅Ξ£α΅X ΞΉα΅α΅' (a , b) = ΞΉα΅ a C.β ΞΉα΅ a b Ξ£α΅α΅' : is-indexed-coproduct X ΞΉα΅α΅' Ξ£α΅α΅' .match f = Ξ£α΅Ξ£α΅ .match Ξ» a β Ξ£α΅ a .match Ξ» b β f (a , b) Ξ£α΅α΅' .commute = C.pulll (Ξ£α΅Ξ£α΅ .commute) β Ξ£α΅ _ .commute Ξ£α΅α΅' .unique {h = h} f p = Ξ£α΅Ξ£α΅ .unique _ Ξ» a β Ξ£α΅ _ .unique _ Ξ» b β sym (C.assoc _ _ _) β p (a , b)
Categories with all indexed coproductsπ
has-coproducts-indexed-by : β {β} (I : Type β) β Type _ has-coproducts-indexed-by I = β (F : I β C.Ob) β Indexed-coproduct F has-indexed-coproducts : β β β Type _ has-indexed-coproducts β = β {I : Type β} β has-coproducts-indexed-by I module Indexed-coproducts-by {ΞΊ : Level} {Idx : Type ΞΊ} (has-ic : has-coproducts-indexed-by Idx) where module β (F : Idx β C.Ob) = Indexed-coproduct (has-ic F) open β renaming (commute to ΞΉ-commute; unique to match-unique) public module Indexed-coproducts {ΞΊ : Level} (has-ic : has-indexed-coproducts ΞΊ) where module β {Idx : Type ΞΊ} (F : Idx β C.Ob) = Indexed-coproduct (has-ic F) open β renaming (commute to ΞΉ-commute; unique to match-unique) public
Disjoint coproductsπ
An indexed coproduct is said to be disjoint if every one of its inclusions is monic, and, for unequal the square below is a pullback with initial apex. Since the maps are monic, the pullback below computes the intersection of and as subobjects of hence the name disjoint coproduct: If is an initial object, then
record is-disjoint-coproduct (F : Idx β C.Ob) (ΞΉ : β i β C.Hom (F i) S) : Type (o β β β level-of Idx) where field has-is-ic : is-indexed-coproduct F ΞΉ injections-are-monic : β i β C.is-monic (ΞΉ i) summands-intersect : β i j β Pullback C (ΞΉ i) (ΞΉ j) different-images-are-disjoint : β i j β Β¬ i β‘ j β is-initial C (summands-intersect i j .Pullback.apex)
Initial objects are disjointπ
We prove that if is an initial object, then it is also an indexed coproduct β for any family β and furthermore, it is a disjoint coproduct.
is-initialβis-disjoint-coproduct : β {β } {F : β₯ β C.Ob} {i : β i β C.Hom (F i) β } β is-initial C β β is-disjoint-coproduct F i is-initialβis-disjoint-coproduct {F = F} {i = i} init = is-disjoint where open is-indexed-coproduct is-coprod : is-indexed-coproduct F i is-coprod .match _ = init _ .centre is-coprod .commute {i = i} = absurd i is-coprod .unique {h = h} f p i = init _ .paths h (~ i) open is-disjoint-coproduct is-disjoint : is-disjoint-coproduct F i is-disjoint .has-is-ic = is-coprod is-disjoint .injections-are-monic i = absurd i is-disjoint .summands-intersect i j = absurd i is-disjoint .different-images-are-disjoint i j p = absurd i
Coproducts and zero objectsπ
Let be a category with a zero object, and let be a coproduct. If is a discrete type, then every coproduct inclusion has a retract.
module _ {ΞΊ} {Idx : Type ΞΊ} {P : Idx β C.Ob} {βP : C.Ob} {ΞΉ : β i β C.Hom (P i) βP} (coprod : is-indexed-coproduct P ΞΉ) where open is-indexed-coproduct coprod
First, a useful lemma. Suppose that we have a coproduct indexed by a discrete type, and a map for some If there exists maps for every then we can obtain a map
detect : β {X} β¦ Idx-Discrete : Discrete Idx β¦ β (i : Idx) β C.Hom (P i) X β (β (j : Idx) β Β¬ i β‘ j β C.Hom (P j) X) β C.Hom βP X
The key idea here is to check if when invoking the universal property of if we use otherwise we use
detect {X = X} β¦ Idx-Discrete β¦ i tα΅’ fβ±Ό = match probe module detect where probe : β (j : Idx) β C.Hom (P j) X probe j with i β‘? j ... | yes i=j = subst _ i=j tα΅’ ... | no Β¬i=j = fβ±Ό j Β¬i=j probe-yes : probe i β‘ tα΅’ probe-yes with i β‘? i ... | yes i=i = is-setβsubst-refl (Ξ» j β C.Hom (P j) X) (Discreteβis-set Idx-Discrete) i=i tα΅’ ... | no Β¬i=i = absurd (Β¬i=i refl) probe-no : β j β (Β¬i=j : Β¬ (i β‘ j)) β probe j β‘ fβ±Ό j Β¬i=j probe-no j Β¬i=j with i β‘? j ... | yes i=j = absurd (Β¬i=j i=j) ... | no _ = ap (fβ±Ό j) prop!
Moreover, we observe that our newly created map interacts nicely with the inclusions into the coproduct.
detect-yes : β {X} β¦ Idx-Discrete : Discrete Idx β¦ β {i : Idx} β {tα΅’ : C.Hom (P i) X} β {fβ±Ό : β (j : Idx) β Β¬ i β‘ j β C.Hom (P j) X} β detect i tα΅’ fβ±Ό C.β ΞΉ i β‘ tα΅’ detect-yes = commute β detect.probe-yes _ _ _ detect-no : β {X} β¦ Idx-Discrete : Discrete Idx β¦ β {i : Idx} β {tα΅’ : C.Hom (P i) X} β {fβ±Ό : β (j : Idx) β Β¬ i β‘ j β C.Hom (P j) X} β β j β (Β¬i=j : Β¬ i β‘ j) β detect i tα΅’ fβ±Ό C.β ΞΉ j β‘ fβ±Ό j Β¬i=j detect-no j Β¬i=j = commute β detect.probe-no _ _ _ j Β¬i=j
Refocusing our attention back to our original claim, suppose that has a zero object. This means that there is a canonical choice of morphism between any two objects, so we can apply our previous lemma to obtain a retract
zeroβΞΉ-has-retract : β β¦ Idx-Discrete : Discrete Idx β¦ β Zero C β β i β C.has-retract (ΞΉ i) zeroβΞΉ-has-retract z i = C.make-retract (detect i C.id (Ξ» _ _ β zeroβ)) detect-yes where open Zero z