Reductions and Satisfiability

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

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

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

implementing the breadth-first search algorithm implementing the depth-first search algorithm

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

NP and computational intractability. Kleinberg and Tardos, chapter 8

Computability Theory

The NP-Completeness of Some Edge-Partition Problems

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

Chapter 10 Part 1: Reduction

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

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

8.1 Polynomial-Time Reductions

Complexity Classes and Polynomial-time Reductions

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

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

NP-Completeness. Algorithms

9.1 Cook-Levin Theorem

8 NP-complete problem Hard problems: demo

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

Some Hardness Proofs

NP-Complete Reductions 2

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

managing an evolving set of connected components implementing a Union-Find data structure implementing Kruskal s algorithm

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

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

CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD

P and NP (Millenium problem)

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

CSCE750 Analysis of Algorithms Fall 2017 NP-Complete Problems

On Approximating Minimum Vertex Cover for Graphs with Perfect Matching

Exercises Computational Complexity

The Complexity of Camping

Complexity Results on Graphs with Few Cliques

W4231: Analysis of Algorithms

arxiv: v2 [cs.cc] 29 Mar 2010

CSE 20 DISCRETE MATH. Fall

1 Matching in Non-Bipartite Graphs

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Greedy algorithms Or Do the right thing

CSE 20 DISCRETE MATH. Winter

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

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

Localization in Graphs. Richardson, TX Azriel Rosenfeld. Center for Automation Research. College Park, MD

CS 512, Spring 2017: Take-Home End-of-Term Examination

1 Definition of Reduction

NP-completeness of 4-incidence colorability of semi-cubic graphs

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

The Complexity of Minimizing Certain Cost Metrics for k-source Spanning Trees

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

Discrete Mathematics Lecture 4. Harper Langston New York University

On Covering a Graph Optimally with Induced Subgraphs

Lecture 2: NP-Completeness

On Detecting Global Predicates in Distributed Computations

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

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

CPSC 536N: Randomized Algorithms Term 2. Lecture 10

Stanford University CS261: Optimization Handout 1 Luca Trevisan January 4, 2011

NP-complete Reductions

Least Squares; Sequence Alignment

Reductions. designing algorithms establishing lower bounds establishing intractability classifying problems. Bird s-eye view

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

Exact Algorithms Lecture 7: FPT Hardness and the ETH

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

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

memoization or iteration over subproblems the direct iterative algorithm a basic outline of dynamic programming

CS599: Convex and Combinatorial Optimization Fall 2013 Lecture 14: Combinatorial Problems as Linear Programs I. Instructor: Shaddin Dughmi

Vertex Cover is Fixed-Parameter Tractable

Copyright 2000, Kevin Wayne 1

Homework 4 Solutions

ABSTRACT Finding a cut or nding a matching in a graph are so simple problems that hardly are considered problems at all. Finding a cut whose split edg

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

SAT Solver. CS 680 Formal Methods Jeremy Johnson

A Random Walk through CS70

arxiv: v1 [cs.ds] 19 Feb 2014

PCP and Hardness of Approximation

of m clauses, each containing the disjunction of boolean variables from a nite set V = fv 1 ; : : : ; vng of size n [8]. Each variable occurrence with

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

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

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

CS 151 Complexity Theory Spring Final Solutions. L i NL i NC 2i P.

Partha Sarathi Mandal

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

Implementation of a Sudoku Solver Using Reduction to SAT

2 The Fractional Chromatic Gap

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

arxiv: v1 [cs.cc] 2 Sep 2017

Introduction to Parameterized Complexity

CPSC 320 Notes: What's in a Reduction?

9 About Intersection Graphs

Lecture 4: September 11, 2003

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

10. EXTENDING TRACTABILITY

The Complexity of the Network Design Problem

31.6 Powers of an element

Lecture 14: Lower Bounds for Tree Resolution

