RE- basics
RE- basics
Regular Languages
Define: Regular Expression
14. The regular expression for the language starting with a but not having
consecutive b's is R = {a + ab}*
15. The regular expression for the language accepting all the string in
which any number of a's is followed by any number of b's is followed
by any number of c's is R = a* b* c*
16. The regular expression for the language over ∑ = {0} having even length of
the string is R = (00)*
17. The regular expression for the language having a string which should
have atleast one 0 and alteast one 1 is
R = [(0 + 1)* 0 (0 + 1)* 1 (0 + 1)*] + [(0 + 1)* 1 (0 + 1)* 0 (0 + 1)*]
18. The language consists of the string in which a's appear triples,
there is no restriction on the number of b's is r.e. = (b* (aaa)* b*)*
19. The regular expression for the language L over ∑ = {0, 1} such that all the
string do not contain the substring 01 is R = (1* 0*) (Since
L = {ε, 0, 1, 00, 11, 10, 100, .....} )
20. The regular expression for the language containing the string over {0, 1}
in which there are at least two occurrences of 1's between two
occurrences of 0's.
Solution: At least two 1's between two occurrences of 0's can
be denoted by (0111*0)*.
Similarly, if there is no occurrence of 0’s(zero occurrenc of ZERO), then
any number of 1's are also allowed.
Hence the r.e. for required language is R = (1 + (0111*0))*
21. The regular expression for the language containing the string in
which every 0 is immediately followed by 11 is R = (011 + 1)*
22. The set of strings that alternate 0’s and 1’s
(01)∗+ 1(01)∗+ (01)∗0+ 1(01)∗0
23. Set of strings of odd length- ((a+b)(a+b))* (a+b)
24. Set of strings whose length divisible by 3 –
( (a+b) (a+b) (a+b))*
If it is 2 mod 3=2 -> ( (a+b) (a+b) (a+b))* (a+b) (a+b)
Languages associated with regular
expressions
Exhibit the language L(a* . (a + b)) in set notation
L(a* . (a + b)) = L(a*) . L( (a + b))
= (L(a))*. L(a + b))
= (L(a))*. L(a) U L(b)
= { a }*. { a } U { b }
= {, a, aa, aaa,. . . }. { a, b}
= {a, aa, aaa, aaaa,. . . ,b, ab, aab, aaab,. . . }
Languages associated with regular
expressions
r = (a + b)*. (a + bb), find L(r)
L(r) = L((a + b)*. (a + bb))
= L((a + b)*). L(a + bb)
= (L(a + b))*. L(a + bb)
= (L(a) U L(b))* . L(a) U L(bb)
= {a, b}* . {a} U {b}.{b}
= {a, b}* . {a} U {bb}
= {a, b}* . {a, bb}
= {, a, b, aa, ab, ba, bb,. . .} . {a, bb}
= {a, aa, ba, aaa, aba, baa, bba,. . .,bb, abb, bbb, aabb, abbb, . . .}
Examples
Describe the following sets by regular expressions
1) L1 = the set of all strings of 0’s and 1’s ending with 00- (0 + 1)*00
2) L2 = the set of all strings of 0’s and 1’s and beginning with 0 and ending with
1 - 0(0 + 1)*1
3) L3 = {, aa, aaaa, . . . } - (aa)*
4) The set of all strings of 0’s and 1’s with at least two consecutive zeros - (0 +
1)*00(0 + 1)*
5) The set of all strings of a’s and b’s whose length is divisible by 6 - [(a + b)6]*
6) The set of all strings of a’s and b’s whose 5th last symbol is b - (a + b)4b(a +
b)*
7) The expression r = (aa)* (bb)*b denotes the set of strings with an even
number of a’s followed by an odd number of b’s - L(r) = {a2n b2m+1 / n ≥ 0 , m
≥0}
8) L4 = {an bm / n ≥ 4 , m ≤ 3} - aaaaa*(b + bb + bbb)
Examples
1) (0 + 1)*00
2) 0(0 + 1)*1
3) (aa)*
4) (0 + 1)*00(0 + 1)*
5) [(a + b)6]*
6) (a + b)4b(a + b)*
7) L(r) = {a2n b2m+1 / n ≥ 0 , m ≥ 0 }
8) aaaaa*(b + bb + bbb)
Converting RE to FA
Design a NFA from given regular expression
1 (1* 01* 01*)*.