Exact laws of structured randomized word-RAM programs #
Cslib.WordRAM.ExecRandLaw w c x P T R f μ strengthens Cslib.WordRAM.ExecRandWithin w c x P T R
by the exact distribution μ of an observation f : Data r → α of the final data. Its rules
compose like those of ExecRandWithin. Along a sequence or a loop iteration, the observation of
the first part only has to determine the law of the rest, so the laws compose by PMF.bind
(Cslib.WordRAM.ExecRandLaw.seq, Cslib.WordRAM.ExecRandLaw.loop_iter). This lets a proof match
a program against a mathematical randomized process step by step, observing only the part of the
memory that the process describes.
A compiled program then halts on every path within the time bound, makes at most the given number
of rand calls, and has law μ for every observation of its halting configurations that agrees
with f (Cslib.WordRAM.ExecRandLaw.program).
Main definitions #
Cslib.WordRAM.ExecRandLaw: pathwise postcondition, worst-case instruction andrand-call budgets, and the exact law of an observation of the final data.
Main results #
Cslib.WordRAM.ExecRandLaw.of_execWithin,Cslib.WordRAM.ExecRandLaw.rand: deterministic code and a singlerandinstruction.Cslib.WordRAM.ExecRandLaw.seq_det,Cslib.WordRAM.ExecRandLaw.seq_det_right,Cslib.WordRAM.ExecRandLaw.rand_seq: deterministic prefixes and suffixes, and a draw followed by deterministic code.Cslib.WordRAM.ExecRandLaw.seq,Cslib.WordRAM.ExecRandLaw.branch_pos,Cslib.WordRAM.ExecRandLaw.branch_neg,Cslib.WordRAM.ExecRandLaw.loop_exit,Cslib.WordRAM.ExecRandLaw.loop_iter: composition rules.Cslib.WordRAM.ExecRandLaw.rename: renaming registers.Cslib.WordRAM.ExecRandLaw.execRandWithin: forgetting the law.Cslib.WordRAM.ExecRandLaw.map,Cslib.WordRAM.ExecRandLaw.withBounded,Cslib.WordRAM.ExecRandLaw.withSupport: mapping the observation, and the boundedness and the support of every final observation.Cslib.WordRAM.ExecRandLaw.program: the compiled program halts within the bound, respects the call budget and the postcondition, and has the lawμ.
ExecRandLaw w c x P T R f μ: at word size w, running c from x terminates cleanly on
every path, makes at most R rand calls on every path, every supported outcome (y, n)
satisfies P y and n ≤ T, and the observation f y of the final data has law μ.
Instances For
Forgetting the law leaves an ExecRandWithin specification.
Weakening the postcondition and the budgets.
Post-composing the observation with g maps the law by g.
Strengthening the postcondition with word-boundedness, from bounded initial data.
Strengthening the postcondition: every final observation lies in the support of the law.
Strengthening the postcondition with a register that c never writes.
Renaming along an injective register map ρ: the renamed code observes the registers that ρ
chooses and keeps the others.
Deterministic code reaching y has the point law at the observation of y.
Code.rand dst src draws k uniformly from [0, x.regs src] and observes x.set dst k.
Sequencing. If the observation g after c₁ determines the law κ (g y) of the
observation f after c₂, the laws compose by PMF.bind.
A deterministic prefix leading to y does not change the law of what follows.
A deterministic suffix that keeps the observation does not change the law.
A rand instruction followed by deterministic code: drawing k uniformly from
[0, x.regs src] leads to y k.
Taking the positive branch adds one instruction and keeps the law.
Taking the negative branch adds two instructions and keeps the law.
Exiting a loop takes two instructions and observes the current data.
One loop iteration. The body's observation g determines the law of the rest of the
loop, and the laws compose by PMF.bind.
Compiled programs. Compiling c with Code.program out halts on every path within any
fuel T' ≥ T + 1, makes at most R rand calls, satisfies the postcondition on the halting
data, and every observation F of halting configurations that agrees with f has law μ.