if and only if
OpenPvsNP.P_eq_NP_iff_sat_mem_PA consequence of the Cook–Levin theorem and Cook's Proposition 1(c) (p. 4–5): the classes and are equal if and only if Satisfiability has a polynomial-time decision procedure.
If then (this direction needs only ). Conversely, if then, being -complete, Proposition 1(c) gives . The statement reformulates the goal of the mission as a question about a single concrete language: if and only if no polynomial-time multi-stack machine decides the set of codes of satisfiable CNF formulas.
Formalization Note Both sides are propositions: an equality of two sets of languages and the membership of SAT in P. The backward direction depends on the Cook–Levin theorem; the forward one only on .
import Definitions.Def_PvsNP import Mathlib
namespace PvsNP theorem P_eq_NP_iff_sat_mem_P : P = NP ↔ SAT ∈ P := by sorry end PvsNP
Read-back
What the Lean code literally says, in plain math · claude-fable-5-1
Read-back: PvsNP.P_eq_NP_iff_sat_mem_P
The statement. The declaration asserts a biconditional between two propositions about sets of languages over the two-letter alphabet (Booleans):
where the left-hand side is equality of two sets of languages (every language in lies in and every language in lies in ), and the right-hand side says that one specific language is an element of the set . Both directions of the "iff" are asserted. There are no free variables, hypotheses, or typeclass assumptions; everything below is the unfolding of the three constants , , as they are defined in the preamble, down to Mathlib's stack-machine model. All of this fine print is part of what the theorem literally says.
Strings and languages. A string is a finite list of Booleans; denotes its length (the empty string is allowed). A language is an arbitrary set of such strings (no computability or other restriction), and is ordinary set membership.
The machine model (Mathlib's bundled "TM2" stack machine). A bundled machine consists of:
-
a finite type of stack names (with decidable equality), together with two designated names , the input stack and the output stack (they are allowed to coincide);
-
for each stack name a type of stack symbols; only is required to be finite, the other may be arbitrary (possibly infinite) types;
-
a finite type of program labels with a designated label ;
-
a finite type of internal states with a designated ;
-
a program: to each label a statement , where statements are finite trees built from
- (push onto stack , where is the current internal state, then continue with ),
- (replace the state by , where the top is "none" if the stack is empty, then continue with ),
- (same as peek, but additionally remove the top element of stack ; popping an empty stack leaves it empty),
- (replace by , then continue with ),
- (continue with if , else with ),
- (end the step, making the next label),
- (end the step, entering the halting state).
The functions appearing in statements are arbitrary functions (there is no constraint on them beyond their types).
A configuration is a triple (current label or "halted", internal state , the contents of every stack as a finite list with the head being the top). One step of from a non-halted configuration with label executes the entire statement down to its terminal or ; a halted configuration has no successor. Thus a single step may perform arbitrarily many (but finitely many, bounded by the size of the statement) pushes, pops, peeks and loads.
For an input list of symbols of , the initial configuration has label , state , stack holding and every other stack empty. For an output list of symbols of , the halting configuration has label "halted", internal state equal to , stack holding , and every other stack empty.
" outputs on input within steps" means: there is a natural number such that iterating the step function exactly times from yields exactly the configuration (in particular with state reset to and all non-output stacks empty).
Polynomial-time computability of a function. Let and be fixed encodings and . " is TM2-computable in polynomial time with respect to " means there exist:
- a bundled machine as above,
- bijections and ,
- a polynomial with natural-number coefficients (so may be any such polynomial, including a constant),
such that for every , on input (applied symbol-wise) outputs within steps, in the sense just described. Nothing is said about the machine's behaviour on inputs that are not of the form .
The encoding of a Boolean used for outputs throughout is the one-symbol string .
The class . A language belongs to iff there is a function such that
- is TM2-computable in polynomial time with input encoding the identity (a string is placed on the input stack as itself, via a bijection ) and output encoding (the output stack must end holding exactly the one-symbol list , up to the bijection ), within steps for some fixed polynomial ; and
- for every string : .
The class . A language belongs to iff there exist a function and a natural number (with allowed) such that
- is TM2-computable in polynomial time with input encoding
over the four-letter alphabet (the first component's bits tagged "left", the second component's bits tagged "right", concatenated), output encoding , and time bound for some fixed polynomial ; and 2. for every string :
Edge cases included by the quantifiers: if then for every (including ), so certificates have length at most ; if and is the empty string then , so the only candidate certificate is the empty string.
The language . Fix the following syntax:
- a literal is a pair with a Boolean and a variable index; under an assignment it evaluates to if and to if ;
- a clause is a finite list of literals; it evaluates to iff some literal in it evaluates to (the empty clause evaluates to );
- a CNF formula is a finite list of clauses; it evaluates to iff every clause in it evaluates to (the empty formula evaluates to );
- is satisfiable iff there exists an assignment (defined on all indices) under which evaluates to .
The string coding is:
- is the binary expansion of as a list of Booleans, least significant bit first, with no leading zeros: , , and for (e.g. );
- a literal is coded by taking the list , replacing each entry by the two symbols , and appending the two-symbol terminator :
- a clause is coded by followed by the terminator (so the empty clause is coded by );
- a formula is coded by the concatenation with no further terminator (so the empty formula is coded by the empty string).
Then
In particular the empty string is in (it codes the empty formula, which is satisfiable); a string that is not the code of any formula is not in ; and membership requires only that some formula coding to be satisfiable.
Summary of the assertion. With , and exactly as unfolded above (polynomial time measured in whole-statement steps of a bundled multi-stack machine with a natural-coefficient polynomial bound, halting required to land precisely on the "halting configuration" with the internal state reset and all non-output stacks empty; certificates bounded by ; formulas coded by the specific bit-pair scheme above), the theorem states: