Papers
Topics
Authors
Recent
2000 character limit reached

Stochastic Regular Expressions Overview

Updated 29 October 2025
  • Stochastic regular expressions are a framework that defines probability distributions over strings using convex combinations, concatenation, and discounted repetition.
  • They employ techniques like the discounted Kleene star and equivalence to weighted automata to ensure proper normalization and convergence of modeled distributions.
  • Their compositional properties facilitate efficient statistical inference, approximation, and generative modeling in fields such as natural language processing and bioinformatics.

Stochastic regular expressions (SREs) are algebraic specifications that generate probability distributions over strings through composable probabilistic operations. SREs generalize classical regular expressions by incorporating probabilistic mechanisms, supporting both the modeling and the synthesis of rational stochastic languages—probability distributions over Σ\Sigma^* defined by weighted automata with specific normalization and convergence properties. SREs serve as both a compositional syntax and a semantic foundation for specifying stochastic generative models over strings, with well-defined relationships to weighted automata theory, algebraic closure properties, and statistical inference.

1. Formal Definition and Syntax

An SRE is an inductively defined combinatorial grammar that expresses a probability distribution over strings via the following operators: r::=δσαr1+(1α)r2r1r2rαr ::= \delta_\sigma \mid \alpha r_1 + (1-\alpha) r_2 \mid r_1 \cdot r_2 \mid r_\alpha^* where:

  • δσ\delta_\sigma denotes the Dirac (point mass) distribution on σΣ\sigma \in \Sigma, i.e., δσ(w)=1\delta_\sigma(w) = 1 if w=σw = \sigma, else 0.
  • α(0,1)\alpha \in (0, 1) is a real-valued parameter controlling mixture or repetition probabilities.
  • ++ is convex combination: probabilistic choice between two sub-distributions.
  • \cdot is the Cauchy product: probabilistic concatenation defined via

(f1f2)(w)=w=uvf1(u)f2(v)(f_1 \cdot f_2)(w) = \sum_{w=uv} f_1(u) f_2(v)

  • rαr^*_\alpha is the discounted Kleene star, a geometrically-weighted sum over repeated concatenations:

(f1)α(w)=k=1w1,,wkΣ+ w=w1wkα(1α)k1i=1kf1(wi)(f_1)^*_\alpha(w) = \sum_{k=1}^\infty \sum_{\substack{w_1,\ldots,w_k \in \Sigma^+ \ w = w_1 \cdots w_k}} \alpha (1-\alpha)^{k-1} \prod_{i=1}^k f_1(w_i)

Each SRE rr defines fr:Σ[0,1]f_r: \Sigma^* \rightarrow [0,1] with wΣfr(w)=1\sum_{w \in \Sigma^*} f_r(w) = 1, guaranteeing that all SREs represent proper probability distributions under the specified operations (Agarwal et al., 22 Oct 2025).

2. Expressive Power and Equivalence to Rational Stochastic Languages

The class S\mathcal{S} of languages described by SREs is exactly the class of rational stochastic languages. These are probability distributions realized by finite weighted automata (WA) over non-negative reals whose transition matrix has spectral radius <1<1. This captures the set of all distributions that can be generated by finite-state probabilistic mechanisms augmented with appropriate normalization.

There is a full equivalence between SREs and locally sub-stochastic weighted automata:

  • Every SRE can be implemented as a WA such that, for each state, the sum of outgoing transition weights is at most 1.
  • Conversely, for any locally sub-stochastic WA, there is a state elimination algorithm that constructs an equivalent SRE denoting the same distribution [(Agarwal et al., 22 Oct 2025), Lemma automata-to-SRE].

The class S\mathcal{S} is closed under convex combination, Cauchy product, and discounted Kleene star. This supplies a compositional and recursion-theoretic foundation for stochastic models over strings, directly paralleling the role of regular expressions and unweighted automata for regular languages.

3. Algebraic Kleene–Schützenberger Characterization

The stochastic analog of the classical Kleene theorem is established: stochastic regular languages (the SRE-definable languages) form the smallest class containing all Dirac distributions and closed under convex combination, Cauchy product, and discounted Kleene star. Formally:

The class of stochastic regular languages is the smallest class of quantitative languages over Σ\Sigma that contains all Dirac distributions δσ\delta_\sigma, and is closed under convex combinations, Cauchy products, and discounted Kleene star [(Agarwal et al., 22 Oct 2025), Theorem kleene-characterisation].

This algebraic closure property ensures that stochastic generative models over strings can be built modularly, with each operation corresponding to a well-defined probabilistic interpretation.

4. Closure Properties and Local Sub-stochasticity

The class of SREs exhibits the following robust closure properties:

  • Convex Combination: Any finite mixture of SREs is an SRE.
  • Cauchy Product: Sequential probabilistic composition (concatenation) of SREs is closed.
  • Discounted Kleene Star: The operation rαr^*_\alpha geometrically weights finite repetitions, ensuring convergence and normalization of the overall distribution.

A central consequence is that every rational stochastic language admits a representation by a locally sub-stochastic automaton, such that for every state, outgoing probabilities sum to at most 1. Perron–Frobenius normalization delivers this construction, diagonalizing transition matrices and yielding automata that reflect local syntactic constraints [(Agarwal et al., 22 Oct 2025), Theorem local-substochastic]. This property connects local automata structure to global stochasticity guarantees, facilitating both verification and algorithmic synthesis.

Theorem: f is a rational stochastic language    There exists a locally sub-stochastic WA realizing f.\text{Theorem: } f \text{ is a rational stochastic language} \iff \text{There exists a locally sub-stochastic WA realizing } f.

5. Sampling, Approximation, and Statistical Inference

SREs admit probabilistic generative semantics, enabling efficient recursive sampling algorithms that follow their algebraic syntax. Sampling from a distribution defined by an SRE proceeds via:

  • Sampling according to mixture (++) by tossing an α\alpha-coin.
  • For Cauchy product (\cdot), independently sampling two substrings and concatenating.
  • For discounted Kleene star (rαr^*_\alpha), sampling a geometric number of repeats, then concatenating i.i.d. samples from rr.

Any stochastic language can be approximated arbitrarily well (in L1L_1 total variation) by SREs with finite support distributions. This density property is crucial for statistical applications, providing a flexible approximation toolkit for empirical distributions [(Agarwal et al., 22 Oct 2025), Theorem universal-sup-approx].

Furthermore, the compositional, local structure of SREs allows for provably efficient distribution testing algorithms—specifically, identity testing between an unknown distribution and a reference SRE—with computational and sample complexity analogous to finite-alphabet settings.

6. Table of Core Properties

Aspect Stochastic Regular Expressions / Rational Stochastic Languages
Formal representation Locally sub-stochastic weighted automata / stochastic regular expressions
Expressive power All functions Σ[0,1]\Sigma^* \to [0,1] realizable by finite WA with spectral radius < 1
Algebraic closure Convex combination, Cauchy product, discounted Kleene star
Locality Outgoing weights per state sum 1\leq 1 (after normalization)
Equivalence SREs \Longleftrightarrow locally sub-stochastic WA
Sampling/generative Supports recursive sampling and efficient probability estimation
Approximation Dense in all string distributions under L1L_1 norm
Distribution testing Tractable with standard (truncated) methods

7. Applications and Theoretical Impact

SREs provide a rigorous algebraic foundation for probabilistic modeling over string spaces. This framework is directly applicable to:

  • Probabilistic modeling in natural language processing and bioinformatics, where complex, compositional string distributions arise.
  • Approximate reasoning and density estimation, with SREs providing universal approximators for string distributions.
  • Efficient generative modeling: their recursive definition enables scalable sampling and marginalization.
  • Formal statistical testing, as their syntactic form supports local checks and enables efficient hypothesis testing.

A plausible implication is that SREs can serve as the specification language for probabilistic program synthesis and verification tools, owing to their exact correspondence with weighted automata and closure under expressive and tractable algebraic operations.

8. Example: Discounted Kleene Star

The discounted star rαr^*_\alpha encodes geometric repetition of a primitive stochastic language rr: (r)α(w)=k=1w1,,wkΣ+ w=w1wkα(1α)k1i=1kr(wi)(r)^*_\alpha(w) = \sum_{k=1}^\infty \sum_{\substack{w_1, \dots, w_k \in \Sigma^+ \ w = w_1 \cdots w_k}} \alpha (1 - \alpha)^{k-1} \prod_{i=1}^k r(w_i) Here, α\alpha is the stopping probability for iteration, so the expected number of repetitions is (1α)/α(1-\alpha)/\alpha (Agarwal et al., 22 Oct 2025). This probabilistic generalization of the classical Kleene star ensures the resulting distribution over strings remains normalized and proper (i.e., sums to 1), addressing divergence issues in the unweighted infinite repetition case.


SREs offer a compositional, algebraic, and automata-theoretic framework matching the full class of rational stochastic languages. They underpin efficient algorithms for probabilistic verification, inference, and generation, and their theoretical properties yield strong guarantees for modeling, approximation, and analysis over string domains.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)
Slide Deck Streamline Icon: https://streamlinehq.com

Whiteboard

Forward Email Streamline Icon: https://streamlinehq.com

Follow Topic

Get notified by email when new papers are published related to Stochastic Regular Expressions.