SAT Solving As implemented in - DPLL solvers: GRASP, Chaff and

Slides:



Advertisements
Similar presentations
Exploiting SAT solvers in unbounded model checking K. L. McMillan Cadence Berkeley Labs.
Advertisements

UIUC CS 497: Section EA Lecture #2 Reasoning in Artificial Intelligence Professor: Eyal Amir Spring Semester 2004.
Propositional and First Order Reasoning. Terminology Propositional variable: boolean variable (p) Literal: propositional variable or its negation p 
Proofs from SAT Solvers Yeting Ge ACSys NYU Nov
Effective Propositional Reasoning CSE 473 – Autumn 2003.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View SAT.
Heuristics for Efficient SAT Solving As implemented in GRASP, Chaff and GSAT.
1/30 SAT Solver Changki PSWLAB SAT Solver Daniel Kroening, Ofer Strichman.
The Theory of NP-Completeness
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Abstract Answer Set Solver. Todolist Print the rules of Fig 1.
Properties of SLUR Formulae Ondřej Čepek, Petr Kučera, Václav Vlček Charles University in Prague SOFSEM 2012 January 23, 2012.
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
SAT and Model Checking. Bounded Model Checking (BMC) A.I. Planning problems: can we reach a desired state in k steps? Verification of safety properties:
Weizmann Institute Tuning SAT-checkers for Bounded Model-Checking A bounded guided tour Ofer Shtrichman Weizmann Institute & IBM (HRL)
SAT-based Bounded Model Checking
CS21 Decidability and Tractability
Boolean Satisfiability Solvers Wonhong Nam
1 Boolean Satisfiability in Electronic Design Automation (EDA ) By Kunal P. Ganeshpure.
Heuristics for Efficient SAT Solving As implemented in GRASP, Chaff and GSAT.
Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
1 Quantified Formulas Acknowledgement: QBF slides borrowed from S. Malik.
Ofer Strichman, Technion 1 Decision Procedures in First Order Logic Part I - Introduction.
GRASP-an efficient SAT solver Pankaj Chauhan. 6/19/ : GRASP and Chaff2 What is SAT? Given a propositional formula in CNF, find an assignment.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
88- 1 Chapter 8 The Theory of NP-Completeness P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class.
GRASP SAT solver Presented by Constantinos Bartzis Slides borrowed from Pankaj Chauhan J. Marques-Silva and K. Sakallah.
Pruning techniques for the SAT-based Bounded Model-Checking problem Ofer Shtrichman Weizmann Institute of Science & IBM - HRL.
Weizmann Institute Tuning SAT-checkers for Bounded Model-Checking A bounded guided tour Ofer Shtrichman Weizmann Institute & IBM-HRL.
GRASP: A Search Algorithm for Propositional Satisfiability EE878C Homework #2 2002/11/1 KAIST, EECS ICS Lab Lee, Dongsoo.
SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment.
SAT Solver Math Foundations of Computer Science. 2 Boolean Expressions  A Boolean expression is a Boolean function  Any Boolean function can be written.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Logics for Data and Knowledge Representation Propositional Logic: Reasoning Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto.
Boolean Satisfiability and SAT Solvers
Quantified Formulas - Decision Procedure Daniel Kroening, Ofer Strichman Presented by Changki Hong 07 NOV 08.
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
Lecture 22 More NPC problems
Digitaalsüsteemide verifitseerimise kursus1 Formal verification: SAT SAT applied in equivalence checking.
Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011 TexPoint fonts used in EMF. Read the TexPoint manual before you.
1 Agenda Modeling problems in Propositional Logic SAT basics Decision heuristics Non-chronological Backtracking Learning with Conflict Clauses SAT and.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
LDK R Logics for Data and Knowledge Representation Propositional Logic: Reasoning First version by Alessandro Agostini and Fausto Giunchiglia Second version.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
On the Relation between SAT and BDDs for Equivalence Checking Sherief Reda Rolf Drechsler Alex Orailoglu Computer Science & Engineering Dept. University.
Heuristics for Efficient SAT Solving As implemented in GRASP, Chaff and GSAT.
Solving the Logic Satisfiability problem Solving the Logic Satisfiability problem Jesus De Loera.
NPC.
CSC 413/513: Intro to Algorithms
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
Inference in Propositional Logic (and Intro to SAT) CSE 473.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
Knowledge Repn. & Reasoning Lecture #9: Propositional Logic UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2005.
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
Heuristics for Efficient SAT Solving As implemented in GRASP, Chaff and GSAT.
The Theory of NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Hard Problems Introduction to NP
(xy)(yz)(xz)(zy)
Heuristics for Efficient SAT Solving
ECE 667 Synthesis and Verification of Digital Circuits
Decision Procedures An Algorithmic Point of View
The Theory of NP-Completeness
GRASP-an efficient SAT solver
Presentation transcript:

SAT Solving As implemented in - DPLL solvers: GRASP, Chaff and - Stochastic solvers: GSAT.

Why SAT? Fundamental problem from theoretical point of view Cook theorem, 1971: the first NP-complete problem. Numerous applications: Solving any NP problem... Verification: Model Checking, theorem-proving, ... AI: Planning, automated deduction, ... Design and analysis: CAD, VLSI Physics: statistical mechanics (models for spin-glass material)

SAT made some progress…

The SAT competitions

Competition winners Same (single-core) hardware, same benchmarks. (D Competition winners Same (single-core) hardware, same benchmarks. (D. le-berre ©)

Agenda SAT basics Decision heuristics Non-chronological Backtracking Learning with Conflict Clauses SAT and resolution More techniques: decision heuristics, deduction. Stochastic SAT solvers: the GSAT approach

The K-Coloring problem: Formulation of famous problems as SAT: k-Coloring (1/2) The K-Coloring problem: Given an undirected graph G(V,E) and a natural number k, is there an assignment color:

xi,j = node i is assigned the ‘color’ j (1  i  n, 1  j  k) Formulation of famous problems as SAT: k-Coloring (2/2) xi,j = node i is assigned the ‘color’ j (1  i  n, 1  j  k) Constraints: i) At least one color to each node: (x1,1  x1,2  … x1,k  …) ii) At most one color to each node: iii) Coloring constraints: for each i,j such that (i,j) 2 E:

Given a property p: (e.g. “always signal_a = signal_b”) Formulation of famous problems as SAT: Bounded Model Checking Given a property p: (e.g. “always signal_a = signal_b”) Is there a state reachable within k cycles, which satisfies p ? p p p p p . . . s0 s1 s2 sk-1 sk

The reachable states in k steps are captured by: Formulation of famous problems as SAT: Bounded Model Checking The reachable states in k steps are captured by: The property p fails in one of the cycles 1..k:

The safety property p is valid up to cycle k iff W(k) is Formulation of famous problems as SAT: Bounded Model Checking The safety property p is valid up to cycle k iff W(k) is unsatisfiable: p p p p p . . . s0 s1 s2 sk-1 sk

Example: a two bit counter Formulation of famous problems as SAT: Bounded Model Checking Example: a two bit counter Initial state: I: :l Æ :r 00 01 10 11 Transition: R: l’ = (l  r) Æ r’ = :r Property: G (l  r). For k = 2, W(k) is unsatisfiable. For k = 4 W(k) is satisfiable

Bounded Model Checking BMC(M,f,k) k++ k ¸ ? no yes

Agenda SAT basics Decision heuristics Non-chronological Backtracking Learning with Conflict Clauses SAT and resolution More techniques: decision heuristics, deduction. Stochastic SAT solvers: the GSAT approach

SATisfying assignment! What is SAT? Given a propositional formula in CNF, find an assignment to Boolean variables that makes the formula true: 1 = (x2  x3) 2 = (x1  x4) 3 = (x2  x4) A = {x1=0, x2=1, x3=0, x4=1} SATisfying assignment!

CNF-SAT Conjunctive Normal Form: Conjunction of disjunction of literals. Example: (:x1 Ç :x2) Æ (x2 Ç x4 Ç : x1) Æ ... Experience shows that CNF-SAT solving is faster than solving a general propositional formula. Polynomial transformation to CNF due to Tseitin (1970)

Tseitin’s encoding by example Ç  = x1 Ç :(x2 Æ x3) ’ = a0 Æ (a0 $ x1 Ç a1) Æ (a1 $ :a2) Æ (a2 $ x2 Æ x3) It is left to transform ’ to CNF. : a1 Æ a2 x1 x2 x3

Tseitin’s encoding: CNF encodings of gates And gate. e.g., for ai $ x1 Æ x2 add to S (ai Ç :x1 Ç :x2), (:ai Ç x1), (:ai Ç x2) Or gate. e.g. for ai $ x1 Ç x2 add to S (:ai Ç x1 Ç x2), (ai Ç :x1), (ai Ç :x2) Not gate. e.g. for ai $ :x1 add to S (:ai Ç :x1), (ai Ç x1)

Tseitin’s encoding For each Boolean gate instance gi in , add a new auxiliary variable ai, and add to a stack S the CNF clauses encoding ai $ gi. Let a0 denote the auxiliary variable encoding the main operator of . Let Theorem (Tseitin):  is satisfiable iff ’ is satisfiable.

(CNF) SAT basic definitions: literals A literal is a variable or its negation. Var(l) is the variable associated with a literal l. A literal is called negative if it is a negated variable, and positive otherwise.

SAT basic definitions: literals If var(l) is unassigned, then l is unresolved. Otherwise, l is satisfied by an assignment  if (var(l)) = 1 and l is positive, or (var(l)) = 0 and l is negative, and unsatisfied otherwise.

SAT basic definitions: clauses The state of an n-long clause C under a partial assignment  is: Satisfied if at least one of C’s literals is satisfied, Conflicting if all of C’s literals are unsatisfied, Unit if n-1 literals in C are unsatisfied and 1 literal is unresolved, and Unresolved otherwise.

SAT basic definitions: clauses Example

SAT basic definitions: the unit clause rule The unit clause rule: in a unit clause the unresolved literal must be satisfied.

A Basic SAT algorithm  Decide() Deduce() X  Resolve_Conflict() Given  in CNF: (x,y,z),(-x,y),(-y,z),(-x,-y,-z)  X  Decide() Deduce() Resolve_Conflict()

Basic Backtracking Search Organize the search in the form of a decision tree Each node corresponds to a decision Depth of the node in the decision tree is called the decision level Notation: x=v@d x is assigned v 2 {0,1} at decision level d

Backtracking Search in Action 1 = (x2  x3) 2 = (x1  x4) 3 = (x2  x4) x1 x1 = 0@1 x2 x2 = 0@2 x1 = 1@1  x4 = 0@1  x2 = 0@1 Say which step is which.  x3 = 1@1  x3 = 1@2 {(x1,1), (x2,0), (x3,1) , (x4,0)} {(x1,0), (x2,0), (x3,1)} No backtrack in this example, regardless of the decision!

Backtracking Search in Action Add a clause 1 = (x2  x3) 2 = (x1  x4) 3 = (x2  x4) 4 = (x1  x2  x3) x1 x1 = 1@1 x1 = 0@1  x4 = 0@1 {(x1,0), (x2,0), (x3,1)} x2 x2 = 0@2  x3 = 1@2  x2 = 0@1  x3 = 1@1 conflict

A Basic SAT algorithm (DPLL-based) Choose the next variable and value. Return False if all variables are assigned While (true) { if (!Decide()) return (SAT); while (!Deduce()) if (!Resolve_Conflict()) return (UNSAT); } Apply unit clause rule. Return False if reached a conflict Backtrack until no conflict. Return False if impossible

Agenda Modeling problems in Propositional Logic SAT basics Decision heuristics Non-chronological Backtracking Learning with Conflict Clauses SAT and resolution More techniques: decision heuristics, deduction. Stochastic SAT solvers: the GSAT approach

