Professional Documents
Culture Documents
a). Which strings of 𝐿(𝐺) can be produced by applying the rules at most 4 times?
b). Same string can be derived in different ways, e.g., 𝑆 ⇒ 𝐴𝐴 ⇒ 𝑎𝐴 ⇒ 𝑎𝑎, 𝑆 ⇒ 𝐴𝐴 ⇒ 𝐴𝑎 ⇒ 𝑎𝑎. Give at least
4 distinct derivations for the string 𝑏𝑎𝑏𝑏𝑎𝑏
c). For any 𝑚, 𝑛, 𝑝 > 0, describe a derivation in 𝐺 of the string 𝑏𝑚 𝑎𝑏𝑛 𝑎𝑏𝑝
3. Show that the following languages are context-free by exhibiting contextfree grammars
generating each.
a). {𝑎𝑚 𝑏𝑛 : 𝑚 ≥ 𝑛 ≥ 0}
b). {𝑎𝑚 𝑏𝑛 𝑐 2𝑚+𝑛 : 𝑚, 𝑛 ≥ 0}
a)
S -> aSb | aS | ε
b)
S -> aScc | A
A -> bAc | ε
Homework – 6
b). Show that 𝑎𝑏𝑎, 𝑎𝑎, 𝑎𝑏𝑏 ∉ 𝐿(𝑀), but 𝑏𝑎𝑎, 𝑏𝑎𝑏, 𝑏𝑎𝑎𝑎𝑎 ∈ 𝐿(𝑀)
Homework – 7
c). Describe 𝐿(𝑀) in English
5. Use the pumping theorem to show that the following languages are not context-free
But L\cap L_{1} = { a^{i}b^{i}c^{i} / i>=0 } and by the theorem it must be context-free.
But Lnew can be rewritten as = a^n b^n c^n, which is not context free (this proof is known and should
be present in most of the books). So L is also not context free..
6. Decide whether the following language is context-free or not, and state your reason:
a). {𝑎𝑚 𝑏𝑛 𝑐 𝑝 : 𝑚 = 𝑛 𝑜𝑟 𝑛 = 𝑝 𝑜𝑟 𝑚 = 𝑝}
b). {𝑎𝑚 𝑏𝑛 𝑐 𝑝 : 𝑚 ≠ 𝑛 𝑜𝑟 𝑛 ≠ 𝑝 𝑜𝑟 𝑚 ≠ 𝑝}
c). {𝑎𝑚 𝑏𝑛 𝑐 𝑝 : 𝑚 = 𝑛 𝑎𝑛𝑑 𝑛 = 𝑝 𝑎𝑛𝑑 𝑚 = 𝑝}
7. Construct a Pushdown automata that accept each of the followings:
a). The language {𝑎𝑚 𝑏𝑛 : 𝑚 ≤ 𝑛 ≤ 2𝑚}
b). The language {𝑤 ∈ {𝑎, 𝑏}∗ : 𝑤 = 𝑤 𝑅 }
c). The language {𝑤 ∈ {𝑎, 𝑏}∗ : 𝑤 has the same number of 𝑎′ 𝑠 and 𝑏′𝑠}