Chapter 08 Finite Automata With Output
Chapter 08 Finite Automata With Output
Output
Chapter 8
Background
Computers not only process data but also
present the results of processing
Expansion of abstract machines to support this
feature
Models of FAs with output
Moore Machines
Mealy Machines
Moore Machines
Created by E.F. Moore in 1956
Collection of five elements
A finite set of states q0,q1,q2,qn where q0 is
designated as the start state.
An alphabet of letters for forming the input string
= {a b c }
An alphabet of possible output characters = {x y z} or
numbers {0 1 }
A transition table that shows for each state and each
input letter what state is reached
An output table that shows what character from is
printed by each state as it is entered.
Moore Machine
Prints an automatic output letter of start state for
every input string
It doesnt define the language of accepted words
as there are no final states
Outputs a letter for every input character
Processing is controlled solely by the input
Can be turned into language definers as well
Moore Machine
Example
Old state
b
q0/1
q1/0
b
a
a
q2/0
Output by
old state
q3/1
New State
After Input
a
After input
b
q0
q1
q3
q1
q3
q1
q2
q0
q3
q3
q3
q2
Moore Machine
Application: Pattern count, counting no. of times
the pattern aab occurs
a
a
a
q0/0
q2/0
q3/0
q4/1
Moore Machine
Given a language L and an FA that accepts it, if
printing instruction 0 is added to any nonfinal
state and 1 to each final state, the 1s in any output
sequence mark the end position of all substrings
of the input string starting from the first letter that
are words in L
Moore machine defines the language of all input
strings whose output ends in a 1.
Mealy Machine
Another variation of FA
Output associated with edges
Edges from the same state may
have
different
output
letters
Mealy Machine
Collection of four things
A finite set of states q0,q1,q2,qn where q0 is
designated as the start state.
An alphabet of letters for forming the input string =
{a b c ...}
An alphabet of possible output characters = {x y z}
or numbers {0 1 }
A pictorial representation with states represented by
small circles and directed edges indicating transitions
b/w states. Labels of the edges are compound
symbols of the form i/o where i represents the input
letter while o is the output character associated with
the edge
Mealy Machine
Example, aaabb (01110, same output characters as input
letters)
q1
a/0
b/1
a/1
q0
q2
b/0
a/0
b/1
q3
a/1
b/1
Mealy Machine
Applications: Increment Machine
0/0 1/1
0/1
0/1,1/0
q0
No
carry
0/1
start
1/0
1/0
Owe
carry
Moore Machine
Language Recognition
a/1
a/0
start
a/0
a double letter
The output letter following the
end of a double letter is a 1
b/0
b/1
Mealy
Variation of FA
--
--
No final states
--
strings
give
sensible
aspect
of
comparison
Problem in output string comparison due to
difference in lengths
string from Mo is
exactly x
Moore To Mealy
If Mo is a Moore machine, then there is a
Mealy machine Me that is equivalent to it.
Constructive algorithm
a/t
a
b
c
b/t
q/t
c/t
Moore to Mealy
For any state q of the Mo that has the output character
t associated with it, relabel all the incoming edges as
x/t where x is the input character previously written on
the transition. Change the label of state as it is in
Mealy Machine
Repeat the procedure for all the states in Moore
Machine
The outgoing edges of the state will get replaced in the relabeling
process of other states
Moore to Mealy
a
q0/0
q1
q1/1
a
a/1
a/1
q2/1
b/0
q0
b/0
b
q3/0
a
a/1, b/1
a,b
q2
b/1
q3
a/0
Mealy to Moore
For every Mealy machine Me, there is a
Moore machine Mo, that is equivalent to
it
Constructive Proof
Reverse of
possible
Previous
proof
is
not
Mealy to Moore
b
a
b/0
a/1
q/0
b/1
a/1
a/0
q
a/1
b/1
b/1
b
qc/1
b/1
Mealy to Moore
Conversion of loops
a
q6
a/0
q3/0
a/0
a/0
b/1
b
q3
q6
a/0
q3c/1
Mealy to Moore
Example
b/1
q1
a/0
a/1
b/0
a/1
q0
q2
b/0
a/0
b/1
q3
Mealy to Moore
b
a
q1/0
q0(1)/0
b
q2(1)/0
a
b
a
q0(2)/1
q2(2)/1
b
a
b
q3/0