Documentation

CslibFrontier.Computability.WordRAM.SymbolicExec.Call

Continuing symbolic execution through routine contracts #

The tactic wram_call consumes a routine specification at the current WP or WP.Exact goal. Its continuation receives the returned state and complete postcondition, with the routine's instruction allowance already added by WP.seq. Resume straight-line execution with wram_exec. The routine's definition stays closed: correctness, safety conditions and its charge come from the contract, not from symbolic execution of its body.

Accepted contract shapes:

wram_call uses witness-preserving rules (WP.of_spec', WP.Exact.of_spec', WP.mono', WP.Exact.mono'), keeping a local ExecWithin / Exec witness in the continuation context so regs_frame and mem_frame can automatically follow he.regs_eq and he.mem_eq across the call.

If the goal starts with a Code.seq, wram_call first checks whether the contract applies to the whole sequence and otherwise automatically peels .seq via WP.seq / WP.Exact.seq.

If the contract term is a universally quantified specification (such as an induction hypothesis or bare theorem name), wram_call instantiates its telescope against the goal and automatically discharges its side premises (regs_frame, wram_simp, fits, omega, silent wram_omega, decide, local assumption, and memory-equality transport along d.mem = x.mem). Any remaining nontrivial premises are left as tagged subgoals after the continuation. Optional [h₁, h₂, …] hints supply extra facts or simp lemmas to the discharger.

The renamed form applies ExecWithin.rename_post / Exec.rename_post and retains the caller's outside-register frame. Its injectivity proof hf : f.Injective may be omitted when f is provably injective from the local context, standard Fin embeddings, Fin.val arithmetic, or decide. The word renamed is not reserved: importers may still use it as an identifier.

Main results #

theorem Cslib.WordRAM.WP.of_spec {B : Basis} {r w T : ℕ} {c : Code B r} {x : Data r} {P : Data r → Prop} {Q : Data r → ℕ → Prop} (h : ∃ (y : Data r), ExecWithin w c x y T ∧ P y) (hQ : ∀ (y : Data r), P y → Q y T) :
WP w c x Q

Continue from a routine's complete postcondition at its given instruction allowance.

theorem Cslib.WordRAM.WP.of_spec' {B : Basis} {r w T : ℕ} {c : Code B r} {x : Data r} {P : Data r → Prop} {Q : Data r → ℕ → Prop} (h : ∃ (y : Data r), ExecWithin w c x y T ∧ P y) (hQ : ∀ (y : Data r), ExecWithin w c x y T → P y → Q y T) :
WP w c x Q

Continue from a routine's complete postcondition while retaining its ExecWithin witness in context so regs_frame and mem_frame can use hy.regs_eq and hy.mem_eq.

