Documentation

Complexity.Computability.Ram.Compiler.Language.Arena.Measured.Allocation

Composing actual measured allocation #

The allocation rule retains the initialized source object, its actual extended heap, and the increased arena cursor for the continuation. Its instruction count is the existing allocation constructor's count, not a user-selected budget.

theorem Ram.LanguageCompiler.ArenaMeasured.alloc {signatures : List Complexity.Language.Signature} {program : Complexity.Language.Program signatures} {w heapLimit depth : ℕ} {Γ : List Complexity.Language.Ty} {result : Complexity.Language.Ty} {kind : Complexity.Language.CellTy} {length : Complexity.Language.Atom Γ Complexity.Language.Ty.nat} {initial : Complexity.Language.Atom Γ kind.toTy} {continuation : Complexity.Language.Stmt signatures (Complexity.Language.Ty.buffer kind :: Γ) result} {post : Complexity.Language.State Γ → Complexity.Language.Control result → ℕ → ℕ → Prop} {entry : Complexity.Language.State Γ} {cursor : ℕ} (initialFits : ValueFits w (initial.eval entry.locals)) (capacity : cursor + length.eval entry.locals ≤ heapLimit) (body : have allocated := entry.heap.alloc (length.eval entry.locals) (kind.ofValue (initial.eval entry.locals)); ArenaMeasured program w heapLimit depth continuation (fun (finish : Complexity.Language.State (Complexity.Language.Ty.buffer kind :: Γ)) (control : Complexity.Language.Control result) (finalCursor steps : ℕ) => post finish.tail control finalCursor (14 * length.eval entry.locals + 18 + steps)) (Complexity.Language.State.cons allocated.1 { locals := entry.locals, heap := allocated.2 }) (cursor + length.eval entry.locals)) :
ArenaMeasured program w heapLimit depth (Complexity.Language.Stmt.alloc length initial continuation) post entry cursor

Allocate the actual initialized array, then continue at its extended heap and cursor. Initialization work is included by the existing compiler cost rule.