Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 23UofH - COSC 3340 - Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 23.

Similar presentations


Presentation on theme: "Lecture 23UofH - COSC 3340 - Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 23."— Presentation transcript:

1 Lecture 23UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 23

2 UofH - COSC Dr. Verma 2 Tree Automata The automata concept is general and powerful! (should be in every CS student toolkit) Just as DFAs and NFAs work on strings, we can define automata that process trees, DAGs, graphs, matrices, etc. We illustrate this generality thru tree automata

3 Lecture 23UofH - COSC Dr. Verma 3 Tree Automata Process trees instead of strings Can be bottom-up (we consider) or top-down The tree automata TA has: – a finite set of states – 0 or more special states - final states – input alphabet – transition table containing rules of two kinds: a -> q, f(q1,…,qn) -> q

4 Lecture 23UofH - COSC Dr. Verma 4 Informally -- How does a TA work? TA works from the leaves to the root of the tree. TA goes into a loop until the entire tree is read. – In each step, TA consults its transition table and determines states for nodes higher up the tree based on (f, q1,…,qn) where f – symbol at the node q1, …, qn – states at the children of the node

5 Lecture 23UofH - COSC Dr. Verma 5 How does a TA work? (contd.) For deterministic TA, after reading input tree, – if TA state final, input accepted – if TA state not final, input rejected For nondeterministic TA, as long as one accepting computation exits, input is accepted; if none, input is rejected. Language of TA -- set of all trees accepted by TA. TAs have applications in XML, Xpath, compilers, logic, and verification

6 Lecture 23UofH - COSC Dr. Verma 6 Formal definition of NTA NTA M = (Q, , Δ, F) Where, – Q is a finite set of states –  is the input alphabet – F  Q is set of final states – Δ is a set of transition rules of two kinds a -> q where a is in  and q is in Q f(q1, …, qn) -> q where f is in  and q, qi’s in Q

7 Lecture 23UofH - COSC Dr. Verma 7 Formal definition of L(M) We can define the yields in one-step relation between two trees Take its reflexive-transitive closure and define L(M) Reference: Tree Automata and Applications book by Comon et al. (available on the web)

8 Lecture 23UofH - COSC Dr. Verma 8 DFAs are special case of TA The DFA symbols become unary functions The TA has rules: – a(q0) -> q1 – b(q0) -> q0 – a(q1) -> q0 – b(q1) -> q1 – q0 is final state

9 Lecture 23UofH - COSC Dr. Verma 9 Example of TA – boolean formula evaluation 0 -> q0, 1 -> q1 not(q0) -> q1, not(q1) -> q0 and(q0, q0) -> q0, …, and(q1, q1) -> q1 or(q0, q0) -> q0, …, or(q1, q1) -> q1 q1 is final state Evaluate: or(and(not(0), not(1)), and(0, 0))

10 Lecture 23UofH - COSC Dr. Verma 10 More generally … We can have rules of the form: – expr1 -> expr2, where lhs and rhs are expressions containing variables x, y, z and function symbols f, g, h, a, … Example: x + 0 -> x and x + -x -> 0 These rules are applied using pattern matching A derivation: (0 + -0) + 0 => => 0

11 Lecture 23UofH - COSC Dr. Verma 11 How powerful are such rules? As powerful as a Turing Machine! (Reference: TCS paper by Max Dauchet) An interpreter, called LRR, for such rules has been implemented by me and my students – LRR saves every rule application in a compact data structure – Can be used for programming or verification LRR Demo available for interested students (see me)


Download ppt "Lecture 23UofH - COSC 3340 - Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 23."

Similar presentations


Ads by Google