lecture 4 boolean algebra. logical statements °a proposition that may or may not be true: today is...

34
Lecture 4 Boolean Algebra

Upload: chad-richards

Post on 18-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Lecture 4

Boolean Algebra

Page 2: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Logical Statements

° A proposition that may or may not be true:• Today is Monday

• Today is Sunday

• It is raining

° Compound Statements

° More complicated expressions can be built from simpler ones:

• Today is Monday AND it is raining.

• Today is Sunday OR it is NOT raining

• Today is Monday AND today is NOT Monday

- (This is a contradiction)

° The expression as a whole is either true or false.

Page 3: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Things can get a little tricky…

° Are these two statements equivalent?• It is not nighttime and it is Monday OR it is raining and it is

Monday.

• It is not nighttime or it is raining and Monday AND it is Monday.

Page 4: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Boolean Algebra

° Formal logic: In formal logic, a statement (proposition) is a declarative sentence that is either

true(1) or false (0).

° It is easier to communicate with computers using formal logic.

° Boolean variable: Takes only two values – either true (1) or false (0).

They are used as basic units of formal logic.

Page 5: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Venn Diagrams

5

A BA

BA

A B

BA

A B

BA

A B

BA

A B

BA

A

A

A

Page 6: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Boolean Algebra

° Boolean Algebra is a mathematical technique that provides the ability to algebraically simplify logic expressions. These simplified expressions will result in a logic circuit that is equivalent to the original circuit, yet requires fewer gates.

A

B

C

B+AC

A

BC AB+A(B+C)+B(B+C)

Page 7: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Boolean Algebra, Logic and Gates

° Logical operators operate on binary values and binary variables.

° Basic logical operators are the logic functions AND, OR and NOT.

° Logic gates implement logic functions.

° Boolean Algebra: a useful mathematical system for specifying and transforming logic functions.

° We study Boolean algebra as a foundation for designing and analyzing digital systems!

° A literal is a Boolean variable or its complement. A minterm of the Boolean variables x1, x2, …, xn is a Boolean product y1y2…yn, where yi = xi or yi = -xi.

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

Page 8: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Boolean Switching° Boolean (switching) variable x {0,1}∈

• 0, 1 are abstract symbols

They may correspond to {false, true} in logic, {off, on} of a switch, {low voltage, high voltage} of a CMOS circuit, or other meanings

° Boolean space {0,1}n

