Local-address RAM simulation #
A finite RAM interval has address registers separate from scalar registers. Each cell holds a scalar and a reference. The only address arithmetic is successor and predecessor, with a distinguished null reference for a move outside the interval.
The pointer representation has one record per cell, with immutable predecessor and successor links. The representation is supplied at entry. Each RAM instruction translates to one pointer instruction, and structured executions preserve instruction counts.
Schönhage describes the real-time equivalence of storage modification machines and successor RAMs [Sch80], abstract. The compiler here goes from the typed local-address RAM to the pointer machine.
Main definitions #
Data,Direction,Op,Test,instructionSet: the typed local-address RAM.layout,encode,compile: its linked representation and compiler.evalRand: the interpretation with randomized scalar operations.
Main results #
exec_compile: exact simulation of structured executions.executes_compile: the corresponding flat pointer-machine program, including its final halt.execRand_compile: exact joint distribution of output states and instruction counts for structured runs with common probabilistic scalar primitives.runRand_compile: output distribution of the assembled randomized pointer-machine program.
A local-address RAM with n cells, p address registers and d scalar registers.
Address registers.
Scalar registers.
Data stored at each RAM address.
References stored at each RAM address.
A local address move.
The operations of the local-address RAM.
- null {M : PointerMachine.Model} {p d : ℕ} (dst : Fin p) : Op M p d
- copyAddr {M : PointerMachine.Model} {p d : ℕ} (dst src : Fin p) : Op M p d
- move {M : PointerMachine.Model} {p d : ℕ} (dir : Direction) (dst src : Fin p) : Op M p d
- copyData {M : PointerMachine.Model} {p d : ℕ} (dst src : Fin d) : Op M p d
- scalar {M : PointerMachine.Model} {p d : ℕ} (o : M.Op) (dst a b : Fin d) : Op M p d
- loadData {M : PointerMachine.Model} {p d : ℕ} (dst : Fin d) (src : Fin p) : Op M p d
- storeData {M : PointerMachine.Model} {p d : ℕ} (dst : Fin p) (src : Fin d) : Op M p d
- loadAddr {M : PointerMachine.Model} {p d : ℕ} (dst src : Fin p) : Op M p d
- storeAddr {M : PointerMachine.Model} {p d : ℕ} (dst src : Fin p) : Op M p d
Operations through null leave the state unchanged.
The local-address RAM can test reference equality and compare scalar data.
- addrEq {M : PointerMachine.Model} {p d : ℕ} (a b : Fin p) : Test M p d
- scalar {M : PointerMachine.Model} {p d : ℕ} (t : M.Test) (a b : Fin d) : Test M p d
Structured instruction semantics for the local-address RAM.
Record fields for the reference, successor and predecessor, and one scalar payload.
Encode an interval as a doubly linked chain of records in address order.
Encoded states start at label zero.
The linked representation uses exactly one record per source cell.
All references in the initial linked representation designate allocated records or null.
Compile local-address programs, preserving their control flow.
Compilation preserves the number of assembled instructions.
Every source structured run executes on the linked representation at the same cost.
The encoded scalar registers retain their source values.
Assembling the simulation adds only the final halt to the source instruction count.
Probabilistic scalar primitives #
Interpret scalar operations using probabilistic kernels. Address operations and memory access keep their deterministic meanings. Each operation costs one instruction.
With matching scalar kernels, compilation preserves the entire distribution of results and instruction counts of each terminating structured execution.
A budget covering every structured run reaches the compiled halt with the encoded output distribution.