The Complexity of Tree Transducer Output Languages

45
www.kmonos.net The Complexity of Tree Transducer Output Languages ToPS 2009/02/20 Kazuhiro Inaba @ U-Tokyo Joint work with Sebastian Maneth @ NICTA&UNSW

description

The Complexity of Tree Transducer Output Languages. ToPS 2009/02/20 Kazuhiro Inaba @ U-Tokyo Joint work with Sebastian Maneth @ NICTA&UNSW. “Complexity of Output Languages”. Given … A tree language L ⊆ T Σ A (nondeterministic) tree-to-tree translation τ ⊆ T Σ ×T Δ - PowerPoint PPT Presentation

Transcript of The Complexity of Tree Transducer Output Languages

Page 1: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

The Complexity of Tree Transducer Output Languages

ToPS 2009/02/20

Kazuhiro Inaba @ U-TokyoJoint work with Sebastian Maneth @ NICTA&UNSW

Page 2: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

“Complexity of Output Languages”

Given… A tree language

L ⊆ TΣ A (nondeterministic) tree-to-tree translation

τ ⊆ TΣ×TΔ

How complex is the language τ(L) ⊆ TΔ ?

(i.e., for a tree t ∈ TΔ, how is it computationally hard to determine whether t ∈τ(L) or not ?)

Page 3: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

Classic Results τ: Program of the Turing-Machine

Undecidable

L : Regular String Language τ: Nondet. Finite State Transduction

τ(L) is regular! The membership of τ(L) is

solved in O(n) time, O(1) space

Corollary: for τ∈ Finitely Many Compositionsof Nondet-FST, τ(L) is regular

b/bb

a/aa/b/b

Page 4: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

4

Today’s Topic

Macro Tree Transducers? A very powerful translation model

containing most known classes of string/tree translations!

Yet still has many decidable properties

L : Regular Tree Languageτ: Composition of Nondeterministic

Macro Tree Transducers the membership problem ofτ(L) is

NP-complete and in DSPACE(n).

Page 5: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

OutlineWhat is/Why Macro Tree

Transducers?

Review on Previous WorkOutput Language of Deterministic MTTs

The Proof“Translation Membership” Problem“Garbage-Free Form”

Page 6: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

6

Brief Introduction toMacro Tree Transducers (MTTs)

Page 7: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

MTT

An MTT M = (Q, start, Σ, Δ, R) is a set of first-order functions of type Tree(Σ) × Tree(Δ)k Tree(Δ)

Defined by mutual induction on the1st parameter (the input tree) Application in the right-hand side is restricted only to the

direct children of the current node Can take output tree fragments via other parameters, but

not allowed to inspect or decompose them

start( A(x1) ) → double( x1, double(x1, E) )

double( A(x1), y1) → double( x1, double(x1, y1) )double( B, y1 ) → F( y1, y1 )double( B, y1 ) → G( y1, y1 )

RHS ::= F( RHS, … , RHS ) | q(xi, RHS, …, RHS) | yi

Nondeterminism!

Page 8: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

8

Evaluation StrategyTwo Evaluation Strategies

(analogous to the λ-calculus…)Call-by-Value (IO : Inside-Out)Call-by-Name (OI : Outside-In)

Page 9: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

Example (IO / call-by-value)

start(A(B)) double( B, double(B, E) ) double( B, F(E, E) )

F( F(E,E), F(E,E) ) or G( F(E,E), F(E,E) ) or double( B, G(E, E) )

F( G(E, E), G(E, E) ) or G( G(E, E), G(E, E) )

double( A(x1), y1) → double( x1, double(x2, y1) )double( B, y1 ) → F( y1, y1 )double( B, y1 ) → G( y1, y1 )

Page 10: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

Example (OI / call-by-name)

start(A(B)) double( B, double(B, E) ) F( double(B, E), double(B, E) ) F( F(E,E), double(B, E) ) F( F(E,E), F(E,E) )

F( F(E,E), G(E,E) ) !! F( G(E,E), double(B, E) ) F( G(E,E), F(E,E) ) !!

F( G(E,E), G(E,E) ) G( double(B, E), double(B, E) ) G( F(E,E), double(B, E) ) G( F(E,E), F(E,E) )

G( F(E,E), G(E,E) ) !! G( G(E,E), double(B, E) ) G( G(E,E), F(E,E) ) !!

G( G(E,E), G(E,E) )

