| Minimization of Boolean functions to match the sets |
|
|
| Written by Олег Дамаскин | |
| Воскресенье, 07 Сентябрь 2008 | |
|
The text of the original in Russian Minimization of Boolean functions to match the sets In the Reporting Boolean formula "has been mentioned that one of the challenges of reporting a Boolean formula is the problem of creating a formula with at least the minimum number of letters in it. The problem often is, and to developers of logic for the various devices, including finite automata and circuits for computers. Because the number of letters in the formula of a Boolean function, implemented in logic, determines the number of elements in the matrix. "There are several ways to minimize Boolean funktsiy.Prezhde all, an analytical character and the analytical reference methods, the method Kvayna - Mack-Klaski method BlackJack - Poretskogo, the method of generalized codes [11] and minimizing with graphics cards Carnot [12]. Example for the demonstration of analytical techniques: z = x_y + xy_ + xy = (x_y + xy) + (xy_ + xy) = y (x_ + x) + x (y_ + y) = x + y. z = 01 +10 +11 = (01 +11) + (10 +11) = -1 +1- = x + y. The first four methods is extremely cumbersome and inefficient already when the number of arguments for more than four. The method of generalized codes is focused on the use of computers, but can be used with manual functions for the synthesis of a large number of variables. " (http://ruslogic.narod.ru/lectures/3.htm) I would add to that statement somewhat subjective noticed. 1. Most of the methods actually minimizes the function only at the level of DNF (dizyunktivnoy normal form), ie in the absence of brackets, which then give a real reduction in the number of letters in the formula. 2. Reducing the number of letters carried out on the rules of Boolean algebra (the method of Blake) and depends on your experience. (http://www.sgu.ru/ie/mehmat/odfka/r3/R3-1.htm) 3. Practically there is no guarantee that you have obtained the formula, if it is rather difficult, is the minimum that it can not be reduced further. I at one time was involved in the development of automated devices (in theory - finite automata) to missile technology, and I can say that most designers were schemes devices, guided not so much a theory, but common sense. I think this is because the theory is complex and not sufficiently developed for practical use. Ideas that I want to present here, were born in those times. Getting started Let's consider the proposed method on the example of the system functions for the implementation of the logical network "mouse in a maze," a synthesis of which is given in the book "N. Kobrinsky and BA Trakhtenbrot Introduction to the theory of finite automata. 1962" In total, we'll find the 5 functions of z1, z2, f1 (t +1), f2 (t +1), f3 (t +1) of the 5 variables x1, x2, f1 (t), f2 (t), f3 (t) , each of which is set truth table. Truth table for all five functions shown in Fig. 1. Table excerpted from this book with some adjustments for the convenience of recording. Truth table for the system functions, "Mouse in the maze" Number p. Logon ID code input condition code output code output state --------------- ---------------------------------- -- --------------- ----------------------------------- -- Number count 1 2 3 4 5 6 7 8 9 10 x1 x2 f1 (t) f2 (t) f3 (t) z1 z2 f1 (t +1) f2 (t +1) f3 (t +1) 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 0 0 0 0 2 0 0 0 1 0 1 0 0 0 0 3 0 0 0 1 1 1 0 0 0 0 4 0 0 1 0 0 1 0 0 0 0 5 0 0 1 0 1 1 0 0 0 0 6 0 0 1 1 0 1 0 0 0 0 7 0 0 1 1 1 (1) (0) (0) (0) (0) 8 0 1 0 0 0 0 1 1 1 0 9 0 1 0 0 1 0 0 1 1 0 10 0 1 0 1 0 0 0 1 1 0 11 0 1 0 1 1 0 0 1 0 1 12 0 1 1 0 0 1 0 0 1 1 13 0 1 1 0 1 (1) (0) (0) (1) (1) 14 0 1 1 1 0 1 0 0 1 1 15 0 1 1 1 1 (1) (0) (0) (1) (1) 16 1 0 0 0 0 0 0 0 0 1 17 1 0 0 0 1 0 0 1 1 0 18 1 0 0 1 0 0 1 1 1 0 19 1 0 0 1 1 0 0 1 0 0 20 1 0 1 0 0 1 1 1 1 1 21 1 0 1 0 1 0 1 1 1 0 22 1 0 1 1 0 (1) (1) (1) (1) (1) 23 1 0 1 1 1 1 1 1 1 1 24 1 1 0 0 0 1 1 1 1 1 25 1 1 0 0 1 (1) (1) (1) (1) (1) 26 1 1 0 1 0 (1) (1) (1) (1) (1) 27 1 1 0 1 1 (1) (1) (1) (1) (1) 28 1 1 1 0 0 (1) (1) (1) (1) (1) 29 1 1 1 0 1 (1) (1) (1) (1) (1) 30 1 1 1 1 0 (1) (1) (1) (1) (1) 31 1 1 1 1 1 1 1 1 1 1 Fig. 1 To this truth table in the book using graphs is the following system of equations for the five functions that implement automatic "mouse in a maze." The system of equations 1 z1 =-x1 (-x2 [f2 (t) + f3 (t)] + f1 (t)) + x1 (f1 (t) [f2 (t) +-f3 (t)] + x2) (1) 10 z2 = x2 [-f1 (t)-f2 (t)-f3 (t) + x1] + x1 [f2 (t)-f3 (t) + f1 (t)] (2) 9 f1 (t +1) = x2 [x1 +-f1 (t)] + x1 [f1 (t) + f2 (t) + f3 (t)] (3) 7 f2 (t +1) =-x1 (x2 [f1 (t) +-f2 (t) +-f3 (t)] +-f1 (t)-f2 (t)-f3 (t)) + x1 [x2 + f1 (t) +-f2 (t) f3 (t) + f2 (t)-f3 (t)] (4) 15 f3 (t +1) =-x1 (x2 [f2 (t) f3 (t) + f1 (t)]) + x1 (-f2 (t)-f3 (t) + f1 (t) [f2 (t) + f3 (t)] + x2) (5) 12 The figures at the end of each row with formulas (1) - (5) show the number of letters (input variables) in each formula Basic concepts of minimization of Boolean functions to match the sets Functional subsets. Under the functional defined as the set of sets of the function for which a Boolean formula, ie it is a lot of zeros and ones in the table of truth. For example, for the function z2 such a lot of column 7 is the truth table in Figure 1. Sets of functional elements are only 0 and 1. Field to the functional sets. The field - a finite ordered set, designed to accommodate the functional set and creating it through the use of arbitrary sets of Boolean algebra. Denote this set as a Pole. Pole did not contain any element of 0 or 1, these elements are functional elements of the sets, the actual elements Pole is the place to accommodate it to any other elements, including the functional elements of the sets 0 and 1. The place may remain empty. Power Pole M, ie number of seats on the board, shall not be less than the maximum possible number of elements funkuionalnogo sets, ie M> = 2 in the degree of Alf, (6) where Alf - the number of input variables of the required functions. Field, you can create a high supply and use it to create the functions of the different number of variables. For example, with 5 of the input variables number M = 32 (2 to 5 so far). Graphically Pole can be represented as a sequence of cells, such as _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I_I Fig.2 Pole Call Pole functional if this field contains at least one element of 0 or 1. The field in Fig.2 is not functional, as it does not contain the elements of 0 or 1. On the field, you can place any of the items. In Fig. 3 shows the field in each cell that contains numbers from 0 to 31, but each number represented by two digits to indicate that these elements do not make field functional. Here if the first two squares are the numbers 0 and 1, this field could be called functional. This is exactly the same Pole, as in Fig. 2, but the graphical representation of a rectangle that allows you to more clearly show produced on the field operations. Numbers in cells indicate the number of cells (sites for placement of items). I 00 I 01 I 02 I 03 I I 04 I 05 I 06 I 07 I I 08 I 09 I 10 I 11 I I 12 I 13 I 14 I 15 I I 16 I 17 I 18 I 19 I I 20 I 21 I 22 I 23 I I 24 I 25 I 26 I 27 I I 28 I 29 I 30 I 31 I Fig.3 Pole Now show an example of functional Pole for the function f3 (t +1), consistently moving the values of the function f3 (t +1) in column 10 of Table truth. Note that the lines coincide with the truth table cell numbers Pole. The result is shown in Fig. 4. or in simplified form in Fig. 5 I 0 I 0 I 0 I 0 I 0000 0000 I 0 I 0 I 0 II 000 000a I 0 I 0 I 0 I 1 I 0001 0001 I 1 II 1 II 1 1 1a1a I 1 I 0 I 0 I 0 I 1000 1000 I 1 I 0 II 1 I 10 1 10a1 I 1 IIII 1 1aaa IIII 1 I 1 aaa1 research. 4 Pole f3 (t +1) Fig. 5 Pole f3 (t +1) Fig. 6 Pole f3 (t +1) Please note that not all elements of Pole f3 (t +1) coincides with the elements of column 10 of Table truth. The table has a number of items in parentheses (lines 13, 15, 22, 25 - 30). Under the terms of the objectives of some of the values of functions are not defined. In practice, this often the case. This happens for various reasons, particularly because some situations are impossible, or the function is not essential for success. The authors of the books themselves, these numbers doopredelili functions entering into them in brackets, not explaining why they choose these values. The proposed method does not need doopredelyat uncertain values of the function, so the place of these values or simply remain empty (Fig. 4, 5), either at their place is an arbitrary element (and - in Fig. 6), which by definition is equivalent to an empty place and is made only for display purposes when using the method. Split Pole into subsets. Application of the method to minimize the splitting field for Alf pairs vzaimnoneperesekayuschihsya subsets as follows. Each input variable with a value of 1 or 0 will match the element Pole. In this case, and received from Alf system pairs vzimoneperesekayuschihsya subsets. For simplicity, denote the set of values of variable 1, as well as very variable, and set the appropriate variable to value 0, as well as very variable, but with the sign "-". For the Pole in Fig.3 then get 5 pairs of sets: x1,-x1; x2,-x2; f1 (t),-f1 (t); f2 (t),-f2 (t); f3 (t),-f3 (t); Many x1 consists of 4 lower rows Pole (items 16-31); many-x1 be held from 4 top Pole (items 00-15); x2 lot consists of 2 sets of strings of lower-x1 (elements 08-15) and 2 bottom lines set x1 (items 24-31); many-x2 consists of 2 sets of top-x1 (elements 00-07) and 2 upper rows of the set of x1 (items 16-23); a lot of f1 (t) consists of a single bottom line of intersection of the sets-x1-x2 (elements 04-07), one bottom line of intersection of the sets-x1x2 (elements 12-15), one bottom line of intersection of the sets x1-x2 (elements 20-23 ), and a bottom line of intersection of the sets x1x2 (items 28-31); many-f1 (t) consists of one line of intersection of the sets of top-x1-x2 (elements 00-03), a top line of intersection of the sets-x1x2 (elements 08-11), a top line of intersection of the sets x1-x2 (items 16 -- 19), and a top line of intersection of the sets x1x2 (items 24-27); a lot of f2 (t) consists of 2 columns right-Pole (02,03,06,07,10,11,14,15,18,19,22,23,26,27,30,31 elements); many-f2 (t) consists of 2 columns Left Pole (00,01,04,05,08,09,12,13,16,17,20,21,24,25,28,29 elements); a lot of f3 (t) consists of odd elements Pole (01,03,05,07,09,11,13,15,17,19,21,23,25,27,29,31 elements); many-f3 (t) consists of even elements Pole (00,02,04,06,08,10,12,14,16,18,20,22,24,26,28,30 elements); Formation of a single set of Note that any desired Boolean function determines the values of truth, ie value 1, for all values of input variables, as reflected in the truth table. If you move to multiple interpretations of a Boolean algebra, this means that it is necessary to form a Pole set of units. The formula of this set, call it a single, and the desired formula, a Boolean function. If you look at the Pole f3 (t +1) in Fig. 4, 5, 6, this problem does not seem such a difficult one. A table 1 for Pole f3 (t +1) sets, including the number of ones and zeros in each. Table 1 for Pole f3 (t +1) x1-x1 x2-x2 f1 (t)-f1 (t) f2 (t)-f2 (t) f3 (t)-f3 (t) 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 5 4 3 10 5 3 3 11 5 4 3 10 4 6 4 8 3 7 5 7 For example, we see that almost all units in the subset of x2 the most units (5), and least of all zeros (3). It faces to the idea that, if the multistep process of forming a single set, the first step you can select a set of x2. The result is a first step, then the formula F1 = x2 (step 1) For the formula on the second step should be to consider two options. The set includes 5 pieces x2 However, this set is zero, and (3 zero), from which you want to get rid of. In the second step, we can both be considered two options. The first option - only a lot of x2. Costavim Table 2-1 for x2, similar to Table 1 Table 2-1 for x2 x1-x1 x2-x2 f1 (t)-f1 (t) f2 (t)-f2 (t) f3 (t)-f3 (t) 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 2 0 3 3 5 3 0 0 3 0 2 3 3 1 2 2 2 1 3 2 Then, you will notice that the largest number of units in the set x2 contain multiple-x1, f1 (t), f2 (t),-f3 (t) (3 units of 5), but only one set of f1 (t) does not contain any one zero. Therefore, the result of the second step will be incomplete formula F2-1 = x2f1 (t) (step 2-1) This formula determines the set, in which 3 units (of a total of 8) and a single scratch. However, there is a second option to consider many-x2 c to form a set containing all the units. A table for the 2-2 set-x2. Table 2-2 for-x2 x1-x1 x2-x2 f1 (t)-f1 (t) f2 (t)-f2 (t) f3 (t)-f3 (t) 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 3 4 1 7 0 0 3 11 2 4 1 7 1 5 2 6 1 7 2 4 Many x1 contains 1 unit and 5 zeros, is the largest number of units compared with the other sets, containing the unit. Therefore, the second option on the second step would be the formula F2-2 = x2 + x1 (step 2-2) This formula determines the set, which is 8 units, and 7 zeros. So how many choose to (step 2-1) and (step 2-2)? Match Sets In the theory of sets such thing as coincidence sets yet. But how to compare the two sets are close if they do they look like? What could be the criterion of similarity, proximity? In the proposed approach to the choice of the minimum formula Boolean function (ie, the formation of the set consisting only of ones) best predstavletsya test compares the number of ones and zeros in the sets, but not absolute, but relative, that is as the difference in the number of units in the set assigned to the total number of units in the other (original) set and the number of zeros is also assigned to the total number of zeros. If the total number of units to designate as s1, and the total number of zeros as s0, and, consequently, the number of units in a set of i, as s1 [i], and the number of zeros as s0 [i], a convergence of sov [i] ic set of baseline defined as sov [i] = s1 [i] / s1 - s0 [i] / s0 (7) In accordance with this definition of convergence on the set itself is 0. Complete coincidence, when the set contains all the units and only one, and the magnitude of convergence is 1. By contrast, if the set contains some zeros, then the value of convergence is -1. Continuation of Procedure We use the formula (1) and find consistent sets of matches for the x2, x2f1 (t), x2 + x1 set on Pole f3 (t +1), where s1 = 8, and s0 = 14. Accordingly, s1 (F1) = 5, s0 (F1) = 3, s1 (F2-1) = 3, s0 (F2-1) = 0, s1 (F2-2) = 8, s0 (F2-2) = 7. Then sov (F1) = 5 / 8 - 3 / 14 = 0.411; sov (F2-1) = 3 / 8 - 0 / 14 = 0.375; sov (F2-2) = 8 / 8 - 7 / 14 = 0.5; Choose a set of x2 + x1 (he has a greater overlap than in the set x2f1 (t)), ie The results of the second step, the formula F2 = x2 + x1 (step 2) What a lot to choose the third step? Here the choice is expanding. You can get rid of the zeros on the set of x2 + x1 whole or at each of the sets of x2 and x1. A table for 3-1 sets of x2 + x1 Table 3-1 for the x2 + x1 x1-x1 x2-x2 f1 (t)-f1 (t) f2 (t)-f2 (t) f3 (t)-f3 (t) 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 5 4 3 3 5 3 3 4 5 1 3 6 4 3 4 4 3 4 5 3 Obviously, the best choice would be a lot of f1 (t) (5 units and 1 zero). Then F3-1 = [x2 + x1] f1 (t) (step 3-1) c coincidence sov (F3-1) = 5 / 8 - 1 / 14 = 0.554. The second option - the conversion of a lot of x2, which is already done in Step 2-1. Then F3-2 = x2f1 (t) + x1 (step 3-2) c coincidence sov (F3-2) = 7 / 8 - 4 / 14 = 0.589. The third option - the transformation of the set of x1. To this end, a table 3-3 Table 3-3 for x1 x1-x1 x2-x2 f1 (t)-f1 (t) f2 (t)-f2 (t) f3 (t)-f3 (t) 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 5 4 0 0 2 0 3 4 3 1 2 3 2 0 3 2 2 3 3 1 The sets of f1 (t), and-f3 (t) have equal chances, but f1 (t) has been used in previous versions, so look at the formula F3-3 = x2 + x1-f3 (t) (step 3-3) c coincidence sov (F3-3) = 7 / 8 - 4 / 14 = 0.589, ie the same result, that F3-2. Therefore, the final outcome of the third step F3 = x2f1 (t) + x1 (step 3) Fourth step. Consider the following options on the basis of formulas obtained in Step 3. F4-1 = x2f1 (t) + x1-f3 (t) (step 4-1), for which the sov (F4-1) = 6 / 8 - 1 / 14 = 0.679 For F4-2, a table 4-2 on the set-x1 [-x2 +-f1 (t)], ie to deny the many x2f1 (t) + x1. Table 4-2 for-x1 [-x2 +-f1 (t)] x1-x1 x2-x2 f1 (t)-f1 (t) f2 (t)-f2 (t) f3 (t)-f3 (t) 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 1 10 1 3 0 7 0 3 1 7 1 4 0 6 1 4 0 6 It is obvious that no one gives a lot of good results, as even the best set of x2 returns us to the second step, the formula F2. The third option is based on the search for additional sets in the set [x2 + x1]-f1 (t) (see F3-1) Table 4-3 to [x2 + x1]-f1 (t) x1-x1 x2-x2 f1 (t)-f1 (t) f2 (t)-f2 (t) f3 (t)-f3 (t) 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 2 3 1 3 2 3 1 3 0 0 3 6 1 3 2 3 1 3 2 3 Then, F4-3 will look like F4-3 = [x2 + x1] [f1 (t) +-f2 (t)], a sov (F4-3) = 7 / 8 - 4 / 14 = 0.589, so that F4 = x2f1 (t) + x1-f3 (t) (step 4), Step 5. Table 5-1 for x2 [-f1 (t)] x1-x1 x2-x2 f1 (t)-f1 (t) f2 (t)-f2 (t) f3 (t)-f3 (t) 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 3 2 3 0 0 0 0 2 3 1 1 1 2 1 1 1 2 Table 5-2 for x1 [f3 (t)] x1-x1 x2-x2 f1 (t)-f1 (t) f2 (t)-f2 (t) f3 (t)-f3 (t) 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 3 1 0 0 1 0 2 1 1 0 2 1 2 1 1 2 1 1 1 2 Table 5-3 for the x1-f3 x1-x1 x2-x2 f1 (t)-f1 (t) f2 (t)-f2 (t) f3 (t)-f3 (t) 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 3 1 0 0 1 0 2 1 1 0 2 1 0 1 3 0 0 0 3 1 Accordingly, consider the formula F5-1 = x2 [f1 (t) + f2 (t)] + x1-f2 (t) sov (F5-1) = 7 / 8 - 3 / 14 = 0.661 F5-2 = x2f1 (t) + x1 [-f3 (t) + f1 (t)] sov (F5-2) = 7 / 8 - 2 / 14 = 0.73 F5-3 = x2f1 (t) + x1-f3 (t)-f2 (t) sov (F5-3) = 6 / 8 = 0.75 The biggest match in the set designated by the formula F5-3, so step 5 choose this formula F5 = x2f1 (t) + x1-f3 (t)-f2 (t) (step 5) sov (F5-3) = 6 / 8 = 0.75 Likewise obrazomo form and follow the formula, choosing at each step with a lot of Most coincidence until we get a lot of overlap, to 1. F6 = x2 [f1 (t) + f2 (t)] + x1-f3 (t)-f2 (t) (step 6) sov (F6) = 7 / 8 - 1 / 14 = 0.804 F7 = x2 [f1 (t) + f2 (t) f3 (t)] + x1-f3 (t)-f2 (t) (step 7) sov (F7) = 7 / 8 = 0.875 F8 = x2 [f1 (t) + f2 (t) f3 (t)] + x1 [-f3 (t)-f2 (t) + f1 (t)] (step 8) sov (F8) = 8 / 8 -- 1 / 14 = 0,929 F9 = x2 [f1 (t) + f2 (t) f3 (t)] + x1 [-f3 (t)-f2 (t) + f1 (t) f2 (t)] (step 9) sov (F9) = 1 Thus, the final formula for the f3 (t +1) would be as follows f3 (t +1) = x2 [f1 (t) + f2 (t) f3 (t)] + x1 [-f3 (t)-f2 (t) + f1 (t) f2 (t)] (8) The number of letters (input variables) in this formula is equal to 9, ie 3 less than the formula (5) system Equations 1, the authors found the book "Introduction to the theory of finite automata." In general, the system of equations for all the functions of logical network "mouse in a maze, found the proposed method is as follows. The system of equations 2 z1 = f1 (t) [-f3 (t) + f2 (t)] +-x1-x2 [f2 (t) + f3 (t)] + x2x1 (9) 9 z2 = x1 (f1 (t) +-f3 (t) [x2 + f2 (t)]) + x2-f2 (t)-f1 (t)-f3 (t) (10) 9 f1 (t +1) = x1 [f1 (t) + f3 (t) + f2 (t)] + x2-f1 (t) (11) 6 f2 (t +1) = [x2 + x1] (f1 (t) + [-f2 (t) +-f3 (t)] [x2 + f3 (t) + f2 (t)]) +-f2-f1 -x1-f3 (12) 12 f3 (t +1) = x2 [f1 (t) + f2 (t) f3 (t)] + x1 [-f3 (t)-f2 (t) + f1 (t) f2 (t)] (13) 9 In this system of equations (9) - (13), as in the system of equations 1 (1) - (5), numbers at the end of rows indicate the number of letters in each formula. In four of the five formulas proposed method reduced the number of letters. The total number of letters decreased from 53 to 45. |




