TreeTransducers HendrikJanHoogeboom LIACSLeiden CSL/GAMES - - PowerPoint PPT Presentation

tree transducers
SMART_READER_LITE
LIVE PREVIEW

TreeTransducers HendrikJanHoogeboom LIACSLeiden CSL/GAMES - - PowerPoint PPT Presentation

\maketitle Tutorialon TreeTransducers HendrikJanHoogeboom LIACSLeiden CSL/GAMES Lausanne,sept 07 from tree to tree parse parse val val symbolic/ syntax%directedtranslation compilertheory


slide-1
SLIDE 1

\maketitle

Tutorialon

TreeTransducers

HendrikJanHoogeboom

LIACSLeiden

CSL/GAMES

Lausanne,sept 07

slide-2
SLIDE 2

from tree to tree

parse val parse val

symbolic/ syntax%directedtranslation

  • compilertheory
  • naturallanguage
  • documenttransformation
slide-3
SLIDE 3

history

1960Ironssyntax%directedtranslation 1968Knuthattributegrammar 1968Thatcher&Roundstop%down,bottom%up 1980Aho&Ullman tree%walkingtr. 1985Engelfriet&Vogler macrotreetr. 2000Milo&Suciu&Vianu pebbletreetr.XML Fülöp&Vogler booktreetransducers Maneth Tarragonalectures

slide-4
SLIDE 4

contents

  • 1. automataontrees
  • 2. transducers
  • 3. regularmodels
  • 4. context%freetreegrammars
  • 5. macrotreetransducers
  • 6. pebbletreetransducers
slide-5
SLIDE 5

two views

rankedtrees~terms

[nestedstrings]

f f f f

k 1 2

TΣ treesoverΣ

f ∈ Σk f(x1x2…xk) fx1x2…xk … rankedalphabet (Σ,rank) rank:Σ → Σkrankk δ σ a b b a

δ(σ(ab)ba)

1 1 2 3 2

Σ0 ={a,b} Σ2 ={δ} Σ3 ={σ}

slide-6
SLIDE 6

tree automata

bottom%up evaluation top%down grammatical tree%walking navigation ‘parallel’

slide-7
SLIDE 7

bottom-up

T F T F ∨ ∨ ∨ ∨ T ∧ ∧ ∧ ∧ ∨ ∨ ∨ ∨ ∨ ∨ ∨ ∨ F ∧ ∧ ∧ ∧ F T ∨ ∨ ∨ ∨ T ∨ ∨ ∨ ∨ ∧ ∧ ∧ ∧ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ∧ ∧ ∧ ∧ ∧ ∧ ∧ ∧ 1 1 1 1 ∧ ∧ ∧ ∧ 1 1 1 1 ∧ ∧ ∧ ∧ 1 1 1 1 1 1 1 1 1 1 1 1 ∨ ∨ ∨ ∨ ∨ ∨ ∨ ∨ 1 1 1 1 1 1 1 1 ∨ ∨ ∨ ∨ 1 1 1 1 1 1 1 1 ∨ ∨ ∨ ∨ 1 1 1 1 1 1 1 1 1 1 1 1 F T 1 1 1 1

evaluation rules:

slide-8
SLIDE 8

formalization σ

1 k

q

i

σ

1 k i

q1 qi qk σ(q1…qk)→ qrank(σ)=k σ → qrank(σ)=0 ⇒ ⇒ ⇒ ⇒

∨ ∨ ∨ ∨ 1 1 1 1 1 1 1 1 1 1 1 1 F T 1 1 1 1

F→ 0 T→ 1 ∨ ∨ ∨ ∨11→1 F,T∈ Σ0 ∨ ∨ ∨ ∨,∧ ∧ ∧ ∧ ∈ Σ2

acceptancebyfinalstate(atroot)

slide-9
SLIDE 9

top-down

p1 :A→ AaB p2 :A→ a p3 :B→ Bb p4 :B→ A B p1 p2 a p3 p4 b a A

p1

A a B p1 A a p3 B b ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒2 rewritingatleaves derivationtree p3 B b →

regulartreegrammar

A

slide-10
SLIDE 10

regular tree languages

REG

  • bottom%up(det/nondet)
  • top%down(nondet)
  • MSOlogic
  • regulartreegrammars

