Automata Unit 5
Automata Unit 5
Undecidable Problems:
A problem is undecidable if there is no Turing machine which will always halt in
finite amount of time to give answer as ‘yes’ or ‘no’. An undecidable problem has
no algorithm to determine the answer for a given input.
Examples:
Rice Theorem:
Any nontrivial property about the language recognized by a Turing machine is
undecidable.
A property about Turing machines can be represented as the language of all Turing
machines, encoded as strings, that satisfy that property. The property P is about the
language recognized by Turing machines if whenever L(M)=L(N) then P contains
(the encoding of) M if it contains (the encoding of) N. The property is non-trivial if
there is at least one Turing machine that has the property, and at least one that
hasn't.
Proof: Without limitation of generality, we may assume that a Turing machine that
recognizes the empty language does not have the property P. For if it does, just
take the complement of P. The undecidability of that complement would
immediately imply the undecidability of P.
In order to arrive at a contradiction, suppose P is decidable, i.e. there is a halting
Turning machine B that recognizes the descriptions of Turing machines that satisfy
P. Using B we can construct a Turning machine A that accepts the language
{(M,w)| M is the description of a Turing machine that accepts the string w}. As the
latter problem is undecidable this will show that B cannot exists and P must be
undecidable as well.
Let MP be a Turing machine that satisfies P (as P is non-trivial there must be one).
Now A operates as follows:
1. On input (M,w), create a (description of a) Turing machine C(M,w) as
follows:
a. On input x, let the Turing machine M run on the string w until it
accepts (so if it doesn't accept C(M,w) will run forever).
b. Next run MP on x. Accept iff MP does.
2. Note that C(M,w) accepts the same language as MP if M accepts w; C(M,w)
accepts the empty language if M does not accept w.
Thus if M accepts w the Turing machine C(M,w) has the property P, and
otherwise it doesn't.
3. Feed the description of C(M,w) to B. If B accepts, accept the input (M,w); if
B rejects, reject
"The Post's correspondence problem consists of two lists of string that are of equal
length over the input. The two lists are A = w1, w2, w3, .... , wn and B = x1, x2, x3, ....
xn then there exists a non-empty set of integers i1, i2, i3, .... , in such that,
w1, w2, w3, .... wn = x1, x2, x3, .... xn"
To solve the post correspondence problem, we try all the combinations of i1, i2, i3,
.... , in to find the w1 = x1 then we say that PCP has a solution.
Example 1:
Find whether the lists: M = (abb, aa, aaa) and N = (bba, aaa, aa) have a Post
Correspondence Solution?
Solution:
x1 x 2 x 3
M abb aa aaa
N bba aaa aa
Here,
x2x1x3 = ‘aaabbaaa’
and y2y1y3 = ‘aaabbaaa’
We can see that
x2x1x3 = y2y1y3
Hence, the solution is i = 2, j = 1, and k = 3.
Example 2
Find whether the lists M = (ab, bab, bbaaa) and N = (a, ba, bab) have a Post
Correspondence Solution?
Solution
x1 x2 x3
M ab bab bbaaa
N a ba bab
In this case, there is no solution because −
| x2x1x3 | ≠ | y2y1y3 | (Lengths are not same)
Hence, it can be said that this Post Correspondence Problem is undecidable.
The Halting problem:
Given a program/algorithm will ever halt or not?
Halting means that the program on certain input will accept it and halt or reject it
and halt and it would never go into an infinite loop. Basically, halting means
terminating. So can we have an algorithm that will tell that the given program will
halt or not. In terms of Turing machine, will it terminate when run on some
machine with some particular given input string.
The answer is no we cannot design a generalized algorithm which can
appropriately say that given a program will ever halt or not?
The only way is to run the program and check whether it halts or not.
We can refrain the halting problem question in such a way also: Given a program
written in some programming language(c/c++/java) will it ever get into an infinite
loop (loop never stops) or will it always terminate(halt)?
This is an undecidable problem because we cannot have an algorithm which will
tell us whether a given program will halt or not in a generalized way i.e by having
specific program/algorithm. In general, we can’t always know that’s why we can’t
have a general algorithm. The best possible way is to run the program and see
whether it halts or not. In this way for many programs, we can see that it will
sometimes loop and always halt.
Proof by Contradiction –
Problem statement: Can we design a machine which if given a program can find
out if that program will always halt or not halt on a particular input?
Solution: Let us assume that we can design that kind of machine called as HM(P, I)
where HM is the machine/program, P is the program and I is the input. On taking
input the both arguments the machine HM will tell that the program P either halts
or not.
If we can design such a program this allows us to write another program, we call
this program CM(X) where X is any program (taken as argument) and according to
the definition of the program CM(X) shown in the figure.
In the program CM(X) we call the function HM(X), which we have already
defined and to HM() we pass the arguments (X, X), according to the definition of
HM() it can take two arguments i.e one is program and another is the input. Now in
the second program we pass X as a program and X as input to the function
HM().We know that the program HM() gives two output either “Halt” or “Not
Halt". But in case second program, when HM(X, X) will halt loop body tells to go
in loop and when it doesn’t halt that means loop, it is asked to return.
Now we take one more situation where the program CM is passed to CM()
function as an argument. Then there would be some impossibility, i.e., a condition
arises which is not possible.
It is impossible for outer function to halt if its code (inner body) is in loop and also
it is impossible for outer non halting function to halt even after its inner code is
halting. So the both condition is non halting for CM machine/program even we had
assumed in the beginning that it would halt. So this is the contradiction and we can
say that our assumption was wrong and this problem, i.e., halting problem is
undecidable.
This is how we proved that halting problem is undecidable.
Recursive and recursive enumerable language:
A language is recursive if there exists a Turing machine that accepts every string in
the language and rejects if it is not in the language.
for example, let's take Turing machine M and String w: if string w is a member of
the Turing machine M, then M halts in its final state otherwise it rejects the
computation. ==>==> A language is recursive enumerable if there exists a Turing
machine that accepts every string in the language and rejects if it is not in the
language may be loop forever.
for example, let's take Turing machine M and String w: if string w is in the
language, then M halts in its final state. Otherwise, it rejects the computation or
may be run forever
Recursive languages are decidable by some Turing Machine, i.e., there is a TM
that can, given any input string (over the appropriate alphabet) correctly answer
yes if the string is in the language, or no if it isn't.
A language is recursive enumerable if there exists a TM that keeps outputting
strings that belong to the language (and only such strings), such that eventually
every string in the language will be in the output.
Recursively enumerable languages are only recognized, i.e., there exists a Turing
Machine that accepts when the string is in the language but it may loop forever if
the string is not in the language.
Recursively enumerable Turing machine if it not accepts a string may halt in non-
final state or loop forever which is not the case for recursive languages
Recursive Enumerable (RE) or Type -0 Language:
RE languages or type-0 languages are generated by type-0 grammars. An RE
language can be accepted or recognized by Turing machine which means it will
enter into final state for the strings of language and may or may not enter into
rejecting state for the strings which are not part of the language. It means TM can
loop forever for the strings which are not a part of the language. RE languages are
also called as Turing recognizable languages.
Recursive Language (REC)
A recursive language (subset of RE) can be decided by Turing machine which
means it will enter into final state for the strings of language and rejecting state for
the strings which are not part of the language. e.g.; L= {anbncn|n>=1} is recursive
because we can construct a turing machine which will move to final state if the
string is of the form anbncn else move to non-final state. So, the TM will always
halt in this case. REC languages are also called as Turing decidable languages. The
relationship between RE and REC languages can be shown in Figure 1.
L1 says n no. of a’s followed by n no. of b’s followed by n no. of c’s and
then any no. of d’s. L2 says any no. of a’s followed by n no. of b’s followed
by n no. of c’s followed by n no. of d’s. Their intersection says n no. of a’s
followed by n no. of b’s followed by n no. of c’s followed by n no. of d’s. So
it can be decided by turing machine, hence recursive.
Similarly, complement of recursive language L1 which is ∑*-L1, will also
be recursive.
Are all languages either recursive or recursively enumerable (decidable or
recognizable)?
Take the language HALT(M,w) that consists of all Turing machines that halt for
input w.
Turing proved that this language is not decidable. It is, however, recursively
enumerable because we can test all Turing machines with input w and print them if
they ever halt.
If a language and its complement are recursively enumerable, it is decidable. Why?
Simply execute the enumerators for the language and its complement with and wait
until one of them outputs your input. If it is the enumerator of the language, your
input is in the language. If it is the other enumerator, your input is not in the
language.
It follows directly that the complement of HALT(M,w) cannot be recursively
enumerable because else, HALT(M,w) would be decidable.
NP-Hard
Intuitively, these are the problems that are at least as hard as the NP-complete
problems. Note that NP-hard problems do not have to be in NP, and they do not
have to be decision problems.
The precise definition here is that a problem X is NP-hard, if there is an NP-
complete problem Y, such that Y is reducible to X in polynomial time.
But since any NP-complete problem can be reduced to any other NP-complete
problem in polynomial time, all NP-complete problems can be reduced to any NP-
hard problem in polynomial time. Then, if there is a solution to one NP-hard
problem in polynomial time, there is a solution to all NP problems in polynomial
time.
Example
The halting problem is an NP-hard problem. This is the problem that given a
program P and input I, will it halt? This is a decision problem but it is not in NP. It
is clear that any NP-complete problem can be reduced to this one. As another
example, any NP-complete problem is NP-hard.
NP-Hard Problems
The following problems are NP-Hard
The circuit-satisfiability problem
Set Cover
Vertex Cover
Travelling Salesman Problem