You are on page 1of 59

Q. Identify the difference between FSM and FSA.

Describe their functional workings, characteristics and


applications.

Ans:
In deterministic finite automata, there's exactly one state transition for every input symbol-
state pair. There are also no epsilon transitions, meaning that you're not allowed to change
states without consuming anything from the input.

In non-deterministic finite automata, there can be 0 or more state transitions for every input-
state pair. You can also have epsilon transitions. When there's no state transition for a given
input-state pair, then we say that the automata had crashed, meaning that it can't proceed
processing the input, and therefore it doesn't accept the input. When there's more than one
choice for a state transition for a given input-state pair, then the machine can just follow all
possible paths (think of it as parallel computation), if one of the paths ends up in an accept
state, then we say that the automata accepted the input string.

Both automata are equivalent in terms of power though. It may seem that a non-deterministic
automata is more powerful, but both automata are proven to be equivalent, meaning that they
recognize the same class of languages called regular languages. The proof of equivalence is by
construction in which you show that given a DFA, you can construct an equivalent NFA, and
vice versa. The proof can be found in any textbook on theory of computation.

***********************************

In general, which you probably know, a finite automaton has a set of states, starts in a start
state, and reads an input string character-by-character, each character making it switch states
depending on which character it read and which state it was previously in (state-character
pair); this is called the transition function or transition relation. Some states may also have
ε-transitions, which are states the machine can go to without reading any character. A certain
set of states are designated accept states; whether the finite automaton accepts or rejects
depends on whether it's in an accept state or reject state after reading the entire string. The
description I just gave was, intentionally, vague enough to apply to both deterministic and
nondeterministic finite automata, which I'll refer to as DFAs and NFAs, respectively, from
here on.

In a nondeterministic finite automaton, the transition relation specifies any number,


including 0, 1, 2, or more, possible states that the NFA can transition to for each state-
character pair. How it decides which one to take is neither defined nor relevant to the abstract
concept, but you can pretend that it chooses uniformly at random. This can produce many
different computation paths for the same input string; and we say that an NFA accepts a
string if at least one of those paths ends in an accept state.

In some sense, we can just say a deterministic finite automaton is one that isn't
nondeterministic - where the transition function specifies only one future state for each state-
character pair, and thus there is only one computation path on any given input string. If it
ends in a designated accept state, the machine accepts. So the key difference is whether the
computation path is determined by the input string, or if there's some additional
nondeterminism involved. But there's another difference, and it has to do with size.

Obviously, any DFA can be made into an "NFA with no nondeterminism", so any language
accepted by a DFA can be accepted by an NFA. Given an NFA, at any point in the string we
can look at all the computation paths up to this point, and the set of states that at least one
computation path is in; and these sets of states can be considered the states of a DFA, since
this transition is deterministic. (If it's not obvious from this explanation, think about it a
bit.) So the languages recognized by DFAs and those recognized by NFAs are
identical. However, if you take an NFA with n states and make a DFA out of it using this
method, that DFA will have 2^n states, and there are some languages where you can't actually
get more efficient than that. It's also proven that the languages that can be described by
regular expressions are the same set as those that can be recognized by DFAs or NFAs, but
given a regular expression of length n, the smallest NFA has O(n) states, while the smallest
DFA in general has O(2^n) states.
Q. Define phrase structure grammar. State and explain different types of phrase structure grammar. How
can you tie up the concept of grammar, languages and FSA together? Give details with examples.

Ans:

Definition of Phrase-Structure Grammars:

A phrase-structure grammar G = (V, T, S, P) consists of a vocabulary V, a subset T

of V consisting of terminal symbols, a start symbol S from V, and a finite set of


productions P. The set V − T is denoted by N. Elements of N are called nonterminal
symbols. Every production in P must contain at least one nonterminal on its left side.

Example: Let G = (V, T, S, P),


Where V = {a, b, A, B, S},
T = {a, b},
S is the start symbol, and
P = {S → ABa, A → BB, B → ab, AB → b}.
G is an example of a phrase-structure grammar.

Types of Phrase-Structure Grammars

Phrase-structure grammars can be classified according to the types of productions


that are allowed. The different types of languages defined in this scheme correspond
to the classes of languages that can be recognized using different models of
computing machines.

A type 0 grammar has no restrictions on its productions.

A type 1 grammar can have productions of the form w1 → w2, where w1 = lAr and
w2 = lwr, where A is a nonterminal symbol, l and r are strings of zero or more
terminal or nonterminal symbols, and w is a nonempty
string of terminal or nonterminal symbols. It can also have the production S → λ as
long as S does not appear on the right-hand side of any other production.

A type 2 grammar can have productions only of the form w1 → w2, where w1 is a
single symbol that is not a terminal symbol.
A type 3 grammar can have productions only of the form w1 → w2 with w1 = A
and either w2 = aB or w2 = a, where A and B are nonterminal symbols and a is a
terminal symbol, or with w1 = S and w2 = λ.

Type 2 grammars are called context-free grammars because a nonterminal symbol


that is the left side of a production can be replaced in a string whenever it occurs, no
matter what else is in the string. A language generated by a type 2 grammar is called
a context-free language.

When there is a production of the form lw1r → lw2r (but not of the form w1 →
w2), the grammar is called type 1 or context-sensitive because w1 can be replaced
by w2 only when it is surrounded by the strings l and r. A language generated by a
type 1 grammar is called a context-sensitive language.

