Cook Proposition 1(b): if is -complete, and , then is -complete
ProvedPvsNP.npComplete_of_pReducibleCook, Proposition 1(b) (p. 4): "If is -complete, , and , then is -complete."
For all languages : if and every language in is p-reducible to , if , and if , then every language in is p-reducible to (and ), i.e. is -complete in the sense of Cook's Definition 4. Cook: "Part (b) uses the transitivity of " and "is the basic method for showing new problems are -complete" (p. 5); it is how Karp's 21 problems and the hundreds of later ones were shown -complete.
Formalization Note The content is the transitivity of PReducible: the composition of two polynomial-time computable functions is polynomial-time computable, which requires composing two multi-stack machines (Mathlib's proof_wanted TM2ComputableInPolyTime.comp). The hypotheses are explicit arguments in the order complete, , .
import Definitions.Def_PvsNP import Mathlib
namespace PvsNP
theorem npComplete_of_pReducible (L₁ L₂ : Language Bool) (h₁ : NPComplete L₁) (h₂ : L₂ ∈ NP)
(h : PReducible L₁ L₂) : NPComplete L₂ := by sorry
end PvsNPRead-back
What the Lean code literally says, in plain math · claude-fable-5-1
Read-back: PvsNP.npComplete_of_pReducible
The statement
For every pair of languages over the alphabet (a language here is an arbitrary set of finite lists of Booleans; the empty set and the set of all strings are allowed), the following implication holds:
where the three predicates are the custom notions unfolded below (they are not Mathlib's, and rest on a specific machine model, specific encodings, and a specific certificate-length bound). There are no further hypotheses: no decidability, non-emptiness or non-triviality assumption on or .
The notions used, fully unfolded
Throughout, a string is a finite list of Booleans, , and denotes the length of a list .
The machine model: bundled two-stack-style machines ("FinTM2")
A machine consists of:
- a type of stack indices, with decidable equality and finitely many elements; two designated indices (input stack) and (output stack) — is allowed;
- for each a type of stack symbols; only is required to be finite (the alphabet becomes finite below via a bijection with the output alphabet; the alphabets of any other stacks are arbitrary, possibly infinite, types);
- a finite type of function labels with a designated label ;
- a finite type of internal states with a designated ;
- a program , assigning to each label a statement built from: push a symbol (computed from the state) onto stack ; peek at the top of stack and update the state; pop stack and update the state; replace the state by a function of itself; branch on a Boolean function of the state; jump to a label computed from the state; or halt.
A configuration is a triple (current label or "halted", internal state, and the contents of every stack as a list). One step executes the statement of the current label in full (all of its push/peek/pop/load/branch instructions) until it reaches a goto, which sets the new label, or a halt, which sets the label to "halted"; a halted configuration has no successor. Thus a "step" here is one whole statement-block, not one primitive stack operation.
For lists and :
- the initial configuration on has label , state , stack equal to , and every other stack empty;
- the halting configuration with output has label "halted", state exactly (the machine must return to its initial internal state), stack equal to , and every other stack empty.
" outputs on within steps" means: there is a natural number such that iterating the step function exactly times from the initial configuration on yields precisely the halting configuration with output (as a defined, non-failed configuration). Since a halted configuration has no successor, is exactly the number of steps until halting. is allowed (in which case the initial and halting configurations must coincide).
Polynomial-time computability of a function, relative to encodings
Given types , alphabets , an input encoding , an output encoding , and a function , a polynomial-time TM2 computation of w.r.t. is the data of:
- a machine as above;
- a bijection between the input stack alphabet and , and a bijection between the output stack alphabet and ;
- a polynomial with natural-number coefficients (the zero polynomial and constants are allowed);
- for every input : outputs (the encoded output, transported symbol-wise into ) on input (the encoded input, transported symbol-wise into ) within steps, where is the length of the encoded input.
Below, " is polynomial-time computable w.r.t. " means that there exists such a datum (the definitions wrap the structure in a mere-existence proposition).
The encodings involved
- , the identity: a string is its own encoding, input alphabet .
- , , the one-element list; output alphabet .
- ,
i.e. the symbols of tagged "left" followed by the symbols of tagged "right", over the four-letter alphabet . Its length is .
The three derived notions
Polynomial-time computable string function. , for , means: is polynomial-time computable w.r.t. — the input stack alphabet and the output stack alphabet are each in bijection with , the input stack initially holds itself, and the machine halts within steps with exactly on the output stack, initial internal state restored, all other stacks empty.
Polynomial-time checker. , for , means: is polynomial-time computable w.r.t. — the input stack alphabet is in bijection with and initially holds , the output stack alphabet is in bijection with , and within steps the machine halts with the single symbol on the output stack (initial state restored, other stacks empty).
The class . A language belongs to iff there exist a function and a natural number such that holds and, for every string ,
Edge cases silently included: is allowed, in which case the bound is for every (including , since ); for and the empty string the only admissible certificate is the empty string. The certificate bound is a pure power , with no multiplicative constant or additive term. Note that is defined directly via checkers; the class from the same file plays no role in this theorem.
Polynomial-time reducibility. means: there exists with such that for every string ,
(A many-one reduction, as a biconditional for every input, with no requirement on the length of beyond what the step bound implies.)
NP-completeness. means: , and for every language over with , holds.
The theorem, restated with everything inlined
For all sets of finite Boolean strings: if
- (there are a checker , computable by some finite-label/finite-state stack machine over the alphabet within a polynomial in steps, and an exponent , such that membership of in is equivalent to the existence of a certificate with and ), and every language admits a polynomial-time computable (in the above sense) many-one reduction with for all ;
- (in the same sense, with its own checker and exponent );
- there is a polynomial-time computable with for all strings ;
then and every admits a polynomial-time computable many-one reduction with for all strings .
The conclusion's first conjunct is literally hypothesis 2 restated; the substantive content is the second conjunct. The statement quantifies over all with no side conditions; if no language satisfies under this machine model and these encodings, the theorem is vacuously true.