====== SAT is NP-complete ====== We have already shown in a previous lecture that $math[SAT \in NP]. It remains to show that $math[SAT] is NP-hard, i.e. $math[\forall f \in NP] we have $math[f \leq_p SAT]. ==== Roadmap ==== The difficulty of the proof relies in the fact that we cannot use the reduction technique shown in the previous lecture, since there is no choice of another NP-hard problem. Therefore, we need to prove that, for **each** NP-problem, there exists a polynomial-time reduction to SAT. Let $math[f \in NP] be a decision problem. The only information that we have of $math[f] is that it is decidable by a nondeterministic Turing Machine in a polynomial time which we consider to be $math[T(n) = n^k] for some $math[k \in \mathbb{N}]. Thus, the reduction $math[f \leq_p SAT] must construct, for each word $math[w], a formula $math[\varphi_w], such that: * $math[\forall w: f(w) = 1 \iff \varphi_w] is satisfiable. In constructing $math[\varphi_w], we must exploit the limited information we have: * there exists a NTM which runs in time $math[n^k] and which decides $math[f]. ==== Proof idea ==== The key idea of the proof is to construct the formula $math[\varphi_w] in such a way that: * a **satisfying assignment** of the formula precisely describes a **successful computation sequence** of the NTM In the construction, a key ingredient is the information that, since the machine performs at most $math[n^k] computation steps, then **at most** $math[n^k] cells of the tape will be employed in the computation. We will again assume that the machine never moves its head beyond the first position of the tape (an assumption similar to that from the proof of PCP undecidability). ==== Proof ==== Let $math[K] be the number of states of the NTM and $math[\Sigma] be the alphabet. A sequence of **successful computations** may be described in a tabular/matrix manner, as follows: ^ # ^ q0 ^ c1 ^ c2 ^ ... ^ cn ^ # ^ # ^ ... ^ # ^ | # | c | q1 | c2 | ... | cn | # | # | ... | # | | ... | ... | ... | ... | ... | ... | ... | ... | ... | # | * **each** table **row** describes a **configuration**. We call an element from the row a **position** (instead of cell, to avoid confusion with the cells of the TM). If a position contains a **state**, it indicates the **current state** and the **current symbol** pointed by the head; otherwise, a position describes the (cell-wise) **contents** of the tape. * The first row of the tape indicates the initial configuration: the current state is ''q0'' and the tape contains the word ''w = c1c2...cn'' * The second row of the tape indicates a subsequent configuration which corresponds to the transition $math[\delta(q_0,c1) = \{(q_1,c,R)\}] * Note that each row has $math[O(n^k)] positions (actually $math[n^k+2] should be sufficient). * Since each row describes a configuration, our matrix will only require $math[n^k] rows. The reason is that, if the NTM enters a successful (accepting) state, it will do so in at most $math[n^k] steps. Note that the matrix has a polynomial number of positions: $math[O(n^{k+k})] positions. Our task is to use a $math[SAT] formula to describe such a matrix. ==== Variables ==== * for each $math[i,j \leq n^k] and each position contents $math[p \in K \cup \Sigma] (either state or symbol), we construct the variable $math[x_{i,j,p}]. If $math[x_{i,j,p}=1] then at position ''i,j'' in the matrix, we have the value $math[p]. We can interpret the position ''i,j'' as: //after computation step ''i'', at position ''j'' of the configuration// ==== The formula ==== The formula which we construct must express the appropriate constraints such that the matrix is a valid description of a NTM computation. Hence: $math[\varphi_w = \varphi_{cell} \wedge \varphi_{start} \wedge \varphi_{move} \wedge \varphi_{yes}] $math[\varphi_{cell}] must express that **each position must contain a single value**, i.e. $math[\varphi_{cell} = \displaystyle \bigwedge_{i,j\leq n^k} (\bigvee_{p\in K \cup \Sigma} x_{i,j,p} \wedge \bigwedge_{p\neq p' \in K \cup \Sigma} (\lnot x_{i,j,p} \vee \lnot x_{i,j,p'})) ] * the first part of the formula states that each position must contain **some value p** * the second part of the formula states that **for each two different possible values of a position, at least one must be false** Note that $math[\varphi_{cell}] is in CNF. Also, the size of $math[\varphi_{cell}] is $math[O(n^{2k})]. $math[\varphi_{start}] must express the **initial configuration**, i.e. $math[\varphi_{start} = \displaystyle x_{1,1,\#} \wedge x_{1,2,q_0} \wedge x_{1,3,c1} \wedge \ldots x_{1,n^k+2,\#}] The size of $math[\varphi_{start}] is $math[O(n^{k})]. $math[\varphi_{yes}] must express the existence of a **successful configuration**, i.e. $math[\varphi_{yes} = \displaystyle \bigvee_{i,j\leq n^k} x_{i,j,q_{yes}}] - that is, the machine enters an accepting state at some time. The size of $math[\varphi_{yes}] is $math[O(n^{2k})]. $math[\varphi_{move}] must express the execution of **one transition** between each step (row) ''i'' and ''i+1'' of the matrix. We illustrate $math[\varphi_{move}] via an example. Suppose $math[\delta(q_1,a) = \{(q_2,b,R)\}] and consider that the head is in position ''j'' after ''i'' transitions have been performed, as shown in the following ''2 x 3'' chuck of our matrix: ^ q1 ^ a ^ a ^ | b | q2 | a | We express a valid transition as: $math[\displaystyle (x_{i+1,j,b} \wedge x_{i+1,j+1,q_2}) \vee (x_{i+1,j,c} \wedge x_{i+1,j-1,q_3})]