You are on page 1of 7

Decidable and Undecidable problems in Theory of Computation

A problem is said to be Decidable if we can always construct a


corresponding algorithm that can answer the problem correctly. We can
intuitively understand Decidable problems by considering a simple
example. Suppose we are asked to compute all the prime numbers in the
range of 1000 to 2000. To find the solution of this problem, we can
easily devise an algorithm that can enumerate all the prime numbers in
this range.

Now talking about Decidability in terms of a Turing machine, a problem


is said to be a Decidable problem if there exists a corresponding Turing
machine which halts on every input with an answer- yes or no. It is also
important to know that these problems are termed as Turing
Decidable since a Turing machine always halts on every input,
accepting or rejecting it.

Semi-Decidable-Problems–
Semi-Decidable problems are those for which a Turing machine halts on
the input accepted by it but it can either halt or loop forever on the input
which is rejected by the Turing Machine. Such problems are termed
as Turing Recognisable problems.
Examples – We will now consider few important Decidable problems:
 Are two regular languages L and M equivalent?
We can easily check this by using Set Difference operation.
L-M =Null and M-L =Null.
Hence (L-M) U (M-L) = Null, then L,M are equivalent.
 Membership of a CFL?
We can always find whether a string exists in a given CFL by
using an algorithm based on dynamic programming.
 Emptiness of a CFL
By checking the production rules of the CFL we can easily state
whether the language generates any strings or not.
Undecidable Problems –
The problems for which we can’t construct an algorithm that can answer
the problem correctly in finite time are termed as Undecidable Problems.
These problems may be partially decidable but they will never be
decidable. That is there will always be a condition that will lead the
Turing Machine into an infinite loop without providing an answer at all.
We can understand Undecidable Problems intuitively by
considering Fermat’s Theorem, a popular Undecidable Problem which
states that no three positive integers a, b and c for any n>2 can ever
satisfy the equation: a^n + b^n = c^n.
If we feed this problem to a Turing machine to find such a solution
which gives a contradiction then a Turing Machine might run forever, to
find the suitable values of n, a, b and c. But we are always unsure
whether a contradiction exists or not and hence we term this problem as
an Undecidable Problem.
Examples – These are few important Undecidable Problems:
 Whether a CFG generates all the strings or not?
As a CFG generates infinite strings, we can’t ever reach up to
the last string and hence it is Undecidable.
 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.
 Ambiguity of CFG?
There exist no algorithm which can check whether for the
ambiguity of a CFL. We can only check if any particular string
of the CFL generates two different parse trees then the CFL is
ambiguous.
 Is it possible to convert a given ambiguous CFG into
corresponding non-ambiguous CFL?
It is also an Undecidable Problem as there doesn’t exist any
algorithm for the conversion of an ambiguous CFL to non-
ambiguous CFL.
 Is a language Learning which is a CFL, regular?
This is an Undecidable Problem as we can not find from the
production rules of the CFL whether it is regular or not.
Some more Undecidable Problems related to Turing machine:
 Membership problem of a Turing Machine?
 Finiteness of a Turing Machine?
 Emptiness of a Turing Machine?
 Whether the language accepted by Turing Machine is regular or
CFL?

What are the undecidable problems in TOC


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 Halting problem is the most famous of the undecidable problems.
Consider the code
num=1;
while(num=0)
{
   num=num+1;
}
It counts up forever since it will never equal 0. This is an example of the
halting problem.
Note: Every context-free language is decidable.
Some of the other undecidable problems are:
Totality problem − It decide whether an arbitrary TM halts on all
inputs. This is equivalent to the problem of whether a program can ever
enter an infinite loop, for any input. It differs from the halting problem,
which asks whether it enters an infinite loop for a particular input.
Equivalence problem − It decide whether two TMs accept the same
language. This is equivalent to the problem of whether two programs
compute the same output for every input.

Difference Between P And NP Problems

P = the set of problems that are solvable in polynomial time by a


Deterministic Turing Machine. NP = the set of decision problems
(answer is either yes or no) that are solvable in nondeterministic
polynomial time i.e can be solved in polynomial time by a
Nondeterministic Turing Machine.

The P versus NP problem is to determine whether every language


accepted by some nondeterministic algorithm in polynomial time is also
accepted by some (deterministic) algorithm in polynomial time. To
define the problem precisely it is necessary to give a formal model of a
computer. The standard computer model in computability theory is the
Turing machine, introduced by Alan Turing in 1936. Although the
model was introduced before physical computers were built, it
nevertheless continues to be accepted as the proper computer model for
the purpose of defining the notion of computable
function.

Informally the class P is the class of decision problems solvable by some


algorithm within a number of steps bounded by some fixed polynomial
in the length of the input. Turing was not concerned with the efficiency
of his machines, but rather his concern was whether they can simulate
arbitrary algorithms given sufficient time. However it turns out Turing
machines can generally simulate more efficient computer models (for
example machines equipped with many tapes or an unbounded random
access memory) by at most squaring or cubing the computation time.
Thus P is a robust class, and has equivalent definitions over a large class
of computer models.

What are P And NP Problems?

P (polynomial time) refers to the class of problems that can be solved by


an algorithm in polynomial time. Problems in the P class can range from
anything as simple as multiplication to finding the largest number in a
list. They are the relatively ‘easier’ set of problems.
NP (non-deterministic polynomial time) refers to the class of problems
that can be solved in polynomial time by a non-deterministic computer.
This is essentially another way of saying “If I have unlimited compute
power (i.e. as many computers as I need), I am capable of solving any
problem in at most polynomial time”. More intuitively though, it refers
to the class of problems that currently, has no way of finding a quick
(polynomial time) enough answer, BUT can be quickly verified (in
polynomial time) if one provides the solution to the problem. The term
verified here means that one is able to check that the solution provided is
indeed correct.
Facts About P Problems

P problems are set of problems which can be solved in


polynomial time by deterministic algorithms.
 The problem belongs to class P if it’s easy to find a solution
for the problem.
 P Problems can be solved and verified in polynomial time.
 P problems are subset of NP problems.
 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.
 All P problems are deterministic in nature.
 Example: Selection sort, linear search
Facts About NP-Class Problems

 NP problems are the problems which can be solved in non-


deterministic polynomial time.
 The problem belongs to NP, if it’s easy to check a solution
that may have been very tedious to find.
 Solution to NP problems cannot be obtained in polynomial
time, but if the solution is given, it can be verified in
polynomial time.
 If P≠NP, there are problems in NP that are neither in P nor in
NP-Complete.
 NP problems are superset of P problems.
 All the NP problems are non-deterministic in nature.
 Example TSP, Knapsack problem.
What is the difference between P vs NP?

P = the set of problems that are solvable in polynomial time by a


Deterministic Turing Machine. NP = the set of decision problems
(answer is either yes or no) that are solvable in nondeterministic
polynomial time i.e can be solved in polynomial time by a
Nondeterministic Turing Machine.

You might also like