4.9.2 · D3Probability Theory & Statistics

Worked examples — Inclusion-exclusion principle

2,492 words11 min readBack to topic

Before anything, one reminder of the only rule we use, in words:


The scenario matrix

Every inclusion–exclusion problem you will ever meet is one of these cells. The right column names the example that nails it.

# Case class What makes it tricky Nailed by
C1 2 sets, generic overlap remember to subtract once Ex 1
C2 2 sets, disjoint () overlap term is zero Ex 2
C3 2 sets, one inside the other () union collapses to the big set Ex 2
C4 3 sets, full formula the "+triple" restoration Ex 3
C5 Complement trick ("none of them" / "at least one") count the opposite, subtract from total Ex 4
C6 Probability version (measures, not counts) divide by universe / use Ex 5
C7 Degenerate: all sets equal union = any one of them Ex 6
C8 Limiting behaviour (derangement ratio as ) infinite sign-alternating sum Ex 7
C9 Exam twist: "exactly " not "at least one" different coefficients Ex 8
C10 4 sets, real-world word problem four-way sign bookkeeping Ex 9

Ex 1 — C1: two sets, generic overlap

Steps.

  1. Name the sets. = French-studiers, ; = German, ; . Why this step? Inclusion–exclusion needs the overlap size named explicitly — it's the whole point.
  2. Add the singles: . Why this step? This counts each "both" student twice, so it's too big.
  3. Subtract the overlap once: . Why this step? The both-students were counted twice; subtracting counts them once.

Verify: partition into disjoint pieces — only French , only German , both . Sum . ✓ And , so it fits in the class. ✓


Ex 2 — C2 & C3: disjoint sets, and one set inside another

Steps for (a) — the disjoint case C2.

  1. Disjoint means , so . Why this step? The general formula still applies — a zero overlap is just a special value.
  2. .

Verify (a): with no overlap there's nothing double-counted, so plain addition is already correct. . ✓

Steps for (b) — the nested case C3.

  1. means every chess-player is already in the games club, so and . Why this step? The overlap is the smaller set when one set sits inside the other.
  2. .

Verify (b): the union is just the bigger set , so it should equal . ✓ The formula did not give the naive — because the chess players are not new people.


Ex 3 — C4: three sets, full formula (with figure)

Look at the figure: the centre region (all three) sits inside every pairwise lens.

Figure — Inclusion-exclusion principle

Steps.

  1. Add singles: . Why this step? Anyone in two drinks counted twice; anyone in all three counted three times.
  2. Subtract pairs: , giving . Why this step? This fixes the double-counted pair-only people, but over-erases the all-three group.
  3. Track the all-three group of : added times in step 1, subtracted times in step 2 → net . That's wrong; we want . Why this step? This is exactly why the triple exists — see the dark centre in the figure.
  4. Add back the triple: .

Verify: "none" . Also decompose into 7 disjoint Venn regions and sum: only-T , only-C , only-J , T∩C-only , T∩J-only , C∩J-only , all-three . Total . ✓


Ex 4 — C5: the complement trick ("at least one" via "none")

Why a new tool here: counting "divisible by or or " directly is inclusion–exclusion — but this problem also teaches the complement idea used in Ex 7. We do it directly first.

Steps.

  1. Singles — count multiples up to . , , . Why this step? = how many multiples of are (every -th number). means "==round down to a whole number=="
  2. Pairs — divisible by both and means divisible by . ; ; . Why this step? "divisible by 2 and 3" is the intersection, and lcm is the smallest number both divide.
  3. Triple — .
  4. Assemble with alternating signs:

Verify (complement): count divisible by none of — i.e. coprime-ish survivors . Sanity: exactly divisible by none should be a handful of numbers like ; is plausible. Direct union . ✓


Ex 5 — C6: probability version

Why probability not counts: dividing every count by the universe size turns the same formula into probabilities — the additivity is identical.

Steps.

  1. (13 hearts). (12 face cards). Why this step? Probability of an equally-likely event favourable total.
  2. Overlap: face-card hearts are J♥, Q♥, K♥, so , . Why this step? = cards that are both heart and face.
  3. Inclusion–exclusion for probability:

Verify: count the union directly — hearts (13) plus non-heart face cards () cards, . Bigger than as expected (we added face cards). ✓ It's a valid probability, . ✓


Ex 6 — C7: the fully degenerate case (all sets equal)

Steps.

  1. Every set has elements, and every intersection (pair or triple) is also the whole set, size . Why this step? When sets coincide, all overlaps collapse to that one set.
  2. Apply the 3-set formula:

Verify: the union of three identical sets is just that set, size . The formula gives . ✓ This is the general "element in sets counted exactly once" identity in action: , so each of the elements nets . ✓


Ex 7 — C8: limiting behaviour (derangements as )

Why inclusion–exclusion: "at least one letter correct" is a union of events "letter correct"; the complement is "none correct".

Steps.

  1. Let = permutations fixing position . , a -fold intersection fixes chosen spots: , chosen ways. Why this step? Fixing letters correctly leaves arrangements of the rest.
  2. "At least one fixed" . Subtract from to get "none fixed": Why this step? , pulling out .
  3. For : . Probability .
  4. Limit: (the exponential series at ). So . Why this step? evaluated at ; the sign-alternating I–E terms are exactly this series.

Verify: (matches parent note). , and — already very close at . ✓ The "no match" chance does not vanish; it settles near .


Ex 8 — C9: the exam twist ("exactly one", not "at least one")

Why different coefficients: "exactly one" needs a formula that cancels out multi-membership, giving different multipliers than the union.

Steps.

  1. Use the disjoint-region decomposition from Ex 3's Verify: only-T , only-C , only-J . Why this step? "Exactly one drink" = sum of the three single-only regions.
  2. Add them: .
  3. Cross-check with the coefficient formula: Why this step? An element in exactly sets must net : ; in all : . Only single-membership survives with coefficient .

Verify: both methods give . Also: exactly-two total , exactly-three , none ; . ✓


Ex 9 — C10: four sets, real-world word problem

Steps.

  1. Add singles (): . Why this step? , sign .
  2. Subtract all pairs (): , giving . Why this step? , sign ; fixes double-counting.
  3. Add all triples (): , giving . Why this step? , sign ; restores triple-erased people.
  4. Subtract the single quadruple (): . Why this step? , sign ; the all-four person was over-added by the triples.

Verify: answer team size, so people know none — plausible. Track the all-four person: added (singles) (pairs) (triples) (quad) . Counted exactly once. ✓


Recall Which cell was which?

C1 generic 2-set (Ex1) ::: subtract the overlap once C2 disjoint / C3 nested (Ex2) ::: overlap is or is the smaller set C4 three sets (Ex3) ::: add the triple back C5 complement (Ex4) ::: "none" total union C6 probability (Ex5) ::: same formula with C7 all equal (Ex6) ::: union any one set C8 limit (Ex7) ::: C9 exactly-one (Ex8) ::: coefficients C10 four sets (Ex9) ::: signs


Connections

  • Inclusion-exclusion principle — the parent: the formula these examples exercise
  • Set Theory & Venn Diagrams — the disjoint-region decomposition used in Ex 3 & 8
  • Counting Principles & Combinatorics counts of intersections in Ex 7 & 9
  • Probability Axioms — Ex 5's probability form is additivity plus overlap correction
  • Derangements & Permutations — Ex 7 is the classic derangement payoff
  • Binomial Theorem limit in Ex 7
  • Bonferroni Inequalities — truncating these alternating sums gives bounds