Post on 05-Jul-2020
Boolean Algebra Introduction to Relations
We identified earlier Hierarchy from symbols to knowledge Levels connected by relations
Will now begin to discuss such relations Simplest relation is unary
These really don’t make much sense We have noted numbers are relevant only
When meaning assigned Context specified
Such an assignment is essential first step Consequences of actions are limited The rules of arithmetic
Specify relations between two objects We have the basic relationships of
Add subtract multiply and divide These are simple and we’re quite familiar with them
To be able to perform more complex systems of reasoning We can also talk about logical relationships
Like arithmetic We begin by talking about relations between two things
From these can go to n-ary relations
With such relations Can form a complete system for reasoning
Introduction to Algebra We will now form what we call an algebra Formally algebra or algebraic system defined as
• Set A together with one or more n-ary operations on A We will define a set with several binary relations
• Which satisfy specified set of axioms Let’s examine these
Boolean Algebra Boolean algebra put forth by George Boole 1854
An Investigation into the Laws of Thought Boolean algebra will be our algebra In Boolean algebra will work with
Two valued variables – our set Can easily extend to multiple valued logics
Binary relations – our relations AND - • OR - +
Now we need some axioms We’ll work with the following axioms or postulates Postulates
Postulates presented by Huntington 1904 Formally
Let A be a set of elements We define an algebraic system {A, •, +, 0, 1}
• and + are the operations of AND and OR 0 and 1 are distinguished elements of A
and an equivalence relation = on A such that
I. For elements a, b, and c in A the equivalence relation is 1. Reflexive
a = a for all a in A 2. Symmetric
if a = b then b = a for all a, b in A 3. Transitive
if a = b and b = c then a = c for all a, b, and c in A 4. Substitutive
if a = b then substituting a for b in any expression will result in equivalent relation
II. Let operators • and + be defined such that if a and b are elements of A Called the closure property a • b is in A a + b is in A
III. There exists elements 0 and 1 in A such that a •1 = a a + 0 = 0
IV. The operators • and + are commutative for all a and b in A a • b = b • a a + b = b + a
V. The operators • and + are distributive for all a, b, and c in A a + (b • c) = (a + b) • (a + c) a • (b + c) = a • b + a • c
VI. For every element a in A there exists an element ~a such that a • ~a = 0 a + ~a = 1
VII. There are at least 2 elements, a and b in A such that a ≠ b
Based upon these postulates Simplest algebra consists of
The set of elements A = {0, 1}
Operations • and + defined as • 0 1
0 0 0 1 0 1
+ 0 1 0 0 1 1 1 1
Discussion and justification for each given in text For our proposed algebra
We will demonstrate that each of these postulates holds
Let’s begin Using the set A
I and II are satisfied Based upon the members in set and {0,1} Definitions of • and + given above
III is satisfied because the elements of the set are defined and Definitions of the operators • and + are specified above IV is satisfied from the definitions of the operators • and +
V is demonstrated using a truth table proof Consider one example
LHS RHS
b • c a + b • c (a + b) • (a + c) a + b a + c a b c
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
Observe left and right hands sides the same
VI given by exhaustive proof a • ~a = 0 a + ~a = 1
Using the definitions for the operators • and +
Let a = 0 Then for the set A
~a must be 1 since 0 and 1 are the only elements in A a • ~a = 0 • ~0 = 0 • 1 = 0 from definition of • a + ~a = 0 + ~0 = 0 + 1 = 1 from the definition of +
Let a = 1
Then for the set A ~a must be 0 since 0 and 1 are the only elements in A a • ~a = 1 • ~1 = 1 • 0 = 0 from definition of • a + ~a = 1 + ~1 = 1 + 0 = 1 from the definition of +
VII proven similarly in text
Theorems
From the basic axioms Following theorems can be derived
These are essential building blocks of all our future work Th I The elements 0 and 1 are unique
Th II For every a in A a • a = a a + a = a
Th III For every a in A
a • 0 = 0 a + 1 = 1
Th IV The elements 0 and 1 are distinct and ~0 = 1 Th V For all a and b in A
a + a•b = a a • (a + b) = a
Th VI For all a in A ~a is unique Th VII For all a in A a = ~~a Th VIII For all a, b, and c in A
a ([(a + b) + c] = a(a + b) + ac = a
Th IX For all a, b, and c in A a + (b + c) = (a + b) + c a (bc) = (ab)c
Th X For all a and b in A a + ~a•b= a + b
(a + ~a) • (a + b)
a•(~a + b) = a•b Can prove with a truth table
Th XI For all a and b in A De Morgan’s Law
~(a•b)= ~a + ~b ~(a + b) = ~a•~b Note:
~(a•b) ≠ ~a•~b De Morgan’s Law extends to any number of variables For 3 variables we have
~(a•b•c)= ~a + ~b + ~c ~(a + b + c) = ~a•~b•~c
Getting Some Practice Let’s now look at working with some of these axioms and theorems When designing logic circuits several major goals
We trade these off in the process of design One of major objectives is simplicity
Why Cost Lower failure rate Easier to build Easier to test
Can use above theorems to simplify logic expressions Let’s try a few examples Examples
ab + ~ab ~a~b + ~ab + a~b ~a + ~a~b + bc~d + b~d abc + ~abc + ~bc ab + ~ac + bc ⇒ ~a~bc + ~abc + ab~c + abc ⇒ ab + ~ac a + ~ab + ~(a + b)c + ~(a + b + c) d
Getting to Work
Now that we are armed with the great collection of Postulates Theorems
Have gotten a little practice at working with them Let’s start putting them to work Boolean Algebra
Operands Operands or variables are 2 valued Binary True
1 True iff not false
False 0 False iff not true
Note Other algebras permit multiple valued logics
Operators 3 basic kinds of operators Unary
Takes single operand Called not
Not 1 is 0 0 is 1 a is ~a, a’ ~a is the complement of a
Binary Take two operands Called the AND and the OR
Written • and + We’ve already seen these earlier
Relations Using the operators and operands
Can now begin to express relations Between and among things
We can express such relations in several ways Truth table Equation
Truth Table Table of combinations
Lists all possible values of variables
Simple case Single Variable
A has two values a01
0, 1 True, false
In tabular form
More complex cases Two Variables
A, B a b 0 0 0 1 1 0 1 1
Each can be either true or false Gives 4 combinations
A, B ⇒ 0,0; 0,1; 1,0; 1,1 In tabular form
n Variables In general Number of combinations
N = 2n n is the number of variables
Using a truth table Can use a truth table to demonstrate truth of a proposition Saw one example earlier Let’s look at another LHS RHS
a b a • b ~(a•b) ~a + ~b
0 0 0 1 1 0 1 0 1 1 1 0 0 1 1 1 1 1 0 0
De Morgan’s Law
Let’s look at more complex relationship
Consider serving tea from a vending machine We have 3 items
Tea ⇒ T TLM Good Tea Bad Tea 0 0 0 0 0 1 1 0 0 1 0 1 2 0 1 0 0 1 3 0 1 1 0 1 4 1 0 0 1 0 5 1 0 1 1 0 6 1 1 0 1 0 7 1 1 1 0 1
Lemon ⇒ L Milk ⇒ M
How many variables How many combinations Can now extract from the truth table
GT = 1 = T~L~M + TL~M + T~LM BT = 1 = ~T~L~M + ~T~LM + ~TL~M + ~TLM + TLM
Minterms Two expressions written in what is called
Sum of products form Each product called minterm
Also known as implicant These are also written as
GT = Σ 4, 5, 6 BT = Σ 0, 1, 2, 3, 7
or GT = m4 + m5 + m6 BT = m0 + m1 + m2 + m3 + m7 Where 4, 5, and 6 etc. are binary equivalent of
Minterm variables 4 is 100 ⇒ T~L~M
We get these by identifying all terms For which logical expression has truth value of 1
Let’s now simplify the two expressions
GT = T~L~M + TL~M + T~LM (A+A=A) = T ~M(~L + L) + T~L(M +~M) A + ~A = 1 = T~M + T~L A•1 = A = T(~M + ~ L)
BT = ~T~L~M + ~T~LM + ~TL~M + ~TLM + TLM = ~T~L(~M + M) + ~TL(~M + M) + TLM A + ~A = 1 = ~T~L + ~TL + TLM A•1 = A = ~T(~L + L) + TLM = ~T + TLM A + ~A = 1 = ~T + LM A + ~AB = A+B
Maxterms
Maxterm Mi = ~mi We get a different form of expression if we cover 0’s
Terms for which value is False
We have now written the expressions in maxterm format Also called product of sums Can also be written as
GT = Π 0, 1, 2, 3, 7 BT = Π 4, 5, 6
or GT = M0 • M1 • M2 • M3 • M7 BT = M4 • M5 • M6
These give a listing of the terms for which the Logical expression is 0
Using De Morgan’s Law GT = 0 = (T+L+M)(T+L+~M)(T+~L+M)(T+~L+~M)(~T+~L+~M) BT = 0
= (~T+L+M)(~T+~L+M)(~T+L+~M)
Implementation Let’s now look at building these functions Looking at the equations see three functions necessary
AND OR NOT
Physical hardware used to implement called gates Probably derived from concept of gating signal
Allowing signal to pass We use 3 symbols to represent logical functions Already familiar with such notions
Resistors Capacitors Transistors
These gates given by the 3 symbols A
B C
A B C
A ~A
Although drawn with 2 inputs each Can draw with any number
Practical values typically 2, 3, or 4
Examples Consider function
F = AB + CD Can rewrite as
S = AB T = CD S
T A
F = S + T Thus A
B S
CD T
First we implement the OR part Then the two AND parts A
B
CD
F Finally we bring them together
Now let’s try B
AA~BF = A~B
Let’s now return to the tea problem
LT~L
M
T
T~M
T~M+T~LObserve
Output could have been written as T(~M+~L) T~(ML)
Logic Minimization When we design something
Want the circuit to be a simple as possible Number of reasons
Cost Power Reliability Weight Size
Algebraic Means We use the theorems and postulates discussed earlier
To do this Let’s look at some examples Examples
F = Σ 1,3,7 When we write this
How many variables do we need
We have 3 minterms Can write as
F = ~A~BC + ~ABC + ABC Observe
Choice of variables is arbitrary in this case
Simplifying
F = ~AC(~B + B) + BC(~A + A) = ~AC + BC = C(~A + B)
How do we build this now
F = Π 0,2,5,7 = (A + B + C)(A + ~B + C)(~A + B + ~C)(~A + ~B + ~C) = (A + C)(~A + ~C) = ~AC + A~C F = Σ 3,4,5 = ~ABC + A~B F = Π 3,4,6,7 = (~A + C)(~B + ~C)
Karnaugh Maps
Motivation Let’s now look at the following equation
F = A~B + AB = 2 + 3 What does this reduce to How about
G = AB~C + ABC = 6 + 7 H = A~BC + ABC = 5 + 7 ABC
0 0 0 0 1 0 0 1 2 0 1 0 3 0 1 1 4 1 0 0 5 1 0 1 6 1 1 0 7 1 1 1
I = ~ABC + ABC = 3 + 7
AB 0 0 0 1 0 1 2 1 0 3 1 1
Let’s also recall a couple of truth tables Slightly re-order
Will keep the same terms What do we see between adjacent rows ABC
0 0 0 0 1 0 0 1 3 0 1 1 2 0 1 0 6 1 1 0 7 1 1 1 5 1 0 1 4 1 0 0
AB 0 0 0 1 0 1 3 1 1 2 1 0
With new ordering Recall earlier discussion of Gray code
Single bit change between rows
Observe If I combine minterms
Any two adjacent rows in reordered truth table One variable drops out
Case I 0 + 1 = ~A 1 + 3 = B 3 + 2 = A Tricky one 2 + 0 = ~b
Case II 0 + 1 = ~A~B 1 + 3 = ~A• C etc.
2 Variable Maps Let’s put this to work
A 0 1 B 0 0 1 1 2 3
Create a matrix like map Begin with 2 variables Observe
Each cell has 2 adjacent cells Those cells differ by single variable
Cells are numbered as minterms Observe that this is a Gray sequence
Let’s go back to Case I
Let minterms 0 and 1 be True 2 and 3 be False A 0 1 B
0 1 1 1 0 0 We enter this information into the map as
The simplification F = ~A~B + ~AB = ~A Same as looking at map and combining 2 true minterms
Now let’s reverse A 0 1 B
0 0 0 1 1 1
The simplification F = A~B + AB = A Same as looking at map and combining 2 true minterms
A 0 1 B 0 1 0 1 0 1
A 0 1 B 0 0 1 1 1 0
These two maps contain minterms 1 and 2
F = ~AB + A~B 0 and 3
F = ~A~B + AB Observe
No logic simplification possible In general to be able to combine terms
They must be adjacent That is differ by single variable change
3 Variable Maps
A B
0 1 C
0 0 0 1 0 1 2 3 1 1 6 7 1 0 4 5
Let’s now extend to 3 variables The map is basically the same Observe
We again use a Gray code pattern Let’s now look at Case II again
A B
0 1 C
0 0 0 0 0 1 0 0 1 1 0 0 1 0 1 1
A B
0 1 C
0 0 0 0 0 1 0 0 1 1 0 1 1 0 0 1
A three variable table
These two reduce to A~B
For F = ∑ 4,5
AC For G = ∑ 5,7
Observe
We are combining or grouping adjacent terms
A B
0 1 C
0 0 0 0 0 1 0 0 1 1 0 1 1 0 1 1
Let’s try a more complex pattern H = ∑ 4,5,7
What does this give In practice
We do not write the 0 terms A B
0 1 C
0 0 0 1 1 1 1 1 1 0 1 1
Now try
J = ∑ 2,4,5,6
Observe Several ways of combining
Now A B
0 1 C
0 0 0 1 1 1 1 1 1 0 1 1
K = ∑ 2,4,5,7 Now
Observe Top and bottom rows adjacent A
B 0 1 C
0 0 1 1 0 1 1 1 1 0 1 1
We now have 4 terms that are adjacent This function is N = Σ 0, 1, 4, 5 N = ~A~B~C + ~A~BC + A~B~C + A~BC N = ~B (~A~C + ~AC + A~C + AC) N = ~B
4 Variables Adding one more variable not too much more complex Adds more adjacencies Now where are new adjacencies
Corners 0, 2 , 8, and 10
Edges Top and bottom Left and right
A B 00 01 11 10 CD 0 0 0 1 3 2 0 1 4 5 7 6 1 1 12 13 15 14 1 0 8 9 11 10
What’s the best way to solve this one
A B 00 01 11 10 CD 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 0
Try this
A B 00 01 11 10 CD 0 0 1 1 0 1 1 1 1 1 1 1 1 0 1 1
Now this
A B 00 01 11 10 CD 0 0 1 1 0 1 1 1 1 1 1 0 1 1
Beyond 4 Variables
Several ways to solve Can continue as we are
Must be aware of new adjacencies Can build map within map
For example 3 variable map is two 2 variable maps A B 0 1 C
0 0 0 1 1 2 3
1 0 0 1 1 2 3
Manage in parts Top map is
~A (Reduced function) Bottom map is
A(Reduced function)
Going Backwards We have seen how to take function from map Let’s see how to put on then remove in simpler form 2 Variables
Let’s begin with 2 variables F = A +~AB + AB A 0 1 B
0 0 1 1 1 1 A is bottom row
AB is minterm 3 ~AB is minterm 2
M = ∏ (0, 1, 3)
Grouping and extracting
F + A + B
3 Variables Working with more variables more interesting
F = AB + A(~B + C) A B 0 1 C
0 0 0 1 1 1 1 1 1 0 1 1
From the map
F = A Now try
G = AB~C + AC + ~BC A B 0 1 C
0 0 1 0 1 1 1 1 1 1 0 1
From the map
G = AB + ~BC
4 Variables H = A~C + AB~D + ~BCD A B 00 01 11 10 C D
0 0 1 0 1 1 1 1 1 1 1 0 1 1 1
J = ~A~B~C + ~A~C~D + BCD + ~A~BC~D
A B 00 01 11 10 C D 0 0 1 1 1 0 1 1 1 1 1 1 1 0
Don’t Care Variables
As we have seen 3 binary variables give is 8 combinations
If we have a system with 3 inputs AB
FC
Those inputs potentially can take on up to 8 values For one reason or another
Some of those values may never occur Under those circumstances
We don’t care what values they take on That is we can give them values of 0 or 1
In map to help in simplification Because we don’t care what value such terms take on
Call them don’t cares
Consider function F F = Σ 0, 1, 5 We enter these as 1’s as usual A B 0 1 C
0 0 1 1 0 1 1 1 1 0 1
As the map stands we get
F = ~A~B + ~BC
Assume combinations given by minterms 4 and 6 never occur Or if they do – they are irrelevant DC = Σ 4, 6
A B 0 1 C 0 0 1 1 0 1 1 1 x 1 0 x 1
We enter these as x’s
If we assign value of
0 for don’t care minterm 6 1 for don’t care minterm 4 With don’t care terms F reduces to F = ~B
Let’s now look at a more extensive example Design a code translator that translates from BCD to Excess 3 code
Decimal Number
BCD Inputs
Excess 3 Output
w x y z f4 f3 f2 f1 0 0 0 0 0 0 0 1 1 1 0 0 0 1 0 1 0 0 2 0 0 1 0 0 1 0 1 3 0 0 1 1 0 1 1 0 4 0 1 0 0 0 1 1 1 5 0 1 0 1 1 0 0 0 6 0 1 1 0 1 0 0 1 7 0 1 1 1 1 0 1 0 8 1 0 0 0 1 0 1 1 9 1 0 0 1 1 1 0 0
Following figure expresses block diagram
In two levels of detail
Level 0
BCD to Excess 3Encoder
BCD Excess 3
BCD to Excess 3Encoder
BCD Excess 3
DI0DI1DI2DI3
DO0DO1DO2DO3
Level 1
Let’s look at the logic for one output line