Vous êtes sur la page 1sur 5

Automata Theory

Midterm Exam Solution


08:30-10:00 am
Wednesday, April 18, 2007
Name:

ID #:

This is a Close Book examination. Only an A4 cheating sheet belonging to you is acceptable.
You can write your answers in English or Chinese.

Maximum Score
Problem 1 20 20
Problem 2 5 5
Problem 3 25 25
Problem 4 15 15
Problem 5 10 10
Problem 6 10 15
Problem 7 5 10
Problem 7 10 10
Total 100 100

1
1. (20 pts) Mark by T(=True) or F(=False) each of the following statements. You don’t need
to prove it.

(1) (L∗ )∗ = L∗ for all languages L.


(2) Let L be any language on a non-empty alphabet. Then, L and L can not both be finite;
(3) Language L = {vwv : v, w ∈ {a, b}∗ , |v| = 2} is not regular.
(4) If two states p and q of a dfa are called distinguishable if there are some string w ∈ Σ∗
such that
δ∗ (p, w) ∈ F and δ∗ (q, w) 6∈ F,
or vice versa.

Question Answer
(1) T
(2) T
(3) F
(4) T

2. (5 pts) Give conditions on S1 and S2 necessary and sufficient to ensure that

S1 = (S1 ∪ S2 ) − S2 .

Sol:
If x is in S1 and x is in S2 , then x is not in (S1 ∪ S2 ) − S2 . Because of this, a necessary and
sufficient condition is that the two sets are disjoint.

3. (25 pts) Please give the answer to each of the following questions. You do not need to show
how to derive the answers. Besides, there is no partial credit for each question.

(1) Give a simple description of the language generated by the grammar with productions,
where Σ = {a, b}?

S → AaAaAaA,
A → aA|bA|λ.

(2) Find a grammar for the language L = {w : na (w) = nb (w) + 1}, where Σ = {a, b}.
(3) Find a grammar for the language L = {w : an bn−3 : n ≥ 3}, where Σ = {a, b}.
(4) Give a dfa for the language L = {ab5 wb2 : w ∈ {a, b}∗ }, where Σ = {a, b}.
(5) Construct an nfa with three states that accepts the language {ab, abc}∗ .

Sol:

(1) the grammar can generate any string w ∈ {a, b}∗ as long as na (w) ≥ 3.

2
(2)

S → aS1 |S1 S,
S1 → S1 S1 ,
S1 → λ,
S1 → aS1 b,
S1 → bS1 a

(3)

S → aaaA,
A → aAb|λ

(4)

(5)

4. (15 pts) Consider the following nfa.

(1) (5 pts) Which of the following strings aabbb, aaa, aba, aabbaba, abbb are accepted by the
nfa? (Note: you must select all the acceptable strings to get the credits)
(2) (10 pts) Please convert it into an equivalent dfa.

Sol:

(1)aaa, aba, and aabbaba.


(2)See Figure 2.

3
Figure 1: An nfa used in Problem 4.

Figure 2: The corresponding dfa for the nfa in Figure 1.

q1
0 1 0, 1
0 0

1
q0 q2 q4
0 1
1

q3

Figure 3: A dfa used in Problem 5.

4
0, 1 0
q0 q2
{q1, q3} 0

1
1

0, 1
q4

Figure 4: The dfa with minimized states for the dfa in Figure 3.

5. (10 pts) Minimize the states in the dfa depicted in the following diagram.
Sol:

6. (10 pts)

(a) (5 pts) Give a regular expression for language L = {an bm : n ≥ 4, m ≤ 3}.


(b) (5 pts) Give a regular expression for the complement of the language L in (a).

Sol:

(a) aaaaa∗ (λ + b + bb + bbb).


(b) (λ + a + aa + aaa)b∗ + a∗ bbbbb∗ + (a + b)∗ ba(a + b)∗ .

7. (5 pts) Show that the language L = {an : n ≥ 0, n 6= 4} is regular.


Sol: We can first consider the dfa for L = {an : n ≥ 0, n = 4}. Then, complement L. The
result is as below.

8. (10 pts) Prove that, if the states qa and qb are indistinguishable, and if qa and qc are distin-
guishable, then qb and qc must be distinguishable.
Sol: By contradiction. Assume that qb and qc are indistinguishable. Since qa and qb are
indistinguishable and indistinguishability is an equivalence relation, qa and qc must be indis-
tinguishable.

Vous aimerez peut-être aussi