boolean algebra

23
Fall 2002 CMSC 203 - Discrete Structures 1 Yes, No, Maybe... Yes, No, Maybe... Boolean Boolean Algebra Algebra

Upload: mdaglis

Post on 13-Dec-2014

646 views

Category:

Technology


4 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 1

Yes, No, Maybe...Yes, No, Maybe...

BooleanBooleanAlgebraAlgebra

Page 2: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 2

Boolean AlgebraBoolean Algebra

Boolean algebra provides the operations and Boolean algebra provides the operations and the rules for working with the set the rules for working with the set {0, 1}.{0, 1}.

These are the rules that underlie These are the rules that underlie electronic electronic circuitscircuits, and the methods we will discuss are , and the methods we will discuss are fundamental to fundamental to VLSI designVLSI design..

We are going to focus on three operations:We are going to focus on three operations:

• Boolean complementation,Boolean complementation,

• Boolean sum, andBoolean sum, and

• Boolean productBoolean product

Page 3: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 3

Boolean OperationsBoolean Operations

The The complementcomplement is denoted by a bar (on the is denoted by a bar (on the slides, we will use a minus sign). It is defined byslides, we will use a minus sign). It is defined by

-0 = 1 and -1 = 0.-0 = 1 and -1 = 0.

The The Boolean sumBoolean sum, denoted by + or by OR, has , denoted by + or by OR, has the following values:the following values:

1 + 1 = 1, 1 + 0 = 1, 0 + 1 = 1, 0 + 0 = 01 + 1 = 1, 1 + 0 = 1, 0 + 1 = 1, 0 + 0 = 0

The The Boolean productBoolean product, denoted by , denoted by or by or by AND, has the following values:AND, has the following values:

1 1 1 = 1, 1 1 = 1, 1 0 = 0, 0 0 = 0, 0 1 = 0, 0 1 = 0, 0 0 = 0 0 = 0

Page 4: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 4

Boolean Functions and ExpressionsBoolean Functions and Expressions

Definition:Definition: Let B = {0, 1}. The variable x is Let B = {0, 1}. The variable x is called a called a Boolean variableBoolean variable if it assumes values if it assumes values only from B.only from B.

A function from BA function from Bnn, the set {(x, the set {(x11, x, x22, …, x, …, xnn) |x) |xiiB, B,

1 1 i i n}, to B is called a n}, to B is called a Boolean function Boolean function of degree nof degree n..

Boolean functions can be represented using Boolean functions can be represented using expressions made up from the variables and expressions made up from the variables and Boolean operations.Boolean operations.

Page 5: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 5

Boolean Functions and ExpressionsBoolean Functions and Expressions

The The Boolean expressionsBoolean expressions in the variables x in the variables x11, x, x22, , …, x…, xnn are defined recursively as follows: are defined recursively as follows:

• 0, 1, x0, 1, x11, x, x22, …, x, …, xnn are Boolean expressions. are Boolean expressions.

• If EIf E11 and E and E22 are Boolean expressions, then (-E are Boolean expressions, then (-E11), ),

(E (E11EE22), and (E), and (E11 + E + E22) are Boolean expressions.) are Boolean expressions.

Each Boolean expression represents a Boolean Each Boolean expression represents a Boolean function. The values of this function are obtained function. The values of this function are obtained by substituting 0 and 1 for the variables in the by substituting 0 and 1 for the variables in the expression.expression.

Page 6: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 6

Boolean Functions and ExpressionsBoolean Functions and Expressions

For example, we can create Boolean expression For example, we can create Boolean expression in the variables x, y, and z using the “building in the variables x, y, and z using the “building blocks”blocks”0, 1, x, y, and z, and the construction rules:0, 1, x, y, and z, and the construction rules:

Since x and y are Boolean expressions, so is xy.Since x and y are Boolean expressions, so is xy.

Since z is a Boolean expression, so is (-z).Since z is a Boolean expression, so is (-z).

Since xy and (-z) are expressions, so is xy + (-Since xy and (-z) are expressions, so is xy + (-z).z).

… … and so on…and so on…

Page 7: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 7

Boolean Functions and ExpressionsBoolean Functions and Expressions

Example:Example: Give a Boolean expression for the Give a Boolean expression for the Boolean function F(x, y) as defined by the Boolean function F(x, y) as defined by the following table:following table:

xx yy F(x, y)F(x, y)

00 00 00

00 11 11

11 00 00

11 11 00

Possible solution:Possible solution: F(x, y) = (-x) F(x, y) = (-x)yy

Page 8: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 8

Boolean Functions and ExpressionsBoolean Functions and ExpressionsAnother Example:Another Example: Possible Possible

solution I:solution I:

F(x, y, z) = -(xz + F(x, y, z) = -(xz + y)y)

00001111

F(x, y, z)F(x, y, z)

11001100zz

0000

1100

1100

0000yyxx

00000011

11001100

1111

1111

00110011

Possible solution Possible solution II:II:

F(x, y, z) = (-(xz))(-F(x, y, z) = (-(xz))(-y)y)

Page 9: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 9

Boolean Functions and ExpressionsBoolean Functions and Expressions

There is a simple method for deriving a Boolean There is a simple method for deriving a Boolean expression for a function that is defined by a expression for a function that is defined by a table. This method is based on table. This method is based on mintermsminterms..

Definition:Definition: A A literal literal is a Boolean variable or is a Boolean variable or its complement. A its complement. A mintermminterm of the Boolean of the Boolean variables xvariables x11, x, x22, …, x, …, xnn is a Boolean product is a Boolean product yy11yy22…y…ynn, where y, where yii = x = xii or y or yii = -x = -xii..

Hence, a minterm is a product of n literals, with Hence, a minterm is a product of n literals, with one literal for each variable.one literal for each variable.

Page 10: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 10

Boolean Functions and ExpressionsBoolean Functions and ExpressionsConsider F(x,y,z) again:Consider F(x,y,z) again: F(x, y, z) = 1 if and F(x, y, z) = 1 if and

only if:only if:

x = y = z = 0 orx = y = z = 0 or

x = y = 0, z = 1 orx = y = 0, z = 1 or

x = 1, y = z = 0x = 1, y = z = 0

Therefore,Therefore,

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

00001111

F(x, y, z)F(x, y, z)

11001100zz

0000

1100

1100

0000yyxx

00000011

11001100

1111

1111

00110011

Page 11: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 11

Boolean Functions and ExpressionsBoolean Functions and Expressions

Definition:Definition: The Boolean functions F and G of n The Boolean functions F and G of n variables are variables are equalequal if and only if F(b if and only if F(b11, b, b22, …, b, …, bnn) ) = G(b= G(b11, b, b22, …, b, …, bnn) whenever b) whenever b11, b, b22, …, b, …, bnn belong belong to B.to B.

Two different Boolean expressions that Two different Boolean expressions that represent the same function are called represent the same function are called equivalentequivalent..

For example, the Boolean expressions xy, xy + For example, the Boolean expressions xy, xy + 0, and xy0, and xy1 are equivalent.1 are equivalent.

Page 12: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 12

Boolean Functions and ExpressionsBoolean Functions and Expressions

The The complement complement of the Boolean function F is the of the Boolean function F is the function –F, where –F(bfunction –F, where –F(b11, b, b22, …, b, …, bnn) = ) = -(F(b-(F(b11, b, b22, …, b, …, bnn)).)).

Let F and G be Boolean functions of degree n. The Let F and G be Boolean functions of degree n. The Boolean sum F+GBoolean sum F+G and and Boolean product FGBoolean product FG are then defined byare then defined by

(F + G)(b(F + G)(b11, b, b22, …, b, …, bnn) = F(b) = F(b11, b, b22, …, b, …, bnn) + G(b) + G(b11, b, b22, , …, b…, bnn))

(FG)(b(FG)(b11, b, b22, …, b, …, bnn) = F(b) = F(b11, b, b22, …, b, …, bnn) G(b) G(b11, b, b22, …, b, …, bnn))

Page 13: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 13

Boolean Functions and ExpressionsBoolean Functions and Expressions

Question:Question: How many different Boolean functions of How many different Boolean functions of degree 1 are there?degree 1 are there?

Solution:Solution: There are four of them, F There are four of them, F11, F, F22, F, F33, and F, and F44::

xx FF11 FF22 FF33 FF44

00 00 00 11 11

11 00 11 00 11

Page 14: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 14

Boolean Functions and ExpressionsBoolean Functions and Expressions

Question:Question: How many different Boolean How many different Boolean functions of degree 2 are there?functions of degree 2 are there?

Solution:Solution: There are 16 of them, F There are 16 of them, F11, F, F22, …, F, …, F1616::

11000000FF22

00000000FF11

001100

110011

001111

000000FF33yyxx

11111100FF88

00111100FF77

00

00

00

11FF99

00001100FF55

11110000FF44

11

00

11

00FF66

00110011FF1111

11000011FF1010

00

11

11

11FF1212

11001111

FF11

44

00001111

FF11

33

11

11

00

11

FF11

55

11111111FF1616

Page 15: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 15

Boolean Functions and ExpressionsBoolean Functions and Expressions

Question:Question: How many different Boolean How many different Boolean functions of degree n are there?functions of degree n are there?

Solution:Solution:

There are 2There are 2nn different n-tuples of 0s and 1s. different n-tuples of 0s and 1s.

