# Constructing a sequence to show that the set is countable

I am studying for my exam and could not understand why my tutor constructed such sequences to show that the following sets are countable:

for example: to show that N×N = {(n,m):n∈N, m∈N} is countable, he constructed the following sequence:

(1,1), (1,2), (1,3), ...
(2,1), (2,2), (2,3), ...
(3,1), (3,2), (3,3), ...
........................
........................


Construct a sequence diagonally: (1,1),(2,1),(1,2),(3,1),(2,2),(1,3),...

Another example: If $A_k$, $k=1,2,\dots$, $k\in N$ are countable sets, then $A= \bigcup\limits_{k=1}^\infty A_k$ is also countable. Method he used:

a11, a12, a13, a14, ...         => Contains all elements of A1
a21, a22, a23, a24, ...         => Contains all elements of A2
a31, a32, a33, a34, ...         => Contains all elements of A3
.......................
.......................


Again construct a sequence diagonally: a11, a21, a12, a31,a22,a13,...

I know that a set A is countable if there exists a surjection $f : N \to A$. However, is it really necessary to construct a sequence in such manner (diagonally) to show that those sets are countable? For the second question, if I construct a sequence like: a11,a22,a13,...,a1n,a21,a22,...,a2n,.... would not it also show that my set is countable? Because it seems like still there exists a surjective function f from N to A. Am I wrong?

Could you please give me some tips, method suggestions to how to figure out if a set (infinite or finite) is countable or not?

The important point is to show that every element $a$ of the domain of $f$ is actually reached, i.e. that there is a (finite, obviously) number $n \in \mathbb{N}$ such that $f(n)=a$.

Now, you can define $f$ by the sequence of its images of $1,2,\ldots$. There is no substantial difference between the function $f$ and the sequence $(f(1),f(2),\ldots)$. In fact, the usual definition of a sequence over a set $X$ is "a function from $\mathbb{N}$ to $X$".

But if you do that, it doesn't really make sense to put an ellipsis ($\ldots$) into the middle of the sequence, if the ellipsis stands for infinitly many elements. Say I write $f = (0,1,\ldots,-1,-2,\ldots)$ for a function from $\mathbb{N}$ to $\mathbb{Z}$. What's the preimage of $-1$ then, i.e. for which $n$ do I have $f(n) = -1$? The answer is for none - no finite $n$ gets me past the first ellipsis! In other words, you are in trouble because there are elements in your "sequence" which have infinitly many predecessors.

The way out of this dilemma is working diagonally, which is exactly what your tutor did. Instead of saying $f = (a_{1,1},a_{1,2},\ldots,a_{2,1},a_{2,2},\ldots,\ldots)$, which per the above doesn't make much sense, and certainly doesn't define a function onto $\mathbb{N}^2$, you instead set $f = (a_{1,1},a_{1,2},a_{2,1},a_{1,3},a_{2,2},a_{3,1},\ldots)$. Now, every element has only finitly many predecessors, since you can draw the diagonal through every element, and there will be only finitely many elements above that diagnoal. All is thus well, because you can then be sure that your function is actuall onto $\mathbb{N}^2$.

In your example, you actually stated $(a_{1,1},\ldots,a_{1,n},a_{2,1},\ldots,a_{2,n},\ldots)$ as the sequence of function values. That makes no sense though, since the set $A_1$ (and all the other sets too) may contain infinitly many elements.

And since you asked - there are lots of ways to define $f$, working diagonally ist just a very simply possibility. Another one is to set $$f(n) = \begin{cases} a_{i,j} & \text{if n=p_i^j where p_i is the i-th prime (1 excluded)} \\ a_{1,1} & \text{otherwise} \end{cases}$$ Since the factorization into primes is unqiue in $\mathbb{N}$, $f$ is well-defined. It also quite obviously surjective - the preimage of $a_{i,j}$ is $p_i^j$. Mappings of this kind actually play a role in the proof of Gödel's incompleteness theorem.

• thank you very much. it was very explanative! – Amadeus Bachmann Oct 16 '12 at 0:08
• I'm leery of calling the particular process at work here 'diagonalization'; that's a term with very particular meanings that don't really fit this process. – Steven Stadnicki Oct 16 '12 at 0:13
• @StevenStadnicki Hm, true, will change to "work diagonally" or something... – fgp Oct 16 '12 at 0:16

First of all, a surjective function is a sequence, so there's no way around constructing a sequence.

Second, in order to be convincingly surjective, a sequence has to follow an easily comprehended rule. Your sequence, $a_{11},a_{22},a_{13}, \dots,a_{1n},\dots$, I am at a loss to comprehend what comes in the first ellipsis, and where if ever $a_{12}$ shows up. The sequence your tutor constructed is by no means the only one possible, but it's probably the simplest one to understand.

• thank you so much for your reply. can you give me any other examples to construct such a sequence? – Amadeus Bachmann Oct 15 '12 at 23:35
• Here's one way: first list all the $a_{mn}$ with $mn=1$, then all the ones with $mn=2$, then $mn=3$, etc.; among terms with the same $mn$, list in increasing order of $m$. This gives you $a_{11},a_{12},a_{21},a_{13},a_{31},a_{14},a_{22},a_{41},\dots$. Or, follow this path: $11,12,22,21,31,32,33,23,13,14,24,34,44,43,42,41,51,52,\dots$. There are many sytematic ways to do it. – Gerry Myerson Oct 16 '12 at 4:54