An Introduction to SAT Solvers

Similar documents
EECS 219C: Formal Methods Boolean Satisfiability Solving. Sanjit A. Seshia EECS, UC Berkeley

EECS 219C: Computer-Aided Verification Boolean Satisfiability Solving. Sanjit A. Seshia EECS, UC Berkeley

Massively Parallel Seesaw Search for MAX-SAT

Zchaff: A fast SAT solver. Zchaff: A fast SAT solver

algorithms, i.e., they attempt to construct a solution piece by piece and are not able to offer a complete solution until the end. The FM algorithm, l

An Analysis and Comparison of Satisfiability Solving Techniques

Heuristic Backtracking Algorithms for SAT

Normal Forms for Boolean Expressions

Satisfiability. Michail G. Lagoudakis. Department of Computer Science Duke University Durham, NC SATISFIABILITY

Constraint Satisfaction Problems

CS-E3200 Discrete Models and Search

Boolean Functions (Formulas) and Propositional Logic

SAT-Solving: Performance Analysis of Survey Propagation and DPLL

Set 5: Constraint Satisfaction Problems Chapter 6 R&N

ESE535: Electronic Design Automation CNF. Today CNF. 3-SAT Universal. Problem (A+B+/C)*(/B+D)*(C+/A+/E)

4.1 Review - the DPLL procedure

Hybrid solvers for the Boolean Satisfiability problem: an exploration

Satisfiability (SAT) Applications. Extensions/Related Problems. An Aside: Example Proof by Machine. Annual Competitions 12/3/2008

Satisfiability Solvers

Set 5: Constraint Satisfaction Problems

A Pearl on SAT Solving in Prolog (extended abstract)

Set 5: Constraint Satisfaction Problems

SAT/SMT Solvers and Applications

Better test results for the graph coloring and the Pigeonhole Problems using DPLL with k-literal representation

Learning Techniques for Pseudo-Boolean Solving and Optimization

Unrestricted Backtracking Algorithms for Satisfiability

Boolean Satisfiability Solving Part II: DLL-based Solvers. Announcements

Random backtracking in backtrack search algorithms for satisfiability

Set 5: Constraint Satisfaction Problems

Full CNF Encoding: The Counting Constraints Case

Practical SAT Solving

Example: Map coloring

DM841 DISCRETE OPTIMIZATION. Part 2 Heuristics. Satisfiability. Marco Chiarandini

CS-E3220 Declarative Programming

Adding a New Conflict Based Branching Heuristic in two Evolved DPLL SAT Solvers

Symbolic Methods. The finite-state case. Martin Fränzle. Carl von Ossietzky Universität FK II, Dpt. Informatik Abt.

Chapter 2 PRELIMINARIES

Chaff: Engineering an Efficient SAT Solver

Finite Model Generation for Isabelle/HOL Using a SAT Solver

Foundations of AI. 8. Satisfiability and Model Construction. Davis-Putnam, Phase Transitions, GSAT and GWSAT. Wolfram Burgard & Bernhard Nebel

Chapter 27. Other Approaches to Reasoning and Representation

Deductive Methods, Bounded Model Checking

QingTing: A Fast SAT Solver Using Local Search and E cient Unit Propagation

Dipartimento di Elettronica Informazione e Bioingegneria. Cognitive Robotics. SATplan. Act1. Pre1. Fact. G. Gini Act2

Combinational Equivalence Checking

CSc Parallel Scientific Computing, 2017

On Resolution Proofs for Combinational Equivalence Checking

Validating SAT Solvers Using an Independent Resolution-Based Checker: Practical Implementations and Other Applications

arxiv: v2 [cs.cc] 29 Mar 2010

Boolean Representations and Combinatorial Equivalence

Stochastic greedy local search Chapter 7

A Stochastic Non-CNF SAT Solver

SAT Solver. CS 680 Formal Methods Jeremy Johnson

SAT Solver Heuristics

Planning as Search. Progression. Partial-Order causal link: UCPOP. Node. World State. Partial Plans World States. Regress Action.

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

Stochastic Local Search for SMT

CS227: Assignment 1 Report

Master s Project Proposal: Enhancements of SAT-Solvers for Some Combinatorial NAE-SAT Problems

The NP-Completeness of Some Edge-Partition Problems

Artificial Intelligence

Solving Satisfiability with a Novel CPU/GPU Hybrid Solution

Simple mechanisms for escaping from local optima:

Automated Theorem Proving: DPLL and Simplex

Solving 3-SAT. Radboud University Nijmegen. Bachelor Thesis. Supervisors: Henk Barendregt Alexandra Silva. Author: Peter Maandag s

PROPOSITIONAL LOGIC (2)

N-Queens problem. Administrative. Local Search

Boolean Satisfiability: From Theoretical Hardness to Practical Success. Sharad Malik Princeton University

Study of efficient techniques for implementing a Pseudo-Boolean solver based on cutting planes

Kalev Kask and Rina Dechter. Department of Information and Computer Science. University of California, Irvine, CA

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

Exact Max-SAT solvers for over-constrained problems

Speeding Up the ESG Algorithm

Solving Non-clausal Formulas with DPLL search

ON SOLVING OPTIMIZATION PROBLEMS USING BOOLEAN SATISFIABILITY

Administrative. Local Search!

On the Relation between SAT and BDDs for Equivalence Checking

Notes on CSP. Will Guaraldi, et al. version 1.7 4/18/2007

Generalizations of Watched Literals for Backtracking Search

Evidence for Invariants in Local Search

SAT and Termination. Nao Hirokawa. Japan Advanced Institute of Science and Technology. SAT and Termination 1/41

CafeSat: A Modern SAT Solver for Scala

On Resolution Proofs for Combinational Equivalence

Module 4. Constraint satisfaction problems. Version 2 CSE IIT, Kharagpur

CMU-Q Lecture 8: Optimization I: Optimization for CSP Local Search. Teacher: Gianni A. Di Caro

SAT Solver and its Application to Combinatorial Problems

Improved Exact Solver for the Weighted Max-SAT Problem

BITCOIN MINING IN A SAT FRAMEWORK

Problem-Sensitive Restart Heuristics for the DPLL Procedure

Parallelizing SAT Solver With specific application on solving Sudoku Puzzles

EMPIRICAL ANALYSIS OF LOCAL SEARCH ALGORITHMS AND PROBLEM DIFFICULTY IN SATISFIABILITY. Dave Tae Shik Yoon

A Virtual Laboratory for Study of Algorithms

Finding Rough Set Reducts with SAT

Watching Clauses in Quantified Boolean Formulae

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

The Barcelogic SMT Solver

An Experimental Evaluation of Conflict Diagnosis and Recursive Learning in Boolean Satisfiability

The implementation is written in Python, instructions on how to run it are given in the last section.

Random Instances of W[2]-complete Problems: thresholds, complexity, and algorithms

CSC2542 SAT-Based Planning. Sheila McIlraith Department of Computer Science University of Toronto Summer 2014

Transcription:

An Introduction to SAT Solvers Knowles Atchison, Jr. Fall 2012 Johns Hopkins University Computational Complexity Research Paper December 11, 2012 Abstract As the first known example of an NP Complete problem, the Boolean Satisfiability Problem (SAT) has no known algorithms that efficiently solve all of its instances. Boolean Satisfiability is probably the most studied of combinatorial optimization/search problems. Significant effort has been devoted to trying to provide practical solutions to this problem for problem instances encountered in a range of applications in Electronic Design Automation and Artificial Intelligence [Moskewicz et al. 2001]. There are SAT solvers that can solve certain subsets of the problem domain efficiently enough for application in the real world. This paper will serve as a technical introduction to the world of SAT solving and the various algorithms that comprise the base of modern research. 1

1 Introduction In complexity theory, SAT is a decision problem whose instance is a Boolean expression written in conjunctive normal form: ( x x ) ( x x ) 1 2 1 2 Is the equation given satisfiable? Given a series of truth values for all variables, does it equate to true? x x ( x x ) ( x x ) 1 2 1 2 1 2 0 0 1 0 1 1 1 0 1 1 1 1 In this trivial example, the equation has multiple satisfying truth assignments. For the decision problem, only one need exist for it to be satisfiable. In his 1971 paper, The Complexity of Theorem Proving Procedures, Stephen Cook proved SAT to be NP-Complete. Every problem in NP can be reduced to SAT in polynomial time by a deterministic Turing machine [Cook 1971]. Thus, if there exists a deterministic polynomial time algorithm to solve SAT, then there is one to solve all problems in NP. Richard Karp followed up on Cook s work with a list of 21 problems that are NP-Complete due to reduction from SAT. 2

Figure 1: Complete Problems [Karp 1972] The significance of the previous sentence cannot be understated. If the SAT domino falls, then the repercussions for complexity theory, not to mention areas like cryptography, will be wide spread and impacting. 1.1 Contributions The goal of this paper is to be a technical introduction to the various implementations of SAT solvers in practice today. The underlying algorithms will also be discussed. Lastly, some future areas of research will be touched upon. 2 SAT Solver Categories The current state of the art in SAT Solvers divides roughly into two categories: complete and incomplete. Complete: Always finds an assignment if the equation is satisfiable Incomplete: It may not find an assignment if the equation is satisfiable [rjlipton 2009] 3

2.1 Complete Complete solvers use the Davis Putnam Logemann Loveland (DPLL) algorithm as a base and then throw additional functionality on top such as advanced forward reasoning, efficient low level data structures, clause learning, watched literals, optimized conflict analysis, nonchronological backtracking, and decision heuristics [Oe et al. 2012]. Algorithm 1 DPLL Input : CNF formulaφ Output : Satisfiable?( yes / no) DPLL( φ) if φ == set of consistent literals(satisfiable): return true if φ contains an empty clause/is inconsistent: return false φ = unit-propagate( φ) φ = pure-literal( φ) l = choose-literal( φ) return DPLL( φ l) or DPLL( φ l) unit-propagate( φ) if φ contains a clause with a single literal l : remove clauses with l delete l from clauses that contain it pure-literal( φ) if some literall has only one polarity( l l) assign l to true assign l to false 4

The basic backtracking algorithm runs by choosing a literal, giving it a truth assignment, simplifying the formula and then recursively checking if the simplified formula is satisfiable. If the new formula is satisfiable, the original was as well. If not, the opposite truth value is attempted. If the formula can be simplified by means of unit propagation or pure literals, the formula is modified and the cycle begins again. Note that some implementations will return true on a partial satisfying result. In this case, not every literal s value is found as long as the formula is still satisfiable given a subset assignment, whereas unsatisfiability of the complete formula can only be found after an exhaustive search. A few examples: ( x x x ) ( x x x ) 1 2 3 1 2 3 Initial formula has no single variable literals, unit propagation cannot be done. x 1 is a pure literal however and thus every instance of it can be replaced with true. The formula is then (true and true) and the partial satisfying assignment returns true. ( x x x ) ( x x x ) 1 2 3 1 2 3 Figure 2: Example DPLL traversal 5

Starting with a choice for x 1 (it is not a pure literal this time), we then satisfy one clause, which is removed. Then the choice for x 2 is made knowing it would satisfy the remaining clause and thus the entire formula. The choice for x3 at this point is irrelevant; the partial assignment satisfies the original formula. 2.1.1 Chaff Algorithm In practice, most SAT Solvers spend the vast majority of their time doing Boolean Constraint Propagation (BCP). BCP identifies variable assignments required by the current state to satisfy the formula. For example, if there was a clause ( x1 0), x 1 (an unassigned literal) would have to be true in order for the formula to be satisfied. Chaff builds upon the backtracking capabilities of DPLL above (specifically DP, but the distinction and evolution of DP to DPLL is out of the scope of this paper). Chaff s success/speedup is the result of specifically engineering key steps of a SAT solver for efficiency: a highly optimized BCP algorithm a decision strategy highly optimized for speed, as well as focused on recently added clauses Algorithm 2 Chaff while (true) { if (!decide()) // if no unassigned vars return(satisifiable); while (!bcp()) { if (!resolveconflict()) return(not satisfiable); } } bool resolveconflict() { d = most recent decision not tried both ways ; if (d == NULL) // no such d was found return false; flip the value of d; mark d as tried both ways; 6

} undo any invalidated implications; return true; The latest Chaff [zchaff] source code can be found at http://www.princeton.edu/~chaff/zchaff.html. In order to optimize BCP, Chaff watches literals. Until a clause has two literals left (n-2 decisions, where n is the number of literals in a clause), there is no need to check in with it. When one of the watched literals in assigned zero, the clause is visited. One of two conditions must hold: (1) The clause is not implied, and thus at least 2 literals are not assigned to zero, including the other currently watched literal. This means at least one non-watched literal is not assigned to zero. We choose this literal to replace the one just assigned to zero. Thus, we maintain the property that the two watched literals are not assigned to 0. (2) The clause is implied. Follow the procedure for visiting an implied clause One should take note that the implied variable must always be the other watched literal, since, by definition, the clause only has one literal not assigned to zero, and one of the two watched literals is now assigned to zero [Moskewicz et al. 2001]. The naïve implementation of which variable to assign next is randomly selected. Other techniques exist such as seeing which variable appears most often in the remaining clauses. In order to improve on existing processes, Chaff employs a technique called Variable State Independent Decaying Sum(VSIDS): (1) Each variable in each polarity has a counter, initialized to 0. (2) When a clause is added to the database, the counter associated with each literal in the clause is incremented. (3) The (unassigned) variable and polarity with the highest counter is chosen at each decision. (4) Ties are broken randomly by default, although this is configurable (5) Periodically, all the counters are divided by a constant [Moskewicz et al. 2001]. 7

