    # Analyzing Individual Proofs as the Basis of Interoperability between Proof Systems

We describe the first results of a project of analyzing in which theories formal proofs can be ex- pressed. We use this analysis as the basis of interoperability between proof systems.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

Sciences study both individual objects and generic ones. For example, Astronomy studies both the individual planets of the Solar system: Mercury, Venus, etc. determining their radius, mass, composition, etc., but also the motion of generic planets: Kepler’s laws, that do not just apply to the six planets known at the time of Kepler, but also to those that have been discovered after, and those that may be discovered in the future. Computer science studies both algorithms that apply to generic data, but also specific pieces of data. Mathematics mostly studies generic objects, but sometimes also specific ones, such as the number or the function .

Proof theory mostly studies generic proofs. For example, Gentzen’s cut elimination theorem for Predicate logic applies to any proof expressed in Predicate logic, those that were known at the time of Gentzen, those that have been constructed after, and those that will be constructed in the future. Much less effort is dedicated to studying the individual mathematical proofs, with a few exceptions, for example .

Considering the proofs that we have, instead of all those that we may build in some logic, sometimes changes the perspective. For example, consider a cut elimination theorem for a logic . The stronger the logic , the stronger the theorem. In contrast, consider a specific proof , say a proof of Fermat’s little theorem, and consider a theorem of the form: the proof can be expressed in the logic . In this case, the weaker the logic, the stronger the theorem. So, studying generic proofs leads to focus on stronger and stronger logics, while studying individual proofs, on weaker and weaker ones.

In this paper, we present a program of analyzing the formal proofs that have been developed in computerized proof systems such as Coq111coq.inria.fr, Matita222matita.cs.unibo.it, HOL Light333www.cl.cam.ac.uk/~jrh13/hol-light, Isabelle/HOL444isabelle.in.tum.de, PVS555pvs.csl.sri.com, FoCaLiZe666focalize.inria.fr, etc. In particular, we want to be able to analyze in which logicsa each of these proofs can be expressed.

Such a project is largely inspired by the reverse mathematics project [19, 35]

, but has some differences. First, we do not propose to classify theorems according to the logics in which they can be proved, but to classify the proofs according to the logics in which they can be expressed. Some theorems, for example, the prime number theorem, have very different proofs, some very elementary and some very complex. Second, we focus on formal proofs, that is proofs expressed and checked in computerized proof systems. Third, our project is in some sense less ambitious, as it focuses on stronger theories than reverse mathematics. We typically address the question of the possibility to express a proof in the Calculus of constructions

, or in Simple type theory , while reverse mathematics focuses on fragments of Second-order arithmetic.

Knowing in which logics, which proof can be expressed is a fundamental question, as it is part of our understanding of these proofs. It is also a practical one, as it opens the way to interoperability between computerized proof systems. In the domain of formal proofs, we currently have Coq proofs, HOL Light proofs, etc. of various theorems. And, when we have a Coq proof of a theorem, we do not necessarily have a HOL Light proof of this theorem, and vice versa. The problem of exchanging proofs between proof systems is not just a problem of translation, as these systems cannot express the same proofs. It is primarily the problem of analyzing the logics in which these proofs can or cannot be expressed.

## 2 From logics to theories

### 2.1 Logical Frameworks

When a proof is expressed in a logic , analyzing the logics in which this proof can be expressed amounts to analyzing the ingredients of the logic

that it uses. This requires to analyze this logic into a number of ingredients, for example into a number of axioms. Set theory, for example, is naturally analyzed into a number of axioms and axiom schemes, including, for example, the axiom of choice, and this analysis permits to classify the proofs according to the axioms they use: the proof that every vector has a unique decomposition in a given basis does not use the axiom of choice, the proof that every vector space has a basis does. These ingredients of set theory are expressed in a logical framework: Predicate logic. So, analyzing a logic amounts to expressing it as a theory in a logical framework.

