Documentation

CslibFrontier.Computability.WordRAM.Realization.Module

Local data-structure adapters for memory-client realizations #

The kernel represents the entire memory function. A finite-footprint data structure instead supplies its existing SubroutineBase, including initialization, register ABI and locality. Realizes.toStateTransitionImpl combines those boundary conditions with a semantic Module over the memory oracle. It derives the native method execution from the single realization certificate; callers do not supply another execution proof or intermediate assertions.

The adapter keeps the semantic method footprint and the resource inequality explicit. In particular, global whole-memory equality does not satisfy finite-block rep_supported. An upper ADT must prove its own local representation and initialization obligations.

Main definitions #

Retaining the operation index permits one faithful result encoding for dependent observations. This is an ordinary existing memory program, with no additional memory operation.

noncomputable def Cslib.WordRAM.Realization.Realizes.toStateTransitionImplWithArgs {δ : Type} {B : Basis} {w r k l kInit : ℕ} {D : DataStructure.StateTransitionSpec} (M : DataStructure.Module D (DataStructure.Memory.spec w)) {p : δ → DataStructure.Memory.Prog D.Label} {input : δ ↪ Fin k → ℕ} {output : D.Label ↪ Fin l → ℕ} {safe : ℕ → δ → DataStructure.Memory.State → Prop} {work : δ → DataStructure.Memory.State → ℕ} (h : Realizes B p input output safe work) (arguments : D.Op → δ) (source : ∀ (o : D.Op), p (arguments o) = taggedMethod M o) (frontier : Fin r) (src : Fin k → Fin r) (tmp : Fin (l + h.scratchSize + 1) → Fin r) (hi : Function.Injective tmp) (hd : ∀ (i : Fin k) (j : Fin (l + h.scratchSize + 1)), src i ≠ tmp j) (hf : ∀ (j : Fin (l + h.scratchSize + 1)), tmp j ≠ frontier) (hs : ∀ (i : Fin k), src i ≠ frontier) {P : SubroutineCode B r kInit} {base : ℕ} {params : Fin kInit → ℕ} {s₀ : D.State} (C : SubroutineBase P D.Result D.valid w base params s₀) (hcode : P.code = h.code frontier src tmp) (entry : ∀ {s : D.State} {x : Data r} (o : D.Op), C.rep s x → D.valid s o → C.argMatch o x.regs → x.regs ∘ src = input (arguments o) ∧ safe w (arguments o) (memoryState frontier x) ∧ M.rep s (memoryState frontier x)) (decode : ∀ (o : D.Op) (a : D.Result o) (regs : Fin r → ℕ), (∀ (i : Fin l), regs (tmp (Fin.castAdd (h.scratchSize + 1) i)) = output ⟨o, a⟩ i) → C.decode o regs = some a) (finish : ∀ {s s' : D.State} {x y : Data r} (o : D.Op) (a : D.Result o), C.rep s x → D.valid s o → C.argMatch o x.regs → D.step s o s' a → M.rep s' (memoryState frontier y) → Data.Bounded w y → (∀ (i : Fin r), i ≠ frontier → (∀ (j : Fin (l + h.scratchSize + 1)), tmp j ≠ i) → y.regs i = x.regs i) → C.rep s' y) (footprint : ∀ {s : D.State} {e : (DataStructure.Memory.spec w).State} (o : D.Op), M.rep s e → D.valid s o → Modifies { base := base, length := C.space }.footprint e.mem ((DataStructure.Memory.spec w).clientState e (M.methods o)).mem) (pay : ∀ {s s' : D.State} {x y : Data r} (o : D.Op) (a : D.Result o), C.rep s x → D.valid s o → C.argMatch o x.regs → D.step s o s' a → M.rep s' (memoryState frontier y) → memoryState frontier y = (DataStructure.Memory.spec w).clientState (memoryState frontier x) (M.methods o) → (∀ (i : Fin r), i ≠ frontier → (∀ (j : Fin (l + h.scratchSize + 1)), tmp j ≠ i) → y.regs i = x.regs i) → h.factor * (memoryCost (p (arguments o)) (memoryState frontier x) + work (arguments o) (memoryState frontier x) + 1) + C.potential y ≤ C.charge s o + C.potential x) :

Derive the existing finite-footprint Word-RAM implementation at the upper ADT boundary. The supplied base already proves initialization and representation locality. entry matches the actual register ABI; finish re-establishes that local representation from semantic module correctness and the kernel's register frame. footprint is a semantic memory property of the method, and pay is a pure inequality for the already certified combined instruction currency. The argument map instantiates an already selected global emitter; runtime layouts stay encoded data rather than choosing new code for each object. Neither obligation introduces an extra execution semantics or grants free native glue.

noncomputable def Cslib.WordRAM.Realization.Realizes.toStateTransitionImpl {B : Basis} {w r k l kInit : ℕ} {D : DataStructure.StateTransitionSpec} (M : DataStructure.Module D (DataStructure.Memory.spec w)) {input : D.Op ↪ Fin k → ℕ} {output : D.Label ↪ Fin l → ℕ} {safe : ℕ → D.Op → DataStructure.Memory.State → Prop} {work : D.Op → DataStructure.Memory.State → ℕ} (h : Realizes B (taggedMethod M) input output safe work) (frontier : Fin r) (src : Fin k → Fin r) (tmp : Fin (l + h.scratchSize + 1) → Fin r) (hi : Function.Injective tmp) (hd : ∀ (i : Fin k) (j : Fin (l + h.scratchSize + 1)), src i ≠ tmp j) (hf : ∀ (j : Fin (l + h.scratchSize + 1)), tmp j ≠ frontier) (hs : ∀ (i : Fin k), src i ≠ frontier) {P : SubroutineCode B r kInit} {base : ℕ} {params : Fin kInit → ℕ} {s₀ : D.State} (C : SubroutineBase P D.Result D.valid w base params s₀) (hcode : P.code = h.code frontier src tmp) (entry : ∀ {s : D.State} {x : Data r} (o : D.Op), C.rep s x → D.valid s o → C.argMatch o x.regs → x.regs ∘ src = input o ∧ safe w o (memoryState frontier x) ∧ M.rep s (memoryState frontier x)) (decode : ∀ (o : D.Op) (a : D.Result o) (regs : Fin r → ℕ), (∀ (i : Fin l), regs (tmp (Fin.castAdd (h.scratchSize + 1) i)) = output ⟨o, a⟩ i) → C.decode o regs = some a) (finish : ∀ {s s' : D.State} {x y : Data r} (o : D.Op) (a : D.Result o), C.rep s x → D.valid s o → C.argMatch o x.regs → D.step s o s' a → M.rep s' (memoryState frontier y) → Data.Bounded w y → (∀ (i : Fin r), i ≠ frontier → (∀ (j : Fin (l + h.scratchSize + 1)), tmp j ≠ i) → y.regs i = x.regs i) → C.rep s' y) (footprint : ∀ {s : D.State} {e : (DataStructure.Memory.spec w).State} (o : D.Op), M.rep s e → D.valid s o → Modifies { base := base, length := C.space }.footprint e.mem ((DataStructure.Memory.spec w).clientState e (M.methods o)).mem) (pay : ∀ {s s' : D.State} {x y : Data r} (o : D.Op) (a : D.Result o), C.rep s x → D.valid s o → C.argMatch o x.regs → D.step s o s' a → M.rep s' (memoryState frontier y) → memoryState frontier y = (DataStructure.Memory.spec w).clientState (memoryState frontier x) (M.methods o) → (∀ (i : Fin r), i ≠ frontier → (∀ (j : Fin (l + h.scratchSize + 1)), tmp j ≠ i) → y.regs i = x.regs i) → h.factor * (memoryCost (taggedMethod M o) (memoryState frontier x) + work o (memoryState frontier x) + 1) + C.potential y ≤ C.charge s o + C.potential x) :

Operation-indexed specialization of the global argument-map adapter.