Switching Algebra - University of Pittsburghkmram/0132/lectures/switching-algebra.pdf · 1 EE/CoE...

23
1 1 EE/CoE 0132 Switching Algebra Switching Algebra Objectives The great advantage of using logical expressions to represent the behavior of gate networks is that there are mathematical tools available to manipulate these expressions. These tools are based on the theory of Boolean algebra, so this section will: Define Boolean algebras and derive those properties most useful for the design of gate networks. Illustrate the use of the theorems of Boolean algebra to simplify logical expressions. Establish the connection between the two main behavioral models for gate networks, namely logical expressions and truth tables, using the two standard canonical forms of logical expressions. 2 EE/CoE 0132 Switching Algebra Reading Assignment Boolean algebra is introduced in section 2.5 of the latest edition of Brown and Vranesic. The classic approaches restrict the presentation to the 2-valued Boolean algebra and start with axioms and theorems involving the operations AND, OR, and NOT. An alternate approach, that does not assume that the Boolean algebra has only two elements, is also presented here. It starts from a set of axioms using only the operations AND and XOR. It is provided at the end of these notes.

Transcript of Switching Algebra - University of Pittsburghkmram/0132/lectures/switching-algebra.pdf · 1 EE/CoE...

1

1EE/CoE 0132 Switching Algebra

Switching AlgebraObjectivesThe great advantage of using logical expressions to represent the behavior of gate networks is that there are mathematical tools available to manipulate these expressions. These tools are based on the theory of Boolean algebra, so this section will:

Define Boolean algebras and derive those properties most useful for the design of gate networks. Illustrate the use of the theorems of Boolean algebra to simplify logical expressions.Establish the connection between the two main behavioral models for gate networks, namely logical expressions and truth tables, using the two standard canonical forms of logical expressions.

2EE/CoE 0132 Switching Algebra

Reading AssignmentBoolean algebra is introduced in section 2.5 of the latest edition of Brown and Vranesic. The classic approaches restrict the presentation to the 2-valued Boolean algebra and start with axioms and theorems involving the operations AND, OR, and NOT.An alternate approach, that does not assume that the Boolean algebra has only two elements, is also presented here. It starts from a set of axioms using only the operations AND and XOR. It is provided at the end of these notes.

Boolean Algebra

• Huntington’s Postulates• Proofs• Basic Theorems• Operator Precedence

Boolean Algebra

In 1845, George Boole introduced a systematic treatment of logic now called Boolean algebra. Logical statements are built up from:

Variables: a, x, etc. Variables can be used to represent propositions (statements that are either true or false) or signals in digital circuits (voltages that are either high or low, representing 0 or 1).

Operators: The two operators (+, ) are used to combine variables to produce more complex statements or logic functions. These operators must satisfy certain properties.

The most well-known form of Boolean algebra is a two-valued system, in which all variables take values on the set {0, 1} and the operators (+, ) correspond to (OR, AND) respectively.

In 1904, E. V. Huntington defined Boolean algebra by providing 6postulates that must be satisfied, called Huntington’s Postulates:

• Closure with respect to the operators:any logical operation yields a value in the set {0, 1}.

• Identity elements with respect to the operators: x + 0 = x x 1 = x

• Commutativity with respect to the operators: x + y = y + x x y = y x

• Distributivity: x (y + z) = (x y) + (x z) x + (y z) = (x + y) (x + z)

• Complements exist for all the elements:x + x' = 1 x x' = 0

• Distinct elements: 0 1

In 1938, Claude Shannon showed that a two-valued Boolean Algebra, which he called switching algebra, could be used to describe digital circuits.

•Two elements: {0,1}•Two binary operators: + (OR), (AND)•One unary operator, the complement '

x y x + y 0 0 0 0 1 1 1 0 1 1 1 1

x y x y 0 0 0 0 1 0 1 0 0 1 1 1

x x'0 11 0