To express set theory, it is also possible to choose another logical framework: Constructive predicate logic and add the excluded middle as an axiom scheme. Then, we can express that the proof that every vector has a unique decomposition in a given basis does not use the excluded middle, while the proof of the Bolzano-Weierstrass theorem does.

The examples of the axiom of choice and of the excluded middle show that, even in everyday mathematics, we do care about the analysis of proofs, even if this analysis is often restricted to the very specific cases of the axiom of choice and of the excluded middle.

### 2.2 Axioms and rewrite rules

Predicate logic is certainly the most widely used logical framework. But it also has some limitations. For example, many theories are expressed with an infinite number of axioms and eliminating axiom schemes, like in Von Neumann-Bernays-Gödel set theory, is often cumbersome . Moreover, if Simple type theory can easily be expressed in Predicate logic, expressing the Calculus of constructions, the Calculus of inductive constructions, etc. is more cumbersome.

Another logical framework is that of Pure type systems , where it is possible to express Simple type theory, the -calculus, the system F, the Calculus of constructions, etc. and analyze these logics into sorts, axioms, and rules. This permits to classify the proofs expressed, for example, in the Calculus of constructions, into those that use the polymorphic rules and those that do not. But this logical framework also has limitations as the Calculus of inductive constructions cannot be expressed in it.

Another logical framework is the -calculus, that is the -calculus with dependent types . Like in Predicate logic, the ingredients of a logic expressed in this framework are axioms and it is difficult to express in the -calculus the logics that include a computational, or definitional, equality that identifies some terms.

So, we shall use another logical framework that is a synthesis of Predicate logic, Pure type systems and the -calculus: the -calculus modulo theory , also called the Martin-Löf logical framework , where the ingredients of a logic are axioms and rewrite rules, like in Deduction modulo theory [17, 18]. Simple type theory can easily be expressed as a theory in the -calculus modulo theory, with three rewrite rules, and the Calculus of constructions as a theory with just four rules. Moreover, the -calculus modulo theory has an efficient implementation: the system Dedukti , whose first implementation has been presented in  and its most recent in .

## 3 Translating proofs expressed in the Calculus of constructions into proofs in Simple type theory

We show, in this section, how to express constructive Simple type theory and the Calculus of constructions, in the -calculus modulo theory. We then discuss how this can be used to analyze if a proof, expressed in the Calculus of constructions, can be reformulated in Simple type theory or not, according to these expressions of these theories in the -calculus modulo theory.

### 3.1 Simple type theory as a theory in the λΠ-calculus modulo theory

Simple type theory can be expressed in Deduction modulo theory  and hence in the -calculus modulo theory [4, 5].

The types of Simple type theory are expressed as terms of type type, with three constants , nat, and arrow. The type is that of propositions, the type nat that of individuals, often written , and those built with the constant arrow are the functional types. For example, the type of Simple type theory is expressed as the term of type type. Then, to each term of type type, is associated a type of the -calculus modulo theory, using a constant of type and the rewrite rule

 (η (\em arrow x y))⟶(η x)→(η y)

For example, to the term , is associated the type that reduces to .

The terms of Simple type theory of type are then expressed as terms of type . For example, the term of Simple type theory is expressed as the term of type .

In particular, the propositions are expressed as terms of type , using two constants and . For example, the proposition is expressed as the term . Note that, in this expression of Simple type theory in the -calculus modulo theory, we do not have a quantifier for each type , but a single quantifier , that is applied to a term of type . Then, to each term of type , is associated a type of the -calculus modulo theory, using a constant of type and the rewrite rules

 (ε (⇒ x y))⟶(ε x)→(ε y)
 (ε (∀ x y))⟶Πz:(η x) (ε (y z))

For example, to the term , is associated the type that reduces to .

Finally, the proofs of a proposition in Simple type theory are expressed as terms of type . For example, the usual proof of the proposition is expressed as the term .

This leads to the theory presented in Figure 1.

### 3.2 The Calculus of constructions as a theory in the λΠ-calculus modulo theory

We consider a slight extension of the Calculus of constructions with a symbol nat of type . Such an extension can be obtained just by adding a constant nat and a rule assigning it the type , a rule allowing to declare a variable of type , or an extra sort allowing to declare a variable of type [20, 21].

This logic can be expressed, in the -calculus modulo theory , as the theory presented in Figure 2. Note that this presentation slightly differs from that of : the symbol has been replaced everywhere by the term allowing to drop the rule

 ε_Kind(˙Type)⟶U_Type

Then, to keep the notations similar to those of Simple type theory, the constant is written , the constant , , the constant , , the constant , , the constant , arrow, the constant , , the constant , , and the constant , . Finally, a symbol nat is added, as we consider an extension of the Calculus of constructions with such a symbol.

### 3.3 Comparing Simple type theory and the Calculus of constructions

Now that the theories have been formulated in the same logical framework, we can compare their expressions.

A first difference is that the symbol arrow has type

 type→type→type

that is

 Πx:type (type→type)

in Simple type theory and

 Πx:type (((η x)→type)→type)

in the Calculus of constructions. This reflects the fact that this symbol is non-dependent in Simple type theory and dependent in the Calculus of constructions, where, in the type , written , the type may contain a variable of type .

In the same way, the symbol is non-dependent in Simple type theory, but it is dependent in the Calculus of constructions, where, in the proposition , also written , the proposition may contain a variable , that is a proof of .

In contrast, the symbol is dependent is both theories: in the expression , the proposition may always contain the variable of type .

Finally, there is an extra constant in the Calculus of constructions, with its associated rewrite rule. This symbol permits to type functions mapping proofs to terms, for example a function mapping a proof of to a term verifying the predicate .

So, the Calculus of constructions is an extension of Simple type theory, because the symbols arrow and are dependent and because it includes a symbol .

### 3.4 Analyzing proofs expressed in the Calculus of constructions

We can define a subset of the proofs, expressed in the Calculus of constructions, that do not use the dependency of the symbol arrow, do not use the dependency of the symbol , and do not use the symbol , where we say that a proof does not use the dependency of the symbol arrow if each time the symbol arrow is used, it is applied to two terms, the second one being a -abstraction where the abstracted variable does not occur in the body of the abstraction: with not free in , and that it does not use the dependency of the symbol if each time the symbol is used, it is applied to two terms, the second being a -abstraction where the abstracted variable does not occur in the body of the abstraction: with not free in .

As we shall see, many proofs expressed in the Calculus of constructions are in this subset.

### 3.5 Translating proofs to Simple type theory

When a proof expressed in the Calculus of constructions is in the subset , it can easily be translated to Simple type theory. All that needs to be done is to replace the terms of the form with and the terms of the form with .

If, in contrast a proof is not in the set , then it genuinely uses a feature of the Calculus of constructions that does not exist in Simple type theory and it cannot be expressed in Simple type theory. In the same way a proof expressed in ZFC, that genuinely uses the axiom of choice, cannot be expressed in ZF.

When a proof, expressed in the Calculus of constructions, is an element of the set and is translated to Simple type theory, we say that the proof and its translation are the same mathematical proof, expressed in different theories, although they are different linguistic objects. Generalizing this notion of identity of proofs across theories remains to be done.

## 4 An arithmetic library

The example of the translation of proofs from the Calculus of constructions to Simple type theory is a toy example, because there is no implementation of the Calculus of constructions per se. The systems Coq and Matita, for example, implement extensions of the Calculus of constructions with various features, at least inductive types and universes.

M. Boespflug and G. Burel  have shown how to extend the theory presented in Figure 2 to inductive types and A. Assaf [4, 5] has shown how to extend it to universes. This has permitted to express a large library of Matita proofs in Dedukti, including a proof of Fermat’s little theorem.

F. Thiré  has then shown that the symbol , and the dependency of the symbols arrow and could be eliminated from this library, but also that universes could be eliminated and that inductive type could be replaced by a very simple principle: an induction principle on natural numbers, that permits to prove propositions by induction and to define functions by induction.

So, we now have an evidence that Fermat’s little theorem not only has a proof in the Calculus of inductive constructions with universes, but also in constructive Simple type theory. Such a result was expected, but note that neither proving Fermat’s little theorem in Matita, that contains dependent products, inductive types, universes, etc. nor proving it in HOL Light, that contains the excluded middle, extensionality, choice, etc., provides a proof in such a weak theory.

On the more practical side, this has permited to export this library from Dedukti to HOL Light, Isabelle/HOL, HOL4, Coq, etc. , HOL Light, Isabelle/HOL, and HOL4 sharing a common input language: OpenTheory .

The size of this library is 1.5 Mo. It contains around 340 lemmas. It is checked in Dedukti in a few milliseconds.

## 5 Abstracting enough

### 5.1 Natural numbers

Both in the Calculus of inductive constructions and in Simple type theory, it is possible to prove propositions by induction and to define functions by induction. But these principles are justified in different ways.

In the Calculus of inductive constructions, the declaration of the inductive type nat comes with a recursion operator that permits to define functions by induction and, as proofs are functions, this operator permits also to build proofs by induction.

In Simple type theory, in contrast, the set of natural numbers is impredicatively defined as the intersection of all sets containing zero and closed by successor. From this definition, the induction principle can be proved. Then, this induction principle and other properties of natural numbers permit to prove the existence of functions defined by induction .

These details should be ignored by the arithmetic library, that should be exported to any system that contains a notion of natural number, an induction principle and a way to define functions by induction, regardless the way this induction principle is proved and this induction operator is defined there . Using such an abstract definition of the natural numbers, R. Cauderlier and C. Dubois  have built a proof of the correctness of Eratosthenes’ sieve in the expression of FoCaLiZe in Dedukti, using definitions coming from Coq and lemmas coming from HOL Light.

### 5.2 Connectives and quantifiers

The same holds for the connectives and quantifiers, that are primitive neither in the Calculus of inductive constructions nor in Simple type theory. They are defined as inductive types in the Calculus of inductive constructions. They are defined from equality in Simple type theory [26, 2, 3].

But these details should be ignored by the library, that only needs to specify that should be provable when is, etc. regardless the way this connective is defined.

So, developing a library of proofs that can be exported to different proof systems gives a formal counterpart to the slogan that defining real numbers with Cauchy’s construction or with Dedekind’s is immaterial, or that defining complex numbers as ordered pairs of real numbers, as similarities, or as classes of polynomials is immaterial. Here, the notions of structure and isomorphic structures are essential, even when all the structures of a class—such as that of the complete Archimedean totally ordered fields—are isomorphic.

Eventually, this should lead to defining algorithms to transform proofs of structural propositions, about objects in a given structure to proofs about objects in an isomorphic structure [27, 38].

## 6 Classical and constructive logics

An important difference between logics, and proof systems implementing these logics, is that some of them are classical and others are constructive, that is the excluded middle is provable in some but not in others. For example, Simple type theory, and HOL Light, are classical and the Calculus of inductive constructions, and Matita, are constructive.

A logical framework, such as the -calculus modulo theory, and its implementation Dedukti, should not make any choice on the excluded middle, but should be able to express both classical and constructive logics as theories. A possibility is to not assume the excluded middle in the framework and include it as an axiom in the definition of some theories. Then, the proofs of Simple type theory, for instance those developed in the system HOL Light, can be expressed in Dedukti using the excluded middle and just like in Section 3, we can analyze which of these proofs use the excluded middle and which do not, and translate these to another theory: constructive Simple type theory.

An alternative is to use the idea, defended for example in [23, 33, 15, 32], that the excluded middle is not a question of theory, but a question of meaning of the connectives and quantifiers. This leads to introduce two existential quantifiers: the constructive, , and the classical, , two disjunctions, etc. and deduction rules defining the meaning of these connectives and quantifiers, in such a way that is not provable, but is.

This permits to define connectives and quantifiers once for all in the framework and to use various quantifiers in various theories, as well as translating proofs using one set of quantifiers into proofs using another [22, 10], changing, in this case, the statement of the theorem.

