0% found this document useful (0 votes)
5 views151 pages

TOA Unit-I Introduction to Automata

The document outlines the Theory of Automata course, focusing on finite automata, including definitions, properties, and examples of acceptability of strings. It distinguishes between deterministic and nondeterministic finite automata, detailing their differences and providing design problems for various automata. The course aims to provide a foundational understanding of automata and formal languages.

Uploaded by

mohd001umar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views151 pages

TOA Unit-I Introduction to Automata

The document outlines the Theory of Automata course, focusing on finite automata, including definitions, properties, and examples of acceptability of strings. It distinguishes between deterministic and nondeterministic finite automata, detailing their differences and providing design problems for various automata. The course aims to provide a foundational understanding of automata and formal languages.

Uploaded by

mohd001umar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 151

Theory of Automata (BCS-402)

2nd year (Semester – IV)


Unit – I

Anil Singh
Asst. Prof.
CSE Dept.
UIT, Prayagraj
Course Outcome (CO)

Theory of Automata & Formal Languages,


2
BCS-402
Unit - I

Theory of Automata & Formal Languages,


3
BCS-402
Introduction
• An automaton is an abstract model of a digital
computer with discrete inputs and outputs.
• It will be assumed that the input is a string
over a given alphabet, written on an input file
which the automaton can read but not
change.
• The input mechanism can read the input file
left to right one symbol at a time.

Theory of Automata & Formal Languages,


4
BCS-402
Introduction
• The internal state of control unit at the next
time step is determined by next step or
transition function.
• The transition function gives the next state in
terms of current state and the current input
symbol.
• The automaton produce output in some form.

Theory of Automata & Formal Languages,


5
BCS-402
Finite Automata
• A finite automata (FA) consists of a finite set of
states and a set of transitions from state to state
that occur on input symbols chosen from an
alphabet Σ.
• For each input symbol there is exactly one
transition out of each state.
• The initial state q0 is the state in which the
automaton starts.
• Some states are designated as final or accepting
states.
Theory of Automata & Formal Languages,
6
BCS-402
Finite Automata
• Mathematical Definition:
– A finite automaton M=(Q, Σ, δ, q0, F) is a collection
of following five things:
• Q is a finite set of states.
• It has an initial state or start state, i.e., q0ϵQ.
• It have some (may be none) final states, i.e., F⊆Q.
• An alphabet Σ of possible input letters.
• A finite set of transition that tells for each state and for
each letter of input alphabet which state to go to the
next, i.e., δ: Q× Σ→Q where δ is a transition function.
Theory of Automata & Formal Languages,
7
BCS-402
Finite Automata
• Note:
– An automaton which gives the output ‘yes’ or ‘no’
is known as acceptor.
– Also, a more general automaton, which is capable
of producing strings of symbols as output, is called
a transducer.

Theory of Automata & Formal Languages,


8
BCS-402
Transition Diagram
• A finite automata is represented by a transition
diagram or transition graphs in which each state
is represented by a small circle and directed
edges represent transitions.
• The label in the circles are names of the states
while names on the edges are current value of
the input symbol.
• The initial state will be identified by incoming
unlabelled arrow not outgoing at any circle.
• Final state is drawn with double circle.
Theory of Automata & Formal Languages,
9
BCS-402
Transition Diagram
• A transition system accepts a string w in Σ* if
– there exists a path which originates from some initial
state goes along the arrow and terminates at some
final state and
– the path value obtained by concatenation of all edge
labels of the path is equal to w.
• A transition system need not be a finite
automaton.
• A transition system may contain more than one
initial state.

Theory of Automata & Formal Languages,


10
BCS-402
Properties of Transition Functions
• Property 1:
– δ(q,Ʌ) = q is a finite automaton.
• Property 2:
– For all strings w and input symbol a
• δ(q,aw) = δ(δ(q,a),w)
• δ(q,wa) = δ(δ(q,w),a)

Theory of Automata & Formal Languages,


