Set Theory
In this session, we cover the basics of set theory, including different ways to describe sets, fundamental set operations, and important properties and laws governing sets.
Session Preparation:¶
Brooks: Chapter 3.
Resources Danish Class¶
Exercises¶
Exercise 1: Roster vs. Set-Builder (equivalence)¶
For each pair, decide whether the two notations define the same set.
-
\(A=\{2,4,6,8\}\) and \(A=\{\,x\in\mathbb Z\mid 1\le x\le 8,\; x\text{ even}\,\}\). (1)
- Same.
-
\(B=\{a,e,i,o,u\}\) and \(B=\{\,l\mid l\text{ is a vowel in English}\,\}\). (1)
- Same.
-
\(C=\{x\in\mathbb Z\mid x^2<10\}\) and \(C=\{-3,-2,-1,0,1,2,3\}\). (1)
- Same.
Exercise 2: Set Operations and Cardinality¶
Consider the sets \(A=\{e, f, g\}\) and \(B=\{a, e, g, h\}\). Determine each set and its cardinality:
-
\(A \cup B\) and \(|A \cup B|\) (1)
- \(\{a, e, f, g, h\}\) and \(5\).
-
\(A \cap B\) and \(|A \cap B|\) (1)
- \(\{e, g\}\) and \(2\).
-
\(B-A\) and \(|B-A|\) (1)
- \(\{a, h\}\) and \(2\).
-
\(A-B\) and \(|A-B|\) (1)
- \(\{f\}\) and \(1\).
Exercise 3: Core Operations (compute explicitly)¶
Let \(U=\{1,2,\dots,10\}\), \(A=\{1,3,4,8,10\}\), \(B=\{2,3,7,8\}\).
-
\(A\cup B\) (1)
- \(\{1,2,3,4,7,8,10\}\).
-
\(A\cap B\) (1)
- \(\{3,8\}\).
-
\(A\setminus B\) and \(B\setminus A\) (1)
- \(A\setminus B=\{1,4,10\}\), \(B\setminus A=\{2,7\}\).
-
\(A^\mathrm c\) (complement in \(U\)) (1)
- \(\{2,5,6,7,9\}\).
-
\(A\oplus B\) (symmetric difference) (1)
- \(\{1,2,4,7,10\}\).
Exercise 4: Membership \(\in\) / \(\notin\)¶
Let \(U=\mathbb Z\), \(E=\{x\in\mathbb Z\mid x\equiv 0\pmod 2\}\), \(O=U\setminus E\).
-
Decide: \( -7\in E\ ?\) (1)
- No, \(-7\in O\).
-
Decide: \(0\in E\ ?\) (1)
- Yes.
-
Decide: \( \pi\in U\ ?\) (1)
- No, \(\pi\notin\mathbb Z\).
Exercise 5: Subset vs. Proper Subset¶
Let \(A=\{1,2\}\), \(B=\{1,2,3\}\), \(C=\{1,2\}\).
-
Is \(A\subseteq B\)? Is \(A\subset B\)? (1)
- Yes; Yes (proper).
-
Is \(A\subseteq C\)? Is \(A\subset C\)? (1)
- Yes; No (equal, not proper).
-
Give an example of two disjoint nonempty subsets of \(\{1,2,3,4\}\). (1)
- \(\{1,3\}\) and \(\{2,4\}\).
Exercise 6: Cardinality and Power Set¶
-
Compute \(|\mathcal P(\{a,b,c\})|\) and list \(\mathcal P\).
\(2^3=8\). \(\{\emptyset,\{a\},\{b\},\{c\},\{a,b\},\{a,c\},\{b,c\},\{a,b,c\}\}\).
-
For \(S=\{1,2,3,4,5\}\), how many subsets contain the element \(1\)?
\(2^{4}=16\) (choose freely among the other 4).
Exercise 7: Interval Notation (translation)¶
Translate between set-builder and interval notation in \(\mathbb R\).
-
\(\{x\in\mathbb R\mid -2\le x<3\}\) (1)
- \([-2,3)\).
-
\((-∞,0]\cup(5,∞)\) in builder form. (1)
- \(\{x\in\mathbb R\mid x\le 0\ \text{or}\ x>5\}\).
Exercise 8: Set Identities¶
-
Prove that \(A \cup (A \cap B) = A\) using fundamental set identities.
\[ \begin{aligned} A \cup (A \cap B) &= (A \cup A)\,\cap\,(A \cup B) && \text{distributivity}\\ &= A \cap (A \cup B) && \text{idempotence}\\ &= A && \text{absorption.} \end{aligned} \] -
Prove that \(\left(A \cap A^{c}\right) \cup (A \cap B) \cup \left(A^{c} \cap B\right) = B\) using set identities.
\[ \begin{aligned} (A \cap A^c) \cup (A \cap B) \cup (A^c \cap B) &= \varnothing \cup \big[(A \cap B) \cup (A^c \cap B)\big] && A \cap A^c=\varnothing \\ &= B \cap (A \cup A^c) && \text{distributivity}\\ &= B \cap U && \text{complement law}\\ &= B. && \text{identity} \end{aligned} \] -
Prove that \(\big((A^c \cup B)^c\big) \cup A = A\) using set identities.
\[ \begin{aligned} \big((A^c \cup B)^c\big) \cup A &= \big((A^c)^c \cap B^c\big) \cup A && \text{De Morgan}\\ &= (A \cap B^c) \cup A && \text{double complement}\\ &= A \cup (A \cap B^c) \\ &= A. && \text{absorption} \end{aligned} \] -
Determine if \((A \oplus B) \cup A = A \cup B\) using set identities.
\[ \begin{aligned} (A \oplus B) \cup A &= \big((A \cap B^c) \cup (A^c \cap B)\big) \cup A && \text{def.\ of }\oplus\\ &= \big(A \cap B^c\big) \cup A \cup \big(A^c \cap B\big)\\ &= A \cup \big(A^c \cap B\big) && A \cup (A \cap X)=A\\ &= (A \cup A^c)\cap (A \cup B) && \text{distributivity}\\ &= U \cap (A \cup B)\\ &= A \cup B. \end{aligned} \]
Challenge Exercises¶
Challenge Exercise 1: Infinite sets and countability¶
In set theory, we distinguish between finite, countably infinite, and uncountably infinite sets.
A set is countably infinite if its elements can be put into one-to-one correspondence with \(\mathbb{N}=\{0,1,2,\dots\}\).
-
Prove that the set of even integers \(E=\{2n \mid n\in\mathbb{Z}\}\) is countably infinite.
Define bijection \(f:\mathbb{Z}\to E\), \(f(n)=2n\). Hence \(|E|=|\mathbb{Z}|\).
-
Show that the set of rational numbers \(\mathbb{Q}\) is countably infinite.
Arrange fractions \(\tfrac{p}{q}\) in a grid, traverse diagonally (Cantor zig-zag), and omit duplicates. This lists all rationals.
-
Argue why the set of real numbers \(\mathbb{R}\) is uncountable.
Cantor’s diagonal: given any enumeration of decimals, construct a number differing in the \(i\)-th digit from the \(i\)-th entry. Contradiction → uncountable.
Challenge Exercise 2: Paradoxes and the power set¶
For any set \(S\), its power set \(\mathcal{P}(S)\) has strictly greater cardinality than \(S\).
-
Prove that no function \(f:S\to\mathcal{P}(S)\) can be surjective.
Suppose \(f\) surjective. Define \(T=\{x\in S\mid x\notin f(x)\}\). Then \(T\in\mathcal{P}(S)\).
If \(T=f(y)\), contradiction: \(y\in T\iff y\notin f(y)=T\). Impossible. -
Interpret why this implies there is no largest infinity.
If \(|\mathcal{P}(S)|>|S|\), then starting with \(\mathbb{N}\), we get a hierarchy: \(\mathcal{P}(\mathbb{N}), \mathcal{P}(\mathcal{P}(\mathbb{N}))\), etc. Thus infinities form an endless ladder.
-
Reflect: what happens if we attempt to apply this idea to the “set of all sets”?
Leads to Russell’s paradox: the “set of all sets not containing themselves” yields contradiction. Avoided in ZFC axioms.
Challenge Exercise 3: Encoding sets as numbers¶
Any finite subset of \(\mathbb{N}\) can be uniquely represented by a natural number. One standard method uses binary expansion:
For \(A \subseteq \{0,1,2,\dots,n-1\}\), define \(\operatorname{code}(A)=\sum_{i \in A} 2^i\)
-
Encode \(A=\{0,3,4\}\) as a number.
\(2^0+2^3+2^4=1+8+16=25\).
-
Decode the number \(45\) into its corresponding subset of \(\{0,1,2,3,4,5\}\).
\(45=32+8+4+1=2^5+2^3+2^2+2^0\). Subset: \(\{0,2,3,5\}\).
-
Explain why this coding gives a bijection between \(\mathcal{P}(\{0,1,\dots,n-1\})\) and the integers \(0,1,\dots,2^n-1\).
Each subset has a unique binary mask, and each binary string corresponds to exactly one subset. Hence bijection.
-
How does this idea connect to computer science (bitsets, databases, logic)?
It’s the foundation of bitsets, permissions flags, and truth tables: subsets stored as integers enable efficient computation.