There are 2 equivalent (and useful) definitions for “countable set”:
Set is countable if (there is an injection from to ).
Set is countable if for some finite alphabet ( is encodable).
You are given a set . Is it countable or uncountable?
Options for showing is countable:
Show is “listable”: The elements of can be listed so that every element in eventually appears in the list. This is equivalent to showing there is a surjection from to : we define as the ’th element in the list.
Show , where is a known countable set like , , , , etc.
Show that is encodable, i.e. the elements of have finite-length string representations/encodings.
Options for showing is uncountable:
Assume for the sake of contradiction that is countable, then diagonalize against to reach a contradiction.
Show , where is a known uncountable set like (the set of all infinite-length binary strings). Note that .
A decider is a TM that halts on all inputs.
A language is undecidable if there is no decider TM such that accepts if and only if .
A language reduces to (i.e. solving reduces to solving ) if it is possible to decide using an algorithm that decides as a subroutine. Denote this as (read: can be used to solve so is at most as hard as .)
First, let’s make sure we have the correct understanding of what is: So denotes the set of all finite-length tuples where each coordinate is an element of .
We’ll show is encodable/countable. Consider the alphabet . Any element of can be uniquely represented with a finite-length string where commas are replaced with . (Note that there is really no need to put the opening and closing parentheses for the tuple.) To make the encoding definition a bit more explicit, if is the usual encoding of the naturals with digits (where ), then is defined as follows: for , In this case, it is rather obvious that is an injective function (i.e. that every element of maps to a unique finite-length string.) Or in other words, if two elements of map to the same string, then it is clear that they represent the same element of . (Explicitly writing a proof of this would be too pedantic in our opinion.) This shows is encodable, i.e. countable.
Similarly, we can conclude that is countable whenever is a countable set.
Part 1: We show that is undecidable via a reduction from (i.e. we show that reduces to ).
Suppose decides . We define a decider for as follows
def M_HALTS(<TM M, string x>):
<HELP> =
"""def HELP(w):
if w is of the form 0^n1^n for some natural number n:
ACCEPT
else:
run M(x)
ACCEPT"""
return M_REG(<HELP>)
We now have to prove that is a correct decider for . In order to do this, we consider all possible inputs to and argue that it gives the correct output.
First, consider the case when the input is such that halts. Then notice that the helper TM we define accepts all strings, i.e. . Therefore accepts (because is a regular language), which means accepts, as desired.
Next, consider the case when the input is such that loops (in the context of TMs, the word “loops” is synonymous with “does not halt”). Then notice that is irregular. Therefore rejects, which means rejects, as desired.
Thus, we’ve shown that , so is undecidable.
(Note that there is also the case when the input string to does not correspond to a valid encoding of a TM together with a string . We would like to remind you once again that even though this is not explicitly written, we implicitly assume that the first thing our machine does is check whether the input is a valid encoding of a TM together with a string . If it is not, the machine rejects. If it is, then it will carry on with the specified instructions. Recall that this step of checking whether the input string has the correct form is never explicitly written. And in the proof of correctness, we do not have to explicitly argue what happens if the input string does not have the expected format since we can assume this step is handled properly.)
Part 2: We show that is undecidable via a reduction from (i.e. we show that reduces to ).
Suppose decides . We define a decider for as follows
def M_HALTS(<TM M, string x>):
<HELP> =
"""def HELP(w):
run M(x)
ACCEPT"""
return M_DOLORES(<HELP, HELP>)
We now argue we have a correct decider for as in the previous part.
Suppose the input is such that halts. Then accepts all inputs. Therefore accepts, which means accepts, as desired.
Suppose the input is such that loops. Then does not accept any inputs. Therefore rejects, which means rejects, as desired.
Thus, we’ve shown that , so is undecidable.
Suppose that decides .
We define a decider for . In the description below, we use the symbol (less than or equal to) to compare two strings. If string is less than or equal to string , it means is lexicographically less than or equal to (this is a total order on the set of all finite-length strings).
def M_TOTAL(<TM M>):
<HELP> =
"""def HELP(w):
for y <= w:
run M(y)
ACCEPT"""
return not M_FINITE(<HELP>)
We now have to prove that is a correct decider for . In order to do this, we consider all possible inputs to and argue that it gives the correct output.
Suppose the input string is such that halts on all inputs. Then notice that . Therefore rejects, which means accepts, as desired.
Suppose the input string is such that does not halt on all inputs. Let be the lexicographically smallest string that does not halt on. Then will not accept any string lexicographically greater (or equal to) than , as will not halt. Since there are only finitely many strings lexicographically smaller than , is finite. Thus, accepts, which means rejects, as desired.
Let be a subset of the positive reals with the property that for every real number , the set has a minimum element. For example is such a set, but is not. Determine whether is necessarily countable.
The set is countable. We’ll use the fact that rationals are dense in the reals. We sketch the main idea without giving a full proof: Inject to by mapping each element of to some rational between and the next largest element of .
Note: If you try to inject to by mapping the smallest element of to , the second smallest to , etc. it won’t work. If , the will not be assigned to anything.