Download - Lecture 41 - Cook%27s Theorem
-
7/28/2019 Lecture 41 - Cook%27s Theorem
1/46
Cooks
Theorem
Robb T.Koether
HomeworkReview
Cooks
TheoremThe Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT is
NP-Complete
Assignment
Cooks TheoremLecture 41
Section 7.4
Robb T. Koether
Hampden-Sydney College
Fri, Dec 5, 2008
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
2/46
Cooks
Theorem
Robb T.Koether
HomeworkReview
Cooks
TheoremThe Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT is
NP-Complete
Assignment
Outline
1 Homework Review
2 Cooks Theorem
The Computation Table
ExampleThe Function cellThe Function startThe Function acceptThe Function move
3 3SAT is NP-Complete
4 Assignment
http://goforward/http://find/http://goback/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
3/46
-
7/28/2019 Lecture 41 - Cook%27s Theorem
4/46
Cooks
Theorem
Robb T.Koether
HomeworkReview
Cooks
TheoremThe Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
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 isn
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.
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
5/46
Cooks
Theorem
Robb T.Koether
HomeworkReview
Cooks
TheoremThe Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
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.
http://find/http://goback/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
6/46
Cooks
Theorem
Robb T.Koether
HomeworkReview
Cooks
TheoremThe Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
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.
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
7/46
Cooks
Theorem
Robb T.Koether
HomeworkReview
Cooks
TheoremThe Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
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 nk.
When M is run, it can access at most the first nk cells.
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
8/46
Cooks
Theorem
Robb T.Koether
HomeworkReview
Cooks
TheoremThe Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT is
NP-Complete
Assignment
Proof of Cooks Theorem
Proof ().
Represent the execution of M by an nk nk array.
Each row contains a configuration of M.
The first row is the initial configuration, with input w.
The sequence of rows represents a computation of M
that reaches a halting state.
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
9/46
Cooks
Theorem
Robb T.Koether
HomeworkReview
Cooks
TheoremThe Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT is
NP-Complete
Assignment
Proof of Cooks Theorem
Proof ().
We will place the symbol # in the first 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, orA state q, orA blank .
http://find/http://goback/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
10/46
Cooks
Theorem
Robb T.Koether
HomeworkReview
Cooks
TheoremThe Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
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 satisfiable if and only if the table represents a valid
accepting computation of M.
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
11/46
Cooks
Theorem
Robb T.Koether
HomeworkReview
Cooks
TheoremThe ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
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 configuration.accept = true One of the rows is a valid accept
configuration.move = true Each row yields the configuration in thenext row.
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
12/46
Cooks
TheoremRobb T.Koether
HomeworkReview
Cooks
TheoremThe ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
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.
http://find/http://goback/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
13/46
Cooks
TheoremRobb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT is
NP-Complete
Assignment
Proof of Cooks Theorem
Proof ().
For each row number i from 1 to nk
, and for eachcolumn number j from 1 to nk, and for each symbol s in
C, let xi,j,s be a Boolean variable that is true if cell (i, j)contains the symbol s.
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
14/46
Cooks
TheoremRobb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT is
NP-Complete
Assignment
Example
Consider the Turing machine below processing theinput 0110.
0 1, R
0 1, R
++, R
1 0, R 1 0, R
p
sr
q
(accept) (reject)
++, R
http://find/http://goback/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
15/46
Cooks
TheoremRobb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
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 #
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
16/46
Cooks
TheoremRobb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT is
NP-Complete
Assignment
Example
For example,
x1,1,# = truex1,1,0 = falsex1,2,p = truex1,3,0 = true
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
17/46
Cooks
TheoremRobb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT is
NP-Complete
Assignment
The Expression cell
Proof ().
The expression cell consists of two parts.
The first part is true if and only if cell (i, j) contains atleastone symbol.
sC
xi,j,s
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
18/46
Cooks
TheoremRobb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT is
NP-Complete
Assignment
The Expression cell
Proof ().
The second part is true if and only if cell (i, j) contains
at mostone symbol.sCtC
(xi,j,s xi,j,t)
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
19/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT is
NP-Complete
Assignment
The Expression cell
Proof ().
Therefore,
cell =
1ink
1jnk
sC
xi,j,s
sCtC
(xi,j,s xi,j,t)
.
http://find/http://goback/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
20/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT is
NP-CompleteAssignment
The Expression start
Proof ().
The expression start is easy because we know what
the start configuration looks like.
#q0w1w2 . . . wn . . . #
We simply verify that the cells contain those symbols.
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
21/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT is
NP-CompleteAssignment
The Expression start
Proof ().
Therefore,
start = x1,1,# x1,2,q0 x1,3,w1 x1,4,w2
x1,n+2,wn x1,n+3, x1,nk1, x1,nk,#.
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
22/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT is
NP-CompleteAssignment
The Expression accept
Proof ().
The expression accept is also very simple.All we need to do is to guarantee that qaccept occurs
somewhere in the table.
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
23/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT is
NP-CompleteAssignment
The Expression accept
Proof ().
Therefore,accept =
1ink
1jnk
xi,j,qaccept .
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
24/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-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 fullnk nk table represents a valid computation if andonly ifcell andstart are true and every2 3 window isvalid.
E l
http://find/http://goback/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
25/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-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 #
E l
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
26/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-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 #
E l
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
27/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-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 #
http://find/http://goback/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
28/46
Example
-
7/28/2019 Lecture 41 - Cook%27s Theorem
29/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-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 #
Example
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
30/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-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 #
The Expression
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
31/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-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 first cell, we
remain in the first cell.
The Expression
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
32/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The Computation
Table
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-Complete
Assignment
The Expression move
Proof ().
Valid 2 3 windows for writing x, moving left, andchanging states from p to q (a, b, c are tape symbols).
p a bc x b
a p bq a x
a b pa 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
The Expression
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
33/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-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 C6 representing valid2 3 windows.
Then S includes (p, a, b, c, x, b), (a,p,b,q,a,x), etc., forall a,b,c,x and for all p, q Q.
The Expression
http://find/http://goback/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
34/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-Complete
Assignment
The Expression move
Proof ().
Then the expression
xi,j1,x1 xi,j,x2 xi,j+1,x3 xi+1,j1,x4
xi+1,j,x5 xi+1,j+1,x6
is true if and only if (x1, x2, x3, x4, x5, x6) S.
The Expression move
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
35/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-Complete
Assignment
The Expression move
Proof ().
So the expression
windowi,j =xS
(xi,j1,x1 xi,j,x2 xi,j+1,x3
xi+1,j1,x4 xi+1,j,x5 xi+1,j+1,x6)
is true if and only if window (i, j) is valid.
The Expression move
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
36/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-Complete
Assignment
The Expression move
Proof ().
Then the expression
move =
1i
-
7/28/2019 Lecture 41 - Cook%27s Theorem
37/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-Complete
Assignment
Proof of Cook s Theorem
Proof ().
Then the Boolean expression
cell start accept move
is satisfiable if and only if w is accepted by M.
Therefore, SAT is NP-complete.
Building from Cooks Theorem
http://find/http://goback/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
38/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-Complete
Assignment
Building from Cook s Theorem
Now we may show that other problems areNP-complete by showing that SAT is polynomial-time
reducible to them.
3SAT is NP-Complete
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
39/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-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.
3SAT is NP-Complete
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
40/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-Complete
Assignment
3S s Co p ete
Proof.
Rewrite the each clause
x1 x2 x3 xn
as
(x1 x2 y1) (y1 x3 y2) (yn3 xn1 xn).
3SAT is NP-Complete
http://goforward/http://find/http://goback/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
41/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-Complete
Assignment
p
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.
3SAT is NP-Complete
http://goforward/http://find/http://goback/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
42/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-Complete
Assignment
p
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).
3SAT is NP-Complete
http://goforward/http://find/http://goback/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
43/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-Complete
Assignment
p
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).
3SAT is NP-Complete
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
44/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-Complete
Assignment
p
Proof.
Therefore, the expression
cell start accept move
can be rewritten in 3-conjunctive normal form.
Therefore, 3SAT is NP-complete.
Other NP-Complete Problems
http://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
45/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-Complete
Assignment
There are many other NP-complete problems.
See NP-Complete
See List of NP-Complete Problems
Assignment
http://en.wikipedia.org/wiki/NP-completehttp://en.wikipedia.org/wiki/List_of_NP-complete_problemshttp://en.wikipedia.org/wiki/List_of_NP-complete_problemshttp://en.wikipedia.org/wiki/NP-completehttp://find/ -
7/28/2019 Lecture 41 - Cook%27s Theorem
46/46
CooksTheorem
Robb T.Koether
HomeworkReview
CooksTheorem
The ComputationTable
Example
The Functioncell
The Functionstart
The Functionaccept
The Functionmove
3SAT isNP-Complete
Assignment
Homework
Read Section 7.4, pages 276 - 283.
Problems 26, 27, 29, 30, 31, 36, 37, 38, page 297 -
298.
http://find/