MathLabs
TheoremProved

Two-set inclusion–exclusion

Statement

For any two finite sets AA and BB: ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A \cup B| = |A| + |B| - |A \cap B|, where ∣A∣|A|, ∣B∣|B|, ∣A∩B∣|A \cap B|, ∣A∪B∣|A \cup B| denote the number of elements of each set.

Why is it true?

Simply adding ∣A∣|A| and ∣B∣|B| double-counts every element that is in both sets, so subtracting ∣A∩B∣|A \cap B| once corrects the overcount. This is exactly the arithmetic behind reading a two-circle Venn diagram from survey data: people who like both coffee and tea must not be counted twice when asking how many people like at least one.

Proof sketch

The key idea is to split A∪BA \cup B into three pairwise-disjoint pieces and count each piece once.

First, partition each set using the other: A=(A∖B)∪(A∩B)A = (A \setminus B) \cup (A \cap B) and B=(B∖A)∪(A∩B)B = (B \setminus A) \cup (A \cap B). In each equation the two pieces on the right are disjoint, because (A∖B)∩(A∩B)=∅(A\setminus B) \cap (A \cap B) = \varnothing (an element outside BB cannot simultaneously be inside BB) and likewise (B∖A)∩(A∩B)=∅(B\setminus A) \cap (A \cap B) = \varnothing. Since a finite set's size equals the sum of the sizes of any partition into disjoint pieces, this gives ∣A∣=∣A∖B∣+∣A∩B∣|A| = |A \setminus B| + |A \cap B| and ∣B∣=∣B∖A∣+∣A∩B∣|B| = |B \setminus A| + |A \cap B|.

Next, observe that A∪BA \cup B itself splits into three pairwise-disjoint pieces: A∪B=(A∖B)∪(B∖A)∪(A∩B)A \cup B = (A \setminus B) \cup (B \setminus A) \cup (A \cap B). Indeed A∖BA\setminus B, B∖AB\setminus A, A∩BA\cap B are pairwise disjoint (an element in A∖BA\setminus B is not in BB, hence not in A∩BA \cap B or in B∖AB \setminus A; symmetrically for the others), and their union recovers exactly the elements that are in AA or in BB. Counting this partition gives ∣A∪B∣=∣A∖B∣+∣B∖A∣+∣A∩B∣|A \cup B| = |A \setminus B| + |B \setminus A| + |A \cap B|.

Finally substitute: from ∣A∣=∣A∖B∣+∣A∩B∣|A| = |A \setminus B| + |A \cap B| we get ∣A∖B∣|A \setminus B| =∣A∣−∣A∩B∣= |A| - |A\cap B|, and from ∣B∣=∣B∖A∣+∣A∩B∣|B| = |B \setminus A| + |A \cap B| we get ∣B∖A∣|B \setminus A| =∣B∣−∣A∩B∣= |B| - |A\cap B|. Plugging both into ∣A∪B∣=∣A∖B∣+∣B∖A∣+∣A∩B∣|A \cup B| = |A \setminus B| + |B \setminus A| + |A \cap B| gives ∣A∪B∣=(∣A∣−∣A∩B∣)+(∣B∣−∣A∩B∣)+∣A∩B∣=∣A∣+∣B∣−∣A∩B∣|A \cup B| = (|A| - |A\cap B|) + (|B| - |A\cap B|) + |A\cap B| = |A| + |B| - |A\cap B|, which is exactly ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A \cup B| = |A| + |B| - |A \cap B|. This finishes the proof.

Topics that use this theorem

Step-by-step proofs

No step-by-step proof yet for this theorem.

References

  1. Paul R. Halmos (1960). Naive Set Theory
  2. Kenneth H. Rosen (2019). Discrete Mathematics and Its Applications