Type 3 grammars are also called regular grammars. A language generated by a


regular grammar is called regular language.

Language Recognition by Finite-State Machines

Here, we define some terms that are used when studying the recognition by finite-
state automata of certain sets of strings.

DEFINITION
A string x is said to be recognized or accepted by the machine M = (S, I, f, s0, F) if
it takes the initial state s0 to a final state, that is, f (s0, x) is a state in F. The
language recognized or accepted by the machine M, denoted by L (M), is the set of
all strings that are recognized by M. Two finite-state automata are called equivalent
if they recognize the same language.

EXAMPLE:
Determine the languages recognized by the finite-state automata M1, M2, and M3 in
Figure 1.
FIGURE 1 Some Finite-State Automata.

Solution: The only final state of M1 is s0. The strings that take s0 to itself are those
consisting of zero or more consecutive 1s. Hence, L (M1) = {1n | n = 0, 1, 2, . . . }.
The only final state of M2 is s2. The only strings that take s0 to s2 are 1 and 01. Hence,
L (M2) = {1, 01}.
The final states of M3 are s0 and s3.The only strings that take s0 to itself are λ, 0, 00,
000, . . . , that is, any string of zero or more consecutive 0s. The only strings that
take s0 to s3 are a string of zero or more consecutive 0s, followed by 10, followed by
any string. Hence, L (M3) = {0n, 0n10x | n = 0, 1, 2, . . . , and x is any string}.

Q. a). Construct a phrase structure grammar that generates all signed decimal
numbers, consisting of a sign, either+ or - ; a nonnegative integer; and a decimal
fraction that is either the empty string or a decimal point followed by a positive
integer, where initial zeros in an integer are allowed.
b). Give the BNF form of this grammar.
Ans:
b). Give the BNF form of this grammar.
Ans:
Q. Identify the difference between FSM and FSA. Describe their functional
workings, characteristics and applications.

Ans:

A finite-state machine (FSM) or finite-state automaton (FSA,


plural: automata), or simply a state machine, is a mathematical model of
computation used to design both computer programs and sequential
logic circuits. It is conceived as an abstract machine that can be in one of a
finite number of states. The machine is in only one state at a time; the state
it is in at any given time is called the current state. It can change from one
state to another when initiated by a triggering event or condition; this is called
a transition. A particular FSM is defined by a list of its states, and the
triggering condition for each transition.
Simple examples are vending machines, which dispense products when the
proper combination of coins is deposited, elevators, which drop riders off at
upper floors before going down, traffic lights, which change sequence when
cars are waiting, and combination locks, which require the input of
combination numbers in the proper order.
Finite-state machines can model a large number of problems, among which
are electronic design automation, communication protocol design,
language parsing and other engineering applications.
Considered as an abstract model of computation, the finite state machine
has less computational power than some other models of computation such
as the Turing machine.
A finite automaton (FA): is a simple idealized machine used to recognize
patterns within input taken from some character set (or alphabet) C. The job
of an FA is to accept or reject an input depending on whether the pattern
defined by the FA occurs in the input.

A finite automaton consists of:

 a finite set S of N states


 a special start state
 a set of final (or accepting) states
 a set of transitions T from one state to another, labeled with chars in C

As noted above, we can represent a FA graphically, with nodes for states, and arcs for
transitions.

We execute our FA on an input sequence as follows:

 Begin in the start state


 If the next input char matches the label on a transition from the current state to
a new state, go to that new state
 Continue making transitions on each input char
o If no move is possible, then stop
o If in accepting state, then accept

Application of FSM or FA:


Application of FA:
Finite automata and its variants are used in formal methods (a field of software
engineering) which deals in proving a software system as mathematically correct. Automata
is used in modelling the system and regular expression and different logic are used to
specify the requirements. Thus the important question now becomes to check whether a
given model satisfies the given logic statement (model checking). Automata are also used for
proving decidability of sat probs.
Q. Define the role of Induction, Recursion and Iteration to describe the behaviour of
a procedure. Give examples of code blocks to define their status. (Hints: Induction
in proving program correctness that arises in recursive programs, recursion in calling
of functions and iteration in different loop status).
Ans:
Mathematical Induction
In general, mathematical induction ∗ can be used to prove statements that assert that
P(n) is true for all positive integers n, where P(n) is a propositional function. A proof
by mathematical induction has two parts, a basis step, where we show that P(1) is
true, and an inductive step, where we show that for all positive integers k, if P(k) is
true, then P(k + 1) is true.
Recursion:
Sometimes it is difficult to define an object explicitly. However, it may be easy to
define this object in terms of itself. This process is called recursion. For instance,
the picture shown in Figure 1 is produced recursively. First, an original picture is
given. Then a process of successively superimposing centered smaller pictures on
top of the previous pictures is carried out.

We can use recursion to define sequences, functions, and sets. In Section 2.4, and in
most beginning mathematics courses, the terms of a sequence are specified using an
explicit formula. For instance, the sequence of powers of 2 is given by an = 2n for
n = 0, 1, 2, . . . . Recall from Section 2.4 that we can also define a sequence
recursively by specifying how terms of the sequence are found from previous terms.
The sequence of powers of 2 can also be defined by giving the first term of the
sequence, namely, a0 = 1, and a rule for finding a term of the sequence from the
previous one, namely, an+1 = 2an for n = 0, 1, 2, . . . . When we define a sequence
recursively by specifying how terms of the sequence are found from previous terms,
we can use induction to prove results about the sequence.
When we define a set recursively, we specify some initial elements in a basis step
and
provide a rule for constructing new elements from those we already have in the
recursive
step. To prove results about recursively defined sets we use a method called
structural
induction.

