Skip to content
Part IA Easter Term

Inclusion-Exclusion Principle

The Problem with Unions

When computing P(EF)P(E \cup F), we cannot simply add P(E)+P(F)P(E) + P(F) because outcomes in EFE \cap F get counted twice.

Two-Event Inclusion-Exclusion

P(EF)=P(E)+P(F)P(EF)P(E \cup F) = P(E) + P(F) - P(E \cap F)

Intuition: Add probabilities of each event, then subtract the intersection to correct for double-counting.

Example: Cards

Draw a card. Let EE = “heart” and FF = “ace”.

P(EF)=1352+452152=1652=413P(E \cup F) = \frac{13}{52} + \frac{4}{52} - \frac{1}{52} = \frac{16}{52} = \frac{4}{13}

Verify directly: 13 hearts + 3 other aces = 16 cards out of 52.

Three-Event Inclusion-Exclusion

P(EFG)=P(E)+P(F)+P(G)P(EF)P(EG)P(FG)+P(EFG)P(E \cup F \cup G) = P(E) + P(F) + P(G) - P(E \cap F) - P(E \cap G) - P(F \cap G) + P(E \cap F \cap G)

Pattern: Add singletons, subtract pairs, add triples. The signs alternate.

Inclusion-exclusion for three events

Why Add the Triple?

Each element in EFGE \cap F \cap G:

  • Counted 3 times in singletons (+3)
  • Counted 3 times in pairs (−3)
  • Not yet counted in triples (+0)

We need +1 total, so add P(EFG)P(E \cap F \cap G).

General Formula

For nn events E1,E2,,EnE_1, E_2, \ldots, E_n:

P(i=1nEi)=k=1n(1)k+11i1<i2<<iknP(Ei1Ei2Eik)P\left(\bigcup_{i=1}^{n} E_i\right) = \sum_{k=1}^{n} (-1)^{k+1} \sum_{1 \leq i_1 < i_2 < \cdots < i_k \leq n} P(E_{i_1} \cap E_{i_2} \cap \cdots \cap E_{i_k})

In words: sum probabilities of kk-fold intersections with sign (1)k+1(-1)^{k+1}.

Example: Hat Check Problem

nn people throw their hats into a pile. Each picks a hat randomly. What is the probability at least one person gets their own hat?

Let EiE_i = person ii gets their own hat.

P(i=1nEi)=k=1n(1)k+1(nk)(nk)!n!P\left(\bigcup_{i=1}^{n} E_i\right) = \sum_{k=1}^{n} (-1)^{k+1} \binom{n}{k} \frac{(n-k)!}{n!}

  • P(Ei)=1nP(E_i) = \frac{1}{n} for each of (n1)\binom{n}{1} choices
  • P(EiEj)=(n2)!n!P(E_i \cap E_j) = \frac{(n-2)!}{n!} for (n2)\binom{n}{2} pairs
  • Generally: PP(kk specific people get their hats) =(nk)!n!= \frac{(n-k)!}{n!}

This gives:

P(at least one match)=k=1n(1)k+11k!P(\text{at least one match}) = \sum_{k=1}^{n} (-1)^{k+1} \frac{1}{k!}

As nn \to \infty, this approaches 1e10.6321 - e^{-1} \approx 0.632.

The Complement View

For complex unions, computing P(none)P(\text{none}) via complement is often easier.

P(i=1nEi)=1P(i=1nEic)P\left(\bigcup_{i=1}^{n} E_i\right) = 1 - P\left(\bigcap_{i=1}^{n} E_i^c\right)

When events are independent: P(all fail)=P(Eic)P(\text{all fail}) = \prod P(E_i^c), giving:

P(at least one)=1i=1n(1P(Ei))P(\text{at least one}) = 1 - \prod_{i=1}^{n}(1 - P(E_i))

Example: Reliability

A system has 3 components, each failing independently with probability 0.1. What is the probability the system fails (at least one component fails)?

P(system fails)=1P(all work)=10.93=10.729=0.271P(\text{system fails}) = 1 - P(\text{all work}) = 1 - 0.9^3 = 1 - 0.729 = 0.271

Inclusion-Exclusion for Counting

The principle applies to counting, not just probability:

i=1nAi=k=1n(1)k+11i1<<iknAi1Aik|\bigcup_{i=1}^{n} A_i| = \sum_{k=1}^{n} (-1)^{k+1} \sum_{1 \leq i_1 < \cdots < i_k \leq n} |A_{i_1} \cap \cdots \cap A_{i_k}|

Example: Integer Properties

How many integers from 1 to 1000 are divisible by 2 or 3?

Let AA = multiples of 2, BB = multiples of 3.

  • A=1000/2=500|A| = \lfloor 1000/2 \rfloor = 500
  • B=1000/3=333|B| = \lfloor 1000/3 \rfloor = 333
  • AB|A \cap B| = multiples of 6: 1000/6=166\lfloor 1000/6 \rfloor = 166

AB=500+333166=667|A \cup B| = 500 + 333 - 166 = 667

Bonferroni Inequalities

The partial sums in inclusion-exclusion alternate between over- and under-estimates:

P(E1En)iP(Ei)P(E_1 \cup \cdots \cup E_n) \leq \sum_{i} P(E_i) P(E1En)iP(Ei)i<jP(EiEj)P(E_1 \cup \cdots \cup E_n) \geq \sum_{i} P(E_i) - \sum_{i<j} P(E_i \cap E_j)

These provide upper and lower bounds when exact computation is impractical.

Summary

EventsFormula
2 eventsP(E)+P(F)P(EF)P(E) + P(F) - P(E \cap F)
3 eventsP(E)+P(F)+P(G)P(EF)P(EG)P(FG)+P(EFG)P(E)+P(F)+P(G) - P(E \cap F) - P(E \cap G) - P(F \cap G) + P(E \cap F \cap G)
nn eventsk=1n(1)k+1i1<<ikP(Ei1Eik)\sum_{k=1}^{n} (-1)^{k+1} \sum_{i_1 < \cdots < i_k} P(E_{i_1} \cap \cdots \cap E_{i_k})
Complement1P(Eic)1 - P(\bigcap E_i^c)