# A Note on Kan Extensions Let $A,B$ be categories, with $B$ complete and cocomplete. Let $L\dashv R : B\to A$ be an adjunction with unit $\eta:Id\to RL$ and counit $\epsilon:LR\to Id$. ## Extending Functors **Prop**: Let $F:A\to A$. Then $LFR$ is the left Kan extension of $LF$ along $L$. *Proof (Sketch):* The unit $LF\to LFRL$ of the Kan extension is $LF\eta$. Moreover, due to $R$ being a right adjoint, we have for all $LF\to GL$ a suitable $LFR\to G$ (due to $L\dashv R$). ![image](https://hackmd.io/_uploads/rJz3LkZoA.png) **Prop**: Let $G:B\to B$. Then $RGL$ is the right Kan extension of $RG$ along $R$. *Proof (Sketch):* The counit $RGLR\to RG$ is $RG\epsilon$ and for all $FR\to RG$ there is a suitable $F\to RGL$. **Remark:** By duality, any one of the propositions implies the other. ## Extending (Co)Monads Continuing from above: **Prop:** If, moreover, $G$ is a monad ($F$ is a comonad), then $RGL$ is a monad ($LFR$ is a comonad). *Proof (Sketch):* Let $e$ and $m$ be the unit and multiplication of the monad $G$. The unit of the monad $RGL$ is $Id \stackrel \eta \to RL \stackrel {ReL} \to RGL$ and the multiplication is $RGLRGL \stackrel {RG\epsilon GL} \to RGGL \stackrel {RmL} \to RGL$. The statement about comonads follows by duality. **Remark:** This generalizes the well known fact that $RL$ itself is a monad. ## Codensity Monads (under construction) The previous proposition generalizes to the situation where $R$ does not have a left adjoint (or $L$ does not have a right adjoint). Thus, for this section drop the assumption that $L\dashv R$. **Prop:** If $G$ is a monad, then ${\rm Ran_R} RG$ is a monad. If $F$ is a comonad, then ${\rm Lan}_L LF$ is a comonad. *Proof (Sketch):* Let $e$ and $m$ be the unit and multiplication of the monad $G$. Abbreviate $M={\rm Ran}_RRG$. The unit of the monad $M$ is obtained from factoring $Re:R\to RG$ through the counit $M R\to RG$ of the right Kan extension. The multiplication of the monad is given by factoring $MMR\stackrel {(\epsilon,\epsilon)} \to RGG \stackrel {Rm} \to RG$ through the counit of the Kan extension. We get the remarkable consequence that every functor (under some completeness assumptions on the codomain) induces a monad and a comonad: **Corollary:** For every functor $R$ with complete codomain, ${\rm Ran}_R R$ is a monad (the *codensity monad* of $R$). For every functor $L$ with cocomplete codomain, ${\rm Lan}_L L$ is a comonad (the *density comonad* of $L$). ## References For the definition of a left Kan extension see [Definition 2.4 at the nLab article on Kan extensions](https://ncatlab.org/nlab/show/Kan+extension#LocalKanExtensions). For the definition of a right Kan extension replace the categories $A,B$ by their opposites. This amounts to keeping the direction of the functors the same but turning around the natural transformations. Codensity monads appear in the last exercise of [Mac Lane 1971](https://ncatlab.org/nlab/show/Categories+for+the+Working+Mathematician). For more see [nLab - codensity monad](https://ncatlab.org/nlab/show/codensity+monad). ## Appendix: Kan extensions $K$ is the left Kan extension of $J$ along $I$ if there is a "unit" $J\to KI$ such that all $J\to HI$ factor uniquely through the unit. $K$ is the right Kan extension of $J$ along $I$ if there is a "counit" $KI\to J$ such that all $HI\to J$ factor uniquely through the counit. ## Appendix: Links to Diagrams https://q.uiver.app/#q=WzAsOSxbMSwxLCJCIl0sWzMsMSwiQiJdLFsxLDMsIkEiXSxbMywzLCJBIl0sWzUsMSwiQiJdLFs3LDEsIkIiXSxbNSwzLCJBIl0sWzcsMywiQSJdLFswLDBdLFsyLDAsIkwiLDAseyJjdXJ2ZSI6LTF9XSxbMywxLCJMIiwxXSxbMiwzLCJGIiwyXSxbMCwxLCJ7XFxybSBMYW59X0wgTEYiXSxbMCwyLCJSIiwwLHsiY3VydmUiOi0xfV0sWzAsMiwiXFxkYXNodiIsMSx7InN0eWxlIjp7ImJvZHkiOnsibmFtZSI6Im5vbmUifSwiaGVhZCI6eyJuYW1lIjoibm9uZSJ9fX1dLFs0LDUsIkciXSxbNCw2LCJSIiwwLHsiY3VydmUiOi0xfV0sWzYsNCwiTCIsMCx7ImN1cnZlIjotMX1dLFs1LDcsIlIiXSxbNiw3LCJ7XFxybSBSYW59X1IgUkciLDJdLFs0LDYsIlxcZGFzaHYiLDEseyJzdHlsZSI6eyJib2R5Ijp7Im5hbWUiOiJub25lIn0sImhlYWQiOnsibmFtZSI6Im5vbmUifX19XV0=