Minimization of k-Variable-Mixed-Polarity Reed-Muller Expansions

The logic circuits using Exclusive OR (EXOR) gates are more economical than the design based on other gates for many important circuits such as adders and parity checkers. With the advent of cellular Field Programmable Gate Arrays (FPGAs) and the introduction of new Programmable Logic Devices (PLDs), for examples, Xilinx lookup based and Actel 1020 multiplexer based FPGAs, and Signetics LHS501 folded NAND devices, propagation delay and gate area is no longer a major concern in Exclusive Sum-ofproducts (ESOP) [4, 19] implementation of logic circuits. What is more, the circuits built around the EXOR gates, are easily testable [14, 15]. Fault detection of any logical circuit by verification of its Reed-Muller coefficients was considered in [14]. The upper bound on the number of ReedMuller coefficients to be verified for detection of all multiple terminal stuck-at-faults and all single input bridging faults is shown to be n [14]. Unfortunately, ESOP of a Boolean function exists in many forms, and exact minimal solutions have been found practically only for functions with less than six variables [13]. Special interest and attention have been focused on two of the canonical subfamilies of ESOP, the Fixed Polarity Reed-Muller (FPRM) expansion [1,4-11, 13, 15] and the Kronecker Reed-Muller (KRM) expansion


INTRODUCTION
The logic circuits using Exclusive OR (EXOR) gates are more economical than the design based on other gates for many important circuits such as adders and parity checkers.With the advent of cellular Field Programmable Gate Arrays (FPGAs) and the introduction of new Program- mable Logic Devices (PLDs), for examples, Xilinx lookup based and Actel 1020 multiplexer based FPGAs, and Signetics LHS501 folded NAND devices, propagation delay and gate area is no longer a major concern in Exclusive Sum-of- products (ESOP) [4, 19] implementation of logic circuits.What is more, the circuits built around the EXOR gates, are easily testable [14,15].Fault detection of any logical circuit by verification of its Reed-Muller coefficients was considered in [14].The upper bound on the number of Reed- Muller coefficients to be verified for detection of all multiple terminal stuck-at-faults and all single input bridging faults is shown to be n [14].
Unfortunately, ESOP of a Boolean function exists in many forms, and exact minimal solutions have been found practically only for functions with less than six variables [13].Special interest and attention have been focused on two of the can- onical subfamilies of ESOP, the Fixed Polarity Reed-Muller (FPRM) expansion [1,4-11, 13, 15]  and the Kronecker Reed-Muller (KRM) expansion *Corresponding author.Tel." (65) 790-4521, Fax: (65)791-2687, e-mail: efalkowski@ntu.edu.sg*Tel.: (65) Fax: (65)792-0415, e-mail: echchang@ntu.edu.sg311 [19].The former has 2 alternative forms and the latter has 3 alternative forms.The problem of finding optimal Reed-Muller expansions with the least number of terms received a lot of attention among the researchers.It can be reformulated in terms of coding or graph theory or solved by means of digital signal processing techniques such as fast transforms and convolution [4]. Nn-exhaustive   minimization methods for Reed-Muller expansions based on the extended truth vector were considered in [4].These algorithms have a space complexity of O(3).In general, the computational complex- ity of the minimization problem for Reed-Muller expansions seems unmanageable when the num- ber of variables n is greater than or equal to 4. This computational complexity has led various authors to present heuristic solutions to minimiza- tion problems when n _> 4 [4].When the original function is represented in the reduced form such as arrays of cubes or decision diagrams, the methods to calculate Reed-Muller expansions directly from such representations have also been considered [1,10].For example, in [15], an exact and quasi-minimal algorithm based on disjoint cubes has been presented.A total search is ne- cessary to find an optimal expansion.To mini- mize the number of operations, such a search is performed in Gray code ordering.This algorithm can handle only a single output completely specified function.Recently a number of exact and heuristic algorithms to minimize FPRMs have been developed [1, 3, 5, 16, 18].Most of the exact algorithms can minimize functions with around 15 variables.Some heuristic methods can deal with functions of about 100 input variables [5,16].
Owing to the high computational complexity, no exact minimization technique for canonical form more general than KRM expansion has been proposed [19].There is another Reed-Muller ca- nonical expansion known as Generalized Reed- Muller (GRM) expansion which consists of a total of 2 n2"-1 alternative forms [2, 4, 8, 11, 19, 20].GRM expansion can be considered as a combination of two subfamilies of Reed-Muller expansions, the Inconsistent Mixed Polarity Reed-Muller (IMPRM) expansion [2] and the FPRM expansion.Although minimal GRM expansion is expected to be closer to the minimal ESOP than the minimal KRM expansion due to the greater number of alternative forms, an exhaustive search for a minimal GRM is also computationally unfeasible even for very small number of variables [4, 11, 19].Recently,  Wu et al., and Zeng et al. [19,20] proposed an- other subfamily of GRM called the Generalized Partially-Mixed-Polarity Reed-Muller (GPMPRM) expansion.GPMPRM is a superset of FPRM which has n2 -I 2 2-1 (n 1)2 n alternative forms.Based on the number of alternative forms, it is believed that the minimal GPMPRM expansion is still much closer to the minimal ESOP than the mini- mal KRM expansion.
The definition of GPMPRM expansion from [19] with only one mixed polarity variable was extended to k mixed polarity variables in [9,20].It should be stressed, however that the authors of [20] have not found an efficient exact algorithm for k > 1, the task which is solved in the current paper.
The extension to k mixed polarity variables further reduces the gap between the minimal GPMPRM and the minimal ESOP since the total number of alternative forms is nczc2n-22n-1-(nC-1)2 based on the new definition.The lookup table based approach for the exact minimization of FPRM expansion developed by the authors in [1,7] is modified to generate a minimal GPMPRM expansion of k mixed polarity variables.Contrary to all algorithms known from the literature [12,19,20], our algorithm for the minimization of GPMPRM expansions, is adaptable to different cost criteria, for instance, the total number of unique products, the total number of unique lit- erals and the linear combination of both criteria.Based on the size of the tackled problem, our algorithm can use different size of the lookup table to trade the space complexity problem into the processing time complexity problem.Experimental results show that even without considering all possible combinations of k variables as the mixed polarity variables, for most functions reported in [19], which considered all combinations of one mixed polarity variable, the quality of the results obtained by our algorithm is either the same or better.
obtained by allowing the k2 n-1 literals of k variables in expression (1) to freely assume either polarity while maintaining consistent fixed polarities for all the literals of the remaining variables.
In [19], a strong constraint is placed in the definition of GRM expansion to obtain the Generalized Partially-Mixed-Polarity Reed-Muller (GPMPRM) expansion.It is a subset of GRM expansions that encloses the FPRM expansions.However, the requirement that the polarities of all but one variable have to be fixed can be relaxed.A more general definition of GPMPRM expansion, the possibility which was mentioned in [9,20] is given as follows:

