CMSC 858F: Algorithmic Lower Bounds Fall SAT and NP-Hardness

Similar documents
CMSC 858F: Algorithmic Lower Bounds Fall SAT and NP-Hardness

Lecture 4 Scribe Notes

Lecture 24 : Even more reductions

1.1 P, NP, and NP-complete

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

Tecniche di Verifica. Introduction to Propositional Logic

A brief introduction to Logic. (slides from

Show that the following problems are NP-complete

CS21 Decidability and Tractability

Propositional Logic Basics Propositional Equivalences Normal forms Boolean functions and digital circuits. Propositional Logic.

Lecture 15 - NP Completeness 1

Critical Reading of Optimization Methods for Logical Inference [1]

Essential facts about NP-completeness:

SAT, Coloring, Hamiltonian Cycle, TSP

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

Non-Deterministic Time

Part 1: Propositional Logic

NP and Computational Intractability

Conjunctive Normal Form and SAT

A New 3-CNF Transformation by Parallel-Serial Graphs 1

Conjunctive Normal Form and SAT

Phase transitions in Boolean satisfiability and graph coloring

Lecture 16: Constraint Satisfaction Problems

A Note on Perfect Partial Elimination

A Collection of Problems in Propositional Logic

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office?

arxiv: v1 [cs.dm] 29 Oct 2012

6.841/18.405J: Advanced Complexity Wednesday, February 12, Lecture Lecture 3

Lecture 5: Efficient PAC Learning. 1 Consistent Learning: a Bound on Sample Complexity

CS 583: Algorithms. NP Completeness Ch 34. Intractability

Introduction to Computational Complexity

NP-completeness. Chapter 34. Sergey Bereg

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA.

Generalizations of Matched CNF Formulas

Conjunctive Normal Form and SAT

CS21 Decidability and Tractability

CSE 555 HW 5 SAMPLE SOLUTION. Question 1.

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9

Linear Programming Formulation of Boolean Satisfiability Problem

CSE 105 THEORY OF COMPUTATION

Minimization of Matched Formulas

Trichotomy Results on the Complexity of Reasoning with Disjunctive Logic Programs

NP Completeness and Approximation Algorithms

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

COP 4531 Complexity & Analysis of Data Structures & Algorithms

The Complexity of Maximum. Matroid-Greedoid Intersection and. Weighted Greedoid Maximization

COMP Analysis of Algorithms & Data Structures

Limitations of Algorithm Power

NP-Complete Reductions 1

Solutions to Sample Problems for Midterm

Harvard CS 121 and CSCI E-121 Lecture 22: The P vs. NP Question and NP-completeness

LOGIC PROPOSITIONAL REASONING

The Connectivity of Boolean Satisfiability: Computational and Structural Dichotomies

Lecture 2. Logic Compound Statements Conditional Statements Valid & Invalid Arguments Digital Logic Circuits. Reading (Epp s textbook)

Theory of Computer Science. Theory of Computer Science. E4.1 Overview E4.2 3SAT. E4.3 Graph Problems. E4.4 Summary.

Computability and Complexity Theory: An Introduction

NP-complete problems. CSE 101: Design and Analysis of Algorithms Lecture 20

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

On the Gap between the Complexity of SAT and Minimization for Certain Classes of Boolean Formulas

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

A Lower Bound for Boolean Satisfiability on Turing Machines

Lecture 7: Polynomial time hierarchy

Normal Forms of Propositional Logic

Comp487/587 - Boolean Formulas

NP Complete Problems. COMP 215 Lecture 20

Introduction to Complexity Theory

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

A Lower Bound of 2 n Conditional Jumps for Boolean Satisfiability on A Random Access Machine

NP-Complete Reductions 2

Week 3: Reductions and Completeness

NP-Complete problems

Pythagorean Triples and SAT Solving

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM

Section 1.2 Propositional Equivalences. A tautology is a proposition which is always true. A contradiction is a proposition which is always false.

CS 301: Complexity of Algorithms (Term I 2008) Alex Tiskin Harald Räcke. Hamiltonian Cycle. 8.5 Sequencing Problems. Directed Hamiltonian Cycle

CSE 421 NP-Completeness

Lecture 14 - P v.s. NP 1

Lecture 4: NP and computational intractability

Lecture 12 Scribe Notes

NP-Hardness reductions

CSCI3390-Lecture 17: A sampler of NP-complete problems

Lecture 21 (Oct. 24): Max Cut SDP Gap and Max 2-SAT

Recap from Last Time

Polynomial-Time Reductions

NP-Completeness Part II

NP and Computational Intractability

Detecting Backdoor Sets with Respect to Horn and Binary Clauses

MATHEMATICAL ENGINEERING TECHNICAL REPORTS. Deductive Inference for the Interiors and Exteriors of Horn Theories

Lecture #14: NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition.

Lecture 20: PSPACE. November 15, 2016 CS 1010 Theory of Computation

NP-Completeness Part II

Propositional Logic: Evaluating the Formulas

On the correlation of parity and small-depth circuits

De Morgan s a Laws. De Morgan s laws say that. (φ 1 φ 2 ) = φ 1 φ 2, (φ 1 φ 2 ) = φ 1 φ 2.

Part V. Intractable Problems

The Cook-Levin Theorem

Notes for Lecture 2. Statement of the PCP Theorem and Constraint Satisfaction

Propositional Calculus: Formula Simplification, Essential Laws, Normal Forms

Transcription:

CMSC 858F: Algorithmic Lower Bounds Fall 2014 3-SAT and NP-Hardness Instructor: Mohammad T. Hajiaghayi Scribe: Philip Dasler September 23, 2014 The most important NP-Complete (logic) problem family! 1 SAT = Satisfiability The Satisfiability problem (introduced by Cook in 1971 [2] and again by Levin in 1973 [11] 1 ), asks the following question: given a boolean formula F (AND, NOT, and OR) over n variables x 1,..., x n, does there exist a set of assignments for each variable x i such that F is TRUE. This problem is well studied and is a well known example of an NP-Complete problem. 2 Circuit SAT The formula to be satisfied can also be expressed as a circuit of logic gates (allows re-use). x 1 x 2 x 3 There is a simple reduction from Circuit SAT to 3-SAT known as the Tseitin transformation. In this reduction, each logic gate is replaced by a set formula, e.g., an AND gate between two variables A and B is replaced with the formula 1 This citation is to a survey in English which translates the original Russian paper. You can find the Russian version here if you re curious. 1

(A B C) (A C) (B C), where C is a new variable created to represent the result of the AND gate. 3 CNF SAT [2] CNF = Conjunctive Normal Form The conjunctive normal form is a formulation of a boolean logic formula such that it consists solely of a conjunction (or logical AND) of clauses. Each of these clauses is a disjunction (or logical OR) of literals. Each literal is {x i, x i }, that is, they are all either the value of a variable or its negation. A CNF formula can also be represented as a bipartite graph. One set contains each of the variables, the other set contains an element for each clause. Edges are drawn from variables to each of the clauses they are in. In this case, there are two types of edges, representing positive and negative literals, respectively. x 1 x 2 x 3 x 4 (x 1 x 2 x 4 ) (x 2 x 3 x 4 ) Alternatively, the first set can contain all of the literals rather than the variables. If so, literals of the same variable (the positive and the negative) must have an edge between them (making this technically not bipartite). x 1 x 1 x 2 x 2 x 3 x 3 x 4 x 4 (x 1 x 2 x 4 ) (x 2 x 3 x 4 ) Note that if the bipartite graph between clauses and variables is planar; the problem is called planar CNF (type 1). If the bipartite graph between clauses and literals plus all edges (x i, x i ) forms a planar graph, the problem is called planar CNF (type 2). Both versions are NP-Complete by a reduction from 3-SAT (by uncrossing the edge-crosses). These formulations are very useful in proving the NP-Hardness of problems on planar graphs and geometric planar graphs. 3.1 3-SAT [2] Each clause is an OR of exactly 3 variables, i.e., the degree of each clause is 3. So, for example, (x 1 x 2 x 3 ) (x 1 x 4 x 5 ). 2

3.1.1 3-SAT-5 [5] Each variable occurs in 5 clauses. Other problems of this form are used (and may be expressed differently), e.g., (3,B2)-SAT provides a formula for satisfaction in which every clause has three literals but each literal may appear at most twice. Note that this is different from 3-SAT-5 in that this problem restricts the appearance of literals rather than variables. 3.1.2 Monotone 3-SAT [7] Each clause consists of either 3 positive literals or 3 negative literals. There is no mixing of signs. 4 Polynomial-Time Variants of SAT : All of the above variants of SAT are NP-Complete, but beware of the polynomialtime variants below! They are very similar to the satisfaction problems above with the key difference that they are solvable in polynomial time. 4.1 2-SAT Each clause is the logical OR of two literals The satisfiability of a formula in this form can be determined in polynomial time First, notice that each clause is of the form (x y), but this is equivalent to (x = y) or (y = x) This causes implication chains where we can guess a value for x, forcing assignments for the rest of the values. To solve in polynomial time, first try TRUE as an assignment for x and if the formula is satisfied, you re work is done. If not, try FALSE. If the formula is still not satisfied, then it must not be satisfiable. P Q P = Q T T T T F F F T T F F T BUT, a simple modification to the problem can make it NP-Complete. 3

4.1.1 MAX 2-SAT [6] The MAX 2-SAT problem asks for a satisfying assignment of the variables that maximizes the number of TRUE clauses. As always, we can turn an optimization problem into a decision problem by assigning a bounding variable (e.g., can we make more than K clauses TRUE?). This problem is NP-Complete. 4.2 Horn SAT A Horn SAT formula is one in which each clause has 1 positive literals. For example, a Horn Clause may take the form x y z w. However, thanks to DeMorgan s Law, this is equivalent to (x y z) w. This, in turn, is equivalent to (x y z) = w, leading to an implication change, making this a generalization of 2-SAT and thus solvable in polynomial time. 4.3 Dual Horn SAT In a Dual Horn SAT formula, each clause has 1 negative literal. This can be reduced to Horn SAT by negating everything (both the literals and the final variable assignment), making it solvable in polynomial time. 5 DNF DNF = Disjunctive Normal Form This is essentially the inverse of a CNF formula. A formula in Disjunctive Normal Form is one that consists of a disjunction (or logical OR) of clauses. Each of these clauses is a conjunction (or logical AND) of literals. Again, a literal is either the positive or negative of a variable, i.e., each literal {x i, x i }. To satisfy a DNF formula it is sufficient to satisfy a single clause, which is done as long as there are no contradictions within it, i.e., a clause cannot include both the positive and negative literals of a variable. Thus, it is essentially trivial as we can select any clause and set each of its literals to TRUE. If instead of finding a satisfying assignment to the formula we attempt to make it evaluate to FALSE, then we have transformed the problem into the dual of a CNF SAT problem. 6 Alternative Clauses for 3-SAT There are many other formulations that have come out of the 3-SAT problem. Below are several in which extra restrictions on clauses/literals allow for the formulas to be used in creative ways to show reductions to many problems. Many of these variants were created by Schaefer in his 1978 paper [10]. 4

6.1 1-in-3-SAT [10] In this case, exactly 1 of the 3 literals in a clause is allowed to be TRUE in order for the clause (and therefore, formula) to evaluate to TRUE. 6.1.1 Monotone 1-in-3-SAT This formulation is similar to 1-in-3-SAT, although no negations are allowed, i.e., all literals must be positive. This lack of negations is what is meant by monotone. This formulation was omitted by Schaefer in his original work on 3-SAT. However, he did formulate its dual, the Monotone Not Exactly 1-in-3-SAT. 6.1.2 Monotone Not Exactly 1-in-3-SAT [10] Just as in the formulation above, all of the literals are positive. In this case, rather than allowing for 1 and only 1 literal to be TRUE, the opposite is required. Namely, only 0, 2, or 3 variables in a clause may be TRUE. Otherwise, the clause evaluates to FALSE. However, this leads to the insight that x i = (x j x k ) Dual Horn SAT. Given that the problem reduces to a Dual Horn SAT problem, it can be solved in polynomial time. There is an additional stipulation that x 1 must be assigned the value TRUE. Otherwise, one could simply set the value of everything to FALSE, which causes every implication to evaluate to TRUE, thereby making the problem entirely trivial. 6.2 NAE 3-SAT [10] NAE = Not All Equal In this case, the 3 literals in a clause may not all be assigned the same value. In other words, neither the assignments FFF or TTT for a clauses literals will satisfy that clause (recall that in SAT, only the FFF is forbidden and the TTT will actually satisfy the clause). Because of this exclusion, the problem exhibits a nice symmetry between TRUE and FALSE which can be useful for certain reductions. 6.2.1 Monotone NAE 3-SAT No negations, all literals are positive. Also omitted by Schaefer. Also NP-Complete Of all of the problems listed above, the most important ones to remember are: 3-SAT, 1-in-3-SAT, and NAE 3-SAT. 5

7 Games Some fun games can be proved to be NP-Complete via reduction from 3-SAT, e.g. Push-1 [8]. Image of a Push-1 (Sokoban) game taken from Wikipedia - Sokoban. You may see Erik s class for high-level ideas. The hardness of other games can proven as well, such as: Super Mario Bros. Legend of Zelda Metroid Donkey Kong Country Pokemon 8 Schaefer s Dichotomy Theorem [10] (A Universal Theorem) Schaefer s Dichotomy Theorem provides necessary and sufficient conditions for a set of relations on Boolean variables. These relations have implicit truth tables associated with them (similar to types in C++ or having an oracle which evaluates the relation). What follows is an application of Schaefer s Dichotomy Theorem to the Satisfiability problem. First, we assume the set of relations are provided in CNF (as usual, we can simply translate the set to CNF if necessary), giving us a logical AND of subclauses. Given this, a particular instance of the SAT problem can be solved in polynomial time if either: setting all variables to TRUE or all variables to FALSE satisfies all relations, 6

OR - subclauses are all Horn or all Dual Horn, OR - relations are all 2-CNF (subclause sizes 2, i.e., 2-SAT case), OR - every relation can be expressed as a system of linear equations over Z 2. x 1 x 2 x 3 x 4 = 0or1 where = XOR. This can be solved via Gaussian elimination. If none of the above cases are true, then the SAT instance is NP-Complete! 9 2-Colorable Perfect Matching [10] Given a planar 3-regular graph (i.e., a graph in which the degree of each vertex is 3), 2-color the vertices such that every vertex has exactly 1 same-colored neighbor (the need for planarity and 3-regularity are left as an exercise). This is, in essence, a special case of 2-in-4-SAT. Red Red Red Edge Schaefer proves the following theorem regarding this problem: Theorem 1 There is a reduction from Monotone NAE 3-Sat to 2-Colorable Perfect Matching [10]. 7

Proof: The proof is based on two key gadgets, as illustrated in the image on the right, taken directly from the paper by Schaefer [10]. Figure 1(a) is a gadget used to represents the individual clauses in a 3-SAT formula. A vertex is created for each literal, which are all linked with an edge. Additionally, an intermediate vertex is added in the center to which each variable is linked. In this way, one cannot set each variable to the same color. The second gadget, illustrated in Figure 1(b), is a copy gadget. In this case, the color of n 1 must be equal to n 2. Finally, figure 1(c) illustrates the reduction of A to a 2-Colorable Perfect Matching problem. 10 Cryptarithms/Alphametics [9] A cryptarithm (also known as an alphametic), is a type of puzzle in which one is provided with a simple equation (usually an addition) in which letters or symbols have been substituted for the individual digits. The goal is to discover which substitutions have occurred (or if there even is a feasible substitution). More formally, one is given a formula x + y = z with each number written in base b (which should be some f(n) to be interesting) and encoded with letters by an unknown bijection between {0, 1,..., b 1} and letters. The goal, then, is to recover the bijection. This puzzle was proven to be strongly NP-Complete [3]. The substitutions are not entirely arbitrary, as they must adhere to the following rules: each letter/symbol represents a unique digit often numbers must not start with zero often the solution is unique Example: 9 5 6 7 + 1 0 8 5 1 0 6 5 2 8

Can also be represented as: a b c d + e f g b e f c b h Or: S E N D + M O R E M O N E Y 10.1 Reduction from 3-SAT To reduce from 3-SAT, a long equation is created that represents the clauses, variables, and the boolean nature of the SAT problem. First, the rightmost three columns are set thusly: 0 p 0 0 p 0 1 q 0 Here the letters 0 and 1 are forced to be 0 and 1 for any mod. Next, for each pair of literals v i and v i, the portion below is added to the left side of the formula: Thus, for the variable gadget: 0 d i 0 1 y i 0 c i y i 0 b i y i 0 a i 0 0 e i 0 d i y i 0 c i y i 0 b i y i 0 a i 0 v i 0 e i z i 0 d i z i 0 v i z i 0 b i a i 0 b i = 2a i v i = 2b i + C (where C = carry(y i + y i ) {0, 1}) = 4a i + C C(mod4) d i = 2c i + C e i = d i + 1 + C = 2c i + 1 + 2C v i = d i + e i = 4c i + 1 + 3C Next, for each clause add: 3C + 1 1 C(mod4) 0 u ab 0 v a 0 1 r i 0 g i w i 0 f i 0 0 v c 0 v b 0 h i r i 0 g i w i 0 f i 0 0 t i 0 u ab 0 t i s i 0 h i x i 0 g i 0 9

Thus, for the clause gadget: g i = 2f i h i = 2g i + {0, 1} = 4f i + {0, 1} t i = h i + 1 + {0, 1} = 4f i + 1 + {0, 1, 2} = 4f i + {1, 2, 3} v a + v b + v c = t i {1, 2, 3}(mod4) The reduction holds for NP-Completeness for any mod multiple of 4, but we still need a solution for the puzzle from a satisfying solution, e.g. uniqueness issues. 10.2 Simplified Reduction From 1-in-3-SAT By reducing from 1-in-3-SAT rather than 3-SAT, the proof can be greatly simplified. Variable gadget: just v i, no v i (monotone) Clause gadget: g i = 2f i h i = 2g i = 4f i t i = h i + 1 = 4f i + 1 v a + v b + v c = t i = 4f i + 1 1(mod4) 10.3 3-SAT Solvable = Cryptorithm Solvable distinguish a i, b i, c i, d i,... by value mod 128 (one class for each variable) e.g., below are possible choices for each variable: v i 8(mod128) if TRUE 9(mod128) if FALSE a i {2, 34, 66, 98}(mod128) b i {4, 68} set v i 128 and vi 128 [0, (2n) 3 ] 10

such that we have distinct sums of triples for all clauses It was proven that for any k there is a set of k numbers all between 1... k 3 such that their sum in triples are distinct (we can use powers of 2 but the base would be in O(4 n ) and not good for strong NP- Hardness)[1]. easy proof of polynomial range (based on fusion trees): if < i set by induction, v i must avoid v j + v k v l v m v p < (2n) 5 choices = (2n) 5 suffices = strongly NP-hard The final result would be in base (2n) 3 3.128 = 3072n 3 (see [3] and its revision [4] for all of the details). A Notes It is unknown whether or not the graph isomorphism problem is NP-Complete. Because of this, researchers have defined a new class GI, the set of problems which are polynomial-time reducible to the graph isomorphism problem. If the graph isomorphism problem is solvable in polynomial time, then GI would be equal to P. References [1] SC Bose and S Chowla. Report inst. theory of numbers, 1959. [2] Stephen A. Cook. The complexity of theorem-proving procedures. In Proceedings of the Third Annual ACM Symposium on Theory of Computing, STOC 71, pages 151 158, New York, NY, USA, 1971. ACM. [3] D Eppstein. On the np-completeness of cryptarithms. ACM SIGACT News, 18(3):38 40, 1987. [4] David Eppstein. On the np-completeness of cryptarithms. Computer Science Department, Columbia University, URL: http://www. ics. uci. edu/ eppstein/pubs/epp-sn-87. pdf, pages 06 8, 2000. [5] Uriel Feige. A threshold of ln n for approximating set cover. JOURNAL OF THE ACM, 45:314 318, 1998. [6] M. R. Garey, D. S. Johnson, and L. Stockmeyer. Some simplified NPcomplete graph problems. Theoretical Computer Science, 1(3):237 267, February 1976. 11

[7] E Mark Gold. Complexity of automaton identification from given data. Information and Control, 37(3):302 320, June 1978. [8] Michael Hoffmann. Motion planning amidst movable square blocks: Push-* is np-hard, 2000. [9] Joseph S Madachy. Madachy s Mathematical Recreations. Dover Publications, 1979. [10] Thomas J. Schaefer. The complexity of satisfiability problems. In Proceedings of the Tenth Annual ACM Symposium on Theory of Computing, STOC 78, pages 216 226, New York, NY, USA, 1978. ACM. [11] B.A Trakhtenbrot. A survey of russian approaches to perebor (brute-force searches) algorithms. Annals of the History of Computing, 6(4):384 400, October 1984. 12