2.1 Recursive and Recursively Enumerable Languages: Remark
2.1 Recursive and Recursively Enumerable Languages: Remark
2.1 Recursive and Recursively Enumerable Languages: Remark
Let be a nite alphabet that contains the symbol \". We will allow as input for
a Turing machine words that do not contain this special symbol: only letters from
0 = n fg.
We call a function f : 0 ! 0 recursive or computable if there exists a Turing
machine that for any input x 2 0 will stop after nite time with f (x) written on
its rst tape. (We have seen in the previous section that we can assume without
loss of generality that the Turing machine has only one tape.)
The notions of recursive, as well as that of \recursively enumerable" and \partial
recursive" dened below can be easily extended, in a unique way, to functions and
sets over some countable sets dierent from 0 , like the set of natural numbers,
the set N of nite strings of natural numbers, etc. The extension goes with help
of some standard coding of, e.g., the set of natural numbers by elements of 0 .
Therefore even though we dene these notions only over 0, we sometimes use
them in connection with function dened over other domains. This is a bit sloppy
but does not lead to any confusion.
We call a language L recursive if its characteristic function
(
x 2 L,
fL (x) = 10 ifotherwise,
is recursive. Instead of saying that a language L is recursive, we can also say that
the property dening L is decidable. If a Turing machine calculates this function
then we say that it decides the language. It is obvious that every nite language is
recursive. Also if a language is recursive then its complement is also recursive.
(2.1) Remark It is obvious that there is a continuum of languages (and so uncountably many) but only countably many Turing machines. So there must exist non-recursive languages. We will see some concrete languages that are nonrecursive. }
We call the language L recursively enumerable if L = ; or there exists a recursive
function f such that the range of f is L. This means that we can enumerate the
elements of L: L = ff (w0); f (w1); : : :g, when 0 = fw0; w1; : : :g. Here, the elements
of L do not necessarily occur in increasing order and repetition is also allowed.
We give an alternative deniton of recursively enumerable languages through
the following lemma.
(2.2) Lemma A language L is recursively enumerable i there is a Turing machine
T such that if we write x on the rst tape of T the machine stops i x 2 L.
26
T0 ouputs x. Since every word of 0 will occur for innitely many values of i the
range of T0 will be L.
p
There is nothing really tricky about the function (i b ic)2 ; all we need is that
for i = 0; 1; 2; : : : its value assumes every non-negative integer innitely many times.
The technique used in this proof, that of simulating innitely many computations
by a single one, is sometimes called \dovetailing".
Now we study the relationship between recursive and recursively enumerable
languages.
(2.3) Lemma Every recursive language is recursively enumerable.
Proof This is clear if the language L is empty. We can change the Turing machine
that decides f to output the input if the intended output is 1, and to output some
arbitrary xed a 2 L if the intended output is 0.
The next theorem characterizes the relation of recursively enumerable and recursive languages.
Proof If L is recursive then its complement is also recursive, and by the previous
Proof The rst statement follows from Lemma 1.3. We prove the second state-
Proof Suppose that the halting problem is decidable for all one-tape Turing machines. Let T be a 2-tape universal Turing machine and let us construct a 1-tape
machine T0 similarly to the proof of Theorem (0.2) (with k = 2), with the dierence
that at the start, we write the i-th letter of word x not only in cell 4i but also in
cell 4i 2. Then on an input x, machine T0 will simulate the work of T , when the
latter starts with x on both of its tapes. Since it is undecidable whether T halts
for a given input (x; x), it is also undecidable about T0 whether it halts on a given
input x.
The above proof, however simple it is, is the prototype of a great number of
undecidability proofs. These proceed by taking any problem P1 known to be undecidable (in this case, membership in LT ) and showing that it can be reduced to
28
the problem P2 at hand (in this case, the halting problem of T0). The reduction
shows that if P2 is decidable then so is P1 . But since we already know that P1 is
undecidable, we conclude that P2 is undecidable as well. The reduction of a problem
to some seemingly unrelated problem is, of course, often very tricky.
A description of a Turing machine is the listing of the sets , (where, as
before, the elements of are coded by words over the set 0 ), and the table of the
functions ; ;
.
(2.7) Corollary It is algorithmically undecidable whether a Turing machine
(given by its description) halts on the empty input.
that its halting problem can be reduced to the general halting problem on the empty
input. Indeed, for each input x, we can construct a Turing machine Tx which, when
started with an empty input, writes x on the input tape and then simulates T . If
we could decide whether Tx halts then we could decide whether T halts on x.
(2.8) Corollary It is algorithmically undecidable whether for a one-tape Turing
machine T (given by its description), the set LT is empty.
Proof For a given machine S , let us construct a machine T that does the following:
it rst erases everything from the tape and then turns into the machine S . The
description of T can obviously be easily constructed from the description of S . Thus,
if S halts on the empty input in nitely many steps then T halts on all inputs in
nitely many steps, hence LT = 0 is not empty. If S works for innite time on
the empty input then T works innitely long on all inputs, and thus LT is empty.
Therefore if we could decide whether LT is empty we could also decide whether S
halts on the empty input, which is undecidable.
Obviously, just as its emptyness, we cannot decide any other property P of of
LT either if the empty language has it and 0 has not, or vice versa. Even a more
general negative result is true. We call a property of a language trivial if either all
languages have it or none.
(2.9) Rice's Theorem For any non-trivial language-property P , it is undecidable
whether the language LT of an arbitrary Turing machine T (given by its description)
has this property.
Thus, it is undecidable on the basis of the description of T whether LT is nite,
regular, contains a given word, etc.
29
Proof We can assume that the empty language does not have property P (oth-
erwise, we can consider the negation of P ). Let T1 be a Turing machine for which
LT1 has property P . For a given Turing machine S , let us make a machine T as
follows: for input x, rst it simulates S on the empty input. When the simulated S
stops it simulates T1 on input x. Thus, if S does not halt on the empty input then
T does not halt on any input, so LT is the empty language. If S halts on the empty
input then T halts on exactly the same inputs as T1, and thus LT = LT1 . Thus if
we could decide whether LT has property P we could also decide whether S halts
on empty input.
30