Documentation

CslibFrontier.Computability.WordRAM.Width

Width-independent native program prefixes #

An execution that halts at one width identifies every successful prefix at a larger width when the program does not read physical width. These rules apply to both complete native frontends and programs that compose them.

Main results #

These determinism and representation lemmas are original.

theorem Cslib.WordRAM.Code.readsWidth_rename {B : Basis} {r r' : ℕ} (f : Fin r → Fin r') (c : Code B r) :

Register renaming never changes whether a structured program observes physical width.

theorem Cslib.WordRAM.Runs.prefix_at_smaller_width {B : Basis} {w w' r : ℕ} {p : Program B r} (hp : ¬p.ReadsWidth) (hw : w ≤ w') {s t : State r} {k v total : ℕ} (hwide : Runs w' p s t k) (hlow : Executes w p s v total) :
Runs w p s t k

Every wider prefix is the same smaller-width prefix if that smaller execution halts.

theorem Cslib.WordRAM.Op.eval_mem_above {B : Basis} {r w a : ℕ} {o : Op B r} {x y : Data r} (h : eval w o x = some y) (hx : Data.Bounded w x) (ha : 2 ^ w ≤ a) :
y.mem a = x.mem a

A native instruction cannot write memory above the admitted address-word universe.

theorem Cslib.WordRAM.Next.mem_above {B : Basis} {r w a : ℕ} {p : Program B r} {s t : State r} (h : Next w p s t) (hs : Data.Bounded w s.data) (ha : 2 ^ w ≤ a) :
t.data.mem a = s.data.mem a

A complete native step preserves memory beyond the admitted address-word universe.

theorem Cslib.WordRAM.Runs.mem_above {B : Basis} {r w a : ℕ} {p : Program B r} {s t : State r} {n : ℕ} (h : Runs w p s t n) (hs : Data.Bounded w s.data) (ha : 2 ^ w ≤ a) :
t.data.mem a = s.data.mem a

A native run preserves every cell above its admitted address-word universe.

theorem Cslib.WordRAM.Runs.prefix_bounds {B : Basis} {r w W P v total k : ℕ} {p : Program B r} {s₀ s : State r} (hr : Runs W p s₀ s k) (hp : ¬p.ReadsWidth) (hw : w ≤ W) (hi : Data.Bounded w s₀.data) (he : Executes w p s₀ v total) (hP : 2 ^ w ≤ P) :
(∀ (i : Fin r), s.data.regs i < P) ∧ (∀ (a : ℕ), s.data.mem a < P) ∧ ∀ (a : ℕ), P ≤ a → s.data.mem a = s₀.data.mem a

A halt at an admitted width bounds every wider prefix and preserves original outside memory. The envelope bounds the address-word universe; no clearing or initial-zero hypothesis is used.

theorem Cslib.WordRAM.Runs.prefix_bounds_init {B : Basis} {r w W P v total k : ℕ} {p : Program B r} {input : List ℕ} {s : State r} (hr : Runs W p (State.init input) s k) (hp : ¬p.ReadsWidth) (hw : w ≤ W) (hi : InputFits w input) (he : Executes w p (State.init input) v total) (hP : 2 ^ w ≤ P) :
(∀ (i : Fin r), s.data.regs i < P) ∧ (∀ (a : ℕ), s.data.mem a < P) ∧ ∀ (a : ℕ), P ≤ a → s.data.mem a = 0

Initialized wider prefixes have bounded words and zero memory above the same envelope.