练习:有限状态机测试

练习:有限状态机测试

1 FSM 示例
在练习中,我们将使用两个 FSM。 两者都有输入字母 X = {a, b} 和输出字母 Y = {0,1}。 第一个 FSM 将称为 M1 并由以下有向图表示。
在这里插入图片描述

对于上面给出的每个 FSM Mi:
1.确定以下值,显示您的工作。
(a) δ*(s0, abbab)。
(b) λ*(s0, abbab)。

δ is a state transfer function of type S x X ->S
λ is a output function of type S x X ->Y
For M1, so (a) is {s1,s0,s3,s2,s3} and (b) is abbab
For M2, so (a) is {s0,s1,s2,s3,s2} and (b) is abbab

2.对于 Mi 的每个状态 s,找到一个使 Mi 从其初始状态到状态 s 的输入序列。 在每种情况下,确定这是否是最短的此类输入序列。

For M1:
to s1,(s0,s1,a/0)
to s2,(s0,s1,a/0) (s1,s2,a/1)
to s3,(s0,s3,b/1)

For M2:
to s1,(s0,s1,b/0)
to s2,(s0,s1,b/0) (s1,s2,b/1)
to s3, (s0,s1,b/0) (s1,s2,b/1) (s2,s3,a/0)

3.导出过渡游。
For M1,
(s0,s3,b/1) (s3,s3,b/0) (s3,s2,a/1) (s2,s0,a/0) (s0,s1,a/0) (s1,s0,b/1) (s0,s1,a/0) (s1,s2,a/1) (s2,s3,b/1)

For M2,
(s0,s0,a/0) (s0,s1, b/0) (s1,s0,a/0) (s0,s1, b/0) (s1,s2,b/1) (s2, s3,a/0) (s3,s3,a/1) (s3,s2,b/1) (s2,s0,b/0)

4.评论这是否是最短的过渡游。 如果不是,则生成最短的过渡行程。
yes it is

在这里插入图片描述
在这里插入图片描述
3 FSM 示例
相同的 M1 和 M2

对于上面给出的每个 FSM Mi:

  1. 判断Mi的每个状态是否有UIO。
  2. 哪里有一个状态的UIO,就找到这样一个UIO。
  3. 为 Mi 找到一个特征集。
  4. 应用 W 方法(无额外状态)。

For M1
在示例中,b/0 为状态 s3 形成一个 UIO:
从状态 s0 输出序列为 1
从状态 s1 输出序列为 1
从状态 s2 输出序列为 1
从状态 s3 输出序列为 0

because s3 has UIO so that in order to go to s3 so that
t = (s0,s3,b/1)
so through b could go to

state aa
s0 01
s1 10
s2 00
s3 10
state ab
s0 01
s1 11
s2 01
s3 00

V is {empty,a,aa,b)
W IS {aa,ab}
X is {a,b}

Answers:
在这里插入图片描述
if there did not give the m, then we normally consider m = n so that is V W U V X W
if m = n+1, then
V W U V X W U V XX W

and the reason it only therefore obtain V X W is because it automatically included V W

For M2
在示例中,a/1 为状态 s3 形成一个 UIO:
从状态 s0 输出序列为 0
从状态 s1 输出序列为 0
从状态 s2 输出序列为 0
从状态 s3 输出序列为 1
and b/0 did not have because s0 and s2 would produce that
and b/1 not have because s3 and s1 have so that
only s3 has a UIO and s0,s1,s2 did not have.

because s3 has UIO so that in order to go to s3 so that
t = (s0,s1,b/0) (s1,s2,b/1) (s2,s3,a/0)
so through bba could go to

state b
s0 0
s1 1
s2 0
s3 1
state ab
s0 00
s1 00
s2 01
s3 11

V is {empty, b,bb,bba}
W is {b,ab}
X is {a,b}
####################################################################

这道题会用到下面的有限状态机(FSM),简称为M0。 请注意,s0 是 M0 的初始状态。
在这里插入图片描述
a) 确定是否:

  1. M0初接;
  2. M0是强连通的;
  3. M0 最小。
    在每种情况下解释所考虑的属性的含义(定义属性)并证明您的答案。 [40%]

the FSM is initially connected and using a breadth-first search is a good way of showing this.
There are several ways to show strongly-connected. Main one is: for each pair (si,sj) of distinct states, give a path from si to sj.
It should also be minimal - ie for each pair of distinct states (si,sj) there should be an input sequence that separates them.

b) 制作 M0 的过渡之旅,证明您的答案是正确的。 [20%]

(s0,s0,b/0) (s0,s1,a/0) (s1,s2,b/0) (s2,s1,a/0) (s1,s2,b/0)
(s2,s3,b/0) (s3,s3,a/1) (s3,s1,b/1) (s1,s3,a/0) (s3,s1,b/1)

c) 将没有额外状态的 W 方法应用于 M0。 你应该证明你的答案(解释你的工作)。 [40%]
V W U V X W

explain the reason why Two FSMs are equivalent if their initial states are equivalent
如果两个 FSM 的初始状态是等价的,则它们是等价的,因为初始状态决定了计算的起点。 如果初始状态相同,则两个 FSM 以相同状态开始,并针对给定输入遵循相同的转换序列,从而导致相同的输出和行为。
Two FSMs are equivalent if their initial states are equivalent because the initial state determines the starting point for computation. If the initial states are equivalent, both FSMs start in the same state and follow the same sequence of transitions for a given input, leading to the same output and behavior.

explain why An FSM M is minimal if no smaller (in terms of number of states) FSM defines the same regular language.

如果没有其他具有较少状态的 FSM 定义相同的正则语言,则 FSM M 是最小的。 换句话说,没有办法在不失去识别相同语言的能力的情况下减少 M 中的状态数。 如果存在较小的 FSM,则意味着 M 中的某些状态是多余的或不必要的。 但是,由于 M 已经识别该语言,因此删除任何状态都会改变其行为。 因此,M 被认为是最小的,因为它具有识别给定常规语言所需的最少状态数。
An FSM M is minimal if there is no other FSM with a smaller number of states that defines the same regular language. In other words, there is no way to reduce the number of states in M without losing its ability to recognize the same language. If a smaller FSM existed, it would imply that some states in M are redundant or unnecessary. However, since M already recognizes the language, removing any state would change its behavior. Therefore, M is considered minimal as it has the smallest number of states required to recognize the given regular language.

explain why If an FSM M is initially-connected then it is minimal if and only if no pair of distinct states of M are equivalent
如果 FSM M 是初始连通的,则意味着 M 中的每个状态都可以从初始状态通过一系列转换到达。 在这种情况下,M 是最小的当且仅当 M 中没有一对不同的状态是等价的。
如果 M 中有一对等价的不同状态,则意味着语言表示中存在冗余。 通过将这些等效状态合并为一个状态,我们将获得一个较小的 FSM,但仍能识别相同的语言。 这与 M 的最小性相矛盾。
相反,如果 M 是最小的,则意味着在不更改其识别的语言的情况下不能合并任何状态。 因此,每一对不同的状态必然有不同的行为,它们不可能等价。
因此,在初始连接的 FSM 中,不存在等效的不同状态对是极小性的充分必要条件。

If an FSM M is initially-connected, it means that every state in M can be reached from the initial state through a sequence of transitions. In this case, M is minimal if and only if no pair of distinct states in M are equivalent.
If there were a pair of distinct states in M that are equivalent, it would imply that there is redundancy in the representation of the language. By merging these equivalent states into a single state, we would obtain a smaller FSM that still recognizes the same language. This contradicts the minimality of M.
Conversely, if M is minimal, it means that no states can be merged without changing the language it recognizes. Therefore, every pair of distinct states must have distinct behaviors, and they cannot be equivalent.
Thus, in an initially-connected FSM, the absence of equivalent pairs of distinct states is a necessary and sufficient condition for minimality.

猜你喜欢

转载自blog.csdn.net/kirsten111111/article/details/131079323