Papers
Topics
Authors
Recent
Search
2000 character limit reached

Fixed-parameter tractable inference for discrete probabilistic programs, via string diagram algebraisation

Published 28 Apr 2026 in cs.DS | (2604.25321v1)

Abstract: Discrete probabilistic programs (DPPs) provide a highly expressive formalism for compactly defining arbitrary finite probabilistic models. This expressivity comes at a price: DPP inference is PSPACE-hard. In this work, we show that DPP inference only takes polynomial time for programs that are 'structurally simple'. More precisely, inference can be performed in polynomial time when the primal graph of each function appearing in the probabilistic program has bounded treewidth, and the inverse acceptance probability is at most exponential in the size of the probabilistic program. Existing algorithms do not achieve this performance guarantee. Our method relies on finding suitable decompositions, algebraisations, of the string diagrams underlying DPPs, employing existing algorithms for tree decompositions. This is independent of the probabilistic setting of DPPs and has direct applications to many problems, such as evaluating queries on relational databases and cybersecurity risk assessment via attack trees.

Summary

  • The paper introduces a fixed-parameter tractable algorithm for DPP inference by algebraising string diagrams under bounded treewidth conditions.
  • It employs a systematic pipeline involving tree and branch decompositions to transform complex, recursive probabilistic programs into efficiently computable matrix expressions.
  • The approach unifies classical FPT results and extends inference techniques to domains such as Bayesian networks, fault trees, and quantum simulations.

Fixed-Parameter Tractable Inference for Discrete Probabilistic Programs via String Diagram Algebraisation

Introduction and Context

The paper "Fixed-parameter tractable inference for discrete probabilistic programs, via string diagram algebraisation" (2604.25321) systematically investigates the computational complexity of inference in discrete probabilistic programs (DPPs), presenting a new algorithmic approach that achieves fixed-parameter tractability (FPT) in settings where prior methods do not. The key insight is that instances of DPP inference whose structural representation (via their primal graphs) has bounded treewidth admit efficient inference algorithms; these instances can be algebraically decomposed using string diagrams, enabling a reduction in complexity otherwise dominated by general PSPACE-hardness.

DPPs provide a uniform syntactic and semantic framework encompassing classic graphical models such as Bayesian networks and fault trees. These programs can compactly represent highly intricate dependencies, conditional probabilities, and recursion, but this expressivity fundamentally leads to intractable inference in the worst case. Thus, identifying meaningful structural restrictions that allow for tractable inference is a central concern in probabilistic programming and AI more broadly.

Technical Foundations

The central objects of study are string diagrams (in fact, dot diagrams à la Kissinger [kissinger2014finite]), which capture the compositional semantics of DPPs in the language of category theory, specifically as morphisms in a free strict hypergraph category.

Given a DPP, its syntax is represented as a hierarchical dot diagram—this allows for modular function definitions and nested structure, crucial for accurate modeling of recursive and compositional stochastic systems. The primal graph of a function (nodes = variables; edges = co-occurrence in assignment/input/output lists) is a key parameter controlling computational complexity.

Semantically, each DPP is interpreted in a matrix hypergraph category. For Boolean-valued programs, this is the category of substochastic matrices with objects of size 2n2^n, supporting composition (matrix multiplication) and tensor products (Kronecker products). The probability that a program returns true—subject to all observe\mathtt{observe} constraints being satisfied—reduces to evaluating a particular entry of the semantic matrix.

Main Contributions

Fixed-Parameter Tractability via Algebraisation

The paper introduces an algorithm to compute DPP inference in time O(2O(k)d2n3log3(pacc1))O(2^{O(k)}d^2 n^3 \log^3(p_\mathrm{acc}^{-1})), where:

  • kk is the maximum treewidth of the primal graphs across all functions of the program.
  • nn encodes program size (specifically, it is cubic in the number of lines/assignments).
  • dd is the number of output bits of precision.
  • paccp_\mathrm{acc} is the acceptance probability (the overall probability all observations are true).

This bound represents a significant improvement for the structurally restricted cases discussed. Notably, existing approaches such as those based on compilation to weighted model counting (e.g., Dice [holtzen2020scaling]) can exhibit exponential intermediate representations even for DPPs that are "tree-like."

Algorithmic Pipeline

