Real-Time Multitape Languages Transfer to
Parsing Expression Grammars
via Persistent Stacks in Scaffolding Automata

Joshua Gay1

Expanded reading edition · 5 September 2026

One new node can preserve several changing stacks

A stack is a sequence whose first item can be pushed or popped. A persistent stack keeps old versions available: pushing an item creates a new head pointing to the old stack, while popping selects an already existing tail. Nothing has to erase the old version.

The obstacle in a scaffolding automaton seems to be its pace. It may create exactly one physical graph node for each incoming symbol. What if the simulated machine changes several stacks during that symbol?

The construction makes one physical node represent a tuple of logical stack heads. Its label stores one top symbol per stack. Its named edges store the corresponding tails. The number of stacks and the symbol alphabet are fixed in advance, so the tuple label still belongs to a finite alphabet. There is no need to allocate a separate physical node for every logical head.

For example, suppose the two stacks are ab and x, with their tops written first. The next symbol asks us to pop the first and push y onto the second. The result should be b and yx. The new node stores the label pair (b,y). Its first edge skips to the first stack’s old second tail; its second edge points to the old physical top, whose second component begins with x. Following the first named port decodes one stack, and following the second decodes the other. The same physical node can therefore be an old record for both stacks without confusing their meanings.

Only a bounded neighborhood is needed. Push refers to the old top; keep refers to one old tail; pop reads the old tail’s head and refers to its tail. Two edge steps suffice. The proof below also treats empty stacks, because an empty pop must not expose a stale symbol from an older version.

This gives a route from ordinary work tapes to parsing expression grammars. Represent a tape by the cells to the left of its head, the currently scanned symbol, and the cells to its right. The two sides are stacks. A head move pushes the symbol just written onto one side and pops the next scanned symbol from the other. A fixed number of tapes therefore becomes a fixed number of persistent stacks, all updated together.

Loff, Moreira, and Reis’s characterization then says that a scaffold for a language gives a PEG for its reversal. This direction matters: the construction does not assert that every real-time language itself has a PEG. Even palindromes are a useful application because reversing an even palindrome leaves the same word, so the orientation disappears in that case.

The real-time premise is exact. A machine that spends a long time after the last input symbol is outside it. So is a bound that averages cheap and expensive steps while allowing an arbitrarily expensive individual step. The article proves the machine-to-scaffold transfer directly; its palindrome application uses the classical recognizer and the source-model correspondence developed in Section 6 and Appendix C.

The main mechanism is in the update table of Section 3. The tape calculation in Section 4 explains why it applies to ordinary machines. The final part identifies which conclusions also use the historical real-time palindrome results. This positive construction complements the late-query obstruction: persistence can make a great deal of old information locally available, but it cannot make every future query cheap.

1 Introduction

Parsing expression grammars (PEGs), introduced by Ford [1], are recognition-based grammars whose ordered choice operator gives them behavior quite different from context-free grammars. Loff, Moreira, and Reis introduced scaffolding automata and proved that they characterize PEG languages up to reversal [4, Theorem 16]. They also proposed the following test of the formalism’s power: EPAL2:={wwR:w∈{0,1}∗},\mathsf{EPAL}_2 :=\{ww^R:w\in\{0,1\}^*\}, the language of even-length binary palindromes. Their Conjecture 7 states that EPAL2∉PEG\mathsf{EPAL}_2\notin\mathsf{PEG}.

The key observation of this paper is that one scaffold node can act as a persistent cons cell for several logical stacks at once. Its finite label is a tuple of stack-top symbols, and its named backward ports point independently to the persistent predecessor of each stack. Thus one physical append operation can perform a fixed tuple of logical memory updates.

This yields the main transfer theorem.

Theorem 1.1 (Real-time transfer). Let LL be recognized by a finite deterministic strict real-time multitape Turing machine with a fixed positive number of ordinary single-head work tapes. The machine receives one input symbol and makes one global transition per step, has no input-length advice, and performs no post-input computation. Then LR∈PEG.L^R\in\mathsf{PEG}.

Together with the online lower bound already proved by Loff–Moreira–Reis, the transfer gives a proper class containment: rev(RT-MTTM)⊊PEG.\mathsf{rev}(\mathsf{RT\text{-}MTTM})\subsetneq\mathsf{PEG}.

The proof has two parts. First, a fixed collection of stacks, each performing one push, keep, or pop operation per input symbol, is simulated letter-for-letter by a distance-two scaffolding automaton. Second, the usual two-stack zipper represents each Turing tape. The resulting scaffold has degree 2m2m for an mm-tape machine.

The proof path is therefore strict real-time multitape machine⟶2m persistent stacks⟶degree-2m scaffold⟶PEG for the reverse.\begin{aligned} \boxed{\text{strict real-time multitape machine}} &\longrightarrow \boxed{2m\text{ persistent stacks}}\\ &\longrightarrow \boxed{\text{degree-}2m\text{ scaffold}}\\ &\longrightarrow \boxed{\text{PEG for the reverse}}. \end{aligned} The construction is effective, although the generic PEG obtained by direct expansion is not expected to be compact or human-readable.

Slisenko constructs a real-time multitape palindrome recognizer [6]. Leong and Seiferas give an ordinary single-head multitape implementation [3]. A parity bit restricts the recognizer to even lengths. Since (EPAL2)R=EPAL2(\mathsf{EPAL}_2)^R=\mathsf{EPAL}_2, theorem 1.1 gives the announced consequence.

Corollary 1.2. EPAL2∈PEG\mathsf{EPAL}_2\in\mathsf{PEG}. Hence Conjecture 7 of Loff–Moreira–Reis is false.

The historical direction is worth noting. Loff, Moreira, and Reis explicitly investigated whether reversals of PEG languages admit efficient online Turing-machine recognition and refuted that proposed containment [4, Section 5.3]. The construction here travels from strict real-time machines to scaffolding automata and then applies their characterization.

2 Models and conventions

For a word x=x1⋯xnx=x_1\cdots x_n, write xR=xn⋯x1x^R=x_n\cdots x_1, and for a language LL, write LR={xR:x∈L}L^R=\{x^R:x\in L\}. For a language class C\mathcal C, define rev⁡(C)={LR:L∈C}.\operatorname{rev}(\mathcal C)=\{L^R:L\in\mathcal C\}. All alphabets and state sets below are finite. Throughout, PEG\mathsf{PEG} is Loff–Moreira–Reis’s class of ordinary total PEGs: the start expression must succeed while consuming the complete input. This is complete-match PEG semantics, not a prefix-acceptance variant [4, Definitions 1–4].

2.1 Scaffolding automata

We use the model of Loff, Moreira, and Reis [4, Definitions 10–15]. A scaffold of degree dd consists of a sequence of labelled nodes. Each node has dd named ports, and every port is either missing or points to a node no later than its source. The scaffold begins with an unlabelled base node.

On each input symbol, the automaton appends exactly one labelled node. Its transition sees the state and the depth-kk unfolding of the old top: a partial, labelled, dd-ary tree that records labels along named port paths but not node identity. Each port of the new node may be left missing, may target the new node itself, or may target the endpoint of a port word of length at most kk starting at the old top. The fixed constants dd and kk are the degree and distance.

Acceptance depends on the finite control state immediately after the last input symbol. The characterization we use is:

Theorem 2.1 (Loff–Moreira–Reis). For every language KK, K∈PEG⟺KR is decided by a scaffolding automaton.K\in\mathsf{PEG} \quad\Longleftrightarrow\quad K^R\text{ is decided by a scaffolding automaton}.

Lemma 2.2 (Fresh initial state). Every finite scaffolding automaton AA has an equivalent finite scaffolding automaton A⋆A^\star whose initial state occurs only before the first input symbol. The construction preserves acceptance of the empty word and every nonempty word without inserting an input step.

Proof. Let q0q_0 be the old initial state, introduce one fresh state q⋆q_\star, and retain an injected copy ι(q)\iota(q) of every old state, including ι(q0)\iota(q_0). The new initial state is q⋆q_\star. On its first input symbol and observed neighborhood, q⋆q_\star performs exactly the old q0q_0-transition, with the returned state injected by ι\iota. From every ι(q)\iota(q), perform the old qq-transition and inject its returned state. Thus no transition returns q⋆q_\star, while a transition that formerly returned q0q_0 now returns the ordinary recurrent copy ι(q0)\iota(q_0).

Declare q⋆q_\star accepting exactly when q0q_0 was accepting, and declare ι(q)\iota(q) accepting exactly when qq was. The empty computation therefore has the same acceptance value. After the first symbol, the old and new computations have the same scaffold and corresponding control states; an induction over the remaining symbols preserves both facts. Hence all nonempty decisions also agree. Adding one state preserves finiteness and changes neither the scaffold alphabet nor its degree or distance. ◻

This is the state duplication used without loss of generality in the sufficient direction of Loff–Moreira–Reis Theorem 16 [4, p. 23].

2.2 Strict real-time multitape machines

We use the letter-synchronous real-time convention of Rosenberg [5]: after each arriving input symbol, the machine performs exactly one transition and the resulting state reports the answer for the prefix then seen.

Definition 2.3. A strict real-time mm-tape machine MM, where m≥1m\geq 1, has a finite input alphabet Σ\Sigma, finite tape alphabet TT with a blank symbol, finite control QQ, and mm ordinary two-way work tapes with one head per tape. Its transition function has the form δ:Q×Σ×Tm⟶Q×(T×{−1,0,+1})m.\delta:Q\times\Sigma\times T^m \longrightarrow Q\times(T\times\{-1,0,+1\})^m. At each step exactly one new input symbol is supplied, one global transition is made, and every work-tape head writes and moves by at most one cell. Acceptance of a prefix is determined by the resulting control state.

The input is an arriving symbol, not a preloaded input tape. In particular, the transition receives neither the total input length nor an end-of-input work interval.

3 Parallel persistent stacks

We first isolate the mechanism responsible for the transfer. Consider a deterministic finite-control machine with s≥1s\geq 1 stacks over a finite alphabet AA. On every input step it reads the ss top symbols and performs one of push⁡(a),keep⁡,pop⁡\operatorname{push}(a),\qquad \operatorname{keep},\qquad \operatorname{pop} on each stack. Popping an empty stack leaves it empty.

We construct a scaffolding automaton of degree ss and distance two. Reserve port jj for stack jj, and take the scaffold alphabet to be Γ=(A∪{⊥})s.\Gamma=(A\cup\{\bot\})^s. For a scaffold node vv, let λj(v)\lambda_j(v) denote component jj of its label and let ej(v)e_j(v) be its port-jj target. Adjoin a sentinel ∅\varnothing and set ej(∅)=∅,λj(∅)=⊥.e_j(\varnothing)=\varnothing, \qquad \lambda_j(\varnothing)=\bot. An unlabelled node also has component ⊥\bot. Following an invalid port path yields ∅\varnothing, exactly as the missing-edge clause in Loff–Moreira–Reis Definition 13 requires.

