Veriml: a Dependently-Typed, User-Extensible and Language-Centric Approach to Proof Assistants
Total Page:16
File Type:pdf, Size:1020Kb
Abstract VeriML: A dependently-typed, user-extensible and language-centric approach to proof assistants Antonios Michael Stampoulis 2013 Software certification is a promising approach to producing programs which are virtually free of bugs. It requires the construction of a formal proof which establishes that the code in question will behave according to its specification – a higher-level description of its functionality. The construction of such formal proofs is carried out in tools called proof assistants. Advances in the current state-of-the-art proof assistants have enabled the certification of a number of complex and realistic systems software. Despite such success stories, large-scale proof development is an arcane art that requires significant manual effort and is extremely time-consuming. The widely accepted best practice for limiting this effort is to develop domain- specific automation procedures to handle all but the most essential steps of proofs. Yet this practice is rarely followed or needs comparable development effort as well. This is due to a profound architectural shortcoming of existing proof assistants: developing automation procedures is currently overly complicated and error-prone. It involves the use of an amalgam of extension languages, each with a different programming model and a set of limitations, and with significant interfacing problems between them. This thesis posits that this situation can be significantly improved by designing a proof assistant with extensibil- ity as the central focus. Towards that effect, I have designed a novel programming language called VeriML, which combines the benefits of the different extension languages used in current proof assistants while eschewing their limitations. The key insight of the VeriML design is to combine a rich programming model with a rich type system, which retains at the level of types information about the proofs manipulated inside automation procedures. The ef- fort required for writing new automation procedures is significantly reduced by leveraging this typing information accordingly. I show that generalizations of the traditional features of proof assistants are a direct consequence of the VeriML design. Therefore the language itself can be seen as the proof assistant in its entirety and also as the single language the user has to master. Also, I show how traditional automation mechanisms offered by current proof assistants can be programmed directly within the same language; users are thus free to extend them with domain-specific sophistication of arbitrary complexity. In this dissertation I present all aspects of the VeriML language: the formal definition of the language; an ex- tensive study of its metatheoretic properties; the details of a complete prototype implementation; and a number of examples implemented and tested in the language. VeriML: A dependently-typed, user-extensible and language-centric approach to proof assistants A Dissertation Presented to the Faculty of the Graduate School of Yale University in Candidacy for the Degree of Doctor of Philosophy by Antonios Michael Stampoulis Dissertation Director: Zhong Shao May 2013 Copyright c 2013 by Antonios Michael Stampoulis All rights reserved. ii Contents List of Figures v List of Tables viii List of Code Listings ix Acknowledgements xi 1 Introduction 1 1.1 Problem description . .2 1.2 Thesis statement . .4 1.3 Summary of results . .5 2 Informal overview 8 2.1 Proof assistant architecture . .8 2.1.1 Preliminary notions . .8 2.1.2 Variations . 11 2.1.3 Issues . 18 2.2 A new architecture: VeriML . 19 2.3 Brief overview of the language . 23 3 The logic λHOL: Basic framework 35 3.1 The base λHOL logic . 35 3.2 Adding equality . 39 3.3 λHOL as a Pure Type System . 42 3.4 λHOL using hybrid deBruijn variables . 44 4 The logic λHOL: Extension variables 54 4.1 λHOL with metavariables . 54 4.2 λHOL with extension variables . 62 4.3 Constant schemata in signatures . 73 4.4 Named extension variables . 74 5 The logic λHOL: Pattern matching 77 5.1 Pattern matching . 77 5.2 Collapsing extension variables . 105 iii 6 The VeriML computational language 112 6.1 Base computation language . 112 6.1.1 Presentation and formal definition . 112 6.1.2 Metatheory . 121 6.2 Derived pattern matching forms . 128 6.3 Staging . 134 6.4 Proof erasure . 141 7 User-extensible static checking 145 7.1 User-extensible static checking for proofs . 149 7.1.1 The extensible conversion rule . 149 7.1.2 Proof object expressions as certificates . 158 7.2 User-extensible static checking for tactics . 160 7.3 Programming with dependently-typed data structures . 167 8 Prototype implementation 176 8.1 Overview............................................................ 176 8.2 Logic implementation . 178 8.2.1 Type inference for logical terms . 180 8.2.2 Inductive definitions . 184 8.3 Computational language implementation . 187 8.3.1 Surface syntax extensions . 188 8.3.2 Translation to OCaml . 192 8.3.3 Staging . 194 8.3.4 Proof erasure . 195 8.3.5 VeriML as a toplevel and VeriML as a translator . 195 9 Examples and Evaluation 197 9.1 Basic support code . 197 9.2 Extensible rewriters . 200 9.3 Naive equality rewriting . 205 9.4 Equality with uninterpreted functions . 205 9.5 Automated proof search for first-order formulas . 212 9.6 Natural numbers . 215 9.7 Normalizing natural number expressions . 220 9.8 Evaluation . 224 10 Related work 227 10.1 Development of tactics and proof automation . 227 10.2 Proof assistant architecture . 233 10.3 Extensibility of the conversion rule . 234 10.4 Type-safe manipulation of languages with binding . 235 10.5 Mixing logic with computation . 236 11 Conclusion and future work 238 iv Bibliography 244 v List of Figures 2.1 Basic architecture of proof assistants . .9 2.2 Programming languages available for writing automation procedures in the Coq architecture . 15 2.3 Comparison of architecture between current proof assistants and VeriML . 19 2.4 Comparison of small-scale automation approach between current proof assistants and VeriML . 21 3.1 The base syntax of the logic λHOL........................................... 36 3.2 The typing rules of the logic λHOL .......................................... 36 3.3 The typing rules of the logic λHOL (continued) . 37 3.4 Capture avoiding substitution . 37 3.5 The logic λHOLE : syntax and typing extensions for equality . 41 3.6 The syntax of the logic λHOL given as a PTS . 42 3.7 The typing rules of the logic λHOL in PTS style . ..