Zhegalkin polynomial explained

Zhegalkin (also Žegalkin, Gégalkine or Shegalkin) polynomials (Russian: полиномы Жегалкина), also known as algebraic normal form, are a representation of functions in Boolean algebra. Introduced by the Russian mathematician Ivan Ivanovich Zhegalkin in 1927, they are the polynomial ring over the integers modulo 2. The resulting degeneracies of modular arithmetic result in Zhegalkin polynomials being simpler than ordinary polynomials, requiring neither coefficients nor exponents. Coefficients are redundant because 1 is the only nonzero coefficient. Exponents are redundant because in arithmetic mod 2, x2 = x. Hence a polynomial such as 3x2y5z is congruent to, and can therefore be rewritten as, xyz.

__TOC__

Boolean equivalent

Prior to 1927, Boolean algebra had been considered a calculus of logical values with logical operations of conjunction, disjunction, negation, and so on. Zhegalkin showed that all Boolean operations could be written as ordinary numeric polynomials, representing the false and true values as 0 and 1, the integers mod 2. Logical conjunction is written as xy, and logical exclusive-or as arithmetic addition mod 2, (written here as xy to avoid confusion with the common use of + as a synonym for inclusive-or ∨). The logical complement ¬x is then x⊕1. Since ∧ and ¬ form a basis for Boolean algebra, all other logical operations are compositions of these basic operations, and so the polynomials of ordinary algebra can represent all Boolean operations, allowing Boolean reasoning to be performed using elementary algebra.

For example, the Boolean 2-out-of-3 threshold or median operation is written as the Zhegalkin polynomial xyyzzx.

Formal properties

Formally a Zhegalkin monomial is the product of a finite set of distinct variables (hence square-free), including the empty set whose product is denoted 1. There are 2n possible Zhegalkin monomials in n variables, since each monomial is fully specified by the presence or absence of each variable. A Zhegalkin polynomial is the sum (exclusive-or) of a set of Zhegalkin monomials, with the empty set denoted by 0. A given monomial's presence or absence in a polynomial corresponds to that monomial's coefficient being 1 or 0 respectively. The Zhegalkin monomials, being linearly independent, span a 2n-dimensional vector space over the Galois field GF(2) (NB: not GF(2n), whose multiplication is quite different). The 22

n vectors of this space, i.e. the linear combinations of those monomials as unit vectors, constitute the Zhegalkin polynomials. The exact agreement with the number of Boolean operations on n variables, which exhaust the n-ary operations on, furnishes a direct counting argument for completeness of the Zhegalkin polynomials as a Boolean basis.

This vector space is not equivalent to the free Boolean algebra on n generators because it lacks complementation (bitwise logical negation) as an operation (equivalently, because it lacks the top element as a constant). This is not to say that the space is not closed under complementation or lacks top (the all-ones vector) as an element, but rather that the linear transformations of this and similarly constructed spaces need not preserve complement and top. Those that do preserve them correspond to the Boolean homomorphisms, e.g. there are four linear transformations from the vector space of Zhegalkin polynomials over one variable to that over none, only two of which are Boolean homomorphisms.

Method of computation

There are various known methods generally used for the computation of the Zhegalkin polynomial:

The method of indeterminate coefficients

Using the method of indeterminate coefficients, a linear system consisting of all the tuples of the function and their values is generated. Solving the linear system gives the coefficients of the Zhegalkin polynomial.

Example

Given the Boolean function

f(A,B,C)=\barA\barB\barC+\barAB\barC+A\barB\barC+ABC

, express it as a Zhegalkin polynomial. This function can be expressed as a column vector\vec f = \begin 1 \\ 0 \\ 1 \\ 0 \\ 1 \\ 0 \\ 0 \\ 1 \end .

This vector should be the output of left-multiplying a vector of undetermined coefficients \vec c = \begin c_0 \\ c_1 \\ c_2 \\ c_3 \\ c_4 \\ c_5 \\ c_6 \\ c_7 \endby an 8x8 logical matrix which represents the possible values that all the possible conjunctions of A, B, C can take. These possible values are given in the following truth table:

1
0 0 0 1 0 0 0 0 0 0 0
0 0 1 1 1 0 0 0 0 0 0
0 1 0 1 0 1 0 0 0 0 0
0 1 1 1 1 1 1 0 0 0 0
1 0 0 1 0 0 0 1 0 0 0
1 0 1 1 1 0 0 1 1 0 0
1 1 0 1 0 1 0 1 0 1 0
1 1 1 1 1 1 1 1 1 1 1

The information in the above truth table can be encoded in the following logical matrix: S_3 = \begin 1&0&0&0&0&0&0&0 \\1&1&0&0&0&0&0&0 \\1&0&1&0&0&0&0&0 \\1&1&1&1&0&0&0&0 \\1&0&0&0&1&0&0&0 \\1&1&0&0&1&1&0&0 \\1&0&1&0&1&0&1&0 \\1&1&1&1&1&1&1&1\endwhere the 'S' here stands for "Sierpiński", as in Sierpiński triangle, and the subscript 3 gives the exponents of its size:

23 x 23

.

It can be proven through mathematical induction and block-matrix multiplication that any such "Sierpiński matrix"

Sn

is its own inverse.

Then the linear system is S_3 \vec c = \vec fwhich can be solved for

\vecc

: \vec c = S_3^ \vec f = S_3 \vec f= \begin 1&0&0&0&0&0&0&0 \\ 1&1&0&0&0&0&0&0 \\ 1&0&1&0&0&0&0&0 \\ 1&1&1&1&0&0&0&0 \\ 1&0&0&0&1&0&0&0 \\ 1&1&0&0&1&1&0&0 \\ 1&0&1&0&1&0&1&0 \\ 1&1&1&1&1&1&1&1 \end \begin 1 \\ 0 \\ 1 \\ 0 \\ 1 \\ 0 \\ 0 \\ 1 \end = \begin 1 \\ 1 \\ 1 \oplus 1 \\ 1 \oplus 1 \\ 1 \oplus 1 \\ 1 \oplus 1 \\ 1 \oplus 1 \oplus 1 \\ 1 \oplus 1 \oplus 1 \oplus 1 \end = \begin 1 \\ 1 \\ 0 \\ 0 \\ 0 \\ 0 \\ 1 \\ 0 \end,and the Zhegalkin polynomial corresponding to

\vecc

is

1CAB

.

Using the canonical disjunctive normal form

Using this method, the canonical disjunctive normal form (a fully expanded disjunctive normal form) is computed first. Then the negations in this expression are replaced by an equivalent expression using the mod 2 sum of the variable and 1. The disjunction signs are changed to addition mod 2, the brackets are opened, and the resulting Boolean expression is simplified. This simplification results in the Zhegalkin polynomial.

Using tables

Let

c0,...,

c
2n-1
be the outputs of a truth table for the function P of n variables, such that the index of the

ci

's corresponds to the binary indexing of the minterms. Define a function ζ recursively by: \zeta(c_i) := c_i \zeta(c_0, \dots, c_k) := \zeta(c_0, \dots, c_) \oplus \zeta(c_1, \dots, c_k). Note that \zeta(c_0, \dots, c_m) = \bigoplus_^m _2 c_k where _2 is the binomial coefficient reduced modulo 2.

Then g_i = \zeta(c_0, \dots, c_i) is the i th coefficient of a Zhegalkin polynomial whose literals in the i th monomial are the same as the literals in the i th minterm, except that the negative literals are removed (or replaced by 1).

The ζ-transformation is its own inverse, so the same kind of table can be used to compute the coefficients

c0,...,

c
2n-1
given the coefficients

g0,...,

g
2n-1
. Just let c_i = \zeta(g_0, \dots, g_i).

In terms of the table in the figure, copy the outputs of the truth table (in the column labeled P) into the leftmost column of the triangular table. Then successively compute columns from left to right by applying XOR to each pair of vertically adjacent cells in order to fill the cell immediately to the right of the top cell of each pair. When the entire triangular table is filled in then the top row reads out the coefficients of a linear combination which, when simplified (removing the zeroes), yields the Zhegalkin polynomial.

To go from a Zhegalkin polynomial to a truth-table, it is possible to fill out the top row of the triangular table with the coefficients of the Zhegalkin polynomial (putting in zeroes for any combinations of positive literals not in the polynomial). Then successively compute rows from top to bottom by applying XOR to each pair of horizontally adjacent cells in order to fill the cell immediately to the bottom of the leftmost cell of each pair. When the entire triangular table is filled then the leftmost column of it can be copied to column P of the truth table.

As an aside, this method of calculation corresponds to the method of operation of the elementary cellular automaton called Rule 102. For example, start such a cellular automaton with eight cells set up with the outputs of the truth table (or the coefficients of the canonical disjunctive normal form) of the Boolean expression: 10101001. Then run the cellular automaton for seven more generations while keeping a record of the state of the leftmost cell. The history of this cell then turns out to be: 11000010, which shows the coefficients of the corresponding Zhegalkin polynomial.

The Pascal method

The most economical in terms of the amount of computation and expedient for constructing the Zhegalkin polynomial manually is the Pascal method.

We build a table consisting of

2N

columns and

N+1

rows, where N is the number of variables in the function. In the top row of the table we place the vector of function values, that is, the last column of the truth table.

Each row of the resulting table is divided into blocks (black lines in the figure). In the first line, the block occupies one cell, in the second line — two, in the third — four, in the fourth — eight, and so on. Each block in a certain line, which we will call "lower block", always corresponds to exactly two blocks in the previous line. We will call them "left upper block" and "right upper block".

The construction starts from the second line. The contents of the left upper blocks are transferred without change into the corresponding cells of the lower block (green arrows in the figure). Then, the operation "addition modulo two" is performed bitwise over the right upper and left upper blocks and the result is transferred to the corresponding cells of the right side of the lower block (red arrows in the figure). This operation is performed with all lines from top to bottom and with all blocks in each line. After the construction is completed, the bottom line contains a string of numbers, which are the coefficients of the Zhegalkin polynomial, written in the same sequence as in the triangle method described above.

The summation method

According to the truth table, it is easy to calculate the individual coefficients of the Zhegalkin polynomial. To do this, sum up modulo 2 the values of the function in those rows of the truth table where variables that are not in the conjunction (that corresponds to the coefficient being calculated) take zero values.

Suppose, for example, that we need to find the coefficient of the xz conjunction for the function of three variables

f(x,y,z)

. There is no variable y in this conjunction. Find the input sets in which the variable y takes a zero value. These are the sets 0, 1, 4, 5 (000, 001, 100, 101). Then the coefficient at conjunction xz is

a_5 = f_0 \oplus f_1 \oplus f_4 \oplus f_5 = f(0,0,0) \oplus f(0,0,1) \oplus f(1,0,0) \oplus f(1,0,1)

Since there are no variables with the constant term,a_0 = f_0.

For a term which includes all variables, the sum includes all values of the function:a_ = f_0 \oplus f_1 \oplus f_2 \oplus \dots \oplus f_ \oplus f_

Let us graphically represent the coefficients of the Zhegalkin polynomial as sums modulo 2 of values of functions at certain points. To do this, we construct a square table, where each column represents the value of the function at one of the points, and the row is the coefficient of the Zhegalkin polynomial. The point at the intersection of some column and row means that the value of the function at this point is included in the sum for the given coefficient of the polynomial (see figure). We call this table

TN

, where N is the number of variables of the function.

There is a pattern that allows you to get a table for a function of N variables, having a table for a function of

N-1

variables. The new table

TN+1

is arranged as a 2 × 2 matrix of

TN

tables, and the right upper block of the matrix is cleared.

Lattice-theoretic interpretation

Consider the columns of a table

TN

as corresponding to elements of a Boolean lattice of size

2N

. For each column

fM

express number M as a binary number

M2

, then

fM\lefK

if and only if

M2\veeK2=K2

, where

\vee

denotes bitwise OR.

If the rows of table

TN

are numbered, from top to bottom, with the numbers from 0 to

2N-1

, then the tabular content of row number R is the ideal generated by element

fR

of the lattice.

Note incidentally that the overall pattern of a table

TN

is that of a logical matrix Sierpiński triangle. Also, the pattern corresponds to an elementary cellular automaton called Rule 60, starting with the leftmost cell set to 1 and all other cells cleared.

Using a Karnaugh map

The figure shows a function of three variables, P(A, B, C) represented as a Karnaugh map, which the reader may consider as an example of how to convert such maps into Zhegalkin polynomials; the general procedure is given in the following steps:

Möbius transformation

The Möbius inversion formula relates the coefficients of a Boolean sum-of-minterms expression and a Zhegalkin polynomial. This is the partial order version of the Möbius formula, not the number theoretic. The Möbius inversion formula for partial orders is: g(x) = \sum_ f(y) \leftrightarrow f(x) = \sum_ g(y) \mu(y,x),where

\mu(y,x)=(-1)|x|

, |x| being the Hamming distance of x from 0. Since

-1\equiv1

in the Zhegalkin algebra, the Möbius function collapses to being the constant 1.

The set of divisors of a given number x is also the order ideal generated by that number:

\langlex\rangle

. Since summation is modulo 2, the formula can be restated as g(x) = \bigoplus_ f(y) \leftrightarrow f(x) = \bigoplus_ g(y)

Example

As an example, consider the three-variable case. The following table shows the divisibility relation:

xdivisors of x
000000
001000, 001
010000, 010
011000, 001, 010, 011
100000, 100
101000, 001, 100, 101
110000, 010, 100, 110
111000, 001, 010, 011, 100, 101, 110, 111

Then\begin g(000) &= f(000) \\[1ex] g(001) &= f(000) \oplus f(001) \\[1ex] g(010) &= f(000) \oplus f(010) \\[1ex] g(011) &= f(000) \oplus f(001) \oplus f(010) \oplus f(011) \\[1ex] g(100) &= f(000) \oplus f(100) \\[1ex] g(101) &= f(000) \oplus f(001) \oplus f(100) \oplus(101) \\[1ex] g(110) &= f(000) \oplus f(010) \oplus f(100) \oplus f(110) \\[1ex] g(111) &= f(000) \oplus f(001) \oplus f(010) \oplus f(011) \oplus f(100) \oplus f(101) \oplus f(110) \oplus f(111)\end

The above system of equations can be solved for f, and the result can be summarized as being obtainable by exchanging g and f throughout the above system.

The table below shows the binary numbers along with their associated Zhegalkin monomials and Boolean minterms:

Boolean mintermABCZhegalkin monomial

\barA\barB\barC

0001

\barA\barBC

001C

\barAB\barC

010B

\barABC

011BC

A\barB\barC

100A

A\barBC

101AC

AB\barC

110AB

ABC

111ABC

The Zhegalkin monomials are naturally ordered by divisibility, whereas the Boolean minterms do not so naturally order themselves; each one represents an exclusive eighth of the three-variable Venn diagram. The ordering of the monomials transfers to the bit strings as follows: given

a1a2a3

and

b1b2b3

, a pair of bit triplets, then

a1a2a3\leb1b2b3\leftrightarrowa1\leb1\wedgea2\leb2\wedgea3\leb3

.

The correspondence between a three-variable Boolean sum-of-minterms and a Zhegalkin polynomial is then:\begin&f(000) \bar A \bar B \bar C \vee f(001) \bar A \bar B C \vee f(010) \bar A B \bar C \vee f(011) \bar A B C \vee f(100) A \bar B \bar C \vee f(101) A \bar B C \vee f(110) A B \bar C \vee f(111) A B C \\[1ex]&\qquad \equiv g(000) \oplus g(001) C \oplus g(010) B \oplus g(011) BC \oplus g(100) A \oplus g(101) AC \oplus g(110) AB \oplus g(111) ABC.\end

The system of equations above may be summarized as a logical matrix equation:

\begin g(000) \\ g(001) \\ g(010) \\ g(011) \\ g(100) \\ g(101) \\ g(110) \\ g(111) \end =\begin1 && 0 && 0 && 0 && 0 && 0 && 0 && 0 \\1 && 1 && 0 && 0 && 0 && 0 && 0 && 0 \\1 && 0 && 1 && 0 && 0 && 0 && 0 && 0 \\1 && 1 && 1 && 1 && 0 && 0 && 0 && 0 \\1 && 0 && 0 && 0 && 1 && 0 && 0 && 0 \\1 && 1 && 0 && 0 && 1 && 1 && 0 && 0 \\1 && 0 && 1 && 0 && 1 && 0 && 1 && 0 \\1 && 1 && 1 && 1 && 1 && 1 && 1 && 1 \end \begin f(000) \\ f(001) \\ f(010) \\ f(011) \\ f(100) \\ f(101) \\ f(110) \\ f(111) \end

which N. J. Wildberger calls a Boole–Möbius transformation.

Below is shown the “XOR spreadsheet” form of the transformation, going in the direction of g to f:

f000

f001

f010

f011

f100

f101

f110

f111

g000

g000g001

g000g010

g000g010g001g011

g000g100

g000g100g001g101

g000g100g010g110

g000g100g010g110g001g101g011g111

g001

g001g010

g001g011

g001g011g010g100

g001g101

g001g101g010g110

g001g101g011g111

g010

g010g011

g010g100

g010g100g011g101

g010g110

g010g110g011g111

g011

g011g100

g011g101

g011g101g100g110

g011g111

g100

g100g101

g100g110

g100g110g101g111

g101

g101g110

g101g111

g110

g110g111

g111

Related work

In 1927, in the same year as Zhegalkin's paper, the American mathematician Eric Temple Bell published a sophisticated arithmetization of Boolean algebra based on Richard Dedekind's ideal theory and general modular arithmetic (as opposed to arithmetic mod 2). The much simpler arithmetic character of Zhegalkin polynomials was first noticed in the west (independently, communication between Soviet and Western mathematicians being very limited in that era) by the American mathematician Marshall Stone in 1936 when he observed while writing up his celebrated Stone duality theorem that the supposedly loose analogy between Boolean algebras and rings could in fact be formulated as an exact equivalence holding for both finite and infinite algebras, leading him to substantially reorganize his paper over the next few years.

See also

Further reading