1. Recurrence Relation
“Recursive Definition of sequences, Solution of linear recurrence, Solution of
Non-linear recurrence, Application to Algorithm Analysis.”

1. Recursive Definition of sequences

Recursion is a process in which each step of a pattern is dependent on


the step or steps that come before it

EXAMPLE 1 Suppose that f is defined recursively by


f (0) = 3,
f (n + 1) = 2f (n) + 3.
Find f (1), f (2), f (3), and f (4).

Solution: From the recursive definition it follows that


f (1) = 2f (0) + 3 = 2 · 3 + 3 = 9,
f (2) = 2f (1) + 3 = 2 · 9 + 3 = 21,
f (3) = 2f (2) + 3 = 2 · 21 + 3 = 45,
f (4) = 2f (3) + 3 = 2 · 45 + 3 = 93.

Recursively defined functions are well defined. That is, for every positive integer,
the value of the function at this integer is determined in an unambiguous way. This
means that given any positive integer, we can use the two parts of the definition to
find the value of the function at that integer, and that we obtain the same value no
matter how we apply the two parts of the definition. This is a consequence of the
principle of mathematical induction.

EXAMPLE 2 Give a recursive definition of an, where a is a nonzero real number


and n is a nonnegative integer.
Solution: The recursive definition contains two parts. First a0 is specified, namely,
a0 = 1. Then the rule for finding an+1 from an, namely, an+1 = a · an, for n = 0,
1, 2, 3, . . . , is given. These two equations uniquely define an for all nonnegative
integers n.
EXAMPLE 3 Give a recursive definition of

Solution: The first part of the recursive definition is


In some recursive definitions of functions, the values of the function at the first k
positive integers are specified, and a rule is given for determining the value of the
function at larger integers from its values at some or all of the preceding k integers.
That recursive definitions defined in this way produce well-defined functions
follows from strong induction.

Recall from Section 2.4 that the Fibonacci numbers, f0, f1, f2, . . . , are defined by
the equations f0 = 0, f1 = 1, and
fn = fn− 1 + fn− 2

for n = 2, 3, 4, . . .. [We can think of the Fibonacci number fn either as the nth term
of the sequence of Fibonacci numbers f0, f1, . . . or as the value at the integer n of a
function f (n).] We can use the recursive definition of the Fibonacci numbers to
prove many properties of these numbers. We give one such property in Example 4.

EXAMPLE 4 Show that whenever n ≥ 3, fn > αn− 2, where α = (1 +√5)/2.


Solution: We can use strong induction to prove this inequality. Let P(n) be the
statement fn > αn− 2.Wewant to showthat P(n) is true whenever n is an integer
greater than or equal to 3.
BASIS STEP: First, note that
α < 2 = f3, α2 = (3 +√ 5)/2 < 3 = f4,
so P(3) and P(4) are true.
Digital System Design
Q. Discuss about the major levels of abstraction for VLSI design process. Explain
and list out the steps for Design abstractions.
Ans:

Karnaugh Maps
Why Do You Need To Know About Karnaugh Maps?

What Is a Karnaugh Map?

Using Karnaugh Maps

Some Observations

Problems

Why Do You Need To Know About Karnaugh Maps?

Karnaugh Maps are used for many small design problems. It's true
that many larger designs are done using computer implementations of
different algorithms. However designs with a small number of variables
occur frequently in interface problems and that makes learning Karnaugh
Maps worthwhile. In addition, if you study Karnaugh Maps you will gain a
great deal of insight into digital logic circuits.

In this section we'll examine some Karnaugh Maps for three and
four variables. As we use them be particularly tuned in to how they are
really being used to simplify Boolean functions.

The goals for this lesson include the following.

Given a Boolean function described by a truth table or logic function,


Draw the Karnaugh Map for the function.
Use the information from a Karnaugh Map to determine the
smallest sum-of-products function.

What Does a Karnaugh Map Look Like?

A Karnaugh Map is a grid-like representation of a truth table. It is


really just another way of presenting a truth table, but the mode of
presentation gives more insight. A Karnaugh map has zero and one entries
at different positions. Each position in a grid corresponds to a truth
table entry. Here's an example taken from the voting circuit presented
in the lesson on Minterms. The truth table is shown first. The Karnaugh
Map for this truth table is shown after the truth table.

A B C V

0 0 0 0

0 0 1 0

0 1 0 0

0 1 1 1

1 0 0 0

1 0 1 1

1 1 0 1

1 1 1 1
How Can a Karnaugh Map Help?

At first, it might seem that the Karnaugh Map is just another way of
presenting the information in a truth table. In one way that's
true. However, any time you have the opportunity to use another way of
looking at a problem advantages can accrue to you. In the case of the
Karnaugh Map the advantage is that the Karnaugh Map is designed to
present the information in a way that allows easy grouping of terms that
can be combined.

Let's start by looking at the Karnaugh Map we've already


