Compiling repeated calls with reusable temporary storage #
The source declaration and its mathematical correctness proof remain unchanged. Its real worker allocates nested scratch arrays, returns through scope cleanup, and updates a result allocated outside those scopes. Resource readiness adds only finite-word ranges, actual call nesting and simultaneous scratch capacity.
The loop reuses the same arena boundary after every call. Its source proof supplies termination; the compiled memory guarantee concerns every real access of the complete call-and-halt invocation, including transient accesses and the call stack, rather than only the final allocator cursor. The seeded physical footprint also retains the original arena prefix; repeated scratch and stack addresses are counted once, independently of the call count.
The existing scalar realization rules handle the actual generated guard. Only the remaining call count is read; heap contents do not affect it.
Realize the exact successful guard execution already used by source correctness, with no allocation and no change to the arena cursor.
The body calls the actual reclaiming worker and decrements the saved count. The caller and callee share one cursor; returning from the worker restores its scratch extent before the caller's normal continuation.
Every finite source loop reuses the same scratch capacity. The original mathematical invariant and body contract supply preservation; the additional proof checks only ranges and one level of actual callee nesting.
The generated maker's ordinary arguments, in the source function table's parameter order. This is an environment encoding, not another implementation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The complete maker retains only its one result cell. Its loop contract
tracks both ordinary completion and the actual last-round local return;
temporary capacity is independent of count.
A sufficient physical workspace envelope: the retained entry arena, one
result word, two simultaneously live scratch arrays, and two actual call frames.
The frame size is derived from the fixed generated program, not from count.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The same high-level declaration returns its mathematical array in the real halted RAM invocation. Every actual memory access, and therefore every distinct word touched, stays within a workspace bound independent of the iteration count. The shared launch carries the same preloaded representation, scalar ranges and word/code capacity. The result retains actual RAM memory, returned fields and counted execution; input loading and output conversion remain outside it.
Repeated scratch calls have a count-independent physical footprint in their actual halted invocation. The seed includes the complete preloaded arena prefix, and the access set includes transient scratch and call-frame words. Reclamation does not erase accesses, but reusing their addresses does not charge them again. This retains the original correctness and returned cursor; it is not a claim of exact peak-live storage or of free input loading.