## 7 Future work

The arithmetic library, described in Section 4, is, of course, only the beginning of a library of proofs, that could be shared by various proof systems. Each proof in this library should be labeled with the ingredients it uses, hence the systems to which it may be exported.

Also, we now have a formal proof of Fermat’s little theorem, in constructive Simple type theory, but we should continue to transform it, to express it in weaker theories, such as predicative type theory, Heyting arithmetic, and beyond.

## Acknowledgments

Many thanks to Catherine Dubois, Stéphane Graham-Lengrand, Bruno Woltzenlogel Paleo, and François Thiré for very useful remarks on a first draft of this paper.

## References

• 
•  P.B. Andrews (1963): A reduction of the axioms for the theory of propositional types. Fundam. Math. 52, pp. 345–350, doi:10.4064/fm-52-3-345-350.
•  P.B. Andrews (1986): An Introduction to Mathematical Logic and Type Theory: To Truth Through Proof. Academic Press.
•  A. Assaf (2014): A Calculus of Constructions with explicit subtyping. In H. Herbelin, P. Letouzey & M. Sozeau, editors: Types, LIPICS 39, pp. 27–46, doi:10.4230/LIPIcs.TYPES.2014.27.
•  A. Assaf (2015): A framework for defining computational higher-order logics. Ph.D. thesis, École polytechnique.
•  A. Assaf, G. Burel, R. Cauderlier, D. Delahaye, G. Dowek, C. Dubois, F. Gilbert, P. Halmagrand, O. Hermant & R. Saillard (2016): Dedukti: a Logical Framework based on the lambda-Pi-Calculus Modulo Theory. Manuscript.
•  H. Barendregt (1992): Lambda calculi with types. In S. Abramsky, D.M. Gabbay & T.S.E. Maibaum, editors: Handbook of Logic in Computer Science, 2, Oxford University Press, pp. 117–309.
•  M. Boespflug (2011): Conception d’un noyau de vérification de preuves pour le lambda-Pi-calcul modulo. Ph.D. thesis, École polytechnique.
•  M. Boespflug & G. Burel (2012): CoqInE : Translating the Calculus of Inductive Constructions into the lambda-Pi-calculus modulo. In: Second International Workshop on Proof Exchange for Theorem Proving, pp. 44–50.
•  R. Cauderlier (2017): A Rewrite System for Proof Constructivization.
•  R. Cauderlier & C. Dubois (2017): FoCaLiZe and Dedukti to the Rescue for Proof Interoperability. In M. Ayala-Rincón & C.A. Muñoz, editors: Interactive Theorem Proving, Lecture Notes in Computer Science 10499, Springer, pp. 131–147, doi:10.1007/1191627711.
•  A. Church (1940): A formulation of the simple theory of types. The Journal of Symbolic Logic 5(2), pp. 56–68, doi:10.2307/2371199.
•  T. Coquand & G. Huet (1988): The Calculus of Constructions. Information and Computation, pp. 95–120, doi:10.1016/0890-5401(88)90005-3.
•  D. Cousineau & G. Dowek (2007): Embedding Pure Type Systems in the lambda-Pi-calculus modulo. In S. Ronchi Della Rocca, editor: Typed lambda calculi and applications, Lecture Notes in Computer Science 4583, Springer, pp. 102–117, doi:10.1007/978-3-540-73228-09.
•  G. Dowek (2015): On the definition of the classical connectives and quantifiers. In E.H. Haeusler, W. de Campos Sanz & B. Lopes, editors: Why is this a Proof?, Festschrift for Luiz Carlos Pereira, College Publications.
•  G. Dowek, Th. Hardin & C. Kirchner (2001): HOL-lambda-sigma: an intentional first-order expression of higher-order logic. Mathematical Structures in Computer Science 11, pp. 1–25, doi:10.1017/S0960129500003236.
•  G. Dowek, Th. Hardin & C. Kirchner (2003): Theorem proving modulo.

Journal of Automated Reasoning

