3
SAT in a Nutshell Given a Boolean formula (propositional logic formula), find a variable assignment such that the formula evaluates to 1, or prove that no such assignment exists. For n variables, there are 2 n possible truth assignments to be checked. First established NP-Complete problem. S. A. Cook, The complexity of theorem proving procedures, Proceedings, Third Annual ACM Symp. on the Theory of Computing,1971, F = (a + b)(a’ + b’ + c) a bb cccc

35
Satisfied Literal Unsatisfied Literal Unassigned Literal (a +b’+  c)(b +  c’)(a’ +  c’) a = T, b = T, c is unassigned Implication A variable is forced to be assigned to be True or False based on previous assignments. Unit clause rule (rule for elimination of one literal clauses) An unsatisfied clause is a unit clause if it has exactly one unassigned literal. The unassigned literal is implied because of the unit clause. Boolean Constraint Propagation (BCP) Iteratively apply the unit clause rule until there is no unit clause available. a.k.a. Unit Propagation Workhorse of DLL based algorithms. Implications and Boolean Constraint Propagation

36
Features of DLL Eliminates the exponential memory requirements of DP Exponential time is still a problem Limited practical applicability – largest use seen in automatic theorem proving Very limited size of problems are allowed 32K word memory Problem size limited by total size of clauses (1300 clauses)

60
Restart Abandon the current search tree and reconstruct a new one Helps reduce variance - adds to robustness in the solver The clauses learned prior to the restart are still there after the restart and can help pruning the search space x2x2 x1x1 x4x4 x3x3 x4x4 x3x3 x5x5 x5x5 x5x5 x5x5 Conflict clause: x1’+x3+x5’ x2x2 x1x1 x3x3 x5x5

61
SAT becomes practical! Conflict driven learning greatly increases the capacity of SAT solvers (several thousand variables) for structured problems Realistic applications became plausible Usually thousands and even millions of variables Typical EDA applications that can make use of SAT circuit verification FPGA routing many other applications… Research direction changes towards more efficient implementations

65
Chaff Philosophy Make the core operations fast profiling driven, most time-consuming parts: Boolean Constraint Propagation (BCP) and Decision Emphasis on coding efficiency and elegance Emphasis on optimizing data cache behavior As always, good search space pruning (i.e. conflict resolution and learning) is important Recognition that this is as much a large (in-memory) database problem as it is a search problem.

67
BCP Algorithm (1/8) What “causes” an implication? When can it occur? All literals in a clause but one are assigned to False (v1 + v2 + v3): implied cases: ( v3) or (0 + v2 + 0) or (v ) For an N-literal clause, this can only occur after N-1 of the literals have been assigned to False So, (theoretically) we could completely ignore the first N-2 assignments to this clause In reality, we pick two literals in each clause to “watch” and thus can ignore any assignments to the other literals in the clause. Example: (v1 + v2 + v3 + v4 + v5) ( v1=X + v2=X + v3=? {i.e. X or 0 or 1} + v4=? + v5=? )

73
BCP Algorithm (3.2/8) We begin by processing the assignment v1 = F (which is implied by the size one clause) n To maintain our invariants, we must examine each clause where the assignment being processed has set a watched literal to F. n We need not process clauses where a watched literal has been set to T, because the clause is now satisfied and so can not become unit. State:(v1=F) Pending: v2 + v3 + v1 + v4 + v5 v1 + v2 + v3’ v1 + v2’ v1’+ v4

74
BCP Algorithm (3.3/8) We begin by processing the assignment v1 = F (which is implied by the size one clause) n To maintain our invariants, we must examine each clause where the assignment being processed has set a watched literal to F. n We need not process clauses where a watched literal has been set to T, because the clause is now satisfied and so can not become unit. n We certainly need not process any clauses where neither watched literal changes state (in this example, where v1 is not watched). State:(v1=F) Pending: v2 + v3 + v1 + v4 + v5 v1 + v2 + v3’ v1 + v2’ v1’+ v4

77
BCP Algorithm (4.2/8) Now let’s actually process the second and third clauses: n For the second clause, we replace v1 with v3’ as a new watched literal. Since v3’ is not assigned to F, this maintains our invariants. n The third clause is unit. We record the new implication of v2’, and add it to the queue of assignments to process. Since the clause cannot again become unit, our invariants are maintained. State:(v1=F) Pending: State:(v1=F) Pending:(v2=F) v2 + v3 + v1 + v4 + v5 v1 + v2 + v3’ v1 + v2’ v1’+ v4 v2 + v3 + v1 + v4 + v5 v1 + v2 + v3’ v1 + v2’ v1’+ v4

78
BCP Algorithm (5/8) Next, we process v2’. We only examine the first 2 clauses. n For the first clause, we replace v2 with v4 as a new watched literal. Since v4 is not assigned to F, this maintains our invariants. n The second clause is unit. We record the new implication of v3’, and add it to the queue of assignments to process. Since the clause cannot again become unit, our invariants are maintained. State:(v1=F, v2=F) Pending: State:(v1=F, v2=F) Pending:(v3=F) v2 + v3 + v1 + v4 + v5 v1 + v2 + v3’ v1 + v2’ v1’+ v4 v2 + v3 + v1 + v4 + v5 v1 + v2 + v3’ v1 + v2’ v1’+ v4

83
SATO H. Zhang, M. Stickel, “An efficient algorithm for unit-propagation” Proc. of the Fourth International Symposium on Artificial Intelligence and Mathematics, H. Zhang, “SATO: An Efficient Propositional Prover” Proc. of International Conference on Automated Deduction, The Invariants Each clause has a head pointer and a tail pointer. All literals in a clause before the head pointer and after the tail pointer have been assigned false. If a clause can become unit via any sequence of assignments, then this sequence will include an assignment to one of the literals pointed to by the head/tail pointer.

84
BCP Algorithm Summary During forward progress: Decisions and Implications Only need to examine clauses where watched literal is set to F Can ignore any assignments of literals to T Can ignore any assignments to non-watched literals During backtrack: Unwind Assignment Stack Any sequence of chronological unassignments will maintain our invariants So no action is required at all to unassign variables. Overall Minimize clause access

85
Decision Heuristics – Conventional Wisdom DLIS (Dynamic Largest Individual Sum) is a relatively simple dynamic decision heuristic Simple and intuitive: At each decision simply choose the assignment that satisfies the most unsatisfied clauses. However, considerable work is required to maintain the statistics necessary for this heuristic – for one implementation: Must touch *every* clause that contains a literal that has been set to true. Often restricted to initial (not learned) clauses. Maintain “sat” counters for each clause When counters transition 0  1, update rankings. Need to reverse the process for unassignment. The total effort required for this and similar decision heuristics is *much more* than for our BCP algorithm. Look ahead algorithms even more compute intensive C. Li, Anbulagan, “Look-ahead versus look-back for satisfiability problems” Proc. of CP, 1997.

86
Chaff Decision Heuristic - VSIDS Variable State Independent Decaying Sum Rank variables by literal count in the initial clause database Only increment counts as new clauses are added. Periodically, divide all counts by a constant. Quasi-static: Static because it doesn’t depend on variable state Not static because it gradually changes as new clauses are added Decay causes bias toward *recent* conflicts. Use heap to find unassigned variable with the highest ranking Even single linear pass though variables on each decision would dominate run-time! Seems to work fairly well in terms of # decisions hard to compare with other heuristics because they have too much overhead

87
Interplay of BCP and the Decision Heuristic This is only an intuitive description … Reality depends heavily on specific instance Take some variable ranking (from the decision engine) Assume several decisions are made Say v2=T, v7=F, v9=T, v1=T (and any implications thereof) Then a conflict is encountered that forces v2=F The next decisions may still be v7=F, v9=T, v1=T !  VSIDS variable ranks change slowly… But the BCP engine has recently processed these assignments …  so these variables are unlikely to still be watched. In a more general sense, the more “active” a variable is, the more likely it is to *not* be watched.

88
Interplay of Learning and the Decision Heuristic Again, this is an intuitive description … Learnt clauses capture relationships between variables Learnt clauses bias decision strategy to a smaller set of variables through decision heuristics like VSIDS Important when there are 100k variables! Decision heuristic influences which variables appear in learnt clauses Decisions →implications →conflicts →learnt clause Important for decisions to keep search strongly localized

92
Reconciling Theoretical and Practical Results Many unsat instances have provably exponential lower bounds for resolution based solvers Solving random SAT instances is hard for most solvers How come we manage to do as well as we do? “Short Proofs are Narrow – Resolution Made Simple”, Eli Ben- Sasson, Avi Wigderson, JACM, Vol 48 no. 2, Mar 2001 learn short conflict clauses to find shorter proofs

93
Certifying a SAT Solver Do you trust your SAT solver? If it claims the instance is satisfiable, it is easy to check the claim. How about unsatisfiable claims? Search process is actually a proof of unsatisfiability by resolution Effectively a series of resolutions that generates an empty clause at the end Need an independent check for this proof Must be automatic Must be able to work with current state-of-the-art SAT solvers The SAT solver dumps a trace (on disk) during the solving process from which the resolution graph can be derived A third party checker constructs the empty clause by resolution using the trace

94
Extracting an Unsatisfiable Core Extract a small subset of unsatisfiable clauses from an unsatisfiable SAT instance Motivation: Debugging and redesign: SAT instances are often generated from real world applications with certain expected results: If the expected result is unsatisfiable, but the instance is satisfiable, then the solution is a “stimulus” or “input vector” or “counter-example” for debugging  Combinational Equivalence Checking  Bounded Model Checking What if the expected result is satisfiable?  SAT Planning  FPGA Routing Relaxing constraints: If several constraints make a safety property hold, are there any redundant constraints in the system that can be removed without violating the safety property?

95
The Core as a Checker By- Product Original Clauses Learned Clauses Empty Clause Core Clauses Can do this iteratively Can result in very small cores

96
Summary Rich history of emphasis on practical efficiency. Presence of drivers results in maximum progress. Need to account for computation cost in search space pruning. Need to match algorithms with underlying processing system architectures. Specific problem classes can benefit from specialized algorithms Identification of problem classes? Dynamically adapting heuristics? We barely understand the tip of the iceberg here – much room to learn and improve.