Professional Documents
Culture Documents
ENGINEERING
UNIT - 5
UNDECIDABILITY
UNDECIDABILITY
Recursive
TMs that TMs that always halt, no matter accepting or non no matter
accepting or non-accepting = DECIDABLE PROBLEMS
Recursively enumerable
TMs that TMs that are guaranteed to halt are guaranteed to halt only on
acceptance only on acceptance. If non-accepting, it may or may not halt
(i.e., could loop forever)
Fig.1.1 Recursive, RE, Undecidable languages Recursive, RE, Undecidable languages
UNDECIDABILITY
1. How does a primitive recursive function help to identify the computable function
(5M, Apr/May 2019)
Recursive Enumerability
A Turing Machine on an input w either (halts and) accepts, or (halts and) rejects,
or never halts.
The language of a Turing Machine M, denoted as L(M), is the set of all strings w
on which M accepts.
A language L is recursively enumerable/Turing recognizable if there is a Turing
Machine M such that L(M) = L
Decidability
Undecidability
DIAGONALIZATION
(Programs) M such that M does not halt and accept when given itself as input.
Diagonalization: Cantor
Proof (contd). We can organize all programs and inputs as a (infinite) matrix, where the
(i, j)th entry is Y if and only if j ∈ L(i).
Suppose Ld is recognized by a Turing machine, which is the jth binary string. i.e., Ld =
L(j). But j ∈ Ld iff j 6∈ L(j)!
1. Prove that Universal language is recursively enumerable but not recursive (13M,
Apr/May 2021)
Ld not recursively enumerable, and therefore not decidable. Are there languages
that are recursively enumerable but not decidable?
Yes, ATM = {<M, w> | M is a TM and M accepts w}
Proof. We have already seen that ATM is r.e. Suppose (for contradiction) ATM is
decidable. Then there is a TM M that always halts and L (M) = Atm. Consider a TM D as
follows:
On input i Run M on input hi, ii Output ‘‘yes’’ if i rejects i Output ‘‘no’’ if i accepts i
Observe that L(D) = Ld! But, Ld is not r.e. which gives us the contradiction.
Undecidable Problems about RE
UNIVERSAL TURING MACHINE
Creating a general-purpose Turing Machine (UTM) is a more difficult task. Once the
Turing machine's transition is defined, the machine is restricted to performing a specific
type of computation.
The UTM would include three pieces of data for the machine it is simulating:
A basic description of the machine.
The contents of the machine tape.
The internal state of the machine.
The Universal machine would simulate the machine by checking the tape input and the
machine's state. It would command the machine by modifying its state in response to
the input. This will be like a computer running another computer. The schematic
diagram of a Universal Turing Machine is as follows:
Fig.1. . Universal Turing Machine
RICE THEOREM
Rice theorem states that any non-trivial semantic property of a language which is
recognized by a Turing machine is undecidable. A property, P, is the language of all
Turing machines that satisfy that property.
Formal Definition
Run M on w
If M does not accept (or doesn't halt), then do not accept x (or do not halt)
If M accepts w then run M0 on x. If M0 accepts x, then accept x.
A function that maps an instance ATM = {<M,w>| M accepts input w} to a N such that
If M accepts w and N accepts the same language as M0, Then L(M) = L(M0) ∈ p
If M does not accept w and N accepts φ, Then L(N) = φ ∉ p
Since ATM is undecidable and it can be reduced to Lp, Lp is also undecidable.
1. Outline the halting problem for Turing Machine (5M, Nov/Dec 2019)
Proof. We will reduce ATM to HALT. Based on a machine M, let us consider a new
machine f(M) as follows:
On input x
Run M on x
Proof Suppose HALT is decidable. Then there is a Turing machine H that always halts
and L(H) = HALT. Consider the following program T
Examples
Reduction
When a problem P1 gets reduced to a problem P2, the solution to P2 solves P1,
according to the reduction approach. P1 reduced P2 is the general term for an algorithm
that transforms an instance of a problem P1 into an instance of a problem P2 with the
same solution. As a result, if P1 is not recursive, then neither is P2. In a similar vein, if P1
is not recursively enumerable, then neither is P2.
Theorem
Proof
The Post correspondence problem is another undecidable problem that turns out to be
a very helpful tool for proving problems in logic or in formal language theory to be
undecidable.
Let Σ be an alphabet with at least two letters. An instance of the Post Correspondence
problem (for short, PCP) is given by two sequences U = (u1, . . . , um) and V = (v1, . . . , vm),
of strings ui , vi ∈ Σ ∗ . The problem is to find whether there is a (finite) sequence (i1, . . . ,
ip), with ij ∈ {1, . . . , m} for j = 1, . . . , p, so that
Step-1: We will start with tile in which numerator and denominator are starting with
same number, so we can start with either 1 or 2, then with second tile, string made by
numerator- 10111, string made by denominator is 10.
Step-3: There is extra 1 in numerator to match this 1 we will add first tile in sequence,
string made by numerator is now 10111 1 1, string made by denominator is 10 111 111.
Step-4: Now there is extra 1 in denominator to match it we will add third tile, string
made by numerator is 10111 1 1 10, string made by denominator is 10 111 111 0.
Final Solution - 2 1 1 3
Step-1: We will start from tile 1 as it is our only option, string made by numerator is
100, string made by denominator is 1.
Step-2: We have extra 00 in numerator, to balance this only way is to add tile 3 to
sequence, string made by numerator is 100 1, string made by denominator is 1 00.
Step-3: There is extra 1 in numerator to balance we can either add tile 1 or tile 2. Let’s
try adding tile 1 first, string made by numerator is 100 1 100, string made by
denominator is 1 00 1.
Step-4: There is extra 100 in numerator, to balance this we can add 1st tile again, string
made by numerator is 100 1 100 100, string made by denominator is 1 00 1 1 1. The 6th
digit in numerator string is 0 which is different from 6th digit in string made by
denominator which is 1.
Proof
Reduce Turing Machine to PCP then we will prove that PCP is undecidable as well.
Consider Turing machine M to simulate PCP’s input string w can be represented as
If there is match in input string w, then Turing machine M halts in accepting state. This
halting state of Turing machine is acceptance problem ATM. We know that acceptance
problem ATM is undecidable. Therefore PCP problem is also undecidable. To force
simulation of M, we make 2 modifications to Turing Machine M and one change to our
PCP problem.
1. M on input w can never attempt to move tape head beyond left end of input tape.
2. If input is empty string € we use.
3. PCP problem starts match with first domino [u1/v1] This is called Modified PCP
problem.
MPCP = {[D] | D is instance of PCP starts with first domino}
Construction Steps
Converting MPCP To PCP: Let u = u1, u2, …, un be any string of input length n and
modify these strings as
$u = *u1*u2*u3* …*un
u$ = u1* u2* u3* … un*
$u$ = * u1* u2* u3* ... un*
Let D be set of two faced Dominos,
D = {[u1 / v1], [u2 / v2], [u3 / v3], ..., [un / vn]} and {[$u1 / $v1$], [$u2 / v2$], ..., [*_ / _]}
From above dominos collection, we could see only domino has partial match starts
with [$u1 / $v1$] and to place marker end of inputs[*_ / _]. There by we can avoid
stating explicit requirement of domino should start with first domino. If number of
configurations of Turing machine does not lie within value of qng n, then Turing
machine is looping state. It does not halt.
Theorem 6.8.1
The Post correspondence problem is undecidable, provided that the alphabet Σ has at
least two symbols.
Reduce the halting problem to the PCP, by encoding sequences of ID’s as partial
solutions of the PCP.
For instance, this can be done for RAM programs. The first step is to show that every
RAM program can be simulated by a single register RAM program. Then, the halting
problem for RAM programs with one register is reduced to the PCP.
Theorem 6.8.2
Proof
LU,V = LU ∪ LV .
productions are:
S −→ SU
S −→ SV
SU −→ uiSUci
SU −→ uici
SV −→ viSV ci S
V −→ vici.
It is easily seen that the PCP for (U, V) has a solution iff LU ∩LV = ∅ iff G is ambiguous.
Example 1:
A = (b, bab3, ba) and B = (b3, ba, a). The input set is ∑ = {0, 1}. Find the solution.
Solution:
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
2. Define the classes P and NP problem. Give example problems for both. (2M,
Apr/May 2021)
4. Show that any problem in P is also in NP but not the other way around (5M,
Nov/Dec 2019)
NP-Complete Problems
The above is the standard technique used for showing the NP-hardness or NP-
completeness of a given decision problem.
If the actual input sizes are small, an algorithm with, say, exponential running
time may be acceptable. On the other hand, it may still be possible to obtain near-
optimal solutions in polynomial-time. Such an algorithm that returns near-
optimal solutions (in polynomial time) is called an approximation algorithm.
NP-Hard Problems
A problem is said to be NP-Hard when an algorithm for solving NP Hard can be
translated to solve any NP problem. Then we can say, this problem is at least as hard as
any NP problem, but it could be much harder or more complex.
NP-Complete Problems
NP-Complete (NPC) problems are problems that are present in both the NP and NP-
Hard classes. That is NP-Complete problems can be verified in polynomial time and any
NP problem can be reduced to this problem in polynomial time.
If a polynomial time algorithm exists for any of these types of problems, all problems in
NP can be polynomial time solvable. These problems are called NP-complete. NP
completeness is important for both theoretical and practical reasons.
Definition of NP-Completeness
A language M is NP-complete, if it satisfies the two conditions which are given below −
M is in NP.
Every A in NP is polynomial time reducible to M.
Suppose, if a language satisfies the second property, but not necessarily the first one,
the language M is known as NP-Hard.
Informally, a search problem M is NP-Hard if there exists some NP-Complete problem A
that Turing reduces to M.
NP-Complete Problems
Examples of NP-Complete problems where no polynomial time algorithm is known are
as follows
Determining whether a graph has a Hamiltonian cycle
Determining whether a Boolean formula is satisfactory, etc.
NP-Hard Problems
Example
Step 1 − If a problem is in class P, it is nothing but we can find a solution to that type of
problem in polynomial time.
Step 2 − If a problem is in class NP, it is nothing but that we can verify a possible solution in
polynomial time.
Step 4 − so, if you can solve a problem in polynomial time, you can certainly verify that your
answer is correct in polynomial time, can't you? Sure, if you can prove that your algorithm is
correct and that it can find an answer in polynomial time, which it must to be in P.
Example
TSP is NP-Complete
The travelling salesman problem (TSP) is having a salesman and a set of cities. The
salesman needs to visit each one of the cities starting from a certain one and returning
to the same city i.e. back to starting position. The challenge of this problem is that the
travelling salesman wants to minimise the total length of the trip.
Proof
In TSP, we have to find a tour and check that the tour contains each vertex once.
Then, we calculate the total cost of the edges of the tour. Finally, we check if the
cost is minimum or not. This can be done in polynomial time. Therefore, TSP
belongs to NP.
To prove this, one way is to show that the Hamiltonian cycle ≤p TSP (as we know
that the Hamiltonian cycle problem is NP Complete)
Hence, an instance of TSP is constructed. We can create the complete graph G' =
(V, E').
Now, assume that a Hamiltonian cycle H exists in G. The cost of each edge in H is
0 in G' as each edge belongs to E. Therefore, H is having a cost of 0 in G'. Thus, if
graph G has a Hamiltonian cycle, then graph G' has a tour of 0 cost.
Now let us assume that G' has a tour H’ of cost at most 0. The cost of edges in E'
are 0 and 1 by definition. Hence, each edge must have a cost of 0 as the cost of H’
is 0. We finally conclude that H' contains only edges in E.
Finally proved that G has a Hamiltonian cycle, if and only if G' has a tour of cost at
most 0. TSP is NP-complete.
A Harder Example:
To show that not all languages are (obviously) in P, consider the following:
Such a cycle is called a Hamiltonian cycle and the decision problem is the Hamiltonian
Cycle Problem.
Fig. 1.4: The Hamiltonian cycle (HC) problem
In Fig. 1.4 (a) we show an example of a Hamiltonian cycle in a graph. If you think that
the problem is easy to solve, try to solve the problem on the graph shown in Fig. 1.4 (b),
which has one additional vertex and one additional edge. Either find a Hamiltonian cycle
in this graph or show than none exists. To make this even harder, imagine a million-
vertex graph with many slight variations of this pattern. Is HC ∈ P? No one knows the
answer for sure, but it is conjectured that it is not.
Many language recognition problems that may be hard to solve, but they have the
property that they are easy to verify that a string is in the language. There is no
obviously efficient way to find a Hamiltonian cycle in a graph. However, suppose that a
graph did have a Hamiltonian cycle and someone wanted to convince us of its existence.
This person would simply tell us the vertices in the order that they appear along the
cycle. It would be a very easy matter for us to inspect the graph and check that this is
indeed a legal cycle that it visits all the vertices exactly once. Thus, even though we
know of no efficient way to solve the Hamiltonian cycle problem, there is a very efficient
way to verify that a given graph has one.
The given cycle in the above example is called a certificate. A certificate is a piece of
information which allows us to verify that a given string is in a language in polynomial
time.
Note that not all languages have the property that they are easy to verify. For example,
consider the following languages:
There is no known polynomial time verification algorithm for either of these. For
example, suppose that a graph G is in the language UHC.
Definition: NP is the set of all languages that can be verified in polynomial time.
Observe that if we can solve a problem efficiently without a certificate, we can certainly
solve given the additional help of a certificate. Therefore, P ⊆ NP. However, it is not
known whether P = NP. Most experts believe that P 6= NP, but no one has a proof of this.
Next time we will define the notions of NP-hard and NP-complete. There is one last
ingredient that will be needed before defining NP-completeness, namely the notion of a
polynomial time reduction. We will discuss that next time.