Complexity Classes and Polynomial-time Reductions

Similar documents
NP-complete Reductions

NP-Complete Reductions 2

8 NP-complete problem Hard problems: demo

9.1 Cook-Levin Theorem

P and NP (Millenium problem)

CSCE750 Analysis of Algorithms Fall 2017 NP-Complete Problems

NP-Completeness of 3SAT, 1-IN-3SAT and MAX 2SAT

Computability Theory

Best known solution time is Ω(V!) Check every permutation of vertices to see if there is a graph edge between adjacent vertices

Lecture 7: Counting classes

Unit 8: Coping with NP-Completeness. Complexity classes Reducibility and NP-completeness proofs Coping with NP-complete problems. Y.-W.

Lecture 1. 2 Motivation: Fast. Reliable. Cheap. Choose two.

P -vs- NP. NP Problems. P = polynomial time. NP = non-deterministic polynomial time

NP-Completeness. Algorithms

8.1 Polynomial-Time Reductions

Reductions and Satisfiability

W4231: Analysis of Algorithms

Example of a Demonstration that a Problem is NP-Complete by reduction from CNF-SAT

NP and computational intractability. Kleinberg and Tardos, chapter 8

8.1 Polynomial-Time Reductions

NP Completeness. Andreas Klappenecker [partially based on slides by Jennifer Welch]

NP-Hardness. We start by defining types of problem, and then move on to defining the polynomial-time reductions.

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

CMPSCI611: The SUBSET-SUM Problem Lecture 18

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

(p 300) Theorem 7.27 SAT is in P iff P=NP

Steven Skiena. skiena

More NP-complete Problems. CS255 Chris Pollett May 3, 2006.

COMP260 Spring 2014 Notes: February 4th

A New Reduction from 3-SAT to Graph K- Colorability for Frequency Assignment Problem

Lecture 10 October 7, 2014

P and NP CISC4080, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang

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

Exercises Computational Complexity

Lecture 20: Satisfiability Steven Skiena. Department of Computer Science State University of New York Stony Brook, NY

CS 580: Algorithm Design and Analysis

3/7/2018. CS 580: Algorithm Design and Analysis. 8.1 Polynomial-Time Reductions. Chapter 8. NP and Computational Intractability

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18

Where Can We Draw The Line?

Greedy algorithms Or Do the right thing

P and NP CISC5835, Algorithms for Big Data CIS, Fordham Univ. Instructor: X. Zhang

Boolean Functions (Formulas) and Propositional Logic

Computational problems. Lecture 2: Combinatorial search and optimisation problems. Computational problems. Examples. Example

Towards the Proof of the PCP Theorem

Chapter 8. NP-complete problems

Some Hardness Proofs

Lecture 24: More Reductions (1997) Steven Skiena. skiena

P vs. NP. Simpsons: Treehouse of Horror VI

Chapter 9 Graph Algorithms

Chapter 10 Part 1: Reduction

Lecture 2. 1 Introduction. 2 The Set Cover Problem. COMPSCI 632: Approximation Algorithms August 30, 2017

4 Greedy Approximation for Set Cover

Chapter 9 Graph Algorithms

Online Appendix: A Stackelberg Game Model for Botnet Data Exfiltration

1 Variations of the Traveling Salesman Problem

1 Better Approximation of the Traveling Salesman

Reductions. Linear Time Reductions. Desiderata. Reduction. Desiderata. Classify problems according to their computational requirements.

1 Introduction. 1. Prove the problem lies in the class NP. 2. Find an NP-complete problem that reduces to it.

Approximation Algorithms: The Primal-Dual Method. My T. Thai

CS270 Combinatorial Algorithms & Data Structures Spring Lecture 19:

Hardness of Approximation for the TSP. Michael Lampis LAMSADE Université Paris Dauphine

Lecture 4: 3SAT and Latin Squares. 1 Partial Latin Squares Completable in Polynomial Time

The Satisfiability Problem [HMU06,Chp.10b] Satisfiability (SAT) Problem Cook s Theorem: An NP-Complete Problem Restricted SAT: CSAT, k-sat, 3SAT

CSE 417 Branch & Bound (pt 4) Branch & Bound

Questions? You are given the complete graph of Facebook. What questions would you ask? (What questions could we hope to answer?)

Chapter 9 Graph Algorithms

CS 125 Section #10 Midterm 2 Review 11/5/14

V1.0: Seth Gilbert, V1.1: Steven Halim August 30, Abstract. d(e), and we assume that the distance function is non-negative (i.e., d(x, y) 0).

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Homework 4 Solutions

