open import Cat.Instances.Functor.Compose open import Cat.Diagram.Limit.Base open import Cat.Instances.Functor open import Cat.Diagram.Duals open import Cat.Functor.Kan open import Cat.Prelude module Cat.Functor.Kan.Right where
Right Kan extensionsπ
Dually to our setup for a left Kan extension, we have right Kan extensions: The (suitably weakly) terminal solution to the problem of lifting a functor along a functor . We picture the situation as in the following commutative diagram:
Note the same warnings about βweak, directedβ commutativity as for [left Kan extensions] apply here, too. Rather than either of the triangles commuting on the nose, we have natural transformations witnessing their commutativity.
record Ran (p : Functor C Cβ²) (F : Functor C D) : Type (kan-lvl p F) where field Ext : Functor Cβ² D eps : Ext Fβ p => F Ο : {M : Functor Cβ² D} (Ξ± : M Fβ p => F) β M => Ext Ο-comm : {M : Functor Cβ² D} {Ξ² : M Fβ p => F} β eps βnt (Ο Ξ² β p) β‘ Ξ² Ο-uniq : {M : Functor Cβ² D} {Ξ² : M Fβ p => F} {Οβ² : M => Ext} β Ξ² β‘ eps βnt (Οβ² β p) β Ο Ξ² β‘ Οβ² Ο-uniqβ : {M : Functor Cβ² D} (Ξ² : M Fβ p => F) {Οββ² Οββ² : M => Ext} β Ξ² β‘ eps βnt (Οββ² β p) β Ξ² β‘ eps βnt (Οββ² β p) β Οββ² β‘ Οββ² Ο-uniqβ Ξ² p q = sym (Ο-uniq p) β Ο-uniq q
The first thing weβll verify is that this construction is indeed dual to the left Kan extension. This is straightforward enough to do, but we have some administrative noise from all the opposite categories getting in the way.
module _ (p : Functor C Cβ²) (F : Functor C D) where open Ran open _=>_ Co-lanβRan : Lan (Functor.op p) (Functor.op F) -> Ran p F Co-lanβRan lan = ran where module lan = Lan lan ran : Ran p F ran .Ext = Functor.op lan.Ext ran .eps .Ξ· x = lan.eta .Ξ· x ran .eps .is-natural x y f = sym (lan.eta .is-natural y x f) ran .Ο {M = M} Ξ± = op (lan.Ο Ξ±β²) where Ξ±β² : Functor.op F => Functor.op M Fβ Functor.op p Ξ±β² .Ξ· x = Ξ± .Ξ· x Ξ±β² .is-natural x y f = sym (Ξ± .is-natural y x f) ran .Ο-comm = Nat-path Ξ» x β lan.Ο-comm Ξ·β x ran .Ο-uniq {M = M} {Οβ² = Οβ²} p = Nat-path Ξ» x β lan.Ο-uniq {Οβ² = Οβ²op} (Nat-path Ξ» x β p Ξ·β x) Ξ·β x where Οβ²op : lan.Ext => Functor.op M Οβ²op .Ξ· x = Οβ² .Ξ· x Οβ²op .is-natural x y f = sym (Οβ² .is-natural y x f)
Computationπ
Using the helper Co-lanβRan defined above and the formula for computing left Kan extensions, we can formulate a condition for the existence of right Kan extensions based on the size and completeness of the categories involved. If admits limits of -small diagrams, is -small, and is locally -small, then for any and , the right Kan extension exists.
module _ {o oβ² β ΞΊ} {C : Precategory ΞΊ ΞΊ} {D : Precategory oβ² ΞΊ} {E : Precategory o β} (lims : is-complete ΞΊ ΞΊ E) (p : Functor C D) (F : Functor C E) where completeβran : Ran p F completeβran = Co-lanβRan p F $ cocompleteβlan (Ξ» F β Co-limitβColimit (E ^op) (lims (Functor.op F))) (Functor.op p) (Functor.op F)
As before, itβs impossible to cheat the size limitations for computing Kan extensions as (co)limits, but this does not preclude the existence of extensions in other situations.