Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber 15-414 Aug 31, 2011 TexPoint fonts used in EMF. Read the TexPoint manual before you.

Slides:



Advertisements
Similar presentations
Exploiting SAT solvers in unbounded model checking
Advertisements

Automated Theorem Proving
Presented by Monissa Mohan 1.  A highly optimized BCP algorithm  Two watched literals  Fast Backtracking  Efficient Decision Heuristic  Focused on.
Introduction to MiniSat v1.14 Presented by Yunho Kim Provable Software Lab, KAIST.
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
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
Properties of SLUR Formulae Ondřej Čepek, Petr Kučera, Václav Vlček Charles University in Prague SOFSEM 2012 January 23, 2012.
ECE 667 Synthesis & Verification - SAT 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Boolean SAT CNF Representation Slides adopted (with.
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
1 Quantified Formulas Acknowledgement: QBF slides borrowed from S. Malik.
GRASP-an efficient SAT solver Pankaj Chauhan. 6/19/ : GRASP and Chaff2 What is SAT? Given a propositional formula in CNF, find an assignment.
Efficient SAT Solving for Non- clausal Formulas using DPLL, Graphs, and Watched-cuts Himanshu Jain Edmund M. Clarke.
1 Satisfiability Checking of Non-clausal Formulas using General Matings Himanshu Jain Constantinos Bartzis Edmund Clarke Carnegie Mellon University.
GRASP SAT solver Presented by Constantinos Bartzis Slides borrowed from Pankaj Chauhan J. Marques-Silva and K. Sakallah.
Search in the semantic domain. Some definitions atomic formula: smallest formula possible (no sub- formulas) literal: atomic formula or negation of an.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
SAT Algorithms in EDA Applications Mukul R. Prasad Dept. of Electrical Engineering & Computer Sciences University of California-Berkeley EE219B Seminar.
ECI 2007: Specification and Verification of Object- Oriented Programs Lecture 4.
ENGG3190 Logic Synthesis “Boolean Satisfiability” Winter 2014 S. Areibi School of Engineering University of Guelph.
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.
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic.
SAT Solver Math Foundations of Computer Science. 2 Boolean Expressions  A Boolean expression is a Boolean function  Any Boolean function can be written.
Satisfiability Introduction to Artificial Intelligence COS302 Michael L. Littman Fall 2001.
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
Decision Procedures - An algorithmic point of view
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.
INTRODUCTION TO ARTIFICIAL INTELLIGENCE COS302 MICHAEL L. LITTMAN FALL 2001 Satisfiability.
1 Agenda Modeling problems in Propositional Logic SAT basics Decision heuristics Non-chronological Backtracking Learning with Conflict Clauses SAT and.
Logical Agents Chapter 7. Knowledge bases Knowledge base (KB): set of sentences in a formal language Inference: deriving new sentences from the KB. E.g.:
LDK R Logics for Data and Knowledge Representation Propositional Logic: Reasoning First version by Alessandro Agostini and Fausto Giunchiglia Second version.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
Nikolaj Bjørner Microsoft Research DTU Winter course January 2 nd 2012 Organized by Flemming Nielson & Hanne Riis Nielson.
SAT Solver Heuristics. SAT-solver History Started with David-Putnam-Logemann-Loveland (DPLL) (1962) –Able to solve variable problems Satz (Chu Min.
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.
Satisfiability and SAT Solvers CS 270 Math Foundations of CS Jeremy Johnson.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
SAT Solving As implemented in - DPLL solvers: GRASP, Chaff and
1 Boolean Satisfiability (SAT) Class Presentation By Girish Paladugu.
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
Knowledge Repn. & Reasoning Lecture #9: Propositional Logic UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2005.
© R.A. Rutenbar 2009 Slide 1 Carnegie Mellon (Lec 06) Boolean Satisfiability: SAT Solvers (Pt 1) What you know  Representation and manipulation via BDDs,
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
Heuristics for Efficient SAT Solving As implemented in GRASP, Chaff and GSAT.
Inference and search for the propositional satisfiability problem
Introduction to Software Verification
Logical Inference: Through Proof to Truth
Logic Synthesis CNF Satisfiability.
Heuristics for Efficient SAT Solving
Elementary Metamathematics
Introduction to the Boolean Satisfiability Problem
ECE 667 Synthesis and Verification of Digital Circuits
Artificial Intelligence: Agents and Propositional Logic.
Decision Procedures An Algorithmic Point of View
Introduction to the Boolean Satisfiability Problem
Solving Non-clausal Formulas with DPLL search
GRASP-an efficient SAT solver
Presentation transcript:

Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA A A A A A A A

2 Why study SAT solvers? Many problems reduce to SAT. Formal verification CAD, VLSI Optimization AI, planning, automated deduction Modern SAT solvers are often fast. Other solvers (QBF, SMT, etc.) borrow techniques from SAT solvers. SAT solvers and related solvers are still active areas of research.

3 Negation-Normal Form (NNF) A formula is in negation-normal form iff: all negations are directly in front of variables, and the only logical connectives are: “  ”, “  ”, “  ”. A literal is a variable or its negation. Convert to NNF by pushing negations inward: (De Morgan’s Laws)

4 Disjunctive Normal Form (DNF) Recall: A literal is a variable or its negation. A formula is in DNF iff: it is a disjunction of conjunctions of literals. Every formula in DNF is also in NNF. A simple (but inefficient) way convert to DNF: Make a truth table for the formula φ. Each row where φ is true corresponds to a conjunct.

5 Conjunctive Normal Form (CNF) A formula is in CNF iff: it is a conjunction of disjunctions of literals. Modern SAT solvers use CNF. Any formula can be converted to CNF. Equivalent CNF can be exponentially larger. Equi-satisfiable CNF (Tseitin encoding): Only linearly larger than original formula.

6 Tseitin transformation to CNF Introduce new variables to represent subformulas. E.g, to convert (A  (B  C)): Replace (B  C) with a new variable g 1. Add clauses to equate g 1 with (B  C). Gives value of g 1 for all 4 possible assignments to {B, C}.

7 Tseitin transformation to CNF Convert (A  (B  C)) to CNF by introducing new variable g 1 for (B  C).

8 SAT Solvers -- Representation A CNF formula is represented by a set of clauses. Empty set represents a true formula. A clause is represented by a set of literals Empty set represents a false clause. A variable is represented by a positive integer. The logical negation of a variable is represented by the arithmetic negation of its number. E.g., ((x1  x2)  (  x1   x2)) is represented by {{1, 2}, {-1, -2}}

9 Naïve Approach SAT problem: Given a boolean formula φ, does there exist an assignment that satisfies φ? Naïve approach: Search all assignments! n variables  2 ^ n possible assignments Explosion! SAT is NP-complete: Worst case is likely O(2 ^ n ), unless P=NP. But for many cases that arise in practice, we can do much better.

10 Unit Propagation Davis-Putnam-Logemann-Loveland (DPLL) Unit Clause: Clause with exactly one literal. Algorithm: If a clause has exactly one literal, then assign it true. Repeat until there are no more unit clauses. Example: ((x1  x2)  (  x1   x2)  (x1)) (( T  x2)  ( F   x2)  (T)) (( T )  (  x2 )) T

11 Helper function def AssignLit (ClauseList, lit): ClauseList = deepcopy(ClauseList) for clause in copy(ClauseList): if lit in clause: ClauseList.remove(clause) if -lit in clause: clause.remove(-lit) return ClauseList >>> AssignLit([[1, 2, -3], [-1, -2, 4], [3, 4]], 1) [[-2, 4], [3, 4]] >>> AssignLit([[1, 2, -3], [-1, -2, 4], [3, 4]], -1) [[2, -3], [3, 4]] Assumption: No clause contains both a variable and its negation. from copy import copy, deepcopy

12 Naïve Solver def AssignLit (ClauseList, lit): ClauseList = deepcopy(ClauseList) for clause in copy(ClauseList): if lit in clause: ClauseList.remove(clause) if -lit in clause: clause.remove(-lit) return ClauseList def IsSatisfiable (ClauseList): # Test if no unsatisfied clauses remain if len(ClauseList) == 0: return True # Test for presense of empty clause if [ ] in ClauseList: return False # Split on an arbitrarily decided literal DecLit = ClauseList[0][0] return (IsSatisfiable(AssignLit(ClauseList, DecLit)) or IsSatisfiable(AssignLit(ClauseList, -DecLit)))

13 DPLL Solver def IsSatisfiable (ClauseList): # Unit propagation repeat until fixed point: for each unit clause UC in ClauseList: ForcedLit = UC[0] ClauseList = AssignLit(ClauseList, ForcedLit) # Test if no unsatisfied clauses remain if len(ClauseList) == 0: return True # Test for presense of empty clause if [ ] in ClauseList: return False # Split on an arbitrarily decided literal DecLit = (choose a variable occuring in ClauseList) return (IsSatisfiable(AssignLit(ClauseList, DecLit)) or IsSatisfiable(AssignLit(ClauseList, -DecLit))) unchanged

GRASP: an efficient SAT solver Original Slides by Pankaj Chauhan Modified by Will Klieber Please interrupt me if anything is not clear!

15 Terminology CNF formula  x 1,…, x n : n variables  1,…,  m : m clauses Assignment A Set of (variable, value) pairs. Notation: {(x 1,1), (x 2,0)}, {x 1 :1, x 2 :0}, {x 1 =1, x 2 =0}, {x 1,  x 2 } |A| < n  partial assignment {x 1 =0, x 2 =1, x 4 =1} |A| = n  complete assignment {x 1 =0, x 2 =1, x 3 =0, x 4 =1}  | A = 0  falsifying assignment {x 1 =1, x 4 =1}  | A = 1  satisfying assignment {x 1 =0, x 2 =1, x 4 =1}  | A = X  unresolved asgnment {x 1 =0, x 2 =0, x 4 =1} φ =  1   2   3  1 = (x 2  x 3 )  2 = (  x 1   x 4 )  3 = (  x 2  x 4 ) A = {x 1 =0, x 2 =1, x 3 =0, x 4 =1} φ =  1   2   3  1 = (x 2  x 3 )  2 = (  x 1   x 4 )  3 = (  x 2  x 4 ) A = {x 1 =0, x 2 =1, x 3 =0, x 4 =1}

16 Terminology An assignment partitions the clause database into three classes: Satisfied, falsified, unresolved Free literal: an unassigned literal Unit clause: has exactly one free literal

17 Basic Backtracking Search Organize the search in the form of a decision tree. Each node is a decision variable. Outgoing edges: assignment to the decision variable. Depth of node in decision tree is decision level  (x). “ d ” means variable x is assigned value v at decision level d. x2 x2 x 2 = x 1 = x1 x1 x 1 = x2 x2 x 2 =

18 Basic Backtracking Search 1. Make new decision assignments. 2. Infer implied assignments by a deduction process (unit propagation). May lead to falsifying clauses, conflict! The assignment is called “conflicting assignment”. 3. Conflicting assignments leads to backtrack.

19 Backtracking Search in Action  1 = (x 2  x 3 )  2 = (  x 1   x 4 )  3 = (  x 2  x 4 )  1 = (x 2  x 3 )  2 = (  x 1   x 4 )  3 = (  x 2  x 4 ) x1 x1 x 1 = {(x 1,0), (x 2,0), (x 3,1)} x2 x2 x 2 =  x 3 = No backtrack in this example! Example 1

20 Backtracking Search in Action  1 = (x 2  x 3 )  2 = (  x 1   x 4 )  3 = (  x 2  x 4 )  1 = (x 2  x 3 )  2 = (  x 1   x 4 )  3 = (  x 2  x 4 ) x1 x1 {(x 1,1), (x 2,0), (x 3,1), (x 4,0)} x 1 =  x 4 =  x 2 =  x 3 = No backtrack in this example! Example 2

21 Backtracking Search in Action  1 = (x 2  x 3 )  2 = (  x 1   x 4 )  3 = (  x 2  x 4 )  4 = (  x 1  x 2   x 3 )  1 = (x 2  x 3 )  2 = (  x 1   x 4 )  3 = (  x 2  x 4 )  4 = (  x 1  x 2   x 3 )  x 4 =  x 2 =  x 3 = conflict {(x 1,0), (x 2,0), (x 3,1)} x2 x2 x 2 =  x 3 = x 1 = x1 x1 x 1 = Example 3

22 GRASP GRASP is Generalized seaRch Algorithm for the Satisfiability Problem (Silva, Sakallah, ’96). Features: Implication graphs for Unit Propagation and conflict analysis. Learning of new clauses. Non-chronological backtracking!

23 Learning GRASP can learn new clauses that are logically implied by the original formula. Goal is to allow Unit Prop to deduce more forced literals, pruning the search space. Example: φ contains clauses (x  y  z) and (x  y   z). Resolving on z yields a new clause (x  y). If y is false, then x must be true for φ to be true. But not discoverable by simple Unit Prop w/o resolvent clause. Clause (x  y) allows Unit Prop to force x=1 when y=0. New clauses learned from conflicting assignments.

24 Resolution

25 Top-level of GRASP-like solver 1. CurAsgn = {}; 2. while (true) { 3. while (value of φ under CurAsgn is unknown) { 4. DecideLit(); // Add decision literal to CurAsgn. 5. Propagate(); // Add forced literals to CurAsgn. 6. } 7. if (CurAsgn satisifies φ) {return true;} 8. Analyze conflict and learn a new clause; 9. if (the learned clause is empty) {return false;} 10. Backtrack(); 11. Propagate(); // Learned clause will force a literal 12. }

26 GRASP Decision Heuristics Procedure DecideLit() Choose the variable that satisfies the most clauses Other possibilities exist

27 GRASP Deduction Unit Propagation is a type of Boolean Constraint Propagation (BCP). Grasp does Unit Prop using implication graphs: E.g., for the clause  = (x   y), if y=1, then x=1 is forced; the antecedent of x is {y=1}. If a variable x is forced by a clause during BCP, then assignment of 0 to all other literals in the clause is called the antecedent assignment A(x). E.g., for  = (x  y   z), A(x) = {y:0, z:1}, A(y) = {x:0, z:1}, A(z) = {x:0, y:0} Variables directly responsible for forcing the value of x. Antecedent assignment of a decision variable is empty.

28 Implication Graphs Depicts the antecedents of assigned variables. A node is an assignment to a variable. (decision or implied) Predecessors of x correspond to antecedent A(x). No predecessors for decision assignments! For special conflict vertex , antecedent A(  ) is assignment to vars in the falsified clause.  conflict x 9 x 1 x 10 x 11 x 5 x 6 x 3 x 2 x 4

29 Example Implication Graph  1 = (  x 1  x 2 )  2 = (  x 1  x 3  x 9 )  3 = (  x 2   x 3  x 4 )  4 = (  x 4  x 5  x 10 )  5 = (  x 4  x 6  x 11 )  6 = (  x 5   x 6 )  7 = (x 1  x 7   x 12 )  8 = (x 1  x 8 )  9 = (  x 7   x 8   x 13 )  1 = (  x 1  x 2 )  2 = (  x 1  x 3  x 9 )  3 = (  x 2   x 3  x 4 )  4 = (  x 4  x 5  x 10 )  5 = (  x 4  x 6  x 11 )  6 = (  x 5   x 6 )  7 = (x 1  x 7   x 12 )  8 = (x 1  x 8 )  9 = (  x 7   x 8   x 13 ) Current truth assignment: {x 9 x 12 x 13 x 10 x 11 Current decision assignment: {x 1 66 66  conflict x 9 x 1 x 10 x 11 x 5 44 44 55 55 x 6 22 22 x 3 11 x 2 33 33 x 4

30 GRASP Conflict Analysis After a conflict arises, analyze the implication graph. Add new clause that would prevent the occurrence of the same conflict in the future.  Learning Determine decision level to backtrack to; this might not be the immediate one.  Non-chronological backtrack

31 Learning Algorithm 1. Let CA be the assignment of False to all literals in the falsified clause. (“CA” is short for “conflict assignment”.) Example: CA= {x 5 x 6 = 2. A literal l 2 CA is a unique implication point (UIP) iff every other literal in CA has an earlier decision level than l. 3. loop: Remove the most recently assigned literal from CA and replace it by its antecedent. if (CA is empty or has a UIP): break; 4. Let {L 1,..., L n } = CA; learn clause (  L 1 ...   L n ). 5. Backtrack to the earliest decision level at which the learned clause will force the UIP to be false. Why is this guaranteed to be possible?

32 Example Implication Graph  1 = (  x 1  x 2 )  2 = (  x 1  x 3  x 9 )  3 = (  x 2   x 3  x 4 )  4 = (  x 4  x 5  x 10 )  5 = (  x 4  x 6  x 11 )  6 = (  x 5   x 6 )  7 = (x 1  x 7   x 12 )  8 = (x 1  x 8 )  9 = (  x 7   x 8   x 13 )  1 = (  x 1  x 2 )  2 = (  x 1  x 3  x 9 )  3 = (  x 2   x 3  x 4 )  4 = (  x 4  x 5  x 10 )  5 = (  x 4  x 6  x 11 )  6 = (  x 5   x 6 )  7 = (x 1  x 7   x 12 )  8 = (x 1  x 8 )  9 = (  x 7   x 8   x 13 ) Current truth assignment: {x 9 x 12 x 13 x 10 x 11 Current decision assignment: {x 1 66 66  conflict x 9 x 1 x 10 x 11 x 5 44 44 55 55 x 6 22 22 x 3 11 x 2 33 33 x 4

33 Example  1 = (  x 1  x 8  x 9 )  2 = (  x 1  x 8   x 9 )  3 = (  x 1   x 8  x 9 )  4 = (  x 1   x 8   x 9 )  5 = (x 1  x 3 )  6 = (x 1   x 3 )  1 = (  x 1  x 8  x 9 )  2 = (  x 1  x 8   x 9 )  3 = (  x 1   x 8  x 9 )  4 = (  x 1   x 8   x 9 )  5 = (x 1  x 3 )  6 = (x 1   x 3 )

34 Is that all? Huge overhead for boolean constraint propagation (BCP) Better decision heuristics Better learning, problem specific Better engineering! Chaff