Certifying CPS Transformation of Let-Polymorphic Calculus Using PHOAS
This paper formalizes the correctness of a one-pass CPS transformation for the lambda calculus extended with let-polymorphism. We prove in Agda that equality is preserved through the CPS transformation. Parameterized higher-order abstract syntax is used to represent binders both at the term level and the type level. Unlike the previous work based on denotational semantics, we use small-step operational semantics to formalize the equality. Thanks to the small-step formalization, we can establish the correctness without any hypothesis on the well-formedness of input terms. The resulting formalization is simple enough to serve as a basis for more complex CPS transformations such as selective one for a calculus with delimited control operators.
KeywordsOne-pass CPS transformation Parameterized higher-order abstract syntax Let-polymorphism Agda
We would like to thank the reviewers for useful and constructive comments. This work was partly supported by JSPS KAKENHI under Grant No. JP18H03218.
- 1.Appel, A.W.: Compiling with Continuations. Cambridge University Press, New York (2007)Google Scholar
- 3.Asai, K., Uehara, C.: Selective CPS transformation for shift and reset. In: Proceedings of the ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation (PEPM 2018), pp. 40–52 (2018)Google Scholar
- 5.de Bruijn, N.: Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. In: Indagationes Mathematicae, Proceedings, vol. 75, no. 5, pp. 381–392 (1972)Google Scholar
- 6.Chlipala, A.: Parametric higher-order abstract syntax for mechanized semantics. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP 2008), pp. 143–156, September 2008Google Scholar
- 9.Danvy, O., Filinski, A.: Abstracting control. In: Proceedings of the ACM Conference on LISP and Functional Programming (LFP 1990), pp. 151–160 (1990)Google Scholar
- 11.Dargaye, Z., Leroy, X.: Mechanized verification of CPS transformations. In: Proceedings of the International Conference on Logic for Programming Artificial Intelligence and Reasoning (LPAR 2005), pp. 211–225 (2007)Google Scholar
- 12.Minamide, Y., Okuma, K.: Verifying CPS transformations in Isabelle/HOL. In: Proceedings of the 2003 ACM SIGPLAN Workshop on Mechanized Reasoning About Languages with Variable Binding (MERLIN 2003), pp. 1–8 (2003)Google Scholar
- 15.Tian, Y.H.: Mechanically verifying correctness of CPS compilation. In: Proceeding of the Twelfth Computing: The Australasian Theory Symposium (CATS 2006), vol. 51, pp. 41–51 (2006)Google Scholar