Hostname: page-component-8448b6f56d-tj2md Total loading time: 0 Render date: 2024-04-23T11:03:53.768Z Has data issue: false hasContentIssue false

Implementing type theory in higher order constraint logic programming

Published online by Cambridge University Press:  01 March 2019

FERRUCCIO GUIDI
Affiliation:
Department of Computer Science and Engineering, University of Bologna, Italy Email: ferruccio.guidi@unibo.it, claudio.sacerdoticoen@unibo.it
CLAUDIO SACERDOTI COEN
Affiliation:
Department of Computer Science and Engineering, University of Bologna, Italy Email: ferruccio.guidi@unibo.it, claudio.sacerdoticoen@unibo.it
ENRICO TASSI
Affiliation:
Université Côte d’Azur, Inria Sophia-Antipolis, France Email: Enrico.Tassi@inria.fr

Abstract

In this paper, we are interested in high-level programming languages to implement the core components of an interactive theorem prover for a dependently typed language: the kernel – responsible for type-checking closed terms – and the elaborator – that manipulates open terms, that is terms containing unresolved unification variables.

In this paper, we confirm that λProlog, the language developed by Miller and Nadathur since the 80s, is extremely suitable for implementing the kernel. Indeed, we easily obtain a type checker for the Calculus of Inductive Constructions (CIC). Even more, we do so in an incremental way by escalating a checker for a pure type system to the full CIC.

We then turn our attention to the elaborator with the objective to obtain a simple implementation thanks to the features of the programming language. In particular, we want to use λProlog’s unification variables to model the object language ones. In this way, scope checking, carrying of assignments and occur checking are handled by the programming language.

We observe that the eager generative semantics inherited from Prolog clashes with this plan. We propose an extension to λProlog that allows to control the generative semantics, suspend goals over flexible terms turning them into constraints, and finally manipulate these constraints at the meta-meta level via constraint handling rules.

We implement the proposed language extension in the Embedded Lambda Prolog Interpreter system and we discuss how it can be used to extend the kernel into an elaborator for CIC.

Type
Paper
Copyright
© Cambridge University Press 2019 

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

References

