Absorbed loop rules and realize tactic extension for RealizesBounded #
Absorbed iterate₀ and while₀ rules for Cslib.WordRAM.Realization.RealizesBounded, together
with an elab_rules extension instantiating Cslib.Tactic.Realize.elabRealize directly on
RealizesBounded combinators without post-hoc proof translation.
Main results #
Cslib.WordRAM.Realization.RealizesBounded.iterate₀,Cslib.WordRAM.Realization.RealizesBounded.while₀: absorbed frontier-bounded iteration andboundedWhilecertificates when each step issues at least one memory query.
theorem Cslib.WordRAM.Realization.RealizesBounded.iterate₀ {δ : Type} {k l : ℕ} {σ : Type} (input : δ ↪ Fin k → ℕ) (output : σ ↪ Fin l → ℕ) {body : δ × σ → DataStructure.Memory.Prog σ} {safe : ℕ → δ × σ → DataStructure.Memory.State → Prop} (h :
RealizesBounded Basis.exact body ((input.prodMap output).trans (Fin.appendEquiv k l).toEmbedding) output safe
fun (x : δ × σ) (x_1 : DataStructure.Memory.State) => 0) (hquery : ∀ (x : δ × σ) (s : DataStructure.Memory.State), 1 ≤ memoryCost (body x) s) :
RealizesBounded Basis.exact
(fun (x : (δ × σ) × ℕ) =>
match x with
| ((d, a), fuel) => iterate body d fuel a)
((((input.prodMap output).trans (Fin.appendEquiv k l).toEmbedding).prodMap
(Equiv.funUnique (Fin 1) ℕ).symm.toEmbedding).trans
(Fin.appendEquiv (k + l) 1).toEmbedding)
output
(fun (w : ℕ) (x : (δ × σ) × ℕ) (s : DataStructure.Memory.State) =>
match x with
| ((d, a), fuel) => iterationSafe body safe w d fuel a s)
fun (x : (δ × σ) × ℕ) (x_1 : DataStructure.Memory.State) => 0
Absorbed frontier-bounded iterate₀ rule when every body issues at least one memory query.
theorem Cslib.WordRAM.Realization.RealizesBounded.while₀ {δ σ : Type} {B : Basis} {k l : ℕ} (input : δ ↪ Fin k → ℕ) (output : σ ↪ Fin l → ℕ) (cond : Cond (k + l)) (cutoff : δ × σ → ℕ) {body : δ × σ → DataStructure.Memory.Prog σ} {safe : ℕ → δ × σ → DataStructure.Memory.State → Prop} (h :
RealizesBounded B body (appendWords input output) output safe fun (x : δ × σ) (x_1 : DataStructure.Memory.State) => 0) (hquery : ∀ (x : δ × σ) (s : DataStructure.Memory.State), 1 ≤ memoryCost (body x) s) :
RealizesBounded B
(fun (x : δ × σ) =>
match x with
| (d, a) =>
boundedWhile (fun (d : δ) (a : σ) => test cond ((appendWords input output) (d, a))) body d (cutoff (d, a)) a)
(appendWords input output) output
(fun (w : ℕ) (x : δ × σ) (s : DataStructure.Memory.State) =>
match x with
| (d, a) =>
whileSafe (fun (d : δ) (a : σ) => test cond ((appendWords input output) (d, a))) body safe w d (cutoff (d, a)) a
s)
fun (x : δ × σ) (x_1 : DataStructure.Memory.State) => 0
Absorbed frontier-bounded while₀ rule when every body issues at least one memory query.