Sub topic 9
Three-set Venn diagrams and inclusion-exclusion
This chapter assumes you can use the two-set formula (total = A + B − both + neither), that you can read "and" and "or" as set overlap and set union, and that you can solve a linear equation for one unknown. Three-set problems use the same idea with one more correction term. Most mistakes come from reading what each number means, not from the arithmetic.
Why the two-set formula needs a third term
Adding the sizes of two sets counts the overlap twice, so you subtract it once:
- |A ∪ B| = |A| + |B| − |A ∩ B|
With three sets, adding |A| + |B| + |C| counts these elements:
- Elements in exactly one set are counted once. This is correct.
- Elements in exactly two sets are counted twice.
- Elements in all three sets are counted three times.
Subtracting the three pairwise overlaps |A ∩ B|, |A ∩ C| and |B ∩ C| fixes the double counts. It also removes too much from the elements in all three sets. Each such element sits in all three pairwise overlaps, so it is subtracted three times and has a net count of 3 − 3 = 0. It has to be counted once, so you add the triple overlap back:
- |A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|
This pattern is called inclusion-exclusion: include the singles, exclude the pairs, include the triple.
# Three-set inclusion-exclusion
a, b, c = 30, 25, 20
ab, ac, bc = 10, 8, 6 # sizes of each pairwise overlap (including the triple overlap)
abc = 4
union = a + b + c - ab - ac - bc + abc
print(union) # 55The comment in the code matters. Here the pairwise overlap |A ∩ B| = 10 counts everyone in both A and B, including the 4 people who are also in C.
The seven regions of the diagram
A three-circle Venn diagram has seven inner regions plus the outside area. Each region means something specific.
| Region | Meaning | How to find it | Column | Column |
|---|---|---|---|---|
| Center | In A, B and C | Given as the triple overlap | ||
| Only A and B | In A and B, not C | A ∩ B | − center | |
| Only A and C | In A and C, not B | A ∩ C | − center | |
| Only B and C | In B and C, not A | B ∩ C | − center | |
| Only A | In A and nothing else | A | − (only AB) − (only AC) − center | |
| Only B | In B and nothing else | B | − (only AB) − (only BC) − center | |
| Only C | In C and nothing else | C | − (only AC) − (only BC) − center | |
| Outside | In none of the sets | Total − union |
Fill the diagram from the center outward. First write the triple overlap in the center. Then fill the three "exactly two" regions by subtracting the center from each pairwise overlap. Last, fill the "only one" regions.
Apply this to the numbers above (A = 30, B = 25, C = 20, pairwise overlaps 10, 8 and 6, triple 4):
- Center: 4.
- Only AB = 10 − 4 = 6. Only AC = 8 − 4 = 4. Only BC = 6 − 4 = 2.
- Only A = 30 − 6 − 4 − 4 = 16. Only B = 25 − 6 − 2 − 4 = 13. Only C = 20 − 4 − 2 − 4 = 10.
- Union = 16 + 13 + 10 + 6 + 4 + 2 + 4 = 55.
The region sum matches the formula result of 55. You can use this as a check on your work.
A second formula: counting by how many sets
GRE questions often give counts such as "exactly two" instead of pairwise overlaps. Group the elements by how many sets they belong to:
- Let x₁ be the number in exactly one set, x₂ the number in exactly two, and x₃ the number in all three.
- Union = x₁ + x₂ + x₃.
- Sum of the set sizes = x₁ + 2·x₂ + 3·x₃, because each element is counted once per set it belongs to.
Subtracting the second line from the first gives a useful rearrangement:
- Union = |A| + |B| + |C| − x₂ − 2·x₃
Check it on the example. The three set sizes sum to 75, x₂ = 6 + 4 + 2 = 12, and x₃ = 4. So the union is 75 − 12 − 8 = 55, which matches.
Worked example: finding "neither"
A survey of 120 people asks about three newspapers. Of these, 70 read A, 55 read B and 40 read C. Also, 25 read A and B, 20 read A and C, 15 read B and C, and 10 read all three. How many read none?
- Union = 70 + 55 + 40 − 25 − 20 − 15 + 10 = 165 − 60 + 10 = 115.
- Neither = 120 − 115 = 5.
total = 120
a, b, c = 70, 55, 40
ab, ac, bc, abc = 25, 20, 15, 10
union = a + b + c - ab - ac - bc + abc
print(union) # 115
print(total - union) # 5 read noneSolving for an unknown
Inclusion-exclusion is one equation. If one quantity is missing, solve for it with the algebra you already know.
Suppose 85 people are in at least one of three clubs. Club A has 40 members, B has 45 and C has 30. The pairwise overlaps are 15, 12 and 10. How many are in all three?
- Write the equation: 85 = 40 + 45 + 30 − 15 − 12 − 10 + x.
- Simplify: 85 = 115 − 37 + x = 78 + x.
- So x = 7.
Check that the answer is possible. The triple overlap can never exceed the smallest pairwise overlap, which is 10 here, so 7 is acceptable. If a problem produces a triple overlap larger than a pairwise overlap, you have misread a number or made an arithmetic error.
Minimum and maximum questions
Some GRE questions ask for the least or greatest possible overlap. The inclusion-exclusion formula alone cannot answer these. Use a complement argument instead.
Example: in a group of 100 people, 70 own a bike, 80 own a car and 90 own a scooter. What is the least number who own all three?
- Count the people who lack each item: 30 have no bike, 20 have no car and 10 have no scooter.
- Add these: 30 + 20 + 10 = 60. At most 60 people lack at least one item, and only if nobody lacks two.
- Everyone else owns all three, so at least 100 − 60 = 40 people own all three.
This is the complement method from earlier in the tutorial, applied to overlaps. The maximum possible overlap is limited by the smallest set, here 70.
Common errors
| Error | What goes wrong | Fix | Column | Column |
|---|---|---|---|---|
| Forgetting to add back the triple overlap | The union comes out too small by | A ∩ B ∩ C | Include the + term | |
| Treating "both A and B" as "only A and B" | The center is subtracted twice or not at all | Decide whether the number includes the center | ||
| Using the standard formula with "exactly" counts | The union is wrong | Use Union = sum of sizes − x₂ − 2·x₃ | ||
| Forgetting the "neither" region | Total and union are confused | Neither = total − union | ||
| Putting the set total in a region | A region holds only part of a set | Subtract the other regions that touch it |
Checking with code
When you build a Venn diagram by hand, a short function can confirm that all seven regions are nonnegative and add up correctly.
def three_set_regions(a, b, c, ab, ac, bc, abc):
"""Return the seven region sizes. Pairwise overlaps include the triple overlap."""
only_ab = ab - abc
only_ac = ac - abc
only_bc = bc - abc
only_a = a - only_ab - only_ac - abc
only_b = b - only_ab - only_bc - abc
only_c = c - only_ac - only_bc - abc
regions = {
"only A": only_a, "only B": only_b, "only C": only_c,
"only AB": only_ab, "only AC": only_ac, "only BC": only_bc,
"all three": abc,
}
if any(value < 0 for value in regions.values()):
raise ValueError("inconsistent counts: a region is negative")
return regions
regions = three_set_regions(30, 25, 20, 10, 8, 6, 4)
print(regions)
print(sum(regions.values())) # 55A negative region means the numbers in the problem are contradictory, or you have used the wrong meaning for an overlap.
Exercises
Exercise
In a class of 60 students, 35 take French, 30 take Spanish and 25 take German. There are 12 who take French and Spanish, 10 who take French and German, and 8 who take Spanish and German. Also, 5 take all three. How many students take none of the three languages?
Show answer
Union = 35 + 30 + 25 − 12 − 10 − 8 + 5 = 90 − 30 + 5 = 65. This is more than the 60 students in the class, so the numbers are inconsistent. Check: only French and Spanish = 12 − 5 = 7, only French and German = 10 − 5 = 5, only Spanish and German = 8 − 5 = 3, only French = 35 − 7 − 5 − 5 = 18, only Spanish = 30 − 7 − 3 − 5 = 15, only German = 25 − 5 − 3 − 5 = 12, and the regions add to 18 + 15 + 12 + 7 + 5 + 3 + 5 = 65. The regions are all nonnegative, but the union exceeds the class size, so the problem as stated is impossible. With a class of 70, the answer would be 70 − 65 = 5.
Exercise
Of 50 people, 20 own a cat, 25 own a dog and 15 own a bird. Exactly 8 people own exactly two kinds of pet, and 3 people own all three kinds. Everyone owns at least one pet. How many own exactly one kind?
Show answer
Use sum of sizes = x₁ + 2·x₂ + 3·x₃. The sum is 20 + 25 + 15 = 60, so 60 = x₁ + 2(8) + 3(3) = x₁ + 25, which gives x₁ = 35. Check: x₁ + x₂ + x₃ = 35 + 8 + 3 = 46, which is less than 50, so 4 people own no pet. But the problem says everyone owns at least one pet, so the data contradict the statement. The calculation of x₁ = 35 still follows from the pet counts; removing the claim that everyone owns a pet makes the problem consistent, with 4 people owning none.
Exercise
In a group of 100 people, 60 speak English, 70 speak Hindi and 80 speak Tamil. What is the least possible number who speak all three?
Show answer
People who do not speak each language: 40, 30 and 20, totaling 90. At most 90 people lack at least one language, so at least 100 − 90 = 10 speak all three.