Boolean Operators The Boolean operators AND and OR are binary infix operators (that is, they take two arguments, and the operator appears between them.) A AND B D OR E We will form Boolean Functions of these by setting them equal to a result variable, f. f AND = A AND B f OR = D OR E They are formally defined by specifying the Truth Table associated with them. A truth table is a table in which all possible combinations of values for the arguments (sometimes called inputs, for reasons which will become clear later) are listed, and the value of the function (result, or output) for each combination is given. Since these are binary operators, there are two arguments, each of which can take on only the values of T or F, so that there are only a total of four possible combinations of values. Thus there are only four rows in the truth table, which is Arguments Result A B f AND F F F F T F T F F T T T This truth table defines the AND function by specifying that the result of the function is TRUE only if both of the arguments are TRUE. This should be intuitively make sense. In words, if A is TRUE AND B is TRUE, then f AND is TRUE, otherwise f AND is FALSE. Alternatively, it is sometimes useful to interpret the table as saying if either A is FALSE or B is FALSE, then f AND is FALSE, otherwise it is TRUE. In an identical fashion, the OR function, f OR, is defined by the truth table A B f OR 1
F F F F T T T F T T T T This truth table defines the OR function by specifying that the result of the function is TRUE whenever either of the arguments is TRUE. This should be intuitively make sense. In words, if A is TRUE OR B is TRUE, then f OR is TRUE, otherwise f OR is FALSE. Alternatively, it is sometimes useful to interpret the table as saying if both A is FALSE AND B is FALSE, then f OR is FALSE, otherwise it is TRUE. Notice that the OR function includes the case, and is TRUE, when both rguments are TRUE; for this reason it is sometimes referred to as the inclusive OR. We will discuss the exclusive OR shortly. The Boolean operator NOT is a monadic prefix operator, meaning it takes just one argument, and the operator precedes the argument. NOT A The corresponding function is f NOT = NOT A and the truth table is given as A F T f NOT T F That is, f NOT is the complement of A. We will now introduce some symbolism to make writing Boolean expressions more compact and easier to read (trust me). The AND and OR functions are represented by many different symbols in the literature, usually depending on the context of the discussion. For instance the following symbols are often used for the AND function:,, and. The symbols,, and + are frequently used for OR, and ~,, or an overbar are used for NOT. In what follows we will use the following: 2
A AND B will be given by A B or AB A OR B will be given by A+B NOT A will be given by A In addition, FALSE, or F, will be given by the binary digit 0 TRUE, or T will be given by the binary digit 1 Rewriting the truth tables above in this symbolism gives A B AB A B A+B A A 0 0 0 0 0 0 0 1 0 1 0 0 1 1 1 0 1 0 0 1 0 1 1 1 1 1 0 1 Boolean Expressions A Boolean expression is any combination of Boolean variables, constants and operators. E.g. AB + C(A+BC) + BC [B1] Such an expression has a value (0 or 1) only when all of the variables are assigned values of either 0 or 1. Of course, the order in which the operations are done must be correct. This is determined, just as with arithmetic expressions, using a predefined order of precedence, modified by parentheses if necessary. Boolean expressions are evaluated left to right, with expressions within parentheses being evaluated first. Among the AND, OR and NOT operators, the order of precedence is NOT, AND, OR. Thus, in the above expression, A+BC is evaluated first (within parentheses), than the complement of that part of the expression is evaluated. Then the ANDs are evaluated, and finally, the outermost ORs are evaluated. Suppose, in this example, values are assigned to the variables thusly: A=1, B=0, and C=1. Then the value of expression [B1] will be 1. We will show how this is arrived at later. Without assigning values to the variables, there are still many important jobs that may need to be done with such expressions, including, as stated above, proving different Boolean Expressions equivalent, or simplifying them. 3
For example a) Simplify AB+AB C = AB+AC We will present two methods for simplification later. b) Prove ABC+ ABC +AB C is equivalent to AB + AC It is clear that a Boolean expression is not unique - there are many Boolean expressions which will evaluate to the same result for the same assignment of variable values. Such expressions are called equivalent. Truth Tables Just as with the fundamental functions AND, OR and NOT, any Boolean Expression can be fully described by its truth table. The expression [B1] has the following truth table (let s call the expression f B1 ) A B C f B1 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 0 Notice that if there are n variables in the expression, then its truth table must have 2 n rows, since this is the total number of ways 1's and 0's can be assigned to the variables. Two Boolean Expressions are equivalent if they have the exact same truth table - that is, the 1's in the f column of the truth table are in the exact same rows. Determining the Boolean Expression given the Truth table Consider the following truth table: A B f 0 0 1 0 1 0 1 0 0 1 1 1 4
The algebraic Boolean expression is determined as follows: 1. Consider only the rows where f = 1 2. For each such row, write a term containing all the variables; if the value of a variable in the row is 1, write the variable; if the value is 0, write the variable complemented. 3. The final expression is generated by taking the OR of all the terms generated in step 2. In the current example, only the first and fourth rows have 1's. From the first row we create the term A B (both variables have the value 0 in this row, so we use the complement of both variables.) Similarly, from the fourth row we get the term AB. The final expression, ORing these two terms together is Consider another example: f = A B + AB A B C f 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 0 1 1 1 0 The Boolean expression corresponding to this table is f = A BC +A BC+AB C +AB C [B2] Any Boolean expression which is expressed as the OR of ANDs, as is [B2], is said to be in Sum of Products form. If, in addition, every one of the ANDs contains every variable, the form is a canonical one called the Disjunctive Normal Form (DNF). The method of generating Boolean expressions from truth tables just shown always produces the expression s DNF. Each term in [B2] is called a minterm. An alternative but equivalent expression from the same truth table can be expressed in a Product of Sums form f = (A+B+C)(A+B+C )(A +B +C)(A +B +C ) [B3] 5
Again, if every sum term in the expression contains all variables, then we have another canonical form called the Conjunctive Normal Form (CNF). Each term in [B3] is called a maxterm. As stated earlier, Boolean expressions are not unique for any given function. Note, for example, that the function [B2] could also be given (in sum of products form, but not DNF as) f = AB + A B (and yes, the variable C is not needed; that is, the value of C has no effect upon the value of f. Such terms are referred to as Don t Cares ) Practice problems - Deriving Boolean Expressions From Truth Tables: What is the Boolean expression for the following truth tables? 1. A B f b. A B C f 0 0 1 0 1 1 0 0 0 0 1 0 0 0 0 1 1 1 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 Some Interesting Facts 1. There are 2 n minterms for a function of n variables. For instance, there are 2 2 =4 minterms of two variables: AB, AB, A B, A B and 2 3 = 8 minterms of 3 variables: ABC, ABC, AB C, AB C, A BC, A BC, A B C, A B C 6
2. All Boolean expressions of n variables can be found by taking all possible subsets of the minterms that exist for n variables. Thus, there are 2^2 n functions of n variables. For two variables, there are 2^2 2 = 16 functions, all of which are shown (in DNF form) here: f 0 =0 (no minterms), f 1 = AB f 2 = AB f 3 = A B f 4 = A B f 5 = AB + AB f 6 = AB + A B f 7 = AB + A B f 8 = AB + A B f 9 = AB + A B f 10 = A B + A B f 11 = AB + AB + A B f 12 = AB + AB + A B f 13 = AB + A B + A B f 14 = AB + A B + A B f 15 = AB + AB + A B + A B = 1 Note that f = 0 when no minterms are present and f = 1 when all minterms are present. 3. If f is represented in DNF form (such as all the examples in 2 above) then f is represented by all those terms not present in f. Examples: If f 5 = AB + AB then f 5 = A B + A B = f 10 If f = ABC + ABC + A B C then f = AB C + A BC + AB C + A BC + A B C In terms of a truth table, if f is the sum of all the minterms with a 1 in the f column, then f is the sum of all the minterms with a 0 in the f column. Practice Problems - Facts 1. How many minterms exist for a Boolean space of 5 variables? 2. How many possible Boolean functions of 4 variables are there? 3. List all minterms for a Boolean space of 1 variable. 4. List all functions for a boolean space of 1 variable 5. If f = A B, what is the DNF for f? Algebraic Rules of 7
Determining the equivalence of two Boolean expressions can be done algebraically as well as by using truth tables, assuming that we know the rules, postulates and theorems, of. In addition we can use such rules to simplify Boolean expressions, and to take arbitrary Boolean expressions and put them in canonical form (for comparison, or truth table generation.) Let s start with some axioms, or postulates (fundamental properties) of Boolean Algebra. Postulates 1. Both AND and OR have identity elements A + 0 = A A 1 = A 2. Commutativity A+B = B+A AB = BA 3. Associativity A+(B+C) = (A+B)+C A(BC) = (AB)C 4. Distributivity A+BC = (A+B)(A+C) A(B+C) = AB + AC 5. Every element has a complement 0'= 1 1'= 0 A+A =1 A A = 0 and (A ) = A Note that each of these postulates contains a pair of rules; they are called duals of each other. In general, the dual of any Boolean expression is obtained by replacing all + s with s and all 0's with 1's. If a Boolean expression or equation is determined to be true, then its dual will also be true, and it is not necessary to prove the dual independently. This property of is called the Principal of Duality. By the way, it would seem that the functions AND and OR correspond in many ways with the arithmetic operators MULTIPLICATION and ADDITION, respectively. This is 8
certainly true regarding identities, commutativity, and associativity. Note, however, that the distributive rule is a bit different in that both Boolean operators are distributive across each other, while multiplication is distributive across addition, but not vice versa. Many additional theorems of can be proved using the postulates given above. Theorems, of course, can then be used to prove other theorems and results. The most important and useful theorems are presented here, with their proofs. In each case, as a result of the Principle of Duality, only one of the dual pair need be proved. Theorems 1. A+A = A AA = A 2. A+1 = 1 A0 = 0 3. A+AB = A A(A+B) = A Absorption 4. A+A B = A+B A(A +B) = AB Adsorption 5. (A+B) = A B (AB) = A +B De Morgan s Theorem The primary use for these theorems is for the simplification of Boolean expressions, generating canonical forms, and for proving the equivalence of Boolean expressions. Simplification and Equivalence a) Simplify AB+AB C = A(B+B C) Distributivity = A(B+C) Adsorption = AB+AC Distributivity b) Prove ABC+ ABC +AB C is equivalent to AB + AC ABC+ABC +AB C = AB(C+C ) +AB C Distributivity = AB+AB C Complement = AB+AC (proved in a) Canonical Forms The canonical Boolean forms are the Disjunctive Normal Form, referenced repeatedly 9
above, and the Conjunctive Normal form (CNF). Recall that the DNF is a sum-ofproducts form in which every minterm contains every variable used in the function; the CNF is a product-of-sums form in which every maxterm contains every variable used in the function. The Exclusive OR (XOR) The Exclusive Or (XOR) is a binary infix operator defined by the following truth table: A B f XOR 0 0 0 0 1 1 1 0 1 1 1 0 That is, it is the same as the OR function with the exception that it is not TRUE when both A and B are TRUE. Thus, f XOR is TRUE whenever A is TRUE or B is TRUE, but not if both are TRUE. The XOR function can be expressed in terms of AND, OR and NOT as A XOR B = A B + AB [B8] as indicated by the truth table. From now on we will use the symbol for the XOR operator. Two other interpretations are of interest, and make this a very useful function: 1. The result is 1 when the arguments are different; the result is 0 when the arguments are the same. 2. The result is 1 when an odd number arguments are 1, and 0 when an even number of arguments (including none) are 1. Like the OR, the XOR is associative and commutative, but it is not distributive. A B = B A A (B C) = (A B) C Consider f = A B C. The truth table for this function is A B C f 10
0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 This demonstrates the second of the two bullets above, since a result of 1 appears only if there are one or three 1's among the arguments. A useful consequence of this property of the XOR is that an XOR function can be complemented simply by complementing any odd number of variables. if f = A B C, f = A B C = A B C = A B C = A B C = (A B C) Another useful consequence of the this is that any Boolean expression can be complemented by XORing it with 1: f = f 1 11
Review Questions 1. Which of the following truth tables represent XOR (or NOT XOR) functions? a. b. c. d. A B C f A B C f A B C f A B C f 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 0 0 1 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 1 1 0 0 1 1 1 0 1 1 1 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0 0 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 1 0 0 1 1 0 0 1 1 0 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 2. Which of the following DNF expressions represent XOR (or NOT XOR) functions? a. AB + A B b. AB C + A B C + A BC c. ABC + A BC + AB C + ABC NAND and NOR The NAND and NOR functions are the invert (complement) of the AND and OR functions, respectively. That is, they have the following truth tables, in which all the 1's and 0's in the output columns for the AND and OR operators have been complemented (inverted) to get the NAND and NOR functions, respectively. A B A NAND B A B A NOR B 0 0 1 0 0 1 0 1 1 0 1 0 1 0 1 1 0 0 1 1 0 1 0 0 Algebraically, A NAND B = NOT (A AND B) = (AB) A NOR B = NOT (A OR B) = (A+B) The importance of these two functions, or operators, lies in the fact that each of them is 12
sufficient to implement any Boolean Expression! This is valuable in computer chip manufacturing as it means a chip can be built containing only one kind of circuit and personalized only through metalization. The alternative, using ANDs, ORs and NOTs, would require chip designers to guess, before any engineering design has been done, what percentage of each kind of circuit might be required, and also what the placement of the circuits ought to be across the chip. We will use the symbol for the NOR function and for the NAND. We now show that the basic Boolean operators, AND, OR, and NOT can all be expressed using only NANDs or NORs. From this the assertion in the previous paragraph follows. Logic Circuits 1. A = (A1) = A 1 A = (A+0) = A 0 A = (AA) = AA A = (A+A) = AA 2. AB = ((AB) ) = (A B) = (A B) 1 = (A + B ) = ((A 0) + (B 0)) = (A 0)(B 0) 3. A+B = (A B ) = A B = (A 1)(B 1) = ((A+B) ) = (A B)0 4. A B = A B+AB = ((A 1)B)(A (B 1)) = (AB+A B ) = AB A B = ((A 0)(B 0))(A B) Logic circuits are electronic devices which implement Boolean expressions. Such circuits can be exceedingly complex, but they are built up from a few fundamental circuits, called logic gates, or just gates (no relation.) As you might expect, there is an AND gate, an OR gate, and a NOT gate (which is commonly called an inverter, since it inverts the level of the incoming signal.) Since these gates are commonly used to implement more complex logic circuits, there is a standardized set of figures which are used to draw such circuits. 13
The function f = ABC + D would be implemented in hardware as Practice Problems - Logic Circuits 1. Draw the logic circuits corresponding to each of the following Boolean expressions. Do not simplify the expressions. a. AB+C(A +B) c. (A+B )(BC +A)+D b. A+B+C(A +C ) d. AB +A B 14