Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's...

23
Lecture 18: Boolean Algebra Boolean Functions

description

Binary Operators In the following descriptions, we will let A and B be Boolean variables and define a set of binary operators on them. The term binary in this case does not refer to base-two arithmetic but rather to the fact that the operators act on two operands. unary operator

Transcript of Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's...

Page 1: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Lecture 18: Boolean Algebra

Boolean Functions

Page 2: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

w = Chris is allowed to watch televisionx = Chris's homework is finishedy = it is a school nightz = it is earlier than 10:00 p.m.

Definition of Symbolic Logic

w = ( x AND z ) OR ( NOT y )

Symbolic logic is the method of representation and techniques of algebraic manipulation that separates the meaning of factual statements from proofs of their consistency and their truth value.

w = the dog is wetx = the dog is outsidey = the dog did not jump in the poolz = it is raining

Page 3: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Binary Operators

In the following descriptions, we will let A and B be Boolean variables and define a set of binary operators on them. The term binary in this case does not refer to base-two arithmetic but rather to the fact that the operators act on two operands.

unary operator

Page 4: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Operator Precedence

As with other algebraic systems, we recognize an order of precedence for the application of its operators. The highest precedence is associated with the unary operator NOT (~). At the next level is AND and NAND. At the next lower level is OR and NOR and XOR. In this text, we place the equality operator (=) at the lowest precedence.

Page 5: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Truth Tables

Definition: Given a Boolean function F containing n Boolean variables b0, b1, b2, . . ., bn-1, we can construct a truth table containing 2n rows which gives the value of F for every combination of truth values of the variables b0, b1, b2, . . ., bn-1.

F(x,y,z) = (xy) + (~xz) + (y)(~z) + (~xyz)

Page 6: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Evaluating Logical Expressions

F(x,y,z) = (xy) + (x'z) + (y)(z') + (x'yz)

F(0,1,1) = 0.1 + 1.1 + 1.0 + 1.1.1

F(0,1,1) = 0 + 1 + 0 + 1

F(0,1,1) = 1

Page 7: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

All Boolean Binary Operators

A B 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 10 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 11 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 11 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1

FALS

E

~(A

+ B)

~(B ->

A)

= ~A

. B

~A ~(A ->

B)

= A. (

~B)

~B A

B =

A. (~B

)+(~

A). B

~(A.B)

A.B

(A=B

) =

A. B +

(~A

). (~B

)

B A ->

B =

~A+

B

A B ->

A =

~B+

A

A +

B

TRUE

A B 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 10 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 11 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 11 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1

FALS

E

~(A

+ B)

~(B ->

A)

= ~A

. B

~A ~(A ->

B)

= A. (

~B)

~B A

B =

A. (~B

)+(~

A). B

~(A.B)

A.B

(A=B

) =

A. B +

(~A

). (~B

)

B A ->

B =

~A+

B

A B ->

A =

~B+

A

A +

B

TRUE

Page 8: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

TRUE - This operator evaluates to true regardless of the truth values of A and B.A+B - Evaluates to true if either A or B or both are true, also called OR.B A - This is the implication operator. Stated as B implies A it evaluates to true unless B is true and A is false.A - This is a copy of the truth value set of the variable A.AB - This is the implication operator. Stated as A implies B it evaluates to true unless A is true and B is false.B - This is a copy of the truth value set of the variable B.A = B - The equality operator evaluates to true when the values of A and B are the same.A.B - Evaluated to true when both A and B are true, also called AND.~(A.B) - The negation of A.B, also called NAND.AB - This operator is the exclusive-OR or XOR operator.~B - The negation of B. This is a representation of the NOT operator.~A - The negation of A. This is a representation of the NOT operator.~(BA) - The negation of implication. See (BA) below.~(A+ B) - This operator is the negation of OR (+) also called NOR.FALSE - This operator evaluates to false regardless of the truth values of A and B.

Boolean Operator Defintions

Page 9: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Boolean Functions

Definition: A Boolean Function F in n variables is a mapping from the 2n possible truth value combinations of the n variables to truth values for F. There are unique Boolean functions possible using a maximum of n Boolean variables.

)( n22

Page 10: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Tautologies

F(A,B,C) = (A + B).(B' + C)

G(A,B,C) = AB' + AC + BC

A tautology is a logical expression that is true for every combination of truth values of its variables.

(A + B).(B' + C) <=> AB' + AC + BC

A B C (A+B) ~B (~B+C) LHS A(~B) AC BC RHS LHS=RHS

0 0 0 0 1 1 0 0 0 0 0 1

0 0 1 0 1 1 0 0 0 0 0 1

0 1 0 1 0 0 0 0 0 0 0 1

0 1 1 1 0 1 1 0 0 1 1 1

1 0 0 1 1 1 1 1 0 0 1 1

1 0 1 1 1 1 1 1 1 0 1 1

1 1 0 1 0 0 0 0 0 0 0 1

1 1 1 1 0 1 1 0 1 1 1 1

A B C (A+B) ~B (~B+C) LHS A(~B) AC BC RHS LHS=RHS

0 0 0 0 1 1 0 0 0 0 0 1

0 0 1 0 1 1 0 0 0 0 0 1

0 1 0 1 0 0 0 0 0 0 0 1

0 1 1 1 0 1 1 0 0 1 1 1

1 0 0 1 1 1 1 1 0 0 1 1

1 0 1 1 1 1 1 1 1 0 1 1

1 1 0 1 0 0 0 0 0 0 0 1

1 1 1 1 0 1 1 0 1 1 1 1

Page 11: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Venn Diagrams

A A B A B

A B A BA B

A

~A + B

A.BA+B

A.BA=B

A A B A B

A B A BA B

A

~A + B

A.BA+B

A.BA.BA=B

Page 12: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Three-Variable Venn Diagram

000

001

010

011

100

101

110

111

A B

C

A B

C

F(A,B,C) = A + BC'

Page 13: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Laws and PostulatesClosure - We state without proof that Boolean algebra is closed under all Boolean operations. The principle of closure states that a set S is closed with respect to a binary operator if, for every pair of elements of S, the binary operator specifies a rule for obtaining a unique element in S.

Associative Law - The binary operators AND and OR are associative on the set of Boolean values (0,1). The associative law states that the order in which the operators are applied to the operands does not affect the result.

Commutative Law - The binary operators AND and OR are commutative on the set of Boolean values (0,1). the commutative laws states that the order in which the operands appear in the expression does not affect the result of the operation.

Identity Element - The binary operators AND and OR have an identity element in the set of Boolean values (0,1). An identity element is one which when operated on with a Boolean value X results in the same value X.

Inverse - Now that we have identity elements for AND and OR we can define Y as the inverse of X with respect to an operator as X+Y = 1, X.Y = 0, X+X' = 1, and X.X' = 0.

Distributive Law - The distributive law defines the interrelationship between two different operators. For Boolean algebra both AND and OR follow the distributive laws.

0XX0YX1XX1YX

''

X1XX0X

ABBAABBA

CBACBACBACBA

)()()()(

associative commutative identity inverse)()()(

)(CBCACBA

CBCACBA

distributive

Page 14: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Idempotent Laws and Absorption

When performing algebraic manipulations of logical expressions we often encounter terms in which one or more of the variables are repeated. The idempotent laws and the laws of absorption give us a way to simplify these terms.

absorptionABAAabsorptionABAA

eidempotencXXXeidempotencXXX

)(

identityAinverse1A

vedistributiBBAeidempotencBABA

vedistributiBABABAinverseBABBAidentityBA1A

eidempotencBAAvedistributiBAAABAA

)()~(

)(~)(~

)~()(

)(

Page 15: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

De Morgan's Theorem

BABA

BABA

A B A+B ~(A+B) ~A ~B (~A).(~B) ~(A+B)=(~A).(~B)0 0 0 1 1 1 1 10 1 1 0 1 0 0 11 0 1 0 0 1 0 11 1 1 0 0 0 0 1

A B A+B ~(A+B) ~A ~B (~A).(~B) ~(A+B)=(~A).(~B)0 0 0 1 1 1 1 10 1 1 0 1 0 0 11 0 1 0 0 1 0 11 1 1 0 0 0 0 1

Page 16: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

F(x,y,z) = xy + x'z + yz' + x'yz

= xy + x'z + yz'

= xy(1) + x'z(1) + yz'(1)

= xy(z+z') + x'z(y+y') + yz'(x+x')

= xyz + xyz' + x'yz + x'y'z + xyz' + x'yz'

= xyz + xyz' + x'yz + x'y'z + x'yz'

= xy(z+z') + yz(x+x') + yz'(x+x') + x'z(y+y') + x'y(z+z')

= xy(1) + yz(1) + yz'(1) + x'z(1) + x'y(1)

= (xy+x'y) + (yz+yz') + x'z

= y(x+x') + y(z+z') + x'z

= y(1) + y(1) + x'z

= y + y + x'z

= y + x'z

Algebraic Simplification

yx

z

yx

z

Page 17: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

NAND Stands Alone

yidempotencBBAA

theoremsMorganDeBA

negationdoubleBABA

'

yidempotencBABA

negationdoubleBABA

yidempotencAAA

OR

AND

NOT

Page 18: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Canonical Forms of Logical Expressions

(1) The canonical forms of logical expressions representing Boolean function will be either disjunctive form (also called sum-of-products) or conjuntive form (also called product-of-sums) .

(2) The canonical form of a logical expression for a particular Boolean function must be unique to within the labels used for the Boolean variables and whether the expression is disjunctive or conjuntive.

(3) The canonical forms of logical expressions representing two different Boolean functions must be different.

F(x,y,z) = xy + y + xz' + x'y'z

F(x,y,z) = xyz + xyz' + x'yz + xy'z' + x'yz'

Sum of Products

Canonical Sum of Products

Page 19: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Canonical Sum of Products

x y z F(x,y,z) term0 0 0 0 x'y'z'0 0 1 0 x'y'z0 1 0 1 x'yz'0 1 1 1 x'yz1 0 0 0 xy'z'1 0 1 0 xy'z1 1 0 1 xyz'1 1 1 1 xyz

x y z F(x,y,z) term0 0 0 0 x'y'z'0 0 1 0 x'y'z0 1 0 1 x'yz'0 1 1 1 x'yz1 0 0 0 xy'z'1 0 1 0 xy'z1 1 0 1 xyz'1 1 1 1 xyz

F(x,y,z) = xyz + xyz' + x'yz + xy'z' + x'yz' 111 110 011 100 010

Page 20: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Product of SumsG(x,y,z) = (x+y)(x+z')(y')(x'+y'+z)

(x+y) = (x+y+z)(x+y+z')

(x+z') = (x+y+z')(x+y'+z')

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

= (x+y'+z)(x+y'+z')(x'+y'+z)(x'+y'+z')

G(x,y,z) = (x+y+z)(x+y'+z)(x+y+z')(x+y'+z')(x'+y'+z)(x'+y'+z') 000 010 001 011 110 111

x y z G(x,y,z) clause0 0 0 0 (x + y + z)0 0 1 0 (x + y + z')0 1 0 0 (x + y' + z)0 1 1 0 (x + y' + z')1 0 0 1 (x' + y + z)1 0 1 1 (x' + y + z')1 1 0 0 (x' + y' + z)1 1 1 0 (x' + y' + z')

x y z G(x,y,z) clause0 0 0 0 (x + y + z)0 0 1 0 (x + y + z')0 1 0 0 (x + y' + z)0 1 1 0 (x + y' + z')1 0 0 1 (x' + y + z)1 0 1 1 (x' + y + z')1 1 0 0 (x' + y' + z)1 1 1 0 (x' + y' + z')

Page 21: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Minterms and Maxterms

F(x,y,z)=xyz+xyz'+x'yz+xy'z'+x'yz' 111 110 011 100 010 7 6 3 4 2 = m(2, 3, 4, 6, 7)

G(x,y,z) = (x+y+z)(x+y'+z)(x+y+z')(x+y'+z')(x'+y'+z)(x'+y'+z') 000 010 001 011 110 111 0 2 1 3 6 7 = M(0, 1, 2, 3, 6, 7)

minterms

Maxterms

x y z (x + y' + z)0 0 0 0 + 1 + 0 = 10 0 1 0 + 1 + 1 = 10 1 0 0 + 0 + 0 = 00 1 1 0 + 0 + 1 = 11 0 0 1 + 1 + 0 = 11 0 1 1 + 1 + 1 = 11 1 0 1 + 0 + 0 = 11 1 1 1 + 0 + 1 = 1

x y z (x + y' + z)0 0 0 0 + 1 + 0 = 10 0 1 0 + 1 + 1 = 10 1 0 0 + 0 + 0 = 00 1 1 0 + 0 + 1 = 11 0 0 1 + 1 + 0 = 11 0 1 1 + 1 + 1 = 11 1 0 1 + 0 + 0 = 11 1 1 1 + 0 + 1 = 1

Page 22: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =

Converting from SOP to POS

F(a,b,c) = a'bc + a'bc' + ab'c' + a'b'c' SOP form 011 010 100 000 binary vectors

F(a,b,c) = m(0,2,3,4) minterm list

F(a,b,c) = M(1,5,6,7) maxterm list

001 101 110 111 binary vectorsF(a,b,c) = (a + b + c')(a'+ b + c')(a'+ b'+ c)(a'+ b'+ c') POS form

Page 23: Lecture 18: Boolean Algebra Boolean Functions. w = Chris is allowed to watch television x = Chris's homework is finished y = it is a school night z =