Chapter 28
P, NP and Cook-Levin
“P and NP” defines the two classes, and “Nibble, sized” places the toy among them. This chapter states the theorem that ties NP to one formal language, SAT, and says what it means for the toy.
SAT, as hard as all of NP §
A reduction from a formal language A to a formal language B is a polynomial-time translation of A's inputs into B's that keeps every answer: x is in A exactly when its translation is in B. A machine for B then answers A too. A formal language is NP-complete when it is in NP and every language in NP reduces to it. In 1971 Stephen Cook, in "The Complexity of Theorem-Proving Procedures", and independently Leonid Levin, published in 1973, showed that SAT is as hard as anything in NP. Their proof takes the checking machine, which runs for a polynomial number of steps, and writes each step of its run as clauses: the whole run becomes one formula, satisfiable exactly when a certificate exists.
Guessing, and the computation history §
Michael Sipser's MIT lecture on the theorem (lecture 16) frames NP with a nondeterministic machine. At each choice it forks and follows every branch at once, and it accepts if any branch accepts. Such a machine forks for free and follows every branch, which is different from guessing at random. For the toy, the choices are the program's twelve bits. A nondeterministic machine guesses them two at a time, then runs the guessed program on the four inputs. A player clicking through a puzzle's buttons, knowing only the buttons, is that machine run one branch at a time, as “Which instructions are needed” counts.
Sipser calls the record of one branch's run, every state from the start to the verdict, its computation history. Cook and Levin write a formula that is satisfiable exactly when some branch has an accepting computation history. For the toy, a history is the tableau of “The Cook-Levin machine”: seven rows by four cores.
The toy as a checker §
The toy is such a checker. Given a problem and a program, it runs the program on four inputs and says whether the program decides the problem; the program is the certificate. The chapters that follow take that checker apart two ways, after “Six expressions, composed” sets the two side by side. “Arithmetization” through “The polynomials, in full” write its step as polynomials and compose all six, the riff's own route. “The Cook-Levin machine” through “The solver's work, in full” take Cook and Levin's route: the run as a tableau, the tableau as clauses, and a SAT solver to find the certificates.