1 decompositions of higher-order grammars to first-order transducers kazuhiro inaba
TRANSCRIPT
![Page 1: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/1.jpg)
1
Decompositions of Higher-Order Grammars to First-Order Transducers
Kazuhiro Inaba
![Page 2: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/2.jpg)
2
Input: a string t
Determine if t belongs toa regular language
Regular Language
O( |t| ) time
O( 1 ) space
( 0 | 1 (0 (1*0)+)* 1)+
![Page 3: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/3.jpg)
3
Input: a string t
Context-Free Language
O( |t|ω ) time = the order of matrix multiplication
O( (log|t|)2 ) space
E ::= T | T + T | T – TT ::= F | F * F | F / FF ::= ( E ) | 0 | 1NN ::= 0 | 1 | 0N | 1N
![Page 4: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/4.jpg)
4
• Nonterminals of CFGhas type :: string.
• MG can have string->string or (string, string)->string,etc.
Macro Language [Fischer68, Aho68, Rounds73]
NP-complete
O(|t|) space
S() ::= T(,,)T(x,y,z) ::= T(ax,by,cz) | xyz
![Page 5: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/5.jpg)
5
• ((tree->tree)->tree)->tree• etc.
Higher-Order Tree Garmmers
????? time
????? space
S ::= TWICE(X)TWICE(f) ::= f(f(1))X(e) ::= Plus(e, e) | Minus(e, e)
P
M P
1 1 1 1
![Page 6: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/6.jpg)
6
For “safe” subset of higher order grammars, it is still:
Goal of Today’s Talk (1)
NP time
O(|t|) space
[Inaba09] K. Inaba, “Complexity and Expressiveness of Models of XML Transformations”, Dissertation
![Page 7: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/7.jpg)
7
Conjecture:For any higher order grammars, it is still:
Goal of Today’s Talk (2)
NP time
O(|t|) space
![Page 8: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/8.jpg)
8
• In this talk, we concentrate on the complexity with respect to the size of the input tree t.
• Regard grammar G as fixed.
• “O(|t|) space” means “O(|t| f(|G|)) space”.– Indeed, f(x) n-EXP where n is the highest order.≧
Caution:
![Page 9: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/9.jpg)
9
Overview of Our Approach
1) Introduce HTT: Higher-order Tree Transducers– A slight generalization of higher-order grammars.– Examine the problem:“Can t be an output of a HTT?”
HTT: λ
λ λ
t
∋?
![Page 10: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/10.jpg)
10
Overview of Our Approach
2) First Order Decomposition– Show order-n HTT is simulatable by n composition
of first order HTTs.
t
∋?
τ1 τ2 τn
t
∋?
HTT: λ
λ λ
![Page 11: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/11.jpg)
11
Overview of Our Approach
3) “Garbage Free Form”– Show that we can transform the HTTs so that all
intermediate trees are smaller than t.
τ1 τ2 τn
t
∋?
s1 s2 Sn-1
s0
τ'1 τ'2 τ'nτ'del
t
∋?
![Page 12: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/12.jpg)
12
Overview of Our Approach
4) Subproblem: translation membership– Given trees s1, s2 and 1-HTT τ, can we determine
“τ(s1) s2 ?”∋ in NP / O(|s1|+|s2|) space?
s1 s2 Sn-1
s0
τ'1 τ'2 τ'nτ'del
t
∋?
![Page 13: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/13.jpg)
13
Overview of Our Approach
5) Wrap up! Given HTT G and a tree t, - Convert G to garbage-free 1st order composition - “Guess” (by NP / O(n) space) all intermediate trees sk. - Check each translation membership.
s1 s2 Sn-1
s0
τ'1 τ'2 τ'nτ'del
t∋?
τ1 τ2 τn
HTT: λ
λ λ
![Page 14: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/14.jpg)
14
HTT [Engelfriet&Vogler 88]
Higher-order “single-input” “safe” tree transducer Mult :: Tree Tree
Mult(Pair(x1,x2)) Iter(x1)(Add(x2))(Z)
Iter :: Tree (Tree Tree) Tree Tree
Iter(S(x))(f)(y) Iter(x)(f)(f(y))Iter(Z)(f)(y) y
Add :: Tree Tree Tree
Add(S(x))(y) Add(x)(S(y))Add(Z)(y) y
![Page 15: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/15.jpg)
15
Iter :: Tree (Tree Tree) Tree Tree
Iter(S(x))(f)(y) Iter(x)(f)(f(y))Iter(Z)(f)(y) y
HTT
• Set of mutually recursive functions– Defined in terms of induction on a single input tree
• Input trees are always consumed, not newly constructed• Output trees are always created, but not destructed
– Rest of the parameters are ordered by the order• Multiple parameters of the same order is ok but in uncurried form
Inductive Input Param Order-1 Param(s) Order-0 Param(s) Result
![Page 16: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/16.jpg)
16
HTT
Nondeterminism (∥and ⊥) Subseq :: Tree TreeSubseq(Cons(x,xs)) Cons(x, Subseq(xs)) ∥ Subseq(xs)Subseq(Nil) NilSubseq(Other) ⊥
In this talk, evaluation strategy is unrestricted (= call-by-name).But call-by-value can also be dealt with.
![Page 17: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/17.jpg)
17
HTT
• Notation: n-HTT– is the class of TreeTree functions
representable by HTTs of order n.≦– {Subseq} is 0-HTT, {Mult, Iter, Add} 2-HTT∈
Subseq :: Tree Tree
Mult :: Tree Tree Iter :: Tree (Tree Tree) Tree Tree Add :: Tree Tree Tree
![Page 18: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/18.jpg)
18
Order-n to Order-1
THEOREM [EV88] [EV86]
(n-HTT) ⊆ (1-HTT)n
n-th order tree transducer is representable by a n-fold composition of 1st-order tree transducers.
[EV86] J. Engelfriet & H. Vogler, “Pushdown Machines for Macro Tree Transducers”, TCS 42[EV88] ─, “High Level Tree Transducers and Iterated Pushdown Tree Transducers”, Acta Inf. 26
![Page 19: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/19.jpg)
19
Proof: n-HTT = 1-HTT (n-1)-HTT ∘
Idea: Represent 1st-order term TreeTree by a Tree.
Represent 1st-order application symbolically, too.
F :: Tree TreeTree
F(Z)(y) S(S(y))
F :: Tree Tree
F(Z) S(S(Y))
… @(F(x), Z)… F(x)(Z)
![Page 20: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/20.jpg)
20
Proof: n-HTT = 1-HTT (n-1)-HTT ∘
Represent 1st-order things symbolically.
Then a 1-HTT performs the actual “application”.Eval(@(f, b))(y) Eval(f, Eval(b)(y))Eval(Y)(y) yEval(S(x))(y) S(Eval(x)(y))Eval(Z)(y) Z
F :: Tree Tree
F(Z) S(S(Y))… @(F(x), Z)
![Page 21: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/21.jpg)
21
Mult(Pair(S(Z),S(Z))) @
ZIter(S(Z))(Add(S(Z))) @
Z
Iter(Z)(Add(S(Z)))
@
@
Add(S(Z)) Y
@
Z@
@
Add(S(Z)) Y
Y
@
Z@
@
Y
Y
@
Y
SY
Example
Mult(Pair(x1,x2)) @(Iter(x1)(Add(x2)), Z)Iter(S(x))(f) @(Iter(x)(f), @(f, Y))Iter(Z)(f) YAdd(S(x)) @(Add(x),S(Y))Add(Z) Y
![Page 22: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/22.jpg)
22
Eval( , y=⊥)@
Z@
@
Y
Y
@
Y
SY
Eval( , y= )Z@
@
Y
Y
@
Y
SY
Eval( ,y=Eval( ,y= )Z@
Y
Y
@
Y
SY
Z
S
Eval(@(f, b))(y) Eval(f, Eval(b)(y))Eval(Y)(y) yEval(S(x))(y) S(Eval(x)(y))Eval(Z)(y) Z
Eval( ,y= )Z@
Y@
Y
SY
![Page 23: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/23.jpg)
23
Why That Easy
• Relies on the ordered-by-order condition.– No variable renaming is required! [Blum&Ong 09]
[BO09] W. Blum and C.-H. L. Ong, “The Safe Lambda Calculus”, LMCS 5
Eval( ,y=Eval( ,y= )Z@
Y
Y
@
Y
SY
![Page 24: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/24.jpg)
24
Decomposed.
n-HTTλ λ λ
1-HTT n
τ1 τ2 τn
![Page 25: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/25.jpg)
25
Next, Make Intermediate Trees Small.
1-HTT n
ts
s1 s2 Sn-1
s0
τ1 τ2 τn τ'1 τ'2 τ'nτ'del
ts
![Page 26: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/26.jpg)
26
THEOREM [I. & Maneth 08] [I. 09](+ improvement)
∀τ1, ..., τn 1-HTT∈ , ∃τ’del 0-LHTT∈ , τ’1, ..., τ’n 1-HTT∈ , for any (τn ... τ∘ ∘ 1)(s) t,∋ there exist τ’del(s) s∋ 0, τ’i(si) s∋ i+1, |si| |s≦ i+1|, sn=t.
[IM08] K. Inaba & S. Maneth, “The complexity of tree transducer output languages”, FSTTCS
[Inaba09] K. Inaba, “Complexity and Expressiveness of Models of XML Transformations”, Dissertation
ts
s1 s2 Sn-1
s0
τ1 τ2 τn τ'1 τ'2 τ'nτ'del
ts
|s| = number of nodes
![Page 27: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/27.jpg)
27
How to Construct the “Garbage-Free” Form
Make each 1-HTT “productive”
τ’nτn-1
t
τnτn-1
t
![Page 28: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/28.jpg)
28
How to Construct the “Garbage-Free” Form
Make each 1-HTT “productive”by separating its “deleting” part
τ’nτn-1
t
τ’del
τnτn-1
t
τn τ’nτ’del=
![Page 29: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/29.jpg)
29
How to Construct the “Garbage-Free” Form
Make each 1-HTT “productive”by separating its “deleting” part,and fuse the deleter to the left [En75,77][EnVo85][EnMa02]
τ’nτ’n-1+del
t
τnτn-1
t
![Page 30: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/30.jpg)
30
Repeat τ4τ3τ2τ1
τ3τ2τ1 τ’4τ’4d
τ34dτ2τ1 τ’4
τ’3τ2τ1 τ’4τ’34d
τ’3τ234dτ1 τ’4
τ’3τ’2τ1 τ’4τ’234d
τ’3τ’2 τ’4τ1234d
τ’3τ’2 τ’4τ’1τ’1234d
Split
Fuse
Split
Fuse
Split
Fuse
Split
![Page 31: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/31.jpg)
31
Separate the “deleting” transformation
Key Part
τ’n= τ’delτn ;
=
![Page 32: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/32.jpg)
32
Slogan: Work on every node(τ’n must generate at least one node for each input node)
Key Part
τ’nτ’del ;
![Page 33: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/33.jpg)
33
Deleting HTTs
Work on Every Node Visit All Nodes⇒
G(Z)(y1) Z ∥ y1
F(S(x1,x2)) F(x1) ∥ F(x2) ∥ G(x1)(F(x2))
τn
may not recurse down to a subtree.
![Page 34: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/34.jpg)
34
Nondeterministically delete every subtree!
Work on Every Node Visit All Nodes⇒
F(S(x1,x2)) G(x1)(F(x2)) τn
F(S12(x1,x2)) G(x1)(F(x2))F(S1_(x1)) G(x1)(⊥)F(S_2(x2)) ⊥F(S__()) ⊥ τ’n
Del(S(x1,x2)) S12(Del(x1),Del(x2)) ∥ S1_(Del(x1)) ∥ S_2(Del(x2)) ∥ S__()
τ’del
At least one choice of nodeterminism “deletes correctly”.
![Page 35: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/35.jpg)
35
Work on Every Node Work on Leaf⇒
Erasing HTTs
F(S(x)) G(x)(Z) G(Z)(y) y
may be idle at leaves.
τn
![Page 36: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/36.jpg)
36
Work on Every Node Work on Leaf⇒
F(S(Z)) Z τ’nInline Expansion
Erasing HTTs
F(S(x)) G(x)(Z) G(Z)(y) y
τn
![Page 37: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/37.jpg)
37
Work on Every Node Work on Monadic Nodes⇒
F(S(x))(y1,y2,y3) F(x)(y2,y3,y1)F(Z)(y1,y2,y3) Done(y1,y2,y3)
Skipping HTTs
are good at juggling.
τn
![Page 38: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/38.jpg)
38
Work on Every Node Work on Monadic Nodes⇒
Nondeterministic deletion again.Remember how arguments would’ve been shuffled.F(Z123)(y1,y2,y3)
Done(y1,y2,y3)F(Z231)(y1,y2,y3) Done(y2,y3,y1)F(Z312)(y1,y2,y3) Done(y3,y1,y2)
F(S(x))(y1,y2,y3) F(x)(y2,y3,y1)F(Z)(y1,y2,y3) Done(y1,y2,y3)
Skipping HTTs τn
τ’n
![Page 39: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/39.jpg)
39
• Input size = #leaf + #monadic + #others – For each leaf on the input, generate 1 node.≧– For each monadic node, generate 1 node.≧– Thus, #leaf + #monadic ≦ Output size.
• For any tree, #others < #leaf ≦ Output size.• Add: #leaf + #monadic + #others ≦ Output size*2
• So, Input size < Output Size * 2
Simple Arithmetic
![Page 40: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/40.jpg)
40
• Input size < Output Size * 2
This bound is sufficient for deriving the results,but we can improve this to Input size ≦ Output Size, by deterministic deletion of leaves + inline expansion.
Work on Nodes with Rank-2,3,...
Fr(Bin(x1,x2))(y) Fr(x1)(Fr(x2)(y))Fr(A)(y) A(y)Fr(B)(y) B(y)
![Page 41: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/41.jpg)
41
Done!Intermediate trees are small!
τ’nτ’del ;
![Page 42: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/42.jpg)
42
Next.“Translation membership problem”
s1 s2 Sn-1
s0
τ'1 τ'2 τ'nτ'del
t
∋?
![Page 43: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/43.jpg)
43
Given trees s1, s2 and τ, can we determine “τ(s1) s2 ?”∋ in NP / O(|s1|+|s2|) space?
From the construction, τ is always– 1st order HTT– Non-deleting/erasing/skipping.– Path-linear: recursive call to the same
child node will not nest. • OK: Node(f(x), g(x)) BAD: f(x, g(x))• height(s2) O(|s1|)∈
Translation Membership
s1 s2
τ
![Page 44: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/44.jpg)
44
τ
Example
A
B
C C
C
s1Γ
β
α
Γ
Γ
s2
S(x) F(x)(Δ)F(A(x1,x2))(y) F(x1)(α(F(x2,y)))F(B(x1,x2))(y) F(x2)(β(F(x2,y)))F(C)(y) Γ(y)
![Page 45: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/45.jpg)
45
Basic Idea:Just compute τ(s1) and compare.
A
B
C C
C
s1
τ
Γ
β
α
Γ
Γ
τ(s1)Γ
β
α
Γ
Δ
s2
S(x) F(x)(Δ)F(A(x1,x2))(y) F(x1)(α(F(x2,y)))F(B(x1,x2))(y) F(x2)(β(F(x2,y)))F(C)(y) Γ(y)
Δ
![Page 46: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/46.jpg)
46
• τ(s1) may be very big Compute τ(s1) incrementally. If it becomes largerthan s2, return false immediately.
• τ may be nondeterministic For NP algorithm, use the nondeterminism. “non-deleting” property ensures polynomial choices. For linear space algorithm, do back-track search.The “call-stack” is linear-size bounded (next page),so it can be done in linear space.
Key Points
![Page 47: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/47.jpg)
47
Each node corresponds to a “call-stack”
A
B
C C
C
s1
S(x) F(x)(Δ)F(A(x1,x2))(y) F(x1)(α(F(x2,y)))F(B(x1,x2))(y) F(x2)( β(F(x2,y)))F(C)(y) Γ( y)
τ
τ(s2) Γ
β
α
Γ
Γ
s2
1
Γ
β
α
Γ
Γ
Δ
23
4 5
6
1 2 3 4 5 6
![Page 48: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/48.jpg)
48
Summary
• Safe n-HTT (1-HTT)n
• Split input-deletion• Split erasing• Split skipping• Fuse deleter• Translation membership
λλ λ
ts1 s2 Sn-1
s0
τ1 τ2 τn
τ'1 τ'2 τ'nτ'del
![Page 49: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/49.jpg)
49
What about UNSAFE HTT?
• UNSAFE n-HTT (1-stack-HTT)n
– ???: Now variable names matter. Use De Bruijn index.• Split input-deletion– OK: same technique works (nondet deletion)
• Split erasing– OK: same technique works (inline expansion)
• Split skipping– ?????????????????????
• Fuse deleter– OK: same technique works (product construction)
• Translation membership– OK: same technique works (call-stack size argument)
![Page 50: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/50.jpg)
50
• Parameters are now passed as a stack.
Stack-HTT
F :: Tree Stack<Tree> Tree
F(ADD(x))(..., y1, y2) F(x)(..., PLUS(y1, y2))
F(SUB(x))(..., y1, y2) F(x)(..., MINUS(y1, y2))
F(ONE(x))(...) F(x)(..., 1)F(EOP)(f)(..., y) y
PUSH!
POP!
![Page 51: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/51.jpg)
51
Unsafe substitution Stack HTT
@
@
C
B
A
ss
(λx. λy. A(x, y))(B)(C)
(λ. λ. A(1, 0))(B)(C)
z
Eval(@(f, a))(...) Eval(f)(..., Eval(a)(...))Eval(s(x))(...,y) Eval(x)(...)Eval(z)(...,y) y
Eval( )( , )CA
z
ss
B
![Page 52: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/52.jpg)
52
F(σ(x...))(y0)...(yn)(z) rhs where z :: tree
F(σ(x...))(y0)...(yn) [[rhs]]0
• [[ e ]]k+1 = s( [[ e ]]k ) if e :: tree
• [[ yi ]]0 = s( yi ) if yi :: tree• [[ z ]] = z• [[ x(...) ]]k = x( [[...]]k+1 ) if x(...) :: tree->tree
• ...• [[ e1(e2) ]]k = @( [[e1]]k+1, [[e2 ]]k ) if e1 :: tree->tree
• [[ e1(e2) ]]k = [[ e1 ]]k ( [[e2 ]]k ) otherwise
n-Unsafe-HTT Substitution
...something like this (the above presentation may not be correct) should work, I hope!
![Page 53: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/53.jpg)
53
ExampleI :: tree
I S(A)
S :: tree -> tree
S(x) F( G(F(x))(B) )(C)
F :: tree -> tree -> tree
F(x)(y) = D(x, y)
G :: (tree->tree) -> tree -> tree
G(u)(x) = u(x)
I @(S, A)
S @(F(s(@(G(F(s(s(z)))), B))), C)
F(x) D(x, z)
G(u) @(u, z)
![Page 54: 1 Decompositions of Higher-Order Grammars to First-Order Transducers Kazuhiro Inaba](https://reader036.vdocuments.mx/reader036/viewer/2022062321/56649eca5503460f94bd9170/html5/thumbnails/54.jpg)
54
Example@
@
C
A
D
zs
@
B@
z
I @(S, A)
S @(F(s(@(G(F(s(s(z)))), B))), C)
F(x) D(x, z)
G(u) @(u, z)
D
z
s
z
s