简体   繁体   English

NP和co-NP有什么区别

[英]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?我知道他们的完全对应意味着 NP - complete 是 NP 问题中最难的,而 co-NP-complete 意味着在 co-NP 问题中最难,但是两者之间有什么区别? My textbook said "The yes and no are reversed" which doesn't leave that much of a clue to me.我的教科书说“是和否是颠倒的”,这并没有给我留下太多线索。

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?"例如,在 Set Cover 中,我们可能会问我们可以仅使用 X 个子集覆盖所有元素吗?” where X is some arbitrary number.其中 X 是某个任意数字。 We can show that this problem exists in NP because a solution to it is easily verifiable;我们可以证明这个问题存在于 NP 中,因为它的解决方案很容易验证; you provide the X subsets, and I check to see if all elements are covered in polynomial time.您提供 X 子集,然后我检查是否所有元素都在多项式时间内被覆盖。 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).如果我们可以有效地对决策问题回答“是”,那么我们可以最小化 X,从而有效地解决整个 Set Cover 问题(从而证明 P=NP)。

Co-* (Co-NP, Co-NP-complete) focuses on answering "no" to the complemented decision problem. Co-*(Co-NP,Co-NP-complete)侧重于对补充决策问题回答“否”。 For example, the complemented decision problem of Set Cover would be " For every combination of X subsets, is it impossible to cover all elements?"例如,集合覆盖的补充决策问题将是“对于 X 个子集的每个组合,是否不可能覆盖所有元素?” 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.总而言之:NP 关注对某些决策问题的“是”答案。 Co-NP is concerned with a "no" answer to the same, but complemented, decision problem. Co-NP 关注对相同但补充的决策问题的“否”答案。

NP is the class of decision problems for which there is a polynomial time algorithm that can verify "yes" instances given the appropriate certificate. NP是一类决策问题,有多项式时间算法可以在给定适当的证书的情况下验证“是”实例。

CoNP is the class of decision problems for which there is a polynomial time algorithm that can verify "no" instances given the appropriate certificate. CoNP是一类决策问题,有多项式时间算法可以在给定适当的证书的情况下验证“否”实例。

We don't know whether coNP is different from NP.我们不知道 coNP 是否与 NP 不同。

There is a problem in NP for every problem in coNP, and vice versa. coNP 中的每个问题都有一个 NP 问题,反之亦然。 For example, the SAT problem asks "does there exist a boolean assignment which makes this formula evaluate to True?".例如,SAT 问题会询问“是否存在使此公式评估为 True 的布尔赋值?”。 The complement problem, which is in coNP, asks, "do all boolean assignments make this formula evaluate to False?" coNP 中的补码问题是:“是否所有布尔赋值都使这个公式的计算结果为 False?”

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.只是为了补充其他人所说的(因为我自己发现这令人困惑),是否 NP = co-NP 的问题是询问是否每个决策问题都可以在多项式时间内检查“是”的答案有一个“否”的答案,可以在多项式时间内检查。

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.这有点令人困惑,所以这里有一个例子:旅行商问题的决策形式(“给定一个图 G,在 G 中是否有一条长度为 L 或更短的路径至少访问每个顶点一次?”)在 NP 中:如果我说“是的,有一条长度为 L 或更短的路径至少访问每个顶点一次”,我证明这一点的方法是给你一条长度为 L 或更小的路径,该路径至少访问每个顶点一次,并且检查我的解决方案的方式是走我的路,检查它是否至少到达每个顶点一次,并且它的长度为 L 或更小。 This problem is in NP because doing this check takes polynomial time (ie it's fast)这个问题在 NP 中,因为做这个检查需要多项式时间(即它很快)

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?"这个问题的补充是“给定一个图 G,在 G 中是否没有长度为 L 或更短的路径至少访问每个顶点一次?” 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."为了证明这一点,我会说“不,没有长度为 L 或更短的路径(双重否定令人困惑)至少访问每个顶点一次。为了证明这一点,这里有一条长度为 L 或更小的路径访问每个顶点至少访问一次。所以 G 中长度为 L 的路径存在至少访问每个顶点一次的说法是正确的。” This is what people mean when they say that the complement of any NP problem is in co-NP.这就是人们所说的任何 NP 问题的补集都在 co-NP 中的意思。

So, what would it mean if NP = co-NP?那么,如果 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).这意味着如果问题在 NP 中(您可以轻松地检查“是”答案),那么它也在 co-NP 中(您可以轻松地检查“否”答案)。

(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.) (重申一下,我们不是在谈论问题的补:我们已经知道 NP 问题的补在 co-NP 中。我们在问原始问题。)

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?但是对于旅行商问题,它的工作原理并不明显:如果我说“不,G 中没有长度为 L 或更短的路径可以恰好访问每个顶点一次”,我将如何证明这一点? 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.发现自己的NP = CO-NP将是令人吃惊,因为这意味着,一些证据,我可以给你的是,你可以快速检查一下,看看我是正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM