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
A comprehensive tutorial on Kan extensions can be found in “All Concepts are Kan Extensions” by M.C.Lehner.
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 
and two functors
and comes in two varieties: the "left" Kan extension and the "right" Kan extension of formula_3 along formula_4.
The right Kan extension amounts to finding the dashed arrow and the natural transformation formula_5 in the following diagram:
Formally, the right Kan extension of formula_3 along formula_4 consists of a functor formula_10 and a natural transformation formula_11 that is couniversal with respect to the specification, in the sense that for any functor formula_12 and natural transformation formula_13, a unique natural transformation formula_14 is defined and fits into a commutative diagram:
where formula_15 is the natural transformation with formula_16 for any object formula_17 of formula_18
The functor "R" is often written formula_19.
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. 
This gives rise to the alternate description: the left Kan extension of formula_3 along formula_4 consists of a functor formula_29 and a natural transformation formula_30 that are universal with respect to this specification, in the sense that for any other functor formula_12 and natural transformation formula_32, a unique natural transformation formula_33 exists and fits into a commutative diagram:
where formula_34 is the natural transformation with formula_35 for any object formula_17 of formula_37.
The functor "L" is often written formula_38.
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 formula_39 are two left Kan extensions of formula_3 along formula_4, and formula_42 are the corresponding transformations, then there exists a unique "isomorphism" of functors formula_33 such that the second diagram above commutes. Likewise for right Kan extensions.
Properties.
Kan extensions as (co)limits.
Suppose formula_44 and formula_45 are two functors. If A is small and C is cocomplete, then there exists a left Kan extension formula_38 of formula_3 along formula_4, defined at each object "b" of B by
where the colimit is taken over the comma category formula_50, where formula_51 is the constant functor. Dually, if A is small and C is complete, then right Kan extensions along formula_4 exist, and can be computed as the limit 
over the comma category formula_54.
Kan extensions as (co)ends.
Suppose formula_55 and formula_56 are two functors such that for all objects "m" and "m′" of M and all objects "c" of C, the copowers formula_57 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,
when the above coend exists for every object "c" of C.
Dually, right Kan extensions can be computed by the end formula
Limits as Kan extensions.
The limit of a functor formula_60 can be expressed as a Kan extension by
where formula_62 is the unique functor from formula_63 to 𝟙 (the category with one object and one arrow, a terminal object in formula_64). The colimit of formula_4 can be expressed similarly by
Adjoints as Kan extensions.
A functor formula_67 possesses a left adjoint if and only if the right Kan extension of formula_68 along formula_4 exists and is preserved by formula_4. In this case, a left adjoint is given by formula_71 and this Kan extension is even preserved by any functor formula_72 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 formula_4 exists and is preserved by formula_4.
Applications.
The codensity monad of a functor formula_75 is a right Kan extension of "G" along itself.