On the equivalence between generating functions computed by memory transducers and enumerating functions produced by indexed grammars
Vincent Ghigo
Abstract
We consider the sequences of natural integers that can be computed by a deterministic transducer, with input in a structure A, output in N and with memory the set of stacks of stacks of A. We show that these sequences are, exactly, the counting sequences of formal languages generated by unambiguous context-free indexed grammars (equivalently, the counting sequences of derivation trees of arbitrary context-free indexed grammars), with indexes in A. This general theorem applies, notably, to the set of natural integers endowed with the operation n↦n−1 and the non-zero predicate, showing that the polynomial recurrences count exactly the index-languages (where the parameter used for counting is the index itself).
2012 ACM Subject Classification Theory of computation → Formal languages and automata theory
Keywords and phrases Indexed Grammar, Pushdown Transducer, Enumeration problem
Digital Object Identifier 10.4230/LIPIcs.CVIT.2016.23
Acknowledgements I want to thank my PhD advisors V.Penelle and G.Sénizergues
42nd Conference on Very Important Topics (CVIT 2016).
Editors: John Q. Open and Joan R. Access; Article No.23; pp. 23:1–23:40
Leibniz International Proceedings in Informatics
LIPICS Schloss Dagstuhl – Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany
23:2
1 Introduction
The Context
Relations between automata and grammars is a well-studied topic, in particular for comparing the class of languages they define [4].
This work establishes a similar relation in order to contribute to answering two kinds of questions:
Counting: Given a set E(n) of combinatorial objects (words, trees, planar maps, etc ...) depending on the integer n∈N, what is the number u(n) of these objects? How can it be computed? by which kind of recurrence? or by which kind of transducer?
Representation: Given a sequence u(n) of natural integers (defined by a recurrence or a transducer), can we represent u(n) as the number of objects of some set E(n) of combinatorial objects?
Counting problems are central in combinatorics; therefore, they have been widely studied for many kinds of objects. Representation problems have well-known solutions for N-linear sequences and N-algebraic series; recently, they have been tackled in [11, 1] stimulated by a question about D-finite series raised in ([3], section 6).
The result
The main results of this article are Theorem 1 and Theorem 3, which answer these two questions in the following context:
The counting problem is asked for the set E(σ) of all trees generated by an indexed grammar, where indexes σ belong to a structure A.
The representation problem is asked for the sequences u(σ) computed by a deterministic transducer whose input belongs to a structure A, whose output lies in N, and whose memory consists of the set of stacks of stacks over A.
The framework
We place ourselves in a context in which we study computation models over an arbitrary structure A, following [6]. This allows us to both give general theorems and use techniques that shed light on computation models themselves.
We define a transducer with memory over a structure A, as an automaton with memory in A whose initial memory is given as input.
An indexed grammar on A, as introduced in [2], is a context-free grammar in which each non-terminal is indexed by an element of A, and rules may depend on this element via guards; these rules can also apply operations of A to the index.
As a consequence of the generalization to an arbitrary structure, we also give an answer to the representation problem for transducers with the set of k-stacks of A as memory for all k≥2.
2 Preliminaries
Structure A structure is a tuple <S,Pred,Op> where:
S is a set of elements. We denote by σ an element of S.
Pred is a set of predicates S→{⊤,⊥}.
Op is a set of operations on S→S. We denote by op an element of Op.
23:3
Stack Let A=<SA,PredA,OpA> be a structure and Γ a finite set of symbols.
A stack structure P(Γ,A) is a structure where :
=(Γ×SA)∗ is the set of elements. We note X[σ] an atom (X,σ)∈(Γ×SA).
=PredA∪{PX∣X∈Γ} is the set of predicates, with PX(stk) being true if the topmost symbol of stk is X.
=OpA∪{push(γ)∣γ∈Γ∗} is a set of operations.
We denote by X,Y,Z symbols of Γ, stk an element of (Γ×SA)∗, X[σ] an atom in (Γ×SA) and σ an index in SA. Operations and predicates from A extend to the stack structure by acting/evaluating on the topmost atom of the stack. More formally, we define the application op to a stack as op(X[σ]stk):=X[op(σ)]stk and the evaluation of p∈PredA on a stack as p(A[σ]stk):=p(σ).
Let γ=1X2X…kX∈Γ∗. The operation push(γ) on X[σ]stk erases the topmost atom X[σ]stk and copy the index σ in each symbol of γ. More formally, push(γ) is defined as push(γ)(X[σ]stk):=1X[σ]2X[σ]…kX[σ]stk. For the sake of clarity, we will note push(ε) as pop.
When considering nested stacks, for the sake of clarity, we index stack symbols according to their order, with the outermost stack designated as order 1. We will also label the stack operations by the order. We write Pk(A) for the order k stacks on A when the alphabets are not relevant.
In this article, we consider stacks with bottom-of-stack symbol # and the predicate P#.
Memory transducer An A-transducer is a tuple A:=(Q,T,Δ,q0,A,Start,End), such that:
=Q is the finite set of states and q0∈Q is the initial state. We denote by q,p,r,s elements of Q.
=T is the set of terminal symbols. We denote by a an element of T and aˉ an element of T∪{ε}.
=Start⊆SA is the set of initial elements.
=Δ⊆((Q×F)×(Q×T∪{ε}×OpA)) is the set of rules, where F is the set of boolean formulae over PredA. We note (q,g)→(p,aˉ,op) a rule ((q,g),(p,aˉ,op))∈Δ.
=End∈Q×SA is the accepting configuration.
On A, we use the following semantics:
=the one-step relation δwith δ=((q,gδ)→(p,aˉδ,opδ))∈Δ is {((q,σ),(p,σ′))∣σ′=opδ(σ)∧σ⊨gδ}.
=ε is the identity relation.
=δ,c:=δ.cwith c∈Δ∗.
We call a run (q,σ)c(p,σ′):
=accepting if (p,σ′)=End.
=If A=Pm(B), for some B with m≥1:
23:4
(PA2∧=0,a,pop1)(PB2∧=0,ε,pop2)
Figure 2 Example of P2(N)-transducer computing (i+1)!
= well-nested if operations of order 1 in c form a Dyck word, i.e. there is an equal number of push 1 and pop 1 in c, and for every prefix of c there are more push 1 than pop 1.
= well-formed if c=c′. δ with opδ=pop1 and c′ is well-nested.
We say that A, with TA={a}, computes u:SA→N if A is computing and ∀σ∈Start,(q0,σ)cEnd∧δ⊙aˉδ=au(σ), where ⊙ is a notation for concatenation.
Tree Let S be a set. We define inductively T(S), the set of S-labelled trees, as the set of tuples (σ,l) where l∈T(S)∗ is the list of subtrees and σ∈S is the label of the root. If l is empty, we call (σ,l) a leaf. For a tree t:=(σ,l), we call the label of the root rt(t):=σ. For a list of trees l=t1,t2,…,tk, rt(l):=rt(t1)rt(t2)…rt(tk). For a tree t=(σ,l), we
define the set of labels of the leaves leaf(t):={σ⋃t′∈lleaf(t′)if l=∅else
Indexed grammar An A-grammar scheme is a tuple Gscheme:=(N,T,A,P), such that:
= N is the set of non-terminal symbols. We denote by A, B, C elements of N.
= T is the set of terminal symbols. We denote by a an element of T.
= A is a structure.
P⊆((N×F)×((T∪N)∗×OpA)) is the set of rules, where F is the set of boolean formulae over PredA. We note ((A,g)→(γ,op)) a rule ((A,g),(γ,op))∈P.
We define the derivation trees of a A-grammar scheme as:
Let r=(A,g)→(0β1A1β2A…kAkβ,op)∈P, with iβ∈(T∗) and iA∈N.
The one-step derivation B[σ]→Z is accepted by r if, and only if, B=A, σ⊨g, and Z=0β1A[op(σ)]1β2A[op(σ)]…kA[op(σ)]kβ.
= A derivation tree of G is inductively defined by:
Figure 3 Example of an P(N)-grammar and derivation tree
=(A[σ],l) for l a list of derivation tree such that A[σ]→rt(l) is accepted by a rule of Gscheme.
We define G an A-grammar as a tuple (N,T,A,P,S) such that (N,T,A,P) is a A-grammar scheme and S∈N that we call the axiom. A derivation tree t of Gscheme is a derivation tree of G if ∃σ∈SA,rt(t)=S[σ].
Alternating transducer We will use alternating transducers as a technical object to make the transformation from transducer to grammar easier and more understandable. An alternating P(A)-transducer AAlt:=(Q,T,Δ,q0,P(A),Start,End) is a P(A)-transducer where transitions lead to conjunctions 1 of a state, a non-terminal or ε, and an operation.
= Let δ=(q,g)→(1q,1aˉ,1op)∧…∧(kq,kaˉ,kop)∈Δ. The one-step relation δ is {((q,σ),φ)∣(σ⊨g)∧(φ=(1q,1σ)∧…∧(kq,kσ))∧(⋀1≤i≤kiσ=iop(σ))}.
= A run tree of AAlt is, inductively, defined by:
=((q,stk),∅).
=((q,stk),l) with l a run tree such that rt(l)=(1q,1stk),…,(kq,kstk) and there exists δ∈Δ for which (q,stk)δ⋀1≤i≤k(iq,istk).
= An accepting run tree of AAlt is defined as a run tree where all leaves are (End,∅).
= We write (q,stk)α⋀1≤i≤k(iq,istk) with α∈T(Δ) if there exists a run tree t of AAlt rooted in (q,stk) such that leaf(t)={(1q,1stk),…,(kq,kstk)}, the trees α and t are equivalent up to relabelling and the rule used from a node in t to its children is the label of the corresponding node in α.
= We call a run tree well-formed if all of its branches are well-formed runs.
Symbolic runs Observe that stack operations and predicates only touch the topmost of the stack. Because of this, in transducers and alternating transducers, if there is a run (resp. run tree) from (q,stk), then for every stack r, there is a run (resp. run tree) with the same transitions from (q,stk.r), as r is never observed by said run. To deal with this fact,
1 Rigorously, conjunctions are taken in free distributive lattice on Q×(T∪ε)×Op
23:6
in transducers and alternating transducers, when dealing with sub-runs of the principal run, we use the notion of so-called symbolic runs to represent sets of runs with the same transitions (resp. tree), with a symbol Ω to represent the bottom of the stack that is never observed. This notion is crucial to our proofs, as we show that derivation trees of the grammars we construct are in bijection with symbolic runs of transducers, rather than with concrete runs.
3 From indexed grammar to memory transducer
In this part, we prove the following theorem:
► Theorem 1. Let G be a A-indexed grammar, without infinite derivations, producing u(σ) derivation trees from the axiom indexed by σ for all σ∈SA. There exists a P2(A)-transducer that computes u(σ).
3.1 Grammar normal form
Without loss of generality, we consider a A-grammar in a normal form similar to Chomsky normal form for context-free grammars. This normal form separates terminal production, non-terminal production and operation on index.
where ∣∥ is a syntactic sugar for non-determinism.
For every non-terminal, we allow at most one rule in the previous form, and for every rule in the previous form, we add a complementary guard rule.
Complementary:
(A,¬g)→□
The complementary rules guarantee that every indexed non-terminal generates a tree. The □ symbol allows us to distinguish derivation trees generated by these rules.
3.2 Computing transducer
Theorem 1 is obtained by providing an explicit transducer T1(G). Its main idea is to simulate each derivation tree with an order 2 stack, and to encode non-determinism via push1 operations. We ensure the absence of deadlocks in the transducer by the guarantee that every indexed non-terminal generates a tree thanks to the absence of infinite derivations and the complementary rules. The transformation of complementary rules ensures no a is produced in the subrun corresponding to trees with □.
► Definition 2. Let G=(N,T,A=<S,Pred,OP>,P,S) be a A-grammar in normal form as defined in Section 3.1.
Proof Sketch of Theorem 1. For the sake of simplicity, we prove this lemma for leftmost derivations (that corresponds to derivation trees; see section 4.3 in [10]) instead of derivation trees. We prove by structural induction that if there are i leftmost derivation from a word u∈(N×S)∗ in G then the run from (q,X1[u#2]Ω1) produces the word ai.
The principal difficulty is for OR rules because of non-determinism. This is solved by noticing that, in G, the number of leftmost derivation from A[σ].u correspond to the addition of the number of leftmost derivation from B[σ].u and from C[σ].u and that, in T1(G), the word produced from (q0,X1[B2[σ]u#2]X1[C2[σ]u#2]Ω1) is equivalent to the word produced from (q0,X1[B2[σ]u#2]Ω1) concatenated with the word produced from (q0,X1[C2[σ]u#2]Ω1).
4 From memory transducer to index grammar
For the rest of the paper, we fix A=(QA,{a},ΔA,q0,P({X1,#1},P(Γ,A)),StartA,(qend,#1)) a P2(A)-transducer with StartA={X1[Start2[σ]#2]#1∣σ∈S}, without cycle in the configuration graph, called after a livelock, from any configuration, computing a mapping u:A→N and A=<S,Op,P> a structure.
In this part, we prove the following theorem:
▶ Theorem 3. There exists a A-indexed grammar producing u(σ) derivation trees from the axiom indexed by σ, for all σ∈SA.
The lower part creates from A a grammar enumerating the function u whose trees correspond to productive pop1 of the accepting run of A. This grammar will use additional predicates to ensure its trees only represent correct portions of the accepting run of A. The upper part creates a grammar in which non-terminals correspond to these additional predicates: those non-terminals produces a single derivation tree from a non-terminal if and only if the corresponding additional predicate is true and non otherwise. Then, we merge the two grammars into one by replacing predicates with the corresponding non-terminals.
The majority of the lemmas in this section are true for a P2(A)-transducer with livelock from non-reachable configurations; but the final merging step is not necessarily true for P2(A)-transducer with livelock.
23:8
Figure 4 Road map for Theorem 3
4.1 Transducer normal form
Without loss of generality, we consider that, in A, every run from any configuration terminates with stack #12, there is only one order 1 symbol in addition to the bottom-of-stack symbol, operations pushi push at most 2 symbols and only rules using pop1 can produce a. Consequently, there is a sink state ⊥ and rules are in the following form:
Rules on ⊥ are (⊥,¬P#2)→(⊥,ε,pop2) and (⊥,P#2)→(p,ε,pop1).
Observe that this normal form preserves the absence of livelock.
4.2 Enumerating grammar with predicates
4.2.1 Transducer with predicates
► Lemma 4. There exists a P(A)-transducer using additional predicates producing u(σ) runs from X[σ]# for all σ∈SA.
This lemma is obtained by providing a non-deterministic P(A)-transducer T2(A) is such that runs from (q,stk) correspond to pop1 operations occurring in runs of A from (q,X1[stk]Ω). Thus, a run of T2(A) corresponding to a pop1 operation simulates the order-2 stack that is popped by this operation, while keeping only the transitions that affects it. Runs whose corresponding pop1 operations are productive are accepting; the others are rejecting. Hence, T2(A) has i accepting runs from (q,stk) if and only if the run of A from (q,X1[stk]Ω) produces ai.
Figure 5 represents, in black, a symbolic well-formed run of A, and, in colors, the corresponding runs of T2(A).
To achieve this, in T2(A), order-2 and operation transitions of A are preserved. Transitions producing pop1 are replaced with transitions to an accepting state, while push1 transitions are replaced by transitions that follow the new topmost 2-stack, together with non-deterministic transitions that follow the remaining one below it (whose computation occurs after the
² That we obtain by completing the transducer
23:9
corresponding pop1). Consequently, we need to know the state in which the computation of A will be after the pop1 operation. This is the key technical difficulty in the proof of Theorem 3. This is achieved by introducing P(p,r), which is used in this section; its computability will be established later. The determinism and completeness of A ensure that, given a stack stk and a state p, there exists exactly one state r such that P(p,r) holds. Thus, every push1 rule of A corresponds to exactly two rules of T2(A).
The computing property of A ensures its determinism and totality. Therefore, no predicate is needed for the second stack added by push1.
Figure 5 visualization of symbolic well-formed runs in a run
► Definition 5. We define T2(A):=(QA∪{⊤},∅,ΔT2(A),q0,PT2(A)(Γ2,A),StartT2(A),(⊤,#)) where StartT2(A)={X[σ]#∣σ∈S} and PT2(A) is a stack augmented with predicates {Pq,p∣q,p∈Q} and where ΔT2(A)=⋃δ∈ΔAT2(δ) with:
If δ is an unproductive pop1 rule then T2(δ)=∅
If δ is a productive pop1 rule then T2(δ)={(q,P#)→(⊤,ε,id)}
If δ is a push1 rule then T2(δ)={(q,g)→(p,ε,id)(q,g∧Pp,r)→(r,ε,id)∣r∈Q}
Else T2(δ)={δ}
Following the notation used in Section 4.1
A predicate Pp,r(stk) is true if and only if (p,A1[stk]Ω1)∗A(r,Ω1).
Proof Sketch of Lemma 4. The proof consists in a structural induction on symbolic well-formed runs of A from q,X1[stk]Ω1. It shows that for any such run with kpop1, there is k runs of T2(A) from q,stk. The conclusion is obtained by the fact that the accepting run is a well-formed run. ◃
For the rest of the paper, we denote T2(A) as APred=(QPred,∅,ΔPred,q0,PPred(Γ,A),{X[σ]#∣σ∈SA},(⊤,#)).
4.2.2 Grammar with predicates
► Lemma 6. There exists a A-grammar using additional predicates producing u(σ) derivation trees from S[σ] for all σ∈SA.
This lemma is obtained by providing an explicit transformation T3. The main idea is that each derivation tree rooted at the axiom indexed by σ represents an accepting run of APred
23:10
on σ. To achieve this, we use a triple grammar (Chapter 5.4 in [9]), in which a non-terminal is composed of the current state, the current symbol, and a guess of the state reached after popping the current atom.
The predicates added by APred cannot be used directly, since they apply on a stack which is not explicit. We therefore need to add a fourth component to the non-terminals.
Consequently, each derivation tree rooted at an indexed non-terminal (q,X,p,M)[σ] represents a well-formed run starting from the current atom X[σ], in state q, and ending in state p.
Figure 6 transformation of a well-formed run of APred into derivation tree of T3(APred)
In a non-terminal, we memorize in M all pairs of states (q,p) such that Pq,p holds on the current simulated stack after popping the current element. More precisely, a non-terminal (q,X,p,M)[σ] represents the equivalence class of configurations (q,X[σ]stk) such that M is the set of pairs of states (q,p) for which P(q,p)(stk) holds. The memories are computed step by step by adding predicates PM′,M,Z(σ) to rules simulating push2T2. This relies on the fact that Pq,p(A[σ]stk) holds if and only if there exists a state r such that Pr,p(stk) holds and (q,A[σ]stk)∗APred(r,stk). The computed memories are then used in rules simulating push1, in place of the predicates P(q,p).
► Remark 7. By determinism, completeness, and the absence of livelocks in A, we ensure that the possible memory values of non-terminals always form a total function.
► Definition 8. We define T3(APred):=(N,∅,AT3(APred),S,PT3(APred)) with
Proof of Lemma 6. We prove this lemma in two steps.
We exhibit a total surjective function from the well-formed runs of APred to the derivation trees of T3(APred) not rooted in S. This is done by promoting T3 to a relation from the well-formed runs of APred to the derivation trees of T3(APred) that are not rooted in S, and by showing that this relation is a total function. Surjectivity is achieved by establishing the totality of T3−1, both by structural induction. The key idea is to notice that T3 associates a run (q,X[σ]stk)∗APred(p,stk) with the derivation tree rooted in (q,X,p,M)[σ], where
M={(q,p)∣q,X1[stk]Ω1∗A(p,Ω1)}.
Then, we exhibit a bijection from the well-formed runs of APred starting from (q0,X[σ]#) to the derivation trees of T3(APred) rooted in S. We show that this relation is a total surjective function by proving that the rules on S preserve the totality, the surjectivity and the functionality proved before. Finally, we establish injectivity by showing that T3−1 is a function, since stk is uniquely determined in every configuration appearing in an accepting run.
For the rest of the paper, we denote T3(APred) as GPred=(TPred,∅,APred,S,PPred) with \mathbb{A}_{Pred} = \left\langle \mathcal{S}, \mathcal{P} \cup \{\mathcal{P}_{M',M,X} | M', M \subseteq (\mathcal{Q}_{Pred} \times \mathcal{Q}_{Pred}) \land X \in \Gamma\}\right\rangle, op\right\rangle.
4.3 Boolean output grammar
We construct, from A, a A-grammar with the aim of replacing the predicates used in T3(T2(A)). This notion of grammar should not be confused with the notion of conjunctive grammar introduced by A. Okhotin [12]. Intuitively, our grammar returns a Boolean value in response to a query to the underlying transducer: the answer is true if and only if there exists a corresponding derivation tree, and false otherwise. This grammar respects the syntax given in the preliminaries.
4.3.1 Alternating transducer
Lemma 9. There exists a P(A) alternating transducer having states in (Q×Q) producing a unique accepting run tree from ((q,p),stk) if and only if there exists a symbolic well-formed
23:12
run from (q,X1[stk]Ω1) to (p,Ω1) in A, and none otherwise.
This lemma is obtained by providing an explicit transformation T4. Its main idea is to contract runs into run trees whose leaves correspond to its pop1. In a run of A, rules are applied to the topmost order 2 stack. A branch of a run tree of AAlt simulates the part of the associated run of A corresponding to an order 2 stack or its predecessor. For a run tree of AAlt, the associated run of A can be reconstructed by a depth-first search on the run tree. When the topmost order 2 stack changes via an order 1 operation, we must ensure state coherence in AAlt despite the lack of state synchronization caused by the contraction. Similar to Section 4.2.2, this is achieved by assuming the state in which the topmost stack created by push1 will be popped and by verifying this assumption in the rule obtained from pop1. If the guess is incorrect, the branch fails, hence also the full tree.
Figure 7 visualization of the simulation of run in Figure 5
► Definition 10. We define T4(A):=(QT4(A),∅,ΔT4(A),q0T4(A),P(Γ2,A),StartT4(A),(⊤,#)) where :
QT4(A)=(QA×QA)∪{⊤}
ΔT4(A)=⋃δ∈ΔAT4(δ) where T4(δ) is defined by:
If δ is a pop1 rule then T4(δ)={((q,p),P#)→(⊤,ε,id)}
If δ is a push1 rule then T4(δ)={∣(r∈Q)∧(s∈Q)((q,s),g)→((p,r),ε,id)∧((r,s),ε,id)}
Else T4(δ)={((q,s),g)→((p,s),ε,op)∣s∈Q}
Following the notation used in Section 4.1.
q0T4(A)=(q0,qfin)
StartT4(A)={Start2[σ]#∣σ∈SA}
Proof Sketch of Lemma 9. We exhibit a bijection between the symbolic well-formed runs of A and the accepting run trees of T4(A). This is done by promoting T4 to a relation from the symbolic well-formed runs of A to the accepting run trees of T4(A), and by showing that both T4 and T4−1 are total functions. Both directions are solved by structural induction, using the determinism of A.
We state a lemma that can be regarded as the key lemma of this part.
23:13
► Lemma 11. (uniqueness property) For all q∈QA, X[σ]∈Γ2×Sh and ψ∈P(QA×QA) functional, ∃≤1p∈QA, φ⊆ψ, α∈T(ΔT4(A)), \left((q,p), X[\sigma]\Omega\right) \xrightarrow[\substack{T_4(\mathcal{A}) \\ (q_i,p_i) \in \varphi}}{\alpha} \bigwedge_{(q_i,p_i) \in \varphi} ((q_i,p_i), \Omega).
From now on, we call ϕq,X,ψ,σ the subset of ψ and pq,X,ψ,σ the state such that
This uniqueness property is necessary in the definition of the enumerating grammar. In it, when eliminating the additional predicates, we need to know ϕq,X,ψ,σ. This can be handled with a non-deterministic guess, as thanks to the uniqueness property, at most one guess can produce a tree.
As a consequence of this lemma, there exists at most one (q′,pq,X,ψ,σ) ending state for the lower branch, i.e. the branch corresponding to the second symbol for every push1T4, for a state q, an atom X[σ], and a functional set ψ. We denote this state by (qq,X,ψ,σ,pq,X,ψ,σ).
Proof Sketch of Lemma 11. For the sake of simplicity, we prove this lemma by proving it for any stack stk instead of X[σ]. We establish this property by structural induction on run trees. By the determinism of A, only one rule r can be applied to a given configuration in A. Consequently, only rules produced by T4(r) can be applied in T4(A). The only minor difficulty concerns the rules obtained from the transformation of push1 rules due to the union of the two branches. This is solved by the conservation of p through the run tree in the upper branch, fixing the state q in the lower branch. ◃
For the rest of the paper, we denote T4(A) as AAlt=(QAlt,∅,ΔAlt,q0,P(Γ2,A),{X[σ]#∣σ∈Sh},(⊤,#)).
4.3.2 Proof grammar
► Lemma 12. There exists a grammar producing one derivation tree from (X,{(q,p)}→φ)[σ] with φ functional if and only if ((q,p),X[σ]Ω)∗AAlt⋀(qi′,pi′)∈φ((qi′,pi′),Ω), and zero otherwise.
This lemma is obtained by providing an explicit transformation T5. Its main idea is, once again, to represent each atom of a stack AAlt as a non-terminal. Once again, the idea is similar to that of a triple grammar, but adapted to alternating transducers. Due to the fact that alternating transducers produce run trees rather than runs, the third component is the set of states reached after popping the current atom, rather than a single state. These sets are separated by rules simulating push1 and are verified as singletons during the simulation of pop rules. As an extension of Lemma 11, thanks to Lemma 12, we ensure that the grammar produces exactly one derivation tree from an indexed non-terminal (X,(q,p)→φ)[σ], and no derivation tree otherwise, if and only if p=pq,X,ψ,σ and φ=ϕq,X,ψ,σ for all ψ such that φ⊆ψ.
► Definition 13. We consider an arbitrary total order < on the states of AAlt. We define
\begin{aligned}Decomp=&\left\{\left(\left(X,\left(\left\{(q,p)\right\}\cup\psi\right)\rightarrow\left(\varphi_{1}\cup\varphi_{2}\right)\right),\top\right)\\&\rightarrow\left(\left(A,\left(\left\{(q,p)\right\}\rightarrow\varphi_{1}\right)\right)\left(A,\left(\psi\rightarrow\varphi_{2}\right)\right),id\right)\\&\left|\psi,\varphi_{1},\varphi_{2}\in\mathcal{P}(\mathcal{Q}_{Alt}),\forall v\in\psi,(q,p)<v\right\}\end{aligned}\begin{aligned}If r~is~op_{T_{4}}~then\quad&T_{5}(r)=\left\{\left(\left(Z,\left(\left\{(q,s)\right\}\rightarrow\varphi\right)\right),g\right)\\&\rightarrow\left(\left(Z,\left(\left\{(p,s)\right\}\rightarrow\varphi\right)\right),op\right)\Bigg|\varphi\in\mathcal{P}(\mathcal{Q}_{Alt})\Bigg\}\end{aligned}\begin{aligned}If r~is~pop_{2_{T_{4}}}~then\quad&T_{5}(r)=\left\{\left(\left(Z,\left(\left\{(q,s)\right\}\rightarrow\left\{(p,s)\right\}\right)\right),g\right)\rightarrow\left(\varepsilon,id\right)\right\}\\ If r~is~renaming_{2_{T_{4}}}~then\quad&T_{5}(r)=\left\{\left(\left(Z,\left(\left\{(q,s)\right\}\rightarrow\varphi\right)\right),g\right)\\&\rightarrow\left(\left(X,\left(\left\{(p,s)\right\}\rightarrow\varphi\right)\right),id\right)\Bigg|\varphi\in\mathcal{P}(\mathcal{Q}_{Alt})\Bigg\}\end{aligned}\begin{aligned}If r~is~push_{2_{T_{4}}}~then\quad&T_{5}(r)=\left\{\left(\left(Z,\left(\left\{(q,s)\right\}\rightarrow\varphi\right)\right),g\right)\rightarrow\\&\left(\left(X,\left(\left\{(p,s)\right\}\rightarrow\psi\right)\right)\left(Y,\left(\psi\rightarrow\varphi\right)\right),id\right)\\&\left|\psi,\varphi\subseteq\mathcal{P}(\mathcal{Q}_{Alt})~functional\right\}\end{aligned}\begin{aligned}If r~is~pop_{1_{T_{4}}}~then\quad&T_{5}(r)=\left\{\left(\left(\#,\left(\left\{(q,p)\right\}\rightarrow\top\right)\right),\top\right)\rightarrow\left(\varepsilon,id\right)\right\}\\ If r~is~push_{1_{T_{4}}}~then\quad&T_{5}(r)=\left\{\left(\left(Z,\left(\left\{(q,s)\right\}\rightarrow\left(\varphi_{1}\cup\varphi_{2}\right)\right)\right),g\right)\\&\rightarrow\left(\left(Z,\left(\left\{(p,r)\right\}\rightarrow\varphi_{1}\right)\right)\left(Z,\left(\left\{(r,s)\right\}\rightarrow\varphi_{2}\right)\right),id\right)\\&\left|\varphi_{1},\varphi_{2}\in\mathcal{P}(\mathcal{Q}_{Alt})\right\}\end{aligned}
Following the notation used in Section 4.1 and Definition 10
Proof Sketch of Lemma 12. We consider the promotion of T5 as a relation from the symbolic well-formed run trees to the derivation trees. We prove that T5−1 is a total function using Lemma 11. Then, we prove a uniqueness property lemma, that follows from Lemma 11, for the derivation trees of the grammar scheme and we use it to prove that T5 is a total function.
23:15
In all parts of this proof, we consider a promotion T5 as a relation from the symbolic well-formed run trees of AAlt to the derivation trees of T5(AAlt) rooted in (X,(q,p)→φ)[σ]. The relation T5 associates a symbolic well-formed run tree ((q,p),X[σ]Ω)∘(φ,Ω) with a derivation tree from (X,(q,p)→φ)[σ].
We first prove, via structural induction from (X,(q,p)→φ)[σ] with φ functional, that T5−1 is total. Functionality follows immediately, since there is at most one symbolic well-formed run tree from ((q,p),X[σ]Ω) to (φ,Ω) with φ functional, as established in Lemma 11.
Secondly, we prove via structural induction that T5 is total. We prove that T5 is functional if there is a uniqueness property for derivation trees of T5(AAlt) rooted in (X,(q,p)→φ) with φ functional.
So, finally, we prove that for all non-terminals (X,(q,p)→φ) with φ functional, there exists at most one derivation tree rooted in the non-terminal. There is a minor difficulty for pushT5 due to the addition of ψ. This is solved by the order < on states of AAlt, ensuring uniqueness in the separation made by Decomp, and the functionality of ψ allowing the use of Lemma 11.
◃
For the rest of the paper, we denote T5(AAlt) as GProof=(TProof,∅,A,PProof).
4.4 Enumerating grammar
We give a transformation creating, from GPred and GProof, a A-grammar satisfying Theorem 3. This transformation consists in a substitution of each predicate PM′,M,A in GPred by a concatenation of non-terminals (A,(qi,pi)→Mi) of GProof with (qi,pi)∈M′ and Mi⊆M. Thanks to the uniqueness property in GProof for every subset of a functional set, and M is functional by Remark 7, we can use non-determinism to guess the correct Mi for every element of M′ without multiplying the number of derivation trees.
► Definition 14. We define T6(GPred,GProof):=(TPred∪TProof,∅,A,PProof∪⋃r∈PPredT6(r),SPred).
Proof of Theorem 3. By Lemma 6, the grammar T6(GPred,GProof) produces u(σ) derivations trees from SPred for all σ∈SA if the substitution of PM′,M,X produces one derivation tree if and only if the predicate is true and zero otherwise.
23:16
By Lemma 11 and Lemma 12, we know that there exists a derivation tree from (X,(qi,pi)→Mi)[σ] only if (qqi,X,M,σ,pqi,X,M,σ)∈Mi. By rewriting the property given for qqi,X,M,σ in Section 4.3.1, we have that ∀stk∈SP(A), such that M={(q,p)∣q,X1[stk]Ω1∗Ap,Ω1}
Which is equivalent to the definition of PM′,M,X[σ] given in Definition 8, thanks to the totality of M and M′ as stated in Remark 7.
5 Conclusions and further work
Using effective proofs, we have shown that functions computed by P2(A)-transducers are equivalent to functions enumerating trees generated by A-grammars. Since a stack built over a structure is itself a structure, we obtain the following corollary:
Corollary 15. The following classes of functions are equivalent:
functions computed by Pk+2(A)-transducers;
functions enumerating trees generated by Pk(A)-grammars.
In the case where A is the structure on N endowed with the operation n↦n−1 and the non-zero predicate, since the sequences defined by polynomial recurrences are computed by deterministic transducers with memory in stacks of stacks of N ([7], Proposition 53), our result shows that such sequences can be represented by context-free grammars with indexes in N.
This link between transducers and combinatorial objects, can be thought of as an extension of the well-known links between N-linear recurrences and regular grammars, N-algebraic recurrences and context-free grammars (see the surveys [13, 5, 3]).
Since they are contained in series defined by polynomial recurrences, this framework could be used to identify syntactic restrictions on indexed grammars to answer the representation problem for D-finite series.
23:17
References
1 Jared Adams, Eric Freden, and Marni Mishna. From indexed grammars to generating functions. RAIRO Theor. Informatics Appl., 47(4):325-350, 2013. URL: https://doi.org/10.1051/ita/2013041, doi:10.1051/ITA/2013041.
2 Alfred V. Aho. Indexed grammars - an extension of context-free grammars. J. ACM, 15(4):647-671, 1968. doi:10.1145/321479.321488.
3 Mireille Bousquet-Mélou. Algebraic generating functions in enumerative combinatorics and context-free languages. In Volker Diekert and Bruno Durand, editors, STACS 2005, 22nd Annual Symposium on Theoretical Aspects of Computer Science, Stuttgart, Germany, February 24-26, 2005, Proceedings, volume 3404 of Lecture Notes in Computer Science, pages 18-35. Springer, 2005. doi:10.1007/978-3-540-31856-9_2.
5 Maylis Delest. Algebraic languages: A bridge between combinatorics and computer science. In Louis J. Billera, Curtis Greene, Rodica Simion, and Richard P. Stanley, editors, Formal Power Series and Algebraic Combinatorics, Proceedings of a DIMACS Workshop, USA, May 23-27, 1994, DIMACS Series in Discrete Mathematics and Theoretical Computer Science, pages 71-87. DIMACS/AMS, 1994. URL: https://doi.org/10.1090/dimacs/024/04, doi:10.1090/DIMACS/024/04.
7 Séverine Fratani and Géraud Sénizergues. Iterated pushdown automata and sequences of rational numbers. Ann. Pure Appl. Log., 141(3):363-411, 2006. URL: https://doi.org/10.1016/j.apal.2005.12.004, doi:10.1016/J.APAL.2005.12.004.
9 Michael A. Harrison. Introduction to Formal Languages Theory. Addison-Wesley, 1978.
10 John E. Hopcroft and Jeffrey D. Ullman. Introduction to Automata Theory, Languages and Computation. Addison-Wesley, 1979.
11 Tomer Kotek and Johann A. Makowsky. A representation theorem for holonomic sequences based on counting lattice paths. Fundam. Informaticae, 117(1-4):199-213, 2012. doi:10.3233/FI-2012-696.
12 Alexander Okhotin. Conjunctive grammars. J. Autom. Lang. Comb., 6(4):519-535, 2001. URL: https://doi.org/10.25596/jalc-2001-519, doi:10.25596/JALC-2001-519.
13 Gérard Viennot. Enumerative combinatorics and algebraic languages. In Fundamentals of computation theory (Cottbus, 1985), volume 199 of Lecture Notes in Comput. Sci., pages 450-464. Springer, Berlin, 1985. doi:10.1007/BFb0028829.
23:18
Contents
1 Introduction 2
2 Preliminaries 2
3 From indexed grammar to memory transducer 6
3.1 Grammar normal form ..... 6
3.2 Computing transducer ..... 6
4 From memory transducer to index grammar 7
4.1 Transducer normal form ..... 8
4.2 Enumerating grammar with predicates ..... 8
4.2.1 Transducer with predicates ..... 8
4.2.2 Grammar with predicates ..... 9
4.3 Boolean output grammar ..... 11
4.3.1 Alternating transducer ..... 11
4.3.2 Proof grammar ..... 13
4.4 Enumerating grammar ..... 15
5 Conclusions and further work 16
A Annexe 18
A.1 Section 3.1 proof ..... 18
A.2 Theorem 1 proof ..... 24
A.3 proof of Section 4.1 ..... 25
A.4 Lemma 4 proof ..... 30
A.5 Complete Definition 8 ..... 31
A.6 Lemma 9 proof ..... 31
A.7 Lemma 11 proof ..... 34
A.8 Lemma 12 proof ..... 35
A Annexe
A.1 Section 3.1 proof
In this part we will proof the following lemma.
Lemma 16. There exists a transformation from a A-grammar to a normal form that preserves the number of □-free derivation trees generated from the axiom indexed by σ∈SA.
We prove this with two transformation. First, we show a transformation such that the resulting grammar satisfy the required rule form. Second, we show a transformation such that the resulting grammar satisfy the “only one rule per non-terminal” condition using only rule in the required form. Finally, we add the complementary rules.
A.1.0.1 First transformation
Let G=(N,T,A,P,S) be a A-grammar.
We consider that every non-terminal have at least one rule applying on them. If a non-terminal A infringes these properties we solve it by adding the rule (A,⊥)→(ε,id) We first
23:19
define a transformation Tsep from a A-grammar to a grammar satisfying the required rule forms.
According to its definition, Tsep(G) satisfies the required rule forms.
► Lemma 18. Let G=(N,T,A,P,S) be a A-grammar that produces u(σ) derivation trees from S[σ]. Then the A-grammar Tsep(G) produces u(σ) derivation trees rooted in S[σ].
Proof. Let G=(N,T,A,P,S) be a A-grammar, and let Tsep(G)=(N,TTsep(G),A,PTsep(G),S).
We exhibit a bijection between derivation trees of G and derivation trees of Tsep(G) rooted in non-terminals in T. This is done by promoting Tsep to a relation between derivation trees of G and derivation trees of Tsep(G) rooted in non-terminals in T, and showing that Tsep and Tsep−1 are total functions.
Direction 1 We first prove that the promotion of Tsep from derivation trees of G to derivation trees of Tsep(G) rooted in non-terminals in T is a total function. The proof proceeds by structural induction on derivation trees of G.
Let d be a derivation tree whose first applied rule is r=(pr,gr)→(αr1αr2…αrk,opr), where αi∈(N∪T):
Then Tsep(d) is:
23:20
By definition, there exists exactly one rule associated with each non-terminal Ari and Bri. By the induction hypothesis, Tsep(di) is uniquely defined for each i. Hence, Tsep(d) is uniquely determined. Therefore, the promotion of Tsep defines a total function on derivation trees.
Direction 2 We now prove that Tsep−1, from derivation trees of Tsep(G) rooted in non-terminals in T to derivation trees of G, is a total function. The proof proceeds by structural induction on derivation trees of Tsep(G) rooted in non-terminals in T.
The only rules on non-terminals in T are of the form (pr,gr)→(Ar1,opr). Let t be a derivation tree of Tsep(G) rooted in pr, whose first applied rule is (pr,gr)→(Ar1,opr). By definition, this rule is followed by rules on Ari and Bri.
23:21
By construction, the rules (pr,gr)→(Ar1,opr) together with rules on Ari and Bri exists if and only if there exists a rule r=(pr,gr)→(αr1…αrk,opr) in G.
By the induction hypothesis, Tsep−1(ti) exists in G and is uniquely determined for each i. Hence, Tsep−1(t) is uniquely determined. Therefore, Tsep−1 defines a total function.
A.1.0.2 Second transformation
We next give a transformation Trule from a A-grammar obtained by Tsep to a grammar satisfying the "only one rule per non-terminal" property.
▶ Lemma 20. Let G=(N,T,A,P,S) be a A-grammar that produces u(σ) derivation trees from S[σ]. Then the A-grammar T1rule(Tsep(G)) produces u(σ) derivation trees rooted in S[σ].
Proof. Let Gsep=Tsep(G) and T1rule(Gsep)=(N,TT1rule(Gsep),A,PT1rule(Gsep),S).
We exhibit a bijection between derivation trees of Gsep and derivation trees of T1rule(Gsep) rooted in indexed non-terminals in Tsep. This is done by promoting T1rule to a relation between derivation trees of Gsep and derivation trees of T1rule(Gsep) rooted in indexed non-terminals in Tsep, and showing that T1rule and T1rule−1 are total functions.
Direction 1 We first prove that the promotion of T1rule from derivation trees of Gsep to derivation trees of T1rule(Gsep) rooted in indexed non-terminals in TGsep is a total function. The proof proceeds by structural induction on derivation trees of Gsep.
By definition, all non-terminals added by the transformation Tsep have only one rule. Therefore, by the definition of ⨁, T1rule does not transform rules on these non-terminals, and the induction is trivial for derivation trees rooted in these non-terminals.
Let A be a non-terminal in T. Let R={r1,…,r#(R)} be the set of rules on A and D={d1,…,d#(R)} the corresponding derivation tree of Gsep rooted in A, such that the first applied rule in di is ri=(A,gi)→(Ai,opi).
By the induction hypothesis, T1rule(di′) is uniquely determined. Hence T1rule(di) is uniquely determined. Therefore, the promotion of T1rule defines a total function on derivation trees.
Direction 2 We now prove that T1rule−1, from derivation trees of T1rule(Gsep) rooted in indexed non-terminals in TGsep to derivation trees of Gsep, is a total function. The proof proceeds by structural induction.
By definition, all non-terminals added by Tsep have only one rule. Therefore, by definition of ⊕, the induction is trivial for derivation trees rooted in these non-terminals.
The only rules on non-terminals in T are of the form (A,⊤)→(C⨁j≤k−1rj∣Crk,id). Let t be a derivation tree of T1rule(Gsep) rooted in A:
23:24
By definition, such a rule exists if and only if there are k rules on A in Gsep. By induction, there exists exactly one derivation tree d such that T1rule(d)=ti.
Therefore, T1rules−1 is a total function.
A.2 Theorem 1 proof
We prove that the word produce by the well formed run from q0,X1[u#2] in T1(G), that we write tT1(G)(X1[u#2]), is equal to the number of leftmost derivation from u without □ on leaves in G, that we write #LmDG(u), for every u∈(N×S)∗, i.e.
∀u∈(N×S)∗,tT1(G)(X1[u#2])=#LmDG(u)
Since G is in normal form, only one rule r can be applied to the leftmost letter of u.
If r is a Complementary rule (A,¬g)→(□,id) then #LmDG(u)=0.
By T1, there is a rule (q0,PX1∧PA2∧¬g)→(q0,ε,pop1).
By normal form and determinism of T1, there is no other rules on (q0,X1[u#2]), so tT1(G)(X1[u#2])=tT1(G)(ε)=0.
Then tT1(G)(X1[u#2])=#LmDG(u)=0.
If r is a Dumping rule (A,g)→(aˉ,id) then #LmDG(u)=#LmDG(u′)=i.
By T1, there is a rule (q0,PX1∧PA2∧g)→(q0,ε,pop2).
By induction tT1(G)(X1[u′#2])=i.
By normal form and determinism of T1, there is no other rules on (q0,X1[u#2]), so tT1(G)(X1[u#2])=tT1(G)(X1[u′#2])=i.
Then tT1(G)(X1[u#2])=#LmDG(u)=i.
23:25
If r is a Operation rule (A,g)→(B,op) then #LmDG(u)=#LmDG(u′)=i.
By T1, there is rules δ1:δ2:(q0,PX1∧PA2∧g)→(qr,ε,op)(qr,⊤)→(q0,ε,push2(B2))
By induction tT1(G)(X1[u′#2])=i.
By T1 there is no other rule than δ2 on qr.
By normal form and determinism of T1, there is no other rules on (q0,X1[u#2]), so tT1(G)(X1[u#2])=tT1(G)(X1[u′#2])=i.
Then tT1(G)(X1[u#2])=#LmDG(u)=i.
If r is a AND rule (A,g)→(BC,id) then #LmDG(u)=#LmDG(u′)=i.
By T1, there is a rule (q0,PX1∧PA2∧g)→(q0,ε,push2(B2C2)).
By induction tT1(G)(X1[u′#2])=i.
By normal form and determinism of T1, there is no other rules on (q0,X1[u#2]), so tT1(G)(X1[u#2])=tT1(G)(X1[u′#2])=i.
Then tT1(G)(X1[u#2])=#LmDG(u)=i.
If r is a OR rule (A,g)→(B∣C,id) then #LmDG(A[σ]u)=#LmDG(B[σ]u)+#LmDG(C[σ]u)=i+j.
By induction tT1(G)(X1[B2[σ]u#2])=i and tT1(G)(X1[C2[σ]u#2])=j.
By T1 there is no other rule than δ2 on qr and no other rule than δ3 on qr′.
By normal form and determinism of T1, there is no other rules on (q0,X1[u#2]), so tT1(G)(X1[A2[σ]u#2])=tT1(G)(X1[B2[σ]u#2]X1[C2[σ]u#2]).
Notice that tT1(G)(X1[B2[σ]u#2]X1[C2[σ]u#2])=tT1(G)(X1[B2[σ]u#2])+tT1(G)(X1[C2[σ]u#2]).
So, tT1(G)(X1[A2[σ]u#2])=tT1(G)(X1[B2[σ]u#2])+tT1(G)(X1[C2[σ]u#2])=i+j.
Then tT1(G)(X1[A2[σ]u#2])=#LmDG(A2[σ]u)=i+j.
If A[σ]→ε then #LmDG(A[σ])=1.
By rule (q0,PX1∧P#2)→(q0,a,pop1), and the fact that it is the only rule on #2, then tT1(G)(X1[#2])=1.
By induction tT1(G)(X1[A[σ]#2])=1.
A.3 proof of Section 4.1
In this part, we will prove the following lemma.
Lemma 21. There exists a function that transforms a P2(A)-transducer into normal form while preserving the computed function.
We prove this result through three rule transformations. First, we show a transformation such that pushi operations are binary and unary. Second, we show a transformation such that only rules applying the pop1 operation produce a using only binary and unary pushi operations. Finally, we show a transformation satisfying the “single order 1 symbol” condition keeping the previous properties.
Let A=(Q,T,Δ,P(Γ1,P(Γ2,A)),Z,End) be a computing P2(A)-transducer.
The property allowing pop1 only when the topmost order 2 symbol is #2 can easily be ensured by adding a draining state performing pop2 transitions until #2 is reached. Hence, we assume that this property holds in A.
23:26
A.3.0.1 First transformation
As stated in the proof sketch, we first define a transformation Tbin that decomposes every n-ary pushi, for n > 2, into a sequence of unary and binary pushi operations.
▶ Definition 22. We define Tbin(A)=(QAbin,T,ΔAbin,A,Z,End) where ΔAbin=⋃r∈ΔTbin(r). For a rule r=(q,gr)→(p,aˉ,opr):
▶ Lemma 23. Let A be a P2(A)-transducer computing u(σ). Then Tbin(A) computes u(σ).
Proof. We establish a bijection between symbolic well-formed runs of A and symbolic well-formed runs of Tbin(A) starting from stacks containing only symbols in Γ1 and Γ2.
We promote Tbin as a relation between such runs and prove that both Tbin and Tbin−1 are total functions.
Direction 1 We prove by structural induction on symbolic well-formed runs of A that the promotion of Tbin is a total function.
Case 1: opr∈OpA∪{popi}.
Let
c=q,A1[stk2]Ω1rc1→q′,Ω1
be a symbolic well-formed run of A.
Since Tbin(r)=r, by construction,
Tbin(c)=q,A1[stk2]Ω1rTbin(c1)q′,Ω1.
By induction hypothesis, Tbin(c1) is uniquely defined. Hence so is Tbin(c).
Uniqueness follows from construction and induction hypothesis.
Direction 2 We prove that the relation Tbin−1, from the symbolic well-formed runs of Tbin(A) over stacks using only symbols in Γ1 and Γ2, to the symbolic well-formed runs of A, is a total function. The proof proceeds by structural induction on symbolic well-formed runs of Tbin(A) using only symbols in Γ1 and Γ2.
Let c=q,A1[stk2]Ω1rc1r,Ω1 be a symbolic well-formed run of Tbin(A) starting with a rule r=(q,gr)→(p,aˉ,opr) such that opr∈OpA∪{popi}.
By construction, Tbin−1(r)=r. Therefore,
Tbin−1(c)=q,A1[stk2]Ω1rTbin−1(c1)r,Ω1.
By induction, there exists exactly one c1′, a symbolic well-formed run of A, such that Tbin−1(c1)=c1′. Hence, there exists exactly one c′, a symbolic well-formed run of A, such that Tbin−1(c)=c′.
Let c be a symbolic well-formed run of Tbin(A) starting with a rule r=(q,gr)→(p,aˉ,push2(Ark−1Ark)). By construction, using the uniqueness of rules on added states:
By construction, r exists in Tbin(A) if and only if there exists r′=(q,gr)→(p,aˉ,push2(Ar1…Ark)) in Δ. By induction, there exists exactly one c1′ such that Tbin−1(c1)=c1′, and hence exactly one c′ such that Tbin−1(c)=c′.
Let c be a symbolic well-formed run starting with r=(q,gr)→(p,aˉ,push1(Ark−1Ark)). By construction and uniqueness of rules on added states:
By induction, there exists exactly one ci′ such that Tbin−1(ci)=ci′, and hence exactly one c′ such that Tbin−1(c)=c′.
23:29
A.3.0.2 Second transformation
We now define a transformation Tprod from the computing P2(A)-transducer Tbin(A) to a computing transducer satisfying the "only pop1 can produce" property while preserving the "unary and binary pushi" property.
▶ Definition 24. We define Tprod(Tbin(A))=(Qprod,T,Δprod,P(Γ1,P(Γ2,A)),Z,End) where Δprod=⋃r∈ΔTbin(A)Tprod(r).
For a rule r=(q,PA1∧gr)→(p,aˉ,opr) in ΔTbin(A), we define:
▶ Lemma 25. Let A=(Q,T,Δ,A,Z,End) be a P2(A)-transducer computing u(σ). Then Tprod(Tbin(A)) is a P2(A)-transducer computing u(σ).
Proof. The proof is analogous to the proof for Tbin. The construction only delays output production until a pop1 transition is performed. This delay is deterministic and finite, hence it preserves runs and the computed function.
A.3.0.3 Third transformation
We finally define a transformation Tsymb from the computing P2(A)-transducer Tprod(Tbin(A)) to a computing transducer satisfying the “only one order 1 symbol” property while preserving the “unary and binary pushi” and “only pop1 can produce” properties.
▶ Definition 26. Let A=(Q,T,Δ,P(Γ1,P(Γ2,A)),Z,End) with Z={A1[A2[σ]#2]#1∣σ∈A}, and let Aprod=Tprod(Tbin(A)).
▶ Lemma 27. Let A be a computing P2(A)-transducer computing u(σ). Then T1symb(Tprod(Tbin(A))) is a computing P2(A)-transducer computing u(σ).
Proof. This construction follows the encoding introduced by Fratani in Chapter 8 of her thesis [8], restricted to order 1. Her thesis provides a detailed correctness proof, which applies verbatim in our setting.
A.4 Lemma 4 proof
Let c be a symbolic well-formed-run of A from (q,stk.Ω).
If the first rule δ of c is a pop1 rule then that is the only rules of c and stk=X1[#2]. If δ is non-productive then c produce a0. By definition of T2 and the determinism of A, there is no rules, then 0 accepting run, from q,#2.
If δ is productive then c produce a1. By definition of T2 there exists an accepting run (q,#)T2(δ)T2(A)(⊤,#), since T2 do not change the guard on #. By definition of T2 and the determinism of A, there exists no other rules on q,#. So, T2(A) produce 1 accepting runs from (q,#)
If the first rule δ of c is a push 1 rules then c is
As said in the proof sketch we prove both direction separately.
direction 1: T4 is a total function
Let c be a symbolic well-formed-run of A from (q,X1[stk].Ω).
If the first rule δ of c is a pop 1 rule then
c=(q,X1[#2]Ω1)δA(p,Ω1)
By definition of T4, there exists an accepting run tree ((q,p),#2)→(⊤,#2). By the determinism of A and definition of T4, there exists no other rules on ((q,p),#2) and there is no accepting run tree from ((q,p′),#2) for p′=p.
By induction, there exists no accepting run trees from ((p, r'), stk) for r' ≠ r and no accepting run trees from ((r, s'), stk) for s' ≠ s.
Then, there is no accepting run trees starting by rules obtained by T4(δ) for r′=r or s′=s. By the determinism of A and definition of T4, there exists no other rules on ((q, s'), stk) for all s′∈Q.
For other type of rules, T4 is the same. So, we just make the proof for operation rules as an example.
By induction, there exists no accepting run trees from ((p,s′),op(stk)) for s′=s.
Then, there is no accepting run trees starting by rules obtained by with T4(δ) for s′=s. By the determinism of A and definition of T4, there exists no other rules on ((q,s′),stk) for all s′∈Q.
23:33
direction 2: T4−1 is a total function
Let α be an accepting run tree of A from ((q,s),stk).
If the first rule δ of α is ((q,s),P#)→(⊤,ε,id) then
α=((q,s),#)δT4(A)(⊤,#)
By definition of T4, there exists δ∈ΔT4(A) if and only if there exists a rule (q,P#)→(s,ε,pop1)∈ΔA. So, there exists a symbolic well-formed run (q,X1[#2]Ω1)T4−1(δ)A(s,Ω1). By determinism of A, there exists no other rules on (q,X1[#2]Ω1).
If the first rule δ of α is ((q,s),g)→((p,r),ε,id)∧((r,s),ε,id) rule then α is
((q,s),stk)
By definition of T4, there exists δ∈ΔT4(A) if and only if there exists a rule (q,g)→(p,ε,push1(X1X1))∈A.
By induction, there exists a symbolic well-formed run
(q,X1[stk]Ω1)T4−1(δ)A(p,X1[stk]X1[stk]Ω1)T4−1(α1)A(r,X1[stk]Ω1)T4−1(α2)A(s,Ω1)
By determinism of A, there exists no other rules on (q,X1[stk]Ω1).
For other type of rules, T4 is the same. So, we just make the proof for operation rules as an example.
If the first rule δ of α is ((q,s),g)→((p,s),ε,op) rule then α is
23:34
By definition of T4, there exists δ∈ΔT4(A) if and only if there exists a rule (q,g)→(p,ε,op)∈ΔA.
By induction, there exists a symbolic well-formed run
By determinism of A, there exists no other rules on (q,X1[stk]Ω1).
A.7 Lemma 11 proof
Let q∈Q, u∈SP(A) and ψ⊆P(Q×Q) a functional set.
Let α a run tree (q,p), stk.ΩαT4(A)⋀(qi,pi)∈φ(qi,pi), Ω with φ⊆ψ.
We prove that there is not s′=s,φ′=φ and α′ such that (q,p′), stk.Ωα′T4(A)⋀(qi,pi)∈φ′(qi,pi), Ω with φ′⊆ψ.
If the first rule δ of α is ((q,s),g)→((p,r),ε,id)∧((r,s),ε,id) then α is
We note (p,r), stk.Ωα1T4(A)⋀(qi,pi)∈φ1(qi,pi), Ω
and (r,s), stk.Ωα2T4(A)⋀(qi,pi)∈φ2(qi,pi), Ω.
By definition of T4, there exists, for all r′∈Q, rule: ((q,s),g)→((p,r′),ε,id)∧((r′,s),ε,id)
23:35
By induction, for all r′=r there is no φ1′⊆ψ such that (p,r′), stk.Ωα1′T4(A)⋀(qi,pi)∈φ1′(qi,pi), Ω.
By induction, there is no φ1=φ1′ such that (p,r), stk.Ωα1′T4(A)⋀(qi,pi)∈φ1′(qi,pi), Ω with φ1′⊆ψ.
and there is no φ2=φ2′ such that (r,s), stk.Ωα2′T4(A)⋀(qi,pi)∈φ2′(qi,pi), Ω with φ2′⊆ψ.
So, there is no φ=φ′ such that (q,s), stk.Ωα′T4(A)⋀(qi,pi)∈φ′(qi,pi), Ω with φ′⊆ψ.
For s′=s there is a rule (q,s′), stk()T4(A)(p,r), ε, id)∧((r,s′),ε, id).
By induction, there is no φ2′⊆ψ such that (r,s′), stk.Ωα2′T4(A)⋀(qi,pi)∈φ2′(qi,pi), Ω.
So, there is no φ=φ′ or s′=s such that (q,s′), stk.Ωα′T4(A)⋀(qi,pi)∈φ′(qi,pi), Ω with φ′⊆ψ.
If the first rule δ of α is an other type of rule then α is
((q,s),stk)((p,s),stk′)
By induction, there exists no φ′=φ or s′=s ( p,s′), stk′. Ωα1T4(A)⋀(qi,pi)∈φ′(qi,pi), Ω with φ′⊆ψ.
By definition of T4 and determinism of A, the only rule on (q,s′), stk.Ω is ((q,s′),g)→((p,s′),ε,op).
Consequently, there is no φ=φ′ or s′=s such that (q,s′),stk.Ωα′T4(A)⋀(qi,pi)∈φ′(qi,pi), Ω with φ′⊆ψ.
A.8 Lemma 12 proof
As said the proof sketch, we consider a promotion T5 as a relation from the symbolic well-formed run trees of AAlt to the derivation trees of T5(AAlt) rooted in (X,(q,p)→φ)[σ]. The relation T5 associates symbolic well-formed run tree (q,p),X[σ]Ω∘φ,Ω with derivation trees from (X,(q,p)→φ)[σ].
23:36
direction 2: T5−1 is a total function
As stated in the proof sketch, the functionality of T5−1 is direct since there is at most one symbolic well-formed run tree from q,X[σ] to φ functional as established in Lemma 11.
We prove that T5−1 is total.
Let t be a derivation tree of T5(AAlt) from (Z,(q,s)→φ)[σ].
If t is
(Z,(q,s)→(p,s))[σ]
ε
Then, there is a rule r=((Z,(q,s)→(p,s)),g)→(ε,id))∈PT5(Aalt).
By definition of T5, there is such rule if and only if there is a rule ((q,s),g)→((p,s),ε,id)∈ΔAlt. So, there is a well-formed run tree (q,p),Z[σ]Ω)T5−1(r)Aalt(⊤,#).
If t is
(Z,(q,s)→φ)[σ]
(Z,(p,s)→φ)[op(σ)]
t1
Then, there is a rule r=((Z,((q,s)→φ)),g)→((Z,((p,s)→φ)),op))∈PT5(Aalt).
By definition of T5, there is such rule if and only if there is a rule ((q,s),g)→((p,s),ε,op)∈ΔAlt.
By induction on t1, there is a symbolic well-formed run ((p,s),Z[op(σ)]Ω)T5−1(t1)AAlt((φ,Ω).
So, there is a symbolic well-formed run tree ((q,s),Z[σ]Ω)T5−1(r)AAlt((p,s),Z[op(σ)]Ω)T5−1(t1)AAlt(φ,Ω).
If t is
23:37
(Z,(q,s)→φ)[σ](X,(p,s)→φ)[σ]t1
Then, there is a rule r=((Z,((q,s)→φ)),g)→((X,((p,s)→φ)),id))∈PT5(Aalt).
By definition of T5, there is such rule if and only if there is a rule ((q,s),g)→((p,s),ε,push2(X))∈ΔAlt.
By induction on t1, there is a symbolic well-formed run ((p,s),X[σ]Ω)T5−1(t1)AAlt((φ,Ω).
So, there is a symbolic well-formed run tree ((q,s),Z[σ]Ω)T5−1(r)AAlt((p,s),X[σ]Ω)T5−1(t1)AAlt(φ,Ω).
So, by the the totality of T5−1, there no derivation trees (Z,(p,r′)→φ1′)[σ] and (Z,(r,s)→φ2′)[σ] for r=r′, φ1′=φ1 and φ2′=φ2.
23:40
By induction, t1 is the only derivation tree from (Z,(p,r)→φ)[σ] and t2 is the only derivation tree from (Z,(r,s)→φ)[σ].
Then, t is the only derivation tree from (Z,(q,s)→φ)[σ].
For each case of this induction, we proceed similarly.
There is a minor difficulty for push2T4 due to the add of ψ. Which is solved by the functionality of ψ allowing the use of Lemma 11 and the order > on state of Aalt, ensuring the uniqueness on the separation made by Decomp and ψ.
direction 2: T5 is a total function
As stated in the proof sketch, the functionality of T5 is direct since there is at most one derivation tree rooted in (A,(q,s)→φ) with φ functional.
We prove that T5 is total by structural induction on well formed run trees of AAlt similarly to the proof of totality for T5−1.