A Verified Compiler for Probability Density Functions

  • Manuel Eberl
  • Johannes Hölzl
  • Tobias Nipkow
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9032)


Bhat et al. developed an inductive compiler that computes density functions for probability spaces described by programs in a probabilistic functional language. We implement such a compiler for a modified version of this language within the theorem prover Isabelle and give a formal proof of its soundness w. r. t. the semantics of the source and target language. Together with Isabelle’s code generation for inductive predicates, this yields a fully verified, executable density compiler. The proof is done in two steps: First, an abstract compiler working with abstract functions modelled directly in the theorem prover’s logic is defined and proved sound. Then, this compiler is refined to a concrete version that returns a target-language expression.


  1. 1.
    Audebaud, P., Paulin-Mohring, C.: Proofs of randomized algorithms in Coq. In: Uustalu, T. (ed.) MPC 2006. LNCS, vol. 4014, pp. 49–68. Springer, Heidelberg (2006), CrossRefGoogle Scholar
  2. 2.
    Avigad, J., Hölzl, J., Serafin, L.: A formally verified proof of the Central Limit Theorem. CoRR abs/1405.7012 (2014)Google Scholar
  3. 3.
    Bertot, Y., Castéran, P.: Interactive Theorem Proving and Program Development. Coq’Art: The Calculus of Inductive Constructions. Springer (2004)Google Scholar
  4. 4.
    Bhat, S., Agarwal, A., Vuduc, R., Gray, A.: A type theory for probability density functions. In: Proceedings of the 39th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2012, pp. 545–556. ACM, New York (2012), Google Scholar
  5. 5.
    Bhat, S., Borgström, J., Gordon, A.D., Russo, C.: Deriving probability density functions from probabilistic functional programs. In: Piterman, N., Smolka, S.A. (eds.) TACAS 2013. LNCS, vol. 7795, pp. 508–522. Springer, Heidelberg (2013),
  6. 6.
    Bhat, S., Borgström, J., Gordon, A.D., Russo, C.: Deriving probability density functions from probabilistic functional programs (full version, submitted for publication)Google Scholar
  7. 7.
    de Bruijn, N.G.: Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. Indagationes Mathematicae 34, 381–392 (1972)CrossRefGoogle Scholar
  8. 8.
    Cock, D.: Verifying probabilistic correctness in Isabelle with pGCL. In: Proceedings of the 7th Systems Software Verification, pp. 1–10 (November 2012)Google Scholar
  9. 9.
    Cock, D.: pGCL for Isabelle. Archive of Formal Proofs Formal proof development (July 2014),
  10. 10.
    Doberkat, E.E.: Stochastic relations: foundations for Markov transition systems. Studies in Informatics. Chapman & Hall/CRC (2007)Google Scholar
  11. 11.
    Doberkat, E.E.: Basing Markov transition systems on the Giry monad (2008),
  12. 12.
    Eberl, M.: A Verified Compiler for Probability Density Functions. Master’s thesis, Technische Universität München (2014),
  13. 13.
    Eberl, M., Hölzl, J., Nipkow, T.: A verified compiler for probability density functions. Archive of Formal Proofs, Formal proof development (October 2014),,
  14. 14.
    Giry, M.: A categorical approach to probability theory. In: Mosses, P.D., Nielsen, M. (eds.) CAAP 1995, FASE 1995, and TAPSOFT 1995. LNCS, vol. 915, pp. 68–85. Springer, Heidelberg (1995),, doi:10.1007/BFb0092872Google Scholar
  15. 15.
    Hölzl, J.: Construction and stochastic applications of measure spaces in Higher-Order Logic. PhD thesis, Technische Universität München, Institut für Informatik (2012)Google Scholar
  16. 16.
    Hurd, J.: Formal Verification of Probabilistic Algorithms. Ph.D. thesis, University of Cambridge (2002)Google Scholar
  17. 17.
    Hurd, J., McIver, A., Morgan, C.: Probabilistic guarded commands mechanized in HOL. Electron. Notes Theor. Comput. Sci. 112, 95–111 (2005), CrossRefGoogle Scholar
  18. 18.
    Nipkow, T., Klein, G.: Concrete Semantics with Isabelle/HOL. Springer (2014),
  19. 19.
    Nipkow, T., Paulson, L.C., Wenzel, M.: Isabelle/HOL. LNCS, vol. 2283. Springer, Heidelberg (2002)zbMATHGoogle Scholar
  20. 20.
    Park, S., Pfenning, F., Thrun, S.: A probabilistic language based upon sampling functions. In: Proceedings of the 32Nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2005, pp. 171–182. ACM, New York (2005), Google Scholar
  21. 21.
    Urban, C.: Nominal techniques in Isabelle/HOL. Journal of Automated Reasoning 40, 327–356 (2008)CrossRefzbMATHMathSciNetGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2015

Authors and Affiliations

  • Manuel Eberl
    • 1
  • Johannes Hölzl
    • 1
  • Tobias Nipkow
    • 1
  1. 1.Fakultät für InformatikTechnische Universität MünchenMünchenGermany

Personalised recommendations