Sie sind auf Seite 1von 41

CSC3011

Discrete
Structures
Boolean Algebra

Outline
O Introduction
O Boolean Functions and expressions
O Logic Networks and Karnaugh maps
O Structure of Boolean Algebra
O Application: Seven segment display

Introduction
O Boolean algebra was formulated by

George Boole
O It is an essential tool for designing
networks to solve input and output
problems
O It is the basic mathematics required
for the study of the logic design of
digital systems
O Digital computers use two-state
devices that produce two distinct
output signals

Introduction
O Definition
O A Boolean Algebra (B,+,.,,0,1) consists of

operations + and on B, a unary operation on


B, and specified elements 0 and 1 in B such
that the following axioms for Boolean algebra
hold for all x, y, and z in B
O Boolean Axioms
O x+y = y+x

x.y = y.x
O (x+y).z = (x.z+y.z)
(x.y).z = x.(y.z)
O x+(y.z) = (x+y).(x+z)
x.(y+z) = x.y + x.z
O x+0 = x x.0 = 0
O x+x = 1 x.x = 0

Boolean Laws for Set Theory


O XY = YX X Y = Y X
O (XY)Z = X(YZ) (XY) Z = X (Y Z)
O X(YZ) = (X Y)(X Z) X (Y Z) = (X Y) (X Z)
O X = X

XU = X

O X X = U XX =
O The system (P(U), , ,, ,U) is an example of a

Boolean Algebra

Example
O Two-element Boolean algebra
O Let (B,+,.,,0,1) be a given system

with B = {0,1}, where operations +, .,


and are defined as follows
O 0+0 = 0,

0.0=0,
0=1
O 0+1 = 1, 0.1=0,
1=0
O 1+0 = 1, 1.0=0
O 1+1 =1,
1.1=1

O This is a Boolean algebra

Example
O Light bulb problem
O Suppose a single bulb in the middle of

a long hallway is controlled by


switches at each end of the hallway.
The light bulb should be on when
either, but not both, of the switches is
on. Otherwise it should be off. How
might we design a logic network to
control the light bulb?. This network
has two inputs and one output

Example

O The relationship

between the light


bulb and the
switches can be
described by the
table on the right

S1

S2

Boolean Algebra
O Theorem
O x.y + x.y = x
O (x+y).(x+y)=x

O Proof
O x.y + x.y = x.(y+y) = x.1 = x

O Theorem: Unique complement law


O For each element x B, x is the unique

element in B satisfying x+x=1 and x.x=0


O Proof.
O Show that x+y=1 and x.y=0 implies y=x

Boolean Algebra
O Proof ctd
O Let x + y = 1 and x.y=0 then

y = y.1
=y.(x + x)
=y.x + y.x
=x.y + x.y
=0 + x.y
=x.x + xy
=x.(x + y)
=x.1
=x

Boolean Algebra
O Theorem: Involution Laws
O (x) = x
O 1=0 and 0=1

O Proof
O Exercise

O Theorem: De Morgans Law


O (x+y) =x.y
O (x.y) = x+y

Boolean Algebra
O Proof ctd

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


= (x + x.y) + y
=(x + x).(x + y) + y
=1.(x + y) + y
=x + (y + y)
=x + 1 = 1
=1
So (x + y) = (x.y)

Boolean Functions
O Definition: Boolean Function
O Let {0, 1}n denote the set of all n-tuples of 0s

and 1s. A Boolean Function is a function of n


variables f:{0,1}n {0,1} where n1
O i.e
O f(x1,x2,..,xn) = 0 or
O f(x1,x2,..,xn) = 1 for any Boolean function f.

O Example: Consider f:{0,1} {0,1} defined

by

O f(0) = 1 and f(1) = 0. f can be represented as.

Boolean Function
O Boolean functions are usually

represented by tables called truth


