Permutation Independent Comparison of Pseudo Boolean Functions

0 downloads 0 Views 200KB Size Report
function f that is independent of the permutation of the other input variables of f. .... pseudo Boolean function f : {0, 1}n → Z can be represented by a ∗Bmd. Just.
Permutation Independent Comparison of Pseudo Boolean Functions Riccardo Forth

Paul Molitor

Institute for Computer Science Martin–Luther–University Halle–Wittenberg 06099 Halle, Germany E-mail: @informatik.uni-halle.de Abstract We address the problem of permutation independent comparison of two pseudo Boolean functions given by multiplicative binary moment diagrams (∗Bmds), i. e., the problem of deciding whether there exists a permutation of the input variables such that the two ∗Bmds are equal. The analogous problem has already been investigated for binary decision diagrams (Bdds) in detail [5, 7, 8, 9, 10]. All these methods successfully use signatures which are permutation independent attributes of the input variables. Unfortunately, the signatures for Bdds cannot be applied to ∗Bmds. In this paper, we present signatures for ∗Bmds and prove their efficiency by extensive benchmark computations. In particular we show that the signatures for ∗Bmds are as efficient as signatures for Bdds.

1. Introduction Checking for equivalence of two Boolean functions is a general and important task in logic synthesis and verification of integrated circuits [6]. By using canonical representations of Boolean functions, this equivalence problem reduces to checking for equality of the two canonical representations. If the Boolean functions are given by reduced ordered binary decision diagrams (Bdds) [2] or reduced ordered multiplicative binary moment diagrams (∗Bmds) [1] which are canonical representations of Boolean functions, this check can be made in constant time. Unfortunately, Bdds and ∗Bmds are canonical representations of Boolean functions only for fixed variable orders and the correspondence between the input variables of the two Boolean functions under consideration are often unknown. For illustration, look at the physical design of sequential circuits. During the place and route phase the latches are placed and reordered on the chip. Thus the correspondence between the latches of the golden specification and the latches of the synthesized circuit is lost in some cases. However, the order of the primary outputs of the combinational circuit which realizes the output function of the finite state machine usually remains fixed during the place and route phase. Thus, in order to formally verify the combinational part of the sequential circuit after the place and route phase, the correspondence between the inputs of the synthesized combinational circuit and the inputs of the golden specification have to be re-established. The correspondence between the outputs is known. The corresponding decision problem as to whether two Boolean functions are isomorphic is called isomorphism problem in computation theory [11]. Unfortunately, the complexity of the isomorphism problem for decision diagrams is still unknown, even for single-output Boolean functions. On the one hand, no polynomial algorithm solving this problem is known. On the other hand, the problem has not been proven to be NP-hard. The only thing which is known about the problem is that it is in NP and that it is not NP-hard unless the polynomial hierarchy collapses [12]. Testing each possible correspondence is not practical because two Boolean functions with n input variables have n! of these correspondences. Many heuristics have been proposed in the literature in the last seven years [3, 4, 5, 7, 8, 9, 10]. All these methods use signatures to identify the input variables. A signature assigns a permutation independent value to each input variable. If each variable of a Boolean function has a unique signature value, then there is at most one permissible correspondence between the input variables of this Boolean function and any other Boolean function because an input variable can only correspond to an input variable

1

which has the same signature value. The experimental results made in [7, 8, 9] prove that signatures applied to Bdds are very efficient and allow to identify the input variables of the Boolean functions unless the Boolean functions are invariant under application of some permutations of the input variables. Of course, the permutation independent comparison problem also has to be taken up if the combinational circuits are given by ∗Bmds. Unfortunately, the signatures proposed for Bdds cannot be applied to ∗Bmds because of the different decomposition types used at the inner nodes of both decision diagrams. To the best of our knowledge, signatures for ∗Bmds have not been presented in the literature till now. In this paper, we present efficient signatures for ∗Bmds. We prove by experiments that they are (almost) as efficient as signatures for Bdds are. The paper is structured as follows. In Section 2, we explain some basic notions, we give a formal definition of the permutation independent comparison problem for pseudo Boolean functions and signatures. Furthermore, we present ∗Bmds and monomial expressions which are related canonical representations of pseudo Boolean functions. Signatures which can be applied to ∗Bmds are presented in Section 3. The paper closes with experimental results which prove the approach to be very efficient (Section 4) and some conclusions (Section 5).

2. Preliminary 2.1. Some basic definitions In the following, let f : {0, 1}n → Z be a pseudo Boolean function with n input Boolean variables x1 , . . . , xn . ˜ n and the set of the Boolean variables x1 , . . . , xn We will denote the set of these pseudo Boolean functions by B by X. ˜ n with respect to a variable xi is the pseudo Boolean The positive cofactor of the pseudo Boolean function f ∈ B ˜ function fxi ∈ Bn defined by fxi (α1 , . . . , αi−1 , αi , αi+1 , . . . , αn ) : = f (α1 , . . . , αi−1 , 1, αi+1 , . . . , αn ). Analogous, the negative cofactor fx0i is given by setting xi to 0. Let Pn be the set of all possible permutations on the set X of the variables. The pseudo Boolean function f is called symmetric with respect to a sub-group G ⊆ P if f is invariant under application of any input permutation π ∈ G, i. e., f = f ◦ π. In particular, if f is invariant under application of each permutation of the variables of some subset Xsym ⊆ X, then f is called (partially) symmetric with respect to subset Xsym .

2.2. Signature A signature is defined to be a function which assigns a characteristic to any input variable of a pseudo Boolean function f that is independent of the permutation of the other input variables of f . Formally, a signature can be defined as follows: Definition

˜ n × X → U is a signature iff Let U be an ordered set. A function S : B ˜ n ∀π ∈ Pn ∀xi ∈ X : ∀f ∈ B

S(f, xi ) = S(f ◦ π, πi (x1 , . . . , xn )).

(1)

With signatures each input variable can be characterized independently of the permutation applied. Thus, the signature value of variable xi with respect to f must be the same as the signature value of xj := πi (x1 , . . . , xn ) with respect to f ◦ π. Properties

Signatures have the following three features:

1. A signature partitions set X of the input variables into disjoint subsets. Each variable of a class has the same signature value. 2. If we have several signatures, each signature can refine the variable partition. Of course, each signature is applied to the variables only once because applying a signature several times to the same variable does not bring new information. 2

3. If each variable of f has a unique signature value, then there is at most one permissible correspondence of the input variables of f to the input variables of any other pseudo Boolean function g under which both functions are equal. The approach to use signatures for input permutation independent comparison of functions is based on Feature 3. If it is possible to construct a signature which uniquely identifies the input variables of any (pseudo) Boolean function, the input correspondence problem would be solved. Unfortunately, there is no hope to meet this goal. There is no signature which can assign different signature values to the variables of (pseudo) Boolean functions which are symmetric with respect to some non-trivial sub-group G of the permutation group Pn . More precisely, Mohnke et. al. [7, 9] have proven that there exists a universal signature which distinguishes between two variables xi and xj of a (pseudo) Boolean function f if and only if there is no permutation π of the variables of f with πi (x1 , . . . , xn ) = xj and f ◦ π = f . Unfortunately, the universal signature cannot be applied in practice because its computational complexity. Therefore we are looking for simple signatures able to uniquely identify most of the input variables of a (pseudo) Boolean function which are distinguishable on principle.

2.3. Multiplicative Binary Moment Diagrams Binary Moment Diagrams (Bmds) are based on the Shannon decomposition of a pseudo Boolean function f : {0, 1}n → Z. For this, let xi be a Boolean variable of f . Then f can be decomposed with respect to xi by = (1 − xi ) · fx0i + xi · fxi = fx0i + xi · (fxi − fx0i ).

f

(2) (3)

Note that the operations +, -, and · represent integer addition, integer subtraction, and integer multiplication, respectively. Thus, a Bmd decomposes a pseudo Boolean function in two moments, the constant moment fx0i and the linear moment fx˙i := fxi − fx0i . The linear moment represents the variation of f when xi changes from 0 to 1. More formally, a Bmd is a rooted directed acyclic graph. Each inner node is marked by some variable xi . Furthermore, each inner node v has exactly two children, the low-son low(v) which represents the constant moment of the pseudo Boolean function fv (with respect to variable xi ) represented by the Bmd rooted by v and the high-son high(v) which represents the linear moment of fv . Thus, the pseudo Boolean function fv represented by an inner node v is given by fv = flow(v) + xi · fhigh(v) .

(4)

Terminals are marked by integer values and represent the corresponding constant pseudo Boolean functions. The representation of pseudo Boolean functions becomes even more efficient if integer edge weights are introduced which act as multiplicative factors. The resulting decision diagram type is called multiplicative binary moment diagram (∗Bmd). More formally, for each inner node v marked by some Boolean variable xi the equation fv = wlow(v) · flow(v) + xi · whigh(v) · fhigh(v)

(5)

holds. Here, wlow(v) and whigh(v) represent the edge weights of the low-edge and the high-edge of v, respectively. Thus, sub-∗Bmds which only differ in a multiplicative factor can be represented by only one sub-graph. Due to this sharing, the size of a ∗Bmd of a pseudo Boolean function is often smaller than the corresponding Bmd.

2.4. Monomial expressions It is easy to see that every pseudo Boolean function f : {0, 1}n → Z can be represented by a ∗Bmd. Just recursively decompose f into the constant moment fx0i and the linear moment fx˙i with respect to some variable xi on which f depends. Thus, each pseudo Boolean function f can be represented by a linear expression n

f=

2 X

bi

bi

bi

ai · x1x1 x2x2 · . . . · xnxn

i=1

3

(6)

which is called complete monomial expansion of f . Here ai is a numerical coefficient from Z and bixj ∈ {0, 1} defines whether the ith monom of f contains variable xj . If bixj = 1 holds, then the ith monom of f contains variable xj . A monom i of f is called real if its coefficient ai is not zero. Of course, deleting the non-real monoms from the complete monomial expression does not alter the pseudo Boolean function f described. We will call this reduced representation monomial expansion of f in the following. Example Let f be the pseudo Boolean function defined by f = 8 + 12x − 20xz + 2yz + 2xyz. Then, the monomial expansion of f is given by f = 8 · x0 y 0 z 0 + 12 · x1 y 0 z 0 − 20 · x1 y 0 z 1 + 2 · x0 y 1 z 1 + 2 · x1 y 1 z 1 . It contains all monoms with non-zero coefficients.

2.5. Satisfy Count While the satisfy count |g| := size({α ∈ {0, 1}n : g(α) = 1}) of a Boolean function g : {0, 1}n → {0, 1} is well-defined and can be applied during permutation independent Boolean comparison, this notion applied to pseudo Boolean functions makes no sense at first sight. However, note that the satisfy count of a Boolean function g corresponds to the number of paths from the root to the 1-leaf of the Bdd of g. Of course, this definition can be generalized to pseudo Boolean functions. Thus, if ˜ n is a pseudo Boolean function, |f | can be defined to be the number of the real monoms of f which f ∈ B corresponds to the number of paths from the root to a non-zero leaf of the ∗Bmd of f . More formally, |f | is defined by |f | = size({i : i is a monom of f with coefficient ai 6= 0}).

(7)

3. Signatures for pseudo Boolean functions This section presents signatures for pseudo Boolean functions. In particular, we show how to compute the signature values of the variables of pseudo Boolean functions by applying ∗Bmds.

