A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Inclusion-Exclusion Principle

College Depth 79 in the knowledge graph ☐ I know this ☆ Set as goal
367prerequisites beneath it
See this on the map →
The Inclusion-Exclusion Principle and CountingCombinations and Selections+1 more→
inclusion-exclusion derangements advanced-counting

Core Idea

|A₁ ∪ A₂ ∪ ... ∪ Aₙ| = Σ|Aᵢ| − Σ|Aᵢ ∩ Aⱼ| + Σ|Aᵢ ∩ Aⱼ ∩ Aₖ| − ... The principle counts elements in unions by adding individual sets, subtracting pairwise overlaps, adding triple overlaps, etc., correcting for over-counting.

How It's Best Learned

Visualize with Venn diagrams for 2 or 3 sets first. Apply to derangements (permutations with no fixed points) and other classic problems. Recognize the alternating sum pattern.

Common Misconceptions

Terms alternate in sign strictly—positive for odd-cardinality intersections, negative for even. Applying this correctly requires careful bookkeeping.

Explainer

You already know inclusion-exclusion for two or three sets: |A ∪ B| = |A| + |B| − |A ∩ B|, with the three-set version adding back the triple intersection after subtracting the three pairwise ones. The general principle extends this to any number of sets using an alternating sum that corrects for over- and under-counting in a systematic way. The formula is: add all individual set sizes, subtract all pairwise intersections, add all triple intersections, subtract all quadruple intersections, and continue alternating signs through all k-fold intersections.

The reason the alternating sum works is that every element in the union gets counted exactly once. An element appearing in exactly k of the sets is counted in C(k,1) single-set terms, subtracted in C(k,2) pairwise terms, added back in C(k,3) triple terms, and so on. The total contribution is C(k,1) − C(k,2) + C(k,3) − ... which equals 1 for every k ≥ 1, by a direct application of the binomial theorem to (1−1)k. The alternating-sign structure is not arbitrary — it is precisely what keeps every element counted once regardless of how many sets it belongs to.

The most elegant application is derangements — permutations of n elements where no element lands in its original position. Let Aᵢ be the set of permutations that fix element i. Derangements are the permutations outside every Aᵢ. Inclusion-exclusion on A₁ ∪ ... ∪ Aₙ counts permutations where "at least one element is fixed"; subtracting from n! gives the derangement count D(n) = n!(1 − 1/1! + 1/2! − 1/3! + ... ± 1/n!). This formula has a remarkable consequence: as n grows, D(n)/n! approaches e⁻¹ ≈ 0.368, so roughly 37% of all permutations are derangements regardless of how large n is.

The key skill is bookkeeping, especially when the sets are not symmetric. For n arbitrary sets there are 2ⁿ − 1 intersection terms to consider. When the problem has symmetry — meaning every k-fold intersection has the same size regardless of which k sets you pick — the formula collapses to a much simpler sum weighted by C(n,k). This symmetric structure appears in derangements, counting integers in [1,n] not divisible by any prime from a given list, and many other problems. Recognizing this symmetry and exploiting it is the difference between a tractable calculation and an enormous bookkeeping nightmare.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Set Operations: Union, Intersection, and Complement → Proof by Cases → Proving by Cases and Exhaustion → Vacuous Truth and Trivial Cases → Proof by Cases (Proof by Exhaustion) → Mathematical Induction → The Pigeonhole Principle → Pigeonhole Principle and Its Applications → Counting Fundamentals and the Multiplication Principle → Permutations and Arrangements → Combinations and Selections → Inclusion-Exclusion Principle

Longest path: 80 steps · 367 total prerequisite topics

Prerequisites (3)

Leads To (0)

No topics depend on this one yet.