# Species, derivatives of types and Gröbner bases for operads

Published: Sat 18 December 2010

This is a typed up copy of my lecture notes from the combinatorics seminar at KTH, 2010-09-01. This is not a perfect copy of what was said at the seminar, rather a starting point from which the talk grew.

In some points, I've tried to fill in the most sketchy and un-articulated points with some simile of what I ended up actually saying.

Combinatorial species started out as a theory to deal with enumerative combinatorics, by providing a toolset & calculus for formal power series. (see Bergeron-Labelle-Leroux and Joyal)

As it turns out, not only is species useful for manipulating generating functions, btu it provides this with a categorical approach that may be transplanted into other areas.

For the benefit of the entire audience, I shall introduce some definitions.

Definition: A category C is a collection of objects and arrows with each arrow assigned a source and target object, such that

1. Each object has its own identity arrow 1.
2. Chains of arrows are associatively composable, with 1 the identity of this composition.

Examples: Sets, Finite sets, k-Vector spaces, left and right R-Modules, Graphs, Groups, Abelian groups.

$$\mathbb B$$: finite sets with only bijections as morphisms.

Examples:

• Category of a monoid.
• Category generated by a graph
• Category of a group (groupoid version of the category of a monoid)
• Category of a poset
• Category of Haskell types and functions.

Definition: A functor F is a map of categories, in other words, a pair of maps Fo on objects and Fa on arrows, such that the identity arrow maps to identity arrows and compositions of maps map to compositions of their images.

Examples:
Constant functor: sends every object to A, every map to 1.

Identity functor: sends objects and arrows to themselves.

Underlying set functor, free monoid/vector space/module/... functors.

We are now equipped to define Species:
Definition: A species of structures is a functor $$\mathbb B\to\mathbb B$$.

The idea is a set gets mapped to the set of all structures labelled by the elements in the original set. A bijection on labels maps to the transport of structures along the relabeling.

Examples:
$$A$$: rooted trees, labels on vertices
$$G$$: simple graphs, labels on vertices
$$Gc$$: connected simple graphs, labels on vertices.
$$a$$: trees, labels on vertices.
$$D$$: directed graphs, labels on vertices
$$\wp$$: subsets, $$\wp[U] = \{S: S\subseteq U\}$$.
$$End$$: endofunctions
$$Inv$$: involutions
$$S$$: permutations
$$C$$: cycles
$$L$$: linear orders
$$E$$: sets: $$E[U] = \{U\}$$
$$e$$: elements: $$e[U] = U$$
$$X$$: singletons: $$X[U] = U$$ if $$|U|=1$$ and $$X[U] = \emptyset$$ otherwise
$$1$$: empty set: $$1[\emptyset]=\{\emptyset\}$$, $$1[U] = \emptyset$$ otherwise
$$0$$: empty species: $$0[U] = \emptyset$$.

In enumerative combinatorics, the power of species resides in the association to each species a number of generating functions:

The generating series of a species F is the exponential formal power series
$$F(x) = \sum_{n=0}^\infty |F[n]|\frac{x^n}{n!}$$
where we use the convention $$[n] = \{1,2,\dots,n\}$$, and $$F[n] = F[[n]]$$.
Thus:
$$L(x) = \frac{1}{1-x}$$
$$S(x) = \frac{1}{1-x}$$
$$E(x) = e^x$$
$$e(x) = xe^x$$
$$\wp(x) = e^{2x}$$
$$X(x) = x$$
$$1(x) = 1$$
$$0(x) = 0$$

There are a number other in use for combinatorics, but for my purposes, this is the one I'll focus on.

## Operations on species

The real power, though, emerges when we start combining species, and carry over the combinations to actions on the corresponding power series.

The number of ways to form either, say, a graph or a linear order on a set of labels is the sum of the numbers of ways to form either in isolation.

This corresponds cleanly to the coproduct in Set, and we may write F+G for the species
$$(F+G)[U] = F[U] + G[U]$$
(where the second + is the coproduct — i.e. disjoint union — of sets)

In the power series, we get $$(F+G)(x) = F(x) + G(x)$$.

Examples: We may define the species of all non-empty sets $$E_+$$ by
$$E = 1 + E_+$$
This kind of functional equations is where the theory of species starts to really shine.

### Multiplication

A tricoloring of a set is a subdivision of the set into three disjoint subsets covering the original set. The number of tricolorings of size n is
$$\sum_{i+j+k=n} \#\text{sets of size i}\cdot\#\text{sets of size j}\cdot\#\text{sets of size k}$$
A permutation fixes some set of points. The permutation restricted to the non-fixed points is a derangement. Total number of permutations on n elements is
$$\sum_{i+j=n}\#\text{sets of size i}\cdot\#\text{derangements of size j}$$
In both of these cases, the total generating series is a product of the component series, and we end up defining
$$F\cdot G[U] = \{(f,g): f\in F[U_1], g\in G[U_2], U_1\cap U_2 = \emptyset, U_1\cup U_2 = U\}$$
So $$F\cdot G[U] = \sum_{U_1,U_2\text{ decompose }U} F[U_1]\times G[U_2]$$.

