Formally Verified Samplers from Probabilistic Programs with Loops and Conditioning
Open Access
- 6 June 2023
- journal article
- research article
- Published by Association for Computing Machinery (ACM) in Proceedings of the ACM on Programming Languages
- Vol. 7 (PLDI) , 1-24
Abstract
We present Zar: a formally verified compiler pipeline from discrete probabilistic programs with unbounded loops in the conditional probabilistic guarded command language (cpGCL) to proved-correct executable samplers in the random bit model. We exploit the key idea that all discrete probability distributions can be reduced to unbiased coin-flipping schemes. The compiler pipeline first translates cpGCL programs into choice-fix trees, an intermediate representation suitable for reduction of biased probabilistic choices. Choice-fix trees are then translated to coinductive interaction trees for execution within the random bit model. The correctness of the composed translations establishes the sampling equidistribution theorem: compiled samplers are correct wrt. the conditional weakest pre-expectation semantics of cpGCL source programs. Zar is implemented and fully verified in the Coq proof assistant. We extract verified samplers to OCaml and Python and empirically validate them on a number of illustrative examples.Keywords
All Related Versions
This publication has 32 references indexed in Scilit:
- Formal verification of a realistic compilerCommunications of the ACM, 2009
- Extraction in Coq: An Overview2008
- On probabilistic inference by weighted model countingArtificial Intelligence, 2008
- Schnorr randomnessThe Journal of Symbolic Logic, 2004
- Gradient-based learning applied to document recognitionProceedings of the IEEE, 1998
- Automatic translation of FORTRAN programs to vector formACM Transactions on Programming Languages and Systems, 1987
- Guarded commands, nondeterminacy and formal derivation of programsCommunications of the ACM, 1975
- The definition of random sequencesInformation and Control, 1966
- A Mathematical Theory of CommunicationBell System Technical Journal, 1948
- ber die Gleichverteilung von Zahlen mod. EinsMathematische Annalen, 1916