# SP20:Lecture 9 Diagonalization

We gave several examples of proofs that set were Countable, and started an example showing that The power set of the naturals is uncountable.

# Countability

Definition: Countable
A set is countable if .

Equivalently, is countable of .

This last definition gives an intuitive definition of countability: if we have a surjection , then we can talk about could write , , etc., so that we can write in the form .

The fact that is surjective means that every element of is for some .

So the informal definition of countability is that is countable if its elements can be put in a (potentially infinite) sequence.

# Examples of countable sets

## ℕ ∪ {-1}

You might imagine the adding an element to a set makes it bigger. While this is true for finite sets, it is not true in general:

Proof:
Let be given by .

To see that is injective, choose arbitrary in and assume . Then so as required.

To see that is surjective, choose an arbitrary . Let . Since we have so . Moreover, as required.

## Even naturals

You might expect that the set of even natural numbers is smaller than the set of all natural numbers. But in fact, funny things happen with infinite sets:

Let be the set of even natural numbers. Then .
Proof: cardinality of evens
Let be given by . is clearly a well-defined function, because every element of the domain is of the form for exactly one . It is also clearly a bijection (details left as an exercise). Thus the evens and the naturals have the same cardinality.

## Integers

You might think that adding an infinite number of numbers to the set of natural numbers might make it bigger. But in fact, this is not (necessarily) so. The integers have the same cardinality as the natural numbers:

Proof: cardinality of the integers
The following image clearly defines a bijection: Details are left as an exercise.

## ℕ ⨯ ℕ

You might imagine that the set of pairs of natural numbers is larger than the set of natural numbers, but in fact they can still be matched one-to-one:

Proof: │ℕ ⨯ ℕ│ = │ℕ│
Note: Although this proof creates a bijection by enumerating the elements on the diagonal, this technique is 'not' called diagonalization (which is used to prove that sets are uncountable). This often leads to confusion.

We wish to construct a bijection .

We can draw a table containing all pairs of natural numbers:

0 1 2
0 (0,0) (0,1) (0,2)
1 (1,0) (1,1) (1,2)
2 (2,0) (2,1) (2,2)

Now, giving a function is the same as giving a method for iterating through this table (identifying the 0th element, the 1th element, etc.). will be a bijection if we enumerate each pair exactly once.

To do so, we will start in the upper left hand corner, and then enumerate each pair along each diagonal, starting in the lower left, and ending in the upper right. For example, the first few pairs would be:

n f(n)
0 (0,0)
1 (1,0)
2 (0,1)
3 (2,0)
4 (1,1)
5 (0,2)
6 (3,0)
7 (2,1)
8 (1,2)
9 (0,3)
10 (4,0)

This pattern clearly hits each pair once, and doesn't hit any pair more than once, so it defines a bijection.

Note: I would consider this a complete and correct proof. It clearly defines a function, and explains why it is bijective. Some students have worried about the lack of clarity of the function.

To the address the former concern, we could write down a formula for this function. However, it is 'not' necessary to write down a formula for every function; indeed many functions do not have formulae at all. Rather, we must check that the function definition is unambiguous. A good way to reason about this informally is to ask "how would I go about computing f(73)?" If there is enough description to answer this question (and it will only give one answer!), the function is probably well defined.

If we wanted to provide more specificity on the bijectivity of the function, we could note that the function first lists every pair that sums to 0, then all pairs that sum to 1, and then all pairs that sum to 2, and so on. So a pair (a,b) will be on the (a+b)th diagonal (and will be the bth element of that diagonal).

# Examples of uncountable sets

At this point, you might suspect that all sets are countable. However, this is not the case.

## Diagonalization

A common technique to prove that a set is uncountable is called diagonalization.

The most famous examples of diagonalization are the proofs that the power set of the naturals is uncountable and the set of reals is uncountable.

To use diagonalization to prove that a set is uncountable, you typically do a proof by contradiction: assume that 'is' countable, so that there is a surjection , and then find a contradiction by constructing a diabolical object that is not in the image of . This contradicts the surjectivity of , completing the proof.

To construct , you typically imagine an (infinite) table describing : the row describes . In the table, you represent each element of as an infinite sequence of values; so that the table has a column for each natural number. The exact structure of the table depends on the set .

You then find by changing every value on the diagonal: you ensure that differs from in the th column. Since for all , , cannot be in the image of , so cannot be surjective.

## The set of subsets of the natural numbers

is uncountable.
Proof:
We use diagonalization to prove the claim. Suppose, for the sake of contradiction, that is countable. Then there exists a surjection .

We can imagine drawing as a table. For example, the first few outputs of might look like this:

i f(i)
0
1
2 the set of even numbers
3 the set of odd numbers
4

To put the sets into a common format, we might expand each set as a sequence of yes/no questions, with the th column of indicating whether :

i f(i)
0 (yes) yes yes yes yes
1 no (no) no no no
2 the set of even numbers yes no (yes) no yes
3 the set of odd numbers no yes no (yes) no
4 yes no no no (no)

Now, we construct a new diabolical set by changing each element on the diagonal. In this example, we have a "yes" in the 0th column of row 0 (meaning , so in our diabolical set we put a "no" in column 0 (by ensuring . Similarly, we have a "no" in row 1, column 1 (so ), so we put a "yes" in column 1 of (by placing ). Continuing in this fashion, we have

no yes no no yes

In general, we include if and only if . We can write this succinctly by defining . Note that although we used a specific example to figure out how to construct , this construction will work for an arbitrary .

Now, cannot be in the image of , because for any , differs from in the th column. If then , and if then . in either case, . Thus cannot be surjective, a contradiction.