Semantics of oracle programs #
A program program : OracleComp spec α is a tree of oracle calls. It has a meaning once its calls
are answered, and this module gives that meaning once, for every interface spec, relative to the
answers:
OracleComp.evalWith h programis the output distribution when each callqis answered by an independent sample ofh q : PMF (spec q). It isOracleComp.interpretintoPMF.OracleComp.supportWith possible programis the set of results reached when each callqmay be answered by any element ofpossible q. It is defined by recursion on the tree of calls, so it needs no distribution on the replies. With every reply possible it isOracleComp.support, the results at the leaves of the tree.OracleComp.runWith oracle program sis the joint law of the result and the final state when each call is answered by a stateful probabilistic oracleoracle : (q : ι) → StateT σ PMF (spec q)from the states. It isOracleComp.interpretintoStateT σ PMF.
The three agree: the support of evalWith h program is supportWith of the supports of h
(support_evalWith), a result of a stateful run is reached along replies the oracle can give
(mem_supportWith_of_mem_support_runWith), and a memoryless oracle run with state is evalWith
with the state unchanged (runWith_lift). On the sum spec₁ ⊕ₒ spec₂, a handler is a
sumHandler, and an embedded program sees only its own side (evalWith_sumHandler_liftLeft,
supportWith_sumHandler_liftLeft, runWith_sumHandler_liftLeft).
The library's semantics are instances. ProbComp.eval is evalWith ProbComp.unifOracle
(ProbComp.eval_eq_evalWith), and since every uniform reply has positive probability, the
possible results of a closed program are its results for any replies (ProbComp.support_eval).
A program with private coins and external calls, ProbOracleComp spec, is a program over
unifSpec ⊕ₒ spec: its run against a stateful oracle is runWith of the sum of the lifted uniform
handler and that oracle (ProbOracleComp.runWith), and its possible results are support.
Algorithms are programs #
Probabilistic algorithms, such as key generation, signing, provers, verifiers, simulators,
extractors and samplers, are ProbComp or OracleComp programs. PMF is reserved for their
semantics, evalWith and its instances, and for genuinely semantic objects such as ideal
distributions and the laws compared in a statistical argument. A program can be run against
different oracles, budgeted (OracleComp.IsCostBounded), realized by a machine, and substituted
into a reduction, while a bare PMF can do none of these. Exact theorems stay exact, as statements
about evalWith.
Main definitions #
Cslib.OracleComp.evalWith: the output distribution for independent answers.Cslib.OracleComp.supportWith: the results for answers in given sets.Cslib.OracleComp.support: the results for any answers.Cslib.OracleComp.runWith: the joint law of the result and final state of a stateful oracle.
Main results #
Cslib.OracleComp.evalWith_bind,.mem_supportWith_bind_iff,.runWith_bind,.bind_congr_on_support, and thepure,mapandqueryrules: the structural rules of each semantics.Cslib.OracleComp.isMonadHom_evalWith:evalWith his a monad morphism.Cslib.OracleComp.evalWith_interpret,.supportWith_interpret: replacing calls by programs composes with the semantics.Cslib.OracleComp.support_evalWith: evaluation and support agree.Cslib.OracleComp.mem_supportWith_of_mem_support_runWith: stateful runs reach possible results.Cslib.OracleComp.runWith_lift: memoryless oracles leave the state unchanged.Cslib.OracleComp.support_liftLeft,.support_liftRight: embedding into a sum keeps the possible results.Cslib.ProbComp.eval_eq_evalWith,Cslib.ProbComp.support_eval,Cslib.ProbComp.support_nonempty,Cslib.ProbComp.mem_support_unifFin: closed probabilistic programs are the instance with uniform answers.Cslib.ProbComp.isMonadHom_eval,Cslib.ProbComp.eval_interpret: the instances ofisMonadHom_evalWithandevalWith_interpret.
References #
The design follows Devon Tuma, Quang Dao, and collaborators' VCVio, whose programs carry their distribution and possible outputs relative to an interpretation of the oracle calls.
Distributions for independent answers #
The output distribution of program when each call q is answered by an independent sample
of h q.
Instances For
A returned value has a point distribution.
Evaluating a sequence draws a result of the first program and evaluates the continuation at it.
Postprocessing maps the distribution.
A single call has the distribution of its answer.
Evaluation is a monad morphism into PMF.
Evaluating a program whose calls were replaced by programs over another interface evaluates the original calls by the distributions of their replacements.
Possible results #
The results of program when each call q may be answered by any element of possible q:
the results at the leaves of its tree of calls reached along such answers.
Instances For
A returned value is the only possible result.
A possible result of a sequence is a possible result of a continuation at a possible first result.
The possible results of a sequence, as a union over the possible first results.
A possible mapped result is the image of a possible result.
The possible results of a mapped program are the image of its possible results.
A single call may return any of its possible answers.
Allowing more answers allows more results.
Replacing calls by programs over another interface: the possible results are those of the original program, with each call answered by a possible result of its replacement.
A returned value is the only possible result.
The results of program for any replies to its calls: the results at the leaves of its tree
of calls. It is supportWith with every reply possible, and the rules of supportWith apply.
Instances For
Two continuations that agree on every possible output of program have identical >>= in
OracleComp.
Evaluation and support #
The results with positive probability are the results reached along answers with positive probability.
Stateful oracles #
The joint law of the result of program and the final state of the stateful oracle answering
its calls, starting from the state s.
Instances For
Running a sequence runs the first program, then the continuation at its result from the state it reached.
Postprocessing maps the result and keeps the final state.
A single call is answered by the oracle from the current state.
Every result of a stateful run is reached along replies the oracle can give: if each reply of
the oracle to q, from any state, lies in possible q, every result is in
supportWith possible.
A memoryless oracle run with state leaves the state unchanged, and the result has the law of
evalWith.
Sums of interfaces #
An embedded left program is evaluated by the left handler alone.
An embedded right program is evaluated by the right handler alone.
Evaluation distributes over the two sides of a handler by programs.
The supports of the answers of a sum handler are the sum of the supports.
An embedded left program has the possible results allowed by the left answers alone.
An embedded right program has the possible results allowed by the right answers alone.
An embedded left program has the same possible results for any replies.
An embedded right program has the same possible results for any replies.
An embedded left program is run by the left oracle alone, which keeps the whole state.
An embedded right program is run by the right oracle alone, which keeps the whole state.
Evaluating a closed probabilistic program is evalWith of the uniform handler.
The possible results of a closed probabilistic program are its results for any replies, since every uniform reply has positive probability.
Every closed probabilistic program has at least one possible result.
Every value in Fin (n + 1) is a possible output of unifFin n.
Evaluating a closed probabilistic program is a monad morphism into PMF.
Evaluating an interpreted oracle program is interpreting each call by its evaluated sampler.