简体   繁体   中英

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) . I think (b) and (c) should also be answers. 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. 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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