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

Similar documents
Steven Skiena. skiena

Lecture 21: Other Reductions Steven Skiena

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

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

W4231: Analysis of Algorithms

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

NP-Complete Reductions 2

NP-complete 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.

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

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

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

P and NP (Millenium problem)

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

1 Definition of Reduction

15-451/651: Design & Analysis of Algorithms November 4, 2015 Lecture #18 last changed: November 22, 2015

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

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

Chapter 10 Part 1: Reduction

Notes for Lecture 24

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

8.1 Polynomial-Time Reductions

8 NP-complete problem Hard problems: demo

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

Lecture 2: NP-Completeness

CMPSCI611: The SUBSET-SUM Problem Lecture 18

Module 6 NP-Complete Problems and Heuristics

Complexity Classes and Polynomial-time Reductions

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

Module 6 P, NP, NP-Complete Problems and Approximation Algorithms

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

1. Suppose you are given a magic black box that somehow answers the following decision problem in polynomial time:

Introduction to Algorithms

P Is Not Equal to NP. ScholarlyCommons. University of Pennsylvania. Jon Freeman University of Pennsylvania. October 1989

NP-Completeness. Algorithms

Questions... How does one show the first problem is NP-complete? What goes on in a reduction? How hard are NP-complete problems?

Some Hardness Proofs

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

Greedy algorithms Or Do the right thing

Partha Sarathi Mandal

NP and computational intractability. Kleinberg and Tardos, chapter 8

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

COMP 355 Advanced Algorithms Approximation Algorithms: VC and TSP Chapter 11 (KT) Section (CLRS)

Lecture 10 October 7, 2014

Computability Theory

Chapter 8. NP-complete problems

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

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

CPSC 320 Notes: What's in a Reduction?

arxiv: v2 [cs.cc] 29 Mar 2010

Recitation 4: Elimination algorithm, reconstituted graph, triangulation

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

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

Vertex Cover Approximations

Module 6 NP-Complete Problems and Heuristics

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

Module 6 NP-Complete Problems and Heuristics

Introduction to Algorithms. Lecture 24. Prof. Patrick Jaillet

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

Homework 4 Solutions

Approximation Algorithms

Approximation Algorithms

Where Can We Draw The Line?

Exact Algorithms Lecture 7: FPT Hardness and the ETH

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

NP-Complete Problems

CMSC 451: Lecture 22 Approximation Algorithms: Vertex Cover and TSP Tuesday, Dec 5, 2017

More NP-Complete Problems [HMU06,Chp.10b] Node Cover Independent Set Knapsack Real Games

Reductions and Satisfiability

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

9.1 Cook-Levin Theorem

Horn Formulae. CS124 Course Notes 8 Spring 2018

The NP-Completeness of Some Edge-Partition Problems

Chapter 8. NP-complete problems. Search problems. cient algorithms. Exponential search space

1 Algorithm and Proof for Minimum Vertex Coloring

Chapter 8. NP-complete problems

P vs. NP. Simpsons: Treehouse of Horror VI

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Algorithms For Inference Fall 2014

Assignment 5: Solutions

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

CS154, Lecture 18: PCPs, Hardness of Approximation, Approximation-Preserving Reductions, Interactive Proofs, Zero-Knowledge, Cold Fusion, Peace in

Complexity of Disjoint Π-Vertex Deletion for Disconnected Forbidden Subgraphs

Lecture 8: The Traveling Salesman Problem

4.1 Review - the DPLL procedure

1. The following graph is not Eulerian. Make it into an Eulerian graph by adding as few edges as possible.

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

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

Parameterized Reductions

Towards the Proof of the PCP Theorem

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).

1 Variations of the Traveling Salesman Problem

8.1 Polynomial-Time Reductions

Lecture 7: Counting classes

CS270 Combinatorial Algorithms & Data Structures Spring Lecture 19:

W[1]-hardness. Dániel Marx 1. Hungarian Academy of Sciences (MTA SZTAKI) Budapest, Hungary

Inapproximability of the Perimeter Defense Problem

On Approximating Minimum Vertex Cover for Graphs with Perfect Matching

Notes for Recitation 9

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

Transcription:

