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), 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 , 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 . 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, , the set of its initial states, replaces ; second, its transition rules are oriented conversely:
q(
f(
x1,...,
xn)) →
f(
q1(
x1),...,
qn(
xn)), for an
n-ary , 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.{{efn|1= Let
Q = {
qa,
qg,
qf,
q0 }, with the informal meaning
qa: "saw an
a",
qg: "saw some
g(...)",
qf: saw some
f(
a,
g(...))",
q0: "saw none of those". Let
Qf = {
qf } be the set of final states. The transition rules set Δ = {
a →
qa(
a),
f(
qa(
x),
qg(
y)) →
qf(
f(
x,
y)) } ∪ {
g(
qf(
x)) →
qf(
g(
x)) } ∪ {
f(
qf(
x),
q(
y)) →
qf(
f(
x,
y)),
f(
q(
x),
qf(
y)) →
qf(
f(
x,
y)), :
q ∈
Q } ∪ {
g(
q(
x)) →
qg(
g(
x)), :
q ∈
Q \ {
qf } } ∪ {
f(
qg(
x),
q(
y)) →
q0(
f(
x,
y)),
f(
q(
x),
qa(
y)) →
q0(
f(
x,
y)) :
q ∈
Q } maintains the informal meanings of the states during bottom-up movement through a tree
t and hence accepts
t if, and only if,
t somewhere contains a subtree
f(
a,
g(...)).}}
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 ==