Compositions of Tree Series Transformations Andreas Maletti a Technische Universität Dresden Fakultät Informatik D 01062 Dresden, Germany maletti@tcs.inf.tu-dresden.de December 03, 2004 1. Motivation 2. Semirings, Tree Series, and Tree Series Substitution 3. Distributivity, Associativity, and Linearity 4. Tree Series Transducers and Composition Results a Financially supported by the German Research Foundation (DFG, GK 334) 1 December 03, 2004
Motivation Tree series transducers are a straightforward generalization of (i) tree transducers, which are applied in syntax-directed semantics, functional programming, and XML querying, (ii) weighted automata, which are applied in (tree) pattern matching, image compression and speech-to-text processing. Applications: can be used for code selection [Borchardt 04] potential uses in connection with tree banks Motivation 2 December 03, 2004
Generalization Hierarchy tree series transducer τ : T Σ A T weighted tree automaton L A T Σ weighted transducer τ : Σ A tree transducer τ : T Σ B T weighted automaton L A Σ tree automaton L B T Σ generalized sequential machine τ : Σ B string automaton L B Σ Motivation 3 December 03, 2004
Trees Σ ranked alphabet, Σ k Σ symbols of rank k, X = { x i i N + } T Σ (X) set of Σ-trees indexed by X, T Σ = T Σ ( ), t T Σ (X) is linear (resp., nondeleting) in Y X, if every y Y occurs at most (resp., at least) once in t, t[t 1,..., t k ] denotes the tree substitution of t i for x i in t Semirings, Tree Series, and Tree Series Substitution 4 December 03, 2004
Semirings A semiring is an algebraic structure A = (A,, ) (A, ) is a commutative monoid with neutral element 0, (A, ) is a monoid with neutral element 1, 0 is absorbing wrt., and distributes over. Examples: semiring of non-negative integers N = (N { }, +, ) Boolean semiring B = ({0, 1},, ) tropical semiring T = (N { }, min, +) any ring, field, etc. Semirings, Tree Series, and Tree Series Substitution 5 December 03, 2004
Properties of Semirings We say that A is commutative, if is commutative, idempotent, if a a = a, complete, if there is an operation I : AI A such that 1. i I a i = a i1 a in, if I = {i 1,..., i n }, and 2. i I a i = j J i I j a i, if I = j J I j is a partition of I, and 3. i I (a a i) = a i I a i and i I (a i a) = ( i I a i) a, completely idempotent, if it is complete with i I a = a for every non-empty I. Semiring Commutative Idempotent Complete Completely Idempotent N YES no YES no B YES YES YES YES T YES YES YES YES Semirings, Tree Series, and Tree Series Substitution 6 December 03, 2004
Tree Series A = (A,, ) semiring, Σ ranked alphabet Mappings ϕ : T Σ (X) A are also called tree series the set of all tree series is A T Σ (X), the coefficient of t T Σ (X) in ϕ, i.e., ϕ(t), is denoted by (ϕ, t), the sum is defined pointwise (ϕ 1 ϕ 2, t) = (ϕ 1, t) (ϕ 2, t), the support of ϕ is supp(ϕ) = { t T Σ (X) (ϕ, t) 0 }, ϕ is linear (resp., nondeleting in Y X), if supp(ϕ) is a set of trees, which are linear (resp., nondeleting in Y), the series ϕ with supp(ϕ) = is denoted by 0. Example: ϕ = 1 α + 1 β + 3 σ(α, α) +... + 3 σ(β, β) + 5 σ(α, σ(α, α)) +... Semirings, Tree Series, and Tree Series Substitution 7 December 03, 2004
Tree Series Substitution A = (A,, ) complete semiring, ϕ, ψ 1,..., ψ k A T Σ (X) Pure substitution of (ψ 1,..., ψ k ) into ϕ: ϕ (ψ 1,..., ψ k ) = (ϕ, t) (ψ 1, t 1 ) (ψ k, t k ) t[t 1,..., t k ] t supp(ϕ), ( i [k]): t i supp(ψ i ) o-substitution of (ψ 1,..., ψ k ) into ϕ: ϕ (ψ o 1,..., ψ k ) = t supp(ϕ), ( i [k]): t i supp(ψ i ) (ϕ, t) (ψ 1, t 1 ) t x 1 (ψk, t k ) t x k t[t1,..., t k ] Example: 5 σ(x 1, x 1 ) (2 α) = 10 σ(α, α) and 5 σ(x 1, x 1 ) o (2 α) = 20 σ(α, α) Semirings, Tree Series, and Tree Series Substitution 8 December 03, 2004
Distributivity ( ) ϕ i i I m ( i 1 I 1 ψ 1i1,..., i k I k ψ kik ) = ϕ i i I, ( j [k]): i j I j m (ψ 1i1,..., ψ kik ) Substitution Sufficient condition for distributivity pure substitution always o-substitution ϕ i linear, A completely idempotent OI-substitution ϕ i linear and nondeleting [Kuich 99] Distributivity, Associativity, and Linearity 9 December 03, 2004
( ϕ (ψ m 1,..., ψ k ) ) m Associativity m m (τ 1,..., τ n ) = ϕ (ψ 1 (τ 1,..., τ n ),..., ψ k (τ 1,..., τ n )) m Substitution Sufficient condition for associativity pure substitution A completely idempotent, conforming partition ( I j ) j [k] of [n], τ i boolean τ i singletons with idempotent coefficients special associativity law o-substitution ϕ, ψ 1,..., ψ k linear, A zero-divisor free and completely idempotent ϕ linear, A zero-divisor free, τ i singletons OI-substitution ϕ i linear and nondeleting [Kuich 99] Special associativity law: partition ( I j ) j J of I with var(ψ j ) X Ij for every j J ( ) ϕ ( ψj ) j J ( τi ) i I = ϕ ( ) ψ j ( τ i ) i Ij j J Distributivity, Associativity, and Linearity 10 December 03, 2004
Linearity (a ϕ) m (a 1 ψ 1,..., a k ψ k ) = a a 1 a k ϕ m (ψ 1,..., ψ k ) Substitution Sufficient condition for distributivity pure substitution always o-substitution a i {0, 1} or special linearity law OI-substitution ϕ i linear and nondeleting [Kuich 99] Special linearity law: tree t T Σ (X k ) (a t) o (a 1 ψ 1,..., a k ψ k ) = a a t 1 1 a t k k ( ) o t (ψ 1,..., ψ k ) Distributivity, Associativity, and Linearity 11 December 03, 2004
Tree Series Transducers Definition: A (bottom-up) tree series transducer (tst) is a system M = (Q, Σ,, A, F, µ) Q is a non-empty set of states, Σ and are input and output ranked alphabets, A = (A,, ) is a complete semiring, F A T (X 1 ) Q is a vector of final outputs, µ = ( µ k ) k N with µ k : Σ k A T (X k ) Q Qk. If Q is finite and µ k (σ) q, q is polynomial, then M is called finite. Tree Series Transducers and Composition Results 12 December 03, 2004
Semantics of Tree Series Transducers m {ε, o}, q Q, t T Σ, ϕ A T Σ Definition: The mapping h m µ : T Σ A T Q is defined as h m m µ (σ(t 1,..., t k )) q = µ k (σ) q,(q1,...,q k ) (h m µ (t 1 ) q1,..., h m µ (t k ) qk ) q 1,...,q k Q and h m µ (ϕ) q = t T Σ (ϕ, t) h m µ (t) q. the m-tree-to-tree-series transformation M m : T Σ A T computed by M is ( M m, t) = q Q F m q (h m µ (t) q ) and the m-tree-series-to-tree-series transformation M m : A T Σ A T computed by M is ( M m, ϕ) = t T Σ (ϕ, t) ( M m, t). Tree Series Transducers and Composition Results 13 December 03, 2004
Extension (Q, Σ,, A, F, µ) tree series transducer, m {ε, o}, q Q k, q Q, ϕ A T Σ (X k ) Definition: We define hµ,m q : T Σ (X k ) A T (X k ) Q hµ,m(x q 1 x i, if q = q i i ) q = 0, otherwise hµ,m(σ(t q m 1,..., t k )) q = µ k (σ) q,p1...p k (hµ,m(t q 1 ) p1,..., hµ,m(t q k ) pk ) p 1,...,p k Q We define hµ,m q : A T Σ (X k ) A T (X k ) Q by hµ,m(ϕ) q q = (ϕ, t) hµ,m(t) q q t T Σ (X I ) Tree Series Transducers and Composition Results 14 December 03, 2004
Composition Construction M 1 = (Q 1, Σ,, A, F 1, µ 1 ) and M 2 = (Q 2,, Γ, A, F 2, µ 2 ) tree series transducer Definition: The m-product of M 1 and M 2, denoted by M 1 m M 2, is the tree series transducer M = (Q 1 Q 2, Σ, Γ, A, F, µ) F pq = i Q 2 (F 2 ) i m h q µ 2,m((F 1 ) p ) i µ k (σ) pq,(p1 q 1,...,p k q k ) = h q 1...q k µ 2,m ((µ 1 ) k (σ) p,p1...p k ) q. Tree Series Transducers and Composition Results 15 December 03, 2004
Main Theorem A commutative and complete semiring, M 1 and M 2 tree series transducer Theorem: M 1 m M 2 m = M 1 m M 2 m, if m = ε and M 1 linear, or m = ε and M 2 boolean and deterministic, or m = ε and M 2 is deterministic and A is multiplicatively idempotent, or m = o and M 1 is linear, M 2 is nondeleting and linear, and A is completely idempotent. Tree Series Transducers and Composition Results 16 December 03, 2004
Main Corollary Corollary: l-bot ts-ts (A) BOT ts-ts (A) = BOT ts-ts (A). BOT ts-ts (A) db-bot ts-ts (A) = BOT ts-ts (A), BOT ts-ts (A) d-bot ts-ts (A) = BOT ts-ts (A), provided that A is multiplicatively idempotent, l-bot o ts-ts(a) nl-bot o ts-ts(a) = l-bot o ts-ts(a), provided that A is completely idempotent. Tree Series Transducers and Composition Results 17 December 03, 2004
References [Borchardt 04] B. Borchardt: Code Selection by Tree Series Transducers. CIAA 04, Kingston, Canada, 2004. to appear [Engelfriet et al 02] J. Engelfriet, Z. Fülöp, and H. Vogler: Bottom-up and Topdown Tree Series Transformations. Journal of Automata, Languages, and Combinatorics 7:11 70, 2002 [Fülöp et al 03] Z. Fülöp and H. Vogler: Tree Series Transformations that Respect Copying. Theory of Computing Systems 36:247 293, 2003 [Kuich 99] W. Kuich: Tree Transducers and Formal Tree Series. Acta Cybernetica 14:135 149, 1999 Tree Series Transducers and Composition Results 18 December 03, 2004