theorem Cslib.WordRAM.WP.mono' {B : Basis} {r w : ℕ} {c : Code B r} {x : Data r} {Q Q' : Data r → ℕ → Prop} (h : WP w c x Q) (hQ : ∀ (y : Data r) (T : ℕ), ExecWithin w c x y T → Q y T → Q' y T) :
WP w c x Q'

Weaken a WP postcondition while retaining its ExecWithin witness in context.

theorem Cslib.WordRAM.WP.of_execWithin_eq {B : Basis} {r w T : ℕ} {c : Code B r} {x y : Data r} {Q : Data r → ℕ → Prop} (h : ExecWithin w c x y T) (hQ : ∀ (y' : Data r), ExecWithin w c x y' T → y' = y → Q y' T) :
WP w c x Q

Continue from a direct ExecWithin contract while retaining y' = y and the witness.

theorem Cslib.WordRAM.WP.of_execWithin_and {B : Basis} {r w T : ℕ} {c : Code B r} {x y : Data r} {P : Prop} {Q : Data r → ℕ → Prop} (h : ExecWithin w c x y T ∧ P) (hQ : ExecWithin w c x y T → P → Q y T) :
WP w c x Q

Continue from a direct ExecWithin w c x y T ∧ P pair while retaining the witness.

theorem Cslib.WordRAM.WP.Exact.of_spec {B : Basis} {r w T : ℕ} {c : Code B r} {x : Data r} {P : Data r → Prop} {Q : Data r → ℕ → Prop} (h : ∃ (y : Data r), Exec w c x y T ∧ P y) (hQ : ∀ (y : Data r), P y → Q y T) :
Exact w c x Q

Continue from a routine's complete postcondition at its exact instruction count.

theorem Cslib.WordRAM.WP.Exact.of_spec' {B : Basis} {r w T : ℕ} {c : Code B r} {x : Data r} {P : Data r → Prop} {Q : Data r → ℕ → Prop} (h : ∃ (y : Data r), Exec w c x y T ∧ P y) (hQ : ∀ (y : Data r), Exec w c x y T → P y → Q y T) :
Exact w c x Q

Continue from a routine's complete postcondition at its exact instruction count, retaining its Exec witness so regs_frame and mem_frame can use hy.regs_eq and hy.mem_eq.

theorem Cslib.WordRAM.WP.Exact.mono' {B : Basis} {r w : ℕ} {c : Code B r} {x : Data r} {Q Q' : Data r → ℕ → Prop} (h : Exact w c x Q) (hQ : ∀ (y : Data r) (T : ℕ), Exec w c x y T → Q y T → Q' y T) :
Exact w c x Q'

Weaken a WP.Exact postcondition while retaining its Exec witness in context.

theorem Cslib.WordRAM.WP.Exact.of_exec_eq {B : Basis} {r w T : ℕ} {c : Code B r} {x y : Data r} {Q : Data r → ℕ → Prop} (h : Exec w c x y T) (hQ : ∀ (y' : Data r), Exec w c x y' T → y' = y → Q y' T) :
Exact w c x Q

Continue from a direct Exec contract while retaining y' = y and the witness.

theorem Cslib.WordRAM.WP.Exact.of_exec_and {B : Basis} {r w T : ℕ} {c : Code B r} {x y : Data r} {P : Prop} {Q : Data r → ℕ → Prop} (h : Exec w c x y T ∧ P) (hQ : Exec w c x y T → P → Q y T) :
Exact w c x Q

Continue from a direct Exec w c x y T ∧ P pair while retaining the witness.

theorem Cslib.WordRAM.ExecWithin.rename_post_of_exec {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} (h : ExecWithin w c (Data.comap f x) y t) :
∃ (z : Data s), ExecWithin w (Code.rename f c) x z t ∧ Data.comap f z = y ∧ ∀ (i : Fin s), (∀ (j : Fin r), f j ≠ i) → z.regs i = x.regs i

Renamed existential view of a direct ExecWithin execution.

theorem Cslib.WordRAM.Exec.rename_post_of_exec {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} (h : Exec w c (Data.comap f x) y t) :
∃ (z : Data s), Exec w (Code.rename f c) x z t ∧ Data.comap f z = y ∧ ∀ (i : Fin s), (∀ (j : Fin r), f j ≠ i) → z.regs i = x.regs i

Renamed existential view of a direct Exec execution.

theorem Cslib.WordRAM.WP.of_execWithin_wit {B : Basis} {r w T : ℕ} {c : Code B r} {x y : Data r} {Q : Data r → ℕ → Prop} (h : ExecWithin w c x y T) (hQ : ExecWithin w c x y T → Q y T) :
WP w c x Q

WP.of_execWithin keeping h in context as an ExecWithin witness.

theorem Cslib.WordRAM.WP.Exact.of_exec_wit {B : Basis} {r w T : ℕ} {c : Code B r} {x y : Data r} {Q : Data r → ℕ → Prop} (h : Exec w c x y T) (hQ : Exec w c x y T → Q y T) :
Exact w c x Q

WP.Exact.of_exec keeping h in context as an Exec witness.

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.

Refine the goal with the first of tacs that succeeds and run cont; if none succeeds, explain the failure with rules (see explain).

Introduce pats across a continuation where the witness ExecWithin/Exec sits after the initial witAfter binders (y for of_spec', y T for mono', 0 for of_execWithin_wit). The witness is introduced with an inaccessible name so it never shadows user variables while staying visible to regs_frame and mem_frame.

Run attempt against the current goal, peeling leading Code.seq layers via WP.seq / WP.Exact.seq only if the direct call fails. Restores the state on failure.

Discharge all resolvable Prop metavariables in mvars:

  1. Fixpoint pass binding value metavariables via register equations and direct hypotheses/hints (caching failed target expressions so unchanged premises are not re-tested).
  2. Single ground pass running arithmetic, fits, and simp dischargers once per remaining ground Prop premise.

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 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 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 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.