Whats the difference between NP and co-NP
Asked Answered
B

3

19

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.

Boggs answered 11/6, 2013 at 14:20 Comment(2)
Related: math.stackexchange.com/questions/361422/why-isnt-np-conpStrain
Also math.stackexchange.com/questions/2334429Guise
I
19

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.

Infernal answered 11/6, 2013 at 15:3 Comment(4)
Do you mean that you use the same polynomial verifier to answer both questions? One to check if a certificate is a solution, and the other to check it's a counter example and thus a solution for the complement question? If yes, what is the goal of this playing with words?Winebaum
@Ahmad: We do not, and in fact cannot, use the same verifier to answer both questions. Just like we're not sure that P = NP, we're also not sure that NP = Co-NP. A polynomial verifier that can answer "yes" to an "NP" may not be able to easily answer "no" to the complemented decision problem.Infernal
But in your examples, it seems such a verifier could answer both questions. I would like you to add another example to show that it's not easy to answer "no" to the complement question or any other question.Winebaum
From Wikipedia on Co-NP: A decision problem X is a member of co-NP if and only if its complement X is in the complexity class NP So I think, yes, the same verifier could be used to solve both problems. If you change NP to Co-NP and take the complement of the problem, it is essentially the same problem. I think Co-NP is useful to express the concept how hard it is to provide a "no" answer to a problem, without changing the definition of the problem (taking the complement).Rumsey
H
14

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.

Hexahedron answered 4/4, 2021 at 18:31 Comment(0)
L
6

NP is the class of decision problems for which there is a polynomial time algorithm that can verify "yes" instances given the appropriate certificate.

CoNP is the class of decision problems for which there is a polynomial time algorithm that can verify "no" instances given the appropriate certificate.

We don’t know whether coNP is different from NP.

There is a problem in NP for every problem in coNP, and vice versa. For example, the SAT problem asks "does there exist a boolean assignment which makes this formula evaluate to True?". The complement problem, which is in coNP, asks, "do all boolean assignments make this formula evaluate to False?"

Laconism answered 27/10, 2019 at 4:38 Comment(1)
there isn't necessary that Co-NP be polynomial certifiable because then Co-NP = NPGearldinegearshift

© 2022 - 2024 — McMap. All rights reserved.