SHSLib

A Lean 4 / Mathlib formalization of Stochastic Hybrid Systems (SHS) — discrete-mode, continuous-state processes that mix ordinary differential flow with random jumps (mode switches and state resets), as introduced by Hespanha (2005) and built on Davis's theory of Piecewise-Deterministic Markov Processes (PDMPs).

Alongside the Hespanha/Davis core, the library formalizes three further treatments of the same circle of ideas: Bect's (2010) unifying Fokker–Planck–Kolmogorov equation for general stochastic hybrid systems, Bujorianu & Lygeros's (2006) general theory of stochastic hybrid systems, and the textbook derivations of the differential Chapman–Kolmogorov equation from Gardiner and from Ullah & Wolkenhauer.

A further layer, SHSLib.Category, relates these frameworks through one category of generator presentations. Each framework enters as objects and morphisms, and Dynkin's formula, the forward equation and the martingale problem transfer along every morphism. Composing morphisms gives cross-framework results, for example Bect's generalized Dynkin formula for a Bujorianu–Lygeros system that satisfies Dynkin's formula.

The extended generator

An SHS evolves in mode and continuous state , flowing according to between jumps, and jumping to mode / state with intensity , for .

For a test function , the extended generator is defined as

The first two terms capture drift along the deterministic flow; the sum captures the expected jump contribution across all transition types.

Differential form. Along a sample path of the SHS,

Integral form. Equivalently,

These identities (SHS.eq10_differential_generator_formula and SHS.theorem1_generator_formula in SHSLib/Core/Generator.lean) are the basis for deriving moment ODEs and the Fokker–Planck equation for the state density.

Forward equations

Three further layers formalize the forward (density- or measure-level) evolution. They are stated here exactly as they appear in Lean, with the declaration that proves each one.

The differential Chapman–Kolmogorov equation (Gardiner §3.4)

For a Markov process on with drift , diffusion and jump rate , the transition density satisfies

This is Gardiner (3.4.22), proved as Gardiner.differentialCK (right-hand side Gardiner.ckRHS) from the weak form (3.4.16) Gardiner.differentialCK_weak by integration by parts (3.4.19). Dropping the jump term gives the Fokker–Planck equation (3.5.6), dropping the second-order term gives the Master equation (3.5.2), and keeping only the drift gives Liouville's equation (3.5.13) — all three in Gardiner.Special. The third and all higher conditional moments are proved to vanish (Gardiner.CondThird.eq_zero, Gardiner.CondHigher.eq_zero), which is what makes the truncation legitimate rather than an approximation.

The same equation, derived without integration by parts (Ullah §8.2)

Ullah.differentialCK reaches the identical right-hand side — Ullah.fpTerm for the drift/diffusion part and Ullah.jumpTerm for the jump part — by splitting the gain–loss flux into a near region and a far region and taking the two limits (8.11), (8.12) separately.

The two derivations are formally connected, not merely parallel: Ullah.condDrift_iff_mom and Ullah.condDiffusion_iff_mom prove that that text's conditions (8.8), (8.9) are Gardiner's conditions (ii), (iii).

The generalized FPK equation for hybrid systems (Bect 2010)

On a hybrid state space the density may not exist, so the equation is stated for the law as a measure. Writing , a family is a solution when is differentiable with

where is the generator, the reset kernel and the mean jump intensity. This is Definition 7 / Eq. (14), GSHS.FPKData.IsWeakFPKSolution; its integrated form is the generalized Dynkin formula (13), GSHS.FPKData.WeakDynkin:

For a diffusion in each mode with drift and noise fields , the generator is Eq. (16), GSHS.generatorL:

The point of the formulation is that a single equation covers diffusions, Markov chains, spontaneous jumps and forced jumps at the boundary, with the classical density-level equations recovered under extra regularity. Bect's Example 18 specializes it back to the Hespanha SHS above, recovering Eq. (33) (SHSLib/FPK/HespanhaFPK.lean).

A note on faithfulness

Formalizing a paper sometimes shows a stated result to be false as literally written. Where that happened, this library keeps the original statement in a comment, proves a counterexample certificate next to it, and then proves a corrected form. Hespanha's Eq. (35) (SHS.lemma1_linear_growth_bound_false, with the corrected ..._varying_rate in Core.GronwallGrowthBound) and three PDMP results in Foundations.DavisCh2 are handled this way. Nothing is quietly weakened.

Structure

404 modules, entirely free of sorry — every theorem depends only on propext, Classical.choice and Quot.sound. There are no axiom declarations anywhere in the library.

Module groupModulesContents
SHSLib.Core.Basic, .Generator, .GeneratorDefs3SHS structure and flow; extended generator , moment evolution, Fokker–Planck
SHSLib.Core.GronwallGrowthBound1Grönwall's inequality with a time-varying rate; sample-path growth bounds for flow segments and whole hybrid paths (Hespanha Lemma 1 / Eq. 35)
SHSLib.Core.Davis{Bridge,Construction,Martingale}3SHS ↦ Davis PDP; the PDP generator equals the extended generator; Hespanha Theorem 2
SHSLib.Core.Davis* — reset compensation55Compensator of the reset part: counter augmentation, conditional holding-time and channel laws, reset-occupation densities, occupation centering
SHSLib.Core.Davis* — process extensions75Elapsed-occupation martingales and filtrations, marked-jump processes, two-channel characteristics, age/ramped/refractory/Poisson clock models
SHSLib.Core.{Flow,GlobalFlow,Envelope,LinearGrowth,ExplicitFlows}*, .DavisModeBlind, .DavisTransitionFree13Global existence and uniqueness of the flow under Lipschitz and under locally-Lipschitz-plus-linear-growth drifts; flow regularity and dependence on the initial state; growth envelopes and their sharpness; the deterministic Dynkin identity along the flow; Theorem 1 for transition-free and mode-blind systems
SHSLib.Foundations.DavisCh11Measure theory, probability, martingales, Dynkin
SHSLib.Foundations.DavisCh2, .DavisCh2StrongMarkov, .DavisCh2ProcessLinks3PDMP theory: ODE flows, Grönwall, inverse-transform sampling, the PDP semigroup, the strong Markov property, and process-level links
SHSLib.Foundations.DavisCh2Finite*3Finite-state renewal kernel, semigroup laws, strong Markov property
SHSLib.Foundations.{Stirling,Beta,Digamma,Trigamma,Tetragamma,Polygamma,ClopperPearson,UniformOrderStatistic}*51Special-functions groundwork: Stirling/Binet asymptotics, the Beta distribution and its quantiles, the polygamma family, exact binomial intervals, uniform order statistics
SHSLib.Foundations.BetaOrderStatistic*6Moments of order statistics of a Beta sample: reflected and direct fractional moments, mean/variance of the -st order statistic, Chebyshev concentration, the integer-exponent product form, and variance bounds from a Lipschitz parent quantile
SHSLib.FPK.*37Bect (2010): the generalized Fokker–Planck–Kolmogorov equation for general stochastic hybrid systems — hybrid state space, Lévy systems, the generalized Dynkin formula, probability current, boundary conditions, densities, and worked solutions (two-state chain, sawtooth); one-dimensional Itô diffusions as jump-free FPK data, satisfying the generalized Dynkin formula (13)
SHSLib.Gardiner (Ch. 3)8Gardiner, Handbook of Stochastic Methods §3.4–3.6: derivation of the differential Chapman–Kolmogorov equation in weak and strong form, and its Master / Fokker–Planck / Liouville special cases
SHSLib.Gardiner.Approx.*15Gardiner Ch. 6–7: small-noise expansion, Kramers–Moyal expansion with truncation error, van Kampen's system-size expansion and the linear noise approximation with explicit O(Ω^{-1/2}) generator bounds, the chemical Fokker–Planck equation and Lyapunov covariance
SHSLib.Gardiner.Adiabatic.*12Gardiner §6.4–6.6: adiabatic elimination — Kramers → Smoluchowski, the white-noise limit of coloured noise, chemical intermediates, Haken's model, with explicit error bounds
SHSLib.Gardiner.Escape.*12Gardiner §5.2.7–5.2.8, §7.4, Ch. 9: mean first-passage times, exit and splitting probabilities, a quantitative Laplace method, and the Kramers escape rate as a genuine limit `
SHSLib.Gardiner.SDE.*13Gardiner §6.2 and Ch. 10 §10.1–10.5: pathwise small-noise expansion and Euler convergence for additive noise; Euler, Milstein and semi-implicit schemes with exact moments and O(τ) weak error on linear SDEs; stability and consistency
SHSLib.Gardiner.Ito.*69Gardiner Ch. 4: a standard Wiener process (via the brownian-motion dependency) with its natural filtration; quadratic variation; the Itô integral for simple, deterministic (Wiener) and general L² nonanticipating integrands with isometry and martingale property; Itô's formula (4.3.14); the Ornstein–Uhlenbeck process and geometric Brownian motion; stochastic differential equations under Gardiner's Lipschitz and growth conditions (4.3.10)–(4.3.11) — existence and uniqueness on every horizon, moment bounds, Doob's L² inequality, Euler–Maruyama strong order ½ (10.1.26); the generator, Dynkin's formula, the martingale problem and the Fokker–Planck equation (4.3.18)–(4.3.20) for SDE solutions; the law of the linearised process and the multiple integrals of Ch. 10
SHSLib.Ullah.*5Ullah & Wolkenhauer, Stochastic Approaches for Systems Biology §8.2: the same dCKE derived by near/far region splitting, without integration by parts
SHSLib.Bujorianu2006.*8Bujorianu & Lygeros (2006): general stochastic hybrid systems — hybrid state space, Markov strings, jump measures, resolvent and -excessive functions, terminal times, the strong generator and Dynkin's formula
SHSLib.Category.*11Cross-framework organization: the category SHSCat.GenPres of generator presentations (state space, test functions, evaluation, generator) and intertwiners. Dynkin's formula, the forward equation and the martingale problem transfer along every morphism and are invariant under isomorphism. Transition semigroups and Davis PDPs map in through functors; Hespanha's SHS and the Bujorianu–Lygeros GSHS are each isomorphic to Bect's Lévy-system form; a compatible Davis PDP maps to its SHS; Gardiner/Ullah kernel semigroups map to the dCKE presentation. Composite arrows turn Dynkin's formula for a GSHS or a compatible Davis PDP into Bect's generalized Dynkin formula (13). One-dimensional Itô diffusions, with the martingale problem and Dynkin's formula up to a horizon

Building

lake build

Requires Lean 4 and Mathlib (pinned via lakefile.toml).

The Itô layer also depends on brownian-motion (Degenne, Ledvinka, Marion, Pfaffelhuber; Apache-2.0), pinned at commit 4fa8fc01, the commit that uses the same Lean v4.28.0 and Mathlib as this library. SHSLib imports only its module BrownianMotion.Gaussian.BrownianMotion, which is sorry-free; other modules of that package are not imported.

Documentation

  • Website: https://cavargar.github.io/SHSLib/ — overview, key results and how the layers fit together.
  • API documentation: https://cavargar.github.io/SHSLib/docs/ — every module, definition and theorem of SHSLib (and of the modules it uses from brownian-motion and kolmogorov_extension4), with search and source links. It is generated by doc-gen4, the tool behind the Mathlib documentation, and rebuilt on every push to main. Names from Mathlib, Batteries and Lean link to the Mathlib documentation, which follows the current Mathlib rather than the version SHSLib pins. To preview it locally, run scripts/preview_docs.sh and open http://localhost:8000.
  • Module notes: wiki/index.md — what each module proves, its key theorems and definitions, and remaining gaps.

References

  • M. H. A. Davis, Markov Models and Optimization, Chapman & Hall, 1993.
  • J. P. Hespanha, "A model for stochastic hybrid systems with application to communication networks," Nonlinear Analysis, 2005.
  • J. Bect, "A unifying formulation of the Fokker–Planck–Kolmogorov equation for general stochastic hybrid systems," Nonlinear Analysis: Hybrid Systems 4 (2010) 357–370.
  • C. W. Gardiner, Handbook of Stochastic Methods for Physics, Chemistry and the Natural Sciences, Springer.
  • R. Degenne, D. Ledvinka, E. Marion, P. Pfaffelhuber, Formalization of Brownian motion in Lean, arXiv:2511.20118 (2025); brownian-motion.
  • M. Ullah and O. Wolkenhauer, Stochastic Approaches for Systems Biology, Springer, 2011.
  • M. L. Bujorianu and J. Lygeros, "Toward a general theory of stochastic hybrid systems," in Stochastic Hybrid Systems, LNCIS 337, Springer, 2006.

License

MIT — see LICENSE.