- Answer True or False to the following questions. You do not need to justify your answers. All strings considered are over some fixed alphabet Sigma.
- The complement of a CFL is never a CFL.
- For any context-free grammar G there is a PDA M such
that G generates exactly the set of strings that M accepts.
- Any set of languages that is closed under union, concatenation,
and Kleene star must be the regular languages.
- If K=L U M and both K and L are regular then so is M.
- If K is not a CFL and K=R intersect L where R is regular then
L is not a CFL.
- If L=L(M) for some PDA M then both L and L* are CFL's.
- If L\subset K and L is a CFL then so is K.
- There exist some non-regular languages that are generated
by CFG's.
- For every regular language L over Sigma there are strings
x,y,z in Sigma* such that |y|>= 1 and for every k>= 0,
xykz is in L.
- If K and L are context-free languages then so is
K intersect L.\
- Classify each of the following sets as:
- [A] Both Regular and Context-Free,
- [B] Context-Free, but not regular,
- [C] Regular, but not context-free, or
- [D] Neither context-free nor regular.
You do not need to justify your answer. Unless otherwise specified
it is assumed that w is in {a,b}*.
- { w | w contains a different number of a's and b's}
- { w | w contains an even number of a's but does not
contain abb as a substring}
- { an bn am bm | m,n >= 0}
- { an bm an bm | m,n >= 0 }
- { xcy | x is in {a,b}* and y != xR }
- { x | x is in {a,b}* and |x|>= 100 }
- {an2 | n >= 0}
- { w | wR=w}
- { w | wR != w}
- { w | w contains both abaa and aaba as substrings}
- Let L={x in {0,1}* | x has exactly twice as many 0's as 1's}
- State the Pumping Lemma for Regular Languages (in the version that we
proved and used in class.)
- Prove that L is not a regular language.
- Let G = (V,Sigma,R,S) be a context-free grammar, where
Sigma = {a,b}, V = {S,T,a,b}, and R is
S-> TS, S->a, T-> aTb, T->ab
- Give a parse tree for the string: aabba
- Write out the leftmost derivation corresponding to the parse tree
in part (a).
- Use the general construction that converts a CFG to a PDA
to give a PDA M such that L(M)=L(G).
(Write out its full formal definition.)
- Show the computation of your PDA
on the input aabba. Be sure to show
the full configuration at each step.
- Let B be the set of all strings over {(,)} with
balanced parentheses. (Recall that this means that every prefix of the
string has at least as many left parentheses, (, as right parentheses,
), and the string as a whole has an
equal number of left and right parentheses.)
- Design a PDA M such that L(M)=B. Give its full formal definition.
- Modify your PDA from part (a) to produce a PDA M' such that L(M')
consists of those strings in B with an even number of left parentheses.
Give its full formal definition.
- Prove that {ak b2k a3k | k>= 0} is not a
context-free language.
- A substitution is a function f:Sigma1 -> (Sigma2)*
that associates a string f(a) over Sigma2 with each symbol a in Sigma1.
We can extend this to a function that maps strings over Sigma1 to strings
over Sigma2 by defining
f(a1 a2 ... ak)=w1 w2 ... wk
where f(a1)=w1, f(a2)=w2, ...,
f(ak)=wk.
(That is, from string x we obtain a new string f(x) by substituting strings
for each symbol in x and concatenating the results together.)
For L subset (Sigma1)* define f(L)={f(x) | x is in L} as a
subset of (Sigma2)*.
Show that if L is a regular language then so is f(L).