+ All Categories
Home > Documents > The Theory of NP-Completeness

The Theory of NP-Completeness

Date post: 06-Jan-2016
Category:
Upload: peers
View: 19 times
Download: 0 times
Share this document with a friend
Description:
The Theory of NP-Completeness. NP. =. NPC. P. P. X. P=NP. ?. NP: Non-deterministic Polynomial. P: Polynomial. NPC: Non-deterministic Polynomial Complete. P : the class of problems which can be solved by a deterministic p olynomial algorithm. - PowerPoint PPT Presentation
59
1 The Theory of NP-Completeness
Transcript
Page 1: The Theory of  NP-Completeness

1

The Theory of NP-Completeness

Page 2: The Theory of  NP-Completeness

2

NP

PNPC

NP: Non-deterministic Polynomial

P: Polynomial

NPC: Non-deterministic Polynomial Complete

P=NP?

X

=

P

Page 3: The Theory of  NP-Completeness

3

P: the class of problems which can be solved by a deterministic polynomial algorithm.

NP : the class of decision problem which can be solved by a non-deterministic polynomial algorithm.

NP-hard: the class of problems to which every NP problem reduces.

NP-complete (NPC): the class of problems which are NP-hard and belong to NP.

Page 4: The Theory of  NP-Completeness

4

Decision problems The solution is simply “Yes” or “No”. Optimization problem : more difficult

Decision problem E.g. the traveling salesperson problem

Optimization version:Find the shortest tour

Decision version:Is there a tour whose total length is less than or equal to a constant C ?

Page 5: The Theory of  NP-Completeness

5

Nondeterministic algorithms

A nondeterministic algorithm is an algorithm consisting of two phases: guessing and checking.

Furthermore, it is assumed that a nondeterministic algorithm always makes a correct guessing.

Page 6: The Theory of  NP-Completeness

6

Nondeterministic algorithms

They do not exist and they would never exist in reality.

They are useful only because they will help us define a class of problems: NP problems

Page 7: The Theory of  NP-Completeness

7

NP algorithm If the checking stage of a

nondeterministic algorithm is of polynomial time-complexity, then this algorithm is called an NP (nondeterministic polynomial) algorithm.

Page 8: The Theory of  NP-Completeness

8

NP problem

If a decision problem can be solved by a NP algorithm, this problem is called an NP (nondeterministic polynomial) problem.

NP problems : (must be decision problems)

Page 9: The Theory of  NP-Completeness

9

To express Nondeterministic Algorithm

Choice(S) : arbitrarily chooses one of the elements in set S

Failure : an unsuccessful completion

Success : a successful completion

Page 10: The Theory of  NP-Completeness

10

Nondeterministic searching Algorithm :

j ← choice(1 : n) /* guessif A(j) = x then success /* check

else failure A nondeterministic algorithm terminates unsuccessfully iff t

here exist no set of choices leading to a success signal. The time required for choice(1 : n) is O(1). A deterministic interpretation of a non-deterministic algorith

m can be made by allowing unbounded parallelism in computation.

Page 11: The Theory of  NP-Completeness

11

Problem Reduction

Problem A reduces to problem B (AB) iff A can be solved by using any algorithm whic

h solves B. If AB, B is more difficult (B is at least as hard a

s A)

Note:T(tr1) + T(tr2) < T(B) T(A) T(tr1) + T(tr2) + T(B) O(T(B))

instance of A

transformation T(tr1)

instance of B

T(A) T(B) solver of B

answer of A

transformation

T(tr2)

answer of B

Page 12: The Theory of  NP-Completeness

12

Polynomial-time Reductions

We want to solve a problem R; we already have an algorithm for S

We have a transformation function T Correct answer for R on x is “yes”, iff the

correct answer for S on T(x) is “yes” Problem R is polynomially reducible to

S if such a transformation T can be computed in polynomial time

The point of reducibility: S is at least as hard to solve as R

Page 13: The Theory of  NP-Completeness

13

Polynomial-time Reductions

We use reductions (or transformations) to prove that a problem is NP-complete

x is an input for R; T(x) is an input for S (R S)

T Algorithm for ST(x)

Yes or noanswer

x

Algorithm for R

Page 14: The Theory of  NP-Completeness

14

NPC and NP-hard

A problem A is NP-hard if every NP problem reduces to A.

A problem A is NP-complete (NPC) if A∈NP and every NP problem reduces to A. Or we can say a problem A is NPC if A∈NP and A is NP-hard.

Page 15: The Theory of  NP-Completeness

15

NP-Completeness “NP-complete problems”: the

hardest problems in NP Interesting property

If any one NP-complete problem can be solved in polynomial time, then every problem in NP can also be solved similarly (i.e., P=NP)

Many believe P≠NP

Page 16: The Theory of  NP-Completeness

16

Importance of NP-Completeness

NP-complete problems: considered “intractable”

Important for algorithm designers & engineers Suppose you have a problem to solve

Your colleagues have spent a lot of time to solve it exactly but in vain

See whether you can prove that it is NP-complete If yes, then spend your time developing an

approximation (heuristic) algorithm Many natural problems can be NP-complete

Page 17: The Theory of  NP-Completeness

17

Relationship Between NP and P

It is not known whether P=NP or whether P is a proper subset of NP

It is believed NP is much larger than P But no problem in NP has been proved as

not in P No known deterministic algorithms that ar

e polynomially bounded for many problems in NP

So, “does P = NP?” is still an open question!

Page 18: The Theory of  NP-Completeness

18

Cook’s theorem (1971)

NP = P iff SATNP = P iff SATPP SAT (the satisfiability problemthe satisfiability problem) is

NP-complete It is the first NP-complete problem Every NP problem reduces to SAT

Page 19: The Theory of  NP-Completeness

19

SAT is NP-complete Every NP problem can be solved by an NP al

gorithm Every NP algorithm can be transformed in p

olynomial time to an SAT problem (a Boolean formula C)

Such that the SAT problem is satisfiable iff the answer for the original NP problem is “yes”

That is, every NP problem SAT SAT is NP-complete

Page 20: The Theory of  NP-Completeness

20

Definition of the satisfiability problem: Given a Boolean formula, determine whether this formula is satisfiable or not.

A literal: xi or -xi A clause: x1 v x2 v -x3 Ci A formula: conjunctive normal form

C1& C2 & … & Cm

Page 21: The Theory of  NP-Completeness

21

The Satisfiability Problem The satisfiability problem

A logical formula: x1 v x2 v x3

& - x1 & - x2

the assignment : x1 ← F , x2 ← F , x3 ← T

will make the above formula true. (-x1, -x2 , x3) represents x1 ← F , x2 ← F , x3 ← T

Page 22: The Theory of  NP-Completeness

22

If there is at least one assignment which satisfies a formula, then we say that this formula is satisfiable; otherwise, it is unsatisfiable.

An unsatisfiable formula: x1 v x2 & x1 v -x2 & -x1 v x2 & -x1 v -x2

Page 23: The Theory of  NP-Completeness

23

Resolution principle c1 : -x1 v -x2 v x3 c2 : x1 v x4

c3 : -x2 v x3 v x4 (resolvent) If no new clauses can be deduced

satisfiable -x1 v -x2 v x3 (1)

x1 (2) x2 (3)

(1) & (2) -x2 v x3 (4) (4) & (3) x3 (5)

(1) & (3) -x1 v x3 (6)

The satisfiability problem

Page 24: The Theory of  NP-Completeness

24

The satisfiability problem If an empty clause is deduced unsatisfiable - x1 v -x2 v x3 (1) x1 v -x2 (2) x2 (3) - x3 (4) deduce (1) & (2) -x2 v x3 (5) (4) & (5) -x2 (6) (6) & (3) □ (7)

Page 25: The Theory of  NP-Completeness

25

Nondeterministic SAT

Guessing for i = 1 to n do xi ← choice( true, false

)

if E(x1, x2, … ,xn) is true

Checking then success

else failure

Page 26: The Theory of  NP-Completeness

26

Transforming Searching to SAT

Does there exist a number in { x(1), x(2), …, x(n) }, which is equal to 7?

Assume n = 2

Page 27: The Theory of  NP-Completeness

27

Transforming Search to SAT

Does there exist a number in { x(1), x(2), …, x(n) }, which is equal to 7?

Assume n = 2.

nondeterministic algorithm:

i = choice(1,2)

if x(i)=7 then SUCCESS

else FAILURE

Page 28: The Theory of  NP-Completeness

28

i=1 v i=2& i=1 → i≠2 & i=2 → i≠1 & x(1)=7 & i=1 → SUCCESS & x(2)=7 & i=2 → SUCCESS & x(1)≠7 & i=1 → FAILURE & x(2)≠7 & i=2 → FAILURE & FAILURE → -SUCCESS & SUCCESS (Guarantees a successful termination) & x(1)=7 (Input data) & x(2)≠7

Page 29: The Theory of  NP-Completeness

29

CNF (conjunctive normal form) : i=1 v i=2 (1) i≠1 v i≠2 (2) x(1)≠7 v i≠1 v SUCCESS (3) x(2)≠7 v i≠2 v SUCCESS (4) x(1)=7 v i≠1 v FAILURE (5) x(2)=7 v i≠2 v FAILURE (6) -FAILURE v -SUCCESS (7) SUCCESS (8) x(1)=7 (9) x(2)≠7 (10)

Page 30: The Theory of  NP-Completeness

30

Satisfiable with the following assignment: i=1 satisfying (1) i≠2 satisfying (2), (4) and (6) SUCCESS satisfying (3), (4) and (8) -FAILURE satisfying (7) x(1)=7 satisfying (5) and (9) x(2)≠7 satisfying (4) and (10)

Page 31: The Theory of  NP-Completeness

31

Searching for 7, but x(1)7, x(2)7

CNF (conjunctive normal form): i=1 v i=2 (1) i1 v i2 (2) x(1)7 v i1 v S U C C E S S ( 3 ) x(2)7 v i2 v S U C C E S S ( 4 ) x(1)=7 v i1 v FAILURE (5 ) x(2)=7 v i2 v FAILURE (6 ) SUCCESS (7) -SUCCESS v -FAILURE (8) x(1) 7 (9) x(2) 7 (10)

Page 32: The Theory of  NP-Completeness

32

Apply resolution principle:

(9) & (5) i1 v FAILURE (11) (10) & (6) i2 v FAILURE (12) (7) & (8) -FAILURE (13) (13) & (11) i1 (14) (13) & (12) i2 (15) (14) & (1) i=2 (11) (15) & (16) □ (17)

We get an empty clause unsatisfiable 7 does not exit in x(1) or x(2).

Page 33: The Theory of  NP-Completeness

33

CNF:

i=1 v i=2 (1) i1 v i2 (2) x(1)7 v i1 v S U C C E S S ( 3 ) x(2)7 v i2 v S U C C E S S ( 4 ) x(1)=7 v i1 v FA I L U R E ( 5 ) x(2)=7 v i2 v FA I L U R E ( 6 ) SUCCESS (7) -SUCCESS v -FAILURE (8) x(1)=7 (9) x(2)=7 (10)

Searching for 7, where x(1)=7, x(2)=7

Page 34: The Theory of  NP-Completeness

34

The Node Cover Problem

Def: Given a graph G = (V, E), S is the node cover of G if S V and for ever edge (u, v) E, (u,v) is incident to a node in S.

node cover:{1, 3}{5, 2, 4}

Decision problem: S S K

Page 35: The Theory of  NP-Completeness

35

How to Prove a Problem S is NP-Complete?

1. Show S is in NP2. Select a known NP-complete problem

R Since R is NP-complete, all problems in NP

are reducible to R

3. Show how R can be poly. reducible to S Then all problems in NP can be poly.

reducible to S (because polynomial reduction is transitive)

4. Therefore S is NP-complete

Page 36: The Theory of  NP-Completeness

36

Cook

Cook showed the first NPC problem: SAT

Cook received Turing Award in 1982.

Page 37: The Theory of  NP-Completeness

37

Karp R. Karp showed several NPC problems, such as 3-STA, node (vertex) cover, and Hamiltonian cycle, etc.

Karp received Turing Award in 1985

Page 38: The Theory of  NP-Completeness

38

NP-Completeness Proof: Reduction

Vertex Cover

Clique 3-SAT

SAT

Chromatic Number

Dominating Set

All NP problems

Page 39: The Theory of  NP-Completeness

39

NPC Problems CLIQUE(k): Does G=(V,E) contain a clique o

f size k?

Definition: A clique in a graph is a set of vertices such

that any pair of vertices are joined by en edge.

Page 40: The Theory of  NP-Completeness

40

NPC Problems Vertex Cover(k): Given a graph G=(V, E) an

d an integer k, does G have a vertex cover with k vertices?

Definition: A vertex cover of G=(V, E) is V’V such th

at every edge in E is incident to some vV’.

Page 41: The Theory of  NP-Completeness

41

Dominating Set(k): Given an graph G=(V, E) and an integer k, does G have a dominating set of size k ?

Definition: A dominating set D of G=(V, E) is DV s

uch that every vV is either in D or adjacent to at least one vertex of D.

NPC Problems

Page 42: The Theory of  NP-Completeness

42

• SAT: Give a Boolean expression (formula) in DNF (conjunctive normal form), determine if it is satisfiable.

• 3SAT: Give a Boolean expression in DNF such that each clause has exactly 3 variables (literals), determine if it is satisfiable.

NPC Problems

Page 43: The Theory of  NP-Completeness

43

• Chromatic Coloring(k): Given a graph G=(V, E) and an integer k, does G have a coloring for k

Definition A coloring of a graph G=(V, E) is a function

f : V { 1, 2, 3,…, k } if (u, v) E, then f(u)f(v).

NPC Problems

Page 44: The Theory of  NP-Completeness

44

0/1 Knapsack problem

M(weight limit)=14best solution: P1, P2, P3, P5(optimal)

This problem is NP-complete.

P1 P2 P3 P4 P5 P6 P7 P8

Value 10 5 1 9 3 4 11 17

Weight

7 3 3 10 1 9 22 15

Page 45: The Theory of  NP-Completeness

45

Traveling salesperson problem

Given: A set of n planar pointsFind: A closed tour which includes all points exactly once such that its total length is minimized.

This problem is NP-complete.

Page 46: The Theory of  NP-Completeness

46

Partition problem Given: A set of positive integers S

Find: S1 and S2 such that S1S2=, S1S2=S, iS1i=iS2 i

(partition into S1 and S2 such that the sum of S1 is equal to S2)

e.g. S={1, 7, 10, 9, 5, 8, 3, 13} S1={1, 10, 9, 8} S2={7, 5, 3, 13}

This problem is NP-complete.

Page 47: The Theory of  NP-Completeness

47

Art gallery problem

NP-complete !!

Page 48: The Theory of  NP-Completeness

48

3-Satisfiability Problem (3-SAT)

Def: Each clause contains exactly three literals. (I)  3-SAT is an NP problem (obviously) (II) SAT 3-SAT Proof:

(1) One literal L1 in a clause in SAT:In 3-SAT:

L1 v y1 v y2

L1 v -y1 v y2

L1 v y1 v -y2

L1 v -y1 v -y2

Page 49: The Theory of  NP-Completeness

49

(2) Two literals L1, L2 in a clause in SAT:In 3-SAT:L1 v L2 v y1

L1 v L2 v -y1

(3) Three literals in a clause: remain unchanged.

(4) More than 3 literals L1, L2, …, Lk in a clause:in 3-SAT:L1 v L2 v y1

L3 v -y1 v y2

Lk-2 v -yk-4 v yk-3

Lk-1 v Lk v -yk-3

Page 50: The Theory of  NP-Completeness

50

The instance S in 3-SAT:

x1 v x2 v y1

x1 v x2 v -y1

-x3 v y2 v y3

-x3 v -y2 v y3

-x3 v y2 v -y3

-x3 v -y2 v -y3

x1 v -x2 v y4

x3 v -y4 v y5

-x4 v x5 v -y5

An instance S in SAT:

x1 v x2

-x3

x1 v -x2 v x3 v -x4 v x5

SAT transform 3-SAT S S

Example of Transforming a 3-SATInstance to an SAT Instance

Page 51: The Theory of  NP-Completeness

51

Chromatic Number Decision Problem (CN)

Def: A coloring of a graph G = (V, E) is a function f: V { 1, 2, 3,…, k } such that if (u, v) E, then f(u)f(v). The CN problem is to determine if G has a coloring for k.

E.g.

<Theorem> Satisfiability with at most 3 literals per clause (SATY) CN.

3-colorable f(a)=1, f(b)=2, f(c)=1f(d)=2, f(e)=3

Page 52: The Theory of  NP-Completeness

52

Set Cover Decision Problem

Def: F = { S1, S2, …, Sk } Si = { u1, u2, …, un } T is a set cover of F if T F and Si = Si

The set cover decision problem is to determine if F has a cover T containing no more than c sets.

Example: c=3. F = {(a1, a3), (a2, a4), (a2, a3), (a4), (a1, a3 , a4)} s1 s2 s3 s4 s5

T = { s1, s3, s4 } set cover T = { s1, s2 } another set cover

FSi

TSi

FSi

Page 53: The Theory of  NP-Completeness

53

Exact Cover Problem

Def: To determine if F has an exact

cover T, which is a cover of F and the sets in T are pairwise disjoint.

<Theorem> CN exact cover

Page 54: The Theory of  NP-Completeness

54

Sum of Subsets Problem

Def: A set of positive numbers A = { a1, a2, …, an }a constant CDetermine if A A ai = C

e.g. A = { 7, 5, 19, 1, 12, 8, 14 } C = 21, A = { 7, 14 } C = 11, no solution

<Theorem> Exact cover sum of subsets.

a Ai

Page 55: The Theory of  NP-Completeness

55

Exact Cover Sum of Subsets

Proof: Instance of exact cover: F = { S1, S2, …, Sn } Instance of sum of subs

ets: A = { a1, a2, …, an } wher

e

FS

mi

i

uuuS

..., ,2,1

aj = mi1

eji(n + 1)i 1 where eji = 1 if ui Sj and eji = 0 otherwise.

C = mi0

(n + 1)i = ((n + 1)m 1) / n .

Page 56: The Theory of  NP-Completeness

56

Partition Problem

Def: Given a set of positive numbers A = { a1,a2,…,an },

determine if a partition P, ai = ai ip ip

e.g. A = {3, 6, 1, 9, 4, 11} partition: {3, 1, 9, 4} and {6, 11}

<Theorem> sum of subsets partition

Page 57: The Theory of  NP-Completeness

57

Bin Packing Problem

Def: n items, each of size ci , ci > 0, a positive number k and bin capacity C,

determine if we can assign the items into k bins such that the sum of ci’s assigned to each bin does not exceed C.

<Theorem> partition bin packing.

Page 58: The Theory of  NP-Completeness

58

VLSI Discrete Layout Problem

Given: n rectangles, each with height hi (integer) width wi and an area A, determine if there is a placement of the n rectangles within A according to the following rules:

1. Boundaries of rectangles are parallel to x axis or y axis.

2. Corners of rectangles lie on integer points. 3. No two rectangles overlap.

4. Two rectangles are separated by at least a unit distance.

(See the figure on the next page.)

Page 59: The Theory of  NP-Completeness

59

A Successful Placement

<Theorem> bin packing VLSI discrete layout.


Recommended