1 The Traveling Salesperson Problem (TSP)

Introduction to Graph Theory

Lecture 2: NP-Completeness

1 Definition of Reduction

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

A Simplied NP-complete MAXSAT Problem. Abstract. It is shown that the MAX2SAT problem is NP-complete even if every variable

Principles of AI Planning. Principles of AI Planning. 7.1 How to obtain a heuristic. 7.2 Relaxed planning tasks. 7.1 How to obtain a heuristic

2SAT Andreas Klappenecker

Theorem 2.9: nearest addition algorithm

Solutions for the Exam 6 January 2014

NP versus PSPACE. Frank Vega. To cite this version: HAL Id: hal

arxiv: v2 [cs.cc] 29 Mar 2010

PCP and Hardness of Approximation

Modules. 6 Hamilton Graphs (4-8 lectures) Introduction Necessary conditions and sufficient conditions Exercises...

11.1 Facility Location

EECS 219C: Formal Methods Boolean Satisfiability Solving. Sanjit A. Seshia EECS, UC Berkeley

Approximation Algorithms

Inapproximability of the Perimeter Defense Problem

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/18/14

Vertex Cover Approximations

EECS 219C: Computer-Aided Verification Boolean Satisfiability Solving. Sanjit A. Seshia EECS, UC Berkeley

val(y, I) α (9.0.2) α (9.0.3)

SAT-CNF Is N P-complete

Notes for Lecture 24

Handout 9: Imperative Programs and State

Lecture 21: Other Reductions Steven Skiena

CS261: A Second Course in Algorithms Lecture #16: The Traveling Salesman Problem

Decision Problems. Observation: Many polynomial algorithms. Questions: Can we solve all problems in polynomial time? Answer: No, absolutely not.

Math 170- Graph Theory Notes

Lecture 21: Other Reductions Steven Skiena. Department of Computer Science State University of New York Stony Brook, NY

Transcription:

COMPSCI 330: Design and Analysis of Algorithms April 19, 2016 Complexity Classes and Polynomial-time Reductions Lecturer: Debmalya Panigrahi Scribe: Tianqi Song 1 Overview In this lecture, we introduce complexity classes and polynomial-time reductions. 1 2 Easy versus hard problems In this section, we will begin by defining a suite of hard problems we have not examined before during the semester. Interestingly, many of these problems have seemingly similar variants that are easy to solve. We will mention these variants as we go in order to highlight how a small change in a problem definition can result in a large jump in complexity. 2.1 Satisfiability The first hard problem we will examine is what is known as Satisfiability or SAT. As input, we are given a set of n boolean variables X = {x 1, x 2,..., x n } (i.e., each variable can be set to either true or false). We are then given a boolean formula over these variables of the following form (noting that this is just a specific example where X = {x 1, x 2, x 3, x 4 }): (x 1 x 2 x 3 ) (x 2 x 3 x 4 ) (x 4 x 1 x 2 ) (1) In terms of notation, and denote the conjunction and disjunction operations, respectively (which are analogous to the OR and AND operations for boolean variables in a programming language). x i denotes the negation of the boolean variable x i (analogous to!x i ). We deem sequence of conjunctions within a given set of parentheses (e.g., (x 2 x 3 x 4 )) as a clause, and we call the unnegated/negated variables within the formula literals. So more generally, as input we are given a boolean formula over the variables in X that the disjunction of m clauses, each of which is the conjunction of a sequence of boolean literals. Our goal then is to determine if there is a way of setting the variables (i.e., assigning true or false to each x i ) such that the entire formula evaluates to true. We call such an assignment a satisfying assignment. If there exists at least one assignment for a formula, we say it is satisfiable. For instance, one satisfying assignment for the above example is x 1 = true, x 2 = false, x 3 = true, and x 4 = true (and there are others, as well). A simple example of a formula that is not satisfiable is (x 1 x 2 ) (x 1 x 2 ) (x 1 x 2 ) (x 1 x 2 ). (2) Observe that no matter how we set x 1 and x 2, at least one of the clauses will not be satisfied. A more structured version of SAT is what is known as k-sat, which is defined identically but with added requirement that each clause has exactly k literals. Therefore, the formulas in (1) and 1 Some materials are from notes by Nat Kell and Allen Xiao. 16-1

