简体   繁体   English

正则表达式0 * 1 * 1 + 11 * 0 * 1 DFA

[英]Regular expression 0*1*1+11*0*1 DFA

Will the expression " 0*1*1+11*0*1 " be accepted by the following automaton? 下面的自动机是否接受表达式“ 0 * 1 * 1 + 11 * 0 * 1 ”?

在此输入图像描述

As the expression generates strings ending with '1' , I believe the automaton will accept it. 当表达式生成以'1'结尾的字符串时 ,我相信自动机会接受它。

However, I found the answer to be otherwise in one of the references. 但是,我在其中一个参考文献中找到了答案。 Can someone please clarify it with explanation? 有人可以解释一下吗?

NOTE: + means OR operation. 注意:+表示OR操作。

No. Your DFA is equivalent to the expression (0*1+)+ 不。您的DFA等同于表达式(0*1+)+

The expression that you've specified requires at least three 1 to be accepted. 您指定的表达式要求至少接受三个1 Breaking it down into parts 把它分解成几部分

0*
1*
1+ <-- Required at least once
1  <-- Required
1*
0*
1 <-- Required

A DFA that is equivalent to your expression needs to represent this looks like this: 与您的表达式等效的DFA需要表示如下所示:

在此输入图像描述

Image created with the Regex visualizer , which allows you to generate these graphs from regular expressions. 使用Regex可视化工具创建的图像,允许您从正则表达式生成这些图形。

Update: If + means or, this changes things. 更新:如果+表示或,这会改变一切。 Your original DFA is still not equivalent. 您的原始DFA仍然不相同。 You're missing that if the accepted string starts with a 1 it will need to be followed by at least one more 1 to be accepted. 你错过了,如果接受字符串以a开头1将需要遵循由至少一个以上1被接受。 The DFA for the expression looks like this: 表达式的DFA如下所示:

在此输入图像描述

As generated by inputting 0*1*1|11*0*1 into the visualizer. 通过将0*1*1|11*0*1输入到可视化器中而生成。

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

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