MAT2033 · Week 4 · sets and functions

Sets: operations, power sets and proving set equality

Subsets, power sets, Cartesian products, set operations, and proving set equality with a membership table or double inclusion.

setelementroster methodset-builder notationempty setsubsetproper subsetcardinalitypower setCartesian productordered pairunionintersectiondifferencecomplementsymmetric differencedisjointVenn diagrammembership tableset identityinclusion-exclusion

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:

  1. A set is unordered and has no repeats. {1,2,3}={3,1,2}={1,1,2,3}\{1, 2, 3\} = \{3, 1, 2\} = \{1, 1, 2, 3\}.
  2. ∈\in and ⊆\subseteq are different questions. The first asks about a single element, the second about all elements.
  3. ∣P(A)∣=2∣A∣\lvert \mathcal{P}(A) \rvert = 2^{\lvert A \rvert}. Don’t forget to write the empty set and AA itself.
  4. Set operations are logical operations. ∩=∧\cap = \land, ∪=∨\cup = \lor, complement =¬= \lnot.
  5. Two directions for equality, one example for inequality.

Basic definitions

Set: a well-defined collection of objects. The objects are called elements: a∈Aa \in A.

Two ways of writing:

  • Roster method (list): A={2,4,6,8}A = \{2, 4, 6, 8\}.
  • Set-builder notation: A={x∈Z+∣x is even and x<10}A = \{x \in \mathbb{Z}^+ \mid x \text{ is even and } x < 10\}.

Standard sets: N={0,1,2,… }\mathbb{N} = \{0, 1, 2, \dots\} (including 0 in Rosen), Z\mathbb{Z} the integers, Z+\mathbb{Z}^+ the positive integers, Q\mathbb{Q} the rationals, R\mathbb{R} the reals. Intervals: [a,b][a, b], (a,b)(a, b) and so on.

ConceptDefinitionExample
Empty set ∅\emptysetthe set with no elements{x∈R∣x2=−1}=∅\{x \in \mathbb{R} \mid x^2 = -1\} = \emptyset
Subset A⊆BA \subseteq B∀x (x∈A→x∈B)\forall x\,(x \in A \to x \in B){1,2}⊆{1,2,3}\{1, 2\} \subseteq \{1, 2, 3\}
Proper subset A⊂BA \subset BA⊆BA \subseteq B and A≠BA \ne B{1}⊂{1,2}\{1\} \subset \{1, 2\}
Equality A=BA = BA⊆BA \subseteq B and B⊆AB \subseteq A{1,2}={2,1}\{1, 2\} = \{2, 1\}
Cardinality ∣A∣\lvert A \rvertthe number of elements in a finite set∣{a,{a}}∣=2\lvert \{a, \{a\}\} \rvert = 2

For every set, ∅⊆A\emptyset \subseteq A and A⊆AA \subseteq A. The empty set is a subset because of “vacuous truth”: since x∈∅x \in \emptyset is never true, the conditional is automatically true.

PITFALL · ∅\emptyset versus {∅}\{\emptyset\}. ∅\emptyset is an empty box. {∅}\{\emptyset\} is a box with an empty box inside: it has one element. ∣∅∣=0\lvert \emptyset \rvert = 0, ∣{∅}∣=1\lvert \{\emptyset\} \rvert = 1.

Power sets and Cartesian products

Power set P(A)\mathcal{P}(A): the set of all subsets of AA.

P({a,b,c})={∅,{a},{b},{c},{a,b},{a,c},{b,c},{a,b,c}}\mathcal{P}(\{a, b, c\}) = \{\emptyset, \{a\}, \{b\}, \{c\}, \{a, b\}, \{a, c\}, \{b, c\}, \{a, b, c\}\}

8 elements: 232^3. Why 2n2^n? There are two choices for each element: it is either in the subset or not. With nn elements, 2⋅2⋯2=2n2 \cdot 2 \cdots 2 = 2^n.

To write them systematically, group by size: 0 elements (1 subset), 1 element (3), 2 elements (3), 3 elements (1).

