• 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!
3
0
0

Texte intégral

(1)

Cursus: M1, computer-science Code UE: JEIN8602

Subject: Formal languages theory Date: 26 August 2014

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 marks.

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

e := ((abb)

a(cb)

) ∪ (ab)

(ba)

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

e

.

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

0

1

2 a

b c

a

c

c

b b

a

Figure 1: finite automaton A

the only initial state and 1 is the only final state.

Construct a regular expression for the language L

A

recognized by the automaton A. Explain the successive steps of your construction.

Exercice 3 [/5] Let

e = (abc)

Give a regular expression for the language {a, b, c}

− L

e

(i.e. the complement, in the set

{a, b, c}

, of the language defined by e).

(2)

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

1

, T

2

} and R consists of the following rules:

r1: S → T

1

r2: S → T

2

r3: T

1

→ aT

1

r4: T

1

→ aT

1

b r5: T

1

→ a r6: T

2

→ T

2

b r7: T

2

→ aT

2

b r8: T

2

→ b

The start symbol of G is S.

1- Which one of the following sets is exactly equal to L(G, T

1

)?

{a

p

b

q

| p ≥ q ≥ 1}, {a

p

b

q

| p > q ≥ 1}, {a

p

b

q

| p ≥ q ≥ 0}, {a

p

b

q

| p > q ≥ 0},

2- Describe the language L(G, T

2

) by an expression analogous to the expressions given at question 1.

3- Describe the language L(G, S) by an expression analogous to the expressions given at question 1.

4- Is the grammar G ambiguous ? Indication: consider the word aaab.

5- What is the set of of words which have exactly one derivation tree from S within the grammar G ?

6- Construct a non-ambiguous context-free grammar G

, with axiom S

, such that L(G, S) = L(G

, S

).

Exercice 5 [/4] 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

} and R consists of the following 12 rules:

S

1

→ aS

1

S

1

S

1

→ bS

3

S

1

S

1

→ S

2

c S

2

→ S

2

S

1

S

2

→ aS

3

S

2

→ S

1

S

2

S

1

S

3

→ a S

3

→ S

1

S

3

S

4

→ cS

4

S

4

→ aS

4

S

5

S

5

→ aS

5

S

5

→ aS

4

a 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 ?

2

(3)

Exercice 6 [/4] We consider the two following context-free grammars G

1

:= (A, N

1

, R

1

), G

2

:=

(A, N

2

, R

2

) where A = {a, b, c}, N

1

= {S, T }, N

2

= {U } ,R

1

consists of the rules:

r1: S → aSbT r2: S → cT r3: T → aT T b r4: T → c

and R

2

consists of the rules:

r4: U → U U b r5: U → a

1- Construct a context-free grammar generating the language L(G

1

, S ) · L(G

2

, U ).

2- Construct a context-free grammar generating the language L(G

1

, S ) ∪ L(G

2

, U ).

3- Construct a context-free grammar generating the language L(G

1

, S )

. 4- Let ϕ : {a, b, c}

→ {x, y}

be the homomorphism defined by:

ϕ(a) = xy, ϕ(b) = yx, ϕ(c) = y

We recall this means that, for every word w = a

1

· · · a

i

· · · a

n

, where the letters a

1

, . . . a

i

. . . , a

n

belong to {a, b, c}

:

ϕ(w) = ϕ(a

1

) · · · ϕ(a

i

) · · · ϕ(a

n

) and ϕ(ε) = ε. For example:

ϕ(ab) = xyyx, ϕ(baa) = yxxyxy, ϕ(cba) = yyxxy.

Construct a context-free grammar H

1

generating ϕ(L(G

1

, S )) and a context-free grammar H

2

generating ϕ(L(G

2

, U )).

3

Références

Documents relatifs

We then eliminate successively states in the ordering: 0, 1, 2, 3... We obtain

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