Finite Automata With Output

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 19

Finite Automata With

Output
Background
• Computers not only process data but also
present the results of processing
• Models of FAs with output
– Moore Machines
– Mealy Machines

• Designed Primarily as a mathematical model for


sequential circuits
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 doesn’t define the language of accepted words
as there are no final states
• Outputs a letter for every input character
• Can be turned into language definers as well
Moore Machine
• Example

b Old state Output by New State


old state
q0/1 a q1/0 After Input After input
a b
b
a a
- q0 1 q1 q3
a
b q1 0 q3 q1
q2/0 q3/1
q2 0 q0 q3
b q3 1 q3 q2
Mealy Machine
• Another variation of FA
• Output associated with edges
• Edges from the same state may
have different output letters
associated with each of them
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

q1
a/0 b/1

q0 a/1
q2
b/0
a/0

b/1 b/1
q3

a/1
Moore vs. Mealy
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/t
b q
q/t

c c/t

Mo Me
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
• The resultant Machine is a Mealy Machine that
produces output strings which when concatenated
with the start state symbol is exactly the one produced
by the original Mo for every input string.
Moore to Mealy
q1/1 q1
a a/1
a a/1
a,b a/1, b/1

b/0
q0/0 b q2/1 q0 q2

b/0
b/1
b b
q3/0 q3

a/0
a
Practice
Convert Moore to Mealy Machine
Mealy to Moore
• For every Mealy machine Me, there is a
Moore machine Mo, that is equivalent to
it
• Constructive Proof
• Different characters associated with
each edge
Mealy to Moore
b

a/1
a
b/0 q/0
a/1 b/1

a/0
q
b/1 a/1

b/1

b qc/1
b/1
Mealy to Moore
• Conversion of loops
a

q6 q3/0 a/0
a/0
a/0

b/1 b q6

q3
b a/0

q3c/1
Mealy to Moore
• Example
b/1
q1
a/0 a/1

b/0

q0 a/1 q2
b/0
a/0

b/1
q3
Mealy to Moore
b a

a q1/1 a
b

q0/0
q2/0

a
b b

a
q0c/1 q2c/1
b
a
b q3/0
Practice
Convert Mealy to Moore Machine

You might also like