Stateful oracle simulation #
Local simulation identities lift to arbitrary adaptive programs, retaining both the result and the oracle's final private state. A simulation may randomly complete hidden state, as in the lazy-sampling proof for a random function. The local identity only needs to hold at states satisfying a preserved invariant.
These rules adapt Languages/Probabilistic/Simulation.lean from the cslib crypto branch at
5ff69ca93402e7c947208dc56396d6d86203ccd8 to the common OracleComp.interpret interface.
There is one oracle specification and one interpreter; stateful execution uses StateT.
Main results #
Cslib.OracleComp.induction: structural induction with the step caseOracleComp.query q >>= cont.Cslib.OracleComp.run_interpret_pure,Cslib.OracleComp.run_interpret_bind,Cslib.OracleComp.run_interpret_map,Cslib.OracleComp.run_interpret_query: stateful interpretation ofpure,>>=,<$>, andquery.Cslib.OracleComp.run_interpret_invariant: invariants of each call hold after execution.Cslib.OracleComp.run_interpret_simulation_of_invariant: probabilistic state simulation.Cslib.OracleComp.run_interpret_map_state_of_invariant: deterministic state representation.Cslib.OracleComp.run_interpret_map_response_state: represent both replies and private state.Cslib.OracleComp.map_run_interpret: a monad morphism commutes with stateful interpretation.Cslib.OracleComp.run_interpret_lift: lifted effects preserve the complete private state.Cslib.OracleComp.run_interpret_run_interpret: a stateful handler whose effects are oracle calls, followed by a stateful oracle for those calls, is one handler on the joint state.Cslib.ProbComp.isMonadHom_eval:ProbComp.evalis a monad morphism intoPMF.Cslib.ProbComp.eval_interpret: evaluating an interpreted oracle program interprets each call by its evaluated sampler.Cslib.ProbComp.mem_support_eval_pure_iff,Cslib.ProbComp.mem_support_eval_bind_iff,Cslib.ProbComp.mem_support_eval_map_iff,Cslib.ProbComp.mem_support_eval_uniform,Cslib.ProbComp.mem_support_eval_uniform_iff: support of evaluated closed probabilistic programs.
Structural induction on an oracle program, presenting the step case as
OracleComp.query q >>= cont.
A pure program returns its value and leaves the state unchanged.
Running program >>= next runs program, then runs next at its result from the state it
reached.
Mapping f over a program maps it over the result and keeps the final state.
A single call is answered by the stateful oracle from the current state.
Lifting every oracle action into state retains the original state beside its result.
An invariant preserved by supported oracle transitions holds after every adaptive program.
A probabilistic change of private state that commutes with calls on invariant states commutes with an entire adaptive computation. Only supported transitions must preserve the invariant, and the equality retains the joint result and final state.
A local probabilistic simulation lifts to every adaptive computation.
Re-encoding private state preserves adaptive execution when calls agree on invariant states.
A deterministic representation commuting with each call preserves the complete execution.
Representing replies and private state commutes with adaptive execution. Oracle substitution supplies each target reply by mapping a source reply, including to adaptive continuations. This corollary of state simulation retains the joint result and represented final state.
Transforming the underlying monad commutes with stateful program interpretation, retaining the joint result and private state.
Running a program against a stateful handler whose own effects are oracle calls, and then running those calls against a stateful oracle, is one stateful execution on the joint state. The result, the handler's final state and the oracle's final state are retained jointly.
Evaluating a closed probabilistic program is a monad morphism into PMF.
Evaluating an interpreted oracle program is interpreting each call by its evaluated sampler.
An outcome is supported by program >>= next iff it is supported by next a for some
supported outcome a of program.