如何检查特定的粉机是否可以生成特定的输出?
如果我有一台 Mealy 机器,并且有一个大字符串,我如何检查 Mealy 机器是否可以生成该字符串?
我考虑过将粉状机器转换为正则表达式,但我也不清楚如何做到这一点。
谢谢。
if I have a mealy machine, and I have a large string, how can I check if the mealy machine can generate that string?
I thought about converting the mealy machine to a regexp, but I am not clear on how to do that either.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会从最后开始。反转所有方向(是的,这意味着门现在可以接收一个值并输出两个值),并以相反的顺序使用字符串作为输入。每当你到达某个门或黑匣子元素时,你就会得到它的输出;找出所有可能导致该输出的输入,并继续不确定地向后进行。
如果在字符串末尾到达某个输入(或一组输入),则该(或那些)输入就是生成给定字符串的输入。否则,该机器无法生成该字符串。
一种不同的方法(有时更简单,有时不是)是尝试查看机器生成的所有字符串是什么,或者尝试找到所有这些字符串必须满足的某个属性,而给定的字符串则不满足(例如,如果你不知道机器生成的确切字符串是什么,但你知道它们都以“A”开头,而给定的字符串则不然)。
I would start at the end. Reverse all directions (yes, that means that a gate may now receive one value and output two), and use the string as input, in reverse order. whenever you reach some gate or black box element, you have it's output; figure out all possible inputs that would lead to that output, and continue going backwards non-deterministically.
If at the end of the string you reach some input (or a group of inputs), then that (or those) input is an input that produces the given string. Otherwise, the string isn't generate-able by that machine.
A different approach (sometimes simpler, sometimes not), would be to try and see what are all the strings that the machine generates, or try and find some attribute that all those strings must satisfy, and that the given string does not (e.g. if you don't know exactly what strings aer generated by the machine, but you know they all start with "A", and the given string doesn't).