Tree Transducers Niko Paltzer Seminar Formal Grammars WS 06/07 - - PowerPoint PPT Presentation

tree transducers
SMART_READER_LITE
LIVE PREVIEW

Tree Transducers Niko Paltzer Seminar Formal Grammars WS 06/07 - - PowerPoint PPT Presentation

0/16 Tree Transducers Niko Paltzer Seminar Formal Grammars WS 06/07 Advisor: Marco Kuhlmann Programming Systems Lab Back Close Outline 1/16 Trees & Tree Transducers Derivations & State-sequences Copying


slide-1
SLIDE 1

0/16

◭◭ ◮◮ ◭ ◮

Back Close

Tree Transducers

Niko Paltzer

Seminar Formal Grammars WS 06/07 Advisor: Marco Kuhlmann Programming Systems Lab

slide-2
SLIDE 2

1/16

◭◭ ◮◮ ◭ ◮

Back Close

Outline

Trees & Tree Transducers Derivations & State-sequences Copying Normal Form Intercalation Lemma

slide-3
SLIDE 3

2/16

◭◭ ◮◮ ◭ ◮

Back Close

Trees

Definition Trees are defined over a ranked alphabet Σ. t ∈ TΣ if t ∈ Σ0 t = σ(t1 . . . tn) σ ∈ Σn, ti ∈ TΣ

slide-4
SLIDE 4

2/16

◭◭ ◮◮ ◭ ◮

Back Close

Trees

Definition Trees are defined over a ranked alphabet Σ. t ∈ TΣ if t ∈ Σ0 t = σ(t1 . . . tn) σ ∈ Σn, ti ∈ TΣ Example Σ2 = {σ} Σ1 = {τ} Σ0 = {δ} Σ = Σ2 ∪ Σ1 ∪ Σ0

slide-5
SLIDE 5

2/16

◭◭ ◮◮ ◭ ◮

Back Close

Trees

Definition Trees are defined over a ranked alphabet Σ. t ∈ TΣ if t ∈ Σ0 t = σ(t1 . . . tn) σ ∈ Σn, ti ∈ TΣ Example Σ2 = {σ} Σ1 = {τ} Σ0 = {δ} Σ = Σ2 ∪ Σ1 ∪ Σ0 σ σ τ τ δ τ δ δ

slide-6
SLIDE 6

3/16

◭◭ ◮◮ ◭ ◮

Back Close

Tree Transducers

Definition M = (Q, Σ, ∆, q0, R) Q finite set of states Σ ranked input alphabet ∆ ranked output alphabet q0 ∈ Q initial state R finite set of rules

slide-7
SLIDE 7

3/16

◭◭ ◮◮ ◭ ◮

Back Close

Tree Transducers

Definition M = (Q, Σ, ∆, q0, R) Q finite set of states Σ ranked input alphabet ∆ ranked output alphabet q0 ∈ Q initial state R finite set of rules Rule Format q(σ(x1 . . . xn)) → τ(q1(xi1) . . . qk(xik)) xj variables σ ∈ Σn τ ∈ ∆k q, q1, . . . , qk ∈ Q

slide-8
SLIDE 8

3/16

◭◭ ◮◮ ◭ ◮

Back Close

Tree Transducers

Definition M = (Q, Σ, ∆, q0, R) Q finite set of states Σ ranked input alphabet ∆ ranked output alphabet q0 ∈ Q initial state R finite set of rules Rule Format q(σ(x1 . . . xn)) → τ(q1(xi1) . . . qk(xik)) xj variables σ ∈ Σn τ ∈ ∆k q, q1, . . . , qk ∈ Q M deterministic ⇔ left-hand sides are disjoint

slide-9
SLIDE 9

4/16

◭◭ ◮◮ ◭ ◮

Back Close

Example

Tree Transducer M = ({q}, {σ, τ, δ}, {β, γ}, q, R) q(σ(xy)) → β(q(x)q(y)) q(τ(x)) → β(q(x)q(x)) q(δ) → γ

slide-10
SLIDE 10

4/16

◭◭ ◮◮ ◭ ◮

Back Close

Example

Tree Transducer M = ({q}, {σ, τ, δ}, {β, γ}, q, R) q(σ(xy)) → β(q(x)q(y)) q(τ(x)) → β(q(x)q(x)) q(δ) → γ Input Tree

σ σ τ τ δ τ δ δ

slide-11
SLIDE 11

5/16

◭◭ ◮◮ ◭ ◮

Back Close

Example - Derivation

q(σ(xy)) → β(q(x)q(y)) q(τ(x)) → β(q(x)q(x)) q(δ) → γ q σ σ τ τ δ τ δ δ

slide-12
SLIDE 12

5/16

◭◭ ◮◮ ◭ ◮

Back Close

Example - Derivation

q(σ(xy)) → β(q(x)q(y)) q(τ(x)) → β(q(x)q(x)) q(δ) → γ q q β σ τ τ δ τ δ δ

slide-13
SLIDE 13

5/16

◭◭ ◮◮ ◭ ◮

Back Close

Example - Derivation

q(σ(xy)) → β(q(x)q(y)) q(τ(x)) → β(q(x)q(x)) q(δ) → γ q q q β β τ τ δ τ δ δ

slide-14
SLIDE 14

5/16

◭◭ ◮◮ ◭ ◮

Back Close

Example - Derivation

q(σ(xy)) → β(q(x)q(y)) q(τ(x)) → β(q(x)q(x)) q(δ) → γ q q β β τ τ γ τ δ δ

slide-15
SLIDE 15

5/16

◭◭ ◮◮ ◭ ◮

Back Close

Example - Derivation

q(σ(xy)) → β(q(x)q(y)) q(τ(x)) → β(q(x)q(x)) q(δ) → γ q q q β β τ β γ τ δ δ δ

slide-16
SLIDE 16

5/16

◭◭ ◮◮ ◭ ◮

Back Close

Example - Derivation

q(σ(xy)) → β(q(x)q(y)) q(τ(x)) → β(q(x)q(x)) q(δ) → γ q q β β τ β γ τ γ δ δ

slide-17
SLIDE 17

5/16

◭◭ ◮◮ ◭ ◮

Back Close

Example - Derivation

q(σ(xy)) → β(q(x)q(y)) q(τ(x)) → β(q(x)q(x)) q(δ) → γ β β β β γ β γ γ γ β γ γ γ

slide-18
SLIDE 18

6/16

◭◭ ◮◮ ◭ ◮

Back Close

State-sequence

σ σ τ τ δ τ δ δ β β β β γ β γ γ γ β γ γ γ

slide-19
SLIDE 19

6/16

◭◭ ◮◮ ◭ ◮

Back Close

State-sequence

σ1 σ2 τ2 τ1 δ2 τ3 δ1 δ3 β β β β γ β γ γ γ β γ γ γ

slide-20
SLIDE 20

6/16

◭◭ ◮◮ ◭ ◮

Back Close

State-sequence

σ1 σ2 τ2 τ1 δ2 τ3 δ1 δ3 q σ1 q σ2 q τ2 q τ1 q δ2 q τ3 q δ1 q δ3 q δ1 q τ3 q δ3 q δ3 q δ3

slide-21
SLIDE 21

6/16

◭◭ ◮◮ ◭ ◮

Back Close

State-sequence

σ1 σ2 τ2 τ1 δ2 τ3 〈q,q〉 δ1 δ3 q σ1 q σ2 q τ2 q τ1 q δ2 q τ3 q δ1 q δ3 q δ1 q τ3 q δ3 q δ3 q δ3

slide-22
SLIDE 22

6/16

◭◭ ◮◮ ◭ ◮

Back Close

State-sequence

σ1 〈q〉 σ2 〈q〉 τ2 〈q〉 τ1 〈q〉 δ2 〈q〉 τ3 〈q,q〉 δ1 〈q,q〉 δ3 〈q,q,q,q〉 q σ1 q σ2 q τ2 q τ1 q δ2 q τ3 q δ1 q δ3 q δ1 q τ3 q δ3 q δ3 q δ3

slide-23
SLIDE 23

7/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying

Copying-bound A derivation has copying-bound k if all state-sequences have at most length k. A transducer M has copying-bound k if for all possible output trees there exists a derivation with copying-bound k.

slide-24
SLIDE 24

7/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying

Copying-bound A derivation has copying-bound k if all state-sequences have at most length k. A transducer M has copying-bound k if for all possible output trees there exists a derivation with copying-bound k. Finite Copying A transducer M is finite copying if it has some copying-bound k ∈ N. DTfc(k) is the class of deterministic tree transducers with copying-bound k.

slide-25
SLIDE 25

8/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying-bound

Dynamic The definition of the copying-bound is based on dynamic properties.

slide-26
SLIDE 26

8/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying-bound

Dynamic The definition of the copying-bound is based on dynamic properties. Static There exists a possibility to check the copying-bound statically.

slide-27
SLIDE 27

9/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying Normal Form

Idea If each state-sequence consists of different states, the number

  • f states is an upper copying-bound.

This is only possible if the transducer is finite copying.

slide-28
SLIDE 28

9/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying Normal Form

Idea If each state-sequence consists of different states, the number

  • f states is an upper copying-bound.

This is only possible if the transducer is finite copying. Algorithm (found in [vV96])

  • 1. encode state-sequences into new states
  • 2. copy transducer rules for additionally introduced states
  • 3. repeat till fixpoint is reached
slide-29
SLIDE 29

10/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying Normal Form - Example

q(τ(x)) → β(r(x)s(x)) q(δ) → γ r(τ(x)) → β(s(x)s(x)) r(δ) → γ s(τ(x)) → α(s(x)) s(δ) → γ

slide-30
SLIDE 30

10/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying Normal Form - Example

q(τ(x)) → β(r(x)s(x)) q(δ) → γ r(τ(x)) → β(s(x)s(x)) r(δ) → γ s(τ(x)) → α(s(x)) s(δ) → γ q(τ(x)) → β(rs(x)rs(x))

slide-31
SLIDE 31

10/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying Normal Form - Example

q(τ(x)) → β(r(x)s(x)) q(δ) → γ r(τ(x)) → β(s(x)s(x)) r(δ) → γ s(τ(x)) → α(s(x)) s(δ) → γ q(τ(x)) → β(rs(x)rs(x)) rs rs

slide-32
SLIDE 32

10/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying Normal Form - Example

q(τ(x)) → β(r(x)s(x)) q(δ) → γ r(τ(x)) → β(s(x)s(x)) r(δ) → γ s(τ(x)) → α(s(x)) s(δ) → γ q(τ(x)) → β(rs(x)rs(x)) q(δ) → γ rs rs

slide-33
SLIDE 33

10/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying Normal Form - Example

q(τ(x)) → β(r(x)s(x)) q(δ) → γ r(τ(x)) → β(s(x)s(x)) r(δ) → γ s(τ(x)) → α(s(x)) s(δ) → γ q(τ(x)) → β(rs(x)rs(x)) q(δ) → γ rs(τ(x)) → β(sss(x)sss(x)) rs

slide-34
SLIDE 34

10/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying Normal Form - Example

q(τ(x)) → β(r(x)s(x)) q(δ) → γ r(τ(x)) → β(s(x)s(x)) r(δ) → γ s(τ(x)) → α(s(x)) s(δ) → γ q(τ(x)) → β(rs(x)rs(x)) q(δ) → γ rs(τ(x)) → β(sss(x)sss(x)) rs sss sss

slide-35
SLIDE 35

10/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying Normal Form - Example

q(τ(x)) → β(r(x)s(x)) q(δ) → γ r(τ(x)) → β(s(x)s(x)) r(δ) → γ s(τ(x)) → α(s(x)) s(δ) → γ q(τ(x)) → β(rs(x)rs(x)) q(δ) → γ rs(τ(x)) → β(sss(x)sss(x)) rs(δ) → γ rs sss sss

slide-36
SLIDE 36

10/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying Normal Form - Example

q(τ(x)) → β(r(x)s(x)) q(δ) → γ r(τ(x)) → β(s(x)s(x)) r(δ) → γ s(τ(x)) → α(s(x)) s(δ) → γ q(τ(x)) → β(rs(x)rs(x)) q(δ) → γ rs(τ(x)) → β(sss(x)sss(x)) rs(δ) → γ rs(τ(x)) → α(sss(x)) sss sss

slide-37
SLIDE 37

10/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying Normal Form - Example

q(τ(x)) → β(r(x)s(x)) q(δ) → γ r(τ(x)) → β(s(x)s(x)) r(δ) → γ s(τ(x)) → α(s(x)) s(δ) → γ q(τ(x)) → β(rs(x)rs(x)) q(δ) → γ rs(τ(x)) → β(sss(x)sss(x)) rs(δ) → γ rs(τ(x)) → α(sss(x)) sss sss sss

slide-38
SLIDE 38

10/16

◭◭ ◮◮ ◭ ◮

Back Close

Copying Normal Form - Example

q(τ(x)) → β(r(x)s(x)) q(δ) → γ r(τ(x)) → β(s(x)s(x)) r(δ) → γ s(τ(x)) → α(s(x)) s(δ) → γ q(τ(x)) → β(rs(x)rs(x)) q(δ) → γ rs(τ(x)) → β(sss(x)sss(x)) rs(δ) → γ rs(τ(x)) → α(sss(x)) rs(δ) → γ sss(τ(x)) → α(sss(x)) sss(δ) → γ sss(τ(x)) → α(sss(x)) sss(δ) → γ sss(τ(x)) → α(sss(x)) sss(δ) → γ

slide-39
SLIDE 39

11/16

◭◭ ◮◮ ◭ ◮

Back Close

Yield Language

Definition Let M = (Q, Σ, ∆, q0, R) be a tree transducer. Then yL(M) = {yield(t′) | q0(t) ⇒∗ t′ for some t ∈ TΣ} is the yield language of M.

slide-40
SLIDE 40

11/16

◭◭ ◮◮ ◭ ◮

Back Close

Yield Language

Definition Let M = (Q, Σ, ∆, q0, R) be a tree transducer. Then yL(M) = {yield(t′) | q0(t) ⇒∗ t′ for some t ∈ TΣ} is the yield language of M. And yL(C) = {yL(M) | M ∈ C} is the set of yield languages for some class of tree transducers C.

slide-41
SLIDE 41

11/16

◭◭ ◮◮ ◭ ◮

Back Close

Yield Language

Definition Let M = (Q, Σ, ∆, q0, R) be a tree transducer. Then yL(M) = {yield(t′) | q0(t) ⇒∗ t′ for some t ∈ TΣ} is the yield language of M. And yL(C) = {yL(M) | M ∈ C} is the set of yield languages for some class of tree transducers C.

σ σ τ τ b τ a a

aba

slide-42
SLIDE 42

12/16

◭◭ ◮◮ ◭ ◮

Back Close

Language Hierarchy

Claim yL(DTfc(k−1)) yL(DTfc(k)) for k > 1

slide-43
SLIDE 43

12/16

◭◭ ◮◮ ◭ ◮

Back Close

Language Hierarchy

Claim yL(DTfc(k−1)) yL(DTfc(k)) for k > 1 Proof Let Lk = {an

1an 2 . . . an 2k | n ∈ N} for k > 1.

Show Lk ∈ yL(DTfc(k))\yL(DTfc(k−1)), i.e. show Lk ∈ yL(DTfc(k)) by construction and Lk / ∈ yL(DTfc(k−1)) with the intercalation lemma.

slide-44
SLIDE 44

13/16

◭◭ ◮◮ ◭ ◮

Back Close

Intercalation Lemma

This is a weak form of the intercalation lemma from [ERS80]: Let k > 0 be an integer. ∀L ∈ yL(DTfc(k)). ∃p. ∀z ∈ L with |z| ≥ p.

slide-45
SLIDE 45

13/16

◭◭ ◮◮ ◭ ◮

Back Close

Intercalation Lemma

This is a weak form of the intercalation lemma from [ERS80]: Let k > 0 be an integer. ∀L ∈ yL(DTfc(k)). ∃p. ∀z ∈ L with |z| ≥ p. ∃z1, . . . , zs and x1, . . . , xs+1 (1 ≤ s ≤ k) such that

  • 1. z = x1z1x2z2 . . . xszsxs+1
slide-46
SLIDE 46

13/16

◭◭ ◮◮ ◭ ◮

Back Close

Intercalation Lemma

This is a weak form of the intercalation lemma from [ERS80]: Let k > 0 be an integer. ∀L ∈ yL(DTfc(k)). ∃p. ∀z ∈ L with |z| ≥ p. ∃z1, . . . , zs and x1, . . . , xs+1 (1 ≤ s ≤ k) such that

  • 1. z = x1z1x2z2 . . . xszsxs+1
  • 2. 0 < |zi| ≤ p for 1 ≤ i ≤ s
slide-47
SLIDE 47

13/16

◭◭ ◮◮ ◭ ◮

Back Close

Intercalation Lemma

This is a weak form of the intercalation lemma from [ERS80]: Let k > 0 be an integer. ∀L ∈ yL(DTfc(k)). ∃p. ∀z ∈ L with |z| ≥ p. ∃z1, . . . , zs and x1, . . . , xs+1 (1 ≤ s ≤ k) such that

  • 1. z = x1z1x2z2 . . . xszsxs+1
  • 2. 0 < |zi| ≤ p for 1 ≤ i ≤ s
  • 3. ∀n ∈ N. ∃v1, . . . , vs such that

(a) v = x1v1x2v2 . . . xsvsxs+1 (b) v ∈ L (c) |v| ≥ n (d) alph(vi) = alph(zi) for 1 ≤ i ≤ s

