Skip to main content
QUICK REVIEW

[Paper Review] A Dynamic Programming Algorithm for Inference in Recursive Probabilistic Programs

Andreas Stuhlmüller, Noah D. Goodman|arXiv (Cornell University)|Jun 15, 2012
Bayesian Modeling and Causal InferenceComputer Science12 references23 citations
TL;DR

This paper presents a dynamic programming algorithm that enables exact inference in recursive probabilistic programs by compiling them into factored sum-product networks (FSPNs), which explicitly model dependencies—including cyclic ones—between sub-distributions. The algorithm solves these via fixed-point iteration over topologically ordered strongly connected components, allowing efficient marginalization even in evidence-infinite cases where prior methods fail.

ABSTRACT

We describe a dynamic programming algorithm for computing the marginal distribution of discrete probabilistic programs. This algorithm takes a functional interpreter for an arbitrary probabilistic programming language and turns it into an efficient marginalizer. Because direct caching of sub-distributions is impossible in the presence of recursion, we build a graph of dependencies between sub-distributions. This factored sum-product network makes (potentially cyclic) dependencies between subproblems explicit, and corresponds to a system of equations for the marginal distribution. We solve these equations by fixed-point iteration in topological order. We illustrate this algorithm on examples used in teaching probabilistic models, computational cognitive science research, and game theory.

Motivation & Objective

  • Address the challenge of exact inference in recursive probabilistic programs where naive enumeration is intractable due to nested conditioning and self-recursion.
  • Overcome the limitation of existing dynamic programming methods that require acyclic computation graphs and cannot handle evidence-infinite computations.
  • Enable efficient marginalization of probabilistic programs by exploiting shared substructures across recursive calls, even when sub-distributions depend on each other cyclically.
  • Provide a generic solution that works with any functional interpreter for discrete probabilistic programming languages, without requiring model-specific inference algorithms.
  • Support practical applications in teaching, cognitive science, and game theory by enabling exact inference on small but structurally complex models.

Proposed method

  • Compile a probabilistic program into a factored sum-product network (FSPN), which reifies dependencies between sub-distributions, including recursive ones.
  • Construct a dependency graph of sub-distributions to represent the system of equations governing the marginal distribution.
  • Cluster vertices in the dependency graph into strongly connected components (SCCs) to handle cyclic dependencies.
  • Apply fixed-point iteration to solve the system of equations within each SCC, ensuring convergence to the correct marginal distribution.
  • Use topological ordering of SCCs to process components in a way that respects dependency order during fixed-point iteration.
  • Leverage the interpreter's recursive structure to automatically expose reusable subcomputations, enabling efficient marginalization without hardcoding inference logic.

Experimental results

Research questions

  • RQ1Can exact inference be efficiently performed in recursive probabilistic programs that involve stochastic self-recursion and evidence-infinite computation?
  • RQ2How can dynamic programming be generalized to handle cyclic dependencies between sub-distributions in probabilistic programs?
  • RQ3To what extent can a generic inference algorithm be built from a functional interpreter without requiring model-specific optimization?
  • RQ4What is the performance gain of this approach over rejection sampling and MCMC on small, complex models with nested conditioning?
  • RQ5Can this method handle classic problems in cognitive science and game theory, such as the blue-eyed islanders puzzle, where exact inference is otherwise intractable?

Key findings

  • The algorithm successfully computes exact marginal distributions for recursive probabilistic programs, including those with evidence-infinite computation, which previous dynamic programming methods like IBAL and PRISM cannot handle.
  • The method enables exact inference on the blue-eyed islanders puzzle for population size 4, where MCMC and rejection sampling fail due to exponential rejection rates.
  • Fixed-point iteration over topologically ordered strongly connected components converges to the correct marginal distribution, even in the presence of cyclic dependencies between sub-distributions.
  • The algorithm outperforms naive enumeration and rejection sampling by sharing subcomputations and avoiding redundant path exploration.
  • The approach generalizes sum-product networks to handle recursive and cyclic dependencies, extending their applicability to a broader class of probabilistic programs.
  • Empirical evaluation shows that the algorithm scales to models with small but complex structure, making it suitable for teaching and research in cognitive science and game theory.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.