encountered. Look at two entries side by side. We'll start by focussing
on the ones shown below in gray.

Let's examine the map again.

 The term on the left in the gray area of the map corresponds to:
o
 The term on the right in the gray area of the map corresponds to:
o
 These two terms can be combined to give
o

The beauty of the Karnaugh Map is that it has been cleverly


designed so that any two adjacent cells in the map differ by a change in
one variable. It's always a change of one variable any time you cross a
horizontal or vertical cell boundaries. (It's not fair to go through the
corners!)

Notice that the order of terms isn't random. Look across the top
boundary of the Karnaugh Map. Terms go 00, 01, 11, 10. If you think
binary well, you might have ordered terms in order 00, 01, 10, 11. That's
the sequence of binary numbers for 0,1,2,3. However, in a Karnaugh Map
terms are not arranged in numerical sequence! That's done deliberately
to ensure that crossing each horizontal or vertical cell boundary will
reflect a change of only one variable. In the numerical sequence, the
middle two terms, 01, and 10 differ by two variables! Anyhow, when only
one variable changes that means that you can eliminate that variable, as in
the example above for the terms in the gray area.

Let's check the claim made on above. Click on the buttons to shade
groups of terms and to find out what the reduced term is.

The Karnaugh Map is a visual technique that allows you to generate


groupings of terms that can be combined with a simple visual
inspection. The technique you use is simply to examine the Karnaugh Map
for any groups of ones that occur. Grouping ones into the largest groups
possible and ensuring that all ones in the table have been included are the
first step in using a Karnaugh Map.

In the next section we will examine how you can generate groups
using Karnaugh Maps. First, however, we will look at some of the kinds of
groups that occur in Truth Tables, and how they appear in Karnaugh Maps.

Click on these buttons to show some groupings. There's one


surprise, but it really is correct. In each case, be sure that you
understand the term that the group represents.
There is a small surprise in one grouping above. The lower left and
the lower right 1s actually form a group. They differ only in having B and
its' inverse. Consequently they can be combined. You will have to imagine
that the right end and the left end are connected.

So far we have focussed on K-maps for three variables. Karnaugh


Maps are useful for more than three variables, and we'll look at how to
extend ideas to four variables here. Shown below is a K-map for four
variables.

Note the following about the four variable Karnaugh Map.

 There are 16 cells in the map. Anytime you have N variables, you
will have 2N possible combinations, and 2N places in a truth table or
Karnaugh Map.
 Imagine moving around in the Karnaugh Map. Every time you cross a
horizontal or vertical boundary one - and only one - variable changes
value.
 The two pairs of variables - WX and YZ - both change in the same
pattern.

Otherwise, if you can understand a Karnaugh Map for a three-variable


function, you should be able to understand one for a four-variable
function. Remember these basic rules that apply to Karnaugh maps of any
size.

 In a Karnaugh Map of any size, crossing a vertical or horizontal cell


boundary is a change of only one variable - no matter how many
variables there are.
 Each single cell that contains a 1 represents a minterm in the
function, and each minterm can be thought of as a "product" term
with N variables.
 To combine variables, use groups of 2, 4, 8, etc. A group of 2 in an
N-variable Karnaugh map will give you a "product" term with N-1
variables. A group of 4 will have N-2 variables, etc.
 You will never have a group of 3, a group of 5, etc. Don't even think
about it. See the points above.

Let's look at some examples of groups in a 4-variable Karnaugh Map.


Example 1 - A Group of 2

Here is a group of 2 in a 4-variable map.

Note that Y and Z are 00 and 01 at the top of the two columns in which
you find the two 1s. The variable, Z, changes from a 0 to a 1 as you move
from the left cell to the right cell. Consequently, these two 1s are not
dependent upon the value of Z, and Z will not appear in the product term
that results when we combine the 1s in this group of 2. Conversely, W, X
and Y will be in the product term. Notice that in the row in which the 1s
appear, W = 0 and X = 1. Also, in the two columns in which the 1s appear
we have Y = 0. That means that the term represented by these two cells
is:

Problem
P1. Here is a Karnaugh map with two entries. Determine the product
term represented by this map.

Larger groups in Karnaugh Maps of any size can lead to greater


simplification. Let's consider the group shown shaded below. There are
four terms covered by the shaded area.

 In the upper left:-

o
 In the upper right;

o
 In the lower left;

o
 In the lower right;
o

These terms can be combined (assuming they are all ones in the
Karnaugh Map!). The result is
 By combining the first two terms above (the two terms at the top of
the Karnaugh Map):-

o
 By combining the last two terms above (the two terms at the
bottom of the Karnaugh Map):-

o
 Then, these two germs can be combined to give:

Notice how making the grouping larger reduces the number of


variables in the resulting terms. That simplification helps when you start
to connect gates to implement the function represented by a Karnaugh
map.

By now you should have inferred the rules for getting the sum-of-
products form from the Karnaugh map.

 The number of ones in a group is a power of 2. That's 2, 4, 8 etc.


 If a variable takes on both values (0 and 1) for different entries
(1s) in the Karnaugh Map, that variable will not be in the sum-of-
products form. Note that the variable should be one in half of the
K-Map ones and it should be zero (inverted) in the other half.
 If a variable is always 1 or always zero (it appears either inverted
all the time in all entries that are one, or it is always not inverted)
then that variable appears in that form in the sum-of-products
form.

