Skip to content

Set theory and inclusion-exclusion

5 min read

Short answer

For two sets, ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A\cup B|=|A|+|B|-|A\cap B|: adding the sizes counts the overlap twice, so subtract it once. For three sets add the pair overlaps back as −∣A∩B∣−∣A∩C∣−∣B∩C∣-|A\cap B|-|A\cap C|-|B\cap C| and then +∣A∩B∩C∣+|A\cap B\cap C|.

Bar chartMath onlyBothPhysics onlyNeither100 students: 60 take math, 45 take physics, 20 take both.
Split the groups into non-overlapping parts before adding.

Set vocabulary

A∪BA\cup B is everything in AA or BB; A∩BA\cap B is what they share; AcA^c is everything outside AA; A∖BA\setminus B is AA without BB. De Morgan: (A∪B)c=Ac∩Bc(A\cup B)^c=A^c\cap B^c.

Why the formula works

Every element of the overlap is counted once in ∣A∣|A| and once in ∣B∣|B|. Subtracting ∣A∩B∣|A\cap B| once leaves it counted exactly once, as it should be.

Worked example

Of 100100 students, 6060 take math, 4545 take physics and 2020 take both. How many take at least one, and how many take neither?

∣M∪P∣=60+45−20=85|M\cup P|=60+45-20=85 take at least one. Neither: 100−85=15100-85=15. Check by parts: 40+20+25=8540+20+25=85. ✓

Try it yourself

In a group of 3030, 1818 play chess and 1212 play go, and 55 play both. How many play neither?

Show the answer

At least one: 18+12−5=2518+12-5=25. Neither: 30−25=530-25=5.

Keep going with practice

Vidi's probability lessons apply exactly this formula as the addition rule for events.