More Reductions for NP Problems

More Reductions for NP Problems
Nabil Mustafa
Computational Complexity
1 / 177
Reductions From Last Time
So far, we have shown the following problems NP complete:
SAT , 3-CNF SAT, INDSET , CLIQUE , VERTEX-COVER , HITTING-SET
, INTEGER-PROGRAMMING
SAT
3-SAT
IP
IS
VC
HS
CL
2 / 177
HAMILTONIAN
Claim
HAMILTONIAN : Given a directed graph G = (V , E ), does G have a
Hamiltonian path?
The Hamiltonian path problem (HAMILTONIAN ) is NP complete.
3 / 177
HAMILTONIAN
Claim
HAMILTONIAN : Given a directed graph G = (V , E ), does G have a
Hamiltonian path?
The Hamiltonian path problem (HAMILTONIAN ) is NP complete.
Review: Hamiltonian path visits each vertex in G exactly once
4 / 177
HAMILTONIAN
Claim
HAMILTONIAN : Given a directed graph G = (V , E ), does G have a
Hamiltonian path?
The Hamiltonian path problem (HAMILTONIAN ) is NP complete.
Review: Hamiltonian path visits each vertex in G exactly once
Computationally very different from Eulerian paths
5 / 177
HAMILTONIAN
Claim
HAMILTONIAN : Given a directed graph G = (V , E ), does G have a
Hamiltonian path?
The Hamiltonian path problem (HAMILTONIAN ) is NP complete.
Review: Hamiltonian path visits each vertex in G exactly once
Computationally very different from Eulerian paths
Note that HAMILTONIAN is in NP
6 / 177
HAMILTONIAN
Claim
HAMILTONIAN : Given a directed graph G = (V , E ), does G have a
Hamiltonian path?
The Hamiltonian path problem (HAMILTONIAN ) is NP complete.
Review: Hamiltonian path visits each vertex in G exactly once
Computationally very different from Eulerian paths
Note that HAMILTONIAN is in NP
We reduce 3-CNF SAT to HAMILTONIAN
I
For a fixed 3-CNF SAT formula, show that it can be transformed into a
graph whose Hamiltonian path will give us the assignments for SAT.
7 / 177
Reduction Sketch
φ = C1 ∧ C2 ∧ . . . ∧ Cm , n variables, Ci = (x1i ∨ x2i ∨ x3i )
8 / 177
Reduction Sketch
φ = C1 ∧ C2 ∧ . . . ∧ Cm , n variables, Ci = (x1i ∨ x2i ∨ x3i )
Given φ, have to construct a graph G such that G has a Hamiltonian
path iff φ is satisfiable.
9 / 177
Reduction Sketch
φ = C1 ∧ C2 ∧ . . . ∧ Cm , n variables, Ci = (x1i ∨ x2i ∨ x3i )
Given φ, have to construct a graph G such that G has a Hamiltonian
path iff φ is satisfiable.
We first define the mapping of variables, and then the clauses.
10 / 177
Reduction Sketch
φ = C1 ∧ C2 ∧ . . . ∧ Cm , n variables, Ci = (x1i ∨ x2i ∨ x3i )
Given φ, have to construct a graph G such that G has a Hamiltonian
path iff φ is satisfiable.
We first define the mapping of variables, and then the clauses.
Each xi will correspond to a path (chain) of 6m vertices
11 / 177
Reduction Sketch
φ = C1 ∧ C2 ∧ . . . ∧ Cm , n variables, Ci = (x1i ∨ x2i ∨ x3i )
Given φ, have to construct a graph G such that G has a Hamiltonian
path iff φ is satisfiable.
We first define the mapping of variables, and then the clauses.
Each xi will correspond to a path (chain) of 6m vertices
xi
12 / 177
Reduction Sketch
φ = C1 ∧ C2 ∧ . . . ∧ Cm , n variables, Ci = (x1i ∨ x2i ∨ x3i )
Given φ, have to construct a graph G such that G has a Hamiltonian
path iff φ is satisfiable.
We first define the mapping of variables, and then the clauses.
Each xi will correspond to a path (chain) of 6m vertices
If we are at the first (or end) vertex, only one path to follow
xi
13 / 177
Add a start vertex vstart which has
14 / 177
Add a start vertex vstart which has
I
no incoming edges.
15 / 177
Add a start vertex vstart which has
I
I
no incoming edges.
an outgoing edge to the first vertex of x1 chain.
16 / 177
Add a start vertex vstart which has
I
I
I
no incoming edges.
an outgoing edge to the first vertex of x1 chain.
an outgoing edge to the last vertex of x1 chain.
17 / 177
Add a start vertex vstart which has
I
I
I
no incoming edges.
an outgoing edge to the first vertex of x1 chain.
an outgoing edge to the last vertex of x1 chain.
vstart
x1
x2
xn−1
xn
18 / 177
Add an end vertex vend which has
19 / 177
Add an end vertex vend which has
I
no outgoing edges.
20 / 177
Add an end vertex vend which has
I
I
no outgoing edges.
an incoming edge from the first vertex of xn chain.
21 / 177
Add an end vertex vend which has
I
I
I
no outgoing edges.
an incoming edge from the first vertex of xn chain.
an incoming edge from the last vertex of xn chain.
22 / 177
Add an end vertex vend which has
I
I
I
no outgoing edges.
an incoming edge from the first vertex of xn chain.
an incoming edge from the last vertex of xn chain.
vstart
x1
x2
xn−1
xn
vend
23 / 177
From the first and last vertex of each chain xi , add
24 / 177
From the first and last vertex of each chain xi , add
I
an outgoing edge to the first vertex of chain xi+1
25 / 177
From the first and last vertex of each chain xi , add
I
I
an outgoing edge to the first vertex of chain xi+1
an outgoing edge to the last vertex of chain xi+1
26 / 177
From the first and last vertex of each chain xi , add
I
I
an outgoing edge to the first vertex of chain xi+1
an outgoing edge to the last vertex of chain xi+1
vstart
x1
x2
xn−1
xn
vend
27 / 177
From the first and last vertex of each chain xi , add
I
I
an outgoing edge to the first vertex of chain xi+1
an outgoing edge to the last vertex of chain xi+1
vstart
x1
x2
xn−1
xn
vend
28 / 177
From the first and last vertex of each chain xi , add
I
I
an outgoing edge to the first vertex of chain xi+1
an outgoing edge to the last vertex of chain xi+1
vstart
x1
x2
xn−1
xn
vend
29 / 177
From the first and last vertex of each chain xi , add
I
I
an outgoing edge to the first vertex of chain xi+1
an outgoing edge to the last vertex of chain xi+1
vstart
x1
x2
xn−1
xn
vend
30 / 177
Construction Properties
vstart
x1
x2
xn−1
xn
vend
31 / 177
Construction Properties
Any Hamiltonian path has to start at vstart
vstart
x1
x2
xn−1
xn
vend
32 / 177
Construction Properties
Any Hamiltonian path has to end at vend
vstart
x1
x2
xn−1
xn
vend
33 / 177
Construction Properties
Any Hamiltonian path first traverses chain x1 , then x2 etc.
vstart
x1
x2
xn−1
xn
vend
34 / 177
Construction Properties
For each chain, only two ways of traversing it.
I
Left-to-right means xi = 1, right-to-left means xi = 0
vstart
x1
x2
xn−1
xn
vend
35 / 177
Construction Properties
Each assignment of variables corresponds to a unique Hamiltonian path.
vstart
x1
x2
xn−1
xn
vend
36 / 177
Construction Properties
Each Hamiltonian path corresponds to a unique variable assignment.
vstart
x1
x2
xn−1
xn
vend
37 / 177
Construction Properties
So far, no constraints – they will come from the clauses now.
vstart
x1
x2
xn−1
xn
vend
38 / 177
Clause Constraints
Each clause Cj corresponds to a new vertex uj .
39 / 177
Clause Constraints
Each clause Cj corresponds to a new vertex uj .
If Cj contains a non-negated literal xi , add edges to uj :
40 / 177
Clause Constraints
Each clause Cj corresponds to a new vertex uj .
If Cj contains a non-negated literal xi , add edges to uj :
I
Add an incoming edge from a vertex, say vk , in the xi chain
41 / 177
Clause Constraints
Each clause Cj corresponds to a new vertex uj .
If Cj contains a non-negated literal xi , add edges to uj :
I
I
Add an incoming edge from a vertex, say vk , in the xi chain
Add an outgoing edge to vk+1 in the xi chain
42 / 177
Clause Constraints
Each clause Cj corresponds to a new vertex uj .
If Cj contains a non-negated literal xi , add edges to uj :
I
I
Add an incoming edge from a vertex, say vk , in the xi chain
Add an outgoing edge to vk+1 in the xi chain
uj
xi
43 / 177
Clause Constraints
If Cj contains a negated literal, reverse the edge directions
44 / 177
Clause Constraints
If Cj contains a negated literal, reverse the edge directions
If Cj contains a negated literal x i , add edges to uj :
I
Add an incoming edge from a vertex, say vk , in the xi chain
45 / 177
Clause Constraints
If Cj contains a negated literal, reverse the edge directions
If Cj contains a negated literal x i , add edges to uj :
I
I
Add an incoming edge from a vertex, say vk , in the xi chain
Add an outgoing edge to vk−1 in the xi chain
46 / 177
Clause Constraints
If Cj contains a negated literal, reverse the edge directions
If Cj contains a negated literal x i , add edges to uj :
I
I
Add an incoming edge from a vertex, say vk , in the xi chain
Add an outgoing edge to vk−1 in the xi chain
uj
xi
47 / 177
An Example
Construction of Hamiltonian path for
(a ∨ b) ∧ (a ∨ b)
Here:
C1 = (a ∨ b)
C2 = (a ∨ b)
48 / 177
The Graph Construction
vstart
a∨b
a
a∨b
b
vend
49 / 177
The Graph Construction
vstart
a∨b
a
a∨b
b
vend
Claim
Hamiltonian path exists ONLY if you go from left to right in a and chose
any one of the two directions for b.
50 / 177
Path Corresponding to Assignment 1
a = 1; b = 1
vstart
a∨b
a
a∨b
b
vend
51 / 177
Path Corresponding to Assignment 2
a = 1; b = 0
vstart
a∨b
a
a∨b
b
vend
52 / 177
Path Corresponding to Assignment 3
a = 0; b = 1
vstart
a∨b
a
a∨b
b
vend
Error in finding HAMILTONIAN
No HAMILTONIAN PATH as (a ∨ b) is not accessible
53 / 177
Path Corresponding to Assignment 4
a = 0; b = 0
vstart
a∨b
a
a∨b
b
vend
Error in finding HAMILTONIAN
No HAMILTONIAN PATH as (a ∨ b) is not accessible
54 / 177
Construction Claim
Claim
The constructed graph G has a Hamiltonian path iff φ satisfiable.
55 / 177
Construction Claim
Claim
The constructed graph G has a Hamiltonian path iff φ satisfiable.
Things to note about the final construction:
56 / 177
Construction Claim
Claim
The constructed graph G has a Hamiltonian path iff φ satisfiable.
Things to note about the final construction:
Any Hamiltonian path has to start at vstart
57 / 177
Construction Claim
Claim
The constructed graph G has a Hamiltonian path iff φ satisfiable.
Things to note about the final construction:
Any Hamiltonian path has to start at vstart
Any Hamiltonian path has to end at vend
58 / 177
Construction Claim
Claim
The constructed graph G has a Hamiltonian path iff φ satisfiable.
Things to note about the final construction:
Any Hamiltonian path has to start at vstart
Any Hamiltonian path has to end at vend
Any Hamiltonian path first traverses chain x1 , then x2 etc.
59 / 177
Construction Claim
Claim
The constructed graph G has a Hamiltonian path iff φ satisfiable.
Things to note about the final construction:
Any Hamiltonian path has to start at vstart
Any Hamiltonian path has to end at vend
Any Hamiltonian path first traverses chain x1 , then x2 etc.
For each chain, only two ways of traversing it.
60 / 177
Construction Claim
Claim
The constructed graph G has a Hamiltonian path iff φ satisfiable.
Things to note about the final construction:
Any Hamiltonian path has to start at vstart
Any Hamiltonian path has to end at vend
Any Hamiltonian path first traverses chain x1 , then x2 etc.
For each chain, only two ways of traversing it.
Each assignment of variables corresponds to a path.
61 / 177
Construction Claim
Claim
The constructed graph G has a Hamiltonian path iff φ satisfiable.
Things to note about the final construction:
Any Hamiltonian path has to start at vstart
Any Hamiltonian path has to end at vend
Any Hamiltonian path first traverses chain x1 , then x2 etc.
For each chain, only two ways of traversing it.
Each assignment of variables corresponds to a path.
Each path corresponds to a unique variable assignment.
62 / 177
Construction Claim
Claim
The constructed graph G has a Hamiltonian path iff φ satisfiable.
Things to note about the final construction:
Any Hamiltonian path has to start at vstart
Any Hamiltonian path has to end at vend
Any Hamiltonian path first traverses chain x1 , then x2 etc.
For each chain, only two ways of traversing it.
Each assignment of variables corresponds to a path.
Each path corresponds to a unique variable assignment.
If xi ∈ Cj and xi = 1, can visit uj along the way.
63 / 177
Construction Claim
Claim
The constructed graph G has a Hamiltonian path iff φ satisfiable.
Things to note about the final construction:
Any Hamiltonian path has to start at vstart
Any Hamiltonian path has to end at vend
Any Hamiltonian path first traverses chain x1 , then x2 etc.
For each chain, only two ways of traversing it.
Each assignment of variables corresponds to a path.
Each path corresponds to a unique variable assignment.
If xi ∈ Cj and xi = 1, can visit uj along the way.
If x i ∈ Cj and xi = 0, can visit uj along the way.
64 / 177
Construction Claim
Claim
The constructed graph G has a Hamiltonian path iff φ satisfiable.
Things to note about the final construction:
Any Hamiltonian path has to start at vstart
Any Hamiltonian path has to end at vend
Any Hamiltonian path first traverses chain x1 , then x2 etc.
For each chain, only two ways of traversing it.
Each assignment of variables corresponds to a path.
Each path corresponds to a unique variable assignment.
If xi ∈ Cj and xi = 1, can visit uj along the way.
If x i ∈ Cj and xi = 0, can visit uj along the way.
The above two only ways to visit uj without getting stuck.
65 / 177
SET-COVER
Claim
SET-COVER : A collection C = {S1 , . . . , Sm } of subsets of a base set X ,
|X | = n, and parameter k, find a set cover C 0 ⊆ C of size k
The set cover problem (SET-COVER ) is NP complete.
66 / 177
SET-COVER
Claim
SET-COVER : A collection C = {S1 , . . . , Sm } of subsets of a base set X ,
|X | = n, and parameter k, find a set cover C 0 ⊆ C of size k
The set cover problem (SET-COVER ) is NP complete.
C 0 = {Si1 , . . . , Sik } is a set-cover iff
S
j
Sij = X .
67 / 177
SET-COVER
Claim
SET-COVER : A collection C = {S1 , . . . , Sm } of subsets of a base set X ,
|X | = n, and parameter k, find a set cover C 0 ⊆ C of size k
The set cover problem (SET-COVER ) is NP complete.
C 0 = {Si1 , . . . , Sik } is a set-cover iff
S
j
Sij = X .
Note that SET-COVER is in NP
68 / 177
SET-COVER
Claim
SET-COVER : A collection C = {S1 , . . . , Sm } of subsets of a base set X ,
|X | = n, and parameter k, find a set cover C 0 ⊆ C of size k
The set cover problem (SET-COVER ) is NP complete.
C 0 = {Si1 , . . . , Sik } is a set-cover iff
S
j
Sij = X .
Note that SET-COVER is in NP
How to prove NP hardness?
69 / 177
SET-COVER
Claim
SET-COVER : A collection C = {S1 , . . . , Sm } of subsets of a base set X ,
|X | = n, and parameter k, find a set cover C 0 ⊆ C of size k
The set cover problem (SET-COVER ) is NP complete.
C 0 = {Si1 , . . . , Sik } is a set-cover iff
S
j
Sij = X .
Note that SET-COVER is in NP
How to prove NP hardness?
Reduce from VERTEX-COVER
70 / 177
Reduction from VERTEX-COVER
Given a graph G = (V , E ), the idea is that:
71 / 177
Reduction from VERTEX-COVER
Given a graph G = (V , E ), the idea is that:
I
Each vertex vi maps to a set Ci
72 / 177
Reduction from VERTEX-COVER
Given a graph G = (V , E ), the idea is that:
I
I
Each vertex vi maps to a set Ci
{vi1 , . . . , vik } is a vertex-cover iff {Ci1 , . . . , Cik } is a set-cover.
73 / 177
Reduction from VERTEX-COVER
Given a graph G = (V , E ), the idea is that:
I
I
Each vertex vi maps to a set Ci
{vi1 , . . . , vik } is a vertex-cover iff {Ci1 , . . . , Cik } is a set-cover.
The exact construction is as follows:
74 / 177
Reduction from VERTEX-COVER
Given a graph G = (V , E ), the idea is that:
I
I
Each vertex vi maps to a set Ci
{vi1 , . . . , vik } is a vertex-cover iff {Ci1 , . . . , Cik } is a set-cover.
The exact construction is as follows:
I
Each edge ej ∈ E maps to an element aj ∈ X .
75 / 177
Reduction from VERTEX-COVER
Given a graph G = (V , E ), the idea is that:
I
I
Each vertex vi maps to a set Ci
{vi1 , . . . , vik } is a vertex-cover iff {Ci1 , . . . , Cik } is a set-cover.
The exact construction is as follows:
I
I
Each edge ej ∈ E maps to an element aj ∈ X .
Each vertex vi ∈ V maps to set Ci = {aj s.t. ej incident to vi }
76 / 177
Reduction from VERTEX-COVER
Given a graph G = (V , E ), the idea is that:
I
I
Each vertex vi maps to a set Ci
{vi1 , . . . , vik } is a vertex-cover iff {Ci1 , . . . , Cik } is a set-cover.
The exact construction is as follows:
I
I
Each edge ej ∈ E maps to an element aj ∈ X .
Each vertex vi ∈ V maps to set Ci = {aj s.t. ej incident to vi }
Claim
V 0 = {vi1 , . . . , vik } is a vertex-cover iff {Cii , . . . , Cik } is a set cover.
77 / 177
Reduction from VERTEX-COVER
Given a graph G = (V , E ), the idea is that:
I
I
Each vertex vi maps to a set Ci
{vi1 , . . . , vik } is a vertex-cover iff {Ci1 , . . . , Cik } is a set-cover.
The exact construction is as follows:
I
I
Each edge ej ∈ E maps to an element aj ∈ X .
Each vertex vi ∈ V maps to set Ci = {aj s.t. ej incident to vi }
Claim
V 0 = {vi1 , . . . , vik } is a vertex-cover iff {Cii , . . . , Cik } is a set cover.
Proof.
If ej incident to vi , then set Ci contains aj
78 / 177
Reduction from VERTEX-COVER
Given a graph G = (V , E ), the idea is that:
I
I
Each vertex vi maps to a set Ci
{vi1 , . . . , vik } is a vertex-cover iff {Ci1 , . . . , Cik } is a set-cover.
The exact construction is as follows:
I
I
Each edge ej ∈ E maps to an element aj ∈ X .
Each vertex vi ∈ V maps to set Ci = {aj s.t. ej incident to vi }
Claim
V 0 = {vi1 , . . . , vik } is a vertex-cover iff {Cii , . . . , Cik } is a set cover.
Proof.
If ej incident to vi , then set Ci contains aj
Picking vi covers all edges incident to vi ⇐⇒ picking Ci covers all
corresponding elements aj
79 / 177
Reduction from VERTEX-COVER
Given a graph G = (V , E ), the idea is that:
I
I
Each vertex vi maps to a set Ci
{vi1 , . . . , vik } is a vertex-cover iff {Ci1 , . . . , Cik } is a set-cover.
The exact construction is as follows:
I
I
Each edge ej ∈ E maps to an element aj ∈ X .
Each vertex vi ∈ V maps to set Ci = {aj s.t. ej incident to vi }
Claim
V 0 = {vi1 , . . . , vik } is a vertex-cover iff {Cii , . . . , Cik } is a set cover.
Proof.
If ej incident to vi , then set Ci contains aj
Picking vi covers all edges incident to vi ⇐⇒ picking Ci covers all
corresponding elements aj
V 0 covers all edges ⇐⇒ C 0 cover all elements
80 / 177
Another Hardness Proof for INTEGER-PROGRAMMING
Another reduction for INTEGER-PROGRAMMING
SET-COVER can be reduced to INTEGER-PROGRAMMING
81 / 177
Another Hardness Proof for INTEGER-PROGRAMMING
Another reduction for INTEGER-PROGRAMMING
SET-COVER can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the set-cover problem as an integer program
82 / 177
Another Hardness Proof for INTEGER-PROGRAMMING
Another reduction for INTEGER-PROGRAMMING
SET-COVER can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the set-cover problem as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
83 / 177
Another Hardness Proof for INTEGER-PROGRAMMING
Another reduction for INTEGER-PROGRAMMING
SET-COVER can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the set-cover problem as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
Integer program variables: xj = 1 iff Sj picked in set-cover
84 / 177
Another Hardness Proof for INTEGER-PROGRAMMING
Another reduction for INTEGER-PROGRAMMING
SET-COVER can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the set-cover problem as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
Integer program variables: xj = 1 iff Sj picked in set-cover
At most k sets:
85 / 177
Another Hardness Proof for INTEGER-PROGRAMMING
Another reduction for INTEGER-PROGRAMMING
SET-COVER can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the set-cover problem as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
Integer program variables: xj = 1 iff Sj picked in set-cover
At most k sets:
X
xj ≤ k
j
86 / 177
Another Hardness Proof for INTEGER-PROGRAMMING
Another reduction for INTEGER-PROGRAMMING
SET-COVER can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the set-cover problem as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
Integer program variables: xj = 1 iff Sj picked in set-cover
At most k sets:
X
xj ≤ k
j
All elements covered:
87 / 177
Another Hardness Proof for INTEGER-PROGRAMMING
Another reduction for INTEGER-PROGRAMMING
SET-COVER can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the set-cover problem as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
Integer program variables: xj = 1 iff Sj picked in set-cover
At most k sets:
X
xj ≤ k
j
All elements covered:
X
xj ≥ 1 ∀i
j|ai ∈Sj
88 / 177
Another Hardness Proof for INTEGER-PROGRAMMING
Another reduction for INTEGER-PROGRAMMING
SET-COVER can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the set-cover problem as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
Integer program variables: xj = 1 iff Sj picked in set-cover
At most k sets:
X
xj ≤ k
j
All elements covered:
X
xj ≥ 1 ∀i
j|ai ∈Sj
Variable 0 or 1:
89 / 177
Another Hardness Proof for INTEGER-PROGRAMMING
Another reduction for INTEGER-PROGRAMMING
SET-COVER can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the set-cover problem as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
Integer program variables: xj = 1 iff Sj picked in set-cover
At most k sets:
X
xj ≤ k
j
All elements covered:
X
xj ≥ 1 ∀i
j|ai ∈Sj
Variable 0 or 1:
xi ∈ {0, 1}
90 / 177
Yet Another Hardness Proof for INTEGER-PROGRAMMING
Yet another reduction for INTEGER-PROGRAMMING
HITTING-SET can be reduced to INTEGER-PROGRAMMING
91 / 177
Yet Another Hardness Proof for INTEGER-PROGRAMMING
Yet another reduction for INTEGER-PROGRAMMING
HITTING-SET can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the hitting-set as an integer program
92 / 177
Yet Another Hardness Proof for INTEGER-PROGRAMMING
Yet another reduction for INTEGER-PROGRAMMING
HITTING-SET can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the hitting-set as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
93 / 177
Yet Another Hardness Proof for INTEGER-PROGRAMMING
Yet another reduction for INTEGER-PROGRAMMING
HITTING-SET can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the hitting-set as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
Integer program variables: xj = 1 iff xj picked in hitting-set
94 / 177
Yet Another Hardness Proof for INTEGER-PROGRAMMING
Yet another reduction for INTEGER-PROGRAMMING
HITTING-SET can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the hitting-set as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
Integer program variables: xj = 1 iff xj picked in hitting-set
At most k elements:
95 / 177
Yet Another Hardness Proof for INTEGER-PROGRAMMING
Yet another reduction for INTEGER-PROGRAMMING
HITTING-SET can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the hitting-set as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
Integer program variables: xj = 1 iff xj picked in hitting-set
At most k elements:
X
xj ≤ k
j
96 / 177
Yet Another Hardness Proof for INTEGER-PROGRAMMING
Yet another reduction for INTEGER-PROGRAMMING
HITTING-SET can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the hitting-set as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
Integer program variables: xj = 1 iff xj picked in hitting-set
At most k elements:
X
xj ≤ k
j
All sets covered:
97 / 177
Yet Another Hardness Proof for INTEGER-PROGRAMMING
Yet another reduction for INTEGER-PROGRAMMING
HITTING-SET can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the hitting-set as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
Integer program variables: xj = 1 iff xj picked in hitting-set
At most k elements:
X
xj ≤ k
j
All sets covered:
X
xj ≥ 1 ∀i
j|aj ∈Si
98 / 177
Yet Another Hardness Proof for INTEGER-PROGRAMMING
Yet another reduction for INTEGER-PROGRAMMING
HITTING-SET can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the hitting-set as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
Integer program variables: xj = 1 iff xj picked in hitting-set
At most k elements:
X
xj ≤ k
j
All sets covered:
X
xj ≥ 1 ∀i
j|aj ∈Si
Variable 0 or 1:
99 / 177
Yet Another Hardness Proof for INTEGER-PROGRAMMING
Yet another reduction for INTEGER-PROGRAMMING
HITTING-SET can be reduced to INTEGER-PROGRAMMING
Proof.
Formulate the hitting-set as an integer program
Given C = {S1 , . . . , Sm } over X = {a1 , . . . , an } and k:
Integer program variables: xj = 1 iff xj picked in hitting-set
At most k elements:
X
xj ≤ k
j
All sets covered:
X
xj ≥ 1 ∀i
j|aj ∈Si
Variable 0 or 1:
xi ∈ {0, 1}
100 / 177
EXACT-COVER
Claim
EXACT-COVER : A collection C = {S1 , . . . , Sn }, |Sj | = 3 over a base set X ,
|X | = 3m, find a disjoint set cover C 0 ⊆ C of size m.
The exact cover by 3-sets problem (EXACT-COVER ) is NP complete.
101 / 177
EXACT-COVER
Claim
EXACT-COVER : A collection C = {S1 , . . . , Sn }, |Sj | = 3 over a base set X ,
|X | = 3m, find a disjoint set cover C 0 ⊆ C of size m.
The exact cover by 3-sets problem (EXACT-COVER ) is NP complete.
Note that EXACT-COVER is in NP
102 / 177
EXACT-COVER
Claim
EXACT-COVER : A collection C = {S1 , . . . , Sn }, |Sj | = 3 over a base set X ,
|X | = 3m, find a disjoint set cover C 0 ⊆ C of size m.
The exact cover by 3-sets problem (EXACT-COVER ) is NP complete.
Note that EXACT-COVER is in NP
How to prove NP hardness?
103 / 177
EXACT-COVER
Claim
EXACT-COVER : A collection C = {S1 , . . . , Sn }, |Sj | = 3 over a base set X ,
|X | = 3m, find a disjoint set cover C 0 ⊆ C of size m.
The exact cover by 3-sets problem (EXACT-COVER ) is NP complete.
Note that EXACT-COVER is in NP
How to prove NP hardness?
Reduce from SAT . Read from the Papadimitriou book.
104 / 177
KNAPSACK
Claim
KNAPSACK : Given a set A = {a1 , . . . , an } of n elements, where each
element ai has a weight wi and a value vi , both positive integers. Find a
subset A0 ⊆ A such that
105 / 177
KNAPSACK
Claim
KNAPSACK : Given a set A = {a1 , . . . , an } of n elements, where each
element ai has a weight wi and a value vi , both positive integers. Find a
subset A0 ⊆ A such that
P
1
aj ∈A0 wi ≤ W ,
106 / 177
KNAPSACK
Claim
KNAPSACK : Given a set A = {a1 , . . . , an } of n elements, where each
element ai has a weight wi and a value vi , both positive integers. Find a
subset A0 ⊆ A such that
P
1
a ∈A0 wi ≤ W ,
Pj
2
aj ∈A0 vi ≥ K .
107 / 177
KNAPSACK
Claim
KNAPSACK : Given a set A = {a1 , . . . , an } of n elements, where each
element ai has a weight wi and a value vi , both positive integers. Find a
subset A0 ⊆ A such that
P
1
a ∈A0 wi ≤ W ,
Pj
2
aj ∈A0 vi ≥ K .
The Knapsack problem (KNAPSACK ) is NP complete.
108 / 177
KNAPSACK
Claim
KNAPSACK : Given a set A = {a1 , . . . , an } of n elements, where each
element ai has a weight wi and a value vi , both positive integers. Find a
subset A0 ⊆ A such that
P
1
a ∈A0 wi ≤ W ,
Pj
2
aj ∈A0 vi ≥ K .
The Knapsack problem (KNAPSACK ) is NP complete.
Note that KNAPSACK is in NP
109 / 177
KNAPSACK
Claim
KNAPSACK : Given a set A = {a1 , . . . , an } of n elements, where each
element ai has a weight wi and a value vi , both positive integers. Find a
subset A0 ⊆ A such that
P
1
a ∈A0 wi ≤ W ,
Pj
2
aj ∈A0 vi ≥ K .
The Knapsack problem (KNAPSACK ) is NP complete.
Note that KNAPSACK is in NP
How to prove NP hardness?
110 / 177
KNAPSACK
Claim
KNAPSACK : Given a set A = {a1 , . . . , an } of n elements, where each
element ai has a weight wi and a value vi , both positive integers. Find a
subset A0 ⊆ A such that
P
1
a ∈A0 wi ≤ W ,
Pj
2
aj ∈A0 vi ≥ K .
The Knapsack problem (KNAPSACK ) is NP complete.
Note that KNAPSACK is in NP
How to prove NP hardness?
Special case: K = W and wi = vi for all i.
111 / 177
KNAPSACK
Claim
KNAPSACK : Given a set A = {a1 , . . . , an } of n elements, where each
element ai has a weight wi and a value vi , both positive integers. Find a
subset A0 ⊆ A such that
P
1
a ∈A0 wi ≤ W ,
Pj
2
aj ∈A0 vi ≥ K .
The Knapsack problem (KNAPSACK ) is NP complete.
Note that KNAPSACK is in NP
How to prove NP hardness?
Special case: K = W and wi = vi for all i. Then problem?
112 / 177
KNAPSACK
Claim
KNAPSACK : Given a set A = {a1 , . . . , an } of n elements, where each
element ai has a weight wi and a value vi , both positive integers. Find a
subset A0 ⊆ A such that
P
1
a ∈A0 wi ≤ W ,
Pj
2
aj ∈A0 vi ≥ K .
The Knapsack problem (KNAPSACK ) is NP complete.
Note that KNAPSACK is in NP
How to prove NP hardness?
Special case: K = W and wi = vi for all i. Then problem?
Subset sum! Find a subset with value and weight equal to W .
113 / 177
SUBSET-SUM
Claim
The subset sum problem (SUBSET-SUM ) is NP complete.
114 / 177
SUBSET-SUM
Claim
The subset sum problem (SUBSET-SUM ) is NP complete.
Reduce EXACT-COVER to SUBSET-SUM
115 / 177
SUBSET-SUM
Claim
The subset sum problem (SUBSET-SUM ) is NP complete.
Reduce EXACT-COVER to SUBSET-SUM
{S1 , . . . , Sn }, |Sj | = 3 over a base set X = {a1 , . . . , a3m }
116 / 177
SUBSET-SUM
Claim
The subset sum problem (SUBSET-SUM ) is NP complete.
Reduce EXACT-COVER to SUBSET-SUM
{S1 , . . . , Sn }, |Sj | = 3 over a base set X = {a1 , . . . , a3m }
Map each set Sj to an integer tj
117 / 177
SUBSET-SUM
Claim
The subset sum problem (SUBSET-SUM ) is NP complete.
Reduce EXACT-COVER to SUBSET-SUM
{S1 , . . . , Sn }, |Sj | = 3 over a base set X = {a1 , . . . , a3m }
Map each set Sj to an integer tj
If Sj ’s are disjoint and cover X , then tj ’s add up to some T
118 / 177
SUBSET-SUM
Claim
The subset sum problem (SUBSET-SUM ) is NP complete.
Reduce EXACT-COVER to SUBSET-SUM
{S1 , . . . , Sn }, |Sj | = 3 over a base set X = {a1 , . . . , a3m }
Map each set Sj to an integer tj
If Sj ’s are disjoint and cover X , then tj ’s add up to some T
For mapping sets into integers, use the characteristic vector
119 / 177
SUBSET-SUM
Claim
The subset sum problem (SUBSET-SUM ) is NP complete.
Reduce EXACT-COVER to SUBSET-SUM
{S1 , . . . , Sn }, |Sj | = 3 over a base set X = {a1 , . . . , a3m }
Map each set Sj to an integer tj
If Sj ’s are disjoint and cover X , then tj ’s add up to some T
For mapping sets into integers, use the characteristic vector
I
Represent set S as a vector v (S) where vi (S) = 1 iff ai ∈ S
120 / 177
SUBSET-SUM
Claim
The subset sum problem (SUBSET-SUM ) is NP complete.
Reduce EXACT-COVER to SUBSET-SUM
{S1 , . . . , Sn }, |Sj | = 3 over a base set X = {a1 , . . . , a3m }
Map each set Sj to an integer tj
If Sj ’s are disjoint and cover X , then tj ’s add up to some T
For mapping sets into integers, use the characteristic vector
I
I
Represent set S as a vector v (S) where vi (S) = 1 iff ai ∈ S
Example: S = {a1 , a4 , a5 } out of 6 elements
121 / 177
SUBSET-SUM
Claim
The subset sum problem (SUBSET-SUM ) is NP complete.
Reduce EXACT-COVER to SUBSET-SUM
{S1 , . . . , Sn }, |Sj | = 3 over a base set X = {a1 , . . . , a3m }
Map each set Sj to an integer tj
If Sj ’s are disjoint and cover X , then tj ’s add up to some T
For mapping sets into integers, use the characteristic vector
I
I
I
Represent set S as a vector v (S) where vi (S) = 1 iff ai ∈ S
Example: S = {a1 , a4 , a5 } out of 6 elements
v (S) =
122 / 177
SUBSET-SUM
Claim
The subset sum problem (SUBSET-SUM ) is NP complete.
Reduce EXACT-COVER to SUBSET-SUM
{S1 , . . . , Sn }, |Sj | = 3 over a base set X = {a1 , . . . , a3m }
Map each set Sj to an integer tj
If Sj ’s are disjoint and cover X , then tj ’s add up to some T
For mapping sets into integers, use the characteristic vector
I
I
I
Represent set S as a vector v (S) where vi (S) = 1 iff ai ∈ S
Example: S = {a1 , a4 , a5 } out of 6 elements
v (S) = 1 0 0 1 1 0
123 / 177
SUBSET-SUM
Claim
The subset sum problem (SUBSET-SUM ) is NP complete.
Reduce EXACT-COVER to SUBSET-SUM
{S1 , . . . , Sn }, |Sj | = 3 over a base set X = {a1 , . . . , a3m }
Map each set Sj to an integer tj
If Sj ’s are disjoint and cover X , then tj ’s add up to some T
For mapping sets into integers, use the characteristic vector
I
I
I
I
Represent set S as a vector v (S) where vi (S) = 1 iff ai ∈ S
Example: S = {a1 , a4 , a5 } out of 6 elements
v (S) = 1 0 0 1 1 0
Easy to see that its a one-to-one mapping
124 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
125 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
1 2 3 4 5 6 7 8 9
126 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
1 2 3 4 5 6 7 8 9
1 0 0 1 0 1 0 0 0
127 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
1 2 3 4 5 6 7 8 9
1 0 0 1 0 1 0 0 0
0 0 0 0 0 1 0 1 1
128 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
1 2 3 4 5 6 7 8 9
1 0 0 1 0 1 0 0 0
0 0 0 0 0 1 0 1 1
0 1 0 1 0 0 1 0 0
129 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
1 2 3 4 5 6 7 8 9
1 0 0 1 0 1 0 0 0
0 0 0 0 0 1 0 1 1
0 1 0 1 0 0 1 0 0
1 1 0 0 0 0 0 1 0
0 1 0 1 0 1 0 0 0
1 0 1 0 1 0 0 0 0
130 / 177
An Example
Lets take the two sets {6, 8, 9}, {2, 4, 7}.
The corresponding vectors are:
0 0 0 0 0 1 0 1 1
131 / 177
An Example
Lets take the two sets {6, 8, 9}, {2, 4, 7}.
The corresponding vectors are:
0 0 0 0 0 1 0 1 1
0 1 0 1 0 0 1 0 0
132 / 177
An Example
Lets take the two sets {6, 8, 9}, {2, 4, 7}.
The corresponding vectors are:
0 0 0 0 0 1 0 1 1
0 1 0 1 0 0 1 0 0
The union of the two sets is: {2, 4, 6, 7, 8, 9}
133 / 177
An Example
Lets take the two sets {6, 8, 9}, {2, 4, 7}.
The corresponding vectors are:
0 0 0 0 0 1 0 1 1
0 1 0 1 0 0 1 0 0
The union of the two sets is: {2, 4, 6, 7, 8, 9}
The characteristic vector of the union is:
0 1 0 1 0 1 1 1 1
134 / 177
An Example
Lets take the two sets {6, 8, 9}, {2, 4, 7}.
The corresponding vectors are:
0 0 0 0 0 1 0 1 1
0 1 0 1 0 0 1 0 0
The union of the two sets is: {2, 4, 6, 7, 8, 9}
The characteristic vector of the union is:
0 1 0 1 0 1 1 1 1
Any observations?
135 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
136 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
137 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
0 0 0 0 0 1 0 1 1 : 23 + 21 + 20 = 011
0 1 0 1 0 0 1 0 0 : 27 + 25 + 22 = 164
1 0 1 0 1 0 0 0 0 : 28 + 26 + 24 = 336
138 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
0 0 0 0 0 1 0 1 1 : 23 + 21 + 20 = 011
0 1 0 1 0 0 1 0 0 : 27 + 25 + 22 = 164
1 0 1 0 1 0 0 0 0 : 28 + 26 + 24 = 336
The union covers X and the sets are pair-wise disjoint:
139 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
0 0 0 0 0 1 0 1 1 : 23 + 21 + 20 = 011
0 1 0 1 0 0 1 0 0 : 27 + 25 + 22 = 164
1 0 1 0 1 0 0 0 0 : 28 + 26 + 24 = 336
The union covers X and the sets are pair-wise disjoint:
1 1 1 1 1 1 1 1 1 : 29 − 1 = 511
140 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
0 0 0 0 0 1 0 1 1 : 23 + 21 + 20 = 011
0 1 0 1 0 0 1 0 0 : 27 + 25 + 22 = 164
1 0 1 0 1 0 0 0 0 : 28 + 26 + 24 = 336
The union covers X and the sets are pair-wise disjoint:
1 1 1 1 1 1 1 1 1 : 29 − 1 = 511
11 + 164 + 336 = 511.
141 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
0 0 0 0 0 1 0 1 1 : 23 + 21 + 20 = 011
0 1 0 1 0 0 1 0 0 : 27 + 25 + 22 = 164
1 0 1 0 1 0 0 0 0 : 28 + 26 + 24 = 336
The union covers X and the sets are pair-wise disjoint:
1 1 1 1 1 1 1 1 1 : 29 − 1 = 511
11 + 164 + 336 = 511. So set W = 2n − 1, and check.
142 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
0 0 0 0 0 1 0 1 1 : 23 + 21 + 20 = 011
0 1 0 1 0 0 1 0 0 : 27 + 25 + 22 = 164
1 0 1 0 1 0 0 0 0 : 28 + 26 + 24 = 336
The union covers X and the sets are pair-wise disjoint:
1 1 1 1 1 1 1 1 1 : 29 − 1 = 511
11 + 164 + 336 = 511. So set W = 2n − 1, and check.
There exists subset equal to W =⇒ exact-cover possible
143 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
0 0 0 0 0 1 0 1 1 : 23 + 21 + 20 = 011
0 1 0 1 0 0 1 0 0 : 27 + 25 + 22 = 164
1 0 1 0 1 0 0 0 0 : 28 + 26 + 24 = 336
The union covers X and the sets are pair-wise disjoint:
1 1 1 1 1 1 1 1 1 : 29 − 1 = 511
11 + 164 + 336 = 511. So set W = 2n − 1, and check.
There exists subset equal to W =⇒ exact-cover possible
Problem:
144 / 177
An Example
{1, 4, 6}, {6, 8, 9}, {2, 4, 7}, {1, 2, 8}, {2, 4, 6}, {1, 3, 5}
0 0 0 0 0 1 0 1 1 : 23 + 21 + 20 = 011
0 1 0 1 0 0 1 0 0 : 27 + 25 + 22 = 164
1 0 1 0 1 0 0 0 0 : 28 + 26 + 24 = 336
The union covers X and the sets are pair-wise disjoint:
1 1 1 1 1 1 1 1 1 : 29 − 1 = 511
11 + 164 + 336 = 511. So set W = 2n − 1, and check.
There exists subset equal to W =⇒ exact-cover possible
Problem: False positives.
145 / 177
A Problem
{3, 4}, {2, 4}, {2, 3, 4}
146 / 177
A Problem
{3, 4}, {2, 4}, {2, 3, 4}
0 0 1 1 :3
147 / 177
A Problem
{3, 4}, {2, 4}, {2, 3, 4}
0 0 1 1 :3
0 1 0 1 :5
148 / 177
A Problem
{3, 4}, {2, 4}, {2, 3, 4}
0 0 1 1 :3
0 1 0 1 :5
0 1 1 1 :7
149 / 177
A Problem
{3, 4}, {2, 4}, {2, 3, 4}
0 0 1 1 :3
0 1 0 1 :5
0 1 1 1 :7
The union does not cover X , and not disjoint.
150 / 177
A Problem
{3, 4}, {2, 4}, {2, 3, 4}
0 0 1 1 :3
0 1 0 1 :5
0 1 1 1 :7
The union does not cover X , and not disjoint.
0011 + 0101 + 0111
151 / 177
A Problem
{3, 4}, {2, 4}, {2, 3, 4}
0 0 1 1 :3
0 1 0 1 :5
0 1 1 1 :7
The union does not cover X , and not disjoint.
0011 + 0101 + 0111 = 1111
152 / 177
A Problem
{3, 4}, {2, 4}, {2, 3, 4}
0 0 1 1 :3
0 1 0 1 :5
0 1 1 1 :7
The union does not cover X , and not disjoint.
0 0 1 1 + 0 1 0 1 + 0 1 1 1 = 1 1 1 1 = 15
153 / 177
A Problem
{3, 4}, {2, 4}, {2, 3, 4}
0 0 1 1 :3
0 1 0 1 :5
0 1 1 1 :7
The union does not cover X , and not disjoint.
0 0 1 1 + 0 1 0 1 + 0 1 1 1 = 1 1 1 1 = 15
So, where is the problem coming from?
154 / 177
A Problem
{3, 4}, {2, 4}, {2, 3, 4}
0 0 1 1 :3
0 1 0 1 :5
0 1 1 1 :7
The union does not cover X , and not disjoint.
0 0 1 1 + 0 1 0 1 + 0 1 1 1 = 1 1 1 1 = 15
So, where is the problem coming from?
Carrying! It messes up the addition.
155 / 177
A Solution
There are actually two different problems due to carrying:
156 / 177
A Solution
There are actually two different problems due to carrying:
I
If a column has all 0’s, could get 1 from carry-over
157 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
158 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution:
159 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
160 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
{2, 3, 4} = 0 1 1 1 =
161 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
{2, 3, 4} = 0 1 1 1 = 22 + 21 + 20 ,
162 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
{2, 3, 4} = 0 1 1 1 = 22 + 21 + 20 , 52 + 51 + 50 = 31
163 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
I
{2, 3, 4} = 0 1 1 1 = 22 + 21 + 20 , 52 + 51 + 50 = 31
{3, 4}
= 0011 =
164 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
I
{2, 3, 4} = 0 1 1 1 = 22 + 21 + 20 , 52 + 51 + 50 = 31
{3, 4}
= 0 0 1 1 = 21 + 20 ,
165 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
I
{2, 3, 4} = 0 1 1 1 = 22 + 21 + 20 , 52 + 51 + 50 = 31
51 + 50 = 6
{3, 4}
= 0 0 1 1 = 21 + 20 ,
166 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
I
I
{2, 3, 4} = 0 1 1 1 = 22 + 21 + 20 , 52 + 51 + 50 = 31
51 + 50 = 6
{3, 4}
= 0 0 1 1 = 21 + 20 ,
{2, 4}
= 0101 =
167 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
I
I
{2, 3, 4} = 0 1 1 1 = 22 + 21 + 20 , 52 + 51 + 50 = 31
51 + 50 = 6
{3, 4}
= 0 0 1 1 = 21 + 20 ,
2
0
{2, 4}
= 0 1 0 1 =2 +2 ,
168 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
I
I
{2, 3, 4} = 0 1 1 1 = 22 + 21 + 20 , 52 + 51 + 50 = 31
51 + 50 = 6
{3, 4}
= 0 0 1 1 = 21 + 20 ,
2
0
52 + 50 = 26
{2, 4}
= 0 1 0 1 =2 +2 ,
169 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
I
I
{2, 3, 4} = 0 1 1 1 = 22 + 21 + 20 , 52 + 51 + 50 = 31
51 + 50 = 6
{3, 4}
= 0 0 1 1 = 21 + 20 ,
2
0
52 + 50 = 26
{2, 4}
= 0 1 0 1 =2 +2 ,
0011 + 0101 + 0111
170 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
I
I
{2, 3, 4} = 0 1 1 1 = 22 + 21 + 20 , 52 + 51 + 50 = 31
51 + 50 = 6
{3, 4}
= 0 0 1 1 = 21 + 20 ,
2
0
52 + 50 = 26
{2, 4}
= 0 1 0 1 =2 +2 ,
0011 + 0101 + 0111 = 0223
171 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
I
I
{2, 3, 4} = 0 1 1 1 = 22 + 21 + 20 , 52 + 51 + 50 = 31
51 + 50 = 6
{3, 4}
= 0 0 1 1 = 21 + 20 ,
2
0
52 + 50 = 26
{2, 4}
= 0 1 0 1 =2 +2 ,
0 0 1 1 + 0 1 0 1 + 0 1 1 1 = 0 2 2 3 = 63 6= 1 1 1 1
172 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
I
I
{2, 3, 4} = 0 1 1 1 = 22 + 21 + 20 , 52 + 51 + 50 = 31
51 + 50 = 6
{3, 4}
= 0 0 1 1 = 21 + 20 ,
2
0
52 + 50 = 26
{2, 4}
= 0 1 0 1 =2 +2 ,
0 0 1 1 + 0 1 0 1 + 0 1 1 1 = 0 2 2 3 = 63 6= 1 1 1 1
Adding at most n 1’s =⇒ no carry-over at any digit
173 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
I
I
{2, 3, 4} = 0 1 1 1 = 22 + 21 + 20 , 52 + 51 + 50 = 31
51 + 50 = 6
{3, 4}
= 0 0 1 1 = 21 + 20 ,
2
0
52 + 50 = 26
{2, 4}
= 0 1 0 1 =2 +2 ,
0 0 1 1 + 0 1 0 1 + 0 1 1 1 = 0 2 2 3 = 63 6= 1 1 1 1
Adding at most n 1’s =⇒ no carry-over at any digit
This solves both the problems since:
174 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
I
I
{2, 3, 4} = 0 1 1 1 = 22 + 21 + 20 , 52 + 51 + 50 = 31
51 + 50 = 6
{3, 4}
= 0 0 1 1 = 21 + 20 ,
2
0
52 + 50 = 26
{2, 4}
= 0 1 0 1 =2 +2 ,
0 0 1 1 + 0 1 0 1 + 0 1 1 1 = 0 2 2 3 = 63 6= 1 1 1 1
Adding at most n 1’s =⇒ no carry-over at any digit
This solves both the problems since:
I
If a column has all 0’s, no carry-over ensures it gets a 0.
175 / 177
A Solution
There are actually two different problems due to carrying:
I
I
If a column has all 0’s, could get 1 from carry-over
If a column has more than one 1, could still get one 1
Solution: Interpret vector over base 3m, not base 2!
I
I
I
{2, 3, 4} = 0 1 1 1 = 22 + 21 + 20 , 52 + 51 + 50 = 31
51 + 50 = 6
{3, 4}
= 0 0 1 1 = 21 + 20 ,
2
0
52 + 50 = 26
{2, 4}
= 0 1 0 1 =2 +2 ,
0 0 1 1 + 0 1 0 1 + 0 1 1 1 = 0 2 2 3 = 63 6= 1 1 1 1
Adding at most n 1’s =⇒ no carry-over at any digit
This solves both the problems since:
I
I
If a column has all 0’s, no carry-over ensures it gets a 0.
If a column has more than one 1, it will get the sum, not 1.
176 / 177
Reductions So Far
SAT
ECOV
3-SAT
SC
IP
IS
VC
HPATH
HS
CL
SSUM
KNAP
177 / 177