0

I'm having problem understanding regular expression.

I was trying this exercise:

Over the alphabet {a,b}, create a regular expression that:

A) Accept all the words that contains at least one occurrence 'a' or 'b'.

epsilon*(a U b )

B) Accept all the words that have at maximum three 'a´s'

C)All the words that ends with double letters (eg. abb ou abaa)

epsilon*( aa U bb)

D)The words has exact one occurrence three aaa( eg. abaaab or baaab)

So, as you can see i'm having a lot of problems with regular expressions, i did the A and C ,but i think they're wrong, B e D i have no idea how to do.

Can i have some help..

user3645265
  • 703
  • 1
  • 6
  • 11

1 Answers1

1

A) Σ*.(a + b)
B) b* + b*.a.b* + b*.a.b*.a.b* + b*.a.b*.a.b*.a.b*
C) Σ*.(aa + bb)
D) (a.b + a.a.b + b*)*.aaa.(b.a + b.a.a + b*)*

You got A) and C) right idea-wise. Also, it's Sigma for alphabet, not epsilon. And you do not use U in regular expressions. It is expressed with the + symbol. Only operations allowed are:
∅ - the empty set
ε - the empty word
a, b - terminals in the alphabet
+ for unification
* for 0+ symbols
. for concatenation

blurry
  • 114
  • 2
  • 9