Now, let's see if you can apply those rules.

Problem
P2. Here is a Karnaugh Map with four entries. What is the sum-of-
products form for the four ones shown?

P3. Here is a Karnaugh Map with four entries. What is the sum-of-
products form for the four ones shown?

P4. Here is a Karnaugh Map with four entries. What is the sum-of-
products form for the four ones shown?
P5. Here is a Karnaugh Map with eight entries. What is the sum-of-
products form for the four ones shown?

Some Further Observations

There are a few further observations that should be made. Note


the following.

 There may well be more than one solution of equal complexity.


o Here is an example Karnaugh Map. There are two groups that
are obvious - one in orange, and one in light blue.

o In this example, the two terms shown are:




o There is still one entry to account for. There is a 1 that can
be joined to either of two other entries to form a
group. There is no best way to go on this. Either way will take
the same number of gates, inputs, etc.

And another observation

 If there are more than four variables, it is still possible to use


Karnaugh Maps, and you will find larger Karnaugh Maps discussed in
many textbooks. However, as the number of variables increases it
becomes more difficult to see patterns, and computer methods
start to become more attractive.

*****************
An Logic Problem (3.1)

Here is a truth table.

A B C F
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 0

Your Job:

Your job is to do the following


 Sketch the Karnaugh Map for this function.

 Using the Karnaugh Map, get the simplest sum-of-products form for this function
 Draw the circuit diagram using all NANDs.

************************
An Logic Problem (3.2)

Dr. Abner Mallity has been working with a logic circuit. He has a circuit
that works but he suspects that it can be made simpler. Here is the circuit.

Your Job:

Your job is to do the following


 Determine the truth table for the function implemented in this circuit. Fill in the truth table
below.

W X Y Z F
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1
 Using the Karnaugh Map, get the simplest sum-of-products form for this function
 Draw the circuit diagram using ANDs, ORs and NOTs.
 Draw the circuit diagram using all NANDs.

******************
A Logic Problem (3.3)- The Solar Collector System (Prob 3.3) - Still
Under Construction.

Here's a solar heating system representation.

 The sun shines out of an intense blue sky onto a solar collector.
 The solar collector heats up.
 Fans can be used to move the accumulated heat in the collector to
a rock bin - to store heat - or to the house itself.
o Fan A can be used to move air through the solar collector.
o Fan B can be used to move air into the heated space (the
house).

The way the system works is:


 When either fan is OFF, air cannot move through that fan.
 When both Fan A and Fan B are ON air moves through the
collector directly into the house.
 When Fan B is ON and Fan A is OFF air moves from the rock bin
into the heated space.
 When Fan A is ON and Fan B is OFF (heated) air moves from the
collector to the rock bin.

Several sensors are available, producing several signals.

 When the heated area needs heat the


signal H becomes TRUE. This signal is supplied by a temperature
sensor that compares measured temperature to desired
temperature.
 When the rock bin is warmer than the heated space - and can
supply heat - a signal RH is TRUE. The measurements from two
temperature sensors is compared to generate this signal, and the
same scheme is used for the two measurements below.
 When the collector is warmer than the heated space the
signal CH is TRUE.
 When the collector is warmer than the rock bin the
signal CR is TRUE.

Your Problem:
 Generate a truth table for all functions. Here is a blank truth table. FA is TRUE when Fan
A is ON, and FB is TRUE when Fan B is ON.
 First, we note that when there is no need for heat to the heated space (H = 0), and the
collector is warmer than the rock bin (CR = 1) we should move heat from the collector to
the rock bin. To do that, turn FAN A ON and B OFF. That allows us to fill in four parts of
the truth table.

H RH CH CR FA FB
0 0 0 0
0 0 0 1 1 0
0 0 1 0
0 0 1 1 1 0
0 1 0 0
0 1 0 1 1 0
0 1 1 0
0 1 1 1 1 0
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1

 However, there is one situation here that is thought-provoking. If CR = 1 (Collector


warmer than the Rock bin), and if RH = 1 (Rock bin warmer than the Heated space.), then it
is clear that CH = 1 (Collecter warmer than the Heated space.) There are places in the truth
table where that is not the case, and when CH = 0 in that situation, it's something that can't
happen. Since it can't happen, we don't care what the function is for that case. That gives
us a new truth table with DON'T CAREs. We'll add DON'T CAREs wherever that happens.

H RH CH CR FA FB
0 0 0 0
0 0 0 1 1 0
0 0 1 0
0 0 1 1 1 0
0 1 0 0
0 1 0 1 X X
0 1 1 0
0 1 1 1 1 0
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1 X X
1 1 1 0
1 1 1 1

o Actually, we can note that anytime heat is needed and either the Collector or Rock
bin can supply it, we need to turn on Fan A. When we don't need heat, Fan A is
OFF. And, if we need heat (H = 1) and nothing can supply heat we won't turn on
Fan A. Let's put that into the truth table.

H RH CH CR FA FB
0 0 0 0 0
0 0 0 1 1 0
0 0 1 0 0
0 0 1 1 1 0
0 1 0 0 0
0 1 0 1 X X
0 1 1 0 0
0 1 1 1 1 0
1 0 0 0 0
1 0 0 1 0
1 0 1 0 1
1 0 1 1 1
1 1 0 0 1
1 1 0 1 X X
1 1 1 0 1
1 1 1 1 1

 Next, we note that we turn on Fan B when

 Determine the simplest sum-of-products form for both fan functions.


