简体   繁体   English

自动机正则表达式

[英]Automata regular Expression

I have this homework question. 我有这个作业问题。

Which pair of regular expressions are equivalent?
a) (ab)* and a*b*
b) r(rr)* and (rr)*r
c) r+ and r*r
d) (b) and (c)

I have been told that the answer is (d) . 有人告诉我答案是(d) I think (b) and (c) should also be answers. 我认为(b)(c)也应该是答案。 Can someone clarify this for me? 有人可以帮我澄清一下吗?

The first thing you should try is writing out a few simple strings in each language. 您应该尝试的第一件事是用每种语言编写一些简单的字符串。 If you find one that's in the language of one RE but not the other, you can check to make sure and, if so, you're done. 如果您发现一种语言是一种RE的语言,而另一种语言不是,则可以进行检查以确保您已经完成。 Here's what that looks like for these: 这些是这样的:

(a)
 - (ab)*: e, ab, abab, ababab, ...
 - a*b* : e, a, b, aa, ab, bb, ...
 guess: a is in L(a*b*) but not (ab)*.
 check: (ab)* only generates strings with the same number of a's as b's.
 L((ab)*) != L(a*b*)

(b)
 - r(rr)*: r, rrr, rrrrr, rrrrrrr, ...
 - (rr)*r: r, rrr, rrrrr, rrrrrrr, ...
 guess: these look the same.
 proof: the first generates all and only strings of r's of odd length.
        the second generates all and only strings of r's of odd length.
        these languages are the same.
        alternatives:
        - derive DFAs L and R and show DFAs for L \ R and R \ L accept
          the empty language.

(c)
 - r+ : r, rr, rrr, rrrr, ...
 - r*r: r, rr, rrr, rrrr, ...
 guess: these look the same.
 proof: the first generates all and only non-empty strings of r's.
        the second generates all and only non-empty strings of r's.
        these languages are the same.
        alternatives:
        - derive DFAs L and R and show DFAs for L \ R and R \ L accept
          the empty language

Based on the above, the most correct answer would appear to be (d). 基于上述情况,最正确的答案似乎是(d)。

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

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