# Discrete Mathematics and Its Application Solution DISCRETE MATHEMATICS by ypt17268

VIEWS: 264 PAGES: 34

Discrete Mathematics and Its Application Solution document sample

• pg 1
```									DISCRETE MATHEMATICS
Lecture 21
Dr. Kemal Akkaya
Department of Computer Science

Kemal Akkaya   Discrete Mathematics   1
§ 11.1: What is Boolean Algebra?
   A minor generalization of propositional logic.
   In general, an algebra is any mathematical structure
satisfying certain standard algebraic axioms.
   Boolean algebra just generalizes the rules of
propositional logic to sets other than {T,F}.
   E.g., to the set {0,1} of base-2 digits, or the set
{VL, VH} of low and high voltage levels in a circuit.
 It thus provides the operations and the rules for
working with the set {0, 1}
 We will see that this algebraic perspective lends
itself to the design of digital logic circuits.
Claude Shannon’s Master’s thesis!

Kemal Akkaya         Discrete Mathematics               2

 Correspond to logical NOT, OR, and AND.
 We will denote the two logic values as
0:≡F and 1:≡T, instead of False and True.
 Using numbers encourages algebraic
thinking.
 New, more algebraic-looking notation for the
most common Boolean operators:
x : x         x  y : x  y            x  y : x  y
Precedence order→

Kemal Akkaya      Discrete Mathematics                3
Examples
   Let B = {0, 1} then
   The variable is called a Boolean variable if it takes
only values in B. Consequently x + x = x
x2 = x . x = xx = x

   Boolean complement,
0  1, 1  0
0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, 1 + 1 = 1
   Product
0 . 0 = 0, 1 . 0 = 0, 0 . 1 = 0, 1 . 1 = 1

Kemal Akkaya       Discrete Mathematics               4
Boolean Functions

 Let B = {0, 1}, the set of Boolean values.
 For all nZ+, any function f:Bn→B is
called a Boolean function of degree n.
 There are 2 2ⁿ distinct Boolean functions

of degree n.
Because  2 rows in truth table, with 0 or 1
n

in each.

Kemal Akkaya       Discrete Mathematics   5
Boolean Functions
Question: How many different Boolean functions of
degree 1 are there?
Solution: There are four of them, F1, F2, F3, and F4:

X       F1       F2           F3    F4

0      0         0            1    1

1      0         1            0    1

Kemal Akkaya        Discrete Mathematics           6
Boolean Functions
Question: How many different Boolean functions of degree 2 are there?
Solution: There are sixteen of them, F1, F2, F3, …, F16
X   Y   F1    F2    F3    F4   F5   F6    F7   F8   F9     F10   F11   F12   F13   F14   F15       F16

0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
1 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
Degree        How many              Degree         How many
0              2                  4              65,536
1             4                   5          4,294,967,296
2            16                   6     18,446,744,073,709,551,616.
3                256

Kemal Akkaya                   Discrete Mathematics                                       7
Boolean Expressions
   Let x1, …, xn be n different Boolean variables.
   n may be as large as desired.
   A Boolean expression (recursive definition) is a
string of one of the following forms:
   Base cases: 0, 1, x1, …, or xn.
   Recursive cases: E1, (E1E2), or (E1+E2), where E1 and
E2 are Boolean expressions: x1.x2 or x1x2 + x3 etc.
   A Boolean expression represents a Boolean
function.
   Furthermore, every Boolean function (of a given
degree) can be represented by a Boolean expression.

Kemal Akkaya      Discrete Mathematics           8
Boolean equivalents & operations on
Boolean expressions
 Two Boolean expressions e1 and e2 that represent the
exact same function f are called equivalent. We write
e1e2, or just e1=e2.
 Implicitly, the two expressions have the same value for
all values of the free variables appearing in e1 and e2.
 The operators ¯, +, and · can be extended from operating
on expressions to operating on the functions that they
represent, in the obvious way.
 Let F and G be Boolean functions of degree n. The
Boolean sum F+G and Boolean product FG are then
defined by
   (F + G)(b1, b2, …, bn) = F(b1, b2, …, bn) + G(b1, b2, …,bn)
   (FG)(b1, b2, …, bn) = F(b1, b2, …, bn) G(b1, b2, …, bn)

Kemal Akkaya            Discrete Mathematics                  9
Some popular Boolean identities
   Double complement:                    Associative laws:
x=x                                      x + (y + z) = (x + y) + z
   Idempotent laws:                         x · (y · z) = (x · y) · z
x + x = x,       x·x=x                Distributive laws:
   Identity laws:                           x + y·z = (x + y)·(x + z)
x + 0 = x,       x·1=x                   x · (y + z) = x·y + x·z
   Domination laws:                    De Morgan’s laws:
(x · y) = x + y, (x + y) = x · y
x + 1 = 1,       x·0=0
   Absorption laws:
 Commutative laws:
x + y = y + x, x · y = y · x
x + x·y = x,   x · (x + y) = x

Kemal Akkaya             Discrete Mathematics                       10
Duality
 There are useful identities of Boolean
expressions that can help us to transform an
expression A into an equivalent expression B.
 We can derive additional identities with the
help of the dual of a Boolean expression.
 The dual of a Boolean expression is obtained
by
   interchanging Boolean sums and Boolean products
   interchanging 0s and 1s.

Kemal Akkaya       Discrete Mathematics         11
Duality
Examples:
The dual of x(y+z) is x+yz.
The dual of x.1+(y+z) is (x+0)(yz).
 An identity between functions represented by
Boolean expressions remains valid when the
duals of both sides of the identity are taken.
 This is called Duality principle
   For example, absorption law x∙(x + y) = x.
   By taking the duals of both sides of this identity,
we obtain the equation x + x∙y = x, which is also
an identity (and also called an absorption law).
Kemal Akkaya      Discrete Mathematics       12
Boolean Functions/Expressions

   Let f:B3→B, where f(x, y, z) = x∙y+z
This Boolean function is determined by evaluating f for
each of the eight possible assignment to the variables x,
y, z.
x   y          z           x∙y   =x∙y+z
0   0          0           0       0
0   0          1           0       1
0   1          0           0       0
0   1          1           0       1
1   0          0           0       0
1   0          1           0       1
1   1          0           1       1
1   1          1           1       1

Kemal Akkaya       Discrete Mathematics                  13
§11.2 – Representing Boolean Functions

   Definition: A literal is a Boolean variable or its
complement. That is if f is a Boolean function on
the n variables x1, x2, …, xn, each term xi or its
complement –xi, for 1≤ i ≤ n is called a literal.
   f(x, y, z) = x∙y+z : x, y and z are literals
   A minterm of the Boolean variables x1,x2, …,xn is
a Boolean product y1y2…yn, where yi=xi or yi=-xi.
   x∙y∙z is a minterm
   Hence, a minterm is a product of n literals, with
one literal for each variable and is referred to as a
fundamental conjunction.

Kemal Akkaya      Discrete Mathematics        14
Simplifying Boolean Functions/Expressions

   Let f:B4→B, where f (x, y, z, w) =       wx  xz  ( y  z)

wx  xz  ( y  z )  wx  ( x  z )  ( y  z )                   DeMorgan’s Law

 wx  ( x  z )  ( y  z )         Law of Double Complement

 [ wx  x)  z )]  ( y  z )              Associative Law of +

 ( x  z)  ( y  z)          Absorption Law (and Commutative
Laws of + and . )
 x  ( z  z)  y       Commutative and Associative Laws of +

 xz y                                     Idempotent Law of +

Kemal Akkaya             Discrete Mathematics                           15
Sum-of-Products Expansions
   A representation of f as a sum of
fundamental conjunctions is called a
disjunctive normal form (dnf) of f.
   xyz + xyz + …
   Dual to the dnf is the conjunctive normal
form (cnf).
   (x+y+z).(x+y+z). …
   Theorem: Any Boolean function can be
represented as a sum of products of
variables and their complements.
Kemal Akkaya    Discrete Mathematics   16
Functional Completeness
 Since every Boolean function can be
represented using the set {∙, +,─} thus the
operators are functionally complete.
 By De Morgan Law we can eliminate
Boolean sum thus making {∙,─} functionally
complete.
 Two operators of NAND | and NOR ↓ can
provide the necessary functionality for {∙,─}
and thus are functionally complete.

Kemal Akkaya   Discrete Mathematics    17
§11.3 – Logic Gates

 Application of Boolean Algebra
 Inverter, Or, And gate symbols.
 Multi-input gates.
 Logic circuits and examples.
 Adders, “half,” “full,” and n-bit.

Kemal Akkaya   Discrete Mathematics   18
Logic Gate Symbols
   Inverter (logical NOT,                  x
Boolean complement).                                x
x    x·y
   AND gate (Boolean
product).                                y
x   x+y
   OR gate (Boolean sum).
y
   XOR gate (exclusive-OR,
x     x⊕y
sum mod 2).                             y
Kemal Akkaya    Discrete Mathematics               19
Multi-input AND, OR, XOR
 Can extend these
gates to arbitrarily                    x1
many inputs.                            x2   x1x2x3
x3
 Two commonly
seen drawing styles:               x1
 Note that the                    ⋮        x1…x5
second style keeps
x5
the gate icon
relatively small.

Kemal Akkaya   Discrete Mathematics           20
NAND, NOR, XNOR

 Just like the earlier icons,              x
but with a small circle on                y
the gate’s output.                            xy
 Denotes that output is                 x
complemented.                          y   x y
 The circles can also be
placed on inputs.
x
 Means, input is                        y
complemented
x y
before being used.

Kemal Akkaya     Discrete Mathematics            21
Buffer
 What about an inverter              x        x
symbol without a circle?
 This is called a buffer. It is the identity
function.
 It serves no logical purpose, but…
 It represents an explicit delay in the circuit.
   This is sometimes useful for timing purposes.
   All gates, when physically implemented, incur
a non-zero delay between when their inputs
are seen and when their outputs are ready.

Kemal Akkaya        Discrete Mathematics           22
Combinational Logic Circuits

 These are circuits composed of Boolean
gates whose outputs depend only on
their most recent inputs, not on earlier
inputs.
 Thus these circuits have no useful
memory.
   Their state persists while the inputs are
constant, but is irreversibly lost when the input
signals change.

Kemal Akkaya         Discrete Mathematics              23
Examples

Examples:
 Majority voting circuit.
 XOR using OR / AND / NOT.

Kemal Akkaya   Discrete Mathematics   24
Combinational Circuit Example

x           xy
y
xy + xy
x
y           xy

Kemal Akkaya       Discrete Mathematics        25
§11.4 – Minimizing Circuits
   Minimize the number of primitive Boolean logic gates
needed to implement the circuit.
   Ultimately, this also roughly minimizes the number of transistors,
the chip area, cost and energy expenditure.
   It is also often useful to minimize the number of
combinational stages or logical depth of the circuit.
   This roughly minimizes the delay or latency through the circuit, the
time between input and output.
   One solution is using Karnaugh Maps
   Karnaugh Maps or K-map is an alternative to the truth-
table form for representing a function. The map consists
of cells that correspond to the rows of the truth table. The
purpose of the map is to allow easy recognition of the
cells that are adjacent and can be combined.

Kemal Akkaya           Discrete Mathematics                  26
K-map Example
Find K-Map for            x y  xy  x y
y       y
x              1
x     1        1

Minterms in any cells that are adjacent, either in the same row
or the same column, can be combined.

For example:         xy  x y                          x

Kemal Akkaya              Discrete Mathematics         27
More K-Map Examples

1)     xy z x y z  x yz  x y z

2)    x yz x y z  xyz  x yz  x y z

3)    xy z x y z  x yz  x y z

Kemal Akkaya     Discrete Mathematics    28
Truth Table
xy z x y z  x yz  x y z
x      y    z   xy z x y z  x yz  x y z Result
0    0    0    0      0        0      1   1
0    0    1    0      0        0      0   0
0    1    0    0      0        0      0   0
0    1    1    0      0        1      0   1
1    0    0    0      1        0      0   1
1    0    1    0      0        0      0   0
1    1    0    1      0        0      0   1
1    1    1    0      0        0      0   0

Kemal Akkaya             Discrete Mathematics               29
Can we simplify it?

xy z  x y z  x yz  x y z
yz   yz           yz        yz

x             1           1

x        1                1

Kemal Akkaya        Discrete Mathematics        30
Get the adjacent terms / combine

yz     yz            yz        yz

x              1            1

x       1                   1

x yz          xz              yz

Kemal Akkaya          Discrete Mathematics         31
Result is same

x   y z
x z  y z  x yz Result
0 0 0       0       1        0   1
0 0 1       0       0        0   0
0 1 0       0       0        0   0
0 1 1       0       0        1   1
1 0 0       1       0        0   1
1 0 1       0       0        0   0
1 1 0       1       0        0   1
1 1 1       0       0        0   0

Kemal Akkaya             Discrete Mathematics       32
Minimizing DNF Expressions

   Using DNF (or CNF) guarantees there is
always some circuit that implements any
desired Boolean function.
   However, it may be far larger than needed!
   We would like to find the smallest sum-of-
products expression that yields a given
function.
   This will yield a fairly small circuit.
   However, circuits of other forms (not CNF or DNF)
might be even smaller for complex functions.

Kemal Akkaya       Discrete Mathematics           33
4-degree functions

wx y z  wxyz  wxy z  wx y z  wx y z  wxy z  wx y z

yz   yz    yz      yz
wx              1

wx    1    1     1

wx         1     1

wx               1

Kemal Akkaya          Discrete Mathematics     34

```
To top