Bounded memory-client loops #
Bounded iteration remains an ordinary Memory.Prog term. The local-work currency counts body
work and every iteration, including iterations issuing no memory query. The native realization
uses one fixed body emitter and static registers for the mutable state and countdown counter.
Main definitions #
iterate: bounded iteration in the existing memory-client monad.iterationWork,iterationSafe: local work and domains along the actual semantic states.loopEmit,loopBody: the native loop with a fixed body emitter, and one native iteration, over the register bankstateSlot,counterSlot,zeroSlot,oneSlot,bodySlot.
Main results #
iterationSum_eq: the native grading rule's semantic sum is memory charge plus local work.loopEmit_entry,loopBody_tail: the native loop's entry prologue and the control tail of one iteration, shared by the deterministic and randomized loop realizations.bodyBank_layout,bodySlot_injective,stateSlot_ne_bodySlot,regs_comp_append_eq_appendWords,loopEmit_not_readsWidth: the body bank's register premises, the state words read back as appended words, and width-freedom of the loop.iterationWork_zero: evaluate local work when the body has no local-work charge.Realizes.Witness.loopEmit_spec: the loop emitter with additive per-iteration overhead.Realizes.Witness.iterateRuntime,Realizes.iterateRuntime: one uniform body witness or certificate realizes a runtime-bounded loop.
The iteration grading and realization are original infrastructure over the existing free monad
and structured Word-RAM code. No additional program syntax or memory model is introduced.
Fixed-environment transport laws are provided by the LoopCongr module.
Execute one fixed body family a runtime-bounded number of times.
Instances For
Local computation and one control-work unit per iteration, along actual semantic states.
Instances For
With no body-local work, the local grade is exactly one control unit per iteration.
Every executed body must satisfy its explicit domain at the reached state.
Instances For
Memory cost and certified local work decompose at each actual iteration.
One semantic iteration updates both the mutable value and the complete memory state.
Instances For
The interpreter follows precisely the bounded semantic transition, not an arbitrary state.
The native grading rule's semantic sum is exactly memory charge plus local iteration work.
One native iteration: run the body on the environment and state words, copy its result into the state words and count down.
Instances For
The native loop: install the state words and the counter, then iterate loopBody while the
counter is positive.
Instances For
Registers holding the environment words followed by the state words read back the appended words.
A body bank tmp ∘ btS inside an injective scratch bank tmp meets the register hypotheses
of the body's certificate, which reads the environment env and the state words tmp ∘ stS.
The native loop reads the word width only where its body does.
The loop's body bank does not repeat a register.
Entering the native loop of loopEmit: copy the state words into the bank, install the
counter and clear the zero register. Memory, the frontier and every register outside the scratch
bank are unchanged.
The control tail of one iteration of loopBody, after the body ran from y to u: copy the
body's result words into the state words and count down. Memory, the frontier, the zero register
and every register outside the scratch bank keep their values.
The existing loop emitter retains the complete realization postcondition while paying body charges and state/control overhead separately. This bounds that supplied emitter, not a classically reselected implementation.
Retain the supplied body and the existing loop emitter as data. Its original coarse
realization contract follows from the sharper same-emitter loopEmit_spec.
Instances For
The existential runtime-loop realization erases the retained supplied emitter.
Frontier-bounded realization of runtime-bounded iterate.