• 沒有找到結果。

•••• Proof Methods NP-Completeness : Proofs

N/A
N/A
Protected

Academic year: 2022

Share "•••• Proof Methods NP-Completeness : Proofs"

Copied!
53
0
0

加載中.... (立即查看全文)

全文

(1)

NP-Completeness :

Proofs

• •

• Proof Methods

A method to show a decision problem ΠΠΠΠ NP-complete is as follows.

(1) Show ΠΠΠΠ∈∈∈∈NP.

(2) Choose an NP-complete problem ΠΠΠΠ’.

(3) Show ΠΠ’ ∝ΠΠ ∝∝∝ ΠΠΠΠ.

A method to show an optimization problem ΨΨΨΨ NP-hard is as follows.

(1) Choose an NP-hard problem ΨΨΨ’Ψ ΨΨΨ’ may be NP-complete).

(2) Show ΨΨΨΨ’ ∝∝∝∝ ΨΨΨΨ.

An alternative method to show ΨΨΨ NP-hard is to Ψ show the decision version of ΨΨΨ NP-complete. Ψ

(2)

• •

• Two Simple Examples

Ex. Sum of Subsets

Instance: A finite set A of positive integers and a positive integer c.

Question: Is there a subset A’ of A whose elements sum to c?

For example, if A={7, 5, 19, 1, 12, 8, 14} and c=21, then the answer is yes (A’={7, 14}).

NP-completeness of Sum of Subsets is shown below.

Sum of Subsets ∈∈ NP.

(3)

Exact Cover

Instance: A finite set S and k subsets S1, S2, …, Sk of S.

Question: Is there a subset of {S1, S2, …, Sk} that forms a partition of S?

For example, if S={7, 5, 19, 1, 12, 8, 14}, k=4, S1 ={7, 19, 12, 14}, S2 ={7, 5, 8}, S3 ={5, 1, 8}, and S4 ={19, 1, 8, 14}, then the answer is yes ({S1, S3} forms a partition of S).

(4)

Exact Cover ∝∝∝∝ Sum of Subsets.

Let S={u1, u2, …, um} and S1, S2, …, Sk be an arbitrary instance of Exact Cover.

An instance of Sum of Subsets can be obtained in polynomial time as follows.

A={a1, a2, …, ak} and c= m (

)

i

k i

=

1 +

0

1 , where for 1≤≤≤≤j≤≤≤≤k,

aj =

, (

)

m i j i

e k i

=

+

1

1 1,

with ej,i =1 if ui ∈∈∈∈Sj and ej,i =0 if ui ∉∉∉∉Sj.

⇒ Sum of Subsets has the answer yes if and

(5)

For example, given the following instance of Exact Cover:

S={7, 5, 19, 1, 12, 8, 14}, k=4, S1 ={7, 19, 12, 14}, S2 ={7, 5, 8},

S3 ={5, 1, 8}, and S4 ={19, 1, 8, 4},

a matrix

e

is defined as follows.

7 5 19 1 12 8 14

1 2 3 4

1 0 1 0 1 0 1 1 1 0 0 0 1 0 0 1 0 1 0 1 0 0 0 1 1 0 1 1 S

S S S

 

 

 

 

 

 

An instance of Sum of Subsets is constructed as follows.

(6)

A={a1, a2, a3, a4} and c=50+51+52+ … +56, where

a1 =50+52+54+56 (1st row of

e

);

a2 =50+51+55 (2nd row of

e

);

a3 =51+53+55 (3rd row of

e

);

a4 =52+53+55+56 (4th row of

e

).

The construction relates ai with Si and c with S.

It is not difficult to see

a1 +a3 =c ⇔⇔⇔⇔ S1 ∪∪∪∪S3 =S and S1 ∩∩∩∩S3 =∅. ∅∅

(7)

Ex. Partition

Instance: A multiset B={b1, b2, …, bn} of positive integers.

Question: Is there a subset B’⊆⊆⊆⊆B such that

i

b B' i

b

=

j

b B B' j

b

?

For example, when B={17, 53, 9, 35, 41, 32, 35}, then the answer is yes (B’={17, 53, 41}).

NP-completeness of Partition is shown below.

Partition ∈∈ NP.

A chosen NP-complete problem: Sum of Subsets.

(8)

Sum of Subsets ∝∝∝∝ Partition

Let A={a1, a2, …, am} and c be an arbitrary instance of Sum of Subsets.

An instance of Partition can be obtained in polynomial time as follows:

B = A ∪∪∪∪ {am+1, am+2},

where am+1 =c+1 and am+2 =1−−−−c+

i

a A i

a

.