The stack rooted at vv is decoded recursively by Dj(v)={ε,λj(v)=⊥,a Dj(ej(v)),λj(v)=a∈A,(1)D_j(v)= \begin{cases} \varepsilon,&\lambda_j(v)=\bot,\\ a\,D_j(e_j(v)),&\lambda_j(v)=a\in A, \end{cases} \tag{1} with Dj(∅)=εD_j(\varnothing)=\varepsilon. The recursion terminates because the construction uses only strictly backward targets.

3.1 The update table

Let vv be the old scaffold top and v+v^+ the new one. Component jj of v+v^+ and port jj are selected as follows:

operation new component λj(v+)\lambda_j(v^+) new target ej(v+)e_j(v^+)
push⁡(a)\operatorname{push}(a) aa vv, named by ε\varepsilon
keep⁡\operatorname{keep} λj(v)\lambda_j(v) ej(v)e_j(v), named by jj
pop⁡\operatorname{pop} λj(ej(v))\lambda_j(e_j(v)) ej(ej(v))e_j(e_j(v)), named by jjjj
Figure 1. For one component jj, the selected operation chooses one of three targets already visible within distance two of the old top. One physical node carries the independently selected component and port for every jj.

Every label read and every target named by this table occurs in the depth-two unfolding of vv. The same newly appended node carries all ss component and port choices simultaneously.

The empty-stack case requires one invariant. Define CleanEmpty(S)⟺∀v∈V∪{∅},j,λj(v)=⊥⟹λj(ej(v))=⊥.(2)\mathsf{CleanEmpty}(S) \quad\Longleftrightarrow\quad \forall v\in V\cup\{\varnothing\},j, \lambda_j(v)=\bot \Longrightarrow \lambda_j(e_j(v))=\bot. \tag{2} Thus a node that terminates stack jj points, if anywhere, to another node that also terminates stack jj. This prevents an empty pop from exposing a stale symbol through a historical port.

Lemma 3.1 (Persistent-stack update). Suppose the old scaffold is strictly backward and satisfies CleanEmpty\mathsf{CleanEmpty}. After appending the node specified by the table, the decoded stack at v+v^+ is exactly the result of the selected stack operation. The new scaffold is strictly backward and again satisfies CleanEmpty\mathsf{CleanEmpty}.

Proof. The three rows are literal list equations. Push gives Dj(v+)=aDj(v)D_j(v^+)=aD_j(v); keep copies the old head and tail; and a nonempty pop copies the head and tail of Dj(ej(v))D_j(e_j(v)). For an empty pop, CleanEmpty\mathsf{CleanEmpty} makes that copied head ⊥\bot, so no stale symbol reappears. The same three cases preserve strict backwardness and CleanEmpty\mathsf{CleanEmpty}. Appendix A gives the sentinel-explicit calculation and a simultaneous two-stack example. ◻

Theorem 3.2 (Parallel persistent stacks). Every deterministic letter-synchronous finite-control machine with a fixed positive number ss of stacks, performing at most one push, keep, or pop per stack and per input symbol, is simulated exactly by a degree-ss, distance-two scaffolding automaton.

Proof. Interpret the unlabelled base as the empty root for every stack. It is strictly backward and satisfies CleanEmpty\mathsf{CleanEmpty}. The scaffold state is the stack machine’s finite control. On each input symbol, the transition reads the old top components, computes the stack machine’s next control and operations, and appends the tuple-valued node specified above.

Induction on the input length, using lemma 3.1, shows that the controls agree and that every decoded scaffold stack equals its source stack after every prefix. Therefore the accepting states agree. ◻

4 From work tapes to persistent stacks

Represent work tape ii by a zipper (Li,ci,Ri),(L_i,c_i,R_i), where cic_i is the scanned symbol, LiL_i lists the cells strictly to the left of the head in nearest-first order, and RiR_i lists the cells strictly to the right in nearest-first order. The scanned symbols (c1,…,cm)(c_1,\ldots,c_m) are stored in finite control. Blank cells beyond the finite lists are supplied by the fixed blank convention. Here ⊔\sqcup is an ordinary tape-alphabet symbol; ⊥\bot means that a finite stack has no next element and is not a tape symbol. Initially Li=Ri=εL_i=R_i=\varepsilon and ci=⊔c_i=\sqcup on every tape.

For extensional comparison with the source tape, define cell⁡L,c,R(z)={c,z=0,L−z,z<0 and that entry exists,Rz,z>0 and that entry exists,⊔,otherwise.(3)\operatorname{cell}_{L,c,R}(z)= \begin{cases} c,&z=0,\\ L_{-z},&z<0\text{ and that entry exists},\\ R_z,&z>0\text{ and that entry exists},\\ \sqcup,&\text{otherwise}. \end{cases} \tag{3}

Suppose the machine writes bib_i and then moves its ii-th head. The zipper updates are: right:(Li,ci,Ri)↦(biLi,head⁡⊔(Ri),tail⁡(Ri)),left:(Li,ci,Ri)↦(tail⁡(Li),head⁡⊔(Li),biRi),stay:(Li,ci,Ri)↦(Li,bi,Ri).(4)\begin{array}{rcl} \text{right:}& (L_i,c_i,R_i)&\mapsto (b_iL_i,\operatorname{head}_{\sqcup}(R_i),\operatorname{tail}(R_i)),\\[2mm] \text{left:}& (L_i,c_i,R_i)&\mapsto (\operatorname{tail}(L_i),\operatorname{head}_{\sqcup}(L_i),b_iR_i),\\[2mm] \text{stay:}& (L_i,c_i,R_i)&\mapsto (L_i,b_i,R_i). \end{array} \tag{4} Consequently each ordinary tape transition performs at most one operation on each of the two stacks Li,RiL_i,R_i. All mm tapes update in parallel.

Lemma 4.1 (Tape zipper). Every strict real-time mm-tape machine is simulated letter-for-letter by a finite-control machine with 2m2m stacks, performing at most one push, keep, or pop on each stack per input symbol.

Proof. Use the representation (4). The source transition depends only on the finite control, the arriving input symbol, and the mm scanned symbols. The new scanned symbols are determined by the written symbols, move directions, and the old top symbols of the 2m2m stacks. Hence they can be placed in the next finite-control state. Equation (4) assigns one stack operation to each zipper half. A direct calculation shows that right and left moves translate every reconstructed offset by one while recording the symbol just written, and that stay changes only offset zero. Induction over the input prefix therefore gives equality at every integer offset, including both implicit blank tails. The three extensional equations are written out in Appendix B. ◻

Theorem 4.2 (Strict machine-to-scaffold simulation). Let MM be a strict real-time mm-tape machine, m≥1m\geq 1. There is a scaffolding automaton AMA_M of degree 2m2m and distance two such that L(AM)=L(M).L(A_M)=L(M). After every input prefix, the two persistent stacks associated with each tape, together with its scanned symbol in finite control, reconstruct the source tape exactly. In particular, the reconstructed and source tapes agree at every integer offset from the head, including their implicit blank tails, and the source control states agree.

Proof. Compose lemma 4.1 with theorem 3.2. If the source control and tape alphabet are QQ and TT, the augmented control is Q×TmQ\times T^m, and the tuple label alphabet is (T∪{⊥})2m(T\cup\{\bot\})^{2m}. Both are finite because QQ, TT, and mm are finite. Since m≥1m\geq1, the scaffold degree 2m2m is positive; its distance is the fixed constant two. Exactly one scaffold node is appended for each input symbol. ◻

5 The real-time transfer

Theorem 5.1. If LL is recognized by a strict real-time multitape machine, then LR∈PEG.L^R\in\mathsf{PEG}. Equivalently, rev(RT-MTTM)⊆PEG.\mathsf{rev}(\mathsf{RT\text{-}MTTM})\subseteq\mathsf{PEG}.

Proof. By theorem 4.2, a scaffolding automaton AA decides LL. If its initial state can recur, apply lemma 2.2; this preserves the language. Put K=LRK=L^R. Then KR=LK^R=L is decided by a scaffolding automaton, so theorem 2.1 gives K∈PEGK\in\mathsf{PEG}. ◻

Lemma 5.2 (Strict real time is online constant time). Every language recognized by a strict real-time multitape machine belongs to Online(O(1))\mathsf{Online}(O(1)) in the sense of Loff–Moreira–Reis Definition 22.

Proof. Their lower-bound model is explicitly a multi-tape online Turing machine [4, p. 5]; the configuration count in their Theorem 25 proof records the plural tape-head positions and the bounded neighborhood around every head, with the fixed machine-dependent tape count absorbed by the OO-constant [4, p. 33]. Their mm there is the suffix length in the equivalence relation; the tape count is a separate constant factor.

Fix a strict machine MM. Give the online machine the same finite control and fixed finite family of work tapes. Between successive advances of its one-way input head, it reads the current symbol and performs MM’s one simultaneous work-tape transition. Initial alignment and the empty-input answer are finite-control cases. The auxiliary tape containing the exact input length in binary is left unread; declining to use an available tape does not place the simulator outside Definition 22. In fact, the authors state that their lower bound survives even arbitrary nonuniform contents on that auxiliary tape [4, footnote 10].

An induction on the consumed prefix shows equality of the control state, every work-tape content, and every work-tape head position. The fixed transition-and-advance schedule takes at most a machine-dependent constant cMc_M steps per symbol. The simulator therefore decides the same language and belongs to Online(O(1))\mathsf{Online}(O(1)). ◻

Corollary 5.3 (Proper class containment). rev(RT-MTTM)⊊PEG.\mathsf{rev}(\mathsf{RT\text{-}MTTM})\subsetneq\mathsf{PEG}.

Proof. Inclusion is theorem 5.1. Loff, Moreira, and Reis prove that there is a language L∈PEGL\in\mathsf{PEG} such that neither LL nor LRL^R belongs to Online(t(n))\mathsf{Online}(t(n)) for any t(n)=o(n/(log⁡n)2)t(n)=o(n/(\log n)^2) [4, Theorem 23]. Write WW for this final tagged witness, to distinguish it from the proof’s intermediate scaffold language HH. Every constant function cMc_M is o(n/(log⁡n)2)o(n/(\log n)^2). By lemma 5.2, neither lower-bound orientation can therefore contain the relevant strict machine language.

If W∈rev(RT-MTTM)W\in\mathsf{rev}(\mathsf{RT\text{-}MTTM}), then W=XRW=X^R for some X∈RT-MTTMX\in\mathsf{RT\text{-}MTTM}, so X=WR∈Online(O(1))X=W^R\in\mathsf{Online}(O(1)), contradicting Theorem 23. Hence W∉rev(RT-MTTM)W\notin\mathsf{rev}(\mathsf{RT\text{-}MTTM}), which makes the inclusion proper. ◻

Remark 13 (Construction size). The Loff–Moreira–Reis proof is constructive, so theorem 5.1 effectively yields a finite PEG. Direct expansion is impractical: with mm tapes the degree is 2m2m, the tuple-label carrier grows exponentially in mm, and the family of depth-two neighbourhoods grows exponentially again in that carrier. This blow-up belongs to the direct generic compiler, not necessarily to the smallest PEG for the language. We establish existence and effectiveness; we do not print the resulting grammar.

6 Even-length palindromes

Let PAL2={x∈{0,1}∗:x=xR}.\mathsf{PAL}_2=\{x\in\{0,1\}^*:x=x^R\}.

The only external premise needed here is stated directly in the source model of definition 2.3. It is a classical imported theorem: the proof below audits the source-model correspondence, while the source theorem itself is not re-mechanized here.

Theorem 6.1 (Classical palindrome interface (classical, imported)). There are finite m,Q,Tm,Q,T and a total strict real-time mm-tape machine PP such that, for every x∈{0,1}∗x\in\{0,1\}^*, the state reached after exactly ∣x∣|x| transitions is accepting if and only if x=xRx=x^R. The statement includes x=εx=\varepsilon: the initial state is accepting.

Proof. Slisenko proves real-time recognizability of palindromes with one new input letter per tick. Determinism and the absence of an endmarker or length advice make the report at tick ∣x∣|x| a verdict for the prefix xx, whether or not more symbols later arrive. Leong and Seiferas realize each fixed multihead tape unit by finitely many ordinary single-head tapes without delay, and their fixed-rate normalization compresses the uniformly bounded work of one source round into one conventional transition. The report bit is retained in finite control; a fresh initial state supplies the correct empty-word verdict.

Appendix C gives the clause-by-clause source correspondence, primary-source locations, same-prefix argument, and full fixed-round strictification invariant. It is part of the proof, not an appeal to terminology alone. ◻

Lemma 6.2 (Even-palindrome identity). For every binary word xx, x∈{wwR:w∈{0,1}∗}⟺x=xR  and  ∣x∣ is even.x\in\{ww^R:w\in\{0,1\}^*\} \quad\Longleftrightarrow\quad x=x^R\ \text{ and }\ |x|\text{ is even}. The equivalence includes x=εx=\varepsilon.

Proof. If x=wwRx=ww^R, then xR=(wwR)R=(wR)RwR=wwR=xand∣x∣=2∣w∣.x^R=(ww^R)^R=(w^R)^Rw^R=ww^R=x \quad\text{and}\quad |x|=2|w|. Conversely, suppose x=xRx=x^R and ∣x∣=2n|x|=2n. Write x=x1⋯x2n=wvx=x_1\cdots x_{2n}=wv, where w=x1⋯xnw=x_1\cdots x_n and v=xn+1⋯x2nv=x_{n+1}\cdots x_{2n}. For 1≤i≤n1\leq i\leq n, reversal symmetry gives vi=xn+i=x2n+1−(n+i)=xn+1−i=wn+1−i.v_i=x_{n+i}=x_{2n+1-(n+i)}=x_{n+1-i}=w_{n+1-i}. Thus v=wRv=w^R and x=wwRx=ww^R. When n=0n=0, this gives w=v=εw=v=\varepsilon and hence x=εx=\varepsilon, so the empty word is included. ◻

Lemma 6.3 (Reversal invariance). (EPAL2)R=EPAL2.(\mathsf{EPAL}_2)^R=\mathsf{EPAL}_2.

Proof. Every member has the form wwRww^R, and (wwR)R=(wR)RwR=wwR(ww^R)^R=(w^R)^Rw^R=ww^R. Thus reversal fixes every member pointwise; since reversal is an involution, the two languages are equal. This includes ε=εεR\varepsilon=\varepsilon\varepsilon^R. ◻

Lemma 6.4 (Parity product). Suppose a strict real-time machine PP reports after every prefix xx, including the empty prefix, whether x=xRx=x^R. Then a strict real-time machine PevenP_{\mathrm{even}} recognizes exactly EPAL2\mathsf{EPAL}_2.

Proof. Take the product of PP’s finite control with one parity bit. Initialize the bit to even and flip it once in the same transition that consumes each new input symbol; leave PP’s tapes and tape actions unchanged. Accept exactly when PP’s report is true and the parity bit is even.

Induction on the consumed prefix shows simultaneously that the projected PP-configuration is its original configuration after that prefix and that the bit is even exactly when the prefix length is even. Hence the product accepts xx exactly when x=xRx=x^R and ∣x∣|x| is even, which is EPAL2\mathsf{EPAL}_2 by lemma 6.2. Initially both predicates are true, so the empty word is accepted without an extra transition. ◻

Theorem 6.5. The even-length binary palindrome language has a parsing expression grammar: EPAL2={wwR:w∈{0,1}∗}∈PEG.\boxed{\mathsf{EPAL}_2=\{ww^R:w\in\{0,1\}^*\}\in\mathsf{PEG}.}

Proof. Apply theorems 6.1 and 6.4. This gives a strict real-time multitape machine for EPAL2\mathsf{EPAL}_2. By theorem 5.1, (EPAL2)R∈PEG(\mathsf{EPAL}_2)^R\in\mathsf{PEG}. Lemma 6.3 gives (EPAL2)R=EPAL2(\mathsf{EPAL}_2)^R=\mathsf{EPAL}_2, so the result follows. ◻

Corollary 6.6. Conjecture 7 of Loff, Moreira, and Reis [4] is false.

Proof. Their conjecture states exactly that {wwR:w∈{0,1}∗}∉PEG\{ww^R:w\in\{0,1\}^*\}\notin\mathsf{PEG} [4, Conjecture 7]. The language is exactly EPAL2\mathsf{EPAL}_2, while theorem 6.5 proves EPAL2∈PEG\mathsf{EPAL}_2\in\mathsf{PEG}. ◻

7 Formal verification

The reviewed Lean 4 source snapshot is commit 20ef2ef5f14274e37ac0dd40af0f944ff34885ce 2. The same source directory on the maintained branch is available here 3. It uses Lean 4.30.0 without Mathlib.

Layer Conclusion Assurance in this release
Machine to scaffold L(AM)=L(M)L(A_M)=L(M), exact tapes and one node per symbol Machine-checked in Lean
Scaffold to PEG LMR sufficient direction and rev⁡(RT-MTTM)⊆PEG\operatorname{rev}(\mathsf{RT\text{-}MTTM})\subseteq\mathsf{PEG} Machine-checked in Lean; the LMR construction is formalized here, not claimed as a new theorem
Properness rev⁡(RT-MTTM)⊊PEG\operatorname{rev}(\mathsf{RT\text{-}MTTM})\subsetneq\mathsf{PEG} LMR lower bound checked against the cited classical statement but not mechanized
Even palindromes EPAL2∈PEG\mathsf{EPAL}_2\in\mathsf{PEG} The implication from an exact strict recognizer is machine-checked; the recognizer interface is checked against the cited classical statements but not mechanized

The principal endpoints are:

  • realtime_transfer_tape_contents;

  • scaffold_to_peg;

  • revRT_multitape_subset_PEG; and

  • epal2_inPEG_of_multitape_recognizer.

The last is the conditional EPAL implication: no palindrome recognizer is introduced as an axiom. Exhaustive finite carriers and bounded port paths produce a literal finite nonterminal type, and the grammar handles automata that use SELF. Searches over the source find no sorry, admit, declared axiom, unsafe, native_decide, or partial def. For all four principal endpoints listed above, #print axioms reports only propext, Classical.choice, and Quot.sound. The occurrence of Classical.choice comes from standard classical finite-carrier and transport constructions in the proof; it is not an added mathematical hypothesis about automata or languages.

As a separate implementation check, a literal interpreter of the published scaffold transition model was tested with a transferred four-stack middle-symbol machine. Exhaustive tests through length 1414, longer structured and random tests, and eight deliberately corrupted variants exercise the unfolding and port-word resolution independently of the Lean development.

8 Discussion

The transfer rests on a simple resource principle: the number of physical updates and the number of logical memory roots updated need not coincide. A scaffold node has a product label and a fixed tuple of named ports, so one append can advance every root in a fixed finite family. The two-stack zipper then converts local movement on each work tape into exactly this form.

This also explains why an explicit midpoint is unnecessary in the palindrome application. The scaffolding automaton does not discover the midpoint by a single stack turn. It simulates the distributed schedule already present in the classical real-time recognizer.

The degree is a fixed parameter of the scaffolding automaton, not a universal bound on the model. An mm-tape realization uses degree 2m2m and distance two. No pointer-identity test is needed: the transition reads only labels along named paths in the published tree unfolding.

9 Conclusion

A fixed tuple of persistent stack roots can be updated by one appended scaffold node. Through the ordinary two-stack representation of a Turing tape, this gives an exact letter-synchronous simulation of strict real-time multitape computation. The Loff–Moreira–Reis characterization therefore places the reversal of every such language in PEG\mathsf{PEG}. Applied to the classical real-time palindrome recognizer, the transfer yields a PEG for even-length binary palindromes.

The assurance boundary is exact. Lean machine-checks the compiler equality L(AM)=L(M)L(A_M)=L(M), the sufficient scaffold-to-PEG construction, the strict-real-time containment, and the implication from an exact strict real-time multitape EPAL recognizer to EPAL2∈PEG\mathsf{EPAL}_2\in\mathsf{PEG}. The Loff–Moreira–Reis, Slisenko, Leong–Seiferas, and fixed-rate speedup results supply the properness and recognizer premises; they were checked against the cited classical statements but not mechanized. Thus the EPAL and proper-containment conclusions are established, while the classical source layer is not re-mechanized in this repository. The enormous generic PEG is not expanded here.

A The persistent update, literally

This appendix expands the compact proof of lemma 3.1. The sentinel conventions make every expression in the update table total: ej(∅)=∅,λj(∅)=⊥,Dj(∅)=ε.e_j(\varnothing)=\varnothing, \qquad \lambda_j(\varnothing)=\bot, \qquad D_j(\varnothing)=\varepsilon. If a port is missing, or a port word first becomes invalid, all remaining steps stay at ∅\varnothing. Thus the expressions ej(v)e_j(v) and ej(ej(v))e_j(e_j(v)) have literal meanings even at the boundary.

Fix jj. For a push, the new node has head aa and tail root vv, so Dj(v+)=aDj(v).D_j(v^+)=aD_j(v). For keep, if λj(v)=a\lambda_j(v)=a, the new node has head aa and tail ej(v)e_j(v), hence reproduces Dj(v)D_j(v). If λj(v)=⊥\lambda_j(v)=\bot, both old and new decodings are empty. For pop, if Dj(v)=aDj(ej(v))D_j(v)=aD_j(e_j(v)), then the new head is λj(ej(v))\lambda_j(e_j(v)), its new tail is ej(ej(v))e_j(e_j(v)), and therefore Dj(v+)=Dj(ej(v)).D_j(v^+)=D_j(e_j(v)). If Dj(v)=εD_j(v)=\varepsilon, CleanEmpty\mathsf{CleanEmpty} gives λj(ej(v))=⊥\lambda_j(e_j(v))=\bot, including when ej(v)=∅e_j(v)=\varnothing, so the pop remains empty. Push cannot create an empty component. Keep inherits the clean-empty implication from vv, and pop inherits it from ej(v)e_j(v). All named targets are at or below the old top, so they are strictly behind the newly appended node.

Here is the simultaneous two-stack case in one line. Suppose D1(v)=aα,D2(v)=bβ.D_1(v)=a\alpha, \qquad D_2(v)=b\beta. Push xx on stack 1 and pop stack 2. The single new node has components xx and λ2(e2(v))\lambda_2(e_2(v)); its first port names vv, while its second names e2(e2(v))e_2(e_2(v)). Consequently (D1(v+),D2(v+))=(xaα,β).\bigl(D_1(v^+),D_2(v^+)\bigr) =\bigl(xa\alpha,\beta\bigr). The two logical updates are simultaneous because both components and both ports belong to the same appended node. If β=ε\beta=\varepsilon, the sentinel and CleanEmpty\mathsf{CleanEmpty} calculation above makes the second result empty.

B Extensional tape reconstruction

Let Z=(L,c,R)Z=(L,c,R) be a zipper and let bb be the symbol written before the head moves. Define the tape after the write but before the move by written⁡Z,b(z)={b,z=0,cell⁡L,c,R(z),z≠0.\operatorname{written}_{Z,b}(z)= \begin{cases} b,&z=0,\\ \operatorname{cell}_{L,c,R}(z),&z\ne0. \end{cases} If Z→Z_{\rightarrow}, Z←Z_{\leftarrow}, and Z∘Z_{\circ} are the three zippers in (4), then for every z∈Zz\in\mathbb Z, cell⁡Z→(z)=written⁡Z,b(z+1),cell⁡Z←(z)=written⁡Z,b(z−1),cell⁡Z∘(z)=written⁡Z,b(z).\begin{aligned} \operatorname{cell}_{Z_{\rightarrow}}(z) &=\operatorname{written}_{Z,b}(z+1),\\ \operatorname{cell}_{Z_{\leftarrow}}(z) &=\operatorname{written}_{Z,b}(z-1),\\ \operatorname{cell}_{Z_{\circ}}(z) &=\operatorname{written}_{Z,b}(z). \end{aligned}

For the right-move equation, z=−1z=-1 reads the newly pushed head of bLbL, hence bb; z=0z=0 reads head⁡⊔(R)\operatorname{head}_{\sqcup}(R); positive offsets read the remaining tail of RR; and offsets below −1-1 read the old entries of LL. These are exactly the four cases of the right-hand side. The left equation is the mirror image, and stay changes only offset zero. The default ⊔\sqcup in head⁡⊔\operatorname{head}_{\sqcup} and in (3) proves the equations even when either finite list is exhausted.

Initially L=R=εL=R=\varepsilon and c=⊔c=\sqcup, so the reconstruction is blank at every integer offset. Induction on input length now maintains the following invariant for each work tape: the source control state and scanned symbol agree with the compiled control, and the source cell at every head-relative integer offset equals the cell reconstructed from the two decoded persistent stacks. This is the exact invariant asserted by theorem 4.2 and by the Lean theorem realtime_transfer_tape_contents.

C Classical palindrome interface audit

This appendix records how the classical statements discharge every clause of theorem 6.1. A longer source-audit note, including the rejected attempt to reconstruct the final theorem from positive-report sublemmas alone, is public with the paper. 4

Compiler requirement Classical evidence Result
Deterministic computation Leong–Seiferas model a tape unit by a deterministic command transducer and its real-time simulator by finite deterministic control; Slisenko gives a fixed Turing-machine algorithm. Match
Fixed finite tapes and heads Slisenko’s program has a fixed finite family of multihead units. Leong–Seiferas Corollary 3.6 replaces any fixed hh-head one-dimensional unit by 4h−44h-4 single-head tapes; their p. 166 twenty-tape count for Slisenko is corroborating, not needed quantitatively. Match
Initial storage Leong–Seiferas Theorem 3.1 and p. 170 start the simulator tapes blank; finite control only pretends that fixed LEFT, RIGHT, and SYNCH markers lie beneath the initial heads. Match
Uniform work per arriving symbol Slisenko uses one new input letter per tick and fixed linear speedup. Leong–Seiferas p. 167 uses a fixed rate kk and the Hartmanis–Stearns normalization to replace a composite step by one conventional step without time loss. Match after normalization
Answer for the prefix just read Slisenko’s final, unnumbered recognition theorem and English summary (pp. 123 and 139), together with the one-letter-per-tick convention before Proposition 4.6 (p. 137), give the verdict at that tick. The same-prefix argument below removes any extension ambiguity. Match
No unbounded finishing computation A new letter arrives every tick and the verdict for the prefix is already present at its report point; there is no endmarker or post-input interval. Match
Finite alphabets and control The source programs, head sets, rates, tapes, and alphabets are fixed. The speedup enlarges the alphabet only by a fixed finite-radius encoding. Match

The remaining source pins are Slisenko’s reporting conditions on p. 132 and Proposition 4.4 on p. 134, and Leong–Seiferas Theorems 3.1 and 3.5 and Corollary 3.6 on pp. 170, 173, and 174. Leong–Seiferas supply the storage realization; palindrome correctness comes from Slisenko’s final theorem.

Same-prefix timing

Fix a prefix uu and regard uu itself as a legitimate finite input. Slisenko’s real-time theorem decides it at tick ∣u∣|u|. The deterministic machine has received exactly the same symbols and no endmarker, length advice, or preloaded suffix after ∣u∣|u| ticks on inputs uu and uvuv. Its configuration is therefore identical in the two runs. Hence the report at each tick is the two-sided verdict for the prefix read through that tick. This argument uses the final recognition theorem; it does not infer rejection correctness from Slisenko’s positive-report propositions.

Fixed-round strictification

Consider a fixed deterministic streaming reporter whose round receives one symbol, performs at most cc controller or tape-unit commands, and returns a Boolean report for that same prefix. Pad every branch to cc program positions, retaining the arriving symbol, a program counter, branch results, and a done bit in finite control. Positions after completion are no-ops.

Instantiate the deterministic Leong–Seiferas simulator for each logical multihead unit, give different units disjoint finite tape families, and take the finite product of their controllers with the padded reporter. Corollary 3.6 supplies the fixed ordinary single-head simulations. The blank-tape initialization of Theorem 3.1 establishes the base configuration without a startup phase.

Choose one fixed speedup rate large enough for the padded schedule and every unit simulator. The no-time-loss normalization cited on Leong–Seiferas p. 167 compresses the product round into one conventional global transition over a fixed enlarged alphabet. A selected tape performs its prescribed write and move; every other tape rewrites its scanned symbol and stays. Put the report bit in the finite control.

After a prefix xx, maintain simultaneously:

  1. equality of the source and simulated controllers and logical unit states;

  2. equality of every decoded tape content and logical head position;

  3. a boundary program counter and exactly ∣x∣|x| consumed symbols; and

  4. equality of the finite-control report bit and the reporter’s answer for xx.

Blank initialization proves the base case. The no-delay unit simulations, padding, and fixed-rate normalization prove one-round preservation, including data-dependent branches. Induction gives the same report after every prefix with no output lag or finishing computation. Fill unreachable transition-table entries arbitrarily to obtain a total transition function. If the historical convention omits an empty report, a fresh accepting initial state delegates its first-symbol transition to the old initial transition and is never re-entered. This proves exactly the strict interface in theorem 6.1.

References

Source[1] Bryan Ford. Parsing expression grammars: A recognition-based syntactic foundation. In Proceedings of POPL 2004, pages 111–122. ACM, 2004.

Source[2] Zvi Galil. Palindrome recognition in real time by a multitape Turing machine. Journal of Computer and System Sciences, 16(2):140–157, 1978.

Source[3] Benton L. Leong and Joel I. Seiferas. New real-time simulations of multihead tape units. Journal of the ACM, 28(1):166–180, 1981.

[4] Bruno Loff, Nelma Moreira, and Rogério Reis. The computational power of parsing expression grammars. Journal of Computer and System Sciences, 111:1–21, 2020. https://doi.org/10.1016/j.jcss.2020.01.001.

Source[5] Arnold L. Rosenberg. Real-time definable languages. Journal of the ACM, 14(4):645–662, 1967.

[6] A. O. Slisenko. A simplified proof of the real-time recognizability of palindromes on Turing machines. Zapiski Nauchnykh Seminarov LOMI, 68:123–139, 1977. English translation in Journal of Soviet Mathematics, 15:68–77, 1981. https://doi.org/10.1007/BF01404109.

Reading-edition notes

This expanded web edition preserves the mathematical statements and proofs of the earlier publication, with the corrections recorded in the publication audit. The PDF is the earlier edition. Historical computational and formal-verification reports retain their original scope; they have not all been rerun for this revision.

Afterword: FPRD Lab’s contribution

9 September 2026 · Methodological and contribution addendum. The paper’s mathematical scope and review status remain as stated in the paper.

The Lab’s approach

FPRD means Finitely Presented Recognition Dynamics. Its starting point is to distinguish a finite description, the possibly infinite process it generates, and what an observer can learn from that process. Equal answers need not come from equal internal structures. Conversely, an infinite state space may have a short, exact description and useful coordinates; failure to compress it into finitely many states need not end the investigation.

A small example: balanced parentheses

The grammar S → (S)S | ε presents the language of balanced parentheses. To recognize a prefix, keep the number of unmatched opening parentheses, or a failure state if a closing parenthesis arrived too early. An opening parenthesis increments the count. A closing parenthesis decrements a positive count; at zero it enters failure. Failure persists. At the end, accept exactly when the count is zero.

The prefixes ( and ()( leave the same future task: any suffix that completes one completes the other. The prefix (( leaves a different task: ) completes the first two prefixes but not this one. These future tasks are residuals. There are infinitely many counts, yet a finite set of update rules generates their dynamics. This is a classical automata example, not a discovery of FPRD Lab. It illustrates the research question: which coordinates preserve all relevant futures, and what does updating or reading those coordinates cost?

From viewpoint to proof

In practice, the Lab fixes the observable and the allowed operations, compares presentations of the same problem, and seeks an exact translation or invariant. A failed shortcut is useful when a counterexample identifies the missing coordinate or hypothesis. Small computations test particular uncertainties; a proof must explain why the result holds beyond those tests. Costs, relation sides, boundary conditions, and the direction of each translation remain explicit.

AI-assisted exploration, source comparison, executable checks, and adversarial reconstruction support this work. Their agreement is not automatically independent evidence: shared assumptions must be exposed. A formal development certifies its stated formal theorem, not every interpretation attached to it. Each paper retains its own evidence and review status.

The approach is most useful when a poor representation hides a reusable construction, a compatibility condition, or a sharp obstruction. Outside recognition theory, it can guide the search for a structural reformulation without producing a literal residual dynamical system. The account below distinguishes that methodological influence from the ingredients of the proof.

FPRD’s contribution to this paper

The key question was how much logical work one legal scaffold append can represent. Treating “one new physical node” as “one new logical cell” would impose a restriction that the source machine model does not require.

The Lab supplied an explicit coordinate representation: one node carries a finite tuple of stack-top symbols, with separately named ports for the corresponding persistent tails. Push, keep, and pop become bounded observations and port choices. A distance-two neighborhood suffices. The representation invariant also handles empty stacks, where a careless decoder could expose stale data.

The familiar two-stack representation of a work tape then becomes useful in this precise setting. Two persistent stacks per tape, together with the scanned symbol in finite control, translate each strict real-time global transition into one scaffold step. The substantive bridge is this letter-for-letter simulation with fixed resources, not the mere observation that tapes can be encoded as graphs.

The method also forced an interface audit at the other end. Applying a historical palindrome recognizer requires an answer for the prefix just read, fixed finite storage units, and no unbounded finishing computation. The paper spells out the source conventions and their normalization instead of treating every use of “real time” as interchangeable.

Inherited ingredients and the boundary of the contribution

Persistent stacks and the tape zipper are established constructions. Loff, Moreira, and Reis supply the exact scaffold/PEG characterization, including reversal. Slisenko supplies the real-time palindrome recognizer; Leong and Seiferas supply the ordinary single-head simulation used in the source-interface argument. The Lab’s contribution is the explicit bounded scaffold realization and the checked composition of these interfaces.

Consequently, the theorem transfers the reversal of a strict real-time multitape language to PEGs. Even palindromes are an application because that language is reversal invariant. The paper does not infer a compact practical PEG, a classification of PEG languages, or unrestricted simulation of machines with post-input work.

The paper records a Lean development and distinguishes it from the historical source audit. This afterword adds no formal-verification or review credit. It identifies where the presentation viewpoint became an actual machine construction.

Where to inspect the contribution: the paper, Sections 3–7 and Appendices A–C, especially the update table, tape reconstruction, and same-prefix timing argument.