Documentation

Examples.Language.ArrayIterationReady

Cumulative allocation for the existing array-record loop #

The unchanged ArrayRangeNative.repeatAppend allocates a new array each round and retains earlier arrays. Its reserve is the sum of all new payload lengths, not merely the final length. The current array layout charges no per-array header cells.

The mathematical guard/body contracts transport observations at actual heaps. The shared readiness rule reuses them on an existing source execution, with word ranges and cumulative capacity explicit. This adds neither a second termination proof nor a new implementation. The full-function result uses the original source totality, the existing nonuniform time certificate and an actual preloaded launch. Its typed outcome retains the original mathematical contract, the exact cursor growth and the same halted runner's instruction bound. No input-loading or exact peak-live-space claim follows from this retained allocation bound.

All fresh array cells allocated by the remaining rounds; old arrays remain allocated.

Equations
Instances For
    theorem Complexity.Language.Examples.LinkedList.NativeRange.RepeatAppendReady.reserve_succ (count size chunk : ℕ) :
    reserve (count + 1) size chunk = size + chunk + reserve count (size + chunk) chunk

    Word ranges and the cumulative unused reservation, expressed only in mathematical locals.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      The current mathematical record has word-sized fields; any actual observation inherits these ranges through the shared representation rules.

      The actual guard does not allocate; its scalar comparison uses the represented count.

      theorem Complexity.Language.Examples.LinkedList.NativeRange.RepeatAppendReady.loop_ready {w heapLimit cursor : ℕ} (positive : 0 < w) (model : ArrayRangeNative.Source.repeatAppend_loop1.Model) (entry : State [Ty.nat, (Ty.buffer CellTy.nat).prod Ty.nat, Ty.nat, Ty.buffer CellTy.nat, (Ty.buffer CellTy.nat).prod Ty.nat]) (valid : invariant w heapLimit model cursor) (related : ArrayRangeNative.Source.repeatAppend_loop1.modelRel model (ArrayRangeNative.Source.repeatAppend_loop1.View entry.locals) entry.heap) {finish : State [Ty.nat, (Ty.buffer CellTy.nat).prod Ty.nat, Ty.nat, Ty.buffer CellTy.nat, (Ty.buffer CellTy.nat).prod Ty.nat]} {control : Control ((Ty.buffer CellTy.nat).prod Ty.nat)} (execution : Exec ArrayRangeNative.Source.program ArrayRangeNative.Source.repeatAppend_loop1.Code entry finish control) (successful : Control.Satisfies (fun (x : State [Ty.nat, (Ty.buffer CellTy.nat).prod Ty.nat, Ty.nat, Ty.buffer CellTy.nat, (Ty.buffer CellTy.nat).prod Ty.nat]) => True) (fun (x : Value ((Ty.buffer CellTy.nat).prod Ty.nat)) (x_1 : State [Ty.nat, (Ty.buffer CellTy.nat).prod Ty.nat, Ty.nat, Ty.buffer CellTy.nat, (Ty.buffer CellTy.nat).prod Ty.nat]) => True) control finish) :

      The same finite loop is ready, consuming exactly the sum of its fresh arrays.

      theorem Complexity.Language.Examples.LinkedList.NativeRange.RepeatAppendReady.function_measured {w heapLimit cursor : ℕ} (positive : 0 < w) (count : ℕ) (chunkValues : Array ℕ) (initialValue : Payload) (chunk : Buffer CellTy.nat) (initial : Buffer CellTy.nat × ℕ) (heap : Heap) (chunkObserved : chunk.Contents heap chunkValues) (initialObserved : ArrayRangeNative.Source.repeatAppend_loop1.state_representation.Rel initialValue initial heap) (valid : invariant w heapLimit (ArrayRangeNative.Source.repeatAppend_loop1.mkModel count initialValue initialValue chunkValues count) cursor) :

      Obtain source termination from the existing correctness contract and measure that very execution, with no additional termination or instruction-budget premise.

      theorem Complexity.Language.Examples.LinkedList.NativeRange.RepeatAppendReady.body_ready {w heapLimit cursor : ℕ} (positive : 0 < w) (count : ℕ) (chunkValues : Array ℕ) (initialValue : Payload) (chunk : Buffer CellTy.nat) (initial : Buffer CellTy.nat × ℕ) (heap : Heap) (chunkObserved : chunk.Contents heap chunkValues) (initialObserved : ArrayRangeNative.Source.repeatAppend_loop1.state_representation.Rel initialValue initial heap) (valid : invariant w heapLimit (ArrayRangeNative.Source.repeatAppend_loop1.mkModel count initialValue initialValue chunkValues count) cursor) {finish : State ArrayRangeNative.Source.signatures[ArrayRangeNative.Source.repeatAppendId].params} {value : Value ((Ty.buffer CellTy.nat).prod Ty.nat)} (execution : Exec ArrayRangeNative.Source.program (ArrayRangeNative.Source.program.body ArrayRangeNative.Source.repeatAppendId) { locals := ArrayRangeNative.Source.repeatAppend_args count chunk initial, heap := heap } finish (Control.returned value)) :
      Ram.LanguageCompiler.ArenaReady execution w heapLimit 2 cursor (cursor + reserve count initialValue.values.size chunkValues.size)

      Attach the loop readiness to the unchanged function's two bindings and final return.

      theorem Complexity.Language.Examples.LinkedList.NativeRange.RepeatAppendReady.function_resources {w heapLimit : ℕ} (positive : 0 < w) (count : ℕ) (chunkValues : Array ℕ) (initialValue : Payload) (copiesFit : initialValue.copies + count < 2 ^ w) (sizeFit : initialValue.values.size + count * chunkValues.size < 2 ^ w) (valuesFit : ∀ (i : ℕ) (hi : i < initialValue.values.size), initialValue.values[i] < 2 ^ w) (chunkFit : ∀ (i : ℕ) (hi : i < chunkValues.size), chunkValues[i] < 2 ^ w) :

      Bound the original function's retained allocation by the cumulative fresh-array reservation. Its source precondition retains actual handles and permits overlapping inputs.

      theorem Complexity.Language.Examples.LinkedList.NativeRange.RepeatAppendReady.execute {w heapLimit cursor : ℕ} {placement : ℕ → Ram.Word w} (count : ℕ) (chunkValues : Array ℕ) (initialValue : Payload) (chunk : Buffer CellTy.nat) (initial : Buffer CellTy.nat × ℕ) {heap : Heap} (chunkObserved : chunk.Contents heap chunkValues) (initialObserved : ArrayRangeNative.Source.repeatAppend_loop1.state_representation.Rel initialValue initial heap) (copiesFit : initialValue.copies + count < 2 ^ w) (sizeFit : initialValue.values.size + count * chunkValues.size < 2 ^ w) (valuesFit : ∀ (i : ℕ) (hi : i < initialValue.values.size), initialValue.values[i] < 2 ^ w) (chunkFit : ∀ (i : ℕ) (hi : i < chunkValues.size), chunkValues[i] < 2 ^ w) {entry : Ram.Source.State w} (launch : Ram.LanguageCompiler.FunctionArenaLaunch ArrayRangeNative.Source.program ArrayRangeNative.Source.repeatAppendId 2 heapLimit placement (ArrayRangeNative.Source.repeatAppend_args count chunk initial) heap cursor entry) (capacity : cursor + reserve count initialValue.values.size chunkValues.size ≤ heapLimit) :

      Publish one complete invocation with the original mathematical contract, the exact retained arena growth and the previously proved nonuniform time bound.