Computation Theory · Complexity Classes

Ladner's Theorem: Building Languages Between P and NP

How to construct an NP language that is neither in P nor NP-complete assuming P differs from NP, using a slow diagonalization that delays each requirement until the padding is large enough.

If P differs from NP, the two classes are not adjacent. There are languages in NP that are not in P and not NP-complete, and the set of them is dense enough that between any two languages in NP that are not polynomial-time equivalent there is a third. The result is Ladner’s theorem, and its proof is unusual: it does not exhibit a natural problem with an intermediate status. It constructs a language by diagonalization, and the construction is deliberately engineered to run slowly, so that each requirement is satisfied only after the input is long enough for the requirement to be checkable within the remaining budget.

The theorem is conditional. It assumes P differs from NP, and it concludes the existence of intermediate languages. Since whether P differs from NP is open, no specific language is known to be intermediate. The natural candidates, integer factorization and graph isomorphism among them, are believed to be intermediate and are not proved to be.

The two requirements and their conflict

A language $L$ in NP that is intermediate must satisfy two conditions at once.

It must not be in P: for every deterministic machine $M_i$ running in polynomial time, $L$ differs from $L(M_i)$ on some input. This is a diagonal requirement, and satisfying it for machine $i$ means finding an input on which the two disagree.

It must not be NP-complete: for every polynomial-time reduction $f_j$ from SAT to $L$, there must be some input on which $f_j$ fails to be a reduction. Since $L$ is in NP, the failure has to be a satisfiability-preservation failure: an input $x$ where $x \in \mathrm{SAT}$ but $f_j(x) \notin L$, or the reverse.

The conflict is that the two requirements pull in opposite directions. Making $L$ harder to decide helps the first requirement and hurts the second, because a harder language is a better target for reductions from SAT. Making $L$ easier helps the second and hurts the first. A construction that satisfies one requirement globally tends to violate the other, so the proof interleaves them: it handles requirement $i$ on a finite initial segment of inputs, then requirement $j$ on a larger segment, and so on, with the segments growing so fast that earlier decisions are never revisited.

Padding as the control knob

The construction needs a language whose difficulty can be dialled up and down as a function of input length. Padding provides exactly that.

Take a hard language, say SAT, and define a padded version:

$$L = { x #^{m} : x \in \mathrm{SAT},\ m = |x|^{h(|x|)} }.$$

The padding makes the input longer without changing the underlying question. If $h$ is a constant, the padded language is polynomial-time equivalent to SAT, hence NP-complete. If $h$ grows fast enough, the padded inputs are so long that a polynomial-time machine cannot even read the padding, let alone decide the underlying question, and the language becomes easy: a machine with a fixed polynomial bound cannot process inputs of length $|x|^{h(|x|)}$ for large $|x|$ unless $h$ is bounded.

Between the two extremes, a slowly growing $h$ gives a language whose difficulty relative to the input length is intermediate. The diagonalization chooses $h$ step by step, so that at each stage the padding is just large enough to defeat the next machine or the next reduction, and not larger.

This is the mechanism in one sentence: the padding length is chosen by a simulation that watches the clock, and the clock is what the diagonal requirements are about. The construction is not choosing a function and then proving it works; it is building the function while proving it works.

The slow diagonal

The construction is best understood as a machine that builds a language by stages, where stage $s$ settles the membership of inputs up to length $n_s$, and the sequence $n_s$ grows fast enough that later stages never need to revisit earlier decisions.

At stage $s$, the machine has a target: either a deterministic polynomial-time machine $M_i$ that must be defeated, or a reduction $f_j$ that must be defeated. It searches for an input $x$ of length at most $n_s$ on which the target fails. The search is bounded, and the bound is chosen so that the search itself takes less than $n_s$ steps, which means the search can be completed within the time budget available at that input length. If the search finds such an $x$, the language is defined to disagree with the target there. If the search finds none, the stage is abandoned and the target is handled at a later, larger stage.

The crucial property is that the search is over inputs whose length is bounded by a function of the stage, and the function grows so fast that the search at stage $s$ is affordable at input lengths around $n_s$ but not at input lengths around $n_{s-1}$. This is why the construction is called slow diagonalization: the diagonal step is taken only after the input has grown enough to pay for it.

The control flow is what the code would express if the construction were run: the length of the input determines which requirement is active, and the requirement determines the answer. The padding is the part that can be written concretely, and it is where the difficulty is dialled:

def pad(x):
    # stage exponent 2: total length is len(x) + len(x)**2
    return x + '#' * (len(x) ** 2)

def unpad(y):
    core = y.rstrip('#')
    if core and len(y) - len(core) == len(core) ** 2:
        return core
    return None

The code above shows the shape of a padded encoding with the exponent fixed at 2. With the exponent at 1 the padded string is about twice as long as the core, and a machine with a linear time bound can still read all of it, so the padded language carries the hardness of the core. With the exponent growing across stages, the padded strings eventually outrun every fixed polynomial, and a machine with a polynomial bound cannot even reach the core. Raising the exponent is the diagonal step, and the proof’s work is in showing it can be raised while keeping the language in NP.

Why the construction stays in NP

A language defined by such a diagonal procedure is in NP only if membership can be verified by a polynomial-time checker with a certificate. The construction ensures this by making the language a subset of a padded SAT in a controlled way: for each length, the language either agrees with padded SAT or is empty, and the choice between the two is made by a computation that is itself polynomial in the length.

The certificate is then the certificate for the underlying SAT instance, together with enough information to identify which stage is active. Since the stage is determined by the input length and the stage table is finite at any given length, the extra information is polynomial. The verifier checks the SAT certificate and checks that the stage assignment is consistent, both in polynomial time.

This is where the construction is most fragile. If the stage assignment required simulating a machine for longer than polynomial time, the language would not be in NP, and the theorem would fail. The growth of the stage boundaries is therefore chosen to keep every stage’s decision procedure polynomial at the lengths it covers, which is possible precisely because the stages are spaced far apart.

What the theorem implies about the structure of NP

The immediate corollary is that NP is not the union of P and the NP-complete problems. If P differs from NP, there is at least one language in between, and in fact infinitely many.

The stronger corollary is a density statement. For any two languages $A$ and $B$ in NP that are not polynomial-time equivalent, there is a language $C$ in NP strictly between them under polynomial-time reducibility. The proof applies the same construction with $A$ and $B$ as the endpoints, using a padded version of $B$ and a diagonal against reductions from $A$. So the reducibility order on NP, restricted to the non-equivalent pairs, is dense.

AssumptionConsequence
P = NPNP has exactly one degree; no intermediate languages exist
P ≠ NPNP has infinitely many degrees, densely ordered
P ≠ NPno natural problem is known to be intermediate

The third row is the one that matters in practice. The theorem is an existence result about a contrived language, and it gives no guidance about whether a specific problem such as factorization is intermediate. That question is not known to be equivalent to P versus NP, and it is not known to be resolvable by the techniques that prove Ladner’s theorem.

The relativization of the result

Ladner’s theorem relativizes: for any oracle $O$, if $\mathrm{P}^O \ne \mathrm{NP}^O$ then there are languages in $\mathrm{NP}^O$ that are neither in $\mathrm{P}^O$ nor $\mathrm{NP}^O$-complete. The construction is uniform in the oracle, since the diagonal only needs to simulate machines with oracle access, and the padding argument is unchanged.

This is consistent with the relativization barrier, and it is worth noting that the theorem is not a counterexample to it. Ladner’s theorem is a conditional structural result: it says what NP must look like if the classes differ. It does not separate them, and it relativizes because the conditional statement is true in every relativized world where the hypothesis holds.

The relativized versions of these questions are also known to be delicate: whether NP has intermediate languages depends on the oracle, in the same way that whether P equals NP does. That dependence is one of the reasons the relativization barrier is taken seriously as a limit on proof techniques rather than as a fact about the world: a structural claim about the degrees of NP that is proved by black-box methods must hold in every relativized world, and the worlds do not agree.

Why the construction is not a recipe

The diagonal language is not computable by a practical algorithm, and it is not intended to be. Its definition quantifies over all polynomial-time machines and all polynomial-time reductions, which is a countable but not effectively enumerable list in the sense needed to run it. The construction is a proof device: it establishes that a language with the required properties exists, by showing that the requirements can be satisfied one at a time without interfering.

The interference is the technical heart. Each stage’s decision must be consistent with all earlier stages, and the growth condition on the stage boundaries is what guarantees consistency: an earlier stage decided membership only for inputs up to $n_{s-1}$, and the current stage only decides inputs above that bound, so no conflict arises. The proof that the growth condition can be met is where the padding function’s specific form enters, and it is also where the assumption that P differs from NP is used: if the classes coincided, the diagonal would have nothing to defeat.

The status of the natural candidates

Integer factorization and graph isomorphism are the two problems most often described as candidates for intermediate status. Both are in NP, neither is known to be in P, and neither is known to be NP-complete. The evidence for each is different.

For factorization, the evidence is that decades of algorithmic work have not produced a polynomial algorithm, and that the problem has a special structure: it is in NP and CoNP, since a factorization can be checked and a primality certificate can be checked, which would make it NP-complete only if NP equals CoNP. That conditional is stronger than P equals NP, so a proof of completeness would settle a question believed to be harder than the one it is usually compared to.

For graph isomorphism, the evidence is similar in shape but weaker in structure: the problem is in NP, not known to be in P, and not known to be complete, and the best algorithms have running times that are subexponential but superpolynomial. Whether it is in P is open, and the recent history of the problem shows that a polynomial algorithm is not excluded.

Neither problem’s status follows from Ladner’s theorem, and the theorem does not predict which candidates will turn out intermediate. It only guarantees that the category is nonempty under the standard assumption, which is enough to make the classification of a problem as NP-complete, in P, or neither an incomplete trichotomy rather than an exhaustive one.

References

  1. On the Structure of Polynomial Time Reducibility — Richard Ladner, Journal of the ACM, 1975
  2. Computational Complexity: A Modern Approach — Sanjeev Arora and Boaz Barak; Cambridge University Press, 2009
  3. Computers and Intractability: A Guide to the Theory of NP-Completeness — Michael Garey and David Johnson; W. H. Freeman, 1979