Skip to main content

Certifying CPS Transformation of Let-Polymorphic Calculus Using PHOAS

  • Conference paper
  • First Online:
Programming Languages and Systems (APLAS 2018)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 11275))

Included in the following conference series:

Abstract

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    We follow the notation employed by Chlipala [6].

  2. 2.

    The two cases, \(\lfloor {e}\rfloor _{\mathsf {S}}\) and \(\lfloor {e}\rfloor _{\mathsf {D}}\), correspond to \([\![{e}]\!]\) and \([\![{e}]\!]'\) in Danvy and Filinski [10].

  3. 3.

    Values and terms correspond to serious expressions and trivial expressions in Danvy’s notation, respectively. Besides the introduction of let terms, our notation differs from Danvy’s in that we allow a term of the form \({c}\,@^{\mathsf {K}}\,{k}\) where c is not necessarily a continuation variable. We need the new form during the correctness proof.

  4. 4.

    As for continuations and terms, we keep the type after the CPS transformation. Since the answer type is always \(\mathsf {Nat}\), we could elide it and write the type of continuations and terms as \(\lnot \tau \) and \(\bot \), respectively.

References

  1. Appel, A.W.: Compiling with Continuations. Cambridge University Press, New York (2007)

    Google Scholar 

  2. Asai, K., Kameyama, Y.: Polymorphic delimited continuations. In: Shao, Z. (ed.) APLAS 2007. LNCS, vol. 4807, pp. 239–254. Springer, Heidelberg (2007). https://doi.org/10.1007/978-3-540-76637-7_16

    Chapter  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 

  4. Aydemir, B.E., et al.: Mechanized metatheory for the masses: the PoplMark challenge. In: Hurd, J., Melham, T. (eds.) TPHOLs 2005. LNCS, vol. 3603, pp. 50–65. Springer, Heidelberg (2005). https://doi.org/10.1007/11541868_4

    Chapter  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 2008

    Google Scholar 

  7. Chlipala, A.: Certified Programming with Dependent Types. MIT Press, Cambridge (2013)

    MATH  Google Scholar 

  8. Danvy, O.: Back to Direct Style. Sci. Comput. Program. 22, 183–195 (1994)

    Article  Google 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 

  10. Danvy, O., Filinski, A.: Representing control: a study of the CPS transformation. Math. Struct. Comput. Sci. 2(4), 361–391 (1992)

    Article  MathSciNet  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 

  13. Nielsen, L.R.: A selective CPS transformation. Electron. Notes Theor. Comput. Sci. 45, 311–331 (2001)

    Article  Google Scholar 

  14. Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)

    MATH  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 

Download references

Acknowledgements

We would like to thank the reviewers for useful and constructive comments. This work was partly supported by JSPS KAKENHI under Grant No. JP18H03218.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Urara Yamada .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Yamada, U., Asai, K. (2018). Certifying CPS Transformation of Let-Polymorphic Calculus Using PHOAS. In: Ryu, S. (eds) Programming Languages and Systems. APLAS 2018. Lecture Notes in Computer Science(), vol 11275. Springer, Cham. https://doi.org/10.1007/978-3-030-02768-1_20

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-02768-1_20

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-02767-4

  • Online ISBN: 978-3-030-02768-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics