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.
Supplemental Material
- 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 Scholar
- 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 Scholar
- Patrick Bahr and Graham Hutton. 2015. Calculating Correct Compilers. Journal of Functional Programming, 25 (2015), Sept..Google Scholar
- Patrick Bahr and Graham Hutton. 2020. Calculating Correct Compilers II: Return of the Register Machines. Journal of Functional Programming, 30 (2020), Aug..Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Peter Dybjer. 1994. Inductive Families. Formal Aspects of Computing, 6, 4 (1994), 440–465.Google Scholar
Cross Ref
- Conal Elliott. 2017. Compiling to Categories. In Proceedings of the ACM on Programming Languages (ICFP).Google Scholar
Digital Library
- Conal Elliott. 2018. Calculating Compilers Categorically. https://tinyurl.com/5de9xfm2Google Scholar
- 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 Scholar
- Martin Handley and Graham Hutton. 2018. Improving Haskell. In Proceedings of the Symposium on Trends in Functional Programming.Google Scholar
- Graham Hutton and Patrick Bahr. 2017. Compiling a 50-Year Journey. Journal of Functional Programming, 27 (2017), Sept..Google Scholar
- 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 Scholar
- Xavier Leroy. 2009. Formal Verification of a Realistic Compiler. Communications of the ACM, 52, 7 (2009).Google Scholar
- 2010. Haskell Language Report, Simon Marlow (Ed.). Available on the web from: https://www.haskell.org/definition/haskell2010.pdfGoogle Scholar
- Conor McBride. 2011. Ornamental Algebras, Algebraic Ornaments. University of Strathclyde.Google Scholar
- James Mckinna and Joel Wright. 2006. A Type-Correct, Stack-Safe, Provably Correct, Expression Compiler in Epigram.Google Scholar
- Erik Meijer. 1992. Calculating Compilers. Ph.D. Dissertation. Katholieke Universiteit Nijmegen.Google Scholar
- 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 Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- Mike Spivey. 1990. A Functional Theory of Exceptions. Science of Computer Programming, 14, 1 (1990), 25–43.Google Scholar
Digital Library
- Martin Sulzmann, Manuel Chakravarty, Simon Peyton Jones, and Kevin Donnelly. 2007. System F with Type Equality Coercions. In TLDI.Google Scholar
- Philip Wadler. 1989. The Concatenate Vanishes. University of Glasgow.Google Scholar
- 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 Scholar
Digital Library
Index Terms
Calculating dependently-typed compilers (functional pearl)
Recommendations
Bidirectional Elaboration of Dependently Typed Programs
PPDP '14: Proceedings of the 16th International Symposium on Principles and Practice of Declarative ProgrammingDependently typed programming languages allow programmers to express a rich set of invariants and verify them statically via type checking. To make programming with dependent types practical, dependently typed systems provide a compact language for ...
Dependently typed programming in Agda
TLDI '09: Proceedings of the 4th international workshop on Types in language design and implementationDependently typed languages have for a long time been used to describe proofs about programs. Traditionally, dependent types are used mostly for stating and proving the properties of the programs and not in defining the programs themselves. An ...
Intrinsically-typed definitional interpreters for imperative languages
A definitional interpreter defines the semantics of an object language in terms of the (well-known) semantics of a host language, enabling understanding and validation of the semantics through execution. Combining a definitional interpreter with a ...






Comments