Algorithms for the Satisfiability Problem
Total Page:16
File Type:pdf, Size:1020Kb
Algorithms for the Satisfiability Problem John Franco University of Cincinnati School of Computing Sciences and Informatics Cincinnati, OH [email protected] and Sean Weaver U.S. Department of Defense Ft. George G. Meade, Maryland [email protected] Contents 1 Logic 1 2 Representations and Structures 7 2.1 (0, ±1)Matrix .......................... 8 2.2 Binary Decision Diagrams . 9 2.3 ImplicationGraph ........................ 10 2.4 Propositional Connection Graph . 11 2.5 Variable-Clause Matching Graph . 11 2.6 FormulaDigraph ......................... 11 2.7 SatisfiabilityIndex . 12 2.8 And/InverterGraphs. 13 3 Applications 14 3.1 Consistency Analysis in Scenario Projects . 14 3.2 TestingofVLSICircuits . 17 3.3 Diagnosis of Circuit Faults . 19 3.4 Functional Verification of Hardware Design . 21 3.5 BoundedModelChecking . 25 3.6 Combinational Equivalence Checking . 26 3.7 Transformations to Satisfiability . 27 3.8 Boolean Data Mining . 32 4 General Algorithms 34 4.1 Efficient Transformation to CNF Formulas . 34 4.2 Resolution............................. 41 4.3 ExtendedResolution . 44 4.4 Davis-Putnam Resolution . 44 4.5 Davis-Putnam Loveland Logemann Resolution . 45 4.6 Conflict-Driven Clause Learning . 50 4.6.1 ConflictAnalysis . 50 i 4.6.2 Conflict Clause Memory Management . 51 4.6.3 LazyStructures. 52 4.6.4 CDCLHeuristics . 53 4.6.5 Restarts.......................... 53 4.7 Satisfiability Modulo Theories . 54 4.8 StochasticLocalSearch . 60 4.8.1 Walksat .......................... 60 4.8.2 Novelty Family . 62 4.8.3 Discrete Lagrangian Methods . 63 4.9 Binary Decision Diagrams . 64 4.9.1 Existential Quantification . 67 4.9.2 Reductions and Inferences . 68 4.9.3 Restrict .......................... 71 4.9.4 Generalized Co-factor . 73 4.9.5 Strengthen ........................ 75 4.10 Decompositions .. .. .. .. .. .. .. .. 79 4.10.1 Monotone Decomposition . 79 4.10.2 Autarkies and Safe Assignments . 83 4.11 Branch-and-bound . 85 4.12 AlgebraicMethods . 88 4.12.1 Gr¨obner Bases Applied to SAT . 88 4.12.2 Integer Programming . 94 5 Algorithms for Easy Classes of CNF Formulas 95 5.1 2-SAT ............................... 95 5.2 HornFormulas .......................... 96 5.3 RenamableHornFormulas. 99 5.4 Linear Programming Relaxations . 99 5.5 q-HornFormulas ......................... 103 5.6 Matched Formulas . 105 5.7 Generalized Matched Formulas . 106 ii 5.8 Nested and Extended Nested Satisfiability . 106 5.9 Linear Autark Formulas . 112 5.10 Minimally Unsatisfiable Formulas . 116 5.11 Bounded Resolvent Length Resolution . 123 5.12 ComparisonofClasses . 124 5.13 Probabilistic comparison of incomparable classes. 126 6 Other Topics 129 7 Acknowledgment 130 A Glossary 141 iii Abstract The Satisfiability problem (SAT) has gained considerable attention over the past decade for two reasons. First, the performance of compet- itive SAT solvers has improved enormously due to the implementation of new algorithmic concepts. Second, so many real-world problems that are not naturally expressed as instances of SAT can be transformed to SAT instances and solved relatively efficiently using one of the ever improving SAT solvers or solvers based on SAT. This chapter attempts to clarify these successes by presenting the important advances in SAT algorithm design as well as the classic implementations of SAT solvers. Some applications to which SAT solvers have been successfully applied are also presented. The first section of the chapter presents some logic background and notation that will be necessary to understand and express the algo- rithms presented. The second section presents several representations for SAT instances in preparation for discussing the wide variety of SAT solver implementations that have been tried. The third section presents some applications of SAT. The final two sections presents algorithms for SAT, including search and heuristic algorithms plus systems that use SAT to manage the logic of complex computations. 1 Logic An instance of Satisfiability is a propositional logic expression in Conjunctive Normal Form (CNF), the meaning of which is described in the next few paragraphs. The most elementary object comprising a CNF expression is the Boolean variable, shortened to variable in the context of this chapter. A variable takes one of two values from the set {0, 1}. A variable v may be negated in which case it is denoted ¬v. The value of ¬v is opposite that of v. A literal is either a variable or a negated variable. The term positive literal is used to refer to a variable and the term negative literal is used to refer to a negated variable. The polarity of a literal is positive or negative accordingly. The building blocks of propositional expressions are binary Boolean op- erators. A binary Boolean operator is a function Ob : {0, 1}×{0, 1} → {0, 1}. Often, such functions are presented in tabular form, called truth tables, as illustrated in Figure 10. There are 16 possible binary operators and the most common (and useful) are ∨ (or), ∧ (and), → (implies), ↔ (equivalent), and ⊕ (xor, alternatively exclusive-or). Mappings defining the common opera- tors are shown in Figure 1. The only interesting unary Boolean operator, denoted ¬ (negation), is a mapping from 0 to 1 and 1 to 0. If ¬l is a literal then ¬¬l is the same as l. A formula is a propositional expression consisting of literals, parenthe- ses, and operators which has some semantic content and whose syntax is described recursively as follows: 1. Any single variable is a formula. 2. If ψ is a formula, then so is ¬ψ. 1 Operator Symbol Mapping Or ∨ {00 → 0; 10, 01, 11 → 1} And ∧ {00, 01, 10 → 0; 11 → 1} Implies → {01 → 0; 00, 10, 11 → 1} Equivalent ↔ {01, 10 → 0; 00, 11 → 1} XOR ⊕ {00, 11 → 0; 01, 10 → 1} Table 1: The most common binary Boolean operators and their mappings Operator Symbol Mapping Or ∨ {00 → 0; 10, 01, 11, 1⊥, ⊥1 → 1; 0⊥, ⊥0, ⊥⊥ → ⊥} And ∧ {00, 01, 10 → 0; 11 → 1; ?⊥, ⊥?, ⊥⊥ → ⊥} Implies → {10 → 0; 00, 01, 11, 0⊥ → 1; 1⊥, ⊥? → ⊥} Equivalent ↔ {01, 10 → 0; 00, 11 → 1; ?⊥, ⊥?, ⊥⊥ → ⊥} XOR ⊕ {00, 11 → 0; 01, 10 → 1; ?⊥, ⊥?, ⊥⊥ → ⊥} Negate ¬ {0 → 1; 1 → 0, ⊥ → ⊥} Table 2: Boolean operator mappings with ⊥. Symbol ? means 1 or 0. 3. If ψ1 and ψ2 are both formulas and O is a Boolean binary operator, then (ψ1 O ψ2) is a formula, ψ1 is called the left operand of O, and ψ2 is called the right operand of O. Formulas can be simplified by removing some or all parentheses. Parentheses around nestings involving the same associative operators such as ∨, ∧, and ↔ may be removed. For example, (ψ1 ∨ (ψ2 ∨ ψ3)), ((ψ1 ∨ ψ2) ∨ ψ3), and (ψ1 ∨ ψ2 ∨ ψ3) are considered to be the same formula. In the case of non- associative operators such as →, parentheses may be removed but right associativity is then assumed. The following is an example of a simplified formula: (¬v0 ∨ v1 ∨¬v7) ∧ (¬v2 ∨ v3) ∧ (v0 ∨¬v6 ∨¬v7) ∧ (¬v4 ∨ v5 ∨ v9) A useful parameter associated with a formula is depth. The depth of a formula is determined as follows: 1. The depth of a formula consisting of a single variable is 0. 2. The depth of a formula ¬ψ is the depth of ψ plus 1. 3. The depth of a formula (ψ1 O ψ2) is the maximum of the depth of ψ1 and the depth of ψ2 plus 1. A truth assignment or assignment is a set of variables all of whom have value 1. If M is an assignment and V is a set of variables then, if v ∈ V and v∈ / M, v has value 0. Any assignment of values to the variables of a formula induces a value on the formula. A formula is evaluated from innermost ¬ or parentheses out using mappings associated with the Boolean operators that are found in Table 1. 2 Many algorithms that will be considered later iteratively build assign- ments and it will be necessary to distinguish variables that have been as- signed a value from those that have not been. In such cases, a variable will be allowed to hold a third value, denoted ⊥, which means the variable is unassigned. This requires that the evaluation of operations be augmented to account for ⊥ as shown in Table 2. If M is an assignment of values to a set of variables where at least one variable has value ⊥ then M is said to be a partial assignment. Formulas that are dealt with in this chapter often have many components of the same type which are called clauses. Two common special types of clauses are disjunctive and conjunctive clauses. A disjunctive clause is a formula consisting only of literals and the operator ∨. If all the literals of a clause are negative (positive) then the clause is called a negative clause (respectively, positive clause). In this chapter disjunctive clauses will usually be represented as sets of literals. When it is understood that an object is a disjunctive clause, it will be referred to simply as a clause. The following two lines show the same formula of four clauses expressed, above, in conventional logic notation and, below, as a set of sets of literals. (¬v0 ∨ v1 ∨¬v7) ∧ (¬v2 ∨ v3) ∧ (v0 ∨¬v6 ∨¬v7) ∧ (¬v4 ∨ v5 ∨ v9) {{¬v0, v1, ¬v7}, {¬v2, v3}, {v0, ¬v6, ¬v7}, {¬v4, v5, v9}} A conjunctive clause is a formula consisting only of literals and the operator ∧. A conjunctive clause will also usually be represented as a set of literals and called a clause when it is unambiguous to do so. The number of literals in any clause is referred to as the width of the clause. Often, formulas are expressed in some normal form. Four of the most frequently arising forms are defined as follows. A CNF formula is a formula consisting of a conjunction of two or more disjunctive clauses. Given CNF formula ψ and Lψ, the set of all literals in ψ, a literal l is said to be a pure literal in ψ if l ∈ Lψ but ¬l∈ / Lψ.