Kan extensions are universal constructs in category theory, a branch of mathematics. They are closely related to adjoints, but are also related to limits and ends. They are named after Daniel M. Kan, who constructed certain (Kan) extensions using limits in 1960.

An early use of (what is now known as) a Kan extension from 1956 was in homological algebra to compute derived functors.

In Categories for the Working Mathematician Saunders Mac Lane titled a section "All Concepts Are Kan Extensions", and went on to write that

The notion of Kan extensions subsumes all the other fundamental concepts of category theory.

Kan extensions generalize the notion of extending a function defined on a subset to a function defined on the whole set. The definition, not surprisingly, is at a high level of abstraction. When specialised to posets, it becomes a relatively familiar type of question on constrained optimization.

Definition

A Kan extension proceeds from the data of three categories

${\displaystyle \mathbf {A} ,\mathbf {B} ,\mathbf {C} }$

and two functors

${\displaystyle X:\mathbf {A} \to \mathbf {C} ,F:\mathbf {A} \to \mathbf {B} }$,

and comes in two varieties: the "left" Kan extension and the "right" Kan extension of ${\displaystyle X}$ along ${\displaystyle F}$.

The right Kan extension amounts to finding the dashed arrow and the natural transformation ${\displaystyle \epsilon }$ in the following diagram:

Formally, the right Kan extension of ${\displaystyle X}$ along ${\displaystyle F}$ consists of a functor ${\displaystyle R:\mathbf {B} \to \mathbf {C} }$ and a natural transformation ${\displaystyle \epsilon :RF\to X}$ that is couniversal with respect to the specification, in the sense that for any functor ${\displaystyle M:\mathbf {B} \to \mathbf {C} }$ and natural transformation ${\displaystyle \mu :MF\to X}$, a unique natural transformation ${\displaystyle \delta :M\to R}$ is defined and fits into a commutative diagram:

where ${\displaystyle \delta _{F))$ is the natural transformation with ${\displaystyle \delta _{F}(a)=\delta (Fa):MF(a)\to RF(a)}$ for any object ${\displaystyle a}$ of ${\displaystyle \mathbf {A} .}$

The functor R is often written ${\displaystyle \operatorname {Ran} _{F}X}$.

As with the other universal constructs in category theory, the "left" version of the Kan extension is dual to the "right" one and is obtained by replacing all categories by their opposites.

The effect of this on the description above is merely to reverse the direction of the natural transformations.

(Recall that a natural transformation ${\displaystyle \tau }$ between the functors ${\displaystyle F,G:\mathbf {C} \to \mathbf {D} }$ consists of having an arrow ${\displaystyle \tau (a):F(a)\to G(a)}$ for every object ${\displaystyle a}$ of ${\displaystyle \mathbf {C} }$, satisfying a "naturality" property. When we pass to the opposite categories, the source and target of ${\displaystyle \tau (a)}$ are swapped, causing ${\displaystyle \tau }$ to act in the opposite direction).

This gives rise to the alternate description: the left Kan extension of ${\displaystyle X}$ along ${\displaystyle F}$ consists of a functor ${\displaystyle L:\mathbf {B} \to \mathbf {C} }$ and a natural transformation ${\displaystyle \eta :X\to LF}$ that are universal with respect to this specification, in the sense that for any other functor ${\displaystyle M:\mathbf {B} \to \mathbf {C} }$ and natural transformation ${\displaystyle \alpha :X\to MF}$, a unique natural transformation ${\displaystyle \sigma :L\to M}$ exists and fits into a commutative diagram:

where ${\displaystyle \sigma _{F))$ is the natural transformation with ${\displaystyle \sigma _{F}(a)=\sigma (Fa):LF(a)\to MF(a)}$ for any object ${\displaystyle a}$ of ${\displaystyle \mathbf {A} }$.

The functor L is often written ${\displaystyle \operatorname {Lan} _{F}X}$.

The use of the word "the" (as in "the left Kan extension") is justified by the fact that, as with all universal constructions, if the object defined exists, then it is unique up to unique isomorphism. In this case, that means that (for left Kan extensions) if ${\displaystyle L,M}$ are two left Kan extensions of ${\displaystyle X}$ along ${\displaystyle F}$, and ${\displaystyle \eta ,\alpha }$ are the corresponding transformations, then there exists a unique isomorphism of functors ${\displaystyle \sigma :L\to M}$ such that the second diagram above commutes. Likewise for right Kan extensions.

Properties

Kan extensions as (co)limits

 Further information: limit (category theory)

Suppose ${\displaystyle X:\mathbf {A} \to \mathbf {C} }$ and ${\displaystyle F:\mathbf {A} \to \mathbf {B} }$ are two functors. If A is small and C is cocomplete, then there exists a left Kan extension ${\displaystyle \operatorname {Lan} _{F}X}$ of ${\displaystyle X}$ along ${\displaystyle F}$, defined at each object b of B by

${\displaystyle (\operatorname {Lan} _{F}X)(b)=\varinjlim _{f:Fa\to b}X(a)}$

where the colimit is taken over the comma category ${\displaystyle (F\downarrow \operatorname {const} _{b})}$, where ${\displaystyle \operatorname {const} _{b}\colon \ast \to \mathbf {B} ,\ast \mapsto b}$ is the constant functor. Dually, if A is small and C is complete, then right Kan extensions along ${\displaystyle F}$ exist, and can be computed as the limit

${\displaystyle (\operatorname {Ran} _{F}X)(b)=\varprojlim _{Fa\leftarrow b}X(a)}$

over the comma category ${\displaystyle (\operatorname {const} _{b}\downarrow F)}$.

Kan extensions as (co)ends

 Further information: coend (category theory)

Suppose ${\displaystyle X:\mathbf {A} \to \mathbf {C} }$ and ${\displaystyle F:\mathbf {A} \to \mathbf {B} }$ are two functors such that for all objects a and a of A and all objects b of B, the copowers ${\displaystyle \mathbf {B} (Fa',b)\cdot Xa}$ exist in C. Then the functor X has a left Kan extension ${\displaystyle \operatorname {Lan} _{F}X}$ along F, which is such that, for every object b of B,

${\displaystyle (\operatorname {Lan} _{F}X)b=\int ^{a}\mathbf {B} (Fa,b)\cdot Xa}$

when the above coend exists for every object b of B.

Dually, right Kan extensions can be computed by the end formula

${\displaystyle (\operatorname {Ran} _{F}X)b=\int _{a}Xa^{\mathbf {B} (b,Fa)}.}$

Limits as Kan extensions

The limit of a functor ${\displaystyle F:\mathbf {C} \to \mathbf {D} }$ can be expressed as a Kan extension by

${\displaystyle \lim F=\operatorname {Ran} _{E}F}$

where ${\displaystyle E}$ is the unique functor from ${\displaystyle \mathbf {C} }$ to ${\displaystyle \mathbf {1} }$ (the category with one object and one arrow, a terminal object in ${\displaystyle \mathbf {Cat} }$). The colimit of ${\displaystyle F}$ can be expressed similarly by

${\displaystyle \operatorname {colim} F=\operatorname {Lan} _{E}F.}$

A functor ${\displaystyle F:\mathbf {C} \to \mathbf {D} }$ possesses a left adjoint if and only if the right Kan extension of ${\displaystyle \operatorname {Id} :\mathbf {C} \to \mathbf {C} }$ along ${\displaystyle F}$ exists and is preserved by ${\displaystyle F}$. In this case, a left adjoint is given by ${\displaystyle \operatorname {Ran} _{F}\operatorname {Id} }$ and this Kan extension is even preserved by any functor ${\displaystyle \mathbf {C} \to \mathbf {E} }$ whatsoever, i.e. is an absolute Kan extension.
Dually, a right adjoint exists if and only if the left Kan extension of the identity along ${\displaystyle F}$ exists and is preserved by ${\displaystyle F}$.
The codensity monad of a functor ${\displaystyle G:\mathbf {D} \to \mathbf {C} }$ is a right Kan extension of G along itself.