Documentation

CslibFrontier.Computability.WordRAM.PointerMachine.Simulation

Standard word-RAM execution on an allocating pointer machine #

The concrete compiler replaces memory accesses by the verified AVL dictionary programs. The time bound is logarithmic in the number of retained dictionary entries; writing zero retains its node. Each source instruction allocates at most one node. Physical heap pointers are opaque; source addresses and word operations are scalar data in model w.

Only successful deterministic source executions are simulated. The input is the explicit inputState encoding; as for source Data.init, constructing that encoding is not charged.

theorem Cslib.WordRAM.PointerMachine.runs_compile {w r : ℕ} {p : Program Basis.standard r} {x y : State r} {n : ℕ} {s : PointerMachine.State (model w) (layout r)} {tree : BinaryTree (DataStructure.SearchTree.PointerMachine.Label (model w) 2)} {avl : DataStructure.AVLTree ℕ} (rep : Represents x.data s tree avl) (pc : s.pc = blockSize w r * x.pc) (run : Runs w p x y n) :

A continuing source run is simulated with logarithmic overhead in the final dictionary size. The complete register/memory representation is preserved, and both dictionary size and allocated space grow by at most one per source instruction.

theorem Cslib.WordRAM.PointerMachine.executes_compile {w r : ℕ} {p : Program Basis.standard r} {x : State r} {v n : ℕ} {s : PointerMachine.State (model w) (layout r)} {tree : BinaryTree (DataStructure.SearchTree.PointerMachine.Label (model w) 2)} {avl : DataStructure.AVLTree ℕ} (rep : Represents x.data s tree avl) (pc : s.pc = blockSize w r * x.pc) (execution : Executes w p x v n) :
∃ (y : State r) (t : PointerMachine.State (model w) (layout r)) (tree' : BinaryTree (DataStructure.SearchTree.PointerMachine.Label (model w) 2)) (avl' : DataStructure.AVLTree ℕ) (time : ℕ), PointerMachine.Executes (compile w p) s t time ∧ t.data 3 = v ∧ Runs w p x y (n - 1) ∧ step w p y = Outcome.halt v ∧ Represents y.data t tree' avl' ∧ avl'.elements.card ≤ avl.elements.card + (n - 1) ∧ time ≤ n * (294 * Nat.log 2 (avl'.elements.card + 1) + 56) ∧ t.heap.length ≤ s.heap.length + (n - 1)

A successful source execution is compiled to a halting pointer-machine execution with its returned word in scalar register three. The complete represented final data is retained. The logarithmic factor uses retained dictionary entries, including cells written back to zero.

theorem Cslib.WordRAM.PointerMachine.executes_input {w r : ℕ} {p : Program Basis.standard r} {input : List ℕ} {v n : ℕ} (execution : Executes w p { pc := 0, data := Data.init input } v n) :
∃ (t : PointerMachine.State (model w) (layout r)) (time : ℕ), PointerMachine.Executes (compile w p) (inputState w r input) t time ∧ t.data 3 = v ∧ time ≤ n * (294 * Nat.log 2 (input.length + n + 1) + 56) ∧ t.heap.length ≤ input.length + n ∧ t.Valid

Every successful standard word-RAM run from a list input has an actual pointer-machine execution returning the same word. For n source instructions and N input words it uses at most N + n records and n * (294 * log₂ (N + n + 1) + 56) instructions, including halt. Target scalars are unbounded naturals carrying the standard word operations at source width w, together with AVL height operations; this is not a simulation by an atom-only scalar model. Input encoding is explicitly constructed by inputState and is not charged in either model. This simulates successful deterministic runs, without asserting fault equivalence.