efficient algorithms and problem complexity techniques
play

Efficient Algorithms and Problem Complexity Techniques for - PowerPoint PPT Presentation

Efficient Algorithms and Problem Complexity Techniques for Constructing Reductions Frank Drewes Department of Computing Science Ume a University Frank Drewes (Ume a University) Efficient Algorithms and Problem Complexity Lecture


  1. Efficient Algorithms and Problem Complexity – Techniques for Constructing Reductions – Frank Drewes Department of Computing Science Ume˚ a University Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 1 / 20

  2. Outline Today’s Menu Different Types of Reductions 1 Reduction by Restriction 2 Reduction by Local Replacement 3 Reduction by Composition of Gadgets 4 Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 2 / 20

  3. Different Types of Reductions Types of Reductions Notation: NPC denotes the class of all NP-complete problems. Suppose we want to show that A ∈ NPC. If we already know that A ∈ NP, we have to find a problem B ∈ NPC and a polynomial-time reduction from B to A . The three most common types of reductions: 1 reduction by restriction (simple) 2 reduction by local replacement (still usually rather simple) 3 reduction by composition of “gadgets” (can be quite tricky) Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 3 / 20

  4. Reduction by Restriction Reduction by Restriction Idea: If A is a more general variant of a problem B ∈ NPC, then the reduction only has to turn an instance of B into an instance of A . Intuition: If A is more general than B , then A cannot be easier than B . Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 4 / 20

  5. Reduction by Restriction Example: Reducing HAM to dHAM Recall Hamiltonian Cycle (HAM) Input: An undirected graph G = ( V, E ) . Question: Does G contain a simple cycle of length | V | ? Directed Hamiltonian Cycle (dHAM) is defined in the same way, except that G is directed (and a directed simple cycle of length | V | is sought). Assume that we already know that HAM ∈ NPC. In which sense is dHAM a more general variant of HAM? Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 5 / 20

  6. Reduction by Restriction Example: Reducing HAM to dHAM Reduction f from HAM to dHAM: In the undirected input graph G , turn every edge into two antiparallel edges: . Correctness: Computability of f in polynomial time is obvious. If G ∈ HAM, then it has a Hamiltonian cycle v 0 · · · v n . Thus, ( v i − 1 , v i ) is a directed edge in f ( G ) for all i ∈ { 1 , . . . , n } , which means that v 0 · · · v n is a directed cycle in f ( G ) , i.e., f ( G ) ∈ dHAM. If f ( G ) ∈ dHAM, then it has a directed Hamiltonian cycle v 0 · · · v n . Since f ( G ) contains an directed edge ( v i − 1 , v i ) only if G contains the corresponding undirected edge, this means that v 0 · · · v n is a Hamiltonian cycle in G . In other words, G ∈ HAM. Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 6 / 20

  7. Reduction by Restriction Example: Reducing HAM to TSP One version of the Travelling Salesman Decision Problem (TSP) Input: An n × n -matrix of distances d i,j ∈ N and a number k ∈ N . Question: Is there a tour v 0 , . . . , v n − 1 such that { v 0 , . . . , v n − 1 } = { 1 , . . . , n } and � n j =1 d v j − 1 ,v j mod n ≤ k ? Assume again that we already know that HAM ∈ NPC. In which sense is TSP a more general variant of HAM? Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 7 / 20

  8. Reduction by Restriction Example: Reducing HAM to TSP Reduction f from HAM to TSP: Let V = { 1 , . . . , n } be the set of nodes of the input graph G . Let k = n and, for i, j ∈ { 1 , . . . , n } , � 1 if G contains the edge ( i, j ) d i,j = 2 otherwise. Correctness: Computability of f in polynomial time is again obvious. If G ∈ HAM, then it has a Hamiltonian cycle v 0 · · · v n . Thus, d v j − 1 ,v j mod n = 1 for all i, j ∈ { 1 , . . . , n } , which means that the tour v 0 · · · v n − 1 has length n = k . If f ( G ) ∈ TSP, then there is a tour v 0 · · · v n − 1 of length k ≤ n . Since the only distances are 1 and 2, this means that all the distances on this tour are 1. Thus, v 0 · · · v n − 1 v 0 is a Hamiltonian cycle in G . Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 8 / 20

  9. Reduction by Local Replacement Reduction by Local Replacement Idea: To turn an instance of B ∈ NPC into a corresponding instance of A , we locally replace substructures of an instance of B by other substructures. This is often used in order to turn a more general problem into a special form, showing that even this special form is NP-complete. Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 9 / 20

  10. Reduction by Local Replacement Example: Reducing SAT to 3SAT Recall (?) 3-Satisfiability (3SAT) Input: An propositional formula ϕ in CNF in which each clause has exactly 3 literals. Question: Is ϕ satisfiable? We already know that SAT ∈ NPC. How can we turn an instance of SAT into an equivalent instance of 3SAT? Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 10 / 20

  11. Reduction by Local Replacement Example: Reducing SAT to 3SAT Reduction f from SAT to 3SAT: replace every individual clause ( l 1 ∨ · · · ∨ l k ) by several clauses consisting of 3 literals each. ( l ) �→ ( l ∨ y 1 ∨ y 2 ) ∧ ( l ∨ y 1 ∨ ¬ y 2 ) ∧ ( l ∨ ¬ y 1 ∨ y 2 ) ∧ ( l ∨ ¬ y 1 ∨ ¬ y 2 ) ( l 1 ∨ l 2 ) �→ ( l 1 ∨ l 2 ∨ y 1 ) ∧ ( l 1 ∨ l 2 ∨ ¬ y 1 ) ( l 1 ∨ · · · ∨ l k ) �→ ( l 1 ∨ l 2 ∨ y 1 ) ∧ ( ¬ y 1 ∨ l 3 ∨ y 2 ) ∧ . . . ( ¬ y k − 4 ∨ l k − 2 ∨ y k − 3 ) ∧ ( ¬ y k − 3 ∨ l k − 1 ∨ l k ) Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 11 / 20

  12. Reduction by Local Replacement Example: Reducing SAT to 3SAT Correctness of C = ( l 1 ∨ · · · ∨ l k ) �→ ( l 1 ∨ l 2 ∨ y 1 ) ∧ ( ¬ y 1 ∨ l 3 ∨ y 2 ) ∧ . . . ( ¬ y k − 4 ∨ l k − 2 ∨ y k − 3 ) ∧ ( ¬ y k − 3 ∨ l k − 1 ∨ l k ) = C ′ α ( C ) = true for an assignment α ⇒ α ( l i ) = true for some i ⇒ extending α by α ( y 1 ) = · · · = α ( y i − 2 ) = true and α ( y i − 1 ) = · · · = α ( y k − 3 ) = false yields α ( C ′ ) = true . α ( C ′ ) = true for an assignment α Consider the first clause that does not contain a y i with α ( y i ) = true ⇒ this clause does not contain ¬ y i − 1 with α ( ¬ y i − 1 ) = true either ⇒ the clause contains l j with α ( l j ) = true ⇒ α ( C ) = true . Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 12 / 20

  13. Reduction by Composition of Gadgets Reduction by Composition of Gadgets Gadgets are often used if the target of the reduction is a graph problem. Idea: To turn an instance of B ∈ NPC into a corresponding instance of A , we build an instance of A by composing copies of one or more “gadgets” that are constructed to fulfill a specific purpose. Intuition: Think of composing, i.e., a binary adder using logical gates, or composing an 8-bit adder from 7 binary adders. Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 13 / 20

  14. Reduction by Composition of Gadgets Example: Reducing SAT to dHAMPATH Recall (?) directed Hamiltonian Cycle (dHAMPATH) Input: A directed graph G = ( V, E ) . Question: Does G contain a simple path of length | V | ? How can we turn an instance of SAT into an equivalent instance of dHAMPATH? In the following, consider a formula ϕ in CNF with n variables x 1 , . . . , x n . Let l 2 , l 4 , . . . , l m be the sequence of literals in (the clauses of) ϕ . Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 14 / 20

  15. Reduction by Composition of Gadgets A gadget for choosing the truth value of x i : x i -gadget α ( x i ) = true v i v i v i v i v i v i j − 1 j m − 1 1 2 m α ( x i ) = false Notes: A path will enter the gadget at v i 1 and leave it at v i m if α ( x i ) = true and conversely if α ( x i ) = false . The gadget contains twice as many nodes as ϕ contains literals. The gadget for the clause containing l j will be attached to v i j − 1 and v i j if l j ∈ { x i , ¬ x i } . Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 15 / 20

  16. Reduction by Composition of Gadgets The gadget for the clauses: . . . x i . . . . . . ¬ x i . . . or (clause with literal l j ) x i -gadget v i v i v i v i v i v i 1 2 j − 1 j m − 1 m Notes: One extra node per clause C . If l j = x i or l j = ¬ x i is in C , it is connected to v i j − 1 , v i j as shown. Passing the x i -gadget left to right, we can make a “detour” to pass C if the literal l j = x i occurs in C . Similarly when passing from right to left and l j = ¬ x i occurs in C . Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 16 / 20

  17. Reduction by Composition of Gadgets Putting it all together: C 1 C k · · · · · · · · · · · · start x 1 -gadget x 2 -gadget . . . . . . . . . x n -gadget end Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 17 / 20

Recommend


More recommend