Cook p. 2:
ProvedPvsNP.P_subset_NPCook (p. 2): "It is trivial to show that , since for each language over , if then we can define the polynomial-time checking relation by for all ."
Every language in is in : if is decided within polynomial time by some machine, then there are and a polynomial-time checking relation with for all .
Formalization Note The checking machine receives Cook's as the tagged string encodePair (w, y) over the alphabet and must produce the answer of the given decider for on the left-tagged part within a polynomial number of steps in ; Mathlib has no lemma composing or pre-processing multi-stack machines, so even this "trivial" inclusion requires an explicit machine construction. Any may be used, for instance with the empty certificate.
import Definitions.Def_PvsNP import Mathlib
namespace PvsNP theorem P_subset_NP : P ⊆ NP := by sorry end PvsNP
Read-back
What the Lean code literally says, in plain math · claude-fable-5-1
Read-back: PvsNP.P_subset_NP
The statement. The declaration asserts the set inclusion
where and are two specific sets of languages over the alphabet defined in the accompanying bundle (unfolded below). A "language" here is any set of finite bit-strings (finite lists of Booleans; the empty string is allowed). Concretely the theorem says: for every set of bit-strings , if satisfies the membership condition of below, then satisfies the membership condition of below. There are no other hypotheses, no free variables, and no typeclass assumptions. (The declaration is stated with a sorry in place of a proof; the read-back describes only what is claimed.)
Throughout, denotes the set of finite bit-strings, the length of a string , and includes .
The machine model shared by both definitions
Both and are phrased in terms of Mathlib's bundled stack machine ("TM2") with the following data and conditions. For a function , an "input encoding" and an "output encoding" (lists over alphabets ), the assertion " is computable in polynomial time relative to " means that the following structure is nonempty (this is merely a proposition; no particular machine is fixed):
- A machine consisting of:
- a finite index type of stacks, with decidable equality;
- two distinguished stack indices (input stack) and (output stack) in — they are allowed to coincide;
- for each a type of stack symbols (arbitrary types; only is required to be finite by the structure itself, though the bijections below force and to be finite anyway);
- a finite type of program labels and a distinguished "main" label ;
- a finite type of internal states and a distinguished initial state ;
- a program , assigning to each label a statement built from the constructors push (onto stack a symbol computed from the internal state), peek (update the internal state from the top of stack , if any), pop (same, and remove the top), load (update the internal state), branch (on a Boolean of the internal state), goto (jump to a label computed from the internal state), and halt.
- Bijections and identifying the input and output stack alphabets with , respectively.
- A polynomial with natural-number coefficients (the "time bound").
- For every input , a witness that the machine, started in the configuration
reaches, after exactly some number of iterations of the one-step transition function (with , where is the length of the encoded input), the configuration
Here one iteration of the transition function on a configuration with label executes the statement to completion (a whole statement counts as one step regardless of how many push/pop/etc. operations it contains) yielding a new configuration, and on a halted configuration (label ) yields "no configuration". Iteration is performed in the option monad, so once "no configuration" is produced it persists; hence the requirement that the -th iterate equals forces the run not to have halted strictly earlier than step , and forces the halting configuration to have the internal state equal to the initial state and all stacks other than empty (if , the single stack must hold exactly the encoded output). The bound is , not .
The set
A language belongs to if and only if there exists a function such that
- is computable in polynomial time, in the sense above, relative to the input encoding (a bit-string is fed in as itself, so and the input length is ) and the output encoding (the one-symbol string consisting of ; so ); and
- for every bit-string (including the empty string): .
The set
A language belongs to if and only if there exist a function and a natural number (possibly ) such that
- is computable in polynomial time, in the sense above, relative to the input encoding
over the four-symbol alphabet (the first string's bits tagged "left", followed by the second string's bits tagged "right"; the encoded length is , so the time bound is ), and the output encoding as before; and 2. for every bit-string (including the empty string):
Here is natural-number exponentiation with ; in particular if the witness must have length for every , and if and is the empty string then must be the empty string.
What the theorem claims, fully unfolded
For every set of bit-strings : if there is a Boolean-valued function on bit-strings, computed (identity input encoding, one-bit output encoding) by some finite stack machine as above within a number of statement-executions bounded by a fixed polynomial in and halting in the exact halting configuration described, with , then there are a Boolean-valued function on pairs of bit-strings and a , with computed (tagged-concatenation input encoding over a four-symbol alphabet, one-bit output encoding) by some finite stack machine within a fixed polynomial in statement-executions and halting in the exact halting configuration described, such that .