arxiv: v3 [cs.ds] 26 Sep 2013

2SAT Andreas Klappenecker

Transcription:

Reductions and Satisfiability 1 Polynomial-Time Reductions reformulating problems reformulating a problem in polynomial time independent set and vertex cover reducing vertex cover to set cover 2 The Satisfiability Problem satisfying truth assignments SAT and 3-SAT reducing 3-SAT to independent set transitivity of reductions CS 401/MCS 401 Lecture 18 Computer Algorithms I Jan Verschelde, 30 July 2018 Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 1 / 45

Reductions and Satifiability 1 Polynomial-Time Reductions reformulating problems reformulating a problem in polynomial time independent set and vertex cover reducing vertex cover to set cover 2 The Satisfiability Problem satisfying truth assignments SAT and 3-SAT reducing 3-SAT to independent set transitivity of reductions Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 2 / 45

reformulating problems The Ford-Fulkerson algorithm computes maximum flow. By reduction to a flow problem, we could solve the following problems: bipartite matching, circulation with demands, survey design, and airline scheduling. Because the Ford-Fulkerson is an efficient algorithm, all those problems can be solved efficiently as well. Our plan for the remainder of the course is to explore computationally hard problems. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 3 / 45

imagine a meeting with your boss... From Computers and intractability. A Guide to the Theory of NP-Completeness by Michael R. Garey and David S. Johnson, Bell Laboratories, 1979. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 4 / 45

what you want to say is From Computers and intractability. A Guide to the Theory of NP-Completeness by Michael R. Garey and David S. Johnson, Bell Laboratories, 1979. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 5 / 45

you better have some backup From Computers and intractability. A Guide to the Theory of NP-Completeness by Michael R. Garey and David S. Johnson, Bell Laboratories, 1979. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 6 / 45

Reductions and Satifiability 1 Polynomial-Time Reductions reformulating problems reformulating a problem in polynomial time independent set and vertex cover reducing vertex cover to set cover 2 The Satisfiability Problem satisfying truth assignments SAT and 3-SAT reducing 3-SAT to independent set transitivity of reductions Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 7 / 45

reformulating a problem in polynomial time If we encounter a difficult problem X, we would like to be able to formally express that problem X is at least as hard as problem Y. If we have a black box capable of solving X, then we can also solve Y. Definition Problem Y is polynomial-time reducible to X, denoted by Y P X, if arbitrary instances of problem Y can be solved using a polynomial number of standard computational steps, and a polynomial number of calls to a black box that solves X. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 8 / 45

an application of reducibility Proposition Assume Y P X. If X can be solved in polynomial time, then Y can be solved in polynomial time. Proof. If Y P X, then we can solve Y using 1 a polynomial number of standard computational steps, and 2 a polynomial number of calls to a black box that solves X. If X can be solved in polynomial time, then the black box that solves X runs in polynomial time. A polynomial number of calls to a black box that runs in polynomial time is bounded by polynomial time because f (g(x)) is a polynomial for any two polynomials f and g. Adding the polynomial that bounds the cost for calling the black box solver to the polynomial number of standard computational steps is again a polynomial. Thus Y can be solved in polynomial time. Q.E.D. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 9 / 45

intractability Definition A problem is computationally tractable if we have an efficient algorithm to solve it. A problem that is not computationally tractable is intractable. Proposition Assume Y P X. If X cannot be solved in polynomial time, then Y cannot be solved in polynomial time. The statement in the proposition is true because it is contrapositive to the statement in the previous preposition. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 10 / 45

Reductions and Satifiability 1 Polynomial-Time Reductions reformulating problems reformulating a problem in polynomial time independent set and vertex cover reducing vertex cover to set cover 2 The Satisfiability Problem satisfying truth assignments SAT and 3-SAT reducing 3-SAT to independent set transitivity of reductions Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 11 / 45

