Formal Methods for XML: Algorithms & Complexity

Similar documents
Petri Nets. Rebecca Albrecht. Seminar: Automata Theory Chair of Software Engeneering

Finite State Automata and Determinisation

Bisimulation, Games & Hennessy Milner logic

Regular languages refresher

Technische Universität München Winter term 2009/10 I7 Prof. J. Esparza / J. Křetínský / M. Luttenberger 11. Februar Solution

Foundations of XML Types: Tree Automata

CS 573 Automata Theory and Formal Languages

Nondeterministic Automata vs Deterministic Automata

Nondeterministic Finite Automata

Abstraction of Nondeterministic Automata Rong Su

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

Prefix-Free Regular-Expression Matching

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS

CS 275 Automata and Formal Language Theory

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA

Java II Finite Automata I

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

State Complexity of Union and Intersection of Binary Suffix-Free Languages

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

Good-for-Games Automata versus Deterministic Automata.

NON-DETERMINISTIC FSA

CS 275 Automata and Formal Language Theory

Supervisory Control under Partial Observation

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

Coalgebra, Lecture 15: Equations for Deterministic Automata

Alpha Algorithm: A Process Discovery Algorithm

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Hybrid Systems Modeling, Analysis and Control

Counting Paths Between Vertices. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs

Non-deterministic Finite Automata

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Compression of Palindromes and Regularity.

Theory of Computation Regular Languages

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides.

Streamed Validation of XML Documents

System Validation (IN4387) November 2, 2012, 14:00-17:00

Minimal DFA. minimal DFA for L starting from any other

XPath Node Selection over Grammar-Compressed Trees

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

where the box contains a finite number of gates from the given collection. Examples of gates that are commonly used are the following: a b

Non Deterministic Automata. Formal Languages and Automata - Yonsei CS 1

Laboratory for Foundations of Computer Science. An Unfolding Approach. University of Edinburgh. Model Checking. Javier Esparza

On Determinisation of History-Deterministic Automata.

More on automata. Michael George. March 24 April 7, 2014

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

XML and Databases. Outline. 1. Top-Down Evaluation of Simple Paths. 1. Top-Down Evaluation of Simple Paths. 1. Top-Down Evaluation of Simple Paths

= state, a = reading and q j

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Project 6: Minigoals Towards Simplifying and Rewriting Expressions

SEMANTIC ANALYSIS PRINCIPLES OF PROGRAMMING LANGUAGES. Norbert Zeh Winter Dalhousie University 1/28

1.4 Nonregular Languages

CMSC 330: Organization of Programming Languages

Non-Deterministic Finite Automata

CS 275 Automata and Formal Language Theory

Regular expressions, Finite Automata, transition graphs are all the same!!

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Strong Bisimulation. Overview. References. Actions Labeled transition system Transition semantics Simulation Bisimulation

Chapter 2 Finite Automata

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model?

Formal Languages and Automata

@#? Text Search ] { "!" Nondeterministic Finite Automata. Transformation NFA to DFA and Simulation of NFA. Text Search Using Automata

Automatic Synthesis of New Behaviors from a Library of Available Behaviors

Complementing Büchi Automata

Chapter 3. Vector Spaces. 3.1 Images and Image Arithmetic

Propositional models. Historical models of computation. Application: binary addition. Boolean functions. Implementation using switches.

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

Logic Synthesis and Verification

2.4 Theoretical Foundations

Graph States EPIT Mehdi Mhalla (Calgary, Canada) Simon Perdrix (Grenoble, France)

Fundamentals of Computer Science

Chapter 4 State-Space Planning

Lecture 6 Regular Grammars

Finite-State Automata: Recap

CS 2204 DIGITAL LOGIC & STATE MACHINE DESIGN SPRING 2014

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Discrete Structures, Test 2 Monday, March 28, 2016 SOLUTIONS, VERSION α

Learning Moore Machines from Input-Output Traces

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

Global alignment. Genome Rearrangements Finding preserved genes. Lecture 18

Metodologie di progetto HW Technology Mapping. Last update: 19/03/09

Math 32B Discussion Session Week 8 Notes February 28 and March 2, f(b) f(a) = f (t)dt (1)

Non-deterministic Finite Automata

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

Unit 4. Combinational Circuits

Automata and Languages

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

Algorithms & Data Structures Homework 8 HS 18 Exercise Class (Room & TA): Submitted by: Peer Feedback by: Points:

Behavior Composition in the Presence of Failure

Automata and Regular Languages

Hardware Verification 2IMF20

Alpha Algorithm: Limitations

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

Designing finite automata II

CS 188 Introduction to Artificial Intelligence Fall 2018 Note 7

XML and Databases. Lecture 5 XML Validation using Automata. Sebastian Maneth NICTA and UNSW

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa

Transcription:

Forml Methods for XML: Algorithms & Complexity S. Mrgherit di Pul August 2004 Thoms Shwentik

Shwentik XML: Algorithms & Complexity Introdution 1 XML Exmple Doument Composer Nme Clude Debussy /Nme Vit Born When August 22, 1862 /When Where Pris /Where /Born Mrried When Otober 1899 /When Whom Roslie /Whom /Mrried Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Died When Mrh 25, 1918 /When Where Pris /Where /Died /Vit Piee PTitle L Mer /PTitle PYer 1905 /PYer Instruments Lrge orhestr /Instruments Movements 3 /Movements... /Piee... /Composer...

Shwentik XML: Algorithms & Complexity Introdution 1 XML Exmple Tree Nme Clude Debussy Born When 1862 Where Pris Composer Vit Mrried Mrried When 1899 Whom Roslie When 1908 Whom Emm Died When 1918 Where Pris PTitle L Mer Piee PYer 1905 Instruments Lrge orhestr Movements 3

Shwentik XML: Algorithms & Complexity Introdution 2 XML Proessing Four importnt kinds of XML proessing Vlidtion Chek whether n XML doument is of given type Nvigtion Selet set of positions in n XML doument Querying Extrt informtion from n XML doument Trnsformtion Construt new XML doument from given one

Shwentik XML: Algorithms & Complexity Introdution 2 XML Proessing Four importnt kinds of XML proessing.......... nd their lnguges Vlidtion DTD, XML Shem Chek whether n XML doument is of given type Nvigtion XPth Selet set of positions in n XML doument Querying XQuery Extrt informtion from n XML doument Trnsformtion XSLT Construt new XML doument from given one

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 3 Vlidtion: DTD Exmple doument Composer Nme Clude Debussy /Nme Vit Born When August 22, 1862 /When Where Pris /Where /Born Mrried When Otober 1899 /When Whom Roslie /Whom /Mrried Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Died When Mrh 25, 1918 /When Where Pris /Where /Died /Vit Piee PTitle L Mer /PTitle PYer 1905 /PYer Instruments Lrge orhestr /Instruments Movements 3 /Movements... /Piee... /Composer...

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 3 Vlidtion: DTD Exmple doument DTD DTDs desribe types of XML douments Composer Nme Clude Debussy /Nme Vit Born When August 22, 1862 /When Where Pris /Where /Born Mrried When Otober 1899 /When Whom Roslie /Whom /Mrried Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Died When Mrh 25, 1918 /When Where Pris /Where /Died /Vit Piee PTitle L Mer /PTitle PYer 1905 /PYer Instruments Lrge orhestr /Instruments Movements 3 /Movements... /Piee... /Composer...

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 3 Vlidtion: DTD Exmple doument Composer Nme Clude Debussy /Nme Vit Born When August 22, 1862 /When Where Pris /Where /Born Mrried When Otober 1899 /When Whom Roslie /Whom /Mrried Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Died When Mrh 25, 1918 /When Where Pris /Where /Died /Vit Piee PTitle L Mer /PTitle PYer 1905 /PYer Instruments Lrge orhestr /Instruments Movements 3 /Movements... /Piee... /Composer... DTD DTDs desribe types of XML douments Exmple <!DOCTYPE Composers [ <!ELEMENT Composers (Composer*)> <!ELEMENT Composer (Nme, Vit, Piee*)> <!ELEMENT Vit (Born, Mrried*, Died?)> <!ELEMENT Born (When, Where)> <!ELEMENT Mrried (When, Whom)> <!ELEMENT Died (When, Where)> <!ELEMENT Piee (PTitle, PYer, Instruments, Movements)> ]>

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 4 Nvigtion: XPth Exmple doument Composer Nme Clude Debussy /Nme Vit Born When August 22, 1862 /When Where Pris /Where /Born Mrried When Otober 1899 /When Whom Roslie /Whom /Mrried Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Died When Mrh 25, 1918 /When Where Pris /Where /Died /Vit Piee PTitle L Mer /PTitle PYer 1905 /PYer Instruments Lrge orhestr /Instruments Movements 3 /Movements... /Piee... /Composer...

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 4 Composer Nme Clude Debussy /Nme Vit Nvigtion: XPth XPth XPth expressions selet sets of nodes of Exmple doument XML douments by speifying nvigtionl ptterns Born When August 22, 1862 /When Where Pris /Where /Born Mrried When Otober 1899 /When Whom Roslie /Whom /Mrried Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Died When Mrh 25, 1918 /When Where Pris /Where /Died /Vit Piee PTitle L Mer /PTitle PYer 1905 /PYer Instruments Lrge orhestr /Instruments Movements 3 /Movements... /Piee... /Composer...

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 4 Composer Nme Clude Debussy /Nme Vit Nvigtion: XPth Born When August 22, 1862 /When Where Pris /Where /Born Mrried When Otober 1899 /When Whom Roslie /Whom /Mrried Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Died When Mrh 25, 1918 /When Where Pris /Where /Died /Vit Piee PTitle L Mer /PTitle PYer 1905 /PYer Instruments Lrge orhestr /Instruments Movements 3 /Movements... /Piee... /Composer... XPth XPth expressions selet sets of nodes of Exmple doument XML douments by speifying nvigtionl ptterns Exmple query //Vit/Died/*

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 4 Composer Nme Clude Debussy /Nme Vit Nvigtion: XPth Born When August 22, 1862 /When Where Pris /Where /Born Mrried When Otober 1899 /When Whom Roslie /Whom /Mrried Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Died When Mrh 25, 1918 /When Where Pris /Where /Vit Piee PTitle L Mer /PTitle PYer 1905 /PYer Instruments Lrge orhestr /Instruments Movements 3 /Movements... /Piee... /Composer... XPth XPth expressions selet sets of nodes of Exmple doument XML douments by speifying nvigtionl ptterns /Died Exmple query //Vit/Died/*

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 5 Querying: XQuery Exmple doument Composer Nme Clude Debussy /Nme Vit Born When August 22, 1862 /When Where Pris /Where /Born Mrried When Otober 1899 /When Whom Roslie /Whom /Mrried Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Died When Mrh 25, 1918 /When Where Pris /Where /Died /Vit Piee PTitle L Mer /PTitle PYer 1905 /PYer Instruments Lrge orhestr /Instruments Movements 3 /Movements... /Piee... /Composer...

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 5 Querying: XQuery Exmple doument XQuery XQuery is full-fledged XML query lnguge Composer Nme Clude Debussy /Nme Vit Born When August 22, 1862 /When Where Pris /Where /Born Mrried When Otober 1899 /When Whom Roslie /Whom /Mrried Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Died When Mrh 25, 1918 /When Where Pris /Where /Died /Vit Piee PTitle L Mer /PTitle PYer 1905 /PYer Instruments Lrge orhestr /Instruments Movements 3 /Movements... /Piee... /Composer...

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 5 Querying: XQuery Exmple doument Composer Nme Clude Debussy /Nme Vit Born When August 22, 1862 /When Where Pris /Where /Born Mrried When Otober 1899 /When Whom Roslie /Whom /Mrried Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Died When Mrh 25, 1918 /When Where Pris /Where /Died /Vit Piee PTitle L Mer /PTitle PYer 1905 /PYer Instruments Lrge orhestr /Instruments Movements 3 /Movements... /Piee... /Composer... XQuery XQuery is full-fledged XML query lnguge Exmple query for $x in do( omposers.xml )/Composer where $x/vit/died/where = Pris return $x/nme

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 5 Querying: XQuery Exmple doument Composer Nme Hetor Berlioz /Nme Nme Clude Debussy /Nme Nme Cmille Sint-Sëns /Nme Vit Nme Born Frédéri When August Chopin 22, /Nme 1862 /When Where Pris /Where /Born Nme Mrried When Murie Rvel Otober /Nme 1899 /When Whom Roslie /Whom /Mrried Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Nme Jim Morrison /Nme Died When Mrh 25, 1918 /When Where Pris /Where /Died Nme /Vit Césr Frnk /Nme Nme Piee Gbriel Furé /Nme Nme PTitle George L Mer Bizet /PTitle /Nme PYer 1905 /PYer Instruments Lrge orhestr /Instruments Movements 3 /Movements... /Piee... /Composer... Result Nme Clude Debussy /Nme Nme Eri Stie /Nme... XQuery XQuery is full-fledged XML query lnguge Exmple query for $x in do( omposers.xml )/Composer where $x/vit/died/where = Pris return $x/nme

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 6 Trnsformtion: XSLT Exmple doument Composer Nme Clude Debussy /Nme Vit Born When August 22, 1862 /When Where Pris /Where /Born Mrried When Otober 1899 /When Whom Roslie /Whom /Mrried Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Died When Mrh 25, 1918 /When Where Pris /Where /Died /Vit Piee PTitle L Mer /PTitle PYer 1905 /PYer Instruments Lrge orhestr /Instruments Movements 3 /Movements... /Piee... /Composer...

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 6 Trnsformtion: XSLT XSLT XSLT trnsforms douments by Exmple doument mens of templtes Composer Nme Clude Debussy /Nme Vit Born When August 22, 1862 /When Where Pris /Where /Born Mrried When Otober 1899 /When Whom Roslie /Whom /Mrried Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Died When Mrh 25, 1918 /When Where Pris /Where /Died /Vit Piee PTitle L Mer /PTitle PYer 1905 /PYer Instruments Lrge orhestr /Instruments Movements 3 /Movements... /Piee... /Composer...

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 6 Trnsformtion: XSLT XSLT XSLT trnsforms douments by Exmple doument mens of templtes Composer Nme Clude Debussy /Nme Vit Born When August 22, 1862 /When Where Pris /Where /Born Mrried When Otober 1899 /When Whom Roslie /Whom /Mrried Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Died When Mrh 25, 1918 /When Where Pris /Where /Died /Vit Piee PTitle L Mer /PTitle PYer 1905 /PYer Instruments Lrge orhestr /Instruments Movements 3 /Movements... /Piee... /Composer... Exmple xsl:templte mth= Composer[Vit//Where= Pris ] PrisComposer xsl:opy-of selet= Nme / xsl:opy-of selet= Vit/Born / /PrisComposer /xsl:templte

Result Trnsformtion: XSLT XSLT XSLT trnsforms douments by Exmple doument mens of templtes PrisComposer Nme Clude Debussy /Nme Composer Born Nme When Clude August Debussy 22, 1862 /Nme /When Vit Where Pris /Where /Born Born When August 22, 1862 /When Where Pris /Where /Born /PrisComposer Mrried When Otober 1899 /When Whom Roslie /Whom /Mrried PrisComposer Mrried When Jnury 1908 /When Whom Emm /Whom /Mrried Nme Died When FrédériMrh Chopin 25, /Nme 1918 /When Where Pris /Where /Died /Vit Born Piee When Mrh 1, 1810 /When PTitle Where LŽelzow Mer /PTitle /Where /Born PYer 1905 /PYer Exmple /PrisComposer Instruments Lrge orhestr /Instruments PrisComposer Movements 3 /Movements Nme... Cmille Sint-Sëns /Nme PrisComposer /Piee Born xsl:opy-of selet= Nme /... When Otober 9, 1835 /When xsl:opy-of selet= Vit/Born / /Composer Where Pris /Where /PrisComposer... /Born /xsl:templte /PrisComposer xsl:templte mth= Composer[Vit//Where= Pris ] Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 6

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 7 A Shemti View DTD/ XML Shem XPth yes/no XQuery XSLT

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 8 Fous of this Tlk Topis Expressive power of XML lnguges Complexity of lgorithmi tsks relted to XML proessing Trdeoff between expressiveness nd omplexity Gols of this Reserh Understnd expressive power nd omplexity of XML lnguges Identify interesting frgments with good trdeoff

Algorithmi Tsks Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 9

Evlution Evlution (Combined) I: Tree t, Query q O: q(t) Algorithmi Tsks Stti Anlysis Stisfibility I: Query q Q: Is q(t) for some t? Evlution (Dt(q)) I: Tree t O: q(t) Inrementl Evl. (q) I: Tree t, Chnges of t O: q(t) Continment I: Queries q 1, q 2 Q: Is lwys q 1 (t) q 2 (t)? Type Cheking I: Types d 1, d 2, Trnsformtion T Q: Does t = d 1 imply T (t) = d 2? Equivlene I: Queries q 1, q 2 Q: Is lwys q 1 (t) = q 2 (t)? Type Inferene Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 10

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 11 Expressive power Question: How do we mesure expressive power? Remrks Clsses of logil formuls re good yrdstik They provide methods to prove tht query n not be expressed

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 11 Expressive power Question: How do we mesure expressive power? Remrks Clsses of logil formuls re good yrdstik They provide methods to prove tht query n not be expressed Rell Reltionl Dtbses Core of SQL First-order Logi Most frequently sked queries Conjuntive queries

Contents Introdution Bkground on Tree Automt nd Logi Shem Lnguges XPth nd Node-seleting Queries XSLT XQuery Conlusion

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 13 Deidble Bkground: Complexity Clsses Overview of Complexity Clsses EXPSPACE EXPTIME PSPACE...... Equivlene of reg. expressions with squring.......................... 2-Plyer Corridor Tiling..................... Quntified Boolen Formuls onp NP.................... Stisfibility of prop. formuls P NC LOGCFL NL LOGSPACE........................ Boolen iruit evlution................. Effiiently prllelizble problems....................... Ayli onjuntive queries................... Rehbility in direted grphs................... Rehbility in direted forests

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 14 XML, Trees nd Automt Question: Why is XML ppeling for Theory people?

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 14 XML, Trees nd Automt Question: Why is XML ppeling for Theory people? Yers go... Theoretil Computer Siene for Dtbse Theorists: Logis, Complexity, Algorithms,... Dtbse Theory for Theoretil Computer Sientists:

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 14 XML, Trees nd Automt Question: Why is XML ppeling for Theory people? Yers go... Theoretil Computer Siene for Dtbse Theorists: Logis, Complexity, Algorithms,... Dtbse Theory for Theoretil Computer Sientists: terr inognit

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 14 XML, Trees nd Automt Question: Why is XML ppeling for Theory people? Yers go... Theoretil Computer Siene for Dtbse Theorists: Logis, Complexity, Algorithms,... Dtbse Theory for Theoretil Computer Sientists: terr inognit After the dvent of XML Mny onnetions between Forml Lnguges & Automt Theory nd XML & Dtbse Theory

XML, Trees nd Automt Question: Why trees? Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 15

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 15 XML, Trees nd Automt Question: Why trees? A Nturl Answer Trees reflet the hierrhil struture of XML Underlying dt model of XML is tree bsed

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 15 XML, Trees nd Automt Question: Why trees? A Nturl Answer Trees reflet the hierrhil struture of XML Underlying dt model of XML is tree bsed Limittions But trees n not model ll spets of XML (e.g., IDREFs, dt vlues) Sometimes extensions re needed E.g., direted grphs insted of trees

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 15 XML, Trees nd Automt Question: Why trees? A Nturl Answer Trees reflet the hierrhil struture of XML Underlying dt model of XML is tree bsed Limittions But trees n not model ll spets of XML (e.g., IDREFs, dt vlues) Sometimes extensions re needed E.g., direted grphs insted of trees Exmple

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 15 XML, Trees nd Automt Question: Why trees? A Nturl Answer Trees reflet the hierrhil struture of XML Underlying dt model of XML is tree bsed Limittions But trees n not model ll spets of XML (e.g., IDREFs, dt vlues) Sometimes extensions re needed E.g., direted grphs insted of trees Exmple

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 15 XML, Trees nd Automt Question: Why trees? A Nturl Answer Trees reflet the hierrhil struture of XML Underlying dt model of XML is tree bsed Limittions But trees n not model ll spets of XML (e.g., IDREFs, dt vlues) Sometimes extensions re needed E.g., direted grphs insted of trees Exmple Nevertheless In this tutoril we will onentrte on the tree view t XML

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 16 XML, Trees nd Automt Question: Why utomt? Ingredients of XML Conepts from forml lnguges re obviously present round XML: Lbelled trees DTD: ontext-free grmmrs DTD: regulr expressions XPth: regulr pth expressions We will see Automt turn out to be useful s: mens to define robust lsses with ler semntis tool for proofs n lgorithmi tool for stti nlysis tool for query evlution

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 16 XML, Trees nd Automt Question: Why utomt? Ingredients of XML Conepts from forml lnguges re obviously present round XML: Lbelled trees DTD: ontext-free grmmrs DTD: regulr expressions XPth: regulr pth expressions We will see Automt turn out to be useful s: mens to define robust lsses with ler semntis tool for proofs n lgorithmi tool for stti nlysis tool for query evlution

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 16 XML, Trees nd Automt Question: Why utomt? Ingredients of XML Conepts from forml lnguges re obviously present round XML: Lbelled trees DTD: ontext-free grmmrs DTD: regulr expressions XPth: regulr pth expressions We will see Automt turn out to be useful s: mens to define robust lsses with ler semntis tool for proofs n lgorithmi tool for stti nlysis tool for query evlution

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 16 XML, Trees nd Automt Question: Why utomt? Ingredients of XML Conepts from forml lnguges re obviously present round XML: Lbelled trees DTD: ontext-free grmmrs DTD: regulr expressions XPth: regulr pth expressions We will see Automt turn out to be useful s: mens to define robust lsses with ler semntis tool for proofs n lgorithmi tool for stti nlysis tool for query evlution

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 16 XML, Trees nd Automt Question: Why utomt? Ingredients of XML Conepts from forml lnguges re obviously present round XML: Lbelled trees DTD: ontext-free grmmrs DTD: regulr expressions XPth: regulr pth expressions We will see Automt turn out to be useful s: mens to define robust lsses with ler semntis tool for proofs n lgorithmi tool for stti nlysis tool for query evlution

Introdution Contents Bkground on Tree Automt nd Logi Prllel Rnked Tree Automt Sequentil Rnked Tree Automt Deision Problems for Rnked Tree Automt Prllel Unrnked Tree Automt Sequentil Unrnked Tree Automt Sequentil Doument Automt Shem Lnguges XPth nd Node-seleting Queries XSLT XQuery Conlusion

From Strings to Trees A String bb Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 18

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 18 String s Tree From Strings to Trees A String bb b b

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 18 String s Tree b From Strings to Trees A String bb A Rnked Tree b b b b b

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 18 String s Tree From Strings to Trees A String bb A Rnked Tree An Unrnked Tree b b e e e e b e e e e b b b e e e

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 19 From Strings to Trees (ont.) XML nd Trees XML trees re unrnked : the number of hildren of node is not restrited Automt hve first been onsidered on rnked trees, where eh symbol hs fixed number of hildren (rnk) Most importnt ides were lredy developed for rnked trees Let us tke look t this first

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 20 Trees s Terms Remrk Sometimes trees re viewed s terms b Exmple b Exmple Tree s Term 1 (b 2 ( 1 ( 2 (b, )), b 2 ( 2 (b, ), ))) b b

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21 From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e

From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21 From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21 From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21 From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21 From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21 From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21 From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21 From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21 From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21 From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e

From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21 From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21 From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21 From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21 From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 21 From String Automt to Tree Automt Question How do utomt generlize to trees? Sequentil e Prllel e e e e e e e

Bottom-Up Automt Exmple: Tree-strutured Boolen Ciruits 0 1 1 0 0 1 1 1 Ide Tree-strutured Boolen iruits Two sttes: q 0, q 1 Aepting t the root: q 1 Trnsitions δ(, q 1 ) = {(q 1, q 1 )} δ(, q 0 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 0, q 0 )} δ(, q 1 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 1, q 1 )} δ(, q 0 ) = {(q 0, q 0 )} δ(0, q 0 ) = {ɛ}; δ(0, q 1 ) = δ(1, q 1 ) = {ɛ}; δ(1, q 0 ) = Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 22