Lecture 20: Satisfiability Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.sunysb.edu/ skiena

Problem of the Day Suppose we are given a subroutine which can solve the traveling salesman decision problem in, say, linear time. Give an efficient algorithm to find the actual TSP tour by making a polynomial number of calls to this subroutine.

The Main Idea Suppose I gave you the following algorithm to solve the bandersnatch problem: Bandersnatch(G) Convert G to an instance of the Bo-billy problem Y. Call the subroutine Bo-billy on Y to solve this instance. Return the answer of Bo-billy(Y ) as the answer to G. Such a translation from instances of one type of problem to instances of another type such that answers are preserved is called a reduction.

What Does this Imply? Now suppose my reduction translates G to Y in O(P (n)): 1. If my Bo-billy subroutine ran in O(P (n)) I can solve the Bandersnatch problem in O(P (n) + P (n )) 2. If I know that Ω(P (n)) is a lower-bound to compute Bandersnatch, then Ω(P (n) P (n )) must be a lowerbound to compute Bo-billy. The second argument is the idea we use to prove problems hard!

Satisfiability Consider the following logic problem: Instance: A set V of variables and a set of clauses C over V. Question: Does there exist a satisfying truth assignment for C? Example 1: V = v 1, v 2 and C = {{v 1, v 2 }, {v 1, v 2 }} A clause is satisfied when at least one literal in it is TRUE. C is satisfied when v 1 = v 2 =TRUE.

Not Satisfiable Example 2: V = v 1, v 2, C = {{v 1, v 2 }, {v 1, v 2 }, {v 1 }} Although you try, and you try, and you try and you try, you can get no satisfaction. There is no satisfying assigment since v 1 must be FALSE (third clause), so v 2 must be FALSE (second clause), but then the first clause is unsatisfiable!

Satisfiability is Hard Satisfiability is known/assumed to be a hard problem. Every top-notch algorithm expert in the world has tried and failed to come up with a fast algorithm to test whether a given set of clauses is satisfiable. Further, many strange and impossible-to-believe things have been shown to be true if someone in fact did find a fast satisfiability algorithm.

3-Satisfiability Instance: A collection of clause C where each clause contains exactly 3 literals, boolean variable v. Question: Is there a truth assignment to v so that each clause is satisfied? Note that this is a more restricted problem than SAT. If 3-SAT is NP-complete, it implies SAT is NP-complete but not visaversa, perhaps long clauses are what makes SAT difficult?! After all, 1-Sat is trivial!

3-SAT is NP-Complete To prove it is complete, we give a reduction from Sat 3 Sat. We will transform each clause independantly based on its length. Suppose the clause C i contains k literals. If k = 1, meaning C i = {z 1 }, create two new variables v 1, v 2 and four new 3-literal clauses: {v 1, v 2, z 1 }, {v 1, v 2, z 1 }, {v 1, v 2, z 1 }, {v 1, v 2, z 1 }. Note that the only way all four of these can be satisfied is if z is TRUE.

If k = 2, meaning {z 1, z 2 }, create one new variable v 1 and two new clauses: {v 1, z 1, z 2 }, {v 1, z 1, z 2 } If k = 3, meaning {z 1, z 2, z 3 }, copy into the 3-SAT instance as it is. If k > 3, meaning {z 1, z 2,..., z n }, create n 3 new variables and n 2 new clauses in a chain: {v i, z i, v i },...

Why does the Chain Work? If none of the original variables in a clause are TRUE, there is no way to satisfy all of them using the additional variable: (F, F, T ), (F, F, T ),..., (F, F, F ) But if any literal is TRUE, we have n 3 free variables and n 3 remaining 3-clauses, so we can satisfy each of them. (F, F, T ), (F, F, T ),..., (F, T, F),..., (T, F, F ), (T, F, F ) Any SAT solution will also satisfy the 3-SAT instance and any 3-SAT solution sets variables giving a SAT solution, so the problems are equivallent.

4-Sat and 2-Sat A slight modification to this construction would prove 4-SAT, or 5-SAT,... also NP-complete. However, it breaks down when we try to use it for 2-SAT, since there is no way to stuff anything into the chain of clauses. Now that we have shown 3-SAT is NP-complete, we may use it for further reductions. Since the set of 3-SAT instances is smaller and more regular than the SAT instances, it will be easier to use 3-SAT for future reductions. Remember the direction to reduction! Sat 3 Sat X

