Q. Identify The Difference Between FSM and FSA. Describe Their Functional Workings, Characteristics and Applications
Q. Identify The Difference Between FSM and FSA. Describe Their Functional Workings, Characteristics and Applications
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 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:
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 = λ.
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.
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:
As noted above, we can represent a FA graphically, with nodes for states, and arcs for
transitions.
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.”
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.
▲
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.
Karnaugh Maps
Why Do You Need To Know About Karnaugh Maps?
Some Observations
Problems
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.
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.
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
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.
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.
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.
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.
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:
By now you should have inferred the rules for getting the sum-of-
products form from the Karnaugh map.
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?
*****************
An Logic Problem (3.1)
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:
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:
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.
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).
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
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
*********************
A Logic Problem (3.4)
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
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:
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.
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)
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 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 ( - ).
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.
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:
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 = .
Note that the above solution can be derived algebracially. Attempt this in your notes.
Example 2:
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.
Answere:
**************************************************
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
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.
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.
Summary:
1. “DFA” stands for “Deterministic Finite Automata” while “NFA”
stands for “Nondeterministic Finite Automata.”
3. NFA can use empty string transition while DFA cannot use empty
string transition.
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
=============
===============
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.
===============
==============