Understanding the “Guess and Check” definition of $NP$.

computational complexitycomputer sciencedefinition

Aside from the normal complexity definition of $NP:= \bigcup_{k \geq 1} \ NTIME$, we have an alternative definition ("Guess and Check") of NP

A language $L \subseteq \Sigma^*$ is in $NP$ , if there exist a
polynomial $p: \mathbb{N} \to \mathbb{N}$ and a deterministic Turing
Machine $M$, so that for every $x \in \Sigma^*$ we have:

$$x \in L \iff \exists u \in \Sigma^{p(\vert x \vert)} : \langle x,u \rangle \in
T(M)$$

If $\langle x,u \rangle \in T(M)$ then $u$ is considered as a certificate of
$x$.

So essentially we use the string $u$ to help us determine a solution but I am not sure if I understand this definition properly.

Best Answer

For the sake of simplicity, I am going to be a little bit informal. This is according to a nice chapter in "Graph Theory" by Bondy and Murty.

We define a decision problem as a question whose answer is either "yes" or "no". A decision problem belongs to $\mathcal{P}$ if every instance of the problem can be solve in polynomial time by some algorithm. It belongs to $\mathcal{NP}$ if, given any instance of the problem whose answer is "yes", there is a certificate validating this fact which can be checked in polynomial time; such a certificate is said to be succinct. (If the answer is "no" and there is such a certificate which can be validated in polynomial time then the problem is in $co-\mathcal{NP}$).

Now, using the formal definition that you have provided. Our turing machine $M$ accepts every word $x \in L$ if and only if there is a word $u$ of length bounded from above by $p(|x|)$ and $M$ accepts the pair $<x,u>$. The point is that $M$ accepts $x$ using $u$ in polynomially many steps, since $u$ has size at most $p(|x|)$.

For example, solving a hereditary property based problem on a simple, undirected graph $G$ (which is a property which must hold for each induced subgraph), we have to check each induced subgraph $H$ of $G$. This boils down to enumerate all subsets of the vertex set $V$ and if $|V|=n$ there are $2^n$ possible subsets. But if a solution is provided, it could be essentially faster to check if this solution is correct.

Furtheremore, the term "Guess and check" is often used in relationship with non-deterministic Turing machines. We guess a solution of our problem instance (which is generated in a non-deterministic way) and then verify its solution in polynomially many steps by some deterministic Turing machine.

In other words: $L$ is in $\mathcal{NP}$ if $x \in L$ can be verified by an algorithm encoded by $u$ whereby $u$ has length at most $p(|x|)$, and this holds for all words of $L$.

Example: Take an instance of the SAT problem. Is $(x_1 \land \lnot x_2) \lor (x_1 \land x_3) \lor (\lnot x_2 \land x_3)$ satisfiable? Now, perform the following steps:

  1. Guess $n$-bit vector,
  2. Verify the guessed vector, simply by calculating the formula of the given instance.

SAT is obviously in $\mathcal{NP}$.