Bottom-Up Automt Exmple: Tree-strutured Boolen Ciruits 0 q 0 1 q 1 1 q 1 0 q 0 0 q 0 1 q 1 1 q 1 1 q 1 Ide Tree-strutured Boolen iruits Two sttes: q 0, q 1 Aepting t the root: q 1 Trnsitions δ(, q 1 ) = {(q 1, q 1 )} δ(, q 0 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 0, q 0 )} δ(, q 1 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 1, q 1 )} δ(, q 0 ) = {(q 0, q 0 )} δ(0, q 0 ) = {ɛ}; δ(0, q 1 ) = δ(1, q 1 ) = {ɛ}; δ(1, q 0 ) = Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 22

Bottom-Up Automt Exmple: Tree-strutured Boolen Ciruits q 0 q 1 q 1 q 1 0 q 0 1 q 1 1 q 1 0 q 0 0 q 0 1 q 1 1 q 1 1 q 1 Ide Tree-strutured Boolen iruits Two sttes: q 0, q 1 Aepting t the root: q 1 Trnsitions δ(, q 1 ) = {(q 1, q 1 )} δ(, q 0 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 0, q 0 )} δ(, q 1 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 1, q 1 )} δ(, q 0 ) = {(q 0, q 0 )} δ(0, q 0 ) = {ɛ}; δ(0, q 1 ) = δ(1, q 1 ) = {ɛ}; δ(1, q 0 ) = Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 22

