Documentation

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

Structural cost of initialized buffer allocation #

This rule bounds the existing allocation cost observation. The continuation starts at Heap.alloc's actual initialized heap and returned descriptor, while the allocator's operand preparation, reservation and initialization retain the count already established by the measured compiler theorem. The rule supplies neither a successful execution nor a new capacity or word-range assumption.

theorem Ram.LanguageCompiler.StmtArenaCostBound.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} {entry : Complexity.Language.State Γ} {bound : ℕ} (body : StmtArenaCostBound program w heapLimit depth continuation (have allocated := entry.heap.alloc (length.eval entry.locals) (kind.ofValue (initial.eval entry.locals)); Complexity.Language.State.cons allocated.1 { locals := entry.locals, heap := allocated.2 }) bound) :
StmtArenaCostBound program w heapLimit depth (Complexity.Language.Stmt.alloc length initial continuation) entry (14 * length.eval entry.locals + 18 + bound)

Compose the measured allocator's real initialization charge with a bound on its continuation at the actual freshly extended source heap.