tables.
O A truth table specifies the values of a
Boolean function for every possible
combination of values in {0,1} of the
variables
O Example construct the truth table for
g:{0,1}3{0,1} defined by g(1,0,1)
= g(1,1,1) = 1 and g is 0 otherwise

Boolean Functions

Ex: Let B ={0,1}


I. Find Card(B) and Card(B3)
II. Find the number of Boolean functions from B3
to B

Boolean Expressions
O Definition
O A Boolean expression in n variables x 1,x2,..,xn

is finite string of symbols involving x 1,x2,..,xn


together with the Boolean Operations +, .,
and parentheses such that the string is
formed by the following rules
a) The symbols 0 and 1 and x1,x2,..,xn are
Boolean expressions.
b) If E and F are Boolean expressions then E,
F,(E+F), and (E.F) are also Boolean
expressions.

Boolean Expressions
O When working with Boolean expressions
O Ignore the outer parentheses
O Follow usual precedence i.e. evaluate

parentheses first, then evaluate


complements, then evaluate products,
and finally evaluate sums
O Write x1x2x3 for x1(x2x3) or (x1x2)x3
O For Boolean expressions involving a few
variables, use x, y, and z instead of x1,
x2, and x3

Boolean Expressions
O Example
O Define a Boolean function of three

variables corresponding to the


Boolean expression xy +zx.

Boolean Expressions
O Ex:
O Outline the truth table for g(x,y,z) =

yx+xz+yy
O The truth table is the same as for the
previous example.
O When a Boolean expression E defines

a Boolean function f, we say E


corresponds to the function f or viceversa.

Boolean Expressions
O The Boolean expression
O 0 defines a constant Boolean function

from {0, 1}n to {0, 1} by formula


f(x1,..,xn) = 0 for all (x1,..,xn) {0,1}n.
O 1 defines the constant Boolean function
from {0, 1}n to {0, 1} by formula
f(x1,..,xn) = 1 for all (x1,..,xn) {0,1}n.
O Boolean expression in m variables can

define a Boolean function f: {0, 1}n


{0,1} for nm

Boolean Expressions
O Two Boolean expressions are

considered to be equivalent if they


define the same Boolean function
from {0, 1}n to {0,1}.
O We can write E = F without causing
confusion if E is equivalent to F
O We can apply Boolean algebra laws
to establish the equivalence of two
Boolean expressions.

Boolean Expressions
O Example
O Show that (x +yz)(yz) is equivalent to

xy+xz+yz.
O Solution

(x+yz)(yz)=(x+yz)(y+z) ;De Morgans


Law
= x(y+z)+yz(y+z); Distributive
=xy+xz+yzy+yzz;
=xy+xz+yz+y.0
= xy+xz+yz

Boolean Expressions
O Every Boolean expression in n

variables is equivalent to a unique


Boolean expression called the
standard sum of products, to be
defined shortly.
O A Boolean expression consisting of a
single variable or its complement is
called a literal.
O A miniterm in n variables is a
product of n literals such that each
variable xi occurs exactly once either
as xi or xi but not both.

Boolean Expressions
O Definition
O Given a Boolean expression E in n

variables, if E is equivalent to a sum of


distinct miniterms, then this sum of
distinct miniterms is called the standard
sum of products (or disjunctive normal
form) for E
O Example
O Given the Boolean expression xz as an

expression of three variables, find the


standard sum of products for xz.

Booleans Expressions
O Example ctd
O From the truth table
O (1,0,1) and (1,1,1)

give the value of 1. So


the function f(x,y,z) =
xyz+xyz is the
standard sum of
products, which
defines the expression
xz

Boolean Expressions
O It is possible to write all Boolean

expressions using only the basic


operations +, ., and
O It is also possible and frequently
useful to write a Boolean expression
using only one or two operations.
O A Boolean operation is functionally
complete if, for every Boolean
function, there is a corresponding
Boolean expression written in terms
of operations in the set. E.g {,+}

Boolean Expressions
O Example
O Define xy by the following truth table
O Clearly xy = xy = (x+y)
O is called a NOR (not or) operation
O To show the is functionally complete
O x = (x + x) = xx
O x.y = (x).(y) = (x + y) = xy =

(xx)(yy)
O The logic gate for NOR is called a NOR gate.
O Any logic network can be written entirely in

terms of NOR gates.

Logic networks
O Definition
O A logic gate is a binary electronic

device with one or more input signals


to produce one output signal.
O There are three basic logic gates

called the OR gate, the AND gate,


and the NOT gate (inverter)

Logic Networks
O The AND

gate
O The OR gate
O The NOT

gate

Logic Networks
O The OR gate represents the Boolean

addition in {0,1}
O The output of the OR gate is 1 if one

or both input values are 1; it is 0


otherwise.
O The AND gate represents Boolean

multiplication in {0,1}
O The output of the AND gate is 1 if and

only when both input values are 1; it


is 0 otherwise.

Logic Networks
O A logic network (also called

switching, gating, combinatorial


network or logic circuit e.t.c) is some
combination of the OR, AND and NOT
gates.
O When we use single variables for
inputs, the output of the logic
network is represented by a Boolean
expression of the input variables
O Example Draw the logic network for
(x+y)(x+y) and x.y +x.y

Logic Networks
O The logic networks in the example

define the same Boolean function f:


{0,1}2{0,1}
O When two output Boolean
expressions are equivalent, we say
that the two corresponding logic
networks are equivalent, and vice
versa
O Given a logic network, it is possible
to derive the Boolean expression it
defines.

Logic Networks
O Example
O What is F(A,B,C) described by the

network below

O F(A,B,C) = (B.C).(A+B) = ABC

Logic Networks
O Since every Boolean expression

defines a Boolean function, every


Logic network also defines a Boolean
function.
O Although many equivalent Boolean
expressions (hence, logic networks)
can correspond to the same Boolean
function g, theres only one standard
sum of products form that
corresponds to g

Logic Networks
O Example
O Construct a logic network to instruct a

robot to answer the phone according


to the following rules:
O if the switch is on or
O if the switch is not on and the master

does not answer the telephone before


the fifth ring

Logic Networks
O Soln
O Define varibles x and y defined
O x for master not answering the

telephone after 5 rings


O y for the switch being on
O We want the robot to answer if and
only if y = 1 or (y=0 and x=1)
O f(x,y) = y + yx

Logic Networks
O The half-adder network has two

output, s and c as described in the


table
O s is the binary sum of the two inputs
O c is the carry resulting when two input

digits are added


O s = xy+xy
O c = xy

Logic Networks
O The designing of logic networks can

be viewed as a three-step process:


O Specify the input and output task with

a Boolean function f
O Find the Boolean expression E, in the
standard sum of products form
O Minimise E
O We define a specific minimised

expression called a minimal sum of


products

Logic Networks
O Definition
O A minimal sum of products F for a Boolean

expression E has the following properties


OF = E
O F is the sum of products
O If G is any other sum of products such that G =

E, then G contains at least as many products


as F
O If H is any other sum of products such that H =
E and H has the same number of products as F,
then H contains at least as many literals as F

Logic Networks
O Minimisation Rule
O If a Boolean expression is the sum of two miniterms

differing in one literal, that literal can be removed


and the sum written as the product of the remaining
literals
O In order to make the above minimisation process

easy to apply, we use the Karnaugh map method.


O The Karnaugh map is the representation of a
Boolean expression written in standard sum of
products form
O It is a rectangular array of boxes with entries of 1s

and blanks such that each entry 1 represents a


miniterm in the given standard sum of products

Logic Networks
O The rows and columns of

boxes in the Karnaugh map


are labeled so that products
in the Boolean expression
differing in one literal are
represented by 1s in
adjacent boxes
O E.g. the Karnaugh map
xy+xy

Das könnte Ihnen auch gefallen