# Kan extension

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\colon \mathbf {A} \to \mathbf {C} ,F\colon \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}$.

It amounts to finding the dashed arrow and the 2-cell ${\displaystyle \eta }$ in the following diagram:

(The natural transformation ${\displaystyle \eta }$ in the above depiction of the right Kan extension points to the functor ${\displaystyle R}$ from the functor ${\displaystyle F}$. However, it should be interpreted as an arrow to the functor ${\displaystyle X}$ from the composed functor ${\displaystyle RF\colon \mathbf {A} \to \mathbf {C} }$.)

Formally, the right Kan extension of ${\displaystyle X}$ along ${\displaystyle F}$ consists of a functor ${\displaystyle R\colon \mathbf {B} \to \mathbf {C} }$ and a natural transformation ${\displaystyle \eta \colon RF\to X}$ which is couniversal with respect to the specification, in the sense that for any functor ${\displaystyle M\colon \mathbf {B} \to \mathbf {C} }$ and natural transformation ${\displaystyle \mu \colon MF\to X}$, a unique natural transformation ${\displaystyle \delta \colon 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)\colon 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 T}$ between the functors ${\displaystyle F,G\colon \mathbf {C} \to \mathbf {D} }$ consists of the data of an arrow ${\displaystyle T(a)\colon 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 T(a)}$ are swapped, causing ${\displaystyle T}$ 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\colon \mathbf {B} \to \mathbf {C} }$ and a natural transformation ${\displaystyle \epsilon \colon X\to LF}$ which are universal with respect to this specification, in the sense that for any other functor ${\displaystyle M\colon \mathbf {B} \to \mathbf {C} }$ and natural transformation ${\displaystyle \alpha \colon X\to MF}$, a unique natural transformation ${\displaystyle \sigma \colon 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)\colon 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 \epsilon ,\alpha }$ are the corresponding transformations, then there exists a unique isomorphism of functors ${\displaystyle \sigma \colon L\to M}$ such that the second diagram above commutes. Likewise for right Kan extensions.

## Properties

### Kan extensions as (co)limits

Suppose that ${\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 \mathrm {Lan} _{F}X}$ of ${\displaystyle X}$ along ${\displaystyle F}$, defined at each object b of B by

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

where the colimit is taken over the comma category ${\displaystyle (F\downarrow b)}$.

Dually, if A is small and C is complete, then right Kan extensions along ${\displaystyle F}$ exist, and can be computed as limits.

### Kan extensions as (co)ends

Suppose that

${\displaystyle K:\mathbf {M} \to \mathbf {C} }$ and ${\displaystyle T:\mathbf {M} \to \mathbf {A} }$

are two functors such that for all objects m and m' of M and all objects c of C, the copowers ${\displaystyle \mathbf {C} (Km',c)\cdot Tm}$ exist in A. Then the functor T has a left Kan extension L along K, which is such that, for every object c of C,

${\displaystyle Lc=(\mathrm {Lan} _{K}T)c=\int ^{m}\mathbf {C} (Km,c)\cdot Tm}$

when the above coend exists for every object c of C.

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

${\displaystyle (\mathrm {Ran} _{K}T)c=\int _{m}Tm^{\mathbf {C} (c,Km)}}$.

### Limits as Kan extensions

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

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

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

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

A functor ${\displaystyle F:C\to D}$ possesses a left adjoint if and only if the right Kan extension of ${\displaystyle \mathrm {Id} :C\to C}$ along ${\displaystyle F}$ exists and is preserved by ${\displaystyle F}$. In this case, a left adjoint is given by ${\displaystyle \mathrm {Ran} _{F}\mathrm {Id} }$ and this Kan extension is even preserved by any functor ${\displaystyle C\to 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}$.