From: Future_News on
MACHINE PROOFED RESOLUTION TO THE P VERSUS NP PROBLEM
PRESENTED BY M. MICHAEL MUSATOV
WITH A PROMISE TO DONATE ALL $1MM DOLLARS OF THE CLAY PRIZE
TO CURE CHILDHOOD CANCER WITH HTTP://WWW.ALEXSLEMONADE.ORG/
THE P VERSUS NP PROBLEM
TWO POSSIBILITIES:
1
OR
2
CHOOSE
[P =/=NP] AND [P == NP] OR
[P =/=NP] AND [P == NP]
BUT NOT BOTH
VERSE THEM
EXPLORE THEM
ENTWINE THEM
INT: 2=TPO UNARY
1.=P===NP P=/=NP
2.=P=/=NP P===NP
3.-=P===NP P=/=NP
4.=P=/=NP P===NP
:----------------------------------------------------------------------------------------------------------------------------
+1.=P===NP P=/=NP
:
+2.=P=/=NP P===NP
:----------------------------------------------------------------------------------------------------------------------------
+3.-=P===NP P=/=NP
:----------------------------------------------------------------------------------------------------------------------------
+4.=P=/=NP P===NP
ECHO HELLO WORLD WRITE OUT = 2- :
OVER THIS MESSAGE AND AFTER THIS MESSAGE ANDE THROUGH THIS MESSEAGE
ECHO HOLLA WORLD:

On Oct 22, 9:03 pm, Future_News <future_n...(a)brew-master.com wrote:

On Oct 22, 8:31 pm, Future_News <future_n...(a)brew-master.com wrote:

On Oct 22, 4:48 pm, Tegiri Nenashi <tegirinena...(a)gmail.com wrote:

On Oct 21, 5:04 pm, cplxphil <cplxp...(a)gmail.com wrote:

I'm not sure if you're disagreeing. If you are, my response is that
you could argue that it preserves the same structure of the decision
problem, but expressed as a formal language, it's technically
different. It has to be proven that languages are basically
equivalent (in terms of decidability, time complexity, and space
complexity) and independent of encoding scheme, and this proof only
applies to encoding schemes that use at least two symbols in the
alphabet.

I'm not comfortable with this alphabet symbols count. Do word
separators count as alphabet symbols or not? Why is the language is
assumed to be structured into sentences of words? This looks like ad-
hoc assumption from language theory perspective.

I guess something I should have mentioned earlier is that Cook's
theorem would not be true if you use a unary alphabet, meaning that
SAT would not be NP-complete in that case. If you think you can prove
Cook's theorem for a unary alphabet, please share this proof.

http://en.wikipedia.org/wiki/Cook%E2%80%93Levin_theorem

The only place I noticed depending on the encoding appeared to be the
last sentence. Changing log into polynomial doesn't change anything
there. Is there another dependency I'm missing?

NP
3
334
44 NP
NPNP-Co
-Co-Com
mmp
pplet
letletene
eneenes
sss
ss

34.1 Polynomial time
34.2 Polynomial-time verification
34.3 NP-completeness and reducibility
34.4 NP-completeness proofs
34.5 NP-complete problems
34 NP-Completeness

3
334
44 NP
NPNP-Co
-Co-Com
mmp
pplet
letletene
eneenes
sss
ss

.............. polynomial time....
,.... worst case....... O(nk),.. n
.. input size, k. constant.
...
............. polynomial time..
Turing.........: Halting
problem,.................,..
.... polynomial time......
..............,........ O(nk).

Generally, we think of problems that are solvable
by polynomial-time algorithms as being tractable,
and problems that require superpolynomial time
as being intractable.

34 NP-Completeness

3
334
44 NP
NPNP-Co
-Co-Com
mmp
pplet
letletene
eneenes
sss
ss

...... polynomial time.....,...
.. P......... polynomial time...
...........,.. NP....

.. 1971...... P = NP ?...,...

..............
........ NP-complete...,... NP
........,...... polynomial time
....,............. polynomial
time....

34 NP-Completeness

3
334
44 NP
NPNP-Co
-Co-Com
mmp
pplet
letletene
eneenes
sss
ss

