Professional Documents
Culture Documents
Pset 2 ToA Fall 2022 221019 140714
Pset 2 ToA Fall 2022 221019 140714
Instructions: This homework is due on Friday, November, 4, 2022. You are welcome to collaborate
on problem sets, provided that (1) you write up your solutions individually, and (2) you clearly cite the
names of all collaborators and sources. Failure to do so will result in zero credit. An additional key
requirement is that you should be able to explain what you submit. Inability to do so will also result
again in zero credit. Direct your all queries to the instructors.
1. (10 points) Prove that the class of context-free languages is not closed under either intersection or
complement. [Hint: the class of context-free languages is known to be closed under union.]
2. Consider the grammar G = (V, Σ, R, S) where V = {S, A}; Σ = {a, b}; and following rules are in R
S → aAa|bAb|ϵ
A → SS.
(a) (10 points) Which strings of L(G) can be produced by derivations of four or fewer steps?
(b) (10 points) Give a derivation of baabbb in G
(c) (10 points) Construct the parse tree of the derivation from previous part
(d) (10 points) Describe L(G) in English?
3. (10 points) For a string x = x1 x2 xn , xrev = xn xn−1 x1 (the reverse of x). For any language L,
Lrev = {xrev : x 2 L}. Show that if L is regular, so is Lrev .
4. (10 points) Let L be a language over some Σ defined as L = {w : w = wrev }. Show that L is not
regular using pumping lemma. [L is the language of palindromes.]
5. (10 points) Give an unambiguous context-free grammar and then construct a pushdown automaton
for the language L over Σ = {a, b, c} :
6. (10 points) Give an unambiguous grammar for A and then construct a pushdown automaton as
well, assume Σ = {a, b}: