1.
MELJUN P. CORTES,
MBA,MPA,BSCS,ACS
Fall 2008
CSC 3130: Automata theory and formal languages
NP-completeness
MELJUN CORTES
2.
P and NP
P = languages that can be decided on a TM
with polynomial running time
(problems that admit efficient algorithms)
NP = languages decidable on a nondeterministic
TM with polynomial running time
(solutions can be checked efficiently)
We believe that NP is bigger than P,
but we are not 100% sure
decidable
NP
P
3.
Evidence that NP is bigger than P
CLIQUE = {(G, k): G is a graph with a clique of k vertices}
IS = {(G, k): G is a graph with an independent set of k vertices}
VC = {(G, k): G is a graph with a vertex cover of k vertices}
SAT = {f: f is a satisfiable Boolean formula}
• These (and many others) are in NP
– Their solutions, once found, are easy to verify
• But no efficient algorithms are known for any of them
– The fastest known algorithms take time ≈2n
4.
Equivalence of certain NP languages
• We strongly suspect that problems like CLIQUE,
SAT, etc. require time ≈2n to solve
• We do not know how to prove this, but what we can
prove is that
If any one of them is tractable (by a polynomialtime algorithm), then all of them are tractable
5.
Equivalence of certain NP languages
• All these problems are as hard as one another
• Moreover, they are at the “frontier” of NP
– They are at least as hard as any problem in NP
NP
sat
y
bilit
isfia
over
tex-c
v er
e
epend
ind
ue
et cliq
nt s
P
6.
Polynomial-time reductions
• What do we mean when we say, for example,
“CLIQUE is at least as hard as IS”
• We mean that
If CLIQUE has a polynomial-time algorithm,
so does IS
• Or, we can convert an imaginary poly-time algorithm
for IS into one for CLIQUE
7.
Polynomial-time reductions
CLIQUE = {(G, k): G is a graph with a clique of k vertices}
IS = {(G, k): G is a graph with an independent set of k vertices}
• Theorem
If CLIQUE has a
polynomial-time
algorithm, so does IS
1
2
3
4
{1, 4}, {2, 3, 4}, {1} are cliques
{1, 2}, {1, 3}, {4} are
independent sets
8.
Polynomial-time reductions
If CLIQUE has a polynomial-time algorithm,
so does IS
• Proof: Suppose CLIQUE has an algorithm A
G, k
G’, k’
A
• We want to use it to solve IS
accept
accept
G clique of size
if G’ifhashas IS of size kk
reject
reject
if
if not not
9.
Reducing IS to CLIQUE
• We look for a polynomial-time transformation s.t.:
If G’ has a clique of size k’,
then G has an IS of size k
G, k
If G’ does not have a clique of size k’,
then G has no IS of size k
1
2
1
G
3
set k’ = k
2
3
flip all edges
4
ISs of size k
R
4
G’
cliques of size k’
G’, k’
10.
Reducing IS to CLIQUE
On input (G, k)
Construct G’ by flipping all edges of G
Set k’ = k
Output (G’, k’)
independent sets in G
If G’ has a clique of size k’,
then G has an IS of size k
G, k
R
cliques in G’
✓
If G’ does not have a clique of size k’,
then G has no IS of size k
✓
G’, k’
11.
Reduction recap
• We showed that
If CLIQUE has a polynomial-time algorithm,
so does IS
by converting an imaginary algorithm for CLIQUE
into one for IS
• To do this, we came up with a reduction that
transforms instances of IS into ones for CLIQUE
12.
Polynomial-time reductions
• Language L polynomial-time reduces to L’ if
there exists a polynomial-time computable map R
that takes an instance x of L into instance y of L’ s.t.
x ∈ L if and only if y ∈ L’
L (IS)
x (G, k)
x∈L
(G has IS of size k)
L’ (CLIQUE)
R
y (G’, k’)
y ∈ L’
(G’ has clique of size k’)
13.
Meaning of poly-time reductions
• Saying L reduces to L’ means L is easier than L’
– In other words, if we can solve L’, then we can also solve L
• Theorem
If L reduces to L’ and L’ ∈ P, then L ∈ P
• Proof
x
x∈L
R
y
y ∈ L’
algorithm for L’
acc
rej
algorithm accepts
14.
Notes about reductions
• The direction of the reduction is very important
– This makes sense, because “A is easier than B” and “B is
easier than A” mean different things
• However, it is possible that L reduces to L’ and L’
reduces to L
– This means that L and L’ are as hard as one another
– For example, IS and CLIQUE reduce to one another
15.
The Cook-Levin Theorem
Every L ∈ NP reduces to SAT
SAT = {f: f is a satisfiable Boolean formula}
• So every problem in NP is easier than SAT
• But SAT itself is in NP, so SAT must be the “hardest
problem” in NP:
If SAT ∈ P, then P = NP
16.
Interpretation of Cook-Levin Theorem
• Optimistic view:
If we manage to solve SAT, then we can also solve
CLIQUE, scheduling, and almost anything
• Pessimistic view:
Since we do not believe P = NP, it is unlikely that
we will ever have a fast algorithm for SAT
Be the first to comment