DEFINITION
The Generalized Partially-Mixed-Polarity Reed-Muller (GPMPRM) expansions are Under this new definition, for an n-variable completely specified Boolean function, there are nck2n-k22"-' (nck 1)2 alternative GPMPRM forms.The proof of this fact can be constructed in a similar way as that shown in [19].
Let r.i,j, denote Yci, xi or for (i,ji)-(1 1), (0, 1) and (-, 0) respectively where the symbol '-' stands for either 0 or 1.A GPMPRM product term can be expressed as I-Ii=l x' where the decimal numbers j-ji=lji 2 i-andi 2i-1 l&i are indicators of the appearances and polarities of the literals in the product term.Each GPMPRM product term has a polarity number, denoted by or ( _1--.2), which is a binary n-tuple formed by writing a 0 or a for each literal according to whether the literal is used in a positive or negative form.It is more convenient to treat the literals present in a GPMPRM product term as a conjunction of two parts: the fixed polarity part i+1 x ''' and the mixed polarity part 1 j xi" '.Since the (n-k)   digits of the polarity number are identical for all product terms of a GPMPRM expansion with k mixed polarity variables, only k digits of corresponding to the mixed polarity variables need to be specified separately for every product term.DEFINITION 2 A polarity vector A is an ordered set of all 2 FPRM expansion coefficients [aoa.. "a2,-1] in some chosen polarity number .
A can also be represented by a decimal number E2"-I 2 i=0 ai with a0 as the least significant bit and a2.-1 the most significant bit of its binary equivalent.DEFINITION 3 The polarity coefficient matrix PC(F) [1, 7, 10] of an n-variable Boolean function F is a 2 2" binary matrix, where every row corresponds to a polarity vector A in a different polarity number .
Every element m 0. (row i, column j)of the polarity coefficient matrix PC(F) describes the coefficient aj. of the FPRM expansion with polarity cO-io DEVINTON 4 The Hamming weight of an integer i, denoted by H(i) is the number of'l' in its binary representation.