A Boolean function is an assignment of 0 or 1 A Boolean function is an assignment of 0 or 1 to each of these 2to each of these 2nn different n-tuples. different n-tuples.

Therefore, there are Therefore, there are 2222nn different Boolean different Boolean

functions.functions.

Page 16: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 16

DualityDuality

There are useful identities of Boolean There are useful identities of Boolean expressions that can help us to transform an expressions that can help us to transform an expression A into an equivalent expression B expression A into an equivalent expression B (see Table 5 on page 597 in the textbook).(see Table 5 on page 597 in the textbook).

We can derive additional identities with the We can derive additional identities with the help of the help of the dualdual of a Boolean expression. of a Boolean expression.

The dual of a Boolean expression is obtained The dual of a Boolean expression is obtained by interchanging Boolean sums and Boolean by interchanging Boolean sums and Boolean products and interchanging 0s and 1s.products and interchanging 0s and 1s.

Page 17: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 17

DualityDualityExamples:Examples:

The dual of The dual of x(y + z)x(y + z) isis

x + yz.x + yz.

The dual of The dual of -x-x1 + (-y + 1 + (-y + z) z) isis

(-x + 0)((-y)z).(-x + 0)((-y)z).

The The dual of a Boolean function Fdual of a Boolean function F represented by a Boolean expression is the represented by a Boolean expression is the function represented by the dual of this function represented by the dual of this expression.expression.

This dual function, denoted by FThis dual function, denoted by Fdd, , does not does not dependdepend on the particular Boolean expression on the particular Boolean expression used to represent F.used to represent F.

Page 18: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 18

DualityDuality

Therefore, an identity between functions Therefore, an identity between functions represented by Boolean expressions represented by Boolean expressions remains remains validvalid when the duals of both sides of the when the duals of both sides of the identity are taken.identity are taken.

We can use this fact, called the We can use this fact, called the duality duality principleprinciple, to derive new identities., to derive new identities.

For example, consider the absorption law For example, consider the absorption law x(x + y) = xx(x + y) = x..

By taking the duals of both sides of this By taking the duals of both sides of this identity, we obtain the equation identity, we obtain the equation x + xy = xx + xy = x, , which is also an identity (and also called an which is also an identity (and also called an absorption law).absorption law).

Page 19: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 19

Definition of a Boolean AlgebraDefinition of a Boolean Algebra

All the properties of Boolean functions and All the properties of Boolean functions and expressions that we have discovered also expressions that we have discovered also apply to apply to other mathematical structuresother mathematical structures such as propositions and sets and the such as propositions and sets and the operations defined on them.operations defined on them.

If we can show that a particular structure is a If we can show that a particular structure is a Boolean algebra, then we know that all results Boolean algebra, then we know that all results established about Boolean algebras apply to established about Boolean algebras apply to this structure.this structure.

For this purpose, we need an For this purpose, we need an abstract abstract definitiondefinition of a Boolean algebra. of a Boolean algebra.

Page 20: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 20

Definition of a Boolean AlgebraDefinition of a Boolean AlgebraDefinition:Definition: A Boolean algebra is a set B with two A Boolean algebra is a set B with two binary operations binary operations and and , elements 0 and 1, and , elements 0 and 1, and a unary operation – such that the following a unary operation – such that the following properties hold for all x, y, and z in B:properties hold for all x, y, and z in B:

x x 0 = x and x 0 = x and x 1 = x 1 = x (identity laws)(identity laws)

x x (-x) = 1 and x (-x) = 1 and x (-x) = 0 (-x) = 0 (domination laws)(domination laws)

(x (x y) y) z = x z = x (y (y z) and z) and (x (x y) y) z = x z = x (y (y z) and z) and (associative laws)(associative laws)

x x y = y y = y x and x x and x y = y y = y x x (commutative (commutative laws)laws)

x x (y (y z) = (x z) = (x y) y) (x (x z) and z) andx x (y (y z) = (x z) = (x y) y) (x (x z) z) (distributive laws)(distributive laws)

Page 21: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 21

Logic GatesLogic GatesElectronic circuits consist of so-called gates.Electronic circuits consist of so-called gates.There are three basic types of gates:There are three basic types of gates:

xx

yy

x+x+yy OR gateOR gate

AND gateAND gatexx

yy

xyxy

xx -x-xinverterinverter

Page 22: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 22

Logic GatesLogic GatesExample:Example: How can we build a circuit that How can we build a circuit that computes the function xy + (-x)y ?computes the function xy + (-x)y ?

xy + (-xy + (-x)yx)y

xx

yy

xyxy

xx -x-x

yy

(-x)y(-x)y

Page 23: Boolean algebra

Fall 2002 CMSC 203 - Discrete Structures 23

TheTheEndEnd