1 / 34

Baumautomaten

Baumautomaten. Christian Klein Betreuer : Tim Priesnitz SS 2003 Seminar “Logische Aspekte von XML”. Gert Smolka Programming Systems Lab Universität des Saarlandes. Übersicht. • Wortautomaten <-> Baumautomaten • Bottom-up und Top-down Automaten Unranked Automaten Tupelautomaten.

estevan
Download Presentation

Baumautomaten

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Baumautomaten Christian Klein Betreuer : Tim Priesnitz SS 2003 Seminar “Logische Aspekte von XML” Gert Smolka Programming Systems Lab Universität des Saarlandes

  2. Übersicht • Wortautomaten <-> Baumautomaten • Bottom-up und Top-down Automaten • Unranked Automaten • Tupelautomaten

  3. Motivation • Endliche Automaten erkennen Bäume nur pfadweise. a -> qa, b -> qb f(qa, qb) -> qfinal, f(qb, qa) -> qfinal f(qa, qa) -> qfalsch, f(qb, qb) -> qfalsch f a b f b a nicht von DEA erkennbar => Baumautomaten

  4. Äquivalente Definition von endlichen Automaten • vorher : Δ Teilmenge von Q x Σ -> Q • jetzt : Δ Teilmenge von Q x Σ -> 2Q p r wird zu : (q, a) -> {p, r} a a q Darstellung: regulärer Ausdruck auf rechter Seite : (q, a) -> p ∪ r Falls q Startzustand (q, a) -> p ∪ r ∪ ε -> Angabe der Startzustände nicht mehr benötigt

  5. Zwei Traversierungsstrategien • klassisch : von vorne nach hinten; akzeptiere wenn am Wortende Endzustand • weitere Strategie : von hinten nach vorne; starte mit Endzuständen und gehe Δ-Regeln rückwärts, akzeptiere wenn ε am Wortanfang a b b q0 q1 a a b q2 q2 (a)-> q1 (b)-> q0 ∪ q1 ∪ q2 (a)->ε∪ q0 ∪ q2 (b)->ε∪ q1 (b)-> q0 ∪ q1 ∪ q2 (a) ->ε∪ q0 ∪ q2

  6. Definition Baumautomat Ein endlicher Baumautomat ist ein Tupel (Q, Σ, F, Δ), mit Alphabet Σ, Zustandsmenge Q, eine Teilmenge F von Q , und Übergangsrelation Δ Die Regeln aus Δ sind von der Form (q0,σ) -> (q11,..., q1n) ∪ ... ∪ (qm1,..., qmn) für arity(σ) = n Baumautomaten gehen zurück auf Doner (1965) und Thatcher & Wright (1965)

  7. Lauf eines Automaten (Q, Σ, F, Δ) • Lauf r auf Baum t ist Funktion Pos(t) -> Q, so dass für alle p aus Pos(t) gilt : Wenn n = arity( t(p) ), r(p) = q0 , r(pi) = qi ( i = 1,...,n ), dann (q0, t(p) ) -> (q1,...,qn)matcht Regel in Δ. • Ein Lauf heißt erfolgreich, wenn r(ε) in F. • Sprache L(M) = { t | t ist Σ-Baum und es gibt erfolgreichen Lauf von M auf t}

  8. Automat und Lauf Σ = {and/2, not/1, 0/0, 1/0} Q = {q0, q1} F={q1} Δ = { (q0, 0) -> ε, (q1,1) -> ε, (q0, not) -> q1, (q1, not) -> q0, (q0, and) -> (q0, q0) ∪ (q0, q1) ∪ (q1, q0) (q1, and) -> (q1, q1) } and and not not 1 0 0 q1 q1 q1 q1 q0 q0 q0

  9. Bottom-up vs. Top-down • Zwei spezielle Strategien Lauf zu berechnen : • von den Blättern zur Wurzel ( Bottom-up ) • F beschreibt Endzustände • von der Wurzel zu den Blättern ( Top-down ) • F beschreibt Startzustände

  10. Bottom-up Berechnung Σ = {and/2, not/1, 0/0, 1/0} Q = {q0, q1} F={q1} Δ = { (q0, 0) -> ε, (q1,1) -> ε, (q0, not) -> q1, (q1, not) -> q0, (q0, and) -> (q0, q0) ∪ (q0, q1) ∪ (q1, q0), (q1, and) -> (q1, q1) } Baum: erfolgreiche Berechnung : and q1 not and q1 q1 0 not 1 q1 q0 q1 0 q0

  11. Alternative algebraische Charakterisierung • Stelle Baum durch Term da • (q0, σ) -> (p1,...,pn) ∪...∪ (q1,..., qn) • wird interpretiert durch Termersetzungsregeln • σ(p1,...,pn) -> q0 • ... • σ(q1,...,qn) -> q0

  12. Lauf durch Termersetzung Δ = { (q0, 0), (q1,1), (q0, not)-> q1, (q1, not)-> q0, (q0, and)-> (q0, q0) ∪ (q0, q1) ∪ (q1, q0), (q1, and)-> (q1, q1) } and( not( and( 1, 1 ) ), and( not( 0 ), 1 ) )

  13. Lauf durch Termersetzung Δ = { (q0, 0), (q1,1), (q0, not)-> q1, (q1, not)-> q0, (q0, and)-> (q0, q0) ∪ (q0, q1) ∪ (q1, q0), (q1, and)-> (q1, q1) } and( not( and( 1, 1 ) ), and( not( 0 ), 1 ) ) -> and( not( and( q1, q1 ) ), and( not( q0) , q1 ) )

  14. Lauf durch Termersetzung Δ = { (q0, 0), (q1,1), (q0, not)-> q1, (q1, not)-> q0, (q0, and)-> (q0, q0) ∪ (q0, q1) ∪ (q1, q0), (q1, and)-> (q1, q1) } and( not( and( 1, 1 ) ), and( not( 0 ), 1 ) ) -> and( not( and( q1, q1 ) ), and( not( q0) , q1 ) ) -> and( not( q1 ) ,and( q1, q1) )

  15. Lauf durch Termersetzung Δ = { (q0, 0), (q1,1), (q0, not)-> q1, (q1, not)-> q0, (q0, and)-> (q0, q0) ∪ (q0, q1) ∪ (q1, q0), (q1, and)-> (q1, q1) } and( not( and( 1, 1 ) ), and( not( 0 ), 1 ) ) -> and( not( and( q1, q1 ) ), and( not( q0) , q1 ) ) -> and( not( q1 ) ,and( q1, q1) ) -> and ( q0, q1)

  16. Lauf durch Termersetzung Δ = { (q0, 0), (q1,1), (q0, not)-> q1, (q1, not)-> q0, (q0, and)-> (q0, q0) ∪ (q0, q1) ∪ (q1, q0), (q1, and)-> (q1, q1) } and( not( and( 1, 1 ) ), and( not( 0 ), 1 ) ) -> and( not( and( q1, q1 ) ), and( not( q0) , q1 ) ) -> and( not( q1 ) ,and( q1, q1) ) -> and ( q0, q1) -> q0 wird also nicht akzeptiert

  17. Deterministische Bottom-up Baumautomaten Definition: Ein Bottom-up Baumautomat heißt deterministisch, wenn es in Δ keine zwei Regeln (qo, σ) -> REGEXP1 ∪ (q1,..., qn) und (p0, σ) -> REGEXP2 ∪ (q1,..., qn) gibt. Satz : Für jede Sprache L, die von einem nichtdeterministischen Bottom-up Automaten erkannt wird, gibt es einen deterministischen Bottom-up Automaten M, so dass L = L(M). (Beweisidee : Teilmengenkonstruktion)

  18. Berechnung bei Top-down Automaten not and and not 1 0 0 q1 q1 q0 q0 q0 q0 q0 q1 q1 q0 q0 q1 q0 q1 ok ok ok ok ok X • det. Bottom-up kann Top-down nichtdet. sein (und umgekehrt!) • Top-down werden genau dieselben Bäume erkannt

  19. Deterministische Top-down Automaten Definition: Ein Top-down Automat heißt deterministisch, wenn es in Δ keine Regel gibt, bei der die rechte Seite mehr als eine Zustandsmenge hat und |F| < 2 . Satz :Es existieren erkennbare Sprachen , die nicht von einem deterministischen Top-down Automat erkannt werden können.

  20. Sprache, die det. Top-down nicht erkannt werden kann not not not and and and 0 1 1 0 1 1 ist in Sprache ist in Sprache ist NICHT in Sprache a a a b b b c d c d c d (0,c) -> ε (1,d) -> ε (1,c) -> ε (0,d) -> ε wird akzeptiert

  21. DEA -> det. Top-down Automaten • Aus DEA M=(Q, Σ, Δ, S, F) (klassische Darstellung) konstruiere Baumautomaten (Q, Σ‘, Δ‘, F‘) mit : • Buchstaben aus Σ -> unäre Funktionssymbole • zusätzliche Konstante # (symbolisiert Wortende) • F‘ = S • Δ‘ = Δ plus Regeln (q, #) für alle q aus F aba a b a #

  22. DEA -> det. Top-down Automaten a b b q0 q1 a a b q2 a q0 b q0 b q1 a q1 b q2 a q1 # q2

  23. Übersicht Sprachenklassen erkennbare Sprachen Sprachen von deterministischen Top-down Automaten DEA/NEA- Sprachen erkennbar = von Bottom-up- oder nicht-deterministischen Top-down Automaten akzeptierte Sprachen

  24. Abschlusseigenschaften Satz: Erkennbare Sprachen sind abgeschlossen unter Schnitt, Vereinigung und Komplementbildung. Satz: Die Menge der Sprachen von det. Top-down Automaten ist abgeschlossen unter Schnitt und Vereinigung.

  25. Entscheidungsprobleme

  26. Unranked Automaten [Thatcher, 1967] • jedes σ aus Σ kann beliebig viele Nachfolger haben • Regeln in Δ beliebige reguläre Ausdrücke (mit Zeichenmenge Q) Automat für boolesche Ausdrücke mit ∧,∨ mit beliebig vielen Kindern : ∨ Σ ={∧,∨,0,1} Q={q0, q1}, F={q1} Δ= { (q0,0) -> ε; (q1,1) -> ε; (q0, ∧) -> (0∪1)*0(0∪1)*; (q1, ∧) -> 1*; (q0, ∨) -> 0*; (q1, ∨) -> (0∪1)*1(0∪1)* } ∨ ∧ ∨ 0 1 0 1 0 q1 q1 q0 q0 q0 q1 q0 q1 q0

  27. XPATH -> Unranked Automat Baue Automat für Anfrage /a//b[/a]//b (/a//b[/a]//b, a) -> Q*(// b[/a]//b)Q* (//b[/a]//b, b) -> Q*(//b[/a]//b)Q* ∪ Q* /a Q* //b Q* ∪ Q* //b Q* /a Q* ∪ Q*(/a//b)Q* (/a//b,a) -> Q* //b Q* (//b,a) -> Q* //b Q* (//b,b) -> Q* (/a,a) -> Q* a a a b b a b a /a//b[/a]//b //b[/a]//b /a //b //b[/a]//b /a //b /a

  28. Unranked Baum -> Binärer Baum • alle Symbole zweistellige Prädikate • # neue Konstante für Blätter • links Unterbäume, rechts nächstes Kind des Vaters a a Kodierung a # a b b a b a b a Dekodierung # b # # b # # a # #

  29. Automaten auf Baumtupeln • Tupel von Zeichen -> binäre Funktionssymbole • ## einzige Konstante f f g b f a ff b a ff ga f bg fg a# ## f a #b ## ba a# ## ## g g ## ## ## ## ## ## b a

  30. Zylindrifikation (an Stelle i) • Tupel um eins erweitern vor i-ter Stelle • Aus (q, s1...si-1si...sk) -> REGEXP1 • für jedes σ aus Σ eine Regel • (q, s1...si-1σsi...sk) -> REGEXP1 • erzeugt evtl. nichtdet. Automaten (nur bei Bottom-up) • Regelmenge wird größer um Faktor | Σ|

  31. Projektion (an Stelle i) • Tupel um eins verkleinern an i-ter Stelle • Aus Regeln (q, s1...si-1σ1si+1...sk) -> REGEXP1 • ... • (q, s1...si-1σmsi+1...sk) -> REGEXPm • wird eine Regel • (q, s1...si-1 si+1...sk) -> REGEXP1 ∪ ... ∪ REGEXPm • erzeugt evtl. nichtdet. Automaten (nur bei Top-down) • Regelmenge wird kleiner

  32. Einfaches Beispiel für Tupelautomaten • Automat, der { [t,t] | t ist Σ-Baum } erkennt • mit Σ = {f/2, g/1, a/1} Q = {q} F = {q} (q, ##) -> ε (q, aa) -> q (q, gg) -> q (q, ff) -> q

  33. Referenzen • H.Comon, M.Dauchet, R.Gilleron, F.Jacquemard, D.Lugiez, S.Tison and M.Tommasi : Tree Automata and its Applications Kap. 1, 3 • Online Version: www . grappa. univ-lille3. fr/ tata • (1997, überarbeitete Fassung 2002) • Frank Neven : Automata Theory for XML researchers, University of Limburg, 2002 • R.Wilhelm, D.Maurer : Übersetzerbau, Springer 1992(2.Version 1997)

  34. ENDE Danke fürs Zuhören!

More Related