Documentation

CslibFrontier.Computability.WordRAM.SymbolicExec.CanonicalCall

Canonical continuations of renamed calls #

WP.of_spec_rename and WP.Exact.of_spec_rename pass the small returned state to a continuation whose caller state is explicitly Data.extend. The wram_call … canonical … with … form handles both WP (bounded-time ExecWithin) and WP.Exact (exact-count Exec) goals, accepts direct ExecWithin/Exec lemmas (wram_call h canonical), automatically peels leading .seq, and infers f.Injective when omitted (wram_call h canonical with …). The word canonical is not reserved: importers may still use it as an identifier.

Outside-bank reads use the original caller; inside-bank reads need the callee's actual output or preservation facts. Memory is the callee's returned memory, with no implied memory frame.

Data.reduceExtendRegs normalizes one read at a time for both symbolic banks (checking the local context for Function.Injective f, j ∉ Set.range f, ∀ k, f k ≠ j, Fin.castAdd, Fin.castLE, Fin.natAdd, and linear Fin.mk definitions in O(1)) and closed finite banks. It never unfolds the noncomputable Function.extend or expands an entire register function.

Main results #

theorem Cslib.WordRAM.WP.of_spec_rename {B : Basis} {r s w T : ℕ} {f : Fin r → Fin s} (hf : Function.Injective f) {c : Code B r} {x : Data s} {P : Data r → Prop} {Q : Data s → ℕ → Prop} (h : ∃ (y : Data r), ExecWithin w c (Data.comap f x) y T ∧ P y) (hQ : ∀ (y : Data r), P y → Q (Data.extend f y x) T) :
WP w (Code.rename f c) x Q

Continue a renamed fixed-time routine at its canonical caller state, with exact allowance.

theorem Cslib.WordRAM.WP.of_spec_rename' {B : Basis} {r s w T : ℕ} {f : Fin r → Fin s} (hf : Function.Injective f) {c : Code B r} {x : Data s} {P : Data r → Prop} {Q : Data s → ℕ → Prop} (h : ∃ (y : Data r), ExecWithin w c (Data.comap f x) y T ∧ P y) (hQ : ∀ (y : Data r), ExecWithin w c (Data.comap f x) y T → P y → Q (Data.extend f y x) T) :
WP w (Code.rename f c) x Q

Witness-preserving variant of WP.of_spec_rename, retaining ExecWithin w c (x.comap f) y T so regs_frame can follow hy.regs_eq across the small callee state y.

theorem Cslib.WordRAM.WP.of_execWithin_rename {B : Basis} {r s w T : ℕ} {f : Fin r → Fin s} (hf : Function.Injective f) {c : Code B r} {x : Data s} {y : Data r} {Q : Data s → ℕ → Prop} (h : ExecWithin w c (Data.comap f x) y T) (hQ : ExecWithin w c (Data.comap f x) y T → Q (Data.extend f y x) T) :
WP w (Code.rename f c) x Q

Continue a renamed direct ExecWithin routine at its canonical caller state y.extend f x.

theorem Cslib.WordRAM.WP.of_execWithin_rename_eq {B : Basis} {r s w T : ℕ} {f : Fin r → Fin s} (hf : Function.Injective f) {c : Code B r} {x : Data s} {y : Data r} {Q : Data s → ℕ → Prop} (h : ExecWithin w c (Data.comap f x) y T) (hQ : ∀ (y' : Data r), ExecWithin w c (Data.comap f x) y' T → y' = y → Q (Data.extend f y' x) T) :
WP w (Code.rename f c) x Q

Continue a renamed direct ExecWithin routine with y' = y binding its small state.

theorem Cslib.WordRAM.WP.Exact.of_spec_rename {B : Basis} {r s w T : ℕ} {f : Fin r → Fin s} (hf : Function.Injective f) {c : Code B r} {x : Data s} {P : Data r → Prop} {Q : Data s → ℕ → Prop} (h : ∃ (y : Data r), Exec w c (Data.comap f x) y T ∧ P y) (hQ : ∀ (y : Data r), P y → Q (Data.extend f y x) T) :
Exact w (Code.rename f c) x Q

