CSC 320 Fall 2010: Assignment #3 Due at beginning of class, Wed

advertisement
CSC 320 Fall 2010: Assignment #3
Due at beginning of class, Wed. Oct. 20
Draw boxes for your marks. Place a 0 in the corresponding box for any questions you omit.
Question
Marks
1.
1
2
3
4
5
6
7
Consider the DFA M = ({s, t, u}, {a, b, c}, δ , s, {t}) where the transition function δ is
given by:
State
s
s
s
t
t
t
u
u
u
Symbol
a
b
c
a
b
c
a
b
c
Next State
t
t
t
u
s
s
u
u
u
(a)
[3] Give a regular expression for the language accepted by this DFA.
(b)
[3] List all strings of length at most 3 accepted by this DFA.
(c)
[3] Give a formula (in terms of k) for the number of strings of length n = 2k + 1 accepted
by this DFA.
(d)
[6] Prove that your formula from (c) is correct by induction.
2.(a) [5] Let w = ar b2r c r . Describe mathematically all possible ways of choosing x, y, and z
such that w = x y z and y is not the empty string.
(b)
[10] Let L = {ar b s c t : s ≥ 2r, t ≤ r 2 }. Prove that L is not regular using w = ar b2r c r .
Assume only that r is chosen so that 4r ≥ k, where k is the number of states of the DFA.
(c)
[5] A more judicious choice of w would simplify your proof from (b). How would you
choose such a string w? Which cases are required from part (b) in your revised proof?
3.
Let L be a language accepted by a DFA with four states. Assume that the string
aaab ∈ L.
(a)
[4] Give regular expressions for seven infinite languages L 1 , L 2 , . . . L 7 such that L i ⊆ L
for at least one value of i.
(b)
[2] Prove that L from part (a) is an infinite language.
-2(c)
[4] State what the pumping lemma says about a language accepted by a DFA with four
states. What needs to be true in order for you to prove that a language L is NOT accepted
by a DFA with four states?
4.
Here is a weaker version of our pumping lemma (found in the first edition of the text):
Let L be a regular language accepted by a DFA with k states. Let w be in L and |w| ≥ k.
Then there exists x, y, and z such that
(a)
w = x y z,
(b)
|y| ≥ 1, and
(c)
x y n z is in L for all n ≥ 0.
(a)
[5] Argue that this version of the pumping lemma is not strong enough to prove directly
that L = {u u R : u ∈ {a, b}* is not regular. [That is, no matter which w you select, you
cannot get the necessary contradiction].
(b)
[5] Prove directly (without using closure properties) using the pumping lemma given in
class (which is mathematically equivalent to the one in the text) that L is not regular.
5.
Design context-free grammars for the following languages.
(a)
[5] L 1 = {a n b m : 2 * n ≤ m ≤ 5 * n}.
(b)
[5] L 2 = {u u R v v R w w R : u, w ∈ {a, b}* , v ∈ {a, b}+ }
6.
Consider the following derivation:
S => ABC => ABDc => ABbc => AabDbc => AabaaBbabc =>
AabaaEcbabc => Aabaaacbabc => aabaaacbabc.
(a)
[5] Draw the parse tree that corresponds to this derivation.
(b)
[5] Use your parse tree from (a) to find a leftmost derivation.
(c)
[5] What are u, v, x, y, z as per the pumping theorem?
7.
Let L = {u u R v : u, v ∈ {a, b}+ } (u and v are strings made up of a’s and b’s of length at
least one).
(a)
[5] How many strings are in in L 1 with length at most 6? Justify your answer by telling
me the choices for a minimal prefix u and the number of choices left for v in each case.
(b)
[10] Write a computer program which generates all strings over the alphabet {a, b} with
length at most 14 and determines the number of strings of each length in L. Hand in your
program and your counts for the number of strings of each length ranging from 1 to 14.
(c)
[5] Give a context-free grammar that generates L.
Bonus [10]: Derive a formula for the number of strings of length k in the language L as defined
for Question 7 and prove that your answer is correct. Turn in any notes you make on the subject
for partial credit.
Download