additional np-complete problems

20
Additional NP-complete Additional NP-complete problems problems Section 7.5 Giorgi Japaridze Theory of Computability

Upload: dory

Post on 08-Feb-2016

40 views

Category:

Documents


0 download

DESCRIPTION

Giorgi Japaridze Theory of Computability. Additional NP-complete problems. Section 7.5. 7.5.a. Giorgi Japaridze Theory of Computability. Why we want to see more NP-completeness proofs. For reasons that are not well understood, most naturally occurring - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Additional NP-complete problems

Additional NP-complete Additional NP-complete problemsproblems

Section 7.5

Giorgi Japaridze

Theory of Computability

Page 2: Additional NP-complete problems

Why we want to see more NP-completeness proofs 7.5.a Giorgi Japaridze Theory of Computability

For reasons that are not well understood, most naturally occurring NP-problems are known to be either in P or to be NP-complete (the graph isomorphism problem being one notable exception; so was the COMPOSITES problem until a few years ago). So, if you seek a polynomial time algorithm for a new NP-problem, spending part of your effort attempting to prove it NP-complete issensible because doing so may prevent you from wasting time. This explains why we want to exercise more with NP-completeness proofs. Such proofs usually proceed by finding a polynomial reduction from an already known NP-complete language, most typically from 3SAT. When doing so, we look for structures in the language under question that can simulate the variables and clauses of Boolean formulas. For example, when reducing 3SAT to CLIQUE, variables were simulated by vertices, and clauses by triples. Such structures areoften called gadgets.

Page 3: Additional NP-complete problems

The NP-completeness of CLIQUE 7.5.b Giorgi Japaridze Theory of Computability

Corollary 7.43 CLIQUE is NP-complete.

Proof.

As was already (easily) observed, CLIQUE is in NP.

Next, Theorem 7.32 showed that 3SAT is polynomial time reducibleto CLIQUE.

In turn, by Corollary 7.42, 3SAT is NP-complete.

But Theorem 7.36 says that if an NP-complete language is polynomialtime reducible to an NP-language C, then C is NP-complete.

Hence CLIQUE is NP-complete.

Page 4: Additional NP-complete problems

The VERTEX-COVER problem defined 7.5.c Giorgi Japaridze Theory of Computability

If G is an undirected graph, a vertex cover of G is a subset of the nodes where every edgeof G touches (at least) one of those nodes.

1 2

3 4

G

VERTEX-COVER = = {<G,k> | G is an undirected graph that has a k-node vertex cover}

<G,4> VERTEX-COVER?

<G,3> VERTEX-COVER?

<G,2> VERTEX-COVER?

<G,1> VERTEX-COVER?

Page 5: Additional NP-complete problems

The NP-completeness of VERTEX-COVER (a)7.5.d Giorgi Japaridze Theory of Computability

Theorem 7.44 VERTEX-COVER is NP-complete.

Proof. Obviously VERTEX-COVERNP (why?). Next, we are going to set up a polynomial time reduction from 3SAT to this language. It maps a 3cnf-formula to a graph G and a value k, such that is satisfiable iff G has a vertex cover of size k.

For each variable x in , we produce a horizontal edge connecting twonodes. We label the two nodes in this gadget x and x. Setting x to beTRUE is going to correspond to selecting the left node for the vertex cover, and setting it to be FALSE correspond to selecting the right node. For example, when = (x x z) (x z z) (x z z),the reduction produces the following two variable gadgets:

xx zz

Page 6: Additional NP-complete problems

The NP-completeness of VERTEX-COVER (b)7.5.e Giorgi Japaridze Theory of Computability

= (x x z) (x z z) (x z z)

xx zz

Next, for each clause, we produce a triangle of (interconnected) nodes,each node of a triangle labeled with the corresponding literal of the corresponding clause. These triangles are clause gadgets.

zx

x

zz

x

zz

x

Finally, we connect each variable-gadget node to each clause-gadgetnode with the identical label.

Page 7: Additional NP-complete problems

The NP-completeness of VERTEX-COVER (c)7.5.f Giorgi Japaridze Theory of Computability

= (x x z) (x z z) (x z z)

xx zz

Thus, G has 2m+3l nodes, where m is the number of variables in and l is the number of clauses. Let k be m+2l. In the present example, k = 2+(23) = 8.

zx

x

zz

x

zz

x

Claim. is satisfiable iff G has a vertex cover of size k.

Page 8: Additional NP-complete problems

The NP-completeness of VERTEX-COVER (d)7.5.g Giorgi Japaridze Theory of Computability

= (x x z) (x z z) (x z z)

xx zz

Suppose is satisfiable.

zx

x

zz

x

zz

x