... NP-complete............
,.... polynomial time.......
......

Shortest vs. Longest simple paths: 24..
............ single source.
shortest path...... O(VE)..

longest simple paths....:.....
,........ simple path(.....
path),...... k........:.
...... Hamiltonian path(......
path)..........,. NPcomplete
.....

34 NP-Completeness

3
334
44 NP
NPNP-Co
-Co-Com
mmp
pplet
letletene
eneenes
sss
ss

Euler tour vs. Hamiltonian cycle:....
...,............. cycle,.
.. Euler tour...,.. O(E).......
......,..............
cycle,.. Hamiltonian cycle......
......,. NP-complete....

34 NP-Completeness

3
334
44 NP
NPNP-Co
-Co-Com
mmp
pplet
letletene
eneenes
sss
ss

2-CNF satisfiability vs. 3-CNF satisfiability:

.........,............
... true,.. satisfiability.......
..
.............. (x1 . -x2) . (-x1

x3) . (-x2 . -x3)....,.. 2

CNF(conjuctive normal form) satisfiability

.... (........ or,......

.... and,............ );.

................,.. 3-CNF

satisfiability.... 2-CNFsatisfiability.
...,. 3-CNF satisfiability..... NPcomplete
.....
34 NP-Completeness

3
334
44 NP
NPNP-Co
-Co-Com
mmp
pplet
letletene
eneenes
sss
ss

NP-completeness and the classes P and NP

.....,.......:..... polynomial
time.....,.... P.........
polynomial time.............,.
.. NP...,.. Hamiltonian cycle, 3-CNF.
... P . NP,...: P . NP?.......:
P..... NP.
.. NP-complete... NP.......,...
.. NP-complete...... polynomial time.
.....,.. NP....... polynomial time
.....

34 NP-Completeness

3
334
44 NP
NPNP-Co
-Co-Com
mmp
pplet
letletene
eneenes
sss
ss

.. NP-complete........
polynomial time....,.......
.. polynomial time....

....,...... P.NP,.. NP-
complete............,.
1971. Cook..... NP-complete..
..,..................
NP-complete... polynomial time....
..............,......
.

34 NP-Completeness

3
334
44 NP
NPNP-Co
-Co-Com
mmp
pplet
letletene
eneenes
sss
ss

......... NP-complete....
...,............ NPcomplete
.

P.... NP......;.. NPcomplete
....,.....
approximation algorithm;......
special case....,.........
polynomial time..........

34 NP-Completeness

3
334
44 NP
NPNP-Co
-Co-Com
mmp
pplet
letletene
eneenes
sss
ss

Overview of showing problems to be NP-
complete

....... NP-complete........
.....,................
.......;........ NPcomplete
.................
........... O(n lg n)......
34 NP-Completeness

3
334
44 NP
NPNP-Co
-Co-Com
mmp
pplet
letletene
eneenes
sss
ss

Decision problems vs. Optimization problems

...................,.
........ (optimization problems),
...........: minimum spanning

tree. shortest path..........
..... decision problems,......
..,....... (Yes/No)...:...
. weight..... 20. spanning tree..
........ k. simple cycle.

.... decision.... optimization..
......... NP-complete.,...
decision problem....34 NP-Completeness

3
334
44 NP
NPNP-Co
-Co-Com
mmp
pplet
letletene
eneenes
sss
ss

Decision problems vs. Optimization problems

. Optimization......... decision
........:......... u, v.
v
.......... decision...... u,
.......... k .......,.
...........,..........
........ k .... decision....
.,.. decision.........
optimization......

.. decision........,.......
..,.... polynomial time,....
decision problem...
34 NP-Completeness

3
334
44 NP
NPNP-Co
-Co-Com
mmp
pplet
letletene
eneenes
sss
ss

Reduction

........... reduction,.....
..... A. NP-complete.
........ A. polynomial time..
......,...... polynomial time
...........:..... A....
(instance)........ polynomial time
...... B ... .,.... .....
...........,.. A....
polynomial time...

1....... polynomial time.
2. ..... .....34 NP-Completeness

