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

时间:2015-10-06 07:37:36

标签: regex automata dfa

以下自动机是否接受表达“ 0 * 1 * 1 + 11 * 0 * 1 ”?

enter image description here

当表达式生成以'1'结尾的字符串时,我相信自动机会接受它。

但是,我在其中一个参考文献中找到了答案。有人可以解释一下吗?

注意:+表示OR操作。

1 个答案:

答案 0 :(得分:2)

No. Your DFA is equivalent to the expression (0*1+)+

The expression that you've specified requires at least three 1 to be accepted. 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:

enter image description here

Image created with the Regex visualizer, which allows you to generate these graphs from regular expressions.

Update: If + means or, this changes things. Your original DFA is still not equivalent. 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. The DFA for the expression looks like this:

enter image description here

As generated by inputting 0*1*1|11*0*1 into the visualizer.