CMPSCI 501: Theory of Computation
First Midterm Exam, Spring 2014
David Mix Barrington
19 February 2014
Directions:
- Answer the problems on the exam pages.
- There are nine problems (some with multiple parts)
for 125 total points plus 10 extra credit.
Actual scale was A = 115, C = 70.
- If you need extra space use the back of a page.
- No books, notes, calculators, or collaboration.
- The first six questions are statements -- in each case say
whether
the statement is true or false and give a convincing justification
of your answer --
a proof, counterexample, quotation from the book or from lecture, etc.
You get five points for the correct boolean answer (so
there is no reason not to guess if you don't know) and up to five for
the justification.
Q1: 10 points
Q2: 10 points
Q3: 10 points
Q4: 10 points
Q5: 10 points
Q6: 10 points
Q7: 40 points
Q8: 25 points
Q9: +10 points
Total: 125+10 points
The language X is the set of all strings in {a, b}* in
which every b has an a immediately before it and an a immediately
after it.
If w is any string, wR is w written backwards. For
example,
(abaab)R = baaba.
The function f from strings in {a, b}* to strings in
{a, b}* replaces each a in the input with ab and each b
in the input with ba. Thus, f(aba) = abbaab.
Language Y is the set of all strings of the form w(f(w))R
where w is any string in {a, b}R. For example, taking w =
aba,
we see that ababaabba is in Y because it is the concatenation of w =
aba
and f(w)R = baabba.
Language Z is the set of all strings of the form wf(w) where w is any
string in {a, b}*. For example, taking w = aba, we find
that abaabbaab is in Z.
The NFA N has input alphabet {a}, state set {i, p, q, r, s, t}, final
state set {i, p, r, s}, and transition function δ defined as
follows:
δ(i, a) = {p, r}, δ(p, a) = {q}, &delta(q, a) = {p},
δ(r, a) = {s}, δ(s, a) = {t}, δ(t, a) = {r}, and
for all states u, δ(u, ε) = ∅. This last
definition
means that there are no ε-moves in N.
- Question 1 (10):
True or false with justification:
The language Y, defined above, is regular.
- Question 2 (10):
True or false with justification:
The language Z, defined above, is context-free.
- Question 3 (10):
True or false with justification:
The language {w: f(w) ∈ X} is regular. (The function f and the
language X are defined above.)
- Question 4 (10):
True or false with justification:
The language {f(w): w ∈ X} is not regular. (Again, f and X are
defined above.)
- Question 5 (10):
True or false with justification:
Let M be a pushdown automaton that follows the rules for our
construction of an equivalent context-free grammar. (It has
exactly one final state that is not its start state, it accepts
only with empty stack, and every transition either pushes or
pops a letter but not both.) Assume in addition that M reads
exactly one input letter on each transition. Then every string
in L(M) has even length.
- Question 6 (10):
True or false with justification:
There is an example of a string ai that is in the
language L(N) while the string ai+6 is not. (The NFA
N is defined above.)
- Question 7 (40):
These questions deal with finite automaton and regular language
constructions. The language X and the NFA N are defined above.
- (a, 10) Build a DFA whose language is X. You may use any
method,
but be sure that your DFA is correct.
- (b, 10) Find a set of four strings that are pairwise
X-distinguishable, and show that they have this property. Explain
(without proof) what the existence of this set implies about the
set of correct DFA's for the language X. (Hint: You must choose
two strings in X and two strings not in X.)
- (c, 10) Find a regular expression for X, using your DFA
from
part (a).
- (d, 10) Using the Subset Construction, find a DFA
equivalent
to the NFA N.
- Question 8 (25):
Here are three questions about the languages Y and Z, which are
defined
above.
- (a, 5) Give three examples of six-letter strings in Y and three
examples of six-letter strings in Z. Explain (without proof)
exactly
which non-negative integers can be the lengths of strings in Y, and
which can be the lengths of strings in Z.
- (b, 10) Give a context-free grammar whose language is Y. You
should justify your answer, but you need not prove that your
grammar is correct.
- (c, 10) Describe a pushdown automaton whose language is Y,
either by construction from your answer to part (b) or otherwise.
- Question 9 (10 extra credit):
The function f defined above is an example of a homomorphism,
a function from strings to strings that satisfies the rule
f(uv) = f(u)f(v) for all strings u and v. (A homomorphism is
completely determined by its outputs for single-letter inputs.)
The homomorphic image of a language L under a
homomorphism f is the set {f(w): w ∈ L}. The inverse
homomorphic image of L under f is the set {w: f(w) ∈ L}.
If L is a context-free language and f is any
homomorphism, is its homomorphic image guaranteed to be a
context-free language? Justify your answer.
If L is a CFL and f is a homomorphism, is its inverse
homomorphic image guaranteed to be a context-free language?
Justify your answer.
Last modified 22 February 2014