Counting with Categories (Part 2)
Posted by John Baez
Here’s my second set of lecture notes for a 4-hour minicourse at the Summer School on Algebra at the Zografou campus of the National Technical University of Athens.
Part 1 was here.
We’ve seen that the category of tame species has a lot of structure resembling that of the ring of formal power series , but it’s richer because two tame species can have the same generating function. To dig deeper we need to understand that and exploit this analogy. But what do I mean exactly?
For starters, we can add and multiply species:
Addition. Given species , they have a sum with
where at right the plus sign means the disjoint union, or coproduct, of sets. Here I’ve said what does to objects , but it does something analogous to morphisms — figure it out and check that it makes into a functor! If and are tame, so is , and
Multiplication. Given species , I said last time that we can multiply them and get a species with
Again, I’ll leave it to you to guess what does to morphisms and check that is then a functor. If and are tame, so is , and
Exercise 5. If you know about coproducts, you can show that is the coproduct of and in the category of species, , which we defined last time.
Exercise 6. If you know about products), you can show that is not the product of and in the category of species. Thus, we often call it the Cauchy product. But if you know about symmetric monoidal categories, you can with some significant work show that the Cauchy product makes into a symmetric monoidal category. For starters, this means that it’s associative and commutative up to isomorphism—but it means more than just that. (If you know about Day convolution, this can speed up your work.)
Now let’s think about addition and the Cauchy product together. We can check that
and indeed addition and the Cauchy product give the category of species a structure much like that of a ring! It’s even more like a ‘rig’, which is a ‘rings without negatives’, since we can add and multiply species, but not subtract them. But all the rig laws hold, not as equations, but as natural isomorphism.
In fact the binary coproduct is just a special case of something called a colimit#Colimits), defined by a more general universal property. And the Cauchy product distributes over all colimits! We thus say the category of species is a ‘symmetric 2-rig’.
A bit more precisely:
Definition. A 2-rig is a monoidal category with all colimits, such that the tensor product distributes over colimits in each argument. That is, if is any small category and is any functor, for any object , the natural morphisms
are isomorphisms.
Definition. A symmetric 2-rig is a 2-rig whose underlying monoidal category is a symmetric monoidal category.
One can work through the details of these definitions and show the category of species is a symmetric 2-rig. But something vastly better is true. It’s very similar to the ring of polynomials in one variable!
Why is the ring , the ring of polynomials in one variable with integer coefficients, so important in mathematics? Because it’s the free ring on one generator! That is, given any ring and any element there’s a unique ring homomorphism
with
To see this, note that the homomorphism rules force that for any we have
I claim that the 2-rig of species is similar: it’s the free symmetric 2-rig on one generator . But what is this species ?
is the structure of ‘being a 1-element set’. What I mean is this: it’s the structure that you can put on a finite set in a unique way if has one element, and not at all if has any other number of elements. In other words:
The name is appropriate because the generating function of this species is :
Here’s the big theorem, which I won’t prove here:
Theorem. The symmetric 2-rig of species, , is the free symmetric 2-rig on one generator. That is, for any symmetric 2-rig and any object , there exists a map of 2-rigs
such that , and is unique up to natural isomorphism.
This result has a baby brother, too. First, note that the free ring on no generators is . That is, is the initital ring: for any ring there exists a unique ring homomorphism
This should make us curious about the free symmetric 2-rig on no generators. This is the category of sets, with its cartesian product as the symmetric monoidal structure.
Theorem. The symmetric 2-rig of sets, , is the initial 2-rig. That is, for any symmetric 2-rig there exists a map of 2-rigsar
which is unique up to natural isomorphism.
So we have a wonderful analogy:
The category of sets is to as the category of species is to .
This suggests that there’s a lot more one can do to ‘categorify’ ring theory — that is, to take ideas from ring theory and develop analogous ideas in 2-rig theory. And even better, it shows that a lot of combinatorics is categorified ring theory!
But let’s see how we can use this 2-rig business to count things. Let’s make up a species where a -structure on a finite set is a way of the leaves of a rooted planar binary tree.
Here are some rooted planar binary trees:
There’s 1 rooted planar binary tree with 1 leaf, 1 with 2, 2 with 3, 5 with 4… and so on.
I’ll draw lots of pictures to explain these trees and what it means to label their leaves by elements of a finite set, but the quickest definition is recursive, involving no pictures.
To put a structure on a finite set , we either
- put an -structure on it
or
- partition it into two parts and and put a -structure on each part.
Remember, an -structure on is the structure of ‘being a one-element set’. This handles the case of the binary tree with just one leaf.
We can state this recursive definition as an equation:
and we can express this more efficiently using the sum and Cauchy product of species:
We can now use this to count -structures on a finite set! By taking generating functions we get
or
This is a quadratic equation for the formal power series , which we can solve using the quadratic formula!
Since the coefficients of a generating function can’t be negative, we must have
since the other sign choice gives a term proportional to with a negative coefficient. Using a computer we can see
Remember
so we get
and so on. The factorials arise because there are ways to label the leaves of a planar binary tree with leaves by elements of . The interesting part is the sequence
These give the number of planar binary trees with leaves! They’re called the Catalan numbers.
Exercise 7. Use your mastery of Taylor series to show that
so
Let’s check this for :
which matches how there are 5 rooted planar binary trees with 4 leaves!