Theory of Computing
Lecture 16
MAS 714
Hartmut Klauck
Problems that are not in P
• EXP: class of all L that can be decided by
Turing machines that run in time at most
exp(p(n)) for some polynomial p
• We will show later that EXP is not equal to P
– i.e., there are problems that can be solved in
exponential time, but not in polynomial time
– These problems tend to be less interesting
Problems that are not in P?
• Definition:
– Given an undirected graph, a clique is a set of vertices
Sµ V, such that all u,v2 S are connected
– The language MaxClique is the set of all G,k, such that
G has a clique of size k (or more)
• Simple Algorithm: enumerate all subsets of size k,
test if they form a clique
• Time O(nk ¢ poly(k))
• Since k is not constant this is not a polynomial
time algorithm
• MaxClique is in P if and only if thousands of
other interesting problems are
• We don’t know an efficient algorithm for any
of them
• Widely believed: there is no such algorithm
Fun Piece of Information
• A random graph is a graph generated by putting
each possible edge into G with probability ½
• The largest clique in G has size dr(n)e or br(n)c
for an explicit r(n) that is around (2+o(1)) log(n)
• With probability approaching 1
• Hence on random graphs the max clique can be
found in sub-exponential time
The class NP
• NP: nondeterministic polynomial time
• NP is the class of problems where a `solution’
or proof can be verified in polynomial time
• Example: Given a set S of k vertices in G we
can check in time O(k2) if S is a clique
• Guess and check definition:
• A language L is in NP, if there is a language
R2P such that for all x:
[There is a poly(|x|) length string y s.t. x#y2R]
, x2 L
• y is called proof or witness
• Max Flow:
– Given a flow we can check that the flow is
maximal in linear time
– But then we can find the max flow in polynomial
time anyway
• Clique:
– We can check a clique easily
– Don’t know how to find a maximum clique fast
• Non-Primality:
– Given a natural number x, is it NOT a prime?
– Any a,b such that ab=x prove that x is no prime
• as long as a,b are not 1
• How can we find a,b?
– It is not known how to factor numbers efficiently
• Note: Checking primality/non-primality is even
known to be in P (but not easy to see this)
Original definition of NP
• Definition: A nondeterministic Turing machine is
defined like a Turing machine, but the transition
function can now map to several successors
– I.e., ±(q,a) is a subset of Q£¡£{left,stay,right}
• Interpretation: on input x there are many
computations of the machine
– At each step the computation can branch out
– The machine accepts if there is at least one accepting
– The machine `guesses’ a good computation
Nondeterministic TM
• The language LM accepted by a
nondeterministic TM is the set of inputs x for
which there is an accepting computation of M
on x
• A language Lµ¡ * is accepted by a
nondeterministic TM M if LM=L
• The time used by an NTM M on x is the
minimum number of steps M performs on x
during any accepting computation on x
– Time on inputs x not in L is not defined
• Time complexity of M: as before
• Nondeterministic time complexity of L upper
bounded by g(n): as before
• Definition: NP is the set of languages that are
accepted by some nondeterministic Turing
machine with polynomial time complexity
• Note: Both definitions [guess and check/NTM]
are equivalent
Notes on NP
• Nondeterministic Turing machines are not a realistic
model of computation
• They are interesting because NP contains many
interesting problems
• Furthermore they formalize proof systems
– NP is the set of languages L for which the statement x2L
can be verified efficiently
– I.e., there is a powerful prover P, while the verifier V is a
polynomial time Turing machine. The prover provides a
proof y
– x2 L iff there is a proof y such that x#y is accepted by V
P vs. NP
• Pµ NP by definition
• Are there problems in NP that are not in P?
• 106 dollar reward from the Clay Math Institute
• Most researchers believe P NP
• There is a large class of problems in NP that are
believed to be hard
– NP-complete problems
• P is a subset of NP by definition
• NP is a subset of EXP:
– Use guess and check definition
– Enumerate all witnesses y and check
– Time:
• There are exp(poly(n)) many witnesses. Checking each
is time poly(n)
NP Completeness
• We will identify a class of problems that
capture the hardness of NP
• P=NP if and only if one of these problems is in
– None are known to be in P
• These are the problems L in NP, such that
every problem in NP can be solved by a
deterministic polynomial time TM given a free
subroutine that solves L
NP Completeness
• Informally, L reduces to S, if, given an `oracle’
that decides S for free, we can compute L in
polynomial time (deterministically)
• NP-complete: L is in NP and all S in NP reduce
to L (in polynomial time)
– This means L is hardest in NP
Coping with hard problems
• Suppose we try to find an algorithm for a
• Maybe it is NP-complete?
– Reduce some known NP-complete problem to it
– Then we know it’s hopeless
• If so, we can try
– approximation
– heuristics
• Don’t have to waste our time searching for an
algorithm that (probably) does not exist

similar documents