° The configuration space of all possible {0,1 assignments to n Boolean variables

E.g.,the Boolean space spanned by (x1,x2) is {0,1}2 =

{0,1}×{0,1} = {00, 01, 10, 11}

Page 9: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Overview

° Logic functions with 1’s and 0’s• Building digital circuitry

° Truth tables

° Logic symbols and waveforms

° Boolean algebra

° Properties of Boolean Algebra• Reducing functions

• Transforming functions

Page 10: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Binary Variables

° Recall that the two binary values have different names:

• True/False

• On/Off

• Yes/No

• 1/0

° We use 1 and 0 to denote the two values.

° Variable identifier examples:• A, B, y, z, or X1 for now

• RESET, START_IT, or ADD1 later

Page 11: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Logical Operations

° The three basic logical operations are:• AND

• OR

• NOT

° AND is denoted by a dot (·).

° OR is denoted by a plus (+).

° NOT is denoted by an overbar ( ¯ ), a single quote mark (') after, or (~) before the variable.

Page 12: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

° Examples:• is read “Y is equal to A AND B.”

• is read “z is equal to x OR y.”

• is read “X is equal to NOT A.”

Notation Examples

Note: The statement: 1 + 1 = 2 (read “one plus one equals two”)

is not the same as1 + 1 = 1 (read “1 or 1 equals 1”).

BAY yxz

AX

Page 13: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Operator Definitions

Operations are defined on the values "0" and "1" for each operator:AND

 

0 · 0 = 00 · 1 = 01 · 0 = 01 · 1 = 1

OR

0 + 0 = 00 + 1 = 11 + 0 = 11 + 1 = 1

NOT

1001

Page 14: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

01

10

X

NOT

XZ

Truth Tables

° Truth table a tabular listing of the values of a function for all possible combinations of values on its arguments

° Example: Truth tables for the basic logic operations:

111

001

010

000

Z = X·YYX

AND OR

X Y Z = X+Y

0 0 0

0 1 1

1 0 1

1 1 1

Page 15: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

° Using Switches• Inputs:

- logic 1 is switch closed

- logic 0 is switch open

• Outputs:

- logic 1 is light on

- logic 0 is light off.

• NOT input:

- logic 1 is switch open

- logic 0 is switch closed

Logic Function Implementation Switches in series => AND

Switches in parallel => OR

CNormally-closed switch => NOT

Page 16: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

° Example: Logic Using Switches

° Light is on (L = 1) for L(A, B, C, D) =

and off (L = 0), otherwise.

° Useful model for relay and CMOS gate circuits, the foundation of current digital logic circuits

Logic Function Implementation – cont’d

B

A

D

C

A (B C + D) = A B C + A D

Page 17: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Digital Systems

° Analysis problem:

• Determine binary outputs for each combination of inputs

° Design problem: given a task, develop a circuit that accomplishes the task• Many possible implementation

• Try to develop “best” circuit based on some criterion (size, power, performance, etc.)

.

...

LogicCircuitInputs Outputs

Page 18: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Toll Booth Controller° Consider the design of a toll booth controller

° Inputs: quarter, car sensor

° Outputs: gate lift signal, gate close signal

° If driver pitches in quarter, raise gate.

° When car has cleared gate, close gate.

LogicCircuit

$.25

Car?

Raise gate

Close gate

Page 19: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Describing Circuit Functionality: Inverter

° Basic logic functions have symbols.

° The same functionality can be represented with truth tables.• Truth table completely specifies outputs for all input combinations.

° The above circuit is an inverter. • An input of 0 is inverted to a 1.

• An input of 1 is inverted to a 0.

A Y

0 1

1 0

Input Output

A Y

Symbol

Truth Table

Page 20: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

The AND Gate

° This is an AND gate.

° So, if the two inputs signals

are asserted (high) the

output will also be asserted.

Otherwise, the output will

be deasserted (low).

A B Y

0 0 0

0 1 0

1 0 0

1 1 1

A

BY

Truth Table

Page 21: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

The OR Gate

° This is an OR gate.

° So, if either of the two

input signals are

asserted, or both of

them are, the output

will be asserted.

A B Y

0 0 0

0 1 1

1 0 1

1 1 1

AB

Y

Page 22: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Describing Circuit Functionality: Waveforms

° Waveforms provide another approach for representing functionality.

° Values are either high (logic 1) or low (logic 0).

° Can you create a truth table from the waveforms?

A B Y

0 0 0

0 1 0

1 0 0

1 1 1

AND Gate

Page 23: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Consider three-input gates

3 Input OR Gate

Page 24: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Ordering Boolean Functions

° How to interpret AB+C?• Is it AB ORed with C ?

• Is it A ANDed with B+C ?

° Order of precedence for Boolean algebra: AND before OR.

° Note that parentheses are needed here :

Page 25: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Boolean Algebra

° A Boolean algebra is defined as a closed algebraic system containing a set K or two or more elements and the two operators, . and +.

° Useful for identifying and minimizing circuit functionality

° Identity elements• a + 0 = a

• a . 1 = a

° 0 is the identity element for the + operation.

° 1 is the identity element for the . operation.

Page 26: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Commutatively and Associativity of the Operators

° The Commutative Property:

For every a and b in K,• a + b = b + a

• a . b = b . a

° The Associative Property:

For every a, b, and c in K,• a + (b + c) = (a + b) + c

• a . (b . c) = (a . b) . c

Page 27: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Distributivity of the Operators and Complements° The Distributive Property:

For every a, b, and c in K,• a + ( b . c ) = ( a + b ) . ( a + c )

• a . ( b + c ) = ( a . b ) + ( a . c )

° The Existence of the Complement:

For every a in K there exists a unique element called a’ (complement of a) such that,• a + a’ = 1

• a . a’ = 0

° To simplify notation, the . operator is frequently omitted. When two elements are written next to each other, the AND (.) operator is implied…• a + b . c = ( a + b ) . ( a + c )

• a + bc = ( a + b )( a + c )

Page 28: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Duality

° The principle of duality is an important concept. This says that if an expression is valid in Boolean algebra, the dual of that expression is also valid.

° To form the dual of an expression, replace all + operators with . operators, all . operators with + operators, all ones with zeros, and all zeros with ones.

° Form the dual of the expressiona + (bc) = (a + b)(a + c)

° Following the replacement rules…a(b + c) = ab + ac

° Take care not to alter the location of the parentheses if they are present.

Page 29: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Involution

° This theorem states:

a’’ = a

° Remember that aa’ = 0 and a+a’=1. • Therefore, a’ is the complement of a and a is also the

complement of a’.

• As the complement of a’ is unique, it follows that a’’=a.

° Taking the double inverse of a value will give the initial value.

Page 30: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Absorption

° This theorem states:

a + ab = a a(a+b) = a

° To prove the first half of this theorem:

a + ab = a . 1 + ab

= a (1 + b)

= a (b + 1)

= a (1)

a + ab= a

Page 31: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

DeMorgan’s Theorem

° A key theorem in simplifying Boolean algebra expression is DeMorgan’s Theorem. It states:

(a + b)’ = a’b’ (ab)’ = a’ + b’

° Complement the expression

a(b + z(x + a’)) and simplify.

(a(b+z(x + a’)))’ = a’ + (b + z(x + a’))’= a’ + b’(z(x + a’))’= a’ + b’(z’ + (x + a’)’)= a’ + b’(z’ + x’a’’)= a’ + b’(z’ + x’a)

Page 32: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

X X 9)

1 X X 8)

X X X 7)

1 1 X 6)

X 0 X 5)

0 X X 4)

X X X 3)

X 1 X 2)

0 0 X 1)

Y X Y X 14B)

Y X YX 14A)

YXYXX 13D)

YXYXX 13C)

YXXYX 13B)

YXYXX 13A)

YZYWXZXWZWYX 12B)

XZXYZYX 12A)

ZYXZY X 11B)

ZXYYZX 11A)

X Y Y X 10B)

X Y Y X 10A)

Commutative

Law

Associative Law

Distributive Law

Consensus Theorem

Boolean & DeMorgan’s Theorems

DeMorgan’s

Page 33: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

DeMorgan Shortcut

BREAK THE LINE, CHANGE THE SIGNBreak the LINE over the two variables, and change the SIGN directly under the line.

BABA For Theorem #14A, break the line, and change the AND function to an OR function. Be sure to keep the lines over the variables.

BABA For Theorem #14B, break the line, and change the OR function to an AND function. Be sure to keep the lines over the variables.

Page 34: Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements

Summary

° Basic logic functions can be made from AND, OR, and NOT (invert) functions

° The behavior of digital circuits can be represented with waveforms, truth tables, or symbols

° Primitive gates can be combined to form larger circuits

° Boolean algebra defines how binary variables can be combined

° Rules for associativity, commutativity, and distribution are similar to algebra

° DeMorgan’s rules are important. • Will allow us to reduce circuit sizes.