Is this really a Boolean algebra? Does it satisfy Huntington’s Postulates?• Closure with respect to +, :

Yes, both operations produce 0 or 1 for all input combinations.

• Identity elements with respect to +, :Yes, from truth tables, x + 0 = x, x 1 = x.

• Commutativity with respect to +, :Yes, if x and y columns are swapped, results are unchanged.

• Distributivity:Yes (proof to follow).

• Complements exist for all the elements:Yes, 0' = 1, 1' = 0.

• Distinct Elements:Yes, by definition: 0 1.

Proofs: What are they?

• Prove that two logical expressions are equivalent.

• Prove that two logic networks are functionally equivalent.

• Prove that one logical expression is the complement of another.

Proofs are a tool for establishing new results or theorems in Boolean algebra. The kinds of things we need to prove usually fall into one of several categories.

OK, so prove it! Hmmm, how do we do that?

• Perfect Induction: show that the two expressions have identical truth tables. If there are n input variables, this requires 2n input combinations. This is a bad idea if there are more than 3 or 4 variables.

• Axiomatic Proof: apply Huntington’s postulates (or other theorems that have already been proven) to the expressions, until the twoexpressions are identical.

• Duality Principle: every theorem in Boolean algebra remains valid if we interchange all AND’s and OR’s, and interchange all 0’s and 1’s.

• Proof by contradiction: assume that the hypothesis is false and then prove that the resulting equation can never be true.

Here are four ways to prove that two expressions are equivalent.

Proof of Distributivity of Over +, by Perfect Induction.

x y z y + z x (y + z) x y x z (x y) + (x z)

0 0 0 0 0 0 0 0

0 0 1 1 0 0 0 0

0 1 0 1 0 0 0 0

0 1 1 1 0 0 0 0

1 0 0 0 0 0 0 0

1 0 1 1 1 0 1 1

1 1 0 1 1 1 0 1

1 1 1 1 1 1 1 1

Proof of Distributivity of + Over , by Perfect Induction.

x y z y z x + (y z) x + y x + z (x + y) (x + z)

0 0 0 0 0 0 0 0

0 0 1 0 0 0 1 0

0 1 0 0 0 1 0 0

0 1 1 1 1 1 1 1

1 0 0 0 1 1 1 1

1 0 1 0 1 1 1 1

1 1 0 0 1 1 1 1

1 1 1 1 1 1 1 1

OK, where are we so far?

So far, we have only shown (through 1 rigorous proof and several less formal arguments) that Huntington’s postulates are satisfied. Therefore, the two valued system with the operations ( , +) as defined above is a Boolean algebra.

Why do we care?

Armed with these 6 postulates, we can now go on to establish other theorems that will help us analyze logic circuits.

Basic Theorems

• Theorem 1a) x + x = xb) x x = x

• Theorem 2a) x + 1 = 1b) x 0 = 0

• Theorem 3(x') ' = x

• Associativitya) (x + y) + z = x + (y + z)b) (x y) z = x (y z)

These theorems can be verified by examining the truth tables for {+, , '}.

Theorem: DeMorgan’s Law

a) (x + y) ' = x ' y '

Proof: by Perfect Induction.

x y (x + y) (x + y)' x' y' x' y'

0 0 0 1 1 1 10 1 1 0 1 0 01 0 1 0 0 1 01 1 1 0 0 0 0

b) (x y) ' = x ' + y '

Proof: apply the duality principle to the expression in part a. If we interchange all and + operators, we obtain the expression in part b.

Theorem: Absorptiona) x + (x y) = xAxiomatic Proof:

x + (x y) = (x 1) + (x y) by x 1 = x= x (1 + y) by distributivity= x (y + 1) by commutativity= x 1 by x + 1 = x= x by x 1 = x

b) x (x + y) = xProof: apply the duality principle to the expression in part a. If we interchange all and + operators, we obtain the expression in part b.

