Abstract
Although the formalization of probabilistic programs already has several applications in the fields of security proofs and artificial intelligence, formal verification experiments are still underway to support the many features of probabilistic programming. We report on the formalization in the Coq proof assistant of a syntax and a denotational semantics for a probabilistic programming language with sampling, scoring, and normalization. We use dependent types in a crucial way since our syntax is intrinsically-typed and since the semantic values are essentially dependent records. Thanks to the features of Coq, we can use notations that hide the details of type inference when writing examples. The resulting formalization is usable to reason about simple probabilistic programs.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
MathComp-Analysis adds to the constructive logic of Coq functional and propositional extensionality and the axiom of constructive indefinite description [3, Sect. 5].
- 2.
In Coq, disables implicit arguments.
References
Affeldt, R., et al.: MathComp-Analysis: mathematical components compliant analysis library (2023). Since 2017. Version 0.6.4. https://github.com/math-comp/analysis
Affeldt, R., Cohen, C.: Measure construction by extension in dependent type theory with application to integration. J. Autom. Reason. 67(3), 28:1–28:27 (2023). https://doi.org/10.1007/s10817-023-09671-5
Affeldt, R., Cohen, C., Rouhling, D.: Formalization techniques for asymptotic reasoning in classical analysis. J. Formaliz. Reason. 11(1), 43–76 (2018). https://doi.org/10.6092/issn.1972-5787/8124
Affeldt, R., Cohen, C., Saito, A.: Semantics of probabilistic programs using s-finite kernels in Coq. In: 12th ACM SIGPLAN International Conference on Certified Programs and Proofs (CPP 2023), Boston, MA, USA, 16–17 January 2023, pp. 3–16. ACM (2023). https://doi.org/10.1145/3573105.3575691
Affeldt, R., Sakaguchi, K.: An intrinsic encoding of a subset of C and its application to TLS network packet processing. J. Formaliz. Reason. 7(1), 63–104 (2014). https://doi.org/10.6092/issn.1972-5787/4317
Audebaud, P., Paulin-Mohring, C.: Proofs of randomized algorithms in Coq. Sci. Comput. Program. 74(8), 568–589 (2009). https://doi.org/10.1016/j.scico.2007.09.002
Bagnall, A., Stewart, G.: Certifying the true error: machine learning in Coq with verified generalization guarantees. In: 33rd AAAI Conference on Artificial Intelligence, 31st Conference on Innovative Applications of Artificial Intelligence, 9th Symposium on Educational Advances in Artificial Intelligence, Honolulu, Hawaii, USA, 27 January–1 February 2019, pp. 2662–2669. AAAI Press (2019). https://doi.org/10.1609/aaai.v33i01.33012662
Barthe, G., Grégoire, B., Béguelin, S.Z.: Formal certification of code-based cryptographic proofs. In: 36th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2009), Savannah, GA, USA, 21–23 January 2009, pp. 90–101. ACM (2009). https://doi.org/10.1145/1480881.1480894
Barthe, G., Katoen, J.P., Silva, A. (eds.): Foundations of Probabilistic Programming. Cambridge University Press, Cambridge (2020). https://doi.org/10.1017/9781108770750
Benton, N., Hur, C., Kennedy, A., McBride, C.: Strongly typed term representations in Coq. J. Autom. Reason. 49(2), 141–159 (2012). https://doi.org/10.1007/s10817-011-9219-0
Borgström, J., Lago, U.D., Gordon, A.D., Szymczak, M.: A lambda-calculus foundation for universal probabilistic programming. In: 21st ACM SIGPLAN International Conference on Functional Programming (ICFP 2016), Nara, Japan, 18–22 September 2016, pp. 33–46. ACM (2016). https://doi.org/10.1145/2951913.2951942
Chapman, J., Kireev, R., Nester, C., Wadler, P.: System F in Agda, for fun and profit. In: Hutton, G. (ed.) MPC 2019. LNCS, vol. 11825, pp. 255–297. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-33636-3_10
Gonthier, G., Ziliani, B., Nanevski, A., Dreyer, D.: How to make ad hoc proof automation less ad hoc. J. Funct. Program. 23(4), 357–401 (2013). https://doi.org/10.1017/S0956796813000051
Heimerdinger, M., Shan, C.: Verified equational reasoning on a little language of measures. In: Workshop on Languages for Inference (LAFI 2019), Cascais, Portugal, 15 January 2019 (2019)
Hirata, M., Minamide, Y., Sato, T.: Program logic for higher-order probabilistic programs in Isabelle/HOL. In: Hanus, M., Igarashi, A. (eds.) FLOPS 2022. LNCS, vol. 13215, pp. 57–74. Springer, Cham (2022). https://doi.org/10.1007/978-3-030-99461-7_4
Hirata, M., Minamide, Y., Sato, T.: Semantic foundations of higher-order probabilistic programs in Isabelle/HOL. In: 14th International Conference on Interactive Theorem Proving (ITP 2023). LIPIcs, Białystok, Poland, 31 July–4 August 2023, vol. 268, pp. 18:1–18:18. Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2023). https://doi.org/10.4230/LIPIcs.ITP.2023.18
Hurd, J.: Formal verification of probabilistic algorithms. Ph.D. thesis, Computer Laboratory, University of Cambridge (2001)
Pickard, M., Hutton, G.: Calculating dependently-typed compilers (functional pearl). Proc. ACM Program. Lang. 5(ICFP), 1–27 (2021). https://doi.org/10.1145/3473587
Pit-Claudel, C., Bourgeat, T.: An experience report on writing usable DSLs in Coq. In: 7th International Workshop on Coq for Programming Languages (CoqPL 2021) (2021). https://popl21.sigplan.org/details/CoqPL-2021-papers/7/An-experience-report-on-writing-usable-DSLs-in-Coq
Poulsen, C.B., Rouvoet, A., Tolmach, A., Krebbers, R., Visser, E.: Intrinsically-typed definitional interpreters for imperative languages. Proc. ACM Program. Lang. 2(POPL), 16:1–16:34 (2018). https://doi.org/10.1145/3158104
Saito, A., Affeldt, R.: Experimenting with an intrinsically-typed probabilistic programming language in Coq. Part of MathComp-Analysis Pull Request (2023). Application of s-finite kernels to program semantics (2023), formal development accompanying this paper. https://github.com/math-comp/analysis/pull/912
Shan, C.: Equational reasoning for probabilistic programming. POPL TutorialFest (2018)
Staton, S.: Commutative semantics for probabilistic programming. In: Yang, H. (ed.) ESOP 2017. LNCS, vol. 10201, pp. 855–879. Springer, Heidelberg (2017). https://doi.org/10.1007/978-3-662-54434-1_32
Staton, S.: Probabilistic programs as measures, pp. 43–74 (2020). https://doi.org/10.1017/9781108770750.003. Chapter in [9]
Staton, S., Yang, H., Wood, F.D., Heunen, C., Kammar, O.: Semantics for probabilistic programming: higher-order functions, continuous distributions, and soft constraints. In: 31st Annual ACM/IEEE Symposium on Logic in Computer Science (LICS 2016), New York, NY, USA, 5–8 July 2016, pp. 525–534. ACM (2016). https://doi.org/10.1145/2933575.2935313
Tassarotti, J., Vajjha, K., Banerjee, A., Tristan, J.: A formal proof of PAC learnability for decision stumps. In: 10th ACM SIGPLAN International Conference on Certified Programs and Proofs (CPP 2021), Virtual Event, Denmark, 17–19 January 2021, pp. 5–17. ACM (2021). https://doi.org/10.1145/3437992.3439917
The Coq Development Team: Custom entries. Inria (2019). Chapter Syntax extensions and notation scopes of [29]. direct link
The Coq Development Team: Bidirectionality hints. Inria (2020). Chapter Setting properties of a function’s arguments of [29]. direct link
The Coq Development Team: The Coq Proof Assistant Reference Manual. Inria (2023). Version 8.17.1. https://coq.inria.fr/distrib/current/refman/
Zhang, Y., Amin, N.: Reasoning about “reasoning about reasoning”: semantics and contextual equivalence for probabilistic programs with nested queries and recursion. Proc. ACM Program. Lang. 6(POPL), 1–28 (2022). https://doi.org/10.1145/3498677
Ziliani, B., Sozeau, M.: A comprehensible guide to a new unifier for CIC including universe polymorphism and overloading. J. Funct. Program. 27, e10 (2017). https://doi.org/10.1017/S0956796817000028
Acknowledgements
The authors would like to thank the members of the Programming Research Group of the Department of Mathematical and Computing Science at the Tokyo Institute of Technology for their input, and to the anonymous reviewers for many comments that substantially improved this paper. The authors acknowledge the support of the JSPS KAKENHI Grant Number 22H00520.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2023 The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd.
About this paper
Cite this paper
Saito, A., Affeldt, R. (2023). Experimenting with an Intrinsically-Typed Probabilistic Programming Language in Coq. In: Hur, CK. (eds) Programming Languages and Systems. APLAS 2023. Lecture Notes in Computer Science, vol 14405. Springer, Singapore. https://doi.org/10.1007/978-981-99-8311-7_9
Download citation
DOI: https://doi.org/10.1007/978-981-99-8311-7_9
Published:
Publisher Name: Springer, Singapore
Print ISBN: 978-981-99-8310-0
Online ISBN: 978-981-99-8311-7
eBook Packages: Computer ScienceComputer Science (R0)