An Efficient Algorithm for the Calculation of Generalized Adding and Arithmetic Transforms from Disjoint Cubes of Boolean Functions

A new algorithm is given that converts a reduced representation of Boolean functions in the form of disjoint cubes to Generalized Adding and Arithmetic spectra. Since the known algorithms that generate Adding and Arithmetic spectra always start from the truth table of Boolean functions the method presented computes faster with a smaller computer memory. The method is extremely efficient for such Boolean functions that are described by only few disjoint cubes and it allows the calculation of only selected spectral coefficients, or all the coefficients can be calculated in parallel.


I. INTRODUCTION
Manipulations and calculations of discrete functions is a fundamental task in many areas of Computer Science and Engineering ranging from applied mathematics, linear integer programming to artificial intelligence and in Computer-Aided Design of digital circuits [1][2][3][4][5][6][7]. For example, efficiently answering questions about satisfiability, tautology, equivalence and classification of Boolean functions has immense applications in various problems of CAD such as synthesis, verification, testing, library matching etc. It has been shown [1,8,9] that many of the above tasks can be efficiently performed when original Boolean domain is converted to standard arithmetic opera- predicates introduced by Hunt [10] that were also used for development of description for reliability of engineering systems [1,7]. A search on trees and graphs is often used in expert systems. There are many ways to generate and store graph [11]. Description of a class of graphs by linear Arithmetic expansion can be useful in a number of cases [4].
The need for working without traditional Boolean operators (NOT, OR, AND, EXOR, NOR, NAND) can also be found in the area of a stochastics (probabilistics) of Boolean analysis [5,7]. The main practical reason for a big interest in representing Boolean functions written as polynomials with standard symbols "+", "-", and "o" for addition, subtraction, and multiplication, respectively, is the easy way of the calculation of the expected value of such a polynomial. It is especially the case when the variables are stochastically independent of each other. Boolean polynomials are nothing else than the orthogonal expansions of the corresponding Boolean functions by the set of basis functions from an Arithmetic transform [5,12,13]. It should be noted, however, that the standard definition of such basis functions does not allow on the negation of any variables of Boolean functions and it is the reason why all the variables in Boolean polynomials are in affirmation [12]. When Boolean polynomials were used in testing, only variables in affirmation were considered [3,14,15].
Links between Reed-Muller and Arithmetic transforms for all not negated variables (so called "zero' polarity of both transforms) were investigated in [5,13]. Since Reed-Muller transform of an n-variable Boolean function is known to have 2 different polarities (such a transform is called a Generalized transform) [16,17], the same concept was applied to Arithmetic transform and the Generalized Arithmetic transform was introduced in [18]. Another counterpart of Generalized Reed-Muller transform based only on addition of real numbers is a Generalized Adding transform introduced in [18]. The Adding transform has been found useful in a recently proposed signature-based library search mapper that is able to distinguish the nonequivalent functions with very low aliasing [19].
By using Generalized Arithmetic transform in an optimal polarity for a given Boolean function the number of terms in Boolean polynomial can be minimized which results in faster calculation of the value of such a polynomial. Generalized Adding transform is also useful when the incompletely specified Boolean functions are to be represented in the form of Generalized Reed-Muller expansions [16,17]. When  As mentioned above Arithmetic and Adding transforms find applications in various problems of CAD and in probabilistics of Boolean analysis and testing. In many such applications the values of only some spectral coefficients are needed which is for example in the case of testing [3]. Therefore, there exists a need for efficient way of calculation for both transforms that has the following properties: ability to evaluate only some chosen spectral coefficients, operations on both completely and incompletely specified Boolean functions, and the usage of efficient reduced representation of Boolean functions to calculate spectrum. Recently, the methods have been shown which operate on various decision diagrams to calculate and store the resulting Arithmetic and Adding spectra [20,21]. These methods can be used efficiently in various CAD systems and the decision diagrams can represent the original Boolean functions and their Arithmetic spectra.  [6,20,21,23] have input data to the algorithm. In order to use proved to be very convenient data structures for Boolean functions that are represented as rainmajority of discrete functions representations terms or arrays of non disjoint cubes, the input permitting manipulations and calculation with data are preprocessed by a fast algorithm that large discrete functions efficiently in terms of space generates on array of disjoint ON-cubes (in the and time. Therefore they are frequently used to case of completely specified Boolean functions) represent data structures in modern CAD VLSI or disjoint ONand DC-cubes (in the case of systems. However, some of such systems are based incompletely specified functions). The algorithm on cubical representation [23,24] rather than that generates such an array and its implementadecision diagrams and the current article solves tion is described in [26]. For each disjoint cube, the the problem of efficient calculation of generalized appropriate partial spectral coefficients from either Arithmetic and Adding spectra for such CAD Adding or Arithmetic spectrum is calculated. systems.
Adding spectrum is found by adding all the entries The presented algorithm has all the properties corresponding to the complete array of disjoint required in CAD applications of Arithmetic and cubes defining a given Boolean function. For Adding spectra and calculates both spectra in an Arithmetic spectrum, the final addition/subtracefficient way. The first attempt to overcome the tion is performed based on some rules that inefficiency of the calculation of both spectra describe the relationship between the disjoint directly from the definition of the transforms by cubes and partial arithmetic spectral coefficients. matrix multiplication was done in [25]. The algorithm presented there solved the problem of calculating the spectra of incompletely specified If. BASIC DEFINITIONS AND PROPERTIES Boolean functions. It allowed also on the independent calculation of only some chosen spectral The properties of disjoint cube representation of coefficients. However the algorithm presented Boolean functions used in the description of the there still operated on truth tables. The new algorithm calculating Adding and Arithmetic algorithm presented in this article has addressed spectra are stated. In what follows, the definitions and solved this issue. By allowing to represent the and basic properties of Adding and Arithmetic Boolean function in the form of an array of transforms are presented to make the paper self disjoint cubes instead of minterms, the spectral contained.
coefficients can be computed more rapidly from DEFN'Or The literal c of a variable x of a such a reduced representation with smaller re-Boolean function can be either in affirmative (x) or quired memory, while the ability to calculate only negative form (). partial spectra is still preserved. Hence, the new algorithm has allowed practical applications of DEFINITION 2 The polarity number of a spectrum, both Adding and Arithmetic transforms in real denoted by , is a binary string computed by life problems' sizes of analysis, synthesis, testing taking the n bit straight binary code (SBC) formed and probabilistics of Boolean functions for CAD by writing a 0 or a for each literal according to systems using cubical ather than graph based whether this literal is used in affirmative or representations of discrete functions, negative form in all the terms. The algorithm introduced in the following section is not only valid for completely specified Example 1 The polarity number of the term Boolean functions but also for incompletely XlX23x4--O010. 138 B.J. FALKOWSKI AND C.-H. CHANG DEFINITION 3 A cube is represented by a positional notation where "0" corresponds to a negated literal, "l" to the affirmative literal and "X" to the literal that is absent in a cube.
The cube x123x4 is represented by DEFINITION 4 A cube of degree m is a cube that has m defined literals that can be either affirmative or negative (i.e., m is equal to the sum of the number of zeros and ones in the description of a cube).
Let symbol p denotes the number of X's in the cube and n denotes the number of variables of a given Boolean function F. Then, n m +p.

DEFINITION 5 The matrix of order N 2 for
Adding Transform in polarity co is defined as [18,[20][21][22]25]: The set of all 2 Arithmetic and Adding transformation matrices and corresponding spectra for all possible polarities co for an n-variable Boolean function are called Generalized or Multipolarity Arithmetic and Adding Transforms and Spectra accordingly [18].
Two types of coding are used for the truth vector of a Boolean function before its spectrum is computed [27]. In the S coding, false minterms are represented by 1, true minterms by -1 and don't care (DC) minterms by 0. In the R coding the truth vector is represented by its original values: 0 for false minterms and for true minterms. The DC minterms are represented by 0.5. The adding spectrum for both codings can be calculated by the following matrix multiplication.
where the elementary Adding matrices of order 2 for polarity bits 0 and are AD( > I1 ] and AD >- [1 ] respectively; "(R)" is the right hand Kronecker product and cor is the r-th bit in the binary representation of the polarity number co.

DEFINITION 6 The matrix of order N 2 for
Arithmetic Transform in polarity co is defined as [18, 20- (3) and (4). The meaning of all the symbols described above is still applicable with the understanding that the word 'Adding' is replaced by 'Arithmetic'.
DISJOINT CUBES 139 DEFINITION 7 Each spectral coefficient from a spectrum is described by its order, and subindices. The order of a spectral coefficient is equal to the number of subindices in the index, where the subindices are the subscripts of all variables of a standard characteristic set corresponding to the coefficient.
Property 2 The number of spectral coefficients of order z is equal to C (z) where n is the number of variables of a Boolean function.
The definition of a standard characteristic set, independent of the type of the transform, is given below.
DEFINITION 8 There exists a correlation value between a Boolean function F and the standard characteristic set u corresponding to each spectral coefficient ai. The standard characteristic set is given by the set of subindices which are present in the index I of the spectral coefficient az.
The index I of the spectral coefficient can also be represented by a positional notation where "1" corresponds to the literal that is present in the index and "0" to the literal that is absent from the index.
The standard characteristic set obtained by direct matrix multiplication using Eqs. (3) and (4) is in the order that by similarity to known orders of Walsh functions can be called a Hadamard order [12,27]. By the properties of orthogonal spectral transforms [3,12,[16][17][18], the superset of standard characteristic sets is canonic.

III. THE GENERALIZED SET COMPARISON METHOD
With the definitions given in Section 2, the Generalized Set Comparison Method to calculate Adding and Arithmetic spectra can be described.
Since there exists a linear relationships between spectra in both S and R codings [18,28], it is not necessary to consider both codings in this article.
In the continuation, all the derivations are presented only for the spectrum in R coding. To obtain the spectrum in S coding from the spectrum in R coding using the linear relationship or by directly modifying the operation presented later in this article is trivial. In order to compute both Adding and Arithmetic spectra, two new operations: cube adding and arithmetic operators are introduced. The presented properties and definitions are based on behavior of Boolean functions and operations in Arithmetic spectral domain proven in [22]. The correctness of the algorithm has also been verified by extensive experimentation and generation of Arithmetic and Adding spectra for all Boolean functions for n < 5.
DEFINITION 9 A cube adding operator, denoted as )(,ad, is defined as an operation between bits of an index of an adding spectral coefficient and a cube in positional notation by Table I(a). The result of this operator is a three valued string (a ternary string).  DEFINITION 10 A cube arithmetic operator, denoted as ar is defined as an operation between bits of an index of an arithmetic spectral coefficient and a cube in positional notation by Table I(b). Xar operator is analogous to Had operator except that for the "X" bits of the cube the result of ar operation is equal to the complemented value of the corresponding bit of the index. Hence, such a result is a two valued string (a binary string).

DEFINITION
The partial spectral coefficients of an ONor DCcube cuj of degree m from disjoint cube representation of a Boolean function F are those part of the final spectral coefficients ai that correspond to the contribution of this cube cuj to the full n-space spectrum of the Boolean function F described by the array of all the disjoint cubes.
Property 4 The partial adding spectral coefficient, adri contributed by an ON-cube, cuj is obtained by the multiplication of all the elements of the ternary string resulting from the operation cuj d I.
Property 5 The partial spectral coefficient arri contributed by an ON-cube cu9 is obtained by the multiplication of all the elements of the binary string resulting from the operation CUjZarI. The value of the partial spectral coefficient has to be negated if the number of affirmative literals describing the cube is even. The final value of such a coefficient has to be negated again if the order of the spectral coefficient is even.
Properties 4 and 5 are valid only for zero polarity for which each literal in the polarity is affirmative. Properties 4 and 5 are valid for any other polarity provided the cube has been adjusted to prior to the respective cube adding or cube arithmetic operation. The explanation of the cube adjustment operation is presented later in Definition 12. Property 6 The partial spectral coefficient contributed by a DC-cube is equal to one half of the contribution of an ON-cube that has the same positional notation. Additionally, the number of partial spectral coefficients (npsc) describing the Boolean function F is equal to the number of ONand DC-cubes describing this function. Property 6 is valid for both adding and arithmetic spectra. It is also obvious that the number npsc does not have a canonical value for a given Boolean function and depends on the disjoint cube representation of such a function obtained by Algorithm from [26]. Example 4 The ADR spectrum in zero polarity (=000) for the three-variable completely specified function F(xl, X2, X3)---X223-[-,lX2X is calculated in Table II. The first row of Table II gives all possible spectral coefficients adrI according to their order.
To abbreviate the notation used, the members of the standard characteristic set of a given spectral coefficient are listed as the subindices of such a coefficient. For example, a spectral coefficient adrx, x3 is denoted by adrl3. The binary representation of the indices of the spectral coefficients is given in the second row. In the first column the two disjoint cubes of F are shown in their binary representation. The values of the partial spectral coefficients for each cube are computed using the cube adding operation and Property 4. The final values of the spectral coefficients are obtained by adding the respective partial values in the columns.  X10:aa110 211.
The value of the partial spectral coefficient While the value of the adding spectral coefficient is in the range from 0 to 2n, an arithmetic spectral coefficient can have a negative value. This is apparent from Formula (2) as the positions of the -1 entries in Arithmetic transformation matrix determine which spectral coefficients can be negative. The previous Properties 4 and 5 are valid only for the positive polarity. They can be, however, adopted for all polarities with a cube adjustment operation defined below. DEFINITION 12 The cube adjustment operator (CUe) on two cubes is essentially a bitwise modulo-2 addition except that "X" is invariant under such operation. Table IV shows the cube adjustment operator between bits of a cube and a polarity number. Example 7 The cube cu-1X00 adjusted to a polarity number -1010 is given by 1X00 CU1010 0X10.
When all ONand DC-cubes for a given function have been adjusted to the required polarity number, Properties 4 to 6 are used to calculate the partial and total Adding and Arithmetic spectra.

IV. IMPLEMENTATION OF THE ALGORITHM FOR THE CALCULATION OF ADR AND ARR
The algorithm presented below refers to properties and definitions from the previous section. In order to use Boolean functions that are represented as minterms or arrays of non disjoint cubes, the input data to the new algorithm are preprocessed by the fast algorithm [26] that generates an array of disjoint ONand DC-cubes. The main body of the algorithm is a for loop where the values of the partial coefficients corresponding to an adjusted cube are calculated. The total number of iterations is equal to npsc. During execution, the values of the spectral coefficients of a currently processed cube are added to the already calculated values corresponding to the previous cubes. Therefore, this algorithm requires only one spectral coefficient to be kept in the computer memory at a time.
When the coefficients are calculated separately or in a group, there is no limit on the number of variables n since the calculated coefficient or group of coefficients can be transferred immediately to the hard disk. This is, however, performed at the expense of the processing time.
Owing to the property that the values for spectral coefficients of even orders have to be negated for the ARR transform, the spectrum is calculated order by order when full spectrum is required. To avoid the calculation of the number  value of the spectral coefficient currently calculated for all cubes subroutine to multiply the elements of either binary or ternary string binary or ternary string resulting from cube arithmetic or adding operation return value of the subroutine mult Example 8 An array of disjoint ONand DCcubes for an incompletely specified Boolean function of four variables is given in Table V. Polarity number 1101 is selected for the computation of both spectra. In the third column of Table  V, the original cubes in the first column are replaced by the results of the cube adjustment operation. The adjusted cubes are taken to generate both Adding and Arithmetic spectra. The coding for Adding spectrum is identical to the original R coding and is given as the fourth column in Table V. The new coding for Arithmetic spectrum is determined by Properties 5 and 6 and is given as the fifth column of Table V TABLE VI ADR spectrum of the incompletely specified function in Example 8 for co 1101   Adjusted Coding 0000 1000 0100 0010 0001 1100 1010 1001 0110 0101 0011 1110 1101 1011 0111 1111   Cube   adro adrl adr2 adr3 adr4 adrl2 adr3 adrl4 adr23 adr24 adr34 adr123 adr124 adr134 adr234adrl:z34   0X01  0  0  0  0  0  0  0  2  0  2  2  2  0X1X  0  0  0  0  0  0  2  0  2  2  0  2  4  4   arithmetic spectrum, respectively. The execution time is given in seconds where the symbol u denotes the elapsed user time and the symbol s denotes the elapsed system time.
As the number of spectral coefficients increase exponentially with the number of input variables, the execution time is affected inevitably by the number of input and output variables, but mainly depends on the number of disjoint cubes. However, as the algorithm uses disjoint cubes instead of minterms, the storage requirement also increases linearly with the number of disjoint cubes, as shown in Table VIII. The computational complex-ity of the above algorithm is of the order O(m) where m is the number of disjoint cubes. Due to the property that the cube arithmetic operation generates more zero partial spectral coefficients than the cube adding operation, the execution time for the arithmetic spectrum is generally faster than that for the adding spectrum.
In the literature, two other spectra of Boolean functions have been calculated from disjoint cubes: Walsh spectrum [27] and Reed-Muller spectrum [16,29,30]. It is obvious that the efficiency of all these methods depends on the function in question and by using different mathematics even for the same original functions, the number of spectral coefficients not equal to zero differs. Hence it is difficult to compare meaningfully the storage requirements, but it can be observed from the published results that the execution time is similar for the functions with comparable number of disjoint cubes. Moreover, each of the methods based on disjoint cubes can calculate spectral coefficients in groups or even individually. When the coefficients are calculated separately, the number of input and output variables is virtually unlimited, since the coefficients can be stored in groups on the hard disk. This is, however, traded off for the increased processing time. design for which the values of only selected spectral coefficients are needed [3,27,28].
The fundamental advantage of the presented algorithm is the usage of a reduced representation of Boolean functions in the form of disjoint cubes as the internal data from which the algorithm calculates the spectra. Such an approach gives the presented algorithm the ability to yield solutions to problems of very high dimensions and is applicable to these CAD systems which use cubical representation for discrete functions. The algorithm is very well suited for systolic VLSI realizations, and may be implemented as hardware coprocessor in a manner similar to those used for other binary expansions [4].

VI. CONCLUSION
A new algorithm that generates any Generalized Adding and Arithmetic spectra from the disjoint cube representation of Boolean functions has been shown. Up to now, the computation of both spectra by known algorithms requires the representation of the Boolean function in the form of a truth table composed of minterins [18,25] or by using different decision diagrams [20,21]. By contrast, in this paper the spectrum is generated directly from the reduced representation of Boolean functions in the form of arrays of disjoint cubes [26]. Since the number of such cubes can be considerably smaller than the number of minterms, the memory requirements can be reduced significantly. The advantages of this kind of representation used frequently in modern CAD VLSI systems [23], especially the fact that for practical functions the number of disjoint cubes is much smaller than the number of minterms, has been manifested in [31]. It is also evident from Tables VI and VII that the number of disjoint cubes for the presented function is much smaller than the number of its minterms. The ability to calculate only some spectral coefficients made possible by this research is very important since there are many spectral methods in digital logic