# Combinatorics (Fall 2010)/Partitions, sieve methods

## Partitions

We count the ways of partitioning $\displaystyle{ n }$ identical objects into $\displaystyle{ k }$ unordered groups. This is equivalent to counting the ways partitioning a number $\displaystyle{ n }$ into $\displaystyle{ k }$ unordered parts.

A $\displaystyle{ k }$-partition of a number $\displaystyle{ n }$ is a multiset $\displaystyle{ \{x_1,x_2,\ldots,x_k\} }$ with $\displaystyle{ x_i\ge 1 }$ for every element $\displaystyle{ x_i }$ and $\displaystyle{ x_1+x_2+\cdots+x_k=n }$.

We define $\displaystyle{ p_k(n) }$ as the number of $\displaystyle{ k }$-partitions of $\displaystyle{ n }$.

For example, number 7 has the following partitions:

\displaystyle{ \begin{align} &\{7\} & p_1(7)=1\\ &\{1,6\},\{2,5\},\{3,4\} & p_2(7)=3\\ &\{1,1,5\}, \{1,2,4\}, \{1,3,3\}, \{2,2,3\} & p_3(7)=4\\ &\{1,1,1,4\},\{1,1,2,3\}, \{1,2,2,2\} & p_4(7)=3\\ &\{1,1,1,1,3\},\{1,1,1,2,2\} & p_5(7)=2\\ &\{1,1,1,1,1,2\} & p_6(7)=1\\ &\{1,1,1,1,1,1,1\} & p_7(7)=1 \end{align} }

Equivalently, we can also define that A $\displaystyle{ k }$-partition of a number $\displaystyle{ n }$ is a $\displaystyle{ k }$-tuple $\displaystyle{ (x_1,x_2,\ldots,x_k) }$ with:

• $\displaystyle{ x_1\ge x_2\ge\cdots\ge x_k\ge 1 }$;
• $\displaystyle{ x_1+x_2+\cdots+x_k=n }$.

$\displaystyle{ p_k(n) }$ the number of integral solutions to the above system.

Let $\displaystyle{ p(n)=\sum_{k=1}^n p_k(n) }$ be the total number of partitions of $\displaystyle{ n }$. The function $\displaystyle{ p(n) }$ is called the partition number.

### Counting $\displaystyle{ p_k(n) }$

We now try to determine $\displaystyle{ p_k(n) }$. Unlike most problems we learned in the last lecture, $\displaystyle{ p_k(n) }$ does not have a nice closed form formula. We now give a recurrence for $\displaystyle{ p_k(n) }$.

 Proposition $\displaystyle{ p_k(n)=p_{k-1}(n-1)+p_k(n-k)\, }$.
Proof.
 Suppose that $\displaystyle{ (x_1,\ldots,x_k) }$ is a $\displaystyle{ k }$-partition of $\displaystyle{ n }$. Note that it must hold that $\displaystyle{ x_1\ge x_2\ge \cdots \ge x_k\ge 1 }$. There are two cases: $\displaystyle{ x_k=1 }$ or $\displaystyle{ x_k\gt 1 }$. Case 1. If $\displaystyle{ x_k=1 }$, then $\displaystyle{ (x_1,\cdots,x_{k-1}) }$ is a distinct $\displaystyle{ (k-1) }$-partition of $\displaystyle{ n-1 }$. And every $\displaystyle{ (k-1) }$-partition of $\displaystyle{ n-1 }$ can be obtained in this way. Thus the number of $\displaystyle{ k }$-partitions of $\displaystyle{ n }$ in this case is $\displaystyle{ p_{k-1}(n-1) }$. Case 2. If $\displaystyle{ x_k\gt 1 }$, then $\displaystyle{ (x_1-1,\cdots,x_{k}-1) }$ is a distinct $\displaystyle{ k }$-partition of $\displaystyle{ n-k }$. And every $\displaystyle{ k }$-partition of $\displaystyle{ n-k }$ can be obtained in this way. Thus the number of $\displaystyle{ k }$-partitions of $\displaystyle{ n }$ in this case is $\displaystyle{ p_{k}(n-k) }$. In conclusion, the number of $\displaystyle{ k }$-partitions of $\displaystyle{ n }$ is $\displaystyle{ p_{k-1}(n-1)+p_k(n-k) }$, i.e. $\displaystyle{ p_k(n)=p_{k-1}(n-1)+p_k(n-k)\, }$.