Finally, Chaff uses restarts. In a backtracking algorithm, one might restart when stuck or when external factors call for it. Here, Chaff restarts voluntarily and uses some of the knowledge it gained in the previous pass. State is cleared, but clauses remained stored in the database for reference. This is to allow the chance for a change in early decisions. 2.2 Incomplete 2009]. Incomplete solvers are generally a permutation of the WalkSAT algorithm [rjlipton Algorithm 3 WalkSAT WalkSAT ( φ) arbitrary truth assignment r if r satisfiesφ return true whileφ contains an unsatisfied clause and #steps < MAXSTEPS C = first unsatisfied clause flip random literalin C, update r if r( φ) == 1 return true return false The greedy variant of the above is similar; it flips a variable in r that results in the max satisfied clauses rather then localizing the choice to an unsatisfied clause. Algorithm 4 GSAT GreedySAT ( φ) arbitrary truth assignment r if r satisfiesφ return true whileφ contains an unsatisfied clause and #steps < MAXSTEPS flip random literalin r which results in max satisfied clauses if r( φ) == 1 return true return false 8

GSAT has been shown to be substantially faster than the DP/DPLL method on certain data sets including randomly generated formulas and SAT encodings of graph coloring problems [Selman et al. 1993]. WalkSAT and GSAT also outperform one another depending on problem class. The issue with the greedy function is local minima. The algorithms reach a plateau where all choices result in similar (or same) number of unsatisfied clauses. Various methods have been added to attempt to resolve this issue including random walk and simulated annealing. Algorithm 5 Random Walk With probability p, pick a variable occurring in some unsatisfied clause and flip its truth assignment. With probability p-1, follow GSAT, i.e. make the best possible local move [Selman et al. 1993]. Algorithm 5 combines the walk of algorithm 3 with the local greedy heuristic of GSAT. The probabilistic choice of which literal to flip allows the algorithm to make an uphill move out of the local minima. Algorithm 6 Simulated Annealing repeatedly pick a random variable calculate δ :the change in the # of unsatisfied clauses when above variable is flipped if δ 0 //downhill/sideways move make the flip else δ / T flip with probability e, wheret is temperature In the above algorithm, temperature can be constant or some decreasing factor. Given a finite cooling schedule, a global optimum is not guaranteed, random starts and possible restarts may be required. 9

In general, a mixed walk strategy has the best results dependent on the problem set. Local search with the appropriate random strategy is a powerful method for solving computationally challenging SAT problems [Selman et al. 1993]. 3 Future Research and Conclusions SAT solvers seem to be following the general trend on computer hardware: smaller and faster. Illustrated in this paper, both complete and incomplete categories have a base algorithm that comprises the core with various accruements placed on top to make the results faster. This does not appear to be changing any time soon. The engine(s) of SAT solvers is forecasted to remain relatively stable, given the latest and greatest developments are approaching their 20 th anniversary. As seen in this paper, the successfulness of a given approach to a SAT instance varies greatly on the data being processed. WalkSAT is well suited for automation planning/artificial intelligence problems, whereas Chaff is faster on Electronic Design Automation items. It speaks to the diversity of the problem domain where all the data can be represented in such a manner that a SAT solver can operate on it, but with such varying results. Knowing thy data is as much a solution to the problem as the algorithm itself. 10

4 References Published Books and Papers COOK, S.A. 1971. The complexity of theorem-proving procedures. In Proceedings of the third annual ACM symposium on Theory of computing, Shaker Heights, Ohio, United States, Anonymous ACM, New York, NY, USA, 151-158. KARP, R.M. 1972. Reducibility Among Combinatorial Problems. In Raymond E. Miller and James W. Thatcher (editors). Complexity of Computer Computations. New York: Plenum. 85 103. MOSKEWICZ, M., MADIGAN, C., ZHAO, Y., ZHANG, L., MALIK, S. 2001. Chaff: Engineering an efficient sat solver. Proceedings - Design Automation Conference, ISSU(PAGE), 530-535. OE, D., STUMP, A., OLIVER, C. AND CLANCY, K. 2012. versat: A Verified Modern SAT Solver. In Verification, Model Checking, and Abstract Interpretation, V. KUNCAK AND A. RYBALCHENKO, Eds. Springer Berlin Heidelberg, 363-378. SELMAN, B., KAUTZ, H.A., COHEN, B. 1993. Local Search Strategies for Satisfiability Testing. Second DIMACS Challenge on Cliques, Coloring, and Satisfiability, David S. Johnson and Michael A. Trick, (editors). DIMACS Series in Discrete Mathematics and Theoretical Computer Science, vol. 26, AMS, 1996. WWW References SAT Solvers: Is SAT Hard or Easy? http://rjlipton.wordpress.com/2009/07/13/sat-solvers-is-sat-hard-oreasy/ 11