• Aucun résultat trouvé

Solutions to the subject: Formal languages theory Date: 26 August 2014

N/A
N/A
Protected

Academic year: 2022

Partager "Solutions to the subject: Formal languages theory Date: 26 August 2014"

Copied!
6
0
0

Texte intégral

(1)

Cursus: M1, computer-science Code UE: JEIN8602

Solutions to the subject: Formal languages theory Date: 26 August 2014

Duration: 3H

Documents: authorized

Lectures by: Mr G´eraud S´enizergues

Exercice 1 [/4]

e := ((abb) a(cb) ) ∪ (ab) (ba) Let us apply Glushkov’s method.

The locally testable language associated to e is:

L := ((a 1 b 1 b 2 ) a 2 (c 1 b 3 ) ) ∪ (a 3 b 4 ) (b 5 a 4 ) We compute

Ini(L ) = {a 1 , a 2 , a 3 , b 5 }, F in(L ) = {a 2 , b 3 , b 4 , a 4 },

Dig(L ) = {a 1 b 1 , b 1 b 2 , b 2 a 1 , b 2 a 2 , a 2 c 1 , c 1 b 3 , b 3 c 1 , a 3 b 4 , b 4 a 3 , b 4 b 5 , b 5 a 4 , a 4 b 5 } This gives the finite automaton represented on figure 1, where the set of states is

{0, a 1 , a 2 , a 3 , a 4 , b 1 , b 2 , b 3 , b 4 , b 5 , c 1 } 0 is the unique initial state and a 2 , b 3 , b 4 , a 4 are the final states.

a

1

b

1

b

0

b

2

a

2

c

1

b

3

a

3

b

4

b

5

a

4

b a

a

a

a

a a

b b

c b

c

a

b b

Figure 1: finite automaton for L e

(2)

Exercice 2 [/4] We transform A into a normalized extended f.a. A 1 where i (resp. t)

0

1

2 a

b

a

c

c

b b

a c

b ∪ cb

a b ∪ ab

c

c ∪ ab

a

a ∪ cb

c i

i ε

ε t

0 1 t

t

i 0

ε

b ∪ cb

a ∪ (( a ∪ cb

c )( b ∪ ab

c )

( c ∪ ab

a )) ( a ∪ cb

c )( b ∪ ab

c )

[ b ∪ cb

a ∪ (( a ∪ cb

c )( b ∪ ab

c )

( c ∪ ab

a ))]

[( a ∪ cb

c )( b ∪ ab

c )

]

i t

ε ε

Figure 2: sequence of extended automata, ex. 2

is the initial (resp. terminal) state. We then eliminate successively states in the ordering:

2, 1, 0. We obtain the sequence of extended automata shown on figure 2. It follows that:

[b ∪ cb a ∪ ((a ∪ cb c)(b ∪ ab c) (c ∪ ab a))] [(a ∪ cb c)(b ∪ ab c) ]

is a regular expression for L A .

(3)

Exercice 3 [/5] The language L e is recognized by the following finite automaton A:

Making A complete and taking its complement, we obtain a finite automaton B recognizing

0 a 1 b 2

c

Figure 3: a non-det automaton for L e

{a, b, c} − L e . We transform B into a normalized extended f.a. B 1 where i (resp. t) is the

0 a 1 b 2

c

a ∪ c a ∪ b b ∪ c

Figure 4: a det automaton for {a, b, c} − L e

initial (resp. terminal) state. We then eliminate successively states in the ordering: 1, 2, 3, 0.

We obtain the sequence of extended automata shown on figure 5. It follows that:

(abc) (b ∪ c ∪ aa ∪ ac ∪ aba ∪ abb)(a ∪ b ∪ c) is a regular expression for {a, b, c} − L e .

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- L(G, T ) = {a | ≥ 0}

(4)

3- L(G, S) = {a p b q | p ≥ 0, q ≥ 0, p 6= q}

4- The word aaab has two different leftmost derivations:

S → T 1 → aT 1 b → aaT 1 b → aaab S → T 1 → aT 1 → aaT 1 b → aaab This shows that G is ambiguous.

5- The ambiguity is due to the fact that rules r3, r4 are commuting and, as well r6, r7 are commuting. Hence a word w is generated by G with exactly one derivation-tree iff w is generated by a derivation tree T such that:

- either T uses r4 but not r3 - or T uses r7 but not r6 - or T uses r3 but not r4 - or T uses r6 but not r7

The two first types of derivation-trees give rise to the set of words:

{a p b q | p ≥ 1, q ≥ 1, |p − q| = 1}

The third type of derivation-trees gives rise to the set of words: {a p | p ≥ 2}

The fourth type of derivation-trees gives rise to the set of words: {b q | q ≥ 2}.

Consequently:

L = {a p b q | p ≥ 1, q ≥ 1, |p − q| = 1} ∪ {a p | p ≥ 2} ∪ {b q | q ≥ 2}

6- A non-ambigyous c.f. grammar could be, for example: G := (A, N , R ) where A = {a, b}, N = {S, T 1 , T 2 , E} and R consists of the following rules:

r’1: S → T 1

r’2: S → T 2

r’3: T 1 → aT 1

r’4: T 1 → aE r’5: T 1 → a r’6: T 2 → T 2 b r’7: T 2 → Eb r’8: T 2 → b r’9: E → aEb r’10: E → ab

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- We compute the subset of productive non-terminals of G by the fixpoint technique explained

(5)

in the lecture:

V 1 = {S 3 }, V 2 = {S 3 , S 2 }.V 3 = {S 3 , S 2 , S 1 }, V 4 = V 3 . Hence the set of productive non-terminals is {S 1 , S 2 , S 3 }.

2- We compute the subset of useful non-terminals of G by the fixpoint technique explained in the lecture:

N 1 = {S 1 }, N 2 = {S 1 , S 2 , S 3 }, N 3 = N 2

Hence the set of useful non-terminals is {S 1 , S 2 , S 3 }.

3- We can thus transform the grammar G into an equivalent grammar G where every non- terminal is productive and useful, just by restricting both the non-terminal alphabet and the rules to the subset N 2 :

G := (A, N , R ) where A = {a, b, c}, N = {S 1 , S 2 , S 3 } and R consists of the following 8 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

4- The language L(G, S 1 ) is not empty, since the non-terminal S 1 is productive.

5- We observe that:

S 1 → aS 1 S 1 → aS 1 aac and S 1 → aac

hence {a n (aac) n +1 } ⊆ L(G, S 1 ), which shows that the language L(G, S 1 ) is infinite.

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- The following context-free grammar generates the language L(G 1 , S) · L(G 2 , U ):

G · := (A, N, R · ) where A = {a, b, c}, N := N 1 ∪ N 2 ∪ {σ} ,R · := R 1 ∪ R 2 ∪ {σ → ST }, 2- The following context-free grammar generates the language L(G 1 , S) ∪ L(G 2 , U ):

G ∪ := (A, N, R ∪ ) where A = {a, b, c}, N := N 1 ∪ N 2 ∪ {σ} ,R ∪ := R 1 ∪ R 2 ∪ {σ → S, σ → T}, 3- The following context-free grammar generates the language L(G 1 , S) :

G ∗ := (A, N ∗ , R ∗ ) where A = {a, b, c}, N ∗ := N 1 ∪ {σ} ,R ∗ := R 1 ∪ {σ → σS, σ → ε},

4- The following context-free grammar H 1 generates ϕ(L(G 1 , S)): H 1 := (B, N 1 , R 1,ϕ ) where B = {x, y}, R 1 ,ϕ consists of the rules:

S → xySyxT, S → yT, T → xyT T yx, T → y

The following context-free grammar H 2 generates ϕ(L(G 2 , U )): H 2 := (B, N 2 , R 2 ,ϕ ) where

B = {x, y}, R consists of the rules:

(6)

0 a 1 b 2 c

a ∪ c a ∪ b b ∪ c

b a

c

b ∪ c a ∪ c a ∪ b

i ε 0 1 2

a ∪ b ∪ c

ε t

c

ab

a ∪ b b ∪ c ∪ aa ∪ ac

i

t

0 2

3 ε

ε

a ∪ b ∪ c a ∪ b ∪ c

ε ε

i 0 t

abc a ∪ b ∪ c

b ∪ c ∪ aa ∪ ac ∪ aba ∪ abb

ε

abc

i 0 ( b ∪ c ∪ aa ∪ ac ∪ aba ∪ abb )( a ∪ b t ∪ c )

i t

( abc )

( b ∪ c ∪ aa ∪ ac ∪ aba ∪ abb )( a ∪ b ∪ c )

6

Références

Documents relatifs

In this connection we are planning to convene a meeting of the chairmen of the national certification committees with national coordinators of laboratory containment of

Conclude to the existence and uniqueness of a global (in time) variational solution to the nonlinear McKean- Vlasov equation..

In any 3-dimensional warped product space, the only possible embedded strictly convex surface with constant scalar curvature is the slice sphere provided that the embedded

We construct a cohomology theory on a category of finite digraphs (directed graphs), which is based on the universal calculus on the algebra of functions on the vertices of

Subject: Formal languages theory Date: 26 August 2014.

Thus each mathematical symbol (G, L,. .) has a single definite meaning inside each exercise, but might have different meanings from an exercise to another.. It is not required to

En comparaison avec le lancer de marteau, quel type d’action doit exercer le Soleil sur une planète pour l’empêcher de s’échapper dans l’espace?. (figures 1 et

Let (M, J) be a compact, connected almost complex manifold, endowed with the action of a connected compact Lie group G, and let L be a positive G-equivariant line bundle on M.. One