Programming Calculations in ManyDimensional Boolean Space
Arkadij Zakrevskij
Abstract — The set of macro operations POBS over Boolean 2"-component vectors is offered, which essentially facilitates programming calculations in many-dimensional Boolean space. The application of that set is illustrated by examples of the analysis of partial Boolean functions on a monotony and presence of functional regularities, solving problems of sequential composition and decomposition. An important role is played by operations of interaction between adjacent units of the space.
Index Terms — Boolean space, programming combinatorial problems, efficient macro operations.
I. Introduction
Aset composed of 2n Boolean n-component vectors is called the Boolean n-dimensional space. The relation of neighborhood is defined there - two vectors are called adjacent, if they differ by values exactly in one component. This relation can be represented by a graph, where nodes correspond to elements of the Boolean space, and edges join nodes corresponding to adjacent elements. Such graphs are widely used in the educational literature for the description of methods of Boolean functions minimization and solution of other logical design tasks. However, already at n>5 the graph image becomes too complicated and inconvenient for practical usage which is illustrated by Fig.
1.
More acceptable from the programming point of view is the representation of n-dimensional Boolean space as a Boolean 2n-vector, i.e. a vector with 2n components corresponding to elements of the space. These components are numbered starting with zero: component with number к corresponds to an element of the considered Boolean space which represents n-component Boolean vector specifying the binary code of number к. Assigning to components of 2n-vector the values from set {0, 1}, it is possible to set any
Manuscript received February 20, 2008.
This work was supported in part by the Belarusian Republican Fond of Fundamental Researches (Project Ф07МС-034).
Arkadij Zakrevskij is with the United Institute of Informatics Problems of the National Academy of Sciences of Belarus, 220023, Minsk; e-mail: zakr@newman. bas-net. by.
Boolean function of n variables. For example, the Boolean vector
f = 10000000 00000000 00001000 00000001 10000000 00000000 00110000 00000001
defines a Boolean function f of six variables xb x2, x3, x4, x5, x6, receiving the value 1 on the following sets of their values: 000000, 010100, 011111, 100000, 110010,
1100011,111111.
For convenience of visual perception the vector f is divided into eight fragments corresponding to intervals of the Boolean space with internal variables x4, x5, x6. These fragments represent coefficients of disjunctive Shannon decomposition of the function f by variables x1, x2, x3.
Boolean 2n-vectors serve as main objects of conversions performed at solution of manifold logic combinatorial tasks, which arise at design of discrete devices and developing systems of artificial intelligence [1]. With the purpose of raising the efficiency of their programming a basic set of macro operations over such vectors is offered in this paper. It is called POBS (Parallel Operations in Boolean Space).
As experience shows, the set POBS appears rather efficient, allowing fast operating on a modern PC with long Boolean vectors representing arbitrary Boolean functions of many variables, up to 27 including. A row presenting such a vector (containing 227 = 134 217 728 characters) would need a paper strip of length more than 250 kilometers.
II. Component-wise operations over Boolean vectors
The elementary operations of the set POBS are component-wise operations: the operation of inverting over one vector and arbitrary two-place Boolean operations over two vectors of the same size. We illustrate them by the following examples.
Designate as g and h the Boolean vectors representing Boolean functions g(x) and h(x), where x = (xb x2, x3, x4, x5). Let
g = 10001100 00100010 11100001 00101010,
h = 00110010 10001111 01100011 01100011.
Then
g = 01110011 11011101 00011110 11010101,
g v h = 10111110 10101111 11100011 01101011, g л h = 00000000 00000010 01100001 00100010,
g © h = 10111110 10101101 10000010 01001001, etc.
More complicated is the operation of permutation of arguments of a Boolean function, which is presented by a Boolean 2n-vector. It is defined by a permutation on the set of variable numbers and results in the appropriate permutation of components of the vector.
For example, as a result of permutation of numbers (4, 2, 1, 3), the variables of the set x = (xb x2, x3, x4) will rearrange in a new sequence (x4, x2, xb x3). It leads to the appropriate permutation of components of vector f, representing the Boolean function fx). The componentfk is relocated in place with number i, if the binary code к of number k represents the result of multiplying the permutation matrix P by the binary code i of number i. In other words, the vector к is equal to the component-wise disjunction of columns of matrix P, marked with ones in vector i. It is illustrated below by the example of substitution of the component f13 by f14:
P i k
1 0 0 0 1 1 1
2 0 1 0 0 1 1
3 1 0 0 0 x 0 = 1
4 0 0 1 0 1 0
1 2 3 4 13 14
Thus, permutation (4, 2, 1, 3) on the set of components of vector x results in the following permutation on the set of components of vector f :
(0, 8, 1, 9, 4, 12, 5, 13, 2, 10, 3, 11, 6, 14, 7, 15).
Let f = 0111 1010 0100 1001. Then the considered permutation on the set of components of this vector results in its new value f * =0100 1110 1110 0001,
corresponding to the new order (x4, x2, xb x3) of arguments.
III. Operations over adjacent elements of Boolean space
The set POBS contains also operations of interaction between different components of one Boolean 2n-vector f, specifying a function f(x) = f(xb x2, ..., xn). Most important are the operations over adjacent elements of Boolean space. Boolean n-vectors are adjacent if they differ by their values only in one component. For representation of Boolean space as a manydimensional Boolean cube such vectors are presented by nodes joint with edges.
Usage of such structure allows to perform parallel logical calculations and by that to accelerate them considerably. This idea is not new. So, a special supplement to the universal computer, called L-machine, was developed in 1961-1962 in the Siberian Physical-Technical Institute, which essentially accelerates the process of solving logical design problems [2]. The basic idea consists in executing of distributed in a Boolean space logic operations on a series of information fields playing the role of some registers. The fields are structurally similar to ten-dimensional Boolean cubes and allow to represent immediately Boolean functions of ten variables and complete component-wise operations over them. One of the fields is named main, and is used for conversions limited by one function. The circuit implementation of the main field provides simultaneous execution of any two-place Boolean operation within of each from 512 couples of elements adjacent by some selected variable.
The same idea was put in the basis of the commutative computer offered by W.D. Hillis in 1978 and designed by Thinking Machine corporation in 1985. This computer provides information exchange in a multiprocessor computer, which components are immediately connected with each other similarly to nodes of the n-dimensional Boolean cube. Transfer of a portion of information between any two processors in such computer takes no more than n time clicks. Several commutative computers where created and used by the researches working in the field of artificial intelligence to solve the logic inference problems [3].
When the number of arguments n exceeds 5 it is convenient to set vector f by a Boolean matrix of size 25 x 2n-5, representing its 32-element rows by words in the computer memory (what is adequate for the majority of modern computers). In this case any two units of the space M adjacent by the variable xk belong to the same word if k <
6, and belong to different words otherwise, that should be taken into account at programming. Let's remark, that in presented below examples it is more convenient for visual perception to use matrices by the size 24 x 2n-4.
We introduce the following elementary operations of conversion of a Boolean function f (x) = f (x1, x2, ..., xn) presented with vector f, by interaction of adjacent units:
f - k - assignment of value 0 to argument xk, f + k - assignment of value 1 to argument xk.
These operations are illustrated by the following matrices, splitting the set of elements of vector f into two parts corresponding to different values of the selected variable xk and called below conditionally left (marked bold font for x4) and right:
f
0110110101011110 | 0010010000010110 | 1100101001110001 || 0100010111010011
1101110111101110 | 0100010001100110 | 1010101000010001 || 0101010100110011
1 2 f + 4
f - 4
________3
__ __ __ __ 5
- _ _ _ _ _ _ _ 6
0110011001010101 0010001000010001 1100110001110111 0100010011011101
0110110101011110
0010010000010110
0110110101011110
0010010000010110
f - 1
At execution of the operation f - k both elements in each couple adjacent by the variable xk accept value from the left part, at execution of the operation f + k - from the right part. If n < 6 (in the given example if n < 5) this operation is implemented by means of appropriate shift of columns in the matrix, otherwise - of rows.
By way of generalization we shall enter the following operations, in which instead of the scalar k the n-component Boolean vector u is used:
f - u - assignment of value 0 to all arguments xk, which correspond to 1-components (having value 1) uk of vector u,
f + u - assignment of value 1 to all arguments xk, which correspond to 1-components uk of vector u.
The first of these operations can be interpreted as obtaining the initial coefficient f0 of disjunctive Shannon decomposition of function f by all variables of the set u (in this case all variables receive value 0), the second - as obtaining the finite coefficient f1 (when all variables receive value 1).
For example, if n = 8 and u = 01100010, the operation f - u is equivalent to the composition ((f - 2) - 3) - 7, and the operation f + u is equivalent to the composition ((f + 2) + 3) + 7. Thus the same value is assigned to variables x2, x3 and x7.
Let's introduce also the operation of symmetrization S f * k, at which execution the both adjacent by variable xk elements in each couple gain an identical value, as a result of application of the operator *, selected from the set {v, л, ^, ©, ...}, to the initial values of the elements of a couple. This operation also is reduced to the surveyed above, as
S f * k = (f - k) * (f + k).
For example,
f
0110110101011110 | 0010010000010110 | 1100101001110001 || 0100010111010011
0111111101111111 | 0011011000110110 | 1111101111111011 || 1101011111010111
1 2 S f v 3
S f © 1
____ 3
__ __ __ __ 5
_______________ 6
1010011100101111
0110000111000101
1010011100101111
0110000111000101
0000110000001100
0000000000000000
1100000000110000
0000000011000011
S f Л 6
In particular, operation S f © k represents the well known operation of derivation of a Boolean function by the variable xk.
The operation of symmetrizing S f * k also is generalized by usage of a vector u instead of a scalar k. It is represented by expression S f * u and is equivalent to the sequence of operations S f * ki, in which scalars ki represent the numbers of 1-components of vector u. In this case operator * is selected from the set { v, л, ©}.
For example, if u = 010011, the operation S f л u is equivalent to the expression
S(S(S f л 2) л 5) л 6.
It can be interpreted in such a way: all elements of the fragment of vector f, corresponding to conjunction xi x3 x4, gain value 0, if even one of them was equal to 0.
IV. Operations of conversion of dimension of Boolean vectors
Such operations allow to implement interaction between Boolean vectors of different dimension.
consider two Boolean vectors:
n-vector u with k ones marking some k variables from the
set x = (x1, x2, ., xn),
2k-vector h, specifying the Boolean function h of the marked variables.
We introduce into set POBS the operation h x u of transfer of the function h into a fragment of the Boolean space of n variables, which corresponds to the conjunction of inversions of not marked in u variables. By that all elements of remaining fragments gain value 0.
Let, for example, n = 5, u = 01101 and h = 10010011.
Then a Boolean 25-vector is created, in which the fragment corresponding to the conjunction x x4 is selected (marked with bold):
00000000 00000000 00000000 00000000,
and the vector h is inscribed in it. As a result, the following vector is obtained:
hxu= 10000100 00001100 00000000 00000000
The operation f : u is introduced by analogy: it realizes a return carry of the information from the selected fragment of 2n-vector to the vector h, specifying obtained by that Boolean function h of к variables. So, if u = 01010 and
f = 00110010 11100000 11100110 00011101
then the fragment is found, which corresponds to conjunction x1 x3 x5
00110010 11100000 11100110 00011101
and the information contained in it is used for build-up of the required vector:
h = f : u = 0111.
If it is known, that function f represented by vector f depends only on variables of the set u (the rest variables appear fictitious), then by means of the operation f : u the latter are deleted from the function and the result is represented by vector h.
V. Operations over partial Boolean functions
Let's pass to reviewing partial (not completely defined) Boolean functions widely used when solving problems of logical design.
Any arbitrary partial Boolean function f of n variables can be represented by a corresponding 2n-component ternary vector f-. For programming it is more convenient to set it by a couple of Boolean vectors f 1 and f 0, also 2n-component. By that ones in the vector f 1 mark components, on which the function f receives value 1, and in the vector f 0 they mark components, where the function is equal to zero. In other words, the vectors f 1 and f 0 represent accordingly characteristic sets M 1 and M 0 of the function f
Let, for example,
f- = 1-001010 011--01-1.
Then
f 1 = 10001010 011000101, f0 = 00110101 100001000.
example, in the operation of disjunctive decomposition of a partial Boolean function f by all variables of the united set u1 u u0 the obtaining of the coefficient at that conjunction is carried out by the series of operations
f1- u0 , f0- u0, f 1+ u1 , f0+ u1.
VI. Programming in basis POBS
Let's show some examples of using a software technology in basis POBS to solve tasks of the theory of Boolean functions.
A.. Testing a partial Boolean function on monotony
Consider a partial Boolean function fx) = (x1, x2, ..., xn), given by two sets of argument values collections: by the set M 1, on which it receives value 1, and the set M 0, where it receives value 0. Let's term it as monotone or, in particular, a positive function, if for any couple of collections p e M 1 and q e M 0 condition p > q (vector p is greater than vector q) is satisfied, i.e. for any couple (pi, q) of vector components pt > qi and at least for one couple pi > qi .
A simple method of checking the function for monotony could be applied, which is based on exhaustive search of all couples (p, q) and testing each of them on satisfying the condition p > q . However, with increase of the number of variables n and corresponding growth of power of sets M 1 and M 0 such method appears too labour-consuming. The offered below method using operations from the set POBS is more efficient.
Let's set the function f (x) by two Boolean 2n-vectors: f 1 and f 0. The elements of set M 1 are represented by ones in vector f 1, the elements of set M o - by ones in vector f 0. Designate as M* the set of such elements of Boolean space, each of which is greater than some element from set M 1 or equals it, and present this set by vector/*.
The affirmation 1. The function fix) is monotone, if and only if f * f 0 = 0.
The vector f * can be found with the help of introduced above operations of the set POBS, by a sequence of n steps. At first we receive the vector f 2 = (f 1 - 1) vf1, presenting set M1, supplemented with elements of Boolean space, adjacent "from above" to some elements from M1 by variable x1. Then the obtained set is expanded similarly by the next variable x2: f 3=(f 2 - 1) v f 2. After iterating this operation by all remaining variables we receive the required vector f "+1 = f *.
Let, for example, n = 5,
In this case the operation of assignment of value 0 to argument xk will be represented by the couple of operations f- к , f0- k, and that of value 1 - by the couple f1 + k,
f0 + k.
Similarly to f, the Boolean vector u also can appear ternary, for example when representing some elementary conjunction Then it also should be replaced by a pair of Boolean vectors u1 and u0, in this case n-component. For
f1 = 00010000 00100000 00000001 00001010, f0 = 11000010 00000100 10100000 10000000.
In this case the process of the sequential extension of set M1, resulting in obtaining vector f * representing set M*, can be demonstrated by the following sequence of vectors obtained on the next steps:
f2 = 00010000 00100000 00010001 00101010 ,
f3 = 00010000 00110000 00010001 00111011 , f4 = 00010001 00110011 00010001 00111011 , f5 = 00010001 00110011 00010001 00111011 , f6 = 00010001 00110011 00010001 00111111=f*
Component-wise conjunction of the obtained vector with vector
11000010 00000100 10100000 10000000 = f0
is equal to zero (f *Af 0=0), therefore, the considered Boolean function is monotone.
B. Search for functional regularities
An important role in modern information technologies is played by procedures of data mining, i.e. extraction of knowledge from the dataflow, search of regularities allowing discovering right decisions at solution of the intellectual tasks [4]. A special but important case of regularities is considered below, namely functional regularities, often encountered in natural sciences.
The following formal task was considered in [5]. We assume that a set of objects is preset, each of which is characterized by some combination of n binary values (indicating if the corresponding signs are present or not present). The question is, whether it is possible always to define uniquely the value of some selected sign, if the values of remaining ones are known? And if possible, how to define it?
The initial information in this task can be presented by a collection R of some elements in n-dimensional Boolean space M = {0, 1}n of signs. These elements set known objects and can be considered as the roots of some Boolean equation F = 1, where x = (xb x2, ..., xn).
This equation is called solvable in regard to some variable, if this variable can be presented by a Boolean function of the remaining variables, which is defined on the set R [5]. We consider the task of detection of such variables in the equation F = 1 and finding the appropriate functions.
The affirmation 2. The necessary and sufficient condition of solvability of the equation F = 1 in regard to the variable xi is the absence in the set R of couples of collections, adjacent by xi.
Proof by contradiction (by the rule modus tollens): if there exists such a couple, the variable xi receives in it different values on identical sets of values of remaining variables, which contradicts the definition of the functional relation.
Let's designate through fx) the characteristic Boolean function of set R, where f (q) = 1 if q e R and f (q) = 0 if — (q e R). Through f (xi = 0) and f (xi = 1) we denote the result of replacement in the function f (x) the variable xi with constant 0 or 1, accordingly.
The affirmation 3. The equation F = 1 is solvable in regard to variable xi, if and only if f (xi = 0) A f (xi = 1) = 0.
This affirmation allows to apply introduced above vector operations f - i and f + i for checking the equation for solvability in regard to variable xi. Affirmation 3 can be
reformulated in terms of these operations in the following way: the necessary and sufficient condition of solvability of the equation F = 1 in regard to variable xi is the satisfaction of the relation
(f - i) a (f + i) = 0.
In case if this condition is satisfied there arises a task of finding an appropriate Boolean function, which generally appears to be partial, and its optimal determination. The optimization can consist both in minimization of the number of arguments of the function, and in simplification of its algebraic representation, for example in DNF.
Let's consider the first of these tasks. It is similar to the task of minimization of unconditional diagnostic test and can be solved by the same method. Some argument xk can be defined as fictitious, if after its deleting the equation remains solvable in regard to the variable xi. The operation of deleting the argument xk can be presented as the extension of set R by this variable, i.e. as the following conversion of its characteristic function f
f := f(xk = 0) v f(xk = 1).
In terms of introduced above vector operations it is defined as S f v k, whence follows
The affirmation 4. The argument xk can be deleted from the set of arguments of the variable xi defined as a function of remaining variables, if and only if
((S f v k) - i) A ((S f v k) + i) = 0.
C. Sequential composition of Boolean functions
Let's consider the following task. The set of arguments x=(xb x2, ..., xn) is divided by the Boolean n-vectors u, w and v into three not intersected subsets u, w and v : x = u u w u v. Two Boolean functions h(u, w) and g(x, w, v), presented with corresponding Boolean vectors h and g are given also. It is required to calculate their composition under condition x = h(u, w) and to present the obtained Boolean functionf(x) by a 2n-vectorf.
Such composition called non-disjoint sequential two-block, is illustrated by an example on fig. 2, where n = 6 and the sets u = (xb x2), w = (x3, x4) and v = (x5, x6) are presented by six-dimensional Boolean vectors u = 110000, w = 001100 and v = 000011.
Fig. 2. An example of non-disjoint sequential two-block composition
Let's assume, that the functions h(u, w) and g(x, w, v) are preset by corresponding vectors:
h=1101001001101100
g= 0011010011001001 1010010110101011
g0 g1
For convenience, the vector g is broken in two halves, specifying values of the function g(x, w, v) at values 0 and 1 of binary variable x.
We present the Boolean space of variables x = (u, w, v) as follows:
0000 0000 0000 0000 | 0000 0000 0000 0000
| 0000 0000 0000 0000
|| 0000 0000 0000 0000
U2 U1
Then we sequentially map onto this space functions g, h0 and h1, introducing thus additional fictitious variables from the sets v and u and representing results by 2n-vectors a, b and c:
h x (u, w) - v = a
1000 1000 0000 1000 1111 1111 0000 1111
0000 0000 1000 0000 0000 0000 1111 0000
0000 1000 1000 0000 0000 1111 1111 0000
1000 1000 0000 0000 1111 1111 0000 0000
g0 X (w, v) - u = b
0011 0100 1100 1001 0011 0100 1100 1001
0000 0000 0000 0000 0011 0100 1100 1001
0000 0000 0000 0000 0011 0100 1100 1001
0000 0000 0000 0000 0011 0100 1100 1001
g1 X (w, v) - u = c
1010 0101 1010 1011 1010 0101 1010 1011
0000 0000 0000 0000 1010 0101 1010 1011
0000 0000 0000 0000 1010 0101 1010 1011
0000 0000 0000 0000 1010 0101 1010 1011
In summary we discover the vector f, representing the
required composition of functions h(u, w) and g(x, w, v):
0011 0100 0000 1001
0000 0000 1100 0000 a b
0000 0100 1100 0000
0011 0100 0000 0000
0000 0000 1010 0000
1010 0101 0000 1011 a c
1010 0000 0000 1011
0000 0000 1010 1011
0011 0100 1010 1001
1010 0101 1100 1011 f = a b Vi a c
1010 0100 1100 1011
0011 0100 1010 1011
D. Testing a partial Boolean function on decomposability at a given partition on the set of arguments
Suppose that a partial Boolean function fx) of n variables, represented by a ternary vector f ~ is known. It is required to test it on decomposability at a given partition u/v of the set x, i.e. to find out, whether there exist such functions h(u, w) and g(x, w, v) of smaller number of variables, that f (x) = g(h(u, w), w, v), where w = x \ (u u v).
At the positive answer to this question the logic circuit implementing function f(x) can be simplified (for example, at logical synthesis in the basis of units LUT (look up tables), implementing functions of restricted number of variables).
The necessary and sufficient condition of decomposability of a completely defined Boolean function fx) at a partition u/v, which should be fulfilled for each coefficient f (u, v) of disjunctive Shannon decomposition of the function f(x) by variables of the set w is the following. Each of the coefficients of alike decomposition of these coefficients by variables of the set u should receive no more than two different values.
The coefficients f (u, v) of disjunctive Shannon decomposition of a partial Boolean function f(x) by variables of set w are represented by fragments T - ternary matrices, which rows correspond to different values of vector u, and columns correspond to different values of vector v. The corresponding components of the ternary vector f - serve as elements of fragments. The condition of decomposability of the function fx) at the partition u/v can be formulated now as follows: for each coefficient fi (u, v) such predetermination of the appropriate matrix T is possible (replacement of values by 0 or 1), at which its rows will receive no more than two different values.
It was shown in [6], that the check of this condition is reduced to finding out if the graph of orthogonality of rows of each matrix Ti is bichromatic. A heuristic algorithm was suggested there, which guarantees obtaining exact solutions under condition of connectivity of the considered graphs (this condition is usually fulfilled). The ternary vector f - is represented in it by an appropriate couple of Boolean vectors f 1 and f 0, and the operations over the neighbors are effectively used providing simultaneous testing of all 2|w| fragments T.
The algorithm tries to divide the set of rows in each fragment into two classes A and B of mutually compatible rows. A sequence of conversions is implemented over the initial vectors f 1 and f 0, which results are represented by Boolean 2n-vectors a 1 and a 0
The algorithm is iterated. The first iteration starts with build-up of the class A by inclosing in it the first row of the fragment. This operation is reduced to a sequence of substitutions of value 0 for the variables from set u.
a 0 = f 0 - u a 1 :=f 1 - u
1
w2 1
V1 2 V2
Then in each fragment the rows orthogonal to the first one are found and marked with 1 in the Boolean vector b.
b := S (h f1 v h f0) v v.
The obtained sets constitute classes B and are checked for compatibility:
a 0 := S (f 0b) v u a 1 := S (f lb) v u
If by that a 0 a 1 Ф 0, some of the considered sets appear incompatible, whence follows, that the graph of orthogonality of rows of the corresponding fragment is not bichromatic and, therefore, the function f(x) is not decomposable at the partition u/v.
On the other hand, if a 0 a 1 = 0, the following iteration is implemented. The classes A are supplemented by rows, orthogonal by some of rows of classes B and are checked for compatibility. Then the classes B can be similarly extended, etc. The algorithm terminates after execution of a sufficient number of iterations.
References
[1] Zakrevskij A.D Computation in Boolean spaces. In “Logical structure of scientific knowledge”. Moscow: Nauka, 1965, pp. 292-310 (in Russian).
[2] Zakrevskiy A.D. Machine for the solution of logical problems of the type of the synthesis of relay circuits. - Relay systems and finite automata. Transl. proceedings., Burrough Corp., 1964. pp. 544-557.
[3] W. Daniel Hillis. Connection machine. - Scientific American, June 1987, Vol. 256, No 6.
[4] Data mining and knowledge discovery approaches based on rule induction techniques (E. Triantaphyllou and G. Felici, Eds.). -Massive Computing Series, Springer, Heidelberg, Germany, 2006.
[5] Zakrevskij A.D. About solvability of Boolean equations. -
Proceedings of NAS of Belarus, 2007, Vol. 51, No 5, pp. 44-46 (in Russian).
[6] Arkadij Zakrevskij. A new heuristic algorithm for sequential two-block decomposition of Boolean functions. - Proceedings of 3rd IFAC Workshop on Discrete Event System Design DESDes’06. September 26-28, 2006, Rydzyna, Poland. University of Zielona Gora, pp. 13-17.