The procedure is based on constructing a low-width algebraisation (hypergraph term representation) of the dot diagram underlying the DPP. This entails:

  1. Tree Decomposition: Compute a tree decomposition of the function's primal graph, using approximation algorithms that run in single-exponential time in kk and linear time in problem size (cf. [korhonen2023single]).
  2. Branch Decomposition and Hierarchicalization: Convert the tree decomposition to a branch decomposition, producing a hierarchical dot diagram with components of bounded size.
  3. Algebraisation: Recursively compose hypergraph terms for each component, using sequential and parallel composition (categorically: \circ for composition, \otimes for tensor product). The resulting terms, when interpreted as matrix expressions, ensure that all intermediate matrices have size bounded by observe\mathtt{observe}0.
  4. Computation of Semantics: Compile the algebraisation to an arithmetic circuit in the corresponding matrix category; this supports direct computation (matrix products and Kronecker products) of the output probability up to desired precision.

This approach is orthogonal to traditional variable elimination or message passing algorithms and generalizes from classical probabilistic graphical models to arbitrary DPPs employing Boolean recursion, function calls, and observations.

Broader Applications

The algebraisation formalism extends beyond DPPs to domains wherever string diagrams capture computation: Bayesian networks, fault trees, relational database conjunctive queries, attack trees for cybersecurity, and tensor networks in quantum simulation. Each of these can be seen as the evaluation of string diagrams in appropriate (semi)ring-valued hypergraph categories.

In particular, the result recovers and unifies a suite of classical FPT results:

  • Probabilistic inference in Bayesian networks is tractable given bounded treewidth [lauritzen1988local].
  • Fault tree reliability analysis with bounded structural complexity [lopuhaa2025fault].
  • Conjunctive query evaluation for bounded query graph treewidth [chekuri2000conjunctive, grohe2001evaluation].
  • Efficient contraction of tensor networks of bounded treewidth/width [markov2008simulating].

This categorical abstraction also highlights when results diverge from the classical approaches: for instance, the algorithm here works via decompositions that need not correspond to the moralization assumptions used in junction tree algorithms.

Numerical and Complexity Guarantees

The paper provides explicit, algorithmically relevant complexity bounds, not just qualitative statements. Notably, all steps in the pipeline are analyzed for runtime, DAG size of algebraisation, and width, yielding confidence that practical implementations for bounded-observe\mathtt{observe}1 instances can achieve strong performance.

A significant technical aspect is the careful treatment of error propagation in arithmetic circuits: output probabilities are guaranteed to a prescribed absolute error by ensuring sufficient bits of precision in all internal computations, taking into account the possibly exponentially small acceptance probabilities (thus the observe\mathtt{observe}2 term).

Discussion of Limitations and Open Questions

Despite the theoretical advances, the paper notes that the practical efficiency of the method remains to be determined. In particular, real-world DPPs may exhibit properties not reflected in observe\mathtt{observe}3 alone (e.g., non-local dependencies, function inlining issues, rare events leading to vanishing observe\mathtt{observe}4). The algebraic nature of the approach, however, may facilitate future enhancements via program optimization, term rewriting, and the adoption of sparse or structure-preserving matrix representations (e.g., decision diagrams for quantum simulation [wille2022decision]).

A further open question concerns the extension or improvement of the notion of "algebraisation width," and connections to recent work on monoidal width in categorical structures [di2023monoidal], for optimizing the representational complexity of string diagrams.

Conclusion

The paper establishes that inference for discrete probabilistic programs is fixed-parameter tractable with respect to the treewidth of their structural representation and the inverse acceptance probability, via an explicit and general algorithm leveraging the algebraic manipulation of string diagrams. This approach achieves performance guarantees beyond previous methods, especially for deeply nested or recursively defined programs.

By developing a general theory of algebraisation for dot diagrams—applicable across multiple domains—the work unifies fixed-parameter tractability results for probabilistic inference, database query evaluation, cybersecurity metrics, and beyond. The categorical and compositional perspective opens new directions for algorithmic reasoning and optimization in probabilistic programming, formal verification, and AI systems that model complex stochastic processes.


References:

  • (2604.25321) "Fixed-parameter tractable inference for discrete probabilistic programs, via string diagram algebraisation"
  • [holtzen2020scaling] "Scaling exact inference for discrete probabilistic programs"
  • [lauritzen1988local] "Local computations with probabilities on graphical structures and their application to expert systems"
  • [korhonen2023single] "A single-exponential time 2-approximation algorithm for treewidth"
  • [lopuhaa2025fault] "Fault Tree Reliability Analysis via Squarefree Polynomials: Mathematical and Experimental Analysis"
  • [chekuri2000conjunctive], [grohe2001evaluation] Conjunctive query evaluation
  • [markov2008simulating] "Simulating quantum computation by contracting tensor networks"
  • [wille2022decision] "Decision diagrams for quantum computing"
  • [di2023monoidal] "Monoidal width"

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.