Symbolic execution of structured randomized word-RAM code #
Weakest-precondition wrappers and symbolic-execution tactics extending Cslib.WordRAM.WP
(wram_exec) to structured randomized execution:
Cslib.WordRAM.WP.Rand w c x Q: weakest-precondition form ofExecRand w c x m(∃ m, ExecRand w c x m ∧ Q m).Cslib.WordRAM.WP.RandWithin w c x P Q: weakest-precondition form ofExecRandWithin w c x P T Rwith residual step andrand-query budgets (∃ t q, ExecRandWithin w c x P t q ∧ Q t q).Cslib.WordRAM.WP.Dist w c x Q: weakest-precondition form ofExecCodeDist w c x μ T(∃ μ T, ExecCodeDist w c x μ T ∧ Q μ T).
The tactic wram_rand_exec steps straight-line deterministic instructions (Code.op),
conditionals (Code.branch, or stops with -split), and uniform draws (Code.rand, both at a
leaf and at the head of Code.seq), reassociating left-nested Code.seq automatically and
reusing the register/memory simprocs and fits discharger of wram_exec.
The tactic wram_rand_call consumes a proved deterministic (Exec, ExecWithin) or randomized
(ExecRand, ExecRandWithin, ExecCodeDist) contract at the head of a WP.Rand,
WP.RandWithin, or WP.Dist goal (including across Code.rename f via renamed hf), exposing a
WP continuation whose residual ProbComp or PMF family unifies by higher-order pattern
matching without manual m₂ or μ₂ annotations.
Main definitions #
Cslib.WordRAM.WP.Rand: weakest-precondition wrapper forExecRand.Cslib.WordRAM.WP.RandWithin: weakest-precondition wrapper forExecRandWithin.Cslib.WordRAM.WP.Dist: weakest-precondition wrapper forExecCodeDist.wram_rand_exec: straight-line andrandsymbolic execution for randomized structured code.wram_rand_call: consume a deterministic or randomized routine specification at aWP.Rand,WP.RandWithin, orWP.Diststop.
Main results #
Cslib.WordRAM.ExecRand.seq_det: compose anExecRandprefix with a family of deterministicExeccontinuations.Cslib.WordRAM.ExecCodeDist.of_execRand_le: lift a pathwise step-boundedExecRandintoExecCodeDist.Cslib.WordRAM.WP.Rand.execRand,Cslib.WordRAM.WP.RandWithin.execRandWithin,Cslib.WordRAM.WP.Dist.execCodeDist: extract structured randomized execution certificates from their weakest preconditions, together with theseq_*,rand, andbranch_*rules applied bywram_rand_execandwram_rand_call.
Shared structural lemmas for ExecRand, ExecRandWithin, and ExecCodeDist #
Post-compose a deterministic continuation Exec w c₂ y (f y) (n₂ y) onto an exact randomized
execution ExecRand w c₁ x m₁.
Continue from a renamed ExecRand execution at a leaf c.rename f.
Execute a deterministic prefix c₁ via WP.Exact, shifting the step count of c₂.
Consume a proved deterministic Exec contract at the head of .seq c₁ c₂.
Consume an existential deterministic Exec contract at the head of .seq c₁ c₂.
Consume an explicit ExecRand contract at the head of .seq c₁ c₂, exposing (y, n) in
m₁.support so m₂ unifies by higher-order pattern matching.
Consume a renamed deterministic Exec execution at the head of .seq (c₁.rename f) c₂.
Consume a renamed ExecRand execution at the head of .seq (c₁.rename f) c₂, indexing m₂
directly by the inner state y : Data r so m₂ unifies without comap/extend inversions.
A leaf Code.rand dst src instruction with the bound register named in closed form.
A Code.rand dst src instruction followed by a WP.Rand continuation c₂.
A Code.rand dst src instruction followed by a deterministic Exec continuation c₂.
A conditional on cond.Holds x, by cases.
A conditional on x.regs i < x.regs j, with the compared values in closed form.
A conditional on x.regs i = x.regs j, with the compared values in closed form.
WP.RandWithin: weakest preconditions for ExecRandWithin #
WP.RandWithin w c x P Q: at word size w, the structured randomized program c terminates
cleanly from x achieving postcondition P within some step bound t and rand-call bound q
satisfying Q t q.
Extract ExecRandWithin w c x P T R.
Continue from an explicit ExecRandWithin certificate.
Lift a deterministic ExecWithin specification into WP.RandWithin.
Continue from an explicit ExecRandWithin contract renamed via an injective register map.
Execute a deterministic prefix c₁ via WP, adding its step count to the continuation.
Consume a deterministic ExecWithin at the head of .seq c₁ c₂.
Consume an existential deterministic ExecWithin contract at the head of .seq c₁ c₂.
Consume a deterministic Exec contract at the head of .seq c₁ c₂.
Consume a randomized ExecRandWithin contract at the head of .seq c₁ c₂.
A leaf Code.rand dst src instruction.
A Code.rand dst src instruction followed by a WP.RandWithin continuation.
Conditional on cond.Holds x.
Conditional on x.regs i < x.regs j.
Conditional on x.regs i = x.regs j.
WP.Dist w c x Q: at word size w, the structured randomized program c executes cleanly
from x with exit distribution μ : PMF (Data r) and expected instruction bound T : ℝ≥0∞
satisfying Q μ T.
Continue from an ExecRand execution with pathwise step bound ≤ n.
Execute a deterministic prefix c₁ via WP, adding its step count to the continuation.
Consume a deterministic ExecWithin at the head of .seq c₁ c₂.
Consume an existential deterministic ExecWithin contract at the head of .seq c₁ c₂.
Consume a deterministic Exec contract at the head of .seq c₁ c₂.
Consume an ExecCodeDist at the head of .seq c₁ c₂ with a uniform continuation step bound
B₂, leaving a WP.Dist continuation so μ₂ unifies by higher-order pattern matching.
Conditional on cond.Holds x.
Conditional on x.regs i < x.regs j.
Conditional on x.regs i = x.regs j.
Randomized symbolic execution tactic (wram_rand_exec) #
wram_rand_exec symbolically executes the straight-line, branching, and rand parts of a
structured randomized word-RAM program on an ExecRand, WP.Rand, ExecRandWithin,
WP.RandWithin, ExecCodeDist, or WP.Dist goal.
It reassociates left-nested Code.seq, collapses deterministic .op steps using wram_exec's
simplifier and discharger, steps Code.branch (or splits unless -split is passed), and steps
Code.rand dst src (both as a leaf and as .seq (.rand dst src) c₂, introducing k when c₂
contains calls or loops). Stops cleanly at loops and unexpanded subroutines, leaving a WP.Rand,
WP.RandWithin, or WP.Dist goal ready for wram_rand_call. Unlike wram_exec, it does not open
a program named among the hints: unfold the program first.
wram_rand_call h applies a proved deterministic (Exec / ExecWithin) or randomized
(ExecRand / ExecRandWithin / ExecCodeDist) contract h at the head of a WP.Rand,
WP.RandWithin, or WP.Dist goal (either a leaf call c or a sequenced call .seq c₁ c₂),
and exposes the continuation. Pass renamed hf to lift a contract across Code.rename f via
hf : f.Injective.
wram_rand_call h applies a proved deterministic (Exec / ExecWithin) or randomized
(ExecRand / ExecRandWithin / ExecCodeDist) contract h at the head of a WP.Rand,
WP.RandWithin, or WP.Dist goal (either a leaf call c or a sequenced call .seq c₁ c₂),
and exposes the continuation. Pass renamed hf to lift a contract across Code.rename f via
hf : f.Injective.
wram_rand_call h applies a proved deterministic (Exec / ExecWithin) or randomized
(ExecRand / ExecRandWithin / ExecCodeDist) contract h at the head of a WP.Rand,
WP.RandWithin, or WP.Dist goal (either a leaf call c or a sequenced call .seq c₁ c₂),
and exposes the continuation. Pass renamed hf to lift a contract across Code.rename f via
hf : f.Injective.
wram_rand_call h applies a proved deterministic (Exec / ExecWithin) or randomized
(ExecRand / ExecRandWithin / ExecCodeDist) contract h at the head of a WP.Rand,
WP.RandWithin, or WP.Dist goal (either a leaf call c or a sequenced call .seq c₁ c₂),
and exposes the continuation. Pass renamed hf to lift a contract across Code.rename f via
hf : f.Injective.