Lune

PLDI2023Top-tier venue

Formally Verified Samplers from Probabilistic Programs with Loops and Conditioning

Alexander Bagnall, Gordon Stewart, Anindya Banerjee

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.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

6 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Guaranteed Bounds on Posterior Distributions of Discrete Probabilistic Programs with Loops cites Scaling exact inference for discrete probabilistic programs
  • KEM-IND-CCA-Preserving Compilation of Jasmin's ML-KEM cites Interaction trees: representing recursive and impure programs in Coq
  • Random Variate Generation with Formal Guarantees cites The Discrete Gaussian for Differential Privacy
  • C4: verified transactional objects cites Interaction trees: representing recursive and impure programs in Coq
  • Verifying Sampling Algorithms via Distributional Invariants cites Deterministic stream-sampling for probabilistic programming: semantics and verification
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers6

  1. Guaranteed Bounds on Posterior Distributions of Discrete Probabilistic Programs with LoopsFabian Zaiser, Andrzej S. Murawski, C.-H. Luke OngPOPL 2025 · 6 citations
  2. Deterministic stream-sampling for probabilistic programming: semantics and verificationFredrik Dahlqvist, Alexandra Silva, William SmithLICS 2023 · 4 citations
  3. KEM-IND-CCA-Preserving Compilation of Jasmin's ML-KEMSantiago Arranz-Olmos, Gilles Barthe, Lionel Blatter, Benjamin Gregoire et al.CCS 2026 · 1 citation
  4. Verifying Sampling Algorithms via Distributional InvariantsDaniel Zilken, Kevin Batz, Joost-Pieter Katoen, Tobias WinklerFM 2026 · 1 citation
  5. Random Variate Generation with Formal GuaranteesFeras A. Saad, Wonyeol LeePLDI 2025

Builds on7

  1. The Discrete Gaussian for Differential PrivacyClément L. Canonne, Gautam Kamath, Thomas SteinkeNeurIPS 2020 · 355 citations
  2. Interaction trees: representing recursive and impure programs in CoqLi-yao Xia, Yannick Zakowski, Paul He, Chung-Kil Hur et al.POPL 2020 · 133 citations
  3. Scaling exact inference for discrete probabilistic programsSteven Holtzen, Guy Van den Broeck, Todd D. MillsteinOOPSLA 2020 · 85 citations
  4. LadderLeak: Breaking ECDSA with Less than One Bit of Nonce LeakageDiego F. Aranha, Felipe Rodrigues Novaes, Akira Takahashi, Mehdi Tibouchi et al.CCS 2020 · 58 citations
  5. C4: verified transactional objectsMohsen Lesani, Li-yao Xia, Anders Kaseorg, Christian J. Bell et al.OOPSLA 2022 · 27 citations

Related papers

  1. Verified Density Compilation for a Probabilistic Programming LanguageJoseph Tassarotti, Jean-Baptiste TristanPLDI 2023 · 6 citations
  2. Foundations for Deductive Verification of Continuous Probabilistic Programs: From Lebesgue to Riemann and BackKevin Batz, Joost-Pieter Katoen, Francesca Randone, Tobias WinklerOOPSLA 2025 · 2 citations
  3. Does a Program Yield the Right Distribution? - Verifying Probabilistic Programs via Generating FunctionsMingshuai Chen, Joost-Pieter Katoen, Lutz Klinkenberg, Tobias WinklerCAV 2022 · 14 citations
  4. A Deductive Verification Infrastructure for Probabilistic ProgramsPhilipp Schröer, Kevin Batz, Benjamin Lucien Kaminski, Joost-Pieter Katoen et al.OOPSLA 2023 · 22 citations
  5. Exact Bayesian Inference for Loopy Probabilistic Programs using Generating FunctionsLutz Klinkenberg, Christian Blumenthal, Mingshuai Chen, Darion Haase et al.OOPSLA 2024 · 11 citations
Dusk over the sea between two cliffs drawn in fine vertical lines