Sub topic 3
Union, intersection, difference and complement
This chapter assumes you know what a set is, how to write one in roster form and set-builder form, and what a subset and a universal set are. It also assumes basic arithmetic and simple linear equations. Here you learn the four operations that combine sets, how to read them in words, and the mistakes that cost marks in CAT-style problems.
The four operations at a glance
Every overlapping-group problem is built from four operations. Each one answers a plain question about membership.
| Operation | Symbol | Plain question | Element x is in the result when |
|---|---|---|---|
| Union | A ∪ B | Who is in A or B (or both)? | x is in A, or in B, or in both |
| Intersection | A ∩ B | Who is in both A and B? | x is in A and also in B |
| Difference | A − B | Who is in A but not in B? | x is in A and x is not in B |
| Complement | A′ (or Aᶜ) | Who is outside A? | x is in the universal set U but not in A |
The word "or" in mathematics is inclusive. "A or B" includes elements that are in both. Mixing this up with the everyday meaning of "one or the other" is one of the most common errors.
Union: A ∪ B
The union collects every element that appears in at least one of the sets. Each element is listed once, even if it appears in both.
Take A = {1, 2, 3, 4} and B = {3, 4, 5}. Then A ∪ B = {1, 2, 3, 4, 5}. The elements 3 and 4 appear in both sets, but they are counted once in the union.
This is why the count of a union is not simply n(A) + n(B). Here n(A) + n(B) = 4 + 3 = 7, but n(A ∪ B) = 5. The two shared elements were counted twice. The next chapters turn this observation into the inclusion-exclusion formula.
Intersection: A ∩ B
The intersection keeps only the elements that belong to every set involved. With the same A and B, A ∩ B = {3, 4}.
Two sets whose intersection is empty are called disjoint, written A ∩ B = ∅. For example, the set of even numbers and the set of odd numbers are disjoint. When sets are disjoint, the union count is exactly n(A) + n(B), because nothing is double counted.
In word problems, the words "and", "both", "as well as" and "also" usually signal an intersection.
Difference: A − B
The difference keeps the elements of A and removes anything that is also in B. With the same sets, A − B = {1, 2}, and B − A = {5}.
Difference is not symmetric. A − B and B − A are usually different sets. This matters because "only A" and "only B" are different groups in a problem.
A useful identity is that A − B = A ∩ B′. Reading it aloud: "in A and not in B". This also gives a counting rule that you will use constantly:
n(A − B) = n(A) − n(A ∩ B)
The reasoning is that A splits into two disjoint pieces, the part shared with B and the part that is not. Remove the shared part and the "only A" piece remains.
Some books write the difference as A \ B. The meaning is the same.
Complement: A′
The complement is always taken relative to a universal set U, the set of everything under discussion. Without U, the complement has no meaning.
If U = {1, 2, 3, 4, 5, 6} and A = {1, 2, 3, 4}, then A′ = {5, 6}. The complement in terms of difference is A′ = U − A.
Two counting facts follow directly:
- n(A′) = n(U) − n(A)
- n(A) + n(A′) = n(U)
The complement is the tool for "neither" counts, which a later chapter develops. The key idea is that "not in A" depends on what U is. If U changes, A′ changes.
Running all four in Python
Python's set type has operators that match these four operations. The complement is written as a difference from U.
A = {1, 2, 3, 4}
B = {3, 4, 5}
U = {1, 2, 3, 4, 5, 6}
print(A | B) # union: {1, 2, 3, 4, 5}
print(A & B) # intersection: {3, 4}
print(A - B) # difference: {1, 2}
print(U - A) # complement of A in U: {5, 6}Note that Python prints set elements in no guaranteed order, so your output may be arranged differently. The members are what matter.
Seeing the operations on a Venn diagram
A two-set Venn diagram splits the universe into four regions: only A, both, only B, and neither. Each operation selects some of these regions.
Read the diagram as a lookup table:
| Expression | Regions it covers |
|---|---|
| A ∪ B | only A, both, only B |
| A ∩ B | both |
| A − B | only A |
| B − A | only B |
| A′ | only B, neither |
| (A ∪ B)′ | neither |
The last row is worth memorizing. The complement of a union is the "neither" region, which is the region outside both circles.
Precedence and brackets
Set expressions can be ambiguous without brackets. The complement binds most tightly, so A ∪ B′ means A ∪ (B′), not (A ∪ B)′. These two differ:
- A ∪ B′ is everything in A, plus everything outside B.
- (A ∪ B)′ is everything outside both A and B.
When you read a problem, write brackets explicitly. If the question says "neither A nor B", the correct translation is (A ∪ B)′, not A′ ∪ B′.
A worked example with counts
A class of 40 students has 22 who play cricket (C) and 18 who play football (F). Exactly 8 play both. Find the number who play cricket only, football only, at least one sport, and neither.
Start from the innermost region, the overlap, and work outward.
- Both: n(C ∩ F) = 8.
- Cricket only: n(C − F) = 22 − 8 = 14.
- Football only: n(F − C) = 18 − 8 = 10.
- At least one: n(C ∪ F) = 14 + 8 + 10 = 32.
- Neither: n((C ∪ F)′) = 40 − 32 = 8.
Check consistency: the four regions are 14 + 8 + 10 + 8 = 40, which matches the universal set. The same steps can be coded to confirm the arithmetic.
total = 40
cricket, football, both = 22, 18, 8
only_c = cricket - both
only_f = football - both
union = only_c + both + only_f
neither = total - union
print(only_c, only_f, union, neither) # 14 10 32 8
assert only_c + both + only_f + neither == totalCommon errors
- Counting the overlap twice. Adding n(A) and n(B) counts shared elements twice. Subtract the overlap once to get the union.
- Confusing "only A" with "A". The set A includes the overlap. "Only A" excludes it. A problem that says "60 study Maths" gives n(A), not n(A − B).
- Taking the complement without a universal set. If a problem does not state U, find it. It is usually the total number of people or items.
- Reading "or" as exclusive. Unless the problem says "exactly one of" or "either but not both", "or" includes the overlap.
- Assuming difference is symmetric. n(A − B) and n(B − A) are equal only when n(A) = n(B).
- Mixing up A′ ∪ B′ and (A ∪ B)′. The first is large; the second is the "neither" region.
Useful identities to keep ready
These follow from the region picture and save time on the exam.
- A ∪ B = (A − B) ∪ (A ∩ B) ∪ (B − A), and the three pieces are disjoint.
- A = (A − B) ∪ (A ∩ B), so n(A) = n(A − B) + n(A ∩ B).
- (A′)′ = A.
- A ∪ A′ = U and A ∩ A′ = ∅.
- If B is a subset of A, then A ∩ B = B, A ∪ B = A, and A − B = A with B removed.
The second identity is the one you use most. It tells you that a total for one group is always "only that group" plus "overlap".
Exercise
In a group of 60 people, 35 like tea (T), 28 like coffee (C), and 12 like neither. Using the operations in this chapter, find (a) n(T ∪ C), (b) n(T ∩ C), (c) n(T − C), and (d) n(C′).
Show answer
(a) The people who like neither form (T ∪ C)′, so n(T ∪ C) = 60 − 12 = 48. (b) The two groups together count the overlap twice, so n(T ∩ C) = 35 + 28 − 48 = 15. (c) n(T − C) = n(T) − n(T ∩ C) = 35 − 15 = 20. (d) n(C′) = n(U) − n(C) = 60 − 28 = 32. Check: only tea 20, both 15, only coffee 13, neither 12 gives 20 + 15 + 13 + 12 = 60.
Exercise
Let U = {1, 2, ..., 10}, A = {2, 4, 6, 8, 10} and B = {3, 6, 9}. List the elements of (A ∪ B)′ and of A′ ∪ B′, and state whether they are equal.
Show answer
A ∪ B = {2, 3, 4, 6, 8, 9, 10}, so (A ∪ B)′ = {1, 5, 7}. A ∩ B = {6}, and A′ ∪ B′ = (A ∩ B)′ = {1, 2, 3, 4, 5, 7, 8, 9, 10}. They are not equal. The first set has 3 elements and the second has 9.