Since am+1 +am+2 =

i

a A i

a

+2, we have {am+1, am+2}⊄⊄⊄⊄B’ and {am+1, am+2}⊄⊄⊄⊄B−−−−B’.

We show below that

i

a Α' i

a

= c if and only if a +

a = a +

a

(9)

(⇒⇒⇒⇒) Suppose

i

a Α' i

a

= c.

am+2 +

i

a Α' i

a

= (1−−−−c+

i

a A i

a

)+

i

a Α' i

a

= 1+

i

a Α i

a

.

am+1 +

i

a Α Α' i

a

= (c+1)+

i

a Α Α' i

a

= 1+

i

a Α i

a

.

(⇐⇐⇐⇐) Suppose am+2 +

i

a Α' i

a

= am+1 +

i

a Α Α' i

a

, i.e., B’=A’+{am+2}.

Then, (1−−−−c+

i

a A i

a

)+

i

a Α' i

a

= (c+1)+

i

a Α Α' i

a

,

from which

a = c can be derived.

(10)

Exercise 5. Read Example 8-14 on page 367 of the textbook.

(1) Give a reduction from Partition to the bin packing problem.

(2) Illustrate the reduction by an example.

(3) Verify the reduction.

Exercise 6. Read Theorem 11.2 on page 518 of Ref. (2).

(1) Give a reduction from Satisfiability to Clique.

(2) Illustrate the reduction by an example.

(3) Verify the reduction.

(11)

• •

• Three Proof Techniques

Restriction

Local Replacement Component Design

(12)

• •

• Restriction

If a problem ΠΠΠΠ contains an NP-hard problem ΠΠΠ’ Π as a special case (i.e., ΠΠΠΠ’ is a restricted subproblem of ΠΠΠΠ), then ΠΠΠΠ is NP-hard.

Ex. Exact Cover

Instance: A finite set S and k subsets S1, S2, …, Sk of S.

Question: Is there a subset of {S1, S2, …, Sk} that forms a partition of S?

Exact Cover by 3-Sets

Instance: A finite set S with |S|=3p and k 3-

(13)

Exact Cover by 3-Sets is a special case of Exact Cover.

3-Dimensional Matching

Instance: A set M⊆⊆⊆⊆W××××X××××Y, where W, X and Y are three disjoint q-element subsets.

Question: Does M contain a matching, i.e., a subset M’⊆⊆⊆⊆M such that |M’|=q and no two elements of M’ agree in any coordinate?

For example, if W={0, 1}, X={a, b}, Y={+++, −+ −−−}, and M={(0, a, ++++), (1, b, +++),+ (1, b, −−−−)}, then the answer is yes (M’={(0, a, +++), (1, b, −+ −−−)}).

3-Dimensional Matching is a special case of Exact Cover by 3-Sets.

(14)

For example, the following instance of 3-Dimensional Matching:

W={0, 1}, X={a, b}, Y={++++, −−},

and M={(0, a, ++++), (1, b, +++),+ (1, b, −−−−)}

can be transformed into an instance of Exact Cover by 3-Sets as follows:

S1 ={0W, aX, ++++Y}, S2 ={1W, bX, ++++Y}, S3 ={1W, bX, −−−−Y}, and S=W∪∪∪∪X∪∪∪∪Y={0W, 1W, aX, bX, ++++Y, −−−−Y}.

Therefore,

3-Dimensional Matching is NP-complete.

⇒⇒

Exact Cover by 3-Sets is NP-complete.

⇒⇒

Exact Cover is NP-complete.

(15)

Ex. Hamiltonian Cycle

Instance: An undirected graph G=(V, E).

Question: Does G contain a Hamiltonian Cycle, i.e., an ordering (v1, v2, …, v|V|) of the vertices of G such that (v1, v|V|)∈∈∈∈

E and (vi, vi+1)∈∈∈∈E for all 1≤≤≤≤i<|V|?

Directed Hamiltonian Cycle

Instance: A directed graph G=(V, A), where A is a set of arcs (i.e., ordered pairs of vertices).

Question: Does G contain a directed Hamiltonian cycle, i.e., an ordering (v1, v2, …, v|V|) of the vertices of G such that (v1, v|V|)∈∈∈ A and (vi, vi+1)∈∈∈∈A for all 1≤≤≤≤i<|V|?

(16)

Hamiltonian Cycle is a special case of Directed Hamiltonian Cycle (or Hamiltonian Cycle ∝∝∝

Directed Hamiltonian Cycle, where each (u, v)∈∈∈∈E corresponds to two arcs (u, v), (v, u)∈∈∈∈A).

Therefore,

