> ##

> ## 3.3 Algebraic Manipulation of Boolean Expressions

> You can transform one boolean expression into an equivalent expression by applying the postulates and theorems of boolean algebra. This is important if you want to convert a given expression to a canonical form (a standardized form) or if you want to minimize the number of literals (primed or unprimed variables) or terms in an expression. Minimizing terms and expressions can be important because electrical circuits often consist of individual components that implement each term or literal for a given expression. Minimizing the expression allows the designer to use fewer electrical components and, therefore, can reduce the cost of the system.

> Unfortunately, there are no fixed rules you can apply to optimize a given expression. Much like constructing mathematical proofs, an individual's ability to easily do these transformations is usually a function of experience. Nevertheless, a few examples can show the possibilities:

>     	ab + ab' + a'b							=	a(b+b') + a'b								By P4

>     								=	a1 + a'b								By P5

>     								=	a + a'b								By Th4

>     								=	a + b								By Th11

>     	(a'b + a'b' + b')		`					=	( a'(b+b') + b')'								By P4

>     								=	(a'1 + b')'								By P5

>     								=	(a' + b')								By Th4

>     								=	( (ab)' )'								By Th8

>     								=	ab								By definition of not

>     	b(a+c) + ab' + bc' + c							=	ba + bc + ab' + bc' + c			By P4

>     								=	a(b+b') + b(c + c') + c			By P4

>     								=	a1 + b1 + c			By P5

>     								=	a + b + c			By Th4

> Although these examples all use algebraic transformations to simplify a boolean expression, we can also use algebraic operations for other purposes. For example, the next section describes a canonical form for boolean expressions. We can use algebraic manipulation to produce canonical forms even though the canonical forms are rarely optimal.

> ## 3.4 Canonical Forms

> Since there are a finite number of boolean functions of n input variables, yet an infinite number of possible logic expressions you can construct with those n input values, clearly there are an infinite number of logic expressions that are equivalent (i.e., they produce the same result given the same inputs). To help eliminate possible confusion, logic designers generally specify a boolean function using a canonical, or standardized, form. For any given boolean function there exists a unique canonical form. This eliminates some confusion when dealing with boolean functions.

> Actually, there are several different canonical forms. We will discuss only two here and employ only the first of the two. The first is the so-called sum of minterms and the second is the product of maxterms. Using the duality principle, it is very easy to convert between these two.

> A term is a variable or a product (logical AND) of several different literals. For example, if you have two variables, A and B, there are eight possible terms: A, B, A', B', A'B', A'B, AB', and AB. For three variables we have 26 different terms: A, B, C, A', B', C', A'B', A'B, AB', AB, A'C', A'C, AC', AC, B'C', B'C, BC', BC, A'B'C', AB'C', A'BC', ABC', A'B'C, AB'C, A'BC, and ABC. As you can see, as the number of variables increases, the number of terms increases dramatically. A minterm is a product containing exactly n literals. For example, the minterms for two variables are A'B', AB', A'B, and AB. Likewise, the minterms for three variables A, B, and C are A'B'C', AB'C', A'BC', ABC', A'B'C, AB'C, A'BC, and ABC. In general, there are 2n minterms for n variables. The set of possible minterms is very easy to generate since they correspond to the sequence of binary numbers:

> Binary Equivalent (CBA) | Minterm
> --- | ---
> 000 | A'B'C'
> 001 | AB'C'
> 010 | A'BC'
> 011 | ABC'
> 100 | A'B'C
> 101 | AB'C
> 110 | A'BC
> 111 | ABC

> We can specify any boolean function using a sum (logical OR) of minterms. Given F 248=AB+C the equivalent canonical form is ABC+A'BC+AB'C+A'B'C+ABC'. Algebraically, we can show that these two are equivalent as follows:

>     ABC+A'BC+AB'C+A'B'C+ABC'								=	BC(A+A') + B'C(A+A') + ABC'										By P4

>     								=	BC1 +B'C1 + ABC'										By Th15

>     								=	C(B+B') + ABC'										By P4

>     								=	C + ABC'										By Th15 & Th4

>     								=	C + AB										By Th11

> Obviously, the canonical form is not the optimal form. On the other hand, there is a big advantage to the sum of minterms canonical form: it is very easy to generate the truth table for a function from this canonical form. Furthermore, it is also very easy to generate the logic equation from the truth table.

> To build the truth table from the canonical form, simply convert each minterm into a binary value by substituting a "1" for unprimed variables and a "0" for primed variables. Then place a "1" in the corresponding position (specified by the binary minterm value) in the truth table:

> 1) Convert minterms to binary equivalents:

> F248 = CBA + CBA' + CB'A + CB'A' + C'BA

> = 111 + 110 + 101 + 100 + 011

> 2) Substitute a one in the truth table for each entry above:

> C | B | A | F = AB+C
> --- | --- | --- | ---
> 0 | 0 | 0 |
> 0 | 0 | 1 |
> 0 | 1 | 0 |
> 0 | 1 | 1 | 1
> 1 | 0 | 0 | 1
> 1 | 0 | 1 | 1
> 1 | 1 | 0 | 1
> 1 | 1 | 1 | 1

> Finally, put zeros in all the entries that you did not fill with ones in the first step above:

> C | B | A | F = AB+C
> --- | --- | --- | ---
> 0 | 0 | 0 | 0
> 0 | 0 | 1 | 0
> 0 | 1 | 0 | 0
> 0 | 1 | 1 | 1
> 1 | 0 | 0 | 1
> 1 | 0 | 1 | 1
> 1 | 1 | 0 | 1
> 1 | 1 | 1 | 1

> Going in the other direction, generating a logic function from a truth table, is almost as easy. First, locate all the entries in the truth table with a one. In the table above, these are the last five entries. The number of table entries containing ones determines the number of minterms in the canonical equation. To generate the individual minterms, substitute A, B, or C for ones and A', B', or C' for zeros in the truth table above. Then compute the sum of these items. In the example above, F 248 contains one for CBA = 111, 110, 101, 100, and 011. Therefore, F 248 = CBA + CBA' + CB'A + CB'A' + C'AB. The first term, CBA, comes from the last entry in the table above. C, B, and A all contain ones so we generate the minterm CBA (or ABC, if you prefer). The second to last entry contains 110 for CBA, so we generate the minterm CBA'. Likewise, 101 produces CB'A; 100 produces CB'A', and 011 produces C'BA. Of course, the logical OR and logical AND operations are both commutative, so we can rearrange the terms within the minterms as we please and we can rearrange the minterms within the sum as we see fit. This process works equally well for any number of variables. Consider the function F 53504 = ABCD + A'BCD + A'B'CD + A'B'C'D. Placing ones in the appropriate positions in the truth table generates the following:

> D | C | B | A | F = ABCD + A'BCD + A'B'CD + A'B'C'D
> --- | --- | --- | --- | ---
> 0 | 0 | 0 | 0 |
> 0 | 0 | 0 | 1 |
> 0 | 0 | 1 | 0 |
> 0 | 0 | 1 | 1 |
> 0 | 1 | 0 | 0 |
> 0 | 1 | 0 | 1 |
> 0 | 1 | 1 | 0 |
> 0 | 1 | 1 | 1 |
> 1 | 0 | 0 | 0 | 1
> 1 | 0 | 0 | 1 |
> 1 | 0 | 1 | 0 |
> 1 | 0 | 1 | 1 |
> 1 | 1 | 0 | 0 | 1
> 1 | 1 | 0 | 1 |
> 1 | 1 | 1 | 0 | 1
> 1 | 1 | 1 | 1 | 1

> The remaining elements in this truth table all contain zero.

> Perhaps the easiest way to generate the canonical form of a boolean function is to first generate the truth table for that function and then build the canonical form from the truth table. We'll use this technique, for example, when converting between the two canonical forms this chapter presents. However, it is also a simple matter to generate the sum of minterms form algebraically. By using the distributive law and theorem 15 (A + A' = 1) makes this task easy. Consider F 248 = AB + C. This function contains two terms, AB and C, but they are not minterms. Minterms contain each of the possible variables in a primed or unprimed form. We can convert the first term to a sum of minterms as follows:

>     	AB			=	AB  1						By Th4

>     				=	AB  (C + C')						By Th 15

>     				=	ABC + ABC'						By distributive law

>     				=	CBA + C'BA						By associative law

> Similarly, we can convert the second term in F 248 to a sum of minterms as follows:

>     	C			=	C  1										By Th4

>     				=	C  (A + A')										By Th15

>     				=	CA + CA'										By distributive law

>     				=	CA1 + CA'1										By Th4

>     				=	CA  (B + B') + CA'  (B + B')										By Th15

>     				=	CAB + CAB' + CA'B + CA'B'										By distributive law

>     				=	CBA + CBA' + CB'A + CB'A'										By associative law

> The last step (rearranging the terms) in these two conversions is optional. To obtain the final canonical form for F 248 we need only sum the results from these two conversions:

>     	F248		=	(CBA + C'BA) + (CBA + CBA' + CB'A + CB'A')

>     			=	CBA + CBA' + CB'A + CB'A' + C'BA

> Another way to generate a canonical form is to use products of maxterms. A maxterm is the sum (logical OR) of all input variables, primed or unprimed. For example, consider the following logic function G of three variables:

>     		G = (A+B+C)  (A'+B+C)  (A+B'+C).

> Like the sum of minterms form, there is exactly one product of maxterms for each possible logic function. Of course, for every product of maxterms there is an equivalent sum of minterms form. In fact, the function G, above, is equivalent to

> F248 = CBA + CBA' + CB'A + CB'A' + C'BA = AB +C.

> Generating a truth table from the product of maxterms is no more difficult than building it from the sum of minterms. You use the duality principle to accomplish this. Remember, the duality principle says to swap AND for OR and zeros for ones (and vice versa). Therefore, to build the truth table, you would first swap primed and non-primed literals. In G above, this would yield:

> G= (A' + B' + C') (A + B' + C') (A' + B + C')

> The next step is to swap the logical OR and logical AND operators. This produces

> G = A'B'C' + AB'C' + A'BC'

> Finally, you need to swap all zeros and ones. This means that you store zeros into the truth table for each of the above entries and then fill in the rest of the truth table with ones. This will place a zero in entries zero, one, and two in the truth table. Filling the remaining entries with ones produces F 248.

> You can easily convert between these two canonical forms by generating the truth table for one form and working backwards from the truth table to produce the other form. For example, consider the function of two variables, F 7 = A + B. The sum of minterms form is F 7 = A'B + AB' + AB. The truth table takes the form:

> Table 15: F7 (OR) Truth Table for Two Variables
> F7 | A | B
> --- | --- | ---
> 0 | 0 | 0
> 0 | 1 | 0
> 1 | 0 | 1
> 1 | 1 | 1

> Working backwards to get the product of maxterms, we locate all entries that have a zero result. This is the entry with A and B equal to zero. This gives us the first step of G=A'B'. However, we still need to invert all the variables to obtain G=AB. By the duality principle we need to swap the logical OR and logical AND operators obtaining G=A+B. This is the canonical product of maxterms form.

> Since working with the product of maxterms is a little messier than working with sums of minterms, this text will generally use the sum of minterms form. Furthermore, the sum of minterms form is more common in boolean logic work. However, you will encounter both forms when studying logic design.