More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems...

22
More NP-completeness Sipser 7.5 (pages 283- 294)

Transcript of More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems...

Page 1: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

More NP-completeness

Sipser 7.5 (pages 283-294)

Page 2: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

2

NP’s hardest problems

• Definition 7.34: A language B is NP-complete if1. B NP∈2. A≤pB, for all A NP∈

NP

A1

SATA3

A2

CLIQUE

Page 3: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

3

Hamiltonian paths

• HAMPATH = {<G,s,t> | Hamiltonian path from s to t}∃• Theorem 7.46: HAMPATH is NP-complete.

s t

Page 4: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

4

Hamiltonian paths

• HAMPATH = {<G,s,t> | Hamiltonian path from s to t}∃• Theorem 7.46: HAMPATH is NP-complete.

s t

Page 5: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

5

Remember… HAMPATH NP∈

• N = "On input <G,s,t>: 1. Guess an orderings, p1, p2,..., pn, of the

nodes of G2. Check whether s = p1 and t = pn

3. For each i=1 to n-1, check whether (pi, pi+1) is an edge of G.

If any are not, reject. Otherwise, accept.”

Page 6: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

6

3SAT≤pHAMPATH

NP

A1

3SATA3

A2

HAMPATH

Page 7: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

7

Proof outline

• Given a boolean formula φ, we convert it to a directed graph G such that φ has a valid truth assignment iff G has a Hamiltonian graph

Page 8: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

8

3SAT’s main features

• Choice: Each variable has a choice between two truth values.

• Consistency: Different occurrences of the same variable have the same value.

• Constraints: Variable occurrences are organized into clauses that provide constraints that must be satisified.

*We model each of these three features by a different a "gadget" in the graph G.

Page 9: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

9

The choice gadget

• Modeling variable xi

Page 10: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

10

Zig-zagging and zag-zigging

Zig-zag (TRUE) Zag-zig (FALSE)

Page 11: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

11

The consistency gadget

Page 12: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

12

Clauses

• Modeling clause cj

cj

Page 13: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

13

The global structure

Page 14: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

14

The constraint gadget

• Modeling when clause cj contains xi

Page 15: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

15

The constraint gadget

• Modeling when clause cj contains xi

Page 16: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

16

A situation that cannot occur

Page 17: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

17

TSP is NP-complete

• TSP: Given n cities, 1, 2, ..., n, together with a nonnegative distance dij between any two cities, find the shortest tour.

Page 18: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

18

HAMPATH ≤p TSP

NP

A1

HAMPATHA3

A2

TSP

Page 19: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

19

SUBSET-SUM is NP-complete

• SUBSET-SUM=

{<S,t> | S = {x1,…,xk} and,

for some {y1,…,yl} S, ⊆yi=t}

• Why is SUBSET-SUM in NP?

Page 20: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

20

3SAT ≤p SUBSET-SUM

Page 21: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

21

And…if that’s not enough

• There are more than 3000 known NP-complete problems!

http://en.wikipedia.org/wiki/List_of_NP-complete_problems

Page 22: More NP-completeness Sipser 7.5 (pages 283-294). CS 311 Fall 2008 2 NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤

CS 311Fall 2008

22

Other types of complexity

• Space complexity• Circuit complexity• Descriptive complexity• Randomized complexity• Quantum complexity• …