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

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

8 NP-complete problem Hard problems: demo

arxiv: v2 [cs.cc] 29 Mar 2010

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

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

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

Complexity Classes and Polynomial-time Reductions

W4231: Analysis of Algorithms

SAT-CNF Is N P-complete

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.

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

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

Reductions and Satisfiability

Computability Theory

VISUALIZING NP-COMPLETENESS THROUGH CIRCUIT-BASED WIDGETS

CSCE750 Analysis of Algorithms Fall 2017 NP-Complete Problems

9.1 Cook-Levin Theorem

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

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

2SAT Andreas Klappenecker

NP-complete Reductions

The NP-Completeness of Some Edge-Partition Problems

Chapter 8. NP-complete problems

Some Hardness Proofs

8.1 Polynomial-Time Reductions

NP and computational intractability. Kleinberg and Tardos, chapter 8

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

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

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

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

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

NP-Completeness. Algorithms

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

(QiuXin Hui) 7.2 Given the following, can you prove that the unicorn is mythical? How about magical? Horned? Decide what you think the right answer

1 Definition of Reduction

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

PCP and Hardness of Approximation

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

8.1 Polynomial-Time Reductions

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

SAT Solver. CS 680 Formal Methods Jeremy Johnson

(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1

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

Mixed Integer Linear Programming

New Upper Bounds for MAX-2-SAT and MAX-2-CSP w.r.t. the Average Variable Degree

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

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

Implementation of a Sudoku Solver Using Reduction to SAT

The Resolution Algorithm

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

Copyright 2000, Kevin Wayne 1

Homework 1. Due Date: Wednesday 11/26/07 - at the beginning of the lecture

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

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

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

Lecture 10 October 7, 2014

arxiv: v1 [cs.cc] 2 Sep 2017

Satisfiability Coding Lemma

Where Can We Draw The Line?

Steven Skiena. skiena

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

Chapter 10 Part 1: Reduction

Exam in Algorithms & Data Structures 3 (1DL481)

Lecture 7: Counting classes

Eulerian disjoint paths problem in grid graphs is NP-complete

Binary Decision Diagrams

PROPOSITIONAL LOGIC (2)

Lecture 21: Other Reductions Steven Skiena

On Approximating Minimum Vertex Cover for Graphs with Perfect Matching

Geometric Unique Set Cover on Unit Disks and Unit Squares

Answer Key #1 Phil 414 JL Shaheen Fall 2010

Inapproximability of the Perimeter Defense Problem

COMP4418 Knowledge Representation and Reasoning

P and NP (Millenium problem)

On Detecting Global Predicates in Distributed Computations

Graph Vertex Colorability & the Hardness. Mengfei Cao COMP-150 Graph Theory Tufts University

Parallelizing SAT Solver With specific application on solving Sudoku Puzzles

Lecture 2: NP-Completeness

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

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

The Complexity of Camping

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

The complement of PATH is in NL

Complexity of unique list colorability

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

CPSC 320 Notes: What's in a Reduction?

Finding a winning strategy in variations of Kayles

Maximization Versions of Lights Out Games in Grids and Graphs

Deductive Methods, Bounded Model Checking

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

Packing Trominoes is NP-Complete, #P-Complete and ASP-Complete

Learning with the Aid of an Oracle

Efficient Enumeration Algorithms for Constraint Satisfaction Problems

Nondeterministic Query Algorithms

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

HW1. Due: September 13, 2018

Integrity Constraints (Chapter 7.3) Overview. Bottom-Up. Top-Down. Integrity Constraint. Disjunctive & Negative Knowledge. Proof by Refutation

CS 3512, Spring Instructor: Doug Dunham. Textbook: James L. Hein, Discrete Structures, Logic, and Computability, 3rd Ed. Jones and Barlett, 2010

Transcription:

NP-Completeness of 3SAT, 1-IN-3SAT and MAX 2SAT 3SAT The 3SAT problem is the following. INSTANCE : Given a boolean expression E in conjunctive normal form (CNF) that is the conjunction of clauses, each of which is the disjunction of three distinct literals. QUESTION : Is E satisfiable? The CSAT problem is the following. INSTANCE : Given a boolean expression E in CNF. QUESTION : Is E satisfiable; that is, is there a truth assignment to the variables of E so that each clause in E becomes true? The Cook-Levin theorem asserts that SATISFIABILITY is NP-complete. Although 3-CNF expressions are a subset of the CNF expressions, they are complex enough in the sense that testing for satisfiability turns out to be NP-complete. Theorem : 3SAT is NP-complete. Proof : Evidently 3SAT is in NP, since SAT is in NP. To determine whether a boolean expression E in CNF is satisfiable, nondeterministically guess values for all the variables and then evaluate the expression. If E turns out to be true, then accept. This can be carried out in nondeterministic polynomial time. Thus 3SAT is in NP. To prove NP-completeness, we shall reduce CSAT to 3SAT. Let a given CNF expression be E = e 1 e 2... e k where each e i is a disjunction of literals. We replace each clause e i (as shown below) to create a new expression F such that i) F is a clause in 3SAT form. ii) time taken to construct F is linear in the length of E. iii) a truth assignment satisfies E if and only if it can be extended to a satisfying truth assignment for F. The construction of F is as follows. 1. If an e i is a single literal, say (x) or (x) we introduce two new variables u and v. We replace (x) by the conjunction of four clauses as (x+u+v)(x+u+v)(x+u+v)(x+u+v). Since u and v appear in all combinations, the only way to satisfy all four clauses is to make x true. Scribe : R. Karthik

2. Suppose an e i is the disjunction of two literals, (x + y). We introduce a new variable z and replace e i by the conjunction of two clauses (x + y + z)(x + y + z). As in case 1, the only way to satisfy both clauses is to satisfy (x + y). 3. If an e i is the disjunction of three literals it is already in the form required for 3-CNF, so we take e i as such to construct F. 4. Suppose e i = (x 1 +x 2 +...+x m ) for some m 4. We introduce new variables y 1, y 2,..., y m 3 and replace e i by the conjunction of clauses (x 1 + x 2 + y 1 )(x 3 + y 1 + y 2 )(x 4 + y 2 + y 3 )... (x m 2 + y m 4 + y m 3 )(x m 1 + x m + y m 3 ). (1) If there is a truth assignment τ that satisfies e i then at least one literal (one of the x s) in x 1 + x 2 +... + x m should be true; say τ makes x j true; that is in... (x j 1 + y j 3 + y j 2 )(x j + y j 2 + y j 1 )(x j+1 + y j 1 + y j )... Then in (1) above, if we make y 1, y 2,..., y j 2 true and make y j 1, y j,..., y m 3 false, we satisfy all the clauses of (1). Thus τ can be extended to satisfy these clauses. On the other hand, if τ makes all the x s false we can reason (as follows) that it is not possible to extend τ to make (1) true. The reason is that, since x 1 and x 2 are false, y 1 must be true (otherwise this clause will become false and will collapse e i to false) in the first clause; since x 3 is false and y 1 is false, y 2 must be true to keep the situation alive. By continuing the argument, we will reason that y m 3 is true. But, alas, x m 1 is false, x m is false and y m 3 is false and we see that e i cannot be satisfied. The above argument shows how to reduce an instance E of CSAT to an instance F of 3SAT, such that F is satisfiable if and only if E is satisfiable. The construction evidently requires time that is linear in the length of E, because none of the four cases above expand a clause by more than a factor 32/3 (that is the ratio of symbol counts in case 1) and it is possible to built F in polynomial time. Since CSAT is NP-complete, it follows that 3SAT is also NP-complete. 1-IN-3SAT The 1-IN-3SAT problem is the following. INSTANCE : A collection of clauses C 1,..., C m, m > 1; each C i is a disjunction of exactly three literals. QUESTION : Is there a truth assignment to the variables occurring so that exactly one literal is true in each C i? Let X = {x 1,..., x 5 } be the set of variables. Let the clause set C = {C 1, C 2, C 3 } be the following : C 1 = {x 1, x 2, x 3 }, C 2 = {x 1, x 4, x 5 }, C 3 = {x 2, x 4, x 5 }. With this (X, C) we consider the 1-IN-3SAT problem. We say a clause is correctly satisfied if and only if the clause is satisfied due to exactly one literal in it. To correctly satisfy C 1 we try setting only x 1 = in C 1. This when applied to C 2 requires x 4 = and x 5 = for correct satisfaction of C 2. But x 4 = and x 5 = in C 3 requires x 2 = for correct satisfaction of C 3 this violates the correct satisfaction of C 1. Similarly we get a contradiction if we try setting only x 2 = in C 1. The only solution is x 1 =, x 2 = and x 3 = and exactly one of x 4 or x 5 is. Note that as a 3SAT instance (X, C) admits other solutions as well.

