• Aucun résultat trouvé

Transducteurs d arbres et (peut-être un peu) apprentissage

N/A
N/A
Protected

Academic year: 2022

Partager "Transducteurs d arbres et (peut-être un peu) apprentissage"

Copied!
103
0
0

Texte intégral

(1)

Introduction Taxonomie Apprentissage Conclusion Biblio

Transducteurs d’arbres et (peut-ˆetre un peu) apprentissage

A. Lemay

2006

(2)

Introduction Taxonomie Apprentissage Conclusion Biblio

Taxonomie des transducteurs d’arbres

Syntax Directed translation (Irons 60)

Attributed Tree Transducers (Knuth 68, F¨ulop 81)

Rational Tree Transductions ”`a TATA” (Tatcher Wright 70) Relabeling Tree Transducers (Engelfriet 75)

Macro Tree Transducers (Engelfriet 80, ...) Tree Walking Transducers (Aho/Ullman 80)

Pebble Tree Transducers (Milo, Suciu, Vianu 2000)

MSO Tree Transducers (Engelfriet 91, Courcelle 92)

+ variantes diverses (Pebble Macro Tree Transducer, . . .)

(3)

Introduction Taxonomie Apprentissage Conclusion Biblio

1 Taxonomie des transducteurs d’arbres Syntax Directed Transducers Attributed Tree Transducer MSO Tree transducers Transductions rationnelles Macro Tree Transducers

Tree Walking/Pebble Tree Transducers R´ecapitulatif

2 Apprentissage de transducteurs

Principes G´en´eraux

(4)

Introduction Taxonomie Apprentissage Conclusion Biblio

Plan

1 Taxonomie des transducteurs d’arbres Syntax Directed Transducers Attributed Tree Transducer MSO Tree transducers Transductions rationnelles Macro Tree Transducers

Tree Walking/Pebble Tree Transducers R´ecapitulatif

2 Apprentissage de transducteurs

Principes G´en´eraux

(5)

Introduction Taxonomie Apprentissage Conclusion Biblio

SD Transducers

Plan

1 Taxonomie des transducteurs d’arbres Syntax Directed Transducers Attributed Tree Transducer MSO Tree transducers Transductions rationnelles Macro Tree Transducers

Tree Walking/Pebble Tree Transducers R´ecapitulatif

2 Apprentissage de transducteurs

Principes G´en´eraux

(6)

Introduction Taxonomie Apprentissage Conclusion Biblio

SD Transducers

SD Transducers : d´efinition

D´efinition (informelle)

bas´ee sur une grammaire context-free

( ' Deux grammaires Context-Free en parall`ele) R`egles de la forme : XaY (1) Y (2) cZ { Y (1) deZY (2) }

tous les non-terminaux se retrouvent dans la production pas de contraintes sur les terminaux

la production se fait en d´eroulant le parse.

Provient des travaux sur les compilateurs (origine ALGOL 60)

(7)

Introduction Taxonomie Apprentissage Conclusion Biblio

SD Transducers

SD Transducers : exemple

Passage infixe vers Suffixe

SE {E } TT × P {TP×}

EE + T { ET + } TT /P { TP/ } EET {ET −} TP {P}

ET {T } Pi × P {iP×}

(8)

Introduction Taxonomie Apprentissage Conclusion Biblio

SD Transducers

SD Transducers : Conclusion

Conclusion

Int´erˆet historique (vient des la compilation d’ALGOL 60)

Sous-famille de transductions rationnels

(9)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Plan

1 Taxonomie des transducteurs d’arbres Syntax Directed Transducers Attributed Tree Transducer MSO Tree transducers Transductions rationnelles Macro Tree Transducers

Tree Walking/Pebble Tree Transducers R´ecapitulatif

2 Apprentissage de transducteurs

Principes G´en´eraux

(10)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammars : Principes

Exemple : parcours dans l’espace

path → ε | step .path step → N | S | O | E

Id´ee : associer des attributs (propri´et´es) aux non terminaux d’une grammaire context-free

Exemple :

quelle est la longueur du chemin en nombre de pas ?

quel est le chemin parcouru sur la coordonn´ee x ou y ?

(11)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : Exemple 1

path .Pos x : Coordonn´ee en x d’un chemin step .Dep x : Coordonn´ee en x d’un pas Grammaire

Grammaire R`egle s´emantique path → ε path .Pos x = 0

path → step .path path .Dep x = step .Dep x + path .Pos x step → N | S step .Dep x = 0

step → O step .Dep x = − 1

step → E step .Dep x = 1

(12)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : Exemple 1

Chemin O. N. E. : path 0 step −1

O

path 1 step 0

N

path 1 step 1

E

path 0

ε 0

(13)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : Exemple 1

Chemin O. N. E. : path 0 step 1

O

path 1 step 0

N

path 1 step 1

E

path 0 ε 0

+

− 1 +

0 +

1 0

Le calcul des attributs peut se voir comme une transformation

(14)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Parenth`ese

ATT et requˆete

Requˆete ATT : ATT dont l’un des attributs est bool´een

mˆeme expressivit´e que MSO (Bloem Engelfriet 96)

(15)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammars : attributs

Deux types d’attributs :

attributs Synth´etis´es (Syn ) : valeur d´ependante des descendants (ici Pos x et Dep x )

attributs h´erit´es (Inh ) : valeur d´ependante des parents ou

des fr`eres (du contexte).

(16)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

Grammaire Infixe vers Suffixe Syn = { a S }

Inh = {a I }

Grammaire R`egle s´emantique ST S.a S = T .a S

T .a I = ε T → 1 T .a S = 1(T .a I ) TT 1 + T 2 T .a S = T 1 .a S

T 1 .a I = T 2 .a S

T 2 .a I = +(T .a I )

(17)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = B.a S , B.a I = C.a S , C.a I = +(A.a I )

(18)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = D.a S , B.a I = C.a S , C.a I = +()

(19)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A . a S = D . a S , B . a I = C . a S , C . a I = +() B.a S = D.a S , D.a I = E.a S ,

E .a I = +(B.a I )

(20)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A . a S = D . a S , B . a I = C . a S , C . a I = +() B.a S = D.a S , D.a I = E.a S ,

E .a I = +(C.a S )

(21)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A . a S = D . a S , B . a I = C . a S , C . a I = +() B.a S = D.a S , D.a I = E.a S ,

E .a I = +(C.a S )

(22)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = D.a S , B.a I = C.a S , C.a I = +() B.a S = D.a S , D.a I = E.a S ,

E .a I = +(C.a S )

C.a S = 1(C.a I )

(23)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = D.a S , B.a I = C.a S , C.a I = +() B.a S = D.a S , D.a I = E.a S ,

E .a I = +(C.a S )

C.a S = 1(+())

(24)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = D.a S , B.a I = 1(+()), C.a I = +() B.a S = D.a S , D.a I = E.a S ,

E .a I = +(C.a S )

C.a S = 1(+())

(25)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = D.a S , B.a I = 1(+()), C.a I = +() B.a S = D.a S , D.a I = E.a S ,

E .a I = +(C.a S )

C.a S = 1(+())

(26)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = D.a S , B.a I = 1(+()), C.a I = +() B.a S = D.a S , D.a I = E.a S ,

E .a I = +(1(+()))

C.a S = 1(+())

(27)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = D.a S , B.a I = 1(+()), C.a I = +() B . a S = D . a S , D . a I = E . a S ,

E .a I = +(1(+()))

C.a S = 1(+())

D.a S = 1(D.a I )

(28)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = D.a S , B.a I = 1(+()), C.a I = +() B . a S = D . a S , D . a I = E . a S ,

E .a I = +(1(+()))

C.a S = 1(+())

D.a S = 1(E.a S )

(29)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = D.a S , B.a I = 1(+()), C.a I = +() B . a S = D . a S , D . a I = E . a S ,

E .a I = +(1(+()))

C.a S = 1(+())

D.a S = 1(E.a S )

(30)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = D.a S , B.a I = 1(+()), C.a I = +() B . a S = 1(E . a S ), D . a I = E . a S ,

E .a I = +(1(+()))

C.a S = 1(+())

D.a S = 1(E.a S )

(31)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = 1(E .a S ), B.a I = 1(+()), C.a I = +() B . a S = 1(E . a S ), D . a I = E . a S ,

E .a I = +(1(+()))

C.a S = 1(+())

D.a S = 1(E.a S )

(32)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = 1(E .a S ), B.a I = 1(+()), C.a I = +() B.a S = 1(E .a S ), D.a I = E.a S ,

E .a I = +(1(+()))

C.a S = 1(+())

D.a S = 1(E.a S )

E .a S = 1(E.a I )

(33)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = 1(E .a S ), B.a I = 1(+()), C.a I = +() B.a S = 1(E .a S ), D.a I = E.a S ,

E .a I = +(1(+()))

C.a S = 1(+())

D.a S = 1(E.a S )

E .a S = 1(+(1(+())))

(34)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = 1(E .a S ), B.a I = 1(+()), C.a I = +() B.a S = 1(E .a S ), D.a I = E.a S ,

E .a I = +(1(+())) C.a S = 1(+())

D.a S = 1(1(+(1(+()))))

E .a S = 1(+(1(+())))

(35)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = 1(E .a S ), B.a I = 1(+()), C.a I = +() B.a S = 1(1(+(1(+())))), D.a I = E.a S , E .a I = +(1(+()))

C.a S = 1(+())

D.a S = 1(1(+(1(+()))))

E .a S = 1(+(1(+())))

(36)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

Attributed Grammar : exemple 2

R`egles

ST S.a

S

= T .a

S

TT

1

+ T

2

T .a

S

= T

1

.a

S

T .a

I

= ε T

1

.a

I

= T

2

.a

S

T → 1 T .a

S

= 1(T .a

I

) T

2

.a

I

= +(T .a

I

) Exemple : (1 + 1) + 1 en 1 1 + 1 +

+

A

+

B

1

D

1

E

1

C

A.a S = 1(1(+(1(+())))), B.a I = 1(+()), C.a I = +() B.a S = 1(1(+(1(+())))), D.a I = E.a S ,

E .a I = +(1(+())) C.a S = 1(+())

D.a S = 1(1(+(1(+()))))

E .a S = 1(+(1(+())))

(37)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

ATT (1)

M = h Syn , Inh , Σ, ∆, a 0 , ], Ri

Syn : attributs synth´etis´ees (par le bas) Inh : attributs h´erit´es (par le haut) a 0 : attribut initial (∈ Syn )

] : symbole initial R : r`egles

Id´ee :

les transformations sont des attributs des noeuds

l’arbre de sortie est un attribut de la racine

Syn permet une transformation ascendante

Inh permet une transformation descendante

Note : pas d’´etats

(38)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

ATT (2)

D´efinition

M = h Syn , Inh , Σ, ∆, a 0 , ], R i R`egles de la forme :

a(π) −→

σ

ν pour a ∈ Syn , σ ∈ Σ ∪ { ] } , ν ∈ RHS ∪ {⊥}

b(π

i

) −→

σ

ν pour b ∈ Inh , σ ∈ Σ ∪ { ] } , ν ∈ RHS ∪ {⊥}

RHS (Right Hand Side) d´efini sur

∆ ∪ Syn ∪ Inh ∪ { π, π 1 , . . . , π k } :

a ∈ Syn : a(π

i

) ∈ RHS (l’attribut a du i -`eme fils)

b ∈ Inh : b(π)RHS (l’attribut b du p`ere)

σ ∈ ∆ : σ(ν

1

, . . . , ν

k

) ∈ RHS avec ν

i

RHS

(39)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

ATT : exemple

Passage notation infixe vers suffixe Syn = a S , Inh = a I

Grammaire ATT

ST S.a S = T .a S a S (π) −→ ] a S1 ) T .a I = ε a I (π 1 ) −→ ] end T → 1 T .a S = 1(T .a I ) a S (π) −→ 1 1(a I (π)) TT 1 + T 2 T . a S = T 1 . a S a S (π) −→ + a S1 )

T 1 .a I = T 2 .a S a I (π 1 ) −→ + a S (π 2 )

T 2 .a I = +, T .a I a I (π 2 ) −→ + +(a I (π))

(40)

Introduction Taxonomie Apprentissage Conclusion Biblio

Attributed Tree Transducer

ATT : Conclusion

Attributed Tree Transducer

bas´e sur les attributed grammars : grammaires CFG avec propri´et´e sur les non-terminaux.

l’arbre de sortie est un attribut particulier (parmi d’autres).

Note

ATT top-down : sans attributs h´erit´es.

ATT top-down ( ATT

n-ATT ( (n+1)-ATT

Apprentissage : improbable

(41)

Introduction Taxonomie Apprentissage Conclusion Biblio

MSO Tree transducers

Plan

1 Taxonomie des transducteurs d’arbres Syntax Directed Transducers Attributed Tree Transducer MSO Tree transducers Transductions rationnelles Macro Tree Transducers

Tree Walking/Pebble Tree Transducers R´ecapitulatif

2 Apprentissage de transducteurs

Principes G´en´eraux

(42)

Introduction Taxonomie Apprentissage Conclusion Biblio

MSO Tree transducers

MSO dans les arbres

formules atomiques : label σ (x ) edge(x , y ) xX leaf (x) root (x )

MSO1

formules MSO avec une variable libre d´efinit des propri´et´es sur les noeuds utile pour les requˆetes unaires

Exemple : Φ(x ) = { lab f (x ) ∧ ∃ x , edge(y , x ), leaf (x) } Les noeuds ´etiquet´es f dont l’un des fils est une feuille.

MSO2

Deux variables libres Φ(x , y ) : d´efinit des relations entre deux

noeuds

(43)

Introduction Taxonomie Apprentissage Conclusion Biblio

MSO Tree transducers

MSO Graph Transducers

D´efinit une fonction partielle τ M : g = (E, V ) → h = (E 0 , V 0 ) Definition (Courcelle 94)

M = h Copy , Φ, Ψ n , Ψ a i avec : Copy : l’ensemble de copie

Φ : formule MSO1 sur Σ (le domaine)

Ψ n c,σ : formule MSO1 (formule des noeuds) d´ependante de c ∈ Copy et σ ∈ ∆

Ψ a c,c

0

: formule MSO2 (formule des arcs) d´ependante de

c, c 0 ∈ Copy

(44)

Introduction Taxonomie Apprentissage Conclusion Biblio

MSO Tree transducers

MSO Graph Transducers

D´efinit une fonction partielle τ M : g = (E, V ) → h = (E 0 , V 0 ) d´efini si g ∈ Φ

E 0 = {(c, u) | c ∈ Copy , uV 0 , ψ c,σ n (u)}

V 0 = { ((c , u), (c 0 , u 0 )) | c , c 0 ∈ Copy , uV 0 , ψ c,c a

0

(u , u 0 ) }

Id´ees

Φ est le domaine de la fonction

Copy d´etermine le ”type” des noeuds de h

ψ c,σ n d´efinit quels sont les noeuds de g copi´es de type c et relabell´es par σ

ψ c,c a

0

d´efinit quels sont les relations entre noeuds de h

n´ecessaires pour cr´eer une arˆete dans h

(45)

Introduction Taxonomie Apprentissage Conclusion Biblio

MSO Tree transducers

MSO Tree Transducers

MSO Tree Transducer

MSO Tree Transducer = MSO Graph Transducer sur les

arbres (en entr´ees/sortie)

(46)

Introduction Taxonomie Apprentissage Conclusion Biblio

MSO Tree transducers

MSO-Tree Transducer : Exemple

HTML BODY TABLE

TR TR

TD TEXTE

TD TEXTE

TR

RACINE ID

...

ID

TEXTE TEXTE

Id ...

Copy = { racine, id, nom, prenom }

(47)

Introduction Taxonomie Apprentissage Conclusion Biblio

MSO Tree transducers

MSO-Tree Transducer : Exemple

HTML BODY TABLE

TR TR

TD TEXTE

TD TEXTE

TR

RACINE ID

...

ID

TEXTE TEXTE

Id ...

Ψ n racine,RACINE (x ) = (root(x)) Ψ n id ,ID (x) = label TR (x )

Ψ n nom,TEXTE (x ) =

(fils d’un TD premier fils d’un TR)

Ψ n prenom,TEXTE (x ) =

(fils d’un TD second fils d’un TR)

(48)

Introduction Taxonomie Apprentissage Conclusion Biblio

MSO Tree transducers

MSO-Tree Transducer : Exemple

HTML BODY TABLE

TR TR

TD TEXTE

TD TEXTE

TR

RACINE ID

...

ID

TEXTE TEXTE

Id ...

Ψ a racine,id (x , y ) = (true) Ψ a id ,nom (x, y ) =

x est le petit-fils de y

Ψ a id ,prenom (x , y ) =

x est le petit-fils de y

(49)

Introduction Taxonomie Apprentissage Conclusion Biblio

Transductions rationnelles

Plan

1 Taxonomie des transducteurs d’arbres Syntax Directed Transducers Attributed Tree Transducer MSO Tree transducers Transductions rationnelles Macro Tree Transducers

Tree Walking/Pebble Tree Transducers R´ecapitulatif

2 Apprentissage de transducteurs

Principes G´en´eraux

(50)

Introduction Taxonomie Apprentissage Conclusion Biblio

Transductions rationnelles

Automate d’Arbres : Notations

M = hQ, Σ, F , δ i

Q : ensemble fini d’´etats

Σ : alphabet ”ranked” (d’entr´ee)

F : ensemble des ´etats finaux (ou initiaux) δ : r`egles de la forme

aq(a)

f (q

1

(x

1

), . . . , q

n

(x

n

)) → q(f (x

1

, . . . , x

n

)) (pour un ascendant)

Pour les transductions : ∆ est l’alphabet de sortie

(51)

Introduction Taxonomie Apprentissage Conclusion Biblio

Transductions rationnelles

Relabeling Tree Transducers

Transducteurs qui changent l’´etiquetage de l’arbre de Σ vers ∆.

´Equivalent aux transducteurs shape-preserving

[Fulop & Gazdag 03 / Gazdag 04]

Formes des r`egles aq(b)

f (q 1 (x 1 ), . . . , q n (x n )) → q(g(x 1 , . . . , x k )) (souvent not´e (f (q 1 , . . . , q n )) → q(g))

Node Selecting Tree Transducers : Relabeling fonctionnels avec Bool comme alphabet de sortie.

Permettent de repr´esenter les requˆetes monadiques r´eguli`eres

(MSO, etc...)

(52)

Introduction Taxonomie Apprentissage Conclusion Biblio

Transductions rationnelles

Relabeling : Exemple

aq 1 (1) aq 2 (0)

f (q 1 , q 1 ) → q 2 (0) f (q 2 , q 2 ) → q 1 (0) Final = { q 2 }

f a f

a f a a

= ⇒ 0 1 0

0 0

1 1

(53)

Introduction Taxonomie Apprentissage Conclusion Biblio

Transductions rationnelles

Relabeling : Conclusion

Avantages

Permettent de repr´esenter les requˆetes monadiques r´eguli`eres (via les NSTT)

Apprenables [ICGI’04]

Limitations

Aucun changement de structure !

(54)

Introduction Taxonomie Apprentissage Conclusion Biblio

Transductions rationnelles

Transducteurs d’arbres ”`a TATA”

Formes des r`egles aq(u)

f (q 1 (x 1 ), . . . , q n (x n )) → q(u) (not´e (f (q 1 , . . . , q n )) → q(u)) avec uT ∆ ∪ X

Peuvent ˆetre d´eterministes top-down ou bottom-up (en fonction

de l’automate d’arbres support)

(55)

Introduction Taxonomie Apprentissage Conclusion Biblio

Transductions rationnelles

Tree Transducers : Exemple

D(+(x

1

, x

2

)) → +(D(x

1

), D(x

2

)) D( × (x

1

, x

2

)) → +( × (D(x

1

), I(x

2

)),

× (I(x

1

), D(x

2

))) I ( × (x

1

, x

2

)) → × (I(x

1

), I(x

2

)) D(sin(x

1

)) → × (cos(I(x

1

)), D(x

1

))

I (a) → a

I (y ) → y

D(a) → 0

D(y ) → 1

. . .

D sin

×

a y

Calcul de la d´eriv´ee d’une fonction Alphabet : 0, 1, a, y , +, ×, sin, cos

´Etats : D (d´erive), I (identit´e)

(56)

Introduction Taxonomie Apprentissage Conclusion Biblio

Transductions rationnelles

Tree Transducers : Exemple

D(+(x

1

, x

2

)) → +(D(x

1

), D(x

2

)) D( × (x

1

, x

2

)) → +( × (D(x

1

), I(x

2

)),

× (I(x

1

), D(x

2

))) I ( × (x

1

, x

2

)) → × (I(x

1

), I(x

2

)) D(sin(x

1

)) → × (cos(I(x

1

)), D(x

1

))

I (a) → a

I (y ) → y

D(a) → 0

D(y ) → 1

. . .

× cos

I

×

a y

D

×

a y

Calcul de la d´eriv´ee d’une fonction Alphabet : 0, 1, a, y , +, ×, sin, cos

´Etats : D (d´erive), I (identit´e)

(57)

Introduction Taxonomie Apprentissage Conclusion Biblio

Transductions rationnelles

Tree Transducers : Exemple

D(+(x

1

, x

2

)) → +(D(x

1

), D(x

2

)) D( × (x

1

, x

2

)) → +( × (D(x

1

), I(x

2

)),

× (I(x

1

), D(x

2

))) I ( × (x

1

, x

2

)) → × (I(x

1

), I(x

2

)) D(sin(x

1

)) → × (cos(I(x

1

)), D(x

1

))

I (a) → a

I (y ) → y

D(a) → 0

D(y ) → 1

. . .

× cos

×

a y

+

× D a

I y

× I a

D y

Calcul de la d´eriv´ee d’une fonction Alphabet : 0, 1, a, y , +, ×, sin, cos

´Etats : D (d´erive), I (identit´e)

(58)

Introduction Taxonomie Apprentissage Conclusion Biblio

Transductions rationnelles

Tree Transducers : Exemple

D(+(x

1

, x

2

)) → +(D(x

1

), D(x

2

)) D( × (x

1

, x

2

)) → +( × (D(x

1

), I(x

2

)),

× (I(x

1

), D(x

2

))) I ( × (x

1

, x

2

)) → × (I(x

1

), I(x

2

)) D(sin(x

1

)) → × (cos(I(x

1

)), D(x

1

))

I (a) → a

I (y ) → y

D(a) → 0

D(y ) → 1

. . .

× cos

×

a y

+

×

0 y

×

a 1

Calcul de la d´eriv´ee d’une fonction Alphabet : 0, 1, a, y , +, ×, sin, cos

´Etats : D (d´erive), I (identit´e)

(59)

Introduction Taxonomie Apprentissage Conclusion Biblio

Transductions rationnelles

Tree Transducers : Conclusion

avantages

changements de structure possible

non-linearit´e (copie), effacement de branches, permutation, ...

Inconv´enients

reste limit´e : difficile de remonter des branches

(60)

Introduction Taxonomie Apprentissage Conclusion Biblio

Transductions rationnelles

Variante : avec look-ahead

Composition avec un automate d’arbre

1

L’arbre est lu par un automate d’arbre ascendant

2

les noeuds sont ´etiquet´es par les ´etats du run

3

le nouvel arbre est transform´e par un transducteur descendant

Le processus peut alors ˆetre d´eterministe

(61)

Introduction Taxonomie Apprentissage Conclusion Biblio

Transductions rationnelles

Variante : avec alg`ebre de substitution

l’alg`ebre YIELD (ou SUBST) n symboles sp´eciaux α i

Un symbole de substitution SUBST

les α i sont substitu´ees par les arguments de SUBST SUBST

f

a α 2 α 1

b c YIELD

f

a c b

Transduction vers les trees avec SUBST puis YIELD :

possibilit´e de d´eplacer des branches

(62)

Introduction Taxonomie Apprentissage Conclusion Biblio

Macro Tree Transducers

Plan

1 Taxonomie des transducteurs d’arbres Syntax Directed Transducers Attributed Tree Transducer MSO Tree transducers Transductions rationnelles Macro Tree Transducers

Tree Walking/Pebble Tree Transducers R´ecapitulatif

2 Apprentissage de transducteurs

Principes G´en´eraux

(63)

Introduction Taxonomie Apprentissage Conclusion Biblio

Macro Tree Transducers

Macro Tree Transducers : Principes

Mˆeme id´ee g´en´eral qu’un transducteur d’arbres mais, utilisation de param`etres (”accumulateurs”) : bouts d’arbres collect´es lors du run

dans une r`egle :

possibilit´e de ”stocker” un bout d’arbre (passer en param`etre)

possibilit´e d’utiliser les arbres stock´es dans les arbres de sortie

Grosso-Modo la mˆeme chose qu’un transducteur avec

alg`ebre de YIELD

(64)

Introduction Taxonomie Apprentissage Conclusion Biblio

Macro Tree Transducers

Macro Tree Transducers : Definition

M = h Q, Σ, ∆, I, δ i Formes des r`egles

q(a, y 1 , . . . , y m ) → ξ

q(f(x 1 , . . . , x k ), y 1 , . . . , y m ) → ξ ξ : arbres tel que

σ(t

1

, . . . , t

l

) ∈ ξ, pour tout σ ∈ ∆, t

j

∈ ξ

arbre sur l’alphabet de sortie

q(x

i

, t

1

, . . . , t

l

), pour qQ, x

i

X , t

j

∈ ξ

copie de sous arbre d’entr ´ee, + accumulation

y

i

∈ ξ, pour tout y

i

Y

copie de param`etre

Attention : vision top-down

Note : MTT sans param`etre = transducteur d’arbre top-down

(65)

Introduction Taxonomie Apprentissage Conclusion Biblio

Macro Tree Transducers

Macro Tree Transducers : Exemple

Exemple : retirer les multiplications q

0

(+(x

1

, x

2

)) → +(q

0

(x

1

), q

0

(x

2

)) q

0

(1) → 1

q

0

( × (x

1

, x

2

)) → q(x

1

, q

0

(x

2

))

q(+(x

1

, x

2

), y

1

) → +(q(x

1

, y

1

), q(x

2

, y

1

)) q(1, y

1

) → y

1

q

0

( × (x

1

, x

2

), y

1

) → q(x

1

, q(x

2

, y

1

))

q0

× + +

1 1

1 +

1 1

(66)

Introduction Taxonomie Apprentissage Conclusion Biblio

Macro Tree Transducers

Macro Tree Transducers : Exemple

Exemple : retirer les multiplications q

0

(+(x

1

, x

2

)) → +(q

0

(x

1

), q

0

(x

2

)) q

0

(1) → 1

q

0

( × (x

1

, x

2

)) → q(x

1

, q

0

(x

2

))

q(+(x

1

, x

2

), y

1

) → +(q(x

1

, y

1

), q(x

2

, y

1

)) q(1, y

1

) → y

1

q

0

( × (x

1

, x

2

), y

1

) → q(x

1

, q(x

2

, y

1

))

q + +

1 1

1

+ q0

1 q0

1

(67)

Introduction Taxonomie Apprentissage Conclusion Biblio

Macro Tree Transducers

Macro Tree Transducers : Exemple

Exemple : retirer les multiplications q

0

(+(x

1

, x

2

)) → +(q

0

(x

1

), q

0

(x

2

)) q

0

(1) → 1

q

0

( × (x

1

, x

2

)) → q(x

1

, q

0

(x

2

))

q(+(x

1

, x

2

), y

1

) → +(q(x

1

, y

1

), q(x

2

, y

1

)) q(1, y

1

) → y

1

q

0

( × (x

1

, x

2

), y

1

) → q(x

1

, q(x

2

, y

1

))

+ q +

1 1

+

1 1

q

1 +

1 1

(68)

Introduction Taxonomie Apprentissage Conclusion Biblio

Macro Tree Transducers

Macro Tree Transducers : Exemple

Exemple : retirer les multiplications q

0

(+(x

1

, x

2

)) → +(q

0

(x

1

), q

0

(x

2

)) q

0

(1) → 1

q

0

( × (x

1

, x

2

)) → q(x

1

, q

0

(x

2

))

q(+(x

1

, x

2

), y

1

) → +(q(x

1

, y

1

), q(x

2

, y

1

)) q(1, y

1

) → y

1

q

0

( × (x

1

, x

2

), y

1

) → q(x

1

, q(x

2

, y

1

))

+ + +

1 1

+

1 1

+

1 1

(69)

Introduction Taxonomie Apprentissage Conclusion Biblio

Macro Tree Transducers

MTT with regular look-ahead MTT R

M = h Q, P, Σ, ∆, I, δ,h i

hQ, Σ, ∆, I, δ, i est un MTT particulier

h P, Σ, h i est un automate d’arbre (l’automate ”look-ahead”

de M) Fonctionnement

On fait un run avec le look-ahead automaton (les noeuds sont ´etiquet´es par les ´etats de P)

Les r`egles du MTT d´ependent des ´etats des fils de l’´etats courants. R`egles de la forme :

hq, σ(p 1 (x 1 ), . . . , p n (x n )) → ξ

Note : MTT R = MTT (Engelfriet Vogler, 85)

(70)

Introduction Taxonomie Apprentissage Conclusion Biblio

Tree Walking et Pebble Tr. Tr.

Plan

1 Taxonomie des transducteurs d’arbres Syntax Directed Transducers Attributed Tree Transducer MSO Tree transducers Transductions rationnelles Macro Tree Transducers

Tree Walking/Pebble Tree Transducers R´ecapitulatif

2 Apprentissage de transducteurs

Principes G´en´eraux

(71)

Introduction Taxonomie Apprentissage Conclusion Biblio

Tree Walking et Pebble Tr. Tr.

Tree Walking Transducer (1)

Principes :

Bas´e sur la notion de Tree Walking Automaton

les r`egles impliquent un mouvement dans l’arbre d’entr´ee (up / down / stay ) (idem Tree Walking Automata)

les r`egles produisent des bouts d’arbres dans lesquelles il

peut y avoir des branchements multiples (branching)

(72)

Introduction Taxonomie Apprentissage Conclusion Biblio

Tree Walking et Pebble Tr. Tr.

Tree Walking Transducer (2)

M = hQ, Σ, ∆, I, Ri R`egles de la forme h q, f i → ξ avec ξ :

hq 0 , stay i

hq 0 , up i (sauf si racine) h q 0 , down i i (i : num´ero du fils)

σ( h q 1 , stay i , . . . , h q k , stay i ) (relabeling + branching)

(73)

Introduction Taxonomie Apprentissage Conclusion Biblio

Tree Walking et Pebble Tr. Tr.

TWT : exemple

Exemple : explosion en largeur

M = hQ = {q} , Σ = {a 1 , e 0 } , ∆ = { σ 2 , e 0 } , I = {q} , R} avec R : h q, a i → σ( h q, down 1 i , h q, down 1 i )

h q, e i → e a

a a e

σ

· ·

(74)

Introduction Taxonomie Apprentissage Conclusion Biblio

Tree Walking et Pebble Tr. Tr.

TWT : exemple

Exemple : explosion en largeur

M = hQ = {q} , Σ = {a 1 , e 0 } , ∆ = { σ 2 , e 0 } , I = {q} , R} avec R : h q, a i → σ( h q, down 1 i , h q, down 1 i )

h q, e i → e a

a

a e

σ σ

· ·

σ

· ·

(75)

Introduction Taxonomie Apprentissage Conclusion Biblio

Tree Walking et Pebble Tr. Tr.

TWT : exemple

Exemple : explosion en largeur

M = hQ = {q} , Σ = {a 1 , e 0 } , ∆ = { σ 2 , e 0 } , I = {q} , R} avec R : h q, a i → σ( h q, down 1 i , h q, down 1 i )

h q, e i → e a

a a e

σ σ

σ σ

σ

σ a

(76)

Introduction Taxonomie Apprentissage Conclusion Biblio

Tree Walking et Pebble Tr. Tr.

TWT : exemple

Exemple : explosion en largeur

M = hQ = {q} , Σ = {a 1 , e 0 } , ∆ = { σ 2 , e 0 } , I = {q} , R} avec R : h q, a i → σ( h q, down 1 i , h q, down 1 i )

h q, e i → e a

a a e

a σ

σ e e

σ e e

σ

σ e e

σ

e e

(77)

Introduction Taxonomie Apprentissage Conclusion Biblio

Tree Walking et Pebble Tr. Tr.

Pebble Tree Transducer (1)

Pebble = caillou

Pebble Tree Transducer `a n cailloux : nptt Principe :

on a n cailloux diff´erents qui peuvent ˆetre d´epos´es sur les noeuds (un de chaque type par noeud au max.)

un vecteur de bool´een sur chaque noeud

les r`egles peuvent d´ependre de la pr´esence de cailloux les r`egles impliquent un mouvement dans l’arbre d’entr´ee (up / down / stay ) (idem Tree Walking Automata)

les r`egles peuvent d´eposer (drop ) ou retirer (lift ) des

cailloux

(78)

