Documentation

Complexity.Computability.Ram.Compiler.Language.Arena.Node

Representing a completed immutable-node allocation #

An initialized fresh three-word interval represents the single node appended by Heap.cons. Its tail word contains the existing tail's actual placement; only the new object's placement changes. All older objects, including nodes with shared tails and mutable buffers, retain their complete representation.

An existing tail root establishes old-domain membership. The new node keeps the concrete backward-link invariant without requiring a complete list proof. The list specialization additionally preserves its typed contents. These rules consume the runtime's initialization, cursor and frame facts; they do not execute an allocator, traverse the tail or assign a constant instruction count.

theorem Ram.LanguageCompiler.ArenaRep.cons_of_rooted {w next heapLimit : ℕ} {placement : ℕ → Word w} {heap : Complexity.Language.Heap} {entry finish : Source.State w} (arena : ArenaRep placement next heapLimit heap entry) {τ : Complexity.Language.CellTy} {head : Complexity.Language.CellValue τ} {tail : Option (Complexity.Language.NodeRef τ)} (rooted : Complexity.Language.ValueRooted heap tail) (headFits : cellToNat head < 2 ^ w) (capacity : next + 3 ≤ heapLimit) (cursor : finish.mem 0 = BitVec.ofNat w (next + 3)) (initialized : Source.ArrayAt heapLimit (BitVec.ofNat w next) (heapObjectWords placement (Complexity.Language.HeapObject.node τ head tail)).toList finish) (same : ∀ (address : Word w), 0 < BitVec.toNat address → BitVec.toNat address < next → finish.mem address = entry.mem address) :
ArenaRep (Function.update placement heap.objects.size (BitVec.ofNat w next)) (next + 3) heapLimit (heap.cons head tail).2 finish

One completed initialization extends the arena by the actual three-word node. The optional tail must name an old object, but need not represent a list. Stored type and list contents remain independent semantic properties.

theorem Ram.LanguageCompiler.ArenaRep.cons {w next heapLimit : ℕ} {placement : ℕ → Word w} {heap : Complexity.Language.Heap} {entry finish : Source.State w} (arena : ArenaRep placement next heapLimit heap entry) {τ : Complexity.Language.CellTy} {head : Complexity.Language.CellValue τ} {tail : Option (Complexity.Language.NodeRef τ)} {values : List (Complexity.Language.CellValue τ)} (observed : Complexity.Language.NodeRef.Contents heap tail values) (headFits : cellToNat head < 2 ^ w) (capacity : next + 3 ≤ heapLimit) (cursor : finish.mem 0 = BitVec.ofNat w (next + 3)) (initialized : Source.ArrayAt heapLimit (BitVec.ofNat w next) (heapObjectWords placement (Complexity.Language.HeapObject.node τ head tail)).toList finish) (same : ∀ (address : Word w), 0 < BitVec.toNat address → BitVec.toNat address < next → finish.mem address = entry.mem address) :
ArenaRep (Function.update placement heap.objects.size (BitVec.ofNat w next)) (next + 3) heapLimit (heap.cons head tail).2 finish

One completed three-word initialization extends the arena by the actual new node. Tail contents are a logical precondition, not a runtime traversal.

theorem Ram.LanguageCompiler.ArenaRep.cons_contents {w next heapLimit : ℕ} {placement : ℕ → Word w} {heap : Complexity.Language.Heap} {entry finish : Source.State w} (arena : ArenaRep placement next heapLimit heap entry) {τ : Complexity.Language.CellTy} {head : Complexity.Language.CellValue τ} {tail : Option (Complexity.Language.NodeRef τ)} {values : List (Complexity.Language.CellValue τ)} (observed : Complexity.Language.NodeRef.Contents heap tail values) (headFits : cellToNat head < 2 ^ w) (capacity : next + 3 ≤ heapLimit) (cursor : finish.mem 0 = BitVec.ofNat w (next + 3)) (initialized : Source.ArrayAt heapLimit (BitVec.ofNat w next) (heapObjectWords placement (Complexity.Language.HeapObject.node τ head tail)).toList finish) (same : ∀ (address : Word w), 0 < BitVec.toNat address → BitVec.toNat address < next → finish.mem address = entry.mem address) :
ArenaRep (Function.update placement heap.objects.size (BitVec.ofNat w next)) (next + 3) heapLimit (heap.cons head tail).2 finish ∧ Complexity.Language.NodeRef.Contents (heap.cons head tail).2 (some (heap.cons head tail).1) (head :: values) ∧ ∀ {σ : Complexity.Language.CellTy} {root : Option (Complexity.Language.NodeRef σ)} {xs : List (Complexity.Language.CellValue σ)}, Complexity.Language.NodeRef.Contents heap root xs → Complexity.Language.NodeRef.Contents (heap.cons head tail).2 root xs

The same completed allocation represents the ordinary list constructor while preserving every older list observation, including shared suffixes.