-1

Suppose some problem L is in the complexity class P. Then there is some polynomial time algorithm A that decides the problem. We have the following theorem: if A accepts L, then A decides L.

The proof works by noting that if A runs in polynomial time, then there are some non negative constants c, k such that the run time of A is cn^k where n is the size of the input L. So we can construct a polynomial time algorithm A' that calls A and returns 1 if A returns 1 in time<= cn^k, and returns 0 if A takes longer than cn^k to return something. By doing this, we note that if A tries to go into an infinite loop, then A' just halts the process in poly time and returns 0 which implies that A' rejects the compliment of L.

My question is: Why does this proof not work for the complexity class NP? Can we not just say that if L is in NP, then there is a non deterministic poly time algorithm A that decides L, so just define A' as above?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

1 Answers1

0

"Deciding" a problem means being able to say whether or not a given string is in the language. If a string is not in an NP language, there is no polynomial amount of time you can wait for acceptance to fail before declaring the string is not in the language, which makes your algorithm untenable.

For languages in P, you don't know what the "polynomial amount of time" actually is, but you do know that your algorithm will terminate in a finite amount of time for any input. But for NP, testing inputs not in the language may not terminate ever, so you can never tell if your input isn't in the language or you just haven't waited long enough.

Scott Hunter
  • 48,888
  • 12
  • 60
  • 101
  • Thanks! I don't really understand. If a string x is in an NP language L and A accepts L, then A must return 1 if x is in L, and either 0 or nothing (infinite loop) otherwise. A must also do this in (non deterministic) polynomial time. So if A returns 1, then x is in L, if A returns 0, then x is not in L. If A takes longer than polynomial time, then can't we say that x is not in L? I.e., algorithm A has failed to non deterministically pick a certificate y for x and verify (in poly time) that y is indeed a certificate for x. Doesn't this mean that x is not in L? – A to the B Jul 08 '18 at 16:47
  • I know that the above is wrong...I just can't see why – A to the B Jul 08 '18 at 16:48
  • If a program is in an infinite loop, it can't return anything. – Scott Hunter Jul 08 '18 at 17:39
  • How would you determine the number of seconds to wait, since you don't know c or k? – Scott Hunter Jul 08 '18 at 17:41