closedunderintersection, complementation decidableemptiness (equivalence) natural! ► ► ►

slide-11
SLIDE 11

walking along the tree

T F F ∨ ∨ ∨ ∨ T ∧ ∧ ∧ ∧ ∨ ∨ ∨ ∨ ∨ ∨ ∨ ∨ F ∧ ∧ ∧ ∧ T ∨ ∨ ∨ ∨ ∨ ∨ ∨ ∨ ∧ ∧ ∧ ∧ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ∧ ∧ ∧ ∧ 1 1 1 1 ∧ ∧ ∧ ∧ 1 1 1 1 1 1 1 1 1 1 1 1 ∨ ∨ ∨ ∨ ∨ ∨ ∨ ∨ 1 1 1 1 1 1 1 1 F T 1 1 1 1 2 1 2 1 2 1 2 1 ∧ ∧ ∧ ∧ 1 ∨ ∨ ∨ ∨ 1 1 1 1 1 1 1 1 1 ? ? ?

cf.two%wayfinitestateautomaton

evaluatesand/ortrees!

slide-12
SLIDE 12

tree walking automaton

3 1 2 H down2 lab∨∧

∨∧ ∨∧ ∨∧:down1

labTF ch1:up ch2:up root

TWA

example:treetraversal walkalongedges,movesbasedon

  • state
  • nodelabel
  • childnumber

(=incomingedge)

∧ ∧ ∧ ∧ 1 2 1

2 lab ch 2 1 3

whenlabelis∨ ∨ ∨ ∨ or∧ ∧ ∧ ∧ movetofirstchild

slide-13
SLIDE 13

tree automata

bottom%up

evaluation

top%down

grammatical

tree%walking

navigation

TWA REG

⊇ ⊇ ⊇ ⊇

“twa easily loosetheirway”

slide-14
SLIDE 14

‘branching structure’ of even length

Bojańczyk & Colcombet

TWA⊂ ⊂ ⊂ ⊂ REG (aa)* notbyTWA butFO(!) a a a a a a a a b b b b b a a b a

slide-15
SLIDE 15

‘branching structure’ of even length

Bojańczyk & Colcombet

TWA⊂ ⊂ ⊂ ⊂ REG notbyTWA butPTWA usingapebble a a a a a a a a b b b b b a a b a

slide-16
SLIDE 16

adding nested pebbles

PTWA⊆ REG

nestedlifetimes nestedlifetimes nestedlifetimes nestedlifetimes LIFO pebble pebble pebble pebble:marksanode ‘regular’ extension

drop retrieve

fixednumberforautomaton canbedistinguished&reused

1 1 1 1 2 2 2 2 3 3 3 3 2 2 2 2

slide-17
SLIDE 17

selected papers on pebble automata

J.Engelfriet,H.J.Hoogeboom.Tree%walkingpebble automata,Jewelsareforever,1999. M.Bojańczyk,T.Colcombet.Tree%walkingautomatado notrecognizeallregularlanguages,STOC'05. J.Engelfriet,H.J.Hoogeboom.Nestedpebblesand transitiveclosure,LMCS,2007. M.Bojańczyk,M.Samuelides,T.Schwentick,L.Segoufin. Ontheexpressivepowerofpebbleautomata, ICALP'06.

slide-18
SLIDE 18

tree automata & logic

FO(+1) FO(<) TWA TWA TWA TWA dTW dTW dTW dTW FO+posTC FO+posTC FO+posTC FO+posTC1

1 1 1=

= = =PTWA PTWA PTWA PTWA MSO MSO MSO MSO= = = =REG REG REG REG

⊂ ⊂ ⊂ ⊂ ? ? ? ?

BojSamSchSeg’06

  • PWTA⊂

⊂ ⊂ ⊂ REGstrict

  • pebblehierarchy
  • typeofpebbles:

physicalvs.abstract FO+dTC FO+dTC FO+dTC FO+dTC1

1 1 1=

= = =dPTWA dPTWA dPTWA dPTWA TC(FO+mod) NevSch

nested pebbles & transitive closure EngHoo’06

Doner; ThaWri’68

slide-19
SLIDE 19

\section

macrotree transducers context%freetree grammars automataontrees pebbletree transducers regularmodels

slide-20
SLIDE 20

top-down tree transducer TΣ → T∆

σ x1 x2 x3 q q q q() δ ε a q q q q′ ′ ′ ′(x1) q q q q′′ ′′ ′′ ′′(x2)

state + subtree ≡ node (input)

→ → → → q(σ(x1 … xk)) → t ∈ T∆[Q(Xk)]rank(σ)=k q(σ) → t ∈ T∆

rank(σ)=0

A A A A =(Σ,∆,Q,Qd,R) {(t,s)∈ TΣ×T∆ |q(t)⇒* s,q∈Qd }

slide-21
SLIDE 21

example top-down

Σ0 ={e},Σ1 ={a} ∆0 ={e},∆2={d} a a a e a a e a a d e q(a(x))→ d(q(x),q(x)) q(e)→ e ⇒ ⇒ ⇒ ⇒

q() q() q() ⇒

⇒ ⇒ ⇒ a e a a d e

q()

d a e

q() q()

e a a d e

q()

d a e

q()

⇒ ⇒ ⇒ ⇒ d e

q() q()

slide-22
SLIDE 22

example top-down

Σ0 ={e},Σ1 ={a} ∆0 ={e},∆2={d} a a a e q(a(x))→ d(q(x),q(x)) q(e)→ e

q()

⇒ ⇒ ⇒ ⇒* e d e e d e d e d e e d e d d exponential sizeincrease

slide-23
SLIDE 23

top-down

q(a(x1))→ d(q(x1)q(x1))copy q(c(x1x2x3))→ d(q(x1)q(x2))delete rulesareconfluent linearheightincrease exponentialsizeincrease

yield

yieldlinearinput→ ET0L

moreLindenmayer connections

⇒ ⇒ ⇒ ⇒*

slide-24
SLIDE 24

top-down characteristic

‘T’ copyinginput,processingcopiesdifferently

Σ0 ={e},Σ1 ={a,σ} ∆0 ={e},∆1 ={a,b},∆2={σ} a a σ a e a a a e a a σ a e q(σ(x))→ σ(q(x),q(x)) q(a(x))→ a(q(x))| b(q(x)) q(e)→ e b a b e b b σ a e ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒*

q q q

slide-25
SLIDE 25

bottom-up characteristic

‘B1’ copyingoutputafternondet processinginput

e → q(e) a(q(x))→ q(a(x))| q(b(x)) σ(q(x))→ q(σ(xx)) Σ0 ={e},Σ1 ={a,σ} ∆0 ={e},∆1 ={a,b},∆2={σ} a a σ a e b a σ b e b a b e b a σ b e ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒*

q

a a σ a e ⇒ ⇒ ⇒ ⇒

q

a a σ a e ⇒ ⇒ ⇒ ⇒

q

slide-26
SLIDE 26

top-down vs. bottom-up

‘B1’ copyingoutputafter nondet processinginput

a a σ a e b a σ b e b a b e b a σ b e ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒*

q ‘T’ copyinginput,processing copiesdifferently

a a σ a e a a a e a a σ a e b a b e b b σ a e ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒*

q q q

top%down bottom%up

copy relabel copy relabel

top%down2

2 2 2

bottom%up2

2 2 2

slide-27
SLIDE 27

some properties

TDTandBUT … haveREGdomains … REGclosedunderinverse … areincomparable … arenotclosedundercomposition

slide-28
SLIDE 28

linear transducers

linear linear linear linear – nocopy lin%BUT =lin%TDT* =lin%TD+regularlook%ahead =(FTA∪ RELAB∪ LHOM)*

q(a(x1))→ d(q(x1)q(x1))

singlestate, nocopy intersection REG

… isclosedundercomposition … REGclosedunderlin%BUT

slide-29
SLIDE 29

\section

pebbletree transducers macrotree transducers regularmodels automataontrees context%freetree grammars

slide-30
SLIDE 30

[Knuth68] ⇒ ⇒ ⇒ ⇒*

1 + exp

σ σ

1 + 1 + exp 1 1 + 1 + 1 + exp +

11010 21+22+24 S:S→ N p0:N→ N0 p1:N→ N1 e:N→ 1 p0 p1 p1 e p0 s handlecontext!

slide-31
SLIDE 31

regular vs. context-free