slide-48
SLIDE 48

14/16

◭◭ ◮◮ ◭ ◮

Back Close

Intercalation Lemma - Application

Claim Let Lk = {an

1an 2 . . . an 2k | n ∈ N} for k > 1, then Lk /

∈ yL(DTfc(k−1)) Proof by Contradiction Assume Lk ∈ yL(DTfc(k−1)). Let z = ap

1ap 2 . . . ap 2k ∈ Lk.

Then z = x1z1x2z2 . . . xszsxs+1 with s ≤ k − 1 and 0 < |zi| ≤ p.

slide-49
SLIDE 49

14/16

◭◭ ◮◮ ◭ ◮

Back Close

Intercalation Lemma - Application

Claim Let Lk = {an

1an 2 . . . an 2k | n ∈ N} for k > 1, then Lk /

∈ yL(DTfc(k−1)) Proof by Contradiction Assume Lk ∈ yL(DTfc(k−1)). Let z = ap

1ap 2 . . . ap 2k ∈ Lk.

Then z = x1z1x2z2 . . . xszsxs+1 with s ≤ k − 1 and 0 < |zi| ≤ p. ⇒ At least 1 and at most 2k − 2 different ai occur in z1, . . . , zs.

slide-50
SLIDE 50

14/16

◭◭ ◮◮ ◭ ◮

Back Close

Intercalation Lemma - Application

Claim Let Lk = {an

1an 2 . . . an 2k | n ∈ N} for k > 1, then Lk /

∈ yL(DTfc(k−1)) Proof by Contradiction Assume Lk ∈ yL(DTfc(k−1)). Let z = ap

1ap 2 . . . ap 2k ∈ Lk.

Then z = x1z1x2z2 . . . xszsxs+1 with s ≤ k − 1 and 0 < |zi| ≤ p. ⇒ At least 1 and at most 2k − 2 different ai occur in z1, . . . , zs. ⇒ There is some aj that does not occur in any zi.

slide-51
SLIDE 51

14/16

◭◭ ◮◮ ◭ ◮

Back Close

Intercalation Lemma - Application

Claim Let Lk = {an

1an 2 . . . an 2k | n ∈ N} for k > 1, then Lk /

∈ yL(DTfc(k−1)) Proof by Contradiction Assume Lk ∈ yL(DTfc(k−1)). Let z = ap

1ap 2 . . . ap 2k ∈ Lk.

Then z = x1z1x2z2 . . . xszsxs+1 with s ≤ k − 1 and 0 < |zi| ≤ p. ⇒ At least 1 and at most 2k − 2 different ai occur in z1, . . . , zs. ⇒ There is some aj that does not occur in any zi. ⇒ When ”intercalating”, the number of aj remains p.

slide-52
SLIDE 52

15/16

◭◭ ◮◮ ◭ ◮

Back Close

Summary

Tree Transducers: Derivations & State-sequences Copying Normal Form: Introduction & Algorithm Intercalation Lemma: Introduction & Application

slide-53
SLIDE 53

16/16

◭◭ ◮◮ ◭ ◮

Back Close

References

[ERS80] Joost Engelfriet, Grzegorz Rozenberg, and Giora

  • Slutzki. Tree Transducers, L Systems, and Two-Way
  • Machines. Journal of Computer and

System Sciences 20, 1980. [Man04] Sebastian Maneth. Models of Tree Translation. IPA Dissertation Series, 2004. [Per75] C. Raymond Perrault. Intercalation theorems for tree transducer languages. STOC ’75: Proceedings of seventh annual ACM symposium on Theory of computing, 1975. [vV96] Nik´ e van Vugt. Generalized Context-Free Grammars. Master’s Thesis, Universiteit Leiden, 1996.

slide-54
SLIDE 54

16/16

◭◭ ◮◮ ◭ ◮

Back Close

Language Hierarchy - Proof

Claim Let Lk = {an

1an 2 . . . an 2k | n ∈ N} for k > 1, then Lk ∈ yL(DTfc(k)).

Proof by Construction M = ({q0, . . . , qk, r1, . . . , r2k}, {a, b, c, d}, {a, b, c, a1, . . . , a2k}, q0, R) and R containing the following rules for 1 ≤ i ≤ k: q0(a(x)) → a(q1(x) . . . qk(x)) qi(b(xyz)) → b(r2i−1(x)qi(y)r2i(z)) qi(c(xy)) → c(r2i−1(x)r2i(y)) ri(d) → ai