$29
CS 334: Problem Set 4.
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.)