skip to main content
research-article
Open Access
Artifacts Available / v1.1

Calculating dependently-typed compilers (functional pearl)

Published:19 August 2021Publication History
Skip Abstract Section

Abstract

Compilers are difficult to write, and difficult to get right. Bahr and Hutton recently developed a new technique for calculating compilers directly from specifications of their correctness, which ensures that the resulting compilers are correct-by-construction. To date, however, this technique has only been applicable to source languages that are untyped. In this article, we show that moving to a dependently-typed setting allows us to naturally support typed source languages, ensure that all compilation components are type-safe, and make the resulting calculations easier to mechanically check using a proof assistant.

Skip Supplemental Material Section

Supplemental Material

Auxiliary Presentation Video

This is a video talk for our ICFP 2021 paper Calculating Dependently-Typed Compilers (Functional Pearl). It gives an overview of the process of calculating a correct-by-construction compiler for typed languages by leveraging the power of dependent types, and contains part of an example calculation to demonstrate the process. The associated paper contains several full example calculations, and there is also a code repository with verified Agda code for these examples.

3473587.mp4

Presentation Videos

References

  1. Mads Sig Ager, Dariusz Biernacki, Olivier Danvy, and Jan Midtgaard. 2003. From Interpreter to Compiler and Virtual Machine: A Functional Derivation. BRICS, Department of Computer Science, University of Aarhus.Google ScholarGoogle Scholar
  2. Andrew Appel, Lennart Beringer, Adam Chlipala, Benjamin Pearce, Zhong Shao, Stephanie Weirich, and Steve Zdancewic. 2015. The Science of Deep Specification. https://deepspec.org/Google ScholarGoogle Scholar
  3. Patrick Bahr and Graham Hutton. 2015. Calculating Correct Compilers. Journal of Functional Programming, 25 (2015), Sept..Google ScholarGoogle Scholar
  4. Patrick Bahr and Graham Hutton. 2020. Calculating Correct Compilers II: Return of the Register Machines. Journal of Functional Programming, 30 (2020), Aug..Google ScholarGoogle Scholar
  5. Edwin Brady and Kevin Hammond. 2006. A Verified Staged Interpreter is a Verified Compiler. In GPCE’06: Proceedings of the 5th International Conference on Generative Programming and Component Engineering.Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Adam Chlipala. 2007. A Certified Type-Preserving Compiler from Lambda Calculus to Assembly Language. In PLDI’07: Proceedings of the ACM SIGPLAN 2007 Conference on Programming Language Design and Implementation.Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Peter Dybjer. 1994. Inductive Families. Formal Aspects of Computing, 6, 4 (1994), 440–465.Google ScholarGoogle ScholarCross RefCross Ref
  8. Conal Elliott. 2017. Compiling to Categories. In Proceedings of the ACM on Programming Languages (ICFP).Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Conal Elliott. 2018. Calculating Compilers Categorically. https://tinyurl.com/5de9xfm2Google ScholarGoogle Scholar
  10. Andrew Farmer, Neil Sculthorpe, and Andy Gill. 2015. Reasoning with the Hermit: Tool Support for Equational Reasoning on GHC Core Programs. In Haskell Symposium.Google ScholarGoogle Scholar
  11. Martin Handley and Graham Hutton. 2018. Improving Haskell. In Proceedings of the Symposium on Trends in Functional Programming.Google ScholarGoogle Scholar
  12. Graham Hutton and Patrick Bahr. 2017. Compiling a 50-Year Journey. Journal of Functional Programming, 27 (2017), Sept..Google ScholarGoogle Scholar
  13. Yong Kiam Tan, Magnus O. Myreen, Ramana Kumar, Anthony Fox, Scott Owens, and Michael Norrish. 2019. The Verified CakeML Compiler Backend. Journal of Functional Programming, 29 (2019).Google ScholarGoogle Scholar
  14. Xavier Leroy. 2009. Formal Verification of a Realistic Compiler. Communications of the ACM, 52, 7 (2009).Google ScholarGoogle Scholar
  15. 2010. Haskell Language Report, Simon Marlow (Ed.). Available on the web from: https://www.haskell.org/definition/haskell2010.pdfGoogle ScholarGoogle Scholar
  16. Conor McBride. 2011. Ornamental Algebras, Algebraic Ornaments. University of Strathclyde.Google ScholarGoogle Scholar
  17. James Mckinna and Joel Wright. 2006. A Type-Correct, Stack-Safe, Provably Correct, Expression Compiler in Epigram.Google ScholarGoogle Scholar
  18. Erik Meijer. 1992. Calculating Compilers. Ph.D. Dissertation. Katholieke Universiteit Nijmegen.Google ScholarGoogle Scholar
  19. Shin-cheng Mu, Hsiang-shang Ko, and Patrik Jansson. 2009. Algebra of Programming in Agda: Dependent Types for Relational Program Derivation. Journal of Functional Programming, 19, 5 (2009).Google ScholarGoogle Scholar
  20. Ulf Norell. 2007. Towards a Practical Programming Language Based on Dependent Type Theory. Ph.D. Dissertation. Department of Computer Science and Engineering, Chalmers University of Technology.Google ScholarGoogle Scholar
  21. Alberto Pardo, Emmanuel Gunther, Miguel Pagano, and Marcos Viera. 2018. An Internalist Approach to Correct-by-Construction Compilers. In Proceedings of the 20th International Symposium on Principles and Practice of Declarative Programming (PPDP ’18).Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Casper Bach Poulsen, Arjen Rouvoet, Andrew Tolmach, Robbert Krebbers, and Eelco Visser. 2018. Intrinsically-Typed Definitional Interpreters for Imperative Languages. Proceedings of the ACM on Programming Languages, 2, POPL (2018).Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Arjen Rouvoet, Robbert Krebbers, and Eelco Visser. 2021. Intrinsically Typed Compilation with Nameless Labels. Proceedings of the ACM on Programming Languages, 5, POPL (2021), Article 22, Jan..Google ScholarGoogle Scholar
  24. Mike Spivey. 1990. A Functional Theory of Exceptions. Science of Computer Programming, 14, 1 (1990), 25–43.Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Martin Sulzmann, Manuel Chakravarty, Simon Peyton Jones, and Kevin Donnelly. 2007. System F with Type Equality Coercions. In TLDI.Google ScholarGoogle Scholar
  26. Philip Wadler. 1989. The Concatenate Vanishes. University of Glasgow.Google ScholarGoogle Scholar
  27. Mitchell Wand. 1982. Deriving Target Code as a Representation of Continuation Semantics. ACM Transactions on Programming Languages and Systems, 4, 3 (1982), 496–517.Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Calculating dependently-typed compilers (functional pearl)

        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!