Lecture 25
Lecture 25
Steven Skiena
http://www.cs.sunysb.edu/∼skiena
Prove that Hamiltonian Path is N P -complete.
k-1
selector
vertices
Stop
0 1 0
1
1
head
-3 -2 -1 0 1 2 3 4 5 TAPE
So, where are we?
Each instance of an optimization or decision problem can be
encoded as string on some alphabet. The set of all instances
which return True for some problem define a language.
Hence, any problem which solves this problem is equivalent
to a machine which recognizes whether an instance is in the
language!
The goal of all this is going to be a formal way to talk about
the set of problems which can be solved in polynomial time,
and the set that cannot be.
Non-deterministic Turing Machines
Suppose we buy a guessing module peripherial for our Turing
machine, which looks at a Turing machine program and
problem instance and in polynomial time writes something
it says is an answer. To convince ourselves it really is an
answer, we can run another program to check it.
Ex: The Traveling Salesman Problem
The guessing module can easily write a permutation of the
vertices in polynomial time. We can check if it is correct
by summing up the weights of the special edges in the
permutation and see that it is less than k.
guessing finite
state
module control
TAPE
Note that there are rp(n) + 2p2 (n) + 2p2 (n)v literals, a
polynomial number if p(n) is polynomial.
We will now have to add clauses to ensure that these variables
takes or the values as in the TM computation.
The group 6 clauses enforce the transition function of the
machine. If the read-write head is not on tape square j at
time i, it doesn’t change ....
There are O(p(2 (n)) literals and O(p2 (n)) clauses in all, so
the transformation is done in polynomial time!
Polynomial Time Reductions
A decision problem is N P -hard if the time complexity on
a deterministic machine is within a polynomial factor of the
complexity of any problem in N P .
A problem is N P -complete if it is N P -hard and in N P .
Cook’s theorem proved SATISFIABILITY was N P -hard by
using a polynomial time reduction translating each problem
in N P into an instance of SAT:
If satisfied, If not satisfied,
instance in instance not in
language language
Polynomial
NP problem SAT
instance: transform
to SAT Solver
NDTM &
Input Tape
All
Problem
Problem Problem
SAT X
in
X Solver
NP
No
Cook’s Theorem Polynomial Reduction Polynomial algorithm
from SAT to X means P=NP