Suppose we want to compute the size of a set of elements that are constructed by some process. At each step of the process, we can chose from among several options. Suppose that the number of available options is the same regardless of the choices made earlier in the process. Then we can find the size of the set by multiplying together the number of choices.
Example: Suppose we want to count the number of ways to arrange the letters "BAR". We first choose the first letter. There are 3 possibilities. We then choose the second letter; there are only two to choose from. Finally, we choose the third letter; there is only one choice remaining. The number of strings is therefore \(3 \cdot 2 \cdot 1 = 3!\).
Example: Suppose we want to count the number of subsets of \(\{1,2,3,4,5\}\). We can construct a subset by first choosing whether or not to include \(1\) (There are two choices), then whether or not to inlcude 2 (2 choices), whether or not to include 3 (2 choices) and so on. Thus there are \(2 \cdot 2 \cdots 2 = 2^5\) possible subsets.
Example: \(|A \times B| = |A||B|\).
Example: Suppose we want to count the number of 4-element strings formed from the 7 characters MICHAEL. There are 7 choices for the first, 6 for the second, 5 for the third, and 4 for the fourth, so there are \(7 \cdot 6 \cdot 5 \cdot 4\) such strings. A compact way to write this is \(7!/3!\).
Why is this justified? Each time we make a choice among \(k\) options while constructing an element of the set \(X\), we are subdividing \(X\) into disjoint subsets: those elements of \(X\) where we chose option 1, those where we chose option 2, and so on. Because future choices don't depend on the choices we made, each subset has the same size (say \(n\)), so we can use the sum rule to find the total size of \(X\); \(X\) is the union of \(k\) subsets of size \(n\), so \(|X| = n + n + n + \cdots + n = kn\).
Note that this requires that the subsets are disjoint; if making two different choices could potentially yield the same element \(x\) of \(X\), then we will be double counting \(x\); in this case the product rule will give the wrong answer.
Suppose we don't care about some of the structure of the elements of \(X\). For example, suppose we want to count the rearrangements of the string \(FOO\). We could start by counting all of the rearrangements of \(FO_1O_2\), but we would be overcounting: we want to consider \(FO_1O_2\) to be the same as \(FO_2O_1\).
What we really want to count is not strings, but equivalence classes of strings. We have an equivalence relation on strings: \(x \sim y\) if we can rearrange the O's of \(x\) to form \(y\). Under this relation, \(FO_1O_2 \sim FO_2O_1\); and we want to count this equivalence class as a single element.
Each equivalence class has 2 strings in it, because we can swap the two O's. Thus we have 6 strings total, divided up into equivalence classes; each class has two elements, so the total number of equivalence classes is 6/2.
In general, we have the division rule: if \(R\) is an equivalence relation on \(A\), and every equivalence class of \(R\) has \(k\) elements, then \(|A/R| = |A|/k\).
Example: Suppose we want to count the number of ways to rearrange the string \(MISSISSIPPI\) (one M, 2 P's, 4 I's, and 4 S's). We can start by finding the number of ways of rearranging the string \(MI_1S_1S_2I_2S_3S_4I_3P_1P_2I_4\). We can then consider two of these strings equal if we can rearrange the subscripts.
There are 11 characters total, so there are 11! ways to rearrange the string. We then want to mod out by the relation given by \(x \sim y\) if we can rearrange the O's, the I's, the P's, and the S's
How many elements are in each equivalence class? This is the same as asking, if I give you a string, how many other strings are equivalent to it? We can use the product rule to count them: to find an equivalent string, first choose one of the 4! permutations of the I's. Then, choose one of the 4! permutations of the S's. Then, chose one of the 2! permutations of the P's. If you want, you can choose one of the 1! permutations of the M's. Applying these permutations to your string yields an equivalent string. Thus, there are \(4!4!2!1!\) elements of each equivalence class.
Thus, the total number of equivalence classes is \(\frac{11!}{4!4!2!1!}\); this is the total number of ways to rearrange the string MISSISSIPPI.
We can use the product and division rules to count the number of ways to choose \(k\) elements from a set of \(n\) elements (where we don't care about the order).
We start by choosing a string of \(k\) distinct elements. To construct a string, we have \(n\) choices for the first element, \((n-1)\) choices for the second, \((n-2)\) for the third, up to \((n-k+1)\) choices for the \(k\)th. Thus there are
\[ n(n-1)\cdots(n-k+1) = n(n-1)\cdots(n-k+1) \frac{(n-k)(n-k-1)\cdots 2 \cdot 1}{(n-k)(n-k-1)\cdots 2 \cdot 1} = \frac{n!}{(n-k)!} \]
strings of length \(k\). We don't care about the order though, so we want to consider two strings to be equivalent if we can rearrange one into the other. There are \(k\) characters in the string, so each string is equivalent to the \(k!\) permutations of itself. Thus each equivalence class has \(k!\) elements, so the number of equivalence classes is \(n!/(n-k)!k!\).
This number is so useful that it has it's own notation: \(n \choose k\), (read "\(n\) choose \(k\)") is defined as \({n \choose k} = n!/(n-k)!k!\), and is the number of ways of choosing a \(k\)-element subset of a set with \(n\) elements.
Sometimes the division rule is hard to apply because the equivalence classes all have different sizes (or the multiplication rule is hard to apply, because different choices lead to different numbers of future choices).
In these cases, you can sometimes divide the set to be counted up into subsets that are individually easy to count, and then use the sum rule to recombine them.
Example: How many ways are there to choose a collection of 3 characters from CHANNEL? We could try using the division rule as above: first choose a 3 element sequence, then consider two strings equivalent if we can swap the two N's, then divide by the number of elements of each equivalence class.
But this doesn't work, because some equivalence classes have different numbers of elements than others. For example, \([CHAN]\) has \(4!\) elements, but \([ANNE]\) has fewer: of the \(4!\) permutations of \(ANNE\), \(2!\) of them are the same, so \([ANNE]\) has \(4!/2!\) elements. Since the different equivalence classes have different numbers of elements, we don't know what to divide by.
But if we break the set of equivalence classes into those containing 2 N's, those containing 1 N, and those containing no N's, we can use the division rule for each of those subsets, then add them together using the sum rule.
To construct a collection of 4 characters containing 2 N's, we first take the two N's, then we choose any two of the remaining 5 characters; there are \(5 \choose 2\) ways to do this. To construct a collection of 4 characters containing 1 N, we first take one N and throw out the other; we must then choose 3 of the remaining 5 characters. Finally, to choose a set of four characters with no N's, we simply choose four characters out of the 5 available non-N characters. There are \(5 \choose 4\) ways to do that.
Thus in total, there are \({5 \choose 2} + {5 \choose 3} + {5 \choose 4}\) ways to construct a collection of 4 characters from \(CHANNEL\).