Bulatov - Duke Computer Science

Computability and Complexity
14-1
Cook’s Theorem
Computability and Complexity
Andrei Bulatov
Computability and Complexity
Cook – Levin Theorem
Definition
A language L is said to be NP-complete if L  NP and, for
any A  NP, A  L
Theorem (Cook – Levin)
Satisfiability is NP-complete
14-2
Computability and Complexity
Proof (Main Idea)
Let A be a language from NP
Then there is a polynomial time nondeterministic Turing Machine NT
For every input x for NT, we build a propositional formula  x
encoding the computation NT(x) such that satisfying assignments
to  x correspond exactly to paths in NT(x)
If  x is short enough and can be constructed in polynomial time,
we get the required polynomial time reduction
14-3
Computability and Complexity
Assumptions about NT
Assume that NT uses:
• h+1 symbols  0 ,, h (where  0 is the blank symbol)
• k+1 states q0 ,, qk (where q1 is the accepting state)
• l instructions r1 ,, rl — distinct possible transitions
Assume that every path in NT(x) has length | x |a
(We can extend every shorter path assuming that no further action
is taken.
We can cut longer paths, because they make no difference whether
x is going to be accepted or not)
Assume that the tape head never moves to the left from the leftmost
symbol of the input
14-4
Computability and Complexity
Variables
We use Boolean variables to specify exactly the possible configurations
of the machine at each time t  t* | x |a :
•
Psi,t is true if and only if s-th cell contains symbol  i at time t
(there are ( h  1) | x |a  | x |a of them)
•
Qti is true if and only if NT in state qi at time t
(there are ( k  1) | x |a of them)
•
S s ,t is true if and only if tape head on s-th cell at time t
(there are | x |a  | x |a of them)
•
Rti is true if and only if the machine implements instruction ri
at time t
(there are l  | x |a of them)
14-5
Computability and Complexity
14-6
Formula
Now we write the formula
x  A  B C  D  E  F G  H  J  K
• A says each cell at each time contains exactly one symbol
As ,t  ( Ps0,t  Ps1,t    Psh,t ) 

0i  j h
( Psi,t  Ps ,jt )
(Remember that ( X  Y )  (X  Y ) )
As  As ,1  As , 2    As ,t*
A  A1  A2    At*
( h  1)h 
(there are 
 1 | x |a  | x |a clauses in A)
 2

Computability and Complexity
14-7
• B says the tape head scans exactly one cell at each time
Bt  ( S1,t  S 2,t    S t*,t ) 

1i  j t*
( S i,t  S j ,t )
B  B1  B2    Bt*
• C says that NT is in exactly one state
• D says that NT implements exactly one instruction at each step
• E says that at time 1, the input x is on the first n cells of the tape,
the head is at position 1, and the state is q1
If
x   s1 s2  sn then
E  Q10  S1,1 
P
1i n
si
i ,1

P
n 1i t*
0
i ,1
Computability and Complexity
Define F, G, H and J as follows for each instruction
ru :  ( qi ,  j )  ( qi ' ,  j ' , m)
• F says that ru is a valid transition
 ((S
1 s ,t t*
s ,t
 Rtu )  (Qti  Ps ,jt ))
or equivalently in CNF
 (S
1 s ,t t*
s ,t
 Rtu  Qti )  (S s ,t  Rtu  Ps ,jt )
• G specifies the effect on the state
Rtu  Qti' 1
14-8
Computability and Complexity
• H specifies that the correct symbol is written
( Rtu  S s ,t )  Ps ,jt'1
• J specifies that the correct movement is made
( Rtu  S s ,t )  S s d ( m ),t 1
where d(L) = –1, d(R) = 1, d(S) = 0
• Finally, K says that the accepting state q1 is entered
K  Q11  Q12    Qt1*
14-9
Computability and Complexity
Conclusions
• We can construct formula  x in polynomial time
(Note that the construction is only possible “in principle”, since
the a will not necessarily be known)
• If formula  x is satisfiable then the values of the variables specify
an accepting computation for x
• Conversely, if there is an accepting computation for x, then the
corresponding values of the variables will satisfy the formula  x
• Hence,
• QED
x  L   x  LSatisfiabi lity
14-10