You are on page 1of 30

Theory of Computation

Lecture 28
Sarmad Abbasi
Virtual University

December 7, 2007

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

1 / 30

The Cook-Levin Theorem

Last time we were discussing the proof of the Cook-Levin Theorem.


Here is the basic outline of the proof.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

2 / 30

The Cook-Levin Theorem

We want to show that if L NP then


L p SAT .
The idea is that if L is in NP then
L is accepted by an NTM M in polynomial time.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

3 / 30

The Cook-Levin Theorem

What do we want:
We want a to show that there is a function f that we can compute in
polynomial time such that
1

x L then f (x) SAT .

We do this by creating a formula x such that:


1

x is satisfiable if and only if M accepts x.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

4 / 30

The Cook-Levin Theorem


What do we want:
We want a to show that there is a function f that we can compute in
polynomial time such that
1

x L then f (x) SAT .

We do this by creating a formula x such that:


1

x is satisfiable if and only if M accepts x.

if M accepts x then we can make a tableau that shows an


accepting computation of M on x.

This tableau will be an nk nk tableau since M runs in polynomial


time.
The formula x is going to be satisfiable if and only if such a
tableau exists.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

5 / 30

The Cook-Levin Theorem

The main idea is to make several variables:


xi,j,s
if the tableau contains a symbol s in the (i, j) place then we will set the
variable xi,j,s = ture.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

6 / 30

The Cook-Levin Theorem

The tableau has several properties:


1

Each entry of the tableau has exactly one entry.

The first computation is the initial computation of M on x.

The tablature corresponds to an accepting computation.

Each configuration row is obtained from the previous row through


the yields relation.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

7 / 30

The Cook-Levin Theorem

We try to express these properties in propositional logic.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

8 / 30

The Cook-Levin Theorem


1

Each entry of the tableau has exactly one entry. we used the
formula cell to express this.

The first computation is the initial computation of M on x. We


used the formula start to express this.

The tableau corresponds to an accepting computation. We used


the formula accept to express this.

Each configuration row is obtained from the previous row through


the yields relation. We will use the formula
move
to express this.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

9 / 30

The Cook-Levin Theorem

In the last lecture we looked closely at


cell
start
and
accept
In this lecture we want to concentrate on
move .

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

10 / 30

The Cook-Levin Theorem

Next was the concept of legal windows. We said a 2 3 window is


legal if it can appear in a possible computation of the machine M.
As an example, let us take a machine with
(q0 , a) = {(q2 , b, R)}
and
(q0 , b) = {(q1 , a, R), (q2 , c, L)}.
Let us look at some legal windows now:

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

11 / 30

The Cook-Levin Theorem

# a b
# a b
b a b
b a b
q0 a b
b q2 b
q0 b b
b c b
These are legal windows.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

12 / 30

The Cook-Levin Theorem


Let us look at some illegal windows.
# a b
# a #
b a b
b c b
q0 a b
b q1 b
q0 b b
c q2 b
These are illegal windows.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

13 / 30

The Cook-Levin Theorem

A very critical observations are the following:


1

By observing the transition function of M we can compute the set


of all legal windows.

Note that this has to be done once in for all. It need not be
recomputed for each x. (Although it is not hard to compute also
but we do not need to do that!)

If we have a tableau that has the first configuration which is the


initial configuration and each window is legal then tableau
corresponds to a computation of M on x

Let us discuss these points one by one.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

14 / 30

The Cook-Levin Theorem


By observing the transition function of M we can compute the set of all
legal windows.
This is not very hard to see. In your homework, I have given you a
NTM and asked you to compute all the possible legal windows. Let us
nevertheless outline a simple (but time consuming method).
1

Note that these are windows of size 2 3. Thus they have 6


entries. The table can let us say have r possible entries. Thus the
total number of possible windows is r 6 . Hence there are only a
finite number of them.

Thus we can go through every possible window and figure out if it


is legal or not.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

15 / 30

The Cook-Levin Theorem

For each possible window W

If W is legal output W .

The above algorithm will compute all legal windows. Provided we can
test if a window is legal. That is not difficult to do!

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

16 / 30

The Cook-Levin Theorem

For each possible window W

