Mathematics · Introduction to Probability and Combinatorics · Fundamental Counting and Probability Models
Sum & Product Rules
Last edited 9/25/2026, 5:48:25 AM
Consider the following scenario. A meal begins with soup or salad. Soup permits three main dishes; salad permits two. Every permitted main dish can be followed by either of two desserts. How many meals are possible?
Having two differing branches after one picks a soup or salad complicates the problem slightly. Consider the case that a meal begins with soup or salad, either permits three main dishes, and has two options for dessert. Now, simply multiplying would give us the total number of options. This motivates a need to retain branch information long enough to count correctly.
The Sum Rule
Theorem (Sum Rule)
If finite sets are pairwise disjoint, then
Proof
List each set's elements once, placing 's list after the lists for .
- No element is missing. Every element of belongs to some by definition of union, so it appears in that set's list.
- No element is repeated. Disjointness means no element belongs to two different 's, so no element can appear on two different lists.
The concatenated list therefore names each element of exactly once, so its length ( the sum of the list lengths ) equals .
∎
The Product Rule
Theorem (Product Rule)
Suppose a construction has stages, indexed . For every valid prefix of length (a partial choice sequence made in stages ), there are exactly permitted choices at stage . If each completed choice sequence of length represents exactly one desired object, and each desired object has exactly one such sequence, then the number of objects is
Proof
By induction on the number of stages considered.
- Base case (). There are length-one prefixes, by hypothesis.
- Inductive step. Suppose there are prefixes of length . Each has exactly extensions to length (by hypothesis, since the count of stage- choices is the same for every prefix). The extensions of different prefixes are distinct sequences and disjoint as sets of extensions, so the sum rule gives disjoint groups of size , hence prefixes of length .
- Conclusion. Repeating step 2 for gives prefixes of length , i.e. complete choice sequences. The unique-representation hypothesis (one sequence per object, one object per sequence) turns this count of sequences into the count of objects.
The available choices may change with previous choices. Their number must be constant across all prefixes of length — the hypothesis the product rule actually needs. For example, after choosing one of four distinct symbols, there are three choices of a different second symbol; which three symbols are available depends on the first choice, but the count stays three.
No probabilities occur in this proof. A constant branching count is not an assumption of probabilistic independence.
∎
Example: Meals
We resolve the opening question: A meal begins with soup or salad. Soup permits three main dishes; salad permits two. Every permitted main dish can be followed by either of two desserts. How many meals are possible?
Match this to the Sum Rule and the Product Rule. Separate soup meals and salad meals: these two cases are disjoint (a meal has one starter) and exhaustive (soup and salad are the only starters), so the sum rule applies to their union.
Within each case, apply the product rule with two stages: main dish then dessert. Soup allows main dishes and desserts per main, giving completions. Salad allows and , giving . By the sum rule, the total is .
Here is the counting tree in text:
starter
soup -> 3 mains -> 2 desserts for each main -> 6 meals
salad -> 2 mains -> 2 desserts for each main -> 4 mealsThe optimal choice was to split where the number of options changed (soup and salad have different ) so that the product rule's constant-count hypothesis holds within each branch.
Example: Disproportionate Branches at Multiple stages
A project has a topic, a format and a review route. Topic A allows a poster with one review route or a report with three routes. Topic B allows a model with two routes. Topic C allows a poster with two routes or a report with two routes. Count complete projects, including the chosen review route.
The three topics are disjoint, exhaustive cases, so the sum rule applies to their union. Within topic A, the format branches (poster, report) are themselves disjoint sub-cases, contributing by the sum rule again. Topic B contributes . Topic C contributes . Summing the three topic totals by the sum rule gives . A single three-factor product would apply the product rule where its hypothesis fails: the number of review routes is not the same for every prefix.
Example: Codes with Repeating elements
A length-three code uses symbols , with neighboring symbols different. Match this to the product rule with stages: (any of the four symbols), (any symbol but the first, whatever the first was), (any symbol but the second, whatever the second was — it may equal the first). Each is genuinely constant across all prefixes even though which symbols are excluded depends on the prefix, so the product rule still applies: codes.
The restriction is local (only to the immediately preceding symbol). Requiring all three symbols to differ would instead make (excluding both earlier symbols) and produce codes.
Example: Cases with overlap
Count two-digit strings over having at least one zero. Counting "first digit zero" and "second digit zero" gives , but these cases are not disjoint ( belongs to both) so the sum rule does not apply directly and the naive sum overcounts twice.
A clever disjoint split does directly apply the sum rule: first digit zero (giving ), or first digit nonzero and second digit zero (giving ). These two cases share no string, so the sum rule gives .
Another method counts all strings, by the product rule with , then subtracts the with no zero, by the product rule again with (excluding at each position). Every string belongs to exactly one of "has a zero" and "has no zero," so these two cases are disjoint and their union is all strings; Now, the sum rule gives , hence , matching the direct count. This is a technique known as complementary counting, the counting analogue of Lesson 2's probability complement rule. We will discuss this further in later sections.
Info: A counting answer is not yet a probability model
The meal example has ten possible records. This does not say customers choose each one with probability . They might prefer soup, or one main dish. To convert a favorable-meal count into a probability by dividing by ten, the model must assign equal weights to complete meals. This follow's by Lesson 1's uniform-model assumption, not a consequence of the sum rule or product rule.
Whenever you multiply, name the object built at each stage and justify the number of extensions, citing the product rule. Whenever you add, state why the cases are exhaustive and disjoint, citing the sum rule. These short explanations are the proof of the count.
Exercise
For strings of length two over , consider the cases “starts with a” and “ends with a.” Do they form a partition of all strings? Explain both possible failures.
Exercise
After choosing one of five symbols, you choose a different second symbol. May the product rule use even though the available second symbols depend on the first?
Exercise
How many length-four strings over have neighboring digits different? Repetition at nonneighboring positions is allowed.
Exercise
Route A offers two morning sessions, each followed by three afternoon sessions. Route B offers one morning session followed by five afternoon sessions. A record includes route and both sessions. Count the records.
Exercise
How many length-three strings over contain at least one a? Choose a disjoint complementary count.
Exercise
A nonempty code has length one, two or three over . Codes of different lengths are distinct. How many codes are possible?
Exercise
Two buttons, red and blue, both display the same word GO. Press exactly one button. Explain the counts if the recorded outcome is the button pressed and if it is the displayed word.
Exercise
A registration form allows one of two tracks. In the first track a student chooses one of three workshops; in the second one of four. Each then chooses online or in-person attendance. Specify an outcome record and derive its count.
Exercise
A finite first-stage set is . For each , let count permitted second-stage choices. Prove that the number of complete records is . Explain when it reduces to .
Exercise
A badge has a color and a symbol. Red and green each allow five symbols, while blue allows two. Choose an efficient counting decomposition and explain why it is valid.
Exercise
For two-digit strings over containing a zero, a learner adds three strings starting with zero and three ending with zero, obtaining six. Repair the reasoning.