A Perpetual Point of Confusion Note carefully the direction of the reduction. We must transform every instance of a known NP-complete problem to an instance of the problem we are interested in. If we do the reduction the other way, all we get is a slow way to solve x, by using a subroutine which probably will take exponential time. This always is confusing at first - it seems bass-ackwards. Make sure you understand the direction of reduction now - and think back to this when you get confused.

Vertex Cover Instance: A graph G = (V, E), and integer k V Question: Is there a subset of at most k vertices such that every e E has at least one vertex in the subset? Here, four of the eight vertices suffice to cover. It is trivial to find a vertex cover of a graph just take all the vertices. The tricky part is to cover with as small a set as possible.

Vertex cover is NP-complete To prove completeness, we show reduce 3-SAT to VC. From a 3-SAT instance with n variables and C clauses, we construct a graph with 2N + 3C vertices. For each variable, we create two vertices connected by an edge:... v1 v1 v2 v2 v3 v3 vn vn To cover each of these edges, at least n vertices must be in the cover, one for each pair.

Clause Gadgets For each clause, we create three new vertices, one for each literal in each clause. Connect these in a triangle. At least two vertices per triangle must be in the cover to take care of edges in the triangle, for a total of at least 2C vertices. Finally, we will connect each literal in the flat structure to the corresponding vertices in the triangles which share the same literal. v1 v1 v2 v2 v3 v3 v4 v4 v3 v2 v1 v4 v1 v4

Claim: G has a vertex cover of size N + 2C iff S is Satisfiable Any cover of G must have at least N + 2C vertices. To show that our reduction is correct, we must show that: 1. Every satisfying truth assignment gives a cover. Select the N vertices cooresponding to the TRUE literals to be in the cover. Since it is a satisfying truth assignment, at least one of the three cross edges associated with each clause must already be covered - pick the other two vertices to complete the cover.

2. Every vertex cover gives a satisfying truth assignment. Every vertex cover must contain n first stage vertices and 2C second stage vertices. Let the first stage vertices define the truth assignment. To give the cover, at least one cross-edge must be covered, so the truth assignment satisfies.

Example Reduction Every SAT defines a cover and Every Cover Truth values for the SAT! Example: V 1 = V 2 = T rue, V 3 = V 4 = F alse. v1 v1 v2 v2 v3 v3 v4 v4 v3 v2 v1 v4 v1 v4

Starting from the Right Problem As you can see, the reductions can be very clever and very complicated. While theoretically any N P -complete problem can be reduced to any other one, choosing the correct one makes finding a reduction much easier. 3 Sat V C As you can see, the reductions can be very clever and complicated. While theoretically any NP-complete problem will do, choosing the correct one can make it much easier.

Maximum Clique Instance: A graph G = (V, E) and integer j v. Question: Does the graph contain a clique of j vertices, ie. is there a subset of v of size j such that every pair of vertices in the subset defines an edge of G? Example: this graph contains a clique of size 5.

Clique is NP-complete When talking about graph problems, it is most natural to work from a graph problem - the only NP-complete one we have is vertex cover! If you take a graph and find its vertex cover, the remaining vertices form an independent set, meaning there are no edges between any two vertices in the independent set, for if there were such an edge the rest of the vertices could not be a vertex cover.

vertex in cover vertex in independant set Clearly the smallest vertex cover gives the biggest independent set, and so the problems are equivallent Delete the subset of vertices in one from the total set of vertices to get the order! Thus finding the maximum independent set must be NPcomplete!

From Independent Set In an independent set, there are no edges between two vertices. In a clique, there are always between two vertices. Thus if we complement a graph (have an edge iff there was no edge in the original graph), a clique becomes an independent set and an independent set becomes a Clique! Max Clique = 5 Max Clique = 2 Max IS = 2 Max IS = 5

Punch Line Thus finding the largest clique is NP-complete: If V C is a vertex cover in G, then V V C is a clique in G. If C is a clique in G, V C is a vertex cover in G.