more np complete problems
play

More NP-Complete Problems A language L is NP-Complete Lecture 4 L - PowerPoint PPT Presentation

CS 573: Algorithms, Fall 2013 Recap NP : languages that have polynomial time certifiers/verifiers. More NP-Complete Problems A language L is NP-Complete Lecture 4 L is in NP September 5, 2013 for every L in NP , L P L L is


  1. CS 573: Algorithms, Fall 2013 Recap NP : languages that have polynomial time certifiers/verifiers. More NP-Complete Problems A language L is NP-Complete ⇐ Lecture 4 ⇒ L is in NP September 5, 2013 for every L ′ in NP , L ′ ≤ P L L is NP-Hard if for every L ′ in NP , L ′ ≤ P L . Theorem (Cook-Levin) Circuit-SAT and SAT are NP-Complete . Sariel (UIUC) CS573 1 Fall 2013 1 / 58 Sariel (UIUC) CS573 2 Fall 2013 2 / 58 Recap contd Today Prove Theorem (Cook-Levin) Hamiltonian Cycle Problem is NP-Complete . Circuit-SAT and SAT are NP-Complete . 3-Coloring is NP-Complete . Subset Sum . Establish NP-Complete ness via reductions: SAT ≤ P 3-SAT and hence 3-SAT is NP -complete 3-SAT ≤ P Independent Set (which is in NP ) and hence Independent Set is NP-Complete Vertex Cover is NP-Complete Clique is NP-Complete Set Cover is NP-Complete Sariel (UIUC) CS573 3 Fall 2013 3 / 58 Sariel (UIUC) CS573 4 Fall 2013 4 / 58

  2. Directed Hamiltonian Cycle Input Given a directed graph G = ( V , E ) with n vertices Goal Does G have a Hamiltonian cycle? Part I A Hamiltonian cycle is a cycle in the graph that visits every vertex in G exactly once NP-Completeness of Hamiltonian Cycle Sariel (UIUC) CS573 5 Fall 2013 5 / 58 Sariel (UIUC) CS573 6 Fall 2013 6 / 58 Directed Hamiltonian Cycle is NP-Complete Reduction Directed Hamiltonian Cycle is in NP Given 3-SAT formula ϕ create a graph G ϕ such that ◮ Certificate: Sequence of vertices G ϕ has a Hamiltonian cycle if and only if ϕ is satisfiable ◮ Certifier: Check if every vertex (except the first) appears exactly G ϕ should be constructible from ϕ by a polynomial time once, and that consecutive vertices are connected by a directed algorithm A edge Hardness: We will show 3-SAT ≤ P Directed Hamiltonian Cycle Notation: ϕ has n variables x 1 , x 2 , . . . , x n and m clauses C 1 , C 2 , . . . , C m . Sariel (UIUC) CS573 7 Fall 2013 7 / 58 Sariel (UIUC) CS573 8 Fall 2013 8 / 58

  3. Reduction: First Ideas The Reduction: Phase I Viewing SAT: Assign values to n variables, and each clauses has Traverse path i from left to right if and only if x i is set to true. 3 ways in which it can be satisfied. Each path has 3 ( m + 1 ) nodes where m is number of clauses in Construct graph with 2 n Hamiltonian cycles, where each cycle ϕ ; nodes numbered from left to right ( 1 to 3 m + 3 ) corresponds to some boolean assignment. Then add more graph structure to encode constraints on assignments imposed by the clauses. x 1 x 2 x 3 x 4 Sariel (UIUC) CS573 9 Fall 2013 9 / 58 Sariel (UIUC) CS573 10 Fall 2013 10 / 58 The Reduction: Phase II Correctness Proof Add vertex c j for clause C j . c j has edge from vertex 3 j and to Proposition vertex 3 j + 1 on path i if x i appears in clause C j , and has edge ϕ has a satisfying assignment ⇐ ⇒ G ϕ has a Hamiltonian cycle. from vertex 3 j + 1 and to vertex 3 j if ¬ x i appears in C j . Proof. x 1 ∨ ¬ x 2 ∨ x 4 x 1 ∨ ¬ x 2 ∨ x 4 x 1 ∨ ¬ x 2 ∨ x 4 ”Buffer” vertices x 1 ∨ ¬ ¬ x 1 ∨ ¬ x 2 ∨ ¬ x 3 ¬ x 1 ∨ ¬ x 2 ∨ ¬ x 3 ¬ x 1 ∨ ¬ x 2 ∨ ¬ x 3 ⇒ Let α be the satisfying assignment for ϕ . Define Hamiltonian cycle as follows ◮ If α ( x i ) = 1 then traverse path i from left to right x 1 x 1 x 1 ◮ If α ( x i ) = 0 then traverse path i from right to left. ◮ For each clause, path of at least one variable is in the “right” x 2 x 2 x 2 direction to splice in the node corresponding to clause. x 3 x 3 x 3 x 4 x 4 x 4 Sariel (UIUC) CS573 11 Fall 2013 11 / 58 Sariel (UIUC) CS573 12 Fall 2013 12 / 58

  4. Hamiltonian Cycle ⇒ Satisfying assignment Example Proof continued x 1 ∨ ¬ x 2 ∨ x 4 ¬ x 1 ∨ ¬ x 2 ∨ ¬ x 3 Suppose Π is a Hamiltonian cycle in G ϕ If Π enters c j (vertex for clause C j ) from vertex 3 j on path i then it must leave the clause vertex on edge to 3 j + 1 on the x 1 same path i ◮ If not, then only unvisited neighbor of 3 j + 1 on path i is 3 j + 2 x 2 ◮ Thus, we don’t have two unvisited neighbors (one to enter x 3 from, and the other to leave) to have a Hamiltonian Cycle Similarly, if Π enters c j from vertex 3 j + 1 on path i then it x 4 must leave the clause vertex c j on edge to 3 j on path i Sariel (UIUC) CS573 13 Fall 2013 13 / 58 Sariel (UIUC) CS573 14 Fall 2013 14 / 58 Hamiltonian Cycle = ⇒ Satisfying assignment (Undirected) Hamiltonian Cycle (contd) Problem ( Undirected Hamiltonian Cycle ) Thus, vertices visited immediately before and after C i are Input: Given undirected graph G = ( V , E ) . connected by an edge Goal: Does G have a Hamiltonian cycle? That is, is there a cycle We can remove c j from cycle, and get Hamiltonian cycle in that visits every vertex exactly one (except start and end vertex)? G − c j Consider Hamiltonian cycle in G − { c 1 , . . . c m } ; it traverses each path in only one direction, which determines the truth assignment Sariel (UIUC) CS573 15 Fall 2013 15 / 58 Sariel (UIUC) CS573 16 Fall 2013 16 / 58

  5. NP -Completeness Reduction Sketch Goal: Given directed graph G , need to construct undirected graph G ′ Theorem such that G has Hamiltonian Path if and only if G ′ has Hamiltonian Hamiltonian cycle problem for undirected graphs is path NP-Complete . Reduction Proof. Replace each vertex v by 3 vertices: v in , v , and v out The problem is in NP ; proof left as exercise. A directed edge ( a , b ) is replaced by edge ( a out , b in ) Hardness proved by reducing Directed Hamiltonian Cycle to this a o c i a c problem. v i v o v v b o d i b d Sariel (UIUC) CS573 17 Fall 2013 17 / 58 Sariel (UIUC) CS573 18 Fall 2013 18 / 58 Reduction: Wrapup The reduction is polynomial time (exercise) The reduction is correct (exercise) Part II NP-Completeness of Graph Coloring Sariel (UIUC) CS573 19 Fall 2013 19 / 58 Sariel (UIUC) CS573 20 Fall 2013 20 / 58

  6. Graph Coloring Graph 3-Coloring Graph Coloring 3 Coloring Instance : G = ( V , E ) : Undirected graph, integer k . Instance : G = ( V , E ) : Undirected graph. Question: Can the vertices of the graph be colored using k Question: Can the vertices of the graph be colored using 3 colors so that vertices connected by an edge do not get the colors so that vertices connected by an edge do not get the same color? same color? Sariel (UIUC) CS573 21 Fall 2013 21 / 58 Sariel (UIUC) CS573 22 Fall 2013 22 / 58 Graph Coloring Graph Coloring and Register Allocation Observation: If G is colored with k colors then each color class Register Allocation (nodes of same color) form an independent set in G . Thus, Assign variables to (at most) k registers such that variables needed G can be partitioned into k independent sets ⇐ ⇒ G is k -colorable. at the same time are not assigned to the same register Interference Graph Graph 2 -Coloring can be decided in polynomial time. Vertices are variables, and there is an edge between two vertices, if the two variables are “live” at the same time. G is 2 -colorable ⇐ ⇒ G is bipartite! There is a linear time Observations algorithm to check if G is bipartite using BFS (we saw this earlier). [Chaitin] Register allocation problem is equivalent to coloring the interference graph with k colors Moreover, 3-COLOR ≤ P k-Register Allocation , for any k ≥ 3 Sariel (UIUC) CS573 23 Fall 2013 23 / 58 Sariel (UIUC) CS573 24 Fall 2013 24 / 58

  7. Class Room Scheduling Frequency Assignments in Cellular Networks Given n classes and their meeting times, are k rooms sufficient? Cellular telephone systems that use Frequency Division Multiple Access (FDMA) (example: GSM in Europe and Asia and AT&T in USA) Reduce to Graph k -Coloring problem Breakup a frequency range [ a , b ] into disjoint bands of frequencies [ a 0 , b 0 ] , [ a 1 , b 1 ] , . . . , [ a k , b k ] Create graph G Each cell phone tower (simplifying) gets one band a node v i for each class i Constraint: nearby towers cannot be assigned same band, an edge between v i and v j if classes i and j conflict otherwise signals will interference Problem: given k bands and some region with n towers, is there a Exercise: G is k -colorable ⇐ ⇒ k rooms are sufficient way to assign the bands to avoid interference? Can reduce to k -coloring by creating interference/conflict graph on towers. Sariel (UIUC) CS573 25 Fall 2013 25 / 58 Sariel (UIUC) CS573 26 Fall 2013 26 / 58 3-Coloring is NP-Complete Reduction Idea 3-Coloring is in NP . Start with 3SAT formula (i.e., 3 CNF formula) ϕ with n variables ◮ Certificate: for each node a color from { 1 , 2 , 3 } . x 1 , . . . , x n and m clauses C 1 , . . . , C m . Create graph G ϕ such that ◮ Certifier: Check if for each edge ( u , v ) , the color of u is G ϕ is 3-colorable ⇐ ⇒ ϕ is satisfiable different from that of v . Need to establish truth assignment for x 1 , . . . , x n via colors for 1 Hardness: We will show 3-SAT ≤ P 3-Coloring . some nodes in G ϕ . Create triangle with nodes true , false , base . 2 For each variable x i two nodes v i and ¯ v i connected in a triangle 3 with the special node base . If graph is 3-colored, either v i or ¯ v i gets the same color as true . 4 Interpret this as a truth assignment to v i . Need to add constraints to ensure clauses are satisfied (next 5 phase). Sariel (UIUC) CS573 27 Fall 2013 27 / 58 Sariel (UIUC) CS573 28 Fall 2013 28 / 58

Recommend


More recommend