Andersson, J., Andersson, S., Boortz, K., Carlsson, M., Nilsson, H., Sjöland, T. and Widen, J. (1993). SICStus Prolog User’s Manual. Technical report.Google Scholar
Asperti, A., Ricciotti, W., Sacerdoti Coen, C. and Tassi, E. (2009). Hints in unification. In: Proceedings of the 22nd International Conference on Theorem Proving in Higher Order Logics, Munich, Germany, August 17–20, 84–98.CrossRefGoogle Scholar
Asperti, A., Ricciotti, W., Sacerdoti Coen, C. and Tassi, E. (2011). The Matita Interactive Theorem Prover, Berlin, Heidelberg: Springer, 6469. ISBN 978-3-642-22438-6.Google Scholar
Asperti, A., Ricciotti, W., Sacerdoti Coen, C. and Tassi, E. (2012). A bi-directional refinement algorithm for the calculus of (co)inductive constructions. Logical Methods in Computer Science 8 (1) 149.CrossRefGoogle Scholar
Asperti, A., Ricciotti, W. and Sacerdoti Coen, C. (2014). Matita tutorial. Journal of Formalized Reasoning 7 (2) 91199. ISSN 1972-5787. Available at https://jfr.unibo.it/article/view/4651.Google Scholar
Baelde, D., Chaudhuri, K., Gacek, A., Miller, D., Nadathur, G., Tiu, A. and Wang, Y. (2014). Abella: A system for reasoning about relational specifications. Journal of Formalized Reasoning 7 (2) 189. ISSN .Google Scholar
Barras, B. (Nov. 1999). Auto-Validation d’un système de preuves avec familles inductives. Thèse de doctorat, Université Paris 7.Google Scholar
Belleanne, C., Brisset, P. and Ridoux, O. (1999). A pragmatic reconstruction of Lambda-Prolog. Journal of Logic Programming 41 (1) 67102.CrossRefGoogle Scholar
Bertot, Y., Gonthier, G., OuldBiha, S. Biha, S. and Pasca, I. (2008). Canonical big operators. In: Mohamed, O.A., Munoz, C. and Tahar, S. (eds.) Theorem Proving in Higher Order Logics, Springer, Berlin, Heidelberg, 86101. ISBN 978-3-540-71067-7.CrossRefGoogle Scholar
Boespflug, M., Carbonneaux, Q. and Hermant, O. (2012). The lambda-pi-calculus modulo as a universal proof language. In: Proceedings of the 2nd International Workshop on Proof Exchange for Theorem Proving, CEUR Workshop Proceedings, vol. 878, 28–43.Google Scholar
Coq development team. (2017). The Coq Proof Assistant Reference Manual, Inria.Google Scholar
de Moura, L., Avigad, J., Kong, S. and Roux, C. (2015a). Elaboration in dependent type theory. CoRR, abs/1505.04324.Google Scholar
de Moura, L., Kong, S., Avigad, J., vanDoorn, F. Doorn, F. and von Raumer, J. (2015b). The Lean Theorem Prover (System Description), Springer International Publishing, Cham, 378388. ISBN 978-3-319-21401-6.Google Scholar
Duck, G.J., Stuckey, P.J., de la Banda, M.G. and Holzbaur, C. (2004). The refined operational semantics of constraint handling rules. In: Demoen, B. and Lifschitz, V. (eds.) Logic Programming, Springer, Berlin, Heidelberg, 90104. ISBN 978-3-540-27775-0.CrossRefGoogle Scholar
Dunchev, C., Guidi, F., Sacerdoti Coen, C. and Tassi, E. (2015). ELPI: Fast, embeddable, λProlog interpreter. In: Proceedings of Logic for Programming, Artificial Intelligence and Reasoning.Google Scholar
Dunchev, C., Sacerdoti Coen, C. and Tassi, E. (2016). Implementing HOL in an higher order logic programming language. In: Proceedings of the 11th Workshop on Logical Frameworks and Meta-Languages: Theory and Practice, ACM, 4:1–4:10. ISBN 978-1-4503-4777-8.Google Scholar
Ebner, G., Ullrich, S., Roesch, J., Avigad, J. and de Moura, L. (Aug. 2017). A metaprogramming framework for formal verification. In: Proceedings of the ACM Programming Languages, vol. 1, 34:1–34:29. ISSN .Google Scholar
Felty, A. and Miller, D. (1988). Specifying theorem provers in a higher-order logic programming language. In: Lusk, E. and Overbeek, R. (eds.) Proceedings of the 9th International Conference on Automated Deduction, Argonne, Illinois, USA, Springer, Berlin, Heidelberg, 61–80.CrossRefGoogle Scholar
Felty, A.P. and Miller, D. (1990). Encoding a dependent-type lambda-calculus in a logic programming language. In: Proceedings of the 10th International Conference on Automated Deduction, London, UK: Springer-Verlag, 221–235. ISBN 3-540-52885-7.Google Scholar
Geuvers, H. and Jojgov, G.I. (2002). Open proofs and open terms: A basis for interactive logic. In: Proceedings of the 16th International Workshop on Computer Science Logic, 11th Annual Conference of the European Association for Computer Science Logic, Edinburgh, Scotland, UK, September 22–25, 537–552.CrossRefGoogle Scholar
Gonthier, G., Asperti, A., Avigad, J., Bertot, Y., Cohen, C., Garillot, F., LeRoux, S. Roux, S., Mahboubi, A., O’Connor, R., OuldBiha, S. Biha, S.. Pasca, I., Rideau, L., Solovyev, A., Tassi, E. and Théry, L. (2013). A machine-checked proof of the odd order theorem. In: International Conference on Interactive Theorem Proving, Lecture Notes in Computer Science, vol. 7998, Springer, 163179.CrossRefGoogle Scholar
Herbelin, H. (2005). Type inference with algebraic universes in the calculus of inductive constructions. Unpublished. Available at: pauillac.inria.fr/~herbelin/publis/univalgcci.pdfGoogle Scholar
Libal, T. and Miller, D. (2016). Functions-as-constructors higher-order unification. In: Proceedings of the 1st International Conference on Formal Structures for Computation and Deduction, Porto, Portugal, Delia Kesner and Brigitte Pientka, 1–17.Google Scholar
Luo, Z. (1989). ECC, an extended calculus of constructions. In: Proceedings of the Fourth Annual Symposium on Logic in Computer Science, Pacific Grove, California, USA, 386–395.CrossRefGoogle Scholar
Luo, Z. (1996). Coercive subtyping in type theory. In: Proceedings of the 10th International Workshop on Computer Science Logic, Annual Conference of the European Association for Computer Science Logic, Utrecht, the Netherlands, September 21–27, Selected Papers, 276–296.Google Scholar
Luo, Z., Soloviev, S. and Xue, T. (2013). Coercive subtyping: Theory and implementation. Information and Computation 223 1842. ISSN .CrossRefGoogle Scholar
Mahboubi, A. and Tassi, E. (July 2013). Canonical structures for the working Coq user. In: Blazy, S., Paulin, C. and Pichardie, D. (eds.) 4th Conference on Interactive Theorem Proving, Lecture Notes in Computer Science, vol. 7998, Rennes, France: Springer, 19–34.Google Scholar
Mazzoli, F. and Abel, A. (2016). Type checking through unification. CoRR, abs/1609.09709.Google Scholar
Miller, D. (1992). Unification under a mixed prefix. Journal of Symbolic Computation 14 (4) 321358CrossRefGoogle Scholar
Miller, D. and Nadathur, G. (1986). Higher-order logic programming. In: Proceedings of the 3rd International Conference Logic Programming, Lecture Notes in Computer Science, vol. 225, Springer-Verlag, 448–462.CrossRefGoogle Scholar
Miller, D. and Nadathur, G. (2012). Programming with Higher-Order Logic, 1st edition, Cambridge University Press. ISBN 052187940X, 9780521879408.CrossRefGoogle Scholar
Miller, D., Nadathur, G., Pfenning, F. and Scedrov, A. (1991). Uniform proofs as a foundation for logic programming. Annals of Pure and Applied Logic 51 (1–2) 125157.CrossRefGoogle Scholar
Norell, U. (2009). Dependently typed programming in Agda. In: Proceedings of the 6th International Conference on Advanced Functional Programming, Springer-Verlag, 230–266. ISBN 3-642-04651-7, 978-3-642-04651-3.CrossRefGoogle Scholar
Paulin-Mohring, C. (Dec. 1996). Définitions Inductives en Théorie des Types d’Ordre Supérieur. Habilitation à diriger les recherches, Université Claude Bernard Lyon I.Google Scholar
Qi, X., Gacek, A., Holte, S., Nadathur, G. and Snow, Z. (2015). The Teyjus System – Version 2. Available at: http://teyjus.cs.umn.edu/Google Scholar
Rabe, F. (2013). The MMT API: A generic MKM system. In: Carette, J., Aspinall, D., Lange, C., Sojka, P. and Windsteiger, W. (eds.) Intelligent Computer Mathematics, Springer, 339343.CrossRefGoogle Scholar
Roberto Blanco, D.M. and Chihani, Z. (2017). Translating between implicit and explicit versions of proof. In: Conference on Automated Deduction 26.Google Scholar
Sacerdoti Coen, C. and Tassi, E. (2008). Working with mathematical structures in type theory. In: Miculan, M., Scagnetto, I. and Honsell, F. (eds.) Types for Proofs and Programs, Springer, Berlin, Heidelberg, 157172. ISBN 978-3-540-68103-8.CrossRefGoogle Scholar
Sacerdoti Coen, C. and Tassi, E. (2009). Nonuniform coercions via unification hints. In: Proceedings TYPES, 16–29.Google Scholar
Sacerdoti Coen, C., Tassi, E. and Zacchiroli, S. (2007). Tinycals: Step by step tacticals. Electronic Notes in Theoretical Computer Science 174 (2) 125142. Available at: https://doi.org/10.1016/j.entcs.2006.09.026.CrossRefGoogle Scholar
Snow, Z., Baelde, D. and Nadathur, G. (2010). A meta-programming approach to realizing dependently typed logic programming. In Proceedings of the 12th International ACM SIGPLAN Symposium on Principles and Practice of Declarative Programming, New York, NY, USA: ACM, 187–198. ISBN 978-1-4503-0132-9.CrossRefGoogle Scholar
Werner, B. (1994). Une Théorie des Constructions Inductives. PhD thesis, Université Paris VII.Google Scholar
Wielemaker, J., Schrijvers, T., Triska, M. and Lager, T. (2012). SWI-Prolog. Theory and Practice of Logic Programming 12 (1–2) 6796.CrossRefGoogle Scholar