3.1. Cofactor Signatures Most signatures for Boolean functions g are based on the satisfy count of the cofactors of g. By the generalization of the notion satisfy count to pseudo Boolean functions, this idea can be adopted for permutation independent comparison of pseudo Boolean variables.

˜ n × X → N0 assigns the number of Signature 1 The most obvious signature which we will denote by S1 : B real monoms of f , which do not contain variable xi , to xi , i. e., S1 (f, xi ) = |fx0i |.

(8)

Signature 2 The second signature, which we have considered, relates to the linear moment of the pseudo Boolean function. It is given by the number of real monoms which contain variable xi , i. e., S2 (f, xi ) = |fx˙i |.

(9)

Signature 3 The third cofactor signature considers the positive cofactor fxi of f which is given by addition of the corresponding constant and linear moments, i. e., fxi = fx0i + fx˙i . More formally, signature S3 is defined by S3 (f, xi ) = |fxi |. 4

(10)

Computational Complexity If the pseudo Boolean function f is given by a ∗Bmd F , then signature S1 and signature S2 applied to a variable xi can be computed in time O(size(F )) without constructing new ∗Bmds and without changing the variable order of F . Just count the number of paths in F which do not contain a high-edge (low-edge) of a node marked by xi . The computation of signature S3 is a little bit more expensive. Here, the ∗Bmd of the pseudo Boolean function fx0i + fx˙i has to be constructed first. Fortunately, this can also be done in time O(size(F )) because of the inequation max {|fx0i |, |fx˙i |} ≤ |fxi | ≤ |fx0i | + |fx˙i |.

(11)

Properties of the cofactor signatures There is a quite simple relation between the first two cofactor signatures just described, namely |f | = |fx0i | + |fx˙i |.

(12)

It states that signature S1 distinguishes between two variables xi and xj if and only if signature S2 distinguishes between these two variables. More formally, let L(S, f ) be the set of the variables of the pseudo Boolean function f that obtain a unique identification by signature S, then the equation L(S1 , f ) = L(S2 , f ) holds for any pseudo Boolean function f . An analogous relation does not exist between signature S1 and S3 . There is a pseudo Boolean function f such that neither L(S1 , f ) 6⊆ L(S3 , f ) nor L(S1 , f ) 6⊇ L(S3 , f ) holds. Thus, both signatures have to be applied. Example Let f = 8 + 12x − 20xz + 2yz + 2xyz be the pseudo Boolean function from above. Then the signatures S1 , S2 and S3 for the variables x, y, and z are given by |fx0 | = 2, |fx˙ | = 3, |fx | = 3,

|fy0 | = 3, |fy˙ | = 2, |fy | = 4,

|fz0 | = 2, |fz˙ | = 3, |fz | = 4.

3.2. Considering the coefficients of the monomial expansion The three cofactor signatures only give information on the number of real monoms of the cofactors fx0i and fxi of the pseudo Boolean function f under consideration. The exact coefficients of the monomial expansion of f have not yet been considered. In this section, we will present a new signature which adds information on the coefficients to the characterization of a variable. Signature 4 The signature value S4 (f, xi ) of variable xi with respect to the pseudo Boolean function f is formally defined to be the multiset (or unordered list)

S4 (f, xi ) = h (aj , ak ) : bk

bk

bk

k is a real monom with k = ak · x1x1 x2x2 · . . . · xnxn , bj

bj

bj

j is a monom with j = aj · x1x1 x2x2 · . . . · xnxn , bkxi = 1, bjxi = 0, and ∀xl 6= xi

bjxl = bkxl

i.

(13)

