简体   繁体   English

有限自动机到正则表达式澄清

[英]FInite automata to regular expression clarification

Can you check on this: https://dl.dropbox.com/u/25439537/finite%20automata.png 您可以检查一下吗: https : //dl.dropbox.com/u/25439537/finite%20automata.png

This is a checked homework, so don't worry. 这是一项已检查的作业,请不要担心。 I just want to clarify whether my answer is correct or not, because it is marked by my teacher as incorrect. 我只想澄清我的答案是否正确,因为我的老师将其标记为不正确。

My answer is ((a+b)(a+b))*a The first (a+b) signifies the upper arrows. 我的答案是((a + b)(a + b))* a第一个(a + b)表示上方的箭头。 The second (a+b) signifies the lower arrows. 第二个(a + b)表示下部箭头。 The last 'a' tells us that it should always end in 'a'. 最后一个“ a”告诉我们它应始终以“ a”结尾。

I just want to record evidences from a lot of experts so that I can give it to my teacher. 我只想记录很多专家的证据,以便将其提供给我的老师。

I believe your answer is correct. 我相信您的回答是正确的。

Let's consider the whole process as two parts: (1) start with start , and go back to start ; 让我们将整个过程分为两个部分:(1)从start ,然后回到start and (2) go from start to end and accept. (2)从去startend ,并接受。 Obviously, the (1) part is a loop. 显然,(1)部分是一个循环。

For (1), starting with start , either accept b or a . 对于(1),从start ,接受ba For b , it's b(a+b) to go back. 对于b ,返回b(a+b) For a , it's a(a+b) to go back. 对于a ,返回a(a+b) So (1) is b(a+b) + a(a+b) which is (a+b)(a+b) . 所以(1)是b(a+b) + a(a+b) ,即(a+b)(a+b)

For (2), it's a '. 对于(2),它是a '。

So, the final result is (loop in (1))* (2) ie ( (a+b)(a+b) )* a . 因此,最终结果是(loop in (1))* (2)( (a+b)(a+b) )* a

Follow the description above, you can also come up with a proof of the equivalence between the two. 按照上面的描述,您还可以提供两者之间等效性的证明。 Proof part (a) every sequence accepted by the automata is in the set ((a+b)(a+b))*a ; 证明部分(a)自动机接受的每个序列都在((a+b)(a+b))*a part (b) every sequence in the set ((a+b)(a+b))*a is accepted by the automata. (b)部分中((a+b)(a+b))*a中的每个序列都被自动机接受。

Your answer is wrong , because it doesn't provide for strings starting with b . 您的答案是错误的 ,因为它没有提供以b开头的字符串。

The path (start) -> b -> a+b -> a -> (end) is accepted by your finite automaton, but not by your regex. 路径(开始)-> b-> a + b-> a->(结束)被有限自动机接受,但正则表达式不接受。 The simplest counterexample to your answer being correct is the regex's rejection of the string "baba". 正确答案最简单的反例是正则表达式拒绝字符串“ baba”。

By the way, if the teacher gave you that regex without the "end" state having two concentric circles (to indicate being an accept state) it was probably a trick question. 顺便说一句,如果老师给你的正则表达式没有带有两个同心圆(表示接受状态)的“结束”状态,那可能是一个技巧问题。 Having no accept state means your automaton rejects everything. 没有接受状态意味着您的自动机会拒绝一切。 The best way to describe that would be to just write down {} (the empty set). 最好的描述方法是写下{}(空集)。

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

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