W4231: Analysis of Algorithms

Similar documents
Computability Theory

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

NP-Completeness. Algorithms

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

NP-complete Reductions

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

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

1 Definition of Reduction

NP-Complete Reductions 2

CMPSCI611: The SUBSET-SUM Problem Lecture 18

8 NP-complete problem Hard problems: demo

9.1 Cook-Levin Theorem

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

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

NP and computational intractability. Kleinberg and Tardos, chapter 8

8.1 Polynomial-Time Reductions

Where Can We Draw The Line?

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

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

P and NP (Millenium problem)

Some Hardness Proofs

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

SAT-CNF Is N P-complete

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

Complexity Classes and Polynomial-time Reductions

Lecture 2: NP-Completeness

Chapter 10 Part 1: Reduction

PCP and Hardness of Approximation

1 Algorithm and Proof for Minimum Vertex Coloring

An IPS for TQBF Intro to Approximability

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

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

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

Lecture 10 October 7, 2014

arxiv: v2 [cs.cc] 29 Mar 2010

Chapter 8. NP-complete problems

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

Module 6 NP-Complete Problems and Heuristics

CSCE750 Analysis of Algorithms Fall 2017 NP-Complete Problems

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

8.1 Polynomial-Time Reductions

HW1. Due: September 13, 2018

Complexity of Disjoint Π-Vertex Deletion for Disconnected Forbidden Subgraphs

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

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

Exercises Computational Complexity

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

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

Homework 4 Solutions

Notes for Lecture 24

Recitation 4: Elimination algorithm, reconstituted graph, triangulation

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

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

FINAL EXAM SOLUTIONS

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

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

8.2 Paths and Cycles

Reductions and Satisfiability

HW Graph Theory SOLUTIONS (hbovik) - Q

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

Math 776 Graph Theory Lecture Note 1 Basic concepts

Engineering 9867 Advanced Computing Concepts

Basics of Graph Theory

Introduction to Parameterized Complexity

In this lecture we discuss the complexity of approximation problems, and show how to prove they are NP-hard.

arxiv: v1 [cs.cc] 30 Jun 2017

2SAT Andreas Klappenecker

Module 6 NP-Complete Problems and Heuristics

Lecture 6: Graph Properties

Chapter 8. NP-complete problems

Partitions and Packings of Complete Geometric Graphs with Plane Spanning Double Stars and Paths

W[1]-hardness. Dániel Marx. Recent Advances in Parameterized Complexity Tel Aviv, Israel, December 3, 2017

Decision Procedures. An Algorithmic Point of View. Decision Procedures for Propositional Logic. D. Kroening O. Strichman.

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

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

Approximation Algorithms

Assignment # 4 Selected Solutions

Inapproximability of the Perimeter Defense Problem

Math 443/543 Graph Theory Notes 2: Transportation problems

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

ALGORITHMS EXAMINATION Department of Computer Science New York University December 17, 2007

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

The Complexity of Camping

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

Paths, Flowers and Vertex Cover

Eulerian disjoint paths problem in grid graphs is NP-complete

Partha Sarathi Mandal

11.2 Eulerian Trails

5 Graphs

Online Appendix: A Stackelberg Game Model for Botnet Data Exfiltration

2. CONNECTIVITY Connectivity

The temporal explorer who returns to the base 1

11.4 Bipartite Multigraphs

Dr. Amotz Bar-Noy s Compendium of Algorithms Problems. Problems, Hints, and Solutions

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

Paths, Flowers and Vertex Cover

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

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

Module 6 NP-Complete Problems and Heuristics

MC 302 GRAPH THEORY 10/1/13 Solutions to HW #2 50 points + 6 XC points

Transcription:

W4231: Analysis of Algorithms 11/23/99 NP-completeness of 3SAT, Minimum Vertex Cover, Maximum Independent Set, Boolean Formulae A Boolean formula is an expression that we can build starting from Boolean variables x 1,...,x n,... and then using (AND) (OR) and (NOT). For example (x 1 x 3 ) ((x 4 x 1 ) (x 2 x 3 )) (1) COMSW4231, Analysis of Algorithms 1 COMSW4231, Analysis of Algorithms 2 CNF Formulae A Boolean formula is in Conjunctive-Normal-Form (CNF) if it is a AND-of-ORs. Negation can be used only as the innermost operator. Formula (1) is not in CNF. The following is in CNF (x 2 x 4 x 5 ) x 3 (x 1 x 3 x 4 ) ( x 2 x 5 ) (2) SAT is clearly in NP. Satisfiability. (Why?) SAT In fact it is a special case of Circuit We want to prove that it is NP-hard. We want to reduce from Circuit Satisfiability. A Boolean formula can be seen as a representation of a Boolean function. Problem: Given a CNF formula, is there a setting of Boolean values to its variables that makes the formula true? (Name of the problem: SAT.) COMSW4231, Analysis of Algorithms 3 COMSW4231, Analysis of Algorithms 4 Doomed approach: Given a circuit, transform it into a Boolean CNF formula that computes the same Boolean function. Parity: consider the Boolean function that is 1 iff an odd number of inputs is 1. There is a circuit of size O(n) that computes this function for inputs of length n. But the smallest CNF for this function has size more than 2 n. So we cannot translate a circuit into a CNF formula of comparable size that computes the same function. But we may be able to transform a circuit into a CNF formula such that the circuit is satisfiable iff the formula is satifiable. The reduction We will add new variables. Suppose the circuit C has m gates, including input gates. We use variables g 1,...,g m variable g j corresponding to gate j. We make a formula F which is the AND of m+1 sub-expression. COMSW4231, Analysis of Algorithms 5 COMSW4231, Analysis of Algorithms 6

Sub-expressions There is a sub-expression for every gate j, saying that the value of the variable for that gate is set in accordance to the value of the variables corresponding to inputs for gate j. We also have a (m +1)-th term that says that the output gate outputs 1. There is no sub-expression for the input gates. For a gate j, which is a NOT applied to the output of gate i, we have the sub-expression (g i g j ) (ḡ i ḡ j ) For a gate j, which is a AND applied to the output of gates i and l, we have the sub-expression (ḡ j g i ) (ḡ j g l ) (g j ḡ i ḡ l ) Similarly for OR. COMSW4231, Analysis of Algorithms 7 COMSW4231, Analysis of Algorithms 8 Proof of Correctness 3-CNF Satisfiability Suppose C is satisfiable, then consider setting g j being equal to the output of the j-th gate of C when a satisfying set of values is given in input. Such a setting for g 1,...,g m satisfies F. Suppose F is satisfiable, and give in input to C the part of the assignment to F corresponding to input gates of C. We can prove by induction that the output of gate j in C is also equal to g j, and therefore the output gate of C outputs 1. So C is satisfiable if and only if F is satisfiable. SAT is a much simpler problem than Circuit Satisfiability, if we want to use it as a starting point of NP-completeness proofs. We can use an even simpler starting point: 3SAT Definition: 3SAT is the same as SAT, except that each OR is on precisely 3 (possibly negates) variables. E.g. (x 2 x 4 x 5 ) (x 1 x 3 x 4 ) ( x 2 x 3 x 5 ) (3) Certainly, 3SAT is in NP. COMSW4231, Analysis of Algorithms 9 COMSW4231, Analysis of Algorithms 10 Terminology 3SAT is NP-complete Each little OR in a SAT formula is called a clause. Each occurrence of a variable, complemented or not, is called a literal. Take a formula F of SAT. We tranform it into a formula F of 3SAT such that F is satisfiable if and only if F is satisfiable. Each clause of F is transformed into a sub-expression of F. Clauses of length 3 are left unchanged. COMSW4231, Analysis of Algorithms 11 COMSW4231, Analysis of Algorithms 12

A clause of length 1, such as (x) is changed as follows (x y 1 y 2 ) (x y 1 ȳ 2 )(x ȳ 1 y 2 ) (x ȳ 1 ȳ 2 ) where y 1 and y 2 are two new variables added specifically for the transformation of that clause. A clause of length 2, such as x 1 x 2 is changed as follows For a clause of length k 4, such as (x 1 x k ), we change it as follows (x 1 x 2 y 1 ) (ȳ 1 x 3 y 2 ) (ȳ 2 x 4 y 4 ) (ȳ k 3 x k 1 x k where y 1,,y k 3 are new variables added specifically for the transformation of that clause. (x 1 x 2 y) (x 1 x 2 ȳ) where y is a new variable added specifically for the transformation of that clause. COMSW4231, Analysis of Algorithms 13 COMSW4231, Analysis of Algorithms 14 Correctness Independent Set We first argue that if F is satisfiable, then there is an assignment that satisfies F. For the shorter clauses, we just set the y-variables arbitrarily. For the longer clause it is slightly more tricky. We then argue that if F is not satisfiable, then F is not satisfiable. Fix an assignment to the x variables. Then there is a clause in F that is not satisfied. We argue that one of the derived clauses in F is not satisfied. Given an undirected non-weighted graph G = (V,E), an independent set is a subset I V of the vertices such that no two vertices of I are adjacent. (Similar to the notion of a matching, except that it involves vertices and not edges) Given a graph, we want to find a largest independent set. Motivations: executing conflicting tasks; related to the construction of error-correcting codes; special case of more interesting problems COMSW4231, Analysis of Algorithms 15 COMSW4231, Analysis of Algorithms 16 Complexity Reduction from 3SAT Decision version: Given a graph G and an integer k, does there exist an independent set in G with at least k vertices? We are going to prove: (The decision version of) the Maximum Independent Set Problem is NP-complete. It is easy to see that the problem is in NP. We have to see that it is NP-hard. We show how to reduce 3SAT to Maximum Independent Set. Starting from a formula φ with n variables x 1,...,x n and m clauses, we generate a graph G φ with 3m vertices, and we show that the graph has an independent set with at least m vertices iff the formula is satisfiable. The graph G φ has a triangle for every clause in φ. The vertices in the triangle correspond to the three literals of the clause. Vertices in different triangles are joined by an edge iff they correspond to two literals that are one the complement of the other. COMSW4231, Analysis of Algorithms 17 COMSW4231, Analysis of Algorithms 18

not x5 x2 Correctness We have to show that x1 not x3 x3 x4 If φ is satisfiable, then there is an independent set in G φ with at least m vertices. x3 If there is an independent set in G with at least m vertices, then φ is satisfiable. not x1 x4 COMSW4231, Analysis of Algorithms 19 COMSW4231, Analysis of Algorithms 20 From Satisfaction to Independence From Independence to Satisfaction Suppose we have an assignment of Boolean values to the variables x 1,...,x n of φ such that all the clauses of φ are satisfied. This means that for every clause, at least on of its literals is satisfied by the assignment. We construct an independent set as follows: for every triangle pick a node that corresponds to a satisfied literal. Break ties arbitrarily. It is impossible that two such nodes are adjacent. Suppose we have an independent set I with m vertices. We better have exactly one vertex in I for every triangle. (Two vertices in the same triangle are always adjacent.) Let us fix an assignment that satisfies all the literals that correspond to vertices of I. Assign values to the other variables arbitrarily. This is a consistent rule to generate an assignment (we cannot have a literal and its negation in the independent set). Every clause is satisfied by this assignment. COMSW4231, Analysis of Algorithms 21 COMSW4231, Analysis of Algorithms 22 Wrapping Up Similar Problems We showed a reduction φ (G φ,m) that given an instance of 3SAT produces an instance of the decision version of Maximum Independen Set. We have the property that φ is satisfiable (answer YES for the 3SAT problem) if and only if G φ has an independent set of size at least m. We knew 3SAT is NP-hard. Then also Max Independent Set is NP-hard; and so also NPcomplete. Maximum Clique. Given a (undirected non-weighted) graph G =(V,E), aclique K is a set of vertices K V such that any two vertices in K are adjacent. We want to find the biggest clique. Maximum Clique is NP-hard by reduction from Maximum Independent Set. Minimum Vertex Cover. Given a (undirected non-weighted) graph G =(V,E), a vertex cover C is a set of vertices C V such that for every edge (u, v) E, either u C or v C (or, possibly, both). COMSW4231, Analysis of Algorithms 23 COMSW4231, Analysis of Algorithms 24

NP-hardness of Minimum Vertex Cover Reduction We show a reduction from Maximum Independent Set. reduction is based on the following observation: The Starting from an instance (G, k) of Maximum Independent set we produce an instance (G, n k) of Minimum Vertex Cover. If you have an independent set I in a graph G =(V,E), then the set of vertices C = V I that are not in I is a vertex cover. Suppose C is not a vertex cover: then there is some edge (u, v) neither of whose endpoints is in C. This means both the endpoints are in I. So I is not an independent set. Contradiction. COMSW4231, Analysis of Algorithms 25 COMSW4231, Analysis of Algorithms 26