Starting from:
$30

$24

Problem Set 4 Solution

Problem 1. (10 points) Convert the following CFG into a PDA using the conversion discussed in
class (Lemma 2.21 in the textbook):
𝐸𝐸 → 𝐸𝐸 + 𝑇𝑇 | 𝑇𝑇
𝑇𝑇 → 𝑇𝑇 × πΉπΉ | 𝐹𝐹
𝐹𝐹 → (𝐸𝐸) | π‘Žπ‘Ž
Problem 2. (10 points) For each of the following languages, either give a CFG generating it, or a
high-level description of a PDA that recognizes it:
a) The complement of {π‘Žπ‘Žπ‘›π‘›π‘π‘π‘›π‘› | 𝑛𝑛 ≥ 0}
b) {π‘₯π‘₯1#π‘₯π‘₯2# β‹― π‘₯π‘₯π‘˜π‘˜ |π‘˜π‘˜ ≥ 1, π‘’π‘’π‘’π‘’π‘’π‘’β„Ž π‘₯π‘₯𝑖𝑖 ∈ {π‘Žπ‘Ž, 𝑏𝑏}∗ π‘Žπ‘Žπ‘Žπ‘Žπ‘Žπ‘Ž 𝑓𝑓𝑓𝑓𝑓𝑓 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 𝑖𝑖,𝑗𝑗 π‘₯π‘₯𝑖𝑖 = π‘₯π‘₯𝑗𝑗
𝑅𝑅}
Problem 3. (10 points) Let 𝐢𝐢 be a context-free language, and 𝑅𝑅 be a regular language. Show
that the language 𝐢𝐢 ∩ 𝑅𝑅 is context free. Start with a PDA (𝑄𝑄, Σ, Γ, 𝛿𝛿, π‘žπ‘žπ‘ π‘ π‘ π‘ π‘ π‘ π‘ π‘ π‘ π‘ , 𝐹𝐹) for 𝐢𝐢 and a DFA
�𝑄𝑄′
, Σ′
, 𝛿𝛿′
, π‘žπ‘ž′
𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠, 𝐹𝐹′
οΏ½ for 𝑅𝑅, then describe a PDA for 𝐢𝐢 ∩ 𝑅𝑅. Your description may be informal
and high-level (i.e. you don’t need to define detailed transitions), but must be precise.
Problem 4. (10points) Use the result of Problem 3 to prove that the language
𝐿𝐿 = {𝑀𝑀 ∈ {π‘Žπ‘Ž, 𝑏𝑏, 𝑐𝑐}∗: 𝑀𝑀 has equal numbers of π‘Žπ‘Ž′
𝑠𝑠, 𝑏𝑏′
𝑠𝑠, and 𝑐𝑐′
𝑠𝑠} is not context free.
You may assume that the language {π‘Žπ‘Žπ‘›π‘›π‘π‘π‘›π‘›π‘π‘π‘›π‘›: 𝑛𝑛 ≥ 0} is not context free.
(Hint: design a regular expression 𝑅𝑅 such that 𝐿𝐿 ∩ 𝑅𝑅 is not context free.)

More products