• Aucun résultat trouvé

Cursus: M1, computer-science Code UE: JEIN8602

N/A
N/A
Protected

Academic year: 2022

Partager "Cursus: M1, computer-science Code UE: JEIN8602"

Copied!
4
0
0

Texte intégral

(1)

Cursus: M1, computer-science Code UE: JEIN8602

Subject: Formal languages theory Date: 20 March 2016

Duration: 3H

Documents: authorized

Lectures by: Mr G´eraud S´enizergues

The exercises are independant one from each other.

It is not required to solve all the exercises. Every correct solution to an exercise will give (around) 4 points.

Exercice 1 [/4] We consider the finite automaton A described on figure 1. Note that 0 is

0

g c

e

f

1 b 2 3

a d

Figure 1: finite automaton A the only initial state and 3 is the only final state.

0- Describe accepting computations of A over the words:

abd, agabd, af bd, abcbd, e.

1- Construct a regular expression for the language L

A

recognized by the automaton A.

Explain the successive steps of your construction.

We consider the monoid homomorphism h : {a, b, c, d, e, f, g}

→ {a, b}

defined by:

h(a) = a, h(b) = ba, h(c) = abb, h(d) = b, h(e) = bb, h(f) = aa, h(g) = b.

2- Give a regular expression for the language h(L

A

).

3- Construct a finite automaton recognizing the language h(L

A

).

Exercice 2 [/4] Let us consider the regular expression:

e := (((ab) ∪ (bc))

a)

c

Construct, by Glushkov’s method, a finite automaton recognizing L

e

.

(2)

Exercice 3 [/4] We consider the finite automaton B described on figure 2. Note that 0 is

0

1

2

3 4

5 6

a

a a c

a

b c

a b b a, b

Figure 2: finite automaton B the initial state and 5 is the only final state.

0- Check that the following words belong to L

B

:

acaaa, acbaa, baa, bcbaa

and that the following words do not belong to L

B

:

acc, bcc, bcab, acbaaa.

1- Is B deterministic ?

2- Is every state of B accessible ?

3- Is B complete ? Is B minimal ? If not, transform B into a minimal deterministic complete automaton C that recognizes the same language.

Exercice 4 [/5]

1- For each of the following languages over the terminal alphabet {a, b, c}, construct a context- free grammar that generates the language L

i

:

L

1

:= {a

n

bc

n

| n ≥ 1}

L

2

:= {(ab)

p

c

q

| p ≥ q ≥ 1}

L

3

:= {uc u ˜ | u ∈ {a, b}

}

we recall that ˜ u designates the “ mirror-image” (also called “ reversal”) of the word u: for example, if u = abbabbb then ˜ u = bbbabba.

Let us consider the language

L

4

:= {ucv | u, v ∈ {a, b}

, v 6= ˜ u}.

2

(3)

2- Check that the following words belong to L

4

:

abacaaa, babacab, bacabab.

3- Let w be some word in {a, b}

c{a, b}

. 3.1- Show that if :

w = v

1

xv

2

cv

3

yv

4

for some v

1

, v

2

, v

3

, v

4

∈ {a, b}

, x, y ∈ {a, b} such that v

4

= ˜ v

1

, x 6= y, then w ∈ L

4

.

3.2- Show that if :

w = v

1

xv

2

cv

4

for some v

1

, v

2

, v

4

∈ {a, b}

, x ∈ {a, b} such that v

4

= ˜ v

1

, then w ∈ L

4

.

4- Let w ∈ L

4

. Does w necessarily have one of the two forms described in 3.1 or 3.2 ? If not, describe the missing possible forms of w.

5- Construct a non-ambiguous context-free grammar generating the language L

4

.

Exercice 5 [/5] We consider the context-free grammar G := (A, N, R) where A = {a, b, c}, N = {S

1

, S

2

, S

3

, S

4

, S

5

, S

6

} and R consists of the following 15 rules:

S

1

→ aS

3

S

5

S

1

→ bS

2

S

2

S

1

→ aS

4

S

2

→ aS

3

S

3

S

2

→ bS

6

c

S

3

→ bS

2

S

3

→ aS

3

S

6

S

3

→ cS

6

S

4

→ bS

3

S

4

S

4

→ aS

4

S

4

S

4

→ b S

5

→ aS

4

S

5

S

5

→ bS

1

S

5

→ aS

5

.

S

6

→ aS

3

.

The start symbol of G is S

1

.

1- What are the productive non-terminals of G ? 2- What are the useful non-terminals of G ?

3- Transform the grammar G into an equivalent grammar G

where every non-terminal is productive and useful.

4- Is the language L(G, S

1

) empty ? 5- Is the language L(G, S

1

) infinite ? 6- Is the language L(G, S

1

) rational ?

3

(4)

Exercice 6 [/4] We consider the context-free grammar G := (A, N, R) where A = {a, a, b, ¯ ¯ b}, N = {S} and R consists of the following rules:

r1: S → aS¯ a r2: S → ¯ aSa r3: S → bS ¯ b r4: S → ¯ bSb r5: S → SS r6: S → ε

The start symbol of G is S.

1- Show that abaa¯ a¯ a ¯ b¯ a ∈ L(G, S). Give a leftmost derivation from S to abaa¯ a¯ a ¯ b¯ a.

Give a rightmost derivation from S to abaa¯ a¯ a ¯ b¯ a.

2- Show that a¯ ab ¯ b ∈ L(G, S). Give a leftmost derivation from S to a¯ ab ¯ b.

Give a rightmost derivation from S to a¯ ab ¯ b.

Give a derivation-tree for a¯ ab ¯ b.

(The student can choose, among the various notions of syntax-tree, abstract syntax-tree, etc...

his/her favorite notion and compute the corresponding tree).

3- Show that a¯ aa¯ a ∈ L(G, S).

Give two different derivation-trees for a¯ aa¯ a.

4- Is the grammar G ambiguous ?

5- Let G

be the context-free grammar obtained from G by removing rule r5.

Is G

ambiguous ? Does G

generate the same language as G ?

4

Références

Documents relatifs

We then eliminate successively states in the ordering: 0, 1, 2, 3.. Hence the Nerode equivalence over Q is just

Automatic language processing : in order to treat natural language text and extract its semantics or to produce some natural language sentence expressing some meaning, the

From now on, we accept as regular expressions, expressions using the usual symbols ∪ (instead of ⊕), · (instead of ⊗), using k-ary notation for the product and for the union

1- For a given language one can build a smaller automaton 2- For a given language one can find easily a non-deterministic automaton, while finding directly a deterministic

The set of regular languages over Σ ∗ is closed under the operations : union, intersection, complement, set-difference.. By Kleene’s theorem we can use, as well, the notion

1- The set of context-free languages over A ∗ is closed under the operations : union, product, star, cross.. 2- If Card (A) ≥ 2, then the set of context-free languages over A ∗ is

Each new line corresponds to a transition : the left-end of the memory is modified, depending on the top(i.e. leftmost symbol) of the stack and on the input-letter. Such an automaton

There exist some programs that try to detect ambiguity and succeed on many grammars ([S. Schmitz, 2006] for example) There are subclasses of c.f. grammars : the simple grammars,