Documentation

CslibFrontier.Computability.WordRAM.Realization.Program.Standard

Initialized flat programs with a fixed register layout #

Choose the frontier, input bank and fresh scratch bank once, before every runtime width and argument. Clients supply the same encoded-input, fit, domain and memory-history premises as Realizes.exists_init_program, without proving register-placement conditions themselves. The real Data.init prefix, native body and trailing halt are all charged. Its positive next-free address must fit even for an empty input; this is not a width-zero initialization.

Main definitions #

Main results #

The observed coordinate is static, as in the existing scalar export. Zero-output Unit clients continue to use the separate charged Unit-observation API.

References #

This is original infrastructure over the existing realization certificate, charged input prefix and native Code.program compiler. It introduces no execution model or client language.

Replace unreachable .rand instructions in p with no-op register copies so the resulting flat program satisfies Program.IsRandFree while preserving all deterministic runs.

stripRand p contains no .rand instructions.

stripRand preserves width-blindness (¬Program.ReadsWidth).

theorem Cslib.WordRAM.Realization.step_stripRand_of_halt {B : Basis} {r w v : ℕ} {p : Program B r} {s : State r} (h : step w p s = Outcome.halt v) :

Halting steps of p transfer unchanged to stripRand p.

theorem Cslib.WordRAM.Realization.runs_stripRand {B : Basis} {r w : ℕ} {p : Program B r} {s t : State r} {m : ℕ} (h : Runs w p s t m) :
Runs w (stripRand p) s t m

Deterministic Runs of p transfer unchanged to stripRand p.

theorem Cslib.WordRAM.Realization.Realizes.exists_standard_init_program_state_from_words {k l : ℕ} {δ α : Type} {p : δ → DataStructure.Memory.Prog α} {input : δ ↪ Fin k → ℕ} {output : α ↪ Fin l → ℕ} {safe : ℕ → δ → DataStructure.Memory.State → Prop} {work : δ → DataStructure.Memory.State → ℕ} (h : Realizes Basis.exact p input output safe work) (i : Fin l) :
∃ (r : ℕ) (C : ℕ) (pc : ℕ) (prog : Program Basis.exact r) (frontier : Fin r) (out : Fin l → Fin r), ∀ (w : ℕ) (d : δ) (words : List ℕ), (∀ (j : Fin k), words.getD (↑j) 0 = input d j) → k ≤ words.length → Fits w (words.length + 1) → InputFits w words → safe w d (DataStructure.Memory.State.init words) → (DataStructure.Memory.spec w).ValidHistory (DataStructure.Memory.State.init words) ((DataStructure.Memory.spec w).clientHistory (DataStructure.Memory.State.init words) (p d)) → ∃ (y : Data r) (n : ℕ), Runs w prog (State.init words) { pc := pc, data := y } n ∧ step w prog { pc := pc, data := y } = Outcome.halt (output ((DataStructure.Memory.spec w).clientResult (DataStructure.Memory.State.init words) (p d)) i) ∧ memoryState frontier y = (DataStructure.Memory.spec w).clientState (DataStructure.Memory.State.init words) (p d) ∧ (∀ (j : Fin l), y.regs (out j) = output ((DataStructure.Memory.spec w).clientResult (DataStructure.Memory.State.init words) (p d)) j) ∧ n + 1 ≤ C * (memoryCost (p d) (DataStructure.Memory.State.init words) + work d (DataStructure.Memory.State.init words) + 1) + 1

One statically laid-out flat program includes charged input installation and its halt. The witnessed native state is the actual final state of the flat run, retaining the entire source memory and frontier and every result coordinate. The raw input words vary independently of the register-encoded argument: only their input prefix must agree. All witnesses precede both kinds of runtime data.

theorem Cslib.WordRAM.Realization.Realizes.exists_standard_init_program_state {k l : ℕ} {δ α : Type} {p : δ → DataStructure.Memory.Prog α} {input : δ ↪ Fin k → ℕ} {output : α ↪ Fin l → ℕ} {safe : ℕ → δ → DataStructure.Memory.State → Prop} {work : δ → DataStructure.Memory.State → ℕ} (h : Realizes Basis.exact p input output safe work) (raw : δ → List ℕ) (hlayout : ∀ (d : δ) (i : Fin k), (raw d).getD (↑i) 0 = input d i) (i : Fin l) :
∃ (r : ℕ) (C : ℕ) (pc : ℕ) (prog : Program Basis.exact r) (frontier : Fin r) (out : Fin l → Fin r), ∀ (w : ℕ) (d : δ), k ≤ (raw d).length → Fits w ((raw d).length + 1) → InputFits w (raw d) → safe w d (DataStructure.Memory.State.init (raw d)) → (DataStructure.Memory.spec w).ValidHistory (DataStructure.Memory.State.init (raw d)) ((DataStructure.Memory.spec w).clientHistory (DataStructure.Memory.State.init (raw d)) (p d)) → ∃ (y : Data r) (n : ℕ), Runs w prog (State.init (raw d)) { pc := pc, data := y } n ∧ step w prog { pc := pc, data := y } = Outcome.halt (output ((DataStructure.Memory.spec w).clientResult (DataStructure.Memory.State.init (raw d)) (p d)) i) ∧ memoryState frontier y = (DataStructure.Memory.spec w).clientState (DataStructure.Memory.State.init (raw d)) (p d) ∧ (∀ (j : Fin l), y.regs (out j) = output ((DataStructure.Memory.spec w).clientResult (DataStructure.Memory.State.init (raw d)) (p d)) j) ∧ n + 1 ≤ C * (memoryCost (p d) (DataStructure.Memory.State.init (raw d)) + work d (DataStructure.Memory.State.init (raw d)) + 1) + 1

One statically laid-out flat program includes charged input installation and its halt. The witnessed native state is the actual final state of the flat run, retaining the entire source memory and frontier and every result coordinate. All witnesses precede runtime data.

theorem Cslib.WordRAM.Realization.Realizes.exists_standard_init_program {k l : ℕ} {δ α : Type} {p : δ → DataStructure.Memory.Prog α} {input : δ ↪ Fin k → ℕ} {output : α ↪ Fin l → ℕ} {safe : ℕ → δ → DataStructure.Memory.State → Prop} {work : δ → DataStructure.Memory.State → ℕ} (h : Realizes Basis.exact p input output safe work) (raw : δ → List ℕ) (hlayout : ∀ (d : δ) (i : Fin k), (raw d).getD (↑i) 0 = input d i) (i : Fin l) :
∃ (r : ℕ) (C : ℕ) (prog : Program Basis.exact r), ∀ (w : ℕ) (d : δ), k ≤ (raw d).length → Fits w ((raw d).length + 1) → InputFits w (raw d) → safe w d (DataStructure.Memory.State.init (raw d)) → (DataStructure.Memory.spec w).ValidHistory (DataStructure.Memory.State.init (raw d)) ((DataStructure.Memory.spec w).clientHistory (DataStructure.Memory.State.init (raw d)) (p d)) → ∃ (t : ℕ), Executes w prog (State.init (raw d)) (output ((DataStructure.Memory.spec w).clientResult (DataStructure.Memory.State.init (raw d)) (p d)) i) t ∧ t ≤ C * (memoryCost (p d) (DataStructure.Memory.State.init (raw d)) + work d (DataStructure.Memory.State.init (raw d)) + 1) + 1

The canonical initialized export requires no caller-written register layout. Its bound includes the actual prefix, body and final halt, with code fixed before every width and input.

theorem Cslib.WordRAM.Realization.Realizes.exists_standard_basis_init_program_state_from_words {k l : ℕ} {δ α : Type} {p : δ → DataStructure.Memory.Prog α} {input : δ ↪ Fin k → ℕ} {output : α ↪ Fin l → ℕ} {safe : ℕ → δ → DataStructure.Memory.State → Prop} {work : δ → DataStructure.Memory.State → ℕ} (h : Realizes Basis.exact p input output safe work) (i : Fin l) :
∃ (r : ℕ) (C : ℕ) (pc : ℕ) (prog : Program Basis.standard r), ¬prog.ReadsWidth ∧ ∃ (frontier : Fin r) (out : Fin l → Fin r), ∀ (w : ℕ) (d : δ) (words : List ℕ), (∀ (j : Fin k), words.getD (↑j) 0 = input d j) → k ≤ words.length → Fits w (words.length + 1) → InputFits w words → safe w d (DataStructure.Memory.State.init words) → (DataStructure.Memory.spec w).ValidHistory (DataStructure.Memory.State.init words) ((DataStructure.Memory.spec w).clientHistory (DataStructure.Memory.State.init words) (p d)) → ∃ (y : Data r) (n : ℕ), Runs w prog (State.init words) { pc := pc, data := y } n ∧ step w prog { pc := pc, data := y } = Outcome.halt (output ((DataStructure.Memory.spec w).clientResult (DataStructure.Memory.State.init words) (p d)) i) ∧ memoryState frontier y = (DataStructure.Memory.spec w).clientState (DataStructure.Memory.State.init words) (p d) ∧ (∀ (j : Fin l), y.regs (out j) = output ((DataStructure.Memory.spec w).clientResult (DataStructure.Memory.State.init words) (p d)) j) ∧ n + 1 ≤ C * (memoryCost (p d) (DataStructure.Memory.State.init words) + work d (DataStructure.Memory.State.init words) + 1) + 1

Standard-basis width-blind analogue of exists_standard_init_program_state_from_words: translates the realized Basis.exact structured code along Basis.Simulates.exactStandard into a Program .standard r satisfying ¬prog.ReadsWidth, preserving exact memory, frontier, result coordinates, and step bounds on every admitted run.