Skip to the Main Content

Note:These pages make extensive use of the latest XHTML and CSS Standards. They ought to look great in any standards-compliant modern browser. Unfortunately, they will probably look horrible in older browsers, like Netscape 4.x and IE 4.x. Moreover, many posts use MathML, which is, currently only supported in Mozilla. My best suggestion (and you will thank me when surfing an ever-increasing number of sites on the web which have been crafted to use the new standards) is to upgrade to the latest version of your browser. If that's not possible, consider moving to the Standards-compliant and open-source Mozilla browser.

June 22, 2025

Counting with Categories (Part 1)

Posted by John Baez

These are some lecture notes for a 3-hour minicourse I’m teaching at the Summer School on Algebra at the Zografou campus of the National Technical University of Athens. To save time, I am omitting the pictures I’ll draw on the whiteboard, along with various jokes and profoundly insightful remarks. This is just the structure of the talk, with all the notation and calculations.

Long-time readers of the nn-Category Café may find little new in this post. I’ve been meaning to write a sprawling book on combinatorics using categories, but here I’m trying to explain the use of species and illustrate them with a nontrivial example in less than an hour. That leaves two hours to go deeper.

Combinatorics, or at least part of it, is the art of counting. For example: how many derangements does a set with nn elements have? A derangement is a bijection

f:SS f: S \to S

with no fixed points. We’ll count them in a while.

But what does counting have to do with category theory? The category of finite sets, FinSet\mathsf{FinSet}, has

  • finite sets as objects
  • functions between these as morphisms

What we count, ultimately, are finite sets. Any object SFinSetS \in \mathsf{FinSet} has a cardinality |S|,|S| \in \mathbb{N}, so counting a finite set simplifies it to natural number, and the key feature of this process is that

ST|S|=|T| S \cong T \iff |S| = |T|

We’ll count structures on finite sets. A ‘species’ is roughly a type of structure we can put on finite sets.

Example 1. There is a species of derangements, called DD. A DD-structure on a finite set SS is simply a derangement f:SS.f: S \to S. We write D(S)D(S) for the set of all derangements of S.S. We would like to know |D(S)||D(S)| for all SFinSet.S \in \mathsf{FinSet}.

Example 2. There is a species of permutations, called PP. A PP-structure on SFinSetS \in \mathsf{FinSet} is a bijection f:SSf: S \to S. We know

|P(S)|=|S|! |P(S)| = |S|!

We often use nn interchangeably for a natural number and a standard finite set with that many elements:

n={0,1,,n1}n = \{0,1, \dots, n-1 \}

With this notation

|P(S)|=n! |P(S)| = n!

But what exactly is a species?

Definition. Let E\mathsf{E} be the category where

  • an object is a finite set
  • a morphism is a bijection between finite sets

Definition. A species is a functor F:ESet.F: \mathsf{E} \to \mathsf{Set}. A tame species is a functor F:EFinSet.F: \mathsf{E} \to \mathsf{FinSet}.

Any tame species has a generating function, which is actually a formal power series F^[[x]],\widehat{F} \in \mathbb{R}[[x]], given by

F^= n0|F(n)n!x n \displaystyle{ \widehat{F} = \sum_{n \ge 0} \frac{|F(n)}{n!} x^n }

Example 3. We can compute the generating function of the species of permutations:

P^= n0n!n!x n=11x \displaystyle{ \widehat{P} = \sum_{n \ge 0} \frac{n!}{n!} x^n = \frac{1}{1 - x} }

Example 4. Given two species FF and GG there is a species FGF \cdot G defined as follows. To put an FGF \cdot G-structure on a finite set SS is to choose a subset XSX \subseteq S and put an FF-structure on XX and a GG-structure on SXS - X. We thus have

FG^= n0|(FG)(n)|n!x n \widehat{F \cdot G} = \sum_{n \ge 0} \frac{|(F \cdot G)(n)|}{n!} x^n

= n0 0kn(nk)|F(k)||G(nk)|x nn! = \sum_{n \ge 0} \sum_{0 \le k \le n} \binom{n}{k} |F(k)| |G(n-k)| \frac{x^n}{n!}

= n0 k0|F(k)|k!|G(nk)|(nk)!x n = \sum_{n \ge 0} \sum_{k \ge 0} \frac{|F(k)|}{k!} \frac{|G(n-k)|}{(n-k)!} x^n

= k0 0|F(k)|k!|G(|!x kx = \sum_{k \ge 0} \sum_{\ell \ge 0} \frac{|F(k)|}{k!} \frac{|G(\ell|}{\ell!} x^k x^\ell

=F^G^ = \widehat{F} \widehat{G}

Example 5. There is a species Exp\text{Exp} where an Exp\text{Exp}-structure on a finite set is no extra structure at all. That is, every finite set has a unique Exp\text{Exp}-structure! We thus have

|Exp(S)|=1 |\text{Exp}(S)| = 1

for all SFinSetS \in \mathsf{FinSet}, so

Exp^= n01n!x n=expx \widehat{Exp} = \sum_{n \ge 0} \frac{1}{n!} x^n = \exp x

That’s why we call this boring structure an Exp\text{Exp}-structure.

Example 6. Recall that a DD-structure on a finite set is a derangement of that finite set. To choose a permutation f:SSf: S \to S of a finite set SS is the same as to choose a subset XSX \subset S, which will be the set of fixed points of ff, and to choose a derangement of SXS - X. Thus by Example 4 we have

PExpD P \cong \text{Exp} \cdot D

and also

|P|=|Exp||D| |P| = |\text{Exp}| \cdot |D|

so by Example 3 and Example 5 we have

11x=exp(x)|D| \frac{1}{1 - x} = \exp(x) |D|

so

|D|=e x1x |D| = \frac{e^{-x}}{1 - x}

or

n0|D(n)|n!x n=e x1x \sum_{n \ge 0} \frac{|D(n)|}{n!} x^n = \frac{e^{-x}}{1 - x}

=(1x+x 22x 36+x 424)(1+x+x 2+x 3+x 4+) = \left(1 - x + \frac{x^2}{2} - \frac{x^3}{6} + \frac{x^4}{24} - \cdots \right)(1 + x + x^2 + x^3 + x^4 + \cdots )

=10!+01!x+12!x 2+23!x 3+94!x 4+ = \frac{1}{0!} + \frac{0}{1!} x + \frac{1}{2!}x^2 + \frac{2}{3!} x^3 + \frac{9}{4!} x^4 + \cdots

so we see that

D(0)=1,D(1)=0,D(2)=1,D(3)=2,D(4)=9, D(0) = 1, \quad D(1) = 0, \quad D(2) = 1, \quad D(3) = 2, \quad D(4) = 9 , \dots

But we can go further with this… and I’ll ask you to go further in this homework:

Also, you’ll notice that I wrote

PExpDP \cong \text{Exp} \cdot D

without ever defining an isomorphism of species! So you can try to figure out what that should mean, and I’ll say more about it next time.

Posted at June 22, 2025 2:59 PM UTC

TrackBack URL for this Entry:   https://golem.ph.utexas.edu/cgi-bin/MT-3.0/dxy-tb.fcgi/3601

0 Comments & 0 Trackbacks

Post a New Comment