11
BCS-402
Acceptability of a string by a Finite
Automata
• Example 1:
• Let us consider a finite automata whose transition
function δ is given in the form of a transition table.
• M=({q0, q1, q2}, {a, b}, δ, q0, {q2})
• Check whether the string aaab is acceptable or not.
Inputs
States
a b
→q0 q1 q2
q1 q0 q2
q2* q2 q2
Theory of Automata & Formal Languages,
12
BCS-402
Acceptability of a string by a Finite
Automata
• Solution:
• Transition diagram:

Theory of Automata & Formal Languages,


13
BCS-402
Acceptability of a string by a Finite
Automata
δ(q0,aaab) = δ(q1,aab)
= δ(q0,ab)
= δ(q1,b)
= δ(q2,Ʌ)
= q2 (Final state)
So aaab is accepted.

Theory of Automata & Formal Languages,


14
BCS-402
Acceptability of a string by a Finite
Automata
• Example 2:
• Check whether the string 110101 is
acceptable or not by the following transition
diagram

Theory of Automata & Formal Languages,


15
BCS-402
Acceptability of a string by a Finite
Automata
• Solution:
• Transition table:
Inputs
States
0 1
→q0* q2 q1
q1 q3 q0
q2 q0 q3
q3 q1 q2

Theory of Automata & Formal Languages,


16
BCS-402
Acceptability of a string by a Finite
Automata
• Consider the binary string 110101
δ(q0,110101) = δ(q1,10101)
= δ(q0,0101)
= δ(q2,101)
= δ(q3,01)
= δ(q1,1)
= q0 which is the final state
Thus the above transition diagram accept all
binary strings which contains even no. of 1’s and
even no. of 0’s.
Theory of Automata & Formal Languages,
17
BCS-402
Acceptability of a string by a Finite
Automata
• Example 3:
Show that the string baababaab Є L(M),
where one of the non-deterministic finite
automaton state diagram is shown below:

Theory of Automata & Formal Languages,


18
BCS-402
Acceptability of a string by a Finite
Automata
• Solution:
• State transition table
Inputs
States
a b
→q0 q0,q1 q0,q1
q1 q3 q2
q2 q4 Ø
q3 Ø q4
q4* q4 q4

Theory of Automata & Formal Languages,


19
BCS-402
Acceptability of a string by a Finite
Automata
• Now check for string acceptivity
δ(q0,baababaab) = δ(q0,aababaab)
= δ(q1,ababaab)
= δ(q3,babaab)
= δ(q4,abaab)
= δ(q4,baab)
= δ(q4,aab)
= δ(q4,ab)
= δ(q4,b)
= δ(q4,Ʌ)
= q4 which is the final state
Hence the string is acceptable.

Theory of Automata & Formal Languages,


20
BCS-402
Deterministic and Nondeterministic
Finite Automata
• A deterministic automata is one in which each
move is uniquely determined by the current
configuration. If internal state, the input and the
contents of temporary storage are known then
future can be predicted easily and exactly.
• On the other hand, a non-deterministic
automaton may have several possible moves,
therefore, we can only predict a set of possible
solutions.
Theory of Automata & Formal Languages,
21
BCS-402
Deterministic Finite Automata (DFA)
• A deterministic finite automata (DFA) is
defined by M=(Q, Σ, δ, q0, F) where
– Q is a finite set of internal state
– Σ is a finite set of symbols (input alphabets)
– δ: Q× Σ→Q is a transition function
– q0ϵQ is the initial state
– F⊆Q is the final state

Theory of Automata & Formal Languages,


