6 Regular Expressions 1)
Describe in English, as briefly as possible, the language defined by each of these regular expressions: a) (b ! ba) (b ! a)* (ab ! b). The set of strings over the alphabet {a, b} that start and end with b . b)
((( a*b*)* ab) ! ((a*b*)* ba))(b ! a)*. The set of strings over the alphabet {a, b} that contain at least one occurrence of ab or ba.
2)
Write a regular expression to describe each of the following languages: a) {w " {a , b}* : every a in w is immediately preceded and followed by b}. (b ! bab)*
b)
{w " {a , b}* : w does not end in ba}. # ! a ! (a ! b)* ( b ! aa )
c)
{w " {0, 1}* : $ y " {0, 1}* (|w y (|w y|| is even)}. (0 ! 1)*
d)
{w " {0, 1}* : w corresponds to the binary encoding, without leading 0’s, of natural numbers that are evenly divisible by 4}. (1(0 ! 1)* 00) ! 0
e)
{w " {0, 1}* : w corresponds to the binary encoding, without leading 0’s, of natural numbers that are powers of 4}. 1(00)*
f)
{w " {0-9}* : w corresponds to the d ecimal encoding, without leading 0’s, of an odd natural number}. (# ! ((1-9)(0-9)*))(1 ! 3 ! 5 ! 7 ! 9)
g)
{w " {0, 1}* : w has 001 as a substring}. (0 ! 1)* 001 (0 ! 1)*
h)
{w " {0, 1}* : w does not have 001 as a substring}. (1 ! 01)* 0*
n
n
5) Let L = {a b : 0 % n % 4}. b) Show an FSM that accepts L. ` a
a
b
a
b
a
b
b
b a,b
b
b a
a
b a
a
a,b
13) Show a possibly nondeterministic FSM to accept the language defined by each of the following regular expressions: d) (ba ! ((a ! bb) a*b)).
1
2
b
b
3
a
a a
4
5
b
6
b
e) (a ! b)* aa (b ! aa) bb (a ! b)*. a,b
a,b
a
a
a
a
a
a
b
14)Show a DFSM to accept the language defined by each of the fo llowing regular expressions:
a.
(aba ! aabaa)*
a a a,b
a b
b
b
b a
a,b
a)
a
b
20) For each of the following s tatements, state whether it is True or False. Prove your answer. (ab)*a = a(ba)*. True.
b)
(a ! b)* b (a ! b)* = a* b (a ! b)*. True.
c)
(a ! b)* b (a ! b)* ! (a ! b)* a (a ! b)* = (a ! b)*. False.
d)
(a ! b)* b (a ! b)* ! (a ! b)* a (a ! b)* = (a ! b)+. True.
e)
(a ! b)* b a (a ! b)* ! a*b* = ( a ! b)*. True.
f)
a* b (a ! b)* = ( a ! b)* b (a ! b)*.
True.