It looks like you're new here. If you want to get involved, click one of these buttons!

- All Categories 2.3K
- Chat 501
- Study Groups 21
- Petri Nets 9
- Epidemiology 4
- Leaf Modeling 2
- Review Sections 9
- MIT 2020: Programming with Categories 51
- MIT 2020: Lectures 20
- MIT 2020: Exercises 25
- Baez ACT 2019: Online Course 339
- Baez ACT 2019: Lectures 79
- Baez ACT 2019: Exercises 149
- Baez ACT 2019: Chat 50
- UCR ACT Seminar 4
- General 70
- Azimuth Code Project 110
- Statistical methods 4
- Drafts 9
- Math Syntax Demos 15
- Wiki - Latest Changes 3
- Strategy 113
- Azimuth Project 1.1K
- - Spam 1
- News and Information 148
- Azimuth Blog 149
- - Conventions and Policies 21
- - Questions 43
- Azimuth Wiki 715

Options

This was a very difficult chapter for me to teach, at least near the end, because it covered some central topics in category theory at a very rapid pace. It was hard to resist going into more detail... but I felt that this chapter was more intimidating than the previous ones, and that more detail might make things even worse!

For example, I said that an adjunction is a pair of functors \(F: \mathcal{A} \to \mathcal{B}\) and \(G: \mathcal{B} \to \mathcal{A}\) equipped with a natural isomorphism

$$ \alpha : \mathcal{B}(F(-),-) \to \mathcal{A}(-,G(-)). $$
I told you what a natural isomorphism is, and we saw what this particular isomorphism is like in some examples... but I didn't really say what benefit we get out of it being *natural*.

We would see this if we discussed how adjunctions give monads, but the textbook doesn't discuss monads at all! I hear hundreds of Haskell programmers groaning in dismay... but presumably this decision was made because monads are already covered by plenty of more traditional textbooks.

Another thing that pains me is this: I don't think I managed to give enough examples to fully explain the sense in which left adjoints are 'liberal' or 'generous' while right adjoints are 'conservative' or 'cautious'.

I also didn't explain *why*, whenever you have a functor \(G : \mathcal{D} \to \mathcal{C}\), the functor

$$ \text{composition with } G : \mathbf{Set}^\mathcal{C} \to \mathbf{Set}^{\mathcal{D}} $$ has both a left adjoint

$$ \text{Lan}_G : \mathbf{Set}^{\mathcal{D}} \to \mathbf{Set}^{\mathcal{C}} $$
called **left Kan extenson along \(G\)**, and a right adjoint

$$ \text{Ran}_G : \mathbf{Set}^{\mathcal{D}} \to \mathbf{Set}^{\mathcal{C}} $$
called **right Kan extension along \(G\)**.

Our textbook makes a good stab at this in one case: the case where \(\mathcal{C}\) is \(\mathbf{1}\), the category with one object and one morphism. There exists a unique functor from any category \(\mathcal{D}\) to \(\mathbf{1}\), usually denoted

$$ ! : \mathcal{D} \to \mathbf{1} $$ Right Kan extension along \(!\) is a functor

$$ \text{Ran}_! : \mathbf{Set}^{\mathcal{D}} \to \mathbf{Set}^{\mathbf{1}} $$ but since \(\mathbf{Set}^{\mathbf{1}}\) is isomorphic to \(\mathbf{Set}\), we can think of it as a functor

$$ \lim_{\mathcal{D}} : \mathbf{Set}^{\mathcal{D}} \to \mathbf{Set} $$
I'm using this funny notation because that's what this functor is usually called: in particular, given an object \(F\) in \(\mathbf{Set}^{\mathcal{D}}\), meaning a functor \(F : \mathcal{D} \to \mathbf{Set}\), we get a set called its **limit**,

$$ \displaystyle{\lim_{\mathcal{D}} F}. $$ And Theorem 3.79 in this book says how to compute it!

Similarly, the left Kan extension along \(!\) is called a **colimit**. Limits and colimits are very important in category theory - but again, they're covered in great detail in all the standard textbooks, so Fong and Spivak didn't feel the need to dwell on them.

So much to explain, so little time!

Please ask questions if you want to know more about anything. As for my lectures, I must now move on to Chapter 4. I'll just leave you with a few puzzles:

**Puzzle 166.** Let \(\mathcal{D}\) be the free category on this graph:

and let \(\mathbf{1}\) be the free category on this graph:

(This is just a German-centered way of thinking about the category with one object and one morphism.) Take a database \(F: \mathbf{1} \to \mathbf{Set}\), for example this:

What is the database \( F \circ ! :\mathcal{D} \to \mathbf{Set}\)?

**Puzzle 167.** Next, take a database \(H: \mathcal{C} \to \mathbf{Set}\), for example this:

What is the database \(\mathrm{Ran}_! : \mathbf{1} \to \mathbf{Set}\)? What is the database \(\mathrm{Lan}_! : \mathbf{1} \to \mathbf{Set}\)?

**Puzzle 168.** Suppose \(F\) is a left adjoint of \(G\), as above. If \(a \in \mathrm{Ob}(\mathcal{A})\) and \(b \in \mathrm{Ob}(\mathcal{B})\) we get a bijection

$$ \alpha_{a,b} : \mathcal{B}(F(a),b) \to \mathcal{A}(a,G(b)). $$ Similarly, if \(a' \in \mathrm{Ob}(\mathcal{A})\) and \(b' \in \mathrm{Ob}(\mathcal{B})\) we get a bijection

$$ \alpha_{a',b'} : \mathcal{B}(F(a'),b') \to \mathcal{A}(a',G(b')). $$ Show that if \(f: a' \to a\) and \(g: b \to b'\) we get a commutative square

$$ \begin{matrix} & & \alpha_{a,b} & & \\ & \mathcal{B}(F(a),b) & \rightarrow & \mathcal{A}(a,G(b)) &\\ \mathcal{B}(F(f),g) & \downarrow & & \downarrow & \mathcal{A}(f,G(g)) \\ & \mathcal{B}(F(a'),b') & \rightarrow & \mathcal{A}(a',G(b')) &\\ & & \alpha_{a',b'} & & \\ \end{matrix} $$ To see what this means concretely, take a guy \(h \in \mathcal{B}(F(a),b) \), meaning a morphism \(h : F(a) \to b\), and send it around the square both ways: down and then across, or across and then down. You get two morphisms from \( a' \) to \(G(b')\); what are they? Since the square commutes these must be equal.

