0% found this document useful (0 votes)
135 views46 pages

Lecture 41 - Cook's Theorem

This document discusses Cook's theorem, which states that SAT is NP-complete if and only if P=NP. It begins with an outline of topics to be covered, including a homework review, explanation of Cook's theorem, examples, and an assignment. It then reviews a homework problem showing that the TRIANGLE problem is in P. Most of the document provides a detailed proof of Cook's theorem, representing a non-deterministic Turing machine computation as a Boolean formula that is satisfiable if and only if the machine accepts. It constructs sub-formulas to check properties of the computation table representation.

Uploaded by

Glenn Gibbs
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
135 views46 pages

Lecture 41 - Cook's Theorem

This document discusses Cook's theorem, which states that SAT is NP-complete if and only if P=NP. It begins with an outline of topics to be covered, including a homework review, explanation of Cook's theorem, examples, and an assignment. It then reviews a homework problem showing that the TRIANGLE problem is in P. Most of the document provides a detailed proof of Cook's theorem, representing a non-deterministic Turing machine computation as a Boolean formula that is satisfiable if and only if the machine accepts. It constructs sub-formulas to check properties of the computation table representation.

Uploaded by

Glenn Gibbs
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Cooks

Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Cooks Theorem
Lecture 41
Section 7.4
Robb T. Koether
Hampden-Sydney College
Fri, Dec 5, 2008
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Outline
1
Homework Review
2
Cooks Theorem
The Computation Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3
3SAT is NP-Complete
4
Assignment
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Homework Review
Exercise 18, page 295.
A triangle in an undirected graph is a 3-clique. show that
TRIANGLE P, where
TRIANGLE = {G | G contains a triangle}.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Homework Review
Solution
Let G be a graph and let n be the number of vertices in
G.
The number of ways to choose three vertices is
_
n
3
_
=
n(n 1)(n 2)
6
,
which is a polynomial function of n.
At worst, we would check every possible set of three
vertices until we either found a triangle or exhausted all
possibilities.
Thus, TRIANGLE P.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Cooks Theorem
Theorem (Cooks Theorem)
SAT P if and only if P = NP.
Proof idea.
First show that SAT is in NP.
Then show that every problem in NP is polynomial-time
reducible to SAT.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Proof of Cooks Theorem
Proof ().
It is easy to see that SAT is in NP.
Simply nondeterministically choose Boolean values for
each variable.
Then verify that the expression is true.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Proof of Cooks Theorem
Proof ().
Let A be a problem in NP.
Then there is a nondeterministic Turing machine M that
decides A in polynomial time.
Let the run time of M be at most n
k
.
When M is run, it can access at most the rst n
k
cells.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Proof of Cooks Theorem
Proof ().
Represent the execution of M by an n
k
n
k
array.
Each row contains a conguration of M.
The rst row is the initial conguration, with input w.
The sequence of rows represents a computation of M
that reaches a halting state.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Proof of Cooks Theorem
Proof ().
We will place the symbol # in the rst and last cells of
each row, to help identify the ends of the tape.
In each row, each cell between the #s will contain
A tape symbol x, or
A state q, or
A blank .
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Proof of Cooks Theorem
Proof ().
That is, each cell contains one symbol from the set
C = Q {#}.
We will create a Boolean expression from the table that
is satisable if and only if the table represents a valid
accepting computation of M.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Proof of Cooks Theorem
Proof ().
Our Boolean expression will be of the form
=
cell

start

accept

move
,
where

cell
= true Every cell contains exactly one symbol.

start
= true Row 1 is a valid start conguration.

accept
= true One of the rows is a valid accept
conguration.

move
= true Each row yields the conguration in the
next row.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Proof of Cooks Theorem
Proof ().
These expressions will all be true if and only if the table
represents a valid computation resulting in acceptance.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Proof of Cooks Theorem
Proof ().
For each row number i from 1 to n
k
, and for each
column number j from 1 to n
k
, and for each symbol s in
C, let x
i,j,s
be a Boolean variable that is true if cell (i, j)
contains the symbol s.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Example
Consider the Turing machine below processing the
input 0110.
0 1, R
0 1, R
+ +, R
1 0, R 1 0, R
p
s r
q
(accept) (reject)
+ +, R
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Example
The computation table.
# p 0 1 1 0 #
# 1 q 1 1 0 #
# 1 0 q 1 0 #
# 1 0 0 q 0 #
# 1 0 0 1 p #
# 1 0 0 1 r #
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Example
For example,
x
1,1,#
= true
x
1,1,0
= false
x
1,2,p
= true
x
1,3,0
= true
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
The Expression
cell
Proof ().
The expression
cell
consists of two parts.
The rst part is true if and only if cell (i, j) contains at
least one symbol.

sC
x
i,j,s
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
The Expression
cell
Proof ().
The second part is true if and only if cell (i, j) contains
at most one symbol.

sC
tC
(x
i,j,s
x
i,j,t
)
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
The Expression
cell
Proof ().
Therefore,

cell
=

1in
k
1jn
k
_

_
_

sC
x
i,j,s
_

_
_
_

sC
tC
(x
i,j,s
x
i,j,t
)
_
_
_
_

_
.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
The Expression
start
Proof ().
The expression
start
is easy because we know what
the start conguration looks like.
#q
0
w
1
w
2
. . . w
n
. . . #
We simply verify that the cells contain those symbols.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
The Expression
start
Proof ().
Therefore,

start
= x
1,1,#
x
1,2,q
0
x
1,3,w
1
x
1,4,w
2

x
1,n+2,w
n
x
1,n+3,
x
1,n
k
1,
x
1,n
k
,#
.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
The Expression
accept
Proof ().
The expression
accept
is also very simple.
All we need to do is to guarantee that q
accept
occurs
somewhere in the table.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
The Expression
accept
Proof ().
Therefore,

accept
=

1in
k
1jn
k
x
i,j,q
accept
.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
The Expression
move
Proof ().
The expression
move
will take a bit more effort.
We will consider 2 3 windows in the table.
Theorem
The full n
k
n
k
table represents a valid computation if and
only if
cell
and
start
are true and every 2 3 window is
valid.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Example
Proof ().
The computation table.
# p 0 1 1 0 #
# 1 q 1 1 0 #
# 1 0 q 1 0 #
# 1 0 0 q 0 #
# 1 0 0 1 p #
# 1 0 0 1 r #
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Example
Proof ().
Window (1, 2)
# p 0 1 1 0 #
# 1 q 1 1 0 #
# 1 0 q 1 0 #
# 1 0 0 q 0 #
# 1 0 0 1 p #
# 1 0 0 1 r #
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Example
Proof ().
Window (1, 3)
# p 0 1 1 0 #
# 1 q 1 1 0 #
# 1 0 q 1 0 #
# 1 0 0 q 0 #
# 1 0 0 1 p #
# 1 0 0 1 r #
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Example
Proof ().
Window (1, 4)
# p 0 1 1 0 #
# 1 q 1 1 0 #
# 1 0 q 1 0 #
# 1 0 0 q 0 #
# 1 0 0 1 p #
# 1 0 0 1 r #
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Example
Proof ().
Window (2, 4)
# p 0 1 1 0 #
# 1 q 1 1 0 #
# 1 0 q 1 0 #
# 1 0 0 q 0 #
# 1 0 0 1 p #
# 1 0 0 1 r #
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Example
Proof ().
Window (3, 4)
# p 0 1 1 0 #
# 1 q 1 1 0 #
# 1 0 q 1 0 #
# 1 0 0 q 0 #
# 1 0 0 1 p #
# 1 0 0 1 r #
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
The Expression
move
Proof ().
For any symbol x and any state q, the legal moves are
Write x, move left, and change state to q.
Write x, move right, and change state to q.
Recall that if we try to move left from the rst cell, we
remain in the rst cell.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
The Expression
move
Proof ().
Valid 2 3 windows for writing x, moving left, and
changing states from p to q (a, b, c are tape symbols).
p a b
c x b
a p b
q a x
a b p
a q b
a b c
a b q
a b c
a b c
# p a
# q x
# a p
# q a
# a b
# a q
# a b
# a b
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
The Expression
move
Proof ().
There is a similar set for a move to the right.
Let S be the set of all sextuples in C
6
representing valid
2 3 windows.
Then S includes (p, a, b, c, x, b), (a, p, b, q, a, x), etc., for
all a, b, c, x and for all p, q Q.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
The Expression
move
Proof ().
Then the expression
x
i,j1,x
1
x
i,j,x
2
x
i,j+1,x
3
x
i+1,j1,x
4

x
i+1,j,x
5
x
i+1,j+1,x
6
is true if and only if (x
1
, x
2
, x
3
, x
4
, x
5
, x
6
) S.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
The Expression
move
Proof ().
So the expression

window
i,j
=

xS
(x
i,j1,x
1
x
i,j,x
2
x
i,j+1,x
3

x
i+1,j1,x
4
x
i+1,j,x
5
x
i+1,j+1,x
6
)
is true if and only if window (i, j) is valid.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
The Expression
move
Proof ().
Then the expression

move
=

1i<n
k
1<j<n
k

window
i,j
is true if and only if every 2 3 window in the table is
valid.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Proof of Cooks Theorem
Proof ().
Then the Boolean expression

cell

start

accept

move
is satisable if and only if w is accepted by M.
Therefore, SAT is NP-complete.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Building from Cooks Theorem
Now we may show that other problems are
NP-complete by showing that SAT is polynomial-time
reducible to them.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
3SAT is NP-Complete
Theorem
3SAT is NP-complete.
Proof.
We need only show that SAT is polynomial-time
reducible to 3SAT.
Any boolean expression may be put into 3-conjunctive
normal form by the following technique.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
3SAT is NP-Complete
Proof.
Rewrite the each clause
x
1
x
2
x
3
x
n
as
(x
1
x
2
y
1
) (y
1
x
3
y
2
) (y
n3
x
n1
x
n
).
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
3SAT is NP-Complete
Proof.
The expressions
cell
,
start
, and
accept
are already in
conjunctive normal form.
Apply the above technique to put them in 3-conjunctive
normal form.
The expression
move
is not in conjunctive normal form.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
3SAT is NP-Complete
Proof.
However, it may be rewritten in conjunctive normal form
by repeatedly applying the distributive laws
x (y z) = (x y) (x z)
and
x (y z) = (x y) (x z).
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
3SAT is NP-Complete
Proof.
For example,
(x y) (z w) = ((x y) z) ((x y) w)
= ((x z) (y z))
((x w) (y w))
= (x z) (y z) (x w)
(y w).
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
3SAT is NP-Complete
Proof.
Therefore, the expression

cell

start

accept

move
can be rewritten in 3-conjunctive normal form.
Therefore, 3SAT is NP-complete.
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Other NP-Complete Problems
There are many other NP-complete problems.
See NP-Complete
See List of NP-Complete Problems
Cooks
Theorem
Robb T.
Koether
Homework
Review
Cooks
Theorem
The Computation
Table
Example
The Function
cell
The Function
start
The Function
accept
The Function
move
3SAT is
NP-Complete
Assignment
Assignment
Homework
Read Section 7.4, pages 276 - 283.
Problems 26, 27, 29, 30, 31, 36, 37, 38, page 297 -
298.

You might also like