NP and coNP
Polynomial certificates, their equivalence to nondeterministic computation, and the asymmetric evidence captured by NP and coNP.
Goals
- Move fluently between the nondeterministic-machine and verifier definitions of NP.
- Explain exactly why the certificate and verifier must have polynomial bounds.
- Read coNP as short evidence for universal/no claims, without treating it as “everything outside NP.”
- Prove the standard containments and recognize which separations remain open.
1. NP: search hidden inside verification
An NP question often has the form “does there exist a small object with an efficiently checkable property?” For SAT the object is an assignment; for CLIQUE it is a vertex set; for Hamiltonian Cycle it is an ordering of the vertices. A deterministic exhaustive search may inspect exponentially many candidates, but one proposed candidate can be checked quickly.
This does not say that NP means “not polynomial,” and it does not prove that any NP-complete problem is outside P. It says that yes-instances possess polynomially bounded evidence checkable in deterministic polynomial time.
The nondeterministic definition
A nondeterministic Turing machine accepts if at least one computation branch accepts. It decides a language in time if every branch halts within steps and
Thus
The quantifiers matter. On a no-instance, every branch must reject; swapping accept and reject would turn “some accepts” into “some rejects,” not into the required universal condition.
The verifier definition
A deterministic polynomial-time verifier is a machine that receives the instance and a certificate . A language is in NP iff there are polynomials and such a verifier satisfying
where halts in at most steps on every pair. Some formulations require ; padding a shorter certificate with a marked block makes the versions equivalent.
The certificate bound is essential. If could be exponentially long, merely reading it could take exponential time in . The verifier’s runtime is polynomial in its actual input ; because , composition gives a polynomial in .
NP and coNP
2. Why verifiers and NTMs are equivalent
Theorem (NP characterization). A language has a polynomial-time nondeterministic decider iff it has polynomial-size certificates checked by a deterministic polynomial-time verifier.
This is an equivalence, so it needs two constructions.
NTM verifier
Assume decides and every branch uses at most steps. Encode one accepting branch by listing the nondeterministic choice made at each step. For a fixed machine, each transition choice needs only a constant number of bits, so the transcript has length at most for a machine-dependent constant .
The verifier deterministically simulates , forcing at each branching point the choice encoded by . It rejects if a choice is illegal, the transcript ends incorrectly, or the simulated branch does not accept. It accepts exactly legal accepting transcripts.
- If , an accepting branch exists, and its transcript is an accepting certificate.
- If , no accepting branch exists, so no transcript can make accept.
- Simulation takes polynomial time because the branch and transcript are polynomially long.
One may instead use a sequence of configurations as the certificate. That encoding is larger but still polynomial, and adjacent configurations are locally checkable.
Verifier NTM
Assume satisfy the verifier definition. On input , the NTM computes , nondeterministically chooses that many certificate bits, and runs . It accepts iff accepts.
- If , some valid exists, hence one branch chooses it and accepts.
- If , every possible is rejected, hence all branches reject.
- Guessing costs steps; verification costs
which is polynomial because a composition and sum of polynomials remain polynomial.
This proof also clarifies “guess and check”: guessing is not random sampling. The NTM semantics existentially ranges over all certificates.
3. Worked certificate examples
SAT
For a CNF formula over variables, gives an assignment. Scan every literal and clause and accept iff every clause has a true literal. A straightforward implementation is polynomial in .
For
certifies membership: the first clause is true through , the second through . A certificate that fails proves nothing; NP asks whether some certificate works.
CLIQUE
An instance is , not just . A certificate can list distinct vertices. Verify the range, distinctness, and each of the required edges. If is binary and larger than , reject before trying to allocate objects. This small guard prevents a numeric parameter from hiding exponential work.
COMPOSITE
For a binary integer , factors with and form a certificate. Their binary lengths are and grade-school multiplication is polynomial in bit length. This is a certificate for COMPOSITE, not automatically a certificate for PRIMES.
4. Complements and coNP evidence
For , define
coNP is a class of languages; it is not the set-theoretic complement of the collection NP. A language can belong to both.
Applying the verifier characterization to yields a useful quantifier view:
after complementing the verifier’s output. Equivalently, if , there is a short witness exposing failure. This is why coNP is often described as efficiently checkable evidence for no-instances.
TAUT versus SAT
TAUT contains formulas true under every assignment. Its complement consists of formulas with a falsifying assignment. That assignment is a short NP certificate, so
UNSAT is likewise in coNP because its complement SAT is in NP. Notice the evidence asymmetry: one satisfying assignment establishes SAT; a failed search over a few assignments does not establish UNSAT.
A subtle but useful example
PRIMES is in P, and therefore in both NP and coNP. Historically, certificates for primality and compositeness illustrated that membership in does not by itself imply a known deterministic algorithm; today primality is known to be in P. Always specify the integer encoding and how malformed strings are handled.
5. Containments and consequences
Proposition. .
Proof walkthrough. A deterministic polynomial-time machine is an NTM with one branch, so . If , take its total polynomial-time decider and swap accepting and rejecting states; this decides in the same time. Hence and .
The same accept/reject swap does not prove NP closed under complement because nondeterministic acceptance is existential.
Proposition. If , then .
Proof. P is closed under complement. If NP equals P, NP inherits that closure. Thus implies , which is equivalent to . Applying complement again gives the reverse containment.
Neither nor is currently known. A Venn diagram must therefore mark uncertain boundaries.
A particularly important consequence is:
If an NP-complete language is in coNP, then .
For every , . coNP is closed downward under polynomial many-one reductions, so . Thus , and complementation gives equality. The closure proof is developed in the reductions lesson.
6. Encodings are part of the language
A language is a set of strings, so “the input is a graph” is shorthand for a chosen encoding. A robust decider first checks syntax. For malformed strings, choose and document a convention—normally reject. A reduction must also map malformed source encodings consistently, often to one fixed no-instance.
Numeric values are not unit-cost merely because they are written as one mathematical symbol. A binary integer occupies bits. An algorithm that performs iterations may therefore be exponential in input length unless a semantic guard such as has already been established.
7. Three quantifier patterns worth separating
It helps to write the logical shape before searching for a certificate:
The predicate inside each bracket is polynomial-time computable. The first line directly has the NP verifier form. The second and third have the coNP form because a counterexample to membership is existentially witnessed. This syntactic comparison explains the evidence asymmetry without asserting a separation: perhaps a clever, non-obvious polynomial certificate for UNSAT exists, but proving that every coNP language has NP certificates is exactly the unresolved equality .
Graph problems show the same distinction. A proposed -clique is immediately checkable, whereas “this graph has no -clique” appears to quantify over all -subsets. The latter language is in coNP because one clique refutes it. That observation alone neither proves nor disproves that it is also in NP.
A more explicit branch encoding
Suppose each configuration of has at most legal successors, where depends only on the fixed transition table. Number the choices and let
For a -step computation, use exactly certificate bits, partitioned into blocks. At step , interpret block as a successor index. Reject if it denotes no legal successor. If halts early, require the remaining blocks to encode a designated padding move. This convention makes the verifier total and removes ambiguity about short transcripts. Its deterministic simulation stores the current configuration, looks up one transition, and updates it for at most rounds.
Conversely, an NTM simulating a verifier need not materialize all certificates. It branches once per guessed bit, creating a depth- computation tree. Complexity measures the longest branch, not the total number of nodes in that tree. Each branch spends steps guessing and then one polynomial verifier run. This is the precise reason exponentially many possible witnesses are compatible with nondeterministic polynomial time.
8. Consequences around complete languages
The statement “an NP-complete language is in coNP” has more force than merely placing one language in an intersection. For each choose a reduction with
Because complementation preserves this same biconditional,
Now means . Composing with an NP verifier for proves , hence . Therefore . Taking complements gives the reverse inclusion.
This argument relies on many-one reductions. Their single output and biconditional make the complement step immediate. With other reduction notions, closure must be checked rather than assumed.
An analogous warning applies to NP-hardness: if is NP-hard but not known to lie in NP, then still implies by downward closure. To call NP-complete, however, one must separately prove .
Common mistakes
- “NP means exponential.” NP defines nondeterministic polynomial time, not a deterministic lower bound.
- Swapping NTM accept/reject states. This changes existential acceptance incorrectly; it does not decide the complement.
- Polynomial in the wrong quantity. Runtime must be polynomial in encoded input length, not numeric value.
- Unbounded certificates. A fast verifier with exponentially long evidence does not establish NP membership.
- Confusing a bad witness with a no-instance. A no-instance rejects every witness; one rejection is insufficient.
- Drawing known strict containments. The boundaries among P, NP, and coNP are unresolved.
Exercises
Exercise 1 —
Prove and . State what you did not prove about .
Solution
A deterministic polynomial machine is an NTM with one branch, so . If , swap accept and reject in its total decider to decide in the same time, so and .
Not proved: (open). Only is known.
Exercise 2 — Hamiltonian-path certificate
Prove that the language of directed Hamiltonian paths is in : define certificate, checks, completeness, and soundness.
Solution
Certificate: a sequence of IDs. Check it is a permutation of and consecutive pairs (and closing edge if cycles) are edges. Length , polynomial time. Completeness/soundness follow the path definition.
Exercise 3 — coNP certificate for nontautology
Let be the language of formulas that are not tautologies. Prove , hence tautologies lie in .
Solution
Certificate for : a falsifying assignment. Verify by evaluation in polynomial time. Thus and its complement (tautologies) is in .
Exercise 4 — Bounding
Prove why a verifier definition must bound . What breaks without the bound?
Solution
The matching NTM guesses ; without a bound the guess is not polynomial in . Even reading may not be polynomial in the input length. The bound ensures .
Exercise 5 — NP-complete language in
Prove: if some NP-complete language lies in , then .
Solution
Let be NP-complete and . For every there is a polynomial reduction . Compose with a polynomial decider for to decide in polynomial time. Thus , hence equality.
Summary
is short efficiently checkable yes-evidence; is no-evidence. Containments with are known; the interesting equalities remain open.
Guided practice
Task 1 — Verifiers do not find certificates
Explain why a polynomial verifier need not find a certificate, and how that differs from a search algorithm.
Solution
The verifier is given and checks. Finding is a search problem that may be hard even when verification is easy. Membership in does not yield a finder.
Task 2 — Closure under complement
Prove is closed under complement. Explain why the same proof fails for without extra assumptions.
Solution
In , swap accept/reject on a deterministic decider. In , swapping tree leaves changes into “ rejecting branch”, not . Closure of under complement is equivalent to , which is open.
Task 3 —
Give a natural problem historically associated with , and state what is known about the intersection.
Solution
PRIMES is a classic example (now known to be in ). In general is known; equality is not. An NP-complete language cannot lie in unless .
Sources
Course evidence
- Current Semester A transcripts 7–8: certificate checking, nondeterministic computation, and the verifier/NTM characterization. No finer transcript line or timestamp locator is asserted here.
- Merged course summary, pp. 39–42: the core NP definitions, polynomial certificates, and verifier/nondeterministic-machine viewpoint.
- Merged course summary, pp. 81–85: complements, coNP, asymmetric evidence, and the NP-versus-coNP discussion. These page ranges are cited as course evidence; no wording is reproduced from the scanned summary.
Textbook verification
- Sipser, Introduction to the Theory of Computation, 3rd ed., §7.3, pp. 293–299: verifier definition of NP and equivalence with nondeterministic polynomial time.
- Arora–Barak, Computational Complexity: A Modern Approach (draft), §2.1–2.2, especially pp. 38–45 in the draft pagination: NP, certificates, and coNP.
- Papadimitriou, Computational Complexity, Ch. 9, pp. 181–187: NP certificates, nondeterminism, and complementary evidence. These references verify the standard claims; the sequencing and examples above follow the current course.
The pages this was written from
3 pages
These pages were chosen by word overlap between the text here and the page's transcription — nobody has verified them. Treat them as a lead to check, not a citation.
Lecture 4 · page 3המשך אי דטרמיניזםShared wordsניסוח · מדויק · שקול · בקבלה · הצגה · סוף
Lecture 8 · page 1בעית החתך המרבי ובעיות צביעהShared wordsCook · Levin · ההתחלה · לאלא · לסכם · Not
Lecture 20 · page 4תרגילים משיעורי ביתShared wordsששתיהן · ואז · קיימות · שונות · מספקות · ההשמות