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.
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Andrew W. Appel. 1992. Compiling with Continuations. Cambridge University Press.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Xavier Leroy. 2009. A Formally Verified Compiler Back-end. J. Autom. Reasoning 43, 4 (2009), 363–446. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Andrew M. Pitts. 1994. Computational adequacy via ‘mixed’ inductive definitions. Springer Berlin Heidelberg, 72–82. Google Scholar
Cross Ref
- Jeremy Siek. 2013. Type Safety in Three Easy Lemmas. (2013). http://siek.blogspot.com/2013/05/ type-safety-in-three-easy-lemmas.html .Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- William D. Young. 1989. A Mechanically Verified Code Generator. J. Autom. Reasoning 5, 4 (1989), 493–518. Google Scholar
Digital Library
Index Terms
Verifying efficient function calls in CakeML
Recommendations
A new verified compiler backend for CakeML
ICFP 2016: Proceedings of the 21st ACM SIGPLAN International Conference on Functional ProgrammingWe have developed and mechanically verified a new compiler backend for CakeML. Our new compiler features a sequence of intermediate languages that allows it to incrementally compile away high-level features and enables verification at the right levels ...
A new verified compiler backend for CakeML
ICFP '16We have developed and mechanically verified a new compiler backend for CakeML. Our new compiler features a sequence of intermediate languages that allows it to incrementally compile away high-level features and enables verification at the right levels ...
CakeML: a verified implementation of ML
POPL '14: Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming LanguagesWe have developed and mechanically verified an ML system called CakeML, which supports a substantial subset of Standard ML. CakeML is implemented as an interactive read-eval-print loop (REPL) in x86-64 machine code. Our correctness theorem ensures that ...






Comments