Bottom-Up Automt Exmple: Tree-strutured Boolen Ciruits q 1 q 1 q 0 q 1 q 1 q 1 0 q 0 1 q 1 1 q 1 0 q 0 0 q 0 1 q 1 1 q 1 1 q 1 Ide Tree-strutured Boolen iruits Two sttes: q 0, q 1 Aepting t the root: q 1 Trnsitions δ(, q 1 ) = {(q 1, q 1 )} δ(, q 0 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 0, q 0 )} δ(, q 1 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 1, q 1 )} δ(, q 0 ) = {(q 0, q 0 )} δ(0, q 0 ) = {ɛ}; δ(0, q 1 ) = δ(1, q 1 ) = {ɛ}; δ(1, q 0 ) = Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 22

Bottom-Up Automt Exmple: Tree-strutured Boolen Ciruits q 1 q 1 q 1 q 0 q 1 q 1 q 1 0 q 0 1 q 1 1 q 1 0 q 0 0 q 0 1 q 1 1 q 1 1 q 1 Ide Tree-strutured Boolen iruits Two sttes: q 0, q 1 Aepting t the root: q 1 Trnsitions δ(, q 1 ) = {(q 1, q 1 )} δ(, q 0 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 0, q 0 )} δ(, q 1 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 1, q 1 )} δ(, q 0 ) = {(q 0, q 0 )} δ(0, q 0 ) = {ɛ}; δ(0, q 1 ) = δ(1, q 1 ) = {ɛ}; δ(1, q 0 ) = Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 22

Non-det. Top-Down Automt Exmple 0 1 1 0 0 1 1 1 Ide Guess the orret vlues strting from the root Chek t the leves Three sttes: q 0, q 1, Initil stte q 1 t the root Aepting if ll leves end in Trnsitions δ(, q 1 ) = {(q 1, q 1 )} δ(, q 0 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 0, q 0 )} δ(, q 1 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 1, q 1 )} δ(, q 0 ) = {(q 0, q 0 )} δ(0, q 0 ) = {}; δ(0, q 1 ) = δ(1, q 1 ) = {}; δ(1, q 0 ) = Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 23

Non-det. Top-Down Automt Exmple q 1 0 1 1 0 0 1 1 1 Ide Guess the orret vlues strting from the root Chek t the leves Three sttes: q 0, q 1, Initil stte q 1 t the root Aepting if ll leves end in Trnsitions δ(, q 1 ) = {(q 1, q 1 )} δ(, q 0 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 0, q 0 )} δ(, q 1 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 1, q 1 )} δ(, q 0 ) = {(q 0, q 0 )} δ(0, q 0 ) = {}; δ(0, q 1 ) = δ(1, q 1 ) = {}; δ(1, q 0 ) = Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 23

Non-det. Top-Down Automt Exmple q 1 q 1 q 1 0 1 1 0 0 1 1 1 Ide Guess the orret vlues strting from the root Chek t the leves Three sttes: q 0, q 1, Initil stte q 1 t the root Aepting if ll leves end in Trnsitions δ(, q 1 ) = {(q 1, q 1 )} δ(, q 0 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 0, q 0 )} δ(, q 1 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 1, q 1 )} δ(, q 0 ) = {(q 0, q 0 )} δ(0, q 0 ) = {}; δ(0, q 1 ) = δ(1, q 1 ) = {}; δ(1, q 0 ) = Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 23

Non-det. Top-Down Automt Exmple q 1 q 1 q 1 q 0 q 1 q 1 q 1 0 1 1 0 0 1 1 1 Ide Guess the orret vlues strting from the root Chek t the leves Three sttes: q 0, q 1, Initil stte q 1 t the root Aepting if ll leves end in Trnsitions δ(, q 1 ) = {(q 1, q 1 )} δ(, q 0 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 0, q 0 )} δ(, q 1 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 1, q 1 )} δ(, q 0 ) = {(q 0, q 0 )} δ(0, q 0 ) = {}; δ(0, q 1 ) = δ(1, q 1 ) = {}; δ(1, q 0 ) = Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 23