the independent set problem Definition Given a graph G = (V, E), a subset S V is an independent set if for all u, v S: (u, v) E. Given a graph G and some number k, does G contain an independent set of size at least k? 1 2 1 2 3 4 5 3 4 5 6 7 6 7 Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 12 / 45

optimization and decision questions The decision question for the Independent Set Problem: Given a graph G and some number k, does G contain an independent set of size at least k? The optimization question for the Independent Set Problem: Given a graph G, find the largest independent set in G. From the polynomial-time solvability, both problems are equivalent: A method to solve the optimization question also solves the decision question for any value of k. A method to solve the decision question can be combined with binary search with O(log(n)), n = #V, different values of k. Decision questions are more convenient to work with. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 13 / 45

the vertex cover problem Definition Given a graph G = (V, E), a subset S V is a vertex cover if for all (u, v) E: u S or v S. Given a graph G and some number k, does G contain a vertex cover of size at most k? 1 2 1 2 3 4 5 3 4 5 6 7 6 7 Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 14 / 45

independent set is equivalent to vertex cover A subset S V is a vertex cover if for all (u, v) E: u S or v S. A subset S V is an independent set if for all u, v S: (u, v) E. Theorem Let G = (V, E) be a graph. Then S is an independent set if and only if its complement V \ S is a vertex cover. Proof. If and only if means and. : Let S be an independent set. Consider any edge (u, v). Because an independent set contains vertices which are not connected by an edge, u and v cannot be both in S. Therefore, u or v must be in V \ S. So the edge (u, v) has at least one vertex in V \ S. Thus V \ S is a vertex cover. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 15 / 45

vertex cover is equivalent to independent set A subset S V is a vertex cover if for all (u, v) E: u S or v S. A subset S V is an independent set if for all u, v S: (u, v) E. Theorem Let G = (V, E) be a graph. Then S is an independent set if and only if its complement V \ S is a vertex cover. Proof. If and only if means and. : Let V \ S be a vertex cover. Consider any u, v S, and note that u and v are not part of the vertex cover. If (u, v) E, then V \ S would not be a vertex cover as (u, v) is an edge with u and v not in the vertex cover. So (u, v) E, for any pair u, v S. Thus S is an independent set. Q.E.D. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 16 / 45

independent set reduces to vertex cover Corollary Independent Set P Vertex Cover This means that arbitrary instances of the independent set problem can be solved using a polynomial number of standard computational steps and a polynomial number of calls to the black box solver that solves the vertex cover problem. Proof. If we have a black box solver for the vertex cover problem, then whether the graph has an independent set of size at least k can be decided by asking the black box whether the graph has a vertex cover of size at most n k, where n equals the number of vertices. Q.E.D. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 17 / 45

vertex cover reduces to independent set Corollary Vertex Cover P Independent Set This means that arbitrary instances of the vertex cover problem can be solved using a polynomial number of standard computational steps and a polynomial number of calls to the black box solver that solves the independent set problem. Proof. If we have a black box solver for the independent set problem, then whether the graph has a vertex cover of size at most k can be decided by asking the black box whether the graph has an independent set of size at least n k, where n equals the number of vertices. Q.E.D. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 18 / 45

Reductions and Satifiability 1 Polynomial-Time Reductions reformulating problems reformulating a problem in polynomial time independent set and vertex cover reducing vertex cover to set cover 2 The Satisfiability Problem satisfying truth assignments SAT and 3-SAT reducing 3-SAT to independent set transitivity of reductions Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 19 / 45

the set cover problem Independent set and vertex cover can be viewed as Independent set can be viewed as a packing problem. The goal is to pack in as many vertices as possible, avoiding conflicts represented by edges. Vertex cover can be viewed as a covering problem. The goal is to cover all edges in the graph, with as few as possible vertices. Vertex cover is a special instance of the Set Cover problem: Given are U = { 1, 2,..., n }, a collection S i U, i = 1, 2,..., m, and some number k. Is there an index set I = { i 1, i 2,..., i k }: j I S j = U? Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 20 / 45