Thus, tricolorings are $$E\cdot E\cdot E$$ and permutations are $$S = E\cdot Der$$, where the set is that of fixed points, and the derangement captures the actual action of the permutation.

### Composition

Endofunctions of sets decompose in their actions on the points as cycles or directed trees leading in to these cycles.

Since a collection of disjoint cycles corresponds to a permutation, we can consider such endofunctions to be permutations decorated with rooted trees attached to points of the permutations; or even permutations of rooted trees.

To form such a structure on a set U, we'd first partition U into subsets, put the structure of a rooted tree on each subset, and then the structure of a permutation on the set of these subsets.

Thus, the number of such structures on n elements is
$$\sum_{r\leq n}\sum_{\sum_{k=1}^n i_k = n} \#\tex{permutations on [r]}\cdot\prod_{k=1}^r\#\text{rooted trees on [i_k]}$$

This corresponds to the power series $$S(A(x))$$, and we write, in general, $$F\circ G[U]$$ for the species of F-structures of G-structures on subsets.

Examples:
A = X·E(A)
L = 1 + X·L
B = 1 + X·B·B

### Pointing

Picking out a single point in a structure on n points can be done in precisely n ways.

Thus the corresponding generating function will be
$$\sum n\cdot f_n\cdot\frac{x^n}{n!}$$
for f-structures with a single label distinguished.
Since we're working with exponential power series, we may notice that
$$\frac{\partial}{\partial x} \sum f_n\frac{x^n}{n!} = \sum f_{n+1}\frac{x^n}{n!}$$
and thus that derivatives are shifts.
Furthermore, $$x\cdot\sum f_n\frac{x^n}{n!} = \sum f_n\frac{x^{n+1}}{n!} = \sum f_{n-1}n\cdot{x^n}{n!}$$
so that the generating function for F-structures with a single distinguished are
$$F^\bullet(x) = x\cdot\frac{\partial}{\partial x}F(x)$$

In species, this process is called pointing.

In functional programming, Conor McBride related this construction to Huet's Zipper datatypes.

As it turns out, many of the constructions for species make eminent sense outside the category $$\mathbb B$$. In fact, species in Hask are known to programming language researchers as container datatypes and the whole calculus translates relatively cleanly.

Functional equations translate to the standard new data type definitions in Haskell.

Examples:
L = 1 + X·L
 data List a = Nil | Cons a (List a)
B = 1 + X·B·B
 data BinaryTree a = Leaf | Node (BinaryTree a) a (BinaryTree a)
A = X·E(A)
 data RootedTree a = Node a (Set (RootedTree a))
usually, we simulate the Set here by a List. If we need for our rooted trees to be planar, we can in fact impose a Linear Order structure instead, and get something like
Ap = X·L(Ap)

The species interpretation of $$\frac{\partial}{\partial x}$$ corresponding to leaving a hole in the structure carries over cleanly, so that $$\frac{\partial}{\partial x}T$$ is the type of T-with-a-hole.

## Two derivatives of lists

We can deal with $$\frac{\partial}{\partial x}L$$ in two different ways:

1.
DL = D(1+X·L) = D1 + D(X·L) = 0 + DX·L+X·DL
and thus
DL-X·DL = 1·L
so (1-X)·DL = L
and thus
DL = L·1/(1-X)
Now, from L=1+X·L follows by a similar cavalier use of subtraction and division — which, by the way, in species theory is captured by the idea of a virtual species, and dealt with relatively cleanly — that
L = 1+X·L
so
L-X·L = 1
and thus
(1-X)·L = 1
so
L = 1/(1-X)
Thus, we can conclude that
DL = L·1/(1-X) = L·L
and thus, a list with a hole is a pair of lists: the stuff before the hole and the stuff after the hole.
2.
We could, instead of using implicit differentiation, as in 1, attack the derivation we had of
L = 1/(1-X) = 1+X+X·X+X·X·X+…
Indeed,
DL = D(1/(1-X)) = D(1+X+X·X+…) = 0+1+2X+3X·X+…
which we can observe factors as
= (1+X+X·X+X·X·X+…)·(1+X+X·X+X·X·X+…) = L·L
Or we can just use the division rule
DL = D(1/(1-X)) = D(1/u)·D(1-X) = -1/(u·u)·(-1) = 1/[(1-X)·(1-X)] = L·L