In: Computer Science
1. Consider the regular grammar G given below:
S → aS|aA|bB|λ
A → aA|bS
B → bB|aS
(a) Give a derivation for the strings aabbba and baaba
(b) Give an infinite language L such that L is not a subset of L(G)
(c) Give a regular expression that describes the language L(G).
(a)
aabbba
S -> (aS) -> a(aS) -> aa(bB) -> aab(bB) -> aabb(bB) -> aabbb(aS) -> aabbba() -> aabbba
baaba
S -> (bB) -> b(aS) -> ba(aS) -> baa(bB) -> baab(aS -> baaba( ) -> baaba
(c) please refer to the image below. We are constructing an NFA from the given relations. We add a starting state q and ending state f . Then we remove each intermidiary state and replacing the edges with their regular expressions until we have only q and f remaining in the NFA to get our regular expression
For part (b) we simply use our regular expression from (c) to construct a language which includes more than what our L(G) defines by including some extra language rules. All has been given in the pictures above