14
34 NP-Completeness
34 NP-Completeness34 NP-Completeness
Reduction
We call such a procedure a polynomial-time
reduction algorithm.
polynomial-time
reduction algorithm
polynomial-time
algorithm to decide B
. .
yes yes
no no
Polynomial-time algorithm to decide A

3
334
44 NP
NPNP-Co
-Co-Com
mmp
pplet
letletene
eneenes
sss
ss

Reduction

........ NP-complete.......
....... polynomial time.....,
.......... reduction......
........ A. NP-complete.....
. reduction...,......... NPcomplete
... B,. polynomial time...
B. input reduce. A. input,.. A...
.. B....

34 NP-Completeness

3
334
44 NP
NPNP-Co
-Co-Com
mmp
pplet
letletene
eneenes
sss
ss

. reduce......,.........
.. NP-complete.....
.....:... NP-complete.....
.......
... NP-complete problem. Cook...
. satisfiability,........ NP...
reduce. satisfiability......
satisfiability.... NP-complete
problem.

34 NP-Completeness

3
334
44.1
.1.1 P
PPo
ooly
lylyn
nno
oom
mmia
iaial
ll tim
timtime
ee
....... polynomial time.....
.. tractable,....:

1.
.. polynomial time........
.....,.. .(n100).......
,... polynomial time.......
.....
2. Polynomial time...........
model.... polynomial time...
,. RAM.... Turing machine..
.....

3. Polynomial time
..........
(closure),..............
...34 NP-Completeness

3
334
44.1
.1.1 P
PPo
ooly
lylyn
nno
oom
mmia
iaial
ll tim
timtime
ee
We define an abstract problem Q to be a
binary relation on a set I of problem
instances and a set S of problem

solutions.
..: shortest path.........
G... u... v,... G. u. v
............. k. path..
....,.... yes..... no,.
. decision problem....

Optimization problems.........
.....,........ decision..
....

34 NP-Completeness

3
334
44.1
.1.1 P
PPo
ooly
lylyn
nno
oom
mmia
iaial
ll tim
timtime
ee
If a computer program is to solve an
abstract problem, problem instances must
be represented in a way that the program
understands. An encoding of a set S of
abstract objects is a mapping e from S to
the set of binary strings.
...... polygons, graphs, functions,
ordered pairs, programs..... binary
strings.
34 NP-Completeness

3
334
44.1
.1.1 P
PPo
ooly
lylyn
nno
oom
mmia
iaial
ll tim
timtime
ee
A computer algorithm that "solves" come
abstract decision problem actually takes an
encoding of a problem instance as input. We
ofcall a problem whose instance set is the set

binary strings a concrete problem. An
algorithm solves a concrete problem in time
O(T(n)) if, when it is provided a problem
instance i of length n = |i|, the algorithm can
produce the solution in O(T(n)) time. A
concrete

problem is polynomial-time
solvable, therefore, if there exists an
algorithm to solve it in time O(nk) for some
constant k.
34 NP-Completeness

3
334
44.1
.1.1 P
PPo
ooly
lylyn
nno
oom
mmia
iaial
ll tim
timtime
ee
The complexity class P is the set of concrete
decision problems that are polynomial-time
solvable.

............
k,. O(k)....

...,.............
..........,.. unary(...
).
......,.. O(n)...;... binary
.......,........ O(2n).

34 NP-Completeness

3
334
44.1
.1.1 P
PPo
ooly
lylyn
nno
oom
mmia
iaial
ll tim
timtime
ee
We say that a function f: {0,1}* .
{0,1}* is
polynomial-time computable if there exists a
polynomial-time algorithm A that, given any
that
input x .
{0,1}*, produces as output f(x).

For some set I of problem instances, we say

two encodings e1 and e2 are

polynomially related if there exist two

polynomial-time computable functions f12 and

ef21 such that for any i .
I, we have f12(e1(i)) =
2(i) and f21(e2(i)) = e1(i).

34 NP-Completeness

3
334
44.1
.1.1 P
PPo
ooly
lylyn
nno
oom
mmia
iaial
ll tim
timtime
ee
Lemma 34.1 Let Q be an abstract decision
problem on an instance set I, and let e1 and
e2 be polynomially related encodings on I.
Then, e1(Q) .
P if and only if e2(Q) .
P.

