Finite-boundary splicing closes green pop
Working research note, 30 September 2026.
The broader goal is to understand when past computation can remain usable through finite rules, bounded local access and bounded allocation. The specific question here is whether the remaining pair-chain branch of the catenable deque’s pop_green operation admits the same local-view factorization as the single-chain branch.
It does. The left view either retains a valid residual view or underflows to a fixed boundary of exactly six stored entries. In the first case, the residual left chain is paired with the unchanged right chain. In the second, those six entries are spliced in front of the right view and converted back to one only chain. Both paths preserve the exact order of arbitrary stored-word blocks.
This proves the complete pop_green sequence contract for the inspected source algebra, under explicit buffer contracts. Combined with the preceding single-chain certificate, pop_green is no longer an assumed semantic predecessor of the prefix-repair theorem. The buffer implementation and the other prefix-repair helpers retain their separately stated obligations.
The deque algorithm and its stronger existing Rocq theorem belong to Viennot, Wendling, Gueneau and Pottier. The inspected companion source is pinned to one commit. The additional result is our finite-boundary certificate decomposition and its connection to bounded persistent-record compilation. Novelty of this exact formulation remains unestablished.
Contents
1. A reusable finite-boundary lemma
Let be sets with word interpretations into a free monoid . Suppose:
A pair representation has meaning .
A local left-pop operation returns and either a boundary or a residual left view , satisfying respectively
A boundary splice satisfies
Residual pairing represents .
Lemma (finite-boundary splice). The operation that uses in the boundary branch and pairs in the residual branch returns and a residual representation satisfying
Proof. In the boundary branch, substitute the left-pop equation and then the splice equation:
In the residual branch,
which is the meaning of the residual pair. These are all result branches.
This semantic lemma does not require to be finite as a set. For a bounded persistent implementation, its shape must have a fixed finite interface. If is a fixed product of element slots and each premise is certified by finitely many bounded rules, the composed operation is bounded. Its resource bounds are obtained by finite call composition. This is a sufficient construction principle, not a characterization or an optimality theorem.
The hypotheses are checkable without assuming the result: list the local-pop branches, normalize each input and output word independently, verify the fixed boundary arity, verify the splice equation, and check constructor types and primitive resource contracts.
2. Exact deque instance
Fix an arbitrary payload type and nesting level . Put . Every value is a finite immutable acyclic value admitted by the source’s indexed constructors. Sharing with retained earlier versions is arbitrary.
For , let be its recursive stored sequence. Extend this interpretation by concatenation to buffers, nodes, triples, chains and semi-cadeques as in theory/Cadeque/Models.v. One entry denotes an arbitrary word block, not necessarily one payload letter.
The pair-route input is exactly
Constructor inversion gives , where is an arity-one left chain with green exposed colors and is an arity-one right chain with green exposed colors. No reachability restriction or maximum level is assumed.
The observation is sequence equality. The theorem does not equate physical graphs, sharing patterns, allocation histories or arbitrary future scaffold contexts. A fixed controller receives exact future trace preservation only when every operation it can call is covered by its certified interface.
Initialization remains a fixed finite well-typed graph with a declared abstract sequence. All operations here are strict and persistent, so old versions remain unchanged.
3. Explicit buffer hypotheses
At element level , require the following contracts:
Buffer.popremoves the first entry and preserves the remaining order.Buffer.has5, on a buffer known to contain at least four entries, distinguishes exactly four from at least five without changing its sequence.Buffer.pair,Buffer.push2andBuffer.push6prepend their supplied entries in the displayed order.- Each helper preserves entry level and its indexed occupancy result.
- Each helper is strict, persistent and has a uniform finite arity, old-access radius and allocation bound independent of , occupancy and history.
These contracts are independently stated module obligations. The source’s has5 is already structural: it removes four entries on temporary persistent versions and tests the residual root for emptiness. pair, push2 and push6 are fixed compositions of at most six pushes. The earlier bounded-threshold audit supplies a scalar-free finite-record route for the larger buffer module. This note does not rerun or formalize that audit.
4. Certifying pop_left_green
Convert to a left triple with triple_of_chain. The preceding certificate proves
for all seven conversion clauses.
Inverting
gives five top-level coloring combinations. Splitting the ending threshold and the yellow child arity gives seven semantic subcases:
| Input coloring | Child | Result after the head is removed |
|---|---|---|
GT / EN, residual prefix exactly 4 |
Empty |
six stored entries |
GT / EN, residual prefix at least 5 |
Empty |
GT / EN left triple |
GT / GN |
nonempty | YT / YN |
YT / YN |
Single |
OST / ON |
YT / YN |
Pair |
OPT / ON |
OST / ON |
Single |
RT / RN |
OPT / ON |
Pair |
RT / RN |
An RT input is impossible because its result color is red. OST and OPT force child arities one and two. The positive-prefix transitions are the same , , and transitions certified for the single route.
The ending case is the new boundary. Write the input prefix as , with boundary pair . If the residual prefix has exactly four entries, the triple word is
pop_left_green returns head and the fixed boundary . A four-entry prefix cannot rebuild a Left node, whose minimum is five. Thus the six-entry result is forced by shape, not merely a convenient implementation choice.
If at least five prefix entries remain, or in every non-ending coloring, the result is a residual left triple and
These equations quantify over arbitrary word substitutions for every stored entry.
5. Certifying only_of_right
Let the six boundary entries have word blocks . Convert the unchanged right chain to with triple_of_chain, preserving its exact word.
There are two source branches.
If is
GT / Right EN, its word is , where is the right node’s boundary pair and is its suffix.push2followed bypush6constructs oneOnly_endbuffer with wordOtherwise the right triple has positive arity and word , where is the child-chain word.
pairfollowed bypush6constructs an eight-entry prefix . The resultingOnlynode therefore has word
In both branches,
The eight constructed prefix entries justify adapt_to_prefix for every positive node coloring. That function changes only phantom index evidence; it does not inspect or modify runtime data. Omitting it can preserve the word while failing to type for an arbitrary right-node prefix index.
Typed coverage consists of GT/EN, GT/GN, YT/YN with Single or Pair child, OST/ON, and OPT/ON. Converting the result with chain_of_triple preserves its word in each corresponding clause.
6. Pair-route and full-pop theorems
Theorem (pair-chain pop_green). Under the contracts in Section 3, for every pair-route input , pop_pair_green(c) returns and a semi-cadeque over satisfying
All returned levels, arities and colors are admitted by the indexed constructors, and every old value is preserved.
Proof. Write and . Then .
In the six-entry branch, Section 4 gives , where is the six-entry boundary word. Section 5 and chain_of_triple give residual word . Hence .
In the residual-triple branch, Section 4 gives . The certified chain_of_triple conversion gives a residual left chain of word , and the returned Pair has word . Hence . These are the two source result branches.
Corollary (complete green pop). Combine the pair theorem with the previous single-chain theorem. For every and every
the source pop_green returns with
The source arity constructors restrict a nonempty chain to arity one or two, so the Single and Pair proofs are exhaustive. This is an exact sequence theorem for the inspected source algebra under the buffer contracts. It is not a claim of raw graph equivalence or a new proof of the upstream Rocq theorem.
7. Resource bound
Count explicit algebraic constructor blocks in the pinned pair route, including result wrappers and excluding buffer-helper internals. triple_of_chain is called at most twice and allocates at most four blocks per call. pop_left_green allocates at most three, only_of_right at most two, chain_of_triple at most three, and the outer result at most two. A conservative wrapper bound is therefore 18 fresh blocks. The six-entry boundary gives maximum explicit arity six.
Suppose each of the five listed buffer helpers has arity at most , radius at most , and allocation at most . A pair route calls at most four helpers: pop, possibly has5, and one of pair or push2, followed by push6. Conservative composed bounds are
The additive radius covers the chain, packet, body or node and view-wrapper paths outside helper calls. The Single route is smaller, so these also bound full pop_green after taking a common helper maximum. They are construction bounds, not optima or measurements of an optimizing OCaml compiler.
For a fixed finite controller with registered roots, once all its called operations have such certificates, the simultaneous-record compiler uses
It preserves decoded records and certified controller observations from a fixed finite initialization. It does not make arbitrary historical roots free, reveal pointer identity, or preserve arbitrary scaffold-context observations. A scaffold recognizing transfers to a PEG for .
8. Verification, examples and novelty
The symbolic checker pins the four source files and checks seven typed pop_left_green subcases, six typed only_of_right subcases, and both pop_pair_green result arms. It uses free word blocks. In particular, one stored head is represented by two formal tokens to prevent accidental identification with one payload letter.
Positive edge cases include the exact five-entry ending prefix, which must return a six-entry boundary, and the non-ending splice, which constructs an eight-entry prefix. Negative controls reject placing the right word before the boundary, reversing the six entries, swapping residual left and right chains, retaining the popped head, rebuilding an undersized Left node, and omitting required prefix-index adaptation.
The recorded output states the exact scope. The checker is a handwritten symbolic model, not an OCaml parser, a source-refinement compiler, a proof-assistant formalization or a verification of buffer internals. Source hashes establish provenance, not a semantic source relation. The written branch derivation supplies that relation for this route.
The finite-boundary splice lemma is elementary algebraic composition. The upstream Rocq development already proves the full deque theorem. No novelty is claimed for either ingredient. The potentially additional contribution is their use as a checkable, resource-explicit local certificate pattern that can feed the scaffolding compiler. A literature search has not established novelty of that combination.
9. Consequence and next question
The prefix-repair theorem previously assumed all of pop_green. That semantic assumption can now be replaced by the explicit buffer contracts and the two route certificates. The remaining local premises for that repair are semi_push, semi_concat, has3p, inject3 and bounded vector injection.
The next decisive question is whether the finite-boundary splice lemma is merely convenient terminology for this deque or a reusable certificate interface. Test it against one independent persistent operation with a different fixed boundary size. A positive instance should expose a bounded underflow boundary and a separately checkable neighbor-splice equation. A negative example should show why unbounded boundary information prevents this certificate, without claiming that every alternative representation is impossible.