Theorem : 1-IN-3SAT is NP-complete. Proof : It can be argued that 1-IN-3SAT is in NP. To prove that the problem is NP-hard, the following reduction shows 3SAT is polynomially reducible to 1-IN-3SAT, where 3SAT is NP-hard. That is, we need to show that any instance of 3SAT can be efficiently transformed to an instance of 1-IN-3SAT so that 3SAT is satsifiable if and only if 1-IN-3SAT is satisfiable. We consider any C i = {x i1, x i2, x i3 } in 3SAT. In the corresponding 1-IN-3SAT instance, we will produce the following three clauses with the addition of four new variables a i, b i, c i, d i : C i1 = {x i1, a i, b i }, C i2 = {x i2, b i, c i }, C i3 = {x i3, c i, d i } Hence if the 3SAT instance has n variables and m clauses, in the 1-IN-3SAT instance, there will be n + 4m variables and 3m clauses. This transformation can be done efficiently. Assume that the 3SAT instance is not satisfiable. Then in any C i, x i1 =, x i2 = and x i3 =. We try to extend this truth assignment to a satisfying truth assignment of 1-IN- 3SAT. In the 1-IN-3SAT instance, in C i2 since x i2 = exactly one of b i or c i should be so that C i2 gets correctly satisfied; if b i =, C i1 will not get satisfied; if c i =, C i3 will not get satisfied. In other words, if the 3SAT instance is not satisfied then no truth assignment of variables can make the 1-IN-3SAT instance satisfied correctly. Now assume that the 3SAT instance is satisfiable. Every C i is in any solution. We consider the following cases that make C i = in the 3SAT instance: 1. x i2 = (we have 4 cases) : In the 1-IN-3SAT instance we can set b i =, c i = in C i2 ; we also set a i = x i1 and d i = x i3 so that C i1 and C i3 are correctly satisfied. 2. x i2 =, x i1 =, x i3 = : In the 1-IN-3SAT instance we can set a i =, b i =, c i =, d i = so that C i1, C i2 and C i3 are correctly satisfied. 3. Only x i1 = : In the 1-IN-3SAT instance we set a i =, b i =, c i =, d i =. This correctly satisfies C i1, C i2 and C i3. 4. Only x i3 = : In the 1-IN-3SAT instance we set a i =, b i =, c i =, d i =. This correctly satisfies C i1, C i2 and C i3. In summary, a satisfying truth assignment to the variables in 3SAT can be extended to a correctly satisfying truth assignment of the variables in 1-IN-3SAT. We conclude that 1-IN-3SAT is also NP-complete. MAX 2SAT The following is the maximum satisfiability with at most two literals per clause (MAX 2SAT) problem. INSTANCE : Given a set C 1,..., C p of clauses, each being a disjunction of at most two literals; and an integer k where 1 k < p. QUESTION : Is there a truth assignment to the variables so that k or more clauses are satisfied? Note that if k = p, the above problem reduces to the 2SAT problem which can be solved

efficiently in polynomial time. The following theorem relies on reducing 3SAT to MAX 2SAT. The proof rewritten slightly essentially follows [2]. Theorem : MAX 2SAT is NP-complete. Proof : First we note that if a truth setting of variable makes at least k clauses true, then by substituting these truth values we can efficiently check the truth or falsity clause by clause, keeping a counter to hold the number of clauses found to be true so far. Hence MAX 2SAT is in NP. The following is a reduction from 3SAT to MAX 2SAT. That is, given an instance of 3SAT we construct an instance of MAX 2SAT so that a satisfying truth assignment of 3SAT can be extended to a satisfying truth assignment of MAX 2SAT. Note that a satisfying truth assignment is one that makes at least k clauses true in the MAX 2SAT instance. Let S be the instance of 3SAT where the clauses are C 1,..., C m where C i = {x i, y i, z i }, where each x i, y i, and z i represents either a variable or its negation and 1 i m. From S we build an instance S of MAX 2SAT as follows. Each C i in S corresponds to a clause group C i in S where C i = {(w i ), (x i ), (y i ), (z i ), (x i + y i ), (y i + z i ), (x i + z i ), (w i + x i ), (w i + y i ), (w i + z i )} where w i is a new variable and 1 i m. We set k = 7m. Each clause in S as constructed above has at most two literals. It can be seen that the clauses in S can be efficiently generated from the clauses in S in polynomial time. We now argue that a satisfying truth assignment of S exists if and only if it can be extended to a satisfying truth assignment for S appropriately. Assume that S is satisfiable. Then in a typical clause C i = {x i, y i, z i } either one or two or all the three variables are true. a) Let x i = T, y i = F, z i = F. With this truth assignment in S, if w i = T, six clauses of C i become true; if w i = F, seven clauses of C i become true. b) Let x i = T, y i = T, z i = F. This truth assignment in S together with w i = T or w i = F, makes seven clauses of C i true. c) Let x i = T, y i = T, z i = T. With this truth assignment in S, if w i = T, seven clauses of C i become true; if w i = F, six clauses of C i become true. In summary, a satisfying truth assignment of S can be extended to a satisfying truth assignment of S where exactly seven clauses in each clause group get satisfied. Moreover no setting of w i causes more than seven of the ten clauses to be true in each clause group in S. Now assume that S is not satisfiable. Then in at least one clause C i = {x i, y i, z i } in S, we have x i = F, y i = F, z i = F. With this truth assignment in S, if w i = T, four clauses of C i become true; if w i = F, six clauses of C i become true. That is, if S is not satisfiable, no truth setting can make at least seven clauses true in each clause group C i. Since 3SAT is NP-complete, we conclude that MAX 2SAT is also NP-complete.

References [1] J. E. Hopcroft, R. Motwani, and J. D. Ullman. Introduction to Automata Theory, Languages, and Computation, third edition. Pearson Addison-Wesley, 2007. [2] M. R. Garey, D. S. Johnson, and L. Stockmeyer. Some simplified NP-complete graph problems. Theo. Comp. Sci., 1(3):237 267, 1976. [3] T. J. Schaefer. The complexity of satisfiability problems, in Proceedings of the 10th Annual ACM Symposium on Theory of Computing, pages 216 226, 1978.