Generating Functions as Cardinality of Set Maps

There is a class of all cardinalities \mathbf{Card}, and it
has elements 0, 1 and operations +, \cdot, and so forth defined on it. Furthermore, there is a map
\mathrm{card}\colon\mathbf{Set}\to\mathbf{Card} which takes
sets to cardinalities such that \mathrm{card}(A\times  B)=\mathrm{card}(A)\cdot\mathrm{card}(B) (and so on).

Ordinary generating functions can be thought of entirely analogously
with set maps \mathbf{Set}\to\mathbf{Set} replacing sets:
There is a class \mathbf{GenFunc} with elements 0,
1, and operations +, \cdot. Furthermore,
there is a (partial) map \mathrm{genFunc}\colon (\mathbf{Set}\to\mathbf{Set})\to\mathbf{GenFunc} such that \mathrm{genFunc}(F\times G)=\mathrm{genFunc}(F)\cdot\mathrm{genFunc}(G) (and so on). Here, F\times G is defined by (F\times G)(S)=F(S)\times G(S). Other operations on set maps (like disjoint union) are similarly defined pointwise.

(This is probably obvious and trivial to anyone who actually works
with generating functions, but it only occurred to me recently, so I
thought I’d write a blog post about it.)

The class \mathbf{GenFunc} is in fact a set, and is just the set of formal power series \{\sum_{i\geq 0} a_i z^i\mid a_i\in\mathbb{N}\}. The partial map \mathrm{genFunc} takes F to \sum_{i\geq 0} a_i z^i just in case F is “canonically isomorphic” (a notion I’ll leave slippery and undefined but that can be made precise) to the map Z\mapsto \coprod_{i\geq 0} \{1,2,\ldots,a_i\}\times Z^i, where \coprod indicates disjoint union.

That provides a semantics for ordinary generating functions. Furthermore, this semantics has a number of features beyond those of cardinality. For example, in addition to respecting \coprod and \times, \mathrm{genFunc} represents composition.

A similar semantics can be provided for exponential generating functions, but it takes a little more work. In particular, we have to single out \lbrack0,1\rbrack as a distinguished set. Let \mathbf{Meas} be the smallest set containing all measurable subsets of \lbrack0,1\rbrack^n for any finite n and which is closed under finite products, countable disjoint unions, and products with sets \{1,\ldots,n\} for finite n\geq 1.

We can define the measure \mu of all sets in \mathbf{Meas} by extending Lebesgue measure in the obvious way (taking the product of a set with \{1,\ldots,n\} will multiply the measure by n). Furthermore, notice that, by construction, every element of every set M in \mathbf{Meas} is a tuple which (after flattening) has all of its elements either natural numbers or elements of \lbrack 0,1\rbrack and has at least one element of \lbrack 0,1\rbrack. Therefore, we can define a pre-ordering on M by comparing the corresponding first elements that are in \lbrack 0,1\rbrack.

The point of all that is that, for M\in\mathbf{Meas}, we can form the set M^n_{<}=\{\langle m_1,\ldots,m_n\rangle\mid m_1 < \cdots < m_n\} which will again be in \mathbf{Meas} and its measure will be \mu(M)^n/n!. The corresponding statement with cardinality is not true since you have to worry about the case when elements in the tuple are equal (\mathrm{card}(X^n_{<}) = \mathrm{card}(X)(\mathrm{card}(X)-1)\cdots(\mathrm{card}(X)-n+1)/n!) but the set of tuples that have duplicates has measure 0, so by working with measure, we can get the equality we want.

Finally, let \mathbf{ExpGenFunc} be the set of formal power series \{\sum_{i\geq 0} a_i/i! z^i\mid a_i\in\mathbb{N}\}. The partial map \mathrm{expGenFunc} takes F to \sum_{i\geq 0} a_i/i! z_i just in case F is “canonically isomorphic” to the map Z\mapsto \coprod_{i\geq 0} \{1,2,\ldots,a_i\}\times Z^i_{<} for all Z in \mathbf{Meas}. Just as before, this map respects +, \cdot, composition, etc.

Note that the exponential generating functions are usually explained via labeled objects and some sort of relabeling operation. This approach weasels out of that by observing that the event that there was a label collision has probability 0, so you can just ignore it.

One thought on “Generating Functions as Cardinality of Set Maps

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s