an application of the set cover problem The set U are n capabilities we want to cover with a subset of size k of m available software systems S i, each software system has capabilities S i U. capabilities all software a set cover Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 21 / 45

reducing vertex cover to set cover Theorem Vertex Cover P Set Cover Proof. An arbitrary instance of vertex cover is given by a graph G = (V, E) and a number k. We have a black box to solve set cover. Given G = (V, E), define the input for a set cover as follows: U = E, and for every vertex i: S i contains all edges incident to i. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 22 / 45

from vertex cover to set cover 1 2 3 4 5 6 7 U = {(1, 2), (1, 3), (2, 3), (2, 4), (2, 5), (3, 6), (3, 7), (4, 7), (5, 7), (6, 7)}. S 1 = {(1, 2), (1, 3)}, S 2 = {(1, 2), (2, 3), (2, 4), (2, 5)}, S 3 = {(1, 3), (2, 3), (3, 6), (3, 7)}, S 4 = {(2, 4), (4, 7)}, S 5 = {(2, 5), (5, 7)}, S 6 = {(3, 6), (6, 7)}, S 7 = {(3, 7), (4, 7), (5, 7), (6, 7)}. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 23 / 45

the corresponding set cover problem U = {(1, 2), (1, 3), (2, 3), (2, 4), (2, 5), (3, 6), (3, 7), (4, 7), (5, 7), (6, 7)}. S 1 = {(1, 2), (1, 3)}, S 2 = {(1, 2), (2, 3), (2, 4), (2, 5)}, S 3 = {(1, 3), (2, 3), (3, 6), (3, 7)}, S 4 = {(2, 4), (4, 7)}, S 5 = {(2, 5), (5, 7)}, S 6 = {(3, 6), (6, 7)}, S 7 = {(3, 7), (4, 7), (5, 7), (6, 7)}. (3,6) (6,7) (3,6) (6,7) (3,6) (6,7) (3,7) (4,7) (5,7) (3,7) (4,7) (5,7) (3,7) (4,7) (5,7) (2,3) (2,4) (2,5) (2,3) (2,4) (2,5) (2,3) (2,4) (2,5) (1,3) (1,2) (1,3) (1,2) (1,3) (1,2) Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 24 / 45

set cover solves vertex cover (3,6) (6,7) (3,7) (4,7) (5,7) (2,3) (2,4) (2,5) (1,3) (1,2) 1 2 3 4 5 6 7 Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 25 / 45

Lemma U can be covered by at most k of the sets S 1, S 2,..., S m if and only if G has a vertex cover of size at most k. Proof. If and only if means and. : If the sets S i1, S i2,..., S il, for l k cover U, then every edge in G is incident to one of the vertices i 1, i 2,..., i l. So the set { i 1, i 2,..., i l } is a vertex cover in G of size l k. : If the set { i 1, i 2,..., i l } is a vertex cover, then the sets S i1, S i2,..., S il cover U. Thus the theorem Vertex Cover P Set Cover follows from Q.E.D. 1 using (V, E) to formulate the instance of the Set Cover problem, 2 pass the input to the Set Cover problem to the black box, and 3 answer yes if and only if the black box solver answers yes. Q.E.D. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 26 / 45

the set packing problem The independent set problem generalizes to the set packing problem: Given a set U of n elements, a collection S 1, S 2,..., S m of subsets of U, and some number k, does there exists a collection of at least k of these sets so that no two of them intersect? As an application, consider U as a set of non-sharable resources, and a set of m processes S i, the i-th process requires S i U resources to run, and some number k. Can you run at least k of the processes? Exercise 1: Show that Independent Set P Set Packing. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 27 / 45

