Computational Complexity Theory
Lecture 4: NP-complete problems,
Search versus Decision
Indian Institute of Science
Recap: Cook-Levin Theorem
Definition. A boolean formula is in Conjunctive Normal
Form (CNF) if it is an AND of OR of literals.
e.g. ϕ = (x1 ∨ x2) ∧ (x3 ∨ ¬x2 )
Definition. Let SAT be the language consisting of all
satisfiable CNF formulae.
Theorem. (Cook-Levin) SAT is NP-complete.
Recap: Cook-Levin Theorem
Let L ∈ NP. We intend to come up with a polynomial
time computable function f: x ϕx s.t.,
x∈L ϕx ∈ SAT
Language L has a poly-time verifier M such that
x∈L ∃u ∈{0,1}p(|x|) s.t. M(x, u) = 1
Recap: Cook-Levin Theorem
Output of ψ
T(n) qaccept o/p 1 …. ….
.
.
.
2 qstart u1 0 …. ….
1 qstart u1 1 …. a cell ….
….
Input u-variables of ψ Observe: ψ(u) = 1 iff N(u) = 1
Recap: Cook-Levin Theorem
Let L ∈ NP. We intend to come up with a polynomial
time computable function f: x ϕx s.t.,
x∈L ϕx ∈ SAT
Language L has a poly-time verifier M such that
x∈L ∃u ∈{0,1}p(|x|) s.t. ψx(u) = 1
ψx is a poly(|x|)-size circuit
Recap: Cook-Levin Theorem
Let L ∈ NP. We intend to come up with a polynomial
time computable function f: x ϕx s.t.,
x∈L ϕx ∈ SAT
Language L has a poly-time verifier M such that
x∈L ψx(u) is satisfiable
Important note: A satisfying assignment u for ψx
trivially gives a certificate u such that M(x, u) = 1.
Recap: Cook-Levin Theorem
Let L ∈ NP. We intend to come up with a polynomial
time computable function f: x ϕx s.t.,
x∈L ϕx ∈ SAT
Language L has a poly-time verifier M such that
x∈L ψx(u) is satisfiable
a poly-size circuit but not a poly-size CNF
Recap: Cook-Levin Theorem
From circuit to CNF. From circuit ψ construct a CNF
ϕ by introducing some extra variables v such that
ψ(u) = 1 iff ϕ(u, v) is satisfiable.
Language L has a poly-time verifier M such that
x∈L ∃u ∈{0,1}p(|x|) s.t. ϕx(u, v) is satisfiable
Recap: Cook-Levin Theorem
From circuit to CNF. From circuit ψ construct a CNF
ϕ by introducing some extra variables v such that
ψ(u) = 1 iff ϕ(u, v) is satisfiable.
Language L has a poly-time verifier M such that
x∈L ϕx(u, v) is satisfiable
Important note: A satisfying assignment (u, v) for ϕx
trivially gives a certificate u such that M(x, u) = 1.
Recap: Cook-Levin Theorem
Definition. A CNF is a called a kCNF if every clause has
at most k literals.
e.g. a 2CNF ϕ = (x1 ∨ x2) ∧ (x3 ∨ ¬x2 )
Definition. kSAT is the language consisting of all
satisfiable kCNFs.
Cook-Levin. There’s some constant k such that kSAT is
NP-complete.
Recap: 3SAT is NP-complete
Definition. A CNF is a called a kCNF if every clause has
at most k literals.
e.g. a 2CNF ϕ = (x1 ∨ x2) ∧ (x3 ∨ ¬x2 )
Definition. kSAT is the language consisting of all
satisfiable kCNFs.
Theorem. 3SAT is NP-complete.
Proof sketch: (x1 ∨ x2 ∨ x3 ∨ ¬x4 ) is satisfiable iff (x1
∨ x2 ∨ z) ∧ ( x3 ∨ ¬x4 ∨ ¬z) is satisfiable.
More NP-complete problems
NP-complete problems: Examples
Independent Set
Clique And many many other
natural problems!
Vertex Cover
0/1 Integer Programming
Max-Cut (NP-hard)
Example 1: Independent Set
INDSET := {(G, k): G has independent set of size k}
Goal: Design a poly-time reduction f s.t.
x ∈ 3SAT f(x) ∈ INDSET
Reduction from 3SAT: Recall, a reduction is just an
efficient algorithm that takes input a 3CNF ϕ and
outputs a (G, k) tuple s.t
ϕ ∈ 3SAT (G, k) ∈ INDSET
Example 1: Independent Set
Reduction: Let ϕ be a 3CNF with m clauses and n
variables. Assume, every clause has exactly 3 literals.
Example 1: Independent Set
Reduction: Let ϕ be a 3CNF with m clauses and n
variables. Assume, every clause has exactly 3 literals.
A vertex stands for a partial
assignment of the variables in
Ci that satisfies the clause
For every clause Ci form a complete
graph (cluster) on 7 vertices
Example 1: Independent Set
Reduction: Let ϕ be a 3CNF with m clauses and n
variables. Assume, every clause has exactly 3 literals.
Ci
Add an edge between two
vertices in two different clusters if
C1 the partial assignments they stand Cm
for are incompatible.
Example 1: Independent Set
Reduction: Let ϕ be a 3CNF with m clauses and n
variables. Assume, every clause has exactly 3 literals.
Ci
C1 Cm
Graph G on 7m vertices
Example 1: Independent Set
Reduction: Let ϕ be a 3CNF with m clauses and n
variables. Assume, every clause has exactly 3 literals.
Ci
C1 Cm
Obs: ϕ is satisfiable iff G has an ind set of size m.
Example 2: Clique
CLIQUE := {(H, k): H has a clique of size k}
Goal: Design a poly-time reduction f s.t.
x ∈ INDSET f(x) ∈ CLIQUE
Reduction from INDSET: The reduction algorithm
computes G from G
(G, k) ∈ INDSET (G, k) ∈ CLIQUE
Example 3: Vertex Cover
VCover := {(H, k): H has a vertex cover of size k}
Goal: Design a poly-time reduction f s.t.
x ∈ INDSET f(x) ∈ VCover
Reduction from INDSET: Let n be the number of
vertices in G. The reduction algorithm maps (G, k) to
(G, n-k).
(G, k) ∈ INDSET (G, n-k) ∈ VCover
Example 4: 0/1 Integer Programming
0/1 IProg := Set of satisfiable 0/1 integer programs
A 0/1 integer program is a set of linear inequalities
with rational coefficients and the variables are
allowed to take only 0/1 values.
Reduction from 3SAT: A clause is mapped to a linear
inequality as follows
x1 ∨ x2 ∨ x3 x1 + (1- x2) + x3 ≥ 1
Example 5: Max Cut
MaxCut : Given a graph find a cut with the max size.
A cut of G = (V, E) is a tuple (U, V\U), U ⊆ V. Size of a
cut (U, V\U) is the number of edges from U to V\U.
MinVCover: Given H, find a Vcover with the min size.
Obs: From MinVCover(H), we can readily check if (H,
k) ∈ VCover, for any k.
Example 5: Max Cut
MaxCut : Given a graph find a cut with the max size.
A cut of G = (V, E) is a tuple (U, V\U), U ⊆ V. Size of a
cut (U, V\U) is the number of edges from U to V\U.
Goal: A poly-time reduction from VCover to
MaxCut. f
(H, k) G s.t.
Size of a MaxCut(G) = 2.|E(H)| - |MinVCover(H)|
Example 5: Max Cut
MaxCut : Given a graph find a cut with the max size.
A cut of G = (V, E) is a tuple (U, V\U), U ⊆ V. Size of a
cut (U, V\U) is the number of edges from U to V\U.
Goal: A poly-time reduction from VCover to
MaxCut. f
(H, k) G s.t.
Thus, checking if (H, k) ∈ VCover reduces to finding
MaxCut(G).
Example 5: Max Cut
f
The reduction: (H, k) G
w
u u
degH(u) – 1 edges
between u and w
H G
G is formed by adding a new vertex w and adding
degH(u) – 1 edges between every u ∈ V(H) and w.
Example 5: Max Cut
Claim: |MaxCut(G)| = 2.|E(H)| - |MinVCover(H)|
Example 5: Max Cut
Claim: |MaxCut(G)| = 2.|E(H)| - |MinVCover(H)|
Proof: Let V(H) = V. Then V(G) = V + w.
Suppose (U, V\U + w) is a cut in G.
Example 5: Max Cut
Claim: |MaxCut(G)| = 2.|E(H)| - |MinVCover(H)|
Proof: Let V(H) = V. Then V(G) = V + w.
Suppose (U, V\U + w) is a cut in G.
Let SG(U) = no. of edges in G with exactly one end
vertex incident on a vertex in U.
Example 5: Max Cut
Claim: |MaxCut(G)| = 2.|E(H)| - |MinVCover(H)|
Proof: Let V(H) = V. Then V(G) = V + w.
Suppose (U, V\U + w) is a cut in G.
Let SG(U) = no. of edges going out of U in G.
Example 5: Max Cut
Claim: |MaxCut(G)| = 2.|E(H)| - |MinVCover(H)|
Proof: Let V(H) = V. Then V(G) = V + w.
Suppose (U, V\U + w) is a cut in G.
Let SG(U) = size of the cut (U,V\U + w).
Example 5: Max Cut
Claim: |MaxCut(G)| = 2.|E(H)| - |MinVCover(H)|
Proof: Let V(H) = V. Then V(G) = V + w.
Suppose (U, V\U + w) is a cut in G.
Let SH(U) = no. of edges in H with exactly one end
vertex incident on a vertex in U.
Example 5: Max Cut
Claim: |MaxCut(G)| = 2.|E(H)| - |MinVCover(H)|
Proof: Let V(H) = V. Then V(G) = V + w.
Suppose (U, V\U + w) is a cut in G.
Then SG(U) = SH(U) + Σ (degH(u) – 1)
u∈U
= SH(U) + ΣdegH(u) – |U|
u∈U
Example 5: Max Cut
Claim: |MaxCut(G)| = 2.|E(H)| - |MinVCover(H)|
Proof: Let V(H) = V. Then V(G) = V + w.
Suppose (U, V\U + w) is a cut in G.
Then SG(U) = SH(U) + Σ (degH(u) – 1)
u∈U
= SH(U) + ΣdegH(u) – |U|
u∈U
Obs: Twice the number of
edges in H with at least one
end vertex in U.
Example 5: Max Cut
Claim: |MaxCut(G)| = 2.|E(H)| - |MinVCover(H)|
Proof: Let V(H) = V. Then V(G) = V + w.
Suppose (U, V\U + w) is a cut in G.
Then SG(U) = SH(U) + Σ (degH(u) – 1)
u∈U
= SH(U) + ΣdegH(u) – |U|
u∈U
= 2.|EU(H)| - |U|
Example 5: Max Cut
Claim: |MaxCut(G)| = 2.|E(H)| - |MinVCover(H)|
Proof: Let V(H) = V. Then V(G) = V + w.
Suppose (U, V\U + w) is a cut in G.
Then SG(U) = 2.|EU(H)| - |U| … Eqn (1)
Proposition: If (U, V\U + w) is a max cut in G then U
is a vertex cover in H.
…proof of the claim follows from the above proposition
Example 5: Max Cut
Proof of the Proposition: Suppose U is not a vertex
cover
degH(u)-1 edges
V\U + w
u
w
U v
Example 5: Max Cut
Proof of the Proposition: Suppose U is not a vertex
cover
V\U + w
w
U v
Gain: degH(u)-1 + 1 edges
Loss: At most degH(u)-1 edges, these are the edges going from U to u
Net gain: At least 1 edge. Hence the cut is not a max cut.
Search versus Decision
Search version of NP problems
Recall: A language L ⊆ {0,1}* is in NP if
➢ There’s a poly-time verifier M such that
➢ x∈L iff there’s a poly-size certificate u s.t M(x,u) = 1
• Search version of L: Given an input x ∈ {0,1}*, find a u
∈{0,1}p(|x|) such that M(x,u) = 1, if such a u exists.
Search version of NP problems
Recall: A language L ⊆ {0,1}* is in NP if
➢ There’s a poly-time verifier M such that
➢ x∈L iff there’s a poly-size certificate u s.t M(x,u) = 1
• Search version of L: Given an input x ∈ {0,1}*, find a u
∈{0,1}p(|x|) such that M(x,u) = 1, if such a u exists.
• Example: Given a 3CNF ϕ, find a satisfying assignment
for ϕ if such an assignment exists.
Decision versus Search
Is the search version of an NP-problem more difficult
than the corresponding decision version?
Decision versus Search
Is the search version of an NP-problem more difficult
than the corresponding decision version?
Theorem. Let L ⊆ {0,1}* be NP-complete. Then, the
search version of L can be solved in poly-time if and
only if the decision version can be solved in poly-time.
Decision versus Search
Is the search version of an NP-problem more difficult
than the corresponding decision version?
Theorem. Let L ⊆ {0,1}* be NP-complete. Then, the
search version of L can be solved in poly-time if and
only if the decision version can be solved in poly-time.
Proof. (search decision) Obvious.
Decision versus Search
Is the search version of an NP-problem more difficult
than the corresponding decision version?
Theorem. Let L ⊆ {0,1}* be NP-complete. Then, the
search version of L can be solved in poly-time if and
only if the decision version can be solved in poly-time.
Proof. (decision search) We’ll prove this for
L = SAT first.
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
ϕ(x1,…,xn)
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
ϕ(x1,…,xn) A(ϕ) = Y
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
ϕ(x1,…,xn) A(ϕ) = Y
ϕ(0,…,xn)
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
ϕ(x1,…,xn) A(ϕ) = Y
A( ϕ(0,..) ) = N ϕ(0,…,xn)
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
ϕ(x1,…,xn) A(ϕ) = Y
A( ϕ(0,..) ) = N ϕ(0,…,xn) ϕ(1,…,xn)
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
ϕ(x1,…,xn) A(ϕ) = Y
A( ϕ(0,..) ) = N ϕ(0,…,xn) ϕ(1,…,xn) A( ϕ(1,..) ) = Y
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
ϕ(x1,…,xn) A(ϕ) = Y
A( ϕ(0,..) ) = N ϕ(0,…,xn) ϕ(1,…,xn) A( ϕ(1,..) ) = Y
ϕ(1,0,…,xn)
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
ϕ(x1,…,xn) A(ϕ) = Y
A( ϕ(0,..) ) = N ϕ(0,…,xn) ϕ(1,…,xn) A( ϕ(1,..) ) = Y
A( ϕ(1,0,..) ) = Y ϕ(1,0,…,xn)
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
ϕ(x1,…,xn) A(ϕ) = Y
A( ϕ(0,..) ) = N ϕ(0,…,xn) ϕ(1,…,xn) A( ϕ(1,..) ) = Y
A( ϕ(1,0,..) ) = Y ϕ(1,0,…,xn)
ϕ(1,0,0,…,xn)
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
ϕ(x1,…,xn) A(ϕ) = Y
A( ϕ(0,..) ) = N ϕ(0,…,xn) ϕ(1,…,xn) A( ϕ(1,..) ) = Y
A( ϕ(1,0,..) ) = Y ϕ(1,0,…,xn)
A( ϕ(1,0,0...) ) = N ϕ(1,0,0,…,xn)
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
ϕ(x1,…,xn) A(ϕ) = Y
A( ϕ(0,..) ) = N ϕ(0,…,xn) ϕ(1,…,xn) A( ϕ(1,..) ) = Y
A( ϕ(1,0,..) ) = Y ϕ(1,0,…,xn)
A( ϕ(1,0,0...) ) = N ϕ(1,0,0,…,xn) ϕ(1,0,1,…,xn)
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
ϕ(x1,…,xn) A(ϕ) = Y
A( ϕ(0,..) ) = N ϕ(0,…,xn) ϕ(1,…,xn) A( ϕ(1,..) ) = Y
A( ϕ(1,0,..) ) = Y ϕ(1,0,…,xn)
A( ϕ(1,0,0...) ) = N ϕ(1,0,0,…,xn) ϕ(1,0,1,…,xn) A( ϕ(1,0,0...) ) = Y
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
ϕ(x1,…,xn) A(ϕ) = Y
A( ϕ(0,..) ) = N ϕ(0,…,xn) ϕ(1,…,xn) A( ϕ(1,..) ) = Y
A( ϕ(1,0,..) ) = Y ϕ(1,0,…,xn)
A( ϕ(1,0,0...) ) = N ϕ(1,0,0,…,xn) ϕ(1,0,1,…,xn) A( ϕ(1,0,0...) ) = Y
.
.
.
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
ϕ(x1,…,xn) A(ϕ) = Y
A( ϕ(0,..) ) = N ϕ(0,…,xn) ϕ(1,…,xn) A( ϕ(1,..) ) = Y
A( ϕ(1,0,..) ) = Y ϕ(1,0,…,xn)
A( ϕ(1,0,0...) ) = N ϕ(1,0,0,…,xn) ϕ(1,0,1,…,xn) A( ϕ(1,0,0...) ) = Y
.
.
.
SAT is downward self-reducible
Proof. (decision search) Let L = SAT, and A be a
poly-time algorithm to decide if ϕ(x1,…,xn) is satisfiable.
We can find a satisfying assignment of ϕ with at most 2n
calls to A.
Decision ≡ Search for NPC problems
Proof. (decision search) Let L be NP-complete, and
B be a poly-time algorithm to decide if x∈L.
Decision ≡ Search for NPC problems
Proof. (decision search) Let L be NP-complete, and
B be a poly-time algorithm to decide if x∈L.
SAT ≤p L L ≤p SAT
Decision ≡ Search for NPC problems
Proof. (decision search) Let L be NP-complete, and
B be a poly-time algorithm to decide if x∈L.
SAT ≤p L L ≤p SAT
x ϕx
Decision ≡ Search for NPC problems
Proof. (decision search) Let L be NP-complete, and
B be a poly-time algorithm to decide if x∈L.
SAT ≤p L L ≤p SAT
x ϕx
From Cook-Levin theorem, we
can find a certificate of x from
a satisfying assignment of ϕx.
Decision ≡ Search for NPC problems
Proof. (decision search) Let L be NP-complete, and
B be a poly-time algorithm to decide if x∈L.
SAT ≤p L L ≤p SAT
x ϕx
How to find a certificate of ϕx using algorithm B ?
Decision ≡ Search for NPC problems
Proof. (decision search) Let L be NP-complete, and
B be a poly-time algorithm to decide if x∈L.
SAT ≤p L L ≤p SAT
x ϕx
How to find a certificate of ϕx using algorithm B ?
… we know how to using A, a poly-time decider for SAT
Decision ≡ Search for NPC problems
Proof. (decision search) Let L be NP-complete, and
B be a poly-time algorithm to decide if x∈L.
SAT ≤p L L ≤p SAT
ϕ f(ϕ) x ϕx
How to find a certificate of ϕx using algorithm B ?
… we know how to using A, a poly-time decider for SAT
Decision ≡ Search for NPC problems
Proof. (decision search) Let L be NP-complete, and
B be a poly-time algorithm to decide if x∈L.
SAT ≤p L L ≤p SAT
ϕ f(ϕ) x ϕx
How to find a certificate of ϕx using algorithm B ?
Take A(ϕ) = B( f(ϕ) )
Decision versus Search
Is search equivalent to decision for every NP problem?
Decision versus Search
Is search equivalent to decision for every NP problem?
Probably not!
Decision versus Search
Is search equivalent to decision for every NP problem?
n
Let EE = ∪ DTIME (2c.2 ) and
c≥0
Doubly exponential
n analogues of P and NP
NEE = ∪ NTIME (2 )
c.2
c≥0
Decision versus Search
Is search equivalent to decision for every NP problem?
Theorem. (Bellare-Goldwasser) If EE ≠ NEE then there’s a
language in NP for which search does not reduce to
decision.