Thus, the signature value S4 (f, xi ) is a multiset of ordered pairs (aj , ak ). ak is the coefficient of a real monom k of f which contains variable xi , i. e., bkxi = 1 and ak 6= 0. aj is the coefficient of a monom j which does not contain variable xi , i. e., bkxi = 0. All the other variables which are contained in monom k are also in monom j and vice versa, i. e., ∀xl 6= xi bjxl = bkxl . Note that monom j must not be a real monom. Example Let us consider the pseudo Boolean function f = 8 · x0 y 0 z 0 + 12 · x1 y 0 z 0 − 20 · x1 y 0 z 1 + 2 · x0 y 1 z 1 + 2 · x1 y 1 z 1 . Then, the signature S4 of the variables x, y and z are given by S4 (f, x) S4 (f, y) S4 (f, z)

= h(8, 12), (0, −20), (2, 2)i, = h(0, 2), (−20, 2)i = h(12, −20), (0, 2), (0, 2)i. 5

The computation of the signature value S4 (f, xi ) is much more expensive than the computation of the cofactor signatures presented in the previous section. We have to sift variable xi to the last position of the variable order of the Bmd or ∗Bmd. Then, we compute for each node v marked by xi the number nv of paths from the root to v. This can be done by one top down pass over the decision diagram. Obviously, S4 (f, xi ) contains the pair (low(v), high(v)) exactly nv times for all node v marked by xi . Other pairs are not contained in S2 (f, xi ). If f is represented by a ∗Bmd, then we have to multiply the elements of each pair by the product of edge weights on the corresponding path. Because of the huge number of paths in a ∗Bmd, the computation of this signature can be exponential in the number of variables. For this reason, we present two restricted versions of signature S4 whose computation time is linear in the size of the ∗Bmd after having sifted the variable under consideration to the last position of the variable order. Signature 4a Signature S4a does not enumerate the pairs explicitely, but forms the sum over the first components and the sum over the second components. More formally, S4a is defined by   X X aj , ak  . (14) S4a (f, xi ) =  (aj ,ak )∈S4 (f,xi )

(aj ,ak )∈S4 (f,xi )

It is easy to see that S4a (f, xi ) can be computed without computing S4 (f, xi ). Signature 4b Signature S4b only determines the size of S4 , i. e., the number of pairs of signature S4 (f, xi ).

3.3. Discussion Signature S4 seems to be a very powerful signature as we can prove that L(S1 ), L(S2 ), L(S3 ), L(S4a ), L(S4b ) ⊂ L(S4 )

(15)

holds, i. e., signature S4 dominates the five other signatures. Unfortunately, the computation of the signature values S4 (f, xi ) is rather hard, so that it seems to be a good idea to first apply the non-expensive signatures S1 , S3 , S4a , and S4b . Following this step, Signature S4 is applied only to those variables which are not yet uniquely identified. Relations between the signatures S1 , S3 , S4a , and S4b do not exist. Thus, the best order in which these signatures should be applied should to be chosen according to their performances.

4. Experimental Results We have implemented the signatures which we have presented in the previous section and applied them to the set of those LGSynth91 benchmarks for which we could construct the corresponding ∗Bmds. As the benchmarks of LGSynth91 represent Boolean functions, we have consecutively numbered the outputs. The ith output has been weighted by 2i . By adding the weighted Boolean outputs, the benchmarks can be interpreted as pseudo Boolean functions. For the experiments, we have applied the signatures in the following order: S4a → S4b → S1 → S3 → S4 . This order has been determined by the performance of the signatures. Table 1 summarizes the experiments made. The first three columns specify the benchmarks (circuit name, number of outputs, number od inputs). Column 4 gives the number of variables which can be uniquely identified by Bdd-based signatures. These results have been proven to be optimal in most cases [7, 9]. Column 5 shows the number of variables uniquely identified by ∗Bmd-based signatures. In both cases partial symmetric variables have been filtered out (see column 6). This experimentally proves that the signatures presented in this paper also compute optimal results in most cases. The running time for applying the signatures on SUN SPARCstations is within some seconds.

6

#variables name

#o

#i

best which can be done

uniquely identified

partial symmetric