## Comments

OK, I'll ask a very high level question, because I have shamefully been too busy to keep up with the technical detail for the last couple of weeks: how do we make this definition of limit yield the notion of a product (which I understand is a kind of limit). People who have taken at least part of a category theory course may have encountered the definition of a product via a universal property (https://en.wikipedia.org/wiki/Product_(category_theory)): how does this relate? I think once I understand this (and I'll need to work through the details) a lot of stuff will click.

`OK, I'll ask a very high level question, because I have shamefully been too busy to keep up with the technical detail for the last couple of weeks: how do we make this definition of limit yield the notion of a product (which I understand is a kind of limit). People who have taken at least part of a category theory course may have encountered the definition of a product via a universal property (https://en.wikipedia.org/wiki/Product_(category_theory)): how does this relate? I think once I understand this (and I'll need to work through the details) a lot of stuff will click.`

@Reuben asked:

Let's see what happens when we set \(\mathcal{D} = \textrm{2}\) (the category with two discrete objects).

A \(\textrm{2}\)-database is a functor \(H : \textrm{2} \rightarrow \textbf{Set}\), ie an ordered pair of sets \(\langle A, B \rangle\).

There's a unique map \(! : \textrm{2} \rightarrow \textrm{1}\).

A \(\textrm{1}\)-database is a functor \(F : \textrm{1} \rightarrow \textbf{Set}\), ie a single set \(X\).

Given any \(F\) we can precompose with \(!\) to get a \(\textrm{2}\)-database \(F \circ !\).

This is the diagonal pair \(\langle X, X \rangle\).

The right Kan extension is the right adjoint to the functor \(F \mapsto F \circ !\).

It sends \(\textrm{2}\)-databases to \(\textrm{1}\)-databases, so the pair of sets \(\langle A, B \rangle\) is sent to a single set \(P\).

Given any \(F\), \(H\) we have \(\textrm{Nat}[F \circ !, H] \cong \textrm{Nat}[F, \textrm{Ran}_!(H)]\).

ie natural transformations from \(F \circ !\) to \(H\) correspond bijectively to natural transformations from \(F\) to \(\textrm{Ran}_!(H)\).

ie pairs of maps \(a : X \rightarrow A\), \(b : X \rightarrow B\) correspond to single maps \(k : X \rightarrow P\).

In particular we can set \(F = \textrm{Ran}_!(H)\), ie \(X = P\), and get a pair of maps \(p : P \rightarrow A\), \(q : P \rightarrow B\) corresponding to the identity \(e : P \rightarrow P\).

By naturality in \(F\) the composites \(p \circ k : X \rightarrow P \rightarrow A\) and \(q \circ k : X \rightarrow P \rightarrow B\) correspond to \(e \circ k : X \rightarrow P \rightarrow P = k : X \rightarrow P\).

And since the correspondence is bijective we must have \(a = p \circ k\) and \(b = q \circ k\).

Bijectivity also tells us that \(p \circ k' = p \circ k\) and \(q \circ k' = q \circ k\) implies \(e \circ k' = e \circ k\), ie \(k' = k\).

In other words, for any pair of maps \(a : X \rightarrow A\), \(b : X \rightarrow B\) there is a unique map \(k : X \rightarrow P\) such that \(a = p \circ k\) and \(b = q \circ k\).

ie \(P\) is product of \(A\) and \(B\), with projection maps \(p\) and \(q\).

`@Reuben asked: > how do we make this definition of limit yield the notion of a product (which I understand is a kind of limit) Let's see what happens when we set \\(\mathcal{D} = \textrm{2}\\) (the category with two discrete objects). A \\(\textrm{2}\\)-database is a functor \\(H : \textrm{2} \rightarrow \textbf{Set}\\), ie an ordered pair of sets \\(\langle A, B \rangle\\). There's a unique map \\(! : \textrm{2} \rightarrow \textrm{1}\\). A \\(\textrm{1}\\)-database is a functor \\(F : \textrm{1} \rightarrow \textbf{Set}\\), ie a single set \\(X\\). Given any \\(F\\) we can precompose with \\(!\\) to get a \\(\textrm{2}\\)-database \\(F \circ !\\). This is the diagonal pair \\(\langle X, X \rangle\\). The right Kan extension is the right adjoint to the functor \\(F \mapsto F \circ !\\). It sends \\(\textrm{2}\\)-databases to \\(\textrm{1}\\)-databases, so the pair of sets \\(\langle A, B \rangle\\) is sent to a single set \\(P\\). Given any \\(F\\), \\(H\\) we have \\(\textrm{Nat}[F \circ !, H] \cong \textrm{Nat}[F, \textrm{Ran}_!(H)]\\). ie natural transformations from \\(F \circ !\\) to \\(H\\) correspond bijectively to natural transformations from \\(F\\) to \\(\textrm{Ran}_!(H)\\). ie pairs of maps \\(a : X \rightarrow A\\), \\(b : X \rightarrow B\\) correspond to single maps \\(k : X \rightarrow P\\). In particular we can set \\(F = \textrm{Ran}_!(H)\\), ie \\(X = P\\), and get a pair of maps \\(p : P \rightarrow A\\), \\(q : P \rightarrow B\\) corresponding to the identity \\(e : P \rightarrow P\\). By naturality in \\(F\\) the composites \\(p \circ k : X \rightarrow P \rightarrow A\\) and \\(q \circ k : X \rightarrow P \rightarrow B\\) correspond to \\(e \circ k : X \rightarrow P \rightarrow P = k : X \rightarrow P\\). And since the correspondence is bijective we must have \\(a = p \circ k\\) and \\(b = q \circ k\\). Bijectivity also tells us that \\(p \circ k' = p \circ k\\) and \\(q \circ k' = q \circ k\\) implies \\(e \circ k' = e \circ k\\), ie \\(k' = k\\). In other words, for any pair of maps \\(a : X \rightarrow A\\), \\(b : X \rightarrow B\\) there is a unique map \\(k : X \rightarrow P\\) such that \\(a = p \circ k\\) and \\(b = q \circ k\\). ie \\(P\\) is product of \\(A\\) and \\(B\\), with projection maps \\(p\\) and \\(q\\).`

