ToC Unit5
ToC Unit5
Computable Problems –
You are familiar with many problems (or functions) that are computable (or decidable), meaning
there exists some algorithm that computes an answer (or output) to any instance of the problem
(or for any input to the function) in a finite number of simple steps.A simple example is the
integer increment operation:
f(x) = x + 1
It should be intuitive that given any integer x, we can compute x + 1 in a finite number of steps.
Since x is finite, it may be represented by a finite string of digits. Using the addition method (or
algorithm) we all learned in school, we can clearly compute another string of digits representing
the integer equivalent to x + 1.
Yet there are also problems and functions that that are non-computable (or undecidable or
uncomputable), meaning that there exists no algorithm that can compute an answer or output
for all inputs in a finite number of simple steps. (Undecidable simply means non-computable in
the context of a decision problem, whose answer (or output) is either “true” or “false”).
Non-Computable Problems –
A non-computable is a problem for which there is no algorithm that can be used to solve it. Most
famous example of a non-computablity (or undecidability) is the Halting Problem. Given a
description of a Turing machine and its initial input, determine whether the program, when
executed on this input, ever halts (completes).
The alternative is that it runs forever without halting. The halting problem is about seeing if a
machine will ever come to a halt when a certain input is given to it or if it will finish running. This
input itself can be something that keeps calling itself forever which means that it will cause the
program to run forever.
Other example of an uncomputable problem is: determining whether a computer program loops
forever on some input. You can replace “computer program” by “Turing machine or algorithm”if
you know about Turing machine.
To show that a problem is not computable, we need to show that no algorithm exists that solves
the problem. Since there are an infinite number of possible procedures, we cannot just list all
possible procedures and show why each one does not solve the problem. Instead, we need to
construct an argument showing that if there were such an algorithm it would lead to a
contradiction
The core of our argument is based on knowing the Halting Problem is noncom- putable. If a
solution to some new problem P could be used to solve the Halting Problem, then we know that
P is also noncomputable. That is, no algorithm exists that can solve P since if such an algorithm
exists it could be used to also solve the Halting Problem which we already know is
impossible.The proof technique where we show that a solution for some problem P can be used
to solve a different problem Q is known as a reduction. A problem Q is reducible to a problem
P if a solution to P could be used to solve Q. This means that problem Q is no harder than
problem P, since a solution to problem Q leads to a solution to problem P.
Problem − Does the Turing machine finish computing the string w in a finite number of steps?
The answer must be either yes or no.
Proof − At first, we will assume that such a Turing machine exists to solve this problem and
then we will show it is contradicting itself. We will call this Turing machine as a Halting machine
that produces a ‘yes’ or ‘no’ in a finite amount of time. If the halting machine finishes in a finite
amount of time, the output comes as ‘yes’, otherwise as ‘no’. The following is the block diagram
of a Halting machine −
● Else, halt.
Reduction
1.Consider an instance w of P1. Then construct an algorithm such that the algorithm takes
instance w as input and converts it into another instance x of P2. Then apply that algorithm to
check whether x is in P2. If the algorithm answer 'yes' then that means x is in P2, similarly we
can also say that w is in P1. Since we have obtained P2 after reduction of P1. Similarly if
algorithm answer 'no' then x is not in P2, that also means w is not in P1. This proves that if P1 is
undecidable, then P1 is also undecidable.
2.We assume that P1 is non-RE but P2 is RE. Now construct an algorithm to reduce P1 to P2,
but by this algorithm, P2 will be recognized. That means there will be a Turing machine that
says 'yes' if the input is P2 but may or may not halt for the input which is not in P2. As we know
that one can convert an instance of w in P1 to an instance x in P2. Then apply a TM to check
whether x is in P2. If x is accepted that also means w is accepted. This procedure describes a
TM whose language is P1 if w is in P1 then x is also in P2 and if w is not in P1 then x is also not
in P2. This proves that if P1 is non-RE then P2 is also non-RE
Post Correspondence Problem
The Post Correspondence Problem (PCP), introduced by Emil Post in 1946, is an undecidable
decision problem. The PCP problem over an alphabet ∑ is stated as follows −
We can say that there is a Post Correspondence Solution, if for some i1,i2,………… ik, where 1
≤ ij ≤ n, the condition xi1 …….xik = yi1 …….yik satisfies.
Example 1
Here,
x2x1x3 = ‘aaabbaaa’
Example 2
Find whether the lists M = (ab, bab, bbaaa) and N = (a, ba, bab) have a Post Correspondence
Solution?
Solution
Computational complexity
Time Complexity
Time Complexity of an algorithm is the representation of the amount of time required by the
algorithm to execute to completion. Time requirements can be denoted or defined as a
numerical function t(N), where t(N) can be measured as the number of steps, provided each
step takes constant time.
For example, in case of addition of two n-bit integers, N steps are taken. Consequently, the total
computational time is t(N) = c*n, where c is the time consumed for addition of two bits. Here, we
observe that t(N) grows linearly as input size increases.
P and NP Class
In Computer Science, many problems are solved where the objective is to maximize or minimize
some values, whereas in other problems we try to find whether there is a solution or not. Hence,
the problems can be categorized as follows −
Optimization Problem
Optimization problems are those for which the objective is to maximize or minimize some
values. For example,
Decision Problem
There are many problems for which the answer is a Yes or a No. These types of problems are
known as decision problems. For example,
What is Language?
Every decision problem can have only two answers, yes or no. Hence, a decision problem may
belong to a language if it provides an answer ‘yes’ for a specific input. A language is the totality
of inputs for which the answer is Yes. Most of the algorithms discussed in the previous chapters
are polynomial time algorithms.
For input size n, if worst-case time complexity of an algorithm is O(nk), where k is a constant, the
algorithm is a polynomial time algorithm.
Algorithms such as Matrix Chain Multiplication, Single Source Shortest Path, All Pair Shortest
Path, Minimum Spanning Tree, etc. run in polynomial time. However there are many problems,
such as traveling salesperson, optimal graph coloring, Hamiltonian cycles, finding the longest
path in a graph, and satisfying a Boolean formula, for which no polynomial time algorithms is
known. These problems belong to an interesting class of problems, called the NP-Complete
problems, whose status is unknown.
In this context, we can categorize the problems as follows −
P-Class
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 superpolynomial.
Formally, an algorithm is polynomial time algorithm, if there exists a polynomial p(n) such that
the algorithm can solve any instance of size n in a time O(p(n)).
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 class of
decision problems for which it is easy to check the correctness of a claimed answer, 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.
P versus NP
Every decision problem that is solvable by a deterministic polynomial time algorithm is also
solvable by a polynomial time non-deterministic algorithm.
All problems in P can be solved with polynomial time algorithms, whereas all problems in NP - P
are intractable.
It is not known whether P = NP. However, many problems are known in NP with the property
that if they belong to P, then it can be proved that P = NP.
The problem belongs to class P if it’s easy to find a solution for the problem. The problem
belongs to NP, if it’s easy to check a solution that may have been very tedious to find.
NP Hard and NP-Complete Classes
A problem is in the class NPC if it is in NP and is as hard as any problem in NP. A problem is
NP-hard if all problems in NP are polynomial time reducible to it, even though it may not be in
NP itself.
If a polynomial time algorithm exists for any of these problems, all problems in NP would be
polynomial time solvable. These problems are called NP-complete. The phenomenon of
NP-completeness is important for both theoretical and practical reasons.
Definition of NP-Completeness
B is in NP
If a language satisfies the second property, but not necessarily the first one, the language B is
known as NP-Hard. Informally, a search problem B is NP-Hard if there exists some
NP-Complete problem A that Turing reduces to B.
The problem in NP-Hard cannot be solved in polynomial time, until P = NP. If a problem is
proved to be NPC, there is no need to waste time on trying to find an efficient algorithm for it.
Instead, we can focus on design approximation algorithm.
NP-Complete Problems
Following are some NP-Complete problems, for which no polynomial time algorithm is known.
NP-Hard Problems
Cook’s Theorem
Stephen Cook presented four theorems in his paper “The Complexity of Theorem Proving
Procedures”. These theorems are stated below. We do understand that many unknown terms
are being used in this chapter, but we don’t have any scope to discuss everything in detail.
Theorem-1
If a set S of strings is accepted by some non-deterministic Turing machine within polynomial
time, then S is P-reducible to {DNF tautologies}.
Theorem-2
The following sets are P-reducible to each other in pairs (and hence each has the same
polynomial degree of difficulty): {tautologies}, {DNF tautologies}, D3, {sub-graph pairs}.
Second, he focused attention on the class NP of decision problems that can be solved in
polynomial time by a non-deterministic computer. Most of the intractable problems
belong to this class, NP.
Third, he proved that one particular problem in NP has the property that every other
problem in NP can be polynomially reduced to it. If the satisfiability problem can be
solved with a polynomial time algorithm, then every problem in NP can also be solved in
polynomial time. If any problem in NP is intractable, then satisfiability problem must be
intractable. Thus, satisfiability problem is the hardest problem in NP.
Fourth, Cook suggested that other problems in NP might share with the satisfiability
problem this property of being the hardest member of NP.