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.

Highlights

  • Bahr and Hutton [2015] recently presented a new approach to developing compilers whose correctness is guaranteed by the manner in which they are constructed

  • We begin by defining the syntax of the source language, and a semantics for this language

  • Using the approach developed by Bahr and Hutton [2015] we can use elementary reasoning techniques to permit the calculation of compilers for a wide range of source language features and their combination

Read more

Summary

INTRODUCTION

Bahr and Hutton [2015] recently presented a new approach to developing compilers whose correctness is guaranteed by the manner in which they are constructed. Compiler calculations in the above approach are developed in the setting of Haskell [Marlow 2010], a statically-typed, purely-functional programming language. Mitchell Pickard and Graham Hutton a single base type, the integers This simplification played a key role in the development of the approach, but places limitations on the range of source languages that can be considered, and means that the benefits of static typing are not available in the methodology. We show how Bahr and Hutton’s approach to calculating compilers can naturally be adapted to well-typed source and target languages, by moving from the setting of Haskell to the dependently-typed language Agda [Norell 2007]. The article is targeted at readers with experience of a functional language such as Haskell, but does not assume specialist knowledge of Agda, dependent types or compiler calculation, and is written in a tutorial style to make the ideas accessible to a broader audience. The supplementary material for the article includes verified versions of all the calculations in Agda

EXPRESSION LANGUAGE
Source Language
Compiler Specification
Compiler Calculation
Reflection
CODE CONTINUATIONS
ADDING EXCEPTIONS
Semantics
Compiler Specification II
Summary
RELATED WORK
CONCLUSION AND FURTHER WORK

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.