The notion of Kan extensions subsumes all the other fundamental concepts in category theory.
Motivation
Suppose and are two functors from a common domain, suggestively diagrammed below[1]:
We are interested in functors that "extend" the functor "along" the functor .
For example, if the functor is fully faithful (i.e., is the categorical version of an inclusion), then for any functor we can view the composition as the "restriction" of to . In this case, we might hope for the existence of a functor that literally extends the functor , in the sense that .
In general, the best we can do is the following: for each functor , we can "compare" the composition with the functor by looking at the set of natural transformations between the two. More specifically, we consider either the set of natural transformations , or dually the set of natural transformations . For now, let's focus on the latter.
Our first claim is that the map is the object function of a functor . What is the arrow function? Suppose is an arrow in , i.e., a natural transformation between functors . Let be the identity natural transformation on the functor . "Horizontal" composition of the natural transformations and then gives a natural transformation . We can visualize this horizontal composition as so:
More concretely, the components of this natural transformation are given by In other words, they are simply the components of the natural transformation "restricted" to the objects in the image of .
We can now use "vertical" composition with the natural transformation to define a set map
namely by mapping each natural transformation to the (vertical) composition .
In other words,
You can now verify that we have indeed defined a functor . We can interpret this functor as an exhaustive analysis of every possible functor as a candidate for "extending" the original functor "along" the functor .
Definition of Kan extension
Definition of left Kan extension
Suppose the functor described above is representable, i.e., there exists an object together with a natural isomorphism .
By Yoneda's Lemma, the object is then unique up to unique isomorphism. It is called the left Kan extension of along , and is denoted (or sometimes simply ).
Let's unpack this definition a bit. In view of the definition of the functor , the defining property of the functor is that we have natural bijections
The reason the functor is called the left Kan extension is because it occurs on the left-hand side of its hom-set in the above bijection. As you might expect, the right Kan extension (when it exists) is a functor such that there are natural bijections
In both cases, the above bijections should look very similar to adjoint relationships, and indeed we'll see that: 1) adjoints are a special case of Kan extensions; and 2) if the left Kan extension along of every functor exists, then we do indeed have a functor that is left adjoint to the "restriction" functor (and similarly for the right Kan extension).
Local versus Global
The definition given above is sometimes called a local Kan extension, while the functor that is left adjoint to the restriction functor is called the global Kan extension.
Examples of Kan extensions
Starting with a category and nothing else
Suppose is any category. In general, there are only three functors to/from that are guaranteed to exist:
The unique (empty) functor from the initial (empty) category. (We've denoted this functor as shorthand for the "initial functor to .)
The identity functor
The unique functor to the terminal (one-object) category. (We've denoted this functor as shorthand for the "terminal functor to .)
We can now consider every possible Kan extension that involves one (or more) of these three functors. Many choices lead to "trivial" extensions, but some lead to interesting conclusions. For example, consider the situation below:
Let's first suppose the left Kan extension of the initial functor along the (unique, empty) functor exists, and denote it . Recall that we have an equivalence , where each functor corresponds to an object (namely, the image of the unique object in ). So, given any functor we can let denote the corresponding object. The left Kan extension then corresponds to an object , characterized by the existence of natural bijections
Under the equivalence , the set on the left is bijective to the set . Similarly, under the equivalence , the set on the right is simply a singleton set. (The composition must always equal the unique functor , and the only natural transformation from the functor to itself is the identity (empty) natural transformation.)
So, for every object the set is a singleton set. In other words, for every object there is a unique arrow . This exactly says that is an initial object in .
One can fairly easily show that the converse is true, namely that if has an initial object then the left Kan extension of along exists (and is the functor corresponding to that initial object). Thus, we have the following:
Initial objects as left Kan extensions
A category has an initial object if and only if the left Kan extension of along exists.
Dually, a similar argument proves:
Terminal objects as right Kan extensions
A category has a terminal object if and only if the right Kan extension of along exists.
Somewhat curiously, we can also realize initial objects as right Kan extensions. In this case, we begin from the diagram
One can then show the following:
Initial objects as right Kan extensions
A category has an initial object if and only if the right Kan extension of the identity functor along the terminal functor exists.
The proof of the above statement is slightly less straightforward than the previous argument, but is not terribly difficult (and also follows as a special case of the next type of example). And analogously, we have the dual result:
Terminal objects as left Kan extensions
A category has a terminal object if and only if the left Kan extension of the identity functor along the terminal functor exists.
In any case, out of all of the possible "extension diagrams" we can consider for a general category , these are the only two that lead to interesting outcomes, namely those that characterize the initial and terminal objects in .
Starting with a functor and nothing else
Suppose now is a given functor. Following the ideas of the previous set of examples, we can consider all "extension diagrams" that involve this functor. Once again, without knowing anything more about the categories and , there aren't very many ways to complete an "extension diagram" where one "leg" is the given functor . And out of those limited possibilities, there are only two that lead to interesting extensions.
For the first, consider the following diagram:
Suppose the left Kan extension of along exists. It is then a functor together with a natural isomorphism
Once again, the functors and correspond to objects and in , and the set on the left is canonically identified with the set of arrows . As for the set on the right, the functor sends every object to the object , so a natural transformation is exactly a "cone" from to . The above natural bijection is then exactly the condition for the object (together with the natural isomorphism ) to be the colimit of the functor . Indeed, the image under of the identity arrow gives the cone from to through which all other cones uniquely factor.
It's not hard to prove that the converse is also true, and so we have the following:
Colimits as left Kan extensions
The left Kan extension of a functor along the terminal functor gives a colimit of , and conversely.
Dually, we also have the following result:
Limits as right Kan extensions
The right Kan extension of a functor along the terminal functor gives a limit of , and conversely.
As for the other interesting diagram, now consider the following situation:
Suppose a left Kan extension of along exists, and let denote this functor. This functor comes endowed with a natural isomorphism
Consider the special case of the component map when . This is a natural bijection
Under this bijection, the identity natural transformation on corresponds to a specific natural transformation .
This situation should feel suspiciously similar. It looks like might be some type of adjoint functor! Indeed, one can prove the following:
Adjoints as Kan extensions
A left (respectively, right) Kan extension of the identity functor along the functor is exactly a functor that is right (respectively, left) adjoint to .
Left versus right
There is not a typo in the above result. The left Kan extension corresponds to a right adjoint, and a right Kan extension corresponds to a left adjoint. Definitely inconvenient for human memory!
If you're interested in the details of this proof (and a lot more about Kan extensions), definitely check out Chapter X in Mac Lane's Categories for the Working Mathematician.