Include the variable-gadget nodes corresponding to true literals in the VC. Next, for each clause gadget, select a true-literal-labeled node, andinclude the other two nodes in the VC. We got the total of k nodes. All edges within the variable and clause gadgets are obviously covered. And every intergadget edge is covered either by a (true) variable-gadget node, or by one of the two nodes of the clause gadget that have been included in the vertex cover.

Page 9: Additional NP-complete problems

The NP-completeness of VERTEX-COVER (e)7.5.h Giorgi Japaridze Theory of Computability

= (x x z) (x z z) (x z z)

xx zz

Suppose now G has a VC of size k. Clearly it should include at least one node from each variable gadget and at least two nodes from each clause gadget.

zx

x

zz

x

zz

x

As this number sums up to k, those nodes are exactly the nodes of the vertex cover. We take the nodes of the variable gadgets that are in the VC and assign TRUE to the corresponding literals. This assignment satisfies because, if you take any clause gadget, the node which is not in the VC is (has to be) connected with an edge to a true-literal node of a variable gadget, for otherwise that intergadget edge would not be covered.

Page 10: Additional NP-complete problems

The NP-completeness of HAMPATH (a)7.5.i Giorgi Japaridze Theory of Computability

Theorem 7.46 HAMPATH is NP-complete.

Proof. That HAMPATH is in NP has already been shown. Now we set up a polynomial time reduction from 3SAT to HAMPATH. Consider an arbitrary 3cnf-formula with k clauses:

= (p1 q1 r1) (p2 q2 r2) … (pk qk rk)

c1 c2 … ck

We assume that contains l variables x1,…,xl. Each such variable will be represented with a diamond-shaped structure with 3k+5 nodes:

…xi

And each clause will be representedwith a single node:

cj

Page 11: Additional NP-complete problems

The NP-completeness of HAMPATH (b)7.5.j Giorgi Japaridze Theory of Computability

…x2

c1

…x1

…xl

. . .

c2

c3 . . .

ck

The overall structure of G looks like this.

There are additionaledges connecting clause nodes withinternal nodes of diamonds, explainedon the next slide.

s

t

Page 12: Additional NP-complete problems

The NP-completeness of HAMPATH (c)7.5.k Giorgi Japaridze Theory of Computability

…xi

c1 c2 c3 ck

The horizontal nodes in a diamond structure are grouped as follows:

xi … … cj

cj

xi … … cj

cj

Additional edges when clause cj contains xi :

Additional edges when clause cj contains xi :

Page 13: Additional NP-complete problems

The NP-completeness of HAMPATH (d)7.5.l Giorgi Japaridze Theory of Computability

…x2

c1

…x1

…xl

. . .

c2

c3 . . .

ck

s

t

Suppose is satisfiable.

Consider the path that zig-zags through truediamonds, and zag-zigsthrough false diamonds.

TRUEzig-zag

TRUEzig-zag

FALSEzag-zig

It covers all the nodes except the clause nodes c1,…,ck. We caneasily include them byselecting one true literalin each clause and then adding a detour from the corresponding pair of horizontal nodes of the of the corresponding diamond. E.g.,when c1

includes x1 and x1 is Selected for c1, we have:

Page 14: Additional NP-complete problems

The NP-completeness of HAMPATH (e)7.5.m Giorgi Japaridze Theory of Computability

…x2

c1

…x1

…xl

. . .

c2

c3 . . .

ck

s

t

On the other hand, if c1 included x2 and x2 was selected for c1,we would set up the detour in the opposite direction as you see.

The same story for c2, only the detour will be from the next pair of horizontal nodes, i.e. nodes #6-7 (rather than #3-4).

And so on.

The resulting path with detours is obviouslyHamiltonian.

TRUEzig-zag

TRUEzig-zag

FALSEzag-zig

Page 15: Additional NP-complete problems

The NP-completeness of HAMPATH (e)7.5.n Giorgi Japaridze Theory of Computability

…x2

c1

…x1

…xl

. . .

c2

c3 . . .

ck

s

t

For the reverse direction,assume G has a Hamiltonianpath from s to t. With a little thought, one can see that the path should be normal, meaning that it goes through the diamonds in order from the top one to the bottom one, except for the detours to the clause nodes. From such a normal path we can easily obtain a satisfying assignment: if it zig-zags through the diamond, assign TRUE to the corresponding variable. And if it zag-zigs, then assign FALSE.

TRUEzig-zag

TRUEzig-zag

FALSEzag-zig

Page 16: Additional NP-complete problems

The NP-completeness of UHAMPATH 7.5.o Giorgi Japaridze Theory of Computability

UHAMPATH is the undirected version of HAMPATH.

Theorem 7.55 UHAMPATH is NP-complete.

