Compiling with continuations, correctly
Zoe Paraskevopoulou, Anvay Grover
Abstract
In this paper we present a novel simulation relation for proving correctness of program transformations that combines syntactic simulations and logical relations. In particular, we establish a new kind of simulation diagram that uses a small-step or big-step semantics in the source language and an untyped, step-indexed logical relation in the target language. Our technique provides a practical solution for proving semantics preservation for transformations that do not preserve reductions in the source language. This is common when transformations generate new binder names, and hence α-conversion must be explicitly accounted for, or when transformations introduce administrative redexes. Our technique does not require reductions in the source language to correspond directly to reductions in the target language. Instead, we enforce a weaker notion of semantic preorder, which suffices to show that semantics are preserved for both whole-program and separate compilation. Because our logical relation is transitive, we can transition between intermediate program states in a small-step fashion and hence the shape of the proof resembles that of a simple small-step simulation. We use this technique to revisit the semantic correctness of a continuation-passing style (CPS) transformation and we demonstrate how it allows us to overcome well-known complications of this proof related to α-conversion and administrative reductions. In addition, by using a logical relation that is indexed by invariants that relate the resource consumption of two programs, we are able show that the transformation preserves diverging behaviors and that our CPS transformation asymptotically preserves the running time of the source program. Our results are formalized in the Coq proof assistant. Our continuation-passing style transformation is part of the CertiCoq compiler for Gallina, the specification language of Coq.
Ask about this paper
Ask your agent about it.
Lune has read the top-tier papers around this one, so every answer names the papers it rests on.
Cited by top-tier papers2
- A Low-Level Look at A-Normal FormWilliam J. BowmanOOPSLA 2024 · 4 citations
- A Verified Foreign Function Interface between Coq and CJoomy Korkut, Kathrin Stark, Andrew W. AppelPOPL 2025 · 3 citations
Related papers
- Simuliris: a separation logic framework for verifying concurrent program optimizationsLennard Gäher, Michael Sammler, Simon Spies, Ralf Jung et al.POPL 2022 · 33 citations
- Pyrosome: Verified Compilation for Modular MetatheoryDustin Jamner, Gabriel Kammer, Ritam Nag, Adam ChlipalaOOPSLA 2025
- Stuttering for FreeMinki Cho, Youngju Song, Dongjae Lee, Lennard Gäher et al.OOPSLA 2023 · 11 citations
- Back to Direct Style: Typed and TightMarius Müller, Philipp Schuster, Jonathan Immanuel Brachthäuser, Klaus OstermannOOPSLA 2023 · 3 citations
- Sequential reasoning for optimizing compilers under weak memory concurrencyMinki Cho, Sung-Hwan Lee, Dongjae Lee, Chung-Kil Hur et al.PLDI 2022 · 11 citations
