http://www.cs.tau.ac.il/~safra/Complexity/Cook.ppt

Download Report

Transcript http://www.cs.tau.ac.il/~safra/Complexity/Cook.ppt

C
B
A
Our First NP-Complete
Problem
The Cook-Levin theorem
Complexity
©D.Moshkovitz
1

Introduction
• Objectives:
– To present the first NP-Complete
problem
• Overview:
– SAT - definition and examples
– The Cook-Levin theorem
– What next?
Complexity
©D.Moshkovitz
2
SAT
• Instance: A Boolean formula.
• Problem: To decide if the formula is satisfiable.
A satisfiable Boolean formula:
((x
F1  x
T2   x
T3 )   x
F1 )  (x
T3  x
T2 )
An unsatisfiable Boolean formula:
x1  x1
Complexity
©D.Moshkovitz
3
To Which Time Complexity Class
Does SAT Clearly Belong?
SAT
NP
Complexity
©D.Moshkovitz
P
Co-NP
4
SAT is in NP:
Non-Deterministic Algorithm
• Guess an assignment to the variables.
• Check the assignment.
((x
F1  x
T2   x
T3 )   x
F1 )  (x
T3  x
T2 )
Complexity
©D.Moshkovitz
x1
F
x2
T
x3
T

5
SIP 254-259
The Cook-Levin Theorem:
SAT is NP-Complete
Proof Idea: For any NP machine M and any input
string w, we construct a Boolean formula M,w
which is satisfiable iff M accepts w.
...
Complexity
©D.Moshkovitz
#
1
1
#
1
...
 M ,w
6
Representing a Computation
by a Configurations Table
nk
#
upper bound on
the running time
nk
.
.
.
#
Complexity
©D.Moshkovitz
q0
w1
...
wn _
#
the content of the (relevant#
part of the) tape
and the position of the head
indicates tape bounds
#
7
Tableau: Example
• TM:
– Q={q0,qaccept,qreject}
– ={1}
– ={1,_}
– (q0,1)={(q0,_,R)}
– (q0,_)={(qaccept,L)}
• tableau (input 11)
Q: what does this
machine compute?
Complexity
©D.Moshkovitz
8
The Variables of the Formula
stands for: “Is s the
content of cell (i,j)?”
xi, j, s
#
position in the
tableau (1i,jnk)
.
.
.
#
Complexity
©D.Moshkovitz
...
symbol (sQ{#})
#
#
#
9
The Formula 
M,w = cell  start  move  accept
cell content
consistency
input consistency
Complexity
©D.Moshkovitz
machine accepts
transition legal
10
Ensuring Unique Cell Content
φcell

 

    xi,j,s     (xi,j,s  xi,j,t ) 
  s tC

1i,jnk  sC
The (i,j) cell
must contain
some symbol
It shouldn’t contain
different symbols.
Note: the length of this formula is polynomial in n.
Complexity
©D.Moshkovitz
11
Ensuring Initial Configuration
Corresponds to Input
Observe: we can explicitly state the desired
configuration in the first step. Assuming
the input string is w1w2...wn,
φstart  x1,1,#  x1,2,q0  x1,3,w1  ...  x1,n3,_  ...  x1,nk 1,_  x1,nk ,#
Complexity
©D.Moshkovitz
12
Ensuring the Computation
Accepts
The accepting state is visited during
the computation.
φaccept 
Complexity
©D.Moshkovitz

1i,jn k
xi,j,qaccept
13
Ensuring Every Transition is
Legal
Local: only need
to examine
23 “windows”
#
...
#
#
.
.
.
#
Complexity
©D.Moshkovitz
#
14
Which Windows are Legal in
the Following Example?
• TM:
– Q={q0,qaccept,qreject}
– ={1}
– ={1,_}
– (q0,1)={(q0,_,R)}
– (q0,_)={(qaccept,L)}
Complexity
©D.Moshkovitz






15
Ensuring Every Transition is
Legal
φmove 

1i , j  n k

 xi1,j,a1  ...  xi1,j1,a6
a1 ,..., a6

for any a1,...,a6
s.t. this is a
legal window
a1 a2 a3
a4 a5 a6
Complexity
©D.Moshkovitz
16
The Bottom Line
M,w = cell  start  move  accept
, which is of size polynomial in n - Check! - is
satisfiable iff the TM accepts the input
string.
Complexity
©D.Moshkovitz
17
Conclusion: SAT is NPComplete
For any language A in NP,
can be reduced to...
testing
membership in A
Complexity
©D.Moshkovitz
satisfiability
problem
18
Revisiting the Map
SAT
NPC
NP
Complexity
©D.Moshkovitz
P
Co-NP
19
Looking Forward
From now on, in order to show some NP problem
is NP-Complete, we merely need to reduce
SAT to it.
any NP
problem
We’ve already
shown this
Complexity
©D.Moshkovitz
can be reduced to...
SAT
will imply the new
problem is in NPC
can be reduced to...
new NP
problem
20
... and Beyond!
Moreover, every NP-Complete problem we
discover, provides us with a new way for
showing problems to be NP-Complete.
any NP
problem
Complexity
©D.Moshkovitz
can be reduced to...
Known
NP-hard
problem
can be reduced to...
new NP
problem
21
Summary
• We’ve proved SAT is NP-Complete.
• We’ve also described a general
method for showing other problems
are NP-Complete too.

Complexity
©D.Moshkovitz
22