# Lecture 49 - Kan Extensions

Since adjoint functors are the deepest concept in the course so far, I'll need to keep explaining them before they sink in. There are a lot of technical issues we need to discuss, but you may want to study examples first. We started looking at some examples last time. We need to see more, and think about them harder.

But I can't resist getting to the punchline: the application to databases. I'm hoping that seeing the big picture will help you understand how all the pieces fit together.

In Lecture 41 we saw a trick for getting new databases from old.

Remember, a **database schema** is just a category \(\mathcal{C}\). An **database built using this schema** is a functor

[ F : \mathcal{C} \to \mathbf{Set} .]

If we also have a functor \(G: \mathcal{D} \to \mathcal{C}\), we can take \(F\) and compose it with \(G\) to get a functor

[ F \circ G : \mathcal{D} \to \mathbf{Set} .]

But this is just a database built using the schema \(\mathcal{D}\)!

So that's a pretty obvious trick for turning databases built using the schema \(\mathcal{C}\) into databases built using the schema \(\mathcal{D}\). But often we want to reverse this procedure, and turn databases built using \(\mathcal{D}\) into databases built using \(\mathcal{C}\).

There turn out to be two ways to reverse this procedure: one using a left adjoint, and one using a right adjoint. Remember, the point of adjoints is to reverse computations

Let me sketch the idea, which is really slick. There's actually a *category* whose objects are databases built using the schema \(\mathcal{C}\), or in other words, functors \( F : \mathcal{C} \to \mathbf{Set} \). It's the functor category

[ \mathbf{Set}^{\mathcal{C}} . ]

This is why I introduced functor categories in Lecture 45! Similarly, there's a functor category

[ \mathbf{Set}^{\mathcal{D}} ]

whose objects are databases built using the schema \(\mathcal{D}\).

But we've just seen that composing with \(G: \mathcal{D} \to \mathcal{C}\) takes functors \( F : \mathcal{C} \to \mathbf{Set} \) and gives functors \( F \circ G : \mathcal{D} \to \mathbf{Set} \). In fact - this takes some work to check - this gives a functor

[ \textrm{composing with } G : \mathbf{Set}^{\mathcal{C}} \to \mathbf{Set}^{\mathcal{D}} .]

And here's the cool part: *this functor always has both a left adjoint and a right adjoint!* These are ways to turn databases built using \(\mathcal{D}\) into databases built using \(\mathcal{C}\).

These adjoints, by the way, are called **Kan extensions**. The left adjoint is called the **left Kan extension along \(G\)**, and it's denoted

[ \mathrm{Lan}_G : \mathbf{Set}^{\mathcal{D}} \to \mathbf{Set}^{\mathcal{C}} ]

where 'Lan' is a weird abbreviation of 'left Kan'. The right adjoint is called the **right Kan extension along \(G\)**, and it's denoted

[ \mathrm{Ran}_G : \mathbf{Set}^{\mathcal{D}} \to \mathbf{Set}^{\mathcal{C}}. ]

Okay, that's a lot of abstraction! Next time we need to look at some examples.

In fact you've already seen some examples, last time. You just need to see that they *are* examples.

I'll explain this next time. But just for those of you who like a challenge:

**Puzzle 154.** Which of the functors in the example and puzzles from last time last time are of the form

[ \textrm{composing with } G : \mathbf{Set}^{\mathcal{C}} \to \mathbf{Set}^{\mathcal{D}} ?]

Which are left or right adjoints of functors of this form?

Okay, maybe this is too 'meta': it's a puzzle about puzzles! But if you're taking a course on category theory, maybe you like 'meta'.

**To read other lectures go here.**