I want to show you these gadgets and what they can do, and I want to make use of the affordances of a digital medium to achieve that: so you can expand detail as you like, navigate with the choose-your-own-adventure paths below, or take a quiz and I’ll drop you off somewhere suitable.
:Tasks: the third gadget — objectives written as tasks
Math envy: if you agree with the comic, you’re part of the math-envy problem.
I’ve seen lots of people cleverer than me try to learn and quickly get bored with category theory because all of the payoffs happen after a lot of setup, and it is difficult to find internal motivations to trudge through. So I’ll try to briefly motivate category theory at a high level.
It’s also worth articulating some caveats, especially for younger students who want to do mathematics for “the wrong reasons”, because they correlate arcane-ness of mathematics with something like power-over-the-phenomenon or closeness-to-truth.
All that being said, I’m just going to beeline through the definitions now to get to string diagrams. Once we have categories, we can define :functors as structure-preserving maps between categories. And then we get :natural transformations as maps between functors. Then we are able to define :monoidal categories, and finally :symmetric monoidal categories.
This is already enough for us to optionally pause and make sense of an often used technical term in a lot of contexts, :isomorphism.
The associator and unitors let you reassociate brackets and slide the unit around. That raises a worry: given two chains of such moves between the same two bracketings, do they land on the same morphism?
Mac Lane’s coherence theorem (1963): in a :monoidal category, every diagram built from α, λ, ρ, their inverses, and ⊗ commutes. The :triangle and pentagon are the only axioms needed to force it.
Equivalent statement: every monoidal category is monoidally equivalent to a strict one, in which (A⊗B)⊗C=A⊗(B⊗C) and I⊗A=A=A⊗I hold on the nose.
The working licence this gives you: drop the brackets. Write A⊗B⊗C and never mind the route taken to get there, because any two canonical isomorphisms between the same pair of objects are equal.
For the symmetric case there are two further axioms, the hexagons. With them coherence extends to diagrams that also use the braiding, so long as you never ask a nontrivial permutation of factors to equal the identity :(see symmetric monoidal category).
This is the theorem that makes string diagrams legitimate. Because reassociation and unit-shuffling are invisible up to unique isomorphism, we may draw a morphism as wires and boxes and let deformation of the picture stand for equality of morphisms. No brackets to track, so no brackets to draw.
I love string diagrams and I will try to cast ideas in them even if they are the wrong tool. Uncharitably, this is a common intellectual-colonialist attitude and a shortcoming in the pursuit of understanding and truth. But those aims are not really my concerns. I think mathematics should be visually beautiful, and I am interested in a subset of mathematical truths: those that are both deep and are intuitively accessible for humans if presented in :the right way.
Think of it this way: if Deep Learning is actually like a big deal, we’ll probably teach it to children, right? Starting when? Children can learn about physics and chemistry because those subjects became pedagogically structured over time into a progressively-disclosing series of white-lies, analogies, and insightful simplifications.
At the moment, Deep Learning is far from that: topics that require graduate education to understand are :basically fake.
So I am looking for the idealised essence of Deep Learning that a child can grasp: I refuse to believe that the royal road to understanding is gatekept by linear algebra and calculus and statistics and whatever else prevents the child from understanding what is happening.
For the sake of argument, let’s say evolution is real. Then eyeballs have been getting better at the task of seeing for many hundreds of years!
As a graphical syntax where information flow is topological connection, string diagrams figuratively “mainline” mathematics “straight to the dome”, bypassing the relatively recent and version-alpha language-processing meat in our skulls and going straight to the stable and battle-tested eyeball zone (I am not the useful kind of Doctor.)
And that is why it is :so easy for us to use our eyes to look at string diagrams.
It is a non-achievement to understand and use flowcharts, so it’s nice to use them to express complicated ideas in a way that :everyone can understand.
I’ll level with you, I’m not really sure what “formal” means, but I know it when I see it.
That’s not a joke: you probably think that formal means proof within some deduction system grounded by accepted axioms, or whatever Lean does. The reason why Lean is exciting at the time of writing is that nobody actually does the totally rigorous thing because it takes too long and it’s unreadable for humans. I’m sorry to report that what we consider to be mathematically formal is a field-dependent :social construct.
Functors of two variables (bifunctors): a functor F:C×D→E out of the product category, whose objects are pairs (C,D) and whose morphisms are pairs (f,g). This is exactly the shape a tensor product ⊗ will take.
Functoriality in two variables forces the interchange law: (f′⊗g′)∘(f⊗g)=(f′∘f)⊗(g′∘g). Independent processes may be composed in either order.
:Functor boxes: functors drawn as regions inside a string diagram
It seems like we can express almost any idea with text made up of sentences, and sentences are made up of words, and there are only finitely many words: how do we make infinite use of finite means? More concerningly, text is a one-dimensional string of data, and meanings-as-thoughts-in-our-heads don’t seem very one-dimensional, so how are we relating the two?
The view I take in my thesis is that the grammar of natural languages are solving a recurring engineering problem: we have to more or less faithfully encode our thoughts into the one-dimensional codes of natural language, and then faithfully decode that text back into the shapes of thoughts. Viewing thoughts as (higher-order) relations between entities, we can give an account of this miracle by showing how grammatical connections preserve the topology of meaning connections.
Almost always in Category Theory and in mathematics more broadly, we only care about things up to isomorphism. For example, when we refer to an ordered pair of things (a,b), we don’t want to care about what convention we are using set-theoretically to encode that, i.e. we don’t care whether it’s {{a,b},b}, {{a,∅},b}, {a,{a,b}}, etc. Isomorphism tells us it doesn’t matter which encoding we use because they are all freely convertible into one another. The later notion of natural isomorphism (invertible :natural transformations) articulates the stronger idea that these interconversions are “the same no matter what is inside the ordered pair”, i.e. that the conversions concern structure rather than content.
Now a fair question: if we can both use flowcharts, how come I have a Doctorate of Philosophy in Computer Science from the University of Oxford and you don’t?
Brother, I ask myself that too.
The answer is that I know how to treat the flowcharts as :mathematically formal:syntax. The good news is that by the time you’re done reading you too will be able to do that, but the bad news is that still only one of us will have the degree, c’est la vie.
Examples: (Set,×,{⋆}); (VectK,⊗,K); (CartSp,×,R0); the endofunctors of any category under composition.
The point of the two axioms: Mac Lane proved they are enough. Every other coherence you might demand of α,λ,ρ follows from triangle and pentagon alone :(see coherence theorem).
Moravec’s Paradox was the observation that stuff like chess and math is hard for humans but easy for machines, while walking and talking is easy for humans and (emphasis on was) hard for machines. So what gives?
One answer is that the stuff we humans find easy to do is in fact the hard stuff that we had to evolve solutions for over a long time.
A natural transformationα:F⇒G between two functors F,G:C→D is a family of morphisms αX:FX→GX, one component for each object X of C.
Naturality: for every morphism f:X→Y the square commutes,
αY∘Ff=Gf∘αX.
Read it as: transform then map equals map then transform. The components agree with the morphisms of C at every step; nothing is chosen by hand.
A natural isomorphism is a natural transformation whose every component αX is an isomorphism. Then F≅G as functors.
Examples: the determinant, natural in the ground ring; the map V→V∗∗ into the double dual, natural (so basis-free), while V→V∗ is not; the unit and counit of an adjunction.
Why it matters next: the associator, unitors, and braiding that make a category monoidal and symmetric are all natural isomorphisms. Coherence is a statement about how they compose.
Key cross-references:
:Functor: the objects a natural transformation connects
The test is this: if you can’t explain what you’re doing to a random person at a pub or whatever your local third-space for social drug consumption is, then what you’re doing is fake (“L”), you don’t understand what you’re doing (“Ratio”), and you can’t communicate (“RIP Bozo”).
String diagrams are more than elegant pictorial brainrot; they are the counter-revolution to Descartes, the geometrisation of algebra. That is to say, they turn complicated higher-algebraic arcane scary math into :flowcharts.
A symmetric monoidal category (SMC) is a :monoidal category with a way to swap tensor factors.
The braiding must cohere with associativity through two hexagon axioms: one carries a factor past B⊗C on the left, the other past A⊗B on the right.
Symmetry: swapping twice returns you to the start,
σB,A∘σA,B=idA⊗B.
A braiding with this law is called symmetric; then the two hexagons say the same thing.
Examples: (Set,×) with σ(a,b)=(b,a); (VectK,⊗) with σ(v⊗w)=w⊗v; (CartSp,×), the intended semantics for deep learning.
Why this is the destination: an SMC is exactly the structure whose syntax is string diagrams. Wires are objects, boxes are morphisms, stacking is ⊗, plugging is ∘, and a crossing of wires is the braiding σ. :Coherence makes the picture sound: two diagrams that are isotopic denote equal morphisms.
From here the book runs on pictures: :string diagram basics first, then the three gadgets (tubes, holes, tasks).
Syntax is basically “grammar” and Semantics is basically “meanings”.
Consider “1+1”, and consider “11+”. Some orderings of symbols make sense and some don’t. The basic function of syntax is to tell us what orders of symbols makes sense. It’s the same basic function that grammar serves: “Alice loves Bob” is good, “loves Alice Bob” is not.
Now consider “1+1=2”, and consider “1+1=3”. The former is correct and the latter isn’t. The basic function of semantics is to tell us when expressions are equal. “Alice loves Bob” means the same thing as “Bob is loved by Alice”.
A tarpit question: what is the relationship between syntax and semantics? Between grammar and meaning? Probably the easiest way to get into this is a kind of koan by Coecke:
“There are dictionaries for words, but where are the dictionaries for sentences?”
Working through an answer will get us to where we need to go. We only need dictionaries for words because we know how to combine the meanings of words into meanings of sentences. Plus, languages have finitely many words and infinitely many possible sentences so it just wouldn’t be practical to have an infinite dictionary for sentences.
But, how do we know how to :combine the meanings of words into sentences? This is a bit mysterious, because it seems like we can express almost any idea with text made up of sentences, and sentences are made up of words, and there are only finitely many words: how do we make infinite use of finite means?
The answer given by Montague is that the compositional shape of grammar determines the compositional shape of meaning: that there is a structure-preserving mapping (homomorphism, sameness-transformation) from syntax to semantics.
Copy, learnable boxes, monoid, smax, T-algebra: the attention knot
But when we’re finished, you will agree with me that this one is better.
Permutation equivariance of queries (prop:q-equiv) — a TubeFormer building block, live
If you had drawn this picture, you would have been very rich and famous.