Inclusion-Exclusion Principle
One-line statement: The size of a union of finite sets equals the alternating sum of the sizes of all possible intersections of those sets. Key result in words: Add the sizes of individual sets, subtract pairwise overlaps, add back triple overlaps, and so on, alternating signs, to count a union without double-counting. Where it applies: Combinatorics, probability, number theory (the Euler Totient Function and Sieve Methods), and counting problems with overlapping conditions. Who/when: Formalized by Abraham de Moivre (1718) and named after work by J. J. Sylvester and Henri Poincaré in the 19th century.
When you count elements belonging to at least one of several sets, an element lying in of them is counted times if you simply add the individual set sizes. The fix is systematic correction by overlaps: subtract every pairwise intersection, which over-corrects elements in three or more sets, then add back triple intersections, and continue. The miracle is that the coefficients work out so that an element in exactly sets is counted with net multiplicity , regardless of . The entire principle is the combinatorial identity in disguise.
Formal Statement
Let be finite sets. For a nonempty subset of indices, write
Derivation hint: is the set of elements common to all sets whose indices appear in ; by convention is the universal set . The quantity depends only on which sets are intersected, and the principle expresses in terms of all these intersection sizes.
For finite sets ,
Derivation hint: group terms by the size of the index subset; each size contributes a sum over all intersections of sets, with sign . Equivalently, expanding by intersection size:
Derivation hint: this is [2] with the index subsets sorted by their cardinality ; inner sum ranges over strictly increasing index tuples. The first few terms read , where is the sum of all -fold intersection sizes.
Equivalently, counting elements in none of the sets within a universe of size :
Derivation hint: subtract equation [2] from and absorb the term as the contribution where contributes . This form is the one used in sieve arguments: encodes "having property ," and the left side counts objects with no listed property.
Why It Holds / Derivation
We prove equation [2] by showing each element of the union contributes exactly to both sides.
Step 1 — Fix an element. Let , and let be the number of sets containing . The left side of [2] counts exactly once.
Step 2 — Count 's contributions on the right. An intersection contains if and only if is a subset of the indices whose sets contain . The number of such index sets of size is .
Step 3 — Sum the signed contributions. Element contributes to the right side
Derivation hint: each (sets containing ) of size adds ; there are of them.
Step 4 — Evaluate via the binomial theorem. Since for , we isolate the term:
Derivation hint: factor out the sign and use that the full alternating binomial sum vanishes; the missing term equals .
Step 5 — Conclude. Each in the union contributes exactly to both sides, so the totals are equal. Elements outside the union contribute to both sides.
∎Base case : , since elements in the overlap are added twice and removed once.
Inductive step. Assume [2] holds for sets. Write . Then
Derivation hint: apply the two-set rule with as the first set. Now , so apply the inductive hypothesis to both and ; collecting terms reproduces [2] for sets, with each -fold intersection appearing exactly once with the correct sign.
∎A French-born Huguenot mathematician who fled to England after the revocation of the Edict of Nantes, de Moivre worked largely as a private tutor and consultant on games of chance. In his 1718 The Doctrine of Chances, he gave an early systematic treatment of the inclusion–exclusion formula in the context of probability problems — notably the "problème des rencontres" (the matching/derangement problem). His work tied the combinatorial identity to practical questions of dice, lotteries, and annuities. The principle's later refinement and naming owe much to J. J. Sylvester and Henri Poincaré, but de Moivre's recognition that overcounting must be corrected by alternating subtraction is the historical seed.
Building Intuition
Imagine three overlapping circular spotlights on a stage, lighting up actors. If you ask each operator "how many actors does your beam touch?" and add the three numbers, an actor standing where two beams overlap gets counted twice, and one in the central three-way overlap gets counted three times. To find how many actors are lit at all, you subtract the pairwise-overlap counts — but this removes the central actor one time too many (counted , subtracted , leaving ). So you add back the triple overlap, restoring her to a single count. The alternating add/subtract pattern is precisely the bookkeeping needed so every lit actor ends up counted exactly once, no matter how many beams reach her.
Worked Examples
Given: Count integers with divisible by , , or . Let = multiples of 2, = multiples of 3, = multiples of 5, within .
Step 1 — Single counts (): , , . So .
Step 2 — Pairwise counts (): , , . So .
Step 3 — Triple count (): .
Step 4 — Apply [3]: .
(As a check, the number coprime to 30 in this range, via [4], is .)
Given: Count permutations of with no fixed point (no element maps to itself) — these are derangements. Let = permutations fixing position . We want permutations in none of the , so use complementary form [4] with .
Step 1 — Intersection sizes. A permutation fixing a chosen set of positions permutes the remaining freely, giving permutations. There are ways to choose which positions are fixed.
Step 2 — Build the alternating sum (from [4]):
Step 3 — Evaluate term by term:
- :
- :
- :
- :
- :
Step 4 — Sum: .
This matches the closed form , giving .
Common Misconceptions
Three frequent errors: 1. Forgetting to add back the triple overlap. Subtracting all pairwise intersections over-removes elements in three or more sets; the principle is not "add singles, subtract pairs" — it continues with alternating signs all the way to the -fold intersection. 2. Mixing up (union form [2]) with (complement form [4]). The sign on the leading single-set term is for the union but the term carries no negative in the complement form. 3. Assuming intersection sizes are products. is false in general for cardinalities; it holds for probabilities only under independence. For counting, you must determine each intersection size directly.
Take , a single shared element. Then . If you (incorrectly) used only "singles minus pairs":
The element , counted times then subtracted times, vanishes. Only by adding back do we recover the correct . This shows the full alternating sum is essential — truncating it gives the wrong answer.
Connections
Inclusion–exclusion is a special case of Möbius inversion on the Boolean lattice of subsets, where the alternating signs are exactly the Möbius function values; see Mobius Inversion Formula. In probability it becomes the formula , foundational in Probability Theory. Its number-theoretic incarnation is the Sieve of Eratosthenes and the formula for the Euler Totient Function . The Bonferroni inequalities arise from truncating the alternating sum, giving alternating upper and lower bounds. Topologically, the same alternating structure governs the additivity of the Euler Characteristic under unions of cells.
Real-World Applications
Historical Development
Subtleties & Limits
Inclusion–exclusion is exact for finitely many sets, but practically it can require summing terms, which is computationally infeasible for large — exact application is #P-hard for general systems (e.g., reliability polynomials). This motivates sieve theory's central tension: how to extract good bounds from truncated or weighted versions of the alternating sum. The Bonferroni inequalities give crude bounds; the deeper achievements of Brun's sieve, the Selberg sieve, and the large sieve replace the rigid signs of pure inclusion–exclusion with optimized weights to tame error terms. The famous "parity problem" of sieve theory — the inability of classical sieves to distinguish numbers with an even versus odd number of prime factors — is fundamentally a limitation on how much the inclusion–exclusion structure can detect, and remains a guiding obstacle in attacks on problems like the twin prime conjecture and Goldbach's conjecture.
See Also
Mobius Inversion Formula · Sieve Methods · Euler Totient Function · Derangements · Probability Theory · Binomial Coefficients · Euler Characteristic · Sieve of Eratosthenes