Documentation

Examples.Language.ScopeCompiledWork

Resource readiness of the actual scratch worker #

The source correctness proof supplies the worker's successful execution. This module adds only word ranges and temporary capacity for that same execution; it neither repeats termination nor supplies a separately maintained program. Both nested scopes restore their respective entry cursors. Consequently the worker's temporary capacity depends on the two simultaneous arrays, not on the number of later calls to the worker.

A successful inner scratch block needs exactly one temporary extent and returns the allocator to its entry cursor. The complete local coordinates keep all pending results; their values do not affect the allocation-only body.

theorem Complexity.Language.Examples.Scope.work_ready (out : Buffer CellTy.nat) (n value : ℕ) (heap : Heap) {w limit depth cursor : ℕ} (hw : 0 < w) {finish : State [Ty.buffer CellTy.nat, Ty.nat, Ty.nat]} (outRooted : out.Rooted heap) (outFits : out.length < 2 ^ w) (nFits : n < 2 ^ w) (valueFits : value < 2 ^ w) (capacity : cursor + 2 * n ≤ limit) (execution : Exec Implementation.Source.program Implementation.Source.workBody { locals := Implementation.Source.work_args out n value, heap := heap } finish (Control.returned ())) :
Ram.LanguageCompiler.ArenaReady execution w limit depth cursor cursor

The actual worker can be invoked at any available call depth. Its two simultaneous temporary arrays fit in 2 * n words, and both scopes have released that space before the call returns. The positive word width also represents the local completion tag; no instruction or termination budget enters the premise.