CITS2211 Discrete Structures (2017) Cardinality and Countability
Highlights What is cardinality? Is it the same as size? Types of cardinality and infinite sets
Reading Sections 45 and 81 84 of Mathematics for Computer Scientists
Why We saw that counting is important related to that is determining the size of things, and cardinality is a generalization of size Infinite sets may seem to be of only theoretical interest, but they make many sorts of calculations more convenient (or give them a solid mathematical foundation) calculus, for one!
Cardinality Definition If A is a finite set, then its cardinality is defined to be the number of elements in A, and denoted A For example, and {0, 1, 2, 3} = 4 {0, 1, {0, 1}} = 3
Equal sized sets Two finite sets A and B have the same cardinality if they have the same number of elements For example, {0, 1, 2} = {a, b, c}
Disjoint sets Observation: If A and B are disjoint (that is, A B = ), then A B = A + B Exercise: Show that A B = A + B A B, when A and B are finite sets (Note this generalises the observation above)
Some observations We can use functions to compare cardinalities of two sets A B if and only if there is a surjection from A to B A A B if and only if there is an injection from A to B B A B
Some observations Thus A = B if and only if there is a bijection from A to B A B
Question But what about infinite sets?
Infinite sets why are they useful? Convenience applied sciences, engineering, calculus physics models modelling computations Limits on what s possible (even in theory)
Infinite sets can we describe their size? Cardinality arose out of the desire to be able to compare the sizes of infinite sets (Eg there seem to be more real numbers than integers, in some sense) There are multiple ways we could define the size of an infinite set but cardinality (based on the idea of pairing off members of two sets bijection) has proved most useful For finite sets, our intuitive idea of the size of a set matches up with the idea of cardinality For infinite sets, they differ
Infinite sets how can we define them? Definition A: A set A is called infinite iff there does not exist any k N such that there is a surjection: f : N k A Definition B: A set A is called infinite iff it has a proper subset with the same cardinality That is, A is infinite iff: B : (B A) ( A = B )
Infinite sets do any exist? ZFC does guarantee us the existence of certain sets In standard ZFC, there are 2 sets we re allowed to start with The axioms say: There is an empty set (We write this as )
Infinite sets do any exist? ZFC does guarantee us the existence of certain sets In standard ZFC, there are 2 sets we re allowed to start with The axioms say: There is an empty set (We write this as ) There is an infinite set (We can write it as I)
Infinite sets do any exist? (2) There are two rules about what s in the infinite set, I: The empty set is a member of the infinite set If we pick some set x which is a member of I, then the set {x} is also a member of I In first-order logic: I : ( I) (x I {x} I)
Infinite sets do any exist? (3) This means that the infinite set is the set I = {, { }, {{ }}, {{{ }}}, {{{{ }}}},, } If we re allowed to assume the existence of this set, there are ways of guaranteeing that the other infinite sets we would like to use (N, Z, R, and so on) all exist
Infinite sets Intuitively, a set B is infinite if B = k does not hold for any k We also have that B k does not hold for any k Recall that, for finite sets, B A if and only if there is a surjection from A to B Let N k denote the set {1, 2,, k}, so N k = k Definition A set B is called infinite if there does not exist any k such that there is a surjection f : N k B
Infinite sets We know lots of infinite sets already: N the natural numbers, like 1, 2, 450, Z the integers, like 1, 20, 52, Q the rational numbers, like 1 2, 2 30, 22 7, R the real numbers, like π, 2,
The key concept Recall that, for finite sets, A = B if and only if there is a bijection from A to B We extend this property to infinite sets Definition We define two sets, A and B to have the same cardinality and we write A = B if and only if there is a bijection between them While this seems uncontroversial, it has some counterintuitive consequences!
Which is bigger? Recall N denotes the set of all natural numbers and N >0 denotes the set of positive natural numbers Clearly N >0 N, but what can we say about the relationship between N >0 and N?
Which is bigger? Recall N denotes the set of all natural numbers and N >0 denotes the set of positive natural numbers Clearly N >0 N, but what can we say about the relationship between N >0 and N? Let f : N N >0 be given by the formula f (n) = n + 1 Then it is easy to see that f is injective (one-to-one) and surjective (onto) and therefore N >0 = N
Which is bigger? Let E denote the set of even natural numbers, so that E = {0, 2, 4, 6, } and let N denote the set of all natural numbers Clearly E N, but what can we say about the relationship between E and N?
Which is bigger? Let E denote the set of even natural numbers, so that E = {0, 2, 4, 6, } and let N denote the set of all natural numbers Clearly E N, but what can we say about the relationship between E and N? Let f : N E be given by the formula f (n) = 2n Then it is easy to see that f is injective (one-to-one) and surjective (onto) and therefore E = N
What about the integers? What is the relationship between N >0 and Z?
What about the integers? What is the relationship between N >0 and Z? If we define f : N >0 Z by { (n 1)/2 n is odd, f (n) = n/2 n is even then we see that f (1) = 0, f (2) = 1, f (3) = 1, f (4) = 2, f (5) = 2, and so this is a bijection and therefore N >0 = Z
N A Countability Definition A set A is called countable if either it is finite or if there is a bijection f : N >0 A So we ve demonstrated that the sets E and Z are both countable Intuitively, a set A is countable if you can list its elements in (some) order {a 1, a 2, a 3, } 1 2 3 4 a 1 a 2 a 3 a 4
Z is countable We can visualise the ordering on Z as follows: 3 2 1 0 1 2 3
Z is countable We can visualise the ordering on Z as follows: 3 2 1 0 1 2 3
Z is countable We can visualise the ordering on Z as follows: 3 2 1 0 1 2 3
Z is countable We can visualise the ordering on Z as follows: 3 2 1 0 1 2 3
Z is countable We can visualise the ordering on Z as follows: 3 2 1 0 1 2 3 We get the list {0, 1, 1, 2, 2, 3, 3, }
N >0 N >0 Consider the set N >0 N >0, whose elements are (p, q) where p, q N >0, and arrange them in the following infinite array (1, 1) (2, 1) (3, 1) (4, 1) (5, 1) (6, 1) (1, 2) (2, 2) (3, 2) (4, 2) (5, 2) (6, 2) (1, 3) (2, 3) (3, 3) (4, 3) (5, 3) (6, 3) (1, 4) (2, 4) (3, 4) (4, 4) (5, 4) (6, 4) (1, 5) (2, 5) (3, 5) (4, 5) (5, 5) (6, 5) (1, 6) (2, 6) (3, 6) (4, 6) (5, 6) (6, 6)
N >0 N >0 Consider the set N >0 N >0, whose elements are (p, q) where p, q N >0, and arrange them in the following infinite array (1, 1) (2, 1) (3, 1) (4, 1) (5, 1) (6, 1) (1, 2) (2, 2) (3, 2) (4, 2) (5, 2) (6, 2) (1, 3) (2, 3) (3, 3) (4, 3) (5, 3) (6, 3) (1, 4) (2, 4) (3, 4) (4, 4) (5, 4) (6, 4) (1, 5) (2, 5) (3, 5) (4, 5) (5, 5) (6, 5) (1, 6) (2, 6) (3, 6) (4, 6) (5, 6) (6, 6)
N >0 N >0 Consider the set N >0 N >0, whose elements are (p, q) where p, q N >0, and arrange them in the following infinite array (1, 1) (2, 1) (3, 1) (4, 1) (5, 1) (6, 1) (1, 2) (2, 2) (3, 2) (4, 2) (5, 2) (6, 2) (1, 3) (2, 3) (3, 3) (4, 3) (5, 3) (6, 3) (1, 4) (2, 4) (3, 4) (4, 4) (5, 4) (6, 4) (1, 5) (2, 5) (3, 5) (4, 5) (5, 5) (6, 5) (1, 6) (2, 6) (3, 6) (4, 6) (5, 6) (6, 6)
N >0 N >0 Consider the set N >0 N >0, whose elements are (p, q) where p, q N >0, and arrange them in the following infinite array (1, 1) (2, 1) (3, 1) (4, 1) (5, 1) (6, 1) (1, 2) (2, 2) (3, 2) (4, 2) (5, 2) (6, 2) (1, 3) (2, 3) (3, 3) (4, 3) (5, 3) (6, 3) (1, 4) (2, 4) (3, 4) (4, 4) (5, 4) (6, 4) (1, 5) (2, 5) (3, 5) (4, 5) (5, 5) (6, 5) (1, 6) (2, 6) (3, 6) (4, 6) (5, 6) (6, 6)
N >0 N >0 Consider the set N >0 N >0, whose elements are (p, q) where p, q N >0, and arrange them in the following infinite array (1, 1) (2, 1) (3, 1) (4, 1) (5, 1) (6, 1) (1, 2) (2, 2) (3, 2) (4, 2) (5, 2) (6, 2) (1, 3) (2, 3) (3, 3) (4, 3) (5, 3) (6, 3) (1, 4) (2, 4) (3, 4) (4, 4) (5, 4) (6, 4) (1, 5) (2, 5) (3, 5) (4, 5) (5, 5) (6, 5) (1, 6) (2, 6) (3, 6) (4, 6) (5, 6) (6, 6)
N N and the positive rationals So N >0 N >0 is countable, that is N >0 N >0 = N >0! Now we can define a surjection g : N >0 N >0 Q + (the positive rationals) by g(p, q) = p/q Hence Q + N >0 N >0 = N >0 Clearly N >0 Q + since N Q + Thus Q + = N >0 In other words the positive rationals are countable too
Countable rationals The positive rationals are countable, so clearly the negative rationals are countable Exercise: find a bijection between the positive rationals and the negative rationals Thus the rationals in their entirety are countable! Positive rationals a 1 a 2 a 3 a 4 a 5 a 6 a 7 a 8 a 9 a 10 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 b 8 b 9 b 10 Negative rationals
What else is countable? We can use these ideas to show that The set of vectors (a, b) with a, b Z is countable (these are often called lattice points ) The set of binary strings of finite length (eg 0001010101) is countable The set of all legitimate Java programs is countable The set of all Turing machines is countable
What isn t countable? Cantor s famous diagonal argument shows that there exist sets which are not countable Consider the set of infinite sequences of the numbers 0 and 1 Is it countable? If it is, we can make a list of all those sequences
Cantor s Diagonal Argument Let s assume we have such a list 0 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 0 1 1 0 0 0 1 0 0 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 1 0 0 1 0 0 1
Cantor s Diagonal Argument We will prove that there is always a sequence of 0 s and 1 s that isn t in the list 0 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 0 1 1 0 0 0 1 0 0 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 1 0 0 1 0 0 1
Cantor s Diagonal Argument 0 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 0 1 1 0 0 0 1 0 0 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 1 0 0 1 0 0 1
Cantor s Diagonal Argument 0 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 0 1 1 0 0 0 1 0 0 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 1 0 0 1 0 0 1 d = 0 0 1 0 1 1 0 1 0 1
Cantor s Diagonal Argument 0 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 0 1 1 0 0 0 1 0 0 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 1 0 0 1 0 0 1 d = 0 0 1 0 1 1 0 1 0 1 d = 1 1 0 1 0 0 1 0 1 0
Cantor s Diagonal Argument Now d the 1st sequence because they differ in the 1st number d the 2nd sequence because they differ in the 2nd number d the 3rd sequence because they differ in the 3rd number d the 4th sequence because they differ in the 4th number d the kth sequence because they differ in the kth number We assumed nothing about the list, except that it could be constructed; we ve reached a contradiction; so our assumption must be false Therefore, any listing must be incomplete the set of all 0-1-sequences is uncountable
Some obvious facts Two obvious facts If S T and T is countable, then so is S Any subset of a countable set is itself countable If S T and S is uncountable, then so is T Any superset of an uncountable set is itself uncountable
Cardinality of a countable set What is the common cardinality of N >0, N, Z, E, etc?
Cardinality of a countable set What is the common cardinality of N >0, N, Z, E, etc? There is a special symbol ℵ 0, pronounced aleph-null to refer to the size of a countably infinite set, so N >0 = ℵ 0, Q = ℵ 0 and Z = ℵ 0 However the real numbers are not countable and so R > ℵ 0
Larger and larger There is no limit to making larger and larger sets, even within the class of uncountable sets Theorem For any set A (finite or infinite, countable or uncountable), there is no function f : A P(A) that is a surjection Therefore A < P(A) < P(P(A)) < P(P(P(A))) and there is an infinite number of differently-sized infinities (See http://wwwscientificamericancom/article/ strange-but-true-infinity-comes-in-different-sizes/)
Cardinality of infinite sets consequences There are properties of finite sets that don t extend to infinite sets: Adding a finite set to an infinite set doesn t increase the size of the infinite set Eg N >0 = N {0} and N >0 = N
How many functions? How many functions from the set {a, b, c} to the set {T, F }?
How many functions? How many functions from the set {a, b, c} to the set {T, F }? Answer: 2 2 2 = 2 3 = 8
How many functions? (2) How many functions from the set {0, 1} to the set N >0? Is the set of those functions countable?
How many functions? (2) How many functions from the set {0, 1} to the set N >0? Is the set of those functions countable?
How many functions? (3) How many functions from the set N to the set {0, 1}?
How many functions? (3) How many functions from the set N to the set {0, 1}? Answer: 2 2 2 2 2 = 2 N = 2 ℵ 0
Impossible things be careful when doing them We ve seen, the number of functions from N to {T, F } is uncountable How many legal Java programs are there? What does these mean for functions from J, the set of all possible Java programs, to the set {T, F }?