Density-Based Semantics for Reactive Probabilistic Programming

Guillaume Baudart, Louis Mandel, Christine TassonarXiv 2023

This paper, presented by researchers from ENS, IBM, and ISAE Supaero, tackles a fundamental theoretical hurdle in reactive probabilistic programming: the requirement for ordered equations. By introducing "density-based" semantics, the authors bring probabilistic languages closer to the flexibility of industry-standard synchronous tools like Lustre and Scade.

TL;DR

The authors propose two new "schedule agnostic" semantics for probabilistic synchronous languages, allowing developers to write unordered equations just like in standard dataflow languages. By shifting from measure-based to density-based interpretations, they enable easier formal reasoning and prove the correctness of an optimized inference transformation for models with constant parameters.

What Problem Does This Paper Address?

Synchronous dataflow languages are the backbone of critical embedded systems (think flight controllers or automotive sensors). Their power lies in being "schedule agnostic"—designers write sets of equations or block diagrams, and the compiler figures out the execution order.

Recently, these languages were extended with Bayesian reasoning (e.g., ProbZelus) to handle state-space models that estimate hidden variables from noisy observations. However, the formal math (semantics) for these probabilistic extensions only worked if the equations were manually pre-scheduled based on their data dependencies. This is a major limitation: it prevents common compiler optimizations, makes it difficult to prove that two programs are equivalent, and forces a rigid structure on the programmer that doesn't exist in deterministic synchronous languages.

Methods

The core innovation is moving away from interpreting programs as "streams of measures" (which involve complex, nested integrals that demand a specific order) to interpreting them as streams of un-normalized density functions.

  1. Externalizing Randomness: The authors treat random variables as deterministic functions of a "random seed" stream. This allows them to separate the logic of the program from the source of its randomness.
  2. Density-Based Co-iterative Semantics: This interprets programs as state machines. Because they use density functions, they can apply a fixpoint operator to solve unordered equations, just as one would in a standard deterministic language.
  3. Density-Based Relational Semantics: This is a higher-level view that manipulates infinite streams directly. It abstracts away the state machine details, providing a cleaner framework for proving that a program transformation (like a compiler pass) doesn't change the program's meaning.

The authors use these tools to define a static analysis and compilation pass for Assumed Parameter Filtering (APF). APF is an optimized inference algorithm designed to handle "constant parameters"—values that don't change over time but are refined by new data (like the constant drift speed of a boat).

![Fig.

  1. Tracking a moving boat with a marine radar in ProbZelus.](/figures/art_86753fa7697440a18a767bb3fc4e95fa)

Datasets

Not discussed in the paper. The research is theoretical and uses a simulated radar tracking example (illustrated in Figure 1 above) to validate the semantics and the APF transformation.

Key Insights and Ideas

  • The "Density Trick": By representing probabilistic expressions as results paired with a "score" (weight), the authors can defer the complex integration step to the very end of the inference process. This "unplugs" the dependency that previously forced a specific equation order.
  • Fixpoints for Probability: The paper proves that the same fixpoint techniques used for decades in deterministic synchronous languages are perfectly valid for probabilistic ones, provided you use the right mathematical representation (density functions in a Complete Partial Order).
  • Relational Reasoning: The relational semantics allows for "probabilistic coupling" proofs. If you can map the random seeds of one program to another while preserving their distribution, you can prove the programs are equivalent even if their internal structures differ significantly.

Key Results

  • Semantic Equivalence: The authors formally proved that their new density-based semantics is equivalent to the original measure-based semantics for programs that are already scheduled.
  • Correctness of APF: They used the relational semantics to provide the first formal proof of correctness for the APF program transformation.
  • Solving Particle Impoverishment: Qualitative results show that the APF transformation successfully prevents "particle impoverishment"—a common failure in standard Sequential Monte Carlo inference where the system loses all information about constant parameters over time.

Limitations and Future Work

  • First-Order Focus: The current semantics are designed for first-order languages. Extending this to higher-order probabilistic languages (which allow functions as first-class values) remains a significant challenge.
  • Reactive Bisimulation: While the relational semantics simplifies things, the authors note that adapting traditional probabilistic bisimulation to reactive state machines with explicit state is a complex task for future research.
  • Symbolic vs. APF: While APF is robust for arbitrary models, symbolic inference methods can be faster for specific types of models (conjugate priors). The authors suggest that finding a way to combine these approaches could be a fruitful direction.

Summary updated

BibTeX
@misc{baudart2023density,
  author = {Guillaume Baudart and Louis Mandel and Christine Tasson},
  title = {{Density-Based Semantics for Reactive Probabilistic Programming}},
  year = {2023},
  eprint = {2308.01676},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.01676},
}
Figure