Static Posterior Inference of Bayesian Probabilistic Programming via Polynomial Solving (2307.13160v3)
Abstract: In Bayesian probabilistic programming, a central problem is to estimate the normalised posterior distribution (NPD) of a probabilistic program with conditioning via score (a.k.a. observe) statements. Most previous approaches address this problem by Markov Chain Monte Carlo and variational inference, and therefore could not generate guaranteed outcomes within a finite time limit. Moreover, existing methods for exact inference either impose syntactic restrictions or cannot guarantee successful inference in general. In this work, we propose a novel automated approach to derive guaranteed bounds for NPD via polynomial solving. We first establish a fixed-point theorem for the wide class of score-at-end Bayesian probabilistic programs that terminate almost-surely and have a single bounded score statement at program termination. Then, we propose a multiplicative variant of Optional Stopping Theorem (OST) to address score-recursive Bayesian programs where score statements with weights greater than one could appear inside a loop. Finally, we use polynomial solving to implement our fixed-point theorem and OST variant. To improve the accuracy of the polynomial solving, we further propose a truncation operation and the synthesis of multiple bounds over various program inputs. Our approach can handle Bayesian probabilistic programs with unbounded while loops and continuous distributions with infinite supports. Experiments over a wide range of benchmarks show that compared with the most relevant approach (Beutner et al., PLDI 2022) for guaranteed NPD analysis via recursion unrolling, our approach is more time efficient and derives comparable or even tighter NPD bounds. Furthermore, our approach can handle score-recursive programs which previous approaches could not.
- MOSEK ApS. 2022. The MOSEK optimization toolbox for MATLAB manual. Version 10.0. http://docs.mosek.com/10.0/toolbox/index.html
- Proving expected sensitivity of probabilistic programs. Proc. ACM Program. Lang. 2, POPL (2018), 57:1–57:29. https://doi.org/10.1145/3158145
- Probabilistic Program Verification via Inductive Synthesis of Inductive Invariants. In Tools and Algorithms for the Construction and Analysis of Systems - 29th International Conference, TACAS 2023, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2022, Paris, France, April 22-27, 2023, Proceedings, Part II (Lecture Notes in Computer Science, Vol. 13994), Sriram Sankaranarayanan and Natasha Sharygina (Eds.). Springer, 410–429. https://doi.org/10.1007/978-3-031-30820-8_25
- Guaranteed bounds for posterior inference in universal probabilistic programming. In PLDI ’22: 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation, San Diego, CA, USA, June 13 - 17, 2022, Ranjit Jhala and Isil Dillig (Eds.). ACM, 536–551. https://doi.org/10.1145/3519939.3523721
- Pyro: Deep Universal Probabilistic Programming. J. Mach. Learn. Res. 20 (2019), 28:1–28:6. http://jmlr.org/papers/v20/18-403.html
- Variational inference: A review for statisticians. Journal of the American statistical Association 112, 518 (2017), 859–877.
- A lambda-calculus foundation for universal probabilistic programming. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming, ICFP 2016, Nara, Japan, September 18-22, 2016, Jacques Garrigue, Gabriele Keller, and Eijiro Sumii (Eds.). ACM, 33–46. https://doi.org/10.1145/2951913.2951942
- Aleksandar Chakarov and Sriram Sankaranarayanan. 2013a. Probabilistic Program Analysis with Martingales. In CAV 2013. 511–526.
- Aleksandar Chakarov and Sriram Sankaranarayanan. 2013b. Probabilistic Program Analysis with Martingales. In Computer Aided Verification - 25th International Conference, CAV 2013, Saint Petersburg, Russia, July 13-19, 2013. Proceedings (Lecture Notes in Computer Science, Vol. 8044), Natasha Sharygina and Helmut Veith (Eds.). Springer, 511–526. https://doi.org/10.1007/978-3-642-39799-8_34
- Termination Analysis of Probabilistic Programs Through Positivstellensatz’s. In CAV 2016. 3–22.
- Algorithmic analysis of qualitative and quantitative termination problems for affine probabilistic programs. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, St. Petersburg, FL, USA, January 20 - 22, 2016, Rastislav Bodík and Rupak Majumdar (Eds.). ACM, 327–342. https://doi.org/10.1145/2837614.2837639
- Algorithmic Analysis of Qualitative and Quantitative Termination Problems for Affine Probabilistic Programs. ACM Trans. Program. Lang. Syst. 40, 2 (2018), 7:1–7:45. https://doi.org/10.1145/3174800
- Stochastic invariants for probabilistic termination. In POPL 2017. 145–160.
- Leonardo De Moura and Nikolaj Bjørner. 2008. Z3: An Efficient SMT Solver. In Proceedings of the Theory and Practice of Software, 14th International Conference on Tools and Algorithms for the Construction and Analysis of Systems (Budapest, Hungary) (TACAS’08/ETAPS’08). Springer-Verlag, Berlin, Heidelberg, 337–340.
- Joseph L Doob. 1971. What is a Martingale? The American Mathematical Monthly 78, 5 (1971), 451–463.
- Hongfei Fu and Krishnendu Chatterjee. 2019. Termination of Nondeterministic Probabilistic Programs. In Verification, Model Checking, and Abstract Interpretation - 20th International Conference, VMCAI 2019, Cascais, Portugal, January 13-15, 2019, Proceedings (Lecture Notes in Computer Science, Vol. 11388), Constantin Enea and Ruzica Piskac (Eds.). Springer, 468–490. https://doi.org/10.1007/978-3-030-11245-5_22
- Dani Gamerman and Hedibert F Lopes. 2006. Markov chain Monte Carlo: stochastic simulation for Bayesian inference. CRC press.
- PSI: Exact Symbolic Inference for Probabilistic Programs. In Computer Aided Verification - 28th International Conference, CAV 2016, Toronto, ON, Canada, July 17-23, 2016, Proceedings, Part I (Lecture Notes in Computer Science, Vol. 9779), Swarat Chaudhuri and Azadeh Farzan (Eds.). Springer, 62–83. https://doi.org/10.1007/978-3-319-41528-4_4
- λ𝜆\lambdaitalic_λPSI: exact inference for higher-order probabilistic programs. In Proceedings of the 41st ACM SIGPLAN International Conference on Programming Language Design and Implementation, PLDI 2020, London, UK, June 15-20, 2020, Alastair F. Donaldson and Emina Torlak (Eds.). ACM, 883–897. https://doi.org/10.1145/3385412.3386006
- Church: a language for generative models. In UAI 2008, Proceedings of the 24th Conference in Uncertainty in Artificial Intelligence, Helsinki, Finland, July 9-12, 2008, David A. McAllester and Petri Myllymäki (Eds.). AUAI Press, 220–229.
- Noah D Goodman and Andreas Stuhlmüller. 2014. The Design and Implementation of Probabilistic Programming Languages. http://dippl.org.
- Probabilistic programming. In Future of Software Engineering Proceedings. 167–181.
- David Handelman. 1988. Representing polynomials by positive linear functions on compact convex polyhedra. Pacific J. Math. 132, 1 (1988), 35–62.
- Control-Data Separation and Logical Condition Propagation for Efficient Inference on Probabilistic Programs. CoRR abs/2101.01502 (2021). arXiv:2101.01502 https://arxiv.org/abs/2101.01502
- AQUA: Automated Quantized Inference for Probabilistic Programs. In Automated Technology for Verification and Analysis - 19th International Symposium, ATVA 2021, Gold Coast, QLD, Australia, October 18-22, 2021, Proceedings (Lecture Notes in Computer Science, Vol. 12971), Zhe Hou and Vijay Ganesh (Eds.). Springer, 229–246. https://doi.org/10.1007/978-3-030-88885-5_16
- H Jeffreys. 1988. "Weierstrass’s theorem on approximation by polynomials" and "Extension of Weierstrass’s approximation theory". Methods of Mathematical Physics (1988), 446–448.
- Exact Bayesian Inference for Loopy Probabilistic Programs using Generating Functions. ACM. to appear in OOPSLA 2024.
- Tail probabilities for randomized program runtimes via martingales for higher moments. In International Conference on Tools and Algorithms for the Construction and Analysis of Systems. Springer, 135–153.
- Towards verified stochastic variational inference for probabilistic programs. Proc. ACM Program. Lang. 4, POPL (2020), 16:1–16:33. https://doi.org/10.1145/3371084
- Densities of Almost Surely Terminating Probabilistic Programs are Differentiable Almost Everywhere. In Programming Languages and Systems - 30th European Symposium on Programming, ESOP 2021, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2021, Luxembourg City, Luxembourg, March 27 - April 1, 2021, Proceedings (Lecture Notes in Computer Science, Vol. 12648), Nobuko Yoshida (Ed.). Springer, 432–461. https://doi.org/10.1007/978-3-030-72019-3_16
- Nonparametric Involutive Markov Chain Monte Carlo. In International Conference on Machine Learning, ICML 2022, 17-23 July 2022, Baltimore, Maryland, USA (Proceedings of Machine Learning Research, Vol. 162), Kamalika Chaudhuri, Stefanie Jegelka, Le Song, Csaba Szepesvári, Gang Niu, and Sivan Sabato (Eds.). PMLR, 14802–14859. https://proceedings.mlr.press/v162/mak22a.html
- Annabelle McIver and Carroll Morgan. 2004. Developing and Reasoning About Probabilistic Programs in pGCL. In Refinement Techniques in Software Engineering, First Pernambuco Summer School on Software Engineering, PSSE 2004, Recife, Brazil, November 23-December 5, 2004, Revised Lectures (Lecture Notes in Computer Science, Vol. 3167), Ana Cavalcanti, Augusto Sampaio, and Jim Woodcock (Eds.). Springer, 123–155. https://doi.org/10.1007/11889229_4
- Annabelle McIver and Carroll Morgan. 2005. Abstraction, Refinement and Proof for Probabilistic Systems. Springer. https://doi.org/10.1007/b138392
- Sean P Meyn and Richard L Tweedie. 2012. Markov chains and stochastic stability. Springer Science & Business Media.
- Probabilistic Inference by Program Transformation in Hakaru (System Description). In Functional and Logic Programming - 13th International Symposium, FLOPS 2016, Kochi, Japan, March 4-6, 2016, Proceedings (Lecture Notes in Computer Science, Vol. 9613), Oleg Kiselyov and Andy King (Eds.). Springer, 62–79. https://doi.org/10.1007/978-3-319-29604-3_5
- Bounded expectations: resource analysis for probabilistic programs. In Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2018, Philadelphia, PA, USA, June 18-22, 2018, Jeffrey S. Foster and Dan Grossman (Eds.). ACM, 496–512. https://doi.org/10.1145/3192366.3192394
- David Pollard. 2002. A user’s guide to measure theoretic probability. Number 8. Cambridge University Press.
- Mihai Putinar. 1993. Positive Polynomials on Compact Semi-algebraic Sets. Indiana University Mathematics Journal 42, 3 (1993), 969–984. http://www.jstor.org/stable/24897130
- Alexey Radul and Boris Alexeev. 2021. The Base Measure Problem and its Solution. In The 24th International Conference on Artificial Intelligence and Statistics, AISTATS 2021, April 13-15, 2021, Virtual Event (Proceedings of Machine Learning Research, Vol. 130), Arindam Banerjee and Kenji Fukumizu (Eds.). PMLR, 3583–3591. http://proceedings.mlr.press/v130/radul21a.html
- Thomas Rainforth. 2017. Automating inference, learning, and design using probabilistic programming. Ph. D. Dissertation. University of Oxford.
- RA Rankin. 1968. Real and Complex Analysis. By W. Rudin. Pp. 412. 84s. 1966.(McGraw-Hill, New York.). The Mathematical Gazette 52, 382 (1968), 412–412.
- Universal probabilistic programming offers a powerful approach to statistical phylogenetics. Communications biology 4, 1 (2021), 1–10.
- Reuven Y Rubinstein and Dirk P Kroese. 2016. Simulation and the Monte Carlo method. Vol. 10. John Wiley & Sons.
- Walter Rudin et al. 1976. Principles of mathematical analysis. Vol. 3. McGraw-hill New York.
- SPPL: probabilistic programming with fast exact symbolic inference. In PLDI ’21: 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation, Virtual Event, Canada, June 20-25, 2021, Stephen N. Freund and Eran Yahav (Eds.). ACM, 804–819. https://doi.org/10.1145/3453483.3454078
- Davide Sangiorgi. 2011. Introduction to bisimulation and coinduction. Cambridge University Press.
- Static analysis for probabilistic programs: inferring whole program properties from finitely many paths. In ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’13, Seattle, WA, USA, June 16-19, 2013, Hans-Juergen Boehm and Cormac Flanagan (Eds.). ACM, 447–458. https://doi.org/10.1145/2491956.2462179
- Constraint-Based Linear-Relations Analysis. In Static Analysis, 11th International Symposium, SAS 2004, Verona, Italy, August 26-28, 2004, Proceedings (Lecture Notes in Computer Science, Vol. 3148), Roberto Giacobazzi (Ed.). Springer, 53–68. https://doi.org/10.1007/978-3-540-27864-1_7
- Semantics for probabilistic programming: higher-order functions, continuous distributions, and soft constraints. In Proceedings of the 31st Annual ACM/IEEE Symposium on Logic in Computer Science, LICS ’16, New York, NY, USA, July 5-8, 2016, Martin Grohe, Eric Koskinen, and Natarajan Shankar (Eds.). ACM, 525–534. https://doi.org/10.1145/2933575.2935313
- TreeFlow: probabilistic programming and automatic differentiation for phylogenetics. arXiv preprint arXiv:2211.05220 (2022).
- Alfred Tarski. 1955. A lattice-theoretical fixpoint theorem and its applications. Pacific journal of Mathematics 5, 2 (1955), 285–309.
- Probabilistic Programming in Anglican. In Machine Learning and Knowledge Discovery in Databases - European Conference, ECML PKDD 2015, Porto, Portugal, September 7-11, 2015, Proceedings, Part III (Lecture Notes in Computer Science, Vol. 9286), Albert Bifet, Michael May, Bianca Zadrozny, Ricard Gavaldà, Dino Pedreschi, Francesco Bonchi, Jaime S. Cardoso, and Myra Spiliopoulou (Eds.). Springer, 308–311. https://doi.org/10.1007/978-3-319-23461-8_36
- An Introduction to Probabilistic Programming. CoRR abs/1809.10756 (2018). arXiv:1809.10756
- Central moment analysis for cost accumulators in probabilistic programs. In PLDI ’21: 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation, Virtual Event, Canada, June 20-25, 2021, Stephen N. Freund and Eran Yahav (Eds.). ACM, 559–573. https://doi.org/10.1145/3453483.3454062
- Quantitative analysis of assertion violations in probabilistic programs. In PLDI ’21: 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation, Virtual Event, Canada, June 20-25, 2021, Stephen N. Freund and Eran Yahav (Eds.). ACM, 1171–1186. https://doi.org/10.1145/3453483.3454102
- Peixin Wang. 2022. Tail-Bound Cost Analysis over Nondeterministic Probabilistic Programs. Journal of Shanghai Jiaotong University (Science) (2022), 1–11.
- Proving expected sensitivity of probabilistic programs with randomized variable-dependent termination time. Proc. ACM Program. Lang. 4, POPL (2020), 25:1–25:30. https://doi.org/10.1145/3371093
- Cost Analysis of Nondeterministic Probabilistic Programs. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation (Phoenix, AZ, USA) (PLDI 2019). Association for Computing Machinery, New York, NY, USA, 204–220. https://doi.org/10.1145/3314221.3314581
- David Williams. 1991. Probability with martingales. Cambridge university press.
- Exact Bayesian Inference on Discrete Models via Probability Generating Functions: A Probabilistic Programming Approach. In Advances in Neural Information Processing Systems 36: Annual Conference on Neural Information Processing Systems 2023, NeurIPS 2023, New Orleans, LA, USA, December 10 - 16, 2023, Alice Oh, Tristan Naumann, Amir Globerson, Kate Saenko, Moritz Hardt, and Sergey Levine (Eds.). http://papers.nips.cc/paper_files/paper/2023/hash/0747af6f877c0cb555fea595f01b0e83-Abstract-Conference.html