arXiv:2609.02446cs.LOSep 2026

Manuscript Offprint

arXiv:2609.02446

Polynomial Invariants for Probabilistic Transition Systems with Unbounded Support

Anne Schreuder, Lorenz Winkler, Laura Kovács, C. -H. Luke Ong

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

We study the synthesis of polynomial invariants for probabilistic transition systems (PTS) based on martingale theory. We present tractable methods to verify that such polynomials are indeed invariants, in the sense that their expected value upon termination is the same as their value at the start of the computation. We do this by applying the Optional Stopping Theorem (OST) in the form of a specific precondition. This precondition requires the existence of an integrable dominating function for the martingale expression, which implies uniform integrability; we refer to this condition as dui. For linear PTS we simplify the dui property to proving finiteness of the expected value of an expression depending on the update matrix, the degree of the martingale expression, and the stopping time. Specifically, if all random samples have finite moments and we can verify a moment bound on the runtime of a linear loop, then we can automatically synthesise polynomial loop invariants that satisfy the OST. Notably, dui allows for the sampled distributions to have unbounded support, which is a novel contribution to the field. We implemented and evaluated our method to symbolically compute upper and lower bounds for moments of program variables upon termination.

1 Introduction

Probabilistic programs are computer programs that make random choices. Their increasingly widespread use in many areas of computer science — ranging across machine learning, network protocols and robotics — has led to a recent surge of interest in the semantics of probabilistic programs and methods for reasoning about them. In this paper we present a theoretical result for invariants of probabilistic programs that sample from distributions with unbounded support. We then show the applicability of our result by synthesising polynomial invariants for a restricted class of loops and use them to automatically derive symbolic bounds for the expected value of monomials after the loop has terminated.

Problem setting. Following [2, 1, 15, 11, 21, 27, 6], we explore methods that automatically synthesise expressions over the program variables whose expectation is invariant over the course of the computation. Mathematically, the invariants we construct are martingales. Elegant and effective, martingales are commonplace in the static analysis of probabilistic programs [5, 16, 8, 23, 30, 1, 7, 25, 33, 4, 34, 19, 10].

We restrict ourselves to invariants of probabilistic programs that have the same expected value before and after the program has run. In general, the runtime of a probabilistic program is not a concrete number but a probability distribution. Consequently, the expectation of a step-wise invariant at the point of termination (qua stopping time) may differ from its expectation after any fixed number of steps (see Example 1). For non-probabilistic programs this effect does not exist. First observed in betting strategies, this phenomenon has been analysed extensively

Schreuder, Winkler, Kovács, Ong

in probability theory, leading to Doob's celebrated Optional Stopping Theorem (OST) e.g. [12, Theorem 5.3.1]. This theorem yields preconditions for the expectation of a martingale taken at a stopping time to coincide with the expectation taken at the beginning.

The Optional Stopping Theorem (OST) has recently been successfully applied to the static analysis of probabilistic programs [38, 37, 4, 15, 41, 9]. However the phenomenon of the necessity of an “extra step”, that is verifying a precondition of the OST, had already been observed in the analysis of nested loops [32, 23]. When reasoning about such probabilistic programs, it is common to use inductive arguments for the inner loop. For reasons similar to those described earlier, it is necessary to impose appropriate OST-type preconditions on the inner-loop invariants, in order to formulate sound proof rules. These methods have successfully been applied in [32, 15, 11, 21, 19]. In particular, for nested loop analysis it is important to handle random updates with unbounded support. Otherwise, only loops that are entered at most NN times can be analysed. Although our work mainly restricts to single loop programs, our approach does not require bounds on the support of the sampled distributions.

Our approach. We work with probabilistic transition systems (PTS) [5, 6, 7, 11], a general model of probabilistic imperative programs. Any standard imperative program with random samples and (nested) loops can be expressed as a PTS. An example of such a program is given in Figure 1. In particular, we allow our programs to manipulate values in the field R\mathbb{R} of real numbers and to sample from continuous and unbounded probability distributions. Figure 1, for instance, samples from a continuous uniform and a normal distribution.

We first present a precondition of the OST (Theorem 1), which we call dui. The dui precondition requires the existence of an integrable dominating function (for the martingale expressions) which implies the martingale is uniformly

x:=x0y:=y0z:=z0k:=0while x≥0 dok:=k+1u∼Uniform(−1,0)x:=x+un1∼Normal(1,2)y:=y+n1+un2∼Normal(−2,4)z:=z+y+n2end while\begin{aligned} x := x_0 \\ y := y_0 \\ z := z_0 \\ k := 0 \\ \text{while } x \geq 0 \text{ do} \\ k := k + 1 \\ u \sim \text{Uniform}(-1, 0) \\ x := x + u \\ n_1 \sim \text{Normal}(1, 2) \\ y := y + n_1 + u \\ n_2 \sim \text{Normal}(-2, 4) \\ z := z + y + n_2 \\ \text{end while} \end{aligned}

Figure 1: Linear PTS with updates over distributions with unbounded support.

integrable. A key advantage of dui is its generality and its flexibility. It does not impose a constant bound on the stopping time (runtime), the program variables, or their updates. As such, our work differs from approaches requiring a constant bound on an invariant [23, 15, 11, 21], which is a special case of the dui precondition, or bounded updates [37, 38, 41].

While the dui precondition is rather abstract, it is more concrete than the condition of uniform integrability which it implies. Hence, it can be used to derive more tractable sufficient conditions for invariants satisfying the OST. We demonstrate this by deriving a sufficient condition for polynomial invariants (expressible as a martingale) of simple linear programs consisting of a single loop to satisfy the OST (Theorem 3). This novel condition is twofold: First, the distributions over which we sample must be identically distributed in every iteration, and all moments of those distributions must exist. This is a strict improvement on the state-of-the-art which requires all sample distributions to be bounded [37, 38, 41]. Second, the runtime must satisfy an expectation bound that depends on the degree of the desired polynomial invariant, the structure of the update matrix, and whether variables from distributions with unbounded support affect the runtime. We prove this theorem with the dui precondition. Moreover, our method can deduce upper and lower bounds on the expected values of higher moments of the

Schreuder, Winkler, Kovács, Ong

program variables and of the runtime¹ at the end of the computation — potentially improving the initial bound on the runtime; bounds upon the moments of Figure 1 are listed in Table 1.

Our contributions. We bring the following main contributions².

  • We focus on a very flexible precondition for the OST, which requires the existence of an integrable dominating function for the martingale expression implying that the martingale is uniformly integrable – we refer to this condition as dui (Section 3). To the best of our knowledge, our dui condition is new in the study of probabilistic programs and has the advantage that it does not impose any restrictions on the stopping time a priori³.

  • We present a sufficient condition for the application of the OST for polynomial martingales of simple linear loops (Section 4). Checking the precondition then simplifies to proving finiteness of moments of the stopping time (Theorem 3).

  • Taking the number of finite moments of the stopping time as an input, we construct martingale expressions, which satisfy the OST based on the dui condition (Section 4.1). Those martingales can then be used to symbolically compute upper and lower bounds for the moments of program variables upon termination. Notably this includes variables having negative, unbounded increments that depend on the program state.

  • While we make no claims about completeness of our method and still require (potentially manual) proofs of finiteness of stopping times in advance, we give examples where our method is applicable (Section 5). We implemented our work on top of the Polar analyser [35] and evaluated it on programs with distributions of unbounded support (Table 1). To the best of our knowledge, existing approaches for cost analysis or bound computation in probabilistic programs cannot handle our examples with unbounded support. Our implementation and instructions for reproducing our results are publicly available⁴.

References (41)