2

I have read that an NP problem is verifiable in polynomial time or, equivalently, is solvable in polynomial time by a non-deterministic Turing machine. Why are these definitions equivalent?

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
ishan3243
  • 1,870
  • 4
  • 30
  • 49

2 Answers2

3

First, let's show that anything that can be verified in polynomial time can be solved in nondeterministic polynomial time. Suppose you have some algorithm P(x, y) that decides whether y verifies x, and where P runs in time O(|x|k) for some constant k. The runtime of this algorithm is polynomial in x, meaning that it can only look at polynomially many bits of y. Then you could build this nondetermistic polynomial-time algorithm that solves the problem:

  1. Nondeterministically guess a string y of length O(|x|k).
  2. Deterministically run P(x, y) and output whatever it says.

This runs in nondeterministic polynomial time because y is constructed in nondeterministic polynomial time and P(x, y) then runs in polynomial time. If there is a y that verifies x, this machine can nondeterministically guess it. Otherwise, no guess works and the machine will output NO.

The other direction is trickier. Suppose there's a nondeterministic algorithm P(x) that runs in nondeterministic time O(|x|k) for some constant k. This nondeterministic algorithm, at each step, chooses from one of c different options of what to do next. Therefore, you can make a verification program Q(x, y) where y encodes what choices to make at each step of the computation of P. It can then simulate P(x), looking at the choices encoded in y to determine which step to take next. This will run in deterministic time O(|x|k) because it simply does all of the steps in the nondeterministic computation.

Hope this helps!

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
1

Perhaps this example gives some hint:

Given L = {w : expression w is satisfiable} and Time for n variables:

  • Guess an assignment of the variables O(n)
  • Check if this is a satisfying assignment O(n)
  • Total time: O(n)

The satisfiability problem is an NP-Problem and Intractable but widely used in computing applications due to the fact that it is linear time complexity for each guess.

The class NP is intended to isolate the notion of polynomial time “verifiability”. NP is the class of languages that have polynomial time verifiers.

sepideha
  • 1,669
  • 1
  • 11
  • 14