double( A(x1), y1) → double( x1, double(x2, y1) )double( B, y1 ) → F( y1, y1 )double( B, y1 ) → G( y1, y1 )

Page 11: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

11

Evaluation StrategyTwo Strategies

(analogous to the λ-calculus…)Call-by-Value (IO : Inside-Out)Call-by-Name (OI : Outside-In)

Today, we consider OI evaluation only.Why?

MTTIO* = MTTOI* (even though MTTIO ≠ MTTOI)

MTTOI has better compositionality (as shown later)

Page 12: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

12

Importance of the class MTT*MTT* subsumes almost all

well-studied tree transducer modelsEquals to

(Attributed Tree Transducer)*(Pebble Tree Transducer)*(Higher-Order Tree Transducer)*

Properly Contains(MSO Definable Translation)*(Top-Down Tree Transducer)*(Bottom-Up Tree Transducer)*

Page 13: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

13

Importance of the class MTT*MTT*(REGT) subsumes the

“IO/OI-hierarchy”Context-Free String/Tree LanguageIndexed Language [Aho 1968] Macro Language [Fischer 1968]

CFG with each nonterminals are parameterized by other nonterminals

Level-n Language [Damm 1982]= Higher-order Macro Language

Page 14: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

Context-Free Language

Level-1 OI Language= Macro Language≒ CF Tree Language

Level-2 OI Language

Level-n OI Language

MTT*(REGT)

CFG where nonterminals are parameterized by other nonterminals[Aho68] ⊆NSPACE(n)[Rounds73] NP-complete

Context-Sensitive Language

[Kuroda64]= NSPACE(n)

[CYK, Earley, …] ⊆PTIME

OI-hierarchy [Damm82][Our Work]⊆ DSPACE(n)NP-complete

Level-3 OI Language

Page 15: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

15

Review on Previous Work (= the Basis of Our Approach)

Page 16: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

16

Related WorkT*(REGT) is in DSPACE(n)

[Baker1978]T : the class of translations realizable

by MTTs with no accumulating params.

DMTT*(REGT) is in DSPACE(n) [Maneth2002]DMTT : that of deterministic MTTs

Page 17: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

DSPACE(n) Membership for DMTT*(REGT)

≪Problem Statement≫Given

A regular tree language L andA composition sequence τ1 ; … ; τn of

deterministic MTTsand a tree t,How can we test

t ∈ (τ1 ; … ; τn )( L )in linear space with respect to |t|?

Page 18: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

Guess the input s ∈ L Calculate (τ1 ; … ; τn )(s) If (τ1 ; … ; τn )(s) = t, then t is in the output

language! Otherwise, try another input tree s

Is this a possible output from τ1 ; … ; τn ?

τ1 τ2 τn

ts

Guess an input: s

s1

Compute s1:=τ1(s)

s2

Compute s2:=τ2(s)

Sn-1

Compute sn-1

sn

Compute sn

=?

DSPACE(n) Membership for DMTT*(REGT)

≪Approach: Generate & Test ≫

Page 19: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

In order to carry out the algorithm in DSPACE(|t|) … The sizes |s|, |s1|, |s2|, …, |sn| must be linearly bounded

by |t| i.e., there must be a constant c independent from t

such that |s| ≦ c|t| Each step τi of the computation must be done in linear

spaceThe translation must have

‘no garbage’!

τ1 τ2 τn

ts s1 s2 Sn-1 sn

=?

DSPACE(n) Membership for DMTT*(REGT)

≪Approach: Generate & Test ≫

Page 20: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

Lemma 1: Linear Time Computation (Folklore)For a tree s and a deterministic MTT τ,

we can computeτ(s) in time O( |s| + |τ(s)| )if:τ is linear, orτ is a top-down tree transducer

Lemma 2: DMTT = DT ; DLMTT [EV85]Corollary: DMTT* = (DT ∪ DLMTT)*

DSPACE(n) Membership for DMTT*(REGT)

≪Approach: Generate & Test≫

Page 21: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

Lemma 3: “Garbage-Free Form”For any

L∈REGT and τ1; …;τn ∈DMTT*,there exists L’∈REGT and ρ1, …, ρ2n ∈(T∪DLMTT)*such that (τ1 ; … ; τn)( L ) = (ρ1 ; … ; ρ2n)( L’)and every ρi is “non-deleting”, i.e, ∀s: |s| ≦ 2|ρi(s)|

DSPACE(n) Membership for DMTT*(REGT)

