A polynomial-time verifier for a language \(A\) is a Turing machine \(V\) such that: \[ A = \setbuild{x \in \binary^*}{\left(\exists w \in \binary^{\le |x|^k}\right) \; V \text{ accepts } \encoding{x, w}} \] for some constant \(k\). Furthermore, \(V\) must run in time \(O(|x|^c)\) for some constant \(c\).
Here, \(w\) is called a witness or certificate or proof for \(x\).
\(\NP\) is the class of languages that have polynomial-time verifiers.
We call the language decided by the verifier for \(A \in \NP\) the verification language of \(A\), denoted \(\verifier{A}\).
\[\probHamPath = \setbuild{\encoding{G}}{ G \text{ is a directed graph with a Hamiltonian path }}\]
\[ \probClique = \setbuild{\encoding{G, k}}{ G \text{ is an undirected graph with a } k\text{-clique}} \]
\[ \probSubsetSum = \setbuild{\encoding{C, t}}{ C \text{ is a } \textbf{multiset} \text{of integers, and } (\exists S \subseteq C) \; t = \sum_{y \in S} y} \]
“Proving \(\coNP \ne \NP\) is at least as hard as proving \(\P \ne \NP\).”
Theorem: \(\P \subseteq \NP\)
Proof:
A(x) deciding whether \(x \in L\).def V(x: str, w: str) -> bool:
return A(x)
Theorem: \(\NP \subseteq \EXP.\)
Proof:
k = 7 # change this constant depending on L
def exhaustive(x: str) -> bool:
for i in range(k+1):
for w in binary_strings_of_length(i):
if V(x,w):
return True
return False
Negation/NOT
\[ \begin{array}{c|c} x & \neg x \\ \hline 0 & 1 \\ 1 & 0 \end{array} \]
Conjunction/AND
\[ \begin{array}{cc|c} x & y & x \land y \\ \hline 0 & 0 & 0 \\ 0 & 1 & 0 \\ 1 & 0 & 0 \\ 1 & 1 & 1 \end{array} \]
Disjunction/OR
\[ \begin{array}{cc|c} x & y & x \lor y \\ \hline 0 & 0 & 0 \\ 0 & 1 & 1 \\ 1 & 0 & 1 \\ 1 & 1 & 1 \end{array} \]
More formally, we can define Boolean formulas inductively (like with regular expressions):
Given a finite set of variables \(V\), a Boolean formula \(\phi\) is defined as:
Precedence: \(\neg\) has highest precedence, followed by \(\land\), then \(\lor\).
Parentheses can be used to override this.
We can use this recursive structure to efficiently parse and evaluate Boolean formulas.
A Boolean formula \(\phi\) is satisfiable if there is an assignment of truth values to its variables that makes the formula evaluate to \(1\).
Example: \[ \phi = (x \land y) \lor (z \land \neg y) \] is satisfiable because setting \(x = 0, y = 0, z = 1\) yields \(\phi(001) = 1\).
We introduce the Boolean satisfiability problem:
\[ \probSAT = \setbuild{\encoding{\phi}}{ \phi \text{ is a satisfiable Boolean formula }} \]
We know \(\probSAT \in \NP\) because we can easily implement a polynomial-time decider for:
\[ \verifier{\probSAT} = \setbuild{\encoding{\phi, w}}{ \phi \text{ is a Boolean formula, and } \phi(w) = 1 } \]
Just evaluate \(\phi\) on the assignment \(w\)!
A Boolean formula \(\phi\) is satisfiable if there is an assignment of truth values to its variables that makes the formula evaluate to \(1\).
We introduce the Boolean satisfiability problem:
\[ \probSAT = \setbuild{\encoding{\phi}}{ \phi \text{ is a satisfiable Boolean formula }} \]
We know \(\probSAT \in \NP\) because we can easily implement a polynomial-time decider for:
\[ \verifier{\probSAT} = \setbuild{\encoding{\phi, w}}{ \phi \text{ is a Boolean formula, and } \phi(w) = 1 } \]