Inclusion-exclusion principle Created 2026-09-24 Updated 2026-10-13
For finite sets , the cardinality of their union is
Add the individual cardinalities, subtract pairwise intersection counts, add triple intersection counts, and continue alternating. This is useful whenever one object can satisfy several conditions: a search result can match several filters, or a permutation can have several forbidden fixed points.
Among the integers from 1 to 30, let contain the multiples of 2 and the multiples of 3. Then , , and , because their common multiples are the multiples of 6. The naive sum counts those five twice; the correct union size is . The regions contain ten in alone, five in both, five in alone, and ten in neither.
Figure 1.
Subtracting overlap counts each selected integer once; a third divisibility condition requires adding the triple overlap back
. Details.
Add a third set containing the multiples of 5. Its size is 6; the three pairwise intersections have sizes ; and the triple intersection contains only 30. The inclusion-exclusion principle gives integers divisible by at least one of 2, 3, and 5.
The alternating corrections have a local explanation. An object belonging to exactly of the sets is counted times, by the binomial theorem applied to . An object in none contributes zero. Thus overlapping descriptions are repaired without requiring the sets themselves to be disjoint. For probability, the same calculation applies to event probabilities in place of cardinalities, giving the inclusion-exclusion principle for probabilities.
For a finite family, the random variable counts the events that occur. Linearity of expectation gives , while is the exact union probability. Their difference is
An outcome in exactly events contributes extra counts, weighted by its probability. This nonnegative difference vanishes exactly in equality in Boole's inequality. For two events it is , as the inclusion-exclusion principle for probabilities shows. For more events, the Bonferroni inequalities use pairwise and higher intersection information to bound the exact union probability; blindly subtracting pairwise intersections from the sum gives a lower bound, rather than a corrected upper bound.
Severe overlap can make the union bound arbitrarily pessimistic. Let all events be the same event with probability , where is an integer. A concrete model is the discrete uniform distribution on with . The exact union probability is , whereas the sum and capped bound are both one. The ratio is : adding more names for the same event does not create more ways to fail. The identity above describes the gap in the uncapped sum; capping at one can reduce that gap.