Sei sulla pagina 1di 13

JAYAM COLLEGE OF ENGINEERING AND TECHNOLOGY

(An ISO 9001:2000 Certified Institution)


DHARMAPURI-636813.

COURSE CODE:CS332
COURSE NAME:THEORY OF COMPUTATION
DEPT :CSE
ACADEMIC YEAR:2005-2006 SEMESTER/YEAR:V/3

UNIT – V
UNDECIDABILITY

CONTENTS
§ PROPERTIES OF RECURSIVE AND RECURSIVELY ENUMERABLE
LANGUAGES
§ UNIVERSAL TURING MACHINE AS AN UNDESIDABLE
PROBLEM
§ UNIVERSAL LANGUAGES
§ RICE’S THEOREM
v PROPERTIES OF RECURSIVE AND RECURSIVELY ENUMERABLE
LANGUAGES
Ø After having an introduction about recursive and recursively enumerable languages, this unit
will further deal with properties of recursive and recursively enumerable languages, and relate
the concept of un decidability with them.

q PROBLEMS
Ø We usually associate problems with questions such as “Does there exist a solution for this?”
etc. but we have seen that Turing Machines are capable of solving only the membership problem
i.e. “Given a word w and a language L, does w belong to L?”.
Ø It is important to understand that almost all instances of problems can be expressed as a
membership problem of some language.

Ø For e.g. the question “How many primes exist below a given number n” can be modified as
“Is x a member of L” where 1<=x<=n and L represents the language of primes.

Thus decision problems are those problems which either “yes” or “no” as the answer.

v RECURSIVE AND R.E. LANGUAGES


Ø We know that recursive languages are those languages whose Turing machines halt on any
input that is given i.e. there exists an algorithm which clearly distinguishes between the “yes”
and “no” instances of the membership problem of the language represented by the Turing
machine.

Ø Recursively enumerable (r.e.) languages are those languages whose Turing machines may or
may not halt on all inputs i.e. they may enter into an infinite loop.

Ø This suggests the fact that there does not exist a general algorithm for all instances of the
problem, which clearly distinguishes between the “yes” and the “no” instances of the problem.
Ø Thus problems represented by recursive languages are the only decidable problems i.e. there
exists a Turing machine which will always answer a yes or no to the decision problem.
Ø All the other problems do not have an algorithm and hence a Turing machine which can
accept all instances of the problem and clearly answer yes or no.
Ø It is important to distinguish between a particular instance of a problem and all instances of
the problem.
Ø For e.g. it is a well known fact that halting problem is un decidable, that is, there does not
exist a Turing machine which when given the encoding of any Turing machine and its input
(you’ll subsequently learn how to encode a Turing machine as a string) can always answer a
“yes” or “no”. but it is possible to construct a Turing machine which can accept a particular
Ø Turing machine as input and decide whether it halts on a given input or not. As logic follows,
it can be understood that you cannot write a program which when given any other program and
its input, can state if it enters an infinite loop or not; but it is possible to write a program to
accept a specific type of program and state if it halts on given inputs.

Ø The following theorems will prove certain properties of recursive and recursively enumerable
languages.
ü THEOREM
The complement of a recursive language is recursive.

§ Proof:
Ø Let M be the Turing Machine that accepts the recursive language L, and in order to prove the
theorem, we shall construct another Turing Machine M’ which shall accept L’.
Ø Since the languages they accept are complementary, the behavior of these Turing Machines
will also be the reverse of each other.

Ø Since L is a recursive language, the Turing Machine M will halt on all inputs, whether or not
it accepts the input.
Ø The construction of the machine M’ will be such that when a common input string is given to
both M and M’, M’ will reject the input and halt whenever M accepts it, and will accept the input
and halt whenever M rejects it. Thus we see that the machine M’ halts on both “yes” and “no”
instances of the problem i.e. on all inputs.

Hence the language L’ corresponding to the machine M’ is recursive.

q THEOREM
The union of two recursive languages is recursive. The union of two recursively enumerable
languages is recursively enumerable.

§ Proof:
Ø Let L1 and L2 be the two recursive languages accepted by the Turing Machines M1 and M2.
We construct M, which first simulates M1.
Ø If M1 accepts, then M accepts. If M1 rejects, then M simulates M2 accepts if and only if M2
accepts. Since both M1 and M2 are recursive languages, and each of them will halt on any input
string, M is guaranteed to halt.
Ø This shows that the language corresponding to the Turing Machine M which is L1 L2 is
recursive. If we adopt a similar method for recursively enumerable languages, the Turing
Machine M cannot be guaranteed to halt, since both M1 and M2 may or may not halt. Hence our
construction of M consists of 2-tapes, and in the 1st tape the Turing Machine M1 is simulated
and on the second tape M2 is simulated.
Ø Though there is a possibility that either of them, if not both of them, may enter into an
infinite loop, the Turing Machine M as a whole reaches the halting state if and only if at least one
of them reach their halting states.
Ø Thus we see that this machine accepts L1 L2 where L1 and L2 are recursively enumerable
languages.

q THEOREM
If a language L and its complement L’ are both recursively enumerable, then L (and hence L’) is
recursive.
§ Proof:
Ø We shall consider two Turing machines M1 and M2 constructed to recognize the languages
L and L . We shall construct a new Turing Machine M which does the following:
o Simulate both M1 and M2 simultaneously for any input string.
o M accepts the input string if M1 accepts the same input string.
o M rejects the input string if M2 accepts the same input string and vice-versa. This is done
because M2 corresponds to the complementary language of L.
Exactly one of the Turing Machines M1 or M2 will answer a “yes” and never both. This gives
the guarantee that M will definitely come to a halt.

Ø We can observe that the Turing Machine will surely come to a halt in atleast one of the cases,
even if the head of the other tape has entered into an infinite loop because of non-acceptance.
Since we now have a Turing Machine M which will surely come to a halt, one of the languages
is recursive, and hence by the previous theorem, its complementary language is also recursive.

From the above theorems, we can derive the following conclusions:


• Both L and L’ are recursive.
• Neither L nor L’ is recursively enumerable, or
• If only one language among L and L’ is recursively enumerable but not recursive,
then the other is not recursively enumerable.

v UNIVERSAL TURNING MACHINES AND AN UNDECIDABLE PROBLEM


Ø The concept of a Universal Turing Machine is best when explained with an example.
Imagine the personal computer capable of doing just one particular function but on different
inputs.
Ø We know that we are grossly limiting its functionality and that’s how our discussion of
Turing Machine.
Ø Our earlier construction of Turing Machines such as a TM to check for palindromes could
do just that function but on different inputs.
Ø We would like to have a more general Turing Machine which is more generic and can
perform any function given an algorithm and the corresponding input.
Ø Our present day computers are able to do that, not because they are more powerful than a TM
but the program required to drive the computer was loaded onto the memory as input rather than
being burnt in the hardware (one such hardware is the PLA).
Ø Thus the program and the input required for the program are stored in the memory, and the
computer after reading the Program also reads the input.
Ø Similarly we think of constructing a Universal Turing Machine which can perform the action
of any other Turing Machine.
Ø Imagine the Universal Turing machine checking for palindromes on the input string when the
palindrome Turing machine is given as input. Thus, we need to find a method by which a Turing
Machine can be given as a string input to the Universal Turing Machine.
Ø Let Lu be the language of the Universal Turing Machine, and in order to make the Universal
Turing Machine simulate a given Turing Machine M’ the following is required:

• Encode the Turing Machine M’ using a standard method to convert it into a string which can
be fed as input into the tape of the Universal Turing Machine.
• Provide the input string w which would have been read by the TM M’ along with the
encoding of M’.

ü Turning machine codes:


Ø Turing machines are encoded into strings over the alphabet ={0,1} using the following
method Consider the encoding of the TM M,

M = ( Q,{0,1},{0,1,B}, , q1 ,B ,{q2})

Ø Be a turning machine with input alphabet {0,1} and the blank as the only additional tape
symbol. We further assume that Q = {q1,q2 …….,qn } is the set of states, and that q2 is the only
final state. Also, there is no need for more than one final state in any TM, since once it accepts it
may as well halt.
Ø It is convenient to call symbols 0,1, and B by the synonyms X1, X2, X3 respectively. We
also give directions L and R the synonym D1 and D2 , resp.

Ø Then a generic move (qI , Xj ) = (qk ,Xl , Dm) is encoded by the binary string.
0i 1 0j 1 0k 1 0l 1 0m

A binary code for turning machine M is


111code1 11 code2 11….11 coder 111,

Ø Where each codei is a string of the above form and each move of M is encoded by one of the
codei ‘s. The moves need not be in any particular order, so each TM actually has many codes.
Any such code for M will be denoted <M>.

Ø Every binary string can be interpreted as the code for at most one TM; many binary strings
are not the code of any TM.
Ø To see that decoding is unique, note that no string has two 1’s in a row, so the codei ‘s can be
found directly. If a string fails to begin and end with exactly three 1’s, has three 1’s other than at
the end, or has two pair of 1’s with other than five blocks of 0’s in between, then the string
represents no TM.
Hence <M,w> will be a string denoting the encoding of the Turing Machine M along with its
input string w.

q The Un decidable Problem:


