Sets and set operations
Before you start: the set laws below mirror the laws of propositional logic, so it helps to have read that lesson first.
A set is a collection of distinct objects, its elements. We write \(a \in A\) for "\(a\) is an element of \(A\)", and \(A \subseteq B\) when every element of \(A\) is also in \(B\). Order and repetition do not matter: \(\{1, 2, 2, 3\} = \{3, 1, 2\}\). The empty set \(\emptyset\) has no elements, and the power set \(\mathcal{P}(A)\) is the set of all subsets of \(A\). If \(|A| = n\), then \(|\mathcal{P}(A)| = 2^n\), because each element is either in a subset or not.
Union \(A \cup B\): in \(A\) or \(B\) (or both). Intersection \(A \cap B\): in both.
Difference \(A - B\): in \(A\) but not in \(B\). Complement \(A' = U - A\).
Symmetric difference \(A \oplus B = (A - B) \cup (B - A)\): in exactly one of them.
De Morgan's laws for sets
\[(A \cup B)' = A' \cap B', \qquad (A \cap B)' = A' \cup B'\]
A Venn diagram draws \(U\) as a rectangle and each set as a circle inside it. Two overlapping circles cut the rectangle into 4 regions: only \(A\), only \(B\), both, neither. Three circles give 8 regions. Shading regions is the fastest way to see whether two set expressions are equal, and filling in counts region by region, from the centre outwards, is how most survey problems are solved.
The Cartesian product \(A \times B\) is the set of ordered pairs \((a, b)\) with \(a \in A\) and \(b \in B\). It has \(|A| \cdot |B|\) elements, and in general \(A \times B \ne B \times A\).
Inclusion-exclusion
Adding \(|A|\) and \(|B|\) counts the elements of \(A \cap B\) twice, so subtract them once. With three sets, subtracting the three pairwise overlaps removes the centre region three times after adding it three times, so it has to be added back.
\[|A \cup B| = |A| + |B| - |A \cap B|\]
\[|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|\]
"Neither" or "none" questions use the complement: the number in none of the sets is \(|U| - |A \cup B \cup C|\).
Relations and their properties
A relation \(R\) on a set \(A\) is any subset of \(A \times A\). We write \(a\,R\,b\) when \((a, b) \in R\). Since \(A \times A\) has \(n^2\) pairs, a set with \(n\) elements has \(2^{n^2}\) relations on it.
Reflexive: \(a\,R\,a\) for every \(a \in A\).
Symmetric: if \(a\,R\,b\), then \(b\,R\,a\).
Antisymmetric: if \(a\,R\,b\) and \(b\,R\,a\), then \(a = b\).
Transitive: if \(a\,R\,b\) and \(b\,R\,c\), then \(a\,R\,c\).
For a small set, write the relation matrix \(M_R\): list the elements \(a_1, \dots, a_n\) and put a 1 in row \(i\), column \(j\) when \(a_i\,R\,a_j\). Then reflexive means the diagonal is all 1s, symmetric means \(M_R\) equals its transpose, and antisymmetric means no off-diagonal 1 has a matching 1 in the mirror position.
Equivalence relations
A relation that is reflexive, symmetric and transitive is an equivalence relation. It sorts \(A\) into equivalence classes \([a] = \{x \in A : x\,R\,a\}\). Any two classes are either identical or disjoint, and together they cover \(A\), so the classes form a partition of \(A\).
Partial orders and Hasse diagrams
A relation that is reflexive, antisymmetric and transitive is a partial order, like \(\le\) on numbers or divisibility on positive integers. A Hasse diagram draws it compactly: put \(b\) above \(a\) when \(a\) comes before \(b\), join \(a\) to \(b\) only when nothing sits strictly between them, and leave out the loops and the edges that follow by transitivity.
Solved examples
Example 1: Set operations
Easy\(U = \{1, 2, \dots, 10\}\), \(A = \{1, 2, 3, 4, 5\}\), \(B = \{4, 5, 6, 7\}\). Find \(A \cup B\), \(A \cap B\), \(A - B\), \(A'\) and \(A \oplus B\).
- \(A \cup B = \{1, 2, 3, 4, 5, 6, 7\}\) and \(A \cap B = \{4, 5\}\).
- \(A - B = \{1, 2, 3\}\) and \(B - A = \{6, 7\}\).
- \(A' = \{6, 7, 8, 9, 10\}\).
- \(A \oplus B = (A - B) \cup (B - A) = \{1, 2, 3, 6, 7\}\).
Answer\(A \cup B = \{1, \dots, 7\}\), \(A \cap B = \{4, 5\}\), \(A - B = \{1, 2, 3\}\), \(A' = \{6, \dots, 10\}\), \(A \oplus B = \{1, 2, 3, 6, 7\}\)
Example 2: Two sets
EasyIn a class of 60, 35 students know Python, 28 know Java and 12 know both. How many know at least one? How many know neither?
- \(|P \cup J| = 35 + 28 - 12 = 51\).
- Neither: \(60 - 51 = 9\).
Answer51 know at least one language; 9 know neither.
Example 3: Three sets
MediumHow many integers from 1 to 100 are divisible by 2, 3 or 5?
- Let \(A, B, C\) be the multiples of 2, 3, 5. \(|A| = 50\), \(|B| = \lfloor 100/3 \rfloor = 33\), \(|C| = 20\).
- Pairs: multiples of 6, 10, 15, so \(|A \cap B| = 16\), \(|A \cap C| = 10\), \(|B \cap C| = 6\). All three: multiples of 30, so 3.
- \(|A \cup B \cup C| = 50 + 33 + 20 - 16 - 10 - 6 + 3\).
Answer74 integers
Example 4: Cartesian product
Easy\(A = \{a, b\}\), \(B = \{1, 2, 3\}\). List \(A \times B\). Is it equal to \(B \times A\)?
- List the pairs: \[A \times B = \{(a,1), (a,2), (a,3), (b,1), (b,2), (b,3)\}\] There are \(2 \times 3 = 6\) of them.
- \(B \times A\) contains \((1, a)\), which is a different ordered pair from \((a, 1)\).
Answer\(|A \times B| = 6\), and \(A \times B \ne B \times A\).
Example 5: Testing properties
MediumOn \(A = \{1, 2, 3\}\), let \[R = \{(1,1), (2,2), (3,3), (1,2), (2,1), (2,3), (3,2)\}\] Which properties does \(R\) have?
- Matrix (rows and columns in the order 1, 2, 3): \[M_R = \begin{pmatrix} 1 & 1 & 0 \\ 1 & 1 & 1 \\ 0 & 1 & 1 \end{pmatrix}\]
- Diagonal all 1: reflexive. \(M_R\) equals its transpose: symmetric.
- \((1,2)\) and \((2,1)\) are both in \(R\) with \(1 \ne 2\): not antisymmetric.
- \((1,2)\) and \((2,3)\) are in \(R\) but \((1,3)\) is not: not transitive.
AnswerReflexive and symmetric; not antisymmetric, not transitive. So it is not an equivalence relation.
Example 6: Congruence mod 3
MediumOn \(\mathbb{Z}\), define \(a\,R\,b\) if \(3 \mid (a - b)\). Show that \(R\) is an equivalence relation and find its classes.
- Reflexive: \(a - a = 0 = 3 \cdot 0\).
- Symmetric: if \(a - b = 3k\), then \(b - a = 3(-k)\).
- Transitive: if \(a - b = 3k\) and \(b - c = 3m\), then \(a - c = 3(k + m)\).
- Classes by remainder: \([0] = \{\dots, -3, 0, 3, 6, \dots\}\), \([1] = \{\dots, -2, 1, 4, 7, \dots\}\), \([2] = \{\dots, -1, 2, 5, 8, \dots\}\).
Answer\(R\) is an equivalence relation with exactly three classes, \([0], [1], [2]\).
Example 7: A Hasse diagram
Exam levelShow that divisibility is a partial order on \(A = \{1, 2, 3, 4, 6, 12\}\) and describe its Hasse diagram.
- Reflexive: \(a \mid a\). Antisymmetric: if \(a \mid b\) and \(b \mid a\) for positive integers, then \(a = b\). Transitive: if \(b = ak\) and \(c = bm\), then \(c = a(km)\).
- Keep only the pairs with nothing in between: \(1 \mid 2\), \(1 \mid 3\), \(2 \mid 4\), \(2 \mid 6\), \(3 \mid 6\), \(4 \mid 12\), \(6 \mid 12\). (For example \(2 \mid 12\) is dropped because \(2 \mid 4 \mid 12\).)
- Draw by levels, bottom to top: 1; then 2 and 3; then 4 and 6; then 12. Join each pair in the list above with a line.
AnswerA partial order whose Hasse diagram has the 7 edges 1-2, 1-3, 2-4, 2-6, 3-6, 4-12, 6-12.
Example 8: Counting relations
Exam levelFor \(A = \{1, 2, 3\}\), how many relations are there on \(A\)? How many are reflexive? How many are symmetric?
- \(A \times A\) has 9 pairs; each is in or out, so there are \(2^9 = 512\) relations.
- Reflexive: the 3 diagonal pairs must be in. The other 6 pairs are free: \(2^6 = 64\).
- Symmetric: each diagonal pair is free (3 choices), and each off-diagonal pair \(\{(a,b), (b,a)\}\) goes in or out together (3 such pairs). That is \(2^{3+3} = 64\).
Answer512 relations; 64 reflexive; 64 symmetric. In general, \(2^{n^2}\), \(2^{n(n-1)}\) and \(2^{n(n+1)/2}\).
For a relation on a small set, I always write the matrix first. Reflexive: look at the diagonal. Symmetric: fold the matrix along the diagonal. Transitivity is the only one you must check pair by pair, so do it last and look for a single failure.
Common mistakes
1. Thinking antisymmetric means "not symmetric"
The relation \(\{(1,1), (2,2)\}\) on \(\{1, 2\}\) is both symmetric and antisymmetric. The relation \(\{(1,2), (2,1), (1,3)\}\) on \(\{1, 2, 3\}\) is neither. Antisymmetric only forbids a pair \((a, b)\) and \((b, a)\) together with \(a \ne b\).
2. Forgetting to add back the centre
Wrong: \(|A \cup B \cup C| = 50 + 33 + 20 - 16 - 10 - 6 = 71\) in Example 3. The multiples of 30 have now been added 3 times and removed 3 times. Right: add \(|A \cap B \cap C| = 3\) back to get 74.
3. Missing vacuous cases
On \(\{1, 2\}\), the relation \(R = \{(1, 2)\}\) is transitive: there is no pair \((1,2), (2,c)\) in \(R\) to test, so the condition never fails. It is also antisymmetric. It is not reflexive, because \((1,1)\) is missing.
Practice questions
Try each one on paper before you open the answer.
Q1If \(|A| = 5\), find \(|\mathcal{P}(A)|\), \(|A \times A|\) and the number of relations on \(A\).
\(2^5 = 32\) subsets, \(5^2 = 25\) ordered pairs, and \(2^{25}\) relations.
Q2\(|A| = 20\), \(|B| = 15\) and \(|A \cup B| = 29\). Find \(|A \cap B|\).
\(|A \cap B| = 20 + 15 - 29 = 6\).
Q3Of 100 students, 45 take Maths, 40 Physics and 35 Chemistry; 15 take Maths and Physics, 12 Maths and Chemistry, 10 Physics and Chemistry, and 5 take all three. How many take none?
At least one: \(45 + 40 + 35 - 15 - 12 - 10 + 5 = 88\). None: \(100 - 88 = 12\). (Venn regions: centre 5, M and P only 10, M and C only 7, P and C only 5, M only 23, P only 20, C only 18.)
Q4On \(\{1, 2, 3\}\), \(R\) consists of the pairs \((1,1)\), \((2,2)\), \((3,3)\), \((1,2)\), \((2,3)\) and \((1,3)\). Is \(R\) a partial order?
Yes. The diagonal is complete (reflexive), no pair appears in both directions (antisymmetric), and the only chain \((1,2), (2,3)\) has \((1,3)\) in \(R\) (transitive). It is \(\le\) on \(\{1, 2, 3\}\).
Q5On \(\{1, 2, \dots, 10\}\), \(a\,R\,b\) if \(a\) and \(b\) leave the same remainder on division by 4. List the equivalence classes.
\(\{4, 8\}\), \(\{1, 5, 9\}\), \(\{2, 6, 10\}\), \(\{3, 7\}\). Four classes, disjoint, covering all ten numbers.
Q6On \(\mathbb{Z}\), \(a\,R\,b\) if \(a - b\) is odd. Which properties hold?
Not reflexive (\(a - a = 0\) is even). Symmetric (if \(a - b\) is odd, so is \(b - a\)). Not transitive: \(1\,R\,2\) and \(2\,R\,3\), but \(1 - 3 = -2\) is even. Not antisymmetric: \(1\,R\,2\) and \(2\,R\,1\).
Bring it to a free demo class and work through it with Vipul Sir. Book on WhatsApp.
Frequently asked questions
What is the difference between a relation and a function?
A relation from \(A\) to \(B\) is any set of ordered pairs. A function is a relation in which every element of \(A\) appears as a first entry exactly once, so each input has one output.
What is an equivalence relation?
A relation that is reflexive, symmetric and transitive, such as "has the same remainder mod 3". It splits the set into disjoint equivalence classes.
What is a Hasse diagram?
A drawing of a partial order. Smaller elements go lower, and a line joins \(a\) to \(b\) only when \(b\) covers \(a\) directly. Loops and edges implied by transitivity are left out.
What is the inclusion-exclusion formula for 3 sets?
\(|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|\).