24. NP-Reductions
Apr 12, 2022
Recall theorem: if language A is NP-complete, language B is in NP, and A is polynomially reducible to B, then B is NP-complete.
Using the previous theorem, prove that the following problems are NP-complete.
Vertex Cover
Vertex cover of a graph is a subset of nodes S such that every edge in the graph touches at least one node in S, see vertex cover ↗.
-
Size of vertex-cover is the number of nodes in the cover,
. -
Corresponding language
VERTEX-COVER =
: graph contains vertex cover of size
Theorem. VERTEX-COVER is NP-complete.
Proof.
-
VERTEX-COVER is in NP can be easily proven.
-
We will reduce in P-time 3CNF-SAT to VERTEX-COVER (NP-complete)
Let
e.g.
Formula
Construct gadgets:
1 2 3 4 5 6 7 8 9 10 |
|
Link the literals between variable and clause gadgets
1 2 3 4 5 6 7 8 9 10 |
|
is satisfied contains vertex cover of size .
Choose values for each variable
1 2 3 4 5 6 7 8 9 10 11 12 |
|
In general case:
- edges in variable gadgets are incident to at least one node in the cover.
- edges in clause gadgets are incident to at least one node in the cover, since two nodes are chosen in a clause gadget
Every edge connecting variable gadgets and clause gadgets is one of three types (1 node in variable is selected, 1 node is clause gadget is selected, or both are selected). The case where neither is selected cannot occur by the rules of this construction.
-
contains vertex cover of size is satisfied. -
exactly one literal in each variable gadget is chosen
- exactly two nodes in each clause gadget is chosen
For 3CNF variable assignment, choose the literals is the cover from variable gadgets, e.g.
3CNF-SAT
The proof can be generalized for arbitrary
Hamiltonian path
Theorem. HAMILTONIAN-PATH is NP-complete.
Proof.
-
HAMILTONIAN-PATH is in NP - can be easily proven.
-
We will reduce in P-time 3CNF-SAT to HAMILTONIAN-PATH (NP-complete)
Consider arbitrary CNF formula:
Build a diamond-structure gadget fot variable
A pair of nodes in gadget for each clause node. Pairs separated by a node.
- if variable appears as-is in clause: first edge from gadget outgoing (left to right), second edge from gadget is incoming.
- if variable appears inverted in clause: first edge from gadget incoming (left to right), second edge from gadget outgoing.
Combine the gadgets to form a complete graph.
- If variable is set to 1, traverse its gadget from left to right.
- Visit clauses satisfied from the variable assignment.
- for each clause pick one variable that satisfies it and visit respective node once from that variable gadget
Symmetrically it can be shown: if the graph has a Hamiltonian path, then the formula has a satisfying assignment.
Basic idea: each clause node is visited exactly once from some variable gadget, and that variable satisfies the clause. It is impossible a clause node to be traversed from different variable gadgets.
Therefore the formula is satisfied iff the respective graph has a Hamiltonian path. The proof can apply to any 3CNF formula. The graph is constructed in polynomial time with respect to the size of the formula.
Therefore we have reduced in polynomial time 3CNF-SAT to HAMILTONIAN-PATH.