Cardinality is a measure of the “number of elements” of a set. For finite sets, this is just a natural number, but for infinite sets, things become more complex.
Equinumerosity
Two sets and have the same cardinality, , if there exists a bijection .
A set is countably infinite if it has the same cardinality as the natural numbers . Surprisingly, the set of rational numbers is countable, while the set of real numbers is not.
Interactive Lab
def count_to_infinity(limit):
# Demonstrating that Even numbers are equinumerous to Natural numbers
# f(n) = 2n
evens = [(n, 2*n) for n in range(limit)]
return evens
print("Mapping N to Evens (First 5):")
for pair in count_to_infinity(5):
print(f"n={pair[0]} maps to even={pair[1]}")
python
1def count_to_infinity(limit):
2# Demonstrating that Even numbers are equinumerous to Natural numbers
3# f(n) = 2n
4 evens =[(n, 2*n)for n inrange(limit)]
5return evens
6
7print("Mapping N to Evens (First 5):")
8for pair in count_to_infinity(5):
9print(f"n={pair[0]} maps to even={pair[1]}")
Cantor’s Diagonal Argument
Georg Cantor proved that the cardinality of the real numbers (the Continuum, ) is strictly greater than the cardinality of the natural numbers (). He used a technique called diagonalization.
Interactive Lab
import random
def cantors_diagonal(rows):
"""Given a list of decimal expansions, create a number that isn't in the list."""
new_number = "0."
for i in range(len(rows)):
# Take the i-th digit of the i-th row and change it
digit = int(rows[i][i+2]) # offset for "0."
new_digit = (digit + 1) % 10
new_number += str(new_digit)
return new_number
sequences = ["0.12345", "0.55555", "0.98765", "0.11111", "0.00000"]
print(f"Generated number not in list: {cantors_diagonal(sequences)}")
python
1import random
2
3def cantors_diagonal(rows):
4"""Given a list of decimal expansions, create a number that isn't in the list."""
5 new_number ="0."
6for i inrange(len(rows)):
7# Take the i-th digit of the i-th row and change it
14print(f"Generated number not in list: {cantors_diagonal(sequences)}")
Knowledge Check
What is the result of the union of two countably infinite sets?
Answer: A countably infinite set.
What is the result of the union of two countably infinite sets?
Cantor’s Theorem
Cantor’s Theorem states that for any set , the cardinality of its power set is strictly greater than the cardinality of :
This results in an infinite hierarchy of infinities:
Knowledge Check
Does there exist a set with cardinality between integers and real numbers?
Answer: No, according to the Continuum Hypothesis.
Does there exist a set with cardinality between integers and real numbers?