≪Approach: Generate & Test≫

Page 22: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

22

Main Result:DSPACE(n) Membership of MTT*(REGT)

Page 23: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

≪Approach: Generate & Test≫ Guess the input s ∈ L

and all the intermediate trees s1, …, sn-1 Check whether

(s,s1)∈τ1, (s1,s2)∈τ2, …, (sn-1, t) ∈τn If it is, then t is in the output language! Otherwise, try another s, s2, …, sn-1

τ1 τ2 τn

ts s1 s2 Sn-1

∈ ?∈ ? ∈ ?

Page 24: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

As you might expect…Two Lemmas are needed

Nondeterminstic versionof the ”Garbage-Free” Form

Linear space “Translation Membership”for a single (T ∪ LMTT) translationWe already have MTT* = (T ∪ LMTT)*

[EV85]

Page 25: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

25

Linear Space“Translation Membership”

Lemma 4: Let τ ∈ (T ∪ LMTT). For trees s and t, we can check whether t∈τ(s) or not within O(|s|+|t|) space.

Proof: Basically, try all nondeterministic computation by backtracking. (Some clever stack-sharing is required)

Actually, we’ve shown the lemma for any “path-linear” MTT.

Linear: f(x1, g(x2), h(x3))

Path-linear(but not linear): f(x1, g(x2), h(x2))

Not path-linear: f(x1, g(x1), h(x2))

Page 26: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

26

“Garbage-Free Form”Lemma 5:

For any L∈REGT and τ1; …;τn ∈MTT*,there exists L’∈REGT and ρ1, …, ρ2n ∈(PL-MTT)*such that (τ1 ; … ; τn)( L ) = (ρ1 ; … ; ρ2n)( L’)and every ρi is “non-deleting”, i.e, ∀t∈out(ρ):∃s1,..,s2n: si+1∈ρi(si), t∈ρ2n(s2n), |si|≦ 2|si+1|, |s2n|≦2|t|

Page 27: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

Proof Sketch ofthe Garbage-Free Form

“Factor out” the deletion

τ1 ; τ2 == τ1 ; (D ; ρ2)

== (τ1 ; D) ; ρ2

== τ’1 ; ρ2

Decompose τ2

to ‘deleting part’ Dand ‘nondeleting’ τ’2

Associativity

Compose τ1 with D(Right-Compositionality

of OI MTTs)

Page 28: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

Three Types of Deletion “Input-Deletion”

E.g., f( A(x1, x2) ) B( f(x1) ) Discarding the “x2” subtree!

“Skipping” E.g., f( A(x1) ) f(x1) No output is generated at the unary node A.

“Erasure” E.g., f( L, y1 ) y1 (Mainly at leaf nodes) No new output symbol is

generated at the node.

Page 29: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

29

Three Types of Deletion If there is no input-deletion,

skipping, and erasure during the computation,|in| ≦ 2|out|

Intuition: No input-deletion visits all nodes No skipping outputs at least one node for each

input unary node No erasure outputs at least one node for each input

leaf node For any tree, 2*(#unary + #leaf) ≧ #nodes

(cf., the number of matches in a knockout tournament)

Page 30: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

30

How to eliminate“erasing” rules

Look-ahead + Inline-ExpansionDecompose τ into τ = E ; τne

E : Bottom-up translation that annotates each input tree with

τne: τ without erasing rules

Page 31: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

31

How to eliminate“erasing” rules : τ = E ; τneExample

A

B

C

B

C

C

τ: f( C, y1 ) → y1

g( B(x1,x2) ) → X( f(x1, Y) )

Applying f to the 1st child invokes

erasure…

A

B

C

B

C

CApplying f to the 1st

child invokes erasure…

E

Page 32: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

32

How to eliminate“erasing” rules : τ = E ; τne

τne: f( C, y1 ) → y1

g( B (x1,x2) ) → X( Y )Applying f to the 1st

child invokes erasure…

A

B

C

B

C

C

Applying f to the 1st child invokes

erasure…

A

B

C

B

C

CApplying f to the 1st

child invokes erasure…

E

Page 33: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

33

How to eliminate“erasing” rules : τ = E ; τneMore complex case

τ: f( C, y1 ) → y1

h( B(x1,x2), y1 ) → f(x1, y1)A

B

C

B

C

C

f(1st) erasureh(2nd) erasure

A

B

C

B

C

C f(1st) erasureE

h(1st) erasure

Page 34: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

34

Problem!“Inline-Expansion” is not always

possible for nondeterministic MTTsτ: f( C, y1, y2 ) y1

f( C, y1, y2 ) y2

g( B (x1,x2) ) h( x1, f(x1, Y, Z) )

h( C, y1 ) X( y1, y1 )τne: g( B (x1,x2) ) h( x1, Y ) g( B (x1,x2) ) h( x1, Z ) h( C, y1 ) X( y1, y1 )

er…

er…er…

DifferentTranslation!

Page 35: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

35

Solution!Extend MTTs with “inline-

nondeterminism”τ: f( C, y1, y2 ) y1

f( C, y1, y2 ) y2

g( B (x1,x2) ) h( x1, f(x1, Y, Z) )

h( C, y1 ) X( y1, y1 )

τne: g( B (x1,x2) ) h( x1, +(Y,Z) ) h( C, y1 ) X( y1, y1 )

er…

er…SameTranslation!

Page 36: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

Solution:“MTT with Choice and

Failure”MTT + inline-nondeterminism

+ inline-partiality

Same expressiveness: MTT = MTTCFMuch more flexible syntax

Allows inline-expansion for free!

RHS ::= F( RHS, … , RHS ) | q(xi, RHS, …, RHS) | yi

| +(RHS, RHS) | θ

Page 37: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

37

Note on Path-linearity Inline-Expansion

…does not preserve linearity.…does preserve path-linearity.

This is the reason for using PL-MTTs.

τ: f( C, y1 ) X( y1, y1 ) g( B(x1,x2) ) f( x1, h(x2, Y) )

τne: g( B(x1,x2) ) X( h(x2, Y), h(x2, Y) )

Page 38: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

38

How to eliminate“Input-Deletion”: τne = I ; τnei

Exhaustively trying all deletion by using nondeterminism

A

B

C

B

C

CI

A0 A1

B00

A1

B10

CA0

B01

C

B11

C

or or or

or…

Page 39: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

39

How to eliminate“Input-Deletion”: τne = I ; τnei

Exampleτne: f( B(x1,x2) ) g( x1, g(x1, Y) ) f( B(x1,x2) ) g( x1, g(x2, Y) ) f( B(x1,x2) ) g( x2, g(x1, Y) )

τnei: f( B10(x1) ) g( x1, g(x1, Y) ) f( B10(x1) ) g( x1, θ ) f( B10(x1) ) g( x2, g(x1, Y) ) …

Page 40: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

40

How to eliminate“Skipping”: τnei = S ; τneis

Same as for the “input-deletion”Try all possible deletion

nondeterminisitically…A

B

C

BS

A

CBBCABB

BA

CB

oror or...

Page 41: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

Proof Sketch ofthe Garbage-Free Form

“Factor out” the deletion

τ1 ; τ2 == τ1 ; (E;I;S ; ρ2)

== (τ1 ; E;I;S) ; ρ2

== τ’1 ; ρ2

Decompose τ2

to ‘deleting part’ E;I;Sand ‘nondeleting’ τ’2

Associativity

Compose τ1 with D(Right-Compositionality of OI MTTs with linear top-down transducers)

Page 42: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

Summary Membership problem of MTT*(REGT) is in

DSPACE(n) Note: Almost the same proof shows that it is in

NP Note: NP-hardness was already known

[Rounds73]

Corollary: OI-Hierarchy, PTT*(REGT), ATT*(REGT), etc is in DSPACE(n) and NP-complete

Corollary: MTT*( * ), MTT*(CFTG), etcis in DSPACE(n) and NP-complete

Page 43: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

43

SummaryKey Lemma: “Garbage-Free Form”

Any composition sequence of MTTscan be transformed to the one withno deletion

τ1 τ2 τk

ts

s1

s2Sk-1

τ1 τ2 τk

ts s1 s2 Sk-1

Page 44: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

44

Future Work“Strong” Garbage-Free Form

↓ This is tooooo wasteful

A

B

C

B

C

CI

A0 A1

B00

A1

B10

CA0

B01

C

B11

C

or or or

or…

Page 45: The Complexity of   Tree Transducer   Output Languages

www.kmonos.net

45

Future Work“Strong” Garbage-Free Form

(τ1 ; … ; τn)( L ) = (ρ1 ; … ; ρ2n)( L’)and range(ρi-1) ⊆ domain(ρi)

Application to …Finiteness Problem of the out(MTT*)Nondeterministic Execution of MTT*