$\displaystyle{ \square }$

Use the above recurrence, we can compute the $\displaystyle{ p_k(n) }$ for some decent $\displaystyle{ n }$ and $\displaystyle{ k }$ by computer simulation.

If we are not restricted ourselves to the precise estimation of $\displaystyle{ p_k(n) }$, the next theorem gives an asymptotic estimation of $\displaystyle{ p_k(n) }$. Note that it only holds for constant $\displaystyle{ k }$, i.e. $\displaystyle{ k }$ does not depend on $\displaystyle{ n }$.

 Theorem For any fixed $\displaystyle{ k }$, $\displaystyle{ p_k(n)\sim\frac{n^{k-1}}{k!(k-1)!} }$, as $\displaystyle{ n\rightarrow \infty }$.
Proof.
 Suppose that $\displaystyle{ (x_1,\ldots,x_k) }$ is a $\displaystyle{ k }$-partition of $\displaystyle{ n }$. Then $\displaystyle{ x_1+x_2+\cdots+x_k=n }$ and $\displaystyle{ x_1\ge x_2\ge \cdots \ge x_k\ge 1 }$. The $\displaystyle{ k! }$ permutations of $\displaystyle{ (x_1,\ldots,x_k) }$ yield at most $\displaystyle{ k! }$ many $\displaystyle{ k }$-compositions (the ordered sum of $\displaystyle{ k }$ positive integers). There are $\displaystyle{ {n-1\choose k-1} }$ many $\displaystyle{ k }$-compositions of $\displaystyle{ n }$, every one of which can be yielded in this way by permuting a partition. Thus, $\displaystyle{ k!p_k(n)\ge{n-1\choose k-1} }$. Let $\displaystyle{ y_i=x_i+k-i }$. That is, $\displaystyle{ y_k=x_k, y_{k-1}=x_k+1, y_{k-2}=x_k+2,\ldots, y_{1}=x_k+k-1 }$. Then, it holds that $\displaystyle{ y_1\gt y_2\gt \cdots\gt y_k\ge 1 }$; and $\displaystyle{ y_1+y_2+\cdots+y_k=n+\frac{k(k-1)}{2} }$. Each permutation of $\displaystyle{ (y_1,y_2,\ldots,y_k) }$ yields a distinct $\displaystyle{ k }$-composition of $\displaystyle{ n+\frac{k(k-1)}{2} }$, because all $\displaystyle{ y_i }$ are distinct. Thus, $\displaystyle{ k!p_k(n)\le {n+\frac{k(k-1)}{2}-1\choose k-1} }$. Combining the two inequalities, we have $\displaystyle{ \frac{{n-1\choose k-1}}{k!}\le p_k(n)\le \frac{{n+\frac{k(k-1)}{2}-1\choose k-1}}{k!} }$. The theorem follows.
$\displaystyle{ \square }$

### Ferrers diagram

A partition of a number $\displaystyle{ n }$ can be represented as a diagram of dots (or squares), called a Ferrers diagram (the square version of Ferrers diagram is also called a Young diagram, named after a structured called Young tableaux).

Let $\displaystyle{ (x_1,x_2,\ldots,x_k) }$ with that $\displaystyle{ x_1\ge x_2\ge \cdots x_k\ge 1 }$ be a partition of $\displaystyle{ n }$. Its Ferrers diagram consists of $\displaystyle{ k }$ rows, where the $\displaystyle{ i }$-th row contains $\displaystyle{ x_i }$ dots (or squares).

Ferrers diagram (dot version) of (5,4,2,1) Ferrers diagram (square version) of (5,4,2,1)
Conjugate partition

The partition we get by reading the Ferrers diagram by column instead of rows is called the conjugate of the original partition.

$\displaystyle{ (6,4,4,2,1) }$ conjugate: $\displaystyle{ (5,4,3,3,1,1) }$

Clearly,

• different partitions cannot have the same conjugate, and
• every partition of $\displaystyle{ n }$ is the conjugate of some partition of $\displaystyle{ n }$,

so the conjugation mapping is a permutation on the set of partitions of $\displaystyle{ n }$. This fact is very useful in proving theorems for partitions numbers.

