Set theory is often called the “language of mathematics.” Virtually every mathematical object—numbers, functions, manifolds, operators—can be formally defined as a set.
Russell’s Paradox and the Necessity of Axioms
In Naive Set Theory, one could define a set through any property : . Bertrand Russell asked: if we define (the set of all sets that do not contain themselves), does contain itself?
Interactive Lab
class RussellSet:
def __contains__(self, item):
# A set that contains itself only if it DOES NOT contain itself
return not (item in item if hasattr(item, "__contains__") else False)
r = RussellSet()
try:
print(f"Does r contain r? {r in r}")
except RecursionError:
print("Infinite recursion: Russell's Paradox detected!")
python
1class RussellSet:
2def __contains__(self, item):
3# A set that contains itself only if it DOES NOT contain itself
4returnnot(item in item ifhasattr(item, "__contains__")else False)
To resolve such paradoxes, the Zermelo-Fraenkel axioms with the Axiom of Choice (ZFC) were developed.
Extensionality: Sets are equal if they have the same elements.
Empty Set: exists.
Power Set: For any set , there exists a set containing all subsets of .
Interactive Lab
from itertools import chain, combinations
def power_set(iterable):
s = list(iterable)
return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))
s = {1, 2, 3}
ps = list(power_set(s))
print(f"Set: {s}")
print(f"Power Set size: {len(ps)}")
print(f"Subsets: {ps}")
python
1from itertools import chain, combinations
2
3def power_set(iterable):
4 s =list(iterable)
5return chain.from_iterable(combinations(s, r)for r inrange(len(s)+1))
6
7s ={1, 2, 3}
8ps =list(power_set(s))
9print(f"Set: {s}")
10print(f"Power Set size: {len(ps)}")
11print(f"Subsets: {ps}")
Constructing the Universe: The Von Neumann Hierarchy
Using these axioms, we can build the natural numbers :
Interactive Lab
def von_neumann_ordinal(n):
if n == 0:
return set()
prev = von_neumann_ordinal(n - 1)
# n = prev U {prev}
return prev | {frozenset(prev)}
for i in range(4):
print(f"{i}: {von_neumann_ordinal(i)}")
python
1def von_neumann_ordinal(n):
2if n ==0:
3returnset()
4 prev = von_neumann_ordinal(n -1)
5# n = prev U {prev}
6return prev |{frozenset(prev)}
7
8for i inrange(4):
9print(f"{i}: {von_neumann_ordinal(i)}")
Ordinals and Cardinals
Ordinals: Describe the order type (position).
Cardinals: Describe the size (quantity). Two sets have the same cardinality if there exists a bijection between them.
Knowledge Check
Which axiom in ZFC was specifically introduced to resolve Russell's Paradox by restricting set construction to subsets of existing sets?
Answer: Axiom of Specification (Separation)
Which axiom in ZFC was specifically introduced to resolve Russell's Paradox by restricting set construction to subsets of existing sets?
The Axiom of Choice (AC)
AC states that given a collection of non-empty sets, we can select one element from each. While intuitive, it leads to non-constructive results like the Banach-Tarski Paradox (decomposing a ball into two identical balls).
Knowledge Check
If |A| = n, what is the cardinality of the power set P(A)?
Answer: 2^n
If |A| = n, what is the cardinality of the power set P(A)?