A Method To Find The Best Mixed Polarity Reed-Muller Expansion
A Method To Find The Best Mixed Polarity Reed-Muller Expansion
A Method To Find The Best Mixed Polarity Reed-Muller Expansion
REED-MULLER EXPANSION
by
DMITRY MASLOV
MASTER OF SCIENCE
in
.....................................
.....................................
.....................................
.....................................
.....................................
June 2001
(Signature)
Date
Abstract
In this thesis, we use the transeunt triangle in an efficient algorithm to find the minimum
mixed polarity Reed-Muller expression of a given function. This algorithm runs in
Θ(n2 3n ) time and uses Θ(n3n ) storage space. The algorithm is also designed for multiple
output functions. Efficiency of this algorithm is demonstrated on benchmark functions.
ii
Table of Contents
Abstract ii
Chapter 1. Introduction 1
Chapter 2. Background 3
Chapter 7. Conclusion 38
Bibliography 39
Appendix A. C code for the program that finds the best mixed polarity
Reed-Muller expansion 41
iii
Chapter 1
Introduction
There are many ways to represent a Boolean function. Much research has been devoted
is the AND of variables or complements of variables [1]. It is known that such expres-
sions require, on average, fewer product terms than OR sum-of-products [9]. Another
AND-EXOR circuits have been used in arithmetic, error correcting, and telecommuni-
Such expressions can be used to classify a given function into an equivalence class of
functions, where two functions are equivalent if one is transformed into the other by
and is useful for determining library cells in CAD (computer-aided design) tools. This
is called Boolean matching and is important in the determination of library cells for use
by CAD tools.
This thesis focuses on a special class of AND-EXOR circuits, called mixed polar-
1
Chapter 1. Introduction
both forms, in which case all terms contain the variable. If all variables are uncom-
Polarity Reed-Muller or PPRM (NPRM) form. A fixed polarity Reed Muller (FPRM)
but never in both forms. FPRM expression are a subset of MPRM expressions. MPRM
expressions are unique [2] for a given polarity. Thus, only one representation exists
for the PPRM or NPRM or indeed any MPRM of f (x1 , x2 , ..., xn ). This leads to the
question of which of the MPRM’s produces the fewest product terms [5], [6], [11].
2
Chapter 2
Background
In this section we give the formal definitions of the terms used in this thesis. One method
construction is nothing, but a table with (n + 1) columns and 2n rows. In the rightmost
column the value of the function for the input that is placed in the first n columns is
given for each row. The number of different inputs for a function of n Boolean variables
is 2n , therefore the height of this construction is 2n . In other words, the truth table
has 2n rows. It can be seen that the truth table requires large amount of storage, so in
order to simplify it, the truth vector method is used. The truth vector for a function of
n variables is the sequence of Boolean numbers of length 2n , where the k-th number of
this sequence is the value of the function on the input that is the binary representation
of number k. In the following example we see the advantage of the truth vector method
Example 1. Consider the following truth table shown in Table 2.1. The truth vector for
the same function is [0, 0, 1, 1, 1, 0, 1, 1], which requires one-fourth of the storage space.
For a function of n variables the truth vector method requires (n + 1) times less storage
3
Chapter 2. Background
x1 x2 x3 f (x1 , x2 , x3 )
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 1
Now consider Boolean functions f (x1 , x2 , ..., xn ) of n variables and represent them as
& or concatenation), negation (¯) and exclusive or (⊕). The popular notation xσi i to
represent xi if σi = 1 and x̄i if σi = 0 will be also used. A proof that the system of
Now a polynomial that represents a function of n variables can be built. One of the
1. Take the truth vector and for each 1, say, at i-th place, build the product that has
truth vector [0, 0, ..., 0, 1, 0, ..., 0] where 1 is exactly at the i-th place. This product
will look like xσ1 1 , xσ2 2 , ..., xσnn , where i = (σ1 , σ2 , ..., σn ) is the binary decomposition
4
Chapter 2. Background
2. The function is the “exclusive or” of all products obtained from the previous step.
By Shannon’s theorem this sum-of-products that is obtained from this algorithm is equal
to the function. For example, the function shown in Table 2.1 (function with truth vector
[0, 0, 1, 1, 1, 0, 1, 1]) can be expressed as: x¯1 x2 x¯3 ⊕ x¯1 x2 x3 ⊕ x1 x¯2 x¯3 ⊕ x1 x2 x¯3 ⊕ x1 x2 x3 .
There are many polynomials which represent the same function. For example,
and
x1 ⊕ x2 ⊕ x1 x2 ⊕ x1 x3 ⊕ x1 x2 x3 (2.3)
represent the same function shown in Table 2.1. But in this thesis a function will not be
canonical form). The first polynomial is not in such a form. This becomes clear from
polarity P = (ρ1 , ρ2 , ..., ρn ). Let P = (ρ1 , ρ2 , ..., ρn ) where ρ1 , ρ2 , ..., ρn ∈ {0, 1, 2} be the
polarity of a mixed polarity Reed-Muller expression for the function f (x1 , x2 , ..., xn ),
• xi appears complemented if ρi = 0,
5
Chapter 2. Background
• xi appears mixed if ρi = 2.
f (x1 , x2 , ..., xn ) = xi f0 (x1 , ..., xi−1 , xi+1 , ..., xn ) ⊕ x̄i f1 (x1 , ..., xi−1 , xi+1 , ..., xn ),
where f0 (x1 , ..., xi−1 , xi+1 , ..., xn ) and f1 (x1 , ..., xi−1 , xi+1 , ..., xn ) have polarity
According to Sasao’s classification [8] the above is a Kronecker expression. The polarity
P is said to be fixed, iff ρ1 , ρ2 , ..., ρn ∈ {0, 1}. That is each variable appears either
The polynomial x1 ⊕ x¯1 x2 ⊕ x1 x¯2 x3 is not a valid mixed polarity Reed-Muller expression
because x2 is found in all three possible forms: not present, present, and present with
negation. The other two polynomials (2.2) and (2.3) are Reed-Muller expansions. From
(1, 1, 1) (so, according to commonly used notations, this is a fixed polarity Reed-Muller
expression, namely positive polarity, which by the definition is the polarity where all
The example below illustrates how a mixed polarity Reed-Muller expression is obtained
6
Chapter 2. Background
Example 2. Given the three-variable function with the truth vector [0, 0, 1, 1, 1, 0, 1, 1].
Find the mixed polarity expression with polarity (1, 2, 0). To build it, we construct the
The polynomial is given with (2, 2, 2)-polarity, since all the variables appear in each
term and can be found complemented as well as not complemented. In general, when
we build this simplest polynomial for a function of n variables (which is also called
Muller expression of polarity (2, 2, ..., 2). Returning to our example we notice that in
7
Chapter 2. Background
2. After simplification the obtained polynomial has polarity (1, 2, 2). Now we come
with the procedure that changes the polarity of x3 . We have to substitute every
= x2 ⊕ x1 x¯2 x¯3 .
The last Reed-Muller expression (x2 ⊕ x1 x¯2 x¯3 ) has polarity (1, 2, 0) .
As we see from the example above, different polarity Reed-Muller expressions have
different number of terms. At this point we are ready to give the definition for the
cost of a representation. In general, there are two common ways to understand the
cost. The first approach is to consider the cost to be the number of literals used
to create the polynomial. This understanding of the cost is widely used when one
considers contact schemes [?]. In this method, every time we use a literal, we add
one contact which adds one to the final cost. The geometry of the net consisting of
these contacts defines the function. The second common understanding of the cost is
all necessary products that are used in the “EXOR”-array part. Therefore, according to
the theory of PLA design we care more about the number of products, than the number
of literals in each product. In this work we chose the PLA-oriented definition of the
8
Chapter 2. Background
In case we want to realize the function with some device, two questions are interesting:
is there an efficient algorithm to find the expression with the smallest cost, and what
is the maximum cost for a n-variable function. The main issue of the present thesis
is to find an efficient algorithm to find the best mixed polarity Reed-Muller expansion
and compare its efficiency with the efficiency of previous known algorithms. The second
problem was not forgotten, and one of the hard functions was found. The problem of
finding the hardest functions to represent will be generalized into the case of Cohn’s
inconsistent forms, but this issue refers to future work, which is introduced in Chapter
6.
Several algorithms have been created to solve the problem of finding a minimal mixed
The first, Green [4]. The method he used is the closest to our approach. Green con-
sidered ternary maps with 3n elements that are interpreted as rectangles. The method
to find the best mixed polarity Reed-Muller expansion is very similar to ours: first, we
fill the map by specially described rules. After filling the map, the author proceeds to
add numbers inside the structure, and then the costs for all 3n polarities are obtained
in all 3n different cells. Finally, Green finds the minimum cost among all 3n costs he
obtained.
The second, Lui and Muzio [5]. The authors used the Kronecker product of elemen-
tary matrices to describe the generalized Boolean matrix transforms for modulo-2 fixed
9
Chapter 2. Background
and mixed polarity Reed-Muller expansions of a Boolean function. A method for fast
Boolean matrix transformations was considered to generate exhaustively all the 2n (3n )
fixed (mixed) polarity Reed-Muller expansions. Then, the expansion with the least
The third, Drechsler, Theobald and Becker’s [3]. The core of the data structure they
consider is the ordered functional decision diagram (OFDD), which is a restricted type of
called one-paths and terms in fixed polarity Reed-Muller expansions. This allows to say
that a method that minimizes the number of one-ways in OFDD gives the cost for the
shortest fixed polarity Reed-Muller expansion. For the minimization the authors build
an OFDD with only positive Davio-nodes and transform it step by step to an OFDD
the number of one-paths and store the best result. To avoid the construction of the
10
Chapter 3
Minimization Algorithm
Let f (x1 , x2 , ..., xn ) be a switching function of n variables, where xi ∈ {0, 1}. We seek
a mixed polarity Reed-Muller expression for f with minimal cost. A design algorithm
based on the transeunt triangle, previously applied to symmetric functions, [?], [?], [?],
Definition 3. The transeunt triangle for f (x1 , x2 , ..., xn ) is a triangle of 0’s and 1’s
where the bottom row is the truth vector of f . The j-th element in the i-th row of
the triangle is denoted by ei,j , where the indices run from top-to-bottom and left-to-
the elements e2n ,0 , e2n ,1 , ..., e2n ,2n −1 . The element e2n ,k corresponds to f (α1 , α2 , ..., αn ),
where k = (α1 , α2 , ..., αn ) is the binary representation of integer k. Other elements are
Note that a transeunt triangle for an n-variable function has a width of 2n and a height
of 2n . There are (4n + 2n )/2 elements in total. Besides the defining relation, there are
11
Chapter 3. Minimization Algorithm
1 1
1 0 1
1 0 0 1
Lemma 1. For the transeunt triangle of any function f (x1 , x2 , ..., xn ), ei,j = ei+2k ,j ⊕
Similarly,
and
ei+2m−1 ,j+2m−1 = ei+2m−1 +2m−1 ,j+2m−1 ⊕ ei+2m−1 +2m−1 ,j+2m−1 +2m−1 (3.3)
Since the truth vector for functions with one or more variables has an even number of
entries, it can be divided evenly into two equal parts. Each part produces, on its own,
12
Chapter 3. Minimization Algorithm
two subtriangles. Indeed, we can identify three subtriangles, as shown in Fig. 3.2.
• T2 is the transeunt triangle for the function f (0, x2 , ..., xn ) ⊕ f (1, x2 , ..., xn ).
Proof. First, denote e0i,j to be the (i, j)-th element from T0 , e1i,j to be the (i, j)-th
element from T1 and e2i,j to be the (i, j)-th element from T2 . T0 can be considered as
the transeunt triangle for f (0, x2 , ..., xn ) because it’s bottom row is the truth vector
of f (0, x2 , ..., xn ) and every element e0i,j = e0i+1,j ⊕ e0i+1,j+1 by the construction of T .
Note, that by Lemma 1 and the statement that the height of transeunt triangle is a
power of two e2i,j = e0i,j ⊕ e1i,j . Therefore, the bottom of T2 will be “exclusive or” of the
elements of the bottom row of transeunt triangles for f (0, x2 , ..., xn ) and f (1, x2 , ..., xn ),
13
Chapter 3. Minimization Algorithm
which is the “exclusive or” of truth vectors of f (0, x2 , ..., xn ) and f (1, x2 , ..., xn ), which
is the truth vector for f (0, x2 , ..., xn ) ⊕ f (1, x2 , ..., xn ). Other (non-bottom) elements of
The algorithm to find the best, from the point of view of number of terms, mixed
function f (x1 , x2 , ..., xn ) as a truth vector and a polarity P = (ρ1 , ρ2 , ..., ρn ), construct
the corresponding transeunt triangle. To obtain the cost, divide the triangle into parts,
extracting elements. First, divide the transeunt triangle T into the three triangles T0 , T1
other words, if ρ1 = i where i ∈ {0, 1, 2}, then delete Ti . Next, repeat this process
with x2 (and ρ2 ). As a result we have four triangles. Continue this operation for all
variables until each triangle is a single element. Such a one-element triangle is called
an elementary triangle. There will be 2n of them. The sum of all these 2n values is the
cost for the given polarity (view logic values as integers and sum as integer sum).
Theorem 1. Given function f (x1 , x2 , ..., xn ), Algorithm 1 finds the cost for a given
polarity P .
1. If n = 1 write f (x1 ) = x¯1 f (0) ⊕ x1 f (1) which gives us polarity P = (2), or f (x1 ) =
14
Chapter 3. Minimization Algorithm
Algorithm 1
GetCost(T , P )
if ( |P | = 0 ) then
if ( ρ1 = 0) then
if ( ρ1 = 1) then
if ( ρ1 = 2) then
Figure 3.3: Recursive algorithm to find the cost for a given polarity.
f (0) ⊕ x1 (f (0) ⊕ f (1)) which gives us polarity P = (1), or f (x1 ) = f (1) ⊕ x¯1 (f (0) ⊕ f (1))
which gives us polarity P = (0). In this simple case the cost of the polarity P = (2) is
f (0) + f (1), the cost of the polarity P = (1) is f (0) + (f (0) ⊕ f (1))and the cost of the
polarity P = (0) is f (1) + (f (0) ⊕ f (1)). The transeunt triangle for the given function
f (0) ⊕ f (1)
f (0) f (1)
15
Chapter 3. Minimization Algorithm
Note, that T0 = f (0) is the transeunt triangle for f (0), T1 = f (1) is the transeunt
triangle for f (1) and T2 = f (0) ⊕ f (1) is the transeunt triangle for f (0) ⊕ f (1). By
so the sum of their elements is taken. It is equal to the f (1) + (f (0) ⊕ f (1)) which is
actually the cost for the given polarity as it was shown before. If ρ1 = 1 consider T0 and
T2 and conclude that the sum of their elements is equal to the cost of polarity P = (1)
follows:
From this formula it can be concluded that the final cost for every polarity P =
(2, ρ2 , ..., ρk ) will be the sum of the costs of polarity P 0 = (ρ2 , ρ3 ..., ρk ) for functions
f (0, x2 , ..., xk ) and f (1, x2 , ..., xk ). The algorithm leads one to consider triangles T0 and
T1 , which are transeunt triangles for f (0, x2 , ..., xk ) and f (1, x2 , ..., xk ) correspondingly.
By induction, the algorithm works for functions f (0, x2 , ..., xk ) and f (1, x2 , ..., xk ) as
functions from (k − 1) variables, and the cost for the given polarity P 0 will be the sum
of given by the algorithm elementary triangles inside T0 and T1 . But this sum is equal
to the sum of all given by the algorithm elementary triangles of transeunt triangle for
16
Chapter 3. Minimization Algorithm
f (x1 , x2 , ..., xk ) because the first step takes T0 and T1 due to the algorithm. And, finally,
the number which was obtained can be considered as the sum of costs of polarity P 0
for f (0, x2 , ..., xk ) and f (1, x2 , ..., xk ) which is the cost of polarity P = (2, ρ2 , ..., ρk ) for
For cases P = (1, ρ2 , ..., ρk ) and P = (0, ρ2 , ..., ρk ) the induction step is similar to the
previous proof. ¥
First, build the transeunt triangle, then identify the MPRM coefficients associated with
the given polarity according to Algorithm 1. The coefficients are shown in Fig.3.4 in
A computer program can be built to find the best mixed polarity Reed-Muller expansion
which runs with the complexity of k ∗n3n , k ≤ 4 and requires 3n memory places for n-bit
naturals (n ∗ 3n bits) of memory. Notice that every time the given algorithm is applied,
17
Chapter 3. Minimization Algorithm
some triangles are divided into the 4 parts and only 3 of them are considered: all,
except the central one which is never used. Therefore, at each step of the algorithm the
number of elements, equal to the number of the elements inside all the central triangles
considered are not used. This number of elements for the first step is 22n−3 − 2n−2 , for
the second - 3 ∗ (22n−5 − 2n−3 ), and so on up to the (n − 1)-th step, where we are not
= 2 ∗ 4n−1 − 3n + 2n−1
Now, the number of useful elements is equal to the number of all elements minus the
number of non-useful elements, that gives us 2∗4n−1 +2n−1 −(2∗4n−1 −3n +2n−1 ) = 3n .
that has these 3n elements is considered. We call this a restricted transeunt triangle
18
Chapter 3. Minimization Algorithm
transeunt triangle. The ternary number (γ1 , γ2 , ..., γn ) which corresponds to the element
ei,j of the RTT for the function f (x1 , x2 , ..., xn ) is built as follows: first, γ1 is k, if
ei,j ∈ Tk , where k ∈ {0, 1, 2}. Second, γ2 , is zero if ei,j lies in the bottom-left triangle,
one if ei,j lies in the bottom-right triangle and two if ei,j lies in the top triangle inside
the chosen Tk . Continue this operation until all values are obtained. For example,
e7,3 in (Fig. 3.5) has the ternary number (0, 1, 2), because it is in the second smallest
triangle, which is inside a bigger triangle with number 1, which in its turn, lies in the
Lemma 3. If the element ei,j with the ternary number (γ1 , γ2 , ..., γn ) has γk = 2 for
k ∈ {1, 2, ..., n}, then it is equal to the exclusive or of two elements es,t and eu,v of the
RTT with ternary numbers (γ1 , ..., γk−1 , 0, γk+1 , ..., γn ) and (γ1 , ..., γk−1 , 1, γk+1 , ..., γn )
respectively.
Proof. Notice, that by the construction of a ternary number for ei,j the change of k-th
19
Chapter 3. Minimization Algorithm
position from 2 to 0 gives us element es,t , where s = i + 2n−k and t = j. For the
same reason the change of k-th position of ei,j from 2 to 1 gives us element eu,v , where
u = i + 2n−k and v = j + 2n−k . Now we can apply Lemma 1 to prove the statement. ¥
The fact that all elements with ternary numbers (γ1 , γ2 , ..., γn ) where γi ∈ {0, 1} lie in
lexicographic order in the bottom of the RTT together with the definition of transeunt
Lemma 4. All elements with ternary numbers (γ1 , γ2 , ..., γn ) where γi ∈ {0, 1} are equal
to f (γ1 , γ2 , ..., γn ).
Given the truth vector of a function (the bottom row) we need 3n − 2n “exclusive or”
operations to build the remaining elements in the RTT. That is, there are 3n elements in
the RTT, of which 2n are the truth vector. Next, to find the best mixed polarity Reed-
3.6), switching variables are interpreted as 0, 1 integers. The resulting costs can be
calculated within the RTT so that the elements in T will contain the costs. First, take
3n−1 3-element triangles of the RTT. Each of them has elements ei,j , ei+1,j , ei+1,j+1 and
we
Note: the operations are performed simultaneously. To do this for the single 3-element
triangle requires 3 addition operations. For the first step 3 ∗ 3n−1 = 3n addition op-
20
Chapter 3. Minimization Algorithm
erations are needed. In general, for the k-th step take 3n−k of 3k -element triangles
(decomposition of T into smaller triangles as shown in the Fig. 3.7) and, within each of
them by the same rules, obtain: element-wise sum of Tβ1 ,β2 ,...,βk−1 ,0 and Tβ1 ,β2 ,...,βk−1 ,1
in Tβ1 ,β2 ,...,βk−1 ,2 , element-wise sum of Tβ1 ,β2 ,...,βk−1 ,1 and Tβ1 ,β2 ,...,βk−1 ,2 in Tβ1 ,β2 ,...,βk−1 ,0
and element-wise sum of Tβ1 ,β2 ,...,βk−1 ,2 and Tβ1 ,β2 ,...,βk−1 ,0 in Tβ1 ,β2 ,...,βk−1 ,1 , where βi ∈
{0, 1, 2} for i ∈ {1, 2, ..., k − 1}. To do this 3k ∗ 3n−k = 3k+n−k = 3n addition opera-
tions are required. After all the steps (there will be (n-1) of them) are done, costs of
all 3n different mixed polarities are represented by the elements in the RTT. It is easy
to see, that for polarity P = (ρ1 , ρ2 , ..., ρn ) its cost is in the cell with ternary number
(γ1 , γ2 , ..., γn ). To find the minimal cost any known method which finds the minimal
• 3n integers plus a few integer variables for intermediate assignments (3 were used).
Example 5. Consider the same function used in the previous example. Build the RTT
first, which already has been done, therefore just use the result as it is shown in Fig.3.8A.
Note, that those elements that are not used are initially colored gray in Fig.3.8A and
21
Chapter 3. Minimization Algorithm
will be eliminated from the future parts of the figure. Then corresponding sums inside
the small 3-element triangles are found and placed in the triangle as follows:
• the sum of leftmost bottom and top element is stored in the rightmost bottom
place;
• the sum of rightmost bottom and top element is stored in the leftmost bottom
place.
Assume that these three steps are done in parallel. The procedure is shown by arrows
on the rightmost bottom triangle in Fig.3.8A. The procedure is repeated for each 3-
element triangle colored black. The result of this step is shown in Fig.3.8B. Then take
the 9-element triangles and proceed with element-wise summation of elements of the
3-element triangles inside each of them. The order of this summation is also shown for
one of the triangles in Fig.3.8B, but is done for all 3 triangles that exist at this step.
Fig.3.8C gives us the result of our operation. Now we take the element-wise sum of
sub-triangles T0 , T1 and T2 of the whole triangle T and obtain the final result as shown
in Fig.3.8D. Each cost of the polarity P = (ρ1 , ρ2 , ρ3 ) is given by the element with the
ternary number (ρ1 , ρ2 , ρ3 ). From the figure we see that the minimum cost is 3. The
polarity of the minimal cost circled in Fig.3.8D corresponds to P = (1, 2, 2), which is
not unique. There are 3 other polarities with corresponding polynomials that have the
same cost.
22
Chapter 3. Minimization Algorithm
Given a RTT one can find all the elements inside it which are needed to obtain the
cost of any given polarity as it is shown in the previous chapter. The question that
one may ask is: can the whole expansion be obtained and not only its cost from the
transeunt triangle? The answer is “Yes” and in order to obtain the polynomial we need
to enumerate all the needed elementary triangles. The enumeration is as follows: for
a given polarity P = (ρ1 , ρ2 , ..., ρn ) and triangle Tβ1 ,β2 ,...,βn its binary number as the
needed for the given polarity element is (²1 , ²2 , ..., ²n ) where ²i for i = 1, 2, ..., n can be
ρi βi ²i ϕ(ρi , ²i , i)
0 1 0 1
0 2 1 x̄i
1 2 0 xi
1 0 1 1
2 0 0 x̄i
2 1 1 xi
Denote every coefficient of a term as E(²1 , ²2 , ..., ²n ) due to its binary number (²1 , ²2 , ..., ²n ).
Then, the polynomial for a mixed polarity P = (ρ1 , ρ2 , ..., ρn ) Reed-Muller expansion
M
E(²1 , ²2 , ..., ²n )&ϕ(ρ1 , ²1 , 1)&ϕ(ρ2 , ²2 , 2)&...&ϕ(ρn , ²n , n),
²1 ,²2 ,...,²n ∈{0,1}
23
Chapter 3. Minimization Algorithm
where the meaning of ϕ(ρi , ²i , i) is taken from the Table 3.2. The proof of correctness of
this formula is similar to the proof of Theorem 1 and can be done easily by induction and
usage of formulas (3.4). The formula will now be illustrated by the following example.
Example 6. Take the function and polarity from the previous example. The transeunt
triangle is already built, so the next step is to get all E(²1 , ²2 , ..., ²n ) with their numbers
as shown in Fig.3.9 (identify numbers ²i shown in the figure by the Table 3.2, interpreting
it as the truth table for the function ²i (ρi , βi )). Finally, using the Reed-Muller expansion
M
E(²1 , ²2 , ²3 )&ϕ(ρ1 , ²1 , 1)&ϕ(ρ2 , ²2 , 2)&ϕ(ρ3 , ²3 , 3) =
²1 ,²2 ,²3 ∈{0,1}
= 0&x1 &x¯2 &1 ⊕ 1&x1 &x¯2 &x¯3 ⊕ 1&x1 &x2 &1 ⊕ 1&x1 &x2 &x¯3 ⊕
24
Chapter 3. Minimization Algorithm
Algorithm 2
CalcCostTriangle(Tcost (f ), f )
if ( n > 1 ) then
else if ( n = 1 ) then
if f = 0 then Tcost (f ) = 0, 0, 0
if f = x then Tcost (f ) = 2, 1, 1
if f = x̄ then Tcost (f ) = 1, 2, 1
if f = 1 then Tcost (f ) = 1, 1, 2
end CalcCostTriangle
Figure 3.6: Recursive algorithm to find costs for all mixed polarities for a given function.
25
Chapter 3. Minimization Algorithm
26
Chapter 3. Minimization Algorithm
27
Chapter 4
Multiple Output Functions
The method developed in the previous section also works for multiple output functions.
Recall that a multiple output function is nothing more, but a Boolean vector-function
(f1 (x1 , x2 , ..., xn ), f2 (x1 , x2 , ..., xn ), ..., fk (x1 , x2 , ..., xn )) of some dimensionality k. To
build Reed-Muller expansion for this multiple output function we need to build expan-
sions for all functions f1 (x1 , x2 , ..., xn ), f2 (x1 , x2 , ..., xn ), ..., fk (x1 , x2 , ..., xn ). There are
two different approaches to define the cost of this expansion. One is to realize each func-
tion separately as polynomials and add all costs. From the point of view of present work
the cost defined by this rule is easy to find, and the method to find the best mixed polar-
ity Reed-Muller expansion has minimal adaptations, namely, create k transeunt triangles
and, after obtaining all the costs for all functions f1 (x1 , x2 , ..., xn ), f2 (x1 , x2 , ..., xn ), ...,
The more interesting case is if a term that has been used once, can be used again without
increasing the final cost. In this case one needs to minimize the number of distinct terms
used to realize the set of functions f1 (x1 , x2 , ..., xn ), f2 (x1 , x2 , ..., xn ), ..., fk (x1 , x2 , ..., xn ).
two arrays: “AND”-array and “EXOR”-array. In the first part of a PLA, “AND”-array,
28
Chapter 4. Multiple Output Functions
we create all necessary terms that are used in the “EXOR”-array part as many times
as it is needed. Therefore, in the theory of PLA design we care about the number of
For our algorithm, this means that the multiple output function
F (x1 , x2 , ..., xn ) = (f1 (x1 , x2 , ..., xn ), f2 (x1 , x2 , ..., xn ), ..., fk (x1 , x2 , ..., xn )) the truth vec-
tor is given as a list of words (i.e. is vectors made of ones and zeros of length k) rather
than simple bits. To build the transeunt triangle the words inside the triangle are
element-wise “exclusive or”-ed. Before the cost is calculated, all entries in the transe-
unt triangle are set to 1 if the word contains at least one nonzero bit and are set to 0
The correctness of the algorithm for the multiple output functions can be explained as
follows. First proceed by setting the numbers inside the triangle structure for the whole
multiple output function, a 1 identifies that the word contains at least one 1. Note that
it doesn’t matter how many ones were in the word. If there is at least one 1 in the word
and the cell was chosen, then the product term must be created. It doesn’t matter how
many times it will be used, since we are interested not in the number of times it is used,
but in the number of terms needed. 0 represents the case when the word consists of
29
Chapter 5
Experimental Results
The C programming language was used to implement the algorithm. The complete
program listing is in the Appendix. The RTT is represented as a flat array of the length
3n (variable int* vec;). This structure helps to work with small triangles inside the
initial big one and simplifies the work with recursive functions. Logically, the algorithm
• the recursive function void fill() will set the meanings of the transeunt triangle.
The second part, “normalize”, is needed only for multiple output functions. Here all
non-zero elements are changed to 1 since each term that is used more than once adds only
1 to the overall cost (a term can be reused). The last part, “cost”, takes the transeunt
triangle that was built in the previous part of the program, interprets boolean constants
as integers and recursively calculates costs of all polarities. Numbers for the costs of
polarities are put inside the triangle, so that in some sense the algorithm is destructive,
since the costs were found the initial structure of the transeunt triangle is lost. This
30
Chapter 5. Experimental Results
that this algorithm is destructive in that at the end of it we don’t have RTT unless
a copy of it is made before the third part of the algorithm is activated. Finally, the
minimal cost is achieved by calling minimum(vec, length) that returns the minimal
polarity cost.
The program was applied to several benchmark functions running on a Sun Enterprise
250 with two 400Mhz Ultra Sparc II processors and 1GB of main memory. The results
are summarized in Table 5. In the first column, name, denotes the name of the function
(from MCNC benchmarks). Note: co14 is a symmetric function where the output is
whose output is 1 if exactly one input is 1. Function hardn is explained in the following
section. The number of inputs (outputs) are given in in (out). The minimum number
of terms required for a fixed (mixed) polarity Reed Muller expression are shown in
cost fixed (cost mixed). OFDD time denotes the cpu time in seconds for the OFDD
implementation reported in [3] (run on a HP Apollo series 700 workstation). RTT time
gives the cpu time in seconds for our algorithm. Our results compare favorably with
variables. Memory requirements make it difficult to minimize functions with more than
18 variables.
The Internet was used to obtain the performances of the Sun Enterprise 250 with two
400Mhz Ultra Sparc II processors and the HP Apollo series 700 workstation for com-
parison purposes. From the official Sun web site it was found that the SPECint95 per-
formance of the Sun machine is 19.7 [?] while the performance of the Hewlett Packard
31
Chapter 5. Experimental Results
CPU 744 SPECint95 is 5.90 [?]. As the result of this comparison one may see that to be
fair the results for OFDD should be factored by 4 ≈ 19.7/5.90, but as we see from the
table results for our method is still significantly better. This comparison of computers
Green’s [4] algorithm (which is based on Karnaugh-like maps and has the same com-
plexity) has never been implemented. In the paper there’s no algorithm for getting
were not discussed. The author also claims that the method designed in this thesis is
easier to program.
Drechsler, Theobald and Becker’s [3] implementation is significantly slower than our
program and their algorithm considers only fixed polarity expressions. Drechsler et al.
do not provide a complexity analysis for their algorithm. However, the execution time
depends on the function as well as on the number of variables, whereas our algorithm
Lui and Muzio [5] describe an algorithm based on Boolean matrix transforms. It has
32
Chapter 5. Experimental Results
name in out cost fixed cost mixed OFDD time (secs.) RTT time (secs.)
33
Chapter 6
Further work
The first part of the proposed work will be to reduce the size of RTT for partially sym-
metric functions. Without loss of generality consider the function f (x1 , x2 , ..., xn ), par-
tially symmetric in its first 2 variables. Build its RTT and consider triangles T0,1 and T1,0
shown on the Fig.6.1. It is known that triangle T0,1 is the RTT for the f (0, 1, x3 , ..., xn )
and T1,0 is the RTT for the f (1, 0, x3 , ..., xn ). Because of the symmetry of the func-
tion in the first 2 arguments these triangles have the same bottom, therefore they are
equivalent. It is also known that T2,0 is element-wise “exclusive or” of triangles T0,0 and
T1,0 and T0,2 is element-wise “exclusive or” of triangles T0,0 and T0,1 , so they are equal
34
Chapter 6. Further work
because of the identity of T0,1 and T1,0 . The same goes for triangles T1,2 and T2,1 that
are equal to “exclusive or” of T1,0 , T1,1 and T0,1 , T1,1 correspondingly. It can be seen
that there’s no need to hold both T0,1 and T1,0 , T0,2 and T2,0 , T1,2 and T2,1 in memory.
Therefore, only one from each pair can be held, and the storage space for function par-
tially symmetric in two variables is reduced by 6/9 (keep 6 out of 9 triangles). The new
It should not be too difficult to prove that for partially symmetric functions in k vari-
(k+1)(k+2)
ables one can use a storage space of 2 ∗ 3n−k . The proof of this conjecture is
under investigation right now. The proof can be obtained by combining of the method
suggested by Butler et al. for the symmetric functions and the method for general func-
tions, which is discussed in the given work. The implementation of such an algorithm
The symmetry is exploited by Drechsler’s algorithm [3] in terms of storage. This is due
to the fact that OBDDs take advantage of symmetry naturally. However the symmetry
Cohn conjectured that any boolean function f (x1 , x2 , ..., xn ) can be realized by a poly-
[n/2]
nomial with not more than Cn terms [1]. Consider a polynomial in the basis of
other words, one can consider polynomials such that for any set of indices {i1 , i2 , ..., ik },
where i1 , i2 , ..., ik ∈ {1, 2, ..., n} there is at most one term which contains exactly the
variables xi1 , xi2 , ..., xik , each variable appearing either complemented or not. There’s
still no proof or counterexample for this conjecture, although the problem is easy to
35
Chapter 6. Further work
[n/2]
understand. The boundary Cn is achievable for the function hardn of even number
of variables n = 2k that is equal to one iff equally half of its’ inputs are one’s. In other
L
words, hardn = 1≤s1 <s2 <...<sk ≤n xs1 xs2 ...xsk which is a shortest form of polynomial
for our function (from the point of view that no better can be obtained).
To prove this statement one needs the following definitions and lemma.
Definition 4. The degree of the polynomial, deg(p(x1 , x2 , ..., xn )), is the number of
Definition 5. Two functions (polynomials) are called equal if they have equivalent
truth vectors. I
Lemma 5. Given two equal polynomials p1 (x1 , x2 , ..., xn ) and p2 (x1 , x2 , ..., xn ) which are
both in Cohn’s inconsistent form. One can transform one into the other by applying
1. xi −→ x̄i ⊕ 1;
2. x̄i −→ xi ⊕ 1;
Proof. First, take all the terms of p1 (x1 , x2 , ..., xn ) that have degree deg(p1 (x1 , x2 , ..., xn )).
Notice that for any xσi11 xσi22 ...xσikk from p1 (x1 , x2 , ..., xn ) xδi11 xδi22 ...xδikk from p2 (x1 , x2 , ..., xn )
- a term of the same degree with the same set of variables in it can be found. Prove this
statement by contradiction. Suppose that it is not so. Then there exist xσi11 xσi22 ...xσikk
36
Chapter 6. Further work
from p1 (x1 , x2 , ..., xn ) such that there’s no pair (in the sense described above) for it.
Create the sum p1 ⊕ p2 , which must be equal zero as the exclusive or of equal things.
Apply operation 2 wherever possible and open all the brackets. After doing this we have
the sum of xi1 xi2 ...xik and other terms of smaller degree and equal degree, but having
other sets of indices. Therefore, after applying operation 3, we find that xi1 xi2 ...xik
that for each term of highest degree a pair exists (another term with the same set of
variables), apply operations 1 and 2 to change xσi11 xσi22 ...xσikk to xδi11 xδi22 ...xδikk . Some new
terms may appear during this procedure, but they all will be of the smaller degree.
Now, the parts of degree k of two polynomials are equal. After this is done, proceed
with the same operation on all the terms of degree (k − 1), and so on. Finally, transform
Now, from the proof of previous Lemma we see that if we take hardn as the positive
polarity Reed-Muller expression and that any other Cohn’s inconsistent form polynomial
which represents the same function, the second will be of the same degree and will
contain all the terms of degree k that have the same set of variables as a term from the
first polynomial. Therefore, the number of terms in the second polynomial can not be
smaller than those for the first one. This function is used in our computer program.
This is a good test function, since it is complex, yet the minimal result is known. The
n/2
Theorem 2. The presented function hardn proves that Cn gives the lower boundary
for the number of terms needed to realize a Boolean function of n variables as a Cohn’s
inconsistent form.
37
Chapter 7
Conclusion
A new algorithm to minimize fixed and mixed polarity Reed Muller expressions is pre-
sented in this thesis. The algorithm is easy to understand and to program. One can
apply geometric intuition dealing with RTT. The results compare favorably to previous
algorithms, although the complexity of Θ(3n ) in either storage and execution time have
Initially, an algorithm involving transeunt triangles has been devised to find the best
polarity for totally symmetric functions in Θ(n3 ) operations and Θ(n2 ) storage space [?].
38
Bibliography
[1] M. Cohn. Inconsistent canonical forms of switching functions. IRE Transactions
of Electronic Computers, EC-11:284–285, 1962.
[4] D. H. Green. Reed-Muller canonical forms with mixed polarity and their manipu-
lations. IEE Proceedings, Part E., 137:103–113, Jan. 1990.
[5] P. K. Lui and J. C. Muzio. Boolean matrix transforms for the minimization of
modulo-2 canonical expressions. IEEE Transactions on Computers, 41:342–347,
Mar. 1992.
[7] S. M. Reddy. Easily testable realisations for logic functions. IEEE Trans. on
Computers, pages 1183–1188, 1972.
[8] T. Sasao. Logic Synthesis and Optimization. Kluwer Academic Publisher, 1993.
[9] T. Sasao and Ph. W. Besslich. On the complexity of mod-2 sum pla’s. IEEE Trans.
on Computers, C-29:262–266, Feb. 1990.
[10] J. Saul. Logic synthesis for arithmetic circuits using the Reed-Muller representation.
Proc. Euro. Conf. Design Automation, pages 109–113, 1992.
39
Bibliography
[14] T.Sasao. Switching theory for logic synthesis. Kluwer Academic Publishers, Nor-
well, MA, 1999.
40
Appendix A
C code for the program that finds the
best mixed polarity Reed-Muller
expansion
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/time.h>
#include <sys/resource.h>
/**************/
/* prototypes */
/**************/
int minimum(int *arr, int sz);
int index(int *vars);
void setTerm(char *term, int ovalue);
void fill(int *v, int size);
void normalize(int *v, int size);
void calcMixedCost(int *func, int tn);
/********************/
/* global variables */
/********************/
int* vec; /* all values in the triangle */
41
Appendix A. C code for the program that finds the best mixed polarity Reed-Muller expansion
usage=malloc(sizeof(struct rusage));
getrusage(RUSAGE_SELF,usage);
return(usage->ru_utime.tv_sec*1000000+usage->ru_utime.tv_usec);
}
/*****************************************************************
find the minimum value in an array
******************************************************************/
int minimum(int *arr, int sz){
int res = arr[0], i;
for(i = 1; i < sz; i++)
if(res > arr[i])
res = arr[i];
return res;
}
42
Appendix A. C code for the program that finds the best mixed polarity Reed-Muller expansion
/*****************************************************************
convert the triangle index to a flat one
******************************************************************/
int index(int *vars){
int res = 0, i;
for(i = 0; i < n; i++)
res = (res * 3) + vars[i];
return res;
}
/*****************************************************************
Set the truth values for a single term
******************************************************************/
void setTerm(char *term, int ovalue){
int *vars, *dashes, ndash = 0, i, done;
vars = malloc(n*sizeof(int));
dashes = malloc(n*sizeof(int));
done = 0;
while(!done){
vec[index(vars)] = vec[index(vars)] | ovalue;
i = 0;
43
Appendix A. C code for the program that finds the best mixed polarity Reed-Muller expansion
/*****************************************************************
fill all values in vec
must be called after the truth values are set
******************************************************************/
void fill(int *v, int size){
int i, s3 = size/3;
if(size > 3){
fill(v, s3);
fill(v+s3, s3);
}
for(i = 0; i < s3; i++)
v[i+2*s3] = v[i] ^ v[i+s3];
}
/*****************************************************************
change all non-zero elements to 1
used for multiple output functions
******************************************************************/
void normalize(int *v, int size){
44
Appendix A. C code for the program that finds the best mixed polarity Reed-Muller expansion
int i;
for(i = 0; i < size; i++)
v[i] = v[i] >= 1;
}
/*****************************************************************
calculate the cost for all mixed polarities
45
Appendix A. C code for the program that finds the best mixed polarity Reed-Muller expansion
length = pow(3,n);
vec = malloc(length*sizeof(int));
for( i = 0; i < length; i++)
vec[i] = 0;
fscanf(fin,"%s %d", &parm, &o); /* read number of ouputs */
if(strcmp(".o",parm) != 0){
printf("ERROR expecting .o\n");
46
Appendix A. C code for the program that finds the best mixed polarity Reed-Muller expansion
exit(1);
}
time1 = usertime();
fill(vec, length);
normalize(vec, length);
calcMixedCost(vec,n);
bestCost = minimum(vec, length);
47
Appendix A. C code for the program that finds the best mixed polarity Reed-Muller expansion
48