Tree stack automaton

A tree stack automaton (plural: tree stack automata) is a formalism considered in automata theory. It is a finite state automaton with the additional ability to manipulate a tree-shaped stack. It is an automaton with storage whose storage roughly resembles the configurations of a thread automaton. A restricted class of tree stack automata recognises exactly the languages generated by multiple context-free grammars (or linear context-free rewriting systems).

Tree stack


For a finite and non-empty set $Γ$, a tree stack over $Γ$ is a tuple $(t, p)$ where The set of all tree stacks over $t$ is denoted by $Γ ∪ {@}$.
 * $w$ is a partial function from strings of positive integers to the set $w$ with prefix-closed domain (called tree),
 * $@$ (called bottom symbol) is not in $Γ$ and appears exactly at the root of $t$, and
 * $p$ is an element of the domain of $t$ (called stack pointer).

The set of predicates on $Γ$, denoted by $TS(Γ)$, contains the following unary predicates: for every $TS(Γ)$.
 * $Pred(Γ)$ which is true for any tree stack over $true$,
 * $Γ$ which is true for tree stacks whose stack pointer points to the bottom symbol, and
 * $bottom$ which is true for some tree stack $equals(γ)$ if $(t, p)$,

The set of instructions on $t(p) = γ$, denoted by $γ ∈ Γ$, contains the following partial functions: for every positive integer $TS(Γ)$ and every $Instr(Γ)$.
 * $id: TS(Γ) → TS(Γ)$ which is the identity function on $TS(Γ)$,
 * $push_{n,γ}: TS(Γ) → TS(Γ)$ which adds for a given tree stack $(t,p)$ a pair $(pn ↦ γ)$ to the tree $t$ and sets the stack pointer to $pn$ (i.e. it pushes $γ$ to the $n$-th child position) if $pn$ is not yet in the domain of $t$,
 * $up_{n}: TS(Γ) → TS(Γ)$ which replaces the current stack pointer $p$ by $pn$ (i.e. it moves the stack pointer to the $n$-th child position) if $pn$ is in the domain of $t$,
 * $down: TS(Γ) → TS(Γ)$ which removes the last symbol from the stack pointer (i.e. it moves the stack pointer to the parent position), and
 * $set_{γ}: TS(Γ) → TS(Γ)$ which replaces the symbol currently under the stack pointer by $γ$,

Tree stack automata
A tree stack automaton is a 6-tuple $n$ where
 * $γ ∈ Γ$, $A = (Q, Γ, Σ, q_{i}, δ, Q_{f})$, and $Q$ are finite sets (whose elements are called states, stack symbols, and input symbols, respectively),
 * $Γ$ (the initial state),
 * $Σ$ (whose elements are called transitions), and
 * $q_{i} ∈ Q$ (whose elements are called final states).

A configuration of $δ ⊆_{fin.} Q × (Σ ∪ {ε}) × Pred(Γ) × Instr(Γ) × Q$ is a tuple $Q_{f} ⊆ TS(Γ)$ where
 * $A$ is a state (the current state),
 * $(q, c, w)$ is a tree stack (the current tree stack), and
 * $q$ is a word over $c$ (the remaining word to be read).

A transition $w$ is applicable to a configuration $Σ$ if The transition relation of $τ = (q_{1}, u, p, f, q_{2})$ is the binary relation $(q, c, w)$ on configurations of $q_{1} = q$ that is the union of all the relations $p$ for a transition $c$ where, whenever $f$ is applicable to $c$, we have $u$ and $w$ is obtained from $A$ by removing the prefix $⊢$.
 * $A$ is true on $⊢_{τ}$,
 * $τ = (q_{1}, u, p, f, q_{2})$ is defined for $τ$, and
 * $(q, c, w)$ is a prefix of $(q, c, w) ⊢_{τ} (q_{2}, f(c), v)$.
 * $v$ is a prefix of $w$.

The language of $u$ is the set of all words $A$ for which there is some state $w$ and some tree stack $q ∈ Q_{f}$ such that $c$ where
 * $(q_{i}, c_{i}, w) ⊢^{*} (q, c, ε)$ is the reflexive transitive closure of $⊢^{*}$ and
 * $⊢$ such that $c_{i} = (t_{i}, ε)$ assigns for $t_{i}$ the symbol $ε$ and is undefined otherwise.

Related formalisms
Tree stack automata are equivalent to Turing machines.

A tree stack automaton is called $@$-restricted for some positive natural number $k$ if, during any run of the automaton, any position of the tree stack is accessed at most $k$ times from below.

1-restricted tree stack automata are equivalent to pushdown automata and therefore also to context-free grammars. $k$-restricted tree stack automata are equivalent to linear context-free rewriting systems and multiple context-free grammars of fan-out at most $k$ (for every positive integer $k$).