Non-det. Top-Down Automt Exmple q 1 q 1 q 1 q 0 q 1 q 1 q 1 0 q 0 1 q 1 1 q 1 0 q 0 0 q 0 1 q 1 1 q 1 1 q 1 Ide Guess the orret vlues strting from the root Chek t the leves Three sttes: q 0, q 1, Initil stte q 1 t the root Aepting if ll leves end in Trnsitions δ(, q 1 ) = {(q 1, q 1 )} δ(, q 0 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 0, q 0 )} δ(, q 1 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 1, q 1 )} δ(, q 0 ) = {(q 0, q 0 )} δ(0, q 0 ) = {}; δ(0, q 1 ) = δ(1, q 1 ) = {}; δ(1, q 0 ) = Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 23

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 23 Non-det. Top-Down Automt Exmple q 1 q 1 q 1 q 0 q 1 q 1 q 1 0 q 0 1 q 1 1 q 1 0 q 0 0 q 0 1 q 1 1 q 1 1 q 1 Ide Guess the orret vlues strting from the root Chek t the leves Three sttes: q 0, q 1, Initil stte q 1 t the root Aepting if ll leves end in Trnsitions δ(, q 1 ) = {(q 1, q 1 )} δ(, q 0 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 0, q 0 )} δ(, q 1 ) = {(q 0, q 1 ), (q 1, q 0 ), (q 1, q 1 )} δ(, q 0 ) = {(q 0, q 0 )} δ(0, q 0 ) = {}; δ(0, q 1 ) = δ(1, q 1 ) = {}; δ(1, q 0 ) =

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 24 Regulr Tree Lnguges Definition A bottom-up utomton is deterministi if for eh nd p q: δ(, p) δ(, q) = Theorem The following re equivlent for tree lnguge L: () L is epted by nondeterministi bottom-up utomton (b) L is epted by deterministi bottom-up utomton () L is epted by nondeterministi top-down utomton Proof ide () = (b): Powerset onstrution () (): Just the sme thing, viewed in two different wys

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 25 Automt s Tiling Systems Observtion (q 0, q 1 ) δ(, q 1 ) n be interpreted s n llowed pttern:, q 1 q 0 q 1 A tree is epted, iff there is lbelling with sttes suh tht ll lol ptterns re llowed the root is lbelled with q 1

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 25 Automt s Tiling Systems Observtion (q 0, q 1 ) δ(, q 1 ) n be interpreted s n llowed pttern:, q 1 q 0 q 1 A tree is epted, iff there is lbelling with sttes suh tht ll lol ptterns re llowed the root is lbelled with q 1 Exmple 0 1 1 0 0 1 1 1

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 25 Automt s Tiling Systems Observtion (q 0, q 1 ) δ(, q 1 ) n be interpreted s n llowed pttern:, q 1 q 0 q 1 A tree is epted, iff there is lbelling with sttes suh tht ll lol ptterns re llowed the root is lbelled with q 1 Exmple q 1 q 1 q 1 q 0 q 1 q 1 q 1 0 q 0 1 q 1 1 q 1 0 q 0 0 q 0 1 q 1 1 q 1 1 q 1

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 26 Formuls tlk bout Regulr tree lnguges nd logi edges of the tree (E) node lbels (Q 0, Q 1, Q, Q ) the root of the tree (root) Definition: (MSO logi) First-order-vribles represent nodes Mondi seond-order (MSO) vribles represent sets of nodes Exmple: Boolen Ciruits Boolen iruit true X X(root) x (Q 0 (x) X(x)) ((Q (x) X(x)) ( y[e(x, y) X(y)])) ((Q (x) X(x)) ( y[e(x, y) X(y)])) Theorem [Doner 70; Thther, Wright 68] MSO Regulr Tree Lnguges

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 27 Regulr tree lnguges nd logi (ont.) Theorem MSO Regulr Tree Lnguges Proof ide Automt MSO: Formul expresses tht there exists orret tiling MSO Automt: more involved Bsi ide: Automton omputes for eh node v the set of formuls whih hold in the subtree rooted t v

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 28 Regulr tree lnguges nd logi (ont.) Formul utomton Let ϕ be n MSO-formul, k := quntifier-depth of ϕ k-type of tree t := (essentilly) set of MSO-formuls ψ of quntifier-depth k whih hold in t t 1 k t 2 : k-type(t 1 ) = k-type(t 2 ) Automton omputes k-type of tree nd onludes whether ϕ holds Cruil ft l l t 1 k t 1 = t 1 t 2 k t 1 t 2 t 2 k t 2

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 29 Det. Top-Down Automt Question Wht is the right notion for deterministi top-down utomt? 3 Possibilities Stte t node v might depend on stte nd symbol of prent q stte nd symbol of prent nd symbol of v v q stte nd symbol of prent nd symbols t v nd its sibling v q v e

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 30 Det. Top-Down Automt: Aeptne Question Wht is good eptne mehnism for deterministi top-down utomt? Severl possibilitites (1) At ll leves sttes hve to be epting (2) There is leve with n epting stte (2) is problemti for omplement nd intersetion (1) is problemti for omplement nd union

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 31 Det. Top-Down Automt: Aeptne (ont.) Definition: (Root-to-frontier utomt with regulr eptne ondition) Tree utomt A re equipped with n dditionl regulr string lnguge L over Q Σ A epts t if the (stte,symbol)-string t the leves (from left to right) is in L [Jurvnen, Potthoff, Thoms 93] Illustrtion (q 1, 1 ) (q n, n ) A robust lss The resulting lss is losed under Boolen opertions Good lgorithmi properties Does not pture ll regulr tree lnguges

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 32 Summry Regulr tree lnguges Regulr tree lnguges re robust lss Chrterized by prllel tree utomt MSO logi severl other models They re the nturl nlog of regulr string lnguges Deterministi top-down utomt with regulr eptne onditions define weker but nevertheless robust lss

