Type Theory Unchained: Extending Agda with User-Defined Rewrite Rules

Author Jesper Cockx



PDF
Thumbnail PDF

File

LIPIcs.TYPES.2019.2.pdf
  • Filesize: 0.57 MB
  • 27 pages

Document Identifiers

Author Details

Jesper Cockx
  • Department of Software Technology, TU Delft, The Netherlands

Cite AsGet BibTex

Jesper Cockx. Type Theory Unchained: Extending Agda with User-Defined Rewrite Rules. In 25th International Conference on Types for Proofs and Programs (TYPES 2019). Leibniz International Proceedings in Informatics (LIPIcs), Volume 175, pp. 2:1-2:27, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2020)
https://doi.org/10.4230/LIPIcs.TYPES.2019.2

Abstract

Dependently typed languages such as Coq and Agda can statically guarantee the correctness of our proofs and programs. To provide this guarantee, they restrict users to certain schemes - such as strictly positive datatypes, complete case analysis, and well-founded induction - that are known to be safe. However, these restrictions can be too strict, making programs and proofs harder to write than necessary. On a higher level, they also prevent us from imagining the different ways the language could be extended. In this paper I show how to extend a dependently typed language with user-defined higher-order non-linear rewrite rules. Rewrite rules are a form of equality reflection that is applied automatically by the typechecker. I have implemented rewrite rules as an extension to Agda, and I give six examples how to use them both to make proofs easier and to experiment with extensions of type theory. I also show how to make rewrite rules interact well with other features of Agda such as η-equality, implicit arguments, data and record types, irrelevance, and universe level polymorphism. Thus rewrite rules break the chains on computation and put its power back into the hands of its rightful owner: yours.

Subject Classification

ACM Subject Classification
  • Theory of computation → Rewrite systems
  • Theory of computation → Equational logic and rewriting
  • Theory of computation → Type theory
Keywords
  • Dependent types
  • Proof assistants
  • Rewrite rules
  • Higher-order rewriting
  • Agda

Metrics

  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    0
    PDF Downloads

References

  1. Agda development team. Agda 2.6.1 documentation, 2020. URL: http://agda.readthedocs.io/en/v2.6.1/.
  2. Guillaume Allais, Conor McBride, and Pierre Boutillier. New equations for neutral terms: a sound and complete decision procedure, formalized. In Stephanie Weirich, editor, Proceedings of the 2013 ACM SIGPLAN workshop on Dependently-typed programming, DTP@ICFP 2013, Boston, Massachusetts, USA, September 24, 2013, pages 13-24. ACM, 2013. URL: https://doi.org/10.1145/2502409.2502411.
  3. Thorsten Altenkirch, Conor McBride, and Wouter Swierstra. Observational equality, now! In Proceedings of the 2007 workshop on Programming languages meets program verification, pages 57-68. ACM, 2007. Google Scholar
  4. Ali Assaf and Guillaume Burel. Translating HOL to dedukti. In Cezary Kaliszyk and Andrei Paskevich, editors, Proceedings Fourth Workshop on Proof eXchange for Theorem Proving, PxTP 2015, Berlin, Germany, August 2-3, 2015., volume 186 of EPTCS, pages 74-88, 2015. URL: https://doi.org/10.4204/EPTCS.186.8.
  5. Franco Barbanera, Maribel Fernández, and Herman Geuvers. Modularity of strong normalization in the algebraic-lambda-cube. Journal of Functional Programming, 7(6):613-660, 1997. Google Scholar
  6. Bruno Barras, Jean-Pierre Jouannaud, Pierre-Yves Strub, and Qian Wang. CoQMTU: A higher-order type theory with a predicative hierarchy of universes parametrized by a decidable first-order theory. In Proceedings of the 26th Annual IEEE Symposium on Logic in Computer Science, LICS 2011, June 21-24, 2011, Toronto, Ontario, Canada, pages 143-151. IEEE Computer Society, 2011. URL: https://doi.org/10.1109/LICS.2011.37.
  7. Frédéric Blanqui. Definitions by rewriting in the calculus of constructions. Mathematical Structures in Computer Science, 15(1):37-92, 2005. URL: https://doi.org/10.1017/S0960129504004426.
  8. Frédéric Blanqui. Type safety of rewriting rules in dependent types. In At the 26th Internationan Conference on Types for Proofs and Programs (TYPES 2020), 2020. Google Scholar
  9. Frédéric Blanqui, Guillaume Genestier, and Olivier Hermant. Dependency pairs termination in dependent type theory modulo rewriting. In Herman Geuvers, editor, 4th International Conference on Formal Structures for Computation and Deduction, FSCD 2019, June 24-30, 2019, Dortmund, Germany., volume 131 of LIPIcs, pages 9:1-9:21. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2019. URL: https://doi.org/10.4230/LIPIcs.FSCD.2019.9.
  10. Mathieu Boespflug, Quentin Carbonneaux, and Olivier Hermant. The λπ-calculus modulo as a universal proof language. In the Second International Workshop on Proof Exchange for Theorem Proving (PxTP 2012), 2012. Google Scholar
  11. Jacek Chrzaszcz. Modules in Coq are and will be correct. In Stefano Berardi, Mario Coppo, and Ferruccio Damiani, editors, Types for Proofs and Programs, International Workshop, TYPES 2003, Torino, Italy, April 30 - May 4, 2003, Revised Selected Papers, volume 3085 of Lecture Notes in Computer Science, pages 130-146. Springer, 2003. URL: http://springerlink.metapress.com/openurl.asp?genre=article&issn=0302-9743&volume=3085&spage=130.
  12. Jacek Chrzaszcz and Daria Walukiewicz-Chrzaszcz. Towards rewriting in Coq. In Hubert Comon-Lundh, Claude Kirchner, and Hélène Kirchner, editors, Rewriting, Computation and Proof, Essays Dedicated to Jean-Pierre Jouannaud on the Occasion of His 60th Birthday, volume 4600 of Lecture Notes in Computer Science, pages 113-131. Springer, 2007. URL: https://doi.org/10.1007/978-3-540-73147-4_6.
  13. Manuel Clavel, Francisco Durán, Steven Eker, Patrick Lincoln, Narciso Martí-Oliet, José Meseguer, and Jose F. Quesada. Maude: specification and programming in rewriting logic. Theoretical Computer Science, 285(2):187-243, 2002. URL: https://doi.org/10.1016/S0304-3975(01)00359-0.
  14. Jesper Cockx, Frank Piessens, and Dominique Devriese. Overlapping and order-independent patterns - definitional equality for all. In Zhong Shao, editor, Programming Languages and Systems - 23rd European Symposium on Programming, ESOP 2014, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2014, Grenoble, France, April 5-13, 2014, Proceedings, volume 8410 of Lecture Notes in Computer Science, pages 87-106. Springer, 2014. URL: https://doi.org/10.1007/978-3-642-54833-8_6.
  15. Denis Cousineau and Gilles Dowek. Embedding pure type systems in the lambda-pi-calculus modulo. In Simona Ronchi Della Rocca, editor, Typed Lambda Calculi and Applications, 8th International Conference, TLCA 2007, Paris, France, June 26-28, 2007, Proceedings, volume 4583 of Lecture Notes in Computer Science, pages 102-117. Springer, 2007. URL: https://doi.org/10.1007/978-3-540-73228-0_9.
  16. Gaëtan Gilbert, Jesper Cockx, Matthieu Sozeau, and Nicolas Tabareau. Definitional proof-irrelevance without K. PACMPL, 3(POPL):3:1-3:28, 2019. URL: https://doi.org/10.1145/3290316.
  17. Robert Harper, Furio Honsell, and Gordon D. Plotkin. A framework for defining logics. Journal of the ACM, 40(1):143-184, 1993. URL: https://doi.org/10.1145/138027.138060.
  18. Jean-Pierre Jouannaud and Pierre-Yves Strub. Coq without type casts: A complete proof of Coq modulo theory. In Thomas Eiter and David Sands, editors, LPAR-21, 21st International Conference on Logic for Programming, Artificial Intelligence and Reasoning, Maun, Botswana, May 7-12, 2017, volume 46 of EPiC Series in Computing, pages 474-489. EasyChair, 2017. URL: http://www.easychair.org/publications/paper/340342.
  19. Per Martin-Löf. Intuitionistic type theory, volume 1 of Studies in proof theory. Bibliopolis, 1984. Google Scholar
  20. Richard Mayr and Tobias Nipkow. Higher-order rewrite systems and their confluence. Theoretical Computer Science, 192(1):3-29, 1998. URL: https://doi.org/10.1016/S0304-3975(97)00143-6.
  21. Dale Miller. A logic programming language with lambda-abstraction, function variables, and simple unification. J. Log. Comput., 1(4):497-536, 1991. URL: https://doi.org/10.1093/logcom/1.4.497.
  22. Ulf Norell. Towards a practical programming language based on dependent type theory. PhD thesis, Department of Computer Science and Engineering, Chalmers University of Technology, SE-412 96 Göteborg, Sweden, September 2007. Google Scholar
  23. Pierre-Marie Pédrot and Nicolas Tabareau. Failure is not an option - an exceptional type theory. In Amal Ahmed, editor, Programming Languages and Systems - 27th European Symposium on Programming, ESOP 2018, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2018, Thessaloniki, Greece, April 14-20, 2018, Proceedings, Lecture Notes in Computer Science, pages 245-271. Springer, 2018. URL: https://doi.org/10.1007/978-3-319-89884-1_9.
  24. Ronan Saillard. Typechecking in the lambda-Pi-Calculus Modulo: Theory and Practice. PhD thesis, MINES ParisTech, 2015. Google Scholar
  25. Vilhelm Sjöberg and Stephanie Weirich. Programming up to congruence. In Sriram K. Rajamani and David Walker, editors, Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2015, Mumbai, India, January 15-17, 2015, pages 369-382. ACM, 2015. URL: https://doi.org/10.1145/2676726.2676974.
  26. Mark-Oliver Stehr. The open calculus of constructions (part i): An equational type theory with dependent types for programming, specification, and interactive theorem proving. Fundamenta Informaticae, 68(1-2):131-174, 2005. Google Scholar
  27. Mark-Oliver Stehr. The open calculus of constructions (part ii): An equational type theory with dependent types for programming, specification, and interactive theorem proving. Fundamenta Informaticae, 68(3):249-288, 2005. Google Scholar
  28. Pierre-Yves Strub. Coq Modulo Theory. In Anuj Dawar and Helmut Veith, editors, Computer Science Logic, 24th International Workshop, CSL 2010, 19th Annual Conference of the EACSL, Brno, Czech Republic, August 23-27, 2010. Proceedings, volume 6247 of Lecture Notes in Computer Science, pages 529-543. Springer, 2010. URL: https://doi.org/10.1007/978-3-642-15205-4_40.
  29. Val Tannen. Combining algebra and higher-order types. In Proceedings, Third Annual Symposium on Logic in Computer Science, 5-8 July 1988, Edinburgh, Scotland, UK, pages 82-90. IEEE Computer Society, 1988. Google Scholar
  30. The Univalent Foundations Program. Homotopy Type Theory - Univalent Foundations of Mathematics: The Univalent Foundations Program. Institute for Advanced Study, 2013. URL: https://homotopytypetheory.org/book/.
  31. Daria Walukiewicz-Chrzaszcz. Termination of rewriting in the calculus of constructions. Journal of Functional Programming, 13(2):339-414, 2003. URL: https://doi.org/10.1017/S0956796802004641.
  32. Daria Walukiewicz-Chrzaszcz and Jacek Chrzaszcz. Consistency and completeness of rewriting in the calculus of constructions. In Ulrich Furbach and Natarajan Shankar, editors, Automated Reasoning, Third International Joint Conference, IJCAR 2006, Seattle, WA, USA, August 17-20, 2006, Proceedings, volume 4130 of Lecture Notes in Computer Science, pages 619-631. Springer, 2006. URL: https://doi.org/10.1007/11814771_50.
Questions / Remarks / Feedback
X

Feedback for Dagstuhl Publishing


Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail