0

I am having trouble understanding the class $coNP$. We defined

$$coNP = \left\{ \overline{A} : A \in NP \right\}$$

As far as I know, a language $A$ is in $NP$ if, and only if, a non-deterministic turing machine $M$ exists, which outputs $1$ if $w \in A$ and $0$ if $w \notin A$. But if this is true, then a turing machine $M'$ must exist which simulates $M$ and inverts the output:

$$M' = \begin{cases}0 \text{ if } M = 1\\1 \text{ if } M = 0\end{cases}$$

Therefore, $w \in A \implies w \notin L(M')$ and $w \notin A \implies w \in L(M')$, meaning that $L(M') = \overline{L(M)}$.

As $M'$ works in non-deterministic polynomial time, $L(M') \in NP$, and as $L(M') = \overline{L(M)}$, $\overline{L(M)} \in NP$, but $\overline{L(M)} \in coNP$ as well. As this holds true for all languages in $NP$, why isn't $coNP = NP$?

Raphael
  • 73,212
  • 30
  • 182
  • 400
just.kidding
  • 277
  • 1
  • 3
  • 12

1 Answers1

2

A problem in NP can be solved quickly if the answer is YES. Your inverted Turing machine finds the answer quickly if the answer to the original question is YES and the answer to the inverted question is NO. You need an answer quickly if the answer to the inverted question is YES and to the original is NO, and you don't have that.

Edit: Take for example the "Travelling Salesman" problem. I give you a list of cities to visit and ask you "is there a tour to visit them all that is at most 957 miles"? If the answer is YES then there is such a tour, so all your nondeterministic TM has to do is take such a tour and verify in polynomial time that it is indeed 957 miles or shorter. You only need to check one tour (the right one) to prove the answer is YES. If the answer is NO then you have to check all possible tours and see that none is short enough. Proving the answer is NO is a lot, lot harder.

gnasher729
  • 32,238
  • 36
  • 56