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
: ∀ {Y} → (∀ i → C.Hom (F i) Y) → C.Hom S Y
match : ∀ {i} {Y} {f : ∀ i → C.Hom (F i) Y} → match f C.∘ ι i ≡ f i
commute : ∀ {Y} {h : C.Hom S Y} (f : ∀ i → C.Hom (F i) Y)
unique → (∀ i → h C.∘ ι i ≡ f i)
→ h ≡ match f
: ∀ {Y} (h : C.Hom S Y) → h ≡ match (λ i → h C.∘ ι i)
eta = unique _ λ _ → refl
eta h
: ∀ {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)
unique₂
: ∀ {Y} → C.Hom S Y ≃ (∀ i → C.Hom (F i) Y)
hom-iso = (λ z i → z C.∘ ι i) , is-iso→is-equiv λ where
hom-iso .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
ι : is-indexed-coproduct F ι
has-is-ic open is-indexed-coproduct has-is-ic public
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'
{ι = ι} {ι' = ι'} ΣF-coprod ΣF'-coprod =
is-indexed-coproduct→iso .make-iso (ΣF.match ι') (ΣF'.match ι)
C(Σ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
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.
{A = A} {B} {X} {ΣᵃΣᵇX = ΣᵃΣᵇX} {ιᵃ = ιᵃ} {ιᵇ} Σᵃᵇ ΣᵃΣᵇ Σᵇ =
is-indexed-coproduct-assoc
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 →
Σᵇ (C.assoc _ _ _) ∙ p (a , b) sym
Categories with all indexed coproducts🔗
: ∀ {ℓ} (I : Type ℓ) → Type _
has-coproducts-indexed-by = ∀ (F : I → C.Ob) → Indexed-coproduct F
has-coproducts-indexed-by I
: ∀ ℓ → Type _
has-indexed-coproducts = ∀ {I : Type ℓ} → has-coproducts-indexed-by I
has-indexed-coproducts ℓ
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
: is-indexed-coproduct F ι
has-is-ic : ∀ i → C.is-monic (ι i)
injections-are-monic : ∀ i j → Pullback C (ι i) (ι j)
summands-intersect
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
{F = F} {i = i} init = is-disjoint where
is-initial→is-disjoint-coproduct open is-indexed-coproduct
: 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)
is-coprod
open is-disjoint-coproduct
: 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 is-disjoint
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.
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
{X = X} ⦃ Idx-Discrete ⦄ i tᵢ fⱼ = match probe
detect module detect where
: ∀ (j : Idx) → C.Hom (P j) X
probe with i ≡? j
probe j ... | yes i=j = subst _ i=j tᵢ
... | no ¬i=j = fⱼ j ¬i=j
: probe i ≡ tᵢ
probe-yes with i ≡? i
probe-yes ... | 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)
: ∀ j → (¬i=j : ¬ (i ≡ j)) → probe j ≡ fⱼ j ¬i=j
probe-no with i ≡? j
probe-no j ¬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ᵢ
= commute ∙ detect.probe-yes _ _ _
detect-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
= commute ∙ detect.probe-no _ _ _ j ¬i=j detect-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 .make-retract (detect i C.id (λ _ _ → zero→)) detect-yes
Cwhere open Zero z