Cartesian product A×B={(a,b)∣a∈A, b∈B}A \times B = \{(a, b) \mid a \in A,\ b \in B\}. The elements are ordered pairs: (a,b)=(c,d)(a, b) = (c, d) if and only if a=ca = c and b=db = d. With A={1,2}A = \{1, 2\}, B={p,q}B = \{p, q\}:

A×B={(1,p),(1,q),(2,p),(2,q)},∣A×B∣=∣A∣⋅∣B∣.A \times B = \{(1, p), (1, q), (2, p), (2, q)\}, \qquad \lvert A \times B \rvert = \lvert A \rvert \cdot \lvert B \rvert.

The elements of B×AB \times A look like (p,1)(p, 1), with the first coordinate from BB. So in general A×B≠B×AA \times B \ne B \times A. A×∅=∅A \times \emptyset = \emptyset.

Set operations

OperationDefinition (set-builder)Logic counterpart
Union A∪BA \cup B{x∣x∈A∨x∈B}\{x \mid x \in A \lor x \in B\}∨\lor
Intersection A∩BA \cap B{x∣x∈A∧x∈B}\{x \mid x \in A \land x \in B\}∧\land
Difference A−BA - B{x∣x∈A∧x∉B}\{x \mid x \in A \land x \notin B\}p∧¬qp \land \lnot q
Complement A‾\overline{A}{x∈U∣x∉A}\{x \in U \mid x \notin A\}¬\lnot
Symmetric difference A⊕BA \oplus B(A−B)∪(B−A)(A - B) \cup (B - A)⊕\oplus

If A∩B=∅A \cap B = \emptyset, then AA and BB are disjoint.

Example. U={1,…,8}U = \{1, \dots, 8\}, A={1,2,3,4}A = \{1, 2, 3, 4\}, B={3,4,5,6}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∣\lvert A \cup B \rvert = \lvert A \rvert + \lvert B \rvert - \lvert A \cap B \rvert. In the example, 4+4−2=64 + 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:

LawIdentity
IdentityA∪∅=AA \cup \emptyset = A, A∩U=AA \cap U = A
DominationA∪U=UA \cup U = U, A∩∅=∅A \cap \emptyset = \emptyset
ComplementA∪A‾=UA \cup \overline{A} = U, A∩A‾=∅A \cap \overline{A} = \emptyset, A‾‾=A\overline{\overline{A}} = A
DistributiveA∩(B∪C)=(A∩B)∪(A∩C)A \cap (B \cup C) = (A \cap B) \cup (A \cap C)
De MorganA∪B‾=A‾∩B‾\overline{A \cup B} = \overline{A} \cap \overline{B}, A∩B‾=A‾∪B‾\overline{A \cap B} = \overline{A} \cup \overline{B}
AbsorptionA∪(A∩B)=AA \cup (A \cap B) = A, A∩(A∪B)=AA \cap (A \cup B) = A
DifferenceA−B=A∩B‾A - B = A \cap \overline{B}

Three ways to prove set equality

Way 1: Double inclusion

To show X=YX = Y, show X⊆YX \subseteq Y and Y⊆XY \subseteq X separately.

Theorem. A∪B‾=A‾∩B‾\overline{A \cup B} = \overline{A} \cap \overline{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 \cap C) = (A - B) \cup (A - C).

AABBCCB∩CB \cap CA−(B∩C)A - (B \cap C)A−BA - BA−CA - C(A−B)∪(A−C)(A-B) \cup (A-C)
11110000
11001011
10101101
10001111
01110000
01000000
00100000
00000000

“Since the columns for A−(B∩C)A - (B \cap C) and (A−B)∪(A−C)(A - B) \cup (A - C) are identical, the two sets are equal.” ∎

