Skip to content
Part IA Easter Term

Inclusion-Exclusion Principle

The Problem with Unions

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

Two-Event Inclusion-Exclusion

P(E∪F)=P(E)+P(F)−P(E∩F)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(E∪F)=1352+452−152=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(E∪F∪G)=P(E)+P(F)+P(G)−P(E∩F)−P(E∩G)−P(F∩G)+P(E∩F∩G)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 E∩F∩GE \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(E∩F∩G)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+1∑1≤i1<i2<⋯<ik≤nP(Ei1∩Ei2∩⋯∩Eik)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)(n−k)!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(Ei∩Ej)=(n−2)!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) =(n−k)!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 n→∞n \to \infty, this approaches 1−e−1≈0.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)=1−P(⋂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)=1−∏i=1n(1−P(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)=1−P(all work)=1−0.93=1−0.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+1∑1≤i1<⋯<ik≤n∣Ai1∩⋯∩Aik∣|\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
  • ∣A∩B∣|A \cap B| = multiples of 6: ⌊1000/6⌋=166\lfloor 1000/6 \rfloor = 166

∣A∪B∣=500+333−166=667|A \cup B| = 500 + 333 - 166 = 667

Bonferroni Inequalities

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

P(E1∪⋯∪En)≤∑iP(Ei)P(E_1 \cup \cdots \cup E_n) \leq \sum_{i} P(E_i) P(E1∪⋯∪En)≥∑iP(Ei)−∑i<jP(Ei∩Ej)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(E∩F)P(E) + P(F) - P(E \cap F)
3 eventsP(E)+P(F)+P(G)−P(E∩F)−P(E∩G)−P(F∩G)+P(E∩F∩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)
nn events∑k=1n(−1)k+1∑i1<⋯<ikP(Ei1∩⋯∩Eik)\sum_{k=1}^{n} (-1)^{k+1} \sum_{i_1 < \cdots < i_k} P(E_{i_1} \cap \cdots \cap E_{i_k})
Complement1−P(⋂Eic)1 - P(\bigcap E_i^c)