1. (HU, Exercise 6.1(a)) Show that { ai bj ck | i < j < k} is not a context-free language.
2. (HU, Exercise 6.1(d))
Show that
{ x ∈ (a+b+c)* |
#a(x) = #b(x) = #c(x) }
is not a context-free language.
Hint: Recall Example 6.1 and Theorem 6.5.
3. (HU, Exercise 6.2(a))
Show that
{ ai bj | i ≠ j ∧
i ≠ 2j }
is context-free.
Hint: Recall Theorem 6.1.
4. (HU, Exercise 6.2(c))
Show that { wwRw | w ∈ (a+b)* }
is not context-free.
Hint: Use
a+b+a+b+
and Theorem 6.5 to reduce this to a simpler problem.
5. (HU, Exercise 6.17) Use the CYK algorithm to determine whether aaaaaa is a member of the language generated by the grammar of Example 6.7. (Show the matrix.)
6. (HU, Exercise 6.18)
Let G be a CFG in Chomsky Normal Form.
(a) Augment the CYK algorithm so that it can determine, for a given
string x, the number of distinct derivation trees yielding
x. (The book omits "trees", which seems to be a mistake.)
(b) Augment the CYK algorithm so that it can determine, for a given
string x, the minimum-cost derivation of x.
(Each production has an associated cost; the cost of a derivation is the
sum of the costs of the individual steps. Each step's cost is that of
the production used in that step.)
7. (HU, Exercise 6.11) A CFG is linear if none of its productions has more than one nonterminal on its right side. A language is linear if it is generated by a linear CFG. Prove the following pumping lemma for linear languages:
If L is a linear language, there exists a constant n such that if z∈L is of length n or greater, we may write z = uvwxy such that |uvxy| ≤ n, |vx| > 0, and, for all i≥0, uviwxiy ∈ L.
8. Prove that for every CFL L there is a CFG G generating L such that every w∈L of length two or more has a derivation in G of length less than |w|. (Note that the length of a derivation is equal to the number of uses of productions in it. For example, S ⇒ aB ⇒ aba has length two.)
9. (HU, Exercise 6.8, difficult) Show that if L ⊆ a* is context-free, it is also regular. (See hint in HU.)