Affiliation:
1. Delft University of Technology, Netherlands
2. Radboud University Nijmegen, Netherlands / Delft University of Technology, Netherlands
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.
Publisher
Association for Computing Machinery (ACM)
Subject
Safety, Risk, Reliability and Quality,Software
Reference48 articles.
1. Andreas Abel. 2020. Type-preserving compilation via dependently typed syntax in Agda. Abstract of a talk at TYPES available online at http://www.cse.chalmers.se/~abela/types20.pdf slides available online at http://www.cse.chalmers.se/ ~abela/talkTYPES2020.pdf. Andreas Abel. 2020. Type-preserving compilation via dependently typed syntax in Agda. Abstract of a talk at TYPES available online at http://www.cse.chalmers.se/~abela/types20.pdf slides available online at http://www.cse.chalmers.se/ ~abela/talkTYPES2020.pdf.
2. Thorsten Altenkirch James Chapman and Tarmo Uustalu. 2015. Monads need not be endofunctors. Logical Methods in Computer Science (LMCS) 11 1 ( 2015 ). https://doi.org/10.2168/LMCS-11 ( 1 :3) 2015 10.2168/LMCS-11(1:3)2015 Thorsten Altenkirch James Chapman and Tarmo Uustalu. 2015. Monads need not be endofunctors. Logical Methods in Computer Science (LMCS) 11 1 ( 2015 ). https://doi.org/10.2168/LMCS-11 ( 1 :3) 2015 10.2168/LMCS-11(1:3)2015
3. Foundational proof-carrying code
4. Compiling with Continuations
Cited by
5 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Intrinsically Typed Syntax, a Logical Relation, and the Scourge of the Transfer Lemma;Proceedings of the 9th ACM SIGPLAN International Workshop on Type-Driven Development;2024-08-28
2. An Intrinsically Typed Compiler for Algebraic Effect Handlers;Proceedings of the 2024 ACM SIGPLAN International Workshop on Partial Evaluation and Program Manipulation;2024-01-11
3. Special Delivery: Programming with Mailbox Types;Proceedings of the ACM on Programming Languages;2023-08-30
4. Connectivity graphs: a method for proving deadlock freedom based on separation logic;Proceedings of the ACM on Programming Languages;2022-01-12
5. Calculating dependently-typed compilers (functional pearl);Proceedings of the ACM on Programming Languages;2021-08-22