(2) are instances of 3-SAT and 2-SAT, respectively. Surprisingly, we can solve 2-SAT in O(n + m), but for any k 3, there is no known polynomial time solution. In other words, the jump from k = 2 to k = 3 makes the problem much harder, and in fact we will show that 3-SAT is at least as hard as generic SAT. 2.2 Traveling Salesman, Hamiltonian Cycles, Eulerian Cycles One of the most famous hard problems is what called the Traveling Salesman problem, or TSP. Here, we are given edge-weighted graph G (we typically think of the vertices of the graph as representing cities and an edge weight of an edge (u, v) as specifying the distance between cities u and v). The goal is to find a cycle in the graph that includes every vertex with minimum total weight (this models a salesman traveling to a set of cities and returning home; ideally he wants to minimize the total distance he has to travel). Again, we will be able to argue why TSP is hard later on, but to do this, let us first define a slightly simpler problem known as Hamiltonian Cycle or HAM. Now, we are given an unweighted graph G, and the goal is to determine whether there exists a cycle in the graph that visits every vertex exactly once. Even though HAM is somewhat simpler than TSP, HAM is still a hard problem. As we mentioned a moment ago, the jump from 2-SAT to 3-SAT makes an easy problem into a hard one. A similar phenomenon occurs with an analogous problem to HAM known as Eulerian Cycle. For the Eulerian Cycle problem, we are again given a unweighted graph G, but now the objective is to determine if there exists a path in the graph that starts and ends at the same vertex, includes every edge in the graph, and does not repeat any edges. Eulerian Cycle is in fact polynomial-time solvable due to the following elegant characterization: a graph has an eulerian cycle iff the degree of each vertex is even. Therefore in order to determine if a graph is eulerian, we just need to iterate over each vertex v in V and check to see if deg v is even. 2.3 Matching A problem we have seen earlier in the semester is that of maximum matching. This matching problem turns about to be solvable in polynomial time. However, we can make the problem hard by making it a 3D-matching problem. That is, the problem is now defined for a graph where edges are now a subset of V V V. Making the jump from 2D-matching to 3D-matching makes the problem hard. 3 Computational Complexity Definition 1. A decision problem is one with a yes-no answer depending on the value of its input. Here we will restrict ourselves to decision problems and many of the optimization problems we have seen before can be formulated as decision problems with some polynomial overhead. Definition 2. A decision problem is in the complexity class P (polynomial time) if there exists a polynomial time algorithm deciding (answering) it. It turns out that many interesting problems have not (yet) been proved to be in P. Most of these, however, are in a different class called NP. 16-2

Definition 3. A decision problem is in the complexity class NP (nondeterministic polynomial time) if it has a polynomial time verifier. A verifier for a decision problem takes a (decision problem) input S, an answer (yes or no), some additional information C commonly called a certificate or proof or witness. When the true answer is yes, there must exist some certificate for which the verifier can prove the answer is yes. If given the wrong certificate, the verifier is allowed to answer no incorrectly. When the true answer is no, there must be no certificate for which the verifier proves (incorrectly) the answer is yes. Intuitively, problems in NP are ones whose solutions are naturally easy to check. Example 1. Consider the boolean satisfiability (SAT) problem. The input to SAT is a boolean formula of conjunctions (AND) between disjunctive (OR) clauses. (x 1 x 2 x 3 ) ( x 2 x 3 ) The decision problem for SAT is whether a given formula has a satifying assignment. A polynomial time verifier for this problem takes as a certificate a satisfying assignment, and checks satisfiability clause by clause. On the other hand, if the formula is unsatisfiable, no assignment will pass this verification scheme. We conclude that SAT has a polynomial time verifier, and is therefore a problem in NP. Definition 4. A decision problem is said to be in co NP if its complement is in NP. In the verifier, there must instead exist certificates for all no instances, and no certificates can exist for yes instances. To distinguish: NP: (S, yes, C) is verfiable. co NP: (S, no, C) is verfiable. Lemma 1. P NP and P co NP Proof. If a problem is in P, we can use the polynomial time algorithm solving it as the verifier. No certificate is requried, and the process takes polynomial time for both yes and no instances, so the problem is in both NP and co NP. Some of the central open questions in complexity theory (and computer science as a whole) ask whether there are problems in the gaps between P, NP, and co NP. 1. Does P = NP? 2. Does NP = co NP? The common belief is that these questions all answer negatively. 16-3

