Abstract
Most existing programming languages provide little support to formally state and prove properties about programs. Adding such capabilities is far from trivial, as it requires significant re-engineering of the existing compilers and tools. This paper proposes a novel technique to write correct-by-construction programs in languages without built-in verification capabilities, while maintaining the ability to use existing tools. This is achieved in three steps. Firstly, we give a shallow embedding of the language (or a subset) into a dependently typed language. Secondly, we write a program in that embedding, and we use dependent types to guarantee correctness properties of interest within the embedding. Thirdly, we extract a program written in the original language, so it can be used with existing compilers and tools. Our main insight is that it is possible to express all three steps in a single language that supports both dependent types and reflection. Essentially, this allows us to express a program, its formal properties, and a compiler for it hand-in-hand, offering a lot of flexibility to programmers. We demonstrate this three-step approach by embedding a subset of the PostScript language in Agda, and illustrating it with several short examples. Thus we use the power of reflection to bring the benefits of dependent types to languages that had to go without them so far.
Original language | English |
---|---|
Title of host publication | GPCE 2021: Proceedings of the 20th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences |
Editors | Eli Tilevich, Coen De Roover |
Publisher | Association for Computing Machinery |
Pages | 83-95 |
Number of pages | 13 |
ISBN (Electronic) | 9781450391122 |
DOIs | |
Publication status | Published - 22 Nov 2021 |
Event | 20th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences - Virtual, Online, United States Duration: 17 Oct 2021 → 18 Oct 2021 |
Conference
Conference | 20th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences |
---|---|
Abbreviated title | GPCE 2021 |
Country/Territory | United States |
City | Virtual, Online |
Period | 17/10/21 → 18/10/21 |
Keywords
- Agda
- dependent types
- embedded languages
- program extraction
- program verification
- reflection
ASJC Scopus subject areas
- Information Systems
- Software
- Computer Science Applications