Discrete Mathematics — Logic & Number Theory
Counting sets — inclusion–exclusion
continues from lesson 1 — values defined earlier in the course stay live here
ELI5: to count how many things are in A or B, add the two sizes — but you double-counted the overlap, so subtract it back: |A ∪ B| = |A| + |B| − |A ∩ B|. In a class of 30, if 18 play soccer and 15 play basketball and 7 play both, how many play at least one?
= inclusion–exclusion: 26 play a sport
✓ pass subtract the 7 double-counted
Real-world hook: inclusion–exclusion deduplicates mailing lists, sizes database joins, and counts search results matching any of several tags.
Try it yourself: of 40 people, 22 like tea, 18 like coffee, and 9 like both. How many like at least one?
= ✏️ Your turn: use |A ∪ B| = |A| + |B| − |A ∩ B| with 22, 18, and 9.
✓ pass green when you subtract the overlap correctly