ok, this is amazingly helpful - thanks so much!!

`ok, this is amazingly helpful - thanks so much!!`

Puzzle 166: it maps all the objects to F(German) and all the morphisms to id, so you get the database

`German | Friend Italian Ilsa. | Ilsa. Ilsa. Klaus. | Klaus. Klaus. ... ... ...`

`Puzzle 166: it maps all the objects to F(German) and all the morphisms to id, so you get the database `German | Friend Italian Ilsa. | Ilsa. Ilsa. Klaus. | Klaus. Klaus. ... ... ... ``

Puzzle 167.I haven't solved the puzzle, but here is what I got so far; maybe someone can help me out.From the definition of the left Kan extension, we know there is an one-to-one correspondence between

$$ \textrm{ morphisms from } \textrm{Lan}_!(H) \textrm{ to } F $$ in category \(\mathbf{Set}^1\), and

$$ \textrm{ morphisms from } H \textrm{ to } F \circ ! $$ in category \(\mathbf{Set}^\mathcal{D}\).

I was thinking that maybe we can use the cardinality of the two sets of morphisms to get an idea of what \(\textrm{Lan}_!(H)\) is.

In \(\mathbf{Set}^1\), the objects are sets and the morphisms are functions. If we denote the set picked by \(\textrm{Lan}_!(H)\) by \(T\) and the set picked by \(F\) by \(S\), then the number of morphisms is \(|S|^{|T|}\).

In \(\mathbf{Set}^\mathcal{D}\), the functor \(F \circ !\) picks the same set as \(F\); more precisely, \((F \circ !)(\textrm{Germans}) = S\), \((F \circ !)(\textrm{Italians}) = S\) and \((F \circ !)(\textrm{Friend}) = 1\) (as Christopher has already pointed out). The morphisms are natural transformations and they have to satisfy the naturality condition: \(\alpha_\textrm{Germans} = \alpha_\textrm{Italians} \circ H(\textrm{Friend})\). I think that the number of natural transformations is given by the number of functions \(\alpha_\textrm{Italians}\) from \(H(\textrm{Italians})\) to \(S\), since the component for Germans is completely specified by the component for Italians.

So it seems that the cardinality of the set picked by the left Kan extension equals the cardinality of the set \(H(\textrm{Italians})\).

`**Puzzle 167.** I haven't solved the puzzle, but here is what I got so far; maybe someone can help me out. From the definition of the left Kan extension, we know there is an one-to-one correspondence between \[ \textrm{ morphisms from } \textrm{Lan}_!(H) \textrm{ to } F \] in category \\(\mathbf{Set}^1\\), and \[ \textrm{ morphisms from } H \textrm{ to } F \circ ! \] in category \\(\mathbf{Set}^\mathcal{D}\\). I was thinking that maybe we can use the cardinality of the two sets of morphisms to get an idea of what \\(\textrm{Lan}_!(H)\\) is. - In \\(\mathbf{Set}^1\\), the objects are sets and the morphisms are functions. If we denote the set picked by \\(\textrm{Lan}_!(H)\\) by \\(T\\) and the set picked by \\(F\\) by \\(S\\), then the number of morphisms is \\(|S|^{|T|}\\). - In \\(\mathbf{Set}^\mathcal{D}\\), the functor \\(F \circ !\\) picks the same set as \\(F\\); more precisely, \\((F \circ !)(\textrm{Germans}) = S\\), \\((F \circ !)(\textrm{Italians}) = S\\) and \\((F \circ !)(\textrm{Friend}) = 1\\) (as Christopher has already pointed out). The morphisms are natural transformations and they have to satisfy the naturality condition: \\(\alpha_\textrm{Germans} = \alpha_\textrm{Italians} \circ H(\textrm{Friend})\\). I think that the number of natural transformations is given by the number of functions \\(\alpha_\textrm{Italians}\\) from \\(H(\textrm{Italians})\\) to \\(S\\), since the component for Germans is completely specified by the component for Italians. So it seems that the cardinality of the set picked by the left Kan extension equals the cardinality of the set \\(H(\textrm{Italians})\\).`

1) John, can you recommend a book that covers monads as a next book after Fong & Spivak (especially if it includes applications such as functional programming)?

2) I have a question that arose from trying to transfer Chapter 1's discussion of adjunctions to functors. For a preorder adjunction \(f \dashv g\), we saw that by setting \(b = f(a)\), we could derive \(a \leq g(f(a))\).

Doing the same thing for categories results in a natural isomorphism between

$$ \textrm{Hom}_\mathcal{A}(a,R(L(a))) \qquad\textrm{and}\qquad \textrm{Hom}_\mathcal{B}(L(a),L(a)) $$ Since the second hom-set always contains at least an identity morphism, the first hom-set must contain at least one element. That non-emptiness is the analog of the inequality for preorders.

But here we have an isomorphism between \(\textrm{id}_{L(a)}\) and some morphism \(s:a \rightarrow R(L(a))\). Since identity morphisms are very special, it feels like there should be something special about its isomorphic partner. Is that true?

I wasn't able to find something special. I tried following the naturality conditions, but no unusual properties jumped out at me.

`1) John, can you recommend a book that covers monads as a next book after Fong & Spivak (especially if it includes applications such as functional programming)? ***** 2) I have a question that arose from trying to transfer Chapter 1's discussion of adjunctions to functors. For a preorder adjunction \\(f \dashv g\\), we saw that by setting \\(b = f(a)\\), we could derive \\(a \leq g(f(a))\\). Doing the same thing for categories results in a natural isomorphism between \[ \textrm{Hom}\_\mathcal{A}(a,R(L(a))) \qquad\textrm{and}\qquad \textrm{Hom}\_\mathcal{B}(L(a),L(a)) \] Since the second hom-set always contains at least an identity morphism, the first hom-set must contain at least one element. That non-emptiness is the analog of the inequality for preorders. But here we have an isomorphism between \\(\textrm{id}_{L(a)}\\) and some morphism \\(s:a \rightarrow R(L(a))\\). Since identity morphisms are very special, it feels like there should be something special about its isomorphic partner. Is that true? I wasn't able to find something special. I tried following the naturality conditions, but no unusual properties jumped out at me.`

Technically speaking, there's nothing stopping Fong and Spivak from adding a section on monads, since their book is a rough draft right now.