Reductions and Satifiability 1 Polynomial-Time Reductions reformulating problems reformulating a problem in polynomial time independent set and vertex cover reducing vertex cover to set cover 2 The Satisfiability Problem satisfying truth assignments SAT and 3-SAT reducing 3-SAT to independent set transitivity of reductions Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 28 / 45

Boolean expressions A Boolean variable takes values in { 0, 1 }, false, or true. Operations on Boolean variables x and y are x := not x, the negation, 1 + x mod 2 x y := x or y, the disjunction, x + y mod 2 x y := x and y, the conjunction, x y Definition Let X = { x 1, x 2,..., x n } be a set of Boolean variables. A clause C is a disjunction of distinct terms C = t 1 t 2 t l, t i = x or t i = x, for x X. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 29 / 45

assignments satisfy clauses Definition Let X = { x 1, x 2,..., x n } be a set of Boolean variables. A truth assignment for X is a function ν: ν : X { 0, 1 } x ν(x). Definition Given a clause C and an assignment ν for the variables in C, we say that ν satisfies C if the application of the rules of Boolean logic causes C to evaluate to 1. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 30 / 45

satisfiability Definition Given a collection of clauses C 1, C 2,..., C k, and an assignment ν for the variables in the clauses, we say that ν is a satisfying assignment with respect to C 1, C 2,..., C k if the application of the rule of Boolean logic causes all C i to evaluate to 1, or equivalently, if C 1 C 2 C k evaluates to 1. Then we say that C 1 C 2 C k is satisfiable. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 31 / 45

an example Consider for example (x 1 x 2 ), (x 1 x 3 ), (x 2 x 3 ). The assignment ν: ν(x 1 ) = 1, ν(x 2 ) = 1, ν(x 3 ) = 1 results in (1 0) (0 0) (1 0) = 0 and is therefore not a satisfying assignment. The assignment ν: ν(x 1 ) = 0, ν(x 2 ) = 0, ν(x 3 ) = 0 results in (0 1) (1 1) (0 1) = 1 and is therefore a satisfying assignment. The set of clauses (x 1 x 2 ), (x 1 x 3 ), (x 2 x 3 ) is satifiable. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 32 / 45

Reductions and Satifiability 1 Polynomial-Time Reductions reformulating problems reformulating a problem in polynomial time independent set and vertex cover reducing vertex cover to set cover 2 The Satisfiability Problem satisfying truth assignments SAT and 3-SAT reducing 3-SAT to independent set transitivity of reductions Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 33 / 45

the satisfiability and 3-satisfiability problems The satisfiability problem, or SAT for short is Given X = { x 1, x 2,..., x n } a set of Boolean variables, and C 1, C 2,..., C k, a set of clauses over X, does there exist a satistying truth assignment? A special case which is equally difficult is the case where each clause has exactly three terms. The 3-satisfiability problem, or 3-SAT for short is Given X = { x 1, x 2,..., x n } a set of Boolean variables, and C 1, C 2,..., C k, a set of clauses over X, where each clause C i has exactly three terms, does there exist a satistying truth assignment? The combinatorial problem is that we have to make n independent decisions about the value (zero or one) of the n Boolean variables in order to satisfy a set of constraints simultaneously. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 34 / 45

Reductions and Satifiability 1 Polynomial-Time Reductions reformulating problems reformulating a problem in polynomial time independent set and vertex cover reducing vertex cover to set cover 2 The Satisfiability Problem satisfying truth assignments SAT and 3-SAT reducing 3-SAT to independent set transitivity of reductions Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 35 / 45

reducing 3-SAT to independent set Theorem 3-SAT P Independent Set Proof. We have a black box for independent set and an instance of 3-SAT consisting of k clauses C 1, C 2,..., C k over X = { x 1, x 2,..., x n }. We will formulate the input to 3-SAT as an independent set problem. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 36 / 45

satisfying clauses and independent sets Consider for example (x y z) (x y z) (x y z) and the corresponding graph: x x x y z y z y z Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 37 / 45

