Chapter 3
Chapter 3
• It has been seen in the above sections that there are deterministic
and non-deterministic types of the finite state accepting model, and
these two types are equivalent in terms of modeling power.
• An output-generating automaton model, as the name suggests, is one
that produces an output string in response to an input string applied
to its input.
• In this respect, it is also possible to see the output generating
automaton model as a model that converts input strings to output
strings. Thus, the two main types of finite automata can be
characterized as "recognisers" and "converters".
• In fact, recognizers can also be thought of as producing outputs. Since
a recognizer recognizes some of the input strings applied to its input
and not the other, the FA model produces a binary output.
• FA model can be viewed as a binary output generating model. The
outputs produced by the model can be, for example, “1: accepted”
for final states and “0 : not accepted” for other states. From this point
of view, the output generating finite automata model can be seen as a
broader model, including the recognition model.
• There are two types of output-generating automata, called Moore
and Mealy machines. While the Moore machine is a state-level
output-generating model, the Mealy-machine is a state-transition-
level output-generating model. Moore and Mealy machines are
analyzed separately below.
3.1 Moore Machine
𝑀 =< 𝑄, 𝛴, 𝛥, 𝛿, 𝜆, 𝑞0 >
• The state transition function (𝛿) and the output function (𝜆) of the
Moore machine can be represented by a table or diagram. The table
created to describe the Moore machine is often called the "State
Table", and the diagram is often called the "State Diagram".
Example 3.1 The 𝑀8 machine is defined as a Moore machine that
produces output 𝑧 = 𝑀𝑜𝑑(𝑋, 5) if the binary number applied to its
input is X.
𝑀8 =< 𝑄, 𝛴, 𝛥, 𝛿, 𝜆, 𝑞0 >
𝑄 = {𝐴, 𝐵, 𝐶, 𝐷, 𝐸}
𝛴 = {0,1}
𝛥 = 0,1,2,3,4
𝑞0 = 𝐴
Input: 1 0 1 1 1 1 0
State: 𝐴 → 𝐵 → 𝐶 → 𝐴 → 𝐵 → 𝐷 → 𝐶 → 𝐸
Output: 0 1 2 0 1 3 2 4
3.2 Mealy Machine
𝑀 =< 𝑄, 𝛴, 𝛥, 𝛿, 𝜆, 𝑞0 >
The definition of the elements are the same as in the Moore machine
except the output function (𝜆). In other words, the only difference
between Moore and Mealy machines is in the output function. The
output function, defined as mapping from 𝑄 to 𝛥 for Moore machines
and for Mealy machines, is defined as a mapping from (𝑄 𝑥𝛴) to 𝛥.
Example 3.2 The 𝑀9 machine is defined as the Mealy machine with the
input alphabet {0, 1} and the output alphabet {0, 1, 2} and showing how
many of the last two input symbols are different from the previous one with
the output it produces. When determining the first 2 output values that the
machine will produce, the two input values before the initial state will be
assumed to be 00.
𝑀6 =< 𝑄, 𝛴, 𝛥, 𝛿, 𝜆, 𝑞0 >
𝑄 = {𝐴, 𝐵, 𝐶, 𝐷}
𝛴 = {0,1}
𝛥 = 0,1,2
𝑞0 = 𝐴
𝛿 and 𝜆 are defined by state table and state diagram in figure 3.2. According
to the design, the states of the machine are A, B, C or D, respectively,
according to the previous two input symbol values being 00, 01, 10 or 11.
Figure 3.2 Mealy machine
An example input string and the output string that the machine should
generate in response to this input string are as follows:
X: 0 1 1 0 1 0 1 0 1 1 1 1 0 1 0 0 1 1 1 0 0 0 0 1
Z: 0 1 1 1 2 2 2 2 2 1 0 0 1 2 2 1 1 1 0 1 1 0 0 1
3.3 The Equivalence of Mealy and Moore Machine
• Both Moore and Mealy machines are finite automata models that produce
output.
• In Moore and Mealy models, which are defined as a sextet, 5 elements of
the six are common. It is the output function that separates the Moore and
Mealy models.
• In Moore's model, the machine generates an exit symbol for each state.
When an input string consisting of n input symbols is applied to a Moore
machine in a given state, the machine will generate an output string of
length (n+1). In the Mealy model, the machine generates an output symbol
for each state transition. When an input string of n input symbols is applied
to a Mealy machine in a particular state, the machine will generate an
output string of length n.
• If the initial output symbol produced by the Moore machine is excluded,
equivalent Mealy and Moore machines will produce the same output
string, regardless of the input string applied.
3.3.1 Finding the Mealy Machine Equivalent to the Moore Machine
Figure 3.3
3.3.2 Finding the Moore Machine Equivalent to the Mealy Machine
Lemma 3.2 Let 𝑀2 =< 𝑄, 𝛴, 𝛥, 𝛿, 𝜆, 𝑞0 > is a Mealy machine. The
Moore machine equivalent to 𝑀1 is found as follows:
𝛿′ 𝐴, 0 ,0 = 𝐵, 0 𝜆 𝐴, 0 = 0
𝛿′ 𝐴, 1 ,0 = 𝐵, 0 𝜆 𝐴, 1 = 1
𝛿′ 𝐴, 0 ,1 = 𝐴, 1 𝜆 𝐵, 0 = 0
𝛿′ 𝐴, 1 ,1 = 𝐴, 1 𝜆 𝐵, 1 = 1
𝛿′ 𝐵, 0 ,0 = 𝐵, 1 𝜆 𝐶, 0 = 0
𝛿′ 𝐵, 1 ,0 = 𝐵, 1 𝜆 𝐶, 1 = 0
𝛿′ 𝐵, 0 ,1 = 𝐶, 1
𝛿′ 𝐵, 1 ,1 = 𝐶, 1
𝛿′ 𝐶, 0 ,0 = 𝐴, 0
𝛿′ 𝐶, 1 ,0 = 𝐴, 0
𝛿′ 𝐶, 0 ,1 = 𝐶, 0
𝛿′ 𝐶, 1 ,1 = 𝐶, 0
• Figure 3.4 shows the state diagram of the 𝑀10 Mealy machine and
the equivalent Moore machine. According to Lemme 3.2, when
finding a Moore machine equivalent to a Mealy machine, the states
of the Moore machine should be represented by the pairs [state
name, output symbol].
Figure 3.4 𝑀10 Mealy machine and 𝑀10 ′ equivalent Moore machine
Only after the equivalent Moore machine is found its states can be
renamed. As a matter of fact, the state diagram of the 𝑀10 ′ Moore
machine seen in Figure 3.5, the states of the machine are renamed as:
𝐴, 0 → 𝑞0
𝐴, 1 → 𝑞1
𝐵, 0 → 𝑞2
𝐵, 1 → 𝑞3
𝐶, 0 → 𝑞4
𝐶, 1 → 𝑞5
Figure 3.5 Moore machine – states are renamed
Example 3.4 The Mealy machine is defined as follows:
𝑀 =< 𝑄, 𝛴, 𝛥, 𝛿, 𝜆, 𝑞0 >
𝑄 = {𝑞0 , 𝑞1 }
𝛴 = {0,1}
𝛥 = 𝑎, 𝑏, 𝑐
𝑞0 is the initial state
𝛿 𝑞0 , 0 = 𝑞1 𝜆 𝑞0 , 0 =𝑎
𝛿 𝑞0 , 1 = 𝑞0 𝜆 𝑞0 , 1 =𝑐
𝛿 𝑞1 , 0 = 𝑞0 𝜆 𝑞1 , 0 =𝑏
𝛿 𝑞1 , 1 = 𝑞1 𝜆 𝑞1 , 1 =𝑎
This Mealy machine prints out caab when given the input string 1010.
Example 3.5 Design a Moore machine to generate 1's complement of a
given binary number.
Thus we get 00100 as 1's complement of 1011, we can neglect the initial 0 and the output
which we get is 0100 which is 1's complement of 1011. The transaction table is as follows:
Example 3.6 Design a Mealy machine for a binary input sequence such
that if it has a substring 101, the machine output A, if the input has
substring 110, it outputs B otherwise it outputs C.