Intrinsically typed compilation with nameless labels

Journal Article (2021)
Author(s)

Arjen Rouvoet (TU Delft - Programming Languages)

Robbert Krebbers (Radboud Universiteit Nijmegen, TU Delft - Programming Languages)

Eelco Visser (TU Delft - Programming Languages)

Research Group
Programming Languages
Copyright
© 2021 A.J. Rouvoet, R.J. Krebbers, Eelco Visser
DOI related publication
https://doi.org/10.1145/3434303
More Info
expand_more
Publication Year
2021
Language
English
Copyright
© 2021 A.J. Rouvoet, R.J. Krebbers, Eelco Visser
Research Group
Programming Languages
Issue number
POPL
Volume number
5
Reuse Rights

Other than for strictly personal use, it is not permitted to download, forward or distribute the text or part of it, without the consent of the author(s) and/or copyright holder(s), unless the work is under an open content license such as Creative Commons.

Abstract

To avoid compilation errors it is desirable to verify that a compiler is type correct-i.e., given well-typed source code, it always outputs well-typed target code. This can be done intrinsically by implementing it as a function in a dependently typed programming language, such as Agda. This function manipulates data types of well-typed source and target programs, and is therefore type correct by construction. A key challenge in implementing an intrinsically typed compiler is the representation of labels in bytecode. Because label names are global, bytecode typing appears to be inherently a non-compositional, whole-program property. The individual operations of the compiler do not preserve this property, which requires the programmer to reason about labels, which spoils the compiler definition with proof terms. In this paper, we address this problem using a new nameless and co-contextual representation of typed global label binding, which is compositional. Our key idea is to use linearity to ensure that all labels are defined exactly once. To write concise compilers that manipulate programs in our representation, we develop a linear, dependently typed, shallowly embedded language in Agda, based on separation logic. We show that this language enables the concise specification and implementation of intrinsically typed operations on bytecode, culminating in an intrinsically typed compiler for a language with structured control-flow.