o Be careful. There may be some Don't Care terms in the truth table. Think about
what conditions are possible carefully.
 Show the circuit.

*********************
A Logic Problem (3.4)

Your favorite professor, the ever-ebullient Dr. Abner Mallity, is working on


a little consulting project. As usual he is going to stiff one of his graduate
students, Willy Nilly and Millie Farad, and get one of them to do the project for
him. They could use some help. They are also working hard to finish a term
project. Here's the story.

You need to do a design for the logic circuit that adds ingredients to an
ice cream sundae. Mallity's client - the NutCase Sundae Company - wants to
develop a product that makes sundaes automatically. They plan to add
ingredients chosen from the following list. The list has 16 different ingredients

 1. Avocado Slush
 2. Bannanas
 3. Chocolate Syrup
 4. Dacamania Nuts (Newly discovered in the Fiji Islands, and not
related to macadamia nuts)
 5. Something starting with the letter "E", but the only thing they've
thought of so far is Eggplant.
Here is the truth table for the Avacodo Slush used for different sundaes. The
sundaes are numbered from 0 to 15 (in binary numbers) in the truth
tables. They plan to come up with some interesting names later, and will get
rid of the numbers ASAP.

Sundae # W X Y Z A
0 0 0 0 0 0
1 0 0 0 1 0
2 0 0 1 0 0
3 0 0 1 1 1
4 0 1 0 0 1
5 0 1 0 1 1
6 0 1 1 0 1
7 0 1 1 1 0
8 1 0 0 0 1
9 1 0 0 1 0
10 1 0 1 0 1
11 1 0 1 1 0
12 1 1 0 0 1
13 1 1 0 1 0
14 1 1 1 0 1
15 1 1 1 1 1

Here is what you need to do.


 Determine the Karnaugh map for the Avocado Slush function (A).

 From the Karnaugh map determine the smallest sum-of-products form for the Avocado
Slush function.
 Show an AND-OR-NOT implementation for the circuit.
Quine-McCluskey Method of Logic Minimization

I. INTRODUCTION
The Quine–McCluskey algorithm or the method of prime implicants is a method
used for minimization of Boolean functions. It was developed by W.V. Quine
and Edward J. McCluskey in 1956. It is functionally identical to Karnaugh
mapping, but the tabular form makes it more efficient for use in computer
algorithms, and it also gives a deterministic way to check that the minimal form
of a Boolean function has been reached. It is sometimes referred to as the
tabulation method. The method involves two steps:

1. Finding all prime implicants of the function.


2. Use those prime implicants in a prime implicant chart to find the essential
prime implicants of the function, as well as other prime implicants that are
necessary to cover the function.
In this paper, we intend to discuss the Quine-McCluskey minimization
procedure as well as provide the readers with all the simulation codes which
are available on net in one single paper, highlighting the variations in each of
the given codes implemented using a different computer language. The
procedure which is discussed in the following section 2 and 3 has also been
taken from the net and for that appropriate references have been given.

II QUINE-McCluskey MINIMIZATION PROCEDURE

This is basically a tabular method of minimization and as much it is suitable for


computer applications. The procedure for optimization as follows:

Step 1: Describe individual minterms of the given expression by their equivalent binary numbers.

Step 2: Form a table by grouping numbers with equivalent number of 1‟s in them, i.e. first numbers with
no 1‟s, then numbers with one 1, and then numbers with two 1‟s, … etc.

Step 3: Compare each number in the top group with each minterm in the next lower group. If the two
numbers are the same in every position but one, place a check sign to the right of both numbers to
show that they have been paired and covered. Then enter the newly formed number in the next column
(a new table). The new number is the old numbers but where the literal differ, an “x” is placed in the
position of that literal.

Step 4: Using (3) above, form a second table and repeat the process again until no further pairing is
possible. (On second repeat, compare numbers to numbers in the next group that have the same “x”
position.

Step 5: Terms which were not covered are the prime implicants and are ORed and ANDed together to
form final function. Note: The procedure above gives you the prime implicant but not essential prime
implicant.
***********************************************
Quine-McCluskey Method
 when # variables is large, instead of using Karnaugh map, you can use quine-
McCluskey method (using a CAD tool on a computer)
 Quine-McCluskey method reduces the minterm expansion of a function to
obtain minimum sum of products form
 procedure has two steps
1. Eliminate as many literals as possible from each term by applying xy +
xy' = x. The resulting terms are called prime implicants.
2. Use a prime implicant chart to select as minimum # of prime implicants
such that when they're OR'd together it equals the function being
simplified and contains a minimum # of literals.

determination of prime implicants


function given as sum of minterms

 to determine the prime implicant we represent the minterms in binary


notation and combine them using xy + xy' = x (two terms combine if they differ
in exactly one variable)
 binary minterms are grouped according to # of 1's
o i.e.. binary notation
Group 0,1 ...x (column 1) has 0,1...x number of 1's in the minterm.
The blue column groups minterms from adjacent groups. For example the top
cell groups together minterms from group 0 and group 1 (first two rows). the
next cell groups minterms from group 1 and 2 (i.e.. 0-10 (2,6) formed from
2:0010 and 6: 0110) . The yellow column continues grouping minterms from
the previous (blue column).