Proof:... e1(i)...... O(nk)...
e2(i)... e1(i).... O(nc)....
e2(i)
.,.....:... e1(i)... e1(i)...
,.... O(nc+k),.. polynomial time..

...

34 NP-Completeness

24
34.1 Polynomial time34.1 Polynomial time
....... polynomial time......
....,........... P....
.............. binary code,.
..............
34 NP-Completeness

3
334
44.1
.1.1 P
PPo
ooly
lylyn
nno
oom
mmia
iaial
ll tim
timtime
ee
A formal-language framework

.. formal language....
decision problem
An alphabet S
is a finite set of symbols. A
language L over S
is any set of strings made up
of symbols from S. E.g, if S={0,1}, the set
L={10,11,101,111,1011, 1101, 10001, ...} is
the language of binary representations of

prime numbers.
empty string ., empty language Ø. The
language of all strings over S
is denoted by S*.

34 NP-Completeness

26

3
334
44.1
.1.1 P
PPo
ooly
lylyn
nno
oom
mmia
iaial
ll tim
timtime
ee
Languages. operations: union .,
intersection n, complement L = S* – L,
concatenation, closure.
The concatenation of two languages L1 and L2
isthelanguage L = {xx: x.
Land x.
L}.

1211 22

The closure or Kleene star of a language L is
the language L* = {.} .
L .
L2 .
L3 .
..., where
Lk is the language obtained by concatenating
L to itself k times.

34 NP-Completeness

3
334
44.1
.1.1 P
PPo
ooly
lylyn
nno
oom
mmia
iaial
ll tim
timtime
ee
From the point of view of language theory,
the set of instances for any decision problem
Q is simply the set S*, where S
= {0,1}. Since
Q is entirely characterized by those problem
instances that produce a 1(yes) answer, we
can view Q as a language L over S
= {0,1},
whereL = {x .S* : Q(x) = 1}.
..: PATH = {<G,u,v,k
: G = (V,E) is an
undirected graph, u, v .
V, k = 0 is an
integer, and there exists a path from u to v in
G consisting of at most k edges}.

34 NP-Completeness

3
334
44.1
.1.1 P
PPo
ooly
lylyn
nno
oom
mmia
iaial
ll tim
timtime
ee
We say that an algorithm A accepts a string x
.
{0,1}* if, given input x, the algorithm's
output A(x) is 1. The language accepted by
{0,1}*
an algorithm A is the set of strings L = {x .
: A(x) = 1}, that is, the set of strings

that the algorithm accepts. An algorithm A

rejects string x if A(x) = 0.

34 NP-Completeness

3
334
44.1
.1.1 P
PPo
ooly
lylyn
nno
oom
mmia
iaial
ll tim
timtime
ee
A language L is decided by an algorithm A if
every binary string in L is accepted by A and
every binary string not in L is rejected by A.
A language L is accepted in polynomial time
by an algorithm A if it is accepted by A and if
in addition there is a constant k such that for
any length-n string x .
L, algorithm A accepts
x in time O(nk).
A language L is decided in polynomial time

an algorithm A if there is a constant kby
such that for any length-n string x .
{0,1}*,
the algorithm correctly decides whether x L
in time O(nk). 34 NP-Completeness

30
We define
languages,
determined by
3
334
44.1
.1.1 P
PPo
ooly
lylyn
nno
oom
mmia
iaial
ll tim
timtime
ee
a complexity class as a set of
membership in which is
a complexity measure, such
as running time, of an algorithm that

34 NP-Completeness

determines whether a given string x belongs
to language L.
We can provide an alternative definition of
the complexity class P: P = {L .{0,1}* :
there exists an algorithm A that decides L in
polynomial time}.

3
334
44.1
.1.1 P
PPo
ooly
lylyn
nno
oom
mmia
iaial
ll tim
timtime
ee
In fact, P is also the class of languages that
can be accepted in polynomial time.
Theorem 34.2 P = {L: L is accepted by a

polynomial-time algorithm}.
34 NP-Completeness

