Sunteți pe pagina 1din 12

Recursively Enumerable Languages

We have already learned about turing machines and that the language accepted by a turing machine is
recursively enumerable. In this chapter, we further study recursively enumerable languages (turing
acceptable) and recursive languages (turing decidable).

The recursively enumerable (RE) languages can itself be structured into two classes. One class of
languages can be compared to that with an algorithm so that, the TM not only recognizes the language,
but also tells when it has decided the input string is not in the language. Such a turing machine halts
eventually, regardless of whether or not it reaches an accepting state. This class of languages is called
recursive languages.

The second class of language cannot guarantee that the TM will halt if a string not in the language is
given. These languages are accepted in an inconvenient way. If the input is in the language, we'll
eventually know that, but if the input is not in the language, then the Turing machine may run forever,
and we shall never be sure the input won't be accepted eventually. This class of languages is recursively
enumerable but not recursive. An example of this type of language is the set of coded pairs (M,w) such
that TM M accepts w.

Recursive Languages (R)

A recursive language is a formal language for which there exists a Turing machine which will, when
presented with any input string, halt and accept if the string is in the language, and halt and reject
otherwise. If a Turing machine always halts; it is known as a decider and is said to decide the recursive
language. All recursive languages are also recursively enumerable. All regular, context-free and context-
sensitive languages are recursive. A recursive language is also called decidable or Turing-decidable. The
class of all recursive languages is often called R. This type of language is not defined in the Chomsky
hierarchy.

Formal Definition:

We call a language L recursive if L = L (M) for some Turing machine M such that:

1. If w is in L, then M accepts (and therefore halts).


2. If w is not in L, then M eventually halts, although it never enters an accepting state.

A TM of this type corresponds to our informal notion of an "algorithm," a well-defined sequence of steps
that always finishes and produces an answer. If we think of the language L as a "problem," then problem
L is called decidable if it is a recursive language, and it is called undecidable if it is not a recursive
language.

Recursive Enumerable Languages (RE)

A recursively enumerable language is a formal language for which there exists a Turing machine (or other
computable function) that will halt and accept when presented with any string in the language as input but
may either halt and reject or loop forever when presented with a string not in the language. Contrast this
to recursive languages, which require that the Turing machine halts in all cases. A recursively enumerable
language is also called partially decidable or Turing-recognizable. It is known as a Type 0 language in
the Chomsky hierarchy of formal languages. All regular, context-free, context sensitive
and recursive languages are recursively enumerable.

Formal Definition:

We call a language L recursively enumerable if L = L (M) for some Turing machine M such that:

1. If w is in L, then M accepts (and therefore halts).


2. If w is not in L, the machine M will either halt and reject or loop forever.

The actual meaning of the term "recursively enumerable" is that we can list all the members of that
language, in some order; that is, it could "enumerate" them. The languages that can have their members
listed in some order are the same as the languages that are accepted by some TM, although that TM might
run forever on inputs that it does not accept.

The existence of an algorithm for a given problem is more important than the existence of a TM for the
same problem. This is because TM that is not guaranteed to halt provides no information to conclude the
string is in the language. And this method of solving does not make any sense of actually solving the
problem. Thus the division of problems between decidable (solved by an algorithm) and undecidable is
more important than division between RE languages and Non-RE languages.

• Ld

• Lu

Fig A: Relationship between recursive, RE and non-RE languages.

Fig A shows the distinction between the three classes of languages in our discussion.

1. The recursive languages (R)


2. Languages that are Recursive Enumerable but not Recursive.
3. The non-recursive enumerable languages.
We have already seen the diagonalization language Ld is non recursive. The Universal language (Lu) falls
in the category of languages that are RE but not recursive.

Compliment of a Recursive Language

We can now discuss the compliment of recursive and RE languages which will be useful in describing the
second ring (RE but not recursive) shown in Fig A. If we have an RE language L, then its compliment L’
will not be recursive enumerable (non RE) and L cannot be recursive (as seen from figure).

If L is recursive then L’ would also be recursive and surely RE. This is the closure property of recursive
languages and the proof is given below.

Theorem 1: If L is a recursive language, so is L’

Proof: Let L = L (M) for some TM M that always halts. We construct a TM M’ such that L’ = L (M’) as
constructed in Fig B. That is, M’ behaves just like M. However, M is modified as follows to create M’:

