Tree Automata

Tree Automata

Foundations of XML Types: Tree Automata Pierre Genevès CNRS (slides mostly based on slides by W. Martens and T. Schwentick) University Grenoble Alpes, 2020–2021 1 / 43 Why Tree Automata? • Foundations of XML type languages (DTD, XML Schema, Relax NG...) • Provide a general framework for XML type languages • A tool to define regular tree languages with an operational semantics • Provide algorithms for efficient validation • Basic tool for static analysis (proofs, decision procedures in logic) 2 / 43 Prelude: Word Automata b b a start even odd a Transitions even !a odd odd !a even ... 3 / 43 From Words to Trees: Binary Trees Binary trees with an even number of a’s a a a b a b b How to write transitions? 4 / 43 From Words to Trees: Binary Trees Binary trees with an even number of a’s a even a even a odd b even a odd b even b even How to write transitions? 4 / 43 From Words to Trees: Binary Trees Binary trees with an even number of a’s a even a even a odd b even a odd b even b even How to write transitions? (even; odd) !a even (even; even) !a odd etc: 4 / 43 Ranked Trees? They come from parse trees of data (or programs)... A function call f (a; b) is a ranked tree f a b 5 / 43 Ranked Trees? They come from parse trees of data (or programs)... A function call f (g(a; b; c); h(i)) is a ranked tree f g h a b c i 5 / 43 Ranked Alphabet A ranked alphabet symbol is: • a formalisation of a function call • a symbol a with an integer arity(a) • arity(a) indicates the number of children of a Notation a(k): symbol a with arity(a)= k 6 / 43 Example Alphabet: fa(2); b(2); c(3); #(0)g Possible tree: a b a a c # # # # a # b # # a # # # 7 / 43 Ranked Tree Automata A ranked tree automaton A consists in: Alphabet(A): finite alphabet of symbols States(A): finite set of states Rules(A): finite set of transition rules Final(A): finite set of final states (⊆ States(A)) where : a(k) Rules(A) are of the form (q1; :::; qk ) ! q (0) if k = 0, we write a! q 8 / 43 Ranked Tree Automata A ranked tree automaton A consists in: Alphabet(A): finite alphabet of symbols States(A): finite set of states Rules(A): finite set of transition rules Final(A): finite set of final states (⊆ States(A)) where : a(k) Rules(A) are of the form (q1; :::; qk ) ! q (0) if k = 0, we write a! q 8 / 43 How do they work? Example: Boolean Expressions ^ _ ^ ^ _ _ ^ 0 1 1 0 0 1 1 1 Rules(A) Principle 0 1 ! q0 ! q1 ^ _ • Alphabet(A)= f^; _; 0; 1g (q1; q1) ! q1 (q0; q1) ! q1 ^ _ • States(A)= fq0; q1g (q0; q1) ! q0 (q1; q0) ! q1 ^ _ • 1 accepting state at the root: (q1; q0) ! q0 (q1; q1) ! q1 ^ _ Final(A)= fq1g (q0; q0) ! q0 (q0; q0) ! q0 9 / 43 How do they work? Example: Boolean Expressions ^ _ ^ ^ _ _ ^ 0 q0 1 q1 1 q1 0 q0 0 q0 1 q1 1 q1 1 q1 Rules(A) Principle 0 1 ! q0 ! q1 ^ _ • Alphabet(A)= f^; _; 0; 1g (q1; q1) ! q1 (q0; q1) ! q1 ^ _ • States(A)= fq0; q1g (q0; q1) ! q0 (q1; q0) ! q1 ^ _ • 1 accepting state at the root: (q1; q0) ! q0 (q1; q1) ! q1 ^ _ Final(A)= fq1g (q0; q0) ! q0 (q0; q0) ! q0 9 / 43 How do they work? Example: Boolean Expressions ^ q1 _ q1 ^ q1 ^q0 _q1 _q1 ^q1 0 q0 1 q1 1 q1 0 q0 0 q0 1 q1 1 q1 1 q1 Rules(A) Principle 0 1 ! q0 ! q1 ^ _ • Alphabet(A)= f^; _; 0; 1g (q1; q1) ! q1 (q0; q1) ! q1 ^ _ • States(A)= fq0; q1g (q0; q1) ! q0 (q1; q0) ! q1 ^ _ • 1 accepting state at the root: (q1; q0) ! q0 (q1; q1) ! q1 ^ _ Final(A)= fq1g (q0; q0) ! q0 (q0; q0) ! q0 9 / 43 Terminology • Language(A) : set of trees accepted by A • For a tree automaton A, Language(A) is a regular tree language [Thatcher and Wright, 1968, Doner, 1970] 10 / 43 Example Tree automaton A over fa(2); b(2); #(0)g which recognizes trees with an even number of a’s Alphabet(A): fa; b; #g States(A): Final(A): Rules(A): 11 / 43 Example Tree automaton A over fa(2); b(2); #(0)g which recognizes trees with an even number of a’s Alphabet(A): fa; b; #g States(A): feven; oddg Final(A): feveng Rules(A): (even; even) !a odd (even; even) !b even (even; odd) !a even (even; odd) !b odd (odd; even) !a even (odd; even) !b odd (odd; odd) !a odd (odd; odd) !b even # ! even 11 / 43 Outline 1. Can we implement a tree automaton efficiently? (notion of determinism) 2. Are tree automata closed under set-theoretic operations? 3. Can we check type inclusion? 4. Can we build equivalent top-down tree automata? 5. Nice theory. But... what should I do with my unranked XML trees? ! Can we apply this for XML type-checking? 12 / 43 Deterministic Tree Automata Deterministic does not have two rules of the form: a(k) (q1; :::; qk ) ! q (k) a 0 (q1; :::; qk ) ! q for two different states q and q0 Intuition At most one possible transition at a given node ! implementation... 13 / 43 Can we Make a Tree Automaton Deterministic? Theorem (determinization) From a given non-deterministic (bottom-up) tree automaton we can build a deterministic tree automaton Corollary Non-deterministic and deterministic (bottom-up) tree automata recognize the same languages. Complexity jStates(A)j EXPTIME (jStates(Adet)j = 2 ) 14 / 43 Implementing Validation Membership Checking Given a tree automaton A and a tree t, does t 2 Language(A)? Remark b We can implement even if A is b non-deterministic... b Example a Automaton with Final(A)= fqf g and : c b b ! q q ! qb q ! q b b b a qb ! qf (q; q) ! q c c 15 / 43 Implementing Validation Membership Checking Given a tree automaton A and a tree t, does t 2 Language(A)? Remark b We can implement even if A is b non-deterministic... b Example a Automaton with Final(A)= fqf g and : c b b ! q q ! qb q ! q b b b a qb ! qf (q; q) ! q fqg c c fqg 15 / 43 Implementing Validation Membership Checking Given a tree automaton A and a tree t, does t 2 Language(A)? Remark b We can implement even if A is b non-deterministic... b Example a Automaton with Final(A)= fqf g and : c b b ! q q ! qb q ! q fq; qbg b b fq; qbg b a qb ! qf (q; q) ! q fqg c c fqg 15 / 43 Implementing Validation Membership Checking Given a tree automaton A and a tree t, does t 2 Language(A)? Remark b We can implement even if A is b non-deterministic... b Example a fqg Automaton with Final(A)= fqf g and : c b b ! q q ! qb q ! q fq; qbg b b fq; qbg b a qb ! qf (q; q) ! q fqg c c fqg 15 / 43 Implementing Validation Membership Checking Given a tree automaton A and a tree t, does t 2 Language(A)? Remark b We can implement even if A is b non-deterministic... b fq; qbg Example a fqg Automaton with Final(A)= fqf g and : c b b ! q q ! qb q ! q fq; qbg b b fq; qbg b a qb ! qf (q; q) ! q fqg c c fqg 15 / 43 Implementing Validation Membership Checking Given a tree automaton A and a tree t, does t 2 Language(A)? Remark b We can implement even if A is b fq; qb; qf g non-deterministic... b fq; qbg Example a fqg Automaton with Final(A)= fqf g and : c b b ! q q ! qb q ! q fq; qbg b b fq; qbg b a qb ! qf (q; q) ! q fqg c c fqg 15 / 43 Implementing Validation Membership Checking Given a tree automaton A and a tree t, does t 2 Language(A)? Remark b fq; qb; qf g We can implement even if A is b fq; qb; qf g non-deterministic... b fq; qbg Example a fqg Automaton with Final(A)= fqf g and : c b b ! q q ! qb q ! q fq; qbg b b fq; qbg b a qb ! qf (q; q) ! q fqg c c fqg 15 / 43 Implementing Validation Membership Checking Given a tree automaton A and a tree t, does t 2 Language(A)? Remark b fq; qb; qf g We can implement even if A is b fq; qb; qf g non-deterministic... b fq; qbg Example a fqg Automaton with Final(A)= fqf g and : c b b ! q q ! qb q ! q fq; qbg b b fq; qbg b a qb ! qf (q; q) ! q fqg c c fqg Complexity Membership-Checking is in PTIME (time linear in the size of the tree) 15 / 43 Set-Theoretic Operations Recall • We have seen that neither local tree grammars nor single-type tree grammars are closed under boolean operations (e.g. union) • What about tree automata? 16 / 43 Closure under Union and Intersection... Example • Automaton A: even number of a’s a • (even; even) ! odd • Automaton B: even number of b’s a • (even; even) ! even 17 / 43 Closure under Union and Intersection..

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    73 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us