Formalizing Foundations of Mathematics
Total Page:16
File Type:pdf, Size:1020Kb
Formalizing Foundations of Mathematics Mihnea Iancu and Florian Rabe Computer Science, Jacobs University Bremen, Bremen, Germany Abstract Over the recent decades there has been a trend towards formalized mathematics, and a number of sophisticated systems have been developed to support the formal- ization process and mechanically verify its result. However, each tool is based on a specic foundation of mathematics, and formalizations in dierent systems are not necessarily compatible. Therefore, the integration of these foundations has re- ceived growing interest. We contribute to this goal by using LF as a foundational framework in which the mathematical foundations themselves can be formalized and therefore also the relations between them. We represent three of the most important foundations Isabelle/HOL, Mizar, and ZFC set theory as well as relations between them. The relations are formalized in such a way that the frame- work permits the extraction of translation functions, which are guaranteed to be well-dened and sound. Our work provides the starting point of a systematic study of formalized foundations in order to compare, relate, and integrate them. 1 Introduction The 20th century saw signicant advances in the eld of foundations of mathematics stimulated by the discovery of paradoxes in naive set theory, e.g., Russell's paradox of unlimited set comprehension. Several seminal works have redeveloped and advanced large parts of mathematics based on one coherent choice of foundation, most notably the Principia (Whitehead & Russell 1913) and the works by Bourbaki (Bourbaki 1964). Today various avors of axiomatic set theory and type theory provide a number of well- understood foundations. Given a development of mathematics in one xed foundation, it is possible to give a fully formal language in which every mathematical expression valid in that foundation can be written down. Then mathematics can in principle be reduced to the manipulation of these expression, an approach called formalism and most prominently expressed in Hilbert's program. Recently this approach has gained more and more momentum due to the advent of computer technology: With machine support, the formidable eort of formalizing mathematics becomes feasible, and the trust in the soundness of an argument can be reduced to the trust in the implementation of the foundation. However, compared to traditional mathematics, this approach has the drawback that it heavily relies on the choice of one specic foundation. Traditional mathematics, on 1 the other hand, frequently and often crucially abstracts from and moves freely between foundations to the extent that many mathematical papers do not mention the exact foundation used. This level of abstraction is very dicult to capture if every statement is rigorously reduced to a xed foundation. Moreover, in formalized mathematics, dier- ent systems implementing dierent (or even the same or similar) foundations are often incompatible, and no reuse across systems is possible. But the high cost of formalizing mathematics makes it desirable to join forces and integrate foundational systems. Currently, due to the lack of integration, signicant overlap and redundancies exist between libraries of formalized mathematics, which slows down the progress of large projects such as the formal proofs of the Kepler conjecture (Hales 2003). Our contribution can be summarized as follows. Firstly, we introduce a new method- ology for the formal integration of foundations: Using a logical framework, we formalize not only mathematical theories but also the foundations themselves. This permits for- mally stating and proving relations between foundations. Secondly, we demonstrate our approach by formalizing three of the most widely-used important foundations as well as translations between them. Our work provides the starting point of a formal library of foundational systems that complements the existing foundation-specic libraries and provides the basis for the systematic and formally veried integration of systems for formalized mathematics. We begin by describing our approach and reviewing related work in Sect. 2. Then, in Sect. 3, we give an overview of the logical framework we use in the remainder of the paper. We give a new formalization of traditional mathematics based on ZFC set theory in Sect. 4. Then we formalize two foundations with particularly large formalized libraries: Isabelle/HOL (Nipkow, Paulson & Wenzel 2002) in Sect. 5 and Mizar (Trybulec & Blair 1985) in Sect. 6. We also give a translation from Isabelle/HOL into ZFC and sketch a partial translation from Mizar (which is stronger than ZFC) to ZFC. We discuss our work and conclude in Sect. 7. Our formalizations span several thousand lines of declarations, and their descriptions are correspondingly simplied. The full sources are available at (Iancu & Rabe 2010). 2 Problem Statement and Related Work Automath (de Bruijn 1970) and the formalization of Landau's analysis (Landau 1930, van Benthem Jutting 1977) were the rst major success of formalized mathematics. Since then a number of computer systems have been put forward and have been adopted to varying degrees to formalize mathematics such as LCF (Gordon, Milner & Wadsworth 1979), HOL (Gordon 1988), HOL Light (Harrison 1996), Isabelle/HOL (Nipkow et al. 2002), IMPS (Farmer, Guttman & Thayer 1993), Nuprl (Constable, Allen, Bromley, Cleaveland, Cremer, Harper, Howe, Knoblock, Mendler, Panangaden, Sasaki & Smith 1986), Coq (Coquand & Huet 1988), Mizar (Trybulec & Blair 1985), Isabelle/ZF (Paulson & Coen 1993), and the body of peer-reviewed formalized mathematics is growing (T. Hales and G. Gonthier and J. Harrison and F. Wiedijk 2008, Matuszewski 1990, Klein, 2 Nipkow & (eds.) 2004). A comparison of some formalizations of foundations in Automath, including ZFC and Isabelle/HOL, is given in (Wiedijk 2006). The problem of interoperability and integration between these systems has received growing attention recently, and a number of connections between them have been estab- lished. (Obua & Skalberg 2006) and (McLaughlin 2006) translate between Isabelle/HOL and HOL Light; (Keller & Werner 2010) from HOL Light to Coq; and (Krauss & Schropp 2010) from Isabelle/HOL to Isabelle/ZF. The OpenTheory format (Hurd 2009) was designed as an interchange format for dierent implementations of higher order logic. We call these translations dynamically veried because they have in common that they translate theorems in such a way that the target system reproves every translated theorem. One can think of the source system's proof as an oracle for the target system's proof search. This approach requires no reasoning about or trust in the translation so that users of the target system can reuse translated theorems without making the source system or the translation part of their trusted code base. Therefore, such translations can be implemented and put to use relatively quickly. It is no surprise that such translations are advanced by researchers working with the respective target system. Still, dynamically veried translations can be unsatisfactory. The proofs of the source theorems may not be available because they only exist transiently when the source system processes a proof script. The source system might not be able to export the proofs, or they may be too large to translate. In that case, it is desirable to translate only the theorems and appeal to a general result that guarantees the soundness of the theorem translation. However, the statement of soundness naturally lives outside either of the two involved foundations. Therefore, stating, let alone proving, the soundness of a translation re- quires a third formal system in which source and target system and the translation are represented. We call the third system a foundational framework, and if the soundness of a translation is proved in a foundational framework, we speak of a statically veried translation. Statically veried translations are theoretically more appealing because the soundness is proved once and for all. Of course, this requires the additional assumptions that the foundational framework is consistent and that the representations in the framework are adequate. If this is a concern, the soundness proof should be constructive, i.e., produce for every proof in the source system a translated proof in the target system. Then users of the target system have the option to recheck the translated proof. The most comprehensive example of a statically veried translation from HOL to Nuprl (Naumov, Stehr & Meseguer 2001) was given in (Schürmann & Stehr 2004). HOL and Nuprl proof terms are represented as terms in the framework Twelf (Harper, Honsell & Plotkin 1993, Pfenning & Schürmann 1999) using the judgments-as-types methodology. The translation and a constructive soundness proof are formalized as type-preserving logic programs in Twelf. The soundness is veried by the Twelf type checker, and the well-denedness i.e., the totality and termination of the involved logic programs is proved using Twelf. In this work, we demonstrate a general methodology for statically veried translations. We formalize foundations as signatures in the logical framework Twelf, and we use the 3 LF module system's (Rabe & Schürmann 2009) translations-as-morphisms methodology to formalize translations between them as signature morphisms. This yields translations that are well-dened and sound by design and which are veried by the Twelf type checker. Moreover, they are constructive, and the extraction of translation