skip to main content
research-article
Open Access
Artifacts Evaluated & Reusable

Verifying efficient function calls in CakeML

Published:29 August 2017Publication History
Skip Abstract Section

Abstract

We have designed an intermediate language (IL) for the CakeML compiler that supports the verified, efficient compilation of functions and calls. Verified compilation steps include batching of multiple curried arguments, detecting calls to statically known functions, and specialising calls to known functions with no free variables. Finally, we verify the translation to a lower-level IL that only supports closed, first-order functions.

These compilation steps resemble those found in other compilers (especially OCaml). Our contribution here is the design of the semantics of the IL, and the demonstration that our verification techniques over this semantics work well in practice at this scale. The entire development was carried out in the HOL4 theorem prover.

References

  1. Umut A. Acar, Amal Ahmed, and Matthias Blume. 2008. Imperative self-adjusting computation. In Proceedings of the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2008 . ACM, 309–322. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Amal Ahmed. 2015. Verified Compilers for a Multi-Language World. In 1st Summit on Advances in Programming Languages (SNAPL 2015) (Leibniz International Proceedings in Informatics (LIPIcs)) , Vol. 32. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, 15–31. Google ScholarGoogle ScholarCross RefCross Ref
  3. Amal J. Ahmed. 2006. Step-Indexed Syntactic Logical Relations for Recursive and Quantified Types. In Programming Languages and Systems, 15th European Symposium on Programming, ESOP 2006 (Lecture Notes in Computer Science) , Peter Sestoft (Ed.), Vol. 3924. Springer, 69–83. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Nada Amin and Tiark Rompf. 2017. Type Soundness Proofs with Definitional Interpreters. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017) . ACM, 666–679. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Andrew W. Appel. 1992. Compiling with Continuations. Cambridge University Press.Google ScholarGoogle Scholar
  6. Andrew W. Appel and David A. McAllester. 2001. An indexed model of recursive types for foundational proof-carrying code. ACM Trans. Program. Lang. Syst. 23, 5 (2001), 657–683. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Nick Benton and Chung-Kil Hur. 2009. Biorthogonality, step-indexing and compiler correctness. In Proceeding of the 14th ACM SIGPLAN International Conference on Functional Programming, ICFP 2009 . ACM, 97–108. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. R.S. Boyer and J S. Moore. 1996. Mechanized Formal Reasoning about Programs and Computing Machines.. In Automated Reasoning and Its Applications: Essays in Honor of Larry Wos . MIT Press.Google ScholarGoogle Scholar
  9. Joachim Breitner. 2015. Formally Proving a Compiler Transformation Safe. In Proceedings of the 2015 ACM SIGPLAN Symposium on Haskell (Haskell ’15) . ACM, 35–46. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Adam Chlipala. 2010. A Verified Compiler for an Impure Functional Language. In Proceedings of the 37th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2010 . ACM, 93–106. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Zaynah Dargaye and Xavier Leroy. 2009. A verified framework for higher-order uncurrying optimizations. Higher-Order and Symbolic Computation 22, 3 (2009), 199–231. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Dominique Devriese, Marco Patrignani, and Frank Piessens. 2016. Fully-abstract compilation by approximate back-translation. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016. ACM, 164–177. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Derek Dreyer, Georg Neis, and Lars Birkedal. 2012. The impact of higher-order state and control effects on local relational reasoning. J. Funct. Program. 22, 4-5 (2012), 477–528. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Cormac Flanagan, Amr Sabry, Bruce F. Duba, and Matthias Felleisen. 1993. The Essence of Compiling with Continuations. In Proceedings of the ACM SIGPLAN 1993 Conference on Programming Language Design and Implementation (PLDI ’93). ACM, 237–247. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, and Michael Norrish. 2017. Verified Characteristic Formulae for CakeML. In Programming Languages and Systems: 26th European Symposium on Programming, ESOP 2017, Hongseok Yang (Ed.). Springer, 584–610. Google ScholarGoogle ScholarCross RefCross Ref
  16. Chung-Kil Hur and Derek Dreyer. 2011. A Kripke logical relation between ML and assembly. In Proceedings of the 38th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2011 . ACM, 133–146. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Ramana Kumar, Magnus O. Myreen, Michael Norrish, and Scott Owens. 2014. CakeML: A Verified Implementation of ML. In POPL ’14: Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. ACM Press, 179–191. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Xavier Leroy. 2009. A Formally Verified Compiler Back-end. J. Autom. Reasoning 43, 4 (2009), 363–446. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Simon Marlow and Simon Peyton Jones. 2006. Making a fast curry: Push/Enter vs. Eval/Apply for higher-order languages. J. Funct. Program. 16, 4-5 (2006), 415–449. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Magnus O. Myreen and Jared Davis. 2011. A Verified Runtime for a Verified Theorem Prover. In Interactive Theorem Proving -Second International Conference, ITP 2011 (Lecture Notes in Computer Science) , Marko C. J. D. van Eekelen, Herman Geuvers, Julien Schmaltz, and Freek Wiedijk (Eds.), Vol. 6898. Springer, 265–280. Google ScholarGoogle ScholarCross RefCross Ref
  21. Magnus O. Myreen and Scott Owens. 2014. Proof-producing Translation of Higher-order logic into Pure and Stateful ML. Journal of Functional Programming 24, 2-3 (May 2014), 284–315. Google ScholarGoogle ScholarCross RefCross Ref
  22. Georg Neis, Chung-Kil Hur, Jan-Oliver Kaiser, Craig McLaughlin, Derek Dreyer, and Viktor Vafeiadis. 2015. Pilsner: a compositionally verified compiler for a higher-order imperative language. In Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming, ICFP 2015 . 166–178. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Max S. New, William J. Bowman, and Amal Ahmed. 2016. Fully abstract compilation via universal embedding. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming, ICFP 2016 . ACM, 103–116. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Scott Owens, Magnus O. Myreen, Ramana Kumar, and Yong Kiam Tan. 2016. Functional Big-step Semantics. In Programming Languages and Systems: 25th European Symposium on Programming, ESOP 2016 (Lecture Notes in Computer Science) , Peter Thiemann (Ed.), Vol. 9632. Springer, 589–615. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. James T. Perconti and Amal Ahmed. 2014. Verifying an Open Compiler Using Multi-language Semantics. In Programming Languages and Systems - 23rd European Symposium on Programming, ESOP 2014 (Lecture Notes in Computer Science) , Zhong Shao (Ed.), Vol. 8410. Springer, 128–148. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Andrew M. Pitts. 1994. Computational adequacy via ‘mixed’ inductive definitions. Springer Berlin Heidelberg, 72–82. Google ScholarGoogle ScholarCross RefCross Ref
  27. Jeremy Siek. 2013. Type Safety in Three Easy Lemmas. (2013). http://siek.blogspot.com/2013/05/ type-safety-in-three-easy-lemmas.html .Google ScholarGoogle Scholar
  28. Yong Kiam Tan, Magnus O. Myreen, Ramana Kumar, Anthony Fox, Scott Owens, and Michael Norrish. 2016. A New Verified Compiler Backend for CakeML. In ICFP ’16: Proceedings of the 21th ACM SIGPLAN International Conference on Functional Programming . ACM Press, 60–73. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Yong Kiam Tan, Scott Owens, and Ramana Kumar. 2015. A Verified Type System for CakeML. In 27th Symposium on the Implementation and Application of Functional Programming Languages, IFL 2015 . ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. William D. Young. 1989. A Mechanically Verified Code Generator. J. Autom. Reasoning 5, 4 (1989), 493–518. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Verifying efficient function calls in CakeML

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!