NP-complete Problems

Similar documents
Theory of Computation Chapter 9

SAT, Coloring, Hamiltonian Cycle, TSP

NP-Complete Problems

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

NP and Computational Intractability

CS 301: Complexity of Algorithms (Term I 2008) Alex Tiskin Harald Räcke. Hamiltonian Cycle. 8.5 Sequencing Problems. Directed Hamiltonian Cycle

max bisection max cut becomes max bisection if we require that It has many applications, especially in VLSI layout.

8.5 Sequencing Problems

NP-Complete Problems. More reductions

NP and Computational Intractability

More NP-Complete Problems

Polynomial-Time Reductions

CS 583: Algorithms. NP Completeness Ch 34. Intractability

CS21 Decidability and Tractability

CSCI 1590 Intro to Computational Complexity

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

CSCI3390-Lecture 17: A sampler of NP-complete problems

Hamiltonian Cycle. Hamiltonian Cycle

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2)

Computational Intractability 2010/4/15. Lecture 2

CS21 Decidability and Tractability

NP-Hardness reductions

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM

CSL 356: Analysis and Design of Algorithms. Ragesh Jaiswal CSE, IIT Delhi

Lecture 24 : Even more reductions

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

Design and Analysis of Algorithms

NP-Complete Reductions 2

Classes of Problems. CS 461, Lecture 23. NP-Hard. Today s Outline. We can characterize many problems into three classes:

Lecture 18: More NP-Complete Problems

Chapter 8. NP and Computational Intractability

4/20/11. NP-complete problems. A variety of NP-complete problems. Hamiltonian Cycle. Hamiltonian Cycle. Directed Hamiltonian Cycle

NP and NP-Completeness

Algorithms, Lecture 3 on NP : Nondeterminis7c Polynomial Time

8.5 Sequencing Problems. Chapter 8. NP and Computational Intractability. Hamiltonian Cycle. Hamiltonian Cycle

NP-problems continued

Algorithms Design & Analysis. Approximation Algorithm

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Correctness of Dijkstra s algorithm

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

Complexity, P and NP

Some Algebra Problems (Algorithmic) CSE 417 Introduction to Algorithms Winter Some Problems. A Brief History of Ideas

More on NP and Reductions

Lecture 4: NP and computational intractability

CS 580: Algorithm Design and Analysis

3/22/2018. CS 580: Algorithm Design and Analysis. Circuit Satisfiability. Recap. The "First" NP-Complete Problem. Example.

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Lecture 15 - NP Completeness 1

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

4/12/2011. Chapter 8. NP and Computational Intractability. Directed Hamiltonian Cycle. Traveling Salesman Problem. Directed Hamiltonian Cycle

Theory of Computer Science. Theory of Computer Science. E5.1 Routing Problems. E5.2 Packing Problems. E5.3 Conclusion.

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Chapter 34: NP-Completeness

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 22 Lecturer: David Wagner April 24, Notes 22 for CS 170

NP-Complete Reductions 1

CSE 421 NP-Completeness

NP-completeness. Chapter 34. Sergey Bereg

Algorithm Design and Analysis

Chapter 3: Proving NP-completeness Results

CSI 4105 MIDTERM SOLUTION

1.1 P, NP, and NP-complete

NP-Completeness Part II

Discrete Optimization 2010 Lecture 10 P, N P, and N PCompleteness

NP-problems continued

Algorithms. NP -Complete Problems. Dong Kyue Kim Hanyang University

NP-Completeness Review

Formal definition of P