Hamiltonian Cycle is NP-complete.

⇒⇒

Directed Hamiltonian Cycle is NP-complete.

(17)

Hamiltonian Path between Two Vertices

Instance: An undirected graph G=(V, E) and two distinct vertices u, v∈∈∈∈V.

Question: Does G contain a Hamiltonian path starting at u and ending at v, i.e., an ordering (v1, v2, …, v|V|) of the vertices of G such that u=v1, v=v|V|, and (vi, vi+1)∈∈∈∈E for all 1≤≤≤≤i<|V|?

Hamiltonian Cycle ∝∝∝∝ Hamiltonian Path between Two Vertices:

if the latter is polynomial time solvable,

then the former is also polynomial time solvable (considering all edges (u, v)∈∈∈∈V for the latter).

⇒⇒⇒ Hamiltonian Path between Two Vertices is

(18)

Hamiltonian Path

Instance: An undirected graph G=(V, E).

Question: Does G contain a Hamiltonian path?

Hamiltonian Cycle ∝∝∝∝ Hamiltonian Path:

For each (u, v)∈∈∈∈E, construct an instance of Hamiltonian Path by adding x, y to V and

(x, u), (y, v) to E (thus G’ is induced).

u v u v

x y

G G’

G has a Hamiltonian cycle if and only if G’ has a Hamiltonian x-y path.

(19)

Exercise 7. Show the following two problems NP- complete by restriction to Hamiltonian Path and Partition, respectively.

Bounded Degree Spanning Tree

Instance: An undirected graph G=(V, E) and a positive integer k≤≤≤≤|V|−−−−1.

Question: Does G contains a spanning tree in which each node has degree at most k?

0/1 Knapsack

Instance: A finite set U, a “size” s(u)∈∈∈∈Z+ and a “value” v(u)∈∈∈∈Z+ for each u∈∈∈∈U, a size constraint b∈∈∈∈Z+, and a value goal k∈∈∈∈Z+.

Question: Is there a subset U’⊆⊆⊆⊆U such that

(20)

• •

• Local Replacement

In order to show ΠΠΠΠ’ ∝∝∝∝ ΠΠΠΠ, local replacement specifies the “basic units” for ΠΠΠΠ’ and replaces them with

others, while constructing a corresponding instance of ΠΠ. ΠΠ

Usually, local replacement has one kind of basic units that each are replaced with the same structure.

Ex. Partition into Triangles

Instance: An undirected graph G=(V, E) with

|V|=3p for some integer p>0.

Question: Is there a partition of V into 3-vertex subsets V1, V2, …, Vp, such that each

(21)

For example, the answer for the following instance is yes, because V can be partitioned into {1, 2, 3}, {4, 5, 6}, {7, 8, 9} or {1, 4, 7}, {2, 5, 6}, {3, 8, 9}.

1

2 3

4

5 6

7

8 9

Exact Cover by 3-Sets ∝∝∝∝ Partition into Triangles is shown below.

Let a set S, where |S|=3p, and a collection C of 3-element subsets of S denote an arbitrary instance of Exact Cover by 3-Sets.

Construct an instance of Partition into Triangles as follows.

(22)

Consider each subset {xi, yi, zi}∈∈∈∈C a basic unit, and replace it with the following structure.

ai[3]

ai[1] ai[2]

ai[4] ai[5]

ai[6]

ai[7] ai[8]

ai[9]

xi yi zi

For example, if S={1, 2, 3, 4, 5, 6} and C= {{1, 4, 6}, {2, 4, 6}, {2, 3, 5}}, then an instance of Partition into Triangles is obtained as follows.

3 5

(23)

It is not difficult to check that if Exact Cover by 3-Sets has an answer yes (e.g., {{1, 4, 6}, {2, 3, 5}}

is a partition of S), then Partition into Triangles has an answer yes (the triangles are shown with bold edges).

Also, if Partition into Triangles has an answer yes, then Exact Cover by 3-Sets has an answer yes.

Exercise 8. Read Example 8-9 on page 353 of the textbook.

(1) Give a reduction from Satisfiability to 3-Satisfiability.

(2) Illustrate the reduction by an example.

(3) Verify the reduction.

(24)

Sometimes, additional structures are required, while using the technique of local replacement.

Ex. Sequencing within Intervals

Instance: A finite set T of “tasks” and for each t∈∈∈∈T, a “release time”

r(t)∈∈∈∈Z+ ∪∪∪∪{0}, a “deadline”

d(t)∈∈∈∈Z+, and a “length” l(t)∈∈∈∈Z+. Question: Does there exist a feasible schedule for T, i.e., a function f:T→→→→Z+ such that for each t∈∈∈∈T, f(t)≥≥≥≥r(t),