Some theorems of partitions can be easily proved by representing partitions in Ferrers diagrams.

 Proposition The number of partitions of $\displaystyle{ n }$ which have largest summand $\displaystyle{ k }$, is $\displaystyle{ p_k(n) }$. The number of $\displaystyle{ n }$ into $\displaystyle{ k }$ parts equals the number of partitions of $\displaystyle{ n-k }$ into at most $\displaystyle{ k }$ parts. Formally, $\displaystyle{ p_k(n)=\sum_{j=1}^k p_j(n-k) }$.
Proof.
 For every $\displaystyle{ k }$-partition, the conjugate partition has largest part $\displaystyle{ k }$. And vice versa. For a $\displaystyle{ k }$-partition of $\displaystyle{ n }$, remove the leftmost cell of every row of the Ferrers diagram. Totally $\displaystyle{ k }$ cells are removed and the remaining diagram is a partition of $\displaystyle{ n-k }$ into at most $\displaystyle{ k }$ parts. And for a partition of $\displaystyle{ n-k }$ into at most $\displaystyle{ k }$ parts, add a cell to each of the $\displaystyle{ k }$ rows (including the empty ones). This will give us a $\displaystyle{ k }$-partition of $\displaystyle{ n }$. It is easy to see the above mappings are 1-1 correspondences. Thus, the number of $\displaystyle{ n }$ into $\displaystyle{ k }$ parts equals the number of partitions of $\displaystyle{ n-k }$ into at most $\displaystyle{ k }$ parts.
$\displaystyle{ \square }$

## Principle of Inclusion-Exclusion

Let $\displaystyle{ A }$ and $\displaystyle{ B }$ be two finite sets. The cardinality of their union is

$\displaystyle{ |A\cup B|=|A|+|B|-{\color{Blue}|A\cap B|} }$.

For three sets $\displaystyle{ A }$, $\displaystyle{ B }$, and $\displaystyle{ C }$, the cardinality of the union of these three sets is computed as

$\displaystyle{ |A\cup B\cup C|=|A|+|B|+|C|-{\color{Blue}|A\cap B|}-{\color{Blue}|A\cap C|}-{\color{Blue}|B\cap C|}+{\color{Red}|A\cap B\cap C|} }$.

This is illustrated by the following figure.

Generally, the Principle of Inclusion-Exclusion states the rule for computing the union of $\displaystyle{ n }$ finite sets $\displaystyle{ A_1,A_2,\ldots,A_n }$, such that

\displaystyle{ \begin{align} \left|\bigcup_{i=1}^nA_i\right| &= \sum_{I\subseteq\{1,\ldots,n\}}(-1)^{|I|-1}\left|\bigcap_{i\in I}A_i\right|. \end{align} }

In combinatorial enumeration, the Principle of Inclusion-Exclusion is usually applied in its complement form.

Let $\displaystyle{ A_1,A_2,\ldots,A_n\subseteq U }$ be subsets of some finite set $\displaystyle{ U }$. Here $\displaystyle{ U }$ is some universe of combinatorial objects, whose cardinality is easy to calculate (e.g. all strings, tuples, permutations), and each $\displaystyle{ A_i }$ contains the objects with some specific property (e.g. a "pattern") which we want to avoid. The problem is to count the number of objects without any of the $\displaystyle{ n }$ properties. We write $\displaystyle{ \bar{A_i}=U-A }$. The number of objects without any of the properties $\displaystyle{ A_1,A_2,\ldots,A_n }$ is

\displaystyle{ \begin{align} \left|\bar{A_1}\cap\bar{A_2}\cap\cdots\cap\bar{A_n}\right|=\left|U-\bigcup_{i=1}^nA_i\right| &= |U|+\sum_{I\subseteq\{1,\ldots,n\}}(-1)^{|I|}\left|\bigcap_{i\in I}A_i\right|. \end{align} }

For an $\displaystyle{ I\subseteq\{1,2,\ldots,n\} }$, we denote

$\displaystyle{ A_I=\bigcap_{i\in I}A_i }$

with the convention that $\displaystyle{ A_\emptyset=U }$. The above equation is stated as:

 Principle of Inclusion-Exclusion Let $\displaystyle{ A_1,A_2,\ldots,A_n }$ be a family of subsets of $\displaystyle{ U }$. Then the number of elements of $\displaystyle{ U }$ which lie in none of the subsets $\displaystyle{ A_i }$ is $\displaystyle{ \sum_{I\subseteq\{1,\ldots, n\}}(-1)^{|I|}|A_I| }$.

Let $\displaystyle{ S_k=\sum_{|I|=k}|A_I|\, }$. Conventionally, $\displaystyle{ S_0=|A_\emptyset|=|U| }$. The principle of inclusion-exclusion can be expressed as

$\displaystyle{ S_0-S_1+S_2+\cdots+(-1)^nS_n. }$

### Surjections

In the twelvefold way, we discuss the counting problems incurred by the mappings $\displaystyle{ f:N\rightarrow M }$. The basic case is that elements from both $\displaystyle{ N }$ and $\displaystyle{ M }$ are distinguishable. In this case, it is easy to count the number of arbitrary mappings (which is $\displaystyle{ m^n }$) and the number of injective (one-to-one) mappings (which is $\displaystyle{ (m)_n }$), but the number of surjective is difficult. Here we apply the principle of inclusion-exclusion to count the number of surjective (onto) mappings.

 Theorem The number of surjective mappings from an $\displaystyle{ n }$-set to an $\displaystyle{ m }$-set is given by $\displaystyle{ \sum_{k=1}^m(-1)^{m-k}{m\choose k}k^n }$.
Proof.
 Let $\displaystyle{ U=\{f:[n]\rightarrow[m]\} }$ be the set of mappings from $\displaystyle{ [n] }$ to $\displaystyle{ [m] }$. Then $\displaystyle{ |U|=m^n }$. For $\displaystyle{ i\in[m] }$, let $\displaystyle{ A_i }$ be the set of mappings $\displaystyle{ f:[n]\rightarrow[m] }$ that none of $\displaystyle{ j\in[n] }$ is mapped to $\displaystyle{ i }$, i.e. $\displaystyle{ A_i=\{f:[n]\rightarrow[m]\setminus\{i\}\} }$, thus $\displaystyle{ |A_i|=(m-1)^n }$. More generally, for $\displaystyle{ I\subseteq [m] }$, $\displaystyle{ A_I=\bigcap_{i\in I}A_i }$ contains the mappings $\displaystyle{ f:[n]\rightarrow[m]\setminus I }$. And $\displaystyle{ |A_I|=(m-|I|)^n\, }$. A mapping $\displaystyle{ f:[n]\rightarrow[m] }$ is surjective if $\displaystyle{ f }$ lies in none of $\displaystyle{ A_i }$. By the principle of inclusion-exclusion, the number of surjective $\displaystyle{ f:[n]\rightarrow[m] }$ is $\displaystyle{ \sum_{I\subseteq[m]}(-1)^{|I|}\left|A_I\right|=\sum_{I\subseteq[m]}(-1)^{|I|}(m-|I|)^n=\sum_{j=0}^m(-1)^j{m\choose j}(m-j)^n }$. Let $\displaystyle{ k=m-j }$. The theorem is proved.
$\displaystyle{ \square }$

Recall that, in the twelvefold way, we establish a relation between surjections and partitions.

• Surjection to ordered partition:
For a surjective $\displaystyle{ f:[n]\rightarrow[m] }$, $\displaystyle{ (f^{-1}(0),f^{-1}(1),\ldots,f^{-1}(m-1)) }$ is an ordered partition of $\displaystyle{ [n] }$.
• Ordered partition to surjection:
For an ordered $\displaystyle{ m }$-partition $\displaystyle{ (B_0,B_1,\ldots, B_{m-1}) }$ of $\displaystyle{ [n] }$, we can define a function $\displaystyle{ f:[n]\rightarrow[m] }$ by letting $\displaystyle{ f(i)=j }$ if and only if $\displaystyle{ i\in B_j }$. $\displaystyle{ f }$ is surjective since as a partition, none of $\displaystyle{ B_i }$ is empty.

Therefore, we have a one-to-one correspondence between surjective mappings from an $\displaystyle{ n }$-set to an $\displaystyle{ m }$-set and the ordered $\displaystyle{ m }$-partitions of an $\displaystyle{ n }$-set.

The Stirling number of the second kind $\displaystyle{ S(n,m) }$ is the number of $\displaystyle{ m }$-partitions of an $\displaystyle{ n }$-set. There are $\displaystyle{ m! }$ ways to order an $\displaystyle{ m }$-partition, thus the number of surjective mappings $\displaystyle{ f:[n]\rightarrow[m] }$ is $\displaystyle{ m! S(n,m) }$. Combining with what we have proved for surjections, we give the following result for the Stirling number of the second kind.

 Proposition $\displaystyle{ S(n,m)=\frac{1}{m!}\sum_{k=1}^m(-1)^{m-k}{m\choose k}k^n }$.