Proof: By reducing HAMPATH to UHAMPATH. Given a directed graph G, we construct its undirected equivalent G’ by replacing each node u of G by three nodes: uin, umid and uout; except the node s which gets replaced by sout, and the node t which gets replaced by tin. G’ has two types of edges. One type connects each umid with uin and uout. The other type connects each uout with vin, as long as there is an edge from u to v in G. Now, suppose G has a Hamiltonian path

s, u1, u2, …, uk, tThen obviously the following is a Hamiltonian path in G’:

sout, u1in, u1

mid, u1out, u2

in, u2mid, u2

out, …, ukin, uk

mid, ukout, tin

For the reverse direction, suppose G’ has a Hamiltonian path. With a little thought we find that it has to look like .But then obviously is a Hamiltonian path in G.

sout, u1in, u1

mid, u1out, u2

in, u2mid, u2

out, …, ukin, uk

mid, ukout, tin

s, u1, u2, …, uk, t

Page 17: Additional NP-complete problems

The NP-completeness of SUBSET-SUM (a) 7.5.p Giorgi Japaridze Theory of Computability

Theorem 7.56 SUBSET-SUM is NP-complete.

Proof: That SUBSET-SUMNP was shown in Theorem 7.25. Now we construct a polynomial time reduction from 3SAT to SUBSET-SUM. Let be a 3-cnf Boolean formula with variables x1,…,xl and clauses c1,…,ck. We construct an (l+k)(2l+2k+1) table of decimal digits. The columns are labeled with x1,…,xl, c1,…,cl, and the rows are labeled with y1,z1, y2,z2, …, yl,zl, g1,h1, g2,h2, …, gk,hk, t. The rows of this table are read as decimal numbers. The first 2l+2k rows, as numbers, comprise the set S, and the last row is the target number t. It will be seen later that S has a subset R summing up to t iff is satisfiable. Specifically, row/number t consists of l 1s followed by k 3s. Each row yi has a 1 in the xi column, and also in each cj column such that clause cj contains xi. Each row zi has a 1 in the xi column, and also in each cj column such that clause cj contains xi. Finally, each row gi and hi has a 1 in the ci column. Digits not specified above are all 0s.

Page 18: Additional NP-complete problems

The NP-completeness of SUBSET-SUM (b) 7.5.q Giorgi Japaridze Theory of Computability

y1

z1

y2

z2

…yl

zl

g1

h1

g2

h2…gk

hk

t

x1 x2 x3 x4 … xl c1 c2 … ck

11

1 1

y3

z3

1 1

1 1

1 1 1 1 … 1 3 3 … 3

1 1

1 1

1 1

(x1 x2 x3)

(x2 x3 …)

(x3 … …)

1

1

1 1

1 1

Page 19: Additional NP-complete problems

The NP-completeness of SUBSET-SUM (c) 7.5.r Giorgi Japaridze Theory of Computability

y1

z1

y2

z2

…yl

zl

g1

h1

g2

h2…gk

hk

t

x1 x2 x3 x4 … xl c1 c2 … ck

11

1 1

y3

z3

1 1

1 1

1 1 1 1 … 1 3 3 … 3

1 1

1 1

1 1

1

1

1 1

1 1

Suppose has a satisfying assignment. We construct a subset R of S as follows: Select yi if xi is assigned TRUE, and select zi if xi is assigned FALSE.

If we add up what we have selected so far, we obtain a 1 in each of the first l digits because we have selected either yi or zi for each i.

Furthermore, each of the last k digits is a number between 1 and 3 because each clause is satisfied and so contains between 1 and 3 true literals.

Now we further select enough of the g and hnumbers to bring each of the last k digits up to 3, thus hitting the target.

Page 20: Additional NP-complete problems

The NP-completeness of SUBSET-SUM (d) 7.5.s Giorgi Japaridze Theory of Computability

y1

z1

y2

z2

…yl

zl

g1

h1

g2

h2…gk

hk

t

x1 x2 x3 x4 … xl c1 c2 … ck

11

1 1

y3

z3

1 1

1 1

1 1 1 1 … 1 3 3 … 3

1 1

1 1

1 1

1

1

1 1

1 1

Now suppose a subset R of S sums to t. Observe that each column in the table describing S has at most five 1s. So, a “carry”into the next column never occurs when a subset of S is added. To get a 1 in each of the first l columns oft, we must have either yi or zi for each i, but not both. If it is yi, we assign xi TRUE, otherwise assign FALSE. This assignment must satisfy because in each of the final k columns the sum is always 3. In column cj, at most 2 can come from gj and hj, so at least 1 in this column should come from some yi or zi in the subset. If it is yi, then xi appears in cj and is assigned TRUE, so cj is satisfied. If it is zi, then xi appears in cj and xi is assigned FALSE, so cj is satisfied. Therefore, is satisfied.