module Cat.Instances.Coalgebras.Limits
  {o } (C : Precategory o ) {F : Functor C C} (W : Comonad-on F)
  where

Arbitrary limits of coalgebras🔗

This module concerns itself with the more general construction of limits in a category of coalgebras, as mentioned in the (more focused) construction of finite limits of coalgebras. Namely, if is a comonad on which, as a functor, preserves limits, then the forgetful functor preserves and reflects those same limits.

We start by showing reflection: Let be a diagram of be a coalgebra, and be a natural transformation If is the limit of in then is the limit of in

  is-limit-coalgebra
    :  (F : Functor I (Coalgebras W)) {K phi}
     (l : is-ran !F (πᶠ _ F∘ F) (πᶠ _ F∘ K) (nat-assoc-from (πᶠ _  phi)))
     reflects-ran (πᶠ (Coalgebras-over W)) l
  is-limit-coalgebra F {K} {phi} l = to-is-limitp mk fixup where

It will suffice to show the following: if is a natural family of coalgebra homomorphisms, then one may construct a map satisfying For if we are given such a map, we can show that is a coalgebra homomorphism Since is a limit, we may argue for preservation componentwise against the projections and we have

so that as required. Showing that is indeed the unique map factoring through is done through exactly the same style of argument.

That’s very well and good, but does such exist? Well, yes: much like in the finite case, we note that is also natural in so that the limit factorisation

exists. By composing with we obtain a map and with a short calculation we establish that this map satisfies the commutativity condition we remarked was sufficient above; we’re done!

      opaque
        ν : Hom (x .fst) (K.₀ tt .fst)
        ν = counit.ε _  l'.universal  j  F.₀ j .snd .ρ  eta j .hom) λ {x} {y} f 
          W₁ (F.₁ f .hom)  F.₀ x .snd .ρ  eta x .hom ≡⟨ pulll (F.₁ f .preserves) 
          (F.₀ y .snd .ρ  F.₁ f .hom)  eta x .hom    ≡⟨ pullr (ap hom (nat _)) 
          F.₀ y .snd .ρ  eta y .hom                   

        ν-β :  {j}  phi .η j .hom  ν  eta j .hom
        ν-β {j} =
          phi .η j .hom  ν                         ≡⟨ pulll (sym (counit.is-natural _ _ _)) 
          (counit.ε _  l'.ψ j)  l'.universal _ _  ≡⟨ pullr (l'.factors _ _) 
          counit.ε _  F.₀ j .snd .ρ  eta j .hom   ≡⟨ cancell (F.₀ _ .snd .ρ-counit) 
          eta j .hom                                
  Coalgebra-on-limit
    : (F : Functor I (Coalgebras W))
     (L : Limit (πᶠ (Coalgebras-over W) F∘ F))
     Coalgebra-on W (Limit.apex L)
  Coalgebra-on-limit F L = coalg module Coalgebra-on-limit where

It remains to show that, if and are as before, then the coalgebra structures on assemble into a coalgebra structure on Fundamentally, this amounts to construct a map

Since preserves we may treat maps as “tuplings” of morphisms and test equality componentwise. Tupling the maps where the map is the projection from the limit, we obtain a morphism uniquely characterised by having for every

    opaque
      ν : Hom L.apex (W₀ L.apex)
      ν = L'.universal  j  F.₀ j .snd .ρ  L.ψ j) λ {x} {y} h 
        W₁ (F.₁ h .hom)  F.₀ x .snd .ρ  L.ψ x ≡⟨ pulll (F.₁ h .preserves) 
        (F.₀ y .snd .ρ  F.₁ h .hom)  L.ψ x    ≡⟨ pullr (sym (L.eps .is-natural _ _ _)  elimr L.Ext.F-id) 
        F.₀ y .snd .ρ  L.ψ y                   

      ν-β :  {j}  W₁ (L.ψ j)  ν  F.₀ j .snd .ρ  L.ψ j
      ν-β = L'.factors _ _

Since we may again reason componentwise to establish compatibility of with and these will follow from the naturality of each of structural transformations, and from compatibility of each of the coalgebra maps. We comment on compatibility with the counit, and omit the rest of the proof for space.

    coalg : Coalgebra-on W (Limit.apex L)
    coalg .ρ = ν
    coalg .ρ-counit = L.unique₂ _
       f  sym (L.eps .is-natural _ _ f)  elimr L.Ext.F-id)

To show that it will suffice to show that But we have

       j  L.ψ j  ε _  ν             ≡⟨ pulll (sym (counit.is-natural _ _ _)) 
             (ε _  W₁ (L.ψ j))  ν      ≡⟨ pullr ν-β 
             ε _  F.₀ j .snd .ρ  L.ψ j ≡⟨ cancell (F.₀ j .snd .ρ-counit) 
             L.ψ j                       )
       j  idr (L.ψ j))
  Coalgebra-limit
    : (F : Functor I (Coalgebras W))
     Limit (πᶠ (Coalgebras-over W) F∘ F)
     Limit F
  Coalgebra-limit F lim .Ext = Const (_ , Coalgebra-on-limit F lim)

It remains to show that the projection maps are coalgebra homomorphisms for the “lifted” structure defined above. But this condition is precisely i.e., the defining property of

  Coalgebra-limit F lim .eps .η x .hom       = lim .eps .η x
  Coalgebra-limit F lim .eps .η x .preserves = Coalgebra-on-limit.ν-β F lim
  Coalgebra-limit F lim .eps .is-natural x y f = ext $
    ap₂ _∘_ refl (sym (lim .Ext .Functor.F-id))  lim .eps .is-natural x y f