Probabilistic programs with oracles #
OracleComp spec α is a terminating program with typed oracle calls described by the
specification spec : OracleSpec ι, which gives the response type spec q of each query q : ι.
A specification is the data of a polynomial functor, and programs are its PFunctor.FreeM, so they
use ordinary do notation, and a program lives in the universe of its queries, responses, and
result.
Randomness is not a separate effect. unifSpec is the interface answering n with a uniform
element of Fin (n + 1), and ProbComp is OracleComp unifSpec. Any other distribution is
reached by interpreting an interface with that distribution, so the base language has no
primitive beyond uniform choice from a finite range.
OracleComp.interpret runs a program in any monad by answering each call with a handler in that
monad. Into PMF it gives the output distribution of a program with a memoryless probabilistic
oracle; into StateT State m it threads a hidden oracle state through the calls; into another
OracleComp it replaces each call by a program over another interface, as needed for reductions;
and into a writer monad it logs the queries. It is PFunctor.FreeM.liftM, so it preserves
sequencing, and interpretations compose.
Neither termination nor a bound on the number of queries asserts computational efficiency. Computational efficiency requires a separate machine-realizability predicate. Unbounded loops and nontermination are outside this language; bounded iteration uses Lean recursion.
References #
This is the design of Devon Tuma, Quang Dao, and collaborators'
VCVio: OracleSpec, OracleComp, and unifSpec
are their definitions, and OracleComp.interpret is their simulateQ.
An oracle specification: the response type of each query in ι.
Instances For
Terminating programs with typed oracle calls described by spec.
Instances For
Make one oracle call. Later queries may depend on the answer.
Instances For
Run a program in the monad m, answering each oracle call with oracle.
Instances For
Answering each call by itself leaves the program unchanged.
Interpretations compose: interpreting a program whose calls were replaced by programs over another interface is interpreting the original calls through the replacements. No fresh state is introduced between calls.
An oracle may consult a fixed private environment without changing it. Its stateful execution agrees with interpreting the program against that environment.
Adding an untouched private state to a memoryless oracle does not change the result.
The uniform sampling interface: the query n is answered by a uniform element of
Fin (n + 1).
Instances For
Probabilistic programs whose only randomness is uniform choice from a finite range.
Instances For
The distribution denoted by a closed probabilistic program.
Instances For
Sampling through an enumeration is uniform on the type.