0
  1. It seems correct that any single given algorithm must either have polynomial runtime or not. Is there a specific algorithm that (does or does not actually lie in $P$, but) can neither be proven nor disproven to do so?

  2. Is there a decision procedure for "$\in P$"?

  3. Do we know $P$ vs. $NP$ to be decidable? Could it be proven undecidable in the way that an algorithm with proven "optimal" (i. e. proven asymptotically fastest) runtime is non-constructively provided, and then one proves that it is undecidable whether the optimal algorithm has polynomial runtime or not?

Raphael
  • 73,212
  • 30
  • 182
  • 400
heinzelotto
  • 11
  • 1
  • 2

2 Answers2

6

The following problem is undecidable:

Given an algorithm $A$, decide whether it runs in polynomial time.

Indeed, if you could decide this problem, then you could decide the halting problem, in the following way. Let $M$ be an input to the halting problem (we want to know whether $M$ halts on the empty input). Construct an algorithm $A$ which, on input $n$, runs $M$ for $n$ steps, and if $M$ halts, counts from $1$ to $2^n$. Then $M$ halts iff $A$ doesn't run in polynomial time.


You seem to be conflating several different meanings of decidable:

  1. Decidable by an algorithm.
  2. Can be proved or disproved.
  3. Is true or false.

It is meaningless to ask whether "P vs. NP" can be decided by an algorithm, since there's no input here. It is meaningful to ask whether "P vs. NP" is determined by the "axioms of mathematics" (say, ZFC) or not; see what Scott Aaronson has to say about it. Finally, in classical logic every statement is either true or false, and in particular either P=NP or P≠NP.

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514
2
  1. P is a class of languages, not a class of algorithms. A language (or problem) is in P if there is some Turing machine that decides it in a polynomial number of steps. So, for example, determining whether a graph is connected is in P, since a TM can determine that efficiently. However, there are arbitrarily inefficient algorithms to determine connectivity: for example, an algorithm could waste time counting to $2^n$ before looking at the graph. If you want to know whether a particular algorithm runs in polynomial time, that is undecidable, as Yuval shows.

  2. No, because that isn't even a computational problem. Suppose that you wanted to design a Turing machine that determined if given languages were in P. What would the input to your Turing machine be? Remember – it has to be a finite string. Probably the closest you could get is to give a Turing machine as input and ask if the language accepted by that machine is in P (i.e., either the given TM decides the language in polynomial time or some other TM does). But that is undecidable for the same reasons as above.

  3. No because, again, that isn't a computational problem: it's something that's either true or false. In this case, there's no input at all.

David Richerby
  • 82,470
  • 26
  • 145
  • 239