nov28

CS 461 – Nov. 28
Sections 7.3 – 7.4
• Classes of problems “NP” and “NP-complete”
• We don’t know if P = NP
• Proving that  an NP-complete problem.
– And then showing that we have other problems of similar
complexity.
Beyond P
• We classify decidable problems by their complexity. √
• Some problems apparently have no polynomial-time
algorithm. In other words, they appear not to be in P.
• Most of these are in “NP”. They can be verified by DTM
in polynomial time. (Also: decided by NTM)
– Nobody knows if “Hamiltonian Path” problem is in P.
– But, given a path in a graph, we can easily verifying if it’s
Hamiltonian.
• Worse, some problems are apparently even outside NP.
– “Does this graph not have a Hamiltonian path?” What given info
could we use to verify? Brute force 
NP
• Up to 3 types of problems in NP
– P (the easy ones)
– NP-complete (the hard ones)
– NP-intermediate (we don’t know if any exist!)
• But, if P = NP, then the above 3 types collapse into 1
• NP-complete:
– Many NP problems are intrinsically related to one another. We
can prove so by constructing a polynomial time reduction. Thus,
if one of them turns out to be in P, they all are.
• Examples of NP problems:
– Hamiltonian, Clique & subset sum (p. 268)
– Isomorphic
NP-complete
• Formal definition. Q is NP-complete if:
– The problem is in NP
– Every other problem in NP can be reduced to Q in polynomial
time.
• Step 1 is usually straightforward.
• For step 2, we have to select some existing problem
already known to be NP-complete and show that it
corresponds to Q.
• But, from first principles, we have to show that first of all
there exists one NP-complete problem.
– Analogous to a base case in an inductive proof.
The SAT problem
• Given a boolean formula, is there some assignment of
truth values to the variables that makes the formula true?
– e.g. (p  q’  r’  s)  (p’  s)  (q  r’  s’)
– In general, there could be a lot of different variables used in a
boolean formula, so we give our variables subscripted names x1,
x2, x3, … And if there are lots of possible variables, we can even
see multiple subscripts like x16,40,1.
• Cook-Levin theorem: SAT is NP-complete
– We need to show that it’s NP, and that any other NP problem
can be reduced (in polynomial time) to SAT.
– SAT is in NP because if we are given a truth assignment of the
variables, we can determine if the boolean formula is true.
– The polynomial reduction is very interesting! (pp. 277-281)
Any NP  SAT
• We’ll show that any NP language/problem can be
reduced to SAT, and this reduction can be performed in
polynomial time.
• If A is any NP problem, then there exists a NTM that
decides A.
– Furthermore, it runs in polynomial time, so the number of steps
in its execution can be bounded by nk.
• One possible execution of this NTM can be expressed in
the form of a (nk x nk) table.
– Rows correspond to individual steps of the NTM computation,
and literally represent the ID’s/configurations of the state & tape,
along with blanks to fill up nk columns.
– Columns are for individual tape & state symbols on tape. First
and last columns are # delimiters.
NTM execution table
• The table corresponds to one possible run of the NTM.
It may represent an accepting computation or not.
• Although the table has nk rows, we may accept the input
before running that many steps.
• Each cell in the table contains a symbol in an ID, which
could be:
– Delimiter # on the far left & right ends of the table.
– State
– Tape symbol
• The NTM accepts w if there exists a table showing an
accepting configuration.
Creating 
• We now convert the table into a corresponding boolean
formula.
• The possible variables of our formula are of the form xi,j,s
where
– i is a row number in the table
– j is a column number in the table
– s is a symbol that may appear in cell [ i, j ], such as a state, tape
symbol or #.
• What does this variable mean? xi,j,s is “true” if cell [ i, j ]
contains the symbol s.
•  is created in such a way that  is true when the
corresponding execution table shows that the NTM
accepts w.

•  =  cell   start   accept   move
• In order for the table to represent an “accept”, 4
conditions must be satisfied.
•  cell says that for all cells in the table, there can only be
one symbol in that cell.  For all i and j, there is exactly
one s for which xi,j,s is “true”.
•  start says that the first row of the table contains the
initial configuration of the NTM, including the # delimiters
and blanks.
•  accept says that at some point we must reach an
accept state. One cell must contain qaccept.  For some
i and j, xi,j,q accept is true.
 continued
•  move says that the rows of the table represent legal
moves of the NTM.
– We specify this by examining 2x3 windows of the table.
– Reminiscent of our PCP dominoes.
– Some windows center on activity around the state/cursor; some
are far away from the state and don’t change from one row to the
next.
– All windows must be “legal” according to  and proper move
behavior.
• This reduction from the NTM to  can be done in
polynomial time. We have a polynomial number of
variables and terms to create. At most we need O(n2k)
terms for .
Other problems
• We now have 1 problem, “SAT”, proved to be
NP-complete by definition.
• To show that some other problem is NP-complete, all we
need to do is create a polynomial-time correspondence
with SAT, or other problem already proved to be NPcomplete.
– Not necessary to start over with arbitrary NTM.
• Examples:
– 3SAT: the satisfiability question assuming the boolean formula
is of the form (_  _  _)  (_  _  _)  (_  _  _)  …
i.e. CNF in which each factor has exactly 3 terms.
– Clique, subset-sum, isomorphic, Hamiltonian path, etc.