Let U = {1, 2, …, 12}, A = {2, 4, 6, 8, 10, 12} (even numbers) and B = {3, 6, 9, 12} (multiples of 3). Find A ∪ B, A ∩ B, A − B, B − A, A ⊕ B and (A ∪ B)′, and verify one De Morgan law.
A set is an unordered collection of distinct objects. Union, intersection, difference, complement, symmetric difference, power set and Cartesian product — with their identities and Venn diagrams — form the language that relations, probability and databases are written in.
A set is a well-defined collection of distinct objects called its elements or members. “Well-defined” means that for any object we can decide whether or not it belongs — “the prime numbers below 20” is a set, “the good films of 2025” is not. We write x ∈ A when x belongs to A and x ∉ A when it does not.
A set can be given in roster (tabular) form, listing its elements — A = {2, 3, 5, 7} — or in set-builder form, stating a membership property — A = {x | x is prime and x < 10}. Both describe the same set. An ellipsis shows a clear pattern: {1, 3, 5, …} is the set of odd positive integers.
| Symbol | Set | Sample elements |
|---|---|---|
| ℕ | Natural numbers | 1, 2, 3, … (some books, including Rosen, start at 0) |
| ℤ | Integers | …, −2, −1, 0, 1, 2, … |
| ℤ⁺ | Positive integers | 1, 2, 3, … |
| ℚ | Rational numbers p/q with q ≠ 0 | 1/2, −3, 0.75 |
| ℝ | Real numbers | √2, π, −4.1 |
| ℂ | Complex numbers | 3 + 2i |
| ∅ or {} | Empty (null, void) set | no elements at all |
| U | Universal set | everything under discussion in a problem |
Two sets are equal when they have exactly the same elements; order and repetition are irrelevant, so {a, b, c} = {c, a, b} = {a, a, b, c}. The cardinality |A| is the number of distinct elements. A set with one element, such as {7}, is a singleton; a set is finite if its cardinality is a natural number and infinite otherwise.
A is a subset of B, written A ⊆ B, when every element of A is also in B: ∀x (x ∈ A → x ∈ B). A is a proper subset, A ⊂ B, when A ⊆ B and A ≠ B. Two sets are equal exactly when each is a subset of the other — A = B ⇔ A ⊆ B and B ⊆ A — which is how most set equalities are proved.
For every set A, ∅ ⊆ A (vacuously: the empty set has no element that could fail to lie in A) and A ⊆ A. The subset relation is reflexive, antisymmetric and transitive — a partial order, studied in a later topic.
The power set P(A) (also written 2ᴬ) is the set of all subsets of A. If |A| = n then |P(A)| = 2ⁿ: building a subset means making an independent in-or-out choice for each of the n elements.
Keep membership (∈) and inclusion (⊆) apart. For A = {1, {1}, {2, 3}}: 1 ∈ A; {1} ∈ A and also {1} ⊆ A (because 1 ∈ A); {2, 3} ∈ A but {2, 3} ⊄ A (2 is not an element of A); {{2, 3}} ⊆ A. And |A| = 3.
| Set | Its power set | Cardinality |
|---|---|---|
| ∅ | {∅} | 1 |
| {∅} | {∅, {∅}} | 2 |
| {∅, {∅}} | {∅, {∅}, {{∅}}, {∅, {∅}}} | 4 |
| Operation | Notation | Definition | Venn picture |
|---|---|---|---|
| Union | A ∪ B | {x | x ∈ A ∨ x ∈ B} | both circles shaded |
| Intersection | A ∩ B | {x | x ∈ A ∧ x ∈ B} | only the overlap (lens) |
| Difference (relative complement) | A − B or A \ B | {x | x ∈ A ∧ x ∉ B} | A's circle minus the lens |
| Complement | A′, A̅ or Aᶜ | {x ∈ U | x ∉ A} = U − A | everything outside A |
| Symmetric difference | A ⊕ B or A Δ B | {x | x is in exactly one of A, B} | both circles minus the lens |
Sets with A ∩ B = ∅ are disjoint; a family of sets is pairwise disjoint when every two of them are disjoint. Intersection and union extend to any number of sets: x ∈ A₁ ∩ A₂ ∩ … ∩ Aₙ when x lies in all of them, and x ∈ A₁ ∪ … ∪ Aₙ when it lies in at least one.
Worked numbers: let U = {1, 2, …, 10}, A = {1, 2, 3, 4, 5}, B = {4, 5, 6, 7}. Then A ∪ B = {1, …, 7}, A ∩ B = {4, 5}, A − B = {1, 2, 3}, B − A = {6, 7}, A ⊕ B = {1, 2, 3, 6, 7}, A′ = {6, 7, 8, 9, 10} and (A ∪ B)′ = {8, 9, 10}. Check De Morgan: A′ ∩ B′ = {6, …, 10} ∩ {1, 2, 3, 8, 9, 10} = {8, 9, 10}. ✓
In a Venn diagram (John Venn, 1880) a rectangle stands for U and circles for the sets. Two circles cut the rectangle into 4 regions — A only, B only, both, neither — and three circles into 2³ = 8 regions. Any set expression corresponds to a union of regions, which makes Venn diagrams a quick way to test an identity (a proof still needs an argument).
| Region | Description | Set expression |
|---|---|---|
| 1 | A only | A ∩ B′ ∩ C′ |
| 2 | B only | A′ ∩ B ∩ C′ |
| 3 | C only | A′ ∩ B′ ∩ C |
| 4 | A and B, not C | A ∩ B ∩ C′ |
| 5 | A and C, not B | A ∩ B′ ∩ C |
| 6 | B and C, not A | A′ ∩ B ∩ C |
| 7 | all three | A ∩ B ∩ C |
| 8 | none of them | A′ ∩ B′ ∩ C′ |
Counting with two sets: |A ∪ B| = |A| + |B| − |A ∩ B|, |A − B| = |A| − |A ∩ B|, |A ⊕ B| = |A| + |B| − 2|A ∩ B| and “neither” = |U| − |A ∪ B|. Example: of 50 students, 30 study Java, 25 Python and 12 both. Then 30 + 25 − 12 = 43 study at least one, 7 study neither, 18 study Java only, 13 Python only, and 31 study exactly one.
| Law | Identity | Dual |
|---|---|---|
| Identity | A ∪ ∅ = A | A ∩ U = A |
| Domination | A ∪ U = U | A ∩ ∅ = ∅ |
| Idempotent | A ∪ A = A | A ∩ A = A |
| Complementation (involution) | (A′)′ = A | (A′)′ = A |
| Complement | A ∪ A′ = U | A ∩ A′ = ∅ |
| Commutative | A ∪ B = B ∪ A | A ∩ B = B ∩ A |
| Associative | A ∪ (B ∪ C) = (A ∪ B) ∪ C | A ∩ (B ∩ C) = (A ∩ B) ∩ C |
| Distributive | A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C) | A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) |
| De Morgan | (A ∪ B)′ = A′ ∩ B′ | (A ∩ B)′ = A′ ∪ B′ |
| Absorption | A ∪ (A ∩ B) = A | A ∩ (A ∪ B) = A |
| Identity involving difference | Why it is useful |
|---|---|
| A − B = A ∩ B′ | Turns a difference into an intersection — the first step of most proofs |
| A − (B ∪ C) = (A − B) ∩ (A − C) | De Morgan for differences |
| A − (B ∩ C) = (A − B) ∪ (A − C) | De Morgan for differences |
| (A − B) − C = A − (B ∪ C) = (A − C) − (B − C) | Removing B and then C = removing both |
| A ∩ (B − C) = (A ∩ B) − (A ∩ C) | ∩ distributes over − |
| A ⊆ B ⇔ A ∩ B = A ⇔ A ∪ B = B ⇔ A − B = ∅ ⇔ B′ ⊆ A′ | Five equivalent ways to say “A is a subset of B” |
There are three standard ways to prove an identity: element-chasing (show every element of the left side is in the right side and vice versa), a membership table (a truth table with 1 = member, 0 = non-member), and algebra using the laws above.
| A | B | C | B ∪ C | A ∩ (B ∪ C) | A ∩ B | A ∩ C | (A ∩ B) ∪ (A ∩ C) |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 1 | 0 | 1 |
| 1 | 0 | 1 | 1 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
In an ordered pair (a, b) the order matters: (a, b) = (c, d) exactly when a = c and b = d, so (1, 2) ≠ (2, 1) even though {1, 2} = {2, 1}. The Cartesian product A × B = {(a, b) | a ∈ A, b ∈ B} — named after René Descartes, whose coordinate plane is ℝ × ℝ = ℝ² — collects every such pair.
The product is not commutative — A × B ≠ B × A unless A = B or one set is empty. It does distribute over the other operations: A × (B ∪ C) = (A × B) ∪ (A × C), A × (B ∩ C) = (A × B) ∩ (A × C), A × (B − C) = (A × B) − (A × C), and (A × B) ∩ (C × D) = (A ∩ C) × (B ∩ D).
The idea reappears in databases (Module 5): a table whose columns take values from domains D₁, …, Dₙ is a subset of D₁ × … × Dₙ, and an SQL CROSS JOIN of a 3-row table with a 4-row table returns 3 × 4 = 12 rows.
Two sets have the same cardinality when there is a bijection (one-to-one correspondence) between them. A set is countably infinite when it can be put in bijection with ℕ, i.e. its elements can be listed as a₁, a₂, a₃, … with every element appearing somewhere. Countable means finite or countably infinite; everything else is uncountable.
Cantor's diagonal argument (1891): suppose the reals in (0, 1) could be listed. Build a number whose k-th decimal digit differs from the k-th digit of the k-th number in the list. It lies in (0, 1) yet differs from every listed number — a contradiction. The same idea proves Cantor's theorem, |A| < |P(A)| for every set, so there is no largest infinity. The cardinality of ℕ is written ℵ₀ (aleph-null); that of ℝ is 2^ℵ₀.
A multiset (bag) allows repeated elements, each with a multiplicity: {a, a, b, c, c, c} has m(a) = 2, m(b) = 1, m(c) = 3 and size 6. Union takes the maximum multiplicity, intersection the minimum, and the sum adds them. For P = {a, a, b} and Q = {a, b, b, c}: P ∪ Q = {a, a, b, b, c}, P ∩ Q = {a, b} and P + Q = {a, a, a, b, b, b, c}. SQL's UNION ALL behaves like a multiset sum, while UNION removes duplicates like a set union.
Try the problem first, then reveal the working one step at a time.
Let U = {1, 2, …, 12}, A = {2, 4, 6, 8, 10, 12} (even numbers) and B = {3, 6, 9, 12} (multiples of 3). Find A ∪ B, A ∩ B, A − B, B − A, A ⊕ B and (A ∪ B)′, and verify one De Morgan law.
For A = {a, b, c, d}, find (i) |P(A)|, (ii) the subsets with exactly two elements, (iii) the number of subsets containing a, (iv) the number containing a but not b.
Prove A − (B ∩ C) = (A − B) ∪ (A − C).
A = {1, 2, 3}, B = {p, q}. List A × B, compare it with B × A, and find how many relations exist from A to B.
If |A| = 6, find the number of (a) subsets, (b) proper subsets, (c) subsets with exactly 3 elements, (d) subsets that contain a fixed element x.
True or false? (a) ∅ ∈ {∅} (b) ∅ ⊆ {∅} (c) {∅} ⊆ ∅ (d) {a} ∈ {a, {a}} (e) {a} ⊆ {a, {a}} (f) {{a}} ⊆ {a, {a}}
Prove that (A − B) − C = (A − C) − (B − C).
With U = {1, …, 10}, A = {1, 3, 5, 7, 9}, B = {1, 2, 3, 4} and C = {3, 4, 5, 6}, find A ⊕ B, (A ∪ B) ∩ C′ and A − (B ∩ C).
Which of these sets are countable: (a) ℤ × ℤ (b) the set of all C programs (c) the interval (0, 1) (d) ℝ − ℚ (e) the power set of {1, 2, …, 100}?
10 questions. 70 % passes the topic quiz (+30 XP, +20 more for 100 %). Exam scoring: +1 correct, −⅓ wrong.
Modelled on real KPSC questions (reworded) with the same concept and answer; each links to its original paper.