Sei sulla pagina 1di 4

EXAM IN MA2301

THEORY OF
COMPUTATION AND
Norwegian University of Science
and Technology
COMPUTATIONAL
Institutt for matematiske fag COMPLEXITY
Spring 2007

1 This problem has turned out to be somewhat easier than originally intended. Let
r = (a∗ ∪ b∗ ∪ aba)∗ and L be the language determined by r. Then

¡ ¢ ¡ ¢
{a, b}∗ ⊇ L = L (a∗ ∪ b∗ ∪ aba)∗ ⊇ L (a ∪ b)∗ = {a, b}∗

Therefore, L = {a, b}∗ and a correct answer to both a) and b) is for example:

¯ a,b
>}

2 Let us label the nodes of M as follows:

1 0

¼ 0 1 ¦
8?9
>2=
:;<o /8?>
9=:;< /8?>
9:=<;
1 o 3
0 O 1

1 e

²
0 / 89:;
?>=<
7654
0123
>8?>
9s=
:;< f

Note that M has exactly one final state, f , and there are neither arrows ending at s
or starting at f , so M it has the necessary properties for us to start with the node
elimination. We can eliminate nodes in the order 2, 3, 1:
Step I:

01∗ 0 0

¼ 1 ¦
8?>
91= :;<o /8?9
>=:;<
3
O 1

1 e

²
0 / ?>=<
89:;
7654
0123
>8?>
9s=
:;< f

June 9, 2007 Page 1 of 4


Step II:

01∗ 0∪10∗ 1
¼
8?9
>1=:;<
O ;;;
;;
;;
;; 10∗
1 ;;
;;
;;
;;
À
0 / 89:;
?>=<
7654
0123
>8?9
>s=:;< f

Step III:

¡ ¢
0∪ 1(01∗ 0 ∪ 10∗ 1)∗ 10∗
>8?9
>s=
:;< / ?>=<
89:;
7654
0123
f

Remark: Note that the automaton M accepts exacly those numbers in binary nota-
tion that are divisible by 3.

3 a) Pref(L) is regular. Let M = (K, Σ, δ, s, F ) be an automaton accepting L and


G be the set of all states in K from which a final state can be reached. That is:

G = {q ∈ K : (q, w) `∗M (f, e) for some f ∈ F and w ∈ Σ∗ }

Then M 0 = (K, Σ∗ , δ, s, G) accepts Pref(L).


b) L+ is regular since L = LL∗ and the class of regular languages is closed under
concatenation and Kleene star.
c) The language M = {ww : w ∈ Σ∗ } is not regular. To see this, denote wi = ai b.
Note that wi and wj are not equivalent with respect to M for i 6= j, because
in this case wi wi ∈ M but wj wi 6∈ M . Therefore, there are infinitely many
equivalence classes with respect to M and M is not regular by the Myhill-
Nerode Theorem.
d) The language {wzw | w, z ∈ Σ∗ } is regular. We have:

{wzw | w, z ∈ Σ∗ } ⊇ {z | z ∈ Σ∗ } = Σ∗

Therefore, {wzw | w, z ∈ Σ∗ } = Σ∗ , so it is clearly regular.

4 None of the strings is in L(G). For a) and c), note that no number beginning with
1 can be derived from N . For b), the symbol “-” is not contained in V .

June 9, 2007 Page 2 of 4


The grammar is ambiguous. For example for the string 0+0∗0, we have two different
parse trees:

p S PPPP
ppppp PPP
PPP
ppp PPP
pp PP
pp
S + S@
~~ @@
~ @@
~~~ @@
~~ @
N S ∗ S

0 N N

0 0

and

nn S NNNN
nnnnn NNN
n nnn NNN
NNN
n
nnn
S@ ∗ S
~~ @@
~~ @@@
~~ @@
~~
S + S N

N N 0

0 0

5 The following Turing machines solve the problem:


a)
a b a

° b ° a °
> R NN /R /R
NNN ppp
NNN
N t ppppp b
t NNN p t
N& ² xpppp ²
y n
b)
a,b
/
>Ro R
a,b
t t
² ²
ho Lt o a

June 9, 2007 Page 3 of 4


6 a) This problem is not decidable. It is exactly the halting problem discussed in
section 5.3 in the course book.
b) This problem is decidable. The algorithm is as follows: First we construct
equivalent non-deterministic finite automata for both r and s, from them we
construct deterministic automata, and we use the state minimization algorithm
to construct standard automata. Now, r and s determine the same language if
and only if they have the same standard automata (up to renaming the states).
c) This problem is decidable. The most simple-minded algorithm is as follows:
Given n, go through all integers i such that 1 < i < n and check whether i
divides n. If so, then n is composite. The algorithm is very inefficient, but
theoretically correct.

June 9, 2007 Page 4 of 4

Potrebbero piacerti anche