Sie sind auf Seite 1von 4

EECS219B LOGIC SYNTHESIS CLASS PROJECT REPORT

A Search Algorithm for Multi-Valued Satisfiability Solver


Cong Liu, Matthew W. Moskewicz, and Andreas Kuehlmann, Senior Member, IEEE

AbstractA search algorithm solving multi-valued (MV) satisfiablity (SAT) problems is proposed in this report. It is based on the general Davis-Putnam search-pruning procedure. And it incorporates several speed-up techniques: an efficient constraint propagation process, conflict-based learning, and non-chronological backtracking. Decision heuristics and some implementation techniques are also presented. Index TermsSatisfiability, search algorithm, multi-valued logic, SAT
I.

INTRODUCTION

boolean satisfiabilty (SAT) problem is a well studied subject. It appears in many contexts in the field of artificial intelligence (AI) as well as computeraided design (CAD) of integrated circuits, including logic verification, equivalence checking, timing analysis, and automatic test pattern generation (ATPG) [1]. SAT problems are classic NPcomplete problems, whose solutions are believed to have exponential worst case complexity. Many algorithms have been proposed to solve this problem, and most of them are based on the Davis-Putman procedure [2] or local search heuristics[3]. Public available SAT solvers includes GRASP [4], SATO [5], POSIT [6], and Chaff [7]. Chaff is said to be one or two orders of magnitude faster than other solvers for difficult SAT benchmarks. However all of these solvers can only deal with binaryvalued logic, in which every variable can take value either 0 or 1. But in many applications it is more natural and efficient to describe the problem as a multi-valued SAT problem. For example, in logic verification it is often desirable to describe dont care as a third value other than 0 and 1. By introducing the third value, the problem can be very efficiently formulated. Multi-valued logic is also been a well researched area. Multiple decision diagram (MDD) based multi-valued logic
HE C. Liu is with the Department of Electrical Engineering and Computer Science, University of California, Berkeley, CA 94720, USA (e-mail: congliu@eecs.berkeley.edu). M.W. Moskewicz is with the Department of Electrical Engineering and Computer Science, University of California, Berkeley, CA 94720, USA (email: mosekwcz@alumni.princeton.edu). A. Kuehlmann is with the Cadence Berkeley Lads, Berkeley, CA 94704, USA, (e-mail: kuehl@cadence.com).

verification has been implemented in MV-SIS [8]. But till now there is no SAT-based approach to multi-valued logic verification. Obviously any multi-valued SAT problem can be converted to a binary-valued SAT problem by introducing binary variable(s) to represent each multi-valued variable, which is so called encoding. But how different encoding scheme will finally affect the performance of the resulted solver is difficult to see. And any encoding scheme will introduce additional constraints, which dramatically increases the difficulty of the problem. Since a real multi-valued SAT solver directly deals with multi-valued variables, there is no need to introduce additional constraints. So it may have advantages and consequently outperform the encoding approach. II. BASIC DEFINITIONS AND NOTATIONS A. Multi-valued logic Definition 1. A multi-valued variable can take integer value from Pi = {0,1,, ,,|Pi| - 1}. Symbolic variables can take value from symbolic sets. But there is an one-to-one mapping between symbolic values (states) and integers. So symbolic representations can always be converted to the integer format. Definition 2. A multi-valued literal xi i is a binary logic function in the form of
c

xici = ( xi = 1 ) + +( xi = k ), where i ci Pi
So if a multi-valued variable is assigned to a specific value, all the corresponding multi-valued literals are either 0 or 1. B. Multi-valued Satisfiability Definition 3. A multi-valued clause is a binary function consisted of disjunction (OR) of one or more multi-valued literals. Theorem 1. A multi-valued clause is true if and only if at least one multi-valued literal is true. Definition 4. A multi-valued CNF formula is a binary function consisted of conjunction (AND) of multi-valued clauses. Theorem 2. A multi-valued CNF formula is true if and only if all the multi-valued clauses are true.

EECS219B LOGIC SYNTHESIS CLASS PROJECT REPORT

2 can skip some decision levels when backtracking. This is so called non-chronological backtracking. III. ENCODING A. One-Hot Encoding One of the first methods used to deal with multi-valued variables in logic synthesis was one-hot encoding, in which each value of each multi-valued variable is associated with a binary-valued variable. In this way, each multi-valued literal is converted to a disjunction of binary variables. If a multi-valued formula is to be encoded to a binary-valued formula, additional clauses must be added as constraints. Because in a complete assignment, each multi-valued variable can only take one specific value, only one of those binary variables originated from the same multi-valued variable is true. The number of added clauses for each multi-valued variable is: Ni =

Definition 5. A complete assignment for the multi-valued variables is a single-valued vector, in which every variable corresponds a specific value. Definition 6. A multi-valued SAT problem is satisfiable if and only if there exits a complete assignment which make the corresponding CNF formula true. It is assumed in this paper that multi-valued SAT problems are in the CNF format. C. Davis-Putnam procedure Solving a multi-valued SAT problem can be viewed as the search in the value space of multi-valued variables till find a specific value for each variable, which makes all clauses true. One of the most popular search-pruning algorithm is the DavisPutnam procedure, as shown below:
while (true) { i f ( d e ci d e ( ) ) { // branching while (deduce () == conflict) { // BCP backtrack_level = analyze_conflicts (); // conflict analys is if (backtrack_level == 0) return UNSATISFIABLE; els e back_track(backtrack_level); // backtrack } } els e // no unas s igned variables return SATISFIABLE;
}

1 ( n 1)ni , 2 i

where n i is the number of possible values of the variable. B. Binary Encoding Another way of encoding is to encode a k-valued variable with log2 k binary variables, which is called binary encoding. So each multi-valued literal corresponds a sum of product (SOP) of binary variables. It is known that converting SOP to CNF will generally increase the number of clauses. In binary encoding, excessive binary variable values are treated as dont cares, and need to be added as constraints (clauses) to the original formula. So after binary encoding, the number of clauses will also dramatically increase. IV. ALGORITHM A. Boolean Constraint Propagation It is found that in practical SAT problems, a large portion of the run time is spent on the boolean constraint propagation. So an efficient implementation of the BCP is critical to the performance. As we described before that BCP basically does two things: First, identify unit clause (literal); Second, get the implication or report a conflict. Intuitively, for any assignment we could visit each clause to i entify if the clause is a unit d clause or not. But in practical it turns out very inefficient, because in most SAT problems clauses database dominates the memory. And accessing large memory is, in practical, the bottleneck for most SAT solver. So avoiding visit clause database as much as possible is important. And as defined before a clause becomes unit clause only when all the other literals in that clause is false. So there is no need to visit those clauses in which two or more literals are not false, meaning either true or currently unknown. Two multi-valued literal watching scheme is based on the thought above. In every clause, we first pick the first (head) and last (tail) literal as the two watched literal. The clause is

The decide() is to choose a variable that is not currently assigned and pick a value from its currently allowed value set. Decision is mostly based on heuristics and it can affect the performance in a order of several magnitude [9]. After each decide(), the decision level increased by one. The deduce () is the deduction process, or so called boolean constraint propagation (BCP). It extends the current assignment by following the logic consequence of the assignments made by far. If all multi-valued literal in a clause are false then a conflict is reached. If all but one multi-valued literal in a clause are false, then the clause is called a unit clause. The remaining multi-valued literal is called unit literal. Clearly, in order to make the clause true, the unit literal must be true. So this variable must take on one of the values in its value set. This is called an implication. So deduce() is to identify unit clauses, and get the corresponding implications, or find a conflict. The analyze_conflicts() is to identify decisions which lead to the conflict and add clauses to avoid making the wrong decision again. These added clauses are called conflict-based learning. It can be viewed as a shortcut which can immediate leads to a conflict if the same wrong decisions are made again. The back_track() is to undo recent assignments till a decision which is responsible for the conflict, is reached. All the implications of these assignments are also invalid because of the conflict. It can be shown that not all the assignments made so far are responsible for the conflict. In other words, we

EECS219B LOGIC SYNTHESIS CLASS PROJECT REPORT

3 C. Conflict Analysis The purposes of conflict analysis are to identify proper backtrack level and find assignments which will lead to a conflict again. 1) Non-Chronological Backtracking As we mentioned before, there are only some decisions that are responsible for the conflict. So the most recent relevant decision level is the proper backtrack level. It means that all decisions below that level will lead to conflicts no matter what decisions are made. This feature can greatly reduce the search space, and consequently improve the performance. In the multi-valued SAT solver, every variable is associated with a decision level, which comes from either a decision or an implication. And each assignment is stored in a stack (an array of list) with the decision level as the index. When a conflict is reached, and if all possible values of last assigned variable have been tried, we visit the conflicting clause to find the assignment with the maximum decision level. In the backtracking, we need to undo assignments below the backtrack level and the implication (queue) is simply emptied. D. Learning There are a lot of learning schemes [10] that could be used in the multi-valued SAT solver. The learning in this solver is done by recursively replacing every multi-valued literal (associated to a non-decision variable) in the conflicting clause with other literals in the antecedence clause of that literal. The final clause only contains literals associated to decision variables. And literals with the same variable index are collapsed into one literal. In the following example, assume all variables can take value from {0,1,2,3}, Decisions are: x4 = 0 @ level 1, x3 = 3 @ level 2; Implications are: x2 = {0, 1} @ clause 2, x1 = 1 @ clause 3; The conflict is reached at clause 1.
{ 1 = ( x{2} + x1 2,3} + x{3} ) 2 4 {1} {0 ,1} 2 = ( x3 + x2 )
{ 3 = ( x{1,3} + x{0} + x11} ) 4 3

visited only when one of the watched literal is false. Otherwise, we only need to visit the variable database to update the variable value. S when the head literal is false, we move the o head pointer to the next literal, which is not false. And similar for the tail pointer. A unit clause (literal) is identified if one of the watched literal is false, and a conflict is identified if both watched literals are false. And if the two pointers are allowed to move forward and backward, there is no need to visit the clause when undoing an assignment to one of the watched literals in that clause. This feature also reduces the clause database access. B. Decision Heuristic There are two major concerns in the decision heuristic in a multi-valued SAT solver. One is which variable to choose, the other is which value(s) to assign. The first concern could be treated as an ordering problem, which is similar to the decision heuristics in binary SAT. The second concern is about whether to assign several values by excluding one possible value, or assign only one specific value by excluding all other possible values. Note that if several values are assigned to a variable, we only care if this assignment makes the watched literals false or not. This simplify the operations on the watched literals for each assignment. 1) Variable Ordering In general, most frequently appeared variable is chosen in order to reach a conflict or satisfy all clauses by making as few decisions (assigning a specific value) as possible. This greedy approach works quite well in most practical problems. In the solver, a counter is associated with each variable to record the number of times that the variable appears in the current clause database. And an ordered list of variables is kept. The first variable, whose counter is maximum, is chosen. 2) Choosing Value(s) If only one specific value is assigned to a multi-valued variable, all the corresponding multi-valued literals, as binary functions, is either true or false. So we make at most n, which is the number of variables, decisions to reach a conflict or get a complete assignment that satisfy all clauses. If several values are assigned to a variable, there are maybe some multi-valued literals and consequently some clauses still remain unknown after all variables have been assigned values. In order to reach a complete assignment, we still need to exclude possible values of each assigned variable till only one value is left. It could be viewed as a filtering process, after each cycle, the invalid values are filtered out. So in this approach we usually need to make more than n decisions to get a complete assignment. But the advantage of this approach is that since only one value is exclude at each step, we only need to visit clauses in which there exists the variable with the excluded value. There are definitely some trade-off between these two decision schemes.

The learned clause is

4 = ( x{1,3} + x{0 ,1} ) 4 3


If we learn based on assignments, we would learn the clause

5 = ( x{1,2 ,3} + x{0 ,1,2} ) 4 3


It is clear that in clause 4, x4 = 2, x3 = 2 will lead a n immediate conflict, but it will not if the learned clause is clause 5. It implies that even only a specific value is assigned to a variable, when a conflict occurs, we may learn more than what would expect if the learning is based on clauses. It also implies we learn the same clause as if decisions x4 = {0, 2}, x3 = {2, 3} are made.

EECS219B LOGIC SYNTHESIS CLASS PROJECT REPORT

4 VII. CONCLUSION A search algorithm for multi-valued satifiability solver is presented. It is based on the general Davis-Putnam searchpruning procedure, and incorporates speed-up techniques: an efficient constraint propagation process, conflict-based learning, and non-chronological backtracking. Decision heuristics and some implementation techniques are also discussed. ACKNOWLEDGMENT Thank Matthew and Andreas for their help during the project. My discussions with Matthew shaped the basic algorithm and data structure. Andreas gave me a lot useful advices on implementation, as well as future research directions. REFERENCES
P. Stephan, R. K. Brayton, and A. Sangiovanni-Vincentelli, Combinational Test Generation Using Satisfiability, IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, vol. 15, 1167-1176, 1996. [2] M. Davis, G. Logemann, and D. Loveland. A machine program for theorem proving., Communications of the ACM, (5):394-397, 1962. [3] B. Selman, H. Kautz, and B. Cohen. Local Search Strategies for Satisfiability Testing. DIMACS Series in Discrete Mathematics and Theoretical Computer Science, vol. 26, AMS, 1996. [4] J. P. Marques-Silva and K. A. Sakallah, GRASP: A Search Algorithm for Propositional Satisfiability, IEEE Transactions on Computers, vol. 48, 506-521, 1999. [5] H. Zhang. SATO: An efficient propositional prover, Proceedings of the International Conference on Automated Deduction, July 1997. [6] J. W. Freeman, Improvements to Propositional Satisfiability Search Algorithms, Ph.D. Dissertation, Department of Computer and Information Science, University of Pennsylvania, May 1995. [7] M. Moskewicz, C. Madigan, Y. Zhao, L. Zhang, and S. Malik. Chaff: Engineering an efficient SAT Solver, Proceedings of the Design Automation Conference, July 2001. [8] R. K. Brayton, and S. P. Khatri, Multi-valued Logic Synthesis, International Conference on VLSI Design, Jan 1999 [9] J. P. Marques-Silva, The Impact of Branching Heuristics in Propositional Satisfiability Algorithms, Proceedings of the 9th Portuguese Conference on Artificial Intelligence (EPIA), September 1999. [10] L. Zhang, C. Madigan, M. Moskewicz, and S. Malik. Efficient conflict driven learning in a Boolean satisfiability solver, International conference on Computer Aided Design, ICCAD 2001. [1]

V. DATA STRUCTURES A. Basic Database There are two major concerns when designing the internal data structure of multi-valued literals: the memory space it takes, and allowing efficient operations on them. So it is natural to use bit set to represent the value set of a literal, which is similar to the positional notation widely used in multi-valued logic synthesis. Bit operations are known very efficient. So for each literal, the variable index (an integer) and values (a bit set) are stored in the database. A clause consists of a pointer to the first literal in the clause, and number of literals it has. A variable consists of values, value space, decision level, a list of clause index in which the variable is watched, counters, and some other auxiliary data. B. Assignment Stack Every assignment is pushed into a stack, which is an array of lists. Assignments with the same decision level are put in the same list. From the algorithm described above, we know that these lists start with a decision assignment. The array index corresponds to the decision level. The stack data structure allow us to undo the recent assignments during backtracking. C. Implication Queue Every implication associated with a clause index is pushed into a queue. The clause index represents which clause this implication comes from, which is used in conflict analysis, and is essential when building the implication graph. The queue data structure allow us to process earlier implications first. And when conflict happens, there is no need to process the rest implications. VI. FUTURE RESEARCH DIRECTIONS There are a lot of features that could be added to this MVSAT solver to improve its performance. The future work includes: 1. Decision heuristics generally affect the performance in a magnitude of several orders. But good decision heuristic are application dependent. So if we know more about the application, we can make a better decision heuristic. But the relation between application and the decision heuristic is still not totally understood. 2. Try different learning schemes, e.g. UP to find a good learning scheme. 3. Use pure literal rule as an alternative or assistance to the two-literal-watch scheme for the boolean constraint propagation. 4. Convert a binary SAT problem to a MV-SAT problem by combining several binary variables to a MV variable. Generally speaking, we would prefer combine those strong- related binary variables, meaning they often appear in the same clause. It is not known if this decoding will reduce the time the solving the binary SAT problem.

Das könnte Ihnen auch gefallen