f(t)+l(t)≤≤≤≤d(t), and f(t’)+l(t’)≤≤≤≤f(t) or f(t)+l(t)≤≤≤≤f(t’) for each t’∈∈∈∈T−−−−{t}? (It means that the task t, which is “executed”

(25)

Partition ∝∝∝∝ Sequencing within Intervals is shown below.

An arbitrary instance of Partition:

a multiset B={b1, b2, …, bn} of positive integers.

Consider each bi (1≤≤≤≤i≤≤≤≤n) a basic unit, and let

m = i

i n

b

≤ ≤

1

.

Construct an instance of Sequencing within Intervals as follow:

each bi corresponds to a task ti with r(ti)=0, d(ti)=m+1, and l(ti)=bi.

An additional structure:

a task t% with r t%( )= m/2, d t%( )= (m+1)/2, and l t%( )=1.

⇒ m should be even

(26)

⇒⇒⇒

r t%( )= m/2, d t%( )= (m/2)+1

⇒⇒

f t%( ) must be m/2.

⇒ Partition has the answer yes if and only if Sequencing within Intervals has the answer yes.

2

m 1

2 m+

0 m+1

t%

2 m

2 m

Time

(27)

• •

• Component Design

While showing ΠΠΠΠ’ ∝∝∝∝ ΠΠΠΠ, component design is similar to local replacement in replacing the structures (i.e., basic units) of ΠΠ’ΠΠ with other structures, in order to obtain an instance of Π

Π ΠΠ.

Usually, component design adopts multiple kinds of basic units, and different basic units are replaced with different structures.

Ex. Vertex Cover

Instance: An undirected graph G=(V, E) and a positive integer k≤≤≤≤|V|.

Question: Does G contain a vertex cover of size at most k, i.e., a subset V’⊆⊆⊆⊆V such that |V’|≤≤≤≤k and for each (u, v)∈∈∈∈E,

(28)

For example, {1, 3}, {1, 2, 3} and {1, 2, 4, 5} are three vertex covers of the following graph. If k≥≥≥≥2, the answer is yes. If k=1, the answer is no.

We show below 3-Satisfiability ∝∝∝∝ Vertex Cover.

3-Satisfiability

Instance: A set U of variables and a collection C={c1, c2, …, cm} of clauses over U, where each clause of C contains three literals.

(29)

For example, when U={x1, x2, x3} and C= {x1 ∨∨∨∨x2 ∨∨∨∨x3, x

1 ∨∨∨∨x2 ∨∨∨∨ x

3, x1 ∨∨∨∨ x

2 ∨∨∨∨x3}, the answer is yes, becausethe assignment of U: x1 ←←←←F, x2 ←←←←F, and x3 ←←←←T, can satisfy C (i.e., (x1 ∨∨∨∨x2 ∨∨∨∨x3)∧∧∧∧(x

1 ∨∨∨∨x2 ∨∨∨∨ x

3)∧∧∧∧(x1 ∨∨∨∨ x

2 ∨∨∨∨x3) = T).

Let U={u1, u2, …, un} and C={c1, c2, …, cm} be an arbitrary instance of 3-Satisfiability.

♦ For each ui ∈∈∈∈U, construct a component Ti = (Vi, Ei), where Vi ={ui,

ui } and Ei ={(ui,

ui)}.

♦ For each cj ∈∈∈∈C, construct a component Sj = (V’j, E’j), where V’j ={a1[j], a2[j], a3[j]} and E’j ={(a1[j], a2[j]), (a1[j], a3[j]), (a2[j], a3[j])}.

♦ For each cj ∈∈∈∈C, construct an edge set E’’j = {(a1[j], xj), (a2[j], yj), (a3[j], zj)}, where xj, yj and zj are the three literals in cj.

(30)

An instance of Vertex Cover can be constructed as G=(V, E) and k=n+2m, where

V = ( n

i Vi

=1

U ) ∪∪∪∪ ( m

j V'j

=1

U ) and

E = ( n

i Ei

=1

U ) ∪∪∪∪ ( m

j E'j

=1

U ) ∪∪ (m

j E''j

=1

U ).

For example, if U={u1, u2, u3, u4} and C= {u1 ∨∨∨∨ u

3 ∨∨∨∨u

4, u

1 ∨∨∨∨u2 ∨∨∨∨ u

4}, then the following instance of Vertex Cover is constructed, where k=8.

(31)

•••

• Each edge in E’’j represents a satisfying truth assignment for cj.

For example, (u1, a1[1])∈∈∈∈E’’1 implies that u1 ←←←←T can satisfy c1.

•••

• Any vertex cover V’⊆⊆⊆⊆V of G contains at least one from {ui,

ui } and at least two from {a1[j], a2[j], a3[j]}.

⇒ |V’| ≥≥≥≥ n+2m=k

As explained below, C is satisfiable if and only if G has a vertex cover V’⊆⊆⊆⊆V with |V’|≤≤≤≤k.

(32)

♣♣♣

♣ C is satisfiable ⇒⇒ V’⇒ ⊆⊆⊆⊆V with |V’|≤≤≤≤k exists

Consider the example above, where u1 ←←←←T, u2 ←←←←T, u

3 ←←←←T, and u

4 ←←←←T can satisfy C.

⇒ include u1, u2, u

3, u

4 in V’

In order to make V’ a vertex cover, V’ must be augmented with two vertices from each set

{a1[j], a2[j], a3[j]}, while covering all edges in E’’j.

⇒⇒

⇒ augment V’ with any two from {a1[1], a2[1], a3[1]} and a1[2], a2[2] (or a1[2], a3[2]) from {a1[2], a2[2], a3[2]}

(a1[2] must be included in V’, in order to cover the edge (u , a1[2]))

(33)

♣♣♣

♣ V’⊆⊆⊆⊆V with |V’|≤≤≤≤k exists ⇒⇒ C is satisfiable

V’ contains exactly k=n+2m vertices: one for each {ui,

ui } and two for each {a1[j], a2[j], a3[j]}.

Consider the example above, where k=8 and V’={u

1, u2, u

3, u4, a1[1], a3[1], a1[2], a3[2]} is a vertex cover.

⇒⇒⇒

u

1 ←←←←T, u2 ←←←←T, u

3 ←←←←T and u4 ←←←←T can satisfy C (u

1, u2, u

3, u4∈ V’)

Since two (e.g., a1[1] and a3[1]) from {a1[j], a2[j], a3[j]} are included in V’, the other (e.g., a2[1]) must be connected to ui or

ui (e.g., u

3) that is included in V’.

⇒⇒

⇒ each cj is satisfiable.

(34)

Ex. Minimum Tardiness Sequencing

Instance: A finite set T of “tasks”, where each t∈∈∈∈T has “length” 1 and “deadline”

d(t)∈∈∈∈Z+, a partial order p on T, and a non-negative integer r≤≤≤≤|T|.

Question: Is there a “schedule” f: T→→→→{0, 1, …,

|T|−−−−1} such that f(t)≠≠≠≠f(t’) if t≠≠≠≠t’, f(t)<f(t’) if tp t’, and

|{t∈∈∈∈T: f(t)+1>d(t)}| ≤≤≤≤ r?

A task t∈∈∈∈T is tardy, if f(t)+1>d(t).

The schedule f is required not to cause more than r tasks tardy.

(35)

Clique

Instance: An undirected graph G=(V, E) and a positive integer k≤≤≤≤|V|.

Question: Does there exist a subset V’⊆⊆⊆⊆V such that |V’|≥≥≥≥k and every two vertices of V’ are adjacent in G?

Let G=(V, E) and k≤≤≤≤|V| be an arbitrary instance of Clique.

An instance of Minimum Tardiness Sequencing can be constructed as follows.

T = V∪∪∪∪E;

r = |E|−−−−k(k−−−−1)/2;

vp e ⇔⇔⇔⇔ v∈∈∈∈V, e∈∈∈∈E, and v is an endpoint of e;

d(v) = |V|+|E| for v∈∈∈∈V, and

參考文獻

相關文件

• A concrete problem is polynomial-time solvable if there exists an algorithm that solves any concrete instance of length n in time for some constant k. • Solvable = can produce

• Algorithmic design methods to solve problems efficiently (polynomial time).. • Divide

Specifically, we establish three basic properties of the connectivity region – contiguity, monotonicity of the boundary, and uniqueness of the infinite connected component, where

Let us consider the numbers of sectors read and written over flash memory when n records are inserted: Because BFTL adopts the node translation table to collect index units of a

Students are asked to collect information (including materials from books, pamphlet from Environmental Protection Department...etc.) of the possible effects of pollution on our

 The TRG consists of two components: a basic component which is an annual recurrent cash grant provided to schools for the appointment of supply teachers to cover approved

For example, Ko, Chen and Yang [22] proposed two kinds of neural networks with different SOCCP functions for solving the second-order cone program; Sun, Chen and Ko [29] gave two

危機事件 後果 可預測性 持續性 震撼程度 估計危機 影響程度 一對小四及小. 二的兄妹,居 於學校同邨的