Reference. Denotational Foundations for Expected Cost Analysis
Reasoning about the cost of executing programs is one of the fundamental questions in computer science. In the context of programming with probabilities, however, the notion of cost stops being deterministic, since it depends on the probabilistic samples made throughout the execution of the program. This interaction is further complicated by the non-trivial interaction between cost, recursion and evaluation strategy.
In this work we introduce cert: a Call-By-Push-Value (CBPV) metalanguage for reasoning about probabilistic cost. We equip cert with an operational cost semantics and define two denotational semantics — a cost semantics and an expected-cost semantics. We prove operational soundness and adequacy for the denotational cost semantics and a cost adequacy theorem for the expected-cost semantics.
We formally relate both denotational semantics by stating and proving a novel effect simulation property for CBPV. We also prove a canonicity property of the expected-cost semantics as the minimal semantics for expected cost and probability by building on recent advances on monadic probabilistic semantics.
Finally, we illustrate the expressivity of cert and the expected-cost semantics by presenting case-studies ranging from randomized algorithms to stochastic processes and show how our semantics capture their intended expected cost.
Cite
Cited by (2)
The Compositional Essence of Effectful Cost Analyses: Categorical Foundations and Fibered Logical Relations amorim_effcost
Logical relations for call-by-push-value models, via internal fibrations in a 2-category amorim_kura_saville_2025
We give a denotational account of logical relations for call-by-push-value (CBPV) in the fibrational style of Hermida, Jacobs, Katsumata and others. Fibrations – which axiomatise the usual notion of sets-with-relations – provide a clean framework for constructing new, logical relations-style, models. Such models can then be used to study properties such as effect simulation.
Extending this picture to CBPV is challenging: the models incorporate both adjunctions and enrichment, making the appropriate notion of fibration unclear. We handle this using 2-category theory. We identify an appropriate 2-category, and define CBPV fibrations to be fibrations internal to this 2-category which strictly preserve the CBPV semantics.
Next, we develop the theory so it parallels the classical setting. We give versions of the codomain and subobject fibrations, and show that new models can be constructed from old ones by pullback. The resulting framework enables the construction of new, logical relations-style, models for CBPV.
Finally, we demonstrate the utility of our approach with particular examples. These include a generalisation of Katsumata’s -lifting to CBPV models, an effect simulation result, and a relative full completeness result for CBPV without sum types.
Cites 45 works (4 here)
With notes (4)
Decalf: A Directed, Effectful Cost-Aware Logical Framework grodin-2024-decalf
A cost-aware logical framework niu-2022-a
A domain theory for statistical probabilistic programming vakar-2019-a
A convenient category for higher-order probability theory heunen-2017-a
External (41)
- A Modal Type Theory of Expected Cost in Higher-Order Probabilistic Programs (2024)
- A Calculus for Amortized Expected Runtimes (2023)
- Central Submonads and Notions of Computation: Soundness, Completeness and Internal Languages (2023)
- Automatic Amortized Resource Analysis with Regular Recursive Types (2023)
- Automated Tail Bound Analysis for Probabilistic Recurrence Relations (2023)
- Weakest preconditions in fibrations (2022)
- Automated Expected Amortised Cost Analysis of Probabilistic Data Structures (2022)
- On continuation-passing transformations and expected cost analysis (2021)
- A unifying type-theory for higher-order (amortized) cost analysis (2021)
- A modular cost analysis for probabilistic programs (2020)
- Denotational recurrence extraction for amortized analysis (2020)
- Exponential Automatic Amortized Resource Analysis (2020)
- Raising expectations: automating expected cost analysis with types (2020)
- Type-Based Complexity Analysis of Probabilistic Functional Programs (2019)
- Recurrence extraction for functional programs through call-by-push-value (2019)
- Tail Probabilities for Randomized Program Runtimes via Martingales for Higher Moments (2019)
- Factorisation systems for logical relations and monadic lifting in type-and-effect system semantics (2018)
- Codensity Lifting of Monads and its Dual (2018)
- Bounded expectations: resource analysis for probabilistic programs (2018)
- Measurable cones and stable, measurable functions: a model for probabilistic higher-order programming (2017)
- Arrays and References in Resource Aware ML (2017)
- TiML: a functional language for practical complexity analysis with invariants (2017)
- Algorithmic analysis of qualitative and quantitative termination problems for affine probabilistic programs (2016)
- Relational cost analysis (2016)
- Towards automatic resource bound analysis for OCaml (2016)
- Weakest Precondition Reasoning for Expected Run–Times of Probabilistic Programs (2016)
- Denotational cost semantics for functional languages with inductive types (2015)
- Automatic Static Cost Analysis for Parallel Programs (2015)
- A static cost analysis for a higher-order language (2013)
- Relating computational effects by TT-lifting (2013)
- Call-by-push-value (Levy, PhD dissertation) (2001)
- Markov Chains (Norris) (1998)
- Controlling Effects (Filinski, PhD dissertation, CMU) (1996)
- Randomized Algorithms (1995)
- Handbook of Categorical Algebra (1994)
- Computational lambda-calculus and monads (1989)
- Analysis of a simple yet efficient convex hull algorithm (1988)
- Computational Geometry (1985)
- A Probabilistic PDL (1983)
- An efficient algorithm for determining the convex hull of a finite planar set (1972)
- Algebraic Theories (Wraith, lecture notes, Aarhus) (1970)