When filling in the X−YX - Y column, the rule is: 1 if “1 in XX AND 0 in YY”. In the rows where A=0A = 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}\{1\}, ∅\emptyset), 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 ideaThe truth
{1,1,2}\{1, 1, 2\} has three elementsIt has two elements; repeats are not counted
∅∈A\emptyset \in A is always true∅⊆A\emptyset \subseteq A is always true; ∈\in is a separate question
∣{∅}∣=0\lvert \{\emptyset\} \rvert = 0It is 1
Forgetting ∅\emptyset or AA when writing P(A)\mathcal{P}(A)Count check: 2∣A∣2^{\lvert A \rvert} elements
A×B=B×AA \times B = B \times AOrdered pairs; usually different
∣A∪B∣=∣A∣+∣B∣\lvert A \cup B \rvert = \lvert A \rvert + \lvert B \rvertSubtract the intersection
In “divisible by 4 or 6”, the intersection is the multiples of 24LCM: multiples of 12
It came out equal in one example, so they are equalA general proof for equality; a single example for inequality
A−B=B−AA - B = B - ADifference is not commutative
Writing only one direction in double inclusionBoth directions are needed

Test yourself

Exam-style questions. Solve them on paper first, then reveal the answer.

Question 1easy

Let U={1,2,…,10}U = \{1, 2, \dots, 10\}, A={2,3,5,7}A = \{2, 3, 5, 7\} and B={1,2,3,4,5}B = \{1, 2, 3, 4, 5\}. Find A∩BA \cap B, A∪BA \cup B, A−BA - B, B−AB - A and A‾\overline{A}.

Show answer
A∩B = {2,3,5}, A∪B = {1,2,3,4,5,7}, A−B = {7}, B−A = {1,4}, Ā = {1,4,6,8,9,10}

Intersection: the common elements 2, 3, 5. Union: everything, without repeating. A−BA - B: remove from AA the elements that are in BB, leaving only 7. B−AB - A: remove 2, 3, 5 from BB: {1,4}\{1, 4\}. Complement: elements in UU that are not in AA.

Question 2easy

Find ∣P({a,b,c,d})∣\lvert \mathcal{P}(\{a, b, c, d\}) \rvert and ∣P(P(∅))∣\lvert \mathcal{P}(\mathcal{P}(\emptyset)) \rvert.

Show answer
16 and 2

A set with nn elements has 2n2^n subsets: 24=162^4 = 16. P(∅)={∅}\mathcal{P}(\emptyset) = \{\emptyset\}, which has one element. Its power set is {∅,{∅}}\{\emptyset, \{\emptyset\}\}, with two elements: 21=22^1 = 2.

Question 3easy

True or false? (a) ∅∈{1,2}\emptyset \in \{1, 2\} (b) ∅⊆{1,2}\emptyset \subseteq \{1, 2\} (c) {1}∈{1,{1}}\{1\} \in \{1, \{1\}\} (d) {1}⊆{1,{1}}\{1\} \subseteq \{1, \{1\}\} (e) {{1}}⊆{1}\{\{1\}\} \subseteq \{1\}

Show answer
(a) F (b) T (c) T (d) T (e) F

(a) The elements of {1,2}\{1, 2\} are 1 and 2; ∅\emptyset is not one of them. (b) The empty set is a subset of every set. (c) {1}\{1\} is in the list as the second element. (d) The only element of {1}\{1\} is 1, and it is in the set. (e) The element of {{1}}\{\{1\}\} is {1}\{1\}; the only element of the set {1}\{1\} is 1. {1}≠1\{1\} \ne 1, so false. ∈\in asks "is it an element?", ⊆\subseteq asks "are all its elements inside?".

Question 4medium

Let A={1,2}A = \{1, 2\} and B={x,y,z}B = \{x, y, z\}. Find ∣A×B∣\lvert A \times B \rvert, ∣A×B×A∣\lvert A \times B \times A \rvert and ∣P(A×B)∣\lvert \mathcal{P}(A \times B) \rvert.

Show answer
6, 12, 64

∣A×B∣=2⋅3=6\lvert A \times B \rvert = 2 \cdot 3 = 6. The triple product: 2⋅3⋅2=122 \cdot 3 \cdot 2 = 12. A×BA \times B is a set with 6 elements, so its power set has 26=642^6 = 64 elements.

