Abstract

We define a continuation-passing style (CPS) translation for a typed λ-calculus with probabilistic choice, unbounded recursion, and a tick operator — for modeling cost. The target language is a (non-probabilistic) λ-calculus, enriched with a type of extended positive reals and a fixpoint operator. We then show that applying the CPS transform of an expression M to the continuation λ v . 0 yields the expected cost of M . We also introduce a formal system for higher-order logic, called EHOL, prove it sound, and show it can derive tight upper bounds on the expected cost of classic examples, including Coupon Collector and Random Walk. Moreover, we relate our translation to Kaminski et al.’s ert-calculus, showing that the latter can be recovered by applying our CPS translation to (a generalization of) the classic embedding of imperative programs into λ-calculus. Finally, we prove that the CPS transform of an expression can also be used to compute pre-expectations and to reason about almost sure termination.

Highlights

  • Randomized computation has been one of the most fruitful extensions of the standard, deterministic, computational model, since the birth of computer science [De Leeuw et al 1956; III 1974; Rabin 1963; Santos 1969]

  • We show that the ert-calculus of Kaminski et al [2018] Ð a weakest pre-expectation calculus for reasoning about the expected runtime of randomized algorithms written in an imperative probabilistic language Ð is recovered through an application of our continuation-passing style (CPS) transformation on a

  • The formal system of higher-order logic we introduced in Section 5 is a sound methodology to derive upper bounds on the expected cost of higher-order randomised programs via a CPS translation, as witnessed by Theorem 4.15 and Theorem 5.1

Read more

Summary

INTRODUCTION

Randomized computation has been one of the most fruitful extensions of the standard, deterministic, computational model, since the birth of computer science [De Leeuw et al 1956; III 1974; Rabin 1963; Santos 1969]. As one example of such a methodology, we introduce a form of unary higher-order logic [Aguirre et al 2017] in which statements about terms of the target language can be proved to hold in a sound way, even in the presence of recursive definitions. This crucially relies on a restriction on the kind of predicates one employs when dealing with functions defined as fixed points.

RANDOMIZED PROGRAMS AND CPS: A BIRD’S EYE VIEW
A PROBABILISTIC HIGHER-ORDER LANGUAGE
The Pure Fragment
The Non-pure Fragment
A Semantic Expected Cost Transformer
COMPUTING EXPECTED COSTS
ON HIGHER-ORDER LOGIC AND EXPECTATIONS
EMBEDDING OF THE ERT CALCULUS
DISCUSSION
RELATED WORK
CONCLUSION
Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call