Mealy and Moore finite automatons (FAs)

[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 sQ 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 StateInputNext StateOutput
AaB0
bC0
BaB0
bC1
CaB1
bC0

1.2 Draw the Mealy base on the given set of directed transitions δ \delta δ.

Present StateInputNext StateOutput
AaAb
bBa
BaC-
bBa
CaAa
bDa
DaAb
bD-

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 sQ 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 State01output
q 0 q_0 q0 q 1 q_1 q1 q 2 q_2 q20
q 1 q_1 q1 q 1 q_1 q1 q 3 q_3 q30
q 2 q_2 q2 q 4 q_4 q4 q 2 q_2 q20
q 3 q_3 q3 q 4 q_4 q4 q 2 q_2 q21
q 4 q_4 q4 q 1 q_1 q1 q 3 q_3 q31

📌 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 StateInputNext StateOutput
A0A0
1B
B0E0
1C
C0D1
1C
D0A1
1F
E0A0
1F
F0E1
1C

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 q1q2
在这里插入图片描述
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 StateabOutput
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 StateabOutput
q 0 q_0 q01
q 10 q_{10} q100
q 11 q_{11} q111
q 20 q_{20} q200
q 21 q_{21} q211
q 3 q_3 q30

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 StateabOutput
q 0 q_0 q0 q 3 q_3 q3 q 11 q_{11} q111
q 10 q_{10} q10 q 0 q_0 q0 q 3 q_3 q30
q 11 q_{11} q11 q 0 q_0 q0 q 3 q_3 q31
q 20 q_{20} q20 q 21 q_{21} q21 q 20 q_{20} q200
q 21 q_{21} q21 q 21 q_{21} q21 q 20 q_{20} q201
q 3 q_3 q3 q 10 q_{10} q10 q 0 q_0 q00

📌 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 q1a q0 and q 1 → b q 3 q_1\xrightarrow{b}q_{3} q1b q3 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~

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值