Question 5medium

Use a membership table to determine whether (A∪B)−C=(A−C)∪(B−C)(A \cup B) - C = (A - C) \cup (B - C).

Show answer
Equal (identical columns)

8 rows, in the order ABCA B C = 111, 110, 101, 100, 011, 010, 001, 000. A∪BA \cup B: 1,1,1,1,1,1,0,0. (A∪B)−C(A\cup B) - C ("1 in A∪BA \cup B and 0 in CC"): 0,1,0,1,0,1,0,0. A−CA - C: 0,1,0,1,0,0,0,0. B−CB - 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)−CA - (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}A = B = C = \{1\}: B−C=∅B - C = \emptyset, so A−(B−C)={1}A - (B - C) = \{1\}. A−B=∅A - B = \emptyset, so (A−B)−C=∅(A - B) - C = \emptyset. 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\lvert P \cup J \rvert = \lvert P \rvert + \lvert J \rvert - \lvert P \cap J \rvert = 25 + 18 - 9 = 34. The 9 students who take both were counted twice, and we subtracted them once. Students who take neither: 40−34=640 - 34 = 6.

Question 8hard

Prove that A∩(B−A)=∅A \cap (B - A) = \emptyset for all sets AA and BB.

Show answer
An element of both would satisfy x ∈ A and x ∉ A, a contradiction.

Suppose, for contradiction, that some x∈A∩(B−A)x \in A \cap (B - A). Then x∈Ax \in A and x∈B−Ax \in B - A; the second means x∈Bx \in B and x∉Ax \notin A. So x∈Ax \in A and x∉Ax \notin 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‾\overline{A \cap B} = \overline{A} \cup \overline{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)}\overline{A \cap B} = \{x \mid x \notin A \cap B\} = \{x \mid \lnot(x \in A \land x \in B)\} (def. of intersection)={x∣x∉A∨x∉B}= \{x \mid x \notin A \lor x \notin B\} (De Morgan's law for logic)={x∣x∈A‾∨x∈B‾}= \{x \mid x \in \overline{A} \lor x \in \overline{B}\} (def. of complement)=A‾∪B‾= \overline{A} \cup \overline{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\lvert A_4 \rvert = \lfloor 200/4 \rfloor = 50, ∣A6∣=⌊200/6⌋=33\lvert A_6 \rvert = \lfloor 200/6 \rfloor = 33. The numbers divisible by both 4 and 6 are those divisible by lcm⁡(4,6)=12\operatorname{lcm}(4, 6) = 12: ⌊200/12⌋=16\lfloor 200/12 \rfloor = 16. Total 50+33−16=6750 + 33 - 16 = 67. Pitfall: thinking the intersection is the multiples of 4⋅6=244 \cdot 6 = 24; the correct one is the LCM, 12.

Question 11easy

List the elements of {x∈Z∣x2<10}\{x \in \mathbb{Z} \mid x^2 < 10\}.

Show answer
{−3, −2, −1, 0, 1, 2, 3}

If x2<10x^2 < 10 then ∣x∣≤3\lvert x \rvert \le 3 (32=9<103^2 = 9 < 10, 42=164^2 = 16). Don't forget the negatives: the square of −3-3 is also 9.

Question 12hard

Prove that if A⊆BA \subseteq B, then P(A)⊆P(B)\mathcal{P}(A) \subseteq \mathcal{P}(B).

Show answer
If S ∈ P(A), then S ⊆ A ⊆ B, so S ∈ P(B).

Let S∈P(A)S \in \mathcal{P}(A). By definition S⊆AS \subseteq A. Let x∈Sx \in S; then x∈Ax \in A, and since A⊆BA \subseteq B, x∈Bx \in B. So S⊆BS \subseteq B, i.e. S∈P(B)S \in \mathcal{P}(B). Since SS was arbitrary, P(A)⊆P(B)\mathcal{P}(A) \subseteq \mathcal{P}(B). ∎ A subset proof is always written with the pattern "Let x∈Xx \in X ... then x∈Yx \in 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