open import Cat.Diagram.Equaliser.Joint
open import Cat.Diagram.Limit.Equaliser
open import Cat.Diagram.Product.Indexed
open import Cat.Diagram.Limit.Product
open import Cat.Diagram.Limit.Base
open import Cat.Diagram.Equaliser
open import Cat.Diagram.Initial
open import Cat.Prelude

import Cat.Reasoning as Cat
module Cat.Diagram.Initial.Weak where

Weakly initial objects and families🔗

module _ {o ℓ} (C : Precategory o ℓ) where
  open Cat C

A weakly initial object is like an initial object, but dropping the requirement of uniqueness. Explicitly, an object is weakly initial in if, for every there merely exists an arrow

  is-weak-initial : ⌞ C ⌟  Type _
  is-weak-initial X =  Y  ∥ Hom X Y ∥

We can weaken this even further, by allowing a family of objects rather than the single object a family is weakly initial if, for every there exists a and a map Note that we don’t (can’t!) impose any compatibility conditions between the choices of indices.

  is-weak-initial-fam :  {ℓ'} {I : Type ℓ'} (F : I  ⌞ C ⌟)  Type _
  is-weak-initial-fam {I = I} F = (Y : ⌞ C ⌟)  ∃[ i ∈ I ] (Hom (F i) Y)

The connection between these notions is the following: the indexed product of a weakly initial family is a weakly initial object.

  is-wif→is-weak-initial
    :  {ℓ'} {I : Type ℓ'} (F : I  ⌞ C ⌟) {ΠF} {πf :  i  Hom ΠF (F i)}
     is-weak-initial-fam F
     is-indexed-product C F πf
     (y : ⌞ C ⌟)  ∥ Hom ΠF y ∥
  is-wif→is-weak-initial F {πf = πf} wif ip y = do
    (ix , h) ← wif y
    pure (h ∘ πf ix)

We can also connect these notions to the non-weak initial objects. Suppose has all equalisers, including joint equalisers for small families. If is a weakly initial object, then the domain of the joint equaliser of all arrows is an initial object.

  is-weak-initial→equaliser
    :  (X : ⌞ C ⌟) {L} {l : Hom L X}
     (∀ y  ∥ Hom X y ∥)
     is-joint-equaliser C {I = Hom X X}  x  x) l
     has-equalisers C
     is-initial C L
  is-weak-initial→equaliser X {L} {i} is-wi lim eqs y = contr cen (p' _) where
    open is-joint-equaliser lim

Since, for any the space of maps is inhabited, it will suffice to show that it is a proposition. To this end, given two arrows consider their equaliser First, we have some arrow

    p' : is-prop (Hom L y)
    p' f g = ∥-∥-out! do
      let
        module fg = Equaliser (eqs f g)
        open fg renaming (equ to j) using ()

      k ← is-wi fg.apex

Then, we can calculate: as maps we have

      let
        p =
          i               ≡⟨ introl refl ⟩
          id ∘ i          ≡⟨ equal {j = i ∘ j ∘ k}
          (i ∘ j ∘ k) ∘ i ≡⟨ pullr (pullr refl)
          i ∘ j ∘ k ∘ i   ∎

Then, since a joint equaliser is a monomorphism, we can cancel from both sides to get

        r : j ∘ k ∘ i ≡ id
        r = is-joint-equaliser→is-monic (j ∘ k ∘ i) id (sym p ∙ intror refl)

Finally, if we have with then we can calculate so is an epimorphism. So, since equalises and by construction, we have

        s : is-epic j
        s g h α = intror r ∙ extendl α ∙ elimr r

      pure (s f g fg.equal)

    cen : Hom L y
    cen = ∥-∥-out p' ((_∘ i) <$> is-wi y)

Putting this together, we can show that, if a complete category has a small weakly initial family indexed by a set, then it has an initial object.

  is-complete-weak-initial→initial
    :  {κ} {I : Type κ} (F : I  ⌞ C ⌟)_ :  {n}  H-Level I (2 + n)
     is-complete κ (ℓ ⊔ κ) C
     is-weak-initial-fam F
     Initial C
  is-complete-weak-initial→initial {κ = κ} F compl wif = record { has⊥ = equal-is-initial } where
The proof is by pasting together the results above.
    open Indexed-product

    prod : Indexed-product C F
    prod = Limit→IP C (hlevel 3) F (is-complete-lower κ ℓ κ κ compl _)

    prod-is-wi : is-weak-initial (prod .ΠF)
    prod-is-wi = is-wif→is-weak-initial F wif (prod .has-is-ip)

    equal : Joint-equaliser C {I = Hom (prod .ΠF) (prod .ΠF)} λ h  h
    equal = Limit→Joint-equaliser C _ id (is-complete-lower κ κ lzero ℓ compl _)
    open Joint-equaliser equal using (has-is-je)

    equal-is-initial = is-weak-initial→equaliser _ prod-is-wi has-is-je λ f g 
      Limit→Equaliser C (is-complete-lower κ (ℓ ⊔ κ) lzero lzero compl _)