Boolean Algebra. Boolean Algebra. Boolean Algebra. Boolean Algebra

Full text

(1)

Boolean Algebra

Ver. 1.4

© 2010 - Claudio Fornaro

Boolean Algebra

George Boole was an English mathematician of XIX century

Boolean Algebra can operate on logic (or Boolean) variables that can assume just 2 values:

1/0, true/false, on/off, closed/open

Usually value 1 is associated to True, while 0 to False

3

Boolean Algebra

Boolean algebra is suited for representing

“ binary events ”, that is conditions that can assume just 2 values

Example

A light bulb can be turned on or off

Functions operating on Boolean variables are called Boolean functions and can only produce values 0 or 1

4

Boolean Algebra

A Boolean function F, computed on the Boolean variables v

1

,v

2

,...,v

n

is denoted as:

A Boolean function can be defined in many ways, among them the truth table:

a list of the values that F produces for every possible combination of the variables

) , ,

,

( v

1

v

2

v

n

F

(2)

Boolean Algebra

Example

F(v

1

,v

2

,v

3

) can be defined as shown on the right side:

Each Boolean variable can assume only 2 values, thus n variables can produce 2

n

possible combinations, and each one is a row of the table

v3 v2 v1 F 0

0 0 0

0 1

1 1 0

0 1 1

0 1

0 0 1

1 0 0

0 1

0 1 1

1 1 1

0 1

1 1

Boolean Algebra

Description of an event by using a Boolean function

To pass a certain exam, a student must match one of the following conditions:

s/he passes the written pre-test and then the oral discussion

s/he passes the written test and then the oral discussion

7

Boolean Algebra

Each event is either independent or

dependent (from the independent events)

Each event is assigned a Boolean variable:

a  pre-test, 1=passed b  written test, 1=passed c  oral test, 1=passed e  exam, 1=passed

8

Boolean Algebra

3 variables allow 8 (2

3

) combinations

The truth table for the Boolean function “passing the exam” then is:

a b c e 0

0 0 0

0 1

0 0 0

0 1 1

0 1

0 1 1

1 0 0

0 1

0 1 1

1 1 1

0 1

0 1

Meaning of this row:

the student passed pre-test (a=1), didn’t pass (or try) written test (b=0) and passed oral test (c=1), thus s/he passes the whole exam (e=1)

(3)

Boolean Algebra

After looking carefully, condition a = 0, b = 0, and c = 1 cannot happen, because the oral examination can be tried only when the pre- test or the written test has been passed (or both)

For that combination the exam is not passed, but this is an impossible condition, so it could be useful to indicate a don’t care condition (usually represented by a “–”). A don’t care mark will be eventually replaced by either a 0 or a 1 as needed in a next stage

Logic Operators

Boolean variables can be combined by using Boolean (or logic) operators into Boolean (or logic) expressions

The result of a logic operation is still a logic value (true or false)

The most important operators are:

AND, OR, NOT

EXOR

NAND, NOR, EXNOR

11

Logic Operators

Operator AND (logic product)

symbol: (like the algebraic product), it is often omitted

it combines 2 values and produces a result following the rules below:

0  0 = 0 0  1 = 0 1  0 = 0 1  1 = 1

Result is True if both operands are True

12

Logic Operators

Example

“I go to sea if it is sunny AND it is warm”

X=“it is sunny”

Y=“it is warm”

Z=“I go to sea”

Z = X Y

Both condition must be true to have that “I go to the sea” be true

(4)

Logic Operators

Operator OR (Inclusive OR, logic sum)

symbol: + (like the algebraic sum)

it combines 2 values and produces a result following the rules below:

0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 1

Result is True if at least one operand is True

“I take car if it is raining OR it is cold”

Logic Operators

Example

“I use car if it is raining OR it is cold”

X=“it is raining”

Y=“it is cold”

Z=“I use car”

Z = X + Y

At least one condition must be true to have that “I use car” be true

15

Logic Operators

Operator NOT

symbol: a little line over the variable or the expression to be negated, or just a ’ sign

it applies to just one value and produces a result following the rules below:

0 = 1 1 = 0

Result is True if the operand is False, and vice versa

16

Logic Operators

Operator EX-OR (Exclusive OR)

symbol: 

it combines 2 values and produces a result following the rules below:

0  0 = 0 0  1 = 1 1  0 = 1 1  1 = 0

Result is True if just one operand is True

(5)

Logic Expressions

A logic (or Boolean) expression is composed by:

logic variables

constants 0 and 1

logic operators

parentheses Examples

ab   c

e c ) e a c(d b

a    

Logic Expressions

In a logic expression the operator with the maximum priority is NOT, followed by AND and then OR

This means that the following expressions are equivalent

F = a + b  c F = a + (b  c)

19

Logic Expressions

Two expressions F

1

and F

2

are said equivalent when each input variable combination produce the same output value on both functions (they have the same truth tables)

Examples

2 1

1

x F

x F

20

Logic Expressions

Two expressions F

1

and F

2

are said

complementary when each input variable combination produce an opposite output value on both functions (they have

complementary truth tables)

Examples

b a F

b a F

2 1

(6)

Logic Expressions

Two expressions F

1

and F

2

are said dual when:

each OR of F1 corresponds to an AND of F2 and vice versa

each 1 of F1corresponds to an 0 of F2and v.v.

the order of operator evaluation is the same

Example

)) 0 ( (

) 1 (

2 1

c b a F

c b a F

note the added parentheses

Logic expression reduction

A reduced expression is faster to be

evaluated and the corresponding circuit is smaller, faster, and less power consuming

Reduction can be accomplished in many ways, among them:

Boolean algebra axioms and theorems

Karnaugh maps

23

Boolean Algebra Axioms and Th.

Theorem of duality:

if an equivalence holds, the dual equivalence holds as well

Axioms and theorems

1. x  0 = 0 x + 1 = 1

2. x  1 = x x + 0 = x

3. x  x = 0 x + x = 1

4. x  x = x x + x = x

5. x  y = y  x x + y = y + x

24

Boolean Algebra Axioms and Th.

6. xyz = (xy)  z = x+y+z = (x+y) + z =

= x  (yz) = = x + (y+z) =

= y  (xz) = y + (x+z)

7. De Morgan’s Theorem

xyz… = x+y+z+… x+y+z+… = xyz…

8. xy+xz = x(y+z) (x+y)(x+z) = x+yz

9. x+xy = x x(x+y) = x

10. xy + xy = x (x+y)(x+y) = x

11. x+xy = x+y x(x+y) = xy

12. xy = xy+xy = xy xy=xy=xy=xy+xy

(7)

Boolean Algebra Axioms and Th.

Some demonstrations

9. x+xy = x1+xy = x(1+y) = x1 = x

8. (x+y)(x+z) = xx+xz+xy+yz =

= x+xz+xy+yz =

= x1 +xz+xy+yz =

= x(1+z+y)+yz = x1+yz = x+yz

10. xy+xy = x(y+y) = x1 = x

11. x+xy = x1+xy = x(1+y)+xy = x+xy+xy =

= x+y rule 10

b.

Boolean Algebra Axioms and Th.

In the previous equalities, variables x , y, and z can be considered both as single variables or as full logic expressions E.g. from rule 1bis: (ab+cd) + 1 = 1 where the parentheses content is considered as x

Note that the complementary of xy is NOT xy, but is xy and this for the De Morgan’s Theorem is equal to x+y

27

Reduce the following expressions

1. rule 11

rule 3b

rule 1b

2. rule 11b

rule 4 rule 1

Examples of reduction

1 1

) (

1

) (

) (

everything B A B A A

B A B A B B A

B A B A B A B A

C C B

C A BA

C B A B A

 0

) (

28

Another demonstration of rule 11

x+xy = x1+xy = x(y+y)+xy =

= xy+xy+xy = xy+xy+xy+xy = [rule 4b]

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

Any term in OR may be duplicated, triplicated, etc.

following rule 4b (backward): x=x+x+x+…

Any term in AND may be duplicated, triplicated, etc. following rule 4a (backward): x=xxx…

Examples of reduction

(8)

Logic Functions and Truth Tables

To obtain the truth table from a logic function, the output value for each

combination of the input values must be computed

Example

Compute the truth table of the following function:

F(a,b,c) = (ab + b)  c

Logic Functions and Truth Tables

abc ab b ab + b c (ab+b)  c

000 0 1 1 1 1

001 0 1 1 0 0

010 0 0 0 1 0

011 0 0 0 0 0

100 0 1 1 1 1

101 0 1 1 0 0

110 1 0 1 1 1

111 1 0 1 0 0

31

Expressions in Canonical Forms

SP Canonical Form

Logical sum of products (SP)

Each term (called minterm) is a product of all the variables (some could be affirmed, other negated)

Example

this expression is composed by 4 minterms F(a,b,c) = abc+abc+abc+abc

32

Expressions in Canonical Forms

PS Canonical Form

Logical product of sums (PS)

Each term (called maxterm) is a sum of all the variables (some could be affirmed, other

negated)

Example

this expression is composed by 3 maxterms

F(a,b,c) = (a+b+c)  (a+b+c)  (a+b+c)

(9)

From Truth Table to SP

Because the function must give 1 for some specific combination of input values, for each row with output value 1:

write a product of all the variables (minterm)

Each minterm must give 1 for a specific combination of the input variables, so:

negate each variable whose value is 0 on the input combination corresponding to the minterm

Sum the minterms

From Truth Table to SP

Example

F(a,b,c) = abc+abc+abc+abc

a b c F

0 0 0 0

0 0 1 1

0 1 0 1

0 1 1 0

1 0 0 1

1 0 1 1

1 1 0 0

1 1 1 0

abc

35

From Truth Table to PS

Because the function must give 0 for some specific combination of input values, for each row with output value 0:

write a sum of all the variables (maxterm)

Each maxterm must give 0 for a specific combination of the input variables, so:

negate each variable whose value is 1 on the input combination corresponding to the maxterm

Multiply the maxterms

36

From Truth Table to PS

Example

F(a,b,c)=(a+b+c)(a+b+c)(a+b+c)(a+b+c)

a b c F

0 0 0 0

0 0 1 1

0 1 0 1

0 1 1 0

1 0 0 1

1 0 1 1

1 1 0 0

1 1 1 0

( abc )

(10)

Expressions in Canonical Forms

To canonicalize an SP expression

If in a product a variable is missing (e.g. x) multiply the product by (x+x) and solve removing duplicates

Example

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

= xyz+(x+x)yz+(x+x)(y+y)z

= xyz+xyz+xyz+xyz+xyz+xyz+xyz

Expressions in Canonical Forms

To canonicalize a PS expression

If in a sum a variable is missing (e.g. x) add to the sum the term xx and solve removing duplicates

Example

F(x,y,z) = (x+y+z)  (x+z)  x

= (x+y+z)  (x+yy+z)  (x+yy+zz)

= (x+y+z)  (x+y+z)  (x+y+z)  etc.

39

Logic Circuits

A logical function can be implemented in a digital electronic circuit

Input variables are input signals

Output variables are output signals

Signals have just 2 values: low and high, associated to logic values 0 and 1

Logic operators corresponds to logic gates (e.g. in an AND gate, the output signal is high only when the 2 input signals are high)

40

Logic Gates

AND OR

NOT

NAND =

NOR =

EXOR

EX-NOR =

(11)

Logic Gates

Multiple-input gates exists and are equivalent to more gates connected (thanks to the associative property), but are faster

A multiple-input EXOR gate gives 1 when the number of input with value 1 is odd

Logic Circuits

Example of logic circuit equivalent to a logic expression

F = a  b + c

Note how operator priority is provided by the relative position of the gates

a b

c F

43

Logic Circuits

Example a

F b c F  ( abc )  ( ab ca b )

44

Examples

1.

Four doors (A, B, C, and D) separate two rooms. The doors are operated by 3

switches (X, Y, and Z) that, when pressed, close some doors: X closes A and C, Y closes B and D, Z closes B and C.

Draw the corresponding truth table that produces 1 only when all the doors are closed. Determine the corresponding

function with the least number of variables.

(12)

Examples

XYZ ABCD D 000 0000 0 001 0110 0 010 0101 0 011 0111 0 100 1010 0 101 1110 0 110 1111 1 111 1111 1

1=Door closed

(Note the truth table is the bold part, columns ABCD are just intermediate values)

D=XYZ+XYZ=XY

Examples

2.

Design a digital circuit with inputs:

1. a 2C value D composed by bits a and b

2. a selector: one bit s

and outputs:

1. a 2C value U composed by bits x and y

2. an overflow indicator: one bit w

that works in this way:

U

=

D

if

s

=0

U

=

–D

if

s

=1

w

= 1 if the 2C operation produces an incorrect result

47

Examples

sab D U xy w 000 0 0 00 0 001 +1 +1 01 0 010 -2 -2 10 0 011 -1 -1 11 0 100 0 0 00 0 101 +1 -1 11 0 110 -2 -- -- 1 111 -1 +1 01 0

x=sab+sab+sab

y=sab+sab+sab+sab

w=sab

Figure

Updating...

References

Updating...

Related subjects :