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 ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesSet Operations: Union, Intersection, and ComplementProof by CasesProving by Cases and ExhaustionVacuous Truth and Trivial CasesProof by Cases (Proof by Exhaustion)Mathematical InductionThe Pigeonhole PrinciplePigeonhole Principle and Its ApplicationsCounting Fundamentals and the Multiplication PrinciplePermutations and ArrangementsCombinations and SelectionsInclusion-Exclusion Principle

Longest path: 80 steps · 367 total prerequisite topics

Prerequisites (3)

Leads To (0)

No topics depend on this one yet.