MINIMIZATION OF GPMPRM EXPANSIONS
Recently, an algorithm has been developed that utilizes only a subset of Walsh coefficients to reveal all the information carried by the polarity coeffi- cient matrix of any three variable Boolean func- tions [6].Each class of the functions is associated with a specific subroutine that computes the optimal polarities, optimal weights, optimal fixed polarity Reed-Muller expansions etc., without resorting to an exhaustive search.Direct extension of the method in [6] to handle larger Boolean functions with the number of variables n > 3 is unmanageable due to the increasing number of different classes.Nevertheless, exact optimal gen- eration of FPRM expansions for large n have been solved by reducing the polarity coefficient matrix into submatrices of smaller dimension such that each submatrix is a polarity coefficient matrix of a subfunction obtained by either Shannon's de- composition or Boolean difference with respect to some variables [1,7].Similar approach as [1] can be applied to the minimization of GPMPRM expansions by selecting an optimal FPRM expan- sion for each subfunction, with the exception that the k mixed polarity variables may have different polarities for different subfunctions.

LEMMA
The polarity coefficient matrix PC(F) of an n-variable completely specified Boolean function F(X), can be partitioned into four submatrices of order 2 as [1, 8 10]" PC(F)-[ PC(f) PC(f f l pc(fl) pc(fO @ fl (2) where fo and f are cofactors of Shannon's decomposition of F(X) evaluated at Xn--O and xn-1, respectively.
A subfunction fi, i-0, 1,2 for an n-variable Boolean function F is defined as: f o F(O, Xn-l ,X2,Xl) f F (1,xn-1,.. ,X2,Xl)   f2__fO@fl By applying (2) recursively, the polarity coefficient matrix of order 2 can be partitioned into p2 submatrices of order 2K, where p-2-K.Each submatrix is a polarity coefficient matrix of a k-variable subfunction and the total number of unique subfunctions is equal to 3-K.
It should be noted that the above decomposition into subfunctions does not have to begin with the most significant variable xn.In general, a subfunc- tion of k variables, _< k < n, can be formed by decomposing or taking the Boolean difference of F with respect to some n-k variables.Each subfunction f of k variables is associated with a ternary (n-k)-tuple (On_k'''O201) where (0,1,2).If ai (0,1) for all l_<i_<n-k, a is said to be reducible to a binary (n-k)-tuple and f is a cofactor formed from F by substituting all the k variables with a in the following manner: x with On_k, Xn_ with an_k_l, etc.If there exists an ai-2 for any _< <_ (n-k), then f; (R)f' where /3-O k O / 00 i_ 1''" 0 2 and 7-(an_K'''ai+ ai-'''a2a).It is obvi- ous that two or more different ai, ay, etc., i:/:j, can be equal to 2 in f.
For simplicity, in the sequel, we assume that the k mixed polarity variables of a GPMPRM expansion are x, x2,..., xK and the fixed polarity variables are xK + 1, xK + 2,.x..A different set of mixed polarity variable affects only the indexing of the variables which can be corrected by simply renaming the indices of the affected variables or reordering the input variables of the function.Explicitly, we use r ( _ w'" k + ) to denote the fixed polarity number for the set of (nk) fixed polarity variables and --(k k_'''a;) to denote the mixed olarity number for the k mixed polarity variables of the q-th GPMPRM product term where j2k<_q < (j+l)2kand0<_j_<2"-k-1.

THEOREM
For an n-variable Boolean function F, the minimal number of product terms, wp(F, r) of a GPMPRM expansion with fixed polarity number r is given by: 2 n-k- r) j=0 (3) where <_ k < n, and j is the decimal equivalent of binary (n-k)-tuple (j,,-kj,-k-1" "jl).Wp(fr-j, Cj) is the number of product terms of the optimal FPRM expansion of k-variable subfunction fr,j with polarity @--(ak COk_ 1"'" col }. The operator *'{0, 1}k Proof Let wp(F, a) denote the number of product terms of the FPRM expansion of F in polarity The weight vector Wp(F)= [wp(F, O) wp(F, 1)... Wp (F, 2"-)] r is an ordered set of the number of product terms in each row of PC(F) for an n- variable Boolean function F. Wp(F) can be obtained in a similar recursive way as Lemma from the weight vectors W(f), W(fl) and W(f(R)f) corresponding to the FPRM expan- sions of subfunctions fo,fl and f2 respectively.
Wp(F) [ W(f) + W(f2) 1 Wp (f') + Wp (f2)   Wp(f00) 4-Wp(f02) 4-Wp(f20) 4-Wp(f22) Wp(f O1 4-Wp(f02) 4-Wp(f 21 4-Wp(f22) Wp(f10) 4-Wp(f12) 4-Wp(f20) 4-Wp(f22)   w ,(f + w,,(f + w,,(f + w,,(f .... etc. After n-k recursions, there are 2 "-k rows each having 2 k weight vectors Wp to be summed.The first weight vector in the r-th (r 0,1,..., 2 n-k-1) row is the weight vector Wp of the cofactor generated by decomposing F with respect to Hin=-i k r,,1 If the cofactor at r-th row is denoted Xk+ by fr, the subfunction appearing in the j-th (j-0,1,...,2"-k-l) weight vector Wp of the same row is given by fr.j.If the decomposition of F is performed over the set of fixed polarity literals with polarity number r, the subfunctionsff*J for all j= 0,1,..., 2"-Kare Boolean functions of k mixed polarity variables.Since the k variables of the subfunction ff*J are allowed to have mixed polarities in a GPMPRM expansion, the best weight (smallest number of product terms) with polarity number Cj of Wp(fr-j) for each j is selected.Hence ( 3) is obtained, m THEOREM 2 The minimal number of literals, wl(F,r) of a GPMPRM expansion with fixed polarity number r is given by: 2 n-k- Wl(F, r)   [wl(f r-j, qSj) + H(j) Wp(f r-j, j)] j=o (4) where the symbols j,k,r and the operator have been defined earlier.Here, Cj refers to the polarity number of the FPRM expansion of k-variables subfunction fr,j that has the smallest number of literals, with priority given to FPRM expansion with a0=0 when there is a tie.wi(ff*J, Oj) and Wp(ff*J, @) are the number of literals and product terms of the FPRM expansion offf*J in polarity @ respectively.H(j) is the Hamming weight of the integer j.
Proof When the polarity coefficient matrix (2) is expanded recursively n-k times, the submatrix at the r-th row andj-th column of PC(F) corresponds to a polarity coefficient matrix of a subfunctionff*.
Each such submatrix PC(if*J) has the dimension of 2 k > 2k.If Cj is the row number of PC(fr-j) that has the smallest number of literals, each non zero entry at row qj. and column g of the submatrix PC(if*J) contributes to the GPMPRM expansion y-n ri-k,ji-k [k ..d/)j,, g a product tc,n lli=k+l "i "lli=l _i The number of literals in the product I-[= x+i ''gi is equal to wt(fr-j, cj).Since there are H(j) additional fixed polarity literals in the product I-Ii=k+l x '-'ji-  the total number of literals contributed by any submatrix PC(fr-j) is given by wl(fr*J, dpj)+ H(j)wp(f *j, dpj).Hence (4) follows, m For a small number of mixed polarity vari- ables k, typically k _< 5, instead of searching for the optimal polarity qy and then calculating Wp(ff*Y, @) and w(f r*y, cpy) from PC(if*J), lookup table can be used.For the minimization of the number of product terms in the GPMPRM expansion, each record of the lookup table con- tains an optimal polarity qj., the polarity vector A+J and its number of product terms Wp(f,y) for the subfunction f where a--r,j.For mini- mization with respect to the number of literals, the record for the subfunction f consists of the polarity qj. for minimal number of literals, the polarity vector Aj, and its number of literals wl (f, by) and product terms Wp(f, Cpy).In order to use the k-variable subfunction f as an index to the lookup table, we assign to f a unique inte- ger value N(f) whose binary equivalent is (mzk_lmzk_z...mlmo) where miE (0,1) is the value of the i-th minterm off .Clearly, 9(-) 22k 9(f) and where the symbol '(R)d' is the dyadic addition or the addition of two integers over GF(2).The polarity vector field in each record is also re- presented by an integer whose binary represen- tation is {a7a6... alao) where ai is the coefficient of the FPRM expansion of the subfunction f in the selected optimal polarity.
As a+(f) and a4J(f) differ only in the constant term ao, wz(f,chj)= wz(f,ch).How- ever, from Theorem 2, the constant term of each subfunction contributes H(j) literals to the final GPMPRM expansion and can not be neglected.When seeking for the minimal number of literals in the lookup table, if there are more than one optimal polarities for a subfunction, the optimal polarity for the polarity vector with a0=0 is chosen.
Based on Theorems and 2, the algorithm for the fast computation of the minimal GPMPRM expansion is given in Figure 1.
In Figure 1, Tables I and II are lookup tables for different options of minimization specified by the Boolean variable optimize_nof_products.Each pro- duct term of a GPMPRM is considered as a concatenation of two products, i.e., the products of the fixed polarity variables and the mixed polarity variables.The presence of a mixed polarity product is indicated by a '1' in the binary k-tuple of opt_GPMPRM [1] while its associated fixed polarity variables is indicated by the 'l's in the binary (n k)tuple of j.The polarities of the fixed polarity variables of the final GPMPRM expansion are stored in the bit fields of the variable optimal_fix-ed_polarity, and the polarities of the mixed polarity variables in the products terms of opt_GPMPRM[j] are stored in the bit fields of opt_mixed_polarity [j].
If we consider only one arbitrary set of k mixed polarity variables, the outer loop of GPMPRM can be removed and the resulting GPMPRM expansion is optimum with respect to a given set of mixed polarity variables.Such a constraint is frequently encountered in practice as it may be more cost effective to restrict the privilege of dual polarities to only some specific variables.
Since w(F, 1)= 7 is the minimal weight, the fixed polarity literals are chosen to be x5 and 4.

EXPERIMENTAL RESULTS
The new algorithm is implemented on the HP Apollo Series 715 workstation with k-3 mixed polarity variables.The current implementation can calculate the minimal GPMPRM expansions based on either the minimal number of products, Wp or literals, wl although theoretically, any cost function of the form awl + bwp is possible where a and b are integer constants.The quality of the results for a minimal GPMPRM expansion with three mixed polarity variables always outperforms the procedure with only one mixed polarity variable.For better analysis and comparison with the fast algorithm of [19], an arbitrary set of three mixed polarity variables is selected instead of cycling through all possible selections of three variables to seek for the exact optimal GPMPRM.A range of benchmark examples have been tested.Some multiple output two level examples in pla format from MCNC benchmarks minimized with Wp and wt as cost functions are compared in Table I with the results obtained from the exact FPRM minimizers [1,3].The column labeled Time is the user (usr) and system (sys) execution time of our current implementation in second.For most functions, our results are significantly better than the exact FPRM expansions, particularly in terms of the number of literals.It should be noted that the savings in the total number of literals for GPMPRM expansion is more prominent than the savings in the number of product terms.Table II summarizes the comparison between the quality and system execution time of our algorithm and those of the exact minimizer with all possible selections of one mixed polarity variable, GPMP [19] and exact FPRM minimizer, CGRMIN [15]   for single output functions.Despite the simplification of using an arbitrary set of three mixed polarity variables, our results for majority of the functions are either the same or better than that for GPMP and outperform CGRMIN.Moreover, the processing time of our algorithm is remarkably lower than GPMP and CGRMIN.It should be however noticed, that Table II uses time taken from [15, 19] directly so the time is also influenced by the different workstations used in each of the experiments.

CONCLUSION
This paper solves the open problem stated in [20] on how to minimize GPMPRM expansions with k mixed polarity variables.For such a case, this expansion has nclc2n-lc2k2"-' (nck 1)2 n alter- native forms which is closer to the ESOP than the original definition.An efficient lookup table based method is presented in this paper for the heuristic minimization of GPMPRM expansions with k < 6 mixed polarity variables for multiple output functions.Due to the inherent nature of NP problem, the presented algorithm is highly effi- cient for up to ten input variables with k 3. It is also adaptable to various cost functions which is what lacks in the existing minimizer [19,20]. 8.

TABLE
Benchmark results for GPMPRM and FPRM

TABLE II
Benchmark results of single output for GPMPRM, GPMP and CGRMIN