# Number of Set Partitions by Number of Components

## Contents

## Theorem

Let $S$ be a (finite) set whose cardinality is $n$.

Let $f \paren {n, k}$ denote the number of different ways $S$ can be partitioned into $k$ components.

Then:

- $\displaystyle f \paren {n, k} = {n \brace k}$

where $\displaystyle {n \brace k}$ denotes a Stirling number of the second kind.

## Proof

The proof proceeds by induction on $n$.

For all $n \in \Z_{\ge 0}$, let $P \paren n$ be the proposition:

- $\displaystyle f \paren {n, k} = {n \brace k}$

$P \paren {0}$ is the degenerate case:

- $\displaystyle f \paren {0, k} = \delta_{0 k} = {0 \brace k}$

That is: the empty set can be partitioned one and only one way: into $0$ subsets.

Thus $P \paren 0$ is seen to hold.

The remainder of the proof considers $n \in \Z_{> 0}$.

First we note that when $k < 1$ or $k > n$:

- $\displaystyle f \paren {n, k} = 0 = {n \brace k}$

Hence, throughout, we consider only such $k$ as $1 \le k \le n$.

We define the representative set of cardinality $n$ to be:

- $S_n := \set {1, 2, \ldots, n}$

### Basis for the Induction

$P \paren 1$ is the case $f \paren {1, 1}$.

There is exactly one way to partition $\set 1$, and that is:

- $\set {\set 1}$

Thus $P \paren 1$ is seen to hold.

This is the basis for the induction.

### Induction Hypothesis

Now it needs to be shown that, if $P \paren m$ is true, where $m \ge 1$, then it logically follows that $P \paren {m + 1}$ is true.

So this is the induction hypothesis:

- $\displaystyle f \paren {m, k} = {m \brace k}$

from which it is to be shown that:

- $\displaystyle f \paren {m + 1, k} = {m + 1 \brace k}$

### Induction Step

This is the induction step:

By definition, the number of partitions of $S_m$ into $k$ subsets is $f \paren {m, k}$.

A partition of $S_{m + 1}$ can be generated by adding element $m + 1$ into one of the existing partitions of $S_m$.

There are two ways this can be done:

- $(1): \quad$ The subset $\set {m + 1}$ may be added, in one way, to one of the partitions of $S_m$ into $k - 1$ subsets.

- $(2): \quad$ The element $m + 1$ may be added to any one of the $k$ subsets in one of the partitions of $S_m$ into $k$ subsets.

Option $(1)$ gives $1$ partition of $S_{m + 1}$ for each partition of $S_m$ into $k - 1$ subsets, that is: $f \paren {m, k - 1}$.

Option $(2)$ gives $k$ partitions of $S_{m + 1}$ for each partition of $S_m$ into $k$ subsets, that is: $k f \paren {m, k}$.

Thus:

- $f \paren {m + 1, k} = k f \paren {m, k} + f \paren {m, k - 1}$

By the induction hypothesis:

- $\displaystyle f \paren {m + 1, k} = k {m \brace k} + {m \brace k - 1}$

So by definition of Stirling numbers of the second kind:

- $\displaystyle f \paren {m + 1, k} = {m + 1 \brace k}$

So $P \paren m \implies P \paren {m + 1}$ and the result follows by the Principle of Mathematical Induction.

Therefore:

- $\displaystyle \forall n, k \in \Z_{\ge 0}: f \paren {n, k} = {n \brace k}$

$\blacksquare$

## Examples

### $4$-Sets into $2$ Subsets

A set with $4$ elements $\set {1, 2, 3, 4}$ can be partitioned into $2$ subsets in $\displaystyle {4 \brace 2} = 7$ ways:

Let $T$ be the set with $3$ elements $\set {1, 2, 3}$.

The partition of $T$ into $1$ set is:

- $\set {1, 2, 3}$

to which $\set 4$ can be added in one way to achieve:

- $\set {1, 2, 3 \mid 4}$

The partitions of $T$ into $2$ sets are:

- $\set {1, 2 \mid 3}$
- $\set {1, 3 \mid 2}$
- $\set {2, 3 \mid 1}$

to which the element $4$ can be added in $2$ ways each:

- $\set {1, 2, 4 \mid 3}$
- $\set {1, 2 \mid 3, 4}$

- $\set {1, 3, 4 \mid 2}$
- $\set {1, 3 \mid 2, 4}$

- $\set {2, 3, 4 \mid 1}$
- $\set {2, 3 \mid 1, 4}$

Thus we have a total of $7$ ways of partitioning a $4$-element set into $2$ components.

## Sources

- 1997: Donald E. Knuth:
*The Art of Computer Programming: Volume 1: Fundamental Algorithms*(3rd ed.) ... (previous) ... (next): $\S 1.2.6$: Binomial Coefficients: Exercise $64$