2. INTRODUCTION
Aim
Explore the theory of automata
Explicate finite state machine
Enlist the type of automata
Objective
Examine defining languages
Introduce Deterministic finite automata (DFA)
Elucidate Non-deterministic finite automata (NDFA)
Outcome
Recognize finite automata model
Identify types of automata
Compare DFA and NDFA
3. INTRODUCTION
Theory of automata is a branch of computer science and based on mathematical
computations. These computations are used to represent various models/abstract
machines and the computation problems that can be solved using these machines.
The abstract machine is called the Automata.
The main motivation behind developing the automata theory was to develop
methods to describe and analyze the dynamic behavior of discrete systems.
4. HISTORY OFTOC
1936 Alan Turing invented Turing Machine and proved that there exist unsolvable
problem.
1940 stored program computers were built.
1943 McCulloch and Pitts invented Finite Automata.
1956 Kleene invented Regular Expression and proved equivalence of RE and FA.
1956 Chomsky defined hierarchy, which organized languages recognized by different
FA.
1959 Rabin and Scott introduced NDFA and proved NDFA is equivalent to DFA.
5. DEFINING LANGUAGE
There are the basic terminologies that are important and frequently used in automata:
Symbols:
Symbols are an entity or individual objects, which can be any letter, alphabet or any picture.
Example: 1, a, b, #
Alphabets:
Alphabets are a finite non-empty set of symbols. It is denoted by ∑.
Examples:
∑ = {a, b} ∑ = {A, B, C, D}
∑ = {0, 1, 2} ∑ = {0, 1, ....., 5}
∑ = {#, , }
β Δ
6. Powers of Σ
Σ is the set of a and b, i.e. Σ={a,b}
Σ0
is the set of all string of length 0, i.e. Σ0
={ }
Ԑ
Number of strings, |Σ|0
=0
Σ1
is the set of all string of length 1, i.e. Σ1
={a,b}
Number of strings, |Σ|1
=2
Σ2 is the set of all string of length 2, i.e. Σ2 ={aa,ab,ba,bb}
Number of strings, |Σ|2
=4
Σn
is the set of all string of length n, i.e. Σn
={aa,ab,aba,bbbb,…………}
Number of strings, |Σ|n
=2n
Similarly
Σ*=Σ1
UΣ2
UΣ3
U…….U Σ n
=
set of all strings over Σ
7. DEFINING LANGUAGE
String
It is a finite collection of symbols from the alphabet (∑).The string is denoted by w.
Example 1:
If ∑ = {a, b}, various string that can be generated from ∑ are {ab, aa, aaa, bb, bbb, ba, aba.....}.
A string with zero occurrences of symbols is known as an empty string. It is represented by ε
(epsilon).
The number of symbols in a string w is called the length of a string. It is denoted by |w|.
Example 2:
w = 010
Length of String w is,|w| = 3
8. OPERATIONS ON STRING
Concatenation Operation
Concatenation, is the addition of 2 strings together, where order matters. For example,
“artificial” + “intelligence” = “artificialintelligence”.
Given:
Concatenation is denoted by:
Note that:
For every string w:
9. Exponent Operation
For every string w: w =
⁰ ϵ
For all exponents n>0:
w =w ¹ w
ⁿ ⁿ⁻ ⋅
For example:
If w=”go”, then:
w = =””
⁰ ϵ
w¹=w=”go”
w²=w*w=”gogo”
w³=w*w*w=”gogogo”
10. Reversal Operation
If w is a string, then reverse of w is:
Palindrome is defined by:
Here we mean words like “ana”,“anna”,“racecar” etc.
11. Substring Set, or String Subset
If w is a string, then a substring of w is a sequence formed by taking a
contiguous symbols of w in the order in which they occur in w.
is a substring of w if and only if there are 2 other substring such that
Also w₁ and wᵣ may be empty strings. These two substring are special cases
of substrings called, prefix and suffix.
12. Language:
A language is a collection of appropriate string. A language which is formed over Σ can
be Finite or Infinite.
Example: 1
L1 = {Set of string of length 2} = {aa, bb, ba, bb} Finite Language
Example: 2
L2 = {Set of all strings starts with 'a'} = {a, aa, aaa, abb, abbb, ababb} Infinite Language
If w is a string, then wn
stands for string obtained by repeating w, n times, w0
=Ԑ (empty)
Σ* is the set of strings obtained by concatenating zero or more symbols from Σ
Σ+
= Σ*-{Ԑ or λ}
A language is a subset of Σ*
13. OPERATIONS ON LANGUAGE
Language is a collection of strings. Hence, the operations that can be
carried out on strings are the operations to be applied over language.
If L1 and L2 are two languages than:
Union of two languages is denoted as L1UL2
Concatenation of two languages is denoted as L1.L2
Intersection of two languages is denoted as L1ՈL2
Difference of two languages is denoted as L1-L2
Complement of a language L is L’=Σ*-L
Reverse of a language L is LR
={wR
:wϵL}
Star Closure L*=L0
UL1
UL2
U……
Positive Closure L+
=L1
UL2
U……..
14. FORMAL LANGUAGE
In automata theory, a formal language is a set of strings of symbols
drawn from a finite alphabet.
A formal language can be specified either by a set of rules (such as
regular expressions or a context-free grammar) that generates the
language, or by a formal machine that accepts (recognizes) the language.
15. REGULAR LANGUAGE
A regular language is a language that can be expressed with a regular
expression or a deterministic or non-deterministic finite automata or
state machine.
A language is a set of strings which are made up of characters from a
specified alphabet, or set of symbols.
16. A regular language is a formal language that satisfies the following properties:
It can be accepted by a DFA and NFA.
It can be described by a regular expression.
It can be generated by a regular grammar.
It can be accepted by a read-only Turing Machine.
REGULAR LANGUAGE
Regular
Language
Represented by Regular
Expression
Generated by
regular grammar
Accepted by
finite automata
RLG LLG With
output
Without
output
17. CHOMSKY HIERARCHY
Chomsky Hierarchy represents the class of languages that are accepted by the different machine.
The Chomsky hierarchy is a containment hierarchy of classes of formal grammar, as described by
Noam Chomsky in 1956.
It is an essential tool used in formal language theory, computer science, and linguistics.
The category of language in
Chomsky's Hierarchy is as shown:
18. TYPE 0 : UNRESTRICTED GRAMMAR
Language recognized by Turing Machine is known as Type 0 Grammar.
They are also known as Recursively Enumerable Languages.
Grammar Production for Type 0 is given by
α —> β
For Example:
Sba —> a
S —> B
Where S and B are Variables and a and b are Terminals.
19. TYPE 1: CONTEXT-SENSITIVE GRAMMAR
Languages recognized by Linear Bound Automata are known as Type 1 Grammar.
Context-sensitive grammar represents context-sensitive languages.
For grammar to be context-sensitive, it must be unrestricted. Grammar Production
for Type 1 is given by
—>
α β
(ensuring count symbol in LHS must be less than or equal to RHS)
For Example,
S —> BA
BA —> bca
B —> b
20. TYPE 2: CONTEXT
-FREE GRAMMAR
Languages recognized by Pushdown Automata are known as Type 2 Grammar.
Context-free grammar represents context-free languages.
For grammar to be context-free, it must be context-sensitive. Grammar Production for
Type 2 is given by
A —> α
Where A is a single non-terminal.
For Example,
A —> aB
B —> b
21. TYPE 3: REGULAR GRAMMAR
Type 3 Grammar is known as Regular Grammar.
Regular languages are those languages which can be described using regular expressions.
These languages can be modeled by NFA or DFA.
Type 3 is most restricted form of grammar.TheType 3 grammar should beType 2 and Type 1.
Type 3 should be in the form of
V T*V / T
→
For example:
A xy
→
22. FINITE STATE MACHINE
The finite state system represents a mathematical model of a system with certain input.The model finally
gives certain output. The input, when given to machine, is processed by various states, these states are
called intermediate state.
The very good example of FSM is control mechanism of elevator. The system only remembers the
current floor number pressed. It does not remember all the floor numbers previously pressed.
Another example of FSM is traffic light, it only need to remember the next state (color).
23. SIMPLIFIED NOTATIONS
The presentation by which a finite automaton can be represented are:
Transition equations
State transition graph or Transition Diagram
Transition Table
24. TRANSITION EQUATIONS
A finite automaton can be represented with the help of transition equations. For each
transition there exists a transition equation . For example, consider a finite automaton
M defined as :
M=({q1,q2,q3},{0,1},δ,q1,{q3}) is a FA, where δ is given by
δ(q1,0)=q2, δ(q1,1)=q1
δ(q2,0)= q3, δ(q2,1)=φ
δ(q3,0)=q2, δ(q3,1)= q3
25. TRANSITION DIAGRAM
A transition diagram or state transition diagram is a
directed graph which can be constructed as follows:
There is a node for each state in Q, which is
represented by the circle.
There is a directed edge from node q to node
p labeled a if (q, a) = p.
δ
In the start state, there is an arrow with
no source.
Accepting states or final states are
indicating by a double circle.
Some Notations that are used in the
transition diagram:
26. TRANSITION DIAGRAM
Example 1:
DFA with ∑ = {0, 1} accepts all strings starting with 1.
Solution:
Example 2:
NFA with ∑ = {0, 1} accepts all strings starting with 1.
Solution:
27. TRANSITIONTABLE
The transition table is basically a tabular representation of the transition function. It takes
two arguments (a state and a symbol) and returns a state (the "next state").
A transition table is represented by the following things:
Columns correspond to input symbols.
Rows correspond to states.
Entries correspond to the next state.
The start state is denoted by an arrow with no source.
The accept state is denoted by a star.
28. Example 1:
Solution:
Transition table of given DFA is as follows:
Present State Next state for Input 0 Next State of Input 1
→q0 q1 q2
q1 q0 q2
*q2 q2 q2
29. Example 2:
Solution:
Transition table of given DFA is as follows:
Present State Next state for Input 0 Next State of Input 1
→q0 q0 q1
q1 q1, q2 q2
q2 q1 q3
*q3 q2 q2
30. ADVANTAGES OF AUTOMATA
• Industrial productivity has improved due to automation, which has speed up
product manufacturing.
• The items now have better quality and uniformity. Better and devoid of any
production flaws, products have improved.
• Both labour costs and manufacturing process consistency have decreased as a
result.
• It has shortened operational cycle times and increased precision and consistency
in processes requiring repetitive and complex manual work.
• In hazardous workplaces, including nuclear power plants, corrosive conditions, and
hazardous material handling, automated robotics have taken. the role of people.
• Reducing the workforce needed for repetitive tasks has freed up workers who can
now work in administration and upkeep roles for automated systems.
31. DIS-ADVANTAGES OF AUTOMATA
• Automation has drawbacks because malfunctioning automated systems can expose
systems to security risks and hacking, which can ultimately cause them to collapse.
• High development and maintenance expenses are associated with automation.
Additionally, integrating robots and automated systems into current frameworks is
costly.
• Automated systems are not fully autonomous and cannot make complicated logical
conclusions that are not predetermined by their programming.
32. FINITE AUTOMATA
Finite automata are used to recognize patterns.
It takes the string of symbol as input and changes its state accordingly.
At the time of transition, the automata can either move to the next state or stay in
the same state.
Finite automata have two states, Accept state or Reject state. When the input
string is processed successfully, and the automata reached its final state, then it will
accept.
33. FORMAL DEFINITION OF FINITE
AUTOMATA
A finite automaton is a collection of 5-tuple (Q, ∑, , q0, F), where:
δ
Q: finite set of states
∑: finite set of the input symbol
: Transition function
δ
q0: initial state
F: final state
34. FINITE AUTOMATA MODEL
Finite automata can be represented by input tape and finite control.
Input tape: It is a linear tape having some number of cells. Each input symbol is
placed in each cell.
Finite control: The finite control decides the next state on receiving particular
input from input tape.The tape reader reads the cells one by one from left to right,
and at a time only one input symbol is read.
35. TYPES OF FINITE AUTOMATA
Finite Automata without output
Deterministic Finite Automata (DFA)
Non-deterministic Finite Automata (NDFA)
Epsilon Non-deterministic Finite Automata (ϵ-NFA)
Finite Automata with output
Moore Machine
Mealy Machine
36. DETERMINISTIC FINITE AUTOMATA
(DFA)
DFA refers to deterministic finite automata. Deterministic refers to the uniqueness of
the computation. The finite automata are called deterministic finite automata if the
machine has a unique transition for an input symbol at a time.
In DFA, there is only one path for specific input from the current state to the next
state.
DFA does not accept the null move, i.e., the DFA cannot change state without any
input character.
DFA can contain multiple final states. It is used in Lexical Analysis in Compiler.
37. FORMAL DEFINITION OF DFA
A DFA is a collection of 5-tuples same as we described in the definition of FA.
Q: finite set of states
∑: finite set of the input symbol
q0: initial state
F: final state
: Transition function
δ
Transition function can be defined as: :
δ Q x ∑ Q
→
Graphical Representation of DFA
A DFA can be represented by digraphs called state diagram. In which:
The state is represented by vertices.
The arc labeled with an input character show the transitions.
The initial state is marked with an arrow.
The final state is denoted by a double circle.
38. Example 1:
Q = {q0, q1, q2}
∑ = {0, 1}
q0 = {q0}
F = {q2}
Solution:
Transition Diagram:
TransitionTable: Present State Next state for Input 0 Next State of Input 1
→q0 q0 q1
q1 q2 q1
*q2 q2 q2
39. Example 2:
DFA with ∑ = {0, 1} accepts all starting with 0.
Solution:
Explanation:
In the above diagram, we can see that on given 0 as input to DFA in state q0 the DFA changes state to q1 and always go
to final state q1 on starting input 0. It can accept 00, 01, 000, 001....etc. It can't accept any string which starts with 1,
because it will never go to final state on a string starting with 1.
Example 3:
DFA with ∑ = {0, 1} accepts all ending with 0.
Solution:
Explanation:
In the above diagram, we can see that on given 0 as input to DFA in state q0, the DFA changes state to q1. It can accept
any string which ends with 0 like 00, 10, 110, 100....etc. It can't accept any string which ends with 1, because it will never
go to the final state q1 on 1 input, so the string ending with 1, will not be accepted or will be rejected.
40. EXERCISE:
Design a DFA with ∑ = {0, 1} accepts those string which starts with 1 and ends with 0.
Design a DFA with ∑ = {0, 1} accepts the only input 101.
Design DFA with ∑ = {0, 1} accepts even number of 0's and even number of 1's.
Design DFA with ∑ = {0, 1} accepts the set of all strings with three consecutive 0's.
Design a DFA L(M) = {w | w {0, 1}*} andW is a string that does not contain consecutive 1's.
ε
Design a DFA with ∑ = {0, 1} accepts the strings with an even number of 0's followed by single 1.
Design a DFA that accepts set of all strings over {a,b} of length at least 2.
Design a DFA that accepts set of all strings over {a,b} of length 2.
Design a DFA that accepts set of all strings over {a,b} of length at most 2.
41. NON-DETERMINISTIC FINITE AUTOMATA (NDFA)
NFA stands for non-deterministic finite automata. It is easy to
construct an NFA than DFA for a given regular language.
The finite automata are called NFA when there exist many
paths for specific input from the current state to the next
state.
Every NFA is not DFA, but each NFA can be translated into DFA.
NFA is defined in the same way as DFA but with the following
two exceptions, it contains multiple next states, and it contains
ε transition.
42. FORMAL DEFINITION OF NDFA
A NDFA is a collection of 5-tuples same as we described in the definition of FA.
Q: finite set of states
∑: finite set of the input symbol
q0: initial state
F: final state
: Transition function
δ
Transition function can be defined as: :
δ Q x ∑ 2
→ Q
43. Example 1:
Q = {q0, q1, q2}
∑ = {0, 1}
q0 = {q0}
F = {q2}
Solution:
Transition Diagram:
TransitionTable:
Present State Next state for Input 0 Next State of Input 1
→q0 q0, q1 q1
q1 q2 q0
*q2 q2 q1, q2
44. Example 2:
NFA with ∑ = {0, 1} accepts all strings starting with 01.
Solution:
Transition Diagram:
TransitionTable:
Present State Next state for Input 0 Next State of Input 1
→q0 q1 ε
q1 ε q2
*q2 q2 q2
45. Example 3:
NFA with ∑ = {0, 1} and accept all string of length exactly 2.
Solution:
Transition Diagram:
TransitionTable:
Present State Next state for Input 0 Next State of Input 1
→q0 q1 q1
q1 q2 q2
*q2 ε ε
46. EXERCISE
Design an NFA with ∑ = {0, 1} accepts all string ending with 01.
Design an NFA with ∑ = {0, 1} in which double '1' is followed by double '0'.
Design an NFA in which all the string contain a substring 1110.
Design an NFA with ∑ = {0, 1} accepts all string in which the third symbol from the
right end is always 0.
Design a NFA for the transition table as given below:
Present State 0 1
→q0 q0, q1 q0, q2
q1 q3 ε
q2 q2, q3 q3
→q3 q3 q3
47. EPSILON NON-DETERMINISTIC FINITE AUTOMATA (Ε-NDFA)
The class of NFA is extended by allowing the following instantaneous(ϵ,^) transitions:
The automata may be allowed to change its state without reading the input symbol.
In diagrams, such transitions are depicted by labeling the appropriate arcs with ϵ.
NOTE: Note that this does not mean that has become an input symbol. On the contrary, we assume
ε
that the symbol does not belong to any alphabet.
ε
Fig: -
ε NFA accepting the language {ϵ, a, aa, ab, abb, b, bbb, .........}
48. FORMAL DEFINITION OF Ε-NFA
A ϵ-NFA is a collection of 5-tuples same as we described in the definition of FA.
Q: finite set of states
∑: finite set of the input symbol
q0: initial state
F: final state
: Transition function
δ
Transition function can be defined as: :
δ Q x ∑ U {ϵ } 2
→ Q
49. Example 1:
{ an
| n is even or divisible by 3 }
Transition Diagram:
TransitionTable:
Present State Next state for Input ϵ Next State of Input a
→P Q,R -
Q - Q1
R - R1
Q1 - Q
R1 - R2
R2 - R
50. Ε-CLOSURE
ϵ-Closure of a state
The ϵ-Closure of a state denoted by ϵ-Closure(q) or ECLOSE(q), is the set that
contains q, along with all other states that can be reached starting at q and following
only ϵ-transitions.
In the given transition diagram
ECLOSE(P)={P,Q,R,S}
ECLOSE(Q)={Q}
ECLOSE(R)={R,S}
ECLOSE(Q1)={Q1}
ECLOSE(R1)={R1}
ECLOSE(R2)={R2}
ECLOSE(S)={S}
51. ELIMINATION OF Ε-TRANSITIONS
Given an ϵ-NFA N, this construction produces and NFA N’ such that L(N)=L(N’)
The construction of N’ begins with N as input, and takes 3 steps:
Make P an accepting state of N’ iff ECLOSE(P) contains an accepting state of N.
Add an arc from p to q labeled a iff there is an arc labeled a in N from some state ECLOSE(p) to q.
Delete all arcs labeled ϵ.
54. CONVERSION FROM NFATO DFA
Let, M = (Q, ∑, , q0, F) is an NFA which accepts the language L(M).There should be equivalent DFA
δ
denoted by M' = (Q', ∑', q0', ', F') such that L(M) = L(M').
δ
Steps for converting NFA to DFA:
Step 1: Initially Q' = ϕ
Step 2: Add q0 of NFA to Q'.Then find the transitions from this start state.
Step 3: In Q', find the possible set of states for each input symbol. If this set of states is not in Q', then
add it to Q'.
Step 4: In DFA, the final state will be all the states which contain F(final states of NFA)
55. Example 1: Convert the given NFA to DFA.
Now we will obtain '
δ transition for state q0.
'([
δ q0], 0) = [q0]
'([
δ q0], 1) = [q1]
The '
δ transition for state q1 is obtained as:
'([
δ q1], 0) = [q1, q2] (new state generated)
'([
δ q1], 1) = [q1]
The '
δ transition for state q2 is obtained as:
'([
δ q2], 0) = [q2]
'([
δ q2], 1) = [q1, q2]
Now we will obtain '
δ transition on [q1, q2].
'([
δ q1, q2], 0) = (
δ q1, 0) ∪ (
δ q2, 0)
= {q1, q2} {q2}
∪
= [q1, q2]
'([
δ q1, q2], 1) = (
δ q1, 1) ∪ (
δ q2, 1)
= {q1} {q1, q2}
∪
= {q1, q2}
= [q1, q2]
State 0 1
→[q0] [q0] [q1]
[q1] [q1, q2] [q1]
*[q2] [q2] [q1, q2]
56. The state [q1, q2] is the final state as well because it contains a final state q2.The transition table for the
constructed DFA will be:
The Transition diagram will be:
The state q2 can be eliminated because q2 is an unreachable state.
State 0 1
→[q0] [q0] [q1]
[q1] [q1,q2] [q1]
[q1,q2] [q1,q2] [q1,q2]
57. Exercise:
1. Convert the given NFA to DFA.
2. Convert the NFA with into its equivalent DFA.
ε
3. Convert the given -NFA into its equivalent DFA.
ε
58. MINIMIZATION DFA (METHOD 1)
Minimization of DFA means reducing the number of states from given FA.Thus, we
get the FSM(finite state machine) without redundant states after minimizing the FSM.
We have to follow the various steps to minimize the DFA.These are as follows:
Step 1: Remove all the states that are unreachable from the initial state via any set
of the transition of DFA.
Step 2: Draw the transition table for all pair of states.
Step 3: Now split the transition table into two tables T1 and T2.T1 contains all final
states, and T2 contains non-final states.
59. MINIMIZATION DFA (METHOD 1)
Step 4: Find similar rows from T1 such that:
1. (q, a) = p
δ
2. (r, a) = p
δ
That means, find the two states which have the same value of a and b and remove one
of them.
Step 5: Repeat step 3 until we find no similar rows available in the transition table T1.
Step 6: Repeat step 3 and step 4 for table T2 also.
Step 7: Now combine the reduced T1 and T2 tables.The combined transition table is
60. EXAMPLE:
Solution:
Step 1: In the given DFA, q2 and q4 are the unreachable states so remove them.
Step 2: Draw the transition table for the rest of the states.
Step 3: Now divide rows of transition table into two sets as:
1. One set contains those rows, which start from non-final states:
2.Another set contains those rows, which starts from final states.
Step 1 Step 2 Step 3
State 0 1
→q0 q1 q3
q1 q0 q3
*q3 q5 q5
*q5 q5 q5
State 0 1
q0 q1 q3
q1 q0 q3
State 0 1
q3 q5 q5
q5 q5 q5
61. Step 4: Set 1 has no similar rows so set 1 will be the same.
Step 5: In set 2, row 1 and row 2 are similar since q3 and q5 transit to the same state on 0 and 1. So skip q5 and then
replace q5 by q3 in the rest.
Step 6: Now combine set 1 and set 2 as: Now it is the transition table of minimized DFA.
State 0 1
*q3 q3 q3
State 0 1
→q0 q1 q3
q1 q0 q3
*q3 q3 q3
62. MINIMIZATION DFA (METHOD 2)
The two states p and q are equivalent:
if (p,w)
δ ϵ F and (q,w)
δ ϵ F
OR
if (p,w)
δ ∉ F and (q,w)
δ ∉ F
If |w|=0, then p and q are 0 equivalent
If |w|=1, then p and q are 1 equivalent
63. MINIMIZATION DFA (METHOD 2)
The steps to minimize the DFA.
Step 1: Create a set π0 as π0 = {Q1
0
,Q2
0
} , Q1
0
is the set of all final states and Q2
0
=Q- Q1
0
where Q is
the set of all states in DFA.
Step 2: Now we will construct πk+1 from πk. Let Qi
k
be any subset in πk . If q1 and q2 are in Qi
k
they are
(k+1) equivalent provided (q1,a) and (q2,a) are k equivalent. Find out whether (q1,a) and
δ δ δ
(q2,a) are residing in the same equivalent class
δ πk then it is said that q1 and q2 are (k+1) equivalent.
Thus Qi
k
are further divided into (k+1) equivalent classes. Repeat step 2 for every Qi
k
in πk and obtain
all the elements of πk+1
Step 3: Construct πn for n=1,2,…,n untill πn+1= πn
Step 4: Replace all the equivalent states in one equivalent class by representative state.
64. EXAMPLE:
Minimize the given DFA
Solution:
Step-01:
State q5 is inaccessible from the initial state. So, we eliminate it and its associated edges from the DFA.
The resulting DFA is-
65. Step-02:
Draw a state transition table-
Step-03:
Now using Equivalence Theorem/subset construction
method, we have-
π0 = { q0 , q1 , q2 } { q3 , q4 }
π1 = { q0 } { q1 , q2 } { q3 , q4 }
π2 = { q0 } { q1 , q2 } { q3 , q4 }
Since π2 = π1 , so we stop.
From π2 , we infer-
States (q1 and q2) & (q3 and q4) are equivalent and can be merged together.
So, Our minimal DFA is-
0 1
→q0
q1 q2
q1 q2 *q3
q2 q2 *q4
*q3 *q3 *q3
*q4 *q4 *q4
67. FINITE AUTOMATA WITH OUTPUT : MOORE MACHINE
Moore machine is a finite state machine in which the next state is decided by the current state and
current input symbol. The output symbol at a given time depends only on the present state of the
machine.
Moore machine can be described by 6 tuples M=(Q, q0, ∑, O, , ) where,
δ λ
Q: finite set of states
q0: initial state of machine
∑: finite set of input symbols
O: output alphabet
: transition function where Q × ∑ Q
δ →
: output function where Q O
λ →
68. Example: The state diagram for Moore Machine is
Transition table for Moore Machine is:
In the above Moore machine, the output is represented with each input state separated by /.The output length for a
Moore machine is greater than input by 1.
Input: 010
Transition: (q0,0) => (q1,1) => (q1,0) => q2
δ δ δ
Output: 1110(1 for q0, 1 for q1, again 1 for q1, 0 for q2)
69. Example:
Design a Moore machine to generate 1's complement of a given binary number.
Solution: To generate 1's complement of a given binary number the simple logic is that if the input is
0 then the output will be 1 and if the input is 1 then the output will be 0.That means there are three
states. One state is start state.The second state is for taking 0's as input and produces output as 1.
The third state is for taking 1's as input and producing output as 0.
Example:
Construct a Moore machine that determines whether an input string contains an even or odd number
of 1's.The machine should give 1 as output if an even number of 1's are in the string and 0 otherwise.
70. MEALY MACHINE
A Mealy machine is a machine in which output symbol depends upon the present input symbol and
present state of the machine. In the Mealy machine, the output is represented with each input symbol
for each state separated by /.
The Mealy machine can be described by 6 tuples (Q, q0, ∑, O, , ') where
δ λ
Q: finite set of states
q0: initial state of machine
∑: finite set of input alphabet
O: output alphabet
: transition function where Q × ∑ Q
δ →
': output function where Q × ∑ O
λ →
71. Example:
Design a Mealy machine for a binary input sequence such that if it has a substring 101, the machine
output A, if the input has substring 110, it outputs B otherwise it outputs C.
The partial diagram will be:
Now we will insert the possibilities of 0's and 1's for each state.Thus the Mealy machine becomes:
72. Example:
Design a mealy machine that scans sequence of input of 0 and 1 and generates output 'A' if the
input string terminates in 00, output 'B' if the string terminates in 11, and output 'C' otherwise.
The Mealy Machine will be:
73. CONVERSION FROM MEALY MACHINETO MOORE
MACHINE
To convert Moore machine to Mealy machine, state output symbols are distributed to input symbol paths. But
while converting the Mealy machine to Moore machine, we will create a separate state for every new output
symbol and according to incoming and outgoing edges are distributed.
The following steps are used for converting Mealy machine to the Moore machine:
Step 1: For each state(Qi), calculate the number of different outputs that are available in the transition table of
the Mealy machine.
Step 2: Copy state Qi, if all the outputs of Qi are the same. Break Qi into n states as Qin, if it has n distinct
outputs where n = 0, 1, 2....
Step 3: If the output of initial state is 1, insert a new initial state at the starting which gives 0 output.
74. Example:
Convert the following Mealy machine into
equivalent Moore machine.
Solution:
Transition table for above Mealy machine is as follows:
The state q1 has only one output.The state q2 and q3 have both output 0 and 1. So we will create two states for these
states. For q2, two states will be q20(with output 0) and q21(with output 1). Similarly, for q3 two states will be q30(with
output 0) and q31(with output 1).
75. Transition table for Moore machine will be:
Transition diagram for Moore machine will be:
76. CONVERSION FROM MOORE MACHINETO MEALY
MACHINE
To convert Moore machine to Mealy machine, state output symbols are
distributed into input symbol paths.We are going to use the following method to
convert the Moore machine to Mealy machine.
Method for conversion of Moore machine to Mealy machine
Let M = (Q, ∑, , , q0) be a Moore machine.The equivalent Mealy machine can
δ λ
be represented by M' = (Q, ∑, , ', q0).The output function ' can be obtained
δ λ λ
as:
' (q, a) = ( (q, a))
λ λ δ
77. Example:
Convert the following Moore machine into its equivalent Mealy machine.
Solution:
The transition table of given Moore machine is as follows:
The equivalent Mealy machine can be obtained as follows:
' (q0, a) = ( (q0, a)) = (q0) = 0
λ λ δ λ
' (q0, b) = ( (q0, b)) = (q1) = 1
λ λ δ λ
The for state q1 is as follows:
λ
' (q1, a) = ( (q1, a)) = (q0) = 0
λ λ δ λ
' (q1, b) = ( (q1, b)) = (q1) = 1
λ λ δ λ
Q a b Output( )
λ
q0 q0 q1 0
q1 q0 q1 1
78. Hence the transition table for the Mealy machine can be drawn as follows:
The equivalent Mealy machine will be,
79. Exercise
1. Design a Mealy machine that print’s 1’s complement of an input string.
2. Design a Mealy machine that print’s 2’s complement of an input string.
3. Design a Mealy machine that recognizes the double occurrence of symbol ‘a’ in the
given input string over {a,b}.
4. Construct a Moore machine that takes binary number as input and produces residue
modulo ‘3’ as output.
5. Construct a Moore machine that takes set of all strings over {a,b} as input and prints
‘1’ as output for every occurrence of ‘ab’ as a substring.