Decision heuristics DLIS (Dynamic Largest Individual Sum) Maintain a counter for each literal: in how many unresolved clauses it appears ? Decide on the literal with the largest counter. Requires O(#literals) queries for each decision.

Decision heuristics Jeroslow-Wang method Compute for every clause w and every literal l: J(l) := Choose a variable l that maximizes J(l). This gives an exponentially higher weight to literals in shorter clauses.

Decision heuristics MOM (Maximum Occurrence of clauses of Minimum size). Let f*(x) be the # of unresolved smallest clauses containing x. Choose x that maximizes: (f*(x) + f*(:x)) * 2k + f*(x) * f*( :x) k is chosen heuristically. The idea: Give preference to satisfying small clauses. Among those, give preference to balanced variables Example: f*(x) = 3, f*(:x) = 3 is better than f*(x) = 1, f*(:x) = 5.

Pause... We will see other (more advanced) decision Heuristics soon. These heuristics are integrated with a mechanism called Learning with Conflict-Clauses, which we will learn next.

Agenda Modeling problems in Propositional Logic SAT basics Decision heuristics Non-chronological Backtracking Learning with Conflict Clauses SAT and resolution More techniques: decision heuristics, deduction. Stochastic SAT solvers: the GSAT approach

Implication graphs and learning Current truth assignment: {x9=0@1 ,x10=0@3, x11=0@3, x12=1@2, x13=1@2} Current decision assignment: {x1=1@6} 1 = (x1  x2) 2 = (x1  x3  x9) 3 = (x2  x3  x4) 4 = (x4  x5  x10) 5 = (x4  x6  x11) 6 = (x5   x6) 7 = (x1  x7  x12) 8 = (x1 x8) 9 = (x7  x8   x13) x10=0@3 x5=1@6 4 1 x2=1@6 3 x4=1@6 6  conflict x1=1@6 2 x3=1@6 5 x6=1@6 x9=0@1 x11=0@3 1. Learn the conflict clause 10 : (:x1 Ç x9 Ç x11 Ç x10) 2. Backtrack to the 2nd largest dec. level in this clause (3) without erasing it

Non-chronological backtracking 3 Decision level Which assignments caused the conflicts ? x9= 0@1 x10= 0@3 x11= 0@3 x1= 1@6 Backtrack to decision level 3 And imply x1 = 0 4 These assignments Are sufficient for Causing a conflict. 5 x1 6  Non-chronological backtracking

Let’s continue… 1 = (x1  x2) 2 = (x1  x3  x9) 3 = (x2  x3  x4) 4 = (x4  x5  x10) 5 = (x4  x6  x11) 6 = (x5   x6) 7 = (x1  x7  x12) 8 = (x1 x8) 9 = (x7  x8   x13) 10 : (: x1 Ç x9 Ç x11 Ç x10) x13=1@2 9 ’ x9=0@1 x8=1@3 8 10 x10=0@3 x1=0@3 10 x7=1@3 7 10 x11=0@3 Note that in this case we did not learn an asserting clause. The asserting clause can be found only if we look at the whole implication graph of level 3. Due to the conflict clause x12=1@2 Learn the conflict clause 11 : (:x13 Ç x9 Ç x10 Ç x11 Ç :x12) Backtrack to the 2nd largest decision level in this clause (2).

Non-chronological backtracking So the rule is: backtrack to the 2nd largest decision level in the conflict clause. Q: What if there is one literal in the clause? A: backtrack to decision level 0 Q: It seems to waste work, since it erases assignments in decision levels higher than dl, unrelated to the conflict. A1: indeed. But allows the SAT solver to redirect itself with the new information. A2: we can also save the last assignment for next time (“phase saving”) If, at a later stage, the solver backtracks to $dl$ again, there will be no decision to erase, which will lead to another conflict and immediate backtracking to a decision level shallower that $dl$. For example, if the asserting clause at level dl+3 asserts x=1@dl, since currently x=0@dl and we do not erase it, there is an immediate conflict, which leads to further conflicts. Alternatively: if we do erase all implications at dl, then the asserting clause will assert x=1, but there is still the conflict clause that at dl asserts x=0, hence a conflict.

Conflict-driven Backtracking x1 = 0 x2 = 0 x5 = 1 x3 = 1 x7 = 1 x9 = 1 x4 = 0 x3 = 1 x6 = 0 ... x5 = 0 x9 = 0

Progress of a SAT solver work invested in refuting x=1 (some of it seems wasted) C x=1 Refutation of x=1 C5 C2 Decision Level C1 C4 BCP C3 Decision Time Conflict

More Conflict Clauses Def: A Conflict Clause is any clause implied by the formula Let L be a set of literals labeling nodes that form a cut in the implication graph, separating the conflict node from the roots. Claim: Çl2L:l is a Conflict Clause. 1. (x10 Ç :x1 Ç x9 Ç x11) x10=0@3 2 1 x5=1@6 4 3 1 x2=1@6 2. (x10 Ç :x4 Ç x11) 6  conflict 3 x1=1@6 x4=1@6 3. (x10 Ç :x2 Ç :x3 Ç x11) 3 2 5  2 5 x3=1@6 x6=1@6 x9=0@1 x11=0@3

Conflict clauses How many clauses should we add ? If not all, then which ones ? Shorter ones ? Check their influence on the backtracking level ? The most “influential” ? The answer requires two definitions: Asserting clauses Unique Implication points (UIP’s)

Asserting clauses Asserting Clause: a Conflict Clause with a single literal at the largest decision level. Backtracking (to the right level) makes it a Unit clause. Modern solvers only consider Asserting Clauses.

Unique Implication Points (UIP’s) Def: A Unique Implication Point (UIP) is an internal node in the Implication Graph that all paths from the decision to the conflict node go through it. x10=0@3 4 1 4 UIP 3 UIP 6 x4=1@6  conflict 6 3 2 5 2 5 x11=0@3

Unique Implication Points (UIP’s) The First-UIP is the closest UIP to the conflict. The method of choice: an asserting clause that includes the first UIP. In this case: (x10 Ç :x4 Ç x11). x10=0@3 4 1 4 UIP 3 UIP 6 x4=1@6  conflict 6 3 2 5 2 5 x11=0@3