`Technically speaking, there's nothing stopping Fong and Spivak from adding a section on monads, since their book is a rough draft right now.`

Pete wrote:

Have you looked at this one?

Category Theory for Programmers.It's free online.

`Pete wrote: > 1) John, can you recommend a book that covers monads as a next book after Fong & Spivak (especially if it includes applications such as functional programming)? Have you looked at this one? * Bartosz Milewski, _[Category Theory for Programmers](https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/)_. It's free online.`

Reuben wrote:

Anindya gave a very precise answer, so let me give a vague answer - sometimes it's nice to think a bit more vaguely.

The definition of product you're thinking about says roughly "a morphism from an object \(A\) to a product of objects \(X \times Y\) is the same as a morphism from \(A\) to \(X\) together with a morphism from \(A\) to \(Y\)".

(Experienced category theorists use "is the same as" to indicate a natural one-to-one correspondence obtained by a universal property. It needs to be fleshed out to be made precise, but it's nice when you're trying to talk quickly!)

In my lecture I only discussed limits in the category \(\mathbf{Set}\). This isn't strictly necessary, but let's stick with that case, and see how such limits can give products in the category \(\mathbf{Set}\).

For starters, let's say "a function from a set \(A\) to a product of sets \(X \times Y\) is the same as a function from \(A\) to \(X\) together with a function from \(A\) to \(Y\)".

Translating into a more mathematical style of talking, this says:

$$ \mathbf{Set}^2( (A, A) , (X,Y)) \cong \mathbf{Set}(A, X \times Y). $$ Get it?

If not:

An element in the left-hand side is a morphism in \(\mathbf{Set}^2\) from the object \( (A,A) \) to the object \( (X,Y) \). Remember, an object in \(\mathbf{Set}^2\) is a pair of sets and a morphism is a pair of functions. So, an element in the left-hand side is a function from \(A\) to \(X\) together with a function from \(A\) to \(Y\).

An element in the right-hand side is just a function from \(A\) to \(X \times Y\).

This more mathematical way of talking is nice because when you see this:

\[ \mathbf{Set}^2( (A, A) , (X,Y)) \cong \mathbf{Set}(A, X \times Y). \]

you should instantly guess that we're dealing with a left adjoint and a right adjoint. On the left we're taking \(A\) and "duplicating" it to get \( (A,A)\). On the right we're taking \( (X,Y) \) and "producting" it to get \( X \times Y\).

So, you should suspect that the left-hand side is talking about the "duplication" functor

$$ \Delta : \mathbf{Set} \to \mathbf{Set}^2 $$ which takes any set \(A\) and duplicates it to get \( (A,A) \), while the right-hand side is talking about the "product" functor

$$ \times : \mathbf{Set}^2 \to \mathbf{Set} $$ which takes any pair of sets \( (X,Y) \) and forms their product \( X \times Y\).

In fact, you should suspect that

$$ \Delta : \mathbf{Set} \to \mathbf{Set}^2 $$ is the left adjoint of

$$ \times : \mathbf{Set}^2 \to \mathbf{Set} $$ And it's true!

In other words,

$$ \times : \mathbf{Set}^2 \to \mathbf{Set} $$ is the right adjoint of

$$ \Delta : \mathbf{Set} \to \mathbf{Set}^2 .$$ This is a cool, rather sophisticated way of defining the product. It was discovered by Lawvere.

But we can go a step further - perhaps too far - by thinking of this right adjoint as a right Kan extension. This is where Anindya starts his story. I'll tell it using slightly different notation. I'll let \(\mathbf{1}\) be the category with one object and one morphism, and \(\mathbf{1} + \mathbf{1}\) be the category with two objects and two morphisms. Note that

$$ \mathbf{Set} \cong \mathbf{Set}^{\mathbf{1}} $$ and

$$ \mathbf{Set}^2 \cong \mathbf{Set}^{\mathbf{1} + \mathbf{1}} .$$ Since \(\mathbf{1}\) is the terminal category there is a unique functor

$$ ! : \mathbf{1} + \mathbf{1} \to \mathbf{1} $$ so we get a functor

$$ \text{composition with } ! : \mathbf{Set}^{\mathbf{1}} \to \mathbf{Set}^{\mathbf{1} + \mathbf{1}} $$ and if you take a look you'll see this just our old friend duplication

$$ \Delta : \mathbf{Set} \to \mathbf{Set}^2 $$ wearing fancy new clothes! The right adjoint of this functor is, by definition, right Kan extension along \( !\):

$$ \text{Ran}_! : \mathbf{Set}^{\mathbf{1} + \mathbf{1}} \to \mathbf{Set}^{\mathbf{1}} $$ so this must be our old friend the right adjoint to duplication, namely

$$ \times : \mathbf{Set}^2 \to \mathbf{Set} .$$ I've been using \(\mathbf{Set}\) a lot here, but any category with binary products would do just as well. So, we can summarize and generalize as follows:

Theorem.If \(\mathcal{C}\) is a category with binary products, the functor \( \times : \mathcal{C}^2 \to \mathcal{C} \) is the right adjoint to the duplication functor \(\Delta: \mathcal{C} \to \mathcal{C}^2\).We could also describe \(\times\) as a right Kan extension: it's just another way of saying the same thing.

