Beruflich Dokumente
Kultur Dokumente
| f (w ) | O (| w | ) k
w A f ( w) B
Proof:
Let M be the machine that decides B
in polynomial time
Machine M to decide A in polynomial time:
On input string w : 1. Compute f (w)
2. Run M on input f (w)
3. If f (w ) B acccept w
Fall 2005 Costas Busch - RPI 5
Example of a polynomial-time reduction:
clause
Each clause has three literals
Language:
3CNF-SAT ={ w : w is a satisfiable
3CNF formula}
Language:
CLIQUE = { G, k : graph G
contains a k-clique}
Fall 2005 Costas Busch - RPI 8
Theorem: 3CNF-SAT is polynomial time
reducible to CLIQUE
x1 x1
Clause 1 x2 x2
x4 Clause 4 x3
x2 x3 x4
x1 x2 x4
x1 x1
x2 x2
x4 x3
x2 x3 x4
x1 x2 x4
x1 x1
x2 x2
x4 x3
x2 x3 x4
Resulting Graph
Fall 2005 Costas Busch - RPI 12
( x 1 x 2 x 4 ) (x 1 x 2 x 4 ) ( x 1 x 2 x 3 ) ( x 2 x 3 x 4 ) 1
x1 1
x2 0 x1 x2 x4
x3 0
x1 x1
x4 1
x2 x2
x4 x3
x2 x3 x4
NP
NP-complete
• L is in NP, and
• Every language in NP
is reduced to L in polynomial time
If a NP-complete language
is proven to be in P then:
P NP
NP
NP-complete
NP
P
? NP-complete
Proof:
Part1: SAT is in NP
(we have proven this in previous class)
Part2: reduce all NP languages
to the SAT problem
in polynomial time
Fall 2005 Costas Busch - RPI 19
Take an arbitrary language L NP
of M on string w qi qj
depth
| w | n
n k
…
…
… accept
…
reject accept
(deepest leaf)
reject
Fall 2005 Costas Busch - RPI 21
Consider q0
an accepting qi qj
computation
depth
n k
…
…
… accept
…
reject accept
(deepest leaf)
reject
Fall 2005 Costas Busch - RPI 22
Computation path Sequence of
q0 Configurations
qi
initial state
qj
1: q0 1 2 n
2: 1 qi 2 n
…
qm
nk x : 1 l qa l1 n k
qa
accept state
accept
w 1 2 n
Fall 2005 Costas Busch - RPI 23
n
Machine M Tape
w
n k
n k
2n k
Accept configuration
x: # 1 2 3 qa l1 nk #
indentical rows
nk : # 1 2 3 qa l1 nk #
nk nk
2n 3k
Fall 2005 Costas Busch - RPI 25
Tableau Alphabet
Define variable xi , j ,s
cell
xi , j ,s xi , j ,s xi , j ,t
all i , j s C s ,t C
s t
cell
xi , j ,s xi , j ,s xi , j ,t
all i , j s C s ,t C
s t
2
( 2n 3)k ( |C | | C |2 )
O (n 2k
)
2n 3 O (n )
k k
accept xi , j ,q
all i , j
all q F
Accepting states
accept xi , j ,q
all i , j
all q F
(2n 3) O (n
k 2 2k
)
Window
a q1 b
q2 a c
a q1 b a q1 b
a b, R q2 a c a a q2
b c, L
q1 q2 a a q1 a b a
a a b a b q2
b a,R
a b a a q1 b
a b, R a a a q1 a a
q1 b c, L q2 b q1 b
q2 b q2
b a,R
Formula:
xi , j ,a xi , j 1,q1 xi , j ,b
xi 1, j ,q2 xi 1, j 1,a xi 1, j 2,c
6 | C |6 (2n k 3)2 O (n 2k )
Fall 2005 Costas Busch - RPI 42
Size of (M ,w ) :
O (n 2k ) O (n k ) O (n 2k
) O (n 2k
)
O (n 2k
)
it can also be constructed in time O (n 2k )
polynomial in n
Fall 2005 Costas Busch - RPI 43
(M ,w ) cell start accept move
we have that:
w L (M ,w ) is satisfiable
END OF PROOF
Fall 2005 Costas Busch - RPI 45
Observation 1:
The (M ,w ) formula can be converted
to CNF (conjunctive normal form) formula
in polynomial time
Already CNF
NOT CNF
But can be converted to CNF
using distributive laws
Fall 2005 Costas Busch - RPI 46
Distributive Laws:
P (Q R ) (P Q ) (P R )
P (Q R ) (P Q ) (P R )
a1 a2 al
conver
t
a1 a2 z1 (z1 a3 z 2 ) (z 2 a4 z 3 ) (zl 3 al 1 zl )
CNF-SAT and
3CNF-SAT are
NP-complete languages
Proof:
a. 3CNF-SAT is NP-complete
b. CLIQUE is in NP (shown in last class)
c. 3CNF-SAT is polynomial reducible to CLIQUE
(shown earlier)