Inclusion–exclusion: repair overlap systematically
Derive alternating intersection counts and use them to count permutations with no fixed points.
On this page
The question for today
What you’ll understand
- Explain why pairwise subtraction alone fails for three overlapping sets.
- Apply finite inclusion–exclusion using intersection sizes.
- Derive and evaluate the derangement formula with a precise forbidden-event model.
Adding the sizes of overlapping categories counts some objects repeatedly. Subtracting the overlaps helps, but objects lying in three categories may then disappear entirely. Inclusion–exclusion corrects every multiplicity with an alternating sequence of intersections. The method is especially effective when counting objects that avoid forbidden properties, because intersections often become simple after fixing exactly which properties are required to occur. Derangements provide a clean example with a surprising answer close to one over e.
Audit one object's contribution
For two finite sets, add their sizes and subtract the intersection once. A shared object initially contributed twice and should contribute once. For three sets, an object in all three initially contributes three times, then is subtracted in each of three pairwise intersections and contributes zero. Adding the triple intersection restores its contribution to one. Tracking a single object's coefficient is more reliable than trying to memorize a pattern of signs from a diagram.
In the general finite formula, an object belonging to exactly r sets appears in every intersection chosen from those r sets. Its total coefficient is the alternating sum of the nonempty binomial coefficients from row r, which equals one. An object belonging to no set contributes zero. This proves that the formula counts the union exactly once per member. Finiteness makes every sum and intersection count unambiguous without convergence questions.
Count avoidance by declaring forbidden properties
To count objects with none of several properties, work inside a finite universe and subtract the union of the forbidden-property sets. Begin by describing an individual property and an intersection of several properties. A formula involving an intersection is useful only if it counts objects satisfying all selected requirements simultaneously. It does not mean objects satisfying exactly those requirements; other forbidden properties are still permitted within that intersection.
A derangement is a permutation of n labelled positions in which no position retains its original label. Let the ith forbidden set contain permutations fixing position i. Fixing a specified collection of j positions leaves n minus j labels to permute freely, giving n minus j factorial possibilities. There are n choose j collections of fixed positions. This uniform intersection count makes inclusion–exclusion collapse into a short sum indexed only by j.
A limiting fraction does not replace an exact count
Dividing the derangement count by n factorial gives the probability of no fixed position under a uniform random permutation. Its finite alternating sum tends to the exponential series value one over e as n grows. For a particular n, retain the finite sum when an exact answer is required. The limit does not mean fixed-position events are independent; they are dependent because fixing one position changes the available labels for every other position.
Inclusion–exclusion scales poorly when every intersection requires a separate difficult calculation, since there can be exponentially many terms. Symmetry made derangements tractable by giving all j-fold intersections the same size. In a new problem, search first for such shared structure. Also check impossible intersections explicitly: contradictory properties contribute zero rather than a guessed product. The technique handles overlap exactly, but it does not remove the need to understand the objects in each intersection.
Work it through
Four letters in four addressed envelopes
Four distinct letters are placed bijectively into four addressed envelopes. How many assignments put every letter in the wrong envelope?
There are 4! = 24 assignments. Requiring a particular letter to be correct leaves 3! = 6 arrangements, and there are four choices of that required correct letter.
Requiring a specified pair to be correct leaves 2! = 2 arrangements. There are six pairs. A specified triple leaves one arrangement, and there are four triples.
Apply alternating correction, including the assignment fixing all four: 24 − 4 × 6 + 6 × 2 − 4 × 1 + 1 = 9. Intersections may contain additional fixed letters, which is exactly why correction is needed.
Nine assignments have no correct envelope. Under uniform random assignment, their probability is 9/24 = 3/8.
The living notebook
Explore the model
Interactive lab · probability
Compare independence with forbidden-position dependence
The p and n controls model independent Bernoulli trials. Predict the zero-success bar as (1−p) raised to n. This is a useful contrast: fixed positions of a random permutation are dependent, so setting p=1/n does not produce the exact derangement probability. Compare n=4, where the true result is 3/8, with the lab's independent calculation.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA plausible marginal probability does not license multiplying dependent avoidance events.
Pause & reason
Check your understanding
Your turn
Try it yourself
Count derangements of three labels and explain why treating the three fixed-position events as independent gives the wrong probability.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Use 3! times the finite sum 1 − 1 + 1/2 − 1/6, and compare with (2/3) cubed.
Compare with the solution
The count is 6 − 6 + 3 − 1 = 2, so the exact probability is 2/6 = 1/3. An independence assumption would predict (2/3) cubed = 8/27, which differs from 1/3. Each position individually has fixed-point probability 1/3, but fixing two positions forces the third to be fixed, demonstrating dependence directly.
Keep the idea
Take it with you
- Track an individual object's multiplicity to understand the alternating signs.
- Intersections mean all selected properties hold, not exactly those properties hold.
- Derangements exploit symmetric intersection counts; their fixed-position events are dependent.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.