Ø Now we shall try to prove that the problem “Given the encoding of a Turing Machine M and
a string w, it cannot be stated whether M accepts w or not”.
Ø In order to do this we construct a table, whose rows denote the ith word in the ith row
generated over the alphabet ={0,1} in canonical order.
Ø Thus the ith row contains the word wi. The columns denote the set of Turing Machines listed
in a particular order. The jth column denotes the Turing Machine whose encoding turns out to be
an integer j in binary format.
Ø Also the rule for filling up the cells in the table is as follows:
Ø Now we define a new language Ld namely the diagonal language, which will contain those
strings wi whose diagonal entry is a 0. i.e. wi Ld iff i,ith cell contains a 0.
Ø We shall use a proof by contradiction. It can be shown that there does not exist a language
Ld. If such a language exists, assume that it is accepted by a Turing Machine Mj. By virtue of
our table construction Mj will be featured in the jth row.
Ø If we consider the j,jth entry it can have two of the possibilities:

• If the j,jth entry is a 0 it means that the wj th is not accepted by Ld by virtue of construction
of the table. But by definition of Ld, the j,jth entry should have been 1 if wj th is not accepted.
• If the j,jth entry is a 1 it means that the wj th is accepted by Ld by virtue of construction of
the table. But by definition of Ld, the j,jth entry should have been 0 if wj
th is accepted.

This argument gives rise to a contradiction and hence we see that the problem of deciding
whether a given string can be accepted by a given Turing Machine is unacceptable.

v THE UNIVERSAL LANGUAGE


Ø The universal language Lu consists of strings of the form <M,w> which consists of encoding
of a Turing Machine M followed by a string w, such that w will be accepted by M.
Ø The language Lu is called because universal because any problem, as discussed earlier, can
be thought of as a membership problem i.e. does w belong to language L(M), and it is equivalent
to asking does <M,w> belong to Lu.

• Theorem: The Universal Language Lu is recursively enumerable.

• Proof:
Ø We shall prove that Lu is recursively enumerable by constructing a Turing Machine which
accepts strings of the form <M,w>, and the proof following the detailed construction of the
Turing Machine will prove that the language Lu is recursively enumerable.
Our construction of a TM M1 for recognizing Lu is as follows:
It consists of 3 tapes each one performing a different function.
The first tape is used to store the encoding of M which is <M> and this decodes the functions
of M. It initially reads the string enclosed between the three 1’s, which mark the beginning and
end of the encoding of the Turing Machine.
The second tape initially contains the input to the TM M, which is w. The head on the second
tape performs the same function as that of the head of M.
The third tape of M1 stores the current state of M, during simulation, in the unary format. For
e.g. state qj is stored as 0j.

The typical working of the Turing Machine M1 is as shown under:


1) Check the format of tape 1 to see that it has a prefix of three 1’s and that there are no two
codes that begin with 0i10j1 for the same i and j. Also check that if 0il0iI0kl0lI0m is a code, then
1 j 3, 1 l 3, and 1 m 2.Tape 3 can be used as a scratch tape to facilitate the
comparison of codes.

2) Initialize tape 2 to contain w, the portion of the input beyond the second block of three 1 's.
Initialize tape 3 to hold a single 0, representing q1. All three tape heads are positioned on the
leftmost symbols. These symbols may be marked so the heads can find their way back.

3) If tape 3 holds 00, the code for the final state, halt and accept.

4) Let X j be the symbol currently scanned by tape head 2 and let 0j be the current contents of
tape 3. Scan tape 1 from the left end to the second 111, looking for a substring beginning
110i10i1. If no such string is found, halt and reject; M has no next move and has not accepted. If
such a code is found, let it be 0i10I 10k 10l10m. Then put 0k on tape 3, print XI on the tape cell
scanned by head 2 and move that head in direction Dm , Note that we have checked in (1) that
1 l 3 and 1 m
2. Go to step (3).

Ø It is straightforward to check that M1 accepts <M, w> if and only if M accepts w. It is also
true that if M runs forever on w, M 1 will run forever on <M, w> and if halts on w without
accepting, M1 does the same on (M, w).
Ø Hence, the above construction is sufficient to prove that there exists a Turing Machine for Lu
In order to prove that Lu is recursive enumerable we make use of our previous result where we
proved that Ld is not recursive enumerable.

Ø Since Ld is not recursively enumerable, its complement d L is not recursive. Note that d L =
{wi | Mi accepts wI}. We can prove the universal language d L = {<M, w> I M accepts w} not to
be recursive by reducing d L to Lu. Thus Lu is an example of a language that is recursively
enumerable but not recursive. Also d L is another example of such a language.

• Theorem: Lu is not recursive.

• Proof
Ø Suppose there existed a Turing Machine M for recognizing Lu, then we could recognize d L
as follows. Given string w in (0 + l)*, determine by an easy calculation the value of i such that w
= wi. Integer i in binary is the code for some TM Mi.
Ø Now we could feed the string <Mi,wI> to the TM M and it will accept the string iff Mi
would accept the input string wI. This is simply the membership problem of Ld, which was
proved to be un decidable and hence no algorithm/ Turing Machine exists to recognise Ld. Thus
our assumption of Lu being a recursive language is false and it is a recursively enumerable
language.

v RICE'S THEOREM FOR RECURSIVE INDEX' SETS


Ø From the above examples it can be noted that those properties of languages that are trivial i.e.
which are satisfied by all languages are decidable, but those properties that are non-trivial
(properties satisfied by some but not all languages) are un decidable such as finite, infinite,
regular, CFL, etc.
Ø Also we have been discussing only about the properties of languages accepted by Turing
Machines and not about the properties of Turing Machines themselves.
Ø Now using Rice’s theorem we shall formally prove that any non-trivial property of the
recursively enumerable languages is undecidable.

• Theorem: Rice's Theorem:


Any nontrivial property of the recursively enumerable languages are un decidable.

• Proof:
Ø In order to prove that non-trivial properties are undecidable let us consider a specific property
which does not contain (otherwise rename the complement of as ).
Ø Since is nontrivial, there exists a language L which satisfies the property . Let ML be a
TM accepting L. Suppose were decidable, then there exists an algorithm M accepting L . We
use ML and M to construct an algorithm for Lu as follows.

Ø First construct an algorithm A that takes <M, w> as input and produces <M' > as output,
where L(M') is' in if and only if M accepts w <M, w> is in Lu) .

The design of M' is as given:


§ First M' ignores its input and simulates M on w.
§ If M does not accept w, then M' does not accept x .
§ If M accepts w, then M' simulates ML on x , accepting x if and only if ML
accepts x.
Thus M' either accepts or L depending on whether M accepts w.

Ø We may use the Turing Machine M to determine if L(M') is in . Since L(M') is in if and
only if <M , w> is in Lu, we have an algorithm for recognizing Lu, a contradiction .Thus must
be un decidable.
Examples of Undecidable properties:
1. Is a given language empty?
2. Is a given language finite?
3. Is a given language regular?
4. Is a given language context-free?
q Rice Theorem for recursively enumerable index sets
The condition under which a set L is r.e. is far more complicated. We shall show r .e. if and
only if satisfies the following three conditions.
1) If L is in and L L’, for some r.e. L’, then L’ is in (the containment property).
2) If L is an infinite language in , then there is a finite subset of L in ,
3) The set of finite languages in is enumerable, in the sense that there is a Turing machine that
generates the (possibly) infinite string code1#code2# ..., where codej is a code for the ith finite
language in (in any order). The code for the finite language {w1,w2, …..,wn} is just w1,
w2,……,wn.

In order to prove this we make use of the following Lemma

1. If does not have the containment property, then L is not recursively enumerable.
2. If has an infinite language L such that no finite subset of L is in , then L , is not
recursively enumerable.
3. If L is recursively enumerable then the list of binary codes for the finite sets in is
enumerable.

§ Proof:
Ø We construct a TM M1 that recognizes <M> if and only if L(M) is in as follows. M1
generates pairs (i, j) using the pair generator. In response to (i, j), M1 simulates M2, which is an
enumerator of the finite sets in , for i steps.

Ø We know M2 exists by third condition. Let L1 be the last set completely printed out by M2.
Then simulate M for j steps on each word in L1. If M accepts all words in L1, then M1 accepts
<M>. If not, M1 generates the next (i,j)-pair.

Ø We shall next use the conditions (1) and (2) to show that L(M1) = L . If L is in L and let M
be any TM with L(M) = L. By the second condition there is a finite L’ L in . Let L’ be
generated after i steps of M2, and let j be the maximum number of steps taken by M to accept a
word in L’. Then when M1 generates (i, j), if not sooner, M1 will accept <M>
Conversely, suppose M1 accepts <M>. Then there is some (i, j) such that within j steps M
accepts every word in some finite language L’ such that M2 generates L’ within its first i steps.
Then L’ is in , and L’ L(M).

Ø By condition (1), L(M) is in , so <M> is in L . We conclude that L(M1) = L .


The implications of this theorem are:

§ Corollary 1 The following properties of r.e. sets are not r.e.


a) L= ;
b) L= *.
c) L is recursive.
d) L is not recursive.
e) L is a singleton (has exactly one member).
f) L is a regular set.
g) L –Lu =

§ Corollary 2 The following properties of r.e. sets are r.e.


a) L .
b) L contains at least 10 members.
c) w is in L for some fixed word w.
d) L Lu =

Potrebbero piacerti anche