Show that the set of all computer programs
in any particular programming language is countable.
This can be proved by noting that a computer programs in a
particular language can be thought of as a string of characters
from a finite alphabet.
Theorem 1:
If A and B are countable sets, then A ∪ B is also countable.
Theorem 2: Cantor-Bernstein Theorem
If A and B are sets with |A| ≤ |B| and |B| ≤ |A|, then |A| =
|B|.
Call the set of strings of length n, where n ≥ 0, An.
For any finite alphabet, An is finite and therefore countable.
The set of all strings over the alphabet is S = A0 ∪ A1 ∪ A2 ∪ ..., which is a union of a
countable number of countable sets.
We can see that the number of sets is countable by simply
mapping An to its
corresponding n.
Hence S is also countable.
Now we need to prove that the subset of a countable set is
countable.
Lemma: If B is a subset of a countable set A, then B is also
countable.
If A is a finite set, then we are finished, since |B|≤|A|. If A
is countable infinite, then we know we can list the elements of A
in some way such that A = {a1,
a2, a3, ..., an}, where n∈N.