Inclusion–Exclusion
Applied Combinatorics (CC BY-SA) · appliedcombinatorics.org
To count a union of overlapping sets, add the sizes, subtract the pairwise overlaps, add back the triples, and alternate. Inclusion–exclusion corrects for the double-counting at every level. Its most famous output is the derangement: permutations that fix nothing.
Alternating correction
Singletons overcount the overlaps, so you subtract pairwise intersections; but now the triple is subtracted too many times, so you add it back. The signs alternate by the size of the intersecting group.
Derangements
How many permutations of n items leave nothing in place? Apply inclusion–exclusion over the "item i is fixed" events: D(n) = n!·(1 − 1/1! + 1/2! − … ± 1/n!). The ratio D(n)/n! converges to 1/e fast.
Scheme
Neighbors
- 🎲 Probability — inclusion–exclusion is the union bound made exact
- 🧮 Ch.5 Generating Functions — derangements have a clean exponential generating function