Assignment 3
Assignment 3
Note: 𝑖𝑖 and 𝑗𝑗 cannot be 0 at the same time but they can be 0 alternatively.
𝐿𝐿 = {𝑥𝑥 ∈ {𝑎𝑎, 𝑏𝑏}∗ | 𝑛𝑛𝑎𝑎 (𝑥𝑥) < 𝑛𝑛𝑏𝑏 (𝑥𝑥) < 2𝑛𝑛𝑎𝑎 (𝑥𝑥)}
is not regular.
Here, 𝑛𝑛𝑎𝑎 (𝑥𝑥) denotes the number of a’s in x and 𝑛𝑛𝑏𝑏 (𝑥𝑥) denotes the number of
b’s in x.
In both parts below, the productions in a CFG 𝐺𝐺 are given. In each part, find a
string 𝑥𝑥 ∈ {𝑎𝑎, 𝑏𝑏}∗ with 𝑛𝑛𝑎𝑎 (𝑥𝑥) = 𝑛𝑛𝑏𝑏 (𝑥𝑥) that is not in 𝐿𝐿(𝐺𝐺).
a. 𝑆𝑆 → 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 | 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 | Λ
a. {𝑎𝑎𝑖𝑖 𝑏𝑏 𝑗𝑗 | 𝑖𝑖 ≤ 𝑗𝑗 ≤ 2𝑖𝑖}
b. �𝑎𝑎𝑖𝑖 𝑏𝑏 𝑗𝑗 𝑐𝑐 𝑘𝑘 � 𝑖𝑖 ≠ 𝑗𝑗 + 𝑘𝑘}
𝑆𝑆 → 𝐴𝐴𝐴𝐴
𝐴𝐴 → 𝑎𝑎𝑎𝑎 | Λ
𝐵𝐵 → 𝑎𝑎𝑎𝑎 | 𝑏𝑏𝑏𝑏 | Λ
Every derivation of a string in this grammar must begin with the production
𝑆𝑆 → 𝐴𝐴𝐴𝐴. Clearly, any string derivable from 𝐴𝐴 has only one derivation from 𝐴𝐴,
and likewise for 𝐵𝐵. Therefore, the grammar is unambiguous. True or false? Why?
Give transition tables for PDAs accepting each of the following languages.
a. The language of all the odd-length strings over {𝑎𝑎, 𝑏𝑏} with middle
symbol 𝑎𝑎.
Give transition diagrams for PDAs accepting each of the following languages.
In all the three cases below, a transition table is given for a PDA with initial state
𝑞𝑞0 and accepting state 𝑞𝑞2 for first two PDAs and 𝑞𝑞3 for the third PDA. Describe
in each case the language that is accepted.