Bounded adaptive probabilistic iteration #
OracleComp.iterate count step initial repeats a state-dependent program a bounded number of
times. Its invariant rule reasons only about supported transitions. A common finite seed
realizing each reachable step presents the complete loop as a deterministic fold over independent
uniform seeds. State types need not be finite. These are semantic laws; efficiency is separate.
Main definitions #
Cslib.OracleComp.iterate: bounded iteration of a state-dependent program.
Main results #
Cslib.OracleComp.iterate_map: a representation commuting with each step commutes with the loop.Cslib.OracleComp.run_interpret_iterate: stateful interpretation threads one shared hidden state through the loop.Cslib.OracleComp.interpret_iterate: replacing every call by a program iterates the replaced steps.Cslib.ProbComp.iterate_invariant: supported transitions preserve the final invariant.Cslib.ProbComp.iterate_failure_le,iterate_failure_toReal_le_mul: local failure bounds accumulate additively across adaptive rounds.Cslib.ProbComp.eval_iterate_of_uniform: exact evaluation from independent saved seeds.
References #
Adapted from Languages/Probabilistic/Iteration.lean on the cslib crypto branch at
5ff69ca93402e7c947208dc56396d6d86203ccd8, using the typed PFunctor.FreeM program interface.
Repeat a state-dependent program a bounded number of times.
Instances For
Zero iterations return the initial state.
count + 1 iterations run count iterations, then one more step.
A bounded loop may expose its first transition as well as its last.
Repeating a step that leaves the initial state unchanged has no effects.
A state representation commuting with one step commutes with the complete loop.
Replacing every call of a loop by a program over another interface iterates the replaced steps.
Interpreting a loop with a stateful handler is a loop on the joint program and handler state. The hidden state is retained between iterations, including effects of the last transition.
Every possible final state satisfies an invariant preserved by every supported transition.
Per-step failures of an invariant accumulate additively across an adaptive loop. The local bound is needed only at states where the preceding invariant holds.
The real-valued form of the adaptive error rule.
A uniform per-round error ε gives total error at most count * ε, including adaptive
rounds and state spaces that are not finite.
Independent uniform seeds realize an adaptive loop when they realize each reachable step. The invariant allows the realization law to be restricted to reachable states.