### Derangements

We now count the number of bijections from a set to itself with no fixed points. This is the derangement problem.

For a permutation $\displaystyle{ \pi }$ of $\displaystyle{ \{1,2,\ldots,n\} }$, a fixed point is such an $\displaystyle{ i\in\{1,2,\ldots,n\} }$ that $\displaystyle{ \pi(i)=i }$. A derangement of $\displaystyle{ \{1,2,\ldots,n\} }$ is a permutation of $\displaystyle{ \{1,2,\ldots,n\} }$ that has no fixed points.

 Theorem The number of derangements of $\displaystyle{ \{1,2,\ldots,n\} }$ given by $\displaystyle{ n!\sum_{k=0}^n\frac{(-1)^k}{k!}\approx \frac{n!}{\mathrm{e}} }$.
Proof.
 Let $\displaystyle{ U }$ be the set of all permutations of $\displaystyle{ \{1,2,\ldots,n\} }$. So $\displaystyle{ |U|=n! }$. Let $\displaystyle{ A_i }$ be the set of permutations with fixed point $\displaystyle{ i }$; so $\displaystyle{ |A_i|=(n-1)! }$. More generally, for any $\displaystyle{ I\subseteq \{1,2,\ldots,n\} }$, $\displaystyle{ A_I=\bigcap_{i\in I}A_i }$, and $\displaystyle{ |A_I|=(n-|I|)! }$, since permutations in $\displaystyle{ A_I }$ fix every point in $\displaystyle{ I }$ and permute the remaining points arbitrarily. A permutation is a derangement if and only if it lies in none of the sets $\displaystyle{ A_i }$. So the number of derangements is $\displaystyle{ \sum_{I\subseteq\{1,2,\ldots,n\}}(-1)^{|I|}(n-|I|)!=\sum_{k=0}^n(-1)^k{n\choose k}(n-k)!=n!\sum_{k=0}^n\frac{(-1)^k}{k!}. }$ By Taylor's series, $\displaystyle{ \frac{1}{\mathrm{e}}=\sum_{k=0}^\infty\frac{(-1)^k}{k!}=\sum_{k=0}^n\frac{(-1)^k}{k!}\pm o\left(\frac{1}{n!}\right) }$. It is not hard to see that $\displaystyle{ n!\sum_{k=0}^n\frac{(-1)^k}{k!} }$ is the closest integer to $\displaystyle{ \frac{n!}{\mathrm{e}} }$.
$\displaystyle{ \square }$

Therefore, there are about $\displaystyle{ \frac{1}{\mathrm{e}} }$ fraction of all permutations with no fixed points.

### Permutations with restricted positions

We introduce a general theory of counting permutations with restricted positions. In the derangement problem, we count the number of permutations that $\displaystyle{ \pi(i)\neq i }$. We now generalize to the problem of counting permutations which avoid a set of arbitrarily specified positions.

It is traditionally described using terminology from the game of chess. Let $\displaystyle{ B\subseteq \{1,\ldots,n\}\times \{1,\ldots,n\} }$, called a board. As illustrated below, we can think of $\displaystyle{ B }$ as a chess board, with the positions in $\displaystyle{ B }$ marked by "$\displaystyle{ \times }$".

 a b c d e f g h 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1 a b c d e f g h

For a permutation $\displaystyle{ \pi }$ of $\displaystyle{ \{1,\ldots,n\} }$, define the graph $\displaystyle{ G_\pi(V,E) }$ as

\displaystyle{ \begin{align} G_\pi &= \{(i,\pi(i))\mid i\in \{1,2,\ldots,n\}\}. \end{align} }

This can also be viewed as a set of marked positions on a chess board. Each row and each column has only one marked position, because $\displaystyle{ \pi }$ is a permutation. Thus, we can identify each $\displaystyle{ G_\pi }$ as a placement of $\displaystyle{ n }$ rooks (“城堡”，规则同中国象棋里的“车”) without attacking each other.

For example, the following is the $\displaystyle{ G_\pi }$ of such $\displaystyle{ \pi }$ that $\displaystyle{ \pi(i)=i }$.

 a b c d e f g h 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1 a b c d e f g h

Now define

