TOC Unit 5 Theory of Computation
TOC Unit 5 Theory of Computation
UNIT V
UNDECIDABILITY
UNIT V 1
Paavai Institutions Department of AIML
Table of Contents
UNIT V 2
Paavai Institutions Department of AIML
Technical Terms
UNIT V 3
Paavai Institutions Department of AIML
UNIT V 4
Paavai Institutions Department of AIML
The problems for which we can’t construct an algorithm that can answer the
problem correctly in the infinite time are termed as Undecidable Problems in the theory of
computation (TOC).
A problem is undecidable if there is no Turing machine that will always halt an infinite
amount of time to answer as ‘yes’ or ‘no’.
Examples
The examples of undecidable problems are explained below. Here, CFG refers to Context
Free Grammar.
Whether two CFG L and M equal − Since, we cannot determine all the strings of
any CFG, we can predict that two CFG are equal or not.
Given a context-free language, there is no Turing machine (TM) that will always
halt an infinite amount of time and give an answer to whether language is
ambiguous or not.
Given two context-free languages, there is no Turing machine that will always halt
an infinite amount of time and give an answer whether two context-free languages
are equal or not.
Whether CFG will generate all possible strings of the input alphabet (∑*) is
undecidable.
Halting Problem
The recursive languages are also closed under set difference and complementation.
Recursive: They allow a function to call itself. Or, a recursive language is a recursive
subset in the set of all possible words over alphabet Σ of that language.
UNIT V 5
Paavai Institutions Department of AIML
• Non-recursive should not be taken as simpler version of computation, i.e., e.g., obtaining
factorial value without recursion method. Regular languages ⊆ context free languages ⊆
• Let L be a RE language and M the Turing Machine that accepts it. ∴, for w ∈ L, M halts
in final state. For w ∈/ L, M halts in non-final state or loops for ever.
• A language is Recursive (R) if some Turing machine M recognizes it and halts on every
• Let L be a recursive language and M the Turing Machine that accepts (i.e. recognizes) it.
For string w, if w ∈ L, then M halts in final state. If w ∈/ L, then M halts in non-final
state. (halts always!).
Decidable and Undecidable Languages:
UNIT V 6
Paavai Institutions Department of AIML
• Sometimes the line between what is an ‘easy’ problem and what is a ‘hard’ problem
is a fine one.
• For example, “Find the shortest path from vertex x to vertex y in a given weighted
graph”. This can be solved efficiently without much difficulty.
• However, if we ask for the longest path (without cycles) from x to y, we have a
problem for which no one knows a solution better than an exhaustive search.
The undecidable problem about turing machine is given by halting problem. Let us
understand this.
Halting Problem:
UNIT V 7
Paavai Institutions Department of AIML
UNIT V 8
Paavai Institutions Department of AIML
Let us now see what Tc does when a string describing Tc itself is given to it.
When Tc gets the input d(Tc) , it makes a copy, constructs the string
d(Tc)*d(Tc) and gives it to the modified T. Thus the modified T is given a
description of Turing machine Tc and the string d(Tc).
The way T was modified the modified T is going to go into an infinite loop
if Tc halts on d(Tc) and halts if Tc does not halt on d(Tc).
Thus Tc goes into an infinite loop if Tc halts on d(Tc) and it halts if Tc does
not halt on d(Tc). This is a contradiction. This contradiction has been deduced from
our assumption that there is a Turing machine that solves the halting problem.
Hence that assumption must be wrong. Hence there is no Turing machine that
solves the halting problem.
UNIT V 9
Paavai Institutions Department of AIML
`"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:
Consider the correspondence system as given below
A = (b, bab3, ba) and B = (b3, ba, a). The input set is ∑ = {0, 1}. Find the solution.
Solution:
A solution is 2, 1, 1, 3. That means w2w1w1w3 = x2x1x1x3
The constructed string from both lists is bab3b3a.
Example 2:
Does PCP with two lists x = (b, a, aba, bb) and y = (ba, ba, ab, b) have a solution?
Solution: Now we have to find out such a sequence that strings formed by x and y
are identical. Such a sequence is 1, 2, 1, 3, 3, 4. Hence from x and y list
UNIT V 10
Paavai Institutions Department of AIML
Example 3:
Obtain the solution for the following system of posts correspondence problem. A = {100,
0, 1}, B = {1, 100, 00}
Solution: Consider the sequence 1, 3, 2. The string obtained from A = babababb. The string
obtained from B = bababbbb. These two strings are not equal. Thus if we try various
combination from both the sets to find the unique sequence, we could not get such a
sequence. Hence there is no solution for this system.
Example 4:
Obtain the solution for the following system of posts correspondence problem, X = {100,
0, 1}, Y = {1, 100, 00}.
Definition:
First pair in the A and B lists must be the first pair in the solution, i.e., the
problem is to determine it there is a sequence of zero or more integers i1,i2,……,in
such that:
w1w2w3………wn = x1x2x3…..xn
UNIT V 11
Paavai Institutions Department of AIML
Reduction to MPCP to PCP We are almost done, but not quite. Since our
reduction only show that
An instance of MPCP is a set of tiles (just like an instance of PCP), with the
additional constraint that a specific tile is denoted as an initial tile that must be used
as the first tile in the matching.
As such, to convert this instance T of MPCP into PCP we need to some how
remove the need to specify the initial tile.
Construction of UTM
Without loss of generality, we assume the following for M:
Q = {q1, q2, ….qn} where q1=initial state and q2=Final State
τ = {σ1, σ2,,…σn} where σ represent blanks
Select an encoding on which q1 is representable by 1, q2 by 11, and so on.
Similarly, σ1 is encoded as 1, σ2 as 11, etc.
Finally, let us represent R/W head directions by 1 for L (Left) and 11 for
R(Right).
The symbol 0 will be used as a separator between 1s.
UNIT V 12
Paavai Institutions Department of AIML
Implementation of UTM
A UTM Mu then has an input alphabet = {0, 1} and the structure of a multi-tape
TM.
Mu looks first at the contents of Tape 2 and Tape 3 to determine the
instantaneous description (ID) of M.
It then consults Tape1 to see what M would do with this ID.
Finally, Tape 2 and Tape 3 will be modified to reflect the result of the move
UNIT V 13
Paavai Institutions Department of AIML
UNIT V 14
Paavai Institutions Department of AIML
Examples
Towers of Hanoi: we can prove that any algorithm that solves this problem must have a
worst-case running time that is at least 2n − 1.
* List all permutations (all possible orderings) of n numbers.
The class P consists of those problems that are solvable in polynomial time, i.e.
these problems can be solved in time O(nk) in worst-case, where k is constant.
These problems are called tractable, while others are called intractable or super
polynomial.
UNIT V 15
Paavai Institutions Department of AIML
Problem requiring Ω(n50)time to solve are essentially intractable for large n. Most
known polynomial time algorithm run in time O(nk) for fairly low value of k.
The advantages in considering the class of polynomial-time algorithms is that all
reasonable deterministic single processor model of computation can be simulated
on each other with at most a polynomial slow-d.
NP-Class:
The class NP consists of those problems that are verifiable in polynomial time.
NP is the classofdecisionproblemsforwhichitiseasytocheckthecorrectnessofaclaimedanswer,
with the aid of a little extra information.
Hence, we aren’t asking for a way to find a solution, but only to verify that an
alleged solution really is correct.
Every problem in this class can be solved in exponential time using
exhaustive search
5.6.1 Example of P Class Problem:
Kruskal's algorithm is famous P-Class problem known to get MST. This algorithm generate
Minimum Spanning Tree in polynomial time. Related problems is one of the unit of Automata
Theory, where we learn complexity and decision problems.
Example for Kruskal’s Algorithm:
UNIT V 16
Paavai Institutions Department of AIML
In case of parallel edges, keep the one which has the least cost associated and remove all others.
The least cost is 2 and edges involved are B,D and D,T. We add them. Adding them does not
violate spanning tree properties, so we continue to our next edge selection.
Next cost is 3, and associated edges are A,C and C,D. We add them again
UNIT V 17
Paavai Institutions Department of AIML
Now we are left with only one node to be added. Between the two least cost edges available 7 and
8, we shall add the edge with cost 7.
UNIT V 18
Paavai Institutions Department of AIML
Following are the differences between the P class problem and the NP class problem:
1. P problems are a set of problems that can be NP problems are problems that can be solved in
solved in polynomial time by deterministic nondeterministic polynomial time.
algorithms.
2. P Problems can be solved and verified in The solution to NP problems cannot be obtained in
polynomial time. polynomial time, but if the solution is given, it can be
verified in polynomial time.
4. All P problems are deterministic in nature. All the NP problems are non-deterministic in nature.
5. It takes polynomial time to solve a problem like It takes non-deterministic polynomial time to quickly check
n, n^2, n*logn, etc. a problem.
6. The solution to P class problems is easy to find. The solution to NP class problems is hard to find.
7. Examples of P problems are: Selection sort, Examples of NP problems are the Travelling salesman
Linear Search problem and the knapsack problem.
UNIT V 19
Paavai Institutions Department of AIML
In these two figures, figure II represents the least/minimum distance path. In figure I, when
salesmen travel from Chennai (point 1) to Hyderabad(point 5) it takes a lot of time to reach its
own location and total distance covered i.e.( 1 -> 2 -> 3 -> 4 -> 5 -> 1 ) but in the case of figure
II the salesman directly reach the point at 3(Mumbai) which saves the time and also cover the
total minimum distance i.e. ( 1 -> 3 -> 5 -> 1 ).
Can we find the possibilities of 32 cities problem?
The possibility is given by (n-1)!/2 solution.
UNIT V 20
Paavai Institutions Department of AIML
5.6.3 3CNF SAT
Concept: - In 3CNF SAT, you have at least 3 clauses, and in clauses, you will have almost 3
literals or constants
UNIT V 21
Paavai Institutions Department of AIML
Proof of NPC:-
It shows that you can easily convert a Boolean function of SAT into 3CNF SAT and
satisfied the concept of 3CNF SAT also within polynomial time through Reduction
concept.
If you want to verify the output in 3CNF SAT then perform the Reduction and convert into
SAT and CIRCUIT also to check the output
If you can achieve these two points that means 3CNF SAT also in NPC
UNIT V 22
Paavai Institutions Department of AIML
PART – B
1. (i)Describe about the tractable and intractable problems.
(ii)Identify that “MPCP reduce to PCP”.
2. (i)Describe about Recursive and Recursive Enumerable languages with example.
(ii)State and describe RICE theorem.
3. (i)Summarize diagonalization language.
(ii)Discuss the significance of universal turing machine and also construct a turing
machine to add two numbers and encode it.
UNIT V 23
Paavai Institutions Department of AIML
4. Discuss post correspondence problem .Let ∑={0,1}.Let A and B be the lists of three
strings each defined as
(i) Does the PCP have a solution?(7)
(ii) Prove that the universal language is recursively enumerable.
5. (i)Explain computable functions with suitable example.
(ii)Explain in detail notes on Unsolvable Problems.
6. (i) Describe in detail notes on universal Turing machines with example.
(ii) Collect and write the short notes on NP-complete problems.
7. (i) Show that the diagonalization language (Ld) is not a recursively enumerable.
(ii) Illustrate about unsolvability.
8. (i) Compare the difference between recursive and recursively enumerable
languages.
(ii) Explain about PCP.
9. Prove that for two recursive languages L1 and L2 their union and intersection is
recursive.
UNIT V 24