Sub topic 15
co-NP: Efficiently Checkable No Answers
This chapter assumes you already know the definition of NP from the verifier chapter, what a certificate is, and the SAT problem from the Cook-Levin chapter.
The Asymmetry in NP
NP only requires short, checkable evidence for yes answers. For SAT, a satisfying assignment proves that a formula is satisfiable, and verify_cnf checks it in linear time. Proving that a formula is unsatisfiable is a different matter. No single assignment can show that every one of the 2^n assignments fails. Nobody knows a short certificate that does.
That asymmetry is what defines co-NP.
Definition
The complement of a decision problem swaps its yes and no answers. The complement of SAT is UNSAT: "Is this formula unsatisfiable?"
A problem is in co-NP if its complement is in NP. Put another way, co-NP problems have short certificates for their no answers, and those certificates can be checked in polynomial time.
| Problem | Question | Short certificate for | Class |
|---|---|---|---|
| SAT | Is the formula satisfiable? | yes (an assignment) | NP |
| UNSAT | Is the formula unsatisfiable? | no (an assignment) | co-NP |
| TAUTOLOGY | Is the formula true under every assignment? | no (a falsifying assignment) | co-NP |
| PRIMES | Is n prime? | no (a divisor) | co-NP (and in fact P) |
Checking a No Answer
For PRIMES, a no answer ("n is composite") has an easy certificate: a nontrivial divisor.
def verify_not_prime(n, certificate):
"""certificate: a claimed divisor d with 1 < d < n."""
return 1 < certificate < n and n % certificate == 0
print(verify_not_prime(91, 7)) # True: 91 = 7 * 13, so 91 is not prime
print(verify_not_prime(97, 5)) # False: this certificate proves nothingThe check is one modulo operation, which is polynomial in the bit length of n. So PRIMES is in co-NP. Pratt showed in 1975 that primes also have short certificates, which put PRIMES in NP ∩ co-NP. The AKS algorithm of 2002 then placed it in P.
How the Classes Relate
Any P algorithm can answer the complement problem by flipping its output. So P is closed under complement, and P ⊆ NP ∩ co-NP.
The key facts:
- UNSAT and TAUTOLOGY are co-NP-complete, because complementing a reduction from SAT carries over.
- If any NP-complete problem were in co-NP, then NP = co-NP.
- Most researchers believe NP ≠ co-NP. That would imply P ≠ NP, because P = NP would force NP = co-NP.
- Problems in NP ∩ co-NP, such as the decision version of integer factoring, are considered unlikely to be NP-complete.
Common Errors
- Treating co-NP as harder than NP. The two are mirror images, and neither is known to contain the other.
- Assuming that a brute-force search proving "no" is a certificate. A certificate must have polynomial size and be checkable in polynomial time.
Exercise
The problem NO-HAM-CYCLE asks "Does graph G have no Hamiltonian cycle?" Which class is it obviously in, and what is the certificate for a no answer?
Show answer
It is in co-NP, because its complement, Hamiltonian Cycle, is in NP. A no answer means G does have a Hamiltonian cycle, and the certificate is that cycle: an ordering of the vertices that you check in polynomial time by confirming each consecutive pair, including last to first, is an edge.
Exercise
Why does P = NP imply NP = co-NP?
Show answer
P is closed under complement. If P = NP, then every NP problem's complement is in P, which is contained in NP. So co-NP ⊆ NP, and by symmetry NP ⊆ co-NP.