0% found this document useful (0 votes)
75 views35 pages

Finite Automaton With Output

1. The document discusses finite automata with output, specifically Moore machines and Mealy machines. 2. Moore machines have outputs that depend only on the present state, while Mealy machines have outputs that depend on both the present state and input. 3. It provides examples of both Moore and Mealy machines, showing their components and how they operate on sample input strings to produce output strings. It also proves that for every Moore machine, there exists an equivalent Mealy machine.

Uploaded by

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

Finite Automaton With Output

1. The document discusses finite automata with output, specifically Moore machines and Mealy machines. 2. Moore machines have outputs that depend only on the present state, while Mealy machines have outputs that depend on both the present state and input. 3. It provides examples of both Moore and Mealy machines, showing their components and how they operate on sample input strings to produce output strings. It also proves that for every Moore machine, there exists an equivalent Mealy machine.

Uploaded by

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

Finite Automaton with output

Finite automaton discussed so far, is just


associated with the RE or the language.
There is a question whether does there exist an FA
which generates an output string corresponding to
each input string ? The answer is yes. Such
machines are called machines with output.
There are two types of machines with output.
Moore machine and Mealy machine

1
Moore machine
A Moore machine consists of the
following
1. A finite set of states q0, q1, q2, … where q0 is
the initial state.
2. An alphabet of letters  = {a,b,c,…} from
which the input strings are formed.
3. An alphabet ={x,y,z,…} of output
characters from which output strings are
generated.
2
Moore machine continued …
4. A transition table that shows for each
state and each input letter what state is
entered the next.
5. An output table that shows what
character is printed by each state as it is
entered.

3
Moore machine continued …
Note: It is to be noted that since in Moore machine
no state is designated to be a final state, so there is
no question of accepting any language by Moore
machine. However in some cases the relation
between an input string and the corresponding
output string may be identified by the Moore
machine. Moreover, the state to be initial is not
important as if the machine is used several times
and is restarted after some time, the machine will
be started from the state where it was left off.
Following are the examples
4
Definition
• Moore machine is an FSM whose outputs depend on only
the present state.
• A Moore machine can be described by a 6 tuple (Q, ∑, O, δ,
X, q0) where −
• Q is a finite set of states.
• ∑ is a finite set of symbols called the input alphabet.
• O is a finite set of symbols called the output alphabet.
• δ is the input transition function where δ: Q × ∑ → Q
• X is the output transition function where X: Q → O
• q0 is the initial state from where any input is processed (q0 ∈
Q).
5
Example
Consider the following Moore machine
having the states q0, q1, q2, q3 where q0 is
the start state and
 = {a,b},
O={0,1}
the transition table follows as

6
Example continued …
New States after Characters
Old reading to be
States printed
a b
1
0
q0- q1 q3
0
q1 q3 q1 1
q2 q0 q3 7
Example continued …
the transition diagram corresponding to the
previous transition table may be
b

a
q0/1 q1/0

b a
a

b
q2/0 q3/1 a
b
8
Example continued …
b

a
q0/1 q1/0

b a
a

b
q2/0 q3/1 a
b

It is to be noted that the states are labeled


along with the characters to be printed.
Running the string abbabbba over the above
machine, the corresponding output string
will be 100010101, which can be
determined by the following table as well 9
Example continued …
Input a b b a b b b a

State q0 q1 q1 q1 q3 q2 q3 q2 q0

output 1 0 0 0 1 0 1 0 1

It may be noted that the length of output


string is l more than that of input string as
the initial state prints out the extra character
1, before the input string is read. 10
Mealy machine
A Mealy machine consists of the
following
1. A finite set of states q0, q1, q2, … where q0 is
the initial state.
2. An alphabet of letters  = {a,b,c,…} from
which the input strings are formed.
3. An alphabet O={x,y,z,…} of output
characters from which output strings are
generated.
11
Mealy machine continued …
4. A pictorial representation with states
and directed edges labeled by an input
letter along with an output character. The
directed edges also show how to go from
one state to another corresponding to
every possible input letter.
Note: It is not possible to give transition
table in this case.
12
Mealy machine continued …
Note: It is to be noted that since, similar to Moore
machine, in Mealy machine no state is designated
to be a final state, so there is no question of
accepting any language by Mealy machine.
However in some cases the relation between an
input string and the corresponding output string
may be identified by the Mealy machine.
Moreover, the state to be initial is not important
as if the machine is used several times and is
restarted after some time, the machine will be
started from the state where it was left off.
Following are the examples
13
Example
Consider the following Mealy machine
having the states q0, q1, q2, q3 , where q0 is
the start state and
 = {a,b},
q1 b/1 q2
O={0,1}
a/1 b/1 a/0
a/0

q0 b/0 q3
a/1
b/1
14
Example continued …
q1 b/1 q2

a/1 b/1 a/0


a/0

b/0
q0 q3 a/1
b/1

Running the string abbabbba over the above