Ex
ExExer
ererc
ccis
isise
ees
ss 3
334
44.1
.1.1

for
34.1-4 Is the dynamic-programming algorithm
for the 0-1 knapsack problem that is asked
in Exercise 16.2-2 a polynomial-time

16.2-2 Give
algorithm ? Explain your answer.

a dynamic-programming solution
to the 0-1 knapsack problem that runs in O(n
W) time, where n is number of items and W is
the maximum weight of items that the thief
can put in his knapsack.

34 NP-Completeness

33
Exercises34.1Exercises 34.1
34.1-6 Show that the class P, viewed as a set of
languages, is closed under union,
intersection, concatenation, complement,
and Kleene star. That is, if L1, L2 .P, then L1 .
L2 .P, etc.
34.1-6 Show that the class P, viewed as a set of
languages, is closed under union,
intersection, concatenation, complement,
and Kleene star. That is, if L1, L2 .P, then L1 .
L2 .P, etc.
34 NP-Completeness

34.234.234.234.2 Po
PoPol
lly
yyno
nonom
mmi
iia
aal
ll-
--ti
titim
mme
ee v
vve
eer
rri
iif
ffi
iic
cca
aati
titio
oon
nn
... polynomial-time verification...
..... polynomial-time.......
.........,..... PATH..
.,..... G... u... v,..
.. k,.... path,..... lineartime
....... path... u. v.
path,......... k,....
polynomial-time verification.
..... polynomial-time......,
..... polynomial-time verification.
............ polynomial-time
...,...... polynomial-time
verification....34 NP-Completeness

35
34.2 Polynomial-time verification34.2 Polynomial-time verification
Hamiltonian cycle

.............. hamiltonian
cycle,...............
hamiltonian cycle of an undirectedAgraph G = (V, E) is a simple
cycle
that
contains each vertex in V. A graph that
contains a hamiltonian cycle is said to be
hamiltonian; otherwise, it is
nonhamiltonian.

Hamiltonian-cycle problem: "Does a graph
G have a hamiltonian cycle ?"

34 NP-Completeness

36
34.2 Polynomial-time verification34.2 Polynomial-time verification
.......... hamiltonian-cycle?

.....
dodecahedron
...... bipartite graph

34 NP-Completeness

37
34.2 Polynomial-time verification34.2 Polynomial-time verification
. hamiltonian cycle.......
polynomial time...,.... O(2n).
Verification algorithms:.....,...
.......,............
....... G. cycle C,.....
C
... hamiltonian cycle........
cycle,........,........
,............ hamiltonian
cycle,......:..........

............ edge?....
simple cycle?.......... Yes,.
... hamiltonian cycle.
34 NP-Completeness

38
34.2 Polynomial-time verification34.2 Polynomial-time verification
We define a verification algorithm as
being a two-argument algorithm A, where
one argument is an ordinary input string x
certificate.
and the other is a binary string y called a

A two-argument algorithm A
verifies an input string x if there exists a
certificate y such that A(x, y) = 1. The
language verified by a verification
algorithm A is L = {x .
{0,1}* : there
exists y .
{0,1}* such that A(x, y) = 1}.

34 NP-Completeness

34.234.234.234.2 Po
PoPol
lly
yyno
nonom
mmi
iia
aal
ll-
--ti
titim
mme
ee v
vve
eer
rri
iif
ffi
iic
cca
aati
titio
oon
nn
The complexity class NP

........ polynomial time....,..
hamiltonian-cycle problem.. NP....
.... NP. NP. nondeterministic
model
polynomial ...,.... non-deterministic
..,.. polynomial time......,
.. NP....

A language L .
NP iff there exists a two-input
polynomial-time algorithm A and constant c such
that L = {x .
{0,1}* : there exists a certificate y
with |y| = O(|x|c) such that A(x, y) = 1}.
The algorithm A verifies language L in polynomial
time.

34 NP-Completeness

34.234.234.234.2 Po
PoPol
lly
yyno
nonom
mmi
iia
aal
ll-
--ti
titim
mme
ee v
vve
eer
rri
iif
ffi
iic
cca
aati
titio
oon
nn
..... hamiltonian cycle..... NP.
..,..... L ... P... L....
. NP,.... L .............
..,.. P .
NP.
...... P=
NP........,...
........ P . NP.

