We have now the elements to prove our main technical result: the decidability of the \(\mathsf {FO}[\xrightarrow {*}]\)-theory of graphs generated by GSTRS. We first formally define the graphs we study. We will consider the restriction of these graphs to sets of vertices reachable from a recognisable set of vertices, as we want to have the decidability of the reachability predicate. Notice that although we will be able to express the reachability predicate, it will not be possible to express that a stack tree is in a recognisable set.
As previously, we consider the restriction of this graph to a reachable set of vertices in Λ from a recognisable set of vertices. The graph obtained that way is denoted \(\mathcal {G}_{\Lambda ,L}\). We denote by GSTT
n
the set of the restrictions to reachable sets of vertices of graphs generated by GSTT of order n.
From the previous section, the transitive closure of the relation defined by a GSTRS is defined by an automaton, as well as the transitive closure of the relation defined by a GSTT. Thus, the transitive closure of a graph of GSTR
n
is a graph of GSTT
n
, and this is also true for graphs of RGSTR
n
and of GSTT
n
.
We now detail the formulæ defining the finite set interpretations. After giving useful technical formulæ, we present the formulæ δ, ϕ
A
, and finally ψ
A
.
First, let us recall that from Theorem 1 we can construct from any automaton an equivalent automaton satisfying the conditions of the theorem. In this subsection, we consider that A is such a normalised automaton.
Let us now explain
ϕ
A
(
X,
Y ), which can be written as
$$\begin{array}{@{}rcl@{}} \phi_{A}(X,Y) &=& \exists Z_{q_{1}}{\cdots} Z_{q_{|Q|}}, \phi_{A}^{\prime}(X,Y,\mathbf{Z}), \text{ with} \\ \phi_{A}^{\prime}(X,Y,\mathbf{Z}) &=& \text{Init}(X,Y,\mathbf{Z}) \wedge \text{WellFormed}(\mathbf{Z}) \\ &&\wedge\text{Trans}(\mathbf{Z}) \wedge \text{RTrans}(\mathbf{Z}) \wedge \text{NoCycle}(\mathbf{Z}) \end{array} $$
We detail each of the subformulæ below:
$$\text{Init}(X,Y,\mathbf{Z})\,=\, \left( \bigcup_{q_{i} \in I} Z_{q_{i}}\!\right) \!\subseteq\! X \land \left( \bigcup_{q_{i} \in F} Z_{q_{i}}\!\right) \!\subseteq\! Y \land X \setminus\left( \bigcup_{q_{i} \in I} Z_{q_{i}}\!\right) \,=\, Y \setminus \left( \bigcup_{q_{i} \in F} Z_{q_{i}}\!\right). $$
This formula is here to ensure that only leaves of
X are labelled by initial states, only leaves of
Y are labelled by final states and outside of their labelled leaves,
X and
Y are equal (i.e. not modified).
$$\text{Trans}(\mathbf{Z}) \,=\, \forall s, \bigwedge\limits_{q\in Q} \left( (s\in Z_{q}) \!\Rightarrow\! \left( \bigvee\limits_{K \in \Delta \mid q \in \text{left}(K)} \exists t,t^{\prime}, \text{Trans}_{K}(s,t,t^{\prime},\mathbf{Z}) \vee \rho_{q} \right) \right), $$
where
ρ
q
is true if and only if
q is a final state,
q ∈left(
K) means that
q appears in the left member of
K (as in the cases below), and
$$\begin{array}{@{}rcl@{}} \text{Trans}_{(q,\theta,q^{\prime})}(s,t,t^{\prime},\mathbf{Z}) &=& (t=t^{\prime}) \wedge \psi_{\theta}(s,t) \wedge s\in Z_{q} \wedge t \in Z_{q^{\prime}}, \\ \text{Trans}_{(q,(q^{\prime},q^{\prime\prime}))}(s,t,t^{\prime},\mathbf{Z}) &=& \psi_{\text{copy}_{n}^{2},1}(s,t) \land \psi_{\text{copy}_{n}^{2},2}(s,t^{\prime}) \land s\in Z_{q}\\ &&\land t \in Z_{q^{\prime}} \land t^{\prime} \in Z_{q^{\prime\prime}}, \\ \text{Trans}_{((q,q^{\prime}),q^{\prime\prime})}(s,t,t^{\prime},\mathbf{Z}) &=& (t=t^{\prime}) \land \psi_{\overline{\text{copy}}_{n}^{2},1}(s,t) \land s \in Z_{q} \land t \in Z_{q^{\prime\prime}}, \\ \text{Trans}_{((q^{\prime},q),q^{\prime\prime})}(s,t,t^{\prime},\mathbf{Z}) &=& (t=t^{\prime}) \land \psi_{\overline{\text{copy}}_{n}^{2},2}(s,t) \land s \in Z_{q} \land t \in Z_{q^{\prime\prime}}. \end{array} $$
This formula ensures that the labelling respects the rules of the automaton in the downward direction, and that for every stack
s labelled by
q, if there is a rule starting by
q, there is a labelled stack
s
′ which is the result of
s by at least one of those rules. And also that it is possible for a stack labelled by a final state to have no successor labelled by a state of the automaton (and as the automaton is distinguished, it cannot have a successor).
$$\text{RTrans}(\mathbf{Z}) \,=\, \forall s, \bigwedge\limits_{q\in Q} \!\left( \!(s \in Z_{q}) \!\Rightarrow\! \left( \bigvee\limits_{K \in \Delta \mid q \in \text{right}(K)} \!\exists t,t^{\prime}, \text{RTrans}_{K}(s,t,t^{\prime},\mathbf{Z}) \!\vee\! \sigma_{q} \!\right) \right) $$
where
σ
q
is true if and only if
q is an initial state,
q ∈right(
K) means that
q appears in the right member of
K (as in the cases below), and
$$\begin{array}{@{}rcl@{}} \text{RTrans}_{(q^{\prime},\theta,q)}(s,t,t^{\prime},\mathbf{Z}) &=& (t=t^{\prime}) \wedge \psi_{\theta}(t,s) \wedge s\in Z_{q^{\prime}} \wedge t \in Z_{q}, \\ \text{RTrans}_{(q^{\prime},(q,q^{\prime\prime}))}(s,t,t^{\prime},\mathbf{Z}) &=& (t=t^{\prime}) \wedge \psi_{\text{copy}_{n}^{2},1}(t,s) \land s\in Z_{q^{\prime}} \land t \in Z_{q}, \\ \text{RTrans}_{(q^{\prime},(q^{\prime\prime},q))}(s,t,t^{\prime},\mathbf{Z}) &=& (t=t^{\prime}) \wedge \psi_{\text{copy}_{n}^{2},2}(t,s) \land s\in Z_{q} \land t \in Z_{q^{\prime}}, \\ \text{RTrans}_{((q^{\prime},q^{\prime\prime}),q)}(s,t,t^{\prime},\mathbf{Z}) &=& \psi_{\overline{\text{copy}}_{n}^{2},1}(t,s) \land \psi_{\overline{\text{copy}}_{n}^{2},2}(t^{\prime},s) \land s \in Z_{q}\\ &&\land t \in Z_{q^{\prime}} \land t \in Z_{q^{\prime\prime}} \end{array} $$
This formula ensures that the labelling respects the rules of the automaton in the upward direction, and that for every stack
s labelled by
q, if there is a rule ending by
q, there is a labelled stack
s
′ such that
s is the result of
s
′ by at least one of those rules. And also that it is possible for a stack labelled by an initial state to have no predecessor labelled by a state of the automaton (and as the automaton is distinguished, it cannot have a predecessor).
$$\begin{array}{@{}rcl@{}} \text{WellFormed}(\mathbf{Z}) \!\!\!\!&&= \forall s,t_{1},t_{2},t_{3},t_{4},\\ &&\bigwedge\limits_{\begin{array}{c}K \neq K^{\prime} \in \Delta \\q \in \text{left}(K) \cap \text{left}(K^{\prime})\end{array}} \neg (\text{Trans}_{K}(s,t_{1},t_{2},\mathbf{Z}) \wedge \text{Trans}_{K^{\prime}}(s,t_{3},t_{4},\mathbf{Z}))\wedge\\ && \bigwedge\limits_{\begin{array}{c}K \neq K^{\prime} \in \Delta \\q \in \text{right}(K) \cap \text{right}(K^{\prime})\end{array}} \neg (\text{RTrans}_{K}(s,t_{1},t_{2},\mathbf{Z}) \wedge \text{RTrans}_{K^{\prime}}(s,t_{3},t_{4},\mathbf{Z})) \\ &&\wedge \bigwedge\limits_{q,q^{\prime},q^{\prime\prime}} \forall s,t, [ \text{RTrans}_{(q,(q^{\prime},q^{\prime\prime}))}(t,s,s,\mathbf{Z}) \Rightarrow \exists t^{\prime}, \text{Trans}_{(q,(q^{\prime},q^{\prime\prime})}(s,t,t^{\prime},\mathbf{Z})]\\ &&\wedge [ \text{Trans}_{((q,q^{\prime\prime}),q^{\prime})}(s,t,t,\mathbf{Z}) \Rightarrow \exists t^{\prime}, \text{RTrans}_{((q,q^{\prime\prime}),q^{\prime})}(t,s,t^{\prime},\mathbf{Z})]\\ &&\wedge [ \text{Trans}_{((q^{\prime\prime},q),q^{\prime})}(s,t,t,\mathbf{Z}) \Rightarrow \exists t^{\prime}, \text{RTrans}_{((q^{\prime\prime},q),q^{\prime})}(t,t^{\prime},s,\mathbf{Z})] \end{array} $$
This formula ensures that you never use two different transitions to label stacks from a single stack labelled with a state
q (in direct and reverse direction). This forces that whenever the automaton has a non-deterministic choice, it only takes one. It furthermore ensures that it is impossible to have two nodes linked by a
\(\text {copy}_{n}^{2}\) or
\(\overline {\text {copy}}_{n}^{2}\) transition labelled without having the third node linked with that transition labelled.
$$\begin{array}{@{}rcl@{}} \text{NoCycle}(\mathbf{Z}) &=& \forall s, \bigvee\limits_{q \in Q} (s \in Z_{q}) \\ &&\Rightarrow\forall X, \left( s \in X \wedge \forall s^{\prime},t,t^{\prime}, \left( s^{\prime} \in X \wedge \left( \bigvee\limits_{K} \text{Trans}_{K}(s^{\prime},t,t^{\prime},\mathbf{Z}) \right)\right)\right. \\ &&\Rightarrow \left.\left( t \in X \wedge t^{\prime} \in X \right) {\vphantom{\bigvee\limits_{K}}}\right) \Rightarrow \bigcup\limits_{q \in F} Z_{q} \cap X \neq \emptyset \\ &&\wedge \left( s \in X \wedge \forall s^{\prime},t,t^{\prime}, \left( s^{\prime} \in X \wedge \left( \bigvee\limits_{K} \text{RTrans}_{K}(s^{\prime},t,t^{\prime},\mathbf{Z})\right)\right) \right.\\ &&\Rightarrow \left.\left( t \in X \wedge t^{\prime} \in X\right) {\vphantom{\bigvee\limits_{K}}}\right) \Rightarrow \bigcup\limits_{q \in I} Z_{q} \cap X \neq \emptyset \end{array} $$
This formula ensures that for any labelled stack, we can find a path of labelled stacks related by the transitions of the automaton which starts in an initial state, and another which ends in a final state.
For the sake of simplicity, let us consider for this proof that D is a unique reduced operation D (if it is a tuple of reduced operations, the proof is the same for every operation).
Init First, let us prove that Init is satisfied. From the previous lemma, all nodes of X
s
are labelled with the labels of input nodes of D (or not labelled), thus they are labelled by initial states (as we considered an accepting labelling of D). Furthermore, as the automaton is distinguished, only these ones can be labelled by initial states. Similarly, the nodes of X
t
, and only them are labelled by final states (or not labelled).
Trans and RTrans We show by induction on the size of the operation that Trans and RTrans are satisfied. For the sake of this proof, we will consider that ρ
q
(resp. σ
q
) are replaced by predicates that are true if and only if the nodes considered are output (resp. input). As Init is satisfied, for an operation accepted by the automaton, ρ
q
will only be true for output nodes and σ
q
for input nodes.
For D = □, the formulæ are true by vacuity.
Suppose now that the formulæ are true for any operation of at most n nodes. Consider D with n + 1 nodes and suppose D = D
1⋅1,1
D
𝜃
⋅1,1
D
2. We call x the output node of D
1 and y the input node of D
2. We take an integer i and a stack tree t and consider the (D,i,t) labelling. By definition it is the (D
1,i,t)(D
2,i,t
′) labelling with t
′ is a stack tree such that \((t,t^{\prime }) \in r_{D_{1}}^{i} \circ r_{D_{\theta }}^{i}\). We call t
″ a stack tree such that \((t,t^{\prime \prime }) \in r_{D_{1}}^{i}\). By definition, we thus have \((t^{\prime \prime },t^{\prime }) \in r_{D_{\theta }}^{i}\). By Lemma 11, we have s
1 = Code(t
″,u
i
) labelled by ρ(x) and s
2 = Code(t
′,u
i
) labelled by ρ(y). As furthermore, we have (s
1,s
2) ∈ r
𝜃
, Trans(ρ(x),𝜃,ρ(y))(s
1,s
2,s
2,Z) and RTrans(ρ(x),𝜃,ρ(y))(s
2,s
1,s
1) are true. Thus Trans and RTrans are true for the (D,i,t) labelling, as by hypothesis of induction they hold for all the nodes of the (D
1,i,t) and (D
2,i,t
′) labellings, x is the only output node of D
1 and y the only input node of D
2.
The other cases for the decomposition of D are similar, and thus omitted. Thus, Trans and RTrans are satisfied for any (D,i,t) labelling.
WellFormed Let us now show that the labelling satisfies WellFormed. We show it by induction. We furthermore show that if a stack s is labelled by an input node x, there is no K ∈ Δ with ρ(x) ∈right(K) and no t,t
′ such that RTrans
K
(s,t,t
′,Z), and that if a stack s is labelled by an output node x, there is no K ∈ Δ with ρ(x) ∈left(K) and no t,t
′ such that Trans
K
(s,t,t
′,Z).
If D = □ or \(D = D_{T_{L}}\), the result is immediate.
Suppose that \(D = (D_{1} \cdot _{1,1} (D_{\text {copy}_{n}^{2}} \cdot _{2,1} D_{3})) \cdot _{1,1} D_{2}\). By induction, WellFormed holds for the (D
1,i,t), (D
2,i,t
′) and (D
3,i + 1,t
′) labellings with \((t,t^{\prime }) \in r_{D_{1}}^{i} \circ r_{\text {copy}_{n}^{2}}^{i}\), and we consider t
″ such that \((t^{\prime \prime },t^{\prime }) \in r_{\text {copy}_{n}^{2}}^{i}\). We call x the only output node of D
1, y and z the only input nodes of D
2 and D
3, s
1 = Code(t
″,u
i
), s
2 = Code(t
′,u
i
) and s
3 = Code(t
′,u
i+1). First, observe that we have Trans(ρ(x),(ρ(y),ρ(z)))(s
1,s
2,s
3,Z), RTrans(ρ(x),(ρ(y),ρ(z))(s
2,s
1,s
1,Z) and RTrans(ρ(x),(ρ(y),ρ(z))(s
3,s
1,s
1,Z), by definition of the labelling. By hypothesis of induction, there are no stacks s,s
′ and no transition K with ρ(x) ∈left(K) (resp. ρ(y) ∈right(K), ρ(z) ∈right(K)) such that Trans
K
(s
1,s,s
′,Z) (resp. RTrans
K
(s
2,s,s
′,Z), RTrans
K
(s
3,s,s
′)) holds in the (D
1,i,t) labelling (resp. the (D
2,i,t
′) or (D
3,i + 1,t
′) labellings). Suppose there are stacks s,s
′,s
″ labelled in the (D,i,t) labelling such that Trans
K
(s,s
′,s
″,Z) holds, such that s,s
′,s
″ are not all labelled in the same D
i
. As A is normalised, all stacks labelled in D
2 and D
3 are labelled with states of Q
c
, and have at least 1 (n − 1)-stack more than stack labelled with states of Q
c
in D
1. Moreover, as s
2 is obtained as the left copy of s
1 and s
2 as the right copy of s
1, it is not possible to produce stacks labelled in D
2 from stacks labelled in D
3 without producing first s
1 (and vice-versa), and as A is normalised, this is impossible. Thus, if all three s,s
′,s
″ are labelled in Q
c
, then s is labelled in D
1 and K is a \(\text {copy}_{n}^{d}\) transition. If s is labelled in Q
d
, then the only possibility for K is also to be a \(\text {copy}_{n}^{d}\) transition. Suppose it is a \(\text {copy}_{n}^{1}\) transition, then s
′ = s
″. Suppose s
′ is labelled in D
2 (the case for D
3 being symmetric). It is thus obtained from s by a \(\text {copy}_{n}^{1}\) operation. But it is also obtained from s
2 which has more (n − 1)-stacks than s and is obtained from s
1 as the left copy of a \(\text {copy}_{n}^{2}\). Thus s
2 have at least as many (n − 1)-stacks as s
′, and to obtain s
′ from s
2 we must first annul that binary copy with a \(\overline {\text {copy}}_{n}^{2}\), which is impossible as A is normalised. Thus we have K is a \(\text {copy}_{n}^{2}\) transition, s is labelled in D
1, s
′ in D
2 and s
″ in D
3. They are thus 𝜃
1, 𝜃
2, 𝜃
3 such that \((s,s_{1}) \in r_{\theta _{1}}\), \((s_{2},s^{\prime }) \in r_{\theta _{2}}\) and \((s_{3},s^{\prime \prime }) \in r_{\theta _{3}}\). Thus we have \(D_{\theta _{1}} \cdot _{1,1} ((D_{\text {copy}_{n}^{2}} \cdot _{2,1} D_{\theta _{3}}) \cdot _{1,1} D_{\theta _{2}})\) equivalent to \(D_{\text {copy}_{n}^{2}}\). Thus as A is normalised, 𝜃
1, 𝜃
2 and 𝜃
3 can only be single tests or empty operations, but as there are no state that can be at the left (resp. right) of both a test and a non-test transition, we get that 𝜃
1, 𝜃
2 and 𝜃
3 are empty operation, and thus that s = s
1, s
′ = s
2, s
″ = s
3 and K = (ρ(x),(ρ(y),ρ(z))). Similarly, if RTrans
K
(s,s
′,s
″) for s,s
′,s
″ not labelled in the same DAG, then K = (ρ(x),(ρ(y),ρ(z))) and s = s
2 or s = s
3 and s
′ = s
″ = s
1. Observe as well that as we added a full transition, we did not add any x,y such that there is a K with RTrans
K
(x,y,y,Z) but no z such that Trans
K
(y,z,x) or Trans
K
(y,x,z) (or the converse). Thus WellFormed holds for the (D,i,t) labelling. Finally, as input nodes of D were input nodes of D
1 (resp. output nodes of D were output nodes of D
2 and D
3), and we did not add them any incoming edge (resp. output edge), the same reasoning apply to show there is no RTrans
K
(resp. Trans
K
)) true with them as first variable, and thus the induction hypothesis holds.
For \(D = D_{2} \cdot _{1,2}(D_{1} \cdot _{1,1} D_{\overline {\text {copy}}_{n}^{2}}))\cdot _{1,1} D_{3}\), the case is similar (by exchanging roles of \(\text {copy}_{n}^{d}\) and \(\overline {\text {copy}}_{n}^{d}\) and so on).
Suppose that D = D
1⋅1,1
D
𝜃
⋅1,1
D
2, and call x the output node of D
1 and y the input node of D
2. We take t
″ such that \((t,t^{\prime \prime }) \in r_{D_{1}}^{i}\) and t
′ such that \((t^{\prime \prime },t^{\prime }) \in r_{\theta }^{i}\), and call s
1 = Code(t
″,u
i
) and s
2 = Code(t
′,u
i
). By definition of the labelling, Trans(ρ(x),𝜃,ρ(y))(s
1,s
2,s
2,Z) and RTrans(ρ(x),𝜃,ρ(y))(s
2,s
1,s
1,Z) hold. By hypothesis of induction, WellFormed holds for the (D
1,i,t) and (D
2,i,t
′) labellings, and there are no K, and no s,s
′ labelled in the (D
1,i,t) labelling (resp. the (D
2,i,t
′) labelling) such that Trans
K
(s
1,s,s
′,Z) holds (resp. RTrans
K
(s
2,s,s
′,Z)). Suppose there are stacks s,s
′,s
″ labelled in the (D,i,t) labelling such that Trans
K
(s,s
′,s
″,Z) holds and s,s
′,s
″ are not all labelled in the same D
i
. Suppose that s is labelled by z
2 in D
2 and s
′ by z
1 in D
1. Then, there is a path from z
1 to z
2 labelled by w which contains 𝜃. But as from ρ(z
2) it is possible to take K, it is thus possible to label a DAG containing w followed by K, which is a non-single test word that can leave s
′ unchanged. As A is normalised, this is impossible. Thus, s is labelled by z
1 in D
1 and s
′,s
″ by z
2 and z
3 in D
2. Call 𝜃
′ the operation of K. There is a path from z
1 to z
2 labelled by an operation w that contains 𝜃, and such that \(r_{w} = r_{\theta ^{\prime }}\). We thus have w = w
1 ⋅ 𝜃 ⋅ w
2 for some operation words w
1,w
2. Suppose 𝜃
′ is a \(\text {copy}_{n}^{d}\) operation. Then s
′ has exactly one (n − 1)-stack more than s and their topmost are equal. As 𝜃 is a non-test and non-tree operation, it must be inverted in w to get s
′ from s. Thus w contains a non-single test operation containing the identity, which is impossible as A is normalised. If 𝜃
′ is a \(\overline {\text {copy}}_{n}^{d}\) operation we get a similar contradiction. Thus 𝜃
′ is a stack operation. Suppose w contains tree operations. As A is normalised, you only can have \(\overline {\text {copy}}_{n}^{d}\) followed by the same number of \(\text {copy}_{n}^{d}\), as 𝜃
′ does not modify the number of (n − 1)-stacks. Thus ρ(z
1) is in Q
d
and ρ(z
2) is in Q
c
. But the only transition between Q
d
and Q
c
are labelled with \(\text {copy}_{n}^{d}\) operations, so this is impossible. Thus w does not contain any tree operation and is thus in Red (as A is normalised). If 𝜃≠𝜃
′ and 𝜃 =copy
i
(resp. \(\overline {\text {copy}}_{j}\)) or 𝜃
′ =copy
j
(resp. \(\overline {\text {copy}}_{j}\)), we get a similar contradiction than for the \(\text {copy}_{n}^{d}\) case. If 𝜃 = 𝜃
′ =copy
i
, similarly to the above case for D, we get that w
1 and w
2 can only be empty operations, thus z
1 = x, z
2 = y, and K = (ρ(x),𝜃,ρ(y)). Suppose 𝜃 =rew
α,β
and 𝜃
′ =rew
γ
δ. As w is in Red, it cannot contain non-single test factors containing the identity, thus it only contains tests and \(\text {rew}_{\alpha ^{\prime }}{\beta ^{\prime }}\) operations. But in a word of Red, there cannot be two \(\text {rew}_{\alpha ^{\prime }}{\beta ^{\prime }}\) operations not separated by a copy
i
or a \(\overline {\text {copy}}_{i}\). Moreover as no state can be at the left of the right of both a test and a non-test transition, we get that w =rew
α,β
and is equivalent to rew
γ
δ. Thus z
1 = x, z
2 = y, and K = (ρ(x),𝜃,ρ(y)). Thus in every case, we have that if Trans
K
(s,s
′,s
″) with s,s
′,s
″ labelled in different D
i
, s = s
1, s
′ = s
″ = s
2 and K = (ρ(x),𝜃,ρ(y)). Similarly, if RTrans
K
(s,s
′,s
″) with s,s
′,s
″ labelled in different D
i
, we get s = s
2, s
′ = s
″ = s
1 and K = (ρ(x),𝜃,ρ(y)). Observe as well that as we added a full transition, we did not add any x,y such that there is a K with RTrans
K
(x,y,y,Z) but no z such that Trans
K
(y,z,x) or Trans
K
(y,x,z) (or the converse). Thus WellFormed holds for the (D,i,t) labelling. Finally, as input nodes of D were input nodes of D
1 (resp. output nodes of D were output nodes of D
2 and D
3), and we did not add them any incoming edge (resp. output edge), the same reasoning apply to show there is no RTrans
K
(resp. Trans
K
)) true with them as first variable, and thus the induction hypothesis holds.
Thus WellFormed holds for the (D,i,t) labelling.
NoCycle Finally, let us show that the labelling satisfies NoCycle. Take s a stack labelled in the (D,i,t) labelling of S
t
a
c
k
s
n−1 with the label of a node x. We show by induction on the size of D that there exists a path of stacks related by basic operations from a stack s
′ labelled with a state labelling an input node of D to s and a path of stacks related by basic operations from s to a stack s
″ labelled with a state labelling an output node of D.
If D = □, the result is immediate, both paths being empty.
Suppose D = D
1⋅1,1
D
𝜃
⋅1,1
D
2, and x is a node of D
1 (the case x is a node of D
2 is symmetric and thus omitted). By hypothesis of induction, there exists s
′ labelled by an input node of D
1 such that there is a path from s
′ to s, and s
″ labelled by the only output node of D
1 such that there is a path from s to s
″. By hypothesis of induction, for s
1 labelled by the only input node of D
2, there exists s
2 labelled by an output node of D
2 such that there is a path from s
1 to s
2. Furthermore, by definition of the labelling, we have (s
″,s
1) ∈ r
𝜃
, and thus, there is a path from s to s
2.
The other cases for the decomposition of D are similar and left to the reader.
Thus, as all its sub-formulæ are true, \(\phi _{A}^{\prime }(X_{s},X_{t},\mathbf {Z})\) is true with the described labelling Z. And thus ϕ
A
(X
s
,X
t
) is true. □
Suppose now that
ϕ
A
(
X
s
,
X
t
) is satisfied. We take a labelling
Z that satisfies the formula
\(\phi _{A}^{\prime }(X_{s},X_{t},\mathbf {Z})\), minimal in the number of nodes labelled. We construct the following graph
D:
$$\begin{array}{@{}rcl@{}} V_{D} =\!\!\!&& \{(x,q) \mid x \in Stacks_{n}(\Gamma \times \{\varepsilon,11,21,22\}) \land x \in Z_{q}\} \\ E_{D} =\!\!\!&& \{((x,q),\theta,(y,q^{\prime})) \mid (\exists \theta, (q,\theta,q^{\prime}) \in \Delta \land \psi_{\theta}(x,y))\}\\ && \cup \{((x,q),1,(y,q^{\prime})), ((x,q),2,(z,q^{\prime\prime})) \mid (q,(q^{\prime},q^{\prime\prime})) \in \Delta\\ && \land \psi_{\text{copy}_{n}^{2},1}(x,y) \land \psi_{\text{copy}_{n}^{2},2}(x,z)\}\\ && \cup \{((x,q),\bar{1},(z,q^{\prime\prime})), ((y,q^{\prime}),\bar{2},(z,q^{\prime\prime})) \mid ((q,q^{\prime}),q^{\prime\prime}) \in \Delta\\ && \land \psi_{\text{copy}_{n}^{2},1}(z,x) \land \psi_{\text{copy}_{n}^{2},2}(z,y)\}\\ && \cup \left\{\left( (x,q),\text{copy}_{n}^{1},(y,q^{\prime})\right) \mid \left( q,\text{copy}_{n}^{1},q^{\prime}\right) \in \Delta \land \psi_{\text{copy}_{n}^{1},1}(x,y)\right\}\\ && \cup \left\{\left( (x,q),\overline{\text{copy}}_{n}^{1},(y,q^{\prime})\right) \mid \left( q,\overline{\text{copy}}_{n}^{1},q^{\prime}\right) \in \Delta \land \psi_{\text{copy}_{n}^{1},1}(y,x) \right\} \end{array} $$
We recall that a well-formed DAG is a DAG where for every nodes x,y, if there is an edge between x and y, then the subDAG obtained by restricting the DAG to x, y, the successors of x and the predecessors of y is a DAG representing a basic operation.
Proof
First, we show that D is a DAG. If not, there exists (x,q) ∈ V such that \((x,q) \xrightarrow {w} (x,q)\), with w a non-empty sequence of operations.
Suppose that w is composed of \(Ops_{n-1} \cup \mathcal {T}_{n-1}\) operations. As WellFormed is satisfied, we thus have a cycle \((x,q) \xrightarrow {w_{1}} (x_{1},q_{1}) {\cdots } (x_{k-1},q_{k-1}) \xrightarrow {w_{k}} (x,q)\) without any other edge touching the (x
i
,q
i
). As NoCycle is satisfied, there is a q
i
initial and a q
j
final. As the automaton is distinguished, there is no transition from q
j
and no transition ending in q
i
, thus we have a contradiction, and such a cycle is impossible.
Thus, there is a tree operation in w. Suppose that the first tree operation appearing in w is a \(\overline {\text {copy}}_{n}^{d}\). As this operation diminishes the number of (n − 1)-stacks in x, and w starts from (x,q) and ends in (x,q), it has to increase again the number of (n − 1)-stacks. This can only be done by a \(\text {copy}_{n}^{d^{\prime }}\) operation. As A is normalised, \(\overline {\text {copy}}_{n}^{d}\) transition starts in Q
d
and \(\text {copy}_{n}^{d^{\prime }}\) transition ends in Q
c
. Thus states of both Q
c
and Q
d
appears on the cycle, and in particular, we have an edge from a state of Q
c
to a state of Q
d
, and thus a transition from Q
c
to Q
d
in A. As A is normalised, this is impossible. If w starts by a \(\text {copy}_{n}^{d}\) operations, we reach the same contradiction.
Thus, D is a DAG.
Now, let us suppose that there are (x,q) and (y,q
′) nodes such that there is an edge \((x,q) \xrightarrow {\theta } (y,q^{\prime })\) and the restriction of D to (x,q), its successors, (y,q
′) and its predecessors is not a basic operation. Suppose for example that there is a node (z,q
″) distinct from (y,q
′) such that \((x,q) \xrightarrow {\theta ^{\prime }} (z,q^{\prime \prime })\) and 𝜃 and 𝜃
′ are operations in \(Ops_{n-1} \cup \mathcal {T}_{n-1} \cup \{\text {copy}_{n}^{1},\overline {\text {copy}}_{n}^{1}\}\). Thus, by definition of D, we have ψ
𝜃
(x,y), \(\psi _{\theta ^{\prime }}(x,z)\), \(y \in Z_{q^{\prime }}\) and \(z \in Z_{q^{\prime \prime }}\). Thus, we have \(\text {Trans}_{(q,\theta ,q^{\prime })}(x,y,y,\mathbf {Z})\) and \(\text {Trans}_{(q,\theta ^{\prime },q^{\prime \prime })}(x,z,z,\mathbf {Z})\) which hold. As WellFormed holds, this is impossible.
Suppose there is a node (z,q
″) such that \((x,q) \xrightarrow {1} (z,q^{\prime \prime })\). By construction of D, there is a transition (q,(q
″,q
″′)) in the automaton, and thus as WellFormed is satisfied, there exists a node (z
′,q
″′) such that \(\text {Trans}_{(q,(q^{\prime \prime },q^{\prime \prime \prime }))}(x,z,z^{\prime },\mathbf {Z})\) holds. But as we have \(\text {Trans}_{(q,\theta ,q^{\prime })}(x,y,y,\mathbf {Z})\), this is impossible (by WellFormed).
The other cases for the neighbourhood of x and y which gives a non-basic operation wield similar contradictions and are left to the reader.
Thus, the restriction of D to (x,q), its successors, (y,q
′) and its predecessors is a basic operation. Therefore, D is well-formed. □
Thus, every D
i
is a well-formed DAG accepted by A. From Lemma 7, we get that D
i
is an operation.
We have proved both directions: for every n-stack trees s and t, there exists a tuple of operations D recognised by A and a tuple of positions i such that \((s,t)\in r_{\mathbf {D}}^{\mathbf {i}}\) if and only if ϕ
A
(X
s
,X
t
). □