Professional Documents
Culture Documents
Reductions: Designing Algorithms Proving Limits Classifying Problems NP-completeness
Reductions: Designing Algorithms Proving Limits Classifying Problems NP-completeness
designing algorithms
proving limits
classifying problems
NP-completeness
Birds-eye view
Desiderata.
Classify problems according to their computational requirements.
Frustrating news.
Huge number of fundamental problems have defied classification
Desiderata'.
Suppose we could (couldn't) solve problem X efficiently.
What else could (couldn't) we solve efficiently?
Reduction
Def. Problem X reduces to problem Y
if you can use an algorithm that solves Y to help solve X
instance I
(of X)
Algorithm
for Y
solution to I
Algorithm for X
Reduction
Def. Problem X reduces to problem Y
if you can use an algorithm that solves Y to help solve X
Cost of solving X = M*(cost of solving Y) + cost of reduction.
number of times Y is used
Applications
designing algorithms: given algorithm for Y, can also solve X.
proving limits: if X is hard, then so is Y.
classifying problems: establish relative difficulty of problems.
designing algorithms
proving limits
classifying problems
NP-completeness
Applications.
designing algorithms: given algorithm for Y, can also solve X.
proving limits: if X is hard, then so is Y.
classifying problems: establish relative difficulty of problems.
Mentality: Since I know how to solve Y, can I use that algorithm to solve X?
sorting
convex hull
linear
18
14
6
30
11
15
19
5
6
16
20
44
length of path
Cost of maxflow =
back edge
(remove flow)
linear
depends on path choice!
linear
10
11
12
bipartite
matching
median
finding
element
distinctness
closest
pair
convex hull
PFS
maxflow
shortest
paths
arbitrage
shortest paths
(neg weights)
sorting
Euclidean
MST
Voronoi
LP
LP (standard form)
13
PRIME
COMPOSITE
whose fault?
14
designing algorithms
proving limits
classifying problems
polynomial-time reductions
NP-completeness
15
Applications.
designing algorithms: given algorithm for Y, can also solve X.
proving limits: if X is hard, then so is Y.
classifying problems: establish relative difficulty of problems.
Mentality:
If I could easily solve Y, then I could easily solve X
I cant easily solve X.
Therefore, I cant easily solve Y
Purpose of reduction is to establish that Y is hard
sorting
convex hull
17
(x1 , x12 )
(x2 , x22 )
recall Assignment 2
19
3-SUM instance:
3-COLLINEAR instance:
(2, 8)
(1, 1)
(-3, -27)
-3 + 2 + 1 = 0
20
Pf. Three points (a, a3), (b, b3), (c, c3) are collinear iff:
(a3 - b3) / (a - b)
(a - b)(a2 + ab + b2) / (a - b)
(a2 + ab + b2)
a2 + ab - bc - c2
(a - c)(a + b + c)
a+b+c
=
=
=
=
=
=
(b3 - c3) / (b - c)
(b - c)(b2 + bc + c2) / (b - c)
(b2 + bc + c2)
0
0
0
21
3-SUM
3-COLLINEAR
Want to be convinced that no subquadratic 3-COLLINEAR alg exists?
Hard way: long futile search for a subquadratic algorithm
Easy way: reduction from 3-SUM
22
designing algorithms
proving limits
classifying problems
NP-completeness
23
Applications.
Design algorithms: given algorithm for Y, can also solve X.
Establish intractability: if X is hard, then so is Y.
Classify problems: establish relative difficulty between two problems.
sorting
convex hull
not a loop
because this
reduction is
not intended
to give a
sorting
algorithm
24
Polynomial-time reductions
Def. Problem X polynomial reduces to problem Y if arbitrary instances
of problem X can be solved using:
Polynomial number of standard computational steps for reduction
One call to subroutine for Y.
Notation. X P Y.
Ex. Any linear reduction is a polynomial reduction.
Ex. All algorithms for which we know poly-time algorithms
poly-time reduce to one another.
3-satisfiability
Literal: A Boolean variable or its negation.
xi or xi
Cj = (x1 x2 x3)
(T T F ) (T T F ) (T T F ) (T T T) ( T F T)
no instance
(x1 x2 x3) (x1 x2 x3) (x1 x2 x3) (x1 x2 x4) (x2 x3 x4)
27
3-satisfiability is intractable
Good news: easy algorithm to solve 3-SAT
[ check all possible solutions ]
Bad news: running time is exponential in input size.
[ there are 2n possible solutions ]
Worse news:
no algorithm that guarantees subexponential running time is known
Implication:
suppose 3-SAT poly-reduces to a problem A
poly-time algorithm for A would imply poly-time 3-SAT algorithm
we suspect that no poly-time algorithm exists for A!
Graph 3-colorability
3-COLOR. Given a graph, is there a way to color the vertices
red, green, and blue so that no adjacent vertices have the same color?
yes instance
29
Graph 3-colorability
3-COLOR. Given a graph, is there a way to color the vertices
red, green, and blue so that no adjacent vertices have the same color?
yes instance
30
Graph 3-colorability
3-COLOR. Given a graph, is there a way to color the vertices
red, green, and blue so that no adjacent vertices have the same color?
no instance
31
true
x1
x1
x2
x2
base
x3
x3
...
xn
xn
32
false
true
x1
x1
x2
x2
to true .
base
x3
x3
...
xn
xn
33
false
true
x1
x1
x2
x2
to true .
base
x3
x3
...
xn
xn
34
stay tuned
B
(x1 x2 x3)
x1
x2
x3
6-node gadget
true
false
35
Therefore, is satisfiable.
B
(x1 x2 x3)
x1
x3
x2
6-node gadget
true
??
false
36
at least one
in each clause
Pf.
Color nodes corresponding to false literals T and to true literals F .
(x1 x2 x3)
x1
x2
x3
37
x1
x2
x3
38
(x1 x2 x3)
x1
x2
x3
39
x2
x3
40
Reminder
Construction is not intended for use, just to prove 3-COLOR difficult
41
designing algorithms
proving limits
classifying problems
polynomial-time reductions
NP-completeness
42
3-SAT
AT
R
3-S
OL O
3-C
o
t
ces
redu
3DM
3-COLOR
EXACT COVER
PLANAR-3-COLOR
SUBSET-SUM
PARTITION
KNAPSACK
Dick Karp
'85 Turing award
VERTEX COVER
CLIQUE
HAM-CYCLE
INDEPENDENT SET
TSP
HAM-PATH
INTEGER PROGRAMMING
BIN-PACKING
Cooks Theorem
NP: set of problems solvable in polynomial time
by a nondeterministic Turing machine
THM. Any problem in NP P 3-SAT.
Pf sketch.
Each problem P in NP corresponds to a TM M that accepts or rejects
any input in time polynomial in its size
Given M and a problem instance I, construct an instance of 3-SAT
that is satisfiable iff the machine accepts I.
Construction.
Variables for every tape cell, head position, and state at every step.
Clauses corresponding to each transition.
[many details omitted]
44
3-SAT
R
T
-SA
OLO
3-C es to 3
uc
red
3DM
3-COLOR
EXACT COVER
PLANAR-3-COLOR
SUBSET-SUM
PARTITION
KNAPSACK
Stephen Cook
'82 Turing award
VERTEX COVER
CLIQUE
HAM-CYCLE
INDEPENDENT SET
TSP
HAM-PATH
INTEGER PROGRAMMING
BIN-PACKING
3-COLOR
R
T
-SA
OLO
3-C es to 3
uc
red
LOR
AT
-CO
3
o
3-S
t
ces
redu
EXACT COVER
3DM
PLANAR-3-COLOR
SUBSET-SUM
PARTITION
KNAPSACK
VERTEX COVER
CLIQUE
HAM-CYCLE
INDEPENDENT SET
TSP
HAM-PATH
INTEGER PROGRAMMING
BIN-PACKING
47
48
49
Summary
Reductions are important in theory to:
Establish tractability.
Establish intractability.
Classify problems according to their computational requirements.
50