Blog

Derangements, Dobiński's formula, and their combination

A couple of years ago, someone on a mailing list asked for a proof for their observation that

Bn=k=1nknk!!(nk)(nk)!

where Bn denotes the Bell numbers (the number of set partitions of n items), and !(nk) aka Dnk denotes the number of derangements of nk items.

Actually, this appears to be the m=n special case of something more general: whenever mn, we can say

Bmn!=k(nk)kmDnk

The “symbolic method” of Flajolet and Sedgewick (from their book Analytic Combinatorics) gives a nice unifying framework that puts in perspective (1) the relation between permutations and derangements, (2) Dobinski’s formula, and (3) this result — when viewed from this lens, all these results feel very natural (IMO).

0. Background (EGFs and labelled products)

Suppose we have a combinatorial class C, i.e. a set of objects such that Cn is the number of objects of size n and is finite. Then the exponential generating function (EGF) of this class is defined as

C(z)=nCnznn!

It makes sense to use EGFs when these objects are labelled, i.e. if an object is of size n, then it contains n elements that have labels 1,2,,n. For example, C may be the class of all permutations, so that Cn counts the number of permutations of n items.

Some trivial examples:

We can define the labelled product of two such combinatorial classes: put together an object from the first class and an object from the second, redistributing labels so that the relative order is consistent within each object. For two classes A and B, this operation, denoted AB, corresponds to the product of the EGFs.

Note that the binomial convolution Cn=k(nk)AkBnk corresponds to both

With that quick background (explained more clearly in the book!), all three results have very short proofs.

1. Permutations and derangements

Let P be the class of all permutations. There are Pn=n! permutations of size n, so its EGF is P(z)=nPnznn!=nzn=11z. (In fact we can also obtain this by noting that any permutation is either the empty permutation or the labelled product of a single element and a smaller permutation, so P=E+ZP which for the EGF gives P(z)=1+zP(z) or P(z)=11z.)

Let D be the class of all derangements. Then note that any permutation is the labelled product of a derangement and a set of elements (the fixed points). So

P=DU

P(z)=D(z)ez

Comparing coefficients of zn/n! gives the relation n!=k(nk)Dk, or equivalently, from D(z)=ezP(z), the relation Dn=k(nk)(1)k(nk)!=n!k(nk)1k!

(BTW, the same “symbolic method” also gives us a couple of other ways of deriving the same expression for Dn; see this Math.SE answer.)

2. Surjections and all functions (Dobiński’s formula)

Fix a set S of size M for some fixed constant integer M. (For example, S may be {1,2,,M}.)

Let R be the class of all surjective (“onto”) functions from S to some prefix of the natural numbers. That is, Rn counts the number of surjective functions from S to {1,2,,n}. This is an ordered set partition, so the number is Rn=n!{Mn}, where the notation {Mn} denotes the number of partitions of a set of size M into n parts, known as the Stirling subset numbers (aka Stirling numbers of the second kind). We can see this as: partition S into n nonempty subsets (the preimage of each element), then order these n subsets in any of n! ways. (Note that Rn is 0 for n>M.)

Let F be the class of all functions from S to some prefix of the natural numbers. That is, Fn counts the number of functions from S to {1,2,,n}, and this of course is nM.

Now, any such function is the labelled product of a surjection and set of “dummy” elements (in the co-domain but not in the range). So we have

F=UR

F(z)=ezR(z)

Setting z=1 here gives

nnMn!=enn!{Mn}1n!=en{Mn}=eBM

which is known as Dobiński’s formula.

I had posted this online at some point, excuse the handwriting:

3. Putting them together

Above we’ve seen that P=UD and that F=UR. Putting them together, we have

FD=RUD=RP

F(z)D(z)=R(z)P(z)

So

k(nk)kMDnk=k(nk)k!{Mk}(nk)! =n!kn{Mk}

and for nM the RHS is n!BM. This is precisely the identity we initially wanted to prove.