IntractabilityI 207
IntractabilityI 207
I NTRACTABILITY I
‣ poly-time reductions
‣ packing and covering problems
‣ constraint satisfaction problems
‣ sequencing problems
‣ partitioning problems
‣ graph coloring
‣ numerical problems
Lecture slides by Kevin Wayne
Copyright © 2005 Pearson-Addison Wesley
h t t p : / / w w w . c s . p r i n c e t o n . e d u / ~w a y n e / k l e i n b e r g - t a r d o s
‣ poly-time reductions
‣ packing and covering problems
‣ constraint satisfaction problems
‣ sequencing problems
‣ partitioning problems
‣ graph coloring
‣ numerical problems
SECTION 8.1
Algorithm design patterns and antipatterns
3
Classify problems according to computational requirements
4
Classify problems according to computational requirements
yes probably no
2-satisfiability 3-satisfiability
matching 3d-matching
7
Classify problems
8
Poly-time reductions
Algorithm
instance I solution S to I
for Y
(of X)
Algorithm for X
9
Poly-time reductions
Notation. X ≤ P Y.
10
Intractability: quiz 1
11
Intractability: quiz 2
C. Both A and B.
D. Neither A nor B.
12
Poly-time reductions
13
8. I NTRACTABILITY I
‣ poly-time reductions
‣ packing and covering problems
‣ constraint satisfaction problems
‣ sequencing problems
‣ partitioning problems
‣ graph coloring
‣ numerical problems
SECTION 8.1
Independent set
15
Vertex cover
16
Intractability: quiz 3
C. Both A and B.
D. Neither A nor B.
17
Vertex cover and independent set reduce to one another
18
Vertex cover and independent set reduce to one another
・Let S be any independent set of size k.
・V − S is of size n – k.
・Consider an arbitrary edge (u, v) ∈ E.
・S independent ⇒ either u ∉ S, or v ∉ S, or both.
⇒ either u ∈ V − S, or v ∈ V − S, or both.
・Thus, V − S covers (u, v). ▪
19
Vertex cover and independent set reduce to one another
・Let V − S be any vertex cover of size n – k.
・S is of size k.
・Consider an arbitrary edge (u, v) ∈ E.
・V − S is a vertex cover ⇒ either u ∈ V − S, or v ∈ V − S, or both.
⇒ either u ∉ S, or v ∉ S, or both.
・Thus, S is an independent set. ▪
20
Set cover
Sample application.
・m available pieces of software.
・Set U of n capabilities that we would like our system to have.
・The ith piece of software provides the set Si ⊆ U of capabilities.
・Goal: achieve all n capabilities using fewest pieces of software.
U = { 1, 2, 3, 4, 5, 6, 7 }
Sa = { 3, 7 } Sb = { 2, 4 }
Sc = { 3, 4, 5, 6 } Sd = { 5 }
Se = { 1 } Sf = { 1, 2, 6, 7 }
k=2
A. 1 U = { 1, 2, 3, 4, 5, 6, 7 }
B. 2 Sa = { 1, 4, 6 } Sb = { 1, 6, 7 }
C. 3 Sc = { 1, 2, 3, 6 } Sd = { 1, 3, 5, 7 }
Se = { 2, 6, 7 } Sf = { 3, 4, 5 }
D. None of the above.
22
Vertex cover reduces to set cover
Construction.
・Universe U = E.
・Include one subset for each node v ∈ V : Sv = {e ∈ E : e incident to v }.
a b
e7 e2 e4 U = { 1, 2, 3, 4, 5, 6, 7 }
e3
Sa = { 3, 7 } Sb = { 2, 4 }
f e6 c Sc = { 3, 4, 5, 6 } Sd = { 5 }
e5 Se = { 1 } Sf = { 1, 2, 6, 7 }
e1
e d
a b
e7 e2 e4 U = { 1, 2, 3, 4, 5, 6, 7 }
e3
Sa = { 3, 7 } Sb = { 2, 4 }
f e6 c Sc = { 3, 4, 5, 6 } Sd = { 5 }
e5 Se = { 1 } Sf = { 1, 2, 6, 7 }
e1
e d
Pf. Let Y ⊆ S be a set cover of size k in (U, S, k). “no” instances of VERTEX-COVER
・Then X = { v : Sv ∈ Y } is a vertex cover of size k in G. ▪ are solved correctly
a b
e7 e2 e4 U = { 1, 2, 3, 4, 5, 6, 7 }
e3
Sa = { 3, 7 } Sb = { 2, 4 }
f e6 c Sc = { 3, 4, 5, 6 } Sd = { 5 }
e5 Se = { 1 } Sf = { 1, 2, 6, 7 }
e1
e d
‣ poly-time reductions
‣ packing and covering problems
‣ constraint satisfaction problems
‣ sequencing problems
‣ partitioning problems
‣ graph coloring
‣ numerical problems
SECTION 8.2
Satisfiability
27
Satisfiability is hard
Scientific hypothesis. There does not exist a poly-time algorithm for 3-SAT.
https://www.facebook.com/pg/npcompleteteens
28
3-satisfiability reduces to independent set
Construction.
・G contains 3 nodes for each clause, one for each literal.
・Connect 3 literals in a clause in a triangle.
・Connect literal to each of its negations.
k=3
29
3-satisfiability reduces to independent set
k=3
30
3-satisfiability reduces to independent set
・Set these literals to true (and remaining literals consistently). are solved correctly
k=3
31
Review
32
DECISION, SEARCH, AND OPTIMIZATION PROBLEMS
Goal. Show that all three problems poly-time reduce to one another.
33
SEARCH PROBLEMS VS. DECISION PROBLEMS
Pf. ≥ P
To find a vertex cover of size ≤ k :
・Determine if there exists a vertex cover of size ≤ k.
・Find a vertex v such that G − { v } has a vertex cover of size ≤ k − 1.
(any vertex in any vertex cover of size ≤ k will have this property)
・Include v in the vertex cover.
・Recursively find a vertex cover of size ≤ k − 1 in G − { v }. ▪
35
8. I NTRACTABILITY I
‣ poly-time reductions
‣ packing and covering problems
‣ constraint satisfaction problems
‣ sequencing problems
‣ partitioning problems
‣ graph coloring
‣ numerical problems
SECTION 8.5
Hamilton cycle
yes
37
Hamilton cycle
1 1′
2 2′
3 3′
4 4′
no
38
Directed Hamilton cycle reduces to Hamilton cycle
Pf. Given a directed graph G = (V, E), construct a graph G′ with 3n nodes.
aout
a din
d
b v
bout vin v vout
e
c
ein
cout
directed graph G undirected graph G′
39
Directed Hamilton cycle reduces to Hamilton cycle
Pf.
・Suppose G has a directed Hamilton cycle Γ.
・Then G′ has an undirected Hamilton cycle (same order). ▪
Pf.
・Suppose G′ has an undirected Hamilton cycle Γ ′.
・Γ ′ must visit nodes in G′ using one of following two orders:
…, black, white, blue, black, white, blue, black, white, blue, …
…, black, blue, white, black, blue, white, black, blue, white, …
・Black nodes in Γ ′ comprise either a directed Hamilton cycle Γ in G,
or reverse of one. ▪
40
3-satisfiability reduces to directed Hamilton cycle
41
Poly-time reductions
constraint satisfaction
3-SAT
SET-COVER
49
8. I NTRACTABILITY I
‣ poly-time reductions
‣ packing and covering problems
‣ constraint satisfaction problems
‣ sequencing problems
‣ partitioning problems
‣ graph coloring
‣ numerical problems
SECTION 8.6
3-dimensional matching
51
3-dimensional matching
52
3-dimensional matching
54
8. I NTRACTABILITY I
‣ poly-time reductions
‣ packing and covering problems
‣ constraint satisfaction problems
‣ sequencing problems
‣ partitioning problems
‣ graph coloring
‣ numerical problems
SECTION 8.7
3-colorability
yes instance
63
Intractability: quiz 6
64
Application: register allocation
65
3-satisfiability reduces to 3-colorability
66
Poly-time reductions
constraint satisfaction
3-SAT
SET-COVER
72
8. I NTRACTABILITY I
‣ poly-time reductions
‣ packing and covering problems
‣ constraint satisfaction problems
‣ sequencing problems
‣ partitioning problems
‣ graph coloring
‣ numerical problems
SECTION 8.8
My hobby
Ex. { 215, 215, 275, 275, 355, 355, 420, 420, 580, 580, 655, 655 }, W = 1505.
Yes. 215 + 355 + 355 + 580 = 1505.
75
Subset sum
77
SUBSET SUM REDUCES TO KNAPSACK
81
Poly-time reductions
constraint satisfaction
3-SAT
SET-COVER
88
Karp’s 20 poly-time reductions from satisfiability
89