0% found this document useful (0 votes)
70 views

7-Finite State Automata With Output

This document discusses finite state automata (FSA) with output capabilities, specifically Moore and Mealy machines. Moore machines generate output based on the current state, while Mealy machines generate output based on both the current state and input. Examples are provided to illustrate how each machine type works, including transition tables and diagrams. It is noted that Moore and Mealy machines are equivalent models and can be converted between each other while recognizing the same regular languages.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views

7-Finite State Automata With Output

This document discusses finite state automata (FSA) with output capabilities, specifically Moore and Mealy machines. Moore machines generate output based on the current state, while Mealy machines generate output based on both the current state and input. Examples are provided to illustrate how each machine type works, including transition tables and diagrams. It is noted that Moore and Mealy machines are equivalent models and can be converted between each other while recognizing the same regular languages.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Finite State Automata with Output

In the previous chapters we explain Finite State Automata machines that used
only as acceptors or recognizers of languages. In this chapter, we shall investigate
two different models of FA's with output capabilities ( Moor and Mealy machine ).
These were created by G. H. Mealy (1955) and, independently, by E. F. Moore
(1956).

Moor and Mealy machine


Those two machines are similar but with slight difference in the transition
function of each. In Moor machine, output is generated when the machine is
stabilized in a specific state, ie the output depends on the current state of the machine
Y = g(State )
In the Mealy machine, the machine generates its output when the machine
moves from one state to another, ie the output represent associations depend on the
current input values and the current state of the machine
Y = ( State , Input )
This machines formally known as the following :

M = ( K , ∑ , P i , δ , λ , q0 )

K : finite set of states


∑ : finite set of alphabet
Pi : finite set of output
δ : transition function
λ : output function
q0 : start state
The main difference between them and previous machines is that they do not
have final states, and the function of transition does not put the machine in a new
state only, but generate output. The purpose this type of this machines is not to accept
or reject symbolic string only, but to generate outputs for given inputs.

1
1. Moor Machine definition
Moor Machine defines as the following:

M = ( K , ∑ , Pi , δ , λ , q 0 )

K : finite set of states


∑ : finite set of alphabet
Pi : finite set of output
q0 : start state
δ : represented the transition function :

δ ( qi , a ) = qj where a ϵ ∑ and qi , qj ϵ K

λ : represented the output function :

λ(q)=r where q ϵ K and r ϵ Pi


A Moore machine does not define a language of accepted words, since every
input string creates an output string and there is no such thing as a final state. The
processing is terminated when the last input letter is read and the last output character
is printed.
Example
Input alphabet: Σ = {a, b}
Output alphabet: P = {0, 1}
Names of states: q0, q1, q2, q3. (q0 = start state)

Transition table Output table


Old state New state (the character
After input a after input b printed
in the old state)
- q0 q1 q3 1
q1 q3 q1 0
q2 q0 q3 0
q3 q3 q2 1

2
The transition diagram :
b

a
q0/1 q1/0

a b a

b
q2/0 q3/1
b
a

Note: the two symbols inside the circle are separated by a slash "/", on the left side
is the name of the state and on the right is the output from that state.
In Moore machines, so much information is written inside the state circles that
there is no room for the minus sign indicating the start state. We usually indicate the
start state by an outside arrow as shown above. As mentioned before there is no need
for any plus signs either, since any input string will generate an output string and can
end in any state having done an acceptable job.
Let us trace the operation of this machine on the input string abab. We always
start this machine off in start qo, which automatically prints out the character 1. We
then read the first letter of the input string, which is an a and which sends us to state
q1. This state tells us to print a 0. The next input letter is a b, and the loop shows that
we return to state q1. Being in q, again, we print another 0. Then we read an a, go to
q3, and print a 1. Next we read a b, go to q2, and print a 0. This is the end of the run.
The output sequence has been 10010.

Example : design a moor machine that reads string W and print the value 1 at each
token string appearance 110 or 101 ( allows the overlapping partial symbolic ) and
print 0 otherwise .
Solution : To design this machine we must identify the situations ( states )in which
the machine can pass through its work. Let's say that the status of the input string
and output is as follows :
Input : 0 1 1 0 0 1 0 1 1 0 0
Output : 0 0 0 1 0 0 0 1 0 1 0

3
Since the substring (110 , 101 ) begin with the symbol 1 , so this attribute is used to
determine machine as follows:

 state A represents start state and represents the case where 1 is not appears
 state B represents the case in which the symbol 1 appears
 state C represents the case in which 11 appears
 state D represents the case in which 110 appears . here are outputs 1
 state E represents the case in which 10 appears
 state F represents the case in which 101 appears . here are outputs 1
 The transition diagram :
0
0 0

A/0 1 B/0 0 1 F/1


E/0

1 1 1
C/0
0
1
0

D/1

 The transition table :

Current Next State


Output
State W=0 W=1
A A B 0
B E C 0
C D C 0
D A F 1
E A F 0
F E C 1

4
2. Mealy Machine definition
Mealy machine defines as the following:

M = ( K , ∑ , Pi , δ , λ , q 0 )

K : finite set of states


∑ : finite set of alphabet
Pi : finite set of output
q0 : start state
δ : represented the transition function :

δ ( qi , a ) = qj where a ϵ ∑ and qi , qj ϵ K

λ : represented the output function :

λ(q,a)=r where q ϵK , r ϵ Pi , a ϵ ∑

Example : design a Mealy machine takes binary input and outputs 1 when the number
of 1's is even, otherwise outputs 0.
Solution : Of course, as usual when designing a FSA machine ask what is the
characteristic character of the entered symbolic strings ? the answer here is that the
number of 1's which is either even or odd.
So there are two states K = { E , O } where E represents Even and O represents
Odd. All the transitions to the state E will outputs 1.

0/1 0/0

1/1
E O
1/0

5
The transition table :
Input = 0 Input = 1
Current state
Next state , Output Next state , Output
E E,1 O,0
O O,0 E,1

The transition function :


δ(E,0)=E
δ(E,1)=O
δ(O,0)=O
δ(O,1)=E
and the output function :
λ(E,0)=1
λ(E,1)=0
λ(O,0)=0
λ(O,1)=1
so, if the input = 10100011
then the output = 00111101
Example : the following Mealy machine prints out the 1's complement of an input
bit string .
Solution :
1/0 , 0/1

q0

If the input is 001010 the output is 110101 . this is a case where the input
alphabet and output alphabet are both { 0 , 1 }.

6
The equivalence between Moor and Mealy machines
 The Moor machine can be converted to Mealy machine and vice versa
 Each regular language can be recognized by Moor machine and Mealy machine
 All the languages that defined by Moor machine and Mealy machine are
regular languages

Theorem : If Mo is a Moor machine, then there is a Mealy machine Me that is


equivalent to it.
Proof : The proof will be by constructive algorithm.

a a/t

b q4/t b/t q4
becomes
b b/t

Example:
Below, a Moore machine is converted into a Mealy machine:

Solution :

7
Theorem : For every Mealy machine Me there is a Moore machine Mo that is
equivalent to it.
Proof : The proof will be by constructive algorithm.

If there is more than one possibility for printing as we enter the state, then we
need a copy of the state for each character we might have to print. (we may need as
many copies as there are character in Г).

8
Example:
Convert the following Mealy machine to Moore machine:
Solution :

You might also like