1. The accepting states of M are made non accepting states of M’ with no transitions; i.e., in these
states M’ will halt without accepting.
2. M’ has a new accepting state r; there are no transitions from r.
3. For each combination of a non accepting state of M and a tape symbol of M such that M has no
transition (i.e., M halts without accepting), add a transition to the accepting state r.

M’

Accept Reject
w M
Reject Accept

Fig B: Construction of M’ accepting compliment of a recursive language.


M

0 1
a b c

M’

0 1
a b c

1 0

Fig C: An example showing machine M converted to M’

Since M is guaranteed to halt, we know that M’ is also guaranteed to halt. Moreover, M’ accepts exactly
those strings that M does not accept. Thus M’ accepts L’.

Theorem 2: If both a language L and its complement are RE, then L is recursive. Note that then by
Theorem 1, L’ is recursive as well.

Proof: Let L = L (M1) and L’= L (M2). Both M1 and M2 are simulated in parallel by a TM M (Fig D). We
can make M a two-tape TM, where one tape will be used for M1 and the other for M2. This two tape
machine can be then converted into a single tape machine to make the simulation easier. The states of M1
and M2 now become the states of M.

M
M1 Accept Accept

M2 Accept Reject
Fig D: Machine M simulating M1 and M2 in parallel.

Now if the input string w is in the language of M1, it accepts and halts. If so make machine M also to
accept w. If the input string w is not in L then it will be in L’ so M 2 will accept w. If so make M to halt
without accepting (reject) the string w. Thus we have constructed M such that it halts on all inputs and
thus language of M is recursive and L (M) is exactly L.

Now from Fig A, we can list down the valid possibilities for L and L’.

1. Both L and L’ are recursive; i.e., both are in the inner ring.
2. Neither L nor L’ is RE; i.e., both are in the outer ring.
3. L is RE but not recursive and L’ is not RE; i.e., one is in the middle ring and the other is in the
outer ring.
4. L’ is RE but not recursive, and L is not RE; i.e., the same as (3), but with L and L’ swapped.

Now consider the language Ld which we know is not RE. Thus Ld’ could not be recursive and Ld’ could
be non-RE or RE but not recursive. But actually Ld’ is RE but not recursive. Ld’ is a set of strings wi such
that Mi accepts wi. The universal language Lu consists of pairs (M, w) such that M accepts w and is
recursively enumerable.

Universal Language (Lu)

We have seen that a Turing machine can be made a ‘stored program computer’, in which both its program
and data are stored in one ore more input tapes. Now we can define the universal language Lu shown in
the middle ring in Fig A i.e. a language which is RE but not recursive.

The universal language Lu, is defined to be the set of binary strings that can be represented as a pair (M,
w), where M is a TM with the binary input alphabet, and w is a string in (0+ 1)*, such that w is in L(M).
That is, Lu is the set of strings representing a TM and an input accepted by that TM. We shall show that
there is a TM U, often called the universal Turing machine, such that Lu = L (U).

Universal Turing machine

The Universal Turing machine (U) is a TM which accepts strings from the universal language L u. U can
be best described as a multi tape turing machine. The first tape will be holding the transitions of the
machine M simulated and also the input string w. The second tape represents the simulated tape used by
M. Both the tapes are binary coded as we did in discussing the diagonalization language in Chapter X
(refer). That is the tape symbol Xi will be represented by 0i and tape symbols will be separated by single
1’s. The third tape of U holds the state of M, with state qi represented by i number of 0’s. The fourth tape
is a scratch tape which is used to temporarily hold the binary strings. See Fig E.

The operation of U can be summarized as follows:

1. Examine the input to make sure that the code for M is a valid code for some TM. If not, then M
represents a truing machine with no moves and it accepts no inputs. Thus U halts without
accepting.
2. First initialize the second tape with the input string in binary coded form. That is, for each 0 in w,
place 10 on the second tape, and for each 1 of w, place 100 there. The blanks B are represented
by 1000 by the simulated tape of M and all cells of the second tape beyond the input string hold
blanks but, those cells are not filled with 1000 pattern initially. But if the head encounters a blank
symbol on simulation instead of a simulated symbol of M then, it is replaced by 1000 to represent
a blank.
3. To start operation, place 0, the start state of M, on the third tape, and move the head of U's second
tape to the first simulated cell.
4. To simulate a move of M, U searches on its first tape for a transition 0i l0j10k l0l 10m, such that 0i is
the state on tape 3 and 0 j is the current tape symbol on tape 2 scanned by U. This transition is the
one M would next and we have to make changes in tapes to complete the transition:
a) Change state: - Change the contents of tape 3 to 0k; that is, simulate the state change of M.
To do so, U first changes all the 0's on tape 3 to blanks, and then copies 0k from tape 1 to
tape 3.
b) Write symbol: - Replace 0j on tape 2 by 0l; that is, change the tape symbol of M. If more
or less space is needed (i.e., i ≠ l), use the scratch tape and the shifting-over technique to
manage the spacing. That is copy everything to the right the position where 0l has to be
placed onto the scratch tape. Then place 0l in that position and copy the remaining
symbols back from the scratch tape.
c) Head movement: - Move the head on tape 2 to the position of the next 1 to the left or right,
respectively, depending on whether m = 1 (move left) or m = 2 (move right). Thus, U
simulates the move of M to the left or to the right.
1. If M has no transition that matches the simulated state and tape symbol, M halts in the simulated
configuration, and thus U also halts.
2. If M enters its accepting state, then U accepts.

Fig E: Organization of a Universal Turing Machine


Undecidability of Universal Turing Machine

The universal language Lu is RE but not recursive and knowing Lu is undecidable (not recursive) has
many useful applications. The reduction of a problem L u to another problem P can be used to show there
is no algorithm to solve P (undecidable) regardless of whether or not P is recursively enumerable. In
contrast, the diagonalization language Ld can be used to show undecidability only if P is not RE.

Theorem 3: Lu is RE but not recursive.

Proof: By constructing a turing machine, we have proved Lu to be recursively enumerable. Imagine that
Lu is recursive then we know that Lu’ is also recursively by Theorem 1. However, if we have a TM M to
accept Lu’, then we can construct a TM to accept Ld as seen in Fig F. Since we already know that Ld is not
RE, we have a contradiction of our assumption that L is recursive.

Accept Accept
Hypothetical
w Copy w111w Algorithm M
for Lu’
Reject Reject

M’ for L d

Fig F: Reduction of Ld to Lu

Suppose we have a machine L (M) = Lu then, we can modify TM M into a TM M’ which can accept Ld as
shown in Fig F as follows.

1. Given string w on its input, M' changes the input to w111w. This can be done by using a
second tape to copy w, and then convert the two-tape TM to a one-tape TM.
2. M' simulates M on the new input. If w is wi in our enumeration, then M' determines whether
Mi accepts wi. Since M accepts Lu’, it will accept if and only if Mi does not accept wi; i.e., w
is in Ld.

Thus, M' accepts w if and only if w is in Ld. Since we know M’ cannot exist; we conclude that Lu is not
recursive.

Reducibility

Reducibility is the primary method employed for proving certain problems are computationally
unsolvable. A reduction is a way of converting one problem to another problem in such a way that a
solution to the second problem can be used to solve the first problem. For example, suppose that you want
to find your way around a new city. You know that doing so would be easy if you had a map. Thus you
can reduce the problem of finding your way around the city to the problem of obtaining a map of the city.
Reducibility always involves two problems, which we call A and B. If A reduces to B, we can use a
solution to B to solve A. So in our example, A is the problem of finding your way around the city and B is
the problem of obtaining a map. Note that reducibility says nothing about solving A or B alone, but only
about the solvability of A in the presence of a solution to B. Reducibility also occurs in mathematical
problems. For example, the problem of measuring the area of a rectangle reduces to the problem of
measuring its length and width. The problem of solving a system of linear equations reduces to the
problem of inverting a matrix.

Reductions

We have applied the concept of reducibility to prove many theorems before. In general, if we have an
algorithm to convert instances of a problem P1 to instances of a problem P2 that have the same answer,
then we say that P1 reduces to P2. We can use this proof to show that P2 is at least as hard as P 1. If P1 is not
recursive, then P2 cannot be recursive. If P1 is non-RE, then P2 cannot be RE.

Fig G: Reduction of positive instances to positive and negative instances to negative.

The reduction must be such that all instances where P1 says “yes” must be converted to instances where P2
says “yes”. And similarly all instances where P1 says “no” must be converted to instances where P2 says
“no”. Every instance of P2 need not be a reduction from P1 and only a small portion of P2 is the target of
reduction. Formally, a reduction from P1 to P2 is a Turing machine that takes an instance of P1 written on
its tape and halts with an instance of P2 on its tape.

Theorem 4: If there is a reduction from P1 to P2,

a) If P1 is undecidable then so is P2.


b) If P1 is non-recursive then so is P2.

Proof (a): First suppose P1 is undecidable. If it is possible to decide P2, then we can combine the
reduction from P1 to P2 with the algorithm that decides P2 to construct an algorithm that decides P1. In
more detail, suppose we are given a string w of P1. Now we can apply an algorithm that converts instances
w of P1 to instances x of P2. Then apply the algorithm that decides to P2 to x. If that algorithm says "yes",
then x is in P2. And also because we reduced P1 to P2, we know the answer to w for P1 is “yes"; i.e. w is in
P1. Likewise, if x is not in P2, then w is not in P1. So whatever answer we give for “is x in P 2?” will be
correct for “is w in P1?” But now we have contradicted our assumption that P1 is undecidable. Thus we
can conclude if P1 is undecidable, then P2 is undecidable too.

Proof (b): Assume that P1 is non-RE, but P2 is RE. Now, we have an algorithm to reduce P1 to P2, but we
have only a procedure to recognize P2; that is, there is a TM that says "yes" if its input is in P 2 but may not
halt if its input is not in P2. Consider an instance w of P1, convert it by the reduction algorithm to an
instance x of P2. Then apply the TM for P2 to x. If x is accepted, then accept w.

If w is in P1, then x is in P2, so this TM will accept w. If w is not in P1, then x is not in P2. Then, the TM
may or may not halt, but will surely not accept w. Since we assumed no TM for P1 exists, we have shown
by contradiction that no TM for P2 exists either; i.e., if P1 is non-RE, then P2 is non-RE.

Turing Machines for Empty Languages

In this section we shall discuss the empty language (Le) and the non-empty language (Lne). Each language
consists of binary strings and if w is some binary string, it represents some Turing machine Mi.

If L (Mi) = ϕ, Mi does not accept any input, then w is in Le. Thus Le represents all the encoded TMs
whose language is empty. On the other hand, if L (Mi) is not an empty language, then w is in Lne. Thus Lne
represents the language for TMs that accepts at least one input string. These can be represented as,

• Le = {M | L (M) = ϕ}
• Lne = {M | L (M) ≠ ϕ}

The languages Lne and Le are compliments of each other. Lne is RE but not recursive and Le is not RE.
Now we can prove these.

Theorem 5: Lne is recursively enumerable.

Proof: We first construct a TM M, which accepts the language Lne. And this can be accomplished by a
non deterministic TM as shown in Figure H.

Guessed
w
U Accept Accept
Mi

M for L ne

Figure H: NTM that accepts Lne


M works as follows:

1. M takes as input a TM code Mi.


2. Using its nondeterministic capability, M guesses an input w that Mi might accept.
3. M tests whether Mi accepts w. For this part, M can simulate the universal TM U that accepts Lu.
4. If Mi accepts w, then as we see M accepts its own input, which is Mi.

Thus if Mi accepts even one string, then M will accept Mi. We know the nonempty language Lne will have
at least one string. But if L(Mi) = ϕ, then no guess of w will be accepted by Mi. Thus L(M) has to be Lne
and Lne is recursively enumerable.

Theorem 5: Lne is not recursive.

Proof: We show Lne is not recursive by reducing Lu to Lne. This can be done by designing an algorithm
that transforms an input (M, w) into M’, the code for another TM such that w is in L (M) if and only if
L(M’) is not empty. That is M accepts w if and only if M’ accepts at least one string. To do this, M’
ignores its input x and just simulates M on input w and M’ accept if M accepts w. If Lne were recursive
then we would have an algorithm to tell whether or not M accepts w. If so then as we designed, L (M’) ≠
ϕ, but we will contradict this later. The construction of M’ is shown in Figure I.

w M Accept Accept
x

M’

Figure I: M’ accepts only if M accepts w.

If M does not accept w, then M accepts none of its inputs; i.e., L (M') = ϕ. However, if M accepts w, then
M' accepts every input and thus L (M') surely is not ϕ.

The working of M’ can be described as follows:

1. M' ignores its own input x and replaces its input by the string that represents TM M and input string
w. Since M’ is designed for a specific pair (M, w), which has some length n, M’ will have a sequence
of states q0, ql, ... ,qn, where q0 is the start state.
a) In state qi, for i = 0, 1,..., n - 1, M' writes the (i + 1)st bit of the code for (M, w), goes to state
qi+1, and moves right.
b) In state qn M' moves right, if necessary, replacing any non blanks (which would be the tail of x,
if that input to M' is longer than n) by blanks.
1. If M’ reaches a blank in state qn, it uses a similar collection of states to reposition the head on the left
end of state.
2. M’ simulates a universal TM U on its present tape using additional states.
3. If U accepts, M’ accepts. If U never accepts, M’ never accepts either.
Thus we have designed a TM M’, which can transform the code of M and the string w into the code for
M’. Thus there is an algorithm to perform reduction of L u to Lne. We see that if M accepts w, then M’
accepts whatever input x was in its tape. The fact that input x was ignored is irrelevant and so if M accepts
w, the code for M’ is in Lne.