22
BCS-402
Non-Deterministic Finite Automata
(NFA)
• Nondeterministic means a choice of moves for an
automaton rather than a unique move in each
situation we allow a set of possible moves.
• A non-deterministic finite automata (NFA) is
defined by M=(Q, Σ, δ, q0, F) where
– Q is a finite set of internal state
– Σ is a finite set of symbols (input alphabets)
– δ: Q× Σ→2Q is a transition function, 2Q is the power set
of Q
– q0ϵQ is the initial state
– F⊆Q is the set of final states
Theory of Automata & Formal Languages,
23
BCS-402
Difference: DFA and NFA
• In nondeterministic automata, the range of δ is in
the power set of 2Q , so that its value is not a
single element of Q but a subset of it. This subset
defines the set of all possible states that can be
reached by transition.
– For example, if current state is q1 and the symbol is a,
then δ(q1,a)={q0,q2}. Then either q0 or q2 could be the
next state of the non-deterministic finite automata.
But in deterministic finite automata, it is not possible.
In DFA δ(q1,a)=q0. In DFA, for a single input letter
there is only one move possible from a state to next
state.
Theory of Automata & Formal Languages,
24
BCS-402
Difference: DFA and NFA
• We can allow in NDFA δ(q0,Ʌ)=q. This means
that NDFA can make a transition without
consuming an input symbol. In DFA, the
system changes state if δ(qi,a)=qj. DFA does
not change state without consuming any
letter.
• In an NDFA the set δ(qi,a) may be empty, i.e.,
there is no transition defined for this specific
situation. In DFA, such move is not possible.
Theory of Automata & Formal Languages,
25
BCS-402
Finite Automata Designing Problems
• Example 1:
Design a FA that accepts set of strings such
that every string ends in 00 over alphabet
{0,1}.

Theory of Automata & Formal Languages,


26
BCS-402
Finite Automata Designing Problems
• Solution:

Theory of Automata & Formal Languages,


27
BCS-402
Finite Automata Designing Problems
• Example 2:
Design a FA that accepts set of strings
where the number of 0’s in every string is
multiple of 3 over alphabet {0,1}.

Theory of Automata & Formal Languages,


28
BCS-402
Finite Automata Designing Problems
• Solution:

Theory of Automata & Formal Languages,


29
BCS-402
Finite Automata Designing Problems
• Example 3:
Draw the transition diagram of finite automata
which will accept all binary strings with even
number of zeros and ones.
• Solution:
Let us design a finite automata to accept the
language
L = {w : w has both an even number of 0’s and
even number of 1’s}

Theory of Automata & Formal Languages,


30
BCS-402
Finite Automata Designing Problems
• Define the following four states:
– q0: Both the no. of 0’s and 1’s are even.
– q1: The no. of 0’s are even and no. of 1’s are odd.
– q2: The no. of 0’s are odd and no. of 1’s are even.
– q3: Both the no. of 0’s and 1’s are odd.

• Thus the DFA for the language L is


A = ({q0, q1, q2, q3}, {0, 1}, δ, q0, {q0})

Theory of Automata & Formal Languages,


31
BCS-402
Finite Automata Designing Problems
• The transition diagram is

Theory of Automata & Formal Languages,


32
BCS-402
Finite Automata Designing Problems
• Example 4:
Draw the transition diagram of finite
automata which will accept all binary
strings with odd number of 0’s and 1’s.

Theory of Automata & Formal Languages,


33
BCS-402
Finite Automata Designing Problems
• Solution:

Theory of Automata & Formal Languages,


34
BCS-402
Finite Automata Designing Problems
• Example 5:
Draw the transition diagram of finite
automata which will accept all binary
strings with odd number of 0’s and
even number of 1’s.

Theory of Automata & Formal Languages,


35
BCS-402
Finite Automata Designing Problems
• Solution:

Theory of Automata & Formal Languages,


36
BCS-402
Finite Automata Designing Problems
• Example 6:
Draw the transition diagram of finite
automata which will accept all binary
strings with even number of 0’s and odd
number of 1’s.

Theory of Automata & Formal Languages,


37
BCS-402
Finite Automata Designing Problems
• Solution:

Theory of Automata & Formal Languages,


38
BCS-402
Finite Automata Designing Problems
• Example 7:
Design a FA which accepts set of strings
containing exactly four 1’s i.e., 1111 in
every string over {0,1}.

Theory of Automata & Formal Languages,


39
BCS-402
Finite Automata Designing Problems
• Solution:

Dead state

Theory of Automata & Formal Languages,


40
BCS-402
Finite Automata Designing Problems
• Example 8:
Design a FA over {0,1} which accepts
exactly two 0’s.

Theory of Automata & Formal Languages,


41
BCS-402
Finite Automata Designing Problems
• Solution:

Dead state

Theory of Automata & Formal Languages,


42
BCS-402
Finite Automata Designing Problems
• Example 9:
Design a FA over {0,1} which accepts
atmost two 0’s.

Theory of Automata & Formal Languages,


43
BCS-402
Finite Automata Designing Problems
• Solution:

Dead state

Theory of Automata & Formal Languages,


44
BCS-402
Finite Automata Designing Problems
• Example 10:
Design a FA over {0,1} which accepts
atleast two 0’s.

Theory of Automata & Formal Languages,


45
BCS-402
Finite Automata Designing Problems
• Solution:

Theory of Automata & Formal Languages,


46
BCS-402
Finite Automata Designing Problems
• Example 11:
Design DFA and NFA over {a,b} which
accepts all strings starting with abb.

Theory of Automata & Formal Languages,


47
BCS-402
Finite Automata Designing Problems
• Solution:
• DFA:

Dead state

Theory of Automata & Formal Languages,


48
BCS-402
Finite Automata Designing Problems
• NFA:

Theory of Automata & Formal Languages,


49
BCS-402
Finite Automata Designing Problems
• Example 12:
Design DFA and NFA over {a,b} which
accepts all strings ending with abb.

Theory of Automata & Formal Languages,


50
BCS-402
Finite Automata Designing Problems
• Solution:
• DFA:

Theory of Automata & Formal Languages,


51
BCS-402
Finite Automata Designing Problems
• NFA:

Theory of Automata & Formal Languages,


52
BCS-402
Finite Automata Designing Problems
• Example 13:
Design DFA and NFA over {a,b} which
accepts all strings in which abb is a
substring i.e., abb can be anywhere.

Theory of Automata & Formal Languages,


53
BCS-402
Finite Automata Designing Problems
• Solution:
• DFA:

Theory of Automata & Formal Languages,


54
BCS-402
Finite Automata Designing Problems
• NFA:

Theory of Automata & Formal Languages,


55
BCS-402
Finite Automata Designing Problems
• Example 14:
• Design DFA and NFA over {0,1} starting with 1
and length of the string is divisible by 3.

Theory of Automata & Formal Languages,


56
BCS-402
Finite Automata Designing Problems

• Solution:
• DFA:

Dead state

Theory of Automata & Formal Languages,


57
BCS-402
Finite Automata Designing Problems
• NFA:

Theory of Automata & Formal Languages,


58
BCS-402
Finite Automata Designing Problems
• Example 15:
• Design DFA and NFA over {0,1} not ending in
010.

Theory of Automata & Formal Languages,


59
BCS-402
Finite Automata Designing Problems
• Solution:
• DFA:

• NFA: same as DFA


Theory of Automata & Formal Languages,
60
BCS-402
Finite Automata Designing Problems
• Example 16:
• Design a DFA over {a,b,c} that begins and ends
with different letter.

Theory of Automata & Formal Languages,


61
BCS-402
Finite Automata Designing Problems
• Solution:
• DFA:

Theory of Automata & Formal Languages,


62
BCS-402
Finite Automata Designing Problems
• Example 17:
• Design a DFA that accepts set of strings that
either starts with 01 or ends with 01 over
alphabet {0,1}.

Theory of Automata & Formal Languages,


63
BCS-402
Finite Automata Designing Problems
• Solution:
• DFA:

Theory of Automata & Formal Languages,


64
BCS-402
Epsilon NFA (∈-NFA)
• Epsilon NFA (∈-NFA) is similar to the NFA but with a little
difference in that it has an epsilon (∈) transition that NFA
doesn’t have. A Transition that does not consume any input
symbol is called an ε-transitions.
• ∈-NFA state diagrams usually label Epsilon with the Greek
letter “∈”. It is also called lambda.
• ∈-transitions give a convenient way of designing the
machine systems.
• Due to ε-transitions, the first string of language may be
empty.
• Note: ∈ab∈a = aba, where ∈ is empty. Epsilon (∈) transition
is also known as an empty move or empty transition.
Theory of Automata & Formal Languages,
65
BCS-402
Epsilon NFA (∈-NFA)
• Example 1:
• Draw a NFA which accepts the string “ab”.

Theory of Automata & Formal Languages,


66
BCS-402
Epsilon NFA (∈-NFA)
• Example 2:
• Draw a NFA which accepts the string “a or b”.

Theory of Automata & Formal Languages,


67
BCS-402
Epsilon NFA (∈-NFA)
• Example 3:
• Draw a NFA that accepts the string “a, b or c”.

Theory of Automata & Formal Languages,


68
BCS-402
Epsilon NFA (∈-NFA)
• Example 4:
• Draw a NFA that accepts the string “a*”.

Theory of Automata & Formal Languages,


69
BCS-402
Epsilon NFA (∈-NFA)
• Example 5:
• Create a ∈-NFA for regular expression: (b)*a

Theory of Automata & Formal Languages,


70
BCS-402
Finite Automata with Output
• Mealy and Moore Machine:
– The finite automata which we considered had
binary output i.e., either they accept the string or
they do not accept the string.
– This acceptability was decided on the basis of
reachability of the final state by the initial state.
– Now, we remove this restriction and consider the
model where the outputs can be chosen from
some other alphabet.
Theory of Automata & Formal Languages,
71
BCS-402
Finite Automata with Output
– The value of the output function Z(t) in the most
general case is a function of the present state q(t) and
the present input x(t) i.e.,
Z(t) = λ(q(t), x(t))
where λ is called the output function. This generalized
model is usually called the Mealy machine.
– If the output function Z(t) depends only on the
present state and is independent of the current input,
the output function may be written as
Z(t) = λ(q(t))
This restricted model is called the Moore machine.

Theory of Automata & Formal Languages,


72
BCS-402
Moore Machine
• Definition:
– A Moore machine is a six tuple (Q, Σ, ∆, δ, λ, q0)
where
• Q is a finite nonempty set of states.
• Σ is a set of input letters called input alphabets.
• ∆ is an alphabet of possible output
• δ is a transition function Σ × Q → Q
• λ is the output function mapping Q into ∆
• q0 is the initial state

Theory of Automata & Formal Languages,


73
BCS-402
Moore Machine
• Note:
– A Moore machine does not define a language of accepted words
because every possible input string creates an output string and
there is no such thing as final state. The processing is
terminated when the last input letter is read and last output
character is printed.
– Moore machine have pictorial representation very similar to FA.
The difference is that instead of having only the name of state
inside the little circle, we also specify the output character
printed by that state. The two symbol inside the circle are
separated by a slash “/”. On the left side is the name of the state
and on the right side is output from that state.
– For a Moore machine if the input string is of length n, the
output string is of length n+1.
Theory of Automata & Formal Languages,
74
BCS-402
Moore Machine
• Example:
Let us consider an example defined by
following transition table of Moore machine.
Input alphabet Σ={a,b}
Output alphabet ∆={0,1}
States Q={q0,q1,q2,q3}
q0 is the initial state

Theory of Automata & Formal Languages,


75
BCS-402
Moore Machine
Next state Output
Present state
a b λ
→q0 q1 q3 1
q1 q3 q1 0
q2 q0 q3 0
q3 q3 q2 1
• The pictorial representation of the Moore machine is

Theory of Automata & Formal Languages,


76
BCS-402
Moore Machine
• Let us trace the operation of this machine on
input string abab.

• Output sequence = 10010

Theory of Automata & Formal Languages,


77
BCS-402
Mealy Machine
• Definition:
– A Mealy machine is a six tuple (Q, Σ, ∆, δ, λ, q0)
where
• Q is a finite nonempty set of states.
• Σ is a set of input letters called input alphabets.
• ∆ is an alphabet of possible output
• δ is a transition function Σ × Q → Q
• λ is the output function mapping Q × Σ → ∆
• q0 is the initial state

Theory of Automata & Formal Languages,


78
BCS-402
Mealy Machine
• Note:
– A Mealy machine is like a Moore machine except
that now output letter printing while we are
travelling along the edge, not in state themselves.

– In the case of a Mealy machine if the input string


is of length n, the output string is also of the same
length n.

Theory of Automata & Formal Languages,


79
BCS-402
Mealy Machine
• Example:
• Let us consider an example defined by
following transition diagram of Mealy
machine.

Theory of Automata & Formal Languages,


80
BCS-402
Mealy Machine
• Transition table for this machine is
Next state
Present
Input a Input b
state
Next state Output Next state Output

→q0 q3 0 q1 0

q1 q1 1 q0 1

q2 q1 0 q1 1

q3 q1 1 q2 1

Theory of Automata & Formal Languages,


81
BCS-402
Mealy Machine
• Let us trace the operation of this machine on
input string abab.

• Output sequence = 0101

Theory of Automata & Formal Languages,


82
BCS-402
Procedure for transforming a Mealy
machine into a Moore machine
• We develop procedures for transforming a Mealy
machine into a Moore machine and vice versa so that
for a given input string the output strings are the same
(except for the first symbol) in both the machines.
• At the first stage we develop the procedure so that
both machines accept exactly the same set of input
sequences.
• We look into the next state column for any state, say qi,
and determine the number of different outputs
associated with qi in that column.

Theory of Automata & Formal Languages,


83
BCS-402
Procedure for transforming a Mealy
machine into a Moore machine
• We split qi into several different states, the
number of such states being equal to the number
of different outputs associated with qi.

• Then we construct the transition table for the


new states.
• The pair of states and outputs in the next state
column can be rearranged and we get a new
table. This will give the Moore machine.
Theory of Automata & Formal Languages,
84
BCS-402
Procedure for transforming a Mealy
machine into a Moore machine
• Example:
• Construct a Moore machine which is
equivalent to following Mealy machine
Next state
Present
Input a=0 Input a=1
state
State Output State Output
→q1 q3 0 q2 0
q2 q1 1 q4 0
q3 q2 1 q1 1
q4 q4 1 q3 0

Theory of Automata & Formal Languages,


85
BCS-402
Procedure for transforming a Mealy
machine into a Moore machine
• Solution:
• Here, we look into the next state column for any state, say
qi, and determine the number of different outputs
associated with qi in that column.
• We split qi into several different states, the number of such
states being equal to the number of different outputs
associated with qi.
• For ex., in this problem, q1 is associated with one output 1
and q2 is associated with two different outputs 0 and 1.
Similarly, q3 and q4 are associated with the outputs 0 and
0,1 respectively.
• So we split q2 into q20 and q21.
• Similarly, q4 is split into q40 and q41.
Theory of Automata & Formal Languages,
86
BCS-402
Procedure for transforming a Mealy
machine into a Moore machine
• New table:
Next state
Present
Input a=0 Input a=1
state
State Output State Output
→q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1 q40 0
q3 q21 1 q1 1
q40 q41 1 q3 0
q41 q41 1 q3 0

Theory of Automata & Formal Languages,


87
BCS-402
Procedure for transforming a Mealy
machine into a Moore machine
• The pair of states and outputs in the next state column
can be rearranged as
Present Next state
Output
state a=0 a=1
→q1 q3 q20 1
q20 q1 q40 0
q21 q1 q40 1
q3 q21 q1 0
q40 q41 q3 0
q41 q41 q3 1

• This gives the Moore machine.


Theory of Automata & Formal Languages,
88
BCS-402
Procedure for transforming a Mealy
machine into a Moore machine
• Here we observe that the initial state q1 is
associated with output 1. This means that with
input Ʌ we get an output of 1, if the machine
starts at state q1. Thus this Moore machine
accepts a zero-length sequence (null sequence)
which is not accepted by the Mealy machine.
• To overcome this situation, either we must
neglect the response of a Moore machine to
input Ʌ, or we must add a new starting state q0,
whose state transitions are identical with those of
q1 but whose output is 0.
Theory of Automata & Formal Languages,
89
BCS-402
Procedure for transforming a Mealy
machine into a Moore machine
• So final table is
Present Next state
Output
state a=0 a=1
→q0 q3 q20 0
q1 q3 q20 1
q20 q1 q40 0
q21 q1 q40 1
q3 q21 q1 0
q40 q41 q3 0
q41 q41 q3 1
• Note:
– From the foregoing procedure, it is clear that if we have an m-output,
n-state Mealy machine, the corresponding m-output Moore machine
has no more than mn+1 states.
Theory of Automata & Formal Languages,
90
BCS-402
Procedure for transforming a Moore
machine into a Mealy machine
• We modify the acceptability of input string by a Moore
machine by neglecting the response of the Moore machine
to input Ʌ.
• We thus define that Mealy machine M and Moore machine
M’ are equivalent if for all input strings w,
bZM(w) = ZM’(w),
where b is the output of the Moore machine for its initial
state.
• We give the following result:
Let M1 = (Q, Σ, ∆, δ, λ, q0) be a Moore machine.
Then the following procedure may be adopted to construct
an equivalent Mealy machine M2.
Theory of Automata & Formal Languages,
91
BCS-402
Procedure for transforming a Moore
machine into a Mealy machine
• Construction:
• We have to define the output function λ’ for the
Mealy machine as a function of the present state
and the input symbol. We define λ’ by
λ’(q,a) = λ(δ(q,a))
for all states q and input symbol a.

• The transition function is the same as that of the


given Moore machine.
Theory of Automata & Formal Languages,
92
BCS-402
Procedure for transforming a Moore
machine into a Mealy machine
• Example:
• Construct a Mealy machine which is
equivalent to the following Moore machine
Next state
Present state Output
a=0 a=1
→q0 q3 q1 0
q1 q1 q2 1
q2 q2 q3 0
q3 q3 q0 0

Theory of Automata & Formal Languages,


93
BCS-402
Procedure for transforming a Moore
machine into a Mealy machine
• Solution:
• In the case of the Moore machine, for every
input symbol we form the pair consisting of
the next state and the corresponding output
and reconstruct the table for the Mealy
machine.
• For example, the states q3 and q1 in the next
state column should be associated with
outputs 0 and 1 respectively.

Theory of Automata & Formal Languages,


94
BCS-402
Procedure for transforming a Moore
machine into a Mealy machine
• The transition table for Mealy machine is
Next state
Present
Input a=0 Input a=1
state
State Output State Output
→q0 q3 0 q1 1
q1 q1 1 q2 0
q2 q2 0 q3 0
q3 q3 0 q0 0

Theory of Automata & Formal Languages,


95
BCS-402
Procedure for transforming a Moore
machine into a Mealy machine
• Note:
– We can reduce the number of states in any model
by considering states with identical transitions. If
two states have identical transitions (i.e., the rows
corresponding to these two states are identical),
then we can delete one of them.

Theory of Automata & Formal Languages,


96
BCS-402
Procedure for transforming a Moore
machine into a Mealy machine
• Example:
• Construct a Mealy machine which is
equivalent to the following Moore machine
Next state
Present state Output
a=0 a=1
→q1 q1 q2 0
q2 q1 q3 0
q3 q1 q3 1

Theory of Automata & Formal Languages,


97
BCS-402
Procedure for transforming a Moore
machine into a Mealy machine
• Solution:
– We construct the transition table by associating
the output with the transitions of Mealy machine.
– The transition table for the Mealy machine is
Next state
Present
Input a=0 Input a=1
state
State Output State Output
→q1 q1 0 q2 0
q2 q1 0 q3 1
q3 q1 0 q3 1

Theory of Automata & Formal Languages,


98
BCS-402
Procedure for transforming a Moore
machine into a Mealy machine
• Here we see that the rows corresponding to q2
and q3 are identical. So, we can delete one of
the two states, i.e., q2 or q3. We delete q3.
• The reconstructed table is
Next state
Present
Input a=0 Input a=1
state
State Output State Output
→q1 q1 0 q2 0
q2 q1 0 q2 1

Theory of Automata & Formal Languages,


99
BCS-402
Designing of Moore and Mealy
Machine
• Example:
• Design a Moore machine for the one’s
complement of a binary number.

Theory of Automata & Formal Languages,


100
BCS-402
Designing of Moore and Mealy
Machine
• Solution:
• Transition Diagram:

Theory of Automata & Formal Languages,


101
BCS-402
Designing of Moore and Mealy
Machine
• Transition Table:

Next state
Present state Output
a=0 a=1
→q0 q1 q0 0
q1 q1 q0 1

Theory of Automata & Formal Languages,


102
BCS-402
Designing of Moore and Mealy
Machine
• Example:
• Design a Mealy machine for the one’s
complement of a binary number.

Theory of Automata & Formal Languages,


103
BCS-402
Designing of Moore and Mealy
Machine
• Solution:
• Transition Diagram:

Theory of Automata & Formal Languages,


104
BCS-402
Designing of Moore and Mealy
Machine
• Transition Table:

Next state
Present
Input a=0 Input a=1
state
State Output State Output
→q0 q1 1 q0 0
q1 q1 1 q0 0

Theory of Automata & Formal Languages,


105
BCS-402
Designing of Moore and Mealy
Machine
• Example:
• Design a Moore machine for the binary input
sequence, output A if 101 is recognized,
otherwise output B.

Theory of Automata & Formal Languages,


106
BCS-402
Designing of Moore and Mealy
Machine
• Solution:
• Transition Diagram:

Theory of Automata & Formal Languages,


107
BCS-402
Designing of Moore and Mealy
Machine
• Transition Table:

Next state
Present state Output
a=0 a=1
→q0 q0 q1 B
q1 q2 q1 B
q2 q0 q3 B
q3 q2 q1 A

Theory of Automata & Formal Languages,


108
BCS-402
Designing of Moore and Mealy
Machine
• Example:
• Design a Mealy machine for the binary input
sequence, output A if 101 is recognized,
otherwise output B.

Theory of Automata & Formal Languages,


109
BCS-402
Designing of Moore and Mealy
Machine
• Solution:
• Transition Diagram:

Theory of Automata & Formal Languages,


110
BCS-402
Designing of Moore and Mealy
Machine
• Transition Table:

Next state
Present
Input a=0 Input a=1
state
State Output State Output
→q0 q0 B q1 B
q1 q2 B q1 B
q2 q0 B q3 A
q3 q2 B q1 B

Theory of Automata & Formal Languages,


111
BCS-402
Designing of Moore and Mealy
Machine
• Example:
• Design a Moore machine for the binary input
sequence such that if it has a substring 110
the machine outputs A if it has a substring 101
machine outputs B otherwise outputs C.

Theory of Automata & Formal Languages,


112
BCS-402
Designing of Moore and Mealy
Machine
• Solution:
• Transition Diagram:

Theory of Automata & Formal Languages,


113
BCS-402
Designing of Moore and Mealy
Machine
• Transition Table:

Next state
Present state Output
a=0 a=1
→q0 q0 q1 C
q1 q4 q2 C
q2 q3 q2 C
q3 q0 q5 A
q4 q0 q5 C
q5 q4 q2 B

Theory of Automata & Formal Languages,


114
BCS-402
Limitations of Finite State Machines
• It does not have the capacity to remember
arbitrarily large amount of information because it
has only a fixed number of states and this set has
a limit to the length of the sequence,
remembered by it.
• In finite state machine, if the initial state and
input sequence is known, then we can find the
current state of finite state machine but its
reverse is not possible.
• It cannot recognize the centre because finite state
machine does not have memory.
Theory of Automata & Formal Languages,
115
BCS-402
Limitations of Finite State Machines
• Multiplication operation of long number
cannot be carried out in finite state machine
since the full length sequence are to be
remembered.
• Finite state machine cannot check the well
formedness because we will have to
remember the previous opening brackets.

Theory of Automata & Formal Languages,


116
BCS-402

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy