* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Boolean Algebra
Survey
Document related concepts
Birkhoff's representation theorem wikipedia , lookup
Structure (mathematical logic) wikipedia , lookup
Fundamental theorem of algebra wikipedia , lookup
Congruence lattice problem wikipedia , lookup
Propositional calculus wikipedia , lookup
Linear algebra wikipedia , lookup
Complexification (Lie group) wikipedia , lookup
Universal enveloping algebra wikipedia , lookup
Boolean satisfiability problem wikipedia , lookup
Homological algebra wikipedia , lookup
Geometric algebra wikipedia , lookup
Exterior algebra wikipedia , lookup
Clifford algebra wikipedia , lookup
Transcript
Boolean algebra • • • Last time we talked about Boolean functions, Boolean expressions, and truth tables. Today we’ll learn how to how use Boolean algebra to simplify Booleans expressions. Last time, we saw this expression and converted it to a circuit: (x + y’)z + x’ June 11, 2002 ©2000-2002 Howard Huang 1 Simplifying circuits • The expression and circuit on the previous page are actually equivalent to the simplified ones below: x’ + z • • Simpler hardware is always better! – In many cases, the simpler circuit is also faster. – Less hardware means smaller size, which also reduces costs. – Simpler circuits draw less power. How do we know this circuit is the same as the one on the last page? June 11, 2002 Boolean algebra 2 Boolean algebra is special • • • Boolean algebra gives us a way to simplify Boolean functions, much like regular algebra allows us to simplify mathematical functions. The AND and OR operations are similar to multiplication and addition: – AND is the same as multiplication for the values 0 and 1 – OR is almost the same as addition, except for 1 + 1. x y xy x y x+y 0 0 0 0 0 0 0 1 0 0 1 1 1 0 0 1 0 1 1 1 1 1 1 1 But there are important differences to watch out for, too. – Boolean algebra uses are only two values. – OR is not quite the same as addition, and NOT is a new operation. June 11, 2002 Boolean algebra 3 Formal definition of Boolean algebra • • A Boolean algebra requires: – A set of values B, which contains at least two elements 0 and 1 – Two 2-argument operations + and – A one-argument operation ' The values and operations must satisfy the axioms below. 1. 3. 5. 7. 9. 10. 12. 14. 16. x+0=x x+1=1 x+x=x x + x’ = 1 (x’)’ = x x+y=y+x x + (y + z) = (x + y) + z x(y + z) = xy + xz (x + y)’ = x’y’ June 11, 2002 2. 4. 6. 8. 11. 13. 15. 17. x x x x 1=x 0=0 x=x x’ = 0 xy = yx x(yz) = (xy)z x + yz = (x + y)(x + z) (xy)’ = x’ + y’ Boolean algebra Commutative Associative Distributive DeMorgan’s 4 Satisfying the axioms • • The operations we chose do satisfy all of the axioms. We can show this by looking at the definitions of our operations. x y xy x y x+y x x’ 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 1 1 For example, the axiom x + x’ = 1 is satisfied, because: – We have only two possible values for x: 0 and 1. – The complement of these values are 1 and 0, respectively. – 0 + 1 = 1, and 1 + 0 = 1. June 11, 2002 x x’ x+x’ 0 1 1 1 0 1 Boolean algebra 5 Proofs with truth tables • • • We can always prove equivalences using truth tables, to explicitly show that two expressions always produce the same results. Let’s use truth tables to prove DeMorgan’s law, (x + y)’ = x’y’. – The columns on the left in each table are the inputs. We have two inputs, x and y, so there are four possible input combinations. – The columns on the right, in blue, are outputs. – Intermediate columns can be useful in deriving the outputs. x y x+y (x + y)’ x y x’ y’ x’y’ 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 0 0 0 1 1 0 1 0 1 1 1 0 0 1 0 1 0 1 0 0 0 Since both of the columns in blue are the same, this shows that (x + y)’ and x’y’ really are equivalent. June 11, 2002 Boolean algebra 6 Similarities with regular algebra • • Several of the axioms (in blue) look just like regular algebraic rules. The associative laws show that there is no ambiguity in a term such as xyz or x + y + z, so we can use multiple-input primitive gates: 1. 3. 5. 7. 9. 10. 12. 14. 16. x+0=x x+1=1 x+x=x x + x’ = 1 (x’)’ = x x+y=y+x x + (y + z) = (x + y) + z x(y + z) = xy + xz (x + y)’ = x’y’ June 11, 2002 2. 4. 6. 8. 11. 13. 15. 17. x x x x 1=x 0=0 x=x x’ = 0 xy = yx x(yz) = (xy)z x + yz = (x + y)(x + z) (xy)’ = x’ + y’ Boolean algebra Commutative Associative Distributive DeMorgan’s 7 The complement operation • • The magenta axioms deal with the complement operation, which doesn’t exist in normal algebra. Most of them almost make sense if you translate them into English: – “It is raining or it is not raining” is always true (x + x’ = 1) – “It is raining and it is not raining” can never be true (x x’ = 0) – “I am not not handsome” means “I am handsome” ((x’)’ = x) 1. 3. 5. 7. 9. 10. 12. 14. 16. x+0=x x+1=1 x+x=x x + x’ = 1 (x’)’ = x x+y=y+x x + (y + z) = (x + y) + z x(y + z) = xy + xz (x + y)’ = x’y’ June 11, 2002 2. 4. 6. 8. 11. 13. 15. 17. x x x x 1=x 0=0 x=x x’ = 0 xy = yx x(yz) = (xy)z x + yz = (x + y)(x + z) (xy)’ = x’ + y’ Boolean algebra Commutative Associative Distributive DeMorgan’s 8 DeMorgan’s • DeMorgan’s axioms are especially important for circuit design. (x + y)’ = x’y’ • • • (xy)’ = x’ + y’ We’ve already proved one of these axioms, but here are some rough examples in English. “I am not rich-or-famous” – This is the same as “I am not rich, and I am not famous.” – In other words, I am nothing. “I am not old-and-bald” – This is equivalent to “I am not old, or I am not bald.” – I could still be one of the other three possibilities: young and bald, old and hairy, or young and hairy. June 11, 2002 Boolean algebra 9 Other differences with regular algebra • • • Finally, the red axioms are completely different from regular algebra. The first three make sense if you think about it logically: – “Blah or true” is always true, even if “blah” is false (x + 1 = 1) – “I am handsome or I am handsome” is redundant (x + x = x) – “I am handsome and I am handsome” is redundant (x x = x) The last one, x + yz = (x + y)(x + z), is the trickiest one of the bunch. 1. 3. 5. 7. 9. 10. 12. 14. 16. x+0=x x+1=1 x+x=x x + x’ = 1 (x’)’ = x x+y=y+x x + (y + z) = (x + y) + z x(y + z) = xy + xz (x + y)’ = x’y’ June 11, 2002 2. 4. 6. 8. 11. 13. 15. 17. x x x x 1=x 0=0 x=x x’ = 0 xy = yx x(yz) = (xy)z x + yz = (x + y)(x + z) (xy)’ = x’ + y’ Boolean algebra Commutative Associative Distributive DeMorgan’s 10 Duality • • • Look carefully at the left and right columns of axioms. They are duals, where we’ve: – exchanged all AND operations with OR operations, and – exchanged all 0s with 1s. The dual of any equation is always true. 1. 3. 5. 7. 9. 10. 12. 14. 16. x+0=x x+1=1 x+x=x x + x’ = 1 (x’)’ = x x+y=y+x x + (y + z) = (x + y) + z x(y + z) = xy + xz (x + y)’ = x’y’ June 11, 2002 2. 4. 6. 8. 11. 13. 15. 17. x x x x 1=x 0=0 x=x x’ = 0 xy = yx x(yz) = (xy)z x + yz = (x + y)(x + z) (xy)’ = x’ + y’ Boolean algebra Commutative Associative Distributive DeMorgan’s 11 Simplification with axioms • We can now start doing simplifications using these axioms: x’y’ + xyz + x’y = x’(y’ + y) + xyz = (x’ 1) + xyz = x’ + xyz = (x’ + x)(x’ + yz) = 1 (x’ + yz) = x’ + yz 1. 3. 5. 7. 9. 10. 12. 14. 16. x+0=x x+1=1 x+x=x x + x’ = 1 (x’)’ = x x+y=y+x x + (y + z) = (x + y) + z x(y + z) = xy + xz (x + y)’ = x’y’ June 11, 2002 [ Distributive: x’y’ + x’y = x’(y’ + y) ] [ Axiom 7: y’ + y = 1 ] [ Axiom 2: x’ 1 = x’ ] [ Distributive ] [ Axiom 7: x’ + x = 1 ] [ Axiom 2 ] 2. 4. 6. 8. 11. 13. 15. 17. x x x x 1=x 0=0 x=x x’ = 0 xy = yx x(yz) = (xy)z x + yz = (x + y)(x + z) (xy)’ = x’ + y’ Boolean algebra Commutative Associative Distributive DeMorgan’s 12 Simpler expressions yield simpler hardware • Here are the circuits resulting from the original and simplified expressions on the previous page. June 11, 2002 Boolean algebra 13 Some more laws • • Here are some more useful equations. – These are usually called laws, because they can all be proven from the more fundamental axioms. – You can also prove them using truth tables. – Notice that each law also has a dual. Feel free to use these laws in homeworks and exams, if you like. x + xy = x xy + xy’ = x x + x’y = x + y xy + x’z + yz = xy + x’z June 11, 2002 x(x + y) = x (x + y)(x + y’) = x x(x’ + y) = xy (x + y)(x’ + z)(y + z) = (x + y)(x’ + z) Boolean algebra 14 The complement of a function • • The complement of a function always outputs 0 where the original function output 1, and 1 where the original produced 0. In a truth table, we can just exchange 0s and 1s in the output column. – On the left is a truth table for f(x,y,z) = x(y’z’ + yz) – On the right is the table for the complement, denoted f’(x,y,z). x y z f(x,y,z) x y z f’(x,y,z) 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 1 1 1 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 0 0 0 1 1 0 1 June 11, 2002 Boolean algebra 15 Complementing a function algebraically • When you complement an expression algebraically, you can use DeMorgan’s axiom to keep “pushing” the complement operators inwards: f(x,y,z) = x(y’z’ + yz) f’(x,y,z) = ( x(y’z’ + yz) )’ = x’ + (y’z’ + yz)’ = x’ + (y’z’)’ (yz)’ = x’ + (y + z)(y’ + z’) • [ complement both sides ] [ because (xy)’ = x’ + y’ ] [ because (x + y)’ = x’ y’ ] [ because (xy)’ = x’ + y’, twice] Another clever method to complement an expression is to take the dual of the expression, and then complement each literal: – If f(x,y,z) = x(y’z’ + yz)… – …the dual of f is x + (y’ + z’)(y + z)… – …then complementing each literal gives x’ + (y + z)(y’ + z’)… – …so f’(x,y,z) = x’ + (y + z)(y’ + z’) June 11, 2002 Boolean algebra 16 Standard forms of expressions • • • We can write expressions in many ways, but some ways are more useful than others. A sum of products (SOP) expression is characterized by: – There are only OR (sum) operations at the “outermost” level. – Each term in the sum must be a product of literals. For example: f(x,y,z) = y’ + x’yz’ + xz • The advantage is that a sum of products expression can be implemented using a fairly simple two-level circuit: – Literals are at the “0th” level. – AND gates are at the first level. – A single OR gate is at the second level. June 11, 2002 Boolean algebra 17 Minterms • • A minterm is a special product term, where each input variable appears exactly once. A function with n variables has up to 2n minterms. For example, a threevariable function like f(x,y,z) has up to 8 minterms: x’y’z’ xy’z’ • x’y’z xy’z x’yz’ xyz’ x’yz xyz Each minterm is true for exactly one combination of inputs: Minterm x’y’z’ x’y’z x’yz’ x’yz xy’z’ xy’z xyz’ xyz June 11, 2002 Is true when… xyz = 000 xyz = 001 xyz = 010 xyz = 011 xyz = 100 xyz = 101 xyz = 110 xyz = 110 Shorthand m0 m1 m2 m3 m4 m5 m6 m7 Boolean algebra Hey! This looks like a truth table! 18 Sum of minterms form • • • Every function can be written as a sum of minterms, which is a special kind of sum of products form. The sum of minterms form for any function is unique. If you have a truth table for a function, you can write a sum of minterms expression just by picking out the rows of the table where the function output is 1. x y z f(x,y,z) f’(x,y,z) 0 0 0 0 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 1 0 1 0 0 1 0 1 1 0 1 June 11, 2002 f = m 0 + m1 + m2 + m3 + m 6 = m(0,1,2,3,6) = x’y’z’ + x’y’z + x’yz’ + x’yz + xyz’ f’ = m4 + m5 + m7 = m(4,5,7) = xy’z’ + xy’z + xyz f’ contains all the minterms not in f. Boolean algebra 19 Summary • • • • • We can build complex functions from just the basic Boolean values “true” and “false,” and the operations AND, OR and NOT. Any Boolean expression can be implemented with a circuit, which uses primitive logic gates to compute products, sums and complements. We saw two ways to prove equivalence of expressions: – Truth tables show that all possible inputs yield the same results. – Boolean algebra is especially useful for simplifying expressions, and hence circuits. Expressions can be written in many different ways, so it’s sometimes useful to use standard representations like sums of products or sums of minterms. Next time we’ll study an alternative, graphical simplification method. Then we’ll start using all this stuff to build and analyze bigger, more useful, circuits. June 11, 2002 Boolean algebra 20