Ladner's theorem (1975): if , there are -intermediate languages
OpenPvsNP.ladnerCook (p. 6): "There are interesting examples of problems not known to be either in or -complete. One example is the graph isomorphism problem." Ladner (1975) proved that, if , such intermediate languages must exist.
Theorem (Ladner). Assume . Then there is a language with , , and not -complete; that is, since , some language in is not p-reducible to .
Formalization Note The hypothesis is an explicit argument; if the theorem holds vacuously. NPComplete L is Cook's Definition 4, so "not -complete" for means the failure of -hardness. Ladner's proof (delayed diagonalization against enumerations of polynomial-time machines and of polynomial-time reductions) requires a coding of machines by strings and a universal machine with a step counter, as for the time hierarchy theorem.
import Definitions.Def_PvsNP import Mathlib
namespace PvsNP
theorem ladner (h : P ≠ NP) :
∃ L : Language Bool, L ∈ NP ∧ L ∉ P ∧ ¬ NPComplete L := by sorry
end PvsNPRead-back
What the Lean code literally says, in plain math · claude-fable-5-1
Read-back: PvsNP.ladner
The statement
Let denote the set of all finite strings over the two-letter alphabet (finite lists of Booleans; the empty string is included). A language is any subset (any set whatsoever, with no computability or decidability requirement). Below, , and " is -complete" are the specific notions defined in the accompanying definition file, unfolded in full in the next sections; they are not Mathlib's or the textbook's notions.
The declaration asserts:
Hypothesis. , i.e. the two sets of languages and (both subsets of the power set of ) are not equal as sets. Nothing else is assumed: no inclusion is hypothesised, and there are no other explicit, implicit, or typeclass hypotheses.
Conclusion. There exists a language such that all three of the following hold:
- ;
- ;
- is not -complete, i.e. it is not the case that ( and every is polynomial-time many-one reducible to ). Since item 1 already gives , item 3 amounts to: there is some language that is not polynomial-time many-one reducible to (in the specific sense of "reducible" unfolded below).
The existential is a plain "there exists" (not "there exists a unique"). The statement is a bare implication from the hypothesis to the conclusion; it says nothing about the case .
The machine model underlying every complexity notion
All of , and reducibility are phrased via one Mathlib notion, " is computable in polynomial time by a finite stack machine with respect to input encoding and output encoding ", written here . It unfolds as follows.
Finite stack machine (Mathlib FinTM2). A machine consists of:
- a finite type of stack names (with decidable equality) and two distinguished names (input stack) and (output stack); is allowed;
- for every stack name , a type of stack symbols; only is required to be finite (the alphabets of the other stacks are arbitrary types, not required to be finite);
- a finite type of program labels, with a distinguished label ;
- a finite type of internal states with a distinguished initial state ;
- a program: for each label , a statement .
A statement is a finite tree built from: (push the symbol , computed from the current internal state , onto stack , then continue with ); (replace the internal state by , where the top is "none" if the stack is empty, then continue with ); (same as peek but also remove the top of stack , if any); (replace the internal state by , then continue with ); (continue with or according to the Boolean ); (end this statement and jump to label ); (end this statement and enter the halted status). The functions here are arbitrary set-theoretic functions of the finite state (no computability restriction is imposed on them).
A configuration is a triple : a current label or the special value "halted"; an internal state ; and, for every stack name , a finite list of symbols from (the stack contents; the head of the list is the top of the stack). The one-step function is: on a halted configuration it is undefined (returns "none"); on it executes the entire statement (all of its pushes, pops, peeks, loads and branches) until it reaches a or , yielding the configuration resp. . Thus one "step" is the execution of one whole labelled statement, however many stack operations it contains.
Initial and final configurations. For a list of symbols of , the initial configuration is with and every other stack empty. For a list of symbols of , the final configuration is with and every other stack empty. Note that the final configuration requires the internal state to be back at the initial state and requires all stacks other than to be empty.
Outputs within a time bound. " on input outputs within steps" means: there is a natural number such that iterating exactly times from (propagating "undefined" once it appears) yields precisely the configuration . Since the step function is undefined on halted configurations, this forces the run to first become halted exactly at step , in exactly the configuration . (Because is not halted, necessarily .)
Polynomial-time computability of a function. Given types , an input encoding , an output encoding , and a function , the proposition says: there exists (mere existence, as a proposition) a finite stack machine together with
- a bijection between the input-stack alphabet and ,
- a bijection between the output-stack alphabet and ,
- a polynomial with natural-number coefficients,
such that for every : on input (the encoding of , transported symbol-by-symbol onto the input alphabet) outputs within steps, where is list length. For the empty encoding () the bound is the constant term .
The three encodings used below are:
- on : a string encodes itself, over the alphabet ;
- on Booleans: , the one-symbol string, over ;
- on pairs of strings : the list over the four-symbol alphabet (the two copies tag which component each symbol came from); its length is .
The class
iff there exists a function such that
- holds — i.e. some finite stack machine with two-symbol input and output alphabets, on every input string (placed on the input stack as is), halts in the final configuration whose output stack holds exactly the single symbol (and with internal state and all other stacks empty) within steps for a fixed polynomial with natural coefficients; and
- for every string : .
The class
iff there exist a function and a natural number (with allowed) such that
- holds — i.e. some finite stack machine whose input-stack alphabet is in bijection with the four-symbol alphabet and whose output-stack alphabet is in bijection with , on every input , halts in the final configuration with output stack exactly within steps for a fixed polynomial with natural coefficients; and
- for every string :
Edge cases of the certificate bound : for the bound is for every (including , since ); for and the empty string the bound is , so only the empty certificate is permitted. The time bound for is polynomial in , not directly in .
Polynomial-time reducibility and -completeness
is polynomial-time (many-one) reducible to , written , iff there exists such that
- holds — i.e. some finite stack machine with two-symbol input and output alphabets, on every input string , halts in the final configuration whose output stack holds exactly the string (internal state , all other stacks empty) within steps for a fixed polynomial with natural coefficients; and
- for every string : .
is -complete iff and for every language with , .
Summary of what is asserted, in these terms
If the set of languages (those decided by a polynomially step-bounded finite stack machine as above) differs from the set of languages (those with a polynomially step-bounded checker and certificates of length at most as above), then some language lies in , does not lie in , and fails to be -complete — so, given , some admits no function that is computable by a polynomially step-bounded finite stack machine (in the exact sense above) and satisfies for all .