Lecture 76  The Grand Synthesis
I spent a lot of time in this course explaining two big ideas:

Adjoint functors. We've focused a lot on the simplest of categories: preorders. Pairs of adjoint functors between these are also called Galois connections, and we first met them in Lecture 4. In Lecture 6 we saw that a left adjoint is a 'best approximation from above' to the possibly nonexistent inverse of a monotone function between preorders, while a right adjoint is a 'best approximation from below'. Much later, starting in Lecture 47, we looked at adjoint functors between categories in general. We saw that the pattern persists: left adjoints are 'liberal' while right adjoints are 'conservative'.

Compact closed categories. In Lecture 67, in our study of feasibility relations, we began looking at caps and cups. We saw these allow us to describe feedback, or, more generally, the process of 'bending back' an input to some process and turning it into an output  or vice versa. In Lecture 71 we saw that caps and cups exist  and obey the allimportant snake equations  in any category of enriched profunctors. And in Lecture 74, we saw this works in any 'compact closed' category. Morphisms in a compact closed category can be drawn as string diagrams, which we can manipulate just like boxes with wires coming in and out! In particular, we can 'bend back' the wires.
These are both great ideas... but amazingly, they are two aspects of the same idea!
To see this, start with a pair of adjoint functors:
[ F \colon \mathcal{A} \to \mathcal{B}, \quad G \colon \mathcal{B} \to \mathcal{A} ]
By definition, there's a bijection between these sets:
[ \alpha_{a,b} \colon \mathcal{B}(F(a),b) \to \mathcal{A}(a,G(b)) ]
for any objects \(a\) in \(\mathcal{A}\) and \(b\) in \(\mathcal{B}\). Moreover this is a natural isomorphism.
What can we do with this? Not much until we know some elements of these sets! So let's take \(b = F(a)\):
[ \alpha_{a,F(a)} : \mathcal{B}(F(a),F(a)) \to \mathcal{A}(a,G(F(a))) ]
There's an obvious element of \(\mathcal{B}(F(a),F(a))\), namely the identity \(1_{F(a)}\). Our bijection maps this to some morphism from \(a\) to \(G(F(a))\), which we write as
[ \eta_a \colon a \to G(F(a)) .]
You get such a morphism for any \(a\). And using the fact that \(\alpha\) is natural, you can prove these morphisms define a natural transformation
[ \eta \colon 1_{\mathcal{A}} \to G F ]
This is called the unit. (I'm sorry; that word that is used for too many different things in mathematics.)
Amazingly, the unit is a lot like a cap. Why? Remember that when we have an object \(x\) in a compact closed category, the cap is a morphism
[ \cap_x \colon I \to x \otimes x^\ast.]
This resembles the unit, with \(x\) playing the role of \(G\), and \(x^\ast\) playing the role of \(F\). The surprise is that this resemblance is significant, not just superficial!
What about the cup? Well, we can take our bijection
[ \alpha_{a,b} : \mathcal{B}(F(a),b) \to \mathcal{A}(a,G(b)) ]
and let \(a = G(b)\), getting
[ \alpha_{G(b),b} : \mathcal{B}(F(G(b)),b) \to \mathcal{A}(G(b),G(b)) .]
There's an obvious element of \( \mathcal{A}(G(b),G(b))\), namely the identity \(1_{G(b)}\). It must come from some morphism from \(F(G(b))\) to \(b\), which we write as
[ \epsilon_b \colon F(G(b)) \to b, ]
and you can prove such morphisms define a natural transformation
[ \epsilon \colon F G \Rightarrow 1_{\mathcal{B}} ]
called the counit. This should remind you of how any object \(x\) in a compact closed category has a cup:
[ \cup_x \colon x^\ast \otimes x \to I .]
So far our evidence for an analogy between the unit and counit and the cap and cup is pretty thin. The real test is the snake equation. If we can prove the unit and counit obey that, something real must be going on!
We can do it. Of course, first we need to state the snake equation for the unit and counit. I don't have room to do this here, so watch these short videos by my friends Eugenia Cheng and Simon Willerton:
 The Catsters, Adjunctions 1, Adjunctions 2, Adjunctions 3, Adjunctions 4.
where they call the snake equations the 'triangle equations'  you'll see why. They start by defining an 'adjunction' to be a pair of functors \( F \colon \mathcal{A} \to \mathcal{B}\), \( G \colon \mathcal{B} \to \mathcal{A} \) equipped with a unit and counit \(\eta \colon 1_{\mathcal{A}} \to GF \), \( \epsilon \colon FG \to 1_{\mathcal{B}}\) obeying the triangle equations. Then they show this definition is equivalent to the definition of adjoint functors we've been using!
The success of this analogy suggests that maybe we could use string diagrams to work with categories, functors and natural transformations. It's true! To learn how, watch these:
 The Catsters, String diagrams 1, String diagrams 2, String diagrams 3, String diagrams 4.
After setting up string diagrams for category theory, Simon describes adjunctions using string diagrams in part 3. You'll see exactly why the unit is like a cap and the counit like a cup  and you'll see the snake equations pop out at the end! In parts 4 and 5 he uses string diagrams to get monads from adjunctions. Monads are very popular in programming languages like Haskell, but this will give a completely different outlook on them.
I should warn you: all this is a different idea than using string diagrams to study enriched categories and enriched profunctors, as we'd been doing in Chapter 4. So don't get them mixed up. But everything fits together in the end  as you've probably seen, category theory keeps generalizing everything in order to unify it and eventually simplify it.
There's much more to say; you can see my own take on it by reading this:
 John Baez, The tale of ncategories
You'll see how adjunctions and monads and compact closed categories all fit nicely into the framework of 2categories. Just as you need categories to work efficiently with setbased mathematics, you need 2categories to work efficiently with categorybased mathematics. These days my students and I have been using 2categories (and related gadgets like double categories) to study Markov processes, Petri nets and other kinds of networks.
I'm tempted to go on, but this course was meant to give you just a tiny taste of the grand meal of category theory and its many applications, so I will restrain myself and stop here. I've been getting very abstract, but next time I'll give you some suggestions to read more about applications.
To read other lectures go here.