Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Astrid Pieterse
I Algorithms
• Today we consider decision problems: YES/NO output
I Running time
• Number of steps compared to input size
• Polynomial vs Exponential
• Denoted using big-O notation, O(n5 ) or O(3n )
I NP-hardness
• No polynomial-time algorithm
Why preprocessing 3/37
Without preprocessing
x YES/NO
n bits
With preprocessing
x Fast!
x0 YES/NO
n bits n0
Great preprocessing 4/37
x Fast!
x0
n bits n0
Great preprocessing: does not exist 5/37
x parameter k
Poly-time
x0 k0
n bits ≤ f (k)
Parameterized preprocessing: kernels 7/37
Kernelization
Find an algorithm that
I Runs in polynomial time
I Outputs an equivalent instance of the same problem
I The new instance is small
• Bounded by some function f(k)
• Independent of n
x parameter k
Poly-time
x0 k0
n bits ≤ f (k)
Kernelization: Example 8/37
I Kernel size 34
I Kernel size 34
Correctness
I The new instance is small
I Can solve shortest path in
polynomial time
I Correctness?
Kernelization: Example 10/37
Kernel:
I Runs in polynomial time
I x is a yes-instance ⇔ x 0 is a yes-instance
I |x 0 | 6 f(k) and k 0 6 f(k)
Solutions 12/37
1. Technically, the size is not completely correct. How large are the
edge-weights (length of shortest paths) that we store??
They are not bounded by k.
But, there are ways to solve the problem, there is a way to “rescale”
our weights such that they can be stored efficiently
Satisfiability variants 13/37
(x ∨ y) ∧ (z ∨ ¬y ∨ w) ∧ . . .
Input:
F = {¬x, ¬y} ∧{¬y, z} ∧ {x, z}
| {z }
clause
Example
Let x, y, z ∈ {0, 1} (where 0 is false, 1 is true), then
Example
Let x, y, z ∈ {0, 1} (where 0 is false, 1 is true), then
Example
Let x, y, z ∈ {0, 1} (where 0 is false, 1 is true), then
Example
Let x, y, z ∈ {0, 1} (where 0 is false, 1 is true), then
Example
Let x, y, z ∈ {0, 1} (where 0 is false, 1 is true), then
Algorithm
I Given formula F
I Rewrite by giving an linear equation for each clause
I Find a basis of the row-space
• Use Gaussian elimination
I Remove constraints not in the basis
1 0 ... 1
1
1 1 ... 0 x 1 1.
.. .
.
. =
... ... ... ...
... ..
... ... ... xn .
0 −1 ... 1 0
Kernel for Exact Satisfiability 17/37
Algorithm
I Given formula F
I Rewrite by giving an linear equation for each clause
I Find a basis of the row-space
• Use Gaussian elimination
I Remove constraints not in the basis
1 0 ... 1
1
1 1 ... 0 x 1 1.
.. .
.
. =
... ... ... ...
... ..
... ... ... xn .
0 −1 ... 1 0
Kernel for Exact Satisfiability 17/37
Algorithm
I Given formula F
I Rewrite by giving an linear equation for each clause
I Find a basis of the row-space
• Use Gaussian elimination
I Remove constraints not in the basis
1 0 ... 1 1
1 1 ... 0 1
... ... ... ...
... ... ... ...
0 −1 ... 1 0
Kernel for Exact Satisfiability 17/37
Algorithm
I Given formula F
I Rewrite by giving an linear equation for each clause
I Find a basis of the row-space
• Use Gaussian elimination
I Remove constraints not in the basis
1 0 ... 1 1
1 1 ... 0 1
... ... ... ... ...
... ... ... ... ...
0 −1 ... 1 0
Kernel for Exact Satisfiability 17/37
Algorithm
I Given formula F
I Rewrite by giving an linear equation for each clause
I Find a basis of the row-space
• Use Gaussian elimination
I Remove constraints not in the basis
1 0 ... 1 1
1 1 ... 0 1
... ... ... ... ...
Kernel for Exact Satisfiability 18/37
Correctness
I Polynomial time
I yes-instance after removing constraints ⇒ F is a yes-instance
Size
I Matrix size (#clauses) × (n + 1)
I At most n + 1 clauses remaining
Kernel for Exact Satisfiability: Recap 19/37
Find a kernel for the 3-NAE-SAT problem that has O(n2 ) constraints.
Input A formula in CNF-form where every clause contains exactly
3 variables, such as
F = {x, y, z} ∧ {y, z, w} ∧ . . .
| {z }
clause
x + y + z − (xy + xz + yz) = 1
| {z } | {z }
#true vars. #true pairs
f(x1 , . . . , xd ) := g(x1 + x2 + . . . + xd )
General solution: d-NAE-SAT 22/37
Problem
Given: Graph G
Question: Is it possible to color each vertex of G with red, green or blue
such that any two endpoints of an edge have a different color
Parameter
The size of a vertex cover in G: a set S of vertices, such that for every
edge at least one endpoint is in S
Goal
Find a small kernel (wrt |S|) !
We assume S is given
Problem:
There are many graphs with a small vertex cover
Example 3: 3-Coloring 23/37
Problem
Given: Graph G
Question: Is it possible to color each vertex of G with red, green or blue
such that any two endpoints of an edge have a different color
Parameter
The size of a vertex cover in G: a set S of vertices, such that for every
edge at least one endpoint is in S
Goal
Find a small kernel (wrt |S|) !
We assume S is given
Problem:
There are many graphs with a small vertex cover
Example 3: 3-Coloring 23/37
Problem
Given: Graph G
Question: Is it possible to color each vertex of G with red, green or blue
such that any two endpoints of an edge have a different color
Parameter
The size of a vertex cover in G: a set S of vertices, such that for every
edge at least one endpoint is in S
Goal
Find a small kernel (wrt |S|)
We assume S is given
Problem:
There are many graphs with a small vertex cover
Example 3: 3-Coloring 23/37
Problem
Given: Graph G
Question: Is it possible to color each vertex of G with red, green or blue
such that any two endpoints of an edge have a different color
Parameter
The size of a vertex cover in G: a set S of vertices, such that for every
edge at least one endpoint is in S
Goal
Find a small kernel (wrt |S|)
We assume S is given
Problem:
There are many graphs with a small vertex cover
Example 3: 3-Coloring 23/37
Problem
Given: Graph G
Question: Is it possible to color each vertex of G with red, green or blue
such that any two endpoints of an edge have a different color
Parameter
The size of a vertex cover in G: a set S of vertices, such that for every
edge at least one endpoint is in S
Goal
Find a small kernel (wrt |S|)
We assume S is given
Problem:
There are many graphs with a small vertex cover
Example 3: 3-Coloring 23/37
Problem
Given: Graph G
Question: Is it possible to color each vertex of G with red, green or blue
such that any two endpoints of an edge have a different color
Parameter
The size of a vertex cover in G: a set S of vertices, such that for every
edge at least one endpoint is in S
Goal
Find a small kernel (wrt |S|)
We assume S is given
Problem:
There are many graphs with a small vertex cover
Example 3: 3-Coloring 23/37
Problem
Given: Graph G
Question: Is it possible to color each vertex of G with red, green or blue
such that any two endpoints of an edge have a different color
Parameter
The size of a vertex cover in G: a set S of vertices, such that for every
edge at least one endpoint is in S
Goal
Find a small kernel (wrt |S|)
We assume S is given
Problem:
There are many graphs with a small vertex cover
Kernel for 3-coloring 24/37
Algorithm S
Given: graph G, vertex cover S u
First, we mark vertices we want to keep: v
I For any three distinct vertices u, v, w in S
w
I Mark one common neighbor in V(G) \ S
Remove all unmarked vertices in V(G) \ S x
For u, v, w
I Mark one vertex
For v, w, x
I Mark one vertex.
Other triples have no common neighbor
Kernel for 3-coloring 25/37
Algorithm S
Given: graph G, vertex cover S u
First, we mark vertices we want to keep: v
I For any three distinct vertices u, v, w in S
w
I Mark one common neighbor in V(G) \ S
Remove all unmarked vertices in V(G) \ S x
For u, v, w
I Mark one vertex
For v, w, x
I Mark one vertex.
Other triples have no common neighbor
Kernel for 3-coloring 25/37
Algorithm S
Given: graph G, vertex cover S u
First, we mark vertices we want to keep: v
I For any three distinct vertices u, v, w in S
w
I Mark one common neighbor in V(G) \ S
Remove all unmarked vertices in V(G) \ S x
For u, v, w
I Mark one vertex
For v, w, x
I Mark one vertex.
Other triples have no common neighbor
Kernel for 3-coloring 25/37
Algorithm S
Given: graph G, vertex cover S u
First, we mark vertices we want to keep: v
I For any three distinct vertices u, v, w in S
w
I Mark one common neighbor in V(G) \ S
Remove all unmarked vertices in V(G) \ S x
For u, v, w
I Mark one vertex
For v, w, x
I Mark one vertex.
Other triples have no common neighbor
Kernel for 3-coloring 26/37
Correctness
Let the original input be G and the new graph G 0
Clearly if G is 3-colorable, so is G 0 . Suppose G 0 is 3-colorable, show
how to color G
I Copy the coloring of G 0 to G
Correctness
Let the original input be G and the new graph G 0
Clearly if G is 3-colorable, so is G 0 . Suppose G 0 is 3-colorable, show
how to color G
I Copy the coloring of G 0 to G
Correctness
Let the original input be G and the new graph G 0
Clearly if G is 3-colorable, so is G 0 . Suppose G 0 is 3-colorable, show
how to color G
I Copy the coloring of G 0 to G
Correctness
Let the original input be G and the new graph G 0
Clearly if G is 3-colorable, so is G 0 . Suppose G 0 is 3-colorable, show
how to color G
I Copy the coloring of G 0 to G
Correctness
Let the original input be G and the new graph G 0
Clearly if G is 3-colorable, so is G 0 . Suppose G 0 is 3-colorable, show
how to color G
I Copy the coloring of G 0 to G
Correctness
Let the original input be G and the new graph G 0
Clearly if G is 3-colorable, so is G 0 . Suppose G 0 is 3-colorable, show
how to color G
I Copy the coloring of G 0 to G
Correctness
Suppose vertex y in V(G) \ V(G 0 ) cannot be colored
I Thus, it has three neighbors u, v, w which are red, green and blue
respectively
I But then there is a node y 0 in G 0 with neighbors u, v, w
• since some vertex was marked by u, v, w
I Thus y 0 cannot be colored properly; contradiction
Size
Remember: parameter |S|. Count the vertices in G 0 :
I All vertices in S, clearly there are |S|
I One vertex for all triples in S, at most |S|3
I In total O(|S|3 ) vertices and
• Possibly O(|S|4 ) edges with this kernel
Size
Remember: parameter |S|. Count the vertices in G 0 :
I All vertices in S, clearly there are |S|
I One vertex for all triples in S, at most |S|3
I In total O(|S|3 ) vertices and
• Possibly O(|S|4 ) edges with this kernel
First idea:
Suppose: you already know some lower bound for some problem
Can we use it to get lower bounds for other problems?
Re-using existing kernels 31/37
A kernel for problem X can sometimes be used to get a (general type of)
kernel for problem Y
y Poly-
parameter k time
x g(k)
Kernel x0 k0
n bits poly(n) f (g(k))
y Poly-
parameter k time
x c
Kernel x0 k 00
k
n bits poly(n) f (k c )
y Poly-
parameter k time
x c
Kernel x0 k 00
k
n bits poly(n) f (k c )
It is known that CNF-SAT with unbounded clause length does not have a
kernel of size polynomial in the number of variables
I Transform an instance of CNF-SAT to NAE-SAT, to get a lower bound
Add new variable t to each clause
F = (x ∨ y) ∧ (x ∨ ¬y ∨ z) ∧ (¬w ∨ x)
becomes
F 0 = {t, x, y} ∧ {t, x, ¬y, z} ∧ {t, ¬w, x}
I Can be done in polynomial time
I The number of variables only increased by 1
I It remains to show F is satisfiable iff F 0 is
Lower bound: NAE-SAT 34/37
F = ( x ∨ y) ∧ ( x ∨ ¬y ∨ z) ∧ ( ¬w ∨x)
F 0 = {t, x, y} ∧ {t, x, ¬y, z} ∧ (t, ¬w, x)
Suppose F is satisfiable
I Keep the same assignment for F 0 , extended with t := false
I Every clause in F 0 has a false variable (namely, t)
I and one true variable (from satisfying F)
Suppose F 0 is satisfiable
I If t = false, keep the same assignment for F
I If t = true, take the opposite assignment for F
Exercises 35/37
2. If all clauses have size d, CNF-SAT with n variables does not have a
kernel of size O(nd−ε ), for any ε.
a. Can we use this bound to obtain a bound for NAE-SAT with d variables
per clause? How?
b. Can we hope to improve the kernel for 3-NAE-SAT with O(n2 )
constraints that we saw in a previous exercise?
Solutions 36/37
2. If all clauses have size d, CNF-SAT with n variables does not have a
kernel of size O(nd−ε ), for any ε.
a. Can we use this bound to obtain a bound for NAE-SAT with d variables
per clause? How?
Yes (proof on whiteboard)
b. Can we hope to improve the kernel for 3-NAE-SAT with O(n2 )
constraints that we saw in a previous exercise?
Not really, there is no kernel of size O(n2−ε ). But improvements by
logarithmic factors could still be possible.
Questions? 37/37