Sets are the “data structure” of discrete mathematics. Functions, relations, graphs, probability: all are built on sets. On the midterm this topic usually brings a computation part (do the operations, write the power set) and a proof part (show that two sets are equal). The computation part is free marks; in the proof part you apply one of three methods like a template.
Golden rules:
A set is unordered and has no repeats.{1,2,3}={3,1,2}={1,1,2,3}.
∈ and ⊆ are different questions. The first asks about a single element, the second about all elements.
∣P(A)∣=2∣A∣. Don’t forget to write the empty set and A itself.
Set operations are logical operations.∩=∧, ∪=∨, complement =¬.
Two directions for equality, one example for inequality.
Basic definitions
Set: a well-defined collection of objects. The objects are called elements: a∈A.
Two ways of writing:
Roster method (list):A={2,4,6,8}.
Set-builder notation:A={x∈Z+∣x is even and x<10}.
Standard sets: N={0,1,2,…} (including 0 in Rosen), Z the integers, Z+ the positive integers, Q the rationals, R the reals. Intervals: [a,b], (a,b) and so on.
Concept
Definition
Example
Empty set ∅
the set with no elements
{x∈R∣x2=−1}=∅
Subset A⊆B
∀x(x∈A→x∈B)
{1,2}⊆{1,2,3}
Proper subset A⊂B
A⊆B and A=B
{1}⊂{1,2}
Equality A=B
A⊆B and B⊆A
{1,2}={2,1}
Cardinality ∣A∣
the number of elements in a finite set
∣{a,{a}}∣=2
For every set, ∅⊆A and A⊆A. The empty set is a subset because of “vacuous truth”: since x∈∅ is never true, the conditional is automatically true.
PITFALL · ∅ versus {∅}.∅ is an empty box. {∅} is a box with an empty box inside: it has one element. ∣∅∣=0, ∣{∅}∣=1.
8 elements: 23. Why 2n? There are two choices for each element: it is either in the subset or not. With n elements, 2⋅2⋯2=2n.
To write them systematically, group by size: 0 elements (1 subset), 1 element (3), 2 elements (3), 3 elements (1).
Cartesian productA×B={(a,b)∣a∈A,b∈B}. The elements are ordered pairs: (a,b)=(c,d) if and only if a=c and b=d. With A={1,2}, B={p,q}:
A×B={(1,p),(1,q),(2,p),(2,q)},∣A×B∣=∣A∣⋅∣B∣.
The elements of B×A look like (p,1), with the first coordinate from B. So in general A×B=B×A. A×∅=∅.
Set operations
Operation
Definition (set-builder)
Logic counterpart
Union A∪B
{x∣x∈A∨x∈B}
∨
Intersection A∩B
{x∣x∈A∧x∈B}
∧
Difference A−B
{x∣x∈A∧x∈/B}
p∧¬q
Complement A
{x∈U∣x∈/A}
¬
Symmetric difference A⊕B
(A−B)∪(B−A)
⊕
If A∩B=∅, then A and B are disjoint.
Example.U={1,…,8}, A={1,2,3,4}, B={3,4,5,6}.
A ∩ B = {3, 4} A ∪ B = {1, 2, 3, 4, 5, 6}A − B = {1, 2} B − A = {5, 6}Ā = {5, 6, 7, 8} A ⊕ B = {1, 2, 5, 6}
Inclusion-exclusion:∣A∪B∣=∣A∣+∣B∣−∣A∩B∣. In the example, 4+4−2=6. The intersection is counted twice, so it is subtracted once.
Set identities
All of them are exact copies of the laws of logic:
Law
Identity
Identity
A∪∅=A, A∩U=A
Domination
A∪U=U, A∩∅=∅
Complement
A∪A=U, A∩A=∅, A=A
Distributive
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
Difference
A−B=A∩B
Three ways to prove set equality
Way 1: Double inclusion
To show X=Y, show X⊆Y and Y⊆X separately.
Theorem.A∪B=A∩B.
(⊆) Let x ∈ complement(A ∪ B). Then x ∉ A ∪ B, so it is not the case that x ∈ A or x ∈ B. By De Morgan's law (logic), x ∉ A and x ∉ B, i.e. x ∈ Ā and x ∈ B̄. Hence x ∈ Ā ∩ B̄.(⊇) Let x ∈ Ā ∩ B̄. Then x ∉ A and x ∉ B, so x is in neither set, i.e. x ∉ A ∪ B. Hence x ∈ complement(A ∪ B).Both inclusions hold, so the sets are equal. ∎
Way 2: Membership table
The same as a truth table: 1 means “is an element”, 0 means “is not an element”. Three sets give 8 rows. Compute the column of each side; if they are the same, the sets are equal.
Theorem.A−(B∩C)=(A−B)∪(A−C).
A
B
C
B∩C
A−(B∩C)
A−B
A−C
(A−B)∪(A−C)
1
1
1
1
0
0
0
0
1
1
0
0
1
0
1
1
1
0
1
0
1
1
0
1
1
0
0
0
1
1
1
1
0
1
1
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
“Since the columns for A−(B∩C) and (A−B)∪(A−C) are identical, the two sets are equal.” ∎
When filling in the X−Y column, the rule is: 1 if “1 in X AND 0 in Y”. In the rows where A=0 the difference is automatically 0; you fill in the lower half quickly.
Way 3: Set-builder and laws of logic
Justify each step with a definition or a law of logic. Question 9 is an example of this way. It is the shortest to write, but writing the reason for every line is mandatory.
TIP · Which way should I choose? If the question says “use a membership table”, use the table. If it says “Prove that”, the safest is double inclusion; the instructor usually does that in class. If time is short, the table is the most mechanical way and has the lowest chance of error.
Showing they are not equal
A single concrete example: choose small sets ({1}, ∅), compute both sides, and get different results. In a membership table, a row with different values gives you a ready-made example: put the element 1 into the sets that have a 1 in that row.
Common mistakes
Wrong idea
The truth
{1,1,2} has three elements
It has two elements; repeats are not counted
∅∈A is always true
∅⊆A is always true; ∈ is a separate question
∣{∅}∣=0
It is 1
Forgetting ∅ or A when writing P(A)
Count check: 2∣A∣ elements
A×B=B×A
Ordered pairs; usually different
∣A∪B∣=∣A∣+∣B∣
Subtract the intersection
In “divisible by 4 or 6”, the intersection is the multiples of 24
LCM: multiples of 12
It came out equal in one example, so they are equal
A general proof for equality; a single example for inequality
A−B=B−A
Difference is not commutative
Writing only one direction in double inclusion
Both directions are needed
Test yourself
Exam-style questions. Solve them on paper first, then reveal the answer.
Question 1easy
Let U={1,2,…,10}, A={2,3,5,7} and B={1,2,3,4,5}. Find A∩B, A∪B, A−B, B−A and A.
Intersection: the common elements 2, 3, 5. Union: everything, without repeating. A−B: remove from A the elements that are in B, leaving only 7. B−A: remove 2, 3, 5 from B: {1,4}. Complement: elements in U that are not in A.
Question 2easy
Find ∣P({a,b,c,d})∣ and ∣P(P(∅))∣.
Show answer
16 and 2
A set with n elements has 2n subsets: 24=16. P(∅)={∅}, which has one element. Its power set is {∅,{∅}}, with two elements: 21=2.
(a) The elements of {1,2} are 1 and 2; ∅ is not one of them. (b) The empty set is a subset of every set. (c) {1} is in the list as the second element. (d) The only element of {1} is 1, and it is in the set. (e) The element of {{1}} is {1}; the only element of the set {1} is 1. {1}=1, so false. ∈ asks "is it an element?", ⊆ asks "are all its elements inside?".
Question 4medium
Let A={1,2} and B={x,y,z}. Find ∣A×B∣, ∣A×B×A∣ and ∣P(A×B)∣.
Show answer
6, 12, 64
∣A×B∣=2⋅3=6. The triple product: 2⋅3⋅2=12. A×B is a set with 6 elements, so its power set has 26=64 elements.
Question 5medium
Use a membership table to determine whether (A∪B)−C=(A−C)∪(B−C).
Show answer
Equal (identical columns)
8 rows, in the order ABC = 111, 110, 101, 100, 011, 010, 001, 000. A∪B: 1,1,1,1,1,1,0,0. (A∪B)−C ("1 in A∪B and 0 in C"): 0,1,0,1,0,1,0,0. A−C: 0,1,0,1,0,0,0,0. B−C: 0,1,0,0,0,1,0,0. Their union: 0,1,0,1,0,1,0,0. The columns are the same, so the sets are equal.
Question 6medium
Is A−(B−C)=(A−B)−C for all sets? Prove or give a counterexample.
Show answer
No. A = B = C = {1}: left side {1}, right side ∅.
Set difference is not associative. A=B=C={1}: B−C=∅, so A−(B−C)={1}. A−B=∅, so (A−B)−C=∅. Different. A single concrete example is enough to show they are not equal.
Question 7easy
In a class of 40 students, 25 take Python, 18 take Java and 9 take both. How many students take neither?
Show answer
6
∣P∪J∣=∣P∣+∣J∣−∣P∩J∣=25+18−9=34. The 9 students who take both were counted twice, and we subtracted them once. Students who take neither: 40−34=6.
Question 8hard
Prove that A∩(B−A)=∅ for all sets A and B.
Show answer
An element of both would satisfy x ∈ A and x ∉ A, a contradiction.
Suppose, for contradiction, that some x∈A∩(B−A). Then x∈A and x∈B−A; the second means x∈B and x∈/A. So x∈A and x∈/A, contradiction. Hence the set has no elements. ∎ The standard way to show a set is empty: start with "if there were an element" and reach a contradiction.
Question 9hard
Prove De Morgan's law A∩B=A∪B using set-builder notation and logical equivalences.
Show answer
x ∈ complement(A∩B) ⟺ ¬(x∈A ∧ x∈B) ⟺ x∉A ∨ x∉B ⟺ x ∈ Ā ∪ B̄
A∩B={x∣x∈/A∩B}={x∣¬(x∈A∧x∈B)} (def. of intersection)={x∣x∈/A∨x∈/B} (De Morgan's law for logic)={x∣x∈A∨x∈B} (def. of complement)=A∪B (def. of union). ∎ Write the reason next to every step.
Question 10medium
How many integers from 1 to 200 (inclusive) are divisible by 4 or by 6?
Show answer
67
∣A4∣=⌊200/4⌋=50, ∣A6∣=⌊200/6⌋=33. The numbers divisible by both 4 and 6 are those divisible by lcm(4,6)=12: ⌊200/12⌋=16. Total 50+33−16=67. Pitfall: thinking the intersection is the multiples of 4⋅6=24; the correct one is the LCM, 12.
Question 11easy
List the elements of {x∈Z∣x2<10}.
Show answer
{−3, −2, −1, 0, 1, 2, 3}
If x2<10 then ∣x∣≤3 (32=9<10, 42=16). Don't forget the negatives: the square of −3 is also 9.
Question 12hard
Prove that if A⊆B, then P(A)⊆P(B).
Show answer
If S ∈ P(A), then S ⊆ A ⊆ B, so S ∈ P(B).
Let S∈P(A). By definition S⊆A. Let x∈S; then x∈A, and since A⊆B, x∈B. So S⊆B, i.e. S∈P(B). Since S was arbitrary, P(A)⊆P(B). ∎ A subset proof is always written with the pattern "Let x∈X ... then x∈Y".
Verification: All set operations were checked with JavaScript arrays, membership tables by computing all 8 rows, power set sizes by generating them, and counting questions by scanning 1..200 with node (verify/MAT2033/04.mjs).
Review card
A set: unordered, no repeats. {1,2,2,3} = {3,2,1}, 3 elements.
∈ is it an element? ⊆ are all its elements inside? ∅ ⊆ every set; ∅ ∈ X is a separate question
∅ has 0 elements, {∅} has 1 element. |P(A)| = 2^|A| (including ∅ and A)
|A×B| = |A|·|B| (a,b) ≠ (b,a) A×B ≠ B×A in general
A∩B common, A∪B everything, A−B = A∩B̄, Ā = U−A, A⊕B = (A−B)∪(B−A)
Logic dictionary: ∩↔∧, ∪↔∨, complement↔¬, ⊆↔→
De Morgan: (A∪B)‾ = Ā∩B̄ (A∩B)‾ = Ā∪B̄
|A∪B| = |A|+|B|−|A∩B| (divisible by k or m: the intersection is divisible by the LCM)
Equality proof 1: X⊆Y and Y⊆X ("Let x ∈ X. Then ... so x ∈ Y")
Equality proof 2: membership table, 1/0, identical columns
Equality proof 3: set-builder + laws of logic
NOT equal: one concrete example (like A=B=C={1})
A−(B−C) ≠ (A−B)−C difference is not associative