7-Finite State Automata With Output
7-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).
M = ( K , ∑ , P i , δ , λ , q0 )
1
1. Moor Machine definition
Moor Machine defines as the following:
M = ( K , ∑ , Pi , δ , λ , q 0 )
δ ( qi , a ) = qj where a ϵ ∑ and qi , qj ϵ K
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
1 1 1
C/0
0
1
0
D/1
4
2. Mealy Machine definition
Mealy machine defines as the following:
M = ( K , ∑ , Pi , δ , λ , q 0 )
δ ( qi , a ) = qj where a ϵ ∑ and qi , qj ϵ K
λ(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
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
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 :