Documentation

Complexity.Computability.Ram.Compiler.Language.Arena.MeasuredNode

Measured inline allocation of a typed immutable node #

Three actual field copies prepare the head, optional-tail tag and placed tail address. The existing allocator then reserves and initializes one three-word node. The same counted execution supplies the final arena, fresh reference and lexical correspondence under the extended placement.

Only the optional tail's existing root is needed. There is no runtime validation or copying of its suffix, and a mathematical List observation is not required by this raw node operation. Existing locals retain their representation through their rootedness; the four fresh local slots account for operand preparation as well as the returned base.

theorem Ram.LanguageCompiler.lowerConsNode_measured {w control heapLimit depth cursor : ℕ} {program : Program} {Γ : List Complexity.Language.Ty} {kind : Complexity.Language.CellTy} {placement : ℕ → Word w} {heap : Complexity.Language.Heap} (layout : RegisterMap Γ) (next : Reg) (head : Complexity.Language.Atom Γ kind.toTy) (tail : Complexity.Language.Atom Γ (Complexity.Language.Ty.node kind).option) (env : Complexity.Language.Env Γ) (entry : Source.State w) (arena : ArenaRep placement cursor heapLimit heap entry) (rooted : env.Rooted heap) (matched : layout.Matches placement env entry.regs) (bounded : layout.Bounded next) (headFits : ValueFits w (head.eval env)) (tailFits : ValueFits w (tail.eval env)) (capacity : cursor + 3 ≤ heapLimit) :
have allocated := heap.cons (kind.ofValue (head.eval env)) (tail.eval env); have finalPlacement := Function.update placement heap.objects.size (BitVec.ofNat w cursor); ∃ (finish : Source.State w), Source.LocalMeasuredExec control program heapLimit depth (lowerConsNode (fun {τ : Complexity.Language.Ty} => layout) next head tail) consNodeCodeSize entry finish ∧ ArenaRep finalPlacement (cursor + 3) heapLimit allocated.2 finish ∧ RegisterMap.Matches (fun {τ : Complexity.Language.Ty} => RegisterMap.extend (fun {τ : Complexity.Language.Ty} => layout) (Complexity.Language.Ty.node kind) next) finalPlacement (Complexity.Language.Env.cons allocated.1 env) finish.regs ∧ ∀ (slot : Reg), slot < next ∨ next + 4 ≤ slot → finish.regs slot = entry.regs slot

Materialize the actual operands and allocate one immutable node. The result and complete arena belong to the same execution, including all three copies and initialization stores. Only four fresh local slots may change.