Synthesizing finite input clocks on two input blocks
30 September 2026. Working research note.
A finite input clock predicts stack height from the letters it reads, without seeing the stack. On words , it might count up during the first block and down during the second. Can finite control choose a clock that stays within a fixed error of every legal run of a given pushdown source?
For this two-block restriction, the answer is decidable even when neither the clock’s size nor the allowed error is supplied. The proof turns all possible input lengths and heights into finitely many arithmetic pieces, then checks whether their slopes fit one finite clock. A feasible system constructs the clock and an error bound; an infeasible one rules out every clock in the stated class.
The example below explains the obstruction: a stack can detect when it empties and reverse direction, while input-only finite control cannot remember an arbitrarily distant turning point. This limits reflected clocks, not persistent stack implementations. Extending the synthesis test beyond two input blocks remains open in this note.
Contents
1. A stack can turn around where a finite clock cannot
Consider inputs . A deterministic stack pushes on , pops on until empty, and then pushes on every further . Its height is . Finite control remembers whether it is reading , descending on , or growing on . At empty in the descending phase, the next pushes and enters the growing phase in that same step. Inputs with after are disabled. The initial stack is empty; enters the growing phase on the first . One stack symbol suffices. Accepting exactly at empty recognizes .
There is exactly one height on each legal input. Nevertheless no finite input observer, emitting and updating its height by , can stay within a constant of this source on all prefixes.
Here is a direct proof. Suppose the observer has states and a uniform error bound. After any , follow forever. The source eventually grows at one symbol per letter. The observer’s eventually periodic -output must therefore have mean : any smaller mean gives a smaller asymptotic reflected growth rate. Since each output is at most , every output on that eventual cycle is . The transient has length at most . At the clock is at least while the source is zero, contradicting the bound as grows.
This obstruction concerns every clock in this specified reflected-clock class. The source itself has a direct persistent implementation using one immutable stack root. It is not a lower bound on persistent representations or on its language. A different presentation of can simply stop popping at empty and reject further ’s, and has a matching reflected clock.
The distinction from an absolute signed sum matters: tracks this example exactly. Nowotka and Srba’s treatment of Caucal’s transducer clocks uses that absolute-value convention, not our reflected recurrence. Their Example 2 and Appendix B already discuss this change from descent to growth. The example is not claimed as a new phenomenon.
2. Model and theorem
is a normalized nondeterministic real-time pushdown source: finite control, finite stack alphabet, initially empty stack, finitely many initial states, and one consumed input letter with one push/pop/keep per rule. Guards inspect top or empty only. An empty pop is disabled or explicitly a no-op. There are no epsilon actions, bulk updates or other storage tests.
Restrict legal runs to words in . This restriction is implemented by a finite phase guard and includes every prefix. All runs count, not only accepting runs. Define the height relation
A clock has complete finite input control , fixed initial state, outputs , and . The control reads input only; it cannot inspect , the source stack, or a nondeterministic choice.
Theorem. For this restricted source, it is decidable whether there exist a finite clock and such that for every triple in . On a positive instance one can construct and a valid . Neither its state count nor must be supplied. The finite slope criterion below is necessary and sufficient.
The criterion depends only on . Thus two presentations having the same height relation receive the same answer. This is not invariance under language equivalence, nor a characterization of every persistent realization. If permits other words, the language compiled by this result is , not all of .
The finite source/guard hypotheses are directly checkable. The required semilinear description is computable from P, rather than assumed as evidence that a clock already exists. No practical complexity bound is asserted.
3. Obtaining the arithmetic data
A pushdown machine can simulate , enforce , then nondeterministically stop in any configuration and pop its remaining stack, emitting one fresh letter per symbol. This constructs the context-free language
The draining mode is an offline analysis device, not additional real-time source work. Constructive Parikh theory therefore computes as a finite union of linear sets
Coordinates are written . Effective Parikh semilinearity is classical; we import it, with the explicit automaton construction of Esparza, Ganty, Kiefer and Luttenberger as a primary implementation route.
Call a component -unbounded if some period has positive -coordinate. For each such component put
with if there are no such components.
Let be one greater than the largest base -coordinate of an -bounded component, or if no such component exists. Every triple with lies in an -unbounded component. For each , compute a semilinear description of the fiber . From (1), coefficients of positive- periods are bounded by , so enumerate them; retain zero- periods. The resulting fiber bases and periods are finite and explicit.
4. The finite slope criterion
Introduce rational unknowns
For every residue and -unbounded component satisfying , impose the following constraints.
If some period of has positive -coordinate, require, for every period of that component,
If all periods have zero -coordinate, require, for every period,
For each and every period of every fiber component, require
These are finitely many rational linear equations and weak inequalities. Feasibility over the reals and over the rationals coincide, and elimination decides feasibility and returns a rational solution. The criterion is exactly feasibility of (2)-(4) with the displayed ranges. There is no enumeration of unknown observer sizes, periods or error bounds.
The period is derived from any supplied decomposition (1). Different decompositions can change its size, but not the answer proved below. and the constructed observer size are bounds, not minimum values.
5. Why every finite clock must satisfy the criterion
5.1 Reflected unary behavior
Starting at any finite observer state and reading one letter repeatedly gives an eventually periodic output sequence. Let be its signed sum and its rational cycle mean. There is such that for all . For initial numerical height , reflection has the exact formula
If two signed-sum paths differ by at most , this formula bounds the difference of their reflected paths by . The reflected linear path is . Consequently
where the constant is independent of and . There are finitely many observer states, so the bound can be uniform over starting states.
Applied to the -orbit from height zero, (5) gives , with . The observer state after is eventually periodic in , say with period after threshold . Applying (5) on then gives rational such that, uniformly for all and ,
For any fixed exceptional , the eventual -growth rate is a rational ; its height differs from by a constant.
5.2 Linear components force a common slope
Fix a linear component and a starting point whose -coordinate is at least . Adding times any period preserves the clock’s -residue. Scaling such directions and using (6) with bounded source error shows that every nonnegative combination of the periods satisfies
If all period heights are zero, the individual directions give (3). If some direction has , (7) gives . Every other positive-height period satisfies the same equality. A zero-height period first gives . If that value were negative, choose large enough that the linear expression on is positive. Equation (7) would then equate with a strictly smaller value. Therefore the value on is zero too, yielding (2) for every period. This mixed-direction step is essential: testing the generators’ clipped values separately is weaker.
For a fixed fiber the same scaling argument with its eventual -growth rate gives (4), including zero- periods.
5.3 Why the source-derived period M suffices
The -projection of an -unbounded component is plus the additive monoid generated by its period -coordinates. It contains every sufficiently large integer in that congruence class modulo . To see this, divide by the gcd, choose one positive generator , and choose a nonnegative generated representative of each residue modulo ; adding fills the tail of that residue. Such representatives exist because the generators have gcd one. This also gives an effective finite threshold.
Fix modulo . All components selected for therefore have a common sufficiently large in their -projections. Choose as well. They all encounter the same old observer state after , and hence the same in (6). In each component choose a point above this and apply Section 5.2. That simultaneously satisfies all its required constraints for . Do this for each , retaining the one common . The finitely many fibers supply their . Thus a successful clock yields a feasible finite system despite its possibly unrelated period and threshold .
6. Constructing a clock from a feasible system
Given a rational solution, define if , and otherwise. The intended approximation is
For an n-unbounded component and a relevant residue, (2) makes the linear expression on the period part exactly its height. Replacing its base height by changes (8) by at most , because is 1-Lipschitz. Under (3), height stays at the base height and the linear expression can only decrease as periods are added, giving the same safe bound. For , (4) gives the identical base-error bound on every computed fiber component, using the base triple . Thus
on all , where is the maximum coordinate sum of all -unbounded original bases and all computed small-fiber bases, or zero for an empty list.
On the -th , let the clock emit , a periodic 0/1 sequence. Keep exactly below and thereafter modulo . Here denotes the denominator in reduced form. On the first , choose and reset a finite phase counter. On the -th , emit
These outputs lie in ; for a fixed they are all nonnegative or all nonpositive. The resulting reflected height is exactly
It differs from by less than 2. Hence is a valid integer construction bound. Complete the observer on inputs outside with an arbitrary sink. Its control never tests . With rational numbers in reduced form, a sufficient state count, including the sink, is
This proves sufficiency, effective synthesis and the theorem. The arithmetic criterion already supplies a terminating negative test; the prior fixed- clock decision theorem is not needed for this proof. It may subsequently compute the least skew for the particular clock constructed, if desired.
7. Examples that distinguish the conditions
| Height relation on | Result | Reason |
|---|---|---|
| Yes | , . | |
| No | The two regions impose incompatible slopes. | |
| for even , for odd | Yes | ; , . A single common -slope would fail. |
| if , otherwise | Yes | The exceptional fiber uses ; later -slope is 0. |
| Yes | and . Integer slopes alone would miss it. | |
| All heights | No | Growing and flat -directions require and . |
| for , for | Yes | , , skew at most 1 despite nondeterminism. |
All have normalized sources. Parity and half-rate behavior use finite control. In the last example the first nondeterministically pushes or keeps; all later ’s push and ’s keep. For the exceptional fiber, a finite state records whether any has occurred. All-run height semantics, rather than acceptance pruning, is used throughout.
For the valley , the two linear components have base zero and periods
Both have . The first forces ; the second forces and . The finite system is infeasible. This agrees with the direct obstruction in Section 1. It excludes all finite reflected clocks, not just small clocks tested by enumeration.
8. Persistent compilation and the boundary of the result
On a positive instance, the synthesized clock and enter the existing bounded-skew compiler. For the source restricted to , it supplies a degree-two, native-distance-two scaffold with one physical node per input letter and the reviewed fixed virtual initialization, without a padding letter. It preserves same-word prefix acceptance, including . The corresponding PEG recognizes .
The source-symbol buffer and (11) are construction bounds, not optima. The preservation contract is fixed-controller acceptance and the decoded deterministic stack, not separate nondeterministic histories or raw graph equivalence under arbitrary scaffold contexts. This note’s offline analysis has no bounded-time guarantee.
The valley source still has a direct immutable-stack implementation: one root, one pointer field and at most one fresh logical record per letter. Clock synthesis is therefore a sufficient route to persistent memory. Preserving past stack versions does not by itself support general replay or reuse after arbitrary context changes.
9. Literature, proof status and next question
The proof combines classical effective Parikh semilinearity, unary finite- state periodicity, reflection, numerical-semigroup tails and rational linear feasibility. The additional argument here is the common-residue construction in Section 5.3: it replaces an unknown observer period by the finite period derived from source components, and yields the exact slope test and compiler consequence. Its novelty has not been established.
Primary comparisons inspected:
- Esparza, Ganty, Kiefer and Luttenberger, Parikh’s Theorem: A simple and direct automaton construction, IPL 2011, Theorem 1.1 and Section 3. Effective semilinearity is imported, not a contribution of this note. https://archive.model.in.tum.de/um/bibdb/esparza/IPL11.pdf
- Nowotka and Srba, Height-Deterministic Pushdown Automata, MFCS 2007, Definitions 2-3, Section 4.1, Appendix B Lemma 2 and Example 2. Unique height, exact synchronization, absolute signed sums and reflected clocks are distinct conditions. The periodicity argument is established. https://people.cs.aau.dk/~srba/files/NS:MFCS:07.pdf
- Filiot, Jecker, Loding and Winter, On Equivalence and Uniformisation Problems for Finite Transducers, ICALP 2016, Theorem 2 and the resynchronization results. Choosing outputs by finite input control is related to uniformization, but our source-height relation need not be a rational word relation. No direct transfer of their decision or undecidability results is made. https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ICALP.2016.125
- Filiot, Jecker, Madnani and Sunny, Approximate Problems for Finite Transducers, ICALP 2025. The published abstract’s approximate rational/ sequential-function distinction was checked as a nearby comparison; no theorem is imported from it. Our reflected prefix-height requirement and pushdown source are not identified with its string-distance model. https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ICALP.2025.155
For example, the graph of as a unary-output function on is not rational: the inverse image of is , which is not regular, whereas inverse images of regular languages under a rational transduction are regular. Semilinear triples alone do not make it a rational word relation. This explains why simply invoking finite-transducer synthesis would require an additional proof.
The arithmetic implementation accepts an explicit semilinear relation. It constructs (2)-(4), solves them with exact rational Fourier-Motzkin elimination, and rechecks every positive witness. For negative examples it rechecks nonnegative multipliers of the original inequalities yielding a constant contradiction. Recorded output includes the seven input relations, all constraints, solutions or negative certificates, and finite source-formula/clock comparisons through n,m=24. Those samples do not prove the infinite theorem. The full argument is a written proof, with no independent or proof-assistant verification. PDA-to-semilinear conversion and the scaffold compiler are not implemented.
The unrestricted-input clock-synthesis question remains unresolved here. The next useful test is whether the source-derived finite-period argument extends to three fixed input blocks. That extension is not automatic: later slopes may depend on both earlier residues, and reflection retains another piecewise-linear expression. A proof must bound the joint residue information from the source, rather than enumerate observers indefinitely. No pumping or recurrence theorem for PEGs or arbitrary scaffold interfaces is asserted.