Reductions to Prove NP Hardness
Nabil Mustafa
Computational Complexity
1 / 121
Reductions
The class NP : languages with succinct membership certificates
2 / 121
Reductions
The class NP : languages with succinct membership certificates
Cook-Levin: All L ∈ NP can be reduced to SAT
I
∃ polynomial g (·) such that x ∈ L ⇐⇒ g (x) ∈ SAT
3 / 121
Reductions
The class NP : languages with succinct membership certificates
Cook-Levin: All L ∈ NP can be reduced to SAT
I
I
∃ polynomial g (·) such that x ∈ L ⇐⇒ g (x) ∈ SAT
Very important to remember the implication goes both ways
4 / 121
Reductions
The class NP : languages with succinct membership certificates
Cook-Levin: All L ∈ NP can be reduced to SAT
I
I
∃ polynomial g (·) such that x ∈ L ⇐⇒ g (x) ∈ SAT
Very important to remember the implication goes both ways
Gave a reduction from general CNF SAT to 3-CNF SAT
5 / 121
Reductions
The class NP : languages with succinct membership certificates
Cook-Levin: All L ∈ NP can be reduced to SAT
I
I
∃ polynomial g (·) such that x ∈ L ⇐⇒ g (x) ∈ SAT
Very important to remember the implication goes both ways
Gave a reduction from general CNF SAT to 3-CNF SAT
I
2-CNF SAT is in P through a poly-time algorithm.
6 / 121
Reductions
The class NP : languages with succinct membership certificates
Cook-Levin: All L ∈ NP can be reduced to SAT
I
I
∃ polynomial g (·) such that x ∈ L ⇐⇒ g (x) ∈ SAT
Very important to remember the implication goes both ways
Gave a reduction from general CNF SAT to 3-CNF SAT
I
2-CNF SAT is in P through a poly-time algorithm.
3-CNF SAT then becomes a very important problem. Also,
7 / 121
Reductions
The class NP : languages with succinct membership certificates
Cook-Levin: All L ∈ NP can be reduced to SAT
I
I
∃ polynomial g (·) such that x ∈ L ⇐⇒ g (x) ∈ SAT
Very important to remember the implication goes both ways
Gave a reduction from general CNF SAT to 3-CNF SAT
I
2-CNF SAT is in P through a poly-time algorithm.
3-CNF SAT then becomes a very important problem. Also,
I
An elementary problem, very simple to understand
8 / 121
Reductions
The class NP : languages with succinct membership certificates
Cook-Levin: All L ∈ NP can be reduced to SAT
I
I
∃ polynomial g (·) such that x ∈ L ⇐⇒ g (x) ∈ SAT
Very important to remember the implication goes both ways
Gave a reduction from general CNF SAT to 3-CNF SAT
I
2-CNF SAT is in P through a poly-time algorithm.
3-CNF SAT then becomes a very important problem. Also,
I
I
An elementary problem, very simple to understand
Captures the ‘pure’ combinatorial choices of algorithms
9 / 121
Reductions
The class NP : languages with succinct membership certificates
Cook-Levin: All L ∈ NP can be reduced to SAT
I
I
∃ polynomial g (·) such that x ∈ L ⇐⇒ g (x) ∈ SAT
Very important to remember the implication goes both ways
Gave a reduction from general CNF SAT to 3-CNF SAT
I
2-CNF SAT is in P through a poly-time algorithm.
3-CNF SAT then becomes a very important problem. Also,
I
I
An elementary problem, very simple to understand
Captures the ‘pure’ combinatorial choices of algorithms
Given 3-CNF SAT , can construct a host of other reductions.
10 / 121
INDSET
Claim
INDSET : Given a graph G = (V , E ) and a parameter k, does G have an
independent set of size k?
The independent set problem (INDSET ) is NP complete.
11 / 121
INDSET
Claim
INDSET : Given a graph G = (V , E ) and a parameter k, does G have an
independent set of size k?
The independent set problem (INDSET ) is NP complete.
i) It is in NP
12 / 121
INDSET
Claim
INDSET : Given a graph G = (V , E ) and a parameter k, does G have an
independent set of size k?
The independent set problem (INDSET ) is NP complete.
i) It is in NP
ii) Reduce a NP hard problem to it
13 / 121
INDSET
Claim
INDSET : Given a graph G = (V , E ) and a parameter k, does G have an
independent set of size k?
The independent set problem (INDSET ) is NP complete.
i) It is in NP
ii) Reduce a NP hard problem to it
Show: If one can solve INDSET in polynomial time, then can solve
3-CNF SAT problem in polynomial time as well.
14 / 121
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
15 / 121
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
16 / 121
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
Vertices: Each literal xji ∈ Ci corresponds to the vertex vji .
17 / 121
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
I
Vertices: Each literal xji ∈ Ci corresponds to the vertex vji .
0
0
Edges: (vji , vji0 ) ∈ E if xji , xji0 are the same variable negated.
18 / 121
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
I
I
Vertices: Each literal xji ∈ Ci corresponds to the vertex vji .
0
0
Edges: (vji , vji0 ) ∈ E if xji , xji0 are the same variable negated.
Add all possible edges between v1i , v2i and v3i for all i.
19 / 121
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
I
I
Vertices: Each literal xji ∈ Ci corresponds to the vertex vji .
0
0
Edges: (vji , vji0 ) ∈ E if xji , xji0 are the same variable negated.
Add all possible edges between v1i , v2i and v3i for all i.
(x1 ∨ x2 ∨ x3 ) ∧ (x1 ∨ x3 ∨ x4 ) ∧ (x2 ∨ x4 )
20 / 121
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
I
I
Vertices: Each literal xji ∈ Ci corresponds to the vertex vji .
0
0
Edges: (vji , vji0 ) ∈ E if xji , xji0 are the same variable negated.
Add all possible edges between v1i , v2i and v3i for all i.
(x1 ∨ x2 ∨ x3 ) ∧ (x1 ∨ x3 ∨ x4 ) ∧ (x2 ∨ x4 )
x2
x1
x3
x4
x2
x1
x3
x4
21 / 121
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
I
I
Vertices: Each literal xji ∈ Ci corresponds to the vertex vji .
0
0
Edges: (vji , vji0 ) ∈ E if xji , xji0 are the same variable negated.
Add all possible edges between v1i , v2i and v3i for all i.
(x1 ∨ x2 ∨ x3 ) ∧ (x1 ∨ x3 ∨ x4 ) ∧ (x2 ∨ x4 )
x2
x1
x3
x4
x2
x1
x3
x4
22 / 121
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
I
I
Vertices: Each literal xji ∈ Ci corresponds to the vertex vji .
0
0
Edges: (vji , vji0 ) ∈ E if xji , xji0 are the same variable negated.
Add all possible edges between v1i , v2i and v3i for all i.
(x1 ∨ x2 ∨ x3 ) ∧ (x1 ∨ x3 ∨ x4 ) ∧ (x2 ∨ x4 )
x2
x1
x3
x4
x2
x1
x3
x4
23 / 121
Reduction for INDSET
Claim: If G has an independent set of size k, φ is satisfiable
24 / 121
Reduction for INDSET
Claim: If G has an independent set of size k, φ is satisfiable
I
The independent set, say V 0 , cannot have two vertices from the same
clause
25 / 121
Reduction for INDSET
Claim: If G has an independent set of size k, φ is satisfiable
I
I
The independent set, say V 0 , cannot have two vertices from the same
clause
Therefore, V 0 has exactly one vertex from each of the k clauses
26 / 121
Reduction for INDSET
Claim: If G has an independent set of size k, φ is satisfiable
I
The independent set, say V 0 , cannot have two vertices from the same
clause
I
Therefore, V 0 has exactly one vertex from each of the k clauses
I
No pair maps to literals x and x
27 / 121
Reduction for INDSET
Claim: If G has an independent set of size k, φ is satisfiable
I
The independent set, say V 0 , cannot have two vertices from the same
clause
I
Therefore, V 0 has exactly one vertex from each of the k clauses
I
No pair maps to literals x and x
I
If vji corresponds to literal xji = x, set xji = 1
28 / 121
Reduction for INDSET
Claim: If G has an independent set of size k, φ is satisfiable
I
The independent set, say V 0 , cannot have two vertices from the same
clause
I
Therefore, V 0 has exactly one vertex from each of the k clauses
I
No pair maps to literals x and x
I
If vji corresponds to literal xji = x, set xji = 1
I
If vji corresponds to literal xji = x, set xji = 0
29 / 121
Reduction for INDSET
Claim: If G has an independent set of size k, φ is satisfiable
I
The independent set, say V 0 , cannot have two vertices from the same
clause
I
Therefore, V 0 has exactly one vertex from each of the k clauses
I
No pair maps to literals x and x
I
If vji corresponds to literal xji = x, set xji = 1
I
If vji corresponds to literal xji = x, set xji = 0
I
Each clause satisfied, and no variable-setting conflicts between clauses
30 / 121
Reduction for INDSET
Claim: If G has an independent set of size k, φ is satisfiable
I
The independent set, say V 0 , cannot have two vertices from the same
clause
I
Therefore, V 0 has exactly one vertex from each of the k clauses
I
No pair maps to literals x and x
I
If vji corresponds to literal xji = x, set xji = 1
I
If vji corresponds to literal xji = x, set xji = 0
I
Each clause satisfied, and no variable-setting conflicts between clauses
Claim: If φ is satisfiable, G has an independent set of size k
31 / 121
CLIQUE
Claim
CLIQUE : Given a graph G = (V , E ) and a parameter k, does G have a
clique of size k?
The clique problem (CLIQUE ) is NP complete.
32 / 121
CLIQUE
Claim
CLIQUE : Given a graph G = (V , E ) and a parameter k, does G have a
clique of size k?
The clique problem (CLIQUE ) is NP complete.
Reduction from INDSET
33 / 121
CLIQUE
Claim
CLIQUE : Given a graph G = (V , E ) and a parameter k, does G have a
clique of size k?
The clique problem (CLIQUE ) is NP complete.
Reduction from INDSET
Given G , consider the complement graph G
34 / 121
CLIQUE
Claim
CLIQUE : Given a graph G = (V , E ) and a parameter k, does G have a
clique of size k?
The clique problem (CLIQUE ) is NP complete.
Reduction from INDSET
Given G , consider the complement graph G
Claim: G has an indset of size k iff G has clique of size k
35 / 121
CLIQUE
Claim
CLIQUE : Given a graph G = (V , E ) and a parameter k, does G have a
clique of size k?
The clique problem (CLIQUE ) is NP complete.
Reduction from INDSET
Given G , consider the complement graph G
Claim: G has an indset of size k iff G has clique of size k
v3
v3
v2
v2
v4
v1
v5
v4
v1
v5
36 / 121
Same CLIQUE Reduction ‘Unrolled’
Reduce 3-CNF SAT to CLIQUE
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
37 / 121
Same CLIQUE Reduction ‘Unrolled’
Reduce 3-CNF SAT to CLIQUE
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
38 / 121
Same CLIQUE Reduction ‘Unrolled’
Reduce 3-CNF SAT to CLIQUE
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
Vertices: Each literal corresponds to a vertex.
39 / 121
Same CLIQUE Reduction ‘Unrolled’
Reduce 3-CNF SAT to CLIQUE
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
Vertices: Each literal corresponds to a vertex.
I
Edges: All vertices are connected with an edge except the vertices of
the same clause and vertices with negated literals.
40 / 121
Same CLIQUE Reduction ‘Unrolled’
Reduce 3-CNF SAT to CLIQUE
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
Vertices: Each literal corresponds to a vertex.
I
Edges: All vertices are connected with an edge except the vertices of
the same clause and vertices with negated literals.
F
xi , xj ∈ Ck does not have an edge.
41 / 121
Same CLIQUE Reduction ‘Unrolled’
Reduce 3-CNF SAT to CLIQUE
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
Vertices: Each literal corresponds to a vertex.
I
Edges: All vertices are connected with an edge except the vertices of
the same clause and vertices with negated literals.
F
xi , xj ∈ Ck does not have an edge.
F
xi ∈ Ck , x¯i ∈ Cj does not have an edge.
42 / 121
Same CLIQUE Reduction ‘Unrolled’
Reduce 3-CNF SAT to CLIQUE
φ = C1 ∧ C2 ∧ . . . ∧ Ck , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
Vertices: Each literal corresponds to a vertex.
I
Edges: All vertices are connected with an edge except the vertices of
the same clause and vertices with negated literals.
F
xi , xj ∈ Ck does not have an edge.
F
xi ∈ Ck , x¯i ∈ Cj does not have an edge.
Clique of size k in G iff 3-CNF satisfiable.
43 / 121
Example Clique Reduction
φ = (x1 ∨ x2 ∨ x3) ∧ (x1 ∨ x3 ∨ x4) ∧ (x2 ∨ x4)
x1
x3
x2
x3
x4
x1
x4
x2
44 / 121
Vertex Cover
Definition
A Vertex Cover of an undirected graph G = (V , E ) is a subset V 0 of vertex
set V of the vertices of G which contains at least one of the two end
points of each edge.
V 0 ⊆ V : ∀(vi , vj ) ∈ E : vi ∈ V 0 ∨ vj ∈ V 0
45 / 121
VERTEX-COVER
Claim
VERTEX-COVER : Given a graph G = (V , E ) and a parameter k, does G
have a vertex cover of size k?
The vertex cover problem (VERTEX-COVER ) is NP complete.
46 / 121
VERTEX-COVER
Claim
VERTEX-COVER : Given a graph G = (V , E ) and a parameter k, does G
have a vertex cover of size k?
The vertex cover problem (VERTEX-COVER ) is NP complete.
Note that VERTEX-COVER is in NP
47 / 121
VERTEX-COVER
Claim
VERTEX-COVER : Given a graph G = (V , E ) and a parameter k, does G
have a vertex cover of size k?
The vertex cover problem (VERTEX-COVER ) is NP complete.
Note that VERTEX-COVER is in NP
We reduce 3-CNF SAT to VERTEX-COVER
48 / 121
Reduction for VERTEX-COVER
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
49 / 121
Reduction for VERTEX-COVER
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
50 / 121
Reduction for VERTEX-COVER
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
Variable vertices: Each variable xi creates two vertices vi1 , vi0
51 / 121
Reduction for VERTEX-COVER
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
Variable vertices: Each variable xi creates two vertices vi1 , vi0
I
Edge vertices: Each clause Cj nj creates a set V (Cj ) of nj vertices
52 / 121
Reduction for VERTEX-COVER
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
Variable vertices: Each variable xi creates two vertices vi1 , vi0
I
Edge vertices: Each clause Cj nj creates a set V (Cj ) of nj vertices
I
Edges: For all xi , (vi1 , vi0 ) ∈ E
53 / 121
Reduction for VERTEX-COVER
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
Variable vertices: Each variable xi creates two vertices vi1 , vi0
I
Edge vertices: Each clause Cj nj creates a set V (Cj ) of nj vertices
I
Edges: For all xi , (vi1 , vi0 ) ∈ E
I
Edges: Add all possible edges between each set V (Cj )
54 / 121
Reduction for VERTEX-COVER
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
Variable vertices: Each variable xi creates two vertices vi1 , vi0
I
Edge vertices: Each clause Cj nj creates a set V (Cj ) of nj vertices
I
Edges: For all xi , (vi1 , vi0 ) ∈ E
I
Edges: Add all possible edges between each set V (Cj )
I
Edges: For each literal xi ∈ Cj , connect its vertex in Cj to the
corresponding literal vertex.
55 / 121
Reduction for VERTEX-COVER
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
Variable vertices: Each variable xi creates two vertices vi1 , vi0
I
Edge vertices: Each clause Cj nj creates a set V (Cj ) of nj vertices
I
Edges: For all xi , (vi1 , vi0 ) ∈ E
I
Edges: Add all possible edges between each set V (Cj )
I
I
Edges: For each literal xi ∈ Cj , connect its vertex in Cj to the
corresponding literal vertex.
k = n + 2m
56 / 121
Reduction for VERTEX-COVER
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Construct a graph G = (V , E ) as follows:
I
Variable vertices: Each variable xi creates two vertices vi1 , vi0
I
Edge vertices: Each clause Cj nj creates a set V (Cj ) of nj vertices
I
Edges: For all xi , (vi1 , vi0 ) ∈ E
I
Edges: Add all possible edges between each set V (Cj )
I
I
Edges: For each literal xi ∈ Cj , connect its vertex in Cj to the
corresponding literal vertex.
k = n + 2m
Question: Does G have a vertex-cover of size k?
57 / 121
Reduction for VERTEX-COVER
(x1 ∨ x2 ∨ x3 ) ∧ (x1 ∨ x3 ∨ x4 ) ∧ (x2 ∨ x4 ∨ x1 ), n = 4, m = 3
58 / 121
Reduction for VERTEX-COVER
(x1 ∨ x2 ∨ x3 ) ∧ (x1 ∨ x3 ∨ x4 ) ∧ (x2 ∨ x4 ∨ x1 ), n = 4, m = 3
v1
v1
v2
v2
v3
v3
v4
v4
59 / 121
Reduction for VERTEX-COVER
(x1 ∨ x2 ∨ x3 ) ∧ (x1 ∨ x3 ∨ x4 ) ∧ (x2 ∨ x4 ∨ x1 ), n = 4, m = 3
v1
v1
v2
x2
x1
x3
v3
v2
x1
x4
x3
x2
x4
v4
v4
v3
x1
60 / 121
Reduction for VERTEX-COVER
(x1 ∨ x2 ∨ x3 ) ∧ (x1 ∨ x3 ∨ x4 ) ∧ (x2 ∨ x4 ∨ x1 ), n = 4, m = 3
v1
v1
v2
x2
x1
x3
v3
v2
x1
x4
x3
x2
x4
v4
v4
v3
x1
61 / 121
Reduction for VERTEX-COVER
Claim: If φ is satisfiable, then ∃ a vertex cover of size k = n + 2m
62 / 121
Reduction for VERTEX-COVER
Claim: If φ is satisfiable, then ∃ a vertex cover of size k = n + 2m
If variable xi = 0, pick vi0 to be in the vertex cover
63 / 121
Reduction for VERTEX-COVER
Claim: If φ is satisfiable, then ∃ a vertex cover of size k = n + 2m
If variable xi = 0, pick vi0 to be in the vertex cover
If variable xi = 1, pick vi1 to be in the vertex cover
64 / 121
Reduction for VERTEX-COVER
Claim: If φ is satisfiable, then ∃ a vertex cover of size k = n + 2m
If variable xi = 0, pick vi0 to be in the vertex cover
If variable xi = 1, pick vi1 to be in the vertex cover
Each clause Cj has at least one literal, say x2j , set to true.
65 / 121
Reduction for VERTEX-COVER
Claim: If φ is satisfiable, then ∃ a vertex cover of size k = n + 2m
If variable xi = 0, pick vi0 to be in the vertex cover
If variable xi = 1, pick vi1 to be in the vertex cover
Each clause Cj has at least one literal, say x2j , set to true.
I
Don’t pick edge vertex of xij , pick other two edge vertices
66 / 121
Reduction for VERTEX-COVER
Claim: If φ is satisfiable, then ∃ a vertex cover of size k = n + 2m
If variable xi = 0, pick vi0 to be in the vertex cover
If variable xi = 1, pick vi1 to be in the vertex cover
Each clause Cj has at least one literal, say x2j , set to true.
I
Don’t pick edge vertex of xij , pick other two edge vertices
Claim: The picked vertices cover all the edges of G .
67 / 121
Reduction for VERTEX-COVER
Claim: If φ is satisfiable, then ∃ a vertex cover of size k = n + 2m
If variable xi = 0, pick vi0 to be in the vertex cover
If variable xi = 1, pick vi1 to be in the vertex cover
Each clause Cj has at least one literal, say x2j , set to true.
I
Don’t pick edge vertex of xij , pick other two edge vertices
Claim: The picked vertices cover all the edges of G .
Clearly, the number of vertices picked is n + 2m.
68 / 121
Reduction for VERTEX-COVER
Claim: If φ is satisfiable, then ∃ a vertex cover of size k = n + 2m
If variable xi = 0, pick vi0 to be in the vertex cover
If variable xi = 1, pick vi1 to be in the vertex cover
Each clause Cj has at least one literal, say x2j , set to true.
I
Don’t pick edge vertex of xij , pick other two edge vertices
Claim: The picked vertices cover all the edges of G .
Clearly, the number of vertices picked is n + 2m.
An edge between two variable vertices is covered
69 / 121
Reduction for VERTEX-COVER
Claim: If φ is satisfiable, then ∃ a vertex cover of size k = n + 2m
If variable xi = 0, pick vi0 to be in the vertex cover
If variable xi = 1, pick vi1 to be in the vertex cover
Each clause Cj has at least one literal, say x2j , set to true.
I
Don’t pick edge vertex of xij , pick other two edge vertices
Claim: The picked vertices cover all the edges of G .
Clearly, the number of vertices picked is n + 2m.
An edge between two variable vertices is covered
I
For each i, exactly one of the variable vertices picked.
70 / 121
Reduction for VERTEX-COVER
Claim: If φ is satisfiable, then ∃ a vertex cover of size k = n + 2m
If variable xi = 0, pick vi0 to be in the vertex cover
If variable xi = 1, pick vi1 to be in the vertex cover
Each clause Cj has at least one literal, say x2j , set to true.
I
Don’t pick edge vertex of xij , pick other two edge vertices
Claim: The picked vertices cover all the edges of G .
Clearly, the number of vertices picked is n + 2m.
An edge between two variable vertices is covered
I
For each i, exactly one of the variable vertices picked.
For each Cj , edges to the picked vertices covered.
71 / 121
Reduction for VERTEX-COVER
Claim: If φ is satisfiable, then ∃ a vertex cover of size k = n + 2m
If variable xi = 0, pick vi0 to be in the vertex cover
If variable xi = 1, pick vi1 to be in the vertex cover
Each clause Cj has at least one literal, say x2j , set to true.
I
Don’t pick edge vertex of xij , pick other two edge vertices
Claim: The picked vertices cover all the edges of G .
Clearly, the number of vertices picked is n + 2m.
An edge between two variable vertices is covered
I
For each i, exactly one of the variable vertices picked.
For each Cj , edges to the picked vertices covered.
Crucial: What about the edges incident upon x2j ?
72 / 121
Reduction for VERTEX-COVER
Claim: If φ is satisfiable, then ∃ a vertex cover of size k = n + 2m
If variable xi = 0, pick vi0 to be in the vertex cover
If variable xi = 1, pick vi1 to be in the vertex cover
Each clause Cj has at least one literal, say x2j , set to true.
I
Don’t pick edge vertex of xij , pick other two edge vertices
Claim: The picked vertices cover all the edges of G .
Clearly, the number of vertices picked is n + 2m.
An edge between two variable vertices is covered
I
For each i, exactly one of the variable vertices picked.
For each Cj , edges to the picked vertices covered.
Crucial: What about the edges incident upon x2j ?
I
Edges within its clause covered by the other two picked vertices
73 / 121
Reduction for VERTEX-COVER
Claim: If φ is satisfiable, then ∃ a vertex cover of size k = n + 2m
If variable xi = 0, pick vi0 to be in the vertex cover
If variable xi = 1, pick vi1 to be in the vertex cover
Each clause Cj has at least one literal, say x2j , set to true.
I
Don’t pick edge vertex of xij , pick other two edge vertices
Claim: The picked vertices cover all the edges of G .
Clearly, the number of vertices picked is n + 2m.
An edge between two variable vertices is covered
I
For each i, exactly one of the variable vertices picked.
For each Cj , edges to the picked vertices covered.
Crucial: What about the edges incident upon x2j ?
I
I
Edges within its clause covered by the other two picked vertices
Remaining edge of the form: (xij , vi1 ) if xij is un-negated.
74 / 121
Reduction for VERTEX-COVER
Claim: If φ is satisfiable, then ∃ a vertex cover of size k = n + 2m
If variable xi = 0, pick vi0 to be in the vertex cover
If variable xi = 1, pick vi1 to be in the vertex cover
Each clause Cj has at least one literal, say x2j , set to true.
I
Don’t pick edge vertex of xij , pick other two edge vertices
Claim: The picked vertices cover all the edges of G .
Clearly, the number of vertices picked is n + 2m.
An edge between two variable vertices is covered
I
For each i, exactly one of the variable vertices picked.
For each Cj , edges to the picked vertices covered.
Crucial: What about the edges incident upon x2j ?
I
I
I
Edges within its clause covered by the other two picked vertices
Remaining edge of the form: (xij , vi1 ) if xij is un-negated.
We know that vi1 is picked, since vi = 1.
75 / 121
Reduction for VERTEX-COVER
Claim: If ∃ a vertex cover of size k = n + 2m, then φ satisfiable
76 / 121
Reduction for VERTEX-COVER
Claim: If ∃ a vertex cover of size k = n + 2m, then φ satisfiable
For each i, at least one of the variable vertices in vertex cover.
77 / 121
Reduction for VERTEX-COVER
Claim: If ∃ a vertex cover of size k = n + 2m, then φ satisfiable
For each i, at least one of the variable vertices in vertex cover.
In each set V (Cj ), at least 2 vertices in vertex cover
78 / 121
Reduction for VERTEX-COVER
Claim: If ∃ a vertex cover of size k = n + 2m, then φ satisfiable
For each i, at least one of the variable vertices in vertex cover.
In each set V (Cj ), at least 2 vertices in vertex cover
This already makes n + 2m vertices!
79 / 121
Reduction for VERTEX-COVER
Claim: If ∃ a vertex cover of size k = n + 2m, then φ satisfiable
For each i, at least one of the variable vertices in vertex cover.
In each set V (Cj ), at least 2 vertices in vertex cover
This already makes n + 2m vertices!
Exactly one vertex not picked in each clause
80 / 121
Reduction for VERTEX-COVER
Claim: If ∃ a vertex cover of size k = n + 2m, then φ satisfiable
For each i, at least one of the variable vertices in vertex cover.
In each set V (Cj ), at least 2 vertices in vertex cover
This already makes n + 2m vertices!
Exactly one vertex not picked in each clause
Consider the clause (x1 ∨ x2 ∨ x 3 )
81 / 121
Reduction for VERTEX-COVER
Claim: If ∃ a vertex cover of size k = n + 2m, then φ satisfiable
For each i, at least one of the variable vertices in vertex cover.
In each set V (Cj ), at least 2 vertices in vertex cover
This already makes n + 2m vertices!
Exactly one vertex not picked in each clause
Consider the clause (x1 ∨ x2 ∨ x 3 )
Lets say x1 and x2 were picked in vertex cover
82 / 121
Reduction for VERTEX-COVER
Claim: If ∃ a vertex cover of size k = n + 2m, then φ satisfiable
For each i, at least one of the variable vertices in vertex cover.
In each set V (Cj ), at least 2 vertices in vertex cover
This already makes n + 2m vertices!
Exactly one vertex not picked in each clause
Consider the clause (x1 ∨ x2 ∨ x 3 )
Lets say x1 and x2 were picked in vertex cover
The edge (x 3 , v 3 ) must be covered
83 / 121
Reduction for VERTEX-COVER
Claim: If ∃ a vertex cover of size k = n + 2m, then φ satisfiable
For each i, at least one of the variable vertices in vertex cover.
In each set V (Cj ), at least 2 vertices in vertex cover
This already makes n + 2m vertices!
Exactly one vertex not picked in each clause
Consider the clause (x1 ∨ x2 ∨ x 3 )
Lets say x1 and x2 were picked in vertex cover
The edge (x 3 , v 3 ) must be covered
Therefore v 3 must be in the vertex cover.
84 / 121
Reduction for VERTEX-COVER
Claim: If ∃ a vertex cover of size k = n + 2m, then φ satisfiable
For each i, at least one of the variable vertices in vertex cover.
In each set V (Cj ), at least 2 vertices in vertex cover
This already makes n + 2m vertices!
Exactly one vertex not picked in each clause
Consider the clause (x1 ∨ x2 ∨ x 3 )
Lets say x1 and x2 were picked in vertex cover
The edge (x 3 , v 3 ) must be covered
Therefore v 3 must be in the vertex cover.
Then set the boolean variable x3 = 0
85 / 121
Reduction for VERTEX-COVER
Claim: If ∃ a vertex cover of size k = n + 2m, then φ satisfiable
For each i, at least one of the variable vertices in vertex cover.
In each set V (Cj ), at least 2 vertices in vertex cover
This already makes n + 2m vertices!
Exactly one vertex not picked in each clause
Consider the clause (x1 ∨ x2 ∨ x 3 )
Lets say x1 and x2 were picked in vertex cover
The edge (x 3 , v 3 ) must be covered
Therefore v 3 must be in the vertex cover.
Then set the boolean variable x3 = 0
Similarly, whichever vertex not picked in cover, set corresponding
literal to 1
86 / 121
Reduction for VERTEX-COVER
Claim: If ∃ a vertex cover of size k = n + 2m, then φ satisfiable
For each i, at least one of the variable vertices in vertex cover.
In each set V (Cj ), at least 2 vertices in vertex cover
This already makes n + 2m vertices!
Exactly one vertex not picked in each clause
Consider the clause (x1 ∨ x2 ∨ x 3 )
Lets say x1 and x2 were picked in vertex cover
The edge (x 3 , v 3 ) must be covered
Therefore v 3 must be in the vertex cover.
Then set the boolean variable x3 = 0
Similarly, whichever vertex not picked in cover, set corresponding
literal to 1
Thus, setting variables as above, each clause satisfied
87 / 121
Another reduction for VERTEX-COVER
Claim
V 0 is a vertex cover of size k in G = (V , E ) iff V \ V 0 of size (n − k) is an
independent set.
88 / 121
Another reduction for VERTEX-COVER
Claim
V 0 is a vertex cover of size k in G = (V , E ) iff V \ V 0 of size (n − k) is an
independent set.
Let I = {v1 , v2 , . . . , vn−k } be INDSET of size n − k
89 / 121
Another reduction for VERTEX-COVER
Claim
V 0 is a vertex cover of size k in G = (V , E ) iff V \ V 0 of size (n − k) is an
independent set.
Let I = {v1 , v2 , . . . , vn−k } be INDSET of size n − k
I
There is no edge in G with both endpoints in I
90 / 121
Another reduction for VERTEX-COVER
Claim
V 0 is a vertex cover of size k in G = (V , E ) iff V \ V 0 of size (n − k) is an
independent set.
Let I = {v1 , v2 , . . . , vn−k } be INDSET of size n − k
I
There is no edge in G with both endpoints in I
I
So if we pick the remaining k vertices, all edges covered
91 / 121
Another reduction for VERTEX-COVER
Claim
V 0 is a vertex cover of size k in G = (V , E ) iff V \ V 0 of size (n − k) is an
independent set.
Let I = {v1 , v2 , . . . , vn−k } be INDSET of size n − k
I
There is no edge in G with both endpoints in I
I
So if we pick the remaining k vertices, all edges covered
V 0 = {v1 , v2 , . . . , vk } is a vertex cover of size k
92 / 121
Another reduction for VERTEX-COVER
Claim
V 0 is a vertex cover of size k in G = (V , E ) iff V \ V 0 of size (n − k) is an
independent set.
Let I = {v1 , v2 , . . . , vn−k } be INDSET of size n − k
I
There is no edge in G with both endpoints in I
I
So if we pick the remaining k vertices, all edges covered
V 0 = {v1 , v2 , . . . , vk } is a vertex cover of size k
I
Each edge in G has at least one endpoint in V 0
93 / 121
Another reduction for VERTEX-COVER
Claim
V 0 is a vertex cover of size k in G = (V , E ) iff V \ V 0 of size (n − k) is an
independent set.
Let I = {v1 , v2 , . . . , vn−k } be INDSET of size n − k
I
There is no edge in G with both endpoints in I
I
So if we pick the remaining k vertices, all edges covered
V 0 = {v1 , v2 , . . . , vk } is a vertex cover of size k
I
Each edge in G has at least one endpoint in V 0
I
So the remaining n − k vertices form an independent set
94 / 121
HITTING-SET
Claim
HITTING-SET : A collection C of subsets of a set V , and parameter k, find
a hitting set V 0 ⊆ V of size k.
The hitting set problem (HITTING-SET ) is NP complete.
95 / 121
HITTING-SET
Claim
HITTING-SET : A collection C of subsets of a set V , and parameter k, find
a hitting set V 0 ⊆ V of size k.
The hitting set problem (HITTING-SET ) is NP complete.
S1
S4
8
1
S2
H1
12
7
15
6
S3
3
9
14
10
H2
96 / 121
HITTING-SET
Claim
HITTING-SET : A collection C of subsets of a set V , and parameter k, find
a hitting set V 0 ⊆ V of size k.
The hitting set problem (HITTING-SET ) is NP complete.
S1
S4
8
1
S2
H1
12
7
15
6
S3
3
9
14
10
H2
Reduction from?
97 / 121
HITTING-SET
Claim
HITTING-SET : A collection C of subsets of a set V , and parameter k, find
a hitting set V 0 ⊆ V of size k.
The hitting set problem (HITTING-SET ) is NP complete.
S1
S4
8
1
S2
H1
12
7
15
6
S3
3
9
14
10
H2
Reduction from? Consider each set having size two!
98 / 121
INTEGER-PROGRAMMING
Claim
INTEGER-PROGRAMMING : Given a set of linear inequalities over variables
v1 , . . . , vn , does there exist an satisfying assignment of vi to positive
integers
The integer programming problem is NP complete.
99 / 121
INTEGER-PROGRAMMING
Claim
INTEGER-PROGRAMMING : Given a set of linear inequalities over variables
v1 , . . . , vn , does there exist an satisfying assignment of vi to positive
integers
The integer programming problem is NP complete.
u1 + 4u2 − 32u3 ≥ 34
100 / 121
INTEGER-PROGRAMMING
Claim
INTEGER-PROGRAMMING : Given a set of linear inequalities over variables
v1 , . . . , vn , does there exist an satisfying assignment of vi to positive
integers
The integer programming problem is NP complete.
u1 + 4u2 − 32u3 ≥ 34
2u2 − 2u4 + 7u3 ≤ 239
101 / 121
INTEGER-PROGRAMMING
Claim
INTEGER-PROGRAMMING : Given a set of linear inequalities over variables
v1 , . . . , vn , does there exist an satisfying assignment of vi to positive
integers
The integer programming problem is NP complete.
u1 + 4u2 − 32u3 ≥ 34
2u2 − 2u4 + 7u3 ≤ 239
43u4 − 2u1 + 17u2 ≥ 17
102 / 121
INTEGER-PROGRAMMING
Claim
INTEGER-PROGRAMMING : Given a set of linear inequalities over variables
v1 , . . . , vn , does there exist an satisfying assignment of vi to positive
integers
The integer programming problem is NP complete.
u1 + 4u2 − 32u3 ≥ 34
2u2 − 2u4 + 7u3 ≤ 239
43u4 − 2u1 + 17u2 ≥ 17
Note that INTEGER-PROGRAMMING is in NP
103 / 121
INTEGER-PROGRAMMING
Claim
INTEGER-PROGRAMMING : Given a set of linear inequalities over variables
v1 , . . . , vn , does there exist an satisfying assignment of vi to positive
integers
The integer programming problem is NP complete.
u1 + 4u2 − 32u3 ≥ 34
2u2 − 2u4 + 7u3 ≤ 239
43u4 − 2u1 + 17u2 ≥ 17
Note that INTEGER-PROGRAMMING is in NP
Reduction from 3-CNF SAT
104 / 121
Reduction for INTEGER-PROGRAMMING
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
105 / 121
Reduction for INTEGER-PROGRAMMING
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Given φ, construct the set of inequalities as following:
106 / 121
Reduction for INTEGER-PROGRAMMING
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Given φ, construct the set of inequalities as following:
I
Each boolean variable xi becomes integer variable vi
107 / 121
Reduction for INTEGER-PROGRAMMING
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Given φ, construct the set of inequalities as following:
I
I
Each boolean variable xi becomes integer variable vi
Each clause becomes an equation set to be greater than 1:
108 / 121
Reduction for INTEGER-PROGRAMMING
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Given φ, construct the set of inequalities as following:
I
I
Each boolean variable xi becomes integer variable vi
Each clause becomes an equation set to be greater than 1:
xi → vi ,
x i → (1 − vi ),
∨→+
109 / 121
Reduction for INTEGER-PROGRAMMING
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Given φ, construct the set of inequalities as following:
I
I
Each boolean variable xi becomes integer variable vi
Each clause becomes an equation set to be greater than 1:
xi → vi ,
x i → (1 − vi ),
∨→+
(x1 ∨ x2 ∨ x3 )
110 / 121
Reduction for INTEGER-PROGRAMMING
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Given φ, construct the set of inequalities as following:
I
I
Each boolean variable xi becomes integer variable vi
Each clause becomes an equation set to be greater than 1:
xi → vi ,
x i → (1 − vi ),
∨→+
(x1 ∨ x2 ∨ x3 )
v1 + v2 + (1 − v3 ) ≥ 1
111 / 121
Reduction for INTEGER-PROGRAMMING
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Given φ, construct the set of inequalities as following:
I
I
Each boolean variable xi becomes integer variable vi
Each clause becomes an equation set to be greater than 1:
xi → vi ,
x i → (1 − vi ),
∨→+
(x1 ∨ x2 ∨ x3 ) ∧ (x1 ∨ x3 ∨ x4 )
112 / 121
Reduction for INTEGER-PROGRAMMING
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Given φ, construct the set of inequalities as following:
I
I
Each boolean variable xi becomes integer variable vi
Each clause becomes an equation set to be greater than 1:
xi → vi ,
x i → (1 − vi ),
∨→+
(x1 ∨ x2 ∨ x3 ) ∧ (x1 ∨ x3 ∨ x4 )
v1 + v2 + (1 − v3 ) ≥ 1, (1 − v1 ) + v3 + (1 − v4 ) ≥ 1
113 / 121
Reduction for INTEGER-PROGRAMMING
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Given φ, construct the set of inequalities as following:
I
I
Each boolean variable xi becomes integer variable vi
Each clause becomes an equation set to be greater than 1:
xi → vi ,
x i → (1 − vi ),
∨→+
(x1 ∨ x2 ∨ x3 ) ∧ (x1 ∨ x3 ∨ x4 ) ∧ (x2 ∨ x4 ∨ x1 )
114 / 121
Reduction for INTEGER-PROGRAMMING
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Given φ, construct the set of inequalities as following:
I
I
Each boolean variable xi becomes integer variable vi
Each clause becomes an equation set to be greater than 1:
xi → vi ,
x i → (1 − vi ),
∨→+
(x1 ∨ x2 ∨ x3 ) ∧ (x1 ∨ x3 ∨ x4 ) ∧ (x2 ∨ x4 ∨ x1 )
v1 + v2 + (1 − v3 ) ≥ 1, (1 − v1 ) + v3 + (1 − v4 ) ≥ 1, (1 − v2 ) + v4 + v1 ≥ 1
115 / 121
Reduction for INTEGER-PROGRAMMING
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Given φ, construct the set of inequalities as following:
I
I
Each boolean variable xi becomes integer variable vi
Each clause becomes an equation set to be greater than 1:
xi → vi ,
x i → (1 − vi ),
∨→+
(x1 ∨ x2 ∨ x3 ) ∧ (x1 ∨ x3 ∨ x4 ) ∧ (x2 ∨ x4 ∨ x1 )
v1 + v2 + (1 − v3 ) ≥ 1, (1 − v1 ) + v3 + (1 − v4 ) ≥ 1, (1 − v2 ) + v4 + v1 ≥ 1
116 / 121
Reduction for INTEGER-PROGRAMMING
φ = C1 ∧ C2 ∧ . . . ∧ Cm , where Ci = (x1i ∨ x2i ∨ x3i )
Given φ, construct the set of inequalities as following:
I
I
Each boolean variable xi becomes integer variable vi
Each clause becomes an equation set to be greater than 1:
xi → vi ,
x i → (1 − vi ),
∨→+
(x1 ∨ x2 ∨ x3 ) ∧ (x1 ∨ x3 ∨ x4 ) ∧ (x2 ∨ x4 ∨ x1 )
v1 + v2 + (1 − v3 ) ≥ 1, (1 − v1 ) + v3 + (1 − v4 ) ≥ 1, (1 − v2 ) + v4 + v1 ≥ 1
0 ≤ v1 ≤ 1,
0 ≤ v2 ≤ 1,
0 ≤ v3 ≤ 1,
0 ≤ v4 ≤ 1
117 / 121
Reduction for INTEGER-PROGRAMMING
Claim: Solve INTEGER-PROGRAMMING to get a valid solution. Set boolean
variable xi = vi . This satisfies φ.
118 / 121
Reduction for INTEGER-PROGRAMMING
Claim: Solve INTEGER-PROGRAMMING to get a valid solution. Set boolean
variable xi = vi . This satisfies φ.
Each vi can be either 0 or 1
119 / 121
Reduction for INTEGER-PROGRAMMING
Claim: Solve INTEGER-PROGRAMMING to get a valid solution. Set boolean
variable xi = vi . This satisfies φ.
Each vi can be either 0 or 1
A clause Cj satisfied ⇐⇒ corresponding inequality satisfied
(x1 ∨ x2 ∨ x3 ) = 1 ⇐⇒ v1 + v2 + (1 − v3 ) ≥ 1
120 / 121
Reduction for INTEGER-PROGRAMMING
Claim: Solve INTEGER-PROGRAMMING to get a valid solution. Set boolean
variable xi = vi . This satisfies φ.
Each vi can be either 0 or 1
A clause Cj satisfied ⇐⇒ corresponding inequality satisfied
(x1 ∨ x2 ∨ x3 ) = 1 ⇐⇒ v1 + v2 + (1 − v3 ) ≥ 1
Likewise in the other direction, set vi = xi .
121 / 121
© Copyright 2026 Paperzz