\displaystyle{ \begin{align} N_0 &= \left|\left\{\pi\mid B\cap G_\pi=\emptyset\right\}\right|\\ r_k &= \mbox{number of }k\mbox{-subsets of }B\mbox{ such that no two elements have a common coordinate}\\ &=\left|\left\{S\in{B\choose k} \,\bigg|\, \forall (i_1,j_1),(i_2,j_2)\in S, i_1\neq i_2, j_1\neq j_2 \right\}\right| \end{align} }

Interpreted in chess game,

• $\displaystyle{ B }$: a set of marked positions in an $\displaystyle{ [n]\times [n] }$ chess board.
• $\displaystyle{ N_0 }$: the number of ways of placing $\displaystyle{ n }$ non-attacking rooks on the chess board such that none of these rooks lie in $\displaystyle{ B }$.
• $\displaystyle{ r_k }$: number of ways of placing $\displaystyle{ k }$ non-attacking rooks on $\displaystyle{ B }$.

Our goal is to count $\displaystyle{ N_0 }$ in terms of $\displaystyle{ r_k }$. This gives the number of permutations avoid all positions in a $\displaystyle{ B }$.

 Theorem $\displaystyle{ N_0=\sum_{k=0}^n(-1)^kr_k(n-k)! }$.
Proof.
 For each $\displaystyle{ i\in[n] }$, let $\displaystyle{ A_i=\{\pi\mid (i,\pi(i))\in B\} }$ be the set of permutations $\displaystyle{ \pi }$ whose $\displaystyle{ i }$-th position is in $\displaystyle{ B }$. $\displaystyle{ N_0 }$ is the number of permutations avoid all positions in $\displaystyle{ B }$. Thus, our goal is to count the number of permutations $\displaystyle{ \pi }$ in none of $\displaystyle{ A_i }$ for $\displaystyle{ i\in [n] }$. For each $\displaystyle{ I\subseteq [n] }$, let $\displaystyle{ A_I=\bigcap_{i\in I}A_i }$, which is the set of permutations $\displaystyle{ \pi }$ such that $\displaystyle{ (i,\pi(i))\in B }$ for all $\displaystyle{ i\in I }$. Due to the principle of inclusion-exclusion, $\displaystyle{ N_0=\sum_{I\subseteq [n]} (-1)^{|I|}|A_I|=\sum_{k=0}^n(-1)^k\sum_{I\in{[n]\choose k}}|A_I| }$. The next observation is that $\displaystyle{ \sum_{I\in{[n]\choose k}}|A_I|=r_k(n-k)! }$, because we can count both sides by first placing $\displaystyle{ k }$ non-attacking rooks on $\displaystyle{ B }$ and placing $\displaystyle{ n-k }$ additional non-attacking rooks on $\displaystyle{ [n]\times [n] }$ in $\displaystyle{ (n-k)! }$ ways. Therefore, $\displaystyle{ N_0=\sum_{k=0}^n(-1)^kr_k(n-k)! }$.
$\displaystyle{ \square }$

#### Derangement problem

We use the above general method to solve the derange problem again.

Take $\displaystyle{ B=\{(1,1),(2,2),\ldots,(n,n)\} }$ as the chess board. A derangement $\displaystyle{ \pi }$ is a placement of $\displaystyle{ n }$ non-attacking rooks such that none of them is in $\displaystyle{ B }$.

 a b c d e f g h 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1 a b c d e f g h

Clearly, the number of ways of placing $\displaystyle{ k }$ non-attacking rooks on $\displaystyle{ B }$ is $\displaystyle{ r_k={n\choose k} }$. We want to count $\displaystyle{ N_0 }$, which gives the number of ways of placing $\displaystyle{ n }$ non-attacking rooks such that none of these rooks lie in $\displaystyle{ B }$.

By the above theorem

$\displaystyle{ N_0=\sum_{k=0}^n(-1)^kr_k(n-k)!=\sum_{k=0}^n(-1)^k{n\choose k}(n-k)!=\sum_{k=0}^n(-1)^k\frac{n!}{k!}=n!\sum_{k=0}^n(-1)^k\frac{1}{k!}\approx\frac{n!}{e}. }$

#### Problème des ménages

Suppose that in a banquet, we want to seat $\displaystyle{ n }$ couples at a circular table, satisfying the following constraints:

• Men and women are in alternate places.
• No one sits next to his/her spouse.

In how many ways can this be done?

(For convenience, we assume that every seat at the table marked differently so that rotating the seats clockwise or anti-clockwise will end up with a different solution.)