Two More Theorems

• Theorem 7a) x + (x' y) = x + yb) x (x' + y) = x y

• Theorem 8a) (x y) + (y z) + (x' z) = (x y) + (x' z)b) (x + y) (y + z) (x' + z) = (x + y) (x' + z)

Try to prove these theorems on your own. Note that each pair ofequations are related through the duality principle. Theorem 7b is probably the easiest to prove.

So now we have all these theorems. What good are they?Example 1: Find the compliment of the logical function f.

zyxzyxf

zyxzyxf

Solution: by repeated application of DeMorgan’s Law.

zyxzyx

zyxzyx)()( zyxzyx

So now we have all these theorems. What good are they?Example 2: Simplify the previous expression.

Solution: by algebraic manipulation. Apply the theorems of Boolean algebra.

)()( zyxzyxf

)()( zyzyxxf)()( zyzyx

zyyx )(zx 1

zx

by Commutativity

by Theorem 7a

by Distributivity

by Postulate 5a

by Postulate 2b

Precedence of Boolean Operators

To avoid confusion or incorrect evaluation, the operators in Boolean expressions are applied according to the following order of precedence:

1. Expressions in parentheses: ()2. NOT: '3. AND: 4. OR: +

Also, it is conventional to omit the symbol for AND where convenient. As a result, many Boolean expressions can be written in a compact form, often eliminating extraneous parentheses.

)()( zyxzyxxyyx )(

zyzxzyzx )()(

Reference Sheet: Postulates and Theorems• Postulate 1: Closure

• Postulate 2: Identitya) x + 0 = xb) x 1 = x

• Postulate 3: Commutativitya) x + y = y + xb) xy = yx

• Postulate 4: Distributivitya) x(y + z) = xy + xzb) x + yz = (x + y)(x + z)

• Postulate 5: Complementa) x + x' = 1b) x x' = 0

• Theorem 1: Idempotencya) x + x = xb) x x = x

• Theorem 2: Tautology and Contradiction

a) x + 1 = 1b) x 0 = 0

• Theorem 3: Involution(x')' = x

• Theorem 4: Associativitya) x + (y + z) = (x + y) + zb) x(yz) = (xy)z

• Theorem 5: DeMorgan’s Lawa) (x + y)' = x'y'b) (xy)' = x' + y'

• Theorem 6: Absorptiona) x + xy = xb) x(x + y) = x

• Theorem 7: Common Identitiesa) x + x'y = x + yb) x(x' + y) = xy

• Theorem 8: Consensusa) xy + yz + x'z = xy + x'zb) (x + y)(y + z)(x' + z) = (x + y)(x' + z)

2

3EE/CoE 0132 Switching Algebra

Algebraic SimplificationExample 1

( (A B)•(A•C) )•( (A•B)' (A B) )

= ( (A•B'+A'•B)•(A•C) )•( (A'+B')+(A•B'+A'•B) )

= (A•B'•C) • (A'+B')

= ( A•B'•A•C + A'•B•A•C ) • ( A'+B'+A•B'+A'•B )

= ( A•B'•C ) • ( A'+B' + A•B'+A'•B )

= ( A•B'•C ) • (A' + A'•B + B' + A•B' )

= A•B'•C•A' + A•B'•C•B'

= A•B'•C

4EE/CoE 0132 Switching Algebra

Example 2

(X•Y' Y•Z)•(Y•Z' X•Z)

= X•Y'•Y•Z' + X•Y'•X•Z + Y•Z•Y•Z' + Y•Z•X•Z

= X•Y'•Z + X•Y•Z

= X•Z•(Y'+Y)

= X•Z•1

= X•Z

3

5EE/CoE 0132 Switching Algebra

Example 3

( ( (X•Y')' + Z•X')' • (X•Y'•Z') )'

= ( ( (X•Y')' + Z•X')' )' + (X•Y'•Z')'

= (X•Y')' + Z•X') + (X'+Y+Z)

= (X'+Y + Z•X') + (X'+Y+Z)

= (X'+Y) + (X'+Y+Z)

= X'+Y+Z

6EE/CoE 0132 Switching Algebra

Canonical FormsDefinitions (SOP)

Literal: Variable or complement of a variable.Product Term: A single literal or a product (AND) of 2 or more literals.Sum of Products: Logical sum (OR) of product terms.Normal Product Term: Product term with no repeated variables.Minterm over N Variables: Normal product term with N variables.Canonical Sum Of Products: Sum of unique minterms.

4

7EE/CoE 0132 Switching Algebra

Definitions (POS)Sum Term: A single literal or a sum (OR) of 2 or more literals.Product of Sums: Logical product of sum terms.Normal Sum Term: Sum term with no repeated variables.Maxterm over N variables: Normal sum term with N variables.Canonical Product of Sums: Product of unique maxterms.

8EE/CoE 0132 Switching Algebra

Truth tables of MintermsThe truth table of a minterm has exactly one 1.

Note that order is important:m4(Z, Y, X) = Z•Y'•X'm4(X, Y, Z) = X•Y'•Z'

100000001 1 1

010000001 1 0

001000001 0 1

000100001 0 0

000010000 1 1

000001000 1 0

000000100 0 1

000000010 0 0

X•Y•ZX•Y•Z'X•Y'•ZX•Y'•Z'X'•Y•ZX'•Y•Z'X'•Y'•ZX'•Y'•Z'X Y Zm7 =m6 =m5 =m4 =m3 =m2 =m1 =m0 =

5

9EE/CoE 0132 Switching Algebra

Truth Tables and Canonical Sum of Products Forms.

Listing the order of variables and the mintermsubscripts is enough to completely specify a logical function of those variables.

A,B,C (0, 1, 3, 4) = m0+m1+m3+m4= A'•B'•C' + A'•B'•C + A'•B•C + A•B'•C'

00001 1 1

00001 1 0

00001 0 1

11011 0 0

10000 1 1

01100 1 0

10000 0 1

10000 0 0

m0+m1+m3+m4m4+m2m2m4A B C

10EE/CoE 0132 Switching Algebra

Truth Tables of MaxtermsThe truth table of a maxterm has exactly one 0.

011111111 1 1

101111111 1 0

110111111 0 1

111011111 0 0

111101110 1 1

111110110 1 0

111111010 0 1

111111100 0 0

X'+Y'+Z'X'+Y'+Z'X'+Y+Z'X'+Y+ZX+Y'+Z'X+Y'+ZX+Y+Z'X+Y+ZX Y ZM7 =M6 =M5 =M4 =M3 =M2 =M1 =M0 =

6

11EE/CoE 0132 Switching Algebra

Truth tables and canonical product of sums forms

A,B,C(2, 4, 5, 7) = M2•M4 • M5 • M= (A+B'+C)•(A'+B+C)•(A'+B+C')•(A'+B'+C')

01111 1 1

11111 1 0

01111 0 1

00101 0 0

11110 1 1

00010 1 0

11110 0 1

11110 0 0

M2 • M4 • M5 • M7M4•M2M2M4A B C

12EE/CoE 0132 Switching Algebra

Exercise:

Determine the relationship between minterm mi and maxterm Mi

Determine an easy way to convert a canonical sum of products to an equivalent canonical product of sums, and vice versa.

7

13EE/CoE 0132 Switching Algebra

Review

The definitions and axioms that define Boolean algebras.

The equivalence of different sets of definitions and axioms.

Algebraic proof technique.Canonical Forms

Minterms and Maxterms

14EE/CoE 0132 Switching Algebra

Boolean Algebras, an alternate approachDEFINITION. A Boolean algebra is a non-empty set B and two binary operations • and which satisfy the following axioms, for all X, Y, and Z in B.

A1. (X Y) Z = X (Y Z) AssociativeA2. X Y = Y X CommutativeA3. There is an element 0 in B, Identity

such that X 0 = XA4. X X = 0 Self Inverse

A5. (X•Y)•Z = X•(Y•Z) AssociativeA6. X•Y = Y•X CommutativeA7. There is an element 1 in B, Identity

such that X•1 = XA8. X•X = X Idempotent

A9. X•(Y Z) = (X•Y) (X•Z) Distributive

8

15EE/CoE 0132 Switching Algebra

Example: BA2, the two-element Boolean algebra B = {0, 1}, • and defined by the truth tables for AND and EXCLUSIVE OR.

Truth Tables of Expressions in BA2:We can use truth tables of expressions to prove theorems and verify axioms, a technique called proof by perfect induction.

11 101 000 100 0

X•YX Y

01 111 010 100 0

X YX Y

000111 1 1000001 1 0111101 0 1001001 0 0111010 1 1001000 1 0000000 0 1000000 0 0

(X•Y) (X•Z)X• (Y Z)Y ZX•ZX•YZ Y X

16EE/CoE 0132 Switching Algebra

DEFINITION. Two logical expressions in BA2 are equivalent if they have the same truth table.DEFINITION. The binary operation OR and the unary operation NEGATION (') are defined as follows.

D1. X Y = X Y (X•Y)D2. X' = 1 X

Example: In BA2 we see that + is the familiar OR operation.

1001 1

1101 01100 10000 0

X Y (X•Y)X YX•YX Y

9

17EE/CoE 0132 Switching Algebra

PRINCIPLE OF DUALITY. Given an identity involving only variables, the operations , •, and ', and the constants 0 and 1, another identity can be obtained by interchanging 's with •'s and 0's with 1's. These two identities are said to be duals of one another.

The following three theorems develop properties of the OR operation that are similar to the AND and the Exclusive OR operations.

THEOREM T1. (Dual of A6) X Y = Y X

Proof: X + Y = X Y (X•Y) (by D1)= Y X (Y•X) (by A2 and A6)= Y + X (by D1)

THEOREM T2. (Dual of A8) X + X = X

Proof: X X = X X X•X (by D1)= 0 X•X) (by A4)= (X•X) (by A3)= X (by A8)

18EE/CoE 0132 Switching Algebra

THEOREM T3. (Dual of A5) (X Y) Z = X (Y Z)

Proof: (X Y) Z = (X Y X•Y) Z

= (X Y X•Y) Z (X Y X•Y)•Z

= (X Y Z X•Y) (X•Z) (Y•Z) (X•Y•Z)

X (Y Z) = X (Y Z Y•Z)

= X (Y Z Y•Z) X•(Y Z Y•Z)

= X Y Z (X•Y) (X•Z) Y•Z) (X•Y•Z)

The following five theorems show how the special elements 0 and 1 combine with other elements.

THEOREM T4. X•0 = 0

Proof:

THEOREM T5. X 1 = 1

Proof: This theorem is the dual of Theorem T4.

X• 0 = X•(X X)

= X•X X•X= X X= 0

10

19EE/CoE 0132 Switching Algebra

THEOREM T6. X 0 = X

Proof:

THEOREM T7. 1' = 0Proof: 1' = 1 1 (by D2)

= 0 (by A4)

THEOREM T8. 0' = 1Proof: This theorem is the dual of T7.

X + 0 = X 0 X • 0

= X 0 0

= X 0

= X

20EE/CoE 0132 Switching Algebra

Theorems T9 and T10 are distributive laws for the operations • and . Not only does • distributive over

, but distributes over •.

THEOREM T9. X•(Y Z) = (X•Y) (X•Z)Proof: X•(Y Z) = X•(Y Z Y•Z) (by D1)

= (X•Y) (X•Z) (X•Y•Z) (by A9)

(X•Y) (X•Z) = (X•Y) (X•Z) (X•Y) • (X•Z) (by D1)

= (X•Y) (X•Z) (X•Y•Z) (by A6 and A8)

THEOREM T10. X (Y•Z) = (X Y)•(X Z)Proof: This theorem is the dual of T9.

11

21EE/CoE 0132 Switching Algebra

The following theorems give three properties of the negation operation that are very useful in simplifying complex expressions.

THEOREM T11. X•X' = 0

Proof:

THEOREM T12. X X' = 1

Proof: This is the dual of T11.

THEOREM T13. (X')' = XProof: (X')' = (1 X)' (by D2)

= 1 (1 X) (by D2)

= (1 1) X (by A1)

= 0 X (by A4)

= X (by A3)

X•X' = X•(1 X)

= X•1 X•X

= X X = 0

22EE/CoE 0132 Switching Algebra

The next two theorems establish another relationship between the operations , , •, and '.

THEOREM T14. X Y = X•Y' X'•Y

Proof: X•Y' X'•Y = (X•Y') (X'•Y) (X•Y')•(X'•Y) (by D1)

= (X•Y') (X'•Y) (X•X')•(Y•Y') (by A6)= (X•Y') (X'•Y) 0 (by T11 and A8)= (X•Y') (X'•Y) (by A3)= X•(1 Y) (1 X)•Y (by D2) = X (X•Y) Y (X•Y) (by A9)= (X Y) (X•Y X•Y) (by A2) = (X Y) 0 (by A4)= (X Y) (by A3)

THEOREM T15. X Y = (X + Y)•(X' + Y')Proof: Exercise. Don’t use definitions D1 or D2.

12

23EE/CoE 0132 Switching Algebra

Theorem T16 and its dual, Theorem T17, are known as DeMorgan's Law.

R (X•Y)' = X' + Y'

Proof: (X') + (Y') = X' Y' X'•Y' (by D1)

= (1 X) (1 Y) (1 X)•(1 Y) (by D2)

= (1 1) X Y 1 X Y X•Y (by A2 and A9)

= 1 X•Y (by A4)

= (X•Y)' (by D2)

THEOREM T17. (X Y)' = X'•Y'

Proof: This theorem is the dual of T16.

24EE/CoE 0132 Switching Algebra

The following theorems are useful for simplifying complex expressions since they show how an expression can be replaced by an equivalent expression with fewer symbols.

THEOREM T18. X•(X Y) = XProof: X•(X Y) = X•(X Y X•Y) (by D1)

= (X•X) (X•Y) (X•X•Y) (by A9)

= X (X•Y) (X•Y) (by A8)

= X 0 (by A4)= X (by A3)

THEOREM T19. X X•Y) = X

Proof: This theorem is the dual of T18.

13

25EE/CoE 0132 Switching Algebra

THEOREM T20. X•(X' Y) = X•YProof: X•(X' Y) = X•(X' Y X'•Y) (by D1)

= (X•X') (X•Y) (X•X'•Y) (by A9)

= 0 X•Y 0 (by T11)

= X•Y (by A3)

THEOREM T21. X X'•Y = X YProof: This theorem is the dual of T20.

DEFINITION. The binary operation is defined as follows.

D3. (X Y) = (X Y)'

26EE/CoE 0132 Switching Algebra

The last two theorems can be viewed as alternative definitions of the operation in terms of the operations , •, and '.

THEOREM T22. (X Y) = X'•Y' X•Y

Proof: Exercise.

THEOREM T23. (X Y) = (X' Y)•(X Y')

Proof: Exercise.

14

27EE/CoE 0132 Switching Algebra

Exercises:

Let X be a set and P(X) be the set of all subsets of X. Describe how you would prove that P(X) with the operations of set intersection, union, and complementation is a Boolean algebra.

Prove that NAND and NOR are universal primitives .