machine, the corresponding output string
will be 01111010, which can be determined
by the following table as well
15
Example continued …
Input a b b a b b b a

States q0 q1 q2 q3 q3 q0 q3 q0 q1

output 0 1 1 1 1 0 1 0

It may be noted that in Mealy machine, the


length of output string is equal to that of
input string.
16
Example

Consider the following Mealy machine


having the states q0, q1, q2 , where q0 is the
start state and
 = {a,b},
a/1
b/0
O={0,1} q1
a/0
q2 b/1

a/0 b/0

q0
17
Example continued …
For babaababba as input string the machine
will print 0000100010.

18
Example
Consider the following Mealy machine having
the only state q0 as the start state and
 = {0,1}, 0/1, 1/0
O= {0,1}
q0

If 0011010 is run on this machine then the


corresponding output string will be 1100101.
This machine is also called Complementing
machine.
19
Equivalent machines
Two machines are said to be equivalent if
they print the same output string when the
same input string is run on them.
Remark: Two Moore machines may be
equivalent. Similarly two Mealy machines
may also be equivalent, but a Moore
machine can’t be equivalent to any Mealy
machine. However, ignoring the extra
character printed by the Moore machine,
there exists a Mealy machine which is
equivalent to the Moore machine.
20
Theorem
Statement:
For every Moore machine there is a Mealy
machine that is equivalent to it (ignoring the
extra character printed by the Moore machine).
Proof: Let M be a Moore machine, then
shifting the output characters corresponding to
each state to the labels of corresponding
incoming transitions, machine thus obtained
will be a Mealy machine equivalent to M.
Following is a note
21
Note
It may be noted that while converting a Moore
machine into an equivalent Mealy machine, the
output character of a state will be ignored if there
is no incoming transition at that state. A loop at a
state is also supposed to be an incoming transition.
Following is the example of converting a
Moore machine into an equivalent Mealy
machine

22
Example
Consider the following Moore machine
a q1/1
q0/0

b a
b

a q2/0 b q3/1 a,b

Using the method described earlier, the


above machine may be equivalent to the
following Mealy machine 23
Example continued ...
q0 a/1 q1

b /0 a /1
b/0

q3 a /1,b /1
a /0 q2 b /1

Running the string abbabbba on both the


machines, the output string can be
determined by the following table
24
Example continued ...

Input a b b a b b b a

States q0 q1 q2 q3 q3 q3 q3 q3 q3

Moore 0 1 0 1 1 1 1 1 1

Mealy 1 0 1 1 1 1 1 1

25
Theorem
Statement:
For every Mealy machine there is a Moore
machine that is equivalent to it (ignoring the
extra character printed the Moore machine).
Proof: Let M be a Mealy machine. At each
state there are two possibilities for incoming
transitions
1. The incoming transitions have the same
output character.
2. The incoming transitions have different
output characters.
26
Proof continued …
If all the transitions have same output characters,
then shift that character to the corresponding state.
If all the transitions have different output
characters, then the state will be converted to as
many states as the number of different output
characters for these transitions, which shows that
if this happens at state qi then qi will be converted
to qi1 and qi2 i.e. if at qi there are the transitions
with two output characters then qi1 for one
character and qi2 for other character.

27
Proof continued …
Shift the output characters of the
transitions to the corresponding new
states qi1 and qi2. Moreover, these new
states qi1 and qi2 should behave like qi as
well. Continuing the process, the
machine thus obtained, will be a Moore
machine equivalent to Mealy machine M.
Following is a note
28
Note
It may be noted that if there is no incoming
transition at certain state then any of the output
characters may be associated with that state.
It may also be noted that if the initial state is
converted into more than one new states then
only one of these new states will be considered
to be the initial state. Following is an example

29
Example
Consider the following Mealy machine
q1 b/1 q2

a/1 b/1 a/0


a/0

q0 b/0 q3
a/1
b/1

30
Example continued ...
Shifting the output character 1 of transition b to q0

q1 b/1 q2

a/1 b/1 a/0


a/0

b/0 q3
q0/1 a/1
b

31
Example continued ...
Shifting the output character 0 of transition a to q1

b/1 q2
q1/0

a/1 b/1 a/0


a

b/0 q3
q0/1 a/1
b

32
Example continued ...
Shifting the output character 1 of transition b to q2

q1/0 b q2/1

a/1 b/1 a/0


a

b/0 q3
q0/1 a/1
b

33
Example continued ...
Splitting q3 q1/0 b q2/1
1 2
into q3 and q3
a b
a

q0/1 a
b a

q31/1
b
b
a

q32/0
34
Example continued …
Running the string abbabbba on both the
machines, the output strings can be determined
by the following table

Input a b b a b b b a

States q0 q1 q2 q3 q3 q0 q3 q0 q1

Mealy 0 1 1 1 1 0 1 0

Moore 1 0 1 1 1 1 0 1 0
35

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