Efficient Algorithms and Problem Complexity Techniques for - - PowerPoint PPT Presentation

efficient algorithms and problem complexity techniques
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 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

slide-2
SLIDE 2

Outline

Today’s Menu

1

Different Types of Reductions

2

Reduction by Restriction

3

Reduction by Local Replacement

4

Reduction by Composition of Gadgets

Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 2 / 20

slide-3
SLIDE 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

slide-4
SLIDE 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

slide-5
SLIDE 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

slide-6
SLIDE 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 v0 · · · vn. Thus, (vi−1, vi) is a directed edge in f(G) for all i ∈ {1, . . . , n}, which means that v0 · · · vn is a directed cycle in f(G), i.e., f(G) ∈ dHAM. If f(G) ∈ dHAM, then it has a directed Hamiltonian cycle v0 · · · vn. Since f(G) contains an directed edge (vi−1, vi) only if G contains the corresponding undirected edge, this means that v0 · · · vn 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

slide-7
SLIDE 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 di,j ∈ N and a number k ∈ N. Question: Is there a tour v0, . . . , vn−1 such that {v0, . . . , vn−1} = {1, . . . , n} and n

j=1 dvj−1,vj 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

slide-8
SLIDE 8

Reduction by Restriction

Example: Reducing HAM to TSP

Reduction f from HAM to TSP: Let V = {1, . . . , n} be the set of nodes

  • f the input graph G. Let k = n and, for i, j ∈ {1, . . . , n},

di,j = 1 if G contains the edge (i, j) 2

  • therwise.

Correctness: Computability of f in polynomial time is again obvious. If G ∈ HAM, then it has a Hamiltonian cycle v0 · · · vn. Thus, dvj−1,vj mod n = 1 for all i, j ∈ {1, . . . , n}, which means that the tour v0 · · · vn−1 has length n = k. If f(G) ∈ TSP, then there is a tour v0 · · · vn−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, v0 · · · vn−1v0 is a Hamiltonian cycle in G.

Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 8 / 20

slide-9
SLIDE 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

slide-10
SLIDE 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

slide-11
SLIDE 11

Reduction by Local Replacement

Example: Reducing SAT to 3SAT

Reduction f from SAT to 3SAT: replace every individual clause (l1 ∨ · · · ∨ lk) by several clauses consisting of 3 literals each. (l) → (l ∨ y1 ∨ y2) ∧ (l ∨ y1 ∨ ¬y2) ∧ (l ∨ ¬y1 ∨ y2) ∧ (l ∨ ¬y1 ∨ ¬y2) (l1 ∨ l2) → (l1 ∨ l2 ∨ y1) ∧ (l1 ∨ l2 ∨ ¬y1) (l1 ∨ · · · ∨ lk) → (l1 ∨ l2 ∨ y1) ∧ (¬y1 ∨ l3 ∨ y2) ∧ . . . (¬yk−4 ∨ lk−2 ∨ yk−3) ∧ (¬yk−3 ∨ lk−1 ∨ lk)

Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 11 / 20

slide-12
SLIDE 12

Reduction by Local Replacement

Example: Reducing SAT to 3SAT

Correctness of C = (l1 ∨ · · · ∨ lk) → (l1 ∨ l2 ∨ y1) ∧ (¬y1 ∨ l3 ∨ y2) ∧ . . . (¬yk−4 ∨ lk−2 ∨ yk−3) ∧ (¬yk−3 ∨ lk−1 ∨ lk) = C′ α(C) = true for an assignment α ⇒ α(li) = true for some i ⇒ extending α by α(y1) = · · · = α(yi−2) = true and α(yi−1) = · · · = α(yk−3) = false yields α(C′) = true. α(C′) = true for an assignment α Consider the first clause that does not contain a yi with α(yi) = true ⇒ this clause does not contain ¬yi−1 with α(¬yi−1) = true either ⇒ the clause contains lj with α(lj) = true ⇒ α(C) = true.

Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 12 / 20

slide-13
SLIDE 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

slide-14
SLIDE 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 x1, . . . , xn. Let l2, l4, . . . , lm be the sequence of literals in (the clauses of) ϕ.

Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 14 / 20

slide-15
SLIDE 15

Reduction by Composition of Gadgets

A gadget for choosing the truth value of xi:

vi

1

vi

2

vi

j−1

vi

j

vi

m−1

vi

m

α(xi) = true α(xi) = false

xi-gadget

Notes: A path will enter the gadget at vi

1 and leave it at vi m if α(xi) = true

and conversely if α(xi) = false. The gadget contains twice as many nodes as ϕ contains literals. The gadget for the clause containing lj will be attached to vi

j−1 and vi j if lj ∈ {xi, ¬xi}.

Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 15 / 20

slide-16
SLIDE 16

Reduction by Composition of Gadgets

The gadget for the clauses:

vi

1

vi

2

vi

j−1

vi

j

vi

m−1

vi

m

xi-gadget

. . . xi . . .

  • r

. . . ¬xi . . . (clause with literal lj) Notes: One extra node per clause C. If lj = xi or lj = ¬xi is in C, it is connected to vi

j−1, vi j as shown.

Passing the xi-gadget left to right, we can make a “detour” to pass C if the literal lj = xi occurs in C. Similarly when passing from right to left and lj = ¬xi occurs in C.

Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 16 / 20

slide-17
SLIDE 17

Reduction by Composition of Gadgets

Putting it all together:

x1-gadget x2-gadget xn-gadget

. . . . . . . . .

start end

C1

· · · · · ·

Ck

· · · · · ·

Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 17 / 20

slide-18
SLIDE 18

Reduction by Composition of Gadgets

Example: Reducing SAT to dHAMPATH

Correctness, direction 1: Suppose α makes ϕ true. Start at start. Continue to v1

1 if α(x1) = true; otherwise, go to v1 m.

Pass through the x1-gadget with detours via clause gadgets (see below). Continue similarly with the x2-gadget, and so on. Detours when passing the xi-gasket from left to right (α(xi) = true): If ⋆ a clause C contains the literal lj = xi and ⋆ the node corresponding to C has not yet been passed go from vi

j−1 to vi j via C (rather than directly from vi j−1 to vi j).

Similarly if α(xi) = false and C contains the literal lj = ¬xi. As α(C) = true for every clause C, this visits each node once.

Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 18 / 20

slide-19
SLIDE 19

Reduction by Composition of Gadgets

Example: Reducing SAT to dHAMPATH

Correctness, direction 2: Suppose f(ϕ) ∈ dHAMPATH. The path must start at start, pass the xi-gadgets one after another, and end at end. In particular, clause nodes can only be entered and left via “companion nodes” vi

j−1, vi j (otherwise, there is no way to return).

Depending on the direction in which the xi-gadgets are passed, this yields a truth assignment α. Since all the clause nodes are on the paths, they must have been included via detours. A detour is only possible if the corresponding literal is made true by α. Hence, α(C) = true for all clauses C, meaning that α(ϕ) = true.

Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 19 / 20

slide-20
SLIDE 20

Reduction by Composition of Gadgets

Reading . . .

Please read the remainder of Chapter 10 in the textbook.

Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 11 20 / 20