Overview
Inclusion–exclusion makes counting possible when natural cases overlap. It replaces the demand for a disjoint classification with a different demand: know how many objects lie in each relevant intersection. The resulting cancellation is exact, rather than an approximation to the amount of overlap.
Prerequisites
Use finite sets, unions, intersections, cardinalities, and binomial coefficients. When counting objects that avoid restrictions, first choose a finite universe containing every allowed and forbidden object. Changing that universe changes the answer.
Definition and conventions
Let and let be finite sets. Write . Then
If all lie in a finite universe , the number avoiding every is
where the empty intersection means . For zero restrictions this complement formula correctly returns . Finiteness prevents expressions such as subtracting one infinite cardinality from another.
Intuition
Each object carries a list of the restrictions it meets. Inclusion–exclusion assigns positive and negative contributions to subsets of that list. Objects meeting many restrictions are not treated as independent coincidences: their complete membership pattern determines the cancellation. This explains why knowing only single-set and pairwise counts generally does not suffice when three or more sets overlap.
Examples and non-examples
Consider integers from 1 through 60 divisible by 4 or 9. There are 15 multiples of 4 and 6 multiples of 9. Their common multiples are multiples of 36, so there is exactly one. The union has elements; 40 avoid both conditions.
As a non-example of the uncorrected sum rule, take . Adding their sizes gives four, although their union has two elements. Applying inclusion–exclusion gives . Distinct indices may name identical sets; the formula still works.
Important properties
A short proof examines one object belonging to exactly of the sets. Its contribution to the union formula is
by the binomial expansion of . An object outside every set contributes zero. Summing these individual contributions proves the identity.
For derangements of positions, choose all permutations as the universe and let mean that position is fixed. Specifying fixed positions leaves permutations, giving . The empty permutation supplies the value one at .
Connections and further reading
The method links restricted counting to generating functions and to inversion on the lattice of subsets. The pointwise cancellation proof also works for indicator functions of finitely many events, followed by expectation. See Keller and Trotter, §7.2, Theorem 7.7 for the complement formulation and its inductive proof.