Вы находитесь на странице: 1из 5

2.

1 Recursive and recursively enumerable languages

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" de ned below can be easily extended, in a unique way, to functions and
sets over some countable sets di erent 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 de ne these notions only over 0, we sometimes use
them in connection with function de ned 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 de ning 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 de niton 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

Proof Let L be recursively enumerable. We can assume that it is nonempty. Let


L be the range of f . We prepare a Turing machine which on input x calculates f (y)
in increasing order of y 2 0 and it stops whenever it nds a y such that f (y ) = x.
On the other hand, let us assume that L contains the set of words on which
T stops. We can assume that L is not empty and a 2 L. We construct a Turing
machine T0 that, when
i is its input it simulates T on input x
p 2the natural number

which is the (i b ic) -th word of 0, for i steps. If the simulated T stops then

T0 ouputs x. Since every word of 0 will occur for in nitely 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 in nitely many times.

The technique used in this proof, that of simulating in nitely 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.

(2.4) Theorem A language L is is recursive i both languages L and 0 n L are


recursively enumerable.

Proof If L is recursive then its complement is also recursive, and by the previous

lemma, it is recursively enumerable.


On the other hand, let us assume that both L and its complement are recursively
enumerable. We can construct two machines that enumerate them, and a third one
simulating both that detects if one of them lists x. Sooner or later this happens
and then we know where x belongs.
Now, we will show that there are languages that are recursively enumerable (and
hance rather explicit), but not recursive.
Let T be a Turing machine with k tapes, and let LT be the set of those words
x 2 0 words for which T stops when we write x on all of its tapes.
27

(2.5) Theorem If T is a universal Turing machine with k + 1 tapes then LT is


recursively enumerable, but it is not recursive.

Proof The rst statement follows from Lemma 1.3. We prove the second state-

ment, for simplicity, for k = 1.


Let us assume, by way of contradiction, that LT is recursive. Then 0 n LT
would be recursively enumerable, so there would exist a 1-tape Turing machine T1
that on input x would stop i x 62 LT . The machine T1 can be simulated on T by
writing an appropriate program p on the second tape of T . Then writing p on both
tapes of T , it would stop if T1 would stop because of the simulation. The machine
T1 was de ned, on the other hand, to stop on p if and only if T does not stop with
input p on both tapes (i.e. when p 62 LT ). This is a contradiction.
This proof uses the so called diagonalization technique originating from set theory (where it was used by Cantor to show that the set of all real numbers is not
countable). The technique forms the basis of many proofs in logic, set-theory and
complexity theory. We will see more of these in what follows.
There is a number of variants of the previous result, asserting the undecidability
of similar problems.
Let T be a Turing machine. The halting problem for T is the problem to decide,
for all possible inputs x, whether T halts on x. Thus, the decidability of the halting
problem of T means the decidability of the set of those x for which T halts. We can
also speak about the halting problem in general, which means that a pair (T; x) is
given where T is a Turing machine (given by its transition table) and x is an input.
(2.6) Theorem There is a 1-tape Turing machine whose halting problem is undecidable.

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 di erence
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.

Proof Let T be a Turing machine whose halting problem is undecidable. We show

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 in nite time on
the empty input then T works in nitely 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

Вам также может понравиться