CFG
CFG
S-- aS I bb
Prove that this generates the language defined by the regular expression
a*bb
S -- XYX
X aX I bXI A
Y -- bbb
Prove that this generates the language of all strings with a triple b in
(a + b)*bbb(a + b)*
S-- aX
X- aX I bX IA
S -- XaXaX
X aX I bX IA
S -SS I XaXaX I A
X-- bXI A
(iv) Prove that the language of this CFG is the set of all words in (a + b)*
(v) Show how the difficulty in part (iv) can be alleviated by adding the
production
S-- XS
two steps are interchangeable and it does not matter which comes
first, then the different derivations they give are considered "substantially the same" otherwise they are
"substantially different."
(ii) For those CFG's that do have two ways of generating the same word,
show how the productions can be changed so that the language generated stays the same but all words
are now generated by substantially
S -XbaaX IaX
X -Xa I Xb I A
What is the language this generates? Find a word in this language that can
8. (i) Consider the CFG for "some English" given in this chapter. Show
9. (i) Show how in the CFG for "some English" we can generate the
sentence:
(ii) Change the productions so that the same noun cannot have more than
10. Show that in the CFG for AE given in, this chapter we can eliminate
the nonterminal AE. In which other CFG's in this chapter can we eliminate a nonterminal?
Find a CFG for each of the languages defined by the following regular expressions.
11. ab*
12. a*b*
Find CFG's for the following languages over the alphabet I = {a,b}.
15. (i) All words that do not have the substring ab.
16. All words that have different first and last letters:
S-- AA
A -- AAA
A -- bA I Ab Ia
Prove that the language generated by these productions is the set of all words
with an even number of a's, but not no a's. Contrast this grammar with the
CFG in Problem 5.
S -- SS
S - XXX
X-- aX I Xa l b
19. Write a CFG to generate the language of all strings that have more a's
than b's (not necessarily only one more, as with the nonterminal A for
the language EQUAL, but any number more a's than b's).
{a aa aab aba baa aaaa aaab ... }
For example, if
then
context-free also.