NP co NP P Figure 1: A diagram of the relationships in Lemma 1. 3.1 Reductions Our main tool for arguing about the hardness is reduction. Definition 5. Problem A is polynomial time reducible to problem B if there exists a polynomial time algorithm f which transforms an instance x of A into an instance y = f(x) of B, such that their answers agree. We write this as A B. Polynomial time reductions are transitive. x f y = f(x) Since the we know that the answers agree on x and y, running an algorithm which solves B will let us solve instances of A (in the same time, plus a polynomial factor). Intuitively, A is is no harder than B, since by spending additive polynomial time, solving B will solve A. Definition 6. A problem is NP-hard if every problem in NP is polynomial time reducible to it. Additionally, if an NP-hard problem is a member of NP, we say that it is NP-complete. Theorem 2 (Cook-Levin). The boolean satisfiability problem ( SAT) is NP-complete. Example 2. 3SAT is a variation of SAT, where each clause is restricted to at most 3 literals. Again, we will use the convention of n variables and m clauses. Let each l i be either a variable or its negation. (l 1 l 2 l 3 ) (l 5 l 6 l 7 ) (l 3m 2 l 3m 1 l 3m ) In this example, we will show that 3SAT SAT, and this gives NP-completeness of 3SAT because 3SAT is in NP. Our reduction works by reducing the size of long clauses of SAT until we have only clauses of size at most 3. The main idea is to add dummy variables to strip 1 or 2 variables from a large clause. Consider a clause of size 4: (l 1 l 2 l 3 l 4 ) Let d 1 be a dummy variable. Observe that the following formula is equivalent: (l 1 l 2 d 1 ) ( d 1 l 3 l 4 ) 16-4

Figure 2: Graph of (x 1 x 2 x 3 ) (x 1 x 2 x 3 ) (x 1 x 2 x 1 ). Intuitively, the value of d 1 chooses between halves of the original formula for the l i which must be true. When d 1 = 0, either l 1 or l 2 must be true. When d 1 = 1, either l 3 or l 4 must be true. The two formulas are equivalent. The new formula added one new variable, and one more clause. Suppose instead the clause has k literals: Let each d i be a unique dummy variable: (l 1 l 2 l k ) (l 1 d 1 ) ( d 1 l 2 d 2 ) ( d 2 l 3 d 3 ) ( d k 1 l k ) Suppose the l 2 = 1. Then we can set d i the following way: (l 1 d 1 ) ( d 1 l 21 d 2 ) ( d 2 l 3 d 3 ) ( d k 1 l k ) 1 0 0 1 0 1 In general, notice that we only have k 1 dummy variables for k clauses. By the pigeonhole principle, at least one of the clauses is satisfied by one of the real literals l i, instead of a dummy. Applying this transformation to all clauses, we have a 3SAT instance of polynomial size in n and m. Example 3. The Independent-Set problem takes as input a tuple (G, k), and asks if the graph G = (V, E) has an independent set S V of size at least k. S is an independent set exactly when none of its elements have an edge in E. In this example, we show that Independent-Set 3SAT. Given a 3SAT instance C 1 C 2 C m, we construct the following graph. For each clause, we build a gadget (see an example in Figure 2): for each literal l i in the clause, make a new vertex v i. We add the following edges: Between every literal l i to its negation l i. Between the gadget vertices for each clause (not between clauses). Let k = m. Consider the vertices picked in S to be the literals set to true. If there is an independent set of size k, then the second condition insists that we pick one vertex from each gadget. Additionally, S cannot contain a variable and its negation, since we added edges between them. It follows that, by setting the literals in S to true, we have a satisfying assignment for all m clauses. Example 4. The Vertex-Cover problem takes as input a tuple (G, k), and asks if the graph G = (V, E) has a vertex cover S V of size at most k. S is a vertex cover when each edge is incident 16-5

to at least one vertex in S. In this example, we show that Vertex-Cover Independent-Set. Given an Independent-Set instance (G = (V, E ), k ), we construct a Vertex-Cover instance (G = (V, E), k), where G = G and k = V k. To prove that the two instances have the same answer, we show that S V is an independent set iff V \S is a vertex cover. If S is an independent set, we have for any e E, one endpoint of e is in V \ S, therefore, V \ S is a vertex cover. If V \ S is a vertex cover, we have there does not exist an edge e E such that both two endpoints of e are in S, therefore, S is an independent set. Example 5. The Set-Cover problem takes as input a universe of elements X, subsets S 1, S 2,...,S m, where S i X, and a number k. We ask if there exists a collection of subsets T, where T k, such that Sj T S j = X. In this example, we show that Set-Cover Vertex-Cover. Given a Vertex-Cover instance (G = (V, E), k v ), we construct a Set-Cover instance: X = E; for each v V, let S v = {e = (u, v) e E}; k = k v. Vertex-Cover is just a special case of Set-Cover. 16-6