4.6.23 · D5Theory of Computation

Question bank — NP — non-deterministic polynomial, verifier definition

1,344 words6 min readBack to topic

Before you start, keep the verifier triple in your head: Short certificate, Fast check, Yes-only existence.


True or false — justify

Every problem in P (complexity class) is also in NP.
True. If you can solve in polynomial time, you can verify it by ignoring the certificate and just re-solving — a solver is a lazy verifier, so .
"NP" stands for "non-polynomial," so NP problems can't be solved in polynomial time.
False. NP means Nondeterministic Polynomial. It contains all of P, so plenty of NP problems are solved fast; the name is about guess-then-check, not about being unsolvable.
If a problem is in NP, its "no" instances also have short certificates.
False in general. NP guarantees certificates only for yes instances. Short certificates for the no side define co-NP; whether NP co-NP is open.
A verifier that runs in exponential time but accepts a short certificate still shows the problem is in NP.
False. The verifier itself must run in polynomial time. Both conditions — short certificate and fast check — are required together.
If the certificate can be exponentially long but the verifier is polynomial, the problem is in NP.
False. A polynomial-time verifier can't even read an exponential-length certificate, so the "check" is a fiction. The bound is essential.
(every NP problem is solvable in exponential time).
True. Brute-force every certificate of length : there are at most of them, each checkable in poly time, giving an exponential-time deterministic solver.
A nondeterministic Turing machine is just a randomized (coin-flipping) machine.
False. Nondeterminism accepts if some branch accepts (a logical OR over all branches). Randomness assigns probabilities and takes a majority/threshold — a different acceptance rule.
If someone proves one NP problem is not in P, then .
True. P NP would force every NP problem into P; a single NP problem outside P immediately separates them.
Showing SAT P would settle P vs NP.
True. Boolean Satisfiability (SAT) is NP-complete (by Cook–Levin Theorem), so a poly-time SAT solver would put all of NP into P.
Every problem in NP is NP-complete.
False. NP-complete problems are the hardest in NP (everything reduces to them). Easy problems like "is even?" are in NP but nowhere near complete.

Spot the error

" NP because for the yes-instance I found the certificate is short." — what's missing?
You must also show the verifier checks that certificate in polynomial time. Short certificate alone isn't enough; a hard-to-check hint doesn't qualify.
"My verifier accepts the true certificate on yes-instances, so the problem is in NP." — what's the hidden gap?
You also need the converse: for every no-instance, no certificate makes accept. Otherwise could wrongly accept a no-instance, breaking the biconditional.
"COMPOSITE is in NP, so PRIMES must be non-NP (it's the opposite)." — flaw?
The complement of an NP language isn't automatically outside NP. PRIMES is actually in NP and even in P; complementation gives co-NP membership, not exclusion.
"I gave a polynomial-time algorithm that solves the problem, but I couldn't find a certificate, so it's not in NP." — flaw?
A solver is a verifier that ignores the certificate. Solving in poly time already puts you in P NP; no separate certificate is needed.
"The Hamiltonian-cycle verifier just checks that the given path is a cycle." — what did it forget?
It must also verify every vertex appears exactly once (visiting all vertices). Checking edges alone would accept a short sub-loop that isn't Hamiltonian.
"NP is defined by a polynomial reduction from SAT." — what's confused here?
That's the definition of NP-hardness/completeness via Polynomial-Time Reductions, not NP membership. NP itself is defined by a poly-time verifier and short certificate.

Why questions

Why must the certificate length be bounded by a polynomial in , not just "finite"?
A finite-but-huge (e.g. exponential) certificate couldn't be read in poly time, so every problem would trivially "qualify." The polynomial bound is what makes verification meaningful.
Why is the NP definition one-sided (existence only for yes-instances)?
Because mirrors "there is a proof of yes." A no-instance has nothing to exhibit — the guarantee is that no certificate works. Demanding a certificate for "no" gives co-NP instead.
Why do we say the certificate "is" the nondeterministic guess?
A nondeterministic machine guesses a string bit-by-bit, then checks it deterministically. That guessed string is exactly the certificate , and the checking phase is exactly the verifier — the two views coincide.
Why doesn't already prove ?
EXP is a much bigger, looser bound; NP sitting inside EXP says nothing about whether it also fits inside the smaller class P. The gap between P and NP is untouched by the EXP upper bound.
Why can't we just use a randomized (probabilistic) machine to define NP?
Randomized acceptance uses probability thresholds, but NP's acceptance is a pure OR — accept iff some branch (certificate) works, even one out of exponentially many. That "some" is logical existence, not likelihood.

Edge cases

Is the empty language (always "no") in NP?
Yes. Take a verifier that always outputs ; then no certificate ever makes it accept, and there are no yes-instances to certify — the biconditional holds vacuously.
Is (always "yes", every string accepted) in NP?
Yes. Use the empty certificate and a verifier that always accepts; it's actually in P, and P NP.
If is tiny (say the input is a single symbol), can the certificate still be "polynomial"?
Yes, but is then also tiny, so the certificate must be correspondingly short. The polynomial bound scales with the input; small inputs allow only small certificates.
Can a yes-instance have more than one valid certificate?
Absolutely. SAT can have many satisfying assignments. NP only requires that at least one certificate exists for a yes-instance; multiplicity is fine.
What if a verifier accepts on a yes-instance for some certificates but also accepts a no-instance for some certificate?
Then it's an invalid verifier — the language it defines isn't . A correct verifier must accept some certificate on every yes-instance and no certificate on any no-instance.
Is a decision problem with no inputs at all (a single fixed yes/no question) in NP?
Trivially yes — a constant-time verifier answers it, and any constant-time solvable problem is in P NP. Degenerate inputs never break membership.

Recall One-line self-test

Cover every answer above and re-derive the reason, not the verdict. If you can justify each with the verifier triple (Short / Fast / Yes-only), you own the definition.

Flashcards

Does P NP, and why?
Yes — a poly-time solver doubles as a verifier that ignores the certificate.
Why must the verifier itself be polynomial-time?
Otherwise "easy to check" is meaningless; a slow checker would admit hard problems as trivially NP.
Is NP's certificate guarantee two-sided?
No — certificates exist only for yes-instances; the no-side guarantee is that no certificate accepts (that's co-NP's flip).