Unit v - P NP NP Hard Problem
Unit v - P NP NP Hard Problem
x
y
x
y
z
z
Satisfiability via path finding
• If there is a path from
• And if there is a path from
• Then FAIL!
• How to find paths in graphs?
– DFS/BFS and modifications thereof
3 CNF SAT (3 SAT)
• Not so easy anymore.
• Implication graph cannot be constructed
• No known polytime algorithm
• Is it NP?
– If someone gives you a solution how long does it
take to verify it?
– Make one pass through the formula and check
• This is an NP problem
Hamiltonian cycles
• Determining whether a directed graph has a
Hamiltonian cycle does not have a polynomial
time algorithm (yet!)
• However if someone was to give you a
sequence of vertices, determining whether or
not that sequence forms a Hamiltonian cycle
can be done in polynomial time
• Therefore Hamiltonian cycles are in NP
P is a subset of NP
• Since it takes polynomial time to run the
program, just run the program and get a
solution
• But is NP a subset of P?
• No one knows if P = NP or not
• Solve for a million dollars!
– http://www.claymath.org/millennium-problems
– The Poincare conjecture is solved today
What is not in NP?
• Undecidable problems
– Given a polynomial with integer coefficients, does it have
integer roots
– Hilbert’s nth problem
– Impossible to check for all the integers
– Even a non-deterministic TM has to have a finite number of
states!
– More on decidability later
• Tautology
– A boolean formula that is true for all possible assignments
– Here just one ‘verifier’ will not work. You have to try all possible
values
Amusing analogy
(thanks to lecture notes at University of Utah)
• Students believe that every problem assigned
to them is NP-complete in difficulty level, as
they have to find the solutions.
• Teaching Assistants, on the other hand, find
that their job is only as hard as NP, as they
only have to verify the student’s answers.
• When some students confound the TAs, even
verification becomes hard
Reducibility
• a problem Q can be reduced to another
problem Q’ if any instance of Q can be “easily
rephrased” as an instance of Q’, the solution
to which provides a solution to the instance of
Q
• Is a linear equation reducible to a quadratic
equation?
– Sure! Let coefficient of the square term be 0
NP - hard
• What are the hardest problems in NP?
If we know a single problem in NP-Complete that helps when we are asked to prove some
other problem is NP-Complete
┐x3 x3 x3
Vertex cover problem
• A vertex cover of an undirected graph G=(V,E) is a
subset of vertices such that every edge is incident
to at least one of the vertices
• We’re typically interested in finding the minimum
sized vertex cover
• To show vertex cover is NP-complete
• What problem should we try to reduce to it
• It sounds like the ‘reverse’ of CLIQUE
• Reduction is done from CLIQUE to vertex cover
G’ =
G Complement
Of
G