Conversely, if M does not accept w, then M’ never accepts, no matter what its input is. Hence, in this case
the code for M’ is not in Lne. We have successfully reduced Lu to Lne by the algorithm that constructs M’
from M and w; we may conclude that, since Lu is not recursive, neither is Lne. In other words, if Lne were
recursive, then we would develop an algorithm for Lu as follows:

1. Convert (M, w) to the TM M’ as above.


2. Use the hypothetical algorithm for Lne to tell whether or not L (M’) = ϕ. If so, say M does not
accept w; if L (M’) ≠ ϕ, say M does accept w.

Since we know by Theorem 3 that no such algorithm for Lu exists, we have contradicted the assumption
that Lne is recursive, and conclude that Lne is not recursive.

Theorem 6: Le is not RE.

Proof: If Le were RE, then by Theorem 2, both it and Lne would be recursive. Since Lne is not recursive by
Theorem 5, we conclude that Le is not RE.

Properties of RE Languages

We have already seen that languages like Le (not RE) and Lne (not recursive) are undecidable. But these
two observations are special cases of a general theorem called Rice theorem. Rice theorem states that “All
nontrivial properties of RE languages are undecidable”. Thus we cannot construct a TM to recognize
languages having the nontrivial properties. An example of such a property is “the language is context
free”, and we cannot construct a TM to decide this.

The property of the RE languages can be considered simply as a set of RE languages. Thus the property
“the language is context free” can be considered simply as the set of all CFLs. The property of a language
being empty can be considered as the set with only the empty language. A property is considered trivial if
it is either empty or is all RE languages. Otherwise it is non trivial.

The set of languages cannot be recognized as the language themselves. This is because the languages
itself can be infinite and cannot be represented as finite strings that are input to a TM. But we can
represent a TM that accepts those languages by a finite code. Thus, if P is a property of the RE languages,
the language LP, is the set of codes for Turing machines M i such that L (Mi) is a language in P. Thus
decidability of a property P can be considered as decidability of language LP.

Theorem 7 (Rice Theorem): Every nontrivial properties of RE languages are undecidable.

Proof: Let P be a nontrivial property of the RE languages. Assume to begin that ϕ, the empty language, is
not in P. Since P is nontrivial, there must be some nonempty language L that is in P. Let ML be a TM
accepting L.
We can prove LP as undecidable by reducing LU (undecidable) to LP. The reduction algorithm takes as
input a pair (M, w) as input and produces a TM M’. The TM M’ is shown in Figure J. L (M') is ϕ if M
does not accept w, and L (M’) = L if M accepts w.

Accept
w M start Accept Accept

x ML

M’

Figure J: Construction of M’ for the proof of Rice Theorem

M’ is a two tape turing machine. The first tape is used to simulate M on w and the other tape is used to
simulate ML with input x. The algorithm performing the reduction is given input M and w and these
inputs decide the transitions of M’. The transitions of ML are known to the reduction algorithm and are
built into transitions of M’.

The working of M’ is described as follows:

1. Simulate M on input w. Note that w is not the input to M’ but, M’ writes M and w onto one of its
tapes and simulates the universal TM U on that pair.
2. If M does not accept w, then M’ never accepts its own input, x, so L(M ‘) = ϕ. Since we assume
ϕ is not in property P, the code for M ' is not in LP.
3. If M accepts w, then M’ begins simulating ML on its own input x. Thus, M’ will accept exactly
the language L. Since L is in P, the code for M’ is in LP.

We see that M’ can be constructed from (M, w) using an algorithm. And the algorithm turns (M, w) into
M’ that is in LP, if and only of (M, w) is in LU. Since this algorithm is a reduction from LU to LP, the
property P is undecidable.

Now coming to the case that ϕ is in P, consider the compliment property P’ which is the set of RE
languages not having the property P. And we now know that P’ is undecidable. Since every TM accepts a
RE language, LP’, the set of TM that do not accept a language in P is same as LP’, the set of TMs that
accepts a language in P’. Suppose LP were decidable, then so would be LP’, because the compliment of a
recursive language is recursive.

S-ar putea să vă placă și