Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats the difference between NP and co-NP

I know their complete counterparts mean that NP - complete is the hardest in the NP problems and co-NP-complete means the hardest in co-NP problems but whats the difference between the two? My textbook said "The yes and no are reversed" which doesn't leave that much of a clue to me.

like image 207
Programmerboi Avatar asked Jun 11 '13 14:06

Programmerboi


2 Answers

Just to add to what other people have said (since I myself found this confusing), the question of whether NP = co-NP is asking whether every decision problem for which there is a "yes" answer that can be checked in polynomial time also has a "no" answer that can be checked in polynomial time.

That's a bit confusing, so here's an example: the decision form of the travelling salesman problem ("Given a graph G, is there a path of length L or less in G that visits each vertex at least once?") is in NP: if I say "yes, there is a path of length L or less that visits each vertex at least once", the way I prove that is by giving you a path of length L or less that visits each vertex at least once, and the way you check my solution is by taking my path, checking that it travels to each vertex at least once, and that it's of length L or less. This problem is in NP because doing this check takes polynomial time (i.e. it's fast)

The complement of this problem would be "Given a graph G, are there no paths of length L or less in G that visit each vertex at least once?" Answering "no" to this question is basically the same problem as the one above. To prove that, I would say "no, there are not no paths (the double negatives get confusing) of length L or less that visit each vertex at least once. To prove that, here is a path of length L or less that visits each vertex at least once. So it is not true that there are no paths in G of length L that visit each vertex at least once." This is what people mean when they say that the complement of any NP problem is in co-NP.

So, what would it mean if NP = co-NP? It means that if a problem is in NP (you can check a "yes" answer easily), it's also in co-NP (you can check a "no" answer easily).

(Just to reiterate, we're not talking about the problem's complement: we already know that the complement of an NP problem is in co-NP. We're asking about the original problem.)

But for the travelling salesman problem, it's not obvious how this would work: if I said "no, there are no paths of length L or less in G that visit each vertex exactly once," how would I prove that? When the answer is "yes", it's easy for me to prove that to you (by just giving you the path so you can check it yourself). But if my answer is "no", there's no easy way (that we know of) to check that I'm right. All I could say is "trust me, I checked all of them". Finding out that NP = co-NP would be surprising because it would mean that there is some proof I could give you of that, and you could quickly check it and see that I'm right.

like image 162
Matthew Tromp Avatar answered Sep 28 '22 10:09

Matthew Tromp


When you want to prove the difficulty of a problem, you have to turn it into something called a decision problem, which means a "yes/no" answer type problem. For example, in Set Cover, we may ask "can we cover all elements using only X subsets?" where X is some arbitrary number. We can show that this problem exists in NP because a solution to it is easily verifiable; you provide the X subsets, and I check to see if all elements are covered in polynomial time. If we can answer efficiently answer "yes" to the decision problem, then we can minimize X and thus solve the entire Set Cover problem efficiently (thereby proving P=NP).

Co-* (Co-NP, Co-NP-complete) focuses on answering "no" to the complemented decision problem. For example, the complemented decision problem of Set Cover would be "For every combination of X subsets, is it impossible to cover all elements?" Answering "no" to this question requires you to provide a counter-example.

In summary: NP is concerned with a "yes" answer to some decision problem. Co-NP is concerned with a "no" answer to the same, but complemented, decision problem.

like image 31
AndyG Avatar answered Sep 28 '22 09:09

AndyG