简体   繁体   中英

Automata-Regular Expression

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..

A) Σ*.(a + b)
B) b* + b*.ab* + b*.ab*.ab* + b*.ab*.ab*.ab*
C) Σ*.(aa + bb)
D) (ab + aab + b*)*.aaa.(ba + baa + 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

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