C17 alu2 alu4 b1 b9 c8 cc cm138a cm150a cm151a cm152a cm162a cm163a cm42a cm82a cm85a count cu decod frg1 lal majority mux parity pcle pcler8 pm1 sct t481 tcon term1 ttt2 unreg vda x2

2 6 8 4 21 18 20 8 1 2 2 5 5 10 3 3 16 11 16 3 19 1 1 1 9 17 13 15 1 16 10 21 16 39 7

5 10 14 3 41 28 21 6 21 12 11 14 16 4 5 11 35 14 5 28 26 5 21 16 19 27 16 19 16 17 34 24 36 17 10

5 10 14 1 31 28 21 4 3 3 2 12 12 4 0 11 33 14 5 26 16 1 3 0 19 27 9 19 0 17 13 24 36 17 8

5 10 14 1 31 28 21 4 3 3 2 12 12 4 0 11 33 14 5 20 16 1 3 0 19 27 9 19 0 17 13 24 36 17 8

0 0 0 2 10 0 0 2 0 0 0 2 4 0 5 0 2 0 0 2 10 4 0 16 0 0 7 0 0 0 2 0 0 0 2

Table 1: The experimental results

7

5. Conclusions In this paper we have successfully tried to generalize the approach of signatures to pseudo Boolean functions represented by ∗Bmds. To the best our knowledge, this is the first time that signatures applicable to ∗Bmds have been presented. Experiments have proven these signatures to be very efficient. Thus, input permutation independent Boolean comparison of pseudo Boolean functions can be efficiently done in most cases when both pseudo Boolean functions are given by ∗Bmds.

References [1] R. Bryant and Y. Chen. Verification of arithmetic functions with binary moment diagrams. Design Automation Conf., pages 535–541, 1995. 1 [2] R.E. Bryant. Graph–based algorithms for Boolean function manipulation. IEEE Trans. on CAD, 35(8):677– 691, 1986. 1 [3] I. Cheng, D. and M. Marek Sadowska. Verifying equivalence of functions with unknown input correspondence. In European Conf. on Design Automation, pages 81–85, February 1993. 1 [4] R. Burch J. and E. Long D.˙ Efficient Boolean function matching. In IEEE Int’l Conf. on CAD, pages 408–411, November 1992. 1 [5] Y.-T. Lai, S. Sastry, and M. Pedram. Boolean matching using binary decision diagrams with applications to logic synthesis and verification. In Int’l Conf. on Computer Design, pages 452–458, October 1992. 1, 1 [6] S. Malik, A.R. Wang, R.K. Brayton, and A. Sangiovanni-Vincentelli. Logic verification using binary decision diagrams in a logic synthesis environment. In IEEE Int’l Conf. on CAD, pages 6–9, November 1988. 1 [7] J. Mohnke. A signature-based approach to formal logic verification. PhD thesis, Department of Mathematics and Computer Science, Martin-Luther-University Halle-Wittenberg, 06099 Halle (Saale), Germany, 1999. 1, 1, 2, 3, 6 [8] J. Mohnke and S. Malik. Permutation and phase independent Boolean comparison. INTEGRATION, the VLSI journal, 16:109–129, 1993. 1, 1, 2 [9] J. Mohnke, P. Molitor, and S. Malik. Limits of using signatures for permutation independent Boolean comparison. In Asia and South Pacific Design Automation Conf., pages 459–464, August 1995. 1, 1, 2, 3, 6 [10] U. Schlichtmann, F. Brglez, and P. Schneider. Efficient Boolean matching based on unique variable ordering. In Int’l Workshop on Logic Synthesis, May 1993. 1, 1 [11] T. Thierauf. The computational complexity of equivalence and isomorphism problems. Habilitationsschrift, University Ulm, Germany, February 1998. 1 [12] T. Thierauf. The isomorphism problem for read-once branching programs and arithmetric circuits. In Chicago Journal of Theoretical Computer Science, 1998. 1

8