ArticleslgStudy

computer science

Tree automaton

Tree automaton is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Tree automaton rather than just read about it. In short: A tree automaton is a type of state machine. Tree automata deal with tree structures, rather than the strings of more conventional state machines.

Tree automaton — main illustration
Tree automaton — illustration

Key takeaways

  • Tree automaton belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Tree automaton to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Tree automaton from memory before moving on to harder problems.

Reference excerpt

A tree automaton is a type of state machine. Tree automata deal with tree structures, rather than the strings of more conventional state machines. The following article deals with branching tree automata, which correspond to regular languages of trees. As with classical automata, finite tree automata (FTA) can be either a deterministic automaton or not. According to how the automaton processes the input tree, finite tree automata can be of two types: (a) bottom up, (b) top down. This is an important issue, as although non-deterministic (ND) top-down and ND bottom-up tree automata are equivalent in expressive power, deterministic top-down automata are strictly less powerful than their deterministic bottom-up counterparts, because tree properties specified by deterministic top-down tree automata can only depend on path properties. (Deterministic bottom-up tree automata are as powerful as ND tree automata.)

Definitions A bottom-up finite tree automaton over F is defined as a tuple (Q, F, Qf, Δ), where Q is a set of states, F is a ranked alphabet (i.e., an alphabet whose symbols have an associated arity), Qf ⊆ Q is a set of final states, and Δ is a set of transition rules of the form f(q1(x1),...,qn(xn)) → q(f(x1,...,xn)), for an n-ary f ∈ F, q, qi ∈ Q, and xi variables denoting subtrees. That is, members of Δ are rewrite rules from nodes whose childs' roots are states, to nodes whose roots are states. Thus the state of a node is deduced from the states of its children. For n=0, that is, for a constant symbol f, the above transition rule definition reads f() → q(f()); often the empty parentheses are omitted for convenience: f → q(f). Since these transition rules for constant symbols (leaves) do not require a state, no explicitly defined initial states are needed. A bottom-up tree automaton is run on a ground term over F, starting at all its leaves simultaneously and moving upwards, associating a run state from Q with each subterm. The term is accepted if its root is associated to an accepting state from Qf. A top-down finite tree automaton over F is defined as a tuple (Q, F, Qi, Δ), with two differences with bottom-up tree automata. First, Qi ⊆ Q, the set of its initial states, replaces Qf; second, its transition rules are oriented conversely: q(f(x1,...,xn)) → f(q1(x1),...,qn(xn)), for an n-ary f ∈ F, q, qi ∈ Q, and xi variables denoting subtrees. That is, members of Δ are here rewrite rules from nodes whose roots are states to nodes whose children's roots are states. A top-down automaton starts in some of its initial states at the root and moves downward along branches of the tree, associating along a run a state with each subterm inductively. A tree is accepted if every branch can be gone through this way. A tree automaton is called deterministic (abbreviated DFTA) if no two rules from Δ have the same left hand side; otherwise it is called nondeterministic (NFTA). Non-deterministic top-down tree automata have the same expressive power as non-deterministic bottom-up ones; the transition rules are simply reversed, and the final states become the initial states. In contrast, deterministic top-down tree automata are less powerful than their bottom-up counterparts, because in a deterministic tree automaton no two transition rules have the same left-hand side. For tree automata, transition rules are rewrite rules; and for top-down ones, the left-hand side will be parent nodes. Consequently, a deterministic top-down tree automaton will only be able to test for tree properties that are true in all branches, because the choice of the state to write into each child branch is determined at the parent node, without knowing the child branches contents. For example, if F consists of f, g, and a, which are 2ary, 1ary, and 0ary, respectively, the set of all terms having a ground instance of f(a,g(x)) as a subterm, can be recognized by a bottom-up DFTA, but not by a top-town DFTA. Infinite-tree automata extend top-down automata to infinite trees, and can be used to prove decidability of S2S, the monadic second-order theory with two successors. Finite tree automata (nondeterministic if top-down) suffice for WS2S.

Examples

Bottom-up automaton accepting boolean lists Employing coloring to distinguish members of F and Q, and using the ranked alphabet F={ false,true,nil,cons(.,.) }, with cons having arity 2 and all other symbols having arity 0, a bottom-up tree automaton accepting the set of all finite lists of boolean values can be defined as (Q, F, Qf, Δ) with Q = { Bool,BList }, Qf = { BList }, and Δ consisting of the rules

In this example, the rules can be understood intuitively as assigning to each term its type in a bottom-up manner; e.g. rule (4) can be read as "A term cons(x1,x2) has type BList, provided x1 and x2 has type Bool and BList, respectively". An accepting example run is

Cf. the derivation of the same term from a regular tree grammar corresponding to the automaton, shown at Regular tree grammar#Examples. A rejecting example run is

Intuitively, this corresponds to the term cons(false,true) not being well-typed.

Top-down automaton accepting multiples of 3 in binary notation

Using the same colorization as above, this example shows how tree automata generalize ordinary string automata. The finite deterministic string automaton shown in the picture accepts all strings of binary digits that denote a multiple of 3. Using the notions from Deterministic finite automaton#Formal definition, it is defined by:

the set Q of states being { S0, S1, S2 }, the input alphabet being { 0, 1 }, the initial state being S0, the set of final states being { S0 }, and the transitions being as shown in column (B) of the table. In the tree automaton setting, the input alphabet is changed such that the symbols 0 and 1 are both unary, and a nullary symbol, say nil is used for tree leaves. For example, the binary string "110" in the string automaton setting corresponds to the term "1(1(0(nil)))" in the tree automaton setting; this way, strings can be generalized to trees, or terms. The top-down finite tree automaton accepting the set of all terms corresponding to multiples of 3 in binary string notation is then defined by:

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Tree automaton

Start with the simplest possible case. Write down what Tree automaton claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Tree automaton before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Tree automaton ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Tree automaton

In research
Tree automaton appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Tree automaton in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Tree automaton is common in secondary-school and first-year university syllabi. It links to neighbouring topics Automata (computation), Formal languages, Theoretical computer science, so understanding it makes those chapters shorter.
In everyday life
Look for Tree automaton outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Tree automaton in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Tree automaton means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Tree automaton out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Tree automaton in simple terms?

A tree automaton is a type of state machine. Tree automata deal with tree structures, rather than the strings of more conventional state machines.

Why does Tree automaton matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Tree automaton?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Tree automaton.

Tags

  • Automata (computation)
  • Formal languages
  • Theoretical computer science
  • Trees (data structures)

Keep exploring