o grouping allows one to look for combinations of minterms in adjacent


groups.
o e.i.

 the duplicate terms (0,1 ; 8,9) and (0,8 ; 1,9) were formed by combining the 4
minterms in different order
 Finally we compare the minterms from the two groups in last column, but
there's no more reduction so the procedure terminates.
 each time a term combines with another term it's checked off
 terms which have not been checked off are prime implicants
 since every minterm has been included in at least one of the prime implicants
the function is equal to the sum of it's prime implicants
 so we get last row of table was reduced using consensus theorem., However
instead of using this theorem to reduce further we can use the prime implicant
chart, to be discussed next.
 Definition: given a function F of n variables, a product term P is an implicant of
F iff for every combination of values of n variables for which P=1, F is also 1.
 Definition : a prime implicant of a function F is a product term implicant which
is no longer an implicant if any literal is deleted from it.
 The quine-mccluskey procedure finds all the prime implicants of a function F
(implicants which are not prime are checked off)

The Prime Implicant Chart


 used to select a minimum set of prime implicants
 minterms of f are listed across top of chart
 prime implicants are listed down the side
 a prime implicant is equal to a sum o f minterms and is said to cover these
minterms
 if a prime implicant covers a minterm an X is placed

f= b'c' + cd' + a'bd

 if a minterm is covered by only one prime implicant then that prime implicant
is essential and must be included in minimum sum of products
 each time a prime implicant is included in minimum sum of products its row
should be crossed out and columns of its covered minterms should also be
crossed out.
 then a minimum set of prime implicants must be chosen to cover the remaining
columns.
 in the example, a'bd covers the remaining columns so f = b'c' + cd' + a'bd
 note even though a'bd is included in minimum sum of products it is not an
essential prime implicant
 we can do this by trial and error (although for large charts there are special
procedures)
 simplification of incompletely specified functions:
o treat don't cares as if they were required minterms (so we can eliminate
as many literals as possible) in step(1)
o in step(2) , when form prime implicant chart, do not list these don't care
terms at the top.

**************************************************

Introduction
In order to understand the tabular method of minimization, it is best you understand
the numerical assignment of Karnaugh map cells and the incompletely specified
functions also known as the can't happen conditions. This is because the tabular
method is based on these principles.

The tabular method which is also known as the Quine-McCluskey method is


particularly useful when minimizing functions having a large number of variables, e.g.
The six-variable functions. Computer programs have been developed employing this
algorithm. The method reduces a function in standard sum of products form to a set
of prime implicants from which as many variables are eliminated as possible.
These prime implicants are then examined to see if some are redundant.

The tabular method makes repeated use of the law A + = 1. Note that Binary notation
is used for the function, although decimal notation is also used for the functions. As
usual a variable in true form is denoted by 1, in inverted form by 0, and the absence of
a variable by a dash ( - ).

Rules of Tabular Method


Consider a function of three variables f(A, B, C):

Consider the function:

Listing the two minterms shows they can be


combined
Now consider the following:

Note that these variables cannot be

combined
This is because the FIRST RULE of the Tabular method for two terms to combine, and
thus eliminate one variable, is that they must differ in only one digit position.

Bear in mind that when two terms are combined, one of the combined terms has one
digit more at logic 1 than the other combined term. This indicates that the number of
1's in a term is significant and is referred to as its index.

For example: f(A, B, C, D)

0000...................Index 0
0010, 1000.............Index 1
1010, 0011, 1001.......Index 2
1110, 1011.............Index 3
1111...................Index 4

The necessary condition for combining two terms is that the indices of the two terms
must differ by one logic variable which must also be the same.

Example 1:

Consider the function: Z = f(A,B,C) = + C+A +A C

To make things easier, change the function into binary notation with index value and
decimal value.
Tabulate the index groups in a colunm and insert the decimal value alongside.

From the first list, we combine terms that differ by 1 digit only from one index group
to the next. These terms from the first list are then seperated into groups in the second
list. Note that the ticks are just there to show that one term has been combined with
another term. From the second list we can see that the expression is now reduced to: Z
= + + C+A

From the second list note that the term having an index of 0 can be combined with the
terms of index 1. Bear in mind that the dash indicates a missing variable
and must line up in order to get a third list. The final simplified expression is: Z =

Bear in mind that any unticked terms in any list must be included in the final
expression (none occured here except from the last list). Note that the only prime
implicant here is Z = .

The tabular method reduces the function to a set of prime implicants.

Note that the above solution can be derived algebracially. Attempt this in your notes.

Example 2:

Consider the function f(A, B, C, D) = (0,1,2,3,5,7,8,10,12,13,15), note that this is


in decimal form.

(0000,0001,0010,0011,0101,0111,1000,1010,1100,1101,1111) in binary form.

(0,1,1,2,2,3,1,2,2,3,4) in the index form.


The prime implicants are: + + D + BD + A + AB

The chart is used to remove redundant prime implicants. A grid is prepared having all
the prime implicants listed at the left and all the minterms of the function along the
top. Each minterm covered by a given prime implicant is marked in the appropriate
position.