i times p(p(... (p( n))...) = n ki.

COMP 382. Unit 10: NP-Completeness

Some Algebra Problems (Algorithmic) CSE 417 Introduction to Algorithms Winter Some Problems. A Brief History of Ideas

CS/COE

Algorithm Design and Analysis

Lecture 10: Lovász Local Lemma. Lovász Local Lemma

Out-colourings of Digraphs

CS Fall 2011 P and NP Carola Wenk

PCPs and Inapproximability Gap-producing and Gap-Preserving Reductions. My T. Thai

Lecture 13, Fall 04/05

NP-Completeness Part II

Intro to Theory of Computation

Essential facts about NP-completeness:

Theory of Computation Time Complexity

CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT

NP-Completeness. Sections 28.5, 28.6

NP-Completeness. Subhash Suri. May 15, 2018

Show that the following problems are NP-complete

Algorithm Design and Analysis

NP Complete Problems. COMP 215 Lecture 20

ACO Comprehensive Exam October 14 and 15, 2013

Problem Set 3 Due: Wednesday, October 22nd, 2014

Introduction. Pvs.NPExample

Algorithms: COMP3121/3821/9101/9801

Lecture Notes CS:5360 Randomized Algorithms Lecture 20 and 21: Nov 6th and 8th, 2018 Scribe: Qianhang Sun

Chapter 3. Complexity of algorithms

Limits to Approximability: When Algorithms Won't Help You. Note: Contents of today s lecture won t be on the exam

There are two types of problems:

CSCI3390-Second Test with Solutions

Approximation Preserving Reductions

Lecture 7: Polynomial time hierarchy

Transcription:

NP-complete Problems HP, TSP, 3COL, 0/1IP Dimitris Diamantis µπλ November 6, 2014 Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 1 / 34

HAMILTON PATH is NP-Complete Definition Given an undirected graph G(V, E), is there a simple path containing each vertex exactly once? Claim HAMILTON PATH is in NP Certificate: A list of nodes Certifier: Check that all nodes of G are indeed contained in the list exactly once. Check that for each two consecutive nodes in the list there is indeed an edge in G connecting them. In order to prove that HAMILTON PATH is NP-Complete we will perform a reduction from 3SAT to HAMILTON PATH Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 2 / 34

3SAT to HAMILTON PATH Definition 3SAT Given a finite set of clauses in CNF form, each containing exactly three literals, is there some truth assignment for the variables which satisfies all of the clauses? In order to move from the domain of 3SAT to the domain of HAMILTON PATH, we have to respect the following: Each variable has a choice between values true and false Choice gadget There is consistency of the variables values, across all clauses. Meaning that all occurrences of x have the same value and all occurrences of x have the opposite value. Consistency gadget Finally the clauses impose the constraints that must be satisfied in each 3SAT instance. Constraint gadget Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 3 / 34

Choice gadget It is a subgraph of G. Imagine it being approached from above. A choice is made: which edge to follow. Let us assume that the left edge corresponds to true and the right edge corresponds to false It is connected to the rest of the graph via its endpoints, depicted as full dots. Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 4 / 34

Consistency gadget It is a subgraph of G, connected to the rest of the graph via its endpoints (full dots) Assume that there is a HAMILTON PATH not starting or ending in this subgraph. Then it can only be traversed in two possible ways. Think of it as only two separate edges. When one is traversed, the other one is not. Exclusive-OR edges. Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 5 / 34

Constraint gadget This gadget represents the clauses of the 3SAT instance. Each side of the triangle represents a literal Assume that if the side of a triangle is chosen, then that literal is false. At least on literal has to be true. Otherwise every edge of the triangle is traversed. Hence, there is no HAMILTON PATH. Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 6 / 34

3SAT to HAMILTON Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 7 / 34

3SAT to HAMILTON Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 7 / 34

3SAT to HAMILTON Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 8 / 34

3SAT to HAMILTON Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 9 / 34

3SAT to HAMILTON Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 10 / 34

3SAT to HAMILTON Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 11 / 34

3SAT to HAMILTON Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 12 / 34

3SAT to HAMILTON Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 13 / 34

3SAT to HAMILTON Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 14 / 34

3SAT to HAMILTON Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 15 / 34

3SAT to HAMILTON Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 16 / 34

3SAT to HAMILTON Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 17 / 34

3SAT to HAMILTON Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 18 / 34

3SAT to HAMILTON Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 19 / 34

3SAT to Hamilton Claim There is a truth assignment for instance φ of 3SAT if and only if there is a HAMILTON PATH in graph G if direction Since there is a HAMILTON PATH, we traverse the choice gadget thus giving values to the literals of φ We then proceed to the constraint gadgets. For each triangle, we cannot traverse all 3 sides, otherwise there would be no HAMILTON PATH Since not all sides of each triangle are traversed, not all literals can be false. Hence all clauses are satisfied and the value assignment from the choice gadget is actually a truth assignment Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 20 / 34

Claim There is a truth assignment for instance φ of 3SAT if and only if there is a HAMILTON PATH in graph G else if direction Since there is a truth assignment for φ, we use that to traverse the choice gadget. For the constraint gadgets (triangles) we use the remaining (if any) sides of each triangle that are able to be traversed along with the clique that connects their nodes Traversing the constraint gadgets as well gives us a HAMILTON PATH Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 21 / 34

TSP(D) is NP-COMPLETE Definition Given a list of cities, the distances between each pair of cities and a budget B, is there a route that visits each city exactly once and returns to the origin city(tour) and is of cost less or equal to B? Claim TSP(D) is in NP Certificate: A list of cities Certifier: Check that the list of cities is indeed a tour. Check that the tour s cost is less than or equal to B. In order to prove that TSP(D) is NP-Complete we will perform a reduction from HAMILTON PATH to TSP(D) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 22 / 34

HAMILTON PATH to TSP(D) Given an instance of HAMILTON PATH, we construct an instance of TSP(D) as follows: We introduce n cities, one for each node on the given graph G If there is an edge connecting nodes i and j in G, then we set the distance of the corresponding cities to 1. Otherwise, we set it to 2. We set B = n + 1 Claim Graph G has a HAMILTON PATH if and only if there is a tour of cost B or less in the TSP(D) instance Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 23 / 34

HAMILTON PATH to TSP(D) Claim Graph G has a HAMILTON PATH if and only if there is a tour of cost B or less in the TSP(D) instance Suppose graph G has no HAMILTON PATHS. Then every tour must have at least two edges of distance 2. If this were not true, we could remove one edge of distance 2 and obtain a HAMILTON PATH, which is a contradiction. The total cost of this tour is at least (n 2) 1 + 2 2 = n + 2 > B Suppose G has a HAMILTON PATH This HAMILTON PATH along with the addition of an edge from the last node to the starting node, produces a tour This tour has a cost of at most (n 1) 1 + 2 = n + 1 = B Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 24 / 34

k-coloring Definition Given a graph G(V,E), can we color its vertices using k colors such that no two adjacent nodes have the same color? For k = 2 the problem can be solved in linear time. Test if the graph is bipartite. How? Perform depth-first search (works with breadth-first search as well). Visit the nodes in a pre-order fashion. Color each child the opposite color from its parent. Return a 2-color scheme for the graph or an odd length cycle. Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 25 / 34

3-COLORING is NP-Complete Claim 3-COLORING is in NP Certificate: For each node, a color from {0, 1, 2} Certifier: Check if for each edge (u, v), the color assigned to u is different than the one assigned to v. In order to prove that 3-COLORING is NP-Complete, we will perform a reduction from NAESAT to 3-COLORING. Definition NAESAT Let φ be a 3-CNF formula. Is there a truth assignment for φ where in no clause all three literals are equal in truth value? Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 26 / 34

NAESAT to 3-COLORING We are given a set of clauses C 1,..., C m, each with three literals involving variables x 1,..., x n. We shall construct a graph G that will be an instance of the 3-COLORING problem. For each literal we construct a triangle [a, x i, x i ]. All these triangles associated with our literals, have a common node: a Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 4 ) a x 1 x1 x 2 x2 x 3 x3 x 4 x4 Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 27 / 34

NAESAT to 3-COLORING Each clause C i is also represented by a triangle [C i 1, C i 2, C i 3] in our graph. Finally, there is an edge connecting C ij with the node that represents the jth literal of C i. a x 1 x1 x 2 x2 x 3 x3 x 4 x4 Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 28 / 34

NAESAT to 3-Coloring Claim Graph G can be colored with 3 colors {0, 1, 2} if and only if the given instance of NAESAT is satisfiable else if direction. Suppose that a NAESAT truth assignment exists. We color node a with color 2. Literal Triangles: We color the 2 remaining nodes according to the truth assignment. Clause Triangles: We pick 2 literals in each clause triangle with different truth values and color them with different colors in {0, 1}. If literal is true then we assign color 1, if literal is false we assign color 0 We color the third literal with color 2. Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 29 / 34

NAESAT to 3-Coloring Claim Graph G can be colored with 3 colors {0, 1, 2} if and only if the given instance of NAESAT is satisfiable if direction Suppose that G is indeed 3 colorable. Literal Triangles: Node a takes color 2 and so in the literal triangles, x i and x i take colors 1 and 0 respectively. If x i takes color 1, we think that the variable is true, otherwise it is false Clause Triangles: If all literals in a clause are true, then the corresponding clause triangle cannot be colored, since color 1 cannot be used. Same situation if all literals are false. Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 30 / 34

NASEAT to 3-Coloring Example Let φ be (x 1 x 2 x 3 ) ( x 1 x 2 x 4 ) Truth assignment is (x 1, x 2, x 3, x 4 ) = (T, F, F, T ) a x 1 x1 x 2 x2 x 3 x3 x 4 x4 Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 31 / 34

0/1 IP is NP-Complete Definition Given a matrix A and a vector b, is there a vector x with values from {0, 1} such that Ax b? Claim 0/1 IP is in NP. Certificate: Values for x 1,..., x n Certifier: Check that each value x i {0, 1} and that each constraint is met. In order to show that 0/1 IP is NP-complete we will perform a reduction from 3SAT to 0/1 IP Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 32 / 34

3SAT to 0/1 IP Definition 3SAT Given a finite set of clauses in CNF form, each containing exactly three literals, is there some truth assignment for the variables which satisfies all of the clauses? From the given set of clauses we will construct a corresponding instance of 0/1 IP. Let φ = C 1,..., C k a set of clauses in 3SAT form, involving variables x 1,..., x n Corresponding matrix A will be a k x n matrix where 1 if x j C i c ij = 1 if x j C i 0 otherwise We set b i = 1 (the number of complemented variables in clause i) Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 33 / 34

3SAT to 0/1 IP Hence for some clause C j of the 3SAT instance, the possible corresponding inequalities are 1x j1 + 1x j2 + 1x j3 1 1x j1 + 1x j2 1x j3 0 1x j1 1x j2 1x j3 1x j1 1x j2 1x j3 1 2 If there is a truth assignment for φ then all possible inequalities for each clause are satisfied. If there is no truth assignment for φ, then assuming C j is not satisfied, no possible inequality can be satisfied. If the inequality is satisfied then so is the corresponding clause in φ If the inequality is not satisfied then neither is the clause in φ Dimitris Diamantis (µπλ ) NP-complete Problems November 6, 2014 34 / 34