Introdution Contents Bkground on Tree Automt nd Logi Prllel Rnked Tree Automt Sequentil Rnked Tree Automt Deision Problems for Rnked Tree Automt Prllel Unrnked Tree Automt Sequentil Unrnked Tree Automt Sequentil Doument Automt Shem Lnguges XPth nd Node-seleting Queries XSLT XQuery Conlusion

Tree-Wlk Automt Definition: (Tree-wlk utomt) Depending on urrent stte symbol of urrent node r TWA T e position of urrent node wrt its siblings e A u t the utomton moves to neighbor nd tkes new stte o s Question Wht is the expressive power of tree-wlk utomt? Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 34

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple Ide q 0 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 1 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 1 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 1 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 1 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 1 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 1 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 1 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 1 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Tree-Wlk Automt (ont.) Ft Tree-wlk utomt n evlute Boolen iruit trees 5 sttes Exmple q 1 0 Ide q 0 1 q 1 1 0 0 1 1 0 0 1 1 1 Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 35

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 36 A Reent Result nd n Even More Reent Result Theorem [Bojnzyk, Colombet 04] Deterministi TWAs re weker thn nondeterministi TWAs Corollry Deterministi TWAs do not pture ll regulr tree lnguges Theorem [Bojnzyk, Colombet 04] Nondeterministi TWAs do not pture ll regulr tree lnguges

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 37 Overview of Models Non-det. top-down tree utomt Non-det. bottom-up tree utomt Det. bottom-up tree utomt Non-det. tree wlk utomt Det. top-down tree utomt Det. tree wlk utomt

Introdution Contents Bkground on Tree Automt nd Logi Prllel Rnked Tree Automt Sequentil Rnked Tree Automt Deision Problems for Rnked Tree Automt Prllel Unrnked Tree Automt Sequentil Unrnked Tree Automt Sequentil Doument Automt Shem Lnguges XPth nd Node-seleting Queries XSLT XQuery Conlusion

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 39 Given: Deision Problems Algorithmi problems We onsider the following lgorithmi problems All of them will be useful in the XML ontext Membership test for A Question: Tree t Is t L(A)? Given: Given: Membership test (ombined) Question: Non-emptiness Automton A Question: Is L(A)? Automton A, tree t Is t L(A)? Continment Given: Automt A 1, A 2 Question: Is L(A 1 ) L(A 2 )? Equivlene Given: Automt A 1, A 2 Question: Is L(A 1 ) = L(A 2 )?

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 40 Membership Test Fts Time Bounds for the ombined omplexity of membership test for tree utomt: Deterministi (prllel) tree utomt: O( A t ) Nondeterministi (prllel) tree utomt: O( A 2 t ) (Compute, for eh node, the set of rehble sttes) Deterministi TWAs: O( A 2 t ) (Compute, for eh node v, the ggregted behvior of A on its subtree: Behvior funtion ) Nondeterministi TWAs: O( A 3 t ) (Compute, for eh node v, the ggregted behvior of A on its subtree: Behvior reltion )

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 40 Membership Test Fts Time Bounds for the ombined omplexity of membership test for tree utomt: Deterministi (prllel) tree utomt: O( A t ) Nondeterministi (prllel) tree utomt: O( A 2 t ) (Compute, for eh node, the set of rehble sttes) Deterministi TWAs: O( A 2 t ) (Compute, for eh node v, the ggregted behvior of A on its subtree: Behvior funtion ) Nondeterministi TWAs: O( A 3 t ) (Compute, for eh node v, the ggregted behvior of A on its subtree: Behvior reltion )

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 40 Membership Test Fts Time Bounds for the ombined omplexity of membership test for tree utomt: Deterministi (prllel) tree utomt: O( A t ) Nondeterministi (prllel) tree utomt: O( A 2 t ) (Compute, for eh node, the set of rehble sttes) Deterministi TWAs: O( A 2 t ) (Compute, for eh node v, the ggregted behvior of A on its subtree: Behvior funtion ) Nondeterministi TWAs: O( A 3 t ) (Compute, for eh node v, the ggregted behvior of A on its subtree: Behvior reltion )

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 40 Membership Test Fts Time Bounds for the ombined omplexity of membership test for tree utomt: Deterministi (prllel) tree utomt: O( A t ) Behvior Funtion Nondeterministi (prllel) tree utomt: O( A 2 t ) v (Compute, for eh node, the set of rehble sttes) f : Q Q Deterministi TWAs: O( A 2 t ) (Compute, for eh node v, the ggregted behvior of A on its subtree: Behvior funtion ) Nondeterministi TWAs: O( A 3 t ) (Compute, for eh node v, the ggregted behvior of A on its subtree: Behvior reltion )

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 40 Membership Test Fts Time Bounds for the ombined omplexity of membership test for tree utomt: Deterministi (prllel) tree utomt: O( A t ) Nondeterministi (prllel) tree utomt: O( A 2 t ) (Compute, for eh node, the set of rehble sttes) Deterministi TWAs: O( A 2 t ) (Compute, for eh node v, the ggregted behvior of A on its subtree: Behvior funtion ) Nondeterministi TWAs: O( A 3 t ) (Compute, for eh node v, the ggregted behvior of A on its subtree: Behvior reltion )

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 41 Membership Test (ont.) Question: Wht is the struturl omplexity for the vrious models? [Lohrey 01, Segoufin 03] Model Time Complexity Struturl Complexity Det. top-down TA O( A t ) LOGSPACE Det. bottom-up TA O( A t ) LOGDCFL Nondet. bottom-up TA O( A 2 t ) LOGCFL Nondet. top-down TA O( A 2 t ) LOGCFL Det. TWA O( A 2 t ) LOGSPACE Nondet. TWA O( A 3 t ) NLOGSPACE

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 42 Non-emptiness Fts Non-emptiness for string utomt orresponds to Grph Rehbility (omplete for NLOGSPACE) Non-emptiness for tree utomt : orresponds to Pth Systems p 1 p 2 q

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 42 Non-emptiness Fts Non-emptiness for string utomt orresponds to Grph Rehbility (omplete for NLOGSPACE) Non-emptiness for tree utomt : orresponds to Pth Systems p 1 p 2 q

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 42 Non-emptiness Fts Non-emptiness for string utomt orresponds to Grph Rehbility (omplete for NLOGSPACE) Non-emptiness for tree utomt : orresponds to Pth Systems p 1 p 2 q

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 42 Non-emptiness Fts Non-emptiness for string utomt orresponds to Grph Rehbility (omplete for NLOGSPACE) Non-emptiness for tree utomt : orresponds to Pth Systems p 1 p 2 q

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 42 Non-emptiness Fts Non-emptiness for string utomt orresponds to Grph Rehbility (omplete for NLOGSPACE) Non-emptiness for tree utomt : orresponds to Pth Systems p 1 p 2 q Result Non-emptiness for bottom-up tree utomt n be heked in liner time It is omplete for PTIME

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 43 Continment/Equivlene Of ourse: Observtions L(A 1 ) = L(A 2 ) [L(A 1 ) L(A 2 ) nd L(A 2 ) L(A 1 )] Complexity of ontinment problem is very different for deterministi nd non-deterministi utomt Deterministi utomt: onstrut produt utomton

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 1 0 0,1 0 1 0 d e f 1 0 0 b 1 0110100

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 1 0 0,1 0 1 0 d e 1 f 0 0 b 1 0110100

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 1 0 0,1 0 d 1 e 1 f 0 0 b 1 0 110100

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 1 0 0,1 0 d e 0 1 f 0 0 b 1 01 10100

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 1 0 0,1 0 1 0 d e 1 f 0 0 b 1 011 0100

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 1 0 0,1 0 d 1 e 1 f 0 0 b 1 0110 100

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 1 0 0,1 0 d e 0 1 f 0 0 b 1 01101 00

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 1 0 0,1 0 1 0 d e 1 f 0 0 b 1 011010 0

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 1 0 0,1 0 1 0 d e 1 f 0 0 b 1 0110100

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 0 0,1 0 1 0 d e f 1 0 1 b 1 0 1 1 d e f 0 1 0 1 1 0 0 0 0 b 0 bd 1 be 0 bf 1 1 0110100

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 0 0,1 0 1 0 d e f 1 0 1 b 1 0 1 1 d e f 0 1 0 1 1 0 0 0 0 b 0 bd 1 be 0 bf 1 1 0110100

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 0 0,1 0 d 1 e 0 f 1 0 1 b 1 0 1 1 d e f 0 1 0 1 1 0 0 0 0 b 0 bd 1 be 0 bf 1 1 0 110100

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 0 0,1 0 d 1 e 0 f 1 0 1 b 1 0 1 1 d e f 0 1 0 1 1 0 0 0 0 b 0 bd 1 be 0 bf 1 1 01 10100

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 0 0,1 0 1 0 d e f 1 0 1 b 1 0 1 1 d e f 0 1 0 1 1 0 0 0 0 b 0 bd 1 be 0 bf 1 1 011 0100

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 0 0,1 0 d 1 e 0 f 1 0 1 b 1 0 1 1 d e f 0 1 0 1 1 0 0 0 0 b 0 bd 1 be 0 bf 1 1 0110 100

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 0 0,1 0 d 1 e 0 f 1 0 1 b 1 0 1 1 d e f 0 1 0 1 1 0 0 0 0 b 0 bd 1 be 0 bf 1 1 01101 00

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 0 0,1 0 1 0 d e f 1 0 1 b 1 0 1 1 d e f 0 1 0 1 1 0 0 0 0 b 0 bd 1 be 0 bf 1 1 011010 0

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 44 Reminder: Produt utomton Produt of 2 string utomt even number of zeros ontins substring 00 1 0 0,1 0 1 0 d e f 1 0 1 b 1 0 1 1 d e f 0 1 0 1 1 0 0 0 0 b 0 bd 1 be 0 bf 1 1 0110100

Continment: Complexity Deterministi bottom-up tree utomt Produt utomton nlogous s for string utomt Set of sttes: Q 1 Q 2 Trnsitions omponent-wise To hek L(A 1 ) L(A 2 ): Compute B = A 1 A 2 Aepting sttes: F 1 (Q 2 F 2 ) Chek whether L(B) = If so, L(A 1 ) L(A 2 ) holds Theorem Complexity of Continment for deterministi bottom-up tree utomt: O( A 1 A 2 ) Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 45

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 46 Continment: Complexity (ont.) Non-deterministi utomt Nive pproh: Mke A 2 deterministi (size: O(2 A 2 )) Construt produt utomton Exponentil time

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 46 Continment: Complexity (ont.) Non-deterministi utomt Nive pproh: Mke A 2 deterministi (size: O(2 A 2 )) Construt produt utomton Exponentil time Unfortuntely... There is essentilly no better wy

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 46 Continment: Complexity (ont.) Non-deterministi utomt Nive pproh: Mke A 2 deterministi (size: O(2 A 2 )) Construt produt utomton Exponentil time Unfortuntely... There is essentilly no better wy Theorem [Seidl 1990] Continment for non-deterministi tree utomt is omplete for EXPTIME

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 47 Det. Top-Down Automt: Non-Emptiness Theorem Nonemptiness for deterministi top-down utomt A n be heked in polynomil time Proof ide Chek for eh stte p of A nd eh pir (q, q ) of the leves utomton B: Is there tree t suh tht A strts from stte p nd obtins leve string whih brings B from q to q? Illustrtion p q q

Shwentik XML: Algorithms & Complexity Introdution - XML Proessing 48 Det. Top-Down Automt: Continment Theorem Continment for deterministi top-down utomt A n be heked in polynomil time Proof ide Tree utomt A 1, A 2 with leves utomt B 1, B 2 Chek for eh pir (p 1, p 2 ) of sttes of A 1 nd A 2 nd for eh two pirs (q 1, q 1 ) nd (q 2, q 2 ) of B 1 nd B 2, resp.: Is there tree t suh tht for both i = 1, i = 2: T i strts from stte p i nd obtins leve string whih brings B i from q i to q i?