SAT-CNF Is N P-complete

Similar documents
Computability Theory

arxiv: v2 [cs.cc] 29 Mar 2010

NP-Completeness. Algorithms

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

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

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

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

8.1 Polynomial-Time Reductions

Where Can We Draw The Line?

W4231: Analysis of Algorithms

NP and computational intractability. Kleinberg and Tardos, chapter 8

9.1 Cook-Levin Theorem

1 Definition of Reduction

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

8 NP-complete problem Hard problems: demo

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

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

PCP and Hardness of Approximation

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

Finite Model Generation for Isabelle/HOL Using a SAT Solver

Linear Time Unit Propagation, Horn-SAT and 2-SAT

The Resolution Algorithm

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

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

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

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

Vertex Cover is Fixed-Parameter Tractable

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

CSCE750 Analysis of Algorithms Fall 2017 NP-Complete Problems

Homework 4 Solutions

NP-complete Reductions

2SAT Andreas Klappenecker

PROPOSITIONAL LOGIC (2)

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

P and NP (Millenium problem)

NP-Complete Reductions 2

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

Some Hardness Proofs

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

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

Satisfiability Coding Lemma

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

More on Polynomial Time and Space

The NP-Completeness of Some Edge-Partition Problems

On the Complexity of k-sat

Introduction to Parameterized Complexity

Exact Algorithms Lecture 7: FPT Hardness and the ETH

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

Complexity of unique list colorability

Institut for Matematik & Datalogi November 15, 2010 Syddansk Universitet. DM528: Combinatorics, Probability and Randomized Algorithms Ugeseddel 3

Finding a winning strategy in variations of Kayles

1 Variations of the Traveling Salesman Problem

Efficient Enumeration Algorithms for Constraint Satisfaction Problems

Recitation 4: Elimination algorithm, reconstituted graph, triangulation

On the Complexity of the Policy Improvement Algorithm. for Markov Decision Processes

Copyright 2000, Kevin Wayne 1

Minimum sum multicoloring on the edges of trees

On the Relationships between Zero Forcing Numbers and Certain Graph Coverings

Random Walks and Universal Sequences

The Complexity of Camping

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

Complexity results for Minimum Sum Edge Coloring

CSc Parallel Scientific Computing, 2017

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1

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

Connected Components of Underlying Graphs of Halving Lines

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

Complexity Classes and Polynomial-time Reductions

SAT Solver. CS 680 Formal Methods Jeremy Johnson

Boolean Functions (Formulas) and Propositional Logic

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

Mixed Integer Linear Programming

FINAL EXAM SOLUTIONS

Lecture 7: Counting classes

Lecture 14: Lower Bounds for Tree Resolution

Exercises Computational Complexity

8.1 Polynomial-Time Reductions

The Resolution Width Problem is EXPTIME-Complete

On Detecting Global Predicates in Distributed Computations

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

Finding a -regular Supergraph of Minimum Order

COMPUTABILITY THEORY AND RECURSIVELY ENUMERABLE SETS

Efficiency versus Convergence of Boolean Kernels for On-Line Learning Algorithms

Complexity of Disjoint Π-Vertex Deletion for Disconnected Forbidden Subgraphs

1.4 Normal Forms. We define conjunctions of formulas as follows: and analogously disjunctions: Literals and Clauses

CMPSCI611: The SUBSET-SUM Problem Lecture 18

Normal Forms for Boolean Expressions

Reductions and Satisfiability

More intensional versions of Rice s Theorem

9.5 Equivalence Relations

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

The transition: Each student passes half his store of candies to the right. students with an odd number of candies eat one.

SAT Solvers. Ranjit Jhala, UC San Diego. April 9, 2013

ON THE COMPLEXITY AND TOPOLOGY OF SCORING GAMES: OF PIRATES AND TREASURE

Discrete Optimization. Lecture Notes 2

Binary Decision Diagrams

Optimal Parallel Randomized Renaming

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

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

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

Transcription:

SAT-CNF Is N P-complete Rod Howell Kansas State University November 9, 2000 The purpose of this paper is to give a detailed presentation of an N P- completeness proof using the definition of N P given by Brassard and Bratley [1] and the following definition of N P-hardness: Definition 1 A decision problem Y is N P-hard if for every X N P, X p m Y. We focus on the following two problems: Satisfiability (SAT): Input: A formula f over boolean variables with operators,, and. Question: Is there an assignment of boolean values to the variables in f such that f is true? Conjunctive Normal Form Satisfiability (SAT-CNF): Input: A formula f in conjunctive normal form (CNF), i.e., of the form m k i, i=1 j=1 where each α ij is either a boolean variable or the negation of a boolean variable. Question: Is there an assignment of boolean values to the variables in f such that f is true? We will show that SAT-CNF is N P-complete (this fact is originally due to Cook [2]). We assume the following theorem, also due to Cook [2]: Theorem 1 SAT is N P-hard. Copyright c 2000, Rod Howell. This paper may be copied or printed in its entirety for use in conjunction with CIS 775, Analysis of Algorithms, at Kansas State University. Otherwise, no portion of this paper may be reproduced in any form or by any electronic or mechanical means without permission in writing from Rod Howell. α ij 1

We first show that SAT N P. Because SAT-CNF is a special case of SAT, it will follow that SAT-CNF N P. Theorem 2 SAT N P. Proof: Our proof space Q will be the set of finite sequences of boolean values. Let Φ be the set of all boolean formulas, and let V be the set of all boolean variables. We define a partial function g : Φ Z + V so that g(f, k) is the variable in f whose first occurrence is kth among the first occurrences of all variables in f; if f contains fewer than k variables, g(f, k) is undefined. We then define F SAT Q so that f, b 1, b 2,..., b m F iff f contains exactly m variables; and the assignment of the boolean value b k to the variable g(f, k) for 1 k m is a satisfying assignment for f. Thus, for each f SAT, there is a q Q no longer than f. We will now show that we can decide whether f, q F in O(n 2 ) time, where n is the sum of the lengths of f and q. Our algorithm proceeds as follows: 1. We first construct a list of all the variables in f, ordered by the position of their first occurrence. As we construct this list, we record the position in this list of each occurrence of each variable in f. This can clearly be done in O(n 2 ) time. 2. We then verify that the length of q is exactly the number of variables in f. This can clearly be done in O(1) time if q is stored in an array. 3. We then verify that f is satisfied by assigning the kth variable in the variable list the kth boolean value in q, for all k. We accomplish this by a straightforward recursive evaluation of f, looking up the value of each variable using its recorded position in the variable list. Assuming the sequence q is stored as an array, this evaluation can be done in O(n) time. Corollary 1 SAT-CNF N P. Corollary 2 SAT is N P-complete. Our proof of N P-hardness will involve a reduction from SAT to SAT-CNF. This reduction will consist of two steps. First, we will convert the given boolean formula to an equivalent formula in which negation is applied only to variables, not to arbitrary subexpressions. We will then construct from the resulting formula a formula in CNF that is satisfiable iff the original formula is satisfiable. The CNF formula will not, in fact, be equivalent to the original formula, because conversion to CNF can result in an exponentially larger formula, and hence uses exponential time in the worst case. We begin by showing how negations can be moved to the variables. 2

Lemma 1 There is a linear-time algorithm to convert arbitrary boolean formulas to equivalent boolean formulas in which negation is applied only to variables. Proof: Our algorithm uses the following laws of boolean algebra: (f g) = f g; (1) (f g) = f g; and (2) f = f. (3) We can apply one of these three laws to any subexpression f, where f is not a variable, to obtain an equivalent subexpression in which all negated subexpressions are strictly shorter than f. A straightforward recursive implementation of this strategy produces an equivalent formula of the proper form in linear time. We now define a literal to be either a variable or the negation of a variable. Using this definition, we can describe our reduction from SAT to SAT-CNF. Theorem 3 SAT-CNF is N P-hard. Proof: We will show that SAT p m SAT-CNF. From Theorem 1, it will follow that SAT-CNF is N P-hard. Let f be an arbitrary boolean formula. Our algorithm first coverts f to an equivalent formula f in which negations are applied only to variables. From Lemma 1, this can be done in linear time. Furthermore, because the conversion can be done in linear time, the length of f is linear in the length of f. For the next step of our algorithm, we assume the existence of a polynomial-time algorithm to generate new unique variables. In particular, after the algorithm is initialized, we can call it arbitrarily many times, and each time it will return a variable different from any variable in f and any variable it had previously returned. It is not hard to design such an algorithm that returns n variables in a time polynomial in n and the length of f. We now describe a recursive algorithm that takes a formula φ in which negations are applied only to variables, and produces a formula φ in CNF that is satisfiable iff φ is satisfiable. Let V be the set of variables in φ and V be the set of variables in φ. Specifically, φ will be satisfiable by an assignment g : V {true, false} iff φ is satisfiable by the assignment g : V {true, false}, where g(v) = g (v) for all v V. The base case occurs when φ is a literal. In this case, the algorithm simply returns φ. Otherwise, there are two cases. Case 1: φ = φ 1 φ 2. We first recursively compute φ 1 and φ 2. We then return φ = φ 1 φ 2. Because φ 1 and φ 2 are both in CNF, φ is in CNF. Suppose φ is satisfied by some assignment g. Then g must satisfy both φ 1 and φ 2. Let V 1 be the set of variables in either φ 1 or V, and let V 2 be the set of variables in either φ 2 or V. Then V = V 1 V 2, and V = V 1 V 2. There must be assignments g 1 : V 1 {true, false} satisfying 3

φ 1 and g 2 : V 2 {true, false} satisfying φ 2 such that for all v V, g(v) = g 1(v) = g 2(v). Let g : V {true, false} be defined as { g g (v) = 1(v) if v V 1 g 2(v) if v V 2. Clearly, g satisfies φ. Now suppose φ is satisfied by some assignment g. Then g must satisfy both φ 1 and φ 2; hence, it also satisfies both φ 1 and φ 2. Case 2: φ = φ 1 φ 2. We first recursively compute φ 1 and φ 2, then generate a new variable x. We then change each conjunct c of φ 1 to x c, and change each conjunct c of φ 2 to x c. We return φ, the conjunction of the resulting two formulas. Again, because both φ 1 and φ 2 are in CNF, φ is in CNF. Suppose φ is satisfied by some assignment g. Then g must satisfy at least one of φ 1 or φ 2. Assume g satisfies φ 1 ; the other case is handled symmetrically. Define V 1 and V 2 as in Case 1. Then V = V 1 V 2 {x} and V = V 1 V 2. There must be an assignment g 1 : V 1 {true, false} satisfying φ 1 such that for all v V, g(v) = g 1(v). Let g : V {true, false} be defined as g 1(v) if v V 1 g (v) = false if v = x true otherwise Because g (x) = false, and because each conjunct of φ 1 is satisfied by g 1, each conjunct of φ is satisfied by g. Now suppose φ is satisfied by some assignment g. Assume g (x) = false; the other case is handled symmetrically. Then each conjunct of φ that was derived from φ 1 must contain a literal that is true under g ; furthermore, each of these true literals must contain variables from V 1. It follows that φ 1 is satisfied by g ; hence, φ 1 and φ are satisfied by g. In order to complete the proof, we must show that the entire algorithm operates in polynomial time. In order to facilitate this, we will first show that the formula φ produced by the recursive algorithm described above contains no more conjuncts than φ has literals, and that each conjunct contains no more literals than the number of s in φ, plus 1. The bound on the number of conjuncts follows immediately from the fact that only the base case introduces new conjuncts, and it introduces one for each literal. The bound on the number of literals in each conjunct follows from the fact that only the base case and Case 2 increase the size of a conjunct. The base case creates a new conjunct (effectively increasing from 0 literals to 1 literal), and Case 2 adds 1 literal to existing conjuncts. Because Case 2 is called once for each in φ, the total number literals in any conjunct in φ is at most the number of s in φ plus 1. 4

The recursive algorithm can be implemented to represent φ as a linked list with head and tail pointers. Each element in the list represents a conjunct. Each conjunct in turn is represented by a linked list of literals. Using this representation, it is easily seen that if we ignore the time needed to generate new variables, the recursive algorithm can be implemented to run in time linear in the size of φ, which is polynomial in the size of f. Because the total number of new variables needed is polynomial in the size of f, they can also be generated in polynomial time. Therefore, the entire algorithm runs in time polynomial in the size of f. Corollary 3 SAT-CNF is N P-complete. References [1] Gilles Brassard and Paul Bratley. Fundamentals of Algorithmics. Prentice Hall, 1996. [2] Steven Cook. The complexity of theorem proving procedures. In Proc. Third Annual ACM Symposium on the Theory of Computing, pages 151 158, 1971. 5