简体   繁体   English

不以01结尾的字符串的自动机正则表达式

[英]Regular Expression for Automata for Strings that do not end in 01

Automata for strings that do not end with 01. 不以01结尾的字符串的自动机。

I cannot obtain the regular expression for the Automata with alphabet={0,1} that generates the strings that do not end with 01. 我无法获得带有字母= {0,1}的自动机的正则表达式,该正则表达式生成不以01结尾的字符串。

Here is the state diagram: 这是状态图:

State Diagram 状态图

I get this state diagram with the Visual Automata Simulator tool by Matthew McClintock, so I tested some strings like empty string e, "0","1","00","10","11" and the ones that do not end with 01, and it seems to work. 我使用Matthew McClintock的Visual Automata Simulator工具获得了此状态图,因此我测试了一些字符串,例如空字符串e,“ 0”,“ 1”,“ 00”,“ 10”,“ 11”和那些不以01结尾,似乎可行。

Can you help me to obtain the regular expression?. 您能帮我获得正则表达式吗? I didn't have formal introduction to computer automata theory, so I barely understand the concepts of dfa,nfa and the nomenclature is kind of strange to me. 我没有对计算机自动机理论进行正式介绍,因此我几乎不了解dfa,nfa的概念,因此该术语对我来说有点奇怪。

I tried to obtained the regexp, one was: 我试图获得正则表达式,其中一个是:

(0+1)*(00+10+11) (0 + 1)*(00 + 10 + 11)

but I no sure if that is correct. 但我不确定这是否正确。

Then according to the diagram I have tried things like: 然后根据该图,我尝试了以下操作:

1*(00*1+0+0*1)*+1(00*1+0*1)* 1 *(00 * 1 + 0 + 0 * 1)* + 1(00 * 1 + 0 * 1)*

Or things like that. 或类似的东西。 Do you know were can I test regular expressions? 您知道我可以测试正则表达式吗?

You should at least come up with this DFA: 您至少应该提出以下DFA:

Then use the steps described here to solve for the regular expression. 然后使用此处描述的步骤来求解正则表达式。

R1 = 1R1 + 0R2 +       λ
R2 =       0R2 + 1R3 + λ
R3 = 1R1 + 0R2

The rest is left to you as an exercise. 剩下的作为练习留给您。

As I said in the comments, you were pretty close in your first attempt. 正如我在评论中所说,您的第一次尝试非常接近。 This should work: 这应该工作:

(0+1)*(00+10+11)+0+1+ε

or, in programmer dialect, 或者,以程序员的方言,

^([01]*(00|10|11)|0|1|)$

EDIT: Thank you nhahtdh, indeed I had. 编辑:谢谢nhahtdh,的确是我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM