© R.A. Rutenbar 2009 Slide 1 Carnegie Mellon (Lec 06) Boolean Satisfiability: SAT Solvers (Pt 1) What you know  Representation and manipulation via BDDs,

Slides:



Advertisements
Similar presentations
Exploiting SAT solvers in unbounded model checking
Advertisements

Chaff: Engineering an Efficient SAT Solver Matthew W.Moskewicz, Concor F. Madigan, Ying Zhao, Lintao Zhang, Sharad Malik Princeton University Presenting:
Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License:
UIUC CS 497: Section EA Lecture #2 Reasoning in Artificial Intelligence Professor: Eyal Amir Spring Semester 2004.
Proofs from SAT Solvers Yeting Ge ACSys NYU Nov
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Mar, 4, 2015 Slide credit: some slides adapted from Stuart.
Data Structures for SAT Solvers The 2-Literal Representation Gábor Kusper Eszterházy Károly College Eger, Hungary.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View SAT.
1/30 SAT Solver Changki PSWLAB SAT Solver Daniel Kroening, Ofer Strichman.
IBM Labs in Haifa © 2005 IBM Corporation Adaptive Application of SAT Solving Techniques Ohad Shacham and Karen Yorav Presented by Sharon Barner.
EE 553 Integer Programming
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.
Best-First Search: Agendas
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:
ECE 667 Synthesis & Verification - SAT 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Boolean SAT CNF Representation Slides adopted (with.
Willis Lemasters Grant Conklin. Searching a tree recursively one branch at a time, abandoning any branch which does not satisfy the search constraints.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
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.
Ryan Kinworthy 2/26/20031 Chapter 7- Local Search part 1 Ryan Kinworthy CSCE Advanced Constraint Processing.
Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis
Computational Methods for Management and Economics Carla Gomes
GRASP-an efficient SAT solver Pankaj Chauhan. 6/19/ : GRASP and Chaff2 What is SAT? Given a propositional formula in CNF, find an assignment.
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.
A Compressed Breadth-First Search for Satisfiability DoRon B. Motter and Igor L. Markov University of Michigan, Ann Arbor.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
1 Abstraction Refinement for Bounded Model Checking Anubhav Gupta, CMU Ofer Strichman, Technion Highly Jet Lagged.
Knowledge Representation II (Inference in Propositional Logic) CSE 473 Continued…
ENGG3190 Logic Synthesis “Boolean Satisfiability” Winter 2014 S. Areibi School of Engineering University of Guelph.
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.
Data Structures — Lists and Trees CS-2301, B-Term Data Structures — Lists and Trees CS-2301, System Programming for Non-Majors (Slides include materials.
Binary Decision Diagrams (BDDs)
Logics for Data and Knowledge Representation Propositional Logic: Reasoning Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto.
Boolean Satisfiability and SAT Solvers
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
INTRODUCTION TO ARTIFICIAL INTELLIGENCE COS302 MICHAEL L. LITTMAN FALL 2001 Satisfiability.
Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011 TexPoint fonts used in EMF. Read the TexPoint manual before you.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CP Summer School Modelling for Constraint Programming Barbara Smith 2. Implied Constraints, Optimization, Dominance Rules.
Parallelizing MiniSat I-Ting Angelina Lee Justin Zhang May 05, Final Project Presentation.
Constraint Satisfaction CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.
15.053Tuesday, April 9 Branch and Bound Handouts: Lecture Notes.
LDK R Logics for Data and Knowledge Representation Propositional Logic: Reasoning First version by Alessandro Agostini and Fausto Giunchiglia Second version.
On the Relation between SAT and BDDs for Equivalence Checking Sherief Reda Rolf Drechsler Alex Orailoglu Computer Science & Engineering Dept. University.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.
First-Order Logic and Inductive Logic Programming.
Chapter 5 Constraint Satisfaction Problems
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Oct, 30, 2015 Slide credit: some slides adapted from Stuart.
Problem Reduction So far we have considered search strategies for OR graph. In OR graph, several arcs indicate a variety of ways in which the original.
Heuristics for Efficient SAT Solving As implemented in GRASP, Chaff and GSAT.
Satisfiability and SAT Solvers CS 270 Math Foundations of CS Jeremy Johnson.
SAT Solving As implemented in - DPLL solvers: GRASP, Chaff and
Inference in Propositional Logic (and Intro to SAT) CSE 473.
Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License:
Heuristics for Efficient SAT Solving As implemented in GRASP, Chaff and GSAT.
Inference and search for the propositional satisfiability problem
Gábor Kusper University of Linz RISC Austria
Parallelism in SAT Solvers
First-Order Logic and Inductive Logic Programming
Introduction to Software Verification
ECE 667 Synthesis and Verification of Digital Circuits
Decision Procedures An Algorithmic Point of View
Artificial Intelligence
Artificial Intelligence
GRASP-an efficient SAT solver
Presentation transcript:

© R.A. Rutenbar 2009 Slide 1 Carnegie Mellon (Lec 06) Boolean Satisfiability: SAT Solvers (Pt 1) What you know  Representation and manipulation via BDDs, mainly  Lets us do computational Boolean algebra, solve (ie, satisfy ) Boolean equations What you don’t know  That there’s another way to do this  Called “SAT solvers”  I give you a big Boolean equation in a special form  Tool tells me either (a) it’s satisfiable and returns an assignment of the variables or (b) it’s unsatisfiable, no such assignment exists  This is a whole different approach...

© R.A. Rutenbar 2009 Slide 2 Carnegie Mellon Some Terminology Satisfiability (called “SAT” for short)  Give me an appropriate representation of a Boolean function  (X), where X=(x1, x2, … xn}  Find an assignment of the variables X* so that  (X) = 1  Note – this assignment need not be unique. Could be many satisfying solutions  But if there are no satisfying assignments at all – prove it, and return this info Many things that you can do with BDDs, can also do with SAT  But SAT is especially aimed at scenarios where you need to solve for a satisfying assignment…  …or prove that there is no such satisfying assignment

© R.A. Rutenbar 2009 Slide 3 Carnegie Mellon Consider: Verification via Reachability For basic FSM equivalence, we ended up with this problem  Goal: solve the resulting Boolean equation, to see if we could satisfy it to make a “1”, which indicated we had non-equivalent FSMs  Note: needed BDDs to tell when reachability analysis terminates, to compute R k but the problem is the BDD may be too expensive to build and store in memory

© R.A. Rutenbar 2009 Slide 4 Carnegie Mellon BDDs versus SAT BDD properties  Represents all possible satisfying assignments in paths from root to “1” leaf  Cannot always build it – may require too much memory  Really a data structure, with a set of useful associated algorithms. Satisfiability is really sort of a “side effect” for BDDs  Disadvantage for “just solve it” applications is you still need to build the entire BDD data structure before you can get even one soln Today  BDDs most commonly used for applications where the goal is Boolean manipulation  Not best solution for “just solve it” tasks SAT properties  Does not obtain all possible satisfying assignments. Just finds one, if it exists  Cannot always finish the computation – may require too much CPU time to finish  Really an algorithm, not just a data structure. All SAT does is solve for satisfying assignment, or tell you “none”  Advantage for “just solve it” applications is that this is all that SAT solvers are designed to do: return one answer fast, or say “no!” Today  SAT solvers most commonly used for applications where the goal is “ solve it ”  Not really a solution for the cases where you need heavy duty Boolean manipulation

© R.A. Rutenbar 2009 Slide 5 Carnegie Mellon Standard SAT Form: CNF Conjunctive Normal Form (CNF) = Standard POS form Why CNF is useful  Need only determine that one clause evals to “0” to know whole formula evals to “0”  Of course, to satisfy the whole formula, you must make all clauses identically “1”.  = ( a + c ) ( b + c) ( ¬a + ¬b + ¬c)

© R.A. Rutenbar 2009 Slide 6 Carnegie Mellon Assignment to a CNF Formula An assignment …  …gives values to some, not necessarily all, of the variables xi in X.  Complete assignment: assigns all the variables values.  Partial assignment: some, not all, of the variables have values Assignment means we can evaluate status of the clauses  Suppose a=0, b=1 but c, d are unassigned  = ( a + ¬b ) (¬a + b + ¬ c) ( a + c + d ) ( ¬a + ¬b + ¬c)

© R.A. Rutenbar 2009 Slide 7 Carnegie Mellon How Do We “Solve” Something Like This? Recursively  (Are you surprised?) Strategy has two big ideas  DECIDE:  Pick a variable and assign its value  Simplify the CNF formula as far you can  Hope you can decide if it’s SAT, yes/no, without further work  DEDUCE:  Look at the newly simplified clauses  You may be able to iteratively simplify, based on the structure of these clauses, and the value of the partial assignment  Apply this idea until nothing else simplifies. If you can decide SAT yes/no, great. If not, then you have to recurse some more, back up to DECIDE

© R.A. Rutenbar 2009 Slide 8 Carnegie Mellon How Do We “Solve” Something Like This?  = ( x + y + z)( ¬x + y )( ¬y + z ) ( ¬x + ¬y + ¬z)

© R.A. Rutenbar 2009 Slide 9 Carnegie Mellon Some Definitions and Notation  = ( x + y + z)( ¬x + y )( ¬y + z ) ( ¬x + ¬y + ¬z) Search is organized as a “decision tree”  At every level, you make a decision to assign a variable to a value  Nodes in the tree correspond to these variable decisions  Depth of the tree is the decision level of the variable Notation  Assign var x to value= v at level d of tree  These really label the edges of the tree

© R.A. Rutenbar 2009 Slide 10 Carnegie Mellon Deduction = Boolean Constraint Propagation (BCP) Big idea behind BCP  Given a set of fixed variable assignments, what else can you “ deduce ” about necessary assignments by “ propagating constraints ” Lots of general strategies; most famous is “Unit Clause Rule”  A clause is said to be “ unit ” if it has exactly one unassigned literal  A unit clause has exactly one way to be satisfied, ie, pick polarity that makes clause=“1”  This choice is called an “implication”  Example: suppose a=1 and b=1  = ( a + c ) ( b + c) ( ¬a + ¬b + ¬c)

© R.A. Rutenbar 2009 Slide 11 Carnegie Mellon BCP is Iterative – Run Until No More Implications Assumptions  Partial assignment is x9=0 x10=0 x11=0 x12=1 x13=1 To start…  What are the results of the obvious simplifications when we actually assign these variables?  = (  1 )(  2 )(  3 )(  4 )(  5 )(  6 )(  7 )(  8 )(  9 )  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)

© R.A. Rutenbar 2009 Slide 12 Carnegie Mellon BCP is Iterative – Run Until No More Implications Assumptions  Partial assignment is x9=0 x10=0 x11=0 x12=1 x13=1 Next…  Let’s assume the new decision var is x1  Assign x1=1  Do the obvious simplifications, what clauses are completely resolved now?  = (  1 )(  2 )(  3 )(  4 )(  5 )(  6 )(  7 )(  8 )(  9 )  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)

© R.A. Rutenbar 2009 Slide 13 Carnegie Mellon BCP is Iterative – Run Until No More Implications Assumptions  Partial assignment is x9=0 x10=0 x11=0 x12=1 x13=1  Current decision var is x1 Next… do unit-clause BCP  Does setting x1=1 create any unit clauses?  What values for unassigned vars can we now deduce?  = (  1 )(  2 )(  3 )(  4 )(  5 )(  6 )(  7 )(  8 )(  9 )  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)

© R.A. Rutenbar 2009 Slide 14 Carnegie Mellon BCP is Iterative – Run Until No More Implications Assumptions  Partial assignment is x9=0 x10=0 x11=0 x12=1 x13=1  Current decision var is x1  Unit clause implications: Next… continue unit-clause BCP  Assign vars from unit clause BCP  Did we resolve any more clauses?  Any more values for unassigned vars we can deduce?  = (  1 )(  2 )(  3 )(  4 )(  5 )(  6 )(  7 )(  8 )(  9 )  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) 1

© R.A. Rutenbar 2009 Slide 15 Carnegie Mellon BCP is Iterative – Run Until No More Implications Assumptions  Partial assignment is x9=0 x10=0 x11=0 x12=1 x13=1  Current decision var is x1  Unit clause implications: Next… continue unit-clause BCP  Assign vars from unit clause BCP  Did we resolve any more clauses?  Any more values for unassigned vars we can deduce?  = (  1 )(  2 )(  3 )(  4 )(  5 )(  6 )(  7 )(  8 )(  9 )  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) 2

© R.A. Rutenbar 2009 Slide 16 Carnegie Mellon BCP is Iterative – Run Until No More Implications Assumptions  Partial assignment is x9=0 x10=0 x11=0 x12=1 x13=1  Current decision var is x1  Unit clause implications: Next… continue unit-clause BCP  Assign vars from unit clause BCP  Did we resolve any more clauses?  Any more values for unassigned vars we can deduce?  = (  1 )(  2 )(  3 )(  4 )(  5 )(  6 )(  7 )(  8 )(  9 )  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) 3

© R.A. Rutenbar 2009 Slide 17 Carnegie Mellon BCP is Iterative – Run Until No More Implications 3 cases when BCP finishes  SAT: We find a satisfying assignment, all the clauses resolve to “ 1 ”. Return it.  UNRESOLVED: We have one or more clauses unresolved. Means we need to pick another “free” unassigned variable and recurse more.  UNSAT: Like this case. Found a conflict that made one or more clauses eval to “ 0 ” Now what?  You need to undo one of our variable assignments…  … and backtrack, try something different  = (  1 )(  2 )(  3 )(  4 )(  5 )(  6 )(  7 )(  8 )(  9 )  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)

© R.A. Rutenbar 2009 Slide 18 Carnegie Mellon BCP is Iterative – Run Until No More Implications Assumptions  Partial assignment is x9=0 x10=0 x11=0 x12=1 x13=1  Current decision var is x1  Unit clause implications: Go back to “most recent” decision and if it has not been tried both ways, “flip it” to other value  Erase all the simplifications due to x1=1, but keep the other simplifications  Erase all the unit clause implications too  Start again with x1=0 decision  = (  1 )(  2 )(  3 )(  4 )(  5 )(  6 )(  7 )(  8 )(  9 )  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) 4

© R.A. Rutenbar 2009 Slide 19 Carnegie Mellon BCP is Iterative – Run Until No More Implications Assumptions  Partial assignment is x9=0 x10=0 x11=0 x12=1 x13=1  Current decision var still x1, but now x1=0  Unit clause implications: Again … do BCP till nothing left  Erase all the simplifications due to x1=1, but keep the other simplifications  Erase all the unit clause implications too  Start again with x1=0 decision  = (  1 )(  2 )(  3 )(  4 )(  5 )(  6 )(  7 )(  8 )(  9 )  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) 5

© R.A. Rutenbar 2009 Slide 20 Carnegie Mellon BCP is Iterative – Run Until No More Implications Oops– another conflict! Now what?  Need to erase all the local clause simplifications and implications, again  We know neither x1=1 nor x1=0 works to find a satisfying assignment with these prior decisions  Backtrack again, to last decision made before the x1 assignment, that was not tried both ways, =1 and =0 x9 x10 x11 x12 x13 x1 x9=0 x10=0 x11=0 x12=1 x13=1 unsat  = (  1 )(  2 )(  3 )(  4 )(  5 )(  6 )(  7 )(  8 )(  9 )  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)

© R.A. Rutenbar 2009 Slide 21 Carnegie Mellon This Has a Famous Name: DPLL Davis-Putnam-Logemann-Loveland Algorithm  Davis, Putnam published the basic recursive framework in 1960 (!)  Davis, Logemann, Loveland came up with smarter BCP, eg, unit-clause rule, in 1962  Often called “Davis-Putnam” or “DP” in honor of the first paper in 1960, or (inaccurately) DPLL (all four of them never did publish this stuff together) Big ideas  A complete, systematic search of variable assignments  Useful CNF form for efficiency  BCP to make the recursions terminate earlier by “resolving” more assignments without recursing more deeply We’ll stick with the (inaccurate) but popular “DPLL” name

© R.A. Rutenbar 2009 Slide 22 Carnegie Mellon Vanilla DPLL Algorithm DPLL(set_of_clauses ) // do BCP while ( set_of_clauses contains a unit clause due to literal L ) { Simplify set_of_clauses by setting variable for L to its required value in all clauses } If ( set_of_clauses is all “ 1 ” clauses now) return ( SAT ) // you have simplified every clause to be “1” if ( set_of_clauses contains a clause that evals to “ 0 ”) return ( UNSAT ) // this is a conflict, this set of var assignment doesn’t satisfy // must recurse Heuristically choose an unassigned variable x and heuristically choose a value v if ( DPLL( set_of_clauses = simplified by setting x=v ) == SAT ) return ( SAT ) else return ( DPLL( set_of_clauses = simplified by setting x= ¬v ) )

© R.A. Rutenbar 2009 Slide 23 Carnegie Mellon What Do We Need for “Smart” DPLL? Need 5 basic components Clause database data structure  How do we store them? Access them? Branching heuristics  When we have to recurse—which variable to pick? BCP mechanisms  How do we actually do this deduction stuff to get all the implications? Conflict analysis and learning  Can be very clever about how you do the actual backtracking  Don’t just undo “last” decision, if we augment clause database cleverly Random restarts  Yes – randomness is something we can specifically exploit

© R.A. Rutenbar 2009 Slide 24 Carnegie Mellon (1) Clause Database Data Structure Most conventional approach is “sparse matrix” representation In a normal programming language, you get 2-D arrays  The idea is this is how you’d store an arbitrary “dense” 2-D matrix  Assumption is that you really plan to use all 4x5 = 20 matrix elements Foo[3][4] =

© R.A. Rutenbar 2009 Slide 25 Carnegie Mellon Simplistic Dense Matrix Scheme 2-D structure, one row per clause, one column per variable  Entries in structure tell you if the variable is in the clause, and in which polarity  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) x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13

© R.A. Rutenbar 2009 Slide 26 Carnegie Mellon Sparse Matrix Scheme What’s wrong with that? Very inefficient – mostly empty!  Many variables and clauses, but each clause usually has just a few variables  Solution: “sparse matrix” which is just a set of horizontal and vertical linked lists  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) x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13

© R.A. Rutenbar 2009 Slide 27 Carnegie Mellon Sparse Matrix Scheme Advantages  Conceptually very easy  Avoids all the “empty” entries of the dense matrix scheme  Easy to find all the variables in a particular clause – just walk down the horizontal list  Easy to find all the clauses that have variable xi in them—just walk down the vertical list  Easy to add a new clause to the database, or delete one (we’ll see why later) Disadvantages  It’s smaller than the 2-D dense matrix – yes  But, it’s not necessarily “small” overall, especially if the problem is gigantic  Gigantic means millions of vars or clauses  In this case, the problem is that you are overwhelmed by pointers, especially if you doubly link everything So, how do people really do it?  Combination of schemes.  Use arrays to store literals in clauses  Still use some pointers to link things that need to be searched, but replace some of these ptrs with small searches across clauses  Also, have to do garbage collection to allow for insert/delete actions on the arrays

© R.A. Rutenbar 2009 Slide 28 Carnegie Mellon (2) Branching Heuristics Reminder about the context… xi xj xk xm xi=… xj=… xk=… xm=…

© R.A. Rutenbar 2009 Slide 29 Carnegie Mellon Heuristic Selects Next Decision Var && Its Value Scenario  After decision variable assignment, some clauses are resolved  After BCP iteration, more clauses resolved ..but, not all the clauses are resolve, ie, they are not unit, we don’t know what to do to make them resolve to “1” Strategy:  Use some heuristic to pick an unassigned literal in some clause(s) in this set  Use this as the next decision variable.value  Recurse: Simplify using this decision assignment, then run BCP, etc etc So – which variable/value to pick?  One that makes the search finish faster  Many options…  = (  i)(  j)(  k)…(  m)…(  n)(  p)…(  z)

© R.A. Rutenbar 2009 Slide 30 Carnegie Mellon Branching Heuristics Three sorts of general ideas  Use taxonomy from Ian Gent (eg, and.ac.uk/~ipg/AI/Lectures/Search4.ppt ) How constrained?  Pick variables that are “more constrained” first  Idea: Hope this works on the “hard” stuff first, makes the problem easier to solve How likely to satisfy?  Pick variables that are immediately likely to satisfy the problem  Idea: Should try the variable that might—individually—go farthest toward answer How likely to simplify problem?  Pick variable that will lead to most BCP implications via unit propagation  Idea: Make the problem as small as you can, as fast as you can

© R.A. Rutenbar 2009 Slide 31 Carnegie Mellon Branching Heuristics: MOM “MOM” acronym, means…  Pick unassigned literal occurring M ost O ften in the M inimal size clauses  Pick a threshold (3, or 5, or …) for max # of literals in a “minimal size clause”  Pick the unassigned literal (ie, you can pick x or ¬x ) that occurs most often  This defines both the variable (it’s x ) and the value (if x, it’s 1, if ¬x, it’s 0 ) Motivation  If this literal appears in a LOT of clauses, you hope to immediately resolve (simplify) a maximal number of clauses  Hope is to make the set of unresolved clauses you need to work with very small, or just quickly find out that this assignment makes  =0 so you can backtrack right away  This is a “how constrained” sort of heuristic: pick the most constrained var