a repository of mathematical know-how

Counting by partitioning

Quick description

If you can partition a set X into n pieces, of sizes m_1,\ldots,m_n, then X has size m_1+\ldots+m_n. In particular, if all the pieces have the same size m, then X has size mn. These obvious facts can be surprisingly useful in calculating the size of various sets.

An equivalent statement is that, if a set X is mapped into a set Y=\{y_1,\ldots,y_n\} of size n, and each y_i has a preimage of size m_i, then X has m_1+\ldots+m_n elements. In particular, if all preimages have the same size m, then X has size mn.

The "functional" statement has a sort of dual: if you know that a set X has size mn and can find a function X\rightarrow Y such that every element of y has exactly m preimages in X, then Y has size n. Sometimes the best way to calculate the size of Y is to find a set X that is bigger but simpler in structure, map it into Y and exploit this principle.


Basic mathematical notation.

General discussion

If \Omega' is a finite set and A_1,A_2,...A_n is a partition of \Omega' with |A_i|= m, then

  • The size of \Omega' is |\Omega'|=mn.

  • The number of partitions n is given by  n = |\Omega'| /m.

  • If a set \Omega can be mapped bijectively to the collection \{A_1,A_2,...,A_n\} then |\Omega| = n = | \Omega'| / m. This is a special case of counting using a bijection.

One common way to partition a set is by defining an equivalence relation on it. Two examples below demonstrate this.

Example 1

The binomial coefficients are obtained as an application of partitioning. Let \Omega_0 be a finite set. Let \Omega be all permutations of \Omega_0 of length k. We know that (see Example 1 on this page)

 |\Omega| = \frac{n!}{(n-k)!}.

Let us call two elements of \Omega equivalent if they are permutations of each other. This is an equivalence relation on \Omega with each of its equivalence classes containing k! elements. It follows that the total number of equivalence classes is

 |\Omega|/k! = \frac{n!}{(n-k)!k!} = \binom{n}{k}.

Each equivalence class represents a subset of \Omega_0 with k elements. It follows that the number of subsets of \Omega_0 of size k is \binom{n}{k}.

Example 2

Let \Omega_0 = \{1,2,3,...,n\} and let \Omega be the set of ordered strings of length k from the alphabet \Omega_0 where the repetition of the same letter is allowed. We would like to compute |\Omega|.

Let \Omega' be the set of all possible configurations of k distinct flags on n poles, where on each pole multiple flags are allowed and the order of the flags is important. From Example 2 on this page we know that

 |\Omega'| = \frac{(n+k-1)!}{(n-1)!}.

Let us call two elements of \Omega' equivalent if they can be obtained from one another by permuting the labels of the flags. There are n flags, and therefore n! permutations of flag labels. Then each equivalence class of this relation contains n! factorial elements. Now note that each class can be represented uniquely by an element of \Omega. For example, for k=7 and n=4, (1,1,1,2,2,3,4) \in \Omega represents the equivalence class of elements of \Omega' such that there are three flags in the first pole, two flags in the second pole and one each on the third and the fourth poles. It follows that the number of ordered strings from the alphabet \{1,2,3,...,n\} of length k is

 |\Omega| = \binom{n+k-1}{k}.

Example 3

An important identity in elementary number theory is that n=\sum_{d|n}\phi(d). Here, \phi is Euler's totient function: \phi(d) is defined to be the number of integers in \{1,\ldots,d\} that are prime to d. To prove this identity, we will partition a (conveniently chosen) set of size n into pieces, argue that there is one piece for each d dividing n, and show that the piece corresponding to d has size \phi(d).

Consider the set X=\{\frac{1}{n},\frac{2}{n},\ldots,\frac{n}{n}\} of positive integer multiples of \frac{1}{n} lying in [0,1]; it is clear that X has n elements. We classify these fractions according to the denominator that appears when we reduce them to lowest terms. For example, the case n=4 would yield the following partition:

 \{\frac{1}{4},\frac{2}{4},\frac{3}{4},\frac{4}{4}\} = \{\frac{1}{1}\} \cup \{\frac{1}{2}\} \cup \{\frac{1}{4},\frac{3}{4}\}

It's clear that each such denominator is a divisor of n, and that a non-empty piece of the partition is associated with each divisor d of n, since \frac{1}{d}=\frac{n/d}{n} belongs to the piece associated with d.

Now, how many elements are in the d-piece of the partition? To answer that, we just look at the numerators of the reduced fractions: all the numerators appearing in the d-piece must be prime to d (by definition of "lowest terms") and distinct. Further, any k\leq d that is prime to d must appear as some numerator, since \frac{k}{d} is in lowest terms, lies in [0,1], and equals \frac{k\cdot(n/d)}{n}, so it belongs to X. The identity follows.


Post new comment

(Note: commenting is not possible on this snapshot.)

Before posting from this form, please consider whether it would be more appropriate to make an inline comment using the Turn commenting on link near the bottom of the window. (Simply click the link, move the cursor over the article, and click on the piece of text on which you want to comment.)