🤖 AI Summary
This paper addresses the challenge of automating expected runtime analysis for probabilistic programs. We introduce a refinement-typed probabilistic monad in Liquid Haskell, the first to uniformly embed both probabilistic behavior and cost modeling within a type system. Our approach supports unified reasoning over both finite and infinite distributions, enabling highly automated expected-cost inference via SMT-driven refinement type checking; it further incorporates axiomatic extensions to handle infinite loops and divergent distributions. Key contributions include: (1) the first formal verification of the expected runtime of zip trees; and (2) empirical validation across four benchmarks—meldable heaps, coupon collector, randomized quicksort, and zip trees—demonstrating both fully automated analysis with low annotation overhead (for the first two) and effective integration of interactive proof for enhanced precision and applicability (for the latter two).
📝 Abstract
Probabilistic programming and the formal analysis of probabilistic algorithms are active areas of research, driven by the widespread use of randomness to improve performance. While functional correctness has seen substantial progress, automated reasoning about expected runtime remains comparatively limited. In this work, we address this challenge by introducing a refinement-typed probability monad in Liquid Haskell. Our monad enables automated reasoning about expected values and costs by encoding probabilistic behaviour directly in types. Initially defined for discrete distributions over finite support, it is extended to support infinite distributions via an axiomatic approach. By leveraging Liquid Haskell's SMT-based refinement type checking, our framework provides a high degree of automation. We evaluate our approach through four case studies: meldable heaps, coupon collector, randomised quicksort, and zip trees. The first two demonstrate automation with minimal annotation overhead. The latter two showcase how our monad integrates with interactive proofs, including the first formal verification of the expected runtime of zip trees.