CMPSCI 401: Theory of Computation
First Midterm Exam, Spring 2013
David Mix Barrington
20 February 2013
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 = 75.
- If you need extra space use the back of a page.
- No books, notes, calculators, or collaboration.
- The first five 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: 10 points
Q8: 15 points
Q8: 40+10 points
Total: 125+10 points
The language ABC over the alphabet Σ = {a, b, c} is defined as the set
of all strings that contain at least one a, at least one b, and at least one c.
If X and Y are any two languages over the same alphabet, the symmetric
difference X Δ Y is defined to be the set of strings that are in
either X or Y, but not in both.
- Question 1 (10):
True or false with justification:
Let L be a language over some nonempty alphabet Σ such that there exists
a positive integer k such that for every string w in L, w has at most k letters.
(In symbols, ∃k: ∀w:(w ∈ L) → (|w| ≤ k).) Then L
must be a regular language.
- Question 2 (10):
True or false with justification:
Let L be a language over some nonempty alphabet Σ such that
for every string w in L, there exists
a positive integer k such that w has at most k letters.
(In symbols, ∀w: (w ∈ L) → ( ∃k: |w| ≤ k).) Then L
must be a regular language.
- Question 3 (10):
True or false with justification:
The language ABC (defined above) is the language of some DFA with exactly six
states.
- Question 4 (10):
True or false with justification:
The language {w: ∃k: ∃y: (k ≥ 1) ∧ (w = 1k0y)
∧ (y has at most k ones)} is context-free. (Here the alphabet is {0, 1}.)
- Question 5 (10):
True or false with justification:
If X and Y are regular languages, then X Δ Y is also regular. (The
symmetric difference operator is defined above.)
- Question 6 (10):
We define a queue machine to be analogous to a PDA. It is
nondeterministic and has a finite state set, a start state, a final state set,
an input alphabet, and a queue alphabet. But its transitions enqueue and
dequeue single characters from a queue rather than push and pop characters from
a stack. Describe (in English) a queue machine whose language is not
context-free.
- Question 7 (10):
Find a regular expression either for the language ABC defined above, or for
its complement. (Your choice, no extra credit for both. If you attempt both,
tell me which one you want me to grade.)
- Question 8 (15):
Let N be the NFA with state set {1, 2, 3, 4}, start state 1, final state set
{2, 3}, alphabet {a, b}, and the following six transitions (arrows): (1, a, 2),
(1, ε, 3), (2, b, 2), (2, ε, 3), (3, b, 4), and (4, a, 2).
- (a, 5) Circle exactly the strings on this list that are in the
language L(N): ε, a, b, aa, ab, ba, bb, aaa, aab, aba, abb, baa, bab, bba, bbb.
- (b, 10) Construct an ordinary DFA D such that L(D) = L(N). (Any
correct DFA gets full credit, but showing your reasoning is important to get
partial credit for a wrong answer.)
- Question 9 (40+10):
Let G be the grammar with nonterminals S and T, terminals a, b, and c, start
symbol S, and rules S → TaT, T → bS, and T → c.
- (a, 10):
Give a PDA M such that L(M) = L(G). (The simplest thing is probably
to give the top-down parser, but any correct PDA gets full credit. Explaining
your reasoning may help for partial credit.)
- (b, 10):
Give a PDA M' such that L(M') = L(G) and such that M' meets the three
conditions for the proof that any PDA may be simulated by a context-free
grammar.
- (c, 10):
Prove that for any positive integer k, there is a string in L(G) with
exactly 3k letters.
- (d, 10):
Prove that every string in L(G) has a number of letters that is
divisible by 3. (Hint: One way to do this is to simultaneously prove a fact
about the lengths of strings that are derivable from the nonterminal T in
the grammar G.)
- (e, 10XC): Prove that L(G) is not a regular language. (Hint:
Work with the intersection of L(G) and the regular language
b*(a ∪ c)* -- if the intersection is not regular
than L(G) is not regular.)
Last modified 15 May 2013