{0,1}* of L' to an instance f(x) of L.
4.Prove that the function f satisfies x .
L' if
and only if f(x) .
L for all x .
{0,1}*.
5.Prove that the algorithm computing f
runs in polynomial time.
34.4 NP-completeness proofs
.... 2~5......... NP-hard.
............ NP... reduce
........... CIRCUIT-SAT. NPcomplete
.......
........... NP-complete..,
..............,.......
.. NP-complete........
34.4 NP-completeness proofs
Formula satisfiability
....... formula satisfiability
problem,...... NP-complete.
An instance of SAT is a boolean formula .
composed of
1. n boolean variables: x1, x2, ..., xn;
2. m boolean connectives: any boolean
function with one or two inputs and one
output, such as ., ., ¬, .(imply), .(iff)
3.parentheses.
34.4 NP-completeness proofs
Boolean formula ... encode....
O(m+n). A truth assignment for a boolean
formula . is a set of values for the variables
of ., and a satisfying assignment is a truth
assignment that causes it to evaluate to 1.
A formula with a satisfying assignment is a
satisfiable formula.
SAT = {<. : . is a satisfiable boolean
formula}.
34.4 NP-completeness proofs
..: .= ((x1 .
x2) .
¬ ((¬x1 .
x3) .
x4)) .
¬ x2,.. satisfying assignment. x1 = 0,
x2 = 0, x3 = 1, x4 = 1,.
.= ((0 .
0) .
¬ ((¬0 .
1) .
1)) .
¬0
= (1 .
¬ (1 .
1)) .
1 = (1 .
0) .
1 =1
SAT...... n...,.... 2n..
.....,............
formula.. true,........... .
(2n).
34.4 NP-completeness proofs
Theorem
34.9 Satisfiability of boolean
formulas is NP-complete.
. Lemma 34.8 ......,... SAT.
NP...,...... truth
assignment,..........
formula
.... 1,......... polynomial
time,.. SAT.. NP.
...... CIRCUIT-SAT =P SAT,....
.. CIRCUIT-SAT............
,....... size...........
34.4 NP-completeness proofs
. =x.
(x.
¬x) .
(x.
(x.
x)) .
(x.
104 35126
¬x) .
(x.
(x.
x.
x)) .
(x.
(x.
x)) .
47124856
(x.
(x.
x)) .
(x.
(x.
x.
x)).
9 6710 789
x1
x2
x3 x4
x5
x6
x7
x8
x9
x10
34.4 NP-completeness proofs
...................
polynomial time........ formula
.. satisfiable..,... CIRCUIT-SAT
.. satisfiable,.....
.. SAT..... NP-complete.
34.4 NP-completeness proofs
3-CNF satisfiability
.......: A literal in a boolean
formula is an occurrence of a variable or its
negation. A boolean formula is in
conjunctive normal form, or CNF, if it is
expressed as an AND of clauses, each of
which is the OR of one or more literals. A
boolean formula is in 3-conjunctive normal
form, or 3-CNF, if each clause has exactly
three distinct literals.
77
34.4 NP-completeness proofs
..: (x1 .
¬x1 .
¬x2) .
(x3 .
x2 .
x4) .
(¬x1
.
¬x3 .
¬x4).... 3-CNF.
In 3-CNF-SAT, we are asked whether a
given boolean formula . in 3-CNF is
satisfiable.
Theorem 34.10 Satisfiability of boolean
formulas in 3-conjunctive normal form is
NP-complete.
34.4 NP-completeness proofs
Theorem
34.10 Satisfiability of boolean
formulas in 3-conjunctive normal form is
NP-complete.
3-CNF-SAT .
NP.... SAT .
NP....
........ SAT =P 3-CNF-SAT.
.. SAT... reduce. 3-CNF-SAT..
.,.... SAT. input. polynomial
time.... 3-CNF-SAT. input,...
......... 3-CNF,........
...
34.4 NP-completeness proofs
.. SAT... reduce. 3-CNF-SAT..
.,.... SAT. input. polynomial
time.... 3-CNF-SAT. input,...
......... 3-CNF,........
...
...... SAT input formula. binary
tree.
34.4 NP-completeness proofs
........, . =
((x.
x) .
¬((¬x.
x)
12 13
.
x4)) .
¬x2,...
binary tree..:
..... ... .' = y1
.
(y.
(y.
¬x)) .
(y.
1222
(y.
y)) .
(y.
(x.
3431
x)) .
(y.
¬y) .
(y.
2455
(y.
x)) .
(y.
(¬x.
646 1
x3))
y1
y2
.
y.
.
¬
.
.
y¬x2
3
4
y5
xx
1 2y6
x
4
¬xx
13
34.4 NP-completeness proofs
..... .'.......
and,....
..... and..............
...... or.. y.
(y.
¬x)...
12
y1 y2 x2
. y1 .
(y2 .
¬x2) = 11
1110
¬((y.
y.
x) .
(y
1221 101
.
¬y2 .
x2) .
(y1 .
100
011
¬y.
¬x) .
(¬y.
221 010
y.
¬x))
22001
000
= (¬y.
¬y.
¬x) .
(¬y.
y
12212
(¬y.
y.
x) .
(y.
¬y.
x)
1221 22
2
.y1 ..y2.-x2 ..
0
1
0
0
1
0
1
1
.
¬x2) .
82
34.4 NP-completeness proofs
... .'............,...
CNF .... .".............
.................... (xi
.
xj)..,... (xi .
xj .
p) .
(xi .
xj .
¬p)............ (x),... (x
.
p .
q) .
(x .
¬p .
q) .
(x .
p .
¬q) .
(x .
¬p .
¬q).
............. 3-CNF formula
.,.... satisfiable if and only if..
...... satisfiable... 3-CNF-SAT.
NP-complete.
Exercises 34-4
34.4-6 Suppose that someone gives you a
polynomial-time algorithm to decide
formula satisfiability. Describe how to use
this algorithm to find satisfying
assignments in polynomial time.
34.4-7 Let 2-CNF-SAT be the set of satisfiable
boolean formulas in CNF with exactly 2
literals per clause. Show that 2-CNF-SAT .
P. Make your algorithm as efficient as
possible.(Hint: Observe that x .
y is
equivalent to ¬x .
y. Reduce 2-CNF-SAT to
a problem on a directed graph that is
efficiently solvable.)
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
NP-complete problems arise in diverse
domains: boolean logic, graphs,
arithmetic, network design, sets and
storage and retrieval,
partitions,
sequencing and scheduling, mathematical
programming, algebra and number
theory, games and puzzles, automata and
language theory, program optimization,
biology, chemistry, physics, and more.
............ NP-complete.
34 NP-Completeness
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
CIRCUIT-SAT
SAT
3-CNF-SAT
SUBSET-SUMCLIQUE
VERTEX-COVER
HAM-CYCLE
TSP
34 NP-Completeness
86
34.5 NP-complete problems34.5 NP-complete problems
34.5-1 The clique problem
A clique in an undirected graph G = (V, E)
is a subset V' .
V of vertices, each pair of
other
which is connected by an edge in E. In
words, a clique is a complete
subgraph of G. The size of a clique is the
number of vertices it contains. The clique
problem is the optimization problem of
finding a clique of maximum size in a
graph.
34 NP-Completeness
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
34.5-1 The clique problem
As a decision problem, we ask simply
whether a clique of a given size k exists in
graph. The formal definition isthe
CLIQUE = {<G,k : G is a graph with a
clique of size k}.
............... G. k .
..........,.... complete
graph,.......... .(k2* C(|V|,
k)),.. C(|V|, k). |V|........
k .....,.........
polynomial time.34 NP-Completeness
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
Theorem
34.11 The clique problem is NP-
complete.
..... CLIQUE .
NP,..... V',
k.
..... polynomial time..
V'...
..........,. |V'|......
........ 3-CNF-SAT =P CLIQUE,
...... 3-CNF-SAT. input...
CLIQUE. input,.........,.
.......... k ... clique.,
3-CNF-SAT.. satisfiable,......
......:34 NP-Completeness
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
. 3-CNF-SAT.... .=(x1 .
¬x2 .
¬x3)
.
(¬x1 .
x2 .
x3) .
(x1 .
x2 .
x3),....:
(¬x.
(x.
¬x.
¬x)
123
2 .
x3)
1
34 NP-Completeness
¬x1
x2
x1 2¬x3
x1
x2
x2 .x3) (x1 .xx3
¬x2
x3
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
......... k ... clique ...
3-CNF-SAT... k . clause.....
.. satisfiable... CLIQUE....
NP-complete.
34 NP-Completeness
91
34.5 NP-complete problems34.5 NP-complete problems
34.5.2 The vertex-cover problem
A vertex cover of an undirected graph G
= (V, E) is a subset V' .
V such that if (u,
and
v) .
E, then u .
V' or v .
V'(or both). That
is, each vertex "cover" its incident edges,
a vertex cover for G is a set of
vertices that covers all the edges in E.
The size of a vertex cover is the number
of vertices in it.
The vertex-cover problem is to find a
vertex cover of minimum size in a given
graph.
34 NP-Completeness
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
Restating this optimization problem as a
decision problem, we wish to determine
whether a graph has a vertex cover of a
given size k. As a language, we define
VERTEX-COVER = {<G,k : graph G has a
vertex cover of size k}.
Theorem 34.12 The vertex-cover problem is
NP-complete.
......... NP...,... G=
(V,E)... k..... V' .
V,...
|V'|
=k....,...
E..... (u,v),
.. u .
V'. v .
V'........
34 NP-Completeness
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
..... vertex-cover .... NPhard,
........ CLIQUE =P
VERTEX-COVER.
............ complement,
Given an undirected graph G = (V, E), we
define the complement of G as G = (V, E),
where E = {(u, v) : u, v .
V, u . v, and (u,
v) .
E}.... G
....... G.,.
.. G..... G...
34 NP-Completeness
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
......... complement.
u v
z w
y x
u v
z w
y x
CLIQUE =P VERTEX-COVER.....:.
... clique problem. instance <G,k,
.... G. complement G,...
vertex-cover .. <G,|V|-k...,...
... clique......
34 NP-Completeness
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
The graph G has a clique of size k if and
only if the graph G has a vertex cover of
size |V| -k.
V'. G..... clique,. G. V'.
.............,... G..
...... V – V'......,.. V–
V'. vertex cover.
. G. V – V'. vertex cover,. V'..
........,... G.. V'...
. clique.
34 NP-Completeness
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
.. VERTEX-COVER.... NPcomplete,
............
polynomial time.......
approximation algorithm.,.....
polynomial time..........,..
...........
....... NP-complete...
approximation algorithm.
34 NP-Completeness
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
34.5.3 The hamiltonian-cycle problem
Theorem
34.13 The hamiltonian cycle
problem is NP-complete.
............... NP...,
..... G = (V, E),....
hamiltonian cycle C,..
C......
....,...
C...........
E.....
.... VERTEX-COVER =HAM-CYCLE
P
... hamiltonian cycle.... NPhard
.
34 NP-Completeness
[u,v,1]
[u,v,2]
[u,v,3]
[u,v,4]
[u,v,5]
[u,v,6]
Wu v
(a)
[v,u,1]
[v,u,6]
[u,v,1]
[u,v,6]
Wuv
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
[v,u,1]
[v,u,2]
[v,u,3]
[v,u,4]
[v,u,5]
[v,u,6]
[v,u,1]
[v,u,6]
[u,v,1]
[u,v,6]
Wuv
[v,u,1]
[v,u,6]
[u,v,1]
[u,v,6]
Wuv
(b) (c) (d)
Given an undirected graph G = (V, E) and
an integer k, we construct an undirected
graph G' = (V', E') that has a hamiltonian
cycle if and only if G has a vertex cover of
size k. G'....:. G.... (u,v)..
... 14 ..........: [u,v,1] ~
[u,v,6],. [v,u,1]~[v,u,6].
34 NP-Completeness
99
34 NP-Completeness
(a)
(b)
w
z
x
y
[x,w,1]
[x,w,6]
[w,x,1]
[w,x,6]
Wuv
[y,x,1]
[y,x,6]
[x,y,1]
[x,y,6]
Wuv
[y,w,1]
[y,w,6]
[w,y,1]
[w,y,6]
Wuv
[z,w,1]
[z,w,6]
[w,z,1]
[w,z,6]
Wuv
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
..............,....
k .
selector verteices s1, s2, ..., sk.
... u.. degree(u)...,.....
......... u(1), u(2), ..., u(degree(u)),.
..
{([u,u(i),6], [u,u(i+1),1]) : 1 = i =
degree(u) – 1}...
.... vertex cover .. hamiltonian
cycle.,.... vertex cover .....
......... si....
34 NP-Completeness
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
........, {(sj, [u,u(1),1]) : u .
V
, [u,u(degree(u)),6]) : u .
V
and1 =j= k} .
{(sj
and 1 = j = k}.
.........,... |V'| = 12|E| + k
= 12|E| + |V|,... |E'| = 14|E| + (2|E| |
V|) + (2k|V|) = 16|E| + (2k-1)|V|
......... polynomial time.
34 NP-Completeness
34.5.4 The traveling-salesman problem
Traveling-salesman problem(TSP): A
salesman must visit n cities. We can say
34.5 NP-complete problems
34.5 NP-complete problems
visiting
to
that the salesman wishes to make a tour,
each city exactly once and
finishing at the city he starts from. There
is an integer cost c(i, j) to travel from city
i city j, and the salesman wishes to
make the tour whose total cost is
minimum, where the total cost is the sum
of the individual costs along the edges of
the tour.
34 NP-Completeness
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
TSP = {<G,c,k : G = (V, E) is a complete
graph, c is a function from V × V .
Z, k .
Z, and G has a traveling-salesman tour
Theorem
with cost at most k}.
34.14 The traveling-salesman
problem is NP-complete.
.... TSP..... NP,.....
TSP...,..... polynomial time
..................,..
......... cost...... k.
34 NP-Completeness
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
..... NP-complete... reduce.
TSP...,.... Hamiltonian cycle
=P TSP.
..... G = (V, E),.....
complete.. G' = (V, E'), E' = {(i,j) : i,
j .
V and i . j},... (i,j) .
E. c(i,j) =
0,. (i,j) .
E. c(i,j) = 1.
The graph G has a hamiltonian cycle if
and only if graph G' has a tour of cost at
most 0.
34 NP-Completeness
105
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
34.5.5 The subset-sum problem
....
subset-sum problem, We are
given a finite set S .
N and a target t .
N.
..
We ask whether there is a subset S' .
S
whose elements sum to t.
S = {1, 2, 7, 14, 49, 98, 343, 686,
2409, 2793, 16808, 17206, 117705,
117993}. t = 138457,. S' = {1, 2, 7,
98, 343, 686, 2409, 17206, 117705}..
...
SUBSET-SUM = {<S,t : there exists a
subset S' .
S such that t = S
s}.
s.S'34 NP-Completeness
106
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
Theorem 34.15 The subset-sum problem is
NP-complete.
........ NP...,..... S' ,
..
S'............ t....
.. polynomial time......,...
..... NP.
.... 3-CNF-SAT =P SUBSET-SUM..
...... NP-hard.
34 NP-Completeness
34.5 NP-complete problems34.5 NP-complete problems
107
Given a 3-CNF formula . over variables
x, x, ..., x with clauses C, C, ..., C,
12n 12k
each containing exactly three distinct
the reduction algorithm
an instance <S,t of the
problem such that . is
literals,
constructs
subset-sum
satisfiable if and only if there is a subset
of S whose sum is exactly t.
34 NP-Completeness
108
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
................,. .=
C1 .
C2 .
C3 .
C4,.. C1 = (x1 .
¬x2 .
¬x),C=(¬x.
¬x.
¬x) C=(¬x.
32 1233 1
.
x),C=(x.
x.
x)
234 123
¬x
...... satisfying assignment. x1
= 0, x2= 0, x3 = 1.
..... subset-sum..:
34 NP-Completeness
109
34 NP-Completeness
x1 x2 x3 C1 C2 C3 C4
v1 = 1 0 0 1 0 0 1
v1’ = 1 0 0 0 1 1 0
v2 = 0 1 0 0 0 0 1
v2’ = 0 1 0 1 1 1 0
v3 = 0 0 1 0 0 1 1
v3’ = 0 0 1 1 1 0 0
s1 = 0 0 0 1 0 0 0
s1’ = 0 0 0 2 0 0 0
s2 = 0 0 0 0 1 0 0
s2’ = 0 0 0 0 2 0 0
s3 = 0 0 0 0 0 1 0
s3’ = 0 0 0 0 0 2 0
s4 = 0 0 0 0 0 0 1
s4’ = 0 0 0 0 0 0 2
t = 1 1 1 4 4 4 4
110
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
.............,.......
.. vi. vi',.. xi. Cj...., vi
....
Cj..... 1.... 0, ¬xi
Cj...., vi'....
Cj......
1.... 0.
.......... si. si',.. si. Ci
.... 1.... 0,. si'. Ci....
2.... 0.
t..... n. digits. 1.. k .
digits. 4.
.........34 NP-Completeness
111
3
334.5 N
4.5 N4.5 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
ee p
ppr
rro
oob
bbl
lle
eem
mms
ss
............ subset... t
..,....... satisfiable.
.. subset-sum.... NP-complete.
34 NP-Completeness
E
EEx
xxe
eerc
rcrci
iis
sse
ees
ss 34.5
34.534.5
112
34.5-1 The subgraph-isomorphism problem
takes two graphs G1 and G2 and asks
whether G1 is isomorphic to a subgraph of
G2. Show that the subgraph-isomorphism
problem is NP-complete.
34.5-5 The set-partition problem takes as
input a set S of numbers. The question is
whether the numbers can be partitioned
34 NP-Completeness
into two sets A and S – A such that Sx.Ax =
Sx (.S-A)x. Show that the set-partition
problem is NP-complete.
E
EEx
xxe
eerc
rcrci
iis
sse
ees
ss 34.5
34.534.5
34.5-6 Show that the hamiltonian-path
problem is NP-complete.
34.5-7 The longest-simple-cycle problem is
problem of determining a simple the
cycle(no repeated vertices) of maximum
length in a graph. Show that this problem
is NP-complete.
34 NP-Completeness
.NP
This proof is correct:
When a snail scrunches does he become a 'snali'?
No. [1] http://groups.google.com/group/sci.math/msg/c61385970bc34320?
[2] http://buildasearch.com/meami?start=351&paginas=40&e=%20prove%20%3E%20Cook%27s%20theorem%20for%20a%20unary%20alphabet
34 NP-Completeness 34 NP-Completeness 1971 年 Cook 提出第一個 NP-complete 問
題. 之後,至今三十幾年、沒有人能夠找到任何一個. NP ... Prove that GRAPH- ISOMORPHISM. NP by
describing a. polynomial-time algorithm to verify the ... csie.dyu.edu.tw/~spring/.../96_1/Algorithms/chapter34.pdf
Research conducted and based on: http://buildasearch.com/meami http://meami.org
Posted by M. Michael Musatov 10.22.2009
71.130.128.163 (talk) 02:23, 23 October 2009 (UTC)M. Michael Musatov
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 40:59:58 |
Calls: | 8,141 |
Calls today: | 4 |
Files: | 13,085 |
Messages: | 5,857,726 |