`Reuben wrote: > how do we make this definition of limit yield the notion of a product (which I understand is a kind of limit). People who have taken at least part of a category theory course may have encountered the definition of a product via a universal property (https://en.wikipedia.org/wiki/Product_(category_theory)): how does this relate? Anindya gave a very precise answer, so let me give a vague answer - sometimes it's nice to think a bit more vaguely. The definition of product you're thinking about says roughly "a morphism from an object \\(A\\) to a product of objects \\(X \times Y\\) is the same as a morphism from \\(A\\) to \\(X\\) together with a morphism from \\(A\\) to \\(Y\\)". (Experienced category theorists use "is the same as" to indicate a natural one-to-one correspondence obtained by a universal property. It needs to be fleshed out to be made precise, but it's nice when you're trying to talk quickly!) In my lecture I only discussed limits in the category \\(\mathbf{Set}\\). This isn't strictly necessary, but let's stick with that case, and see how such limits can give products in the category \\(\mathbf{Set}\\). For starters, let's say "a function from a set \\(A\\) to a product of sets \\(X \times Y\\) is the same as a function from \\(A\\) to \\(X\\) together with a function from \\(A\\) to \\(Y\\)". Translating into a more mathematical style of talking, this says: \[ \mathbf{Set}^2( (A, A) , (X,Y)) \cong \mathbf{Set}(A, X \times Y). \] Get it? If not: * An element in the left-hand side is a morphism in \\(\mathbf{Set}^2\\) from the object \\( (A,A) \\) to the object \\( (X,Y) \\). Remember, an object in \\(\mathbf{Set}^2\\) is a pair of sets and a morphism is a pair of functions. So, an element in the left-hand side is a function from \\(A\\) to \\(X\\) together with a function from \\(A\\) to \\(Y\\). * An element in the right-hand side is just a function from \\(A\\) to \\(X \times Y\\). This more mathematical way of talking is nice because when you see this: \\[ \mathbf{Set}^2( (A, A) , (X,Y)) \cong \mathbf{Set}(A, X \times Y). \\] you should instantly guess that we're dealing with a left adjoint and a right adjoint. On the left we're taking \\(A\\) and "duplicating" it to get \\( (A,A)\\). On the right we're taking \\( (X,Y) \\) and "producting" it to get \\( X \times Y\\). So, you should suspect that the left-hand side is talking about the "duplication" functor \[ \Delta : \mathbf{Set} \to \mathbf{Set}^2 \] which takes any set \\(A\\) and duplicates it to get \\( (A,A) \\), while the right-hand side is talking about the "product" functor \[ \times : \mathbf{Set}^2 \to \mathbf{Set} \] which takes any pair of sets \\( (X,Y) \\) and forms their product \\( X \times Y\\). In fact, you should suspect that \[ \Delta : \mathbf{Set} \to \mathbf{Set}^2 \] is the left adjoint of \[ \times : \mathbf{Set}^2 \to \mathbf{Set} \] And it's true! In other words, \[ \times : \mathbf{Set}^2 \to \mathbf{Set} \] is the right adjoint of \[ \Delta : \mathbf{Set} \to \mathbf{Set}^2 .\] This is a cool, rather sophisticated way of defining the product. It was discovered by Lawvere. But we can go a step further - perhaps too far - by thinking of this right adjoint as a right Kan extension. This is where Anindya starts his story. I'll tell it using slightly different notation. I'll let \\(\mathbf{1}\\) be the category with one object and one morphism, and \\(\mathbf{1} + \mathbf{1}\\) be the category with two objects and two morphisms. Note that \[ \mathbf{Set} \cong \mathbf{Set}^{\mathbf{1}} \] and \[ \mathbf{Set}^2 \cong \mathbf{Set}^{\mathbf{1} + \mathbf{1}} .\] Since \\(\mathbf{1}\\) is the terminal category there is a unique functor \[ ! : \mathbf{1} + \mathbf{1} \to \mathbf{1} \] so we get a functor \[ \text{composition with } ! : \mathbf{Set}^{\mathbf{1}} \to \mathbf{Set}^{\mathbf{1} + \mathbf{1}} \] and if you take a look you'll see this just our old friend duplication \[ \Delta : \mathbf{Set} \to \mathbf{Set}^2 \] wearing fancy new clothes! The right adjoint of this functor is, by definition, right Kan extension along \\( !\\): \[ \text{Ran}\_! : \mathbf{Set}^{\mathbf{1} + \mathbf{1}} \to \mathbf{Set}^{\mathbf{1}} \] so this must be our old friend the right adjoint to duplication, namely \[ \times : \mathbf{Set}^2 \to \mathbf{Set} .\] I've been using \\(\mathbf{Set}\\) a lot here, but any category with binary products would do just as well. So, we can summarize and generalize as follows: **Theorem.** If \\(\mathcal{C}\\) is a category with binary products, the functor \\( \times : \mathcal{C}^2 \to \mathcal{C} \\) is the right adjoint to the duplication functor \\(\Delta: \mathcal{C} \to \mathcal{C}^2\\). We could also describe \\(\times\\) as a right Kan extension: it's just another way of saying the same thing.`

Nobody has tackled Puzzle 168 yet - namely, to figure out what the

naturalityin the definition of adjunction actually gives us!But Michael Hong has drawn a great diagram hinting at what's going on. He is calling the adjunction \( L : \mathcal{C} \to \mathcal{D}, R : \mathcal{D} \to \mathcal{C}\) instead of \(F : \mathcal{A} \to \mathcal{B}, G : \mathcal{B} \to \mathcal{A}\), but it's the same story:

`Nobody has tackled Puzzle 168 yet - namely, to figure out what the _naturality_ in the definition of adjunction actually gives us! But Michael Hong has drawn a great diagram hinting at what's going on. He is calling the adjunction \\( L : \mathcal{C} \to \mathcal{D}, R : \mathcal{D} \to \mathcal{C}\\) instead of \\(F : \mathcal{A} \to \mathcal{B}, G : \mathcal{B} \to \mathcal{A}\\), but it's the same story: <center><img src = "http://aether.co.kr/images/adjoint_functor.svg"></center>`

I wonder how (e.g. in what software) the diagram in #10 is drawn. It looks so cool! =D>

`I wonder how (e.g. in what software) the diagram in [#10](https://forum.azimuthproject.org/discussion/comment/19883/#Comment_19883) is drawn. It looks so cool! =D>`

Pete Morcos wrote:

You can find a PDF formatted copy of Milewski's textbook on github: https://github.com/hmemcpy/milewski-ctfp-pdf

`[Pete Morcos](https://forum.azimuthproject.org/profile/2373/Pete%20Morcos) wrote: > John, can you recommend a book that covers monads as a next book after Fong & Spivak (especially if it includes applications such as functional programming)? You can find a PDF formatted copy of Milewski's textbook on github: https://github.com/hmemcpy/milewski-ctfp-pdf`

Puzzle 168So the 2 morphisms are :

$$\alpha_{a',b'}(g \circ h \circ F(f))$$ $$G(g) \circ \alpha_{a,b}(h) \circ f$$ Now check if these two are equal using the fact that \(\alpha_{a,b}\) is like taking \(G\) and \(G(F(h)) = h \) :

$$\alpha_{a',b'}(g \circ h \circ F(f))$$ $$= G(g \circ h \circ F(f))$$ $$= G(g) \circ G(h) \circ f$$ $$= G(g) \circ \alpha_{a,b}(h) \circ f$$

`**Puzzle 168** So the 2 morphisms are : $$\alpha_{a',b'}(g \circ h \circ F(f))$$ $$G(g) \circ \alpha_{a,b}(h) \circ f$$ Now check if these two are equal using the fact that \\(\alpha_{a,b}\\) is like taking \\(G\\) and \\(G(F(h)) = h \\) : $$\alpha_{a',b'}(g \circ h \circ F(f))$$ $$= G(g \circ h \circ F(f))$$ $$= G(g) \circ G(h) \circ f$$ $$= G(g) \circ \alpha_{a,b}(h) \circ f$$`

great diagram Michael – but maybe the arrows \(c\rightarrow c'\) and \(L(c)\rightarrow L(c')\) should be pointing the other way round?

that way the diagram would also show how the maps \(\mathcal{C}(c, R(d))\rightarrow \mathcal{C}(c', R(d'))\) and \(\mathcal{D}(L(c), d)\rightarrow \mathcal{D}(L(c'), d')\) work.

`great diagram Michael – but maybe the arrows \\(c\rightarrow c'\\) and \\(L(c)\rightarrow L(c')\\) should be pointing the other way round? that way the diagram would also show how the maps \\(\mathcal{C}(c, R(d))\rightarrow \mathcal{C}(c', R(d'))\\) and \\(\mathcal{D}(L(c), d)\rightarrow \mathcal{D}(L(c'), d')\\) work.`

Michael Hong wrote:

Are you sure? I was thinking that if \(x \in \mathcal{B}(F(a),b)\) and \(y \in \mathcal{A}(a,G(b))\) then:

$$ \begin{align} \mathcal{B}(F(f),g)(x) & = g \circ x \circ F(f) \\ \mathcal{A}(f,G(g))(y) & = G(g) \circ y \circ f \end{align} $$ Here is my go at a proof:

Assume \(x \in \mathcal{B}(F(a),b)\). To show the diagram commutes, we must show:

$$ \alpha_{a',b'}(\mathcal{B}(F(f),g)(x)) = \mathcal{A}(f,G(g))(\alpha_{a,b}(x)) $$ In other words we must show

$$ \alpha_{a',b'} \circ \mathcal{B}(F(f),g) = \mathcal{A}(f,G(g)) \circ \alpha_{a,b} $$ However, this is exactly the naturality condition on \(\alpha\) from the hom-set definition of an adjunction.

`Michael Hong wrote: >**Puzzle 168** > > So the 2 morphisms are : > > $$\alpha_{a',b'}(F(f) \circ h \circ g)$$ > $$f \circ \alpha_{a,b}(h) \circ G(g)$$ Are you sure? I was thinking that if \\(x \in \mathcal{B}(F(a),b)\\) and \\(y \in \mathcal{A}(a,G(b))\\) then: \[ \begin{align} \mathcal{B}(F(f),g)(x) & = g \circ x \circ F(f) \\\\ \mathcal{A}(f,G(g))(y) & = G(g) \circ y \circ f \end{align} \] Here is my go at a proof: > **Puzzle 168.** Suppose \\(F\\) is a left adjoint of \\(G\\), as above. If \\(a \in \mathrm{Ob}(\mathcal{A})\\) and \\(b \in \mathrm{Ob}(\mathcal{B})\\) we get a bijection > > \[ \alpha_{a,b} : \mathcal{B}(F(a),b) \to \mathcal{A}(a,G(b)). \] > > Similarly, if \\(a' \in \mathrm{Ob}(\mathcal{A})\\) and \\(b' \in \mathrm{Ob}(\mathcal{B})\\) we get a bijection > > \[ \alpha_{a',b'} : \mathcal{B}(F(a'),b') \to \mathcal{A}(a',G(b')). \] > > Show that if \\(f: a' \to a\\) and \\(g: b \to b'\\) we get a commutative square > > \[ \begin{matrix} & & \alpha_{a,b} & & \\\\ & \mathcal{B}(F(a),b) & \rightarrow & \mathcal{A}(a,G(b)) &\\\\ \mathcal{B}(F(f),g) & \downarrow & & \downarrow & \mathcal{A}(f,G(g)) \\\\ & \mathcal{B}(F(a'),b') & \rightarrow & \mathcal{A}(a',G(b')) &\\\\ & & \alpha_{a',b'} & & \\\\ \end{matrix} \] Assume \\(x \in \mathcal{B}(F(a),b)\\). To show the diagram commutes, we must show: \[ \alpha_{a',b'}(\mathcal{B}(F(f),g)(x)) = \mathcal{A}(f,G(g))(\alpha_{a,b}(x)) \] In other words we must show \[ \alpha_{a',b'} \circ \mathcal{B}(F(f),g) = \mathcal{A}(f,G(g)) \circ \alpha_{a,b} \] However, this is exactly the [naturality condition](https://en.wikipedia.org/wiki/Natural_transformation) on \\(\alpha\\) from the [hom-set definition of an adjunction](https://en.wikipedia.org/wiki/Adjoint_functors#Hom-set_adjunction).`

@Anindya Done! Very satisfying lol.

@Matthew Oops had my cap on backwards. Thx!

`@Anindya Done! Very satisfying lol. @Matthew Oops had my cap on backwards. Thx!`

Matthew and Michael - you made a lot of progress on Puzzle 168, but I have the feeling I didn't clearly explain the point of the puzzle. The main point of Puzzle 168 was not to show that this square commutes:

$$ \begin{matrix} & & \alpha_{a,b} & & \\ & \mathcal{B}(F(a),b) & \rightarrow & \mathcal{A}(a,G(b)) &\\ \mathcal{B}(F(f),g) & \downarrow & & \downarrow & \mathcal{A}(f,G(g)) \\ & \mathcal{B}(F(a'),b') & \rightarrow & \mathcal{A}(a',G(b')) &\\ & & \alpha_{a',b'} & & \\ \end{matrix} $$ As Michael notes, it obviously commutes, because when we have an adjunction we get a

naturalisomorphism$$ \alpha : \mathcal{B}(F(-), -) \to \mathcal{A}(-, G(-)) $$ Naturality is all about commutative squares.

The main point of the puzzle was to get a better feeling for what this naturality "really means". I wrote:

As Michael sort of noted, these two morphisms are

$$\alpha_{a',b'}(g \circ h \circ F(f))$$ and

$$G(g) \circ \alpha_{a,b}(h) \circ f$$ so what the naturality "really means" is that

$$\alpha_{a',b'}(g \circ h \circ F(f)) = G(g) \circ \alpha_{a,b}(h) \circ f$$ However, now we have to figure what

thisequation "really means"! At first glance it looks pretty intimidating.Perhaps the best approach would be to look at an example - some example of an adjunction that we understand very well. Then this equation will wind up saying something really nice and obvious, which make us feel "

of coursewe want this equation to be true."`Matthew and Michael - you made a lot of progress on Puzzle 168, but I have the feeling I didn't clearly explain the point of the puzzle. The main point of Puzzle 168 was not to show that this square commutes: \[ \begin{matrix} & & \alpha_{a,b} & & \\\\ & \mathcal{B}(F(a),b) & \rightarrow & \mathcal{A}(a,G(b)) &\\\\ \mathcal{B}(F(f),g) & \downarrow & & \downarrow & \mathcal{A}(f,G(g)) \\\\ & \mathcal{B}(F(a'),b') & \rightarrow & \mathcal{A}(a',G(b')) &\\\\ & & \alpha_{a',b'} & & \\\\ \end{matrix} \] As Michael notes, it obviously commutes, because when we have an adjunction we get a _natural_ isomorphism \[ \alpha : \mathcal{B}(F(-), -) \to \mathcal{A}(-, G(-)) \] Naturality is all about commutative squares. The main point of the puzzle was to get a better feeling for what this naturality "really means". I wrote: > To see what this means concretely, take a guy \\(h \in \mathcal{B}(F(a),b) \\), meaning a morphism \\(h : F(a) \to b\\), and send it around the square both ways: down and then across, or across and then down. You get two morphisms from \\( a' \\) to \\(G(b')\\); **what are they?** Since the square commutes these must be equal. As Michael sort of noted, these two morphisms are $$\alpha_{a',b'}(g \circ h \circ F(f))$$ and $$G(g) \circ \alpha_{a,b}(h) \circ f$$ so what the naturality "really means" is that $$\alpha_{a',b'}(g \circ h \circ F(f)) = G(g) \circ \alpha_{a,b}(h) \circ f$$ However, now we have to figure what _this_ equation "really means"! At first glance it looks pretty intimidating. Perhaps the best approach would be to look at an example - some example of an adjunction that we understand very well. Then this equation will wind up saying something really nice and obvious, which make us feel "_of course_ we want this equation to be true."`

Not sure exactly what the two morphisms "are" in

Puzzle 168but I just noticed this which may or may not help:$$\alpha_{a',b'}(g \circ h \circ F(f)) : a' \rightarrow G(b')$$ and