Continue a renamed fixed-time routine at its canonical caller state with exact instruction count.

theorem Cslib.WordRAM.WP.Exact.of_spec_rename' {B : Basis} {r s w T : ℕ} {f : Fin r → Fin s} (hf : Function.Injective f) {c : Code B r} {x : Data s} {P : Data r → Prop} {Q : Data s → ℕ → Prop} (h : ∃ (y : Data r), Exec w c (Data.comap f x) y T ∧ P y) (hQ : ∀ (y : Data r), Exec w c (Data.comap f x) y T → P y → Q (Data.extend f y x) T) :
Exact w (Code.rename f c) x Q

Witness-preserving variant of WP.Exact.of_spec_rename, retaining Exec w c (x.comap f) y T so regs_frame can follow hy.regs_eq across the small callee state y.

theorem Cslib.WordRAM.WP.Exact.of_exec_rename {B : Basis} {r s w T : ℕ} {f : Fin r → Fin s} (hf : Function.Injective f) {c : Code B r} {x : Data s} {y : Data r} {Q : Data s → ℕ → Prop} (h : Exec w c (Data.comap f x) y T) (hQ : Exec w c (Data.comap f x) y T → Q (Data.extend f y x) T) :
Exact w (Code.rename f c) x Q

Continue a renamed direct Exec routine at its canonical caller state y.extend f x.

theorem Cslib.WordRAM.WP.Exact.of_exec_rename_eq {B : Basis} {r s w T : ℕ} {f : Fin r → Fin s} (hf : Function.Injective f) {c : Code B r} {x : Data s} {y : Data r} {Q : Data s → ℕ → Prop} (h : Exec w c (Data.comap f x) y T) (hQ : ∀ (y' : Data r), Exec w c (Data.comap f x) y' T → y' = y → Q (Data.extend f y' x) T) :
Exact w (Code.rename f c) x Q

Continue a renamed direct Exec routine with y' = y binding its small state.

Normalize only the selected read of a Data.extend register bank. Checks local Injective hypotheses, symbolic Fin.castAdd / Fin.castLE / Fin.natAdd maps, and linear Fin.mk bank maps before falling back to closed finite-bank decide.

Apply a fixed-time, direct, or time-indexed routine contract and expose its continuation. Only bank-view projections are normalized; the callee program remains closed.

Extensions:

  • Direct wram_call h without with (for bare ExecWithin / Exec contracts), optional hint lemmas [h₁, …], and renamed bank forms.

  • Apply a renamed routine contract with its small returned state and canonical caller view small.extend bank caller. Supports both WP and WP.Exact.

Apply a fixed-time, direct, or time-indexed routine contract and expose its continuation. Only bank-view projections are normalized; the callee program remains closed.

Extensions:

  • Direct wram_call h without with (for bare ExecWithin / Exec contracts), optional hint lemmas [h₁, …], and renamed bank forms.

  • Apply a renamed routine contract with its small returned state and canonical caller view small.extend bank caller. Supports both WP and WP.Exact.

Apply a fixed-time, direct, or time-indexed routine contract and expose its continuation. Only bank-view projections are normalized; the callee program remains closed.

Extensions:

  • Direct wram_call h without with (for bare ExecWithin / Exec contracts), optional hint lemmas [h₁, …], and renamed bank forms.

  • Apply a renamed routine contract with its small returned state and canonical caller view small.extend bank caller. Supports both WP and WP.Exact.

Apply a fixed-time, direct, or time-indexed routine contract and expose its continuation. Only bank-view projections are normalized; the callee program remains closed.

Extensions:

  • Direct wram_call h without with (for bare ExecWithin / Exec contracts), optional hint lemmas [h₁, …], and renamed bank forms.

  • Apply a renamed routine contract with its small returned state and canonical caller view small.extend bank caller. Supports both WP and WP.Exact.