/
NP-complete NP-complete

NP-complete - PowerPoint Presentation

tatiana-dople
tatiana-dople . @tatiana-dople
Follow
395 views
Uploaded On 2016-03-27

NP-complete - PPT Presentation

examples CSCI3130 Tutorial 10 ChunHo Hung chhungcsecuhkeduhk Department of Computer Science amp Engineering 1 Outline Review P NP NPC Polynomialtime Reduction 2 problem s ID: 270252

dominating set vertex time set dominating time vertex poly reduction problem cover size sat double show instance polynomial npc

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "NP-complete" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

NP-complete examples

CSCI3130 Tutorial 10

Chun-Ho Hung

chhung@cse.cuhk.edu.hk

Department of Computer Science & Engineering

1Slide2

OutlineReview

P, NP, NPCPolynomial-time Reduction2 problems

Double-SATDominating sethttp://en.wikipedia.org/wiki/Dominating_set_problem

2Slide3

ReviewP, NP, NPCPolynomial-time Reduction

3Slide4

PP is the class of all languages that have poly-time

algorithme.g., Shortest path on a directed graph, Sorting

4Slide5

NPNP is the class of all languages that have poly-time

verifierA verifier – a Turing Machine, V,

s.t.Given a potential xx ∈ L

 V accepts input <x, s> for some sSolution sV runs in polynomial time

5Slide6

NP (con’t)While verifying a solution of a NP problem is easy (in poly-time), finding a solution could be more difficult

An 3SAT instance - Find a satisfying assignment forVerifyingGiven an assignment, just evaluate the truth value

Finding a solution?No efficient algorithm has been discovered yet

6

(x

1

x

2

)

(

x

2

x

3

x

4) ∧ (x1)

f

=Slide7

P versus NPEvery language, L in P, L is also in NP

Let Verifier = Poly-time TM that solves LThereforeP is contained in NPNote: L in NP does not

imply that efficient algorithm that decides Ldoes not exist

7

NP

PSlide8

NPCA language C is NP-complete if:C is in NP

Every language L in NP, L poly-time reduces to CWhat is a reduction

…?8Slide9

ReductionThe

direction of the reduction is very importantSaying “A is easier than B” and “B is easier than A” mean different things“A (

polynomially) reduces to B” means “B is not easier than A”

9Slide10

Reduction (Con’t)Consider 2 problems:

BFS on unweighted graph

Shortest path on weighted graphAssume we have a TM, V

, which solves 2)We can reduce 1) to 2):Given an instance of 1), convert it into an instance of 2):Copy the graph, add weight=1 to every edge in 2)Run this instance on V, output

resultThese two “yes” instances corresponds to each other10Slide11

Poly-Time ReductionHow to show that a problem B is not easier than a problem A?

Informally, if B can be solved efficiently, we can solve A efficientlyFormally, we say A polynomially

reduces to B if:Given an instance a of problem, x

There is a polynomial time transformation to an instance of B, y = f(x) x is a “yes” instance if and only if

y is a “yes” instance

11Slide12

Poly-Time Reduction (Con’t)Suppose A poly-time reduces to B

Then there exists a poly-time TM, R, s.t., Given an instance of A, x, transforms it to an instance of B, y = f(

x), andy is accepted  x is accepted

12Slide13

Poly-Time Reduction (Implication)

Suppose A reduces to BIf B is polynomial time solvable, then A is polynomial time solvableIf A is not polynomial time solvable, then B is not polynomial time solvable

Contrapositive13

x

y

R

TM for

L’

acc

rej

Poly-time TMSlide14

Poly-Time Reduction (Implication)

Suppose A reduces to BSolving B cannot be easier than solving ASuppose A is “difficult” while B is “easy”However, by this reduction, you find a “easy” way to solve AConsequently

, if A is NPC, then B must be NPC14

x

y

R

TM for

L’

acc

rej

Poly-time TMSlide15

Poly-Time Reduction - P versus NPTo show P = NP, one could try to show that a NPC problem, C, can be solved in polynomial time. Why?

Every problem in NP poly-time reduces to CIf C can be solved in poly-time, so does each problem in NP

Then NP = P!!But this is not that easy and it is counter-intuitive (to most people) too

15Slide16

P versus NP (Again)Most believe that P ≠

NP, because intuitively searching for a solution is more difficult than verifying a solution

What does P = NP imply?Know how to verify a solution in poly-time Know how to find a solution in poly-time (?!)

Indeed we prefer P ≠ NPEncryption algorithms heavily rely on the assumption that P ≠ NP

P = NP or P ≠ NP is still an open problem16Slide17

Relations

NP

P

NP-C

easy

hard

Is there any problem even harder than NP-C?

Yes! e.g.

I-go

17Slide18

MethodologyTo show

L is in NP, you can either

Show that solutions for L can be verified in polynomial-time, or

Describe a nondeterministic polynomial-time TM for L(Come back to this if we have enough time)To show L

is NP-completeShow that L is in NPPoly-time reduce some NPC problem to L

i.e., design

a polynomial-time reduction from some problem we know to be NP-complete

18Slide19

ExampleProving a problem being NPC

19Slide20

Double-SATProblem:

Double-SAT = {<φ> |

φ is a Boolean formula with at least two satisfying assignments

}Goal:Show that Double-SAT is NP-Complete

20Slide21

Double-SAT (Proof Sketch)Steps:

Show that Double-SAT ∈

NPShow that Double-SAT is