B→ bA B→ BbA aabaB ⇒ aababA aaBbaA ⇒ aaBbAbaA

STRINGS TREES

A B B B A B B → ⇒ A B B A B

tree substitution

slide-32
SLIDE 32

regular vs. context-free

B→ bA B→ BbA aabaB ⇒ aababA aaBbaA ⇒ aaBbAbaA

STRINGS TREES

B

howtohandlesubtrees?

A B B →

slide-33
SLIDE 33

context-free tree grammars

B

parameters←actual subtrees

A A B →

  • regular

B→ t∈ TΣ[N]Nnonterminals B∈N

  • context%free

B(y1,…,ym)→ t∈ TΣ∪ N[Ym] Nranked nonterminals B∈Nm Ym ={y1,…,ym}parameters y3 y1 y2 y3 y2 y2 t1 t3

slide-34
SLIDE 34

cf tree grammar

y + y y + a F y + b F y F → | a F b F | → S y F → S ⇒ a F a + b F ⇒ + b F a + b ⇒ ⇒ + + b a + b + b a + b

yield{ww |w∈ {a,b}* } notcontext%free

S∈ N0 F∈ N1 a,b ∈ Σ0 +∈ Σ2

slide-35
SLIDE 35

(life is simple …)

a + A y + y F y F → A F → S → S ⇒ A F A + A F ⇒ ⇒ S,A∈ N0 F∈ N1 A a,b ∈ Σ0 +∈ Σ2 A + a | | b | y

yield {w∈{a,b}* |whas2n b’s }

A + A A A + + F A + A A A + + ⇒ ⇒* …

slide-36
SLIDE 36

(… no it isn’t)

A + A A A + + F cfg:leftmostvs.unrestrictedderivations OIoutside%in top%down‘lazy’ unrestriced IOinside%out bottom%up‘eager’

slide-37
SLIDE 37

IO mode

a + A y + y F y F → A F → S → S ⇒ A F S,A∈ N0 F∈ N1 A a,b ∈ Σ0 +∈ Σ2 A + a | | b | y

yield {w^2n |w∈ a*ba* }

⇒* + a a + b + a + a F ⇒* …

slide-38
SLIDE 38

cf tree languages

IO%CFTandOI%cft incomparable

IOgeneratesmoreequalcopies OIislazy:unsuccessfulsubtrees

OI≡ unrestricted

postpone‘inner’ steps context%freeproperty

yieldREG=CFL yieldOI%CFT=Indexed

slide-39
SLIDE 39

context%freetree grammars

\section

pebbletree transducers regularmodels automataontrees macrotree transducers

slide-40
SLIDE 40

selected papers on macro tree transducers

J.Engelfriet,H.Vogler.Macrotreetransducers,JCSS, 1985.

slide-41
SLIDE 41

macro tree transducers

top%downtreetransducers(input)& context%freetreegrammars(output) A B B → σ x1 x2 x3 q q q q δ ε a q q q q′ ′ ′ ′(x1) q q q q′′ ′′ ′′ ′′(x2)

state + subtree ≡ node (input)

→ → → → q(σ(x1 … xk)) → t ∈ T∆[Q(Xk)]rank(σ)=k

regular

slide-42
SLIDE 42

macro tree transducers

top%downtreetransducers(input)& context%freetreegrammars(output)

context%free

A B B → σ x1 x2 x3 q(y1,y2) δ y2 q′(x1) q′′(x2)

state + subtree ≡ node (input)+ parameters (output)

→ → → → y2 a q(σ(x1 … xk),y1 … ym) → t ∈ T∆∪Q(Xk)[Ym]rank(σ)=k,rank(q)=m

slide-43
SLIDE 43

mtt for linear trees

q0a(x1) → q(x1)(q(x1)e) qa(x1),y1 → q(x1)(q(x1)(y1)) qe,y1 → a(y1) x a

q0

y q(x) q(x) → → → → exponentialsize%to%height doubleexponentional size%to%size q0(aae)⇒ q(ae)q(ae)e ⇒ q(e)q(e)q(ae)e ⇒ aq(e)q(ae)e ⇒ aaq(ae)e ⇒ aaq(e)q(e)e ⇒ aaaq(e)e ⇒ aaaae

slide-44
SLIDE 44

MTT properties

  • unrestricted≡ OI
  • OI%MTTandIO%MTTincomparable
  • MTThasregularlook%ahead

bottom%upinspection

  • REGclosedunderinverseMTT

T%1(R)∈ REG

slide-45
SLIDE 45

context%freetree grammars

\section

macrotree transducers regularmodels automataontrees pebbletree transducers

slide-46
SLIDE 46

selected papers on pebble tree transducers

T.Milo,D.Suciu,V.Vianu.Typechecking forXML transformers,JCSS,2003. J.Engelfriet,S.Maneth.Acomparisonofpebbletree transducerswithmacrotreetransducers,Acta Inf, 2003.

slide-47
SLIDE 47

pebble tree transducers

Miloetal.2000: ‘allXMLquerylanguages canbemodeled byk%pebbletreetransducers’ greatfornavigation,but: k%PTTcannottestallregulardomains comparisonpebbles vs.macro:

  • n%dPTT ⊆ 0%dPTTn+1 ⊆ dMTTn+1
  • dMTT

⊆ 0%dPTT3 ⇒ samecompositionclosure tree%walkingautomataAho&Ullman 71

slide-48
SLIDE 48

(1) logic to nested pebbles

x y x x x x≤ ≤ ≤ ≤ y y y y x ∀ ∀ ∀ ∀x x x xϕ ϕ ϕ ϕ(x) (x) (x) (x)

alwayshalting freevariables~ fixedpebbles

laba(x) edgi(x,y) x x x x≤ ≤ ≤ ≤ y y y y x=y ¬ ∧ ∧ ∧ ∧ ∨ ∨ ∨ ∨ ∀ ∀ ∀ ∀x x x x ∃ ∃ ∃ ∃x ϕ*(x,y)

ϕ → ϕ

pebblesarenice (intheory)! theyimplement

  • freevariables
  • quantifiers
  • transitiveclosure
slide-49
SLIDE 49

a a a a a a a a b b b b b a a b a pebblesarenice(inpractice)! theycanbe‘programmed’

slide-50
SLIDE 50

wemovetoanother conference

► ‘classic’ pebbles comparisonpebblesvs.macro:

  • n%dPTT ⊆ 0%dPTTn+1 ⊆ dMTTn+1
  • dMTT

⊆ 0%dPTT3 ► introducinginvisiblepebbles issues% decomposition % complexityperpebble

slide-51
SLIDE 51

XML Transformation

by

Tree-Walking Transducers

with

Invisible Pebbles

Joost Engelfriet HendrikJanHoogeboom BartSamwel

(LeidenUniversity,NL) PODSBeijingJune2007

slide-52
SLIDE 52

tree model

<A> <B>… </B> <C>… </C> <B>… </B> </A>

A B C B

ranked trees nodelabelswithrank unboundednumberofchildren (forests)aretobecoded [usually]thisisnoproblem

rank(A)=3

1 3 2

slide-53
SLIDE 53

background

Milo Milo Milo MiloSuciu Suciu Suciu Suciu Vianu Vianu Vianu Vianu PODS2000 PODS2000 PODS2000 PODS2000 typecheckingforXMLtransformersisdecidable transformerswith‘visible’ pebbles: finitenumberofcoloured markersontree

typechecking

decidewhethertree(document)generatedby transformation satisfiesdescription

  • Gin

Gout

slide-54
SLIDE 54

contents

1. automatawithpebbles 2. decomposition 3. typechecking 4. regulartrees 5. documentnavigation 6. patternmatching 7. conclusion

slide-55
SLIDE 55

tree-walking automata σ

1 n j

q

local local local local configuration configuration configuration configuration qstate σ nodelabel jchild number j=0root bpebble colours b⊆ C i instructions instructions instructions instructions (q,σ,b,j)→ (halt) (q’,stay) (q’,up) (q’,downi) (q’,dropc) (q’,liftc)

with pebbles c b={c}

% finitesetC ofpebbles % nestedlifetimes stackbehaviour

  • nlytopmostcanbelifted

% allobservable

slide-56
SLIDE 56

tree-walking pebble automata

with visible pebbles ‘colours’ used once always observable weadd invisible pebbles colours used many times

  • nly topmostisobservable

stack behaviour ofpebbles! (avoid ‘counting’)

