Regular expressions - They are the same regular expressions?

snnlankrdsm

I have two questions. Are those regular expressions are the same?

(1) b*(ab*)* and (b*a)*b *

(2) b*(aaab*)* and (b*aaa) * b*

I feel like they both create language that have worlds palindrome. Is that right? In the first one, both a's are must and b's are zero or unlimited. The second one is the same. the string aaa is a must in both and b's are zero or unlimited.

Am I right?

Freek Wiedijk

In both cases, the two regular expressions are not the same (they are different regular expressions), but they do describe the same language. So the answer to both questions (from your exercises?) is "yes".

In the first case the regular expressions describe the language of any string of a's and b's. In the second case you get the language where all a's occur in triples, as the combination aaa. This first language also is described by the regular expression (a|b)* (or (a + b)*, or (a U b)*, I don't know what notation your book uses), and the second language also is described by the regular expression (aaa|b)*.

In both cases the languages stay the same if you reverse the elements, and therefore, if you reverse the regular expressions that describe them, they stay the same as well.

Palindromes are words that themselves stay the same if you reverse them. But both languages have elements that are not palindromes, like for example the word aaab, because aaab != baaa. So talking about palindromes is not the right argument here.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related