1

How does these problems fall into the tapestry of the P, NP, NP-Hard, etc... sets? I don't know if any such problems even exists, but what initiated my thought process was thinking of a decidable of the travelling salesman problem:

    Given a list of cities and the distances between each pair of cities, and a 
    Hamiltonian path P, is P the shortest Hamiltonian path?

I suspect that we cannot verify the "shortestness" of P in polynomial time, in which this decision problem is not even in NP. So where does it fall in this case?

theQman
  • 1,690
  • 6
  • 29
  • 52

3 Answers3

0

This problem is in co-NP. You can think of NP as the class of problems where if the answer is yes, there is a small amount of information I could give you that would convince you of this. For example, the problem

Is there a Hamiltonian cycle in G with cost at most k?

is in NP, because if the answer is yes, I could just give you the cycle and you could check it to see whether it's valid. Coming up with that cycle is hard, but once you have the Hamiltonian cycle it's really easy to use it to check the answer.

The class co-NP consists of problems where if the answer is no, there's a small amount of information I could give you that would convince you of this. In your case, suppose that no, P is not the shortest Hamiltonian path. That means that there's some shorter path P'. If I gave you P', you could easily check that P wasn't ideal. Coming up with P' might be really hard (in fact, it's co-NP-hard!), but once you have it it's pretty straightforward to use it to confirm the answer is no.

Hope this helps!

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
  • Thanks. So is every decision problem in either NP or co-NP? Are there decision problems that are in both sets? – theQman Mar 31 '14 at 20:49
  • @theGman No, not all decision problems belong to NP or co-NP. As an example, the halting problem is undecidable, so it can't belong to NP or co-NP (all problems in NP and co-NP are decidable). Also, yes, every problem in P is in both NP and co-NP, though it's unknown whether P = NP, P = co-NP, or whether P is the intersection of NP and co-NP. – templatetypedef Mar 31 '14 at 20:52
  • I see. To build on my last question then... Is every _decidable_ problem in one of NP or co-NP? I don't know of any examples, but isn't it possible for a decision problem to be decidable, but yes/no instances not verifiable in polynomial time? Hmm, I guess such decision problems exists if and only exist if P != NP ? – theQman Mar 31 '14 at 21:22
  • @theGman No, not all decidable problems are in one of NP or co-NP. It's known that NP and co-NP are strict subsets of NEXPSPACE (problems solvable in nondeterministic exponential space), and there are problems in NEXPSPACE that are known not to be in NP or co-NP. I can't think of any natural examples of problems like this (I don't know if any are known); one example would be (I think) "does TM M accept input w in time 2^2^n?" – templatetypedef Apr 01 '14 at 00:21
  • Thanks again. Do you have any references you would suggest for me to get a better feel for this stuff? I am reading Sipser's text but would like some other options. – theQman Apr 01 '14 at 00:53
  • @theGman Sipser is probably the best book on the subject. The rest of this I've learned from courses I've taken or random lecture notes. Stanford's CS254 course might be a good starting point here. – templatetypedef Apr 01 '14 at 01:01
0

Given two integers n and m, are there exactly m prime numbers p <= n?

This can be solved in about O (n^(2/3)) and possibly slightly faster, but the problem size is of course not n but log (n), so it takes sub-linear time in n, but exponential time in the problem size. That's not worse than you'd expect from a problem in NP. However, I cannot see any possible information that would allow you to check this quicker.

(Actually, there is an algorithm which determines the number of primes <= n in about O (n^(2/3)) steps, but there is no known algorithm that can check an answer faster than finding the answer. )

gnasher729
  • 51,477
  • 5
  • 75
  • 98
0

Given integers n and k, is 2^n - 1 the k-th Mersenne prime?

It is possible to prove that p is prime in time polynomial in the size of p if a complete factorisation of p + 1 is known, and if p = 2^n - 1 then the complete factorisation of p + 1 is trivial.

However, that is polynomial in the size of p. 2^n - 1 can be checked for primality in time that is polynomial in n. However, that is not polynomial in the size of the problem, which would be roughly the number of digits in n and k. And it would just answer the question whether 2^n - 1 is a Mersenne prime. To prove that it is the k-th Mersenne prime, we would have to check 2^m - 1 for 1 <= m < n and prove that exactly k-1 of these are primes.

Currently the answer to the question is not known for k >= 44 and many 8-digit values n.

gnasher729
  • 51,477
  • 5
  • 75
  • 98