independent set solves satisfiability x x x y z y z y z Take x = 1, y = 1, z = 1, and is satisfied. (x y z) (x y z) (x y z) Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 38 / 45

defining the corresponding graph G Consider the Boolean variables as vertices (v 1,1 v 1,2 v 1,3 ) (v 2,1 v 2,2 v 2,3 ) (v k,1 v k,2 v k,3 ). Every clause v i,1 v i,2 v i,3 corresponds to a triangle with vertices v i,1, v i,2, v i,3 and edges (v i,1, v i,2 ), (v i,1, v i,3 ), (v i,2, v i,3 ). For a clause to be true, it suffices that one term is true. For every pair of clauses (i, j), we add the edge (u, v) if u = v or u = v, for u { v i,1, v i,2, v i,3 } and v { v j,1, v j,2, v j,3 }. The graph G corresponding to k clauses has 3k vertices and edges defined by the above rules. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 39 / 45

satisfiability implies an independent set Lemma The 3-SAT problem with k clauses is satifiable if and only if the corresponding graph G has an independent set of size at least k. Proof. If and only if means and. : If 3-SAT is satisfiable, then every triangle contains at least one node with value equal to one. Let S collect the nodes of every triangle with value equal to one. We claim that S is an independent set. If for any u, v S, there would be an edge (u, v) in the graph. But if there is an edge (u, v), then the values at the nodes conflict, which contradicts the satisfiability. Thus for any u, v S, there is no edge (u, v) and thus S is an independent set of size k. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 40 / 45

independent set implies satisfiability Proof continued. If we have an independent set S of size k, then we construct an assignment ν as follows: If xi appears in S, then we set ν(x i ) = 1. If x i appears in S, then we set ν(x i ) = 0. By the construction of the graph, we can have at most one vertex from every triangle. Because #S = k, we have assigned one in every clause, so the clause will evaluate to one and we obtained satisfiability. Q.E.D. Thus the theorem 3-SAT P Independent Set follows from 1 the construction of the corresponding graph G, 2 calling the black box for independent set on G, and 3 answering yes if and only if the black box solver answers yes. Q.E.D. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 41 / 45

Reductions and Satifiability 1 Polynomial-Time Reductions reformulating problems reformulating a problem in polynomial time independent set and vertex cover reducing vertex cover to set cover 2 The Satisfiability Problem satisfying truth assignments SAT and 3-SAT reducing 3-SAT to independent set transitivity of reductions Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 42 / 45

transitivity of reductions Theorem If Z P Y and Y P X, then Z P X. Proof. The result follows from a composition of black boxes: To solve an instance of Z, we call the black box for Y. To solve an instance of Y, we call the black box for X. The polynomial number of computational steps in the definition of Z P X is absorbed by the calls to the black box for Y. Q.E.D. We have proved 3-SAT P Independent Set P Vertex Cover P Set Cover, we have therefore also 3-SAT P Set Cover. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 43 / 45

one last exercise Exercise 2: Formulate the relationship between 3-SAT and the Set Packing problem. Illustrate your formulation with an example. Justify your answer. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 44 / 45

last homework due on Wednesday 1 August, at 10AM 1 Exercise 1 of Lecture 15 on slide 7. 2 Exercise 2 of Lecture 15 on slide 15. 3 Exercise 1 of Lecture 16 on slide 6. 4 Exercise 2 of Lecture 16 on slide 9. 5 Exercise 3 of Lecture 16 on slide 13. 6 Exercise 4 of Lecture 16 on slide 26. 7 Exercise 1 of Lecture 17 on slide 6. 8 Exercise 2 of Lecture 17 on slide 30. 9 Exercise 1 of Lecture 18 on slide 27. 10 Exercise 2 of Lecture 18 on slide 44. Computer Algorithms I (CS 401/MCS 401) Reductions and Satifiability L-18 30 July 2018 45 / 45