$$G(g) \circ \alpha_{a,b}(h) \circ f : a' \rightarrow a \rightarrow G(b) \rightarrow G(b')$$ The naturality square essentially went around the world to say these two are equal.

`Not sure exactly what the two morphisms "are" in **Puzzle 168** but I just noticed this which may or may not help: $$\alpha_{a',b'}(g \circ h \circ F(f)) : a' \rightarrow G(b')$$ and $$G(g) \circ \alpha_{a,b}(h) \circ f : a' \rightarrow a \rightarrow G(b) \rightarrow G(b')$$ The naturality square essentially went around the world to say these two are equal.`

The way I understand that equation is in terms of bijective correspondences.

An adjunction, crudely, says that arrows \(F(a)\rightarrow b\) in \(\mathcal{B}\) correspond precisely to arrows \(a\rightarrow G(b)\) in \(\mathcal{A}\) .

Let's write \(h^*\) for the \(\mathcal{A}\)-arrow corresponding to \(h : F(a)\rightarrow b\) in \(\mathcal{B}\).

(This is just a more compact way of writing the effect of \(\alpha\), ie \(h \mapsto h^*\) is the component \(\alpha_{a,b}\).)

But actually adjunction is a bit more than that – the correspondence has to be

natural, ie it plays nicely with composition in both categories.So if we post-compose \(h\) with some \(g : b\rightarrow b'\) in \(\mathcal{B}\), we want \(g\circ h\) to correspond to \(G(g)\circ h^*\).

Similarly, if we pre-compose \(h^* \) with some \(f : a'\rightarrow a\) in \(\mathcal{A}\), we want \(h^*\circ f\) to be the correspondent of \(h\circ F(f)\).

Putting these together we get \((g\circ h\circ F(f))^* = G(g)\circ h^*\circ f\), which is what the naturality square says.

`The way I understand that equation is in terms of bijective correspondences. An adjunction, crudely, says that arrows \\(F(a)\rightarrow b\\) in \\(\mathcal{B}\\) correspond precisely to arrows \\(a\rightarrow G(b)\\) in \\(\mathcal{A}\\) . Let's write \\(h^*\\) for the \\(\mathcal{A}\\)-arrow corresponding to \\(h : F(a)\rightarrow b\\) in \\(\mathcal{B}\\). (This is just a more compact way of writing the effect of \\(\alpha\\), ie \\(h \mapsto h^*\\) is the component \\(\alpha_{a,b}\\).) But actually adjunction is a bit more than that – the correspondence has to be _natural_, ie it plays nicely with composition in both categories. So if we post-compose \\(h\\) with some \\(g : b\rightarrow b'\\) in \\(\mathcal{B}\\), we want \\(g\circ h\\) to correspond to \\(G(g)\circ h^*\\). Similarly, if we pre-compose \\(h^* \\) with some \\(f : a'\rightarrow a\\) in \\(\mathcal{A}\\), we want \\(h^*\circ f\\) to be the correspondent of \\(h\circ F(f)\\). Putting these together we get \\((g\circ h\circ F(f))^* = G(g)\circ h^*\circ f\\), which is what the naturality square says.`

I am trying to see if we can interpret an \(n\) by \(m\) real matrix \(\mathbf{A}\) as a functor so that its conjugate transpose \(\mathbf{A}^*\) is the right adjoint in the categorical sense and use it to understand the meaning of naturality. However, I am too caught up with the "traditional way" that \(\mathbf{A}\) is a morphism from \(\mathbb{R}^m\) to \(\mathbb{R}^n\) and have a hard time to rethink \(\mathbf{A}\) as a functor between suitable categories.

`I am trying to see if we can interpret an \\(n\\) by \\(m\\) real matrix \\(\mathbf{A}\\) as a functor so that its conjugate transpose \\(\mathbf{A}^*\\) is the right adjoint in the categorical sense and use it to understand the meaning of naturality. However, I am too caught up with the "traditional way" that \\(\mathbf{A}\\) is a morphism from \\(\mathbb{R}^m\\) to \\(\mathbb{R}^n\\) and have a hard time to rethink \\(\mathbf{A}\\) as a functor between suitable categories.`

Hi Cheuk, don't think that analogy is going to help. You can look at this math.SE quetion, this paper, and in ch. 3 of this book of Chris Heunen there is a nice diagram of the wider situation. So you can complicate the problem in terms of enriching, or follow the correspondence from dual maps to certain Galois connections, but it is irreversible.

If you want an example of naturality in that area, in Mac Lane's book he explains how

Vectis not naturally isomorphic with its dual, but it is, with itsdoubledual.EDIT: for finite dimensional spaces

`Hi Cheuk, don't think that analogy is going to help. You can look at [this](https://math.stackexchange.com/questions/1009615/connection-between-categorical-notion-of-adjunction-and-dual-space-adjoint-in-ve) math.SE quetion, [this](http://dx.doi.org/10.1090/S0002-9939-1974-0346548-4) paper, and in ch. 3 of this [book](https://www.researchgate.net/publication/235541556_Categorical_quantum_models_and_logics) of Chris Heunen there is a nice diagram of the wider situation. So you can complicate the problem in terms of enriching, or follow the correspondence from dual maps to certain Galois connections, but it is irreversible. If you want an example of naturality in that area, in Mac Lane's book he explains how **Vect** is not naturally isomorphic with its dual, but it is, with its **double** dual. EDIT: for finite dimensional spaces`

Puzzle 168: For a programmer the most important adjunction is the one between product and function type. We call it currying. It's an adjunction between two endofunctors: \(F\) takes takes the set \(a\) and "multiplies" it by some fixed set \(c\) (takes cartesian product). The hom-set \(C(F a, b)\) is a set of functions from a product \((a \times c)\) to \(b\). These functions are in one-to-one correspondence with functions that take \(a\) as an argument and return a function from \(c\) to \(b\). Therefore, the second functor \(G\) takes a set \(b\) and produces a function type \(c \to b\), a.k.a, the exponential \(b^c\)

The adjunction \(\alpha_{a b}\) is called

`curry`

:`curry :: ((a, c) -> b) -> (a ->(c -> b))`

Naturality condition involves two functions,

`f :: a' -> a`

and`g :: b -> b'`

. We have to figure out how \(F\) acts of \(f\) and how \(G\) acts of \(g\).The product is a bifunctor, meaning it can lift a pair of functions at once. In Haskell this is done by a function called

`bimap`

:`bimap :: (a -> a') -> (b -> b') -> (a, b) -> (a', b')`

Here, we want to lift one function, so we'll apply

`bimap`

to`f`

and the identity function`id`

(this is \(id_c\)). The left hand side of the naturality condition becomes:`p1 :: (a' -> a) -> (b -> b') -> ((a, c) -> b) -> (a' -> (c -> b'))`

`p1 f g h = curry (g . h . bimap f id)`

The lifting of \(g\) by functor \(G\) acts on functions from the fixed \(c\) to some \(b\) simply by postcomposing \(g\). This postcomposition is expressed as

`(g . )`

. The right hand side of the naturality condition becomes:`p2 :: (a' -> a) -> (b -> b') -> ((a, c) -> b) -> (a' -> (c -> b'))`

`p2 f g h = (g . ) . curry h . f`

In words: You get the same result if you:

(a) take a function \(h\) of two arguments, precompose it with \((f \times id)\), postcompose with \(g\), and curry the result; or

(b) first curry \(h\) then precompose the resulting function with \(f\) and postcompose its result with \(g\).

`Puzzle 168: For a programmer the most important adjunction is the one between product and function type. We call it currying. It's an adjunction between two endofunctors: \\(F\\) takes takes the set \\(a\\) and "multiplies" it by some fixed set \\(c\\) (takes cartesian product). The hom-set \\(C(F a, b)\\) is a set of functions from a product \\((a \times c)\\) to \\(b\\). These functions are in one-to-one correspondence with functions that take \\(a\\) as an argument and return a function from \\(c\\) to \\(b\\). Therefore, the second functor \\(G\\) takes a set \\(b\\) and produces a function type \\(c \to b\\), a.k.a, the exponential \\(b^c\\) The adjunction \\(\alpha_{a b}\\) is called `curry`: `curry :: ((a, c) -> b) -> (a ->(c -> b))` Naturality condition involves two functions, `f :: a' -> a` and `g :: b -> b'`. We have to figure out how \\(F\\) acts of \\(f\\) and how \\(G\\) acts of \\(g\\). The product is a bifunctor, meaning it can lift a pair of functions at once. In Haskell this is done by a function called `bimap`: `bimap :: (a -> a') -> (b -> b') -> (a, b) -> (a', b')` Here, we want to lift one function, so we'll apply `bimap` to `f` and the identity function `id` (this is \\(id_c\\)). The left hand side of the naturality condition becomes: `p1 :: (a' -> a) -> (b -> b') -> ((a, c) -> b) -> (a' -> (c -> b'))` `p1 f g h = curry (g . h . bimap f id)` The lifting of \\(g\\) by functor \\(G\\) acts on functions from the fixed \\(c\\) to some \\(b\\) simply by postcomposing \\(g\\). This postcomposition is expressed as `(g . )`. The right hand side of the naturality condition becomes: `p2 :: (a' -> a) -> (b -> b') -> ((a, c) -> b) -> (a' -> (c -> b'))` `p2 f g h = (g . ) . curry h . f` In words: You get the same result if you: (a) take a function \\(h\\) of two arguments, precompose it with \\((f \times id)\\), postcompose with \\(g\\), and curry the result; or (b) first curry \\(h\\) then precompose the resulting function with \\(f\\) and postcompose its result with \\(g\\).`