not easier than a certain NPC problemFor the NPC problem, we choose

SATi.e., we want to poly-time reduce Double-SAT to SATShow the correspondence of “yes” instance between reduction

21Slide22

Double-SAT - (1) NP

It is trivial to see that Double-SAT ∈ NPGiven 2 assignments

for φ, and verify whether

both of them satisfy φWe can just evaluate the truth value

in poly-time22Slide23

Double-SAT - (2) ReductionReduction:On input

φ(x1, . . . , xn): 1. Introduce a new variable w

2. Output formula φ’(x1, . . . ,

xn, y) = φ(x1, . . . , xn

) ∧ ( w ∨ w ).

23

x

y

x

L

y

L

R

TM for

L’

acc

rej

TM accepts

SAT

Double-SATSlide24

Double-SAT - (3) Correspondencex

∈ L 

y ∈ L’

 : Suppose there is an satisfying assignment, X, for φ(x

1, . . . , xn), we can find two satisfying assignments for φ’(x1, . . . , xn,

w):

Assignment 1 = {X, w=

True

}

Assignment 2 = {X, w=

False

}

φ’

(x

1

, . . . ,

x

n

,

w) =

φ(x1, . . . , xn) ∧ ( w ∨ w )24For {xi}, assign X,then this part = TrueNo matter what w is,this part = TrueSlide25

Double-SAT - (3) Correspondencex

∈ L 

y ∈ L’

: We use contrapositivei.e., to show x

∉ L ⇒ y ∉ L’Indeed, if x

L

,

φ

(x

1

, . . . ,

x

n

)=

False

Then, no matter what the value of

y

is

φ’

(x

1, . . . , xn, y)=False25Slide26

Dominating SetProblem:Dominating-set = {<

G, K> | A dominating set of size K for G

exists}Goal:Show that Dominating-set

is NP-Complete26Slide27

Dominating Set (Definition)Problem:Dominating-set = {<

G, K> | A dominating set of size (at most) K for

G exists}Let G=(V,

E) be an undirected graphA dominating set D is a set of vertices that covers all

verticesi.e., every vertex of G is either in D or is adjacent to at least one vertex from D

27Slide28

Dominating Set (Example)Size-2 example : {Yellow vertices}

e

28Slide29

Dominating Set (Proof Sketch)Steps:

Show that Dominating-set ∈ NP. Show that

Dominating-set is not easier than a NPC problem

We choose this NPC problem to be Vertex coverReduction from Vertex-cover to Dominating-set

Show the correspondence of “yes” instances between the reduction29Slide30

Dominating Set - (1) NP

It is trivial to see that Dominating-set ∈ NP

Given a vertex set D of size K, we check whether (V-D) are adjacent to Di.e., for each vertex, v, in (V-D), whether v is adjacent to some vertex u in D

30Slide31

Dominating Set - (2) ReductionReduction - Graph transformation

Construct a new graph G' by adding new vertices and edges to the graph G

as follows:31

G

G’

<

G,k

>

L

<G’, k>

L

T

Vertex-cover

Dominating-setSlide32

Dominating Set - (2) ReductionReduction - Graph transformation (

Con’t)For each edge (v, w) of

G, add a vertex vw and the edges (v, vw) and (

w, vw) to G'Furthermore, remove all vertices with no incident edges; such vertices would always have to go in a dominating set but are not needed in a vertex cover of G

We skip the discussion of this subtle part in the followings32

G

G’

<

G,k

>

L

<G’, k>

L

T

Vertex-cover

Dominating-setSlide33

[Recap] Vertex coverA vertex

cover, C, is a set of vertices that covers all edgesi.e., each edge is at least adjacent to some node in C

33

{2, 4}, {3, 4}, {1, 2, 3}

are vertex covers

1

2

3

4Slide34

Dominating Set – Graph Transformation Example

v

w

z

u

G

w

v

z

u

vz

wu

vw

zu

vu

G'

34Slide35

Dominating Set - (3) Correspondence

A dominating set of size K in G’ 

A vertex cover of size K in G

 Let D be a dominating set of size K in G’Case 1): D contains only vertices from G Then, all new vertices have an edge to a vertex in D

D covers all edges D is a valid vertex cover of G35Slide36

Dominating Set - (3) Correspondence

A dominating set of size K in G’ 

A vertex cover of size K in G

 Let D be a dominating set of size K in G’Case 2): D contains some new vertices (vertex in

the form of uv) (We show how to construct a vertex cover using only old vertices, otherwise we cannot obtain a vertex cover for G)

For each new vertex

uv

, replace it by u (or v)

If u

D, this node is not needed

Then the edge u-v in G will be covered

After new edges are removed, it is a valid vertex cover of G (of size at most

K)

36Slide37

Dominating Set - (3) Correspondence

A dominating set of size K in G’ 

A vertex cover of size K in G

 Let C be a vertex cover of size K in G For an old vertex, v

∈ G’ :By the definition of

VC, a

ll

edges incident to v are

covered

v is also covered

For

a new vertex,

uv

G’

:

Edge u-v must be covered, either

u or v

∈ CThis node will cover uv in G’ Thus, C is a valid dominating for G’ (of size at most K)37Slide38

Dominating Set - (3) Correspondence

v

w

z

u

w

v

z

u

vz

wu

vw

zu

vu

Vertex-cover

in G

Dominating-set in

G

'

38Slide39

EndAny questions? (There should be some)

39