Documentation

CslibFrontier.Computability.PointerMachine.WordRAM.NaturalSimulation

Compiling bounded natural-scalar computations #

For the natural scalar basis, one source instruction increases the largest scalar by at most one and allocates at most one record. An initial scalar bound and an instruction bound therefore supply a sufficient word width for the complete execution. executes_compile discharges all intermediate word-fit and scalar-admissibility premises of the general compiler.

The target begins with the canonical encoded input; input preparation is not charged. The bounds are conservative: a particular algorithm may need much less scalar headroom.

The natural basis has a uniform compiler overhead depending only on the record layout, not on the source program's length or control flow.

theorem Cslib.PointerMachine.WordRAM.Natural.executes_compile {L : Layout} {w time limit b : ℕ} {code : List (Instr model L)} {x x' : State model L} (valid : x.Valid) (run : Executes code x x' time) (bound : time ≤ limit) (initial : x.DataValid fun (x : model.Value) => x ≤ b) (memory : Cslib.WordRAM.Fits w (nodeAddr L (x.heap.length + limit))) (values : Cslib.WordRAM.Fits w (b + limit)) :
∃ (z : WordRAM.Data (regCount L)) (k : ℕ), k + 1 ≤ (scalars L).overhead code * time ∧ WordRAM.Runs w ((scalars L).compile code) { pc := (scalars L).blockSize code * x.pc, data := encodeState (scalars L).encode x } { pc := (scalars L).blockSize code * x'.pc, data := z } k ∧ Repr (scalars L).encode x' z ∧ WordRAM.step w ((scalars L).compile code) { pc := (scalars L).blockSize code * x'.pc, data := z } = WordRAM.Outcome.halt 0

Compile a natural-scalar execution with explicit sufficient width. All initial data is at most b; at most limit instructions execute. Fitting b + limit and the next-free address after limit allocations suffices, with no hypotheses about intermediate machine states. The produced target run includes the general compiler's halt and constant time overhead.