If W is legal output W .

The above algorithm will compute all legal windows. Provided we can
test if a window is legal. That is not difficult to do!
Let the output of this algorithm be L the set of all legal windows.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

17 / 30

The Cook-Levin Theorem

Note that this has to be done once in for all. It need not be recomputed
for each x. (Although it is not hard to compute also but we do not need
to do that!).
Note that the legality of the window does not depend on the input to
the machine M. It only depends on the transition table of M. Thus the
set of all legal windows can be computed once in for all.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

18 / 30

The Cook-Levin Theorem


Lastly, note that if all windows in a tableau are legal then it
corresponds to a computation of M. In fact, the definition of a legal
window is designed to enforce this. This is because a 2 3 legal
window ensure that the middle element in the next configuration
comes from a legal move of the NTM M.
Let us look at the following figure:

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

19 / 30

The Cook-Levin Theorem

For this we need to do two exercises.


Let C and D be two configurations such that
C `M D
Write C and D as two rows in the tableau and prove that all the 2 3
windows are legal in that part of the tableau.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

20 / 30

The Cook-Levin Theorem

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

21 / 30

The Cook-Levin Theorem

Let C and D be two configurations such that


C
does not yield
D
Write C and D as two rows in the tableau and prove that at least one of
the 2 3 windows are is illegal in that part of the tableau. This is
because you will have to cheat somewhere. And at that point you will
have to create an illegal window.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

22 / 30

The Cook-Levin Theorem

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

23 / 30

The Cook-Levin Theorem

Now we are in a position to start constructing cell . Let us go one step


at a time. Let us take all the legal windows.
L = {W1 , W2 , . . . , Wt }. What we want to say is that the first window is
legal. We can say that by saying....
1

The first window is W1 or

The first window is W2 or

The first window is W3 or

and so on....

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

24 / 30

The Cook-Levin Theorem


Let us do this by an example. Let us say that W1 is
# q0 a
# b q2
Then we can simply write
x1,1,# x1,2,q0 x1,3,a x2,1,# x2,2,b x2,3,q2
Similarly if I want to say that the (i, j)-th window is equal to W1 I can
write
xi,j,# xi,j+1,q0 xi,j+2,a xi+1,j,# xi+1,j+1,b xi+1,j+2,q2

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

25 / 30

The Cook-Levin Theorem

Let us denote i,j,l to be the formula that says that the (i, j)-th window
is equal to Wl . Then to say that the (i, j)-th window is legal all I have to
do is to say
t
_

(i, j, l)

l=1

This says that the (i, j)-th window is either W1 or W2 or and so on.
Which is equivalent to saying that the (i, j) window is legal.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

26 / 30

The Cook-Levin Theorem

So what would the following formula express:


t
^_

(i, j, l)

i,j l=1

This says that all windows are legal.


This is our move .

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

27 / 30

The Cook-Levin Theorem

Now, let us look at our grand boolean formula that we have created.
x = cell start accept move

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

28 / 30

The Cook-Levin Theorem


This formula is satisfiable if and only if all four components are
satisfiable. Let us look at them one by one:
1
cell is satisfiable if and only if we have an assignment of the
variables that corresponds to putting one symbol in each entry of
the tableau. Thus the tableau is properly filled.
2
cell is satisfied if and only if the variable assignment corresponds
to filing the first row with the initial configuration of M on x.
3
accept is satisfied if the variable assignment corresponds to
having the accept sate somewhere in the tableau. That means the
tableau encodes an accepting computation.
4
Lastly, and most importantly move is satisfied if the assignment
corresponds to filling rows in such a way that they follow from legal
moves of the machine.
In summary
x
is satisfiable if and only if there exists a tableau with these properties.
Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

29 / 30

The Cook-Levin Theorem

To finish the proof of Cook-Levin Theorem let us consider the following


algorithm:
1

On input x

Compute x and output it.

This algorithm computes a function in polynomial time. Our discussion


shows that this is a polynomial time reducibility from L to SAT . This
shows that
L p SAT .
The proof of Cook-Levin Theorem is therefore complete.

Sarmad Abbasi (Virtual University)

Theory of Computation

December 7, 2007

30 / 30

You might also like