First, let the $\displaystyle{ n }$ ladies find their seats. They may either sit at the odd numbered seats or even numbered seats, in either case, there are $\displaystyle{ n! }$ different orders. Thus, there are $\displaystyle{ 2(n!) }$ ways to seat the $\displaystyle{ n }$ ladies.

After sitting the wives, we label the remaining $\displaystyle{ n }$ places clockwise as $\displaystyle{ 0,1,\ldots, n-1 }$. And a seating of the $\displaystyle{ n }$ husbands is given by a permutation $\displaystyle{ \pi }$ of $\displaystyle{ [n] }$ defined as follows. Let $\displaystyle{ \pi(i) }$ be the seat of the husband of he lady sitting at the $\displaystyle{ i }$-th place.

It is easy to see that $\displaystyle{ \pi }$ satisfies that $\displaystyle{ \pi(i)\neq i }$ and $\displaystyle{ \pi(i)\not\equiv i+1\pmod n }$, and every permutation $\displaystyle{ \pi }$ with these properties gives a feasible seating of the $\displaystyle{ n }$ husbands. Thus, we only need to count the number of permutations $\displaystyle{ \pi }$ such that $\displaystyle{ \pi(i)\not\equiv i, i+1\pmod n }$.

Take $\displaystyle{ B=\{(0,0),(1,1),\ldots,(n-1,n-1), (0,1),(1,2),\ldots,(n-2,n-1),(n-1,0)\} }$ as the chess board. A permutation $\displaystyle{ \pi }$ which defines a way of seating the husbands, is a placement of $\displaystyle{ n }$ non-attacking rooks such that none of them is in $\displaystyle{ B }$.

 a b c d e f g h 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1 a b c d e f g h

We need to compute $\displaystyle{ r_k }$, the number of ways of placing $\displaystyle{ k }$ non-attacking rooks on $\displaystyle{ B }$. For our choice of $\displaystyle{ B }$, $\displaystyle{ r_k }$ is the number of ways of choosing $\displaystyle{ k }$ points, no two consecutive, from a collection of $\displaystyle{ 2n }$ points arranged in a circle.

We first see how to do this in a line.

 Lemma The number of ways of choosing $\displaystyle{ k }$ non-consecutive objects from a collection of $\displaystyle{ m }$ objects arranged in a line, is $\displaystyle{ {m-k+1\choose k} }$.
Proof.
 We draw a line of $\displaystyle{ m-k }$ black points, and then insert $\displaystyle{ k }$ red points into the $\displaystyle{ m-k+1 }$ spaces between the black points (including the beginning and end). \displaystyle{ \begin{align} &\sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \, \sqcup \\ &\qquad\qquad\qquad\quad\Downarrow\\ &\sqcup \, \bullet \,\, {\color{Red}\bullet} \, \bullet \,\, {\color{Red}\bullet} \, \bullet \, \sqcup \, \bullet \,\, {\color{Red}\bullet}\, \, \bullet \, \sqcup \, \bullet \, \sqcup \, \bullet \,\, {\color{Red}\bullet} \end{align} } This gives us a line of $\displaystyle{ m }$ points, and the red points specifies the chosen objects, which are non-consecutive. The mapping is 1-1 correspondence. There are $\displaystyle{ {m-k+1\choose k} }$ ways of placing $\displaystyle{ k }$ red points into $\displaystyle{ m-k+1 }$ spaces.
$\displaystyle{ \square }$

The problem of choosing non-consecutive objects in a circle can be reduced to the case that the objects are in a line.

 Lemma The number of ways of choosing $\displaystyle{ k }$ non-consecutive objects from a collection of $\displaystyle{ m }$ objects arranged in a circle, is $\displaystyle{ \frac{m}{m-k}{m-k\choose k} }$.
Proof.
 Let $\displaystyle{ f(m,k) }$ be the desired number; and let $\displaystyle{ g(m,k) }$ be the number of ways of choosing $\displaystyle{ k }$ non-consecutive points from $\displaystyle{ m }$ points arranged in a circle, next coloring the $\displaystyle{ k }$ points red, and then coloring one of the uncolored point blue. Clearly, $\displaystyle{ g(m,k)=(m-k)f(m,k) }$. But we can also compute $\displaystyle{ g(m,k) }$ as follows: Choose one of the $\displaystyle{ m }$ points and color it blue. This gives us $\displaystyle{ m }$ ways. Cut the circle to make a line of $\displaystyle{ m-1 }$ points by removing the blue point. Choose $\displaystyle{ k }$ non-consecutive points from the line of $\displaystyle{ m-1 }$ points and color them red. This gives $\displaystyle{ {m-k\choose k} }$ ways due to the previous lemma. Thus, $\displaystyle{ g(m,k)=m{m-k\choose k} }$. Therefore we have the desired number $\displaystyle{ f(m,k)=\frac{m}{m-k}{m-k\choose k} }$.
$\displaystyle{ \square }$

By the above lemma, we have that $\displaystyle{ r_k=\frac{2n}{2n-k}{2n-k\choose k} }$. Then apply the theorem of counting permutations with restricted positions,

$\displaystyle{ N_0=\sum_{k=0}^n(-1)^kr_k(n-k)!=\sum_{k=0}^n(-1)^k\frac{2n}{2n-k}{2n-k\choose k}(n-k)!. }$

This gives the number of ways of seating the $\displaystyle{ n }$ husbands after the ladies are seated. Recall that there are $\displaystyle{ 2n! }$ ways of seating the $\displaystyle{ n }$ ladies. Thus, the total number of ways of seating $\displaystyle{ n }$ couples as required by problème des ménages is

$\displaystyle{ 2n!\sum_{k=0}^n(-1)^k\frac{2n}{2n-k}{2n-k\choose k}(n-k)!. }$

### The Euler totient function

Two integers $\displaystyle{ m, n }$ are said to be relatively prime if their greatest common diviser $\displaystyle{ \mathrm{gcd}(m,n)=1 }$. For a positive integer $\displaystyle{ n }$, let $\displaystyle{ \phi(n) }$ be the number of positive integers from $\displaystyle{ \{1,2,\ldots,n\} }$ that are relative prime to $\displaystyle{ n }$. This function, called the Euler $\displaystyle{ \phi }$ function or the Euler totient function, is fundamental in number theory.

We know derive a formula for this function by using the principle of inclusion-exclusion.

 Theorem (The Euler totient function) Suppose $\displaystyle{ n }$ is divisible by precisely $\displaystyle{ r }$ different primes, denoted $\displaystyle{ p_1,\ldots,p_r }$. Then $\displaystyle{ \phi(n)=n\prod_{i=1}^r\left(1-\frac{1}{p_i}\right) }$.
Proof.
 Let $\displaystyle{ U=\{1,2,\ldots,n\} }$ be the universe. The number of positive integers from $\displaystyle{ U }$ which is divisible by some $\displaystyle{ p_{i_1},p_{i_2},\ldots,p_{i_s}\in\{p_1,\ldots,p_r\} }$, is $\displaystyle{ \frac{n}{p_{i_1}p_{i_2}\cdots p_{i_s}} }$. $\displaystyle{ \phi(n) }$ is the number of integers from $\displaystyle{ U }$ which is not divisible by any $\displaystyle{ p_1,\ldots,p_r }$. By principle of inclusion-exclusion, \displaystyle{ \begin{align} \phi(n) &=n+\sum_{k=1}^r(-1)^k\sum_{1\le i_1\lt i_2\lt \cdots \lt i_k\le n}\frac{n}{p_{i_1}p_{i_2}\cdots p_{i_k}}\\ &=n-\sum_{1\le i\le n}\frac{n}{p_i}+\sum_{1\le i\lt j\le n}\frac{n}{p_i p_j}-\sum_{1\le i\lt j\lt k\le n}\frac{n}{p_{i} p_{j} p_{k}}+\cdots + (-1)^r\frac{n}{p_{1}p_{2}\cdots p_{r}}\\ &=n\left(1-\sum_{1\le i\le n}\frac{1}{p_i}+\sum_{1\le i\lt j\le n}\frac{1}{p_i p_j}-\sum_{1\le i\lt j\lt k\le n}\frac{1}{p_{i} p_{j} p_{k}}+\cdots + (-1)^r\frac{1}{p_{1}p_{2}\cdots p_{r}}\right)\\ &=n\prod_{i=1}^n\left(1-\frac{1}{p_i}\right). \end{align} }
$\displaystyle{ \square }$

## Reference

• Stanley, Enumerative Combinatorics, Volume 1, Chapter 2.
• van Lin and Wilson, A course in combinatorics, Chapter 10, 15.