34 NP-Completeness

34.234.234.234.2 Po
PoPol
lly
yyno
nonom
mmi
iia
aal
ll-
--ti
titim
mme
ee v
vve
eer
rri
iif
ffi
iic
cca
aati
titio
oon
nn
.. P.... NP..,..........
...,.. NP...... complement.
......... L .
NP..... L .
NP.
NPWe can define the complexity class co-NP as
the set of languages L such that L .
NP.
............ NP.... coNP
....

P = NP = co-NP NP = co-NP
P
co-NP NPP = NP nco-NP co-NP NPNP nco-NP
P
.......
34 NP-Completeness

E
EEx
xxe
eer
rrc
cci
iis
sse
ees
ss 34
3434.2
.2.2

42
34.2-1 Consider
ISOMORPHISM
isomorphic graphs}. Prove that GRAPH-
ISOMORPHISM .NP by describing a
polynomial-time algorithm to verify the
language.
34.2-2 Prove that if G is an undirected bipartite
graph with an odd number of vertices, then G
is nonhamiltonian.
the language GRAPH={<
G,G
:Gand Gare

121 2

34 NP-Completeness

E
EEx
xxe
eer
rrc
cci
iis
sse
ees
ss 34
3434.2
.2.2

34.2-4 Prove that the class NP of languages is
closed under union, intersection,
34.2-6
concatenation, and Kleene star. Discuss the
closure of NP under complement.

A hamiltonian path in a graph is a
simple path that visits every vertex exactly
once. Show that the language HAM-PATH = {
<G, u, v
: there is a hamiltonian path from u
to v in graph G} belongs to NP.

34 NP-Completeness

E
EEx
xxe
eer
rrc
cci
iis
sse
ees
ss 34
3434.2
.2.2

34.2-7 Show that the hamiltonian-path
problem can be solved in polynomial time on
34.2-11
directed acyclic graphs. Give an efficient
algorithm for the problem.

Let G be a connected, undirected
graph with at least 3 vertices, and let G3 be
the graph obtained by connecting all pairs of
vertices that are connected by a path in G of
length

most 3. Prove that G3 is
hamiltonian. (Hint: Construct a spanning tree
at
for G, and use an inductive argument.)

34 NP-Completeness

34.3
34.334.3 N
NNP
PP-
--c
cco
oom
mmp
ppl
lle
eet
tte
een
nne
ees
sss
ss a
aand
ndnd r
rre
eed
dduc
ucuci
iib
bbi
iil
lli
iity
tyty
..... P . NP........ NPcomplete
...,.... NP-complete
...... polynomial time.....,
NP....... polynomial time..
....,... P = NP.........
,..... NP-complete.......
..... polynomial time.....
.. Hamiltonian cycle..... NPcomplete
...,..... polynomial
time.... Hamiltonian cycle...,
.. NP....... polynomial time
.....

34 NP-Completeness

46
34.3 NP-completeness and reducibility34.3 NP-completeness and
reducibility
....,.. NP – P.......,..
Hamiltonian cycle....... NP –
P.

.... NP-complete.... NP...

...
...... polynomial-time reducibility
...... NP-complete......

34 NP-Completeness

47
34.3 NP-completeness and reducibility34.3 NP-completeness and
reducibility
L1 is polynomial-time reducible to L2,

written L1 =P L2,.. L2 . P. L1 . P.
A
..: L2. sorting...,. L1....
....,. L1 =PL2.

language L1 is polynomial-time
reducible to a language L2, written L1 =P
L2, if there exists a polynomial-time
computable function f : {0,1}* .
{0,1}*

such that for all x .
{0,1}*, x .
L1 if and

only if f(x) .
L2.

34 NP-Completeness

48
Lemma 34.3 If Lsuch that L
34.3
34.334.3 N
NNP
PP-
--c
cco
oom
mmp
ppl
lle
eet
tte
een
nne
ees
sss
ss a
aand
ndnd r
rre
eed
dduc
ucuci
iib
bbi
iil
lli
iity
tyty

1, L2 .
{0,1}* are languages
=L,thenL.
P implies L.

1P22 1

P.

34 NP-Completeness
A1
A2F
f(x)x
yes, f(x) .L2
no, f(x) .L2
yes, x .L1
no, x .L1

49
34.3 NP-completeness and reducibility34.3 NP-completeness and
reducibility
NP-completeness

Polynomial-time reductions provide a
formal means for showing that one
We
problem is at least as hard as another, to
within a polynomial-time factor.

define the set of NP-complete

languages, which are the hardest

problems in NP.

A language L .
{0,1}* is NP-complete if

1. L .
NP, and
2. L' =P L for every L' .
NP.
34 NP-Completeness

34.3
34.334.3 N
NNP
PP-
--c
cco
oom
mmp
ppl
lle
eet
tte
een
nne
ees
sss
ss a
aand
ndnd r
rre
eed
dduc
ucuci
iib
bbi
iil
lli
iity
tyty
. L . NP-complete...,. L . NP,
..... NP... L' =P L.
.......... NP... L' =P L..
..., L .. NP-hard....
.... NPC..
NP-complete
languages.
. L1 =PL2.,.. L1. NP-complete.
L2.... NP-hard.

34 NP-Completeness

51
34.3 NP-completeness and reducibility34.3 NP-completeness and
reducibility
Theorem 34.4 If any NP-complete problem
is polynomial-time solvable, then P = NP.
Equivalently, if any problem in NP is not
complete
solvable.
polynomial-time solvable, then no NP-

problem is polynomial-time

...... P .NP

NP
P
NP-Complete
34 NP-Completeness

34.3
34.334.3 N
NNP
PP-
--c
cco
oom
mmp
ppl
lle
eet
tte
een
nne
ees
sss
ss a
aand
ndnd r
rre
eed
dduc
ucuci
iib
bbi
iil
lli
iity
tyty
Circuit satisfiability

... NP-complete .......,....
.. reducibility............ NP-
Thus,
complete....
we now focus on demonstrating the
existence of an NP-complete problem: the
circuit-satisfiability problem.
A boolean combinational element is any
circuit element that has a constant number
of boolean inputs and outputs and that
performs a well-defined function.
....... 0.
1, 0..
FALSE. 1..
TRUE.

34 NP-Completeness

53
34.3 NP-completeness and reducibility34.3 NP-completeness and
reducibility
A boolean combinational circuit consists
of one or more boolean combinational
elements interconnected by wires.

not and or

34 NP-Completeness

54
34.3 NP-completeness and reducibility34.3 NP-completeness and
reducibility
x1
x2
x3
34 NP-Completeness

3
334.3 N
4.3 N4.3 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
eene
nenes
sss
ss a
aand
ndndre
rered
dduc
ucuci
iib
bbi
iil
lli
iity
tyty
•
A truth assignment for a boolean
combinational circuit is a set of boolean input
values. We say that a one-output boolean
combinational circuit is satisfiable if it has a
satisfying assignment: a truth assignment
that causes the output of the circuit to be 1.
34 NP-Completeness

3
334.3 N
4.3 N4.3 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
eene
nenes
sss
ss a
aand
ndndre
rered
dduc
ucuci
iib
bbi
iil
lli
iity
tyty
The circuit-satisfiability problem is, "Given a
boolean combinational circuit composed of
AND, OR, and NOT gates, is it satisfiable?"
...... size. circuit. combinational
element......
CIRCUIT-SAT = {<C : C is a satisfiable
boolean combinational circuit}.
................ true. false

..,.....,.............
. .(2n),...... n...

34 NP-Completeness

3
334.3 N
4.3 N4.3 NP-
P-P-c
cco
oom
mmp
ppl
lle
eet
tte
eene
nenes
sss
ss a
aand
ndndre
rered
dduc
ucuci
iib
bbi
iil
lli
iity
tyty
.... CIRCUIT-SAT. NP-Complete... .
Lemma 34.5 The circuit-satisfiability problem
..
belongs to the class NP.
lemma............
circuit,..... truth assignment,...
. linear time.......
assignment.
.... truth assignment... circuitsatisfiability
. NP....

34 NP-Completeness

Circuit-satisfiability
problem is NP-complete
(cont.)

• Lemma 34.6: (page 991)
– CIRCUIT-SAT is NP-hard.
• Proof: Suppose X is any problem in NP
– construct a poly-time algorithm F maps
every problem instance x in X to a circuit
C=f(x) such that the answer to x is YES if
and only if CÎCIRCUIT-SAT (is satisfiable).

Circuit-satisfiability problem is NP-hard
(cont.)

–
F runs in poly time.
•
Poly space:
–
Size of x is n.
–
Size of A is constant, independent of x.
–
Size of y is O(nk).
–
Amount of working storage is poly in n since A runs at
most O(nk).
–
M has size poly in length of configuration, which is poly
in O(nk), and hence is poly in n.
–
C consists of at most O(nk) copies of M, and hence is poly
in n.
–
Thus, the C has poly space.
•
The construction of C takes at most O(nk) steps and
each step takes poly time, so F takes poly time to
construct C from x.

Circuit-satisfiability problem is NP-hard
(cont.)

•
Since XÎNP, there is a poly-time
algorithm A which verifies X.
•
Suppose the input length is n and let T(n)
denote the worst-case running time. Let k
be the constant such that T(n)=O(nk) and
the length of the certificate is O(nk).

Circuit-satisfiability problem is NP-hard
(cont.)

•
Idea is to represent the computation of A
as a sequence of configurations, c0, c1,
…,ci,ci+1,…,cT(n), each ci can be broken into

–
(program for A, program counter PC, auxiliary machine
state, input x, certificate y, working storage) and
–
ci is mapped to ci+1 by the combinational circuit
M implementing the computer hardware.
–
The output of A: 0 or 1– is written to some
designated location in working storage. If the
algorithm runs for at most T(n) steps, the
output appears as one bit in cT(n).
–
Note: A(x,y)=1 or 0.

Copyright © The McGraw-Hill Companies, Inc. Permission required for
reproduction or display.

62

Circuit-satisfiability problem is NP-hard (cont.)

•
The reduction algorithm F constructs a
single combinational circuit C as follows:
– Paste together all T(n) copies of the circuit
M.
–
The output of the ith circuit, which produces
ci, is directly fed into the input of the (i+1)st
circuit.

–
All items in the initial configuration, except
the bits corresponding to certificate y, are
wired directly to their known values.
–
The bits corresponding to y are the inputs to
C.
– All the outputs to the circuit are ignored,
except the one bit of cT(n) corresponding to
the output of A.

Circuit-satisfiability problem is NP-hard (cont.)

• Two properties remain to be proven:
– F correctly constructs the reduction, i.e., C
is satisfiable if and only if there exists a
certificate y, such that A(x,y)=1.
ÜSuppose there is a certificate y, such
that A(x,y)=1. Then if we apply the bits
of y to the inputs of C, the output of C is
the bit of A(x,y), that is C(y)= A(x,y) =1,
so C is satisfiable.
ÞSuppose C is satisfiable, then there is a
y such that C(y)=1. So, A(x,y)=1.
– F runs in poly time.

34.3 NP-completeness and
reducibility
Theorem 34.7 The circuit-satisfiability
problem is NP-complete.

Exercises 34.3

34.3-2 Show that the =P relation is a

transitive relation on languages. That is,

showthatifL=LandL=L,thenL=

1P2 2P31P

L3.

34.4 NP-completeness proofs
....... NP-complete.......
circuit-satisfiability problem.......
NP.... reduce. circuit-satisfiability
...,............
Lemma 34.8 If L is a language such that L' =P
L for some L' .
NPC, then L is NP-hard.
Moreover, if L .
NP, then L .
NPC.
.. =P. transitive...,......
NP... L''=PL' =P L,.. L. NP-hard
....

34.4 NP-completeness proofs
.
Lemma 34.8........... NPcomplete
......
1. Prove L .
NP.
2. Select a know NP-complete language L'.
3. Describe an algorithm that computes a
function f mapping every instance x .
{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 problems34.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 simplethe
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: -This proof was correct

When a snail scrunches does he become a 'snali'?