Introduction Taxonomie Apprentissage Conclusion Biblio

Tree Walking et Pebble Tr. Tr.

Pebble Tree Transducer (2)

M = hQ, Σ, ∆, I, Ri R`egles de la forme

h q, f , b i → ξ avec b vecteur de cailloux (b ∈ { 0, 1 } n ) et ξ : σ( h q 1 , stay i , . . . , h q k , stay i ) (relabeling + branching) hq 0 , stay i

hq 0 , up i (sauf si racine) hq 0 , down i i (i : num´ero du fils) h q 0 , lift l i (l : type de caillou)

h q 0 , drop l i (l : type de caillou, si pr´esent)

(79)

Introduction Taxonomie Apprentissage Conclusion Biblio

Tree Walking et Pebble Tr. Tr.

Pebble Tree Transducer (3)

M = h Q, Σ, ∆, I, R i

Forme g´en´eralis´ee (Engelfriet & Maneth) hq, f , bi → ξ avec

b vecteur de cailloux (b ∈ {0, 1} n ),

ξ ∈ T ∆ (Q × { stay , up , down i , lift , drop } )

(80)

Introduction Taxonomie Apprentissage Conclusion Biblio Tree Walking et Pebble Tr. Tr.

PTT : exemple

(81)

Introduction Taxonomie Apprentissage Conclusion Biblio

Tree Walking et Pebble Tr. Tr.

Pebble Tree Transducer

Notes

0-PTT : appel´es Tree Walking Transducers n-PTT ( (n + 1)-PTT

n-PTT = composition de n + 1 0-PTT n-DPTT (deterministe) ( n-PTT (non-circulaires) 0-DPTT = ATT Inconv´enients

Apprentissage : Improbable (lien entre arbre d’entr´ee et

de sortie peu clair)

(82)

Introduction Taxonomie Apprentissage Conclusion Biblio

R´ecapitulatif

Plan

1 Taxonomie des transducteurs d’arbres Syntax Directed Transducers Attributed Tree Transducer MSO Tree transducers Transductions rationnelles Macro Tree Transducers

Tree Walking/Pebble Tree Transducers R´ecapitulatif

2 Apprentissage de transducteurs

Principes G´en´eraux

(83)

Introduction Taxonomie Apprentissage Conclusion Biblio

R´ecapitulatif

R´ecapitulatif

Compilation SD Transducers

Transducteurs d’arbres attribu´es Automates d’arbres Relabeling

Transductions rationnelles Macro Tree Transducers Tree Walking Tree Walking Transducers

Pebble Tree Transducers

MSO MSO Tree Transducers

(84)

Introduction Taxonomie Apprentissage Conclusion Biblio

R´ecapitulatif

R´ecapitulatif : Expressivit´e

Expressivit´e des diff´erents mod`eles

RTT SDT

TT MTT

surR

MSOTT ATT

surR

MTT = MTT

R

0 − PTT = TWT ATT MTT

n+1

nPTT = TWT

n+1

MTT

PTT

ATT: Attributed Tree Transducer RTT: Relabeling Tree Transducer SDT: Syntax Directed Transducer PTT: Pebble tree transducer TWT: Tree Walking Tree Transducer MTT: Macro tree Transducers MSO-TT: Monadic Second Order Tree Transducer

Références

Outline

Documents relatifs

Indeed, let us consider the path-testable tree language (see [6]) whose trees have their branch labels (read from the leaves to the root) accepted by the finite automaton of Figure

We will then show that the normal form of a transformation τ definable by a DTopI td is indeed the minimal earliest trimmed compatible DTopI td defining τ, and that this normal form

Polynomially bounded n-ary queries represented by deterministic n- NSTT s are identifiable from polynomial time and data from completely anno- tated examples.. Before defining

We now show how to reduce the acceptance problem for a large class of infinite (complete) deterministic trees to the acceptance problem for equivalent (accord- ing to a suitable

While the λ-tree syntax approach to computing with syntax con- taining bindings has been successfully developed within the logic programming setting (in particular, in λProlog

We assume that the target tree transformation can be defined by a deterministic top-down tree transducer with regular domain inspection ( dtop i:reg ).. An rpni style learning

Equivalence is Ptime for sequential tree-to-word transducers [7], that pre- vents copying in the output and forces subtrees to produce following the order of the input..

We introduce the notion of high-order deterministic top-down tree transducers (HODT) whose