From the above chart, BD is an essential prime implicant. It is the only prime
implicant that covers the minterm decimal 15 and it also includes 5, 7 and 13. is
also an essential prime implicant. It is the only prime implicant that covers the
minterm denoted by decimal 10 and it also includes the terms 0, 2 and 8. The other
minterms of the function are 1, 3 and 12. Minterm 1 is present in and D.
Similarly for minterm 3. We can therefore use either of these prime implicants for
these minterms. Minterm 12 is present in A and AB , so again either can be used.

Thus, one minimal solution is: Z = + BD + +A


Problems

1. Minimise the function below using the tabular method of simplification:


Z = f(A,B,C,D) = + C + A CD + A C + BCD + BC + CD
2. Using the tabular method of simplification, find all equally minimal solutions
for the function below.
Z = f(A,B,C,D) = (1,4,5,10,12,14)

Answere:

1. Consider the function: Z = f(A,B,C,D) = + C + A CD + A C


+ BCD + BC + CD

Convert to decimal and binary equivalents:-

Z = f(A,B,C,D) = (0,2,4,5,8,9,12) - decimal equivalent

Z = f(A,B,C,D) = (0000,0010,0100,0101,1000,1001,1100) - binary


equivalent

(0, 1, 1, 2, 1, 2, 2) - index values

The simplified answer is: Z = + B +A +


2.

Note that the remaining term 12 is covered by B and AB

One simplified answer is: Z = + AC + B


Another answer is: Z = + AC + AB

**************************************************

Using rules of inferences show that the following hypothesis- (p  q) r, r( s
 t ), s  u, u  t leads to the conclusion: p
how can relate nested quantifiers with nested loops. explain with example

THINKING OF QUANTIFICATION AS LOOPS

In working with nested quantifiers, it is sometimes helpful to think in terms of nested


loops, especially helpful in understanding of nested quantifiers.

To see if ∀x∀yP(x, y) is true, we loop the values for x, and for each x we loop through
the values for y. If we find P(x, y) is true for all values of x and y, we see that ∀x∀yP(x,
y) is true. If we ever see a value x for which we find a value y for which P(x, y) is false,
we have shown that ∀x∀yP(x, y) is false.

Similarly to determine whether ∀x∃yP(x, y) is true, we loop through the values for x.
For each x we loop through the values for y until we find a y for which P(x, y) is true.
If for every x we hit such a y, then ∀x∃yP(x, y) is true; if for some x we never hit such
a y, then ∀x∃yP(x, y) is false. ∃x∀yP(x, y), ∃x∃y P(x, y) can be checked by loops.

===============
Difference Between NFA and DFA
NFA vs DFA
The theory of computation is a branch of computer science that deals
with how problems are solved using algorithms. It has three branches,
namely; the computational complexity theory, the computability
theory, and the automaton theory.

The automaton or automata theory is the study of abstract


mathematical machines or systems that can be used to solve
computational problems. An automaton is made up of states and
transitions, and as it sees a symbol or letter of input, it makes a
transition to another state taking the current state and symbol as input.
The automaton or automata theory has several classes that include the
Deterministic Finite Automata (DFA) and the Nondeterministic Finite
Automata (NFA). These two classes are transition functions of
automata or automaton.

In transition, DFA cannot use n empty string, and it can be understood


as one machine. If the string ends at a state that is not an acceptable
state, DFA will reject it. A DFA machine can be constructed with every
input and output.

DFA only has one state transition for every symbol of the alphabet, and
there is only one final state for its transition which means that for each
character that is read, there is one corresponding state in DFA. It is
easier to check membership in DFA but it is more difficult to construct.
Backtracking is allowed in DFA, and it requires more space than NFA.

Backtracking is not always allowed in NFA. While it is possible in some


cases, in others it is not. It is easier to construct NFA, and it also requires
less space, but it is not possible to construct an NFA machine for every
input and output.

It is understood as several tiny machines that compute simultaneously,


and membership can be harder to check. It uses Empty String
Transition, and there are numerous possible next states for each pair of
state and input symbol. It starts at a specific state and reads the
symbols, and the automaton then determines the next state which
depends on the current input and other consequent events. At its
accepting state, NFA accepts the string and rejects it otherwise.

Summary:
1. “DFA” stands for “Deterministic Finite Automata” while “NFA”
stands for “Nondeterministic Finite Automata.”

2. Both are transition functions of automata. In DFA the next possible


state is distinctly set while in NFA each pair of state and input
symbol can have many possible next states.

3. NFA can use empty string transition while DFA cannot use empty
string transition.

4. NFA is easier to construct while it is more difficult to construct DFA.

5. Backtracking is allowed in DFA while in NFA it may or may not be


allowed.

6. DFA requires more space while NFA requires less space.

7. While DFA can be understood as one machine and a DFA machine


can be constructed for every input and output,

8. NFA can be understood as several little machines that compute


together, and there is no possibility of constructing an NFA machine
for every input and output.

Converting RE to FA
===========================
Define chomsky hierarchy of grammar with their respective mathematical model.
How can you convert a RE to grammar? Explain with example and drive a string
using the equivalent grammar

d
a young pair of rabbits is placed on an island. the pair of rabbit does not breed until
they are 2-month-old. after they are two-month-old, each pair

=============

construct a graph having degree sequences 2, 2, 2, 3, 3, 3, 4, 4, 5. also identify


number of edge and faces.

===============
if you do every problem in this book, then you will learn discrete mathematics. you
learn discrete mathematics. therefore you did problem in this book.

===============
==============