donotrecognizeall regulartreelanguages ≡ MSOproperties ☺ recognizeregular &decidabletypechecking &bettercomplexity

(q,σ,b,j)→ (q’,stay) b contains %allvisiblepebbles %invisiblewhentopmost c1 c c2 c c

top

  • bservable

c c u2 u3 u4 u5 u1

slide-57
SLIDE 57

automaton defines …

  • transformation

validation navigation pattern matching

slide-58
SLIDE 58

tree-walking pebble tree transducers

recursivelygenerateoutput q q q q

  • utputtree

1 n

q1

2

q1 qn q (q,σ,b,j)→ δ(q1,q2 … qn)

  • utputproduction

inputtree

t q σ δ

slide-59
SLIDE 59

tree-walking pebble tree transducers

  • utputtree

1 n

q1

2

q1 qn q (q,σ,b,j)→ δ(q1,q2 … qn)

  • utputproduction

inputtree

t q σ δ recursivelygenerateoutput

eachqworksonseparatecopyinputtree

  • tdt % qi pointtochildren(↓)
  • twt % qi pointtosamenode

q’s maymoveup↑ anddown↓ inbetween NOTE

slide-60
SLIDE 60

tree-walking pebble tree transducers

  • utputtree

(q,σ,b,j)→ δ(q1,q2 … qn)

1 n

q1

2

q1 qn

  • utputproduction

inputtree

t qn σ

inputtree

t q2 σ

inputtree

t q1 σ

inputtree

t q σ δ recursivelygenerateoutput

slide-61
SLIDE 61

example: moving the root

a a a a a a a a b b b b b b b b b b b b b b b b b b b b b b b b a a a a a a a a b b b b a a a a b b b b b b b b a a a a a a a a a a a a a a a a b b b b

withoutpebbles

a a a a a a a a b b b b b b b b3

3 3 3

b b b b b b b b b b b b b b b b a a a a a a a a b b b b1

1 1 1

a a a a b b b b b b b b a a a a a a a a a a a a a a a a b b b b 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 2 1 1 2 1 2 1 2 1 3

(↓,b,%,j)→ (↓,down1) (↓,b,%,j)→ (↓,down2)

j=0,1,2i=1,2

(↑,b,%,1)→ b(↑1,c2) (↑,b,%,2)→ b(c1,↑2) (↑i,b,%,i)→ (↑,up) (copy,a,%,j)→ a() (copy,b,%,j)→ b(c1,c2) (ci,b,%,j)→ (copy,downi) walkdown copyup copydown

slide-62
SLIDE 62

the power of composition ⇒ ⇒ ⇒ ⇒* n+1 2n ⇒ ⇒ ⇒ ⇒* n n together:exponentialsize%to%height n%PTT:polynomialsizeincrease

slide-63
SLIDE 63

notation

VkI%PTT Vk%PTT I%PTT TT visible+invisible kvisiblepebblesMiloetal. invisibleonly tree%walking(nopebbles) PebbleTreeTransducers PebbleTreeAutomata VkI%PTA Vk%PTA I%PTA

slide-64
SLIDE 64

contents

1. automatawithpebbles 2. decomposition 3. typechecking 4. regulartrees 5. documentnavigation 6. patternmatching 7. conclusion

slide-65
SLIDE 65

decomposition visible pebbles

VkI%dPTT ⊆ dTT ◦ Vk%1I%dPTT

  • kvisible pebbles

simulation k%1vis.pebbles deterministic preprocessing

iterate

VkI%dPTT ⊆ dTTk ◦ I%dPTT

(1) (2)

in in

  • ut
  • ut
slide-66
SLIDE 66

decomposition (1) preprocessing

copying can be done withoutpebbles preprocessing

t u v t↑u t↑v u u

‘root’ ‘root’

slide-67
SLIDE 67

decomposition (2) simulation

t u v

  • drop/lift

first visible pebble

moveup /down

into subtree

t↑u t↑v u u

‘root’ ‘root’

slide-68
SLIDE 68

decomposition

VkI%dPTT ⊆ dTT ◦ Vk%1I%dPTT I%dPTT ⊆ TT◦ dTT

Vk%PTT ⊆ TTk+1 VkI%PTT ⊆ TTk+2

(deterministic) THEOREM

