Effects and Coeffects in Call-By-Push-Value (Extended Version)

Cassia Torczon,Emmanuel Suárez Acevedo,Shubh Agrawal,Joey Velez-Ginorio,Stephanie Weirich
DOI: https://doi.org/10.1145/3689750
2024-08-31
Abstract:Effect and coeffect tracking integrate many types of compile-time analysis, such as cost, liveness, or dataflow, directly into a language's type system. In this paper, we investigate the addition of effect and coeffect tracking to the type system of call-by-push-value (CBPV), a computational model useful in compilation for its isolation of effects and for its ability to cleanly express both call-by-name and call-by-value computations. Our main result is effect-and-coeffect soundness, which asserts that the type system accurately bounds the effects that the program may trigger during execution and accurately tracks the demands that the program may make on its environment. This result holds for two different dynamic semantics: a generic one that can be adapted for different coeffects and one that is adapted for reasoning about resource usage. In particular, the second semantics discards the evaluation of unused values and pure computations while ensuring that effectful computations are always evaluated, even if their results are not required. Our results have been mechanized using the Coq proof assistant.
Programming Languages
What problem does this paper attempt to address?
The main problem that this paper attempts to solve is to integrate effect and coeffect tracking into the type system of the Call - By - Push - Value (CBPV) computational model. Specifically, the researchers hope to achieve the following goals: 1. **Static tracking of effects and coeffects**: By extending the type system of CBPV, it can accurately analyze and track at compile - time the effects (such as time consumption, resource usage, etc.) that may be triggered during program execution, as well as the program's requirements for the environment (such as the use of input parameters, etc.). This helps ensure that the type system can accurately define the behavioral boundaries of the program. 2. **Soundness of effects and coeffects**: Prove that the extended type system is sound, that is, the type system can correctly predict the behavior of the program at runtime. Specifically, this includes: - **Effect soundness**: The type system can accurately limit the effects that a program may trigger. - **Coeffect soundness**: The type system can accurately track the program's requirements for input. 3. **Support for different dynamic semantics**: Provide two different dynamic semantics for different types of application scenarios: - A general dynamic semantic that can adapt to different coeffects. - Another dynamic semantic optimized for resource - use reasoning, which can ignore unused values and pure computations while ensuring that all computations with effects are executed. 4. **Combination with existing language features**: Enable existing programming languages to add effect and coeffect tracking capabilities by annotating their existing type systems, without introducing new language features or restricting how programmers write code. 5. **Verification of the preservation of standard translations**: Prove that the standard translations from call - by - value (CBV) and call - by - name (CBN) λ - calculus to CBPV not only preserve type information, but also effect and coeffect information. 6. **Formal verification**: Use the Coq proof assistant to formally verify the above results to ensure the correctness and reliability of the theory. Through these efforts, the researchers aim to enrich the capabilities of CBPV as a compilation intermediate representation, support more complex program optimizations, and provide a more powerful tool for understanding and controlling program behavior.