31, pp. 33–72, doi:10.1023/A:1027357912519.
•  G. Dowek & B. Werner (2003): Proof normalization modulo. The Journal of Symbolic Logic 68(4), pp. 1289–1316, doi:10.1007/BFb0037116.
•  H. Friedman (1976): Systems of second-order arithmetic with restricted induction, I, II. The Journal of Symbolic Logic 41(2), pp. 557–559.
•  H. Geuvers (1993): Logics and Type systems. Ph.D. thesis, Nijmegen.
•  H. Geuvers (1995): The Calculus of Constructions and Higher Order Logic. In Ph. de Groote, editor: The Curry-Howard isomorphism, Cahiers du Centre de logique 8, Université catholique de Louvain, pp. 139–191.
•  F. Gilbert (2017): Automated Constructivization of Proofs. In J. Esparza & A.S. Murawski, editors: Foundations of Software Science and Computation Structures, Lecture notes in computer science 10203, Springer, pp. 480–495, doi:10.1007/978-3-540-71070-723.
•  J.-Y. Girard (1993): On the Unity of Logic. Annals of Pure and Applied Logic 59(3), pp. 201–217, doi:10.1016/0168-0072(93)90093-S.
•  R. Harper, F. Honsell & G. Plotkin (1993): A framework for defining logics. Journal of the ACM 40(1), pp. 143–184, doi:10.1145/138027.138060.
•  L. Henkin (1960): On Mathematical Induction. The American Mathematical Monthly 67(4), pp. 323–338, doi:10.2307/2308975.
•  L. Henkin (1963): A theory of propositional types. Fundam. Math. 52, pp. 323–344, doi:10.4064/fm-52-3-323-344. Errata Ibid., 53, 119, 1964.
•  B. Huffman & Kunçar (2013): Lifting and Transfer: A Modular Design for Quotients in Isabelle/HOL. In G. Gonthier & M. Norrish, editors: Certified Programs and Proofs, pp. 131–146, doi:10.1007/978-3-319-03545-19.
•  J. Hurd (2011): The OpenTheory standard theory library. In M. Bobaru, K. Havelund, G.J. Holzmann & R. Joshi, editors: NASA Formal Methods, Lecture Notes in Computer Science 6617, Springer, pp. 177–191, doi:10.1007/3-540-60275-576.
•  F. Kirchner (2006): A Finite First-Order Theory of Classes. In Th. Altenkirch & C. McBride, editors: Types for Proofs and Programs, Lecture Notes in Computer Science, Springer, pp. 188–202.
•  A. Leitsch (2015): On proof mining by cut-elimination. In D. Delahaye & B. Woltzenlogel Paleo, editors: All about Proofs, Proofs for All, Mathematical Logic and Foundations 55, College Publications, pp. 173–200.
•  B. Nordström, K. Petersson & J.M. Smith (2000): Martin-Löf’s type theory. In S. Abramsky, D.M. Gabbay & T.S.E. Maibaum, editors: Handbook of Logic in Computer Science, Clarendon Press, pp. 1–37.
•  L.C. Pereira (2017): Personal communication.
•  D. Prawitz (2015): Classical versus intuitionistic logic. In E.H. Haeusler, W. de Campos Sanz & B. Lopes, editors: Why is this a Proof?, Festschrift for Luiz Carlos Pereira, College Publications.
•  R. Saillard (2015): Type Checking in the Lambda-Pi-Calculus Modulo: Theory and Practice. Ph.D. thesis, École des Mines.
•  S.G. Simpson (2009): Subsystems of second-order arithmetic. Cambridge University Press, doi:10.1017/CBO9780511581007.
•  F. Thiré (2017): Personal communication.
•  F. Thiré (2017): Sharing Arithmetic Proofs from Dedukti to HOL. Manuscript.
•  T. Zimmermann & H. Herbelin (2015): Automatic and Transparent Transfer of Theorems along Isomorphisms in the Coq Proof Assistant. Work in progress session, Conference on Intelligent Computer Mathematics, https://hal.archives-ouvertes.fr/hal-01152588/file/paper.pdf.