Cook p. 5: Satisfiability is in
OpenPvsNP.sat_mem_NPCook (p. 5): "Thus the problem Satisfiability is: Given a propositional formula , determine whether is satisfiable. To show that this is in , we define the polynomial-time checking relation , which holds iff codes a propositional formula and codes a truth assignment to the variables of that makes true."
: there are and a polynomial-time checking relation such that, for every binary string , is the code of a satisfiable CNF formula if and only if there is a string with and . Here is the set of strings of the form encodeCNF F for a CNF formula that is true under some truth assignment.
Formalization Note The certificate coding is the prover's choice: for instance the truth values of the variables occurring in , of which there are at most , so works. The checker must be an explicit multi-stack machine that parses the two-bit block coding of the formula, rejects malformed strings, and evaluates the formula under the certificate within a polynomial number of steps; no such machine-building infrastructure exists in Mathlib.
import Definitions.Def_PvsNP import Mathlib
namespace PvsNP theorem sat_mem_NP : SAT ∈ NP := by sorry end PvsNP
Read-back
What the Lean code literally says, in plain math · claude-fable-5-1
Read-back: PvsNP.sat_mem_NP
Statement. The theorem has no hypotheses and no free variables. It asserts a single membership fact:
where both sides are the bundle's own definitions, unfolded below. Throughout, a string means a finite list of Booleans (elements of , written and below), is the length of a string , and a language is a set of strings.
What is
is the set of strings for which there exists a "CNF" with and satisfiable, where:
- A literal is a pair with a Boolean and (any natural number, including ). A clause is a finite list of literals (possibly empty, possibly with repetitions, in a fixed order). A CNF is a finite list of clauses (possibly empty, possibly with repetitions).
- An assignment is an arbitrary function (no finiteness or finite-support condition).
- The literal evaluates under to if and to if .
- A clause evaluates to iff some literal in it evaluates to ; in particular the empty clause evaluates to .
- A CNF evaluates to iff every clause in it evaluates to ; in particular the empty CNF evaluates to .
- is satisfiable iff there exists an assignment under which evaluates to . So the empty CNF is satisfiable, and any CNF containing an empty clause is not.
The string coding . Write for the list of binary digits of with the least significant digit first and no leading zeros: is the empty list, , , , and for the last entry is always . Then:
- A literal is encoded by taking the list (polarity bit first, then the digits of ), replacing each entry by the two-symbol block , and appending the block :
For example and .
- A clause is encoded as the concatenation followed by the block . The empty clause is encoded as .
- A CNF is encoded as the concatenation with no terminator. The empty CNF is encoded as the empty string.
Consequently a string is in only if it is literally of the form for some CNF (in particular, it has even length and decomposes into the two-symbol blocks above); the empty string is in (via the empty CNF); and is not in (its only decoding is the CNF consisting of one empty clause).
What is
A language belongs to iff there exist a function from pairs of strings to Booleans and a natural number (possibly ) such that
- is a polynomial-time checker in the sense unfolded below, and
- for every string :
Edge cases of item 2: if then for every (including empty, since ), so certificates have length at most ; if and is the empty string, the only admissible certificate is the empty string. is a total function and must be computed by the machine on all pairs , not only those with .
Polynomial-time checker. " is a polynomial-time checker" means: there exists (as a mere existence statement) a package consisting of
- a finite stack machine of the following kind (Mathlib's bundled "TM2"): a finite index set of stacks with decidable equality; two distinguished indices (input stack) and (output stack), which are allowed to coincide; for each a type of stack symbols, where only is required to be finite (the other are arbitrary types); a finite set of labels with a distinguished label ; a finite set of internal states with a distinguished initial state ; and a program assigning to each label a statement. A statement is a finite tree built from: push onto stack a symbol computed from the current internal state; peek at the top of stack (if any) and update the internal state by an arbitrary function of the state and that optional symbol; pop the top of stack with the same kind of state update; replace the internal state by an arbitrary function of itself; branch on a Boolean function of the state; jump to a label computed from the state; or halt.
- a bijection between and the four-element set , and a bijection between and ;
- a polynomial with natural-number coefficients;
such that for every pair of strings the following holds. Let the input word be
a word over the four-letter alphabet (letters of tagged "left", letters of tagged "right"), of length ; transport it letter-by-letter through the inverse input bijection to obtain a list over . The initial configuration has current label , internal state , stack equal to this list (first letter of the input on top), and every other stack empty. The final configuration has no current label (halted), internal state equal to , stack equal to the one-element list containing the preimage of under the output bijection, and every other stack empty. One step of the machine executes the entire statement attached to the current label (all of its pushes/pops/peeks/loads/branches, up to the jump or halt) and either moves to the new label or halts; a halted configuration has no successor. The requirement is that there is a number of steps with
such that iterating the step function exactly times from the initial configuration yields exactly the final configuration described (so the machine halts at step , not earlier and not later, in that exact configuration).
The assertion, assembled
The theorem asserts that there exist a Boolean-valued function on pairs of strings, a natural number , and a stack machine with input/output bijections and a natural-coefficient polynomial as above, such that started on halts in at most steps in the exact configuration encoding (for all ), and such that for every string ,
Nothing is asserted about , about NP-completeness, about -SAT, or about how , , or are chosen; only their existence.