Transducteurs d arbres et (peut-être un peu) apprentissage A. Lemay 2006
Taxonomie des transducteurs d arbres Syntax Directed translation (Irons 60) Attributed Tree Transducers (Knuth 68, Fülop 81) Rational Tree Transductions à 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,...)
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écapitulatif 2 Apprentissage de transducteurs Principes Généraux
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écapitulatif 2 Apprentissage de transducteurs Principes Généraux
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écapitulatif 2 Apprentissage de transducteurs Principes Généraux
SD Transducers SD Transducers : définition Définition (informelle) basée sur une grammaire context-free ( Deux grammaires Context-Free en parallèle) Règles de la forme : X ay (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éroulant le parse. Provient des travaux sur les compilateurs (origine ALGOL 60)
SD Transducers SD Transducers : exemple Passage infixe vers Suffixe S E {E} T T P {TP } E E + T {ET +} T T /P {TP/} E E T {ET } T P {P} E T {T } P i P {ip }
SD Transducers SD Transducers : Conclusion Conclusion Intérêt historique (vient des la compilation d ALGOL 60) Sous-famille de transductions rationnels
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écapitulatif 2 Apprentissage de transducteurs Principes Généraux
Attributed Tree Transducer Attributed Grammars : Principes Exemple : parcours dans l espace path ε step.path step N S O E Idée : associer des attributs (propriétés) 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ée x ou y?
Attributed Tree Transducer Attributed Grammar : Exemple 1 path.pos x : Coordonnée en x d un chemin step.dep x : Coordonnée en x d un pas Grammaire Grammaire Règle sémantique 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
Attributed Tree Transducer Attributed Grammar : Exemple 1 Chemin O. N. E. : path 0 step 1 path 1 O step 0 path 1 N step 1 path 0 E ε 0
Attributed Tree Transducer Attributed Grammar : Exemple 1 Chemin O. N. E. : path 0 + step 1 path 1 1 + O step 0 path 1 0 + N step 1 path 0 1 0 E ε 0 Le calcul des attributs peut se voir comme une transformation
Attributed Tree Transducer Parenthèse ATT et requête Requête ATT : ATT dont l un des attributs est booléen même expressivité que MSO (Bloem Engelfriet 96)
Attributed Tree Transducer Attributed Grammars : attributs Deux types d attributs : attributs Synthétisés (Syn ) : valeur dépendante des descendants (ici Pos x et Dep x ) attributs hérités (Inh ) : valeur dépendante des parents ou des frères (du contexte).
Attributed Tree Transducer Attributed Grammar : exemple 2 Grammaire Infixe vers Suffixe Syn = {a S } Inh = {a I } Grammaire Règle sémantique S T S.a S = T.a S T.a I = ε T 1 T.a S = 1(T.a I ) T T 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 )
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 C A.a S = B.a S, B.a I = C.a S, C.a I = +(A.a I ) 1 D 1 E
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 C A.a S = D.a S, B.a I = C.a S, C.a I = +() 1 D 1 E
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 A.a S = D.a S, B.a I = C.a S, C.a I = +() 1 B.a S = D.a S, D.a I = E.a S, C E.a I = +(B.a I )
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 A.a S = D.a S, B.a I = C.a S, C.a I = +() 1 B.a S = D.a S, D.a I = E.a S, C E.a I = +(C.a S )
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 A.a S = D.a S, B.a I = C.a S, C.a I = +() 1 B.a S = D.a S, D.a I = E.a S, C E.a I = +(C.a S )
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 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, + B 1 C E.a I = +(C.a S ) C.a S = 1(C.a I ) 1 D 1 E
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 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, + B 1 C E.a I = +(C.a S ) C.a S = 1(+()) 1 D 1 E
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 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, + B 1 C E.a I = +(C.a S ) C.a S = 1(+()) 1 D 1 E
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 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, + B 1 C E.a I = +(C.a S ) C.a S = 1(+()) 1 D 1 E
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 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, + B 1 C E.a I = +(1(+())) C.a S = 1(+()) 1 D 1 E
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 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, + B 1 E.a I = +(1(+())) C C.a S = 1(+()) D.a S = 1(D.a I ) 1 D 1 E
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 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, + B 1 E.a I = +(1(+())) C C.a S = 1(+()) D.a S = 1(E.a S ) 1 D 1 E
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 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, + B 1 E.a I = +(1(+())) C C.a S = 1(+()) D.a S = 1(E.a S ) 1 D 1 E
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 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, + B 1 E.a I = +(1(+())) C C.a S = 1(+()) D.a S = 1(E.a S ) 1 D 1 E
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 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, + B 1 E.a I = +(1(+())) C C.a S = 1(+()) D.a S = 1(E.a S ) 1 D 1 E
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 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, + B 1 C E.a I = +(1(+())) C.a S = 1(+()) D.a S = 1(E.a S ) 1 D 1 E E.a S = 1(E.a I )
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 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, + B 1 C E.a I = +(1(+())) C.a S = 1(+()) D.a S = 1(E.a S ) 1 D 1 E E.a S = 1(+(1(+())))
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 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, + B 1 C E.a I = +(1(+())) C.a S = 1(+()) D.a S = 1(1(+(1(+())))) 1 D 1 E E.a S = 1(+(1(+())))
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 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, + B 1 C E.a I = +(1(+())) C.a S = 1(+()) D.a S = 1(1(+(1(+())))) 1 D 1 E E.a S = 1(+(1(+())))
Attributed Tree Transducer Attributed Grammar : exemple 2 Règles S T S.a S = T.a S T T 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 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, + B 1 C E.a I = +(1(+())) C.a S = 1(+()) D.a S = 1(1(+(1(+())))) 1 D 1 E E.a S = 1(+(1(+())))
Attributed Tree Transducer ATT (1) M = Syn, Inh, Σ,, a 0,, R Idée : Syn : attributs synthétisées (par le bas) Inh : attributs hérités (par le haut) a 0 : attribut initial ( Syn ) : symbole initial R : règles 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 états
Attributed Tree Transducer ATT (2) Définition M = Syn, Inh, Σ,, a 0,, R Règles de la forme : σ a(π) ν pour a Syn, σ Σ { }, ν RHS { } σ b(π i ) ν pour b Inh, σ Σ { }, ν RHS { } RHS (Right Hand Side) défini sur Syn Inh {π, π 1,..., π k } : a Syn : a(π i ) RHS (l attribut a du i-ème fils) b Inh : b(π) RHS (l attribut b du père) σ : σ(ν 1,..., ν k ) RHS avec ν i RHS
Attributed Tree Transducer ATT : exemple Passage notation infixe vers suffixe Syn = a S, Inh = a I Grammaire ATT S T S.a S = T.a S a S (π) a S (π 1 ) T.a I = ε a I (π 1 ) end T 1 T.a S = 1(T.a I ) a S (π) 1(a I (π)) T T 1 + T 2 T.a S = T 1.a S a S (π) a S (π 1 ) 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 (π)) 1 + +
Attributed Tree Transducer ATT : Conclusion Attributed Tree Transducer basé sur les attributed grammars : grammaires CFG avec propriété sur les non-terminaux. l arbre de sortie est un attribut particulier (parmi d autres). Note ATT top-down : sans attributs hérités. ATT top-down ATT n-att (n+1)-att Apprentissage : improbable
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écapitulatif 2 Apprentissage de transducteurs Principes Généraux
MSO Tree transducers MSO dans les arbres formules atomiques : label σ (x) edge(x, y) x X leaf (x) root(x) MSO1 formules MSO avec une variable libre définit des propriétés sur les noeuds utile pour les requêtes unaires Exemple : Φ(x) = {lab f (x) x, edge(y, x), leaf (x)} Les noeuds étiquetés f dont l un des fils est une feuille. MSO2 Deux variables libres Φ(x, y) : définit des relations entre deux noeuds
MSO Tree transducers MSO Graph Transducers Définit une fonction partielle τ M : g = (E, V ) h = (E, V ) Definition (Courcelle 94) M = Copy, Φ, Ψ n, Ψ a avec : Copy : l ensemble de copie Φ : formule MSO1 sur Σ (le domaine) Ψ n c,σ : formule MSO1 (formule des noeuds) dépendante de c Copy et σ Ψ a c,c : formule MSO2 (formule des arcs) dépendante de c, c Copy
MSO Tree transducers MSO Graph Transducers Définit une fonction partielle τ M : g = (E, V ) h = (E, V ) défini si g Φ E = {(c, u) c Copy, u V, ψc,σ(u)} n V = {((c, u), (c, u )) c, c Copy, u V, ψc,c a (u, u )} Idées Φ est le domaine de la fonction Copy détermine le type des noeuds de h ψ n c,σ définit quels sont les noeuds de g copiés de type c et relabellés par σ ψ a c,c définit quels sont les relations entre noeuds de h nécessaires pour créer une arête dans h
MSO Tree transducers MSO Tree Transducers MSO Tree Transducer MSO Tree Transducer = MSO Graph Transducer sur les arbres (en entrées/sortie)
MSO Tree transducers MSO-Tree Transducer : Exemple HTML RACINE BODY ID ID Id TABLE... TEXTE TEXTE... TR TR TR TD TD TEXTE TEXTE Copy = {racine, id, nom, prenom}
MSO Tree transducers MSO-Tree Transducer : Exemple HTML BODY TABLE TR TR TR TD TEXTE TD TEXTE ID... RACINE 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) (x) = (fils d un TD second fils d un TR) Ψ n prenom,texte
MSO Tree transducers MSO-Tree Transducer : Exemple HTML BODY TABLE TR TR TR TD TEXTE TD TEXTE ID... RACINE ID TEXTE TEXTE Id... Ψ a racine,id Ψ a id,nom Ψ a id,prenom (x, y) = (true) (x, y) = x est le petit-fils de y (x, y) = x est le petit-fils de y
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écapitulatif 2 Apprentissage de transducteurs Principes Généraux
Transductions rationnelles Automate d Arbres : Notations M = Q, Σ, F, δ Q : ensemble fini d états Σ : alphabet ranked (d entrée) F : ensemble des états finaux (ou initiaux) δ : règles de la forme a q(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
Transductions rationnelles Relabeling Tree Transducers Transducteurs qui changent l étiquetage de l arbre de Σ vers. Équivalent aux transducteurs shape-preserving [Fulop & Gazdag 03 / Gazdag 04] Formes des règles a q(b) f (q 1 (x 1 ),..., q n (x n )) q(g(x 1,..., x k )) (souvent noté (f (q 1,..., q n )) q(g)) Node Selecting Tree Transducers : Relabeling fonctionnels avec Bool comme alphabet de sortie. Permettent de représenter les requêtes monadiques régulières (MSO, etc...)
Transductions rationnelles Relabeling : Exemple a q 1 (1) a q 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 a f a = 0 1 0 0 0 1 1
Transductions rationnelles Relabeling : Conclusion Avantages Permettent de représenter les requêtes monadiques régulières (via les NSTT) Apprenables [ICGI 04] Limitations Aucun changement de structure!
Transductions rationnelles Transducteurs d arbres à TATA Formes des règles a q(u) f (q 1 (x 1 ),..., q n (x n )) q(u) (noté (f (q 1,..., q n )) q(u)) avec u T X Peuvent être déterministes top-down ou bottom-up (en fonction de l automate d arbres support)
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... a D sin y Calcul de la dérivée d une fonction Alphabet : 0, 1, a, y, +,, sin, cos États : D (dérive), I (identité)
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... a cos I a y D y Calcul de la dérivée d une fonction Alphabet : 0, 1, a, y, +,, sin, cos États : D (dérive), I (identité)
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... a cos y D a I y + I a D y Calcul de la dérivée d une fonction Alphabet : 0, 1, a, y, +,, sin, cos États : D (dérive), I (identité)
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... a cos y 0 y + a 1 Calcul de la dérivée d une fonction Alphabet : 0, 1, a, y, +,, sin, cos États : D (dérive), I (identité)
Transductions rationnelles Tree Transducers : Conclusion avantages changements de structure possible non-linearité (copie), effacement de branches, permutation,... Inconvénients reste limité : difficile de remonter des branches
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 étiquetés par les états du run 3 le nouvel arbre est transformé par un transducteur descendant Le processus peut alors être déterministe
Transductions rationnelles Variante : avec algèbre de substitution l algèbre YIELD (ou SUBST) n symboles spéciaux α i Un symbole de substitution SUBST les α i sont substituées par les arguments de SUBST SUBST f b c YIELD f a c b a α 2 α 1 Transduction vers les trees avec SUBST puis YIELD : possibilité de déplacer des branches
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écapitulatif 2 Apprentissage de transducteurs Principes Généraux
Macro Tree Transducers Macro Tree Transducers : Principes Même idée général qu un transducteur d arbres mais, utilisation de paramètres ( accumulateurs ) : bouts d arbres collectés lors du run dans une règle : possibilité de stocker un bout d arbre (passer en paramètre) possibilité d utiliser les arbres stockés dans les arbres de sortie Grosso-Modo la même chose qu un transducteur avec algèbre de YIELD
Macro Tree Transducers Macro Tree Transducers : Definition M = Q, Σ,, I, δ Formes des règles 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 q Q, x i X, t j ξ copie de sous arbre d entrée, + accumulation y i ξ, pour tout y i Y copie de paramètre Attention : vision top-down Note : MTT sans paramètre = transducteur d arbre top-down
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 q 0 + 1 1 1 1
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 q q 0 1 + q 0 1
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 q + + 1 1 q 1 + 1 1
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
Macro Tree Transducers MTT with regular look-ahead MTT R M = Q, P, Σ,, I, δ,h Q, Σ,, I, δ, est un MTT particulier P, Σ, h est un automate d arbre (l automate look-ahead de M) Fonctionnement On fait un run avec le look-ahead automaton (les noeuds sont étiquetés par les états de P) Les règles du MTT dépendent des états des fils de l états courants. Règles de la forme : q, σ(p 1 (x 1 ),..., p n (x n )) ξ Note : MTT R = MTT (Engelfriet Vogler, 85)
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écapitulatif 2 Apprentissage de transducteurs Principes Généraux
Tree Walking et Pebble Tr. Tr. Tree Walking Transducer (1) Principes : Basé sur la notion de Tree Walking Automaton les règles impliquent un mouvement dans l arbre d entrée (up / down / stay ) (idem Tree Walking Automata) les règles produisent des bouts d arbres dans lesquelles il peut y avoir des branchements multiples (branching)
Tree Walking et Pebble Tr. Tr. Tree Walking Transducer (2) M = Q, Σ,, I, R Règles de la forme q, f ξ avec ξ : q, stay q, up (sauf si racine) q, down i (i : numéro du fils) σ( q 1, stay,..., q k, stay ) (relabeling + branching)
Tree Walking et Pebble Tr. Tr. TWT : exemple Exemple : explosion en largeur M = Q = {q}, Σ = {a 1, e 0 }, = {σ 2, e 0 }, I = {q}, R} avec R : q, a σ( q, down 1, q, down 1 ) q, e e a σ a a e
Tree Walking et Pebble Tr. Tr. TWT : exemple Exemple : explosion en largeur M = Q = {q}, Σ = {a 1, e 0 }, = {σ 2, e 0 }, I = {q}, R} avec R : q, a σ( q, down 1, q, down 1 ) q, e e a σ a σ σ a e
Tree Walking et Pebble Tr. Tr. TWT : exemple Exemple : explosion en largeur M = Q = {q}, Σ = {a 1, e 0 }, = {σ 2, e 0 }, I = {q}, R} avec R : q, a σ( q, down 1, q, down 1 ) q, e e a σ a σ σ a σ σ σ a e
Tree Walking et Pebble Tr. Tr. TWT : exemple Exemple : explosion en largeur M = Q = {q}, Σ = {a 1, e 0 }, = {σ 2, e 0 }, I = {q}, R} avec R : q, a σ( q, down 1, q, down 1 ) q, e e a a a σ σ a σ σ σ σ e e e e e e e e e
Tree Walking et Pebble Tr. Tr. Pebble Tree Transducer (1) Pebble = caillou Pebble Tree Transducer à n cailloux : n ptt Principe : on a n cailloux différents qui peuvent être déposés sur les noeuds (un de chaque type par noeud au max.) un vecteur de booléen sur chaque noeud les règles peuvent dépendre de la présence de cailloux les règles impliquent un mouvement dans l arbre d entrée (up / down / stay ) (idem Tree Walking Automata) les règles peuvent déposer (drop ) ou retirer (lift ) des cailloux
Tree Walking et Pebble Tr. Tr. Pebble Tree Transducer (2) M = Q, Σ,, I, R Règles de la forme q, f, b ξ avec b vecteur de cailloux (b {0, 1} n ) et ξ : σ( q 1, stay,..., q k, stay ) (relabeling + branching) q, stay q, up (sauf si racine) q, down i (i : numéro du fils) q, lift l (l : type de caillou) q, drop l (l : type de caillou, si présent)
Tree Walking et Pebble Tr. Tr. Pebble Tree Transducer (3) M = Q, Σ,, I, R Forme généralisée (Engelfriet & Maneth) q, f, b ξ avec b vecteur de cailloux (b {0, 1} n ), ξ T (Q {stay, up, down i, lift, drop })
Tree Walking et Pebble Tr. Tr. PTT : exemple
Tree Walking et Pebble Tr. Tr. Pebble Tree Transducer Notes 0-PTT : appelés 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énients Apprentissage : Improbable (lien entre arbre d entrée et de sortie peu clair)
Récapitulatif 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écapitulatif 2 Apprentissage de transducteurs Principes Généraux
Récapitulatif Récapitulatif Compilation Automates d arbres Tree Walking MSO SD Transducers Transducteurs d arbres attribués Relabeling Transductions rationnelles Macro Tree Transducers Tree Walking Transducers Pebble Tree Transducers MSO Tree Transducers
Récapitulatif Récapitulatif : Expressivité Expressivité des différents modèles RTT SDT TT MTTsur R MSO TT ATTsur R ATT MTT = MTT R 0 PTT = TWT MTT n+1 n PTT = 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
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écapitulatif 2 Apprentissage de transducteurs Principes Généraux
Principes Généraux 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écapitulatif 2 Apprentissage de transducteurs Principes Généraux
Principes Généraux Idées les langages d arbres réguliers sont apprenables par RPNI par exemples positifs et négatifs. on se ramène donc à des langages d arbres. Utilisation de la fonctionnalité. Utilisation d exemples enrichis.
Principes Généraux Correspondance des noeuds : Principe HTML BODY TABLE TR TD TD = RACINE ID Jean Dupont Jean Dupont
Principes Généraux Correspondance des noeuds : Principe HTML BODY TABLE TR TD TD = RACINE ID TEXTE TEXTE TEXTE TEXTE Réduction du vocabulaire
Principes Généraux Correspondance des noeuds : Principe HTML BODY TABLE TR TD TD = RACINE ID TEXTE TEXTE TEXTE TEXTE Correspondance des noeuds
Principes Généraux Correspondance des noeuds : Principe HTML BODY RACINE TABLE TR = ID TD TD TEXTE Jean TEXTE Dupo TEXTE Jean TEXTE Dupont Correspondance des noeuds
Principes Généraux Correspondance des noeuds : Principe HTML BODY RACINE TABLE TR = ID TD TD TEXTE Jean TEXTE Dupo TEXTE Jean TEXTE Dupont Correspondance des noeuds
Principes Généraux Correspondance des noeuds : Principe Idées générales Tous les formalismes de transductions présentés ici peuvent générer une fonction de correspondance de noeuds. On peut obtenir facilement cette fonction sur les exemples (au moins en transformation de document).
Principes Généraux Correspondance des noeuds : Entrées/Sorties f h g c c h h a b a c
Principes Généraux Correspondance des noeuds : Entrées/Sorties f h f /h(x 2, x 1, h(x 2 )) g c c h h g/h(x 1 ) c/c a b a c a/a b/ε Transformation en langage d arbres
Principes Généraux Passage des transductions aux langages d arbres Notes : Règle d un transducteur d arbres : q(f (x 1, x 2 )) h(q 1 (x 2 ), q 2 (x 1 ), h(q 1 (x 2 ))) Règle correspondante dans l automate d arbres : q(f /h(x 2, x 1, h(x 2 ))(x 1, x 2 )) (f /h(x 2, h(x 1 ), x 2 ) )(q 2 (x 1 ), q 1 (x 2 )) Alphabet apparemment infini (Σ T X ), en réalité fini (limité à ce qui apparaît dans le transducteur cible) Restriction : même état lors des copies
Principes Généraux Apprentissage Exemple enrichi Exemple du langage d arbre Inférence Langage d arbres Transducteur d arbres
Principes Généraux Avec des exemples moins enrichis? f h a g b c c h h a c La fonction de correspondance n est connue que pour les feuilles (et la racine) 1 Complétion par défaut (le plus bas possible) 2 Lors d une fusion, possibilité de relever la fonction de correspondance
Principes Généraux Étendre l expressivité a f f b f c d a f f d f c b
Principes Généraux Étendre l expressivité a f f b f c d a f f d f c b Avec YIELD SUBST f a α 1 α 2 f f b c d
Principes Généraux Étendre l expressivité f f f d f b f c f c a b a d Avec MTT d et c sont stockés dans les paramètres ils sont utilisés lors du passage à b (A préciser...)
Classes apprenables à partir d exemples enrichis Affirmations gratuites Classe Apprenable? RTT OUI (copy-safe) TT OUI (très probablement) (copy-safe) MTT J y crois SDT OUI (sans doute?) ATT NON (sans doute) (copy-safe) MSO-TT Possible??
Bibliographie très succinte TATA 1997 Models of tree translations, S. Maneth, PhD thesis A Comparaison of Pebble Tree Transducers with Macro Tree Transducers, J. englefriet and S. Maneth, 2002 characterization of Properties and Relations defined in Monadic Second Order Logic on the nodes of Trees, R. Bloem and J. Engelfriet, 1997 Attribute Grammars and Monadic Second Order Logic, R. Bloem, 1996 Syntax-Directed Semantics - Formal Models based on Tree Transducers (Fülop/Vogler) Macro Tree Transducers in TREEBAG, K. Azab, 2005