skip to main content
research-article

Formally proving a compiler transformation safe

Published:30 August 2015Publication History
Skip Abstract Section

Abstract

We prove that the Call Arity analysis and transformation, as implemented in the Haskell compiler GHC, is safe, i.e. does not impede the performance of the program. We formalized syntax, semantics, the analysis and the transformation in the interactive theorem prover Isabelle to obtain a machine-checked proof and hence a level of rigor rarely obtained for compiler optimization safety theorems. The proof is modular and introduces trace trees as a suitable abstraction in abstract cardinality analyses. We discuss the breadth of the formalization gap.

References

  1. D. Aspinall, L. Beringer, and A. Momigliano. Optimisation validation. In COCV’06, volume 176(3) of ENTCS, pages 37 – 59, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. C. Ballarin. Locales: A module system for mathematical theories. Journal of Automated Reasoning, 52(2):123–153, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 2 see GHC commit 306d255Google ScholarGoogle Scholar
  4. J. Breitner. The correctness of Launchbury’s natural semantics for lazy evaluation. Archive of Formal Proofs, Jan. 2013. http://afp.sf.net/ entries/Launchbury.shtml.Google ScholarGoogle Scholar
  5. J. Breitner. The Safety of Call Arity. Archive of Formal Proofs, Feb. 2015. http://afp.sf.net/entries/Call Arity.shtml.Google ScholarGoogle Scholar
  6. J. Breitner. Call Arity. In TFP’14, volume 8843 of LNCS, pages 34–50. Springer, 2015.Google ScholarGoogle Scholar
  7. A. Chlipala. A verified compiler for an impure functional language. In POPL’10, pages 93–106. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Z. Dargaye and X. Leroy. Mechanized Verification of CPS Transformations. In LPAR’07, volume 4790 of LNCS, pages 211–225. Springer, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. R. Eisenberg. System FC, as implemented in GHC, 2013. URL https://github.com/ghc/ghc/blob/master/docs/core-spec/ core-spec.pdf.Google ScholarGoogle Scholar
  10. P. Gammie. The worker/wrapper transformation. Archive of Formal Proofs, Oct. 2009. http://afp.sf.net/entries/WorkerWrapper.shtml.Google ScholarGoogle Scholar
  11. A. J. Gill. Cheap deforestation for non-strict functional languages. PhD thesis, University of Glasgow, 1996.Google ScholarGoogle Scholar
  12. J. Gustavsson and D. Sands. A foundation for space-safe transformations of call-by-need programs. In HOOTS’99, volume 26 of ENTCS, pages 69–86, 1999.Google ScholarGoogle ScholarCross RefCross Ref
  13. J. Gustavsson and D. Sands. Possibilities and limitations of call-byneed space improvement. In ICFP’01, pages 265–276. ACM, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. J. Hackett and G. Hutton. Worker/Wrapper/Makes It/Faster. In ICFP’14, pages 95–107. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. B. Huffman. HOLCF ’11: A Definitional Domain Theory for Verifying Functional Programs. PhD thesis, Portland State University, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. R. Kumar, M. O. Myreen, M. Norrish, and S. Owens. Cakeml: A verified implementation of ml. In POPL’14, pages 179–191. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. J. Launchbury. A natural semantics for lazy evaluation. In POPL, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. X. Leroy. Mechanized semantics for compiler verification. In APLAS’12, volume 7705 of LNCS, pages 386–388. Springer, 2012.Google ScholarGoogle Scholar
  19. Invited talk.Google ScholarGoogle Scholar
  20. A. Lochbihler. Verifying a compiler for java threads. In ESOP’10, volume 6012 of LNCS, pages 427–447. Springer, Mar. 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. S. Marlow and S. L. Peyton Jones. Making a fast curry: push/enter vs. eval/apply for higher-order languages. Journal of Functional Programming, 16(4-5):415–449, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Y. Minamide and K. Okuma. Verifying CPS Transformations in Isabelle/HOL. In MERLIN’03, pages 1–8. ACM, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. A. K. Moran and D. Sands. Improvement in a Lazy Context: An Operational Theory for Call-By-Need. In POPL’99, pages 43–56. ACM, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. T. Nipkow, L. C. Paulson, and M. Wenzel. Isabelle/HOL — A Proof Assistant for Higher-Order Logic, volume 2283 of LNCS. Springer, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. D. Sands. Operational theories of improvement in functional languages (extended abstract). In Glasgow Workshop on Functional Programming, Workshops in Computing Series, pages 298–311. Springer, August 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. I. Sergey, D. Vytiniotis, and S. Peyton Jones. Modular, Higher-order Cardinality Analysis in Theory and Practice. POPL, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. P. Sestoft. Deriving a lazy abstract machine. Journal of Functional Programming, 7:231–264, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Y. H. Tian. Mechanically Verifying Correctness of CPS Compilation. In CATS’06, volume 51 of CRPIT, pages 41–51. ACS, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. C. Urban and C. Kaliszyk. General Bindings and Alpha-Equivalence in Nominal Isabelle. Logical Methods in Computer Science, 8(2), 2012..Google ScholarGoogle Scholar
  30. D. N. Xu and S. Peyton Jones. Arity analysis, 2005. Working Notes. Introduction Overview and Example From the Example… …to the General Case Syntax and Semantics Semantics Arities and Eta-Expansion Arity Analyses Cardinality Analyses Abstract Cardinality Analysis Trace Tree Cardinality Analysis Co-Call Cardinality Analysis Call Arity, Concretely The Formalization in Isabelle The Formalization Effort The Formalization Gap Related Work ConclusionGoogle ScholarGoogle Scholar

Index Terms

  1. Formally proving a compiler transformation safe

        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!