Boolean Satisfiability in Electronic Design Automation Joo Marques
Boolean Satisfiability in Electronic Design Automation João Marques Silva Informatics Department Technical University of Lisbon IST/INESC, CEL SAT tutorial Karem A. Sakallah EECS Department University of Michigan 1
Context l l l SAT is the quintessential NP-complete problem Theoretically well-studied Practical algorithms for large problem instances started emerging in the last five years Has many applications in EDA and other fields Can potentially have similar impact on EDA as BDDs EDA professionals should have good working knowledge of SAT formulations and algorithms SAT tutorial 2
Outline l l l l Boolean Satisfiability (SAT) Basic Algorithms Representative EDA Applications Taxonomy of Modern SAT Algorithms Advanced Backtrack Search Techniques Experimental Evidence Conclusions SAT tutorial 3
Boolean Satisfiability l Given a suitable representation for a Boolean function f(X): – Find an assignment X* such that f(X*) = 1 – Or prove that such an assignment does not exist (i. e. f(X) = 0 for all possible assignments) l In the “classical” SAT problem, f(X) is represented in product-ofsums (POS) or conjunctive normal form (CNF) l Many decision (yes/no) problems can be formulated either directly or indirectly in terms of Boolean Satisfiability SAT tutorial 4
Conjunctive Normal Form (CNF) = ( a + c ) ( b + c ) (¬a + ¬b + ¬c ) Clause SAT tutorial Positive Literal Negative Literal 5
Basics l Implication x ® y = ¬x + y = ¬(¬y) + (¬x) = ¬y ® ¬x (contra positive) l Assignments: {a = 0, b = 1} = ¬a b – Partial (some variables still unassigned) – Complete (all variables assigned) – Conflicting (imply ¬ ) = (a + c)(b + c)(¬a + ¬b + ¬c) ® (a + c) ¬(a + c) ® ¬ ¬a ¬c ® ¬ SAT tutorial 6
Consensus l General technique for deriving new clauses Example: 1 = (¬a + b + c), 2 = (a + b + d) Consensus: con( 1, 2, a) = (b + c + d) Complete procedure for satisfiability [Davis, JACM’ 60] l Impractical for real-world problem instances l Application of restricted forms has been successful! l – E. g. , always apply restricted consensus • con((¬a + ), (a + ), a) = ( ) is a disjunction of literals SAT tutorial 7
Literal & Clause Classification violated satisfied unresolved satisfied = (a + ¬b)(¬a + b + ¬c )(a + c + d )(¬a + ¬b + ¬c ) a assigned b assigned 0 c and 1 d unassigned SAT tutorial 8
Outline l l l l Boolean Satisfiability (SAT) Basic Algorithms Representative EDA Applications Taxonomy of Modern SAT Algorithms Advanced Backtrack Search Techniques Experimental Evidence Conclusions SAT tutorial 9
Basic Backtracking Search 2 3 (a + b + c) (a + b + ¬c) (¬a + b + ¬c) 4 5 (a + c + d) (¬a + c + d) 6 7 (¬a + c + ¬d) (¬b + ¬c + ¬d) 8 (¬b + ¬c + d) 1 SAT tutorial a b c d c d d d 10
Unit Clause Rule - Implications l An unresolved clause is unit if it has exactly one unassigned literal = (a + c)(b + c)(¬a + ¬b + ¬c) l A unit clause has exactly one option for being satisfied a b ® ¬c i. e. c must be set to 0. SAT tutorial 11
Basic Search with Implications 1 (a + b + c) 2 3 (a + b + ¬c) (¬a + b + ¬c) 4 5 (a + c + d) (¬a + c + d) 6 7 (¬a + c + ¬d) (¬b + ¬c + ¬d) 8 (¬b + ¬c + d) SAT tutorial a b b c a b 5 3 4 7 b c 5 3 4 7 c d c 5 86 86 6 d 6 6 12
Pure Literal Rule A variable is pure if its literals are either all positive or all negative l Satisfiability of a formula is unaffected by assigning pure variables the values that satisfy all the clauses containing them l = (a + c )(b + ¬d)(¬a + ¬b + d) l Set c to 1; if becomes unsatisfiable, then it is also unsatisfiable when c is set to 0. SAT tutorial 13
Circuit Satisfiability a b c d e f g h? = h [d=¬(ab)] [e=¬(b+c)] [f=¬d] [g=d+e] [h=fg] SAT tutorial 14
Circuit Satisfiability a b c d e f g h? h = h [d=¬(ab)] [e=¬(b+c)] [f=¬d] [g=d+e] [h=fg] =h (a + d)(b + d)(¬a + ¬b + ¬d) (¬b + ¬e)(¬c + ¬e)(b + c + e) (¬d + ¬f)(d + f) (¬d + g)(¬e + g)(d + e + ¬g) (f + ¬h)(g + ¬h)(¬f + ¬g + h) SAT tutorial 16
Outline l l l l Boolean Satisfiability (SAT) Basic Algorithms Representative EDA Applications Taxonomy of Modern SAT Algorithms Advanced Backtrack Search Techniques Experimental Evidence Conclusions SAT tutorial 17
ATPG xx 11 xx 22 xx 33 xx 44 x 1 x 2 x 3 x 4 SAT tutorial x 5 x 6 x=6 0 CG x 7 x 9 x 9 s-a-1 x 8 x 5 x 6 = 1 z=1? CF x 7 x 9 x 8 18
Equivalence Checking CA z=1? CB If z = 1 is unsatisfiable, the two circuits are equivalent ! SAT tutorial 19
Outline l l l l Boolean Satisfiability (SAT) Basic Algorithms Representative EDA Applications Taxonomy of Modern SAT Algorithms Advanced Backtrack Search Techniques Experimental Evidence Conclusions SAT tutorial 20
A Taxonomy of SAT Algorithms Incomplete Complete search (DP) Can. Backtrack prove unsatisfiability Local search (hill climbing) Cannot prove unsatisfiability Resolution (original DP) Continuous formulations Stallmarck’s method (SM) Genetic algorithms Recursive learning (RL) Simulated annealing BDDs Tabu search . . . SAT tutorial 21
Resolution (original DP) l Iteratively apply resolution (consensus) to eliminate one variable each time – i. e. , consensus between all pairs of clauses containing x and ¬x – formula satisfiability is preserved l Stop applying resolution when, – Either empty clause is derived instance is unsatisfiable – Or only clauses satisfied or with pure literals are obtained instance is satisfiable = (a + c)(b + c)(d + c)(¬a + ¬b + ¬c) Eliminate variable c 1 = (a + ¬b)(b + ¬a + ¬b )(d + ¬a + ¬b ) = (d + ¬a + ¬b ) Instance is SAT ! SAT tutorial 22
Stallmarck’s Method (SM) in CNF l Recursive application of the branch-merge rule to each variable with the goal of identifying common conclusions = (a + b)(¬a + c) (¬b + d)(¬c + d) Try a = 0: (a = 0) (b = 1) (d = 1) C(a = 0) = {a = 0, b = 1, d = 1} Try a = 1: (a = 1) (c = 1) (d = 1) C(a = 1) = {a = 1, c = 1, d = 1} C(a = 0) C(a = 1) = {d = 1} Any assignment to variable a implies d = 1. Hence, d = 1 is a necessary assignment ! Recursion can be of arbitrary depth SAT tutorial 23
Recursive Learning (RL) in CNF l Recursive evaluation of clause satisfiability requirements for identifying common assignments = (a + b)(¬a + d) (¬b + d) Try a = 1: (a = 1) (d = 1) C(a = 1) = {a = 1, d = 1} Try b = 1: (b = 1) (d = 1) C(b = 1) = {b = 1, d = 1} C(a = 1) C(b = 1) = {d = 1} Every way of satisfying (a + b) implies d = 1. Hence, d = 1 is a necessary assignment ! Recursion can be of arbitrary depth SAT tutorial 24
SM vs. RL Both complete procedures for SAT l Stallmarck’s method: l – hypothetic reasoning based on variables l Recursive learning: – hypothetic reasoning based on clauses l Both can be integrated into backtrack search algorithms SAT tutorial 25
Local Search l Repeat M times: – Randomly pick complete assignment – Repeat K times (and while exist unsatisfied clauses): • Flip variable that will satisfy largest number of unsat clauses = (a + b)(¬a + c) (¬b + d)(¬c + d) Pick random assignment = (a + b)(¬a + c) (¬b + d)(¬c + d) Flip assignment on d = (a + b)(¬a + c) (¬b + d)(¬c + d) Instance is satisfied ! SAT tutorial 26
Comparison l Local search is incomplete – If instances are known to be SAT, local search can be competitive Resolution is in general impractical l Stallmarck’s Method (SM) and Recursive Learning (RL) are in general slow, though robust l – SM and RL can derive too much unnecessary information l For most EDA applications backtrack search (DP) is currently the most promising approach ! – Augmented with techniques for inferring new clauses/implicates (i. e. learning) ! SAT tutorial 27
Outline l l l l Boolean Satisfiability (SAT) Basic Algorithms Representative EDA Applications Taxonomy of Modern SAT Algorithms Advanced Backtrack Search Techniques Experimental Evidence Conclusions SAT tutorial 28
Techniques for Backtrack Search l Conflict analysis – Clause/implicate recording – Non-chronological backtracking l Incorporate and extend ideas from: – Resolution – Recursive learning – Stallmarck’s method Formula simplification & Clause inference [Li, AAAI 00] l Randomization & Restarts [Gomes&Selman, AAAI 98] l SAT tutorial 29
Clause Recording l During backtrack search, for each conflict create clause that explains and prevents recurrence of same conflict = (a + b)(¬b + c + d) (¬b + e)(¬d + ¬e + f) Assume (decisions) c = 0 and f = 0 Assign a = 0 and imply assignments A conflict is reached: (¬d + ¬e + f) is unsat (a = 0) (c = 0) (f = 0) ( = 0) ( = 1) (a = 1) (c = 1) (f = 1) SAT tutorial create new clause: (a + c + f) 30
Clause Recording l Clauses derived from conflicts can also be viewed as the result of applying selective consensus = (a + b)(¬b + c + d) (¬b + e)(¬d + ¬e + f) consensus (a + c + d) (a + e) (a + c + ¬e + f) (a + c + f) SAT tutorial 31
Non-Chronological Backtracking l During backtrack search, in the presence of conflicts, backtrack to one of the causes of the conflict = (a + b)(¬b + c + d) (¬b + e)(¬d + ¬e + f) (a + c + f)(¬a + g)(¬g + b)(¬h + j)(¬i + k) Assume (decisions) c = 0, f = 0, h = 0 and i = 0 Assignment a = 0 caused conflict clause (a + c + f) created (a + c + f) implies a = 1 A conflict is again reached: (¬d + ¬e + f) is unsat (a = 1) (c = 0) (f = 0) ( = 0) ( = 1) (a = 0) (c = 1) (f = 1) create new clause: (¬a + c + 32 f) SAT tutorial
Non-Chronological Backtracking c Created clauses: (a + c + f) and (¬a + c + f) 0 Apply consensus: new unsat clause (c + f) f 0 backtrack to most recent decision: f = 0 h 0 created clauses/implicates: (a + c + f), (¬a + c + f), and (c + f) SAT tutorial i 0 a 0 1 (c + f) 33
Ideas from other Approaches l Resolution, Stallmarck’s method and recursive learning can be incorporated into backtrack search (DP) – create additional clauses/implicates • anticipate and prevent conflicting conditions • identify necessary assignments • allow for non-chronological backtracking Resolution within DP: (a + b + c) (¬a + b + d) (b + c + d) Unit clause ! consensus (b + c + d) SAT tutorial Clause provides explanation for necessary assignment b =341
Stallmarck’s Method within DP = (a + b + e)(¬a + c + f)(¬b + d) (¬c + d + g) Implications: consensus (a = 0) (e = 0) (b = 1) (d = 1) (b + e + c + f) (a = 1) (f = 0) (c = 1) (g = 0) (d = 1) (e = 0) (f = 0) (g = 0) (d = 1) Clausal form: (e + f + g + d) Unit clause ! SAT tutorial (d + e + c + f) (e + f + g + d) Clause provides explanation for necessary assignment d =35 1
Recursive Learning within DP = (a + b + c)(¬a + d + e) (¬b + d + c) Implications: consensus (a = 1) (e = 0) (d = 1) (b = 1) (c = 0) (d = 1) (b + c + e + d) consensus (c = 0) ((e = 0) (c = 0)) (d = 1) (c + e + d) Clausal form: (c + e + d) SAT tutorial Unit clause ! Clause provides explanation for necessary assignment d = 1 36
Formula Simplification l Eliminate clauses and variables – If (x + y) and ( x + y) exist, then x and y are equivalent, (x y) • eliminate y, and replace by x • remove satisfied clauses – Utilize 2 CNF sub-formula for identifying equivalent variables • (¬a + b)(¬b + c)(¬c + d)(¬d + b)(¬d + a) • a, b, c and d are pairwise equivalent Implication graph: SAT tutorial a b d c 37
Clause Inference Conditions Given (l 1 + ¬l 2)(l 1 + ¬l 3)(l 2 + l 3 + ¬l 4) Infer (l 1 + ¬l 4) consensus (l 1 + l 3 + ¬ l 4) consensus (l 1 + ¬ l 4) If we can also infer (¬l 1 + l 4), then we prove (l 1 l 4), and can replace l 4 by l 1 ! Type of Inference: 2 Binary / 1 Ternary (2 B/1 T) Clauses Other types: 1 B/1 T, 1 B/2 T, 3 B/1 T, 2 B/1 T, 0 B/4 T SAT tutorial 38
The Power of Consensus l Most search pruning techniques can be explained as particular ways of applying selective consensus – – – Conflict-based clause recording Non-chronological backtracking Extending Stallmarck’s method to backtrack search Extending recursive learning to backtrack search Clause inference conditions General consensus is computationally too expensive ! l Most techniques indirectly identify which consensus operations to apply ! l – To create new clauses/implicates • To identify necessary assignments SAT tutorial 39
Randomization & Restarts l Run times of backtrack search SAT solvers characterized by heavy-tail distributions – For a fixed problem instance, run times can exhibit large variations with different branching heuristics and/or branching randomization l Search strategy: Rapid Randomized Restarts – Randomize variable selection heuristic – Utilize a small backtrack cutoff value – Repeatedly restart the search each time backtrack cutoff reached • Use randomization to explore different paths in search tree SAT tutorial 40
Randomization & Restarts l Can make the search strategy complete – Increase cutoff value after each restart l Can utilize learning – Useful for proving unsatisfiability l Can utilize portfolios of algorithms and/or algorithm configurations – Also useful for proving unsatisfiability SAT tutorial 41
Outline l l l l Boolean Satisfiability (SAT) Basic Algorithms Representative EDA Applications Taxonomy of Modern SAT Algorithms Advanced Backtrack Search Techniques Experimental Evidence Conclusions SAT tutorial 42
Conclusions Many recent SAT algorithms and (EDA) applications l Hard Applications l – – l Bounded Model Checking Combinational Equivalence Checking Superscalar processor verification FPGA routing “Easy” Applications – Test Pattern Generation: Stuck-at, Delay faults, etc. – Redundancy Removal – Circuit Delay Computation l Other Applications – Noise analysis, etc. SAT tutorial 43
Conclusions l Complete vs. Incomplete algorithms – – – l Backtrack search (DP) Resolution (original DP) Stallmarck’s method Recursive learning Local search Techniques for backtrack search (infer implicates) – – – SAT tutorial conflict-induced clause recording non-chronological backtracking resolution, SM and RL within backtrack search formula simplification & clause inference conditions randomization & restarts 44
More Information on SAT in EDA http: //algos. inesc. pt/grasp l http: //algos. inesc. pt/sat l http: //algos. inesc. pt/~jpms (jpms@inesc. pt) l http: //andante. eecs. umich. edu/grasp_public l http: //nexus 6. cs. ucla. edu/GSRC/bookshelf/Slots/SAT/GRASP l http: //eecs. umich. edu/~karem (karem@umich. edu) l SAT tutorial 45
- Slides: 45