Sub topic 16
Between P and NP-Complete: NP-Intermediate Problems
This chapter assumes you already know the definitions of P, NP, NP-hard, and NP-complete. It also assumes you know what a polynomial-time many-one reduction is and what co-NP means. We now ask whether every problem in NP falls into one of two groups: easy (in P) or hardest (NP-complete).
What "NP-intermediate" means
A problem is NP-intermediate when it meets all three of these conditions:
- It is in NP.
- It is not in P.
- It is not NP-complete.
The definition says "not in P," so we cannot prove that any specific problem is NP-intermediate without also proving P ≠ NP. Any NP-intermediate problem would sit outside P while still being in NP, and that alone would separate the two classes. So every statement about NP-intermediate problems is conditional. It either assumes P ≠ NP or it says a problem is a candidate.
What happens under each answer to P vs NP
Suppose P = NP. Then there are no NP-intermediate problems. Every problem in NP is in P. Under polynomial-time many-one reductions, every problem in P is NP-complete except the two trivial languages: the empty set and the set of all strings. Those two are excluded because no reduction can map yes-instances to "no yes-instances," or no-instances to "no no-instances."
Suppose P ≠ NP. Then Ladner's theorem applies.
Ladner's theorem
Ladner's theorem (1975): if P ≠ NP, then NP contains problems that are neither in P nor NP-complete.
How the proof works
The proof builds an artificial language from SAT by "blowing holes" in it. One standard version uses padding. Here is the idea:
- Define a slowly growing function H(n). A SAT formula φ of length n becomes a member of the new language L only when it is padded with about n^H(n) extra symbols.
- H is computed by diagonalization. At each stage the construction looks at a list of all polynomial-time machines. If H stays bounded, L is basically SAT with polynomial padding. Then L is NP-complete, and that would contradict P ≠ NP being used to make L hard. If H grows without bound, the padding gets huge, L gets so sparse in real SAT content that it cannot be NP-complete, and it is still not easy enough to be in P.
- H is set up to grow just fast enough to defeat every reduction from SAT, and slowly enough to defeat every polynomial-time algorithm for L.
The key property is that H(n) can be computed in polynomial time, so L stays in NP.
What the theorem does and does not give you
| Claim | True? |
|---|---|
| If P ≠ NP, some NP-intermediate language exists | Yes (Ladner) |
| The language is a natural problem people care about | No, it is built by diagonalization |
| Factoring is NP-intermediate | Unknown; it is a candidate |
| There is an infinite hierarchy of degrees between P and NP-complete | Yes, if P ≠ NP (the same technique repeated) |
The repeated construction shows that, if P ≠ NP, the region between P and NP-complete is not a single layer. It contains infinitely many problems that are not polynomially equivalent to each other.
Natural candidates
No natural problem is proven NP-intermediate. Some have strong evidence that they are not NP-complete, though nobody has found a polynomial algorithm for them either.
| Problem | Decision version | Evidence against NP-completeness | Best known algorithm |
|---|---|---|---|
| Integer factoring | Does n have a factor d with 1 < d ≤ k? | In NP ∩ co-NP; if NP-complete, then NP = co-NP | Sub-exponential (number field sieve); polynomial on a quantum computer (Shor) |
| Graph isomorphism | Are graphs G and H isomorphic? | If NP-complete, the polynomial hierarchy collapses to its second level | Quasi-polynomial, 2^O((log n)^c) (Babai, 2015–2017) |
| Discrete logarithm | Is there an x ≤ k with g^x ≡ h (mod p)? | In NP ∩ co-NP | Sub-exponential; polynomial on a quantum computer |
A problem in NP ∩ co-NP is unlikely to be NP-complete. If it were, every NP problem would reduce to it, every NP problem would then have short no-certificates, and NP = co-NP would follow. Most researchers believe NP ≠ co-NP.
Factoring has certificates both ways
The code below checks both kinds of certificate for the factoring decision problem "does n have a factor d with 1 < d ≤ k?" A yes-certificate is one factor in range. A no-certificate is the full prime factorization of n with every prime greater than k. If every prime factor is greater than k, then every divisor greater than 1 is also greater than k.
SMALL_PRIMES = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
def is_prime(n):
"""Miller-Rabin with fixed bases; deterministic for n < 3.3 * 10**24."""
if n < 2:
return False
for p in SMALL_PRIMES:
if n % p == 0:
return n == p
d, s = n - 1, 0
while d % 2 == 0:
d //= 2
s += 1
for a in SMALL_PRIMES:
x = pow(a, d, n)
if x in (1, n - 1):
continue
for _ in range(s - 1):
x = pow(x, 2, n)
if x == n - 1:
break
else:
return False
return True
def verify_yes(n, k, d):
"""Yes-certificate: a factor d with 1 < d <= k."""
return 1 < d <= k and n % d == 0
def verify_no(n, k, primes):
"""No-certificate: the prime factorization of n, every prime > k."""
product = 1
for p in primes:
if not is_prime(p) or p <= k:
return False
product *= p
return product == n
n = 101 * 103 # 10403
print(verify_yes(n, 101, 101)) # True: 101 is a factor <= 101
print(verify_no(n, 100, [101, 103])) # True: no factor in [2, 100]
print(verify_no(n, 101, [101, 103])) # False: 101 is not > 101Both verifiers run in time polynomial in the number of bits of n. This puts the problem in NP and in co-NP. The fixed-base Miller-Rabin test is enough for numbers of this size. In theory, the AKS test gives a deterministic polynomial-time primality check for any n.
Dichotomy theorems: where no middle ground exists
For some problem families, the middle region is provably empty.
- Schaefer's dichotomy theorem (1978): every Boolean constraint satisfaction problem (CSP) is either in P or NP-complete. Examples are 2-SAT, which is in P, and 3-SAT, which is NP-complete.
- The CSP dichotomy theorem (Bulatov and Zhuk, 2017): the same split holds for CSPs over any finite domain. Feder and Vardi had conjectured this in 1993. Graph 3-coloring (NP-complete) and 2-coloring (in P) are both CSPs of this kind.
So if you meet a problem you can phrase as a finite-domain CSP, it is not NP-intermediate. Ladner's theorem shows that intermediate problems exist in NP as a whole. Dichotomy theorems show that whole natural families avoid them.
Common errors
- Calling a problem NP-intermediate as a proven fact. Every such claim depends on P ≠ NP, plus a proof of non-completeness that nobody has for any natural problem.
- Assuming "not NP-complete" means "easy." Factoring is believed to be outside P, and much of today's cryptography depends on that belief.
- Assuming a quantum algorithm makes a problem NP-complete or puts it in P. Shor's algorithm puts factoring in BQP, which is a different class. It tells you nothing about classical P.
- Thinking a quasi-polynomial algorithm settles the question. Babai's graph isomorphism algorithm is faster than any exponential algorithm, but it is still not polynomial.
Exercise
Suppose someone proves that graph isomorphism is NP-complete. Given the result cited in this chapter, what would follow about the polynomial hierarchy, and why would most researchers find that surprising?
Show answer
The polynomial hierarchy would collapse to its second level (Boppana, Håstad, and Zachos). Most researchers believe the hierarchy is infinite, so a collapse would be a major surprise. This is why graph isomorphism is considered unlikely to be NP-complete.
Exercise
Explain why no natural problem has been proven NP-intermediate, even though Ladner's theorem exists.
Show answer
Proving that any problem is NP-intermediate includes proving it is in NP but not in P, which would prove P ≠ NP. Ladner's theorem avoids this by being conditional: it assumes P ≠ NP and then builds an artificial language. It says nothing about any specific natural problem.
Exercise
In verify_no, why is it enough to check that every prime in the factorization is greater than k, instead of checking every divisor of n?
Show answer
Every divisor d > 1 of n is a product of some of n's prime factors, so d is at least as large as its smallest prime factor. If every prime factor is greater than k, every divisor greater than 1 is also greater than k, so n has no factor in [2, k].
Exercise
A colleague proposes a new problem, "Can this graph be colored with 4 colors so that each listed pair of vertices gets different colors?", as an NP-intermediate candidate. What theorem rules this out?
Show answer
The problem is a constraint satisfaction problem over a finite domain (4 colors). The CSP dichotomy theorem of Bulatov and Zhuk says every such problem is either in P or NP-complete, so it cannot be NP-intermediate. This one is NP-complete, since it generalizes graph 4-coloring.