In the blog post at:
I read:
NP is the set of problems that can be solved by polynomial-time non-deterministic algorithms. An equivalent definition of NP is the set of problems for which a solution can be verified in polynomial time.
Questions:
1) How does the equivalence of the definitions follow?
2) Isn't it possible to verify, in polynomial time, also the solutions of the P class of problems? Namely, given a purported solution, one can calculate the actual solution in polynomial time. Thus, one can verify if it is equal to the purported one in polynomial time. Thus, the 'equivalent definition' above is not just true for NP but also for P, i.e. it is not a definition of NP at all, but just one of its properties.
Am I missing something subtle? I must be, since I have encountered similar 'definitions' of NP class of problems in many different instances.
1) Suppose you have a problem with a polynomially verifiable solution. Then, you can get a non-deterministic polynomial algorithm for that problem simply by guessing a solution (via non-determinism) and verifying it in polynomial time.
Suppose you have a non-deterministic polynomial algorithm. How can we obtain a polynomially verifiable solution (in the literature, this is often called a "certificate" instead of "solution")? Simply take the execution trace of the non-deterministic Turing machine that encodes your algorithm and verify that running that trace through the non-deterministic TM yields the correct result.
2) Yes, it is possible to verify the solutions of problems in P in polynomial time. This only demonstrates that P is a subset of NP. The key difference is that in P, we can construct the solution in deterministic polynomial time. In NP, we only need to verify a solution in deterministic polynomial time. This gap between construction and verification is at the heart of the P vs. NP question. Intuitively, it feels like verification should be strictly easier than construction (and hence NP should be strictly larger than P) but so far we are unable to prove this.