slide-69
SLIDE 69

contents

1. automatawithpebbles 2. decomposition 3. typechecking 4. regulartrees 5. documentnavigation 6. patternmatching 7. conclusion

slide-70
SLIDE 70

type inference

Bartha 1982 regulartreegrammarG forthedomain

  • ftreetransducer canbeconstructed

inexponential time

inversetypeinference inversetypeinference inversetypeinference inversetypeinference

giventransducer andregularGout, constructregularGin suchthat L(Gin)=%1 L(Gout)

  • Gin

Gout

inversetypeinferenceissolvable ⇒ forTTinexponentialtime ⇒ forTTk ink%foldexponentialtime

slide-71
SLIDE 71

type checking complexity

typechecking typechecking typechecking typechecking

giventransducer andregularGin,Gout, decidewhether(L(Gin))⊆ L(Gout)

  • Gin

Gout

wecantypecheck ⇒ TTk in(k+1)%foldexponentialtime ⇒ Vk%PTT in(k+2)%foldexponentialtime ⇒ VkI%PTT in(k+3)%foldexponentialtime

Vk%PTT ⊆ TTk+1 VkI%PTT ⊆ TTk+2

M(A)⊆Biff A∩M%1(Bc)=∅

‘typechecking’ ‘inversetype inference’

invisiblepebblesarealmostforfree!

slide-72
SLIDE 72

contents

1. automatawithpebbles 2. decomposition 3. typechecking 4. regulartrees 5. documentnavigation 6. patternmatching 7. conclusion

slide-73
SLIDE 73

regular trees

regulartreelanguage ≡ bottom%uptreeevaluation ≡ post%orderevalation withstack

REGT⊆ I%PTA

1 2 3 4 5 1 2 3 4

popchildren evaluate&push postorder evaluation

slide-74
SLIDE 74

regular trees

regulartreelanguage ≡ bottom%uptreeevaluation ≡ post%orderevalation withstack

REGT⊆ I%PTA

VkI%PTT ⊆ TTk+2

VkI%PTA⊆ REGT REGT⊆ Vk%PTA

Bojańczyk etal.

slide-75
SLIDE 75

regular trees

regulartreelanguage ≡ bottom%uptreeevaluation ≡ post%orderevalation withstack

REGT⊆ I%PTA

VkI%PTT ⊆ TTk+2

VkI%PTA⊆ REGT REGT⊆ Vk%PTA

I%PTAcan % evaluatemarked trees % testtheirvisibleconfiguration

slide-76
SLIDE 76

contents

1. automatawithpebbles 2. decomposition 3. typechecking 4. regulartrees 5. documentnavigation 6. patternmatching 7. conclusion

slide-77
SLIDE 77

pattern matching

I%PTAcan % evaluatemarked trees % testtheirvisibleconfiguration

slide-78
SLIDE 78

pattern matching

I%PTAcan % evaluatemarked trees % testtheirvisibleconfiguration

  • bservable

head +invisible

  • ntop

VI%PTAcantestϕ(x1,…,xn) withn%2 visiblepebbles (usinghead)

slide-79
SLIDE 79

pattern matching

generaltestϕ(x1,…,xn)

XQuery for x1,…,xn with ϕ1∧

∧ ∧ ∧… ∧ ∧ ∧ ∧ϕn return t ϕibinary

u1 u5 u2 u3 u6 u4

ϕ1(x1,x2)∧ ∧ ∧ ∧ϕ2(x3,x6)∧ ∧ ∧ ∧ϕ3(x4,x3)∧ ∧ ∧ ∧ϕ4(x5,x6)∧ ∧ ∧ ∧ϕ5(x1,x4)

  • nly2visiblepebbles!

example ϕ3 ϕ4 ϕ2 ϕ5 ϕ1

slide-80
SLIDE 80

contents

1. automatawithpebbles 2. decomposition 3. typechecking 4. documentnavigation 5. patternmatching 6. conclusion

slide-81
SLIDE 81

conclusion

  • MSOcomplete
  • extendsknownmodels

V%PTT I%PTT=TL

DTLdocumenttransformationlanguage Maneth etal.PODS’05

  • invisiblepebblesarecheap

Milo,Suciu,Vianu

slide-82
SLIDE 82

\end{document}