Theory of Computation
Lecture 27
Sarmad Abbasi
December 7, 2007
Sarmad Abbasi () Theory of Computation December 7, 2007 1 / 30
Satisfiability
Let us define
SAT = {< φ >: φ is satisfiable}.
It is easy to see that
Theorem
SAT is in NP
We gave an easy verification algorithm. The algorithm takes a formula
φ and assignment τ and checks if τ satisfies φ.
Sarmad Abbasi () Theory of Computation December 7, 2007 2 / 30
Satisfiability
Theorem (Cook-Levin)
SAT is NP-complete.
Sarmad Abbasi () Theory of Computation December 7, 2007 3 / 30
Satisfiability
Theorem (Cook-Levin)
P = NP if and only if SAT ∈ P.
Sarmad Abbasi () Theory of Computation December 7, 2007 4 / 30
Satisfiability
Last time we proved a very special case of the Cook-Levin Theorem.
We showed that
Theorem (Cook-Levin)
3 − Color ≤p SAT
Sarmad Abbasi () Theory of Computation December 7, 2007 5 / 30
Satisfiability
Our goal now is to prove the Cook-Levin Theorem in its complete
general form. What do we have to show?
We want to show that if L ∈ NP then
L ≤p SAT .
Let us start with a language L such that L ∈ NP.
Sarmad Abbasi () Theory of Computation December 7, 2007 6 / 30
Satisfiability
What do we know about L? The only thing we know about L is that it is
accepted by a non-deterministic Turing machine M in non-deterministic
polynomial time.
Sarmad Abbasi () Theory of Computation December 7, 2007 7 / 30
Satisfiability
Let us record these facts.
Let M be a non-deterministic Turing machine that accepts L in time nk .
What do we want to do now?
We want to come up with a reduction. This reduction will take an
instance x and convert it into a formula
φx
such that
x ∈ L if and only if φx is satisfiable.
Sarmad Abbasi () Theory of Computation December 7, 2007 8 / 30
Satisfiability
Note that if x ∈ L then at least one computation branch of M accepts x.
Let us write this computation in a table. The first row of this table
consist of the initial configuration. The second row of this table consist
of the second configuration and so on. How does this table look like?
Sarmad Abbasi () Theory of Computation December 7, 2007 9 / 30
Satisfiability
Let us make some observations first:
1 This table will have at most nk rows. Since the machine accepts in
time nk .
2 The machine will scan only nk tape symbols so we only need to
keep nk columns.
This tableau will be an nk × nk tableau. The tableau is a proof of the
fact that M accepts x. Thus it is a proof of the fact that
x ∈ L.
Sarmad Abbasi () Theory of Computation December 7, 2007 10 / 30
Satisfiability
Let us look at a schematic diagram of this tableau.
Sarmad Abbasi () Theory of Computation December 7, 2007 11 / 30
Satisfiability
Let us look at a schematic diagram of this tableau. If anyone has this
tableau they can confirm that x ∈ L by checking the following.
1 Check if the first configuration is an initial configuration.
2 Check if the last configuration is an accepting configuration.
3 Check the i-th configuration yields the i + 1-st configuration.
Sarmad Abbasi () Theory of Computation December 7, 2007 12 / 30
Satisfiability
Thus x ∈ L if an only if we can make a tableau with the above
properties. Let us think a bit about the tableau:
1 Each cell in the tableau has a symbol from C = Q ∪ Γ ∪ {#}.
Sarmad Abbasi () Theory of Computation December 7, 2007 13 / 30
Satisfiability
Can we make a formula which expresses the fact that each cell has
exactly one symbol from C in it. The tableau is made out of cells let
cell[i, j] denote the i, j-th cell. We will make variables xi,j,s for each cell
where s ∈ C. If cell[i, j] = s then we can set the variable xi,j,s = true.
For example if the i, j-th cell has an a then
xi,j,a = ture.
Sarmad Abbasi () Theory of Computation December 7, 2007 14 / 30
Satisfiability
Let us now look at the following formula:
!
_ ^
xi,j,s ∧ (xi,j,s ∨ xi,j,t )
s∈C s,t∈C,s6=t
The above formula says that the i, j-th cell has exactly one symbol
from C in it. Let us review why this is the case.
Sarmad Abbasi () Theory of Computation December 7, 2007 15 / 30
Satisfiability
!
_ ^
xi,j,s ∧ (xi,j,s ∨ xi,j,t )
s∈C s,t∈C,s6=t
Sarmad Abbasi () Theory of Computation December 7, 2007 16 / 30
Satisfiability
Let us now look at the following formula:
!
^ _ ^
φcell = xi,j,s ∧ (xi,j,s ∨ xi,j,t )
1≤i,j≤nk s∈C s,t∈C,s6=t
The above formula says that the every cell has exactly one symbol
from C in it. Let us review why this is the case.
Sarmad Abbasi () Theory of Computation December 7, 2007 17 / 30
Satisfiability
Let x = x1 x2 . . . xn be an input. How can we say that the first row
corresponds to the initial configuration? This is not that difficult. Let us
consider the formula
φstart = x1,1,# ∧ x1,2,q0 ∧ x1,3,x1 ∧ x1,4,x2 ∧ x1,5,x3 ∧ · · · ∧ x1,n+2,xn
∧x1,n+3, ∧ x1,n+4, · · · x1,nk −1, ∧ x1,nk ,# .
Sarmad Abbasi () Theory of Computation December 7, 2007 18 / 30
Satisfiability
Lets examine this formula closely.
φstart = x1,1,# ∧ x1,2,q0 ∧ x1,3,x1 ∧ x1,4,x2 ∧ x1,5,x3 ∧ · · · ∧ x1,n+2,xn
∧x1,n+3, ∧ x1,n+4, · · · x1,nk −1, ∧ x1,nk ,# .
This formula says that the first row of the tablaue is the initial
configuration of M on the input x = x1 · · · xn .
Sarmad Abbasi () Theory of Computation December 7, 2007 19 / 30
Satisfiability
Lets now look at the following formula:
_
φaccept = xi,j,qaccept .
1≤i,j,≤nk
This formula says that the accepting state appears in the tableau.
Sarmad Abbasi () Theory of Computation December 7, 2007 20 / 30
Satisfiability
Lastly, we want a formula
φmove
this formula will say that each of the row comes from the previous row
of the table by a legal move of the Turing machine M.
Sarmad Abbasi () Theory of Computation December 7, 2007 21 / 30
Satisfiability
This is the most important part of the construction and the proof. How
do we say that a move is legal. For this we have to go back to the
tableau and come up with a concept of a legal window.
Sarmad Abbasi () Theory of Computation December 7, 2007 22 / 30
Satisfiability
Consider a window of size 2 × 3 in the tableau. A window is called
legal if it does not violate the actions specified by M’s transition
function. Let us look at some examples of legal windows. Suppose we
have the following moves in the machine M.
δ(q1 , a) = {(q1 , b, R)}
δ(q1 , b) = {q2 , c, L), (q2 , a, R)}
Then the following examples are of legal windows.
Sarmad Abbasi () Theory of Computation December 7, 2007 23 / 30
Satisfiability
a q1 b
q2 a c
This is because the machine reading b can move left and write a
c.
2
a q1 b
a a q2
This is because in q1 machine reading a b can replace it with an a
and move right.
Sarmad Abbasi () Theory of Computation December 7, 2007 24 / 30
Satisfiability
a a q1
a a b
The only information we have is that the machine is in q1 and
reading something. So, it can move right.
2
a b a
a b a
The head maybe too far to make a change in this part of the tape.
Sarmad Abbasi () Theory of Computation December 7, 2007 25 / 30
Satisfiability
a b a
a b q2
The head may have moved to the left.
2
b b b
c b b
The head may be on the left and may have changed the b to a c
and moved to the left.
Sarmad Abbasi () Theory of Computation December 7, 2007 26 / 30
Satisfiability
Now let us look at some illegal windows to get some more intuition.
Sarmad Abbasi () Theory of Computation December 7, 2007 27 / 30
Satisfiability
a b a
a a a
A symbol cannot change unless the head is near it.
2
a q1 b
q1 a a
This move is not allowed by the transition function of M.
Sarmad Abbasi () Theory of Computation December 7, 2007 28 / 30
Satisfiability
b q1 b
q2 a q2
Wrong way to have a configuration. The head cannot become two
heads!
Sarmad Abbasi () Theory of Computation December 7, 2007 29 / 30
Satisfiability
We now want to be able to do two things.
1 First we will show that if each window in a tableau is legal then
every configuration legally follows from the previous one in the
table.
2 Then we will again come up with a formula that says that each
window is legal.
In the end we will combine this formula with φcell , φstart and φaccept to
get a formula.
Sarmad Abbasi () Theory of Computation December 7, 2007 30 / 30