Extracting the Power of Dependent Types

被引:1
|
作者
Sinkarovs, Artjoms [1 ]
Cockx, Jesper [2 ]
机构
[1] Heriot Watt Univ, Edinburgh, Midlothian, Scotland
[2] Delft Univ Technol, Delft, Netherlands
基金
英国工程与自然科学研究理事会; 荷兰研究理事会;
关键词
embedded languages; program extraction; program verification; dependent types; reflection; Agda; DESIGN;
D O I
10.1145/3486609.3487201
中图分类号
TP18 [人工智能理论];
学科分类号
081104 ; 0812 ; 0835 ; 1405 ;
摘要
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.
引用
收藏
页码:83 / 95
页数:13
相关论文
共 50 条
  • [41] A Role for Dependent Types in Haskell
    Weirich, Stephanie
    Choudhury, Pritam
    Voizard, Antoine
    Eisenberg, Richard A.
    PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL, 2019, 3 (ICFP):
  • [42] Cayenne - A language with dependent types
    Augustsson, L
    ADVANCED FUNCTIONAL PROGRAMMING, 1999, 1608 : 240 - 267
  • [43] Dependent Types for Extensive Games
    Lescanne, Pierre
    JOURNAL OF FORMALIZED REASONING, 2018, 11 (01): : 1 - 17
  • [44] Polynomial Time and Dependent Types
    Atkey, Robert
    PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL, 2024, 8 (POPL):
  • [45] Imperative Objects with Dependent Types
    Campos, Joana
    Vasconcelos, Vasco T.
    17TH WORKSHOP ON FORMAL TECHNIQUES FOR JAVA-LIKE PROGRAMS (FTFJP 2015), 2015,
  • [46] Simple Dependent Types for OSTRICH
    Parreira, Joana
    INTEGRATED FORMAL METHODS, IFM 2022, 2022, 13274 : 361 - 364
  • [47] Generic programming with dependent types
    Altenkirch, Thorsten
    McBride, Conor
    Morris, Peter
    DATATYPE-GENERIC PROGRAMMING, 2007, 4719 : 209 - 257
  • [48] Dependent types for program understanding
    Komondoor, R
    Ramalingam, G
    Chandra, S
    Field, J
    TOOLS AND ALGORITHMS FOR THE CONSTRUCTION AND ANALYSIS OF SYSTEMS, PROCEEDINGS, 2005, 3440 : 157 - 173
  • [49] A specification for dependent types in haskell
    Weirich S.
    Voizard A.
    De Amorim P.H.A.
    Eisenberg R.A.
    1600, Association for Computing Machinery (01):
  • [50] Cayenne - a language with dependent types
    Augustsson, L
    ACM SIGPLAN NOTICES, 1999, 34 (01) : 239 - 250