[MUST, SE350]
For DFA and NFA, these finite automatons (FAs) only read inputs, while there do exist some other FAs that read not only inputs but also produce outputs. And now, we are going to introduce Mealy and Moore with not only reading inputs but also producing outputs.
Mealy finite automaton
Definition (Mealy finite automaton description)
A Mealy machine is a 6-tuple ( Q , s , Σ , Z , δ , G ) (Q, s, \Sigma, Z,\delta, G) (Q,s,Σ,Z,δ,G), where:
- Q Q Q is a finite set of states
- s ∈ Q s\in Q s∈Q is the start state
- ∑ \sum ∑ is a finite collection of inputs
- Z Z Z is a finite collection of outputs
-
δ
\delta
δ is a set of directed transitions
Q
×
Σ
→
Q
Q\times \Sigma\rarr Q
Q×Σ→Q
- remark: This ugly equation represents that “one state among the set of states Q Q Q reach to the other states in Q Q Q through one of the input in the input set Σ \Sigma Σ”
- G G G is a set of output functions Q × Σ → Z Q\times\Sigma\rarr Z Q×Σ→Z
📌 Sometimes, δ \delta δ and G G G can be merged into a single function. For instance,
δ : Q × Σ → Q × Z \delta: \space Q\times\Sigma\rarr Q\times Z δ: Q×Σ→Q×Z
Exercise
1.1 Mealy Description
Solution
Firstly, we have M = { Q , Σ , δ , s , F , Z } M = \{Q, \Sigma,\delta,s,F,Z\} M={Q,Σ,δ,s,F,Z}. Then
Q
=
{
A
,
B
,
C
}
Σ
=
{
a
,
b
}
s
=
A
F
=
∅
Z
=
{
0
,
1
}
,
Q = \{A, B, C\}\\ \Sigma = \{a, b\}\\ s = A\\ F = \empty\\ Z = \{0, 1\},
Q={A,B,C}Σ={a,b}s=AF=∅Z={0,1},
where
F
F
F is a set of final states and
Z
Z
Z is a collection of outputs.
Then δ \delta δ is
Present State | Input | Next State | Output |
---|---|---|---|
A | a | B | 0 |
b | C | 0 | |
B | a | B | 0 |
b | C | 1 | |
C | a | B | 1 |
b | C | 0 |
1.2 Draw the Mealy base on the given set of directed transitions δ \delta δ.
Present State | Input | Next State | Output |
---|---|---|---|
A | a | A | b |
b | B | a | |
B | a | C | - |
b | B | a | |
C | a | A | a |
b | D | a | |
D | a | A | b |
b | D | - |
Solution
Moor finite automaton
Definition (Moor finite automaton description)
A Moor machine is a 6-tuple ( Q , s , Σ , Z , δ , G ) (Q, s, \Sigma, Z,\delta, G) (Q,s,Σ,Z,δ,G), where:
- Q Q Q is a finite set of states
- s ∈ Q s\in Q s∈Q is the start state
- ∑ \sum ∑ is a finite collection of inputs
- Z Z Z is a finite collection of outputs
-
δ
\delta
δ is a set of directed transitions
Q
×
Σ
→
Q
Q\times \Sigma\rarr Q
Q×Σ→Q
- remark: This ugly equation represents that “one state among the set of states Q Q Q reach to the other states in Q Q Q through one of the input in the input set Σ \Sigma Σ”
- G G G is a set of output functions Q × Σ → Z Q\times\Sigma\rarr Z Q×Σ→Z
📌 Sometimes, δ \delta δ and G G G can be merged into a single function. For instance,
δ : Q × Σ → Q × Z \delta: \space Q\times\Sigma\rarr Q\times Z δ: Q×Σ→Q×Z
💡As you can see, the Definition (or says Moor finite automaton description) is exactly the same as Mealy. And the only difference between these two automatons reveals in the diagram.
📌 The output is associated with states on Moore while it’s associated with transitions on Mealy. Later on, you will see the difference by looking at the diagram of Moore.
Exercise
2.1 Moore Description
How to describe this Moore?
Solution
Firstly, we have M = { Q , Σ , δ , s , F , Z } M = \{Q, \Sigma,\delta,s,F,Z\} M={Q,Σ,δ,s,F,Z}. Then
Q = { q 0 , q 1 , q 2 , q 3 , q 4 } Σ = { 0 , 1 } s = q 0 F = ∅ , Q = \{q_0,q_1,q_2,q_3,q_4\}\\ \Sigma = \{0, 1\}\\ s = q_0\\ F = \empty, Q={q0,q1,q2,q3,q4}Σ={0,1}s=q0F=∅,
where Q Q Q is a set of states, Σ \Sigma Σ is a finite collection of inputs, s s s is the start state, and F F F is a set of final states.
The directed transition δ \delta δ is
Present State | 0 | 1 | output |
---|---|---|---|
q 0 q_0 q0 | q 1 q_1 q1 | q 2 q_2 q2 | 0 |
q 1 q_1 q1 | q 1 q_1 q1 | q 3 q_3 q3 | 0 |
q 2 q_2 q2 | q 4 q_4 q4 | q 2 q_2 q2 | 0 |
q 3 q_3 q3 | q 4 q_4 q4 | q 2 q_2 q2 | 1 |
q 4 q_4 q4 | q 1 q_1 q1 | q 3 q_3 q3 | 1 |
📌 remark: To speed this dumb 🐒 movement, just like what we mentioned above, Moore is associated with the states while Mealy is associated with transitions. So, we can quickly write down the output by just looking at its associated states and totally ignoring the inputs.
2.2 Draw the Moore base on the given set of directed transitions δ \delta δ.
Present State | Input | Next State | Output |
---|---|---|---|
A | 0 | A | 0 |
1 | B | ||
B | 0 | E | 0 |
1 | C | ||
C | 0 | D | 1 |
1 | C | ||
D | 0 | A | 1 |
1 | F | ||
E | 0 | A | 0 |
1 | F | ||
F | 0 | E | 1 |
1 | C |
Solution
Step1: With the remark, we can rapidly write down the states:
Step2: We assume that
A
A
A is the start state so that we have
Exercise
3 Conversion
3.1.1 Convert Mealy to Equivalent Moore (TYPE: Conversion based on the given graph)
Solution
📌 Note: ‘transition’ is the directed link/path/edge (whatever you want to call it) on the diagram above.
📌 Note that the red color-code line is pretty tricky and don’t forget to draw them. Since
C
/
0
C/0
C/0 and
C
/
1
C/1
C/1 are exactly the same ones. For Mealy both of them should have the transition of the same inputs
a
a
a and
b
b
b, and so do
B
/
0
B/0
B/0 and
B
/
1
B/1
B/1. Furthermore, at this question, there’s nothing to do with the state
A
A
A since there are not any outputs associated with the state
A
A
A, says
A
/
0
A/0
A/0 and
A
/
1
A/1
A/1. But later on, you might need to deal with the scenario that there are
A
/
0
A/0
A/0 and
A
/
1
A/1
A/1 during the Mealy to Moore conversion. So, to tackle that correctly, we (a) randomly take one of them as the start state (says, just take
A
/
0
A/0
A/0 as the start state, but
A
/
1
A/1
A/1 is also correct though 🤷♂️), and the same as what we did so far, © check if both of them (
A
/
0
A/0
A/0 and
A
/
1
A/1
A/1) have the same transition of input
a
a
a and
b
b
b.
3.1.2 One more for award 👼 (TYPE: Conversion based on the given graph)
Mealy to Equivalent Moore
Solution
📍 Here is use
LaTeX
\LaTeX
LATEX notation ‘q_0’ to denote
q
0
q_0
q0 and the same for
q
1
→
q
2
q_1 \rarr q_2
q1→q2
Do you think that you finished this problem perfectly? No, not at all 💩.
For
q
2
q_2
q2, the added states are
q
2
/
0
q_2/0
q2/0 and
q
2
/
1
q_2/1
q2/1. So, all of those added states should keep the transitions corresponding to the same inputs, says
a
a
a and
b
b
b here. — the second time emphasizing this ‘transition’ stuff 😋.
So, the complete answer is
📌 remark again: All added states should keep the transitions corresponding to the same, origin inputs. E.g. The origin transitions for
q
2
q_2
q2 is corresponding to inputs
a
a
a and
b
b
b, so, its added states
q
2
/
0
q_2/0
q2/0 and
q
2
/
1
q_2/1
q2/1 should have the transitions with the inputs
a
a
a and
b
b
b as the origin. So, both of them have two branches
a
a
a and
b
b
b to other states.
3.2.1 Convert Mealy to Equivalent Moore (TYPE: Conversion based on the given transition table)
This type of question is different from the two above.
The former is based on the given diagram while the latter is based on a given transition table.
So, the way to tackle the problem will be different.
Without further ado, let’s get started!
Given the following transition table of Mealy, please finish Mealy to Equivalent Moore conversion.
The follow suit:
Notice those ugly handwrite digits at the problem specification above? It’s quite meaningful though 🌝.
Step1: Determine the added states
We can determine the added states by looking at the ‘Next State’ and ‘Output’ columns.
- And we notice that for q 1 q_1 q1, there is only one possible output 1 1 1. So, no state should be added. We just keep q 0 q_0 q0later on.
- For q 1 q_1 q1, you can find that two possible outputs ( 0 0 0 and 1 1 1) are presented. So, two states, q 1 / 0 q_1/0 q1/0 and q 1 / 1 q_1/1 q1/1 should be added.
And so on and so forth, you can find if additional states should be added or just keep the origin one for q 2 q_2 q2 and q 3 q_3 q3.
Step2: Write down the state under the ‘Present State’ column on the new transition table.
The present states are:
q
0
,
q
10
q_0, q_{10}
q0,q10 (denotes
q
1
/
0
q_1/0
q1/0),
q
11
,
q
20
,
q
21
,
q
3
q_{11},q_{20},q_{21},q_{3}
q11,q20,q21,q3.
Present State | a | b | Output |
---|---|---|---|
q 0 q_0 q0 | |||
q 10 q_{10} q10 | |||
q 11 q_{11} q11 | |||
q 20 q_{20} q20 | |||
q 21 q_{21} q21 | |||
q 3 q_3 q3 |
Step3: Full out the ‘output’ column using the discussed remark (the output of the state in Moore is associated with the State).
Present State | a | b | Output |
---|---|---|---|
q 0 q_0 q0 | 1 | ||
q 10 q_{10} q10 | 0 | ||
q 11 q_{11} q11 | 1 | ||
q 20 q_{20} q20 | 0 | ||
q 21 q_{21} q21 | 1 | ||
q 3 q_3 q3 | 0 |
Step4: Full out the rest of the new transition table. (I skip the result displaying of this step since it’s exactly the solution we needed)
Solution
Present State | a | b | Output |
---|---|---|---|
q 0 q_0 q0 | q 3 q_3 q3 | q 11 q_{11} q11 | 1 |
q 10 q_{10} q10 | q 0 q_0 q0 | q 3 q_3 q3 | 0 |
q 11 q_{11} q11 | q 0 q_0 q0 | q 3 q_3 q3 | 1 |
q 20 q_{20} q20 | q 21 q_{21} q21 | q 20 q_{20} q20 | 0 |
q 21 q_{21} q21 | q 21 q_{21} q21 | q 20 q_{20} q20 | 1 |
q 3 q_3 q3 | q 10 q_{10} q10 | q 0 q_0 q0 | 0 |
📌 Remark: Do you see some badass hiding in the transition table above?
Yeah, these guys are
q
10
q_{10}
q10 and
q
11
q_{11}
q11,
q
20
q_{20}
q20 and
q
21
q_{21}
q21
The tuples of
q
10
q_{10}
q10 and
q
11
q_{11}
q11 are the same.
The tuples of
q
20
q_{20}
q20 and
q
21
q_{21}
q21 are the same.
This is due to the fact that they are added states for
q
1
q_1
q1 and
q
2
q_2
q2, respectively. Both of them should have the same input transition. In other words, both of them should have the branches from input
a
a
a and
b
b
b. So
q
10
q_{10}
q10 and
q
11
q_{11}
q11 should have the same branch as their boss,
q
1
q_1
q1 on the Mealy transition table. By referring to the Mealy transition table, you can find that
q
1
→
a
q
0
q_1\xrightarrow{a}q_0
q1aq0 and
q
1
→
b
q
3
q_1\xrightarrow{b}q_{3}
q1bq3 so that in the new transition table,
q
0
q_0
q0 and
q
3
q_3
q3 are filled into the column ‘next state of input
a
a
a and
b
b
b’.
So, next time we can just make duplication those tuples for the added states.
⏰ Later on, I will organize the part of Conversion from Moore to Mealy. Stay tuned~