Finite automata and regular expressions are useful in defining the

advertisement
CS 454 Theory of Computation
Spring 2002
Final Examination - May 24, 2002
Duration of the examination: 110 minutes (2 PM to 3:50 PM)
This exam will weigh about 25% of total points.
Answer any SEVEN problems. All problems will be equally weighted.
1) Define a language over a 4-letter alphabet {
,
,
,
} that
are connected paths. For example, the language includes the string
but not the string
Design a DFA for this language. To get full credit, the DFA should have as few
states as possible.
2) Construct a regular expression for the set of strings over {0,1} that do not contain
011 as a substring.
3) (a) Show that the language L over {a, b} defined as follows is not regular:
L = { w | length of w is odd, and the middle symbol in w is 1}. For example,
10100 is in L, but 1001 and 0110111 are not in L.
(b) Design a context-free grammar for L.
4) Design a PDA for the language L = { a i b j c k | i  j or j  k }.
5) Consider the context-free grammar G shown below:
SAB
AaBB|
B  b A A | 
(a)
(b)
(c)
(d)
Write down all strings of length 6 that G generates.
Exhibit a string x for which there is a unique leftmost derivation.
Exhibit two leftmost derivations of the string ab.
Convert G into Chomsky normal form.
6) Is disjointness problem for DFA’s decidable? Or equivalently, is the following
language recursive? Justify your answer.
1
{ <M1>#<M2> | and are DFA’s over the same alphabet such that there is no
string accepted by both DFA’s }
7) Give a formal construction of a Turing machine to accept the following language:
{ w # w | w is in {0, 1}* }
To get full-credit, your Turing machine should make at most O(n log n) moves on
strings of length n.
8) (a) Given a halting Turing machine M that takes as input the encodings of two
context-free grammars G and G’, and decides if L(G) is contained in L(G’)
(formally, M takes as input <G>#<G’> and accepts if L(G)  L(G’), rejects
else), construct a halting Turing machine M’ that takes as input two grammars G
and G’ and decides if L(G) = L(G’). Your solution should informally describe
how M’ would simulate M.
(b) Which of the following statements follows from your solution to (a)?
(1) Given that containment problem for CFG’s is decidable, equivalence
problem for CFG’s is decidable.
(2) Given that equivalence problem for CFG’s is decidable, containment
problem is decidable.
(3) Equivalence problem for CFG’s is recognizable.
(4) Equivalence problem for CFG’s is not recognizable.
9) Let L be a recognizable language over the alphabet {0,1} such that L contains
exactly one string of length n for every n. Show that L is decidable.
Extra-credit problem: Show that SQUAREDFA = { <M> | M is a DFA over {0,1}
such that M accepts at least one string of the form ww for some w in {0,1}* } is
decidable.
2
Download