Hostname: page-component-848d4c4894-nmvwc Total loading time: 0 Render date: 2024-06-28T11:33:30.816Z Has data issue: false hasContentIssue false

Type classes for mathematics in type theory

Published online by Cambridge University Press:  01 July 2011

BAS SPITTERS
Affiliation:
Radboud University Nijmegen, Nijmegen, The Netherlands Email: spitters@cs.ru.nl; eelis@eelis.net
EELIS VAN DER WEEGEN
Affiliation:
Radboud University Nijmegen, Nijmegen, The Netherlands Email: spitters@cs.ru.nl; eelis@eelis.net

Abstract

The introduction of first-class type classes in the Coq system calls for a re-examination of the basic interfaces used for mathematical formalisation in type theory. We present a new set of type classes for mathematics and take full advantage of their unique features to make practical a particularly flexible approach that was formerly thought to be unfeasible. Thus, we address traditional proof engineering challenges as well as new ones resulting from our ambition to build upon this development a library of constructive analysis in which any abstraction penalties inhibiting efficient computation are reduced to a minimum.

The basis of our development consists of type classes representing a standard algebraic hierarchy, as well as portions of category theory and universal algebra. On this foundation, we build a set of mathematically sound abstract interfaces for different kinds of numbers, succinctly expressed using categorical language and universal algebra constructions. Strategic use of type classes lets us support these high-level theory-friendly definitions, while still enabling efficient implementations unhindered by gratuitous indirection, conversion or projection.

Algebra thrives on the interplay between syntax and semantics. The Prolog-like abilities of type class instance resolution allow us to conveniently define a quote function, thus facilitating the use of reflective techniques.

Type
Paper
Copyright
Copyright © Cambridge University Press 2011

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

Armand, M., Grégoire, B., Spiwack, A. and Théry, L. (2010) Extending Coq with imperative features and its application to SAT verification. In: Kaufmann, M. and Paulson, L. (eds.) Proceedings, Interactive Theorem Proving, ITP 2010. Springer-Verlag Lecture Notes in Computer Science 61728398.Google Scholar
Asperti, A., Ricciotti, W., Sacerdoti Coen, C. and Tassi, E. (2009) Hints in unification. In: Berghofer, S., Nipkow, T., Urban, C. and Wenzel, M. (eds.) Theorem Proving in Higher Order Logics, 22nd International Conference (TPHOLs 2009). Springer-Verlag Lecture Notes in Computer Science 56748498.CrossRefGoogle Scholar
Asperti, A., Sacerdoti Coen, C., Tassi, E. and Zacchiroli, S. (2007) User interaction with the Matita proof assistant. Journal of Automated Reasoning 39 (2)109139.CrossRefGoogle Scholar
Barthe, G., Capretta, V. and Pons, O. (2003) Setoids in type theory. Journal of Functional Programming 13 (2)261293. (Special issue on ‘Logical frameworks and metalanguages’.)CrossRefGoogle Scholar
Bertot, Y. and Castéran, P. (2004) Interactive Theorem Proving and Program Development. Coq'Art: The Calculus of Inductive Constructions, Texts in Theoretical Computer Science, Springer-Verlag.CrossRefGoogle Scholar
Bishop, E. A. (1967) Foundations of constructive analysis, McGraw-Hill.Google Scholar
Boldo, S., Filliâtre, J. and Melquiond, G. (2009) Combining Coq and Gappa for Certifying Floating-Point Programs. In: Carette, J., Dixon, L., Coen, C. and Watt, S. (eds.) Intelligent Computer Mathematics: Proceedings of the 16th Symposium, Calculemus 2009, held as Part of CICM 2009. Springer-Verlag Lecture Notes in Computer Science 56255974.Google Scholar
Brus, T. H., van Eekelen, C. J. D., van Leer, M. O. and Plasmeijer, M. J. (1987) Clean – A language for functional graph rewriting. In: Kahn, G. (ed.) Functional programming languages and computer architecture. Springer-Verlag Lecture Notes in Computer Science 274364384.CrossRefGoogle Scholar
Capretta, V. (1999) Universal algebra in type theory. In: Bertot, Y., Dowek, G., Hirschowitz, A., Paulin, C. and Théry, L. (eds.) Theorem Proving in Higher Order Logics (TPHOLs 1999) Springer-Verlag Lecture Notes in Computer Science 1690131148.CrossRefGoogle Scholar
Cartmell, J. (1978) Generalized algebraic theories and contextual categories, Ph.D. thesis, University of Oxford.Google Scholar
Coq Development Team (2008) The Coq Proof Assistant Reference Manual, INRIA-Rocquencourt.Google Scholar
Coquand, T. and Huet, G. (1988) The calculus of constructions. Information and Computation 76 (2–3)95120.CrossRefGoogle Scholar
Coquand, T. and Paulin, C. (1990) Inductively defined types. In: Martin-Löf, P. and Mints, G. (eds.) COLOG-88. Springer-Verlag Lecture Notes in Computer Science 4175066.CrossRefGoogle Scholar
Cruz-Filipe, L., Geuvers, H. and Wiedijk, F. (2004) C-CoRN, the Constructive Coq Repository at Nijmegen. In: Asperti, A., Bancerek, G. and Trybulec, A. (eds.) Proceedings of MKM2004. Springer-Verlag Lecture Notes in Computer Science 311988103.Google Scholar
Domınguez, C. (2008) Formalizing in Coq Hidden Algebras to Specify Symbolic Computation Systems. In: Autexier, S. et al. . (eds.) Intelligent Computer Mathematics: Proceedings 9th International Conference, AISC 2008. Springer-Verlag Lecture Notes in Computer Science 5144270284.Google Scholar
Garillot, F., Gonthier, G., Mahboubi, A. and Rideau, L. (2009) Packaging mathematical structures. In: Berghofer, S., Nipkow, T., Urban, C. and Wenzel, M. (eds.) Theorem Proving in Higher Order Logics, 22nd International Conference (TPHOLs 2009). Springer-Verlag Lecture Notes in Computer Science 5674327342.CrossRefGoogle Scholar
Geuvers, H., Pollack, R., Wiedijk, F. and Zwanenburg, J. (2002) A constructive algebraic hierarchy in Coq. Journal of Symbolic Computation 34 (4)271286.CrossRefGoogle Scholar
Haftmann, F. and Wenzel, M. (2008) Local theory specifications in Isabelle/Isar. In: Berardi, S., Damiani, F. and de'Liguoro, U. (eds.) Types for Proofs and Programs International Conference, TYPES 2008. Springer-Verlag Lecture Notes in Computer Science 5497153168.Google Scholar
Hofmann, M. (1997) Extensional constructs in intensional type theory, CPHC/BCS Distinguished Dissertations, Springer-Verlag.CrossRefGoogle Scholar
Huet, G. and Saibi, A. (1995) Constructive category theory. In: Proceedings of the Joint CLICS-TYPES Workshop on Categories and Type Theory, Göteborg.Google Scholar
Jenks, R., Sutor, R. and Morrison, S. (1992) AXIOM: the scientific computation system, Springer-Verlag.Google Scholar
Mac Lane, S. (1998) Categories for the working mathematician, Springer-Verlag.Google Scholar
Martin-Löf, P. (1982) Constructive mathematics and computer programming. In: Cohen, L. J., Los, J., Pfeiffer, H. and Podewski, K.-P. (eds.) Logic, methodology and philosophy of science, VI, Studies in Logic and the Foundations of Mathematics, North-Holland 104 153175.Google Scholar
Martin-Löf, P. (1998) An intuitionistic theory of types. In: Twenty-five years of constructive type theory, Oxford Logic Guides 36, Oxford University Press 127172.Google Scholar
Meinke, K. and Tucker, J. (1993) Universal algebra. In: Abramsky, S., Gabbay, D. and Maibaum, T. (eds.) Handbook of logic in computer science (volume 1), Oxford University Press 189411.Google Scholar
O'Connor, R. (2008) Certified exact transcendental real number computation in Coq. Mohamed, O. A., Muñoz, C. and Tahar, S. (eds.) Proceedings of the 21st International Conference on Theorem Proving in Higher Order Logics (TPHOLs 2008). Springer-Verlag Lecture Notes in Computer Science 5170246261.CrossRefGoogle Scholar
O'Connor, R. and Spitters, B. (2010) A computer verified, monadic, functional implementation of the integral. Theoretical Computer Science 411 (37)33863402.Google Scholar
Palmgren, E. (2009) Constructivist and Structuralist Foundations: Bishops and Lawveres Theories of Sets. Technical Report 4.Google Scholar
Palmgren, E. and Vickers, S. (2007) Partial Horn logic and cartesian categories. Annals of Pure and Applied Logic 145 (3)314353.Google Scholar
Pitts, A. (2001) Categorical logic. Handbook of Logic in Computer Science: Logic and algebraic methods (volume 5), Oxford University Press 39123.Google Scholar
Pollack, R. (2002) Dependently typed records in type theory. Formal Aspects of Computing 13 386402.CrossRefGoogle 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-Verlag Lecture Notes in Computer Science 4941157172.CrossRefGoogle Scholar
Santas, P. (1995) A type system for computer algebra. Journal of Symbolic Computation 19 (1–3)79109.Google Scholar
Sozeau, M. (2009) A new look at generalized rewriting in type theory. Journal of Formalized Reasoning 2 (1)4162.Google Scholar
Sozeau, M. and Oury, N. (2008) First-class type classes. In: Mohamed, O. A., Muñoz, C. and Tahar, S. (eds.) Proceedings of the 21st International Conference on Theorem Proving in Higher Order Logics (TPHOLs 2008). Springer-Verlag Lecture Notes in Computer Science 5170278293.Google Scholar
Wadler, P. and Blott, S. (1989) How to make ad-hoc polymorphism less ad hoc. In: Proceedings of the 16th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, ACM 6076.CrossRefGoogle Scholar
Weber, A. and Klaeren, H. (1993) Type systems for computer algebra. Relation 10 (1.54) 2615.Google Scholar
Zumkeller, R. (2008) Global Optimization in Type Theory, Ph.D. thesis, École Polytechnique, Paris.Google Scholar