🤖 AI Summary
Verifying expected costs of probabilistic programs is highly challenging due to the need to simultaneously reason about probability distributions, recursive stochastic behaviors, and expectations, with existing approaches relying heavily on manual proofs. This work proposes a novel probabilistic monad that integrates refinement types with SMT-based automated reasoning, enabling, for the first time in Liquid Haskell, built-in support for jointly tracking probability mass, expectations, and expected costs. The approach allows compositional derivation of quantitative properties directly from program structure. It successfully verifies classic randomized algorithms—including meldable heaps, randomized quicksort, and splay trees—striking an effective balance between automation and interactive verification.
📝 Abstract
Probabilistic algorithms and data structures are widely used to obtain favourable expected performance guarantees. While their mathematical analysis is often well understood, mechanising expected-cost analyses remains challenging, requiring reasoning about probability distributions, expectations, and recursive stochastic behaviour. Existing formal approaches frequently require substantial manual proof effort, since expected costs are often encoded separately from probabilistic computations and must therefore be propagated explicitly throughout proofs.
In this paper, we present a cost-aware probability monad for \LH/ that supports reasoning about probabilistic programs together with their expected costs. Our approach combines executable probabilistic programs with refinement-type-based verification and SMT-supported automation. The monad intrinsically tracks probability mass, expected values, and expected costs through refinement types, enabling many quantitative properties of probabilistic computations to be inferred compositionally from program structure.
We evaluate our approach on several classical probabilistic algorithms and data structures, including meldable heaps, randomised quicksort and quickselect, randomised splay trees, random permutations, and the hiring problem. The case studies demonstrate different points along the spectrum between automated and interactive verification.