Ali Assaf
email: ali.assaf@inria.fr

Guillaume Burel
email: guillaume.burel@ensiie.fr

Raphaël Cauderlier
email: raphael.cauderlier@irif.fr

David Delahaye
email: david.delahaye@umontpellier.fr

Gilles Dowek
email: gilles.dowek@ens-cachan.fr

Catherine Dubois
email: catherine.dubois@ensiie.fr

Frédéric Gilbert
email: frederic.gilbert@inria.fr

Pierre Halmagrand
email: pierre.halmagrand@inria.fr

Olivier Hermant
email: olivier.hermant@mines-paristech.fr

Ronan Saillard
email: ronan.saillard@mines-paristech.fr

Dedukti: a Logical Framework based on the λΠ-Calculus Modulo Theory

Dedukti is a Logical Framework based on the λΠ-Calculus Modulo Theory. We show that many theories can be expressed in Dedukti: constructive and classical predicate logic, Simple type theory, programming languages, Pure type systems, the Calculus of inductive constructions with universes, etc. and that permits to used it to check large libraries of proofs developed in other proof systems: Zenon, iProver, FoCaLiZe, HOL Light, and Matita.

2

The λΠ-calculus modulo theory

We present the λΠ-calculus modulo theory in two steps. We first present, in Section 2.2, a very general system, not caring about the decidability of type-checking. Then, in Section 2.3, we discuss restrictions of this system that enforce the decidability of type-checking.

The λΠ-calculus

The λΠ-calculus is an extension of the simply typed λ-calculus with dependent types. In this calculus, types are just terms of a particular type T ype, some symbols have the type A → T ype, and can be applied to a term of type A to build a type depending on this term. A type Kind is introduced to type the terms T ype, A → T ype, etc. and the arrow A → B is extended to a dependent product Πx : A B. Finally, besides the usual typing judgements, Consider the context Γ = a : T ype, b : T ype, x : a, f : Πp : (a → T ype) (p x → b), in which the term f (λy : a a) x is a proof of b. This proof is represented in Dedukti as

Introduction

Defining a theory, such as arithmetic, geometry, or set theory, in predicate logic [START_REF] Hilbert | Grundzüge der theoretischen Logik[END_REF] just requires to choose function and predicate symbols and axioms expressing the meaning of these symbols. Using this way a single logical framework to define all these theories has many advantages. First, it requires less efforts, as the logical connectives, ∧, ∨, ∀, etc. and their associated deduction rules are defined, in the framework, once and for all and need not be redefined for each theory. Similarly, the notions of proof, model, etc. are defined once and for all. And general theorems, such as the soundness and the completeness theorems, can be proved once and for all.

Another advantage of using such a logical framework is that this induces a partial order between theories. For instance, Zermelo-Fraenkel set theory with the axiom of choice (ZFC) is an extension of Zermelo-Fraenkel set theory (ZF), as it contains the same axioms, plus the axiom of choice. It is thus obvious that any theorem of ZF is provable in ZFC, and for each theorem of ZFC, we can ask the question of its provability in ZF. Several theorems of ZFC that are provable in ZF have been identified, and these theorems can be used in extensions of ZF that are inconsistent with the axiom of choice.

Finally, using such a common framework permits to combine, in a proof, lemmas proved in different theories: if T is a theory expressed in a language L and T ′ a theory expressed in a language L ′ , if A is expressed in L ∩ L ′ , A ⇒ B is provable in T , and A is provable in T ′ , then B is provable in T ∪ T ′ . Despite these advantages, several logical systems have been defined, not as theories in predicate logic, but as independent systems: Simple type theory [START_REF] Church | A formulation of the simple theory of types[END_REF][START_REF] Andrews | An introduction to mathematical logic and type theory: to truth through proof[END_REF], also known as Higher-order logic, is defined as an independent system-although it is also possible to express it as a theory in predicate logic. Similarly, Intuitionistic type theory [START_REF] Martin-Löf | Intuitionistic type theory[END_REF], the Calculus of constructions [START_REF] Coquand | The calculus of constructions[END_REF], the Calculus of inductive constructions [START_REF] Paulin-Mohring | Inductive definitions in the system coq rules and properties[END_REF], etc. are defined as independent systems. As a consequence, it is difficult to reuse a formal proof developed in an automated or interactive theorem prover based on one of these formalisms in another, without redeveloping it. It is also difficult to combine lemmas proved in different systems: the realm of formal proofs is today a tower of Babel, just like the realm of theories was, before the design of predicate logic.

The reason why these formalisms have not been defined as theories in predicate logic is that predicate logic, as a logical framework, has several limitations, that make it difficult to express some logical systems. 1. Predicate logic does not allow the use of bound variables, except those bound by the quantifiers ∀ and ∃. For instance, it is not possible to define, in predicate logic, a unary function symbol → that would bind a variable in its argument. 2. Predicate logic ignores the propositions-as-types principle, according to which a proof π of a proposition A is a term of type A. 3. Predicate logic ignores the difference between deduction and computation. For example, when Peano arithmetic is presented in predicate logic, there is no natural way to compute the term 2 × 2 into 4. To prove the theorem 2 × 2 = 4, several deduction steps need to be used while a simple computation would have sufficed [START_REF] Poincaré | La science et l'hypothèse[END_REF]. 4. Unlike the notions of proof and model, it is not possible to define, once and for all, the notion of cut in predicate logic and to apply it to all theories expressed in predicate logic: a specific notion of cut must be defined for each theory. 5. Predicate logic is classical and not constructive. Constructive theories must be defined in another logical framework: constructive predicate logic.

This has justified the development of other logical frameworks, that address some of these problems. Problem 1 has been solved in extensions of predicate logic such as λ-Prolog [START_REF] Miller | An overview of λProlog[END_REF] and Isabelle [START_REF] Paulson | Isabelle: the next seven hundred theorem provers[END_REF]. Problems 1 and 2 have been solved in an extension of predicate logic, called the Logical framework [START_REF] Harper | A framework for defining logics[END_REF], also known as the λΠ-calculus, and the λ-calculus with dependent types. Problems 3 and 4 have been solved in an extension of predicate logic, called Deduction modulo theory [START_REF] Dowek | Theorem proving modulo[END_REF]. Combining the λΠ-calculus and Deduction modulo theory yields the λΠ-calculus modulo theory [START_REF] Cousineau | Embedding pure type systems in the lambda-Pi-calculus modulo[END_REF], a variant of Martin-Löf's logical framework [START_REF] Nordström | Programming in Martin-Löf's type theory[END_REF], which solves problems 1, 2, 3, and 4.

Problem 5 has been addressed [START_REF] Dowek | On the definition of the classical connectives and quantifiers[END_REF][START_REF] Hermant | Double negation translations as morphisms[END_REF][START_REF] Prawitz | Classical versus intuitionistic logic[END_REF] and will be discussed in Section 5.

The expressivity of the λΠ-calculus modulo theory has already been discussed [START_REF] Cousineau | Embedding pure type systems in the lambda-Pi-calculus modulo[END_REF]. We have shown that all functional Pure type systems [START_REF] Barendregt | Lambda calculi with types[END_REF], in particular the Calculus of constructions, could be expressed in this framework.

Our goal, in this paper, is twofold: first, we want to go further and show that other systems can be expressed in the λΠ-calculus modulo theory, in particular classical systems, logical systems containing a programming language as a subsystem, Simple type theory, and extensions of the Calculus of constructions with universes and inductive types.

Second, we want to demonstrate this expressivity, not just with adequacy theorems, but also by showing that large libraries of formal proofs coming from automated and interactive theorem provers can be translated to and checked in Dedukti, our implementation of the λΠ-calculus modulo theory. To do so, we translate to Dedukti proofs developed in various systems: the automated theorem proving systems Zenon modulo, iProverModulo, the system containing a programming language as a subsystem FoCaLiZe, and the interactive theorem provers HOL Light and Matita. Expressing formal proofs, coming from different systems, in a single logical framework is a first step towards reverse engineering these proofs, that is precisely analyzing the theories in which these theorems can be proved. It is also a first step towards interoperability, that is building proofs assembling lemmas developed in different systems. Finally, it is also a way to audit formal proofs develop in these systems by checking them in a different, independent, system.

We show this way that the logical framework approach scales up and that it is mature enough to start imagining a single distributed library of formal proofs expressed in different theories, developed in different systems, but formulated in a single framework.

We present here a synthesis of the state of the art about the λΠ-calculus modulo theory, its implementation Dedukti, and the expression of theories in this framework. In Sections 4, 5, 6, 7, and 8, we shall present a number of examples of theories that have been expressed in Dedukti and of libraries of proofs expressed in these theories. Before that, we shall present the λΠ-calculus modulo theory, in Section 2, and the Dedukti system, in Section 3.

Conversion Γ ⊢ t : A Γ ⊢ A : T ype Γ ⊢ B : T ype A ≡ β B Γ ⊢ t : B Γ ⊢ t : A Γ ⊢ A : Kind Γ ⊢ B : Kind A ≡ β B Γ ⊢ t : B

The λΠ-calculus modulo theory

The λΠ-calculus modulo theory is an extension of the λΠ-calculus. In the λΠ-calculus modulo theory, the contexts contain variable declarations-like in the λΠ-calculus-and also rewrite rules. The conversion rule is extended in order to take these rewrite rules into account.

Local and global contexts

Γ ⊢ ∆ local Γ, ∆ ⊢ A : T ype Γ ⊢ ∆, x : A local
The following lemma is proved with a simple induction on the structure of the derivation of the judgment "∆ local".

▶ Lemma 1. If ∆ is local in Γ, then Γ, ∆ is a well-formed global context.
Thus, defining a local context is just a way to express that some end segment of the context contains object variables only.

A rewrite rule in a global context Γ is a pair of terms ⟨l, r⟩, where l is a term of the form f u 1 ... u n for some variable f , together with a context ∆ local in Γ. We note it l -→ ∆ r.

The notion of well-formed global context is extended to allow the declaration of rewrite rules Γ well-formed Γ ⊢ ∆ local Γ, l -→ ∆ r well-formed

Note that, at this stage, l and r can have different types or be not well-typed at all. Conditions will be added in Section 2.3.

Γ ⊢ A : T ype Γ ⊢ B : T ype Γ ⊢ t : A A ≡ βΓ B Γ ⊢ t : B Γ ⊢ A : Kind Γ ⊢ B : Kind Γ ⊢ t : A A ≡ βΓ B Γ ⊢ t : B

Subject reduction

Subject reduction expresses that reduction preserves the type of a term. This property does not hold in general in the λΠ-calculus modulo theory. However it does if we have the two following properties: well-typedness of rewrite rules and product compatibility [START_REF] Barbanera | Modularity of strong normalization in the algebraic lambda-cube[END_REF].

Henceforth, unless stated otherwise, Γ ⊢ t : T stands for "the judgement Γ ⊢ t : T is derivable". A rewrite rule is well-typed if it is type preserving.

▶ Definition 2. Let l -→ ∆0 r be a rewrite rule in the context Γ 0 and Γ be a well-formed extension of Γ 0 . We say that l -→ ∆0 r is well-typed for Γ if for any substitution σ binding the variables of ∆ 0 if Γ ⊢ σl : T , then Γ ⊢ σr : T ▶ Definition 3. A well-formed global context Γ satisfies the product compatibility property if for any products Πx :

A 1 B 1 and Πx : A 2 B 2 well-typed in Γ if Πx : A 1 B 1 ≡ βΓ Πx : A 2 B 2 then A 1 ≡ βΓ A 2 and B 1 ≡ βΓ B 2 .
Note that this property immediately follows from the confluence of βΓ-reduction, but it is weaker.

From well-typedness of rewrite rules and product compatibility, we can prove subject reduction.

▶ Lemma 4 (Subject Reduction, Theorem 2.6.22 in [START_REF] Saillard | Type Checking in the Lambda-Pi-Calculus Modulo: Theory and Practice[END_REF]). Let Γ be a global context satisfying product compatibility and whose rewrite rules are well-typed. If Γ ⊢ t 1 : T and t 1 → βΓ t 2 then Γ ⊢ t 2 : T .

Using product compatibility we can also show that a term has, at most, one type modulo conversion.

▶ Lemma 5 (Uniqueness of Types, Theorem 2.6.34 in [START_REF] Saillard | Type Checking in the Lambda-Pi-Calculus Modulo: Theory and Practice[END_REF]). Let Γ be a global context satisfying the product compatibility property. If Γ ⊢ t : T 1 and Γ ⊢ t : T 2 then T 1 ≡ βΓ T 2 .

Rules and rule schemes

In predicate logic, some theories are defined with a finite set of axioms, in which case these axioms can just be enumerated. Some others, such as arithmetic or set theory, are defined with an infinite but decidable set of axioms: an axiom scheme. In a specific proof however, only a finite number of such axioms can be used. Thus, provability of a proposition A in a theory T having axiom schemes can either be defined as the fact that the infinite sequent T ⊢ A has a proof, or as the fact that there exists a finite subset Γ of T , such that the finite sequent Γ ⊢ A has a proof.

In the same way, some theories in the λΠ-calculus modulo theory may be defined with an infinite set of symbols and an infinite set of rewrite rules, recognized by an algorithm. In this case, as the contexts are always finite in the λΠ-calculus modulo theory, the derivability of a typing relation t : A must be defined as the existence of a finite context Γ, such that the judgment Γ ⊢ t : A is derivable.

Effective subsystems

In the calculus presented in Section 2.2, proof-checking is not always decidable because, when using the conversion rule to reason modulo the congruence,

Γ ⊢ A : s Γ ⊢ B : s Γ ⊢ t : A A ≡ βΓ B Γ ⊢ t : B
the conversion sequence justifying A ≡ βΓ B is not recorded in the conclusion. Thus, we need to restrict to effective subsystems, that is systems where the rewrite rules are restricted in such a way that the congruence ≡ βΓ is decidable. A natural subsystem is obtained by restricting the rewrite rules to form, together with the β-reduction rule, a terminating and confluent rewrite system. This way, the congruence can be decided by checking equality of normal forms. As β-reduction does not terminate on untyped terms, termination can hold only for typed ones. Therefore, the subject reduction property is essential to prove the termination of the calculus. As we have seen in Section 2.2.3, subject reduction is a consequence of well-typedness of rewrite rules and product compatibility, which is itself a consequence of confluence. Thus confluence should be proved first, without assuming termination or restricting ourselves to typed terms.

The rest of this section discusses effective conditions for confluence and well-typedness.

Higher-order rewriting

Confluence of the rewrite relation together with β-reduction is not general enough. Indeed, such a confluence result may easily be lost when allowing λ-abstraction in the left-hand side of a rewrite rule, a useful feature-see, for instance, Section 8.3. For example, let ∆ = f : Real → Real, and consider the rewrite rule explaining how to differentiate the function λx : Real (sin (f x))

(D (λx : Real (sin (f x)))) -→ ∆ (× (D (λx : Real (f x))) (λx : Real (cos (f x))))
where × is the pointwise product of functions. This rule overlaps with β-reduction and creates the critical peak (D (λx (sin x))) ←-(D (λx (sin ((λy y) x)))) -→ (× (D (λx ((λy y) x))) (λx (cos ((λy y) x))))

that cannot be joined. This rewrite system with β-reduction is therefore not confluent.

Still, ≡ βΓ is decidable, as some form of confluence holds. For this, we need a richer rewrite relation: rewriting modulo β-equivalence, also known as higher-order rewriting.

Higher-order rewriting requires higher-order matching: the term t matches the term l if there is a substitution σ such that σl is β-convertible to t. Higher-order matching is undecidable in general [START_REF] Dowek | L'indécidabilité du filtrage du troisième ordre dans les calculs avec types dépendants ou constructeurs de types (the undecidability of third order pattern matching in calculi with dependent types or type constructors)[END_REF][START_REF] Loader | Higher order beta matching is undecidable[END_REF], but it is decidable if we restrict to Miller's patterns [START_REF] Miller | A logic programming language with lambda-abstraction, function variables, and simple unification[END_REF]. Thus, we restrict the left-hand sides of the rewrite rules to be patterns. ▶ Definition 6. A β-normal term f u 1 ... u n is a pattern with respect to ∆ if f is a variable not declared in ∆, and the variables declared in ∆ are applied to pairwise distinct bound variables.

For example, if f is declared in ∆, then the term D (λx (sin (f x))) is a pattern, but neither D (λx (f (sin x))) nor D ((λx (sin x)) y) are. Now, if we consider the derivative rule as a higher-order rule, we have

D (λx (sin x)) -→ × (D (λx x)) (λx (cos x))
thus the peak above is now joinable, and, more generally, confluence holds. Given a pattern l and a term t there are different substitutions σ such that σl ≡ βΓ t and some of them are not be well-typed. To get a precise and type-safe definition of higher-orderrewriting, we use the concepts of higher-order rewrite system [START_REF] Nipkow | Higher-order critical pairs[END_REF]. Remark, however, that our notion of higher-order rewriting does not require the identification of η-equivalent terms as for higher-order rewrite systems. See [START_REF] Saillard | Rewriting modulo β in the λΠ-calculus modulo[END_REF] for more details. This also gives us powerful confluence criteria such as confluence for development-closed systems [START_REF] Van Oostrom | Development closed critical pairs[END_REF].

The reason why we are interested in the confluence of this extended higher-order rewrite relation is that, when combined with β-reduction, first-and higher-order rewriting yield the same congruence. Therefore, if higher-order rewriting is confluent and terminating, ≡ βΓ is decidable.

Typing rewrite rules

As we want reduction to preserve typing, we must check that the rewrite rules are welltyped in the sense of Definition 2. To do so, we introduce two new judgments: Γ ⊢ l -→ ∆ r expressing that the rule l -→ ∆ r is well-typed in Γ and Γ strongly well-formed, expressing that all the rules declared in Γ are well-typed. This judgment is defined by the rules [ ] strongly well-formed Γ strongly well-formed Γ ⊢ A : T ype Γ, x : A strongly well-formed Γ strongly well-formed Γ ⊢ A : Kind Γ, x : A strongly well-formed Γ strongly well-formed Γ ⊢ l -→ ∆ r Γ, l -→ ∆ r strongly well-formed Defining an effective rule for the judgment Γ ⊢ l -→ ∆ r, that fits Definition 2, is more difficult. This definition quantifies over all possible substitutions, so is not effective. Thus, we need to under-approximate this notion and find rules that express sufficient conditions for well-typedness. A first attempt is to require l and r to be well-typed and to have the same type in Γ, ∆ l is a pattern Γ, ∆ ⊢ l : T Γ, ∆ ⊢ r :

T dom(∆) ⊆ F V (l) Γ ⊢ l -→ ∆ r
But this condition is too restrictive as shown by the following example. Consider a context containing a variable A of type T ype, a variable V ector of type nat → T ype, a variable N il of type (V ector 0), and a variable Cons of type Πn : nat (A → (V ector n) → (V ector (S n))). Assume that we want to define the T ail function of type Πn : nat

((V ector (S n)) → (V ector n)).
A first possibility is to use the non left-linear rule (T ail n (Cons n a l)) -→ l but proving confluence of a non-linear rewrite system, not assuming termination-as underlined above, confluence comes first-, is difficult. Thus, we might prefer the linear rule

(T ail n (Cons m a l)) -→ l
This rule is well-typed in the sense of Definition 2, but its left-hand side is not well-typed: (Cons m a l) has type (V ector (S m)) and (T ail n) expects a term of type (V ector (S n)). So we need a weaker condition, in order to accept this rule [START_REF] Blanqui | Definitions by rewriting in the calculus of constructions[END_REF][START_REF] Saillard | Type Checking in the Lambda-Pi-Calculus Modulo: Theory and Practice[END_REF].

Typing the term σ(T ail n (Cons m a l)) generates the constraint

(V ector (S σn)) ≡ (V ector (S σm))
Using the injectivity of the functions V ector and S, this constraint boils down to σn ≡ σm so all the substitutions σ, such that σ(T ail n (Cons m a l)) is well-typed, have the form ητ where η is an arbitrary substitution and τ = p/m, p/n. The substitution τ is the most general typing substitution for l. Both the terms τ (T ail n (Cons m a l)) and τ l have type (V ector p). So, for all η, ητ (T ail n (Cons m a l)) and ητ l have the same type and the rule is well-typed. Therefore, sufficient condition for the rule l -→ r to be well-typed is that l has a most general typing substitution τ and τ l and τ r have the same type. This leads to the rule

l is a pattern Γ, ∆ ⊢ τ l : T Γ, ∆ ⊢ τ r : T dom(∆) ⊆ F V (l) Γ ⊢ l -→ ∆ r
where τ is the most general typing substitution for l in Γ, ∆. This rule subsumes the first one as, if l is well-typed, it has the identity as a most general typing substitution.

▶ Lemma 7 (Theorem 3.5.8 in [START_REF] Saillard | Type Checking in the Lambda-Pi-Calculus Modulo: Theory and Practice[END_REF]). Let Γ be a well-formed context satisfying the product compatibility.

If Γ ⊢ l -→ ∆ r, then (l -→ ∆ r) is well-typed in Γ.
Finally, we can prove the effectiveness theorem.

▶ Theorem 8 (Effectiveness, Theorem 4.5.10 and Theorem 6.3.1 in [START_REF] Saillard | Type Checking in the Lambda-Pi-Calculus Modulo: Theory and Practice[END_REF]). If Γ is a strongly well-formed context such that higher-order rewriting is confluent then Γ satisfies the subject reduction property. Moreover, if higher-order rewriting is terminating on well-typed terms, then typing is decidable.

Dedukti

Dedukti (http://dedukti.gforge.inria.fr/) is a proof-checker for the λΠ-calculus modulo theory. This system is not designed to develop proofs, but to check proofs developed in other systems. In particular, it enjoys a minimalistic syntax. It gives a concrete syntax to the λΠ-calculus modulo theory, defined in Section 2.

The typing algorithm relies on the confluence and termination of the higher-order rewrite system together with β-reduction, to decide whether two terms are convertible.

The text with a grey background is executable Dedukti code. To avoid repetitions part of this code is omitted, the complete version can be found on the Dedukti website.

A proof-checker for the λΠ-calculus modulo theory

As in the λΠ-calculus modulo theory, there are two kinds of constructs available in Dedukti: variable declaration and rewrite rule declaration. The only available constant at the root of a file is Type, that corresponds to T ype above. The sort Kind is not part of the input syntax and is used only internally.

One only needs to declare the variables and rewrite rules, that will take place in the global context. We can declare a variable nat, together with its type as follows nat : Type .

The Π-types Πx : A B are represented with a single-line arrow x:A -> B, which is thus a binder. When there is no dependency, x can be dropped, as in 0 : nat . S : nat -> nat .

Rewrite rules, together with their local context ∆ are declared in the form [local context] l --> r. The types of the variables in the local context are inferred automatically. For instance def plus : nat -> nat -> nat .

[ n ] plus 0 n --> n .

[ n1 , n2 ] plus ( S n1 ) n2 --> S ( plus n1 n2 ).

A head symbol may be defined through several rewrite rules, in this case, we allow their introduction all at once in the context, instead of one by one, as is done in Section 2.2 and just above. We express that the rules are defined all at once by writing just one dot at the end of the sequence.

[ n ] plus 0 n --> n [ n1 , n2 ] plus ( S n1 ) n2 --> S ( plus n1 n2 ).

This has a direct impact on how the rules are typed. In the former case, the first rule can be used to type the second, while in the latter, it cannot.

Rewrite rules having the same head symbol need not be added sequentially, they can be separated by an arbitrary number of steps. In complex cases, the well-typing of a rewrite rule on a symbol g may depend on a rewrite rule on a symbol f, while further rewrite rules on f may depend on those previously declared on g.

Moreover, one can add as many rules as wanted for a given head symbol, as long as confluence is preserved. Checking confluence is out of the scope of Dedukti itself, and is a separate concern. To support confluence checking by external tools, an export feature towards the old TPDB format [53], used in confluence competitions, is available. For instance, we can add the following rule to make plus associative.

[ n1 , n2 , n3 ] plus n1 ( plus n2 n3 ) --> plus ( plus n1 n2 ) n3 .

Defining a constant, standing for a complex expression, is identical to defining a rewrite rule in an empty rewrite context. For convenience, a special syntax is allowed def two := S ( S 0).

Finally, λ-abstraction is expressed with the double arrow => def K2 := x : nat = > two .

Notice, that type annotation on the variable is optional [START_REF] Barthe | Domain-free pure type systems[END_REF], when it can be reconstructed by bidirectional typechecking [START_REF] Boespflug | The λΠ-calculus modulo as a universal proof language[END_REF][START_REF] Chlipala | Strict bidirectional type checking[END_REF][START_REF] Coquand | An algorithm for type-checking dependent types[END_REF]. In this example, it is mandatory.

The semantic difference between variables, constants and constructors is purely in the eyes of the user, Dedukti treats them in the same way.

It is also possible to split definitions in several files, that can be imported. There also exist meta-directives to the checker, for instance to ask the reduction of a term in head normal form. Refer to the user manual [START_REF] Deducteam | User manual for Dedukti[END_REF], for the details.

Static and definable symbols

We have seen in Section 2.3.2, that a key step for accepting the linear rule tail n (Cons m a l) --> l is to compute the most general typing substitution for its left-hand side, tail n (Cons m a l). The existence of this substitution depends on the injectivity of the symbols vector and S. So, Dedukti needs to be aware that these symbols are injective with respect to the congruence ≡ βΓ . A simple way to ensure this property is to forbid rewrite rules whose head symbol is vector or S. Such a symbol, whose appearance at the head of rewrite rules is forbidden, is called a static symbol and is introduced by a declaration containing only the symbol name and its type, such as vector in the declarations A : Type . vector : nat -> Type . Nil : vector 0. Cons : n : nat -> A -> vector n -> vector ( S n ).

Symbols such as tail which may appear at the head of rewrite rules are called definable and are declared using the keyword def def tail : n : nat -> vector ( S n ) -> vector n .

Then, the rule

[n , m , a , l ] tail n ( Cons m a l ) --> l .
is accepted.

Wildcards

Instead of introducing new names for variables which will be inferred by the unification step, the wildcard symbol _ can be used in the left-hand side as an unnamed pattern, matching any term, so we might write

[n , a , l ] tail n ( Cons _ a l ) --> l .
or even

[ l ] tail _ ( Cons _ _ l ) --> l .

Guards

For the rare cases where the injectivity of a definable symbol would be needed to solve a unification problem, or when it would be preferable to use a non-normal term in the left-hand side of a rewrite rule, Dedukti implements a guard mechanism.

For this example, the user can add brackets-the guard-around the subterm whose shape is known by typing constraints.

[n , a , l ] tail n ( Cons { n } a l ) --> l .

Dedukti will type-check the rule as if there were no brackets, but the rewrite rule declared will be the linear one, that is to say the rule obtained by replacing the guard by a fresh variable.

Dedukti cannot check in general the validity of the guard, namely that it indeed follows from typing constraints, since it is undecidable. Thus, in order to guarantee in any case a type-safe reduction, Dedukti checks, each time the rule is used, that the typing constraints are satisfied. If they are not, this means that the rewrite rule is not well-typed and Dedukti fails with an error message.

Constructive predicate logic and Deduction modulo theory

The first example of theory that can be embedded in Dedukti is constructive predicate logic. As the type system is derived from the λΠ-calculus, we shall see that those embeddings can be defined quite naturally, and that, with rewriting, we can endow them with a computational content and make them shallow.

Minimal predicate logic

Even without rewrite rules, the λΠ-calculus can express proofs of minimal many-sorted predicate logic, that is the fragment of constructive many-sorted predicate logic where the only connective is the implication ⇒ and the only quantifiers are the universal quantifiers ∀ s , one for each sort.

▶ Definition 9 (Language embedding). To each language L of predicate logic, we associate a context Σ containing for each sort s of L, a variable s, of type Type, for each function symbol f of arity ⟨s 1 , . . . , s n , s ′ ⟩, a variable f, of type

s 1 -> ... -> s n -> s',
for each predicate symbol P of arity ⟨s 1 , . . . , s n ⟩, a variable P, of type

s 1 -> ... -> s n -> Type.
For instance s : Type . P : s -> Type .

▶ Definition 10 (Term embedding). Let t be a term in the language L, we express the term t as a λ-term as

|x| = x, |f (t 1 , . . . , t n )| = (f |t 1 | . . . |t n |).
The following lemma is proved with a simple induction on t.

▶ Lemma 11. If t is a term of sort s in the language L and Γ a context containing for each variable x of sort s ′ free in t, a variable x, of type s', then Σ, Γ ⊢ |t| : s.

▶ Definition 12 (Proposition embedding). Let A be a proposition in the language L, we express the proposition A as the following λ-term

∥P (t 1 , . . . , t n )∥ = (P |t 1 | . . . |t n |), ∥A ⇒ B∥ = ∥A∥ -> ∥B∥, ∥∀ s x A∥ = x:s -> ∥A∥.
The following lemma is proved with a simple induction on A.

▶ Lemma 13. If A is a proposition in the language L and Γ a context containing for each variable x of sort s free in A, a variable x, of type s, then Σ, Γ ⊢ ∥A∥ : Type.

The following theorem is proved with a simple induction on proof structure and on the structure of the normal form of π.

▶ Theorem 14 (Proof embedding). Let L be a language and A 1 , . . . , A n ⊢ B be a sequent in L, Γ 1 a context containing for each variable x of sort s free in A 1 , . . . , A n ⊢ B, a variable x, of type s, and Γ 2 be a context containing, for each hypothesis A i , a variable a i , of type ∥A i ∥. Then, the sequent A 1 , . . . , A n ⊢ B has a proof in Natural deduction, if and only if there exists a λ-term π such that Σ, Γ 1 , Γ 2 ⊢ π : ∥B∥, if and only if there exists a normal λ-term π such that Σ, Γ 1 , Γ 2 ⊢ π : ∥B∥.

For instance, the proposition ∀ T x (P (x) ⇒ P (x)) is embedded as x:T -> (P x) -> (P x) and it has the proof x:T => a:(P x) => a.

def Thm : x : s -> ( P x ) -> ( P x ) := x : s = > a :( P x ) = > a .

Note that if B is a proposition, then the term ∥B∥ is a type, in the sense that it has type Type and that it is the type of the proofs of B. But not all terms of type Type have the form ∥B∥, for instance if s is a sort of the language, then s has type Type but there exists no proposition B such that s = ∥B∥. So the concepts of proposition and type are not identified: propositions are types, but not all types are propositions.

Constructive predicate logic

The λΠ-calculus has been designed to express functional types but not Cartesian product types, disjoint union types, unit types, or empty types. Thus, the connectives and quantifiers ⊤, ⊥, ¬, ∧, ∨, and ∃ cannot be directly expressed as ⇒ and ∀ in Section 4.1. One possibility is to extend the λΠ-calculus with Cartesian product types or inductive types. Another is to use the rewrite rules of the λΠ-calculus modulo theory to define these connectives and quantifiers.

We first modify the expression of minimal predicate logic presented in Section 4.1. We introduce a variable o, of type Type o : Type . and instead of expressing a predicate symbol as a term of type s 1 -> ... -> s n -> Type, we now express it as a term of type s 1 -> ... -> s n -> o s : Type . P : s -> o .

Thus, the atomic proposition P (c) is expressed, in a first step, as the term (P c), of type o. We can also introduce a variable

imp of type o -> o -> o imp : o -> o -> o .
in order to express the proposition P (c) ⇒ P (c) as the term (imp (P c) (P c)), of type o. Then, to make a connection to Section 4.1, we introduce a variable eps-read "epsilon"-of type o -> Type def eps : o -> Type .

and the proposition P (c) can be expressed as the term eps (P c), of type Type. The type o is thus a universe "à la Tarski" [START_REF] Martin-Löf | Intuitionistic type theory[END_REF]. The proposition P (c) ⇒ P (c) can then be expressed both as eps (imp (P c) (P c)) and as eps (P c)) -> (eps (P c) and we add the rewrite rule to identify these expressions.

This allows also to add other connectives and quantifiers, for instance the conjunction and as a variable of type o -> o -> o, together with the rewrite rule that express its meaning through the so called "second-order" expression of the conjunction and : o -> o -> o .

[x , y ] eps ( and x y ) --> z : o -> ( eps x -> eps y -> eps z ) -> eps z .

▶ Definition 15 (Language embedding). To each language L of predicate logic, we associate a context Σ containing for each sort s of L a variable s of type The embedding of terms is defined as in Definition 10 and that of propositions comes in two steps. First, the translation |.| associates a term of type o to each proposition. Then the symbol eps is applied to this term to obtain a term of type Type.

▶ Definition 16 (Proposition embedding). Let A be a proposition in the language L. We express the proposition A as a λ-term as Finally, we add the rewrite rules expressing the meaning of the connectives-and is presented above-and quantifiers. The rationale behind those rules is, that they turn the deep o-level encoding into a shallow Type-level encoding. [ y ] eps ( fa_s y ) --> x : s -> eps ( y x ).

|P
def ex_s : ( s -> o ) -> o .

[ y ] eps ( ex_s y ) --> z : o -> ( x : s -> eps ( y x ) -> ( eps z )) -> eps z .

▶ Theorem 18 (Embedding of proofs, [START_REF] Dorra | Équivalence Curry-Howard entre le lambda-Pi-calcul et la logique intuitionniste[END_REF]). Let L be a language, Σ be the associated context, V be a set of variables and A 1 , . . . , A n , B be propositions in L such that the free variables of A 1 , . . . , A n , B are in V . Let Γ 1 be a context containing for each variable x of sort s in V , a variable x, of type s, and Γ 2 be a context containing, for each hypothesis A i a variable a i of type ∥A i ∥.

Then, the sequent A 1 , . . . , A n ⊢ B has a proof in Natural deduction if and only if there exists a λ-term π such that Σ, Γ 1 , Γ 2 ⊢ π : ∥B∥.

Again, not all terms of type Type have the form ∥B∥, only those convertible to a term of the form (eps p), where p is a term of type o, do. For instance o has type Type, but there is no proposition B such that o = ∥B∥. In contrast, every normal term of type o is equal to |B| for some B. Thus, the type o, also called Prop or bool in many systems, is the type of propositions.

So, the concepts of proposition and type are not identified in this encoding: the type o of propositions is a subtype of the type of all types, Type, through the explicit embedding eps, of type o -> Type. This way o can have type Type, without introducing inconsistencies.

Deduction modulo theory

The embedding presented in Section 4.2 extends readily to Deduction modulo theory: a theory is just expressed by declaring its rewrite rules.

Moreover, some theories, such as arithmetic or set theory, contain a sort ι and a sort κ for the classes of elements of sort ι and a comprehension scheme

∀x 1 . . . ∀x n ∃c ∀y (y ∈ c ⇔ A)
or its skolemized form

∀x 1 . . . ∀x n ∀y (y ∈ f x1,...,xn,A (x 1 , . . . , x n ) ⇔ A)
In the λΠ-calculus modulo theory this sort can be omitted and replaced by the type i -> o.

For instance, Heyting arithmetic [START_REF] Dowek | Arithmetic as a theory modulo[END_REF][START_REF] Allali | Algorithmic equality in Heyting arithmetic modulo[END_REF] can be presented in Deduction modulo theory with nine rewrite rules defining addition, multiplication, equality, and numberness The last rewrite rule, accounting for numberness, expresses that any n, of type nat, is a natural number if it verifies all predicates k, verified by 0 and closed by successor. Then we can prove the proposition ∀x N (x) ⇒ (x + 0) = x

iProverModulo

In this section we present the Dedukti back-end of iProverModulo, more information can be found about iProverModulo in [START_REF] Burel | Experimenting with deduction modulo[END_REF] and about the back-end in [START_REF] Burel | A shallow embedding of resolution and superposition proofs into the λΠ-calculus modulo[END_REF].

iProver [START_REF] Korovin | iProver -an instantiation-based theorem prover for first-order logic (system description)[END_REF] is a proof-search system for classical predicate logic, based on ordered resolution with selection [START_REF] Bachmair | Resolution theorem proving[END_REF]. An optional Instantiation-Generation rule [START_REF] Ganzinger | New directions in instantiation-based theorem proving[END_REF] can also be used, but we shall use a version of iProver where this option has not been activated.

As usual, a literal is either an atomic proposition or the negation of an atomic proposition and a clause is a set of literals. If C = {L 1 , . . . , L n }, we write ⌜C⌝ for the proposition ∀x

1 . . . ∀x m (L 1 ∨ (• • • ∨ (L n-1 ∨ L n ) . . . ))
where x 1 , . . . , x m are the variables of C. To prove a proposition A, its negation ¬A is first transformed into a set of clauses {C 1 , ..., C n } by an external tool. The proof then amounts to deriving the empty clause, using the usual resolution and factoring rules. The only difference between standard Resolution and ordered resolution with selection is that, in this second method, these rules are restricted to reduce the search space, while preserving completeness.

iProver has been extended to Deduction modulo theory, leading to iProverModulo [START_REF] Burel | Experimenting with deduction modulo[END_REF]. Proposition rewrite rules are simulated using so-called one-way clauses [START_REF] Dowek | Polarized resolution modulo[END_REF] that are handled with just more restrictions on the Resolution rule. Term rewrite rules, in contrast, lead to introduce an additional Narrowing rule.

When the proposition ¬A is transformed into a set of clauses C 1 , ..., C n and the empty clause can be derived from C 1 , ..., C n with the Resolution, Factoring, and Narrowing rules, a proof in Deduction modulo theory of the sequent ⌜C 1 ⌝, ..., ⌜C n ⌝ ⊢ ⊥ can be built, and this proof can then be transformed into a proof of the sequent ⊢ A. The latter transformation is only possible in classical logic, but the proof of the sequent ⌜C 1 ⌝, ..., ⌜C n ⌝ ⊢ ⊥ itself is constructive. And indeed, since version 0.7-0.2, iProverModulo has an export functionality that builds a Dedukti proof of ⌜C 1 ⌝, ..., ⌜C n ⌝ ⊢ ⊥, every time it derives the empty clause from C 1 , ..., C n .

A clause C can be transformed into a proposition ⌜C⌝ and then to a Dedukti term ∥⌜C⌝∥, of type Type, as seen in Section 4.2. However, instead of using the binary disjunction ∨, we generalize it to a multiary disjunction and translate directly the clause C = {L 1 , ..., L n } as the Dedukti term C of, type Type, as

C = x 1 :i->...->x m :i->(∥L 1 ∥->(eps bot))->...

->(∥L n ∥->(eps bot))->(eps bot)

where we use the sort i for terms. In particular, the translation of the empty clause is

∅ = eps bot = ∥⊥∥.
Proofs built by iProverModulo are then expressed in Dedukti step by step. We first declare a variable d C , of type ∥⌜C⌝∥ for each clause C in the set C 1 , ..., C n .

d C :eps |∀x 1 . . . ∀x m (L 1 ∨ • • • ∨ (L n-1 ∨ L n ) . . . )|
Then, using these variables, we can define a term c C , of type C . For each new clause generated by the inference rules, we build a proof of the conclusion from the proof of the premises. For instance, for the Resolution rule

C ∪ {P } D ∪ {¬Q} σ(C ∪ D)
where σ is the most general unifier of P and Q, we have a term c of type C ∪ {P } , and a term d of type D ∪ {¬Q} . We can combine them to define a term of the resolvant type σ(C ∪ D) . See [START_REF] Burel | A shallow embedding of resolution and superposition proofs into the λΠ-calculus modulo[END_REF] for more details. As an example, the proof where d1 (resp. d2) is the declaration of ∥⌜C 1 ⌝∥ (resp. ∥⌜C 2 ⌝∥); c1 (resp. c2) its translation using a multiary disjunction C 1 (resp. C 2 ); and c3, c4 and c5 correspond to the clauses derived from C 1 and C 2 in the proof tree above.

iProverModulo can be used to produce Dedukti proofs for 3383 problems of the TPTP problem library v6.3.0 [START_REF] Sutcliffe | The TPTP Problem Library and Associated Infrastructure: The FOF and CNF Parts, v3.5.0[END_REF]. The generated Dedukti files weight a total of 38.1 MB, when gzipped.

Classical predicate logic

A logical framework should be able to express both constructive and classical theories. A way to mix constructive and classical arguments is to apply the adjectives "constructive" and "classical" not to proofs, but to connectives. So, we shall not say that the proposition P ∨¬P has a classical proof and no constructive one. Instead, we shall say that the proposition P ∨ c ¬ c P has a proof and the proposition P ∨ ¬P does not, distinguishing the classical connectives ∨ c , ¬ c , etc. from the constructive ones ∨, ¬, etc. Reaping the benefit of the work done on negative translations by Kolmogorov, Gödel, Gentzen, Kuroda, and others, we want to define the classical connectives from the constructive ones, adding double negations before or after the connectives. For instance, defining A ∨ c B as ¬¬(A ∨ B). This approach has been investigated by Hermant, Allali, Dowek, Prawitz, etc. [START_REF] Allali | Semantic A-translations and super-consistency entail classical cut elimination[END_REF][START_REF] Dowek | On the definition of the classical connectives and quantifiers[END_REF][START_REF] Prawitz | Classical versus intuitionistic logic[END_REF]. In all these works the main problem is that the translation of an atomic proposition P needs to be ¬¬P and in this case there is no connective to which these negations can be incorporated. This has lead to various solutions: considering two different provability predicates [START_REF] Allali | Semantic A-translations and super-consistency entail classical cut elimination[END_REF], considering two entailment relations [START_REF] Dowek | On the definition of the classical connectives and quantifiers[END_REF], incorporating the double negation to the predicate symbol at the root of P [START_REF] Prawitz | Classical versus intuitionistic logic[END_REF].

We consider here another solution that fits better our goal to express classical proofs in a logical framework: the introduction of a new connective.

Classical connectives and quantifiers

The usual syntax for predicate logic distinguishes terms and propositions

t ::= x | f (t, . . . , t) A = P (t 1 , . . . , t n ) | ⊤ | ⊥ | ¬A | A ⇒ A | A ∧ A | A ∨ A | ∀x A | ∃x A
The syntactic category of terms introduces only function symbols which are specific to the theory, while the second syntactic category of propositions introduces both predicate symbols, which are specific to the theory, and connectives which are not.

A clearer presentation completely separates the symbols of the theory and those of the logic introducing a third syntactic category for atoms

t ::= x | f (t, . . . , t) a ::= P (t 1 , . . . , t n ) A = a | ⊤ | ⊥ | ¬A | A ⇒ A | A ∧ A | A ∨ A | ∀x A | ∃x A
When formalizing such a definition in a logical framework we must introduce a type for terms of each sort, a type for atoms, and a type for propositions, and we cannot just say that atoms are propositions. Instead, we must introduce an explicit embedding from atoms to propositions, a new connective, ▷, so the propositional category becomes

A ::= ▷ a | ⊤ | ⊥ | ¬A | A ⇒ A | A ∧ A | A ∨ A | ∀x A | ∃x A
This way, the new connective ▷, in its classical version, may incorporate the double negation usually put on the atom itself. For instance, Kolmogorov translation yields the following definitions of the classical atomic, conjunction, and disjunction connectives

▷ c A = ¬¬ ▷ A A ∧ c B = ¬¬(A ∧ B) A ∨ c B = ¬¬(A ∨ B)
Assuming the constructive connectives and quantifiers of Section 4.2, the full set of classical connectives and quantifiers can now be defined in Dedukti as The embedding of languages is as in Definitions 9 and 15, except that the predicate symbol now have a target type alpha, instead of Type, or o. The embedding of terms is defined as in Definition 10. We define the constructive and classical embeddings for propositions as follows.

▶ Definition 19 (Proposition embedding). Let A be a proposition in the language L we embed it constructively as a λ-term as |P (t

)| c = atom_c (P |t 1 | . . . |t n |), |⊤| c = top_c, |⊥| c = bot_c, |¬A| c = not_c |A| c , |A ⇒ B| c = imp_c |A| c |B| c , |A ∧ B| c = and_c |A| c |B| c , |A ∨ B| c = or_c |A| c |B| c , |∀ s x A| c = fa_s_c (x:s => |A| c ), |∃ s x A| c = ex_s_c (x:s => |A| c ).
The following lemma is proved with a simple induction on A. Note that the normal form of |A| c is the result of the Kolmogorov translation of A, constructively embedded with | |. Thus, combining Kolmogorov's results about his translation with Theorem 18, we get the following theorem. Note that, since the symbols ∨ and ∨ c , ▷ and ▷ c , etc. have different meanings the propositions ∀x∀y∀z (▷ x ∈ {y, z}

▶

▶ Theorem 21. A proposition A has a proof in constructive logic if and only if the type eps |A| is inhabited. A proposition A has a proof in classical logic if and only if the type eps

⇔ (▷ x = y ∨ ▷ x = z)) ∀ c x∀ c y∀ c z (▷ c x ∈ {y, z} ⇔ c (▷ c x = y ∨ c ▷ c x = z))
also have different meanings. In a mixed logic containing both constructive and classical connectives, we can choose to take one, or the other, or both as axioms, leading to different theories.

Classical Deduction modulo theory

Like constructive logic, classical logic can be extended with a congruence defined by rewrite rules. The translation of a rewrite rule of classical Deduction modulo theory such as

▷ c x ∈ {y, z} -→ (▷ c x = y) ∨ c (▷ c x = z)
could be expressed directly in Dedukti, but it would introduce a critical pair because ▷ c P also reduces to ¬¬ ▷ P . To close this critical pair, we rather add the rule

▷ x ∈ {y, z} -→ (▷ c x = y) ∨ (▷ c x = z)
that subsumes the first one as ¬¬ ▷ x ∈ {y, z} then rewrites to ¬¬((

▷ c x = y) ∨ (▷ c x = z)).
Thus, to avoid critical pairs when translating a rewrite rule of classical Deduction modulo theory, we must remove the two head negations that would otherwise appear at the head of the left-hand and right-hand sides of the rewrite rule. Said otherwise, we turn the head connective of the left-and right-hand sides into a constructive one.

We had two versions of the pairing axiom above, one constructive and the other classical. In the same way, this rule is different from the translation of the rewrite rule of constructive Deduction modulo theory

▷ x ∈ {y, z} -→ (▷ x = y) ∨ (▷ x = z)

Zenon

In this section we present Zenon 0.8.2 and Zenon Modulo 0.4.2, more information about Zenon can be found at [START_REF] Bonichon | Zenon: An extensible automated theorem prover producing checkable proofs[END_REF], and about Zenon Modulo at [START_REF] Delahaye | Zenon Modulo: When Achilles Outruns the Tortoise using Deduction Modulo[END_REF][START_REF] Bury | Automated Deduction in the B Set Theory using Typed Proof Search and Deduction Modulo[END_REF].

Zenon is a proof search system for classical predicate logic with equality, based on a tableaux method, that is a sequent calculus with one-sided sequents, where all propositions are on left-hand side. Zenon Modulo is an extension of Zenon that builds proofs in Deduction modulo theory. A proof of a proposition G in a context Γ is a tableaux proof of the sequent Γ, ¬G ⊢.

As we have seen, a proposition G has a classical proof, if and only if the type (eps |G| c ) is inhabited in Dedukti. When proving a proposition G, Zenon Modulo produces a Dedukti proof-term, of type (eps |G| c ) [START_REF] Cauderlier | Checking Zenon Modulo Proofs in Dedukti[END_REF].

More precisely it first produces a Dedukti term of type eps (not_c |G| c ) -> eps bot. This term can then be turned into a term of type (eps |G| c ) by applying the constructive theorem ¬¬¬A ⇒ ¬A twice, because |G| c starts with a negation.

These proofs of eps (not_c |G| c ) -> eps bot are generated by stating in Dedukti one lemma per tableaux rule. For instance, the tableaux rule

A ∨ c B Ror A B
that corresponds to the sequent calculus rule The translation of Zenon Modulo proofs to Dedukti has been tested using a benchmark of 9,994 B Method [START_REF]The B-Book, Assigning Programs to Meanings[END_REF] proof obligations, representing 5.5 GiB of input files. The generated Dedukti files weigh a total of 595 MB, when gzipped.

Γ, A ⊢ Γ, B ⊢ ∨-left Γ, A ∨ c B ⊢
Around fifty axioms of the B Method set theory were turned into rewrite rules. For instance, membership to the union between two sets is defined as follows def mem : s -> s -> alpha . def union : s -> s -> s .

[a , b , x ] atom ( mem x ( union a b ))

--> ( or ( atom_c ( mem x a )) ( atom_c ( mem x b ))).

6

Simple type theory

Expressing simple type theory

There are two ways to express Simple type theory [START_REF] Church | A formulation of the simple theory of types[END_REF], also known as Higher-order logic, in the λΠ-calculus modulo theory. First, Simple type theory can be expressed in Deduction modulo theory [START_REF] Dowek | Hol-lambda-sigma: an intentional first-order expression of higher-order logic[END_REF]. Thus, as seen in Section 4.3, it can be expressed in the λΠ-calculus modulo theory. It can also be expressed as a Pure type system [START_REF] Geuvers | Logics and Type systems[END_REF][START_REF] Geuvers | The calculus of constructions and higher order logic[END_REF], hence in the λΠcalculus modulo theory [START_REF] Cousineau | Embedding pure type systems in the lambda-Pi-calculus modulo[END_REF], which leads to a similar result.

In Simple type theory, the sorts of the logic are the types of the simply-typed λ-calculus, with two basic types: ι for the objects and o for the propositions. The language contains the variables ⇒, of type o → o → o, that represents implication and ∀ A , for each simple type A, that represent universal quantification. In order to avoid declaring an infinite number of symbols, we represent simple types as Dedukti terms of a type type and pass elements of this type, to index a single symbol ∀. One should not confuse type, which is the type of objects representing types of the Simple type theory, with Type, which is the type of Dedukti types. We endow the arrow types of the type level, the behavior of arrow types of the Type level, by adding the rule

|x| = x, | ⇒ | = imp, |∀ A | = forall |A|, |M N | = |M | |N |, |λx : A M | = x: (term |A|) => |M |.
As in Section 4.2, we declare a variable eps that maps a proposition to the type of its proofs, and we define its meaning with the rewrite rules def eps : term o -> Type .

[p , q ] eps ( imp p q ) --> eps p -> eps q . [a , p ] eps ( forall a p ) --> x : term a -> eps ( p x ).

This signature-call it Σ STT -defines the logic of minimal constructive Simple type theory. For any proposition A, we define ∥A∥ = eps |A|, and for any context Γ = A 1 , . . . , A n , we define ∥Γ∥ = h 1 : ∥A 1 ∥, . . . , h n : ∥A n ∥, where h 1 , ..., h n are new variables. Then we can express all the proofs of Simple type theory.

▶ Theorem 23 (Theorem 5.2.11 and Theorem 6.2.27 in [START_REF] Assaf | A framework for defining computational higher-order logics[END_REF]). Γ ⊢ A is provable in Simple type theory, if and only if there is a λ-term π such that Σ STT , ∥Γ∥ ⊢ π : ∥A∥.

Moreover, the term π is a straightforward encoding of the original proof

HOL Light proofs

The embedding of the previous Section 6.1 can be adapted to represent variations of Simple type theory, in particular classical ones like the system Q 0 [START_REF] Andrews | An introduction to mathematical logic and type theory: to truth through proof[END_REF], which is based on equality as a primitive connective and which is used in modern implementations of Simple type theory, like HOL Light [START_REF] Assaf | Translating HOL to Dedukti[END_REF].

The system HOLiDe-pronounced "holiday"-allows for the expression HOL Light proofs in Dedukti, building on the Open theory project [START_REF] Hurd | The opentheory standard theory library[END_REF]. HOLiDe supports all the features of HOL Light, including prenex polymorphism, constant definitions, and type definitions. It is able to express all of the 10MB OpenTheory standard theory library. This translation results in a Dedukti library of 21.5 MB, when gzipped. It could also be used to check in Dedukti proofs developed in other implementations of HOL, provided they can export proofs to the Open theory format.

Programming languages

Since rewriting is Turing-complete, we can also use the λΠ-calculus modulo theory as a programming language and embed programming languages into it. This allows to express proofs of programs in Dedukti. We target a shallow embedding in the logic, so that we can reason about them as functions. In particular we cannot speak about the number of lines of code of a program, or the number of execution steps, but we can speak about functional properties of these programs. The embedding is defined by a rewrite system expressing the operational semantics of the source language.

In this section, we present three examples, the λ-calculus, the ς-calculus and ML and then FoCaLiZe that is a logic to reason about programs. [f , t ] app ( lam f ) t --> f t .

Lambda-calculus

Encoding programming languages in the λΠ-calculus modulo theory and translating their libraries is mandatory to check proofs of certified programs in Dedukti. It is especially adequate for checking partial correctness proofs-that implicitly assume termination of the program. As shallow embeddings preserve the programming language binding, typing, and reduction, we can abstract on the program reduction and only consider programs as mathematical functions.

Obviously, preserving the programming language reduction can lead to a non-terminating rewrite system, which is not effective in the sense of Section 2.3. However it is not often a problem in practice for the following reasons.

The soundness of Dedukti, that is the fact that Dedukti accepts well-typed terms only, does not depend on termination but only on product compatibility-see Lemma 7. The only place where the type-checking algorithm uses reduction is the conversion rule, to check convertibility of two types; as long as we do not use types depending on nonterminating terms, Dedukti terminates. Even in presence of types depending on weakly-terminating terms, Dedukti's strategycomparison of weak head normal forms-often terminates.

For instance, we can define a fixpoint operator in simply-typed λ-calculus and prove properties of recursive terminating functions defined using this fix operator, such as the function mod2 defined below. The #CONV command in last line checks that the terms mod2 (S (S (S (S O)))) and O are convertible.

The ς-calculus

Abadi and Cardelli [START_REF] Abadi | A Theory of Objects[END_REF] have introduced a family of calculi for object-oriented programming. These calculi differ on their typing discipline and on whether they are purely functional or imperative. The simplest of them is Obj 1 . It is object-based-classes are not primitive constructs but can be defined from objects-and its type system is similar to that of the simply-typed λ-calculus.

Types A are records of types A ::= [l i : A i ] i∈1..n . Labels are distinct and their order is irrelevant. We translate them by first sorting the labels and then using association lists label : Type . type : Type . typenil : type . typecons : label -> type -> type -> type .

|[l

i : A i ] i∈1...n,l1<...<ln | = typecons l 1 |A 1 | (. . . typecons l n |A n | typenil . . .)
Objects are records of methods introduced by a special binder ς, binding the object itself inside the method's body. The primitive operations are method selection and method update:

a, b, . . .

::= x (variable) | [l i = ς(x i : A)a i ] i∈1...n (object) | a.l (method selection) | a.l ⇐ ς(x : A)b (method update)
We cannot define objects as lists in Dedukti, because a sublist of a well-typed object is not a well-typed object: the type annotation on each ς binder refers to the type of the full object. In order to define partially constructed objects as lists, we introduce the notion of preobject.

Preobj : type -> type -> Type .

The first type argument of the type Preobj is the type of the object that we are constructing. The second argument is the type of the part we have already constructed, a dependent type of lists parameterized by the corresponding portion of the type. When this second part reaches the first one, we get an object, so the type for objects is def Obj ( A : type ) := Preobj A A .

The constructors of preobjects are

prenil : A : type -> Preobj A typenil . precons : A : type -> B : type -> l : label ->

ML

The translation of ML types has already been addressed in Section 6.1. The main features added by the ML programming language are call by value, recursion and algebraic datatypes. All these features are present in the λΠ-calculus modulo theory, but they are only available at toplevel and the notion of pattern matching in rewrite systems is slightly different. While, in functional languages, only values are matched and the order in which patterns are given is usually relevant, rewrite rules can be triggered on open terms and rewrite systems are assumed confluent. Making use of tuples if necessary, we assume that every constructor has arity one. Pattern matching can be faithfully encoded without appealing to complex compilation techniques thanks to destructors. Destructors generalize over the if-then-else construct (the destructor associated with the constructor true) by binding the subterm t. Unlike the eliminators of Section 8.2, destructors are specific to a given constructor, which allows to handle nested patterns.

▶ Definition 26. Let C be a datatype constructor of type τ -> τ ′ , the destructor associated with C is the symbol destr C , of type R : type -> (eps τ ′ -> (eps τ -> eps R) -> eps R -> eps R), defined by the following rewrite rules:

destr C R (C t) f d --> f t destr C R (C' t') f d --> d
(for all other constructors C' for type τ ′ ) ▶ Lemma 27 (Theorem 1 in [START_REF] Cauderlier | ML pattern-matching, recursion, and rewriting: from Fo-CaLiZe to Dedukti[END_REF]). ML pattern matching can be expressed by destructors in a semantics-preserving way.

Recursion can also be encoded without generating obvious non-termination on open terms; we introduce a global symbol @, of type A : type -> B: type -> ((eps A -> eps B) -> eps A -> eps B), defined for each constructor C of type τ -> τ ′ by the following rewrite rule

@ τ ′ R f (C t) --> f (C t)
This symbol freezes evaluation until the argument starts with a constructor. It is inserted in the right-hand side of all recursive definitions to freeze recursive calls. ▶ Lemma 28. If a ML term t evaluates to a ML value v, then its translation |t| reduces to |v|.

FoCaLiZe

Our main motivation for translating programming languages to the λΠ-calculus modulo theory is to check program certificates. The FoCaLiZe system [START_REF] Focalize | [END_REF] is an environment for the development of certified programs; it uses ML as an implementation language, classical predicate logic as a specification language, and provides static object-oriented features to ease modularity. Moreover, it delegates most proofs to Zenon Modulo, which provides Dedukti proofs, as seen in Section 5.3. Thus, it is a good candidate for an encoding to Dedukti.

Let us consider again the function mod2. A specification for mod2 would typically include a theorem stating that mod2 returns Zero on even numbers, where by "even number" we mean a number which is the double of another. This can be formulated from the function twice returning the double of a number:

let rec twice (n) = match n with | Zero -> Zero | Succ(m) -> Succ(Succ(twice(m))) ;;
Hence, the statement of our theorem would be all n:nat, mod2(twice(n)) = Zero. This theorem is proved by induction over natural numbers. The two inductive steps can be processed by Zenon Modulo. As we can see from this example, FoCaLiZe proofs are very succinct; they are mere a list of hints, used to compute a first-order problem, that is given to Zenon Modulo. In order to conclude the proof of the theorem, we need an induction principle. It can be axiomatized in FoCaLiZe theorem nat_induction : all p : (nat -> bool), p(Zero) -> (all n : nat, p(n) -> p(Succ(n))) -> all n : nat, p(n) proof = assumed;; but this is not a first-order statement and Zenon Modulo is not able to instantiate it. However FoCaLiZe allows to write the instantiation directly in Dedukti

8

The Calculus of inductive constructions with universes

Pure type systems

Pure type systems [START_REF] Barendregt | Lambda calculi with types[END_REF] are a general class of typed λ-calculi that include many important logical systems based on the propositions-as-types principle such as the Calculus of constructions. We can express functional Pure type systems in the λΠ-calculus modulo theory [START_REF] Cousineau | Embedding pure type systems in the lambda-Pi-calculus modulo[END_REF] using ideas similar to the expression of Simple type theory, see Section 6.1, and to the mechanisms of Tarski-style universes in Intuitionistic type theory [START_REF] Martin-Löf | Intuitionistic type theory[END_REF]. We represent each type A of sort s as a term |A|, of type U s , and each term M of type A as a term |M |, of type eps s |A| [START_REF] Cousineau | Embedding pure type systems in the lambda-Pi-calculus modulo[END_REF]. Consider a Pure type system specification (S, A, R). For each sort s ∈ S, we declare the type U s whose inhabitants represent the types of sort s, and the dependent type eps s whose inhabitants represent the terms of the types of sort s. For conciseness, in this Section we use e instead of eps. U_s : Type. def e_s : U_s -> Type.

For each axiom ⟨s 1 , s 2 ⟩ ∈ A, we declare the variable u s1 which is the term that represents the sort s 1 in s 2 , and we give its interpretation as a type using a rewrite rule.

u_s1 : U_s2. [ ] e_s2 u_s1 --> U_s1.
For each rule ⟨s 1 , s 2 , s 3 ⟩ ∈ R, we declare the variable π s1,s2 which is the term that represents dependent products such as Πx : A B in s 3 , and we give its interpretation as a type using a rewrite rule.

Inductive types

The Calculus of inductive constructions is an extension of the Calculus of constructions with inductive types. The straightforward way to encode inductive types in the λΠ-calculus modulo theory is to use constructors and a primitive recursion operator as in Gödel's system T [START_REF] Gödel | Über eine bisher noch nicht benützte Erweiterung des finiten Standpunktes[END_REF]. For example, for polymorphic lists, we declare a new variable list, such that list A is the type of lists of elements of A and two variables nil and cons for the constructors: list : U_Type -> U_Type . nil : A : U_Type -> e_Type ( list A ). cons : A : U_Type -> e_Type A -> e_Type ( list A ) -> e_Type ( list A ).

We still need an elimination scheme to define functions by recursion on lists and to prove theorems by induction on lists. To this end, we declare a new variable elim_list for the primitive recursion operator:

List : U_Type -> Type .

[ A ] e_Type ( list A ) --> List A . def elim_list : A : U_Type -> P : ( e_Type ( list A ) -> U_Type )

-> e_Type ( P ( nil A )) -> ( x : e_Type A -> l2 : e_Type ( list A ) -> e_Type ( P l2 ) -> e_Type ( P ( cons A x l2 ))) -> l : e_Type ( list A ) -> e_Type ( P l ).

The operator is parameterized by two types: the type A of the elements of the list we are eliminating and the return type P, which is the type of the object we are constructing by eliminating this list. It is a dependent type because it can depend on the list. The type of elim_list expresses that, if we provide a base case of type P nil, and a way to construct, for any element x:A and list l2:(list A) and object of type P l2, an object of type P (cons A x l2), then we can construct an object of type P l for any list l. Finally, we express the computational behavior of the eliminator, that reduces when applied to a constructor.

[A , P , case_nil , case_cons ] elim_list _ P case_nil case_cons ( nil A ) --> case_nil . [A , P , case_nil , case_cons , x , l ] elim_list _ P case_nil case_cons ( cons A x l ) --> case_cons x l ( elim_list A P case_nil case_cons l ).

Recursive functions and inductive proofs can then be expressed using this elimination operator. For instance, the append function is We can extend this technique to other inductive types, and we can also adapt it to represent functions defined by pattern matching and guarded recursion-as opposed to ML general recursion-, like those of the Coq system [START_REF] Boespflug | CoqInE: Translating the calculus of inductive constructions into the lambda-Pi-calculus modulo[END_REF]. Note that to formalize the full Calculus of inductive constructions, we need an infinite number of rules. As noticed in Section 2.2.4, each proof uses only a finite number of rules: those of the inductive types used in this proof.

Universes

Universes are the types of types in Intuitionistic type theory [START_REF] Martin-Löf | Intuitionistic type theory[END_REF]. They are similar to sorts in Pure type systems. To fully encode the universes of Intuitionistic type theory, we need to take into account two more features. First, there is an infinite hierarchy of universes

U 0 : U 1 : U 2 : • • •
Second, the hierarchy is cumulative

U 0 ⊆ U 1 ⊆ U 2 : • • •
which is expressed by the typing rule

Γ ⊢ M : U i Γ ⊢ M : U i+1
To deal with the infinite universe hierarchy, instead of declaring a different variable for each universe, we index the variable U, eps, u, π by natural numbers.

nat : Type . 0 : nat . S : nat -> nat .

U : nat -> Type . def eps : i : nat -> U i -> Type .

u : i : nat -> U ( S i ).

[ i ] eps _ ( u i ) --> U i .

def pi : i : nat -> a : U i -> b : ( eps i a -> U i ) -> U i .

[i , a , b ] eps _ ( pi i a b ) --> x : eps i a -> eps i ( b x ).

To express cumulativity, we cannot just identify the universe U i with the universe U i+1 , because not all terms of type U i+1 have type U i . In particular U i itself does not. We therefore rely on explicit cast operators ↑ i that lift types from a universe U i to a higher universe U i+1 . lift : i : nat -> U i -> U ( S i ).

[i , a ] eps _ ( lift i a ) --> eps i a .

A side effect of introducing explicit casts is that some types can have multiple representations as terms. For example, if Γ ⊢ A : U i and Γ, x : A ⊢ B : U i then the type Πx : A B has two different representations as a term in the universe U i+1 : lift i (pi i |A| (x => |B|) and pi (S i) (lift i |A| ) (x => lift i |B|). This multiplicity can break the preservation of typing [START_REF] Assaf | A calculus of constructions with explicit subtyping[END_REF], so we add the following rewrite rule to ensure that types have a unique representation as terms: These techniques can also be adapted to express the universes of the Calculus of inductive constructions, which in particular include an impredicative universe P rop [START_REF] Assaf | A calculus of constructions with explicit subtyping[END_REF].

Matita proofs

There are not many libraries of proofs expressed in the pure Calculus of constructions with universes. Indeed, the Coq library is expressed in a Calculus of constructions with universes, modules and universe polymorphism. Those two latter features have not yet been expressed in Dedukti, so the Coq library cannot be checked directly. Preliminary results in this direction are presented in [START_REF] Jouannaud | Untyped confluence in dependent type theories[END_REF].

A closely related library comes from Matita. It is expressed in a Calculus of constructions with universes, and proof irrelevance. Even if proof irrelevance has not yet been expressed in Dedukti, the system Krajono is able to translate all the files which come with the Matita tarball and which do not explicitly use proof irrelevance. Tests have been conducted on the arithmetic library of Matita, giving a successfully checked Dedukti library of 1.11 MB, when gzipped.

Conclusion and future work

The encodings and the benchmarks discussed in this paper give an overview of the versatility of Dedukti to express a wide range of theories. They also demonstrate that this tool scales up well to very large libraries, recall the five libraries discussed in this paper:

The iProverModulo TPTP library 38.1 MB The Zenon modulo Set Theory Library 595 MB The Focalide library 1.89 MB The Holide library 21.5 MB The Matita arithmetic library 1.11 MB Like the Dedukti system, all these translators and libraries are available on the Dedukti web site. Future work include expressing more proofs in Dedukti, in particular proofs coming from Coq, PVS and from SMT solvers and build a larger proof library.

It also includes reverse engineering of proofs. Although HOL Light is a classical system, many proofs of the HOL Light library happen to be constructive. Many proofs in the Matita library do not require the full power of the Calculus of inductive constructions with universes and can be expressed in weaker theories.

This reverse engineering of proofs is a first step towards the possibility to use Dedukti to develop complex proofs by combining lemmas developed in several systems. A first investigation in this direction is presented in [START_REF] Assaf | Mixing HOL and Coq in Dedukti[END_REF], but still requires to be generalized and automated.

More generally, we hope, with this project, to contribute to the shift of the general question "What is a good system to express mathematics?" to the more specific questions "Which definitions, axioms and rewrite rules are needed to prove which theorem?"

  [x , y ] eps ( imp x y ) --> ( eps x ) -> ( eps y ).

  def top : o . [ ] eps top --> z : o -> ( eps z ) -> ( eps z ). def bot : o . [ ] eps bot --> z : o -> ( eps z ). def not : o -> o := x : o = > imp x bot . def or : o -> o -> o . [x , y ] eps ( or x y ) --> z : o -> ( eps x -> eps z ) -> ( eps y -> eps z ) -> eps z . def fa_s : ( s -> o ) -> o .

  nat : Type . 0 : nat . S : nat -> nat . def plus : nat -> nat -> nat . def times : nat -> nat -> nat . def equal : nat -> nat -> o . N : nat -> o . [ y ] plus 0 y --> y [x , y ] plus ( S x ) y --> S ( plus x y ). [ y ] times 0 y --> 0 [x , y ] times ( S x ) y --> plus ( times x y ) y . [ ] equal 0 0 --> top [ x ] equal ( S x ) 0 --> bot [ y ] equal 0 ( S y ) --> bot [x , y ] equal ( S x ) ( S y ) --> equal x y . [ n ] eps ( N n ) --> k :( nat -> o ) -> eps ( k 0) -> eps ( fa_nat ( y : nat = > imp ( N y ) ( imp ( k y ) ( k ( S y ))) ) ) -> eps ( k n ).

  def tt : eps top := z : o = > p : eps z = > p . def k := x : nat = > equal ( plus x 0) x . def z_r_neutral : eps ( fa_nat ( x = > imp ( N x ) ( k x ))) := x : nat = > p : eps ( N x ) = > p k tt ( y : nat = > q : eps ( N y ) = > r : eps ( k y ) = > r ).

( 1 )

 1 {P (a, x), P (y, b), P (y, x)} Factoring P (a, b) (1) {¬P (a, x), ¬P (y, b)} Resolution ¬P (a, x) Resolution ∅ is a derivation of the empty clause from the clauses C 1 = {P (a, x), P (y, b), P (y, x)} and C 2 = {¬P (a, x), ¬P (y, b)}. It is translated in Dedukti as i : Type . P : i -> i -> o . a : i . b : i . d1 : eps ( fa_i ( x = > fa_i ( y = > or ( P a x ) ( or ( P y b ) ( P y x ))))). d2 : eps ( fa_i ( x = > fa_i ( y = > or ( not ( P a x )) ( not ( P y b ))))). def c1 : x : i -> y : i -> ( eps ( P a x ) -> eps bot ) -> ( eps ( P y b ) -> eps bot ) -> ( eps ( P y x ) -> eps bot ) -> eps bot := x = > y = > l1 = > l2 = > l3 = > z = > d1 x y z ( l1 ' = > l1 l1 ' z ) ( sb1 = > sb1 z ( l2 ' = > l2 l2 ' z ) ( l3 ' = > l3 l3 ' z )). def c2 : x : i -> y : i -> (( eps ( P a x ) -> eps bot ) -> eps bot ) -> (( eps ( P y b ) -> eps bot ) -> eps bot ) -> eps bot := x = > y = > l1 = > l2 = > z = > d2 x y z ( l1 ' = > l1 l1 ' z ) ( l2 ' = > l2 l2 ' z ). def c3 : ( eps ( P a b ) -> eps bot ) -> eps bot := l1 = > c1 b a l1 l1 l1 . def c4 : x : i -> (( eps ( P a x ) -> eps bot ) -> eps bot ) -> eps bot := x = > l1 = > c3 ( tp = > c2 x a l1 ( tnp = > tnp tp )). def c5 : eps bot := c3 ( tp = > c4 b ( tnp = > tnp tp )).

  alpha : Type . def atom : alpha -> o . def atom_c : alpha -> o := p : alpha = > not ( not ( atom p )). def top_c : o := not ( not top ). def bot_c : o := not ( not bot ). def not_c : o -> o := x : o = > ( not ( not ( not x ))). def and_c : o -> o -> o := x : o = > y : o = > not ( not ( and x y )). def or_c : o -> o -> o := x : o = > y : o = > not ( not ( or x y )). def imp_c : o -> o -> o := x : o = > y : o = > not ( not ( imp x y )). def fa_s_c : ( s -> o ) -> o := x :( s -> o ) = > not ( not ( fa_s x )). def ex_s_c : ( s -> o ) -> o := x :( s -> o ) = > not ( not ( ex_s x )).

  |A| c is inhabited. For instance, the proposition ▷ c P ∨ c ¬ c ▷ c P has the following proof, where a redex has been introduced def lem : p : alpha -> eps ( or_c ( atom_c p ) ( not_c ( atom_c p ))) := p = > h0 : ( eps ( or ( atom_c p ) ( not_c ( atom_c p ))) -> eps bot ) = > ( h1 : eps ( not ( atom_c p )) = > h0 ( z = > h_left = > h_right = > h_right ( h = > h h1 ))) ( h2 : eps ( atom_c p ) = > h0 ( z = > h_left = > h_right = > h_left h2 )).

  is reflected by the following Dedukti lemma def Ror : A : o -> B : o -> ( eps A -> eps bot ) -> ( eps B -> eps bot ) -> eps ( or_c A B ) -> eps bot := A = > B = > HNA = > HNB = > HNNAB = > HNNAB ( HAB = > HAB bot HNA HNB ).

  type : Type . o : type . i : type . arrow : type -> type -> type . def term : type -> Type . imp : term o -> term o -> term o . forall : a : type -> ( term a -> term o ) -> term o .

▶ Definition 22 .

 22 [a , b ] term ( arrow a b ) --> term a -> term b . The terms of Simple type theory are embedded as Dedukti terms as follows

  For example, the untyped λ-calculus can be encoded by |x| = x, |t u| = app |t| |u|, |λx t| = lam (x:term => |t|). in the signature Term : Type . lam : ( Term -> Term ) -> Term . def app : Term -> Term -> Term .

  type : Type . arrow : type -> type -> type . def term : type -> Type . [A , B ] term ( arrow A B ) --> term A -> term B . def fix : A : type -> B : type -> (( term A -> term B ) -> term A -> term B ) -> term A -> term B . [A ,B ,F , a ] fix A B F a --> F ( fix A B F ) a .

  nat : type . def Nat := term nat . O : Nat . S : Nat -> Nat . def match_nat : Nat-> Nat -> ( Nat -> Nat ) -> Nat . [ n0 , nS ] match_nat O n0 nS --> n0 [n , n0 , nS ] match_nat ( S n ) n0 nS --> nS n . def mod2 := fix nat nat ( m2 = > n = > match_nat n O ( p = > match_nat p ( S O ) ( q = > m2 q ))).# CONV mod2 ( S ( S ( S ( S O )))) , O .

  It can be defined in FoCaLiZe by type nat = | Zero | Succ (nat);; let rec mod2 (n) = match n with | Zero -> Zero | Succ(m) -> match m with | Zero -> Succ(Zero) | Succ(k) -> mod2(k) ;;

  theorem mod2_twice_Zero : mod2(twice(Zero)) = Zero proof = by type nat definition of mod2, twice;; theorem twice_Succ : all n : nat, twice(Succ(n)) = Succ(Succ(twice(n))) proof = by type nat definition of twice;; theorem mod2_SuccSucc : all n : nat, mod2(Succ(Succ(n))) = mod2(n) proof = by type nat definition of mod2;; theorem mod2_twice_Succ : all n : nat, mod2(twice(n)) = Zero -> mod2(twice(Succ(n))) = Zero proof = by type nat property mod2_SuccSucc, twice_Succ;;

  let mod2_twice_n_is_Zero (n : nat) : bool = (mod2(twice(n)) = Zero);; theorem mod2_twice : all n : nat, mod2(twice(n)) = Zero proof = dedukti proof {* nat_induction mod2_twice_n_is_Zero mod2_twice_Zero mod2_twice_Succ. *};;FoCaLiZe version 0.9.2 features Dedukti code generation. More than 98% of FoCaL-iZe standard library is checked in Dedukti. The size of the gzipped Dedukti translation weighs 1.89 MB.

▶ Definition 29 .

 29 pi_s1s2 : a : U_s1 -> b : (e_s1 a -> U_s2) -> U_s3. [a, b] e_s3 (pi_s1s2 a b) --> x : e_s1 a -> e_s2 (b x). The terms of the Pure type system are expressed as |x| = x, |s| = u_s, |M N | = |M | |N |, |λx : A M | = x : ∥A∥ => |M |, |Πx : A B| = pi_s1s2 |A| (x: ∥A∥ => |B|) (where Γ ⊢ A : s 1 and Γ, x : A ⊢ B : s 2 ), ∥A∥ = e_s |A| (when Γ ⊢ A : s), ∥s∥ = U_s (when ∄s ′ such that Γ ⊢ s : s ′ ), a : U_Type . b : U_Type . x : e_Type a . f : ( p : ( e_Type a -> U_Type ) -> e_Type ( p x ) -> e_Type b ). def example : e_Type b := f ( y : e_Type a = > a ) x .

  def append : A : U_Type -> List A -> List A -> List A := A : U_Type = > l1 : List A = > l2 : List A = > elim_list A ( __ = > list A ) l2 ( x = > l3 = > l3l2 = > cons A x l3l2 ) l1 .

  [i , a , b ] pi _ ( lift i a ) ( x = > lift { i } ( b x )) --> lift i ( pi i a ( x = > b x )).

  Type, a variable o of type Type, for each function symbol f of arity ⟨s 1 , . . . , s n , s ′ ⟩, a variable f, of type s 1 -> ... -> s n -> s', for each predicate symbol P of arity ⟨s 1 , . . . , s n ⟩, a variable P, of type s 1 -> ... -> s n -> o, variables top and bot of type o, a variable not of type o -> o, variables imp, and, and or of type o -> o -> o, for each sort s of L a variable fa_s and a variable ex_s of type (s -> o) -> o, a variable eps of type o -> Type.

  (t 1 , . . . , t n )| = (P |t 1 | . . . |t n |), |⊤| = top, |⊥| = bot, |¬A| = not |A|, |A ⇒ B| = imp |A| |B|, |A ∧ B| = and |A| |B|, |A ∨ B| = or |A| |B|, |∀ s x A| = fa_s (x:s => |A|), |∃ s x A| = ex_s (x:s => |A|), and finally ∥A∥ = eps |A|. If A is a proposition in the language L and Γ a context containing for each variable x of sort s free in A, a variable x, of type s, then Σ, Γ ⊢ |A| : o and Σ, Γ ⊢ ∥A∥ : Type.

	The following lemma is proved with a simple induction on A.

▶ Lemma 17.

  1 , . . . , t n )| = atom (P |t 1 | . . . |t n |), |⊤| = top, |⊥| = bot, |¬A| = not |A|, |A ⇒ B| = imp |A| |B|, |A ∧ B| = and |A| |B|, |A ∨ B| = or |A| |B|, |∀ s x A| = fa_s (x:s => |A|), |∃ s x A| = ex_s (x:s => |A|). We embed A classically as a λ-term as |P (t 1 , . . . , t n

the typing rules use another kind of judgement expressing the well-formedness of a context. The typing rules are the following. Well-formedness of the empty context [ ] well-formed Declaration of a type or type family variable Γ ⊢ A : Kind Γ, x : A well-formed Declaration of an object variable Γ ⊢ A : T ype Γ, x : A well-formed T ype Γ well-formed Γ ⊢ T ype : Kind Variable Γ well-formed x : A ∈ Γ Γ ⊢ x : A Product (for kinds) Γ ⊢ A : T ype Γ, x : A ⊢ B : Kind Γ ⊢ Πx : A B : Kind

Dedukti: a Logical Framework based on the λΠ-Calculus Modulo Theory Product (for types) Γ ⊢ A : T ype Γ, x : A ⊢ B : T ype Γ ⊢ Πx : A B : T ype Abstraction (for type families) Γ ⊢ A : T ype Γ, x : A ⊢ B : Kind Γ, x : A ⊢ t : B Γ ⊢ λx : A t : Πx : A B Abstraction (for objects) Γ ⊢ A : T ype Γ, x : A ⊢ B : T ype Γ, x : A ⊢ t : B Γ ⊢ λx : A t : Πx : A B Application Γ ⊢ t : Πx : A B Γ ⊢ t ′ : A Γ ⊢ (t t ′ ) : (t ′ /x)B

2.2.2 ConversionIf l -→ ∆ r is a rewrite rule and σ is a substitution binding the variables of ∆, we say that the term σl rewrites to the term σr.If Γ is a well-formed global context, then the rewriting relation generated by β-reduction and Γ, noted → βΓ , is the smallest relation, closed by context, such that if t rewrites to u, for some rule in Γ, or if t β-reduces to u, then t → βΓ u. The congruence ≡ βΓ is the reflexive-symmetric-transitive closure of the relation → βΓ .The conversion rules of the λΠ-calculus modulo theory are the same as the conversion rules of the λΠ-calculus except that the congruence ≡ β is replaced by ≡ βΓ

Dedukti: a Logical Framework based on the λΠ-Calculus Modulo Theory

Acknowledgements

Many thanks to Jasmin Blanchette, Frédéric Blanqui, Cezary Kaliszyk, Claude Kircher, and Jean-Pierre Jouannaud for very helpful comments on a previous version of this paper.

C : type -> ( Obj A -> Obj C ) -> Preobj A B -> Preobj A ( typecons l C B ).

The two primitives on objects, selection and update, are the only functions that recurse on the list structure of preobjects. The update function on preobjects preupdate returns a preobject of the same type whereas the selection function on preobjects preselect returns a function defined on Obj A: mem : label -> type -> type -> Type . athead : l : label -> A : type -> B : type -> mem l A ( typecons l A B ). intail : l : label -> A : type -> l ' : label -> A ' : type -> B : type -> mem l A B -> mem l A ( typecons l ' A ' B ).

Both functions are defined by structural induction on their argument of type mem l C B where mem is the inductive relation representing membership of the couple (l, C) to a type B.

From these, selection and update can be defined on objects:

def select ( A : type ) ( l : label ) ( C : type ) ( p : mem l C A ) ( a : Obj A ) : Obj C := preselect A A l C p a a . def update ( A : type ) := preupdate A A .

▶ Definition 24 (Expression of the ς-calculus). The encoding of ς-terms is then defined by

where p i is a proof that A contains l i : A i .

▶ Lemma 25 (Shallow encoding, Theorems 13 and 18 in [START_REF] Cauderlier | Objects and subtyping in the λΠ-calculus modulo[END_REF]). This encoding preserves binding, typing, and the operational semantics of the simply-typed ς-calculus.

This translation of the simply-typed ς-calculus in the λΠ-calculus modulo theories can be extended to subtyping, see [START_REF] Cauderlier | Objects and subtyping in the λΠ-calculus modulo[END_REF].

▶ Lemma 31 (Preservation of typing, Proposition 3 in [START_REF] Cousineau | Embedding pure type systems in the lambda-Pi-calculus modulo[END_REF]).

It is also conservative-that is, adequate-with respect to the original system.

▶ Lemma 32 (Conservativity, adequacy, [START_REF] Assaf | Conservativity of embeddings in the lambda-Pi calculus modulo rewriting[END_REF]). If Σ, ∥Γ∥ ⊢ M ′ : ∥A∥, then there exists M such that Γ ⊢ M : A and |M | ≡ βηΣ M ′ .

Together, these results show that provability in the Pure type system is equivalent to provability in the embedding.

▶ Theorem 33 ([9]

). There exists M , such that Γ ⊢ M : A if, and only if there exists M , such that Σ, ∥Γ∥ ⊢ M : ∥A∥.

As an example, the Calculus of constructions can be defined as the Pure type system [ ] e_Kind u_Type --> U_Type .

Contributions

The results presented in this paper build upon the work of many people.

The λΠ-calculus modulo theory appeared in a joint paper of Denis Cousineau and Gilles Dowek in 2007 [START_REF] Cousineau | Embedding pure type systems in the lambda-Pi-calculus modulo[END_REF], together with an expression of Pure type systems in it, and a partial correctness proof. The framework was further refined in [START_REF] Saillard | Towards explicit rewrite rules in the lambda-Pi calculus modulo[END_REF] and then in [START_REF] Saillard | Type Checking in the Lambda-Pi-Calculus Modulo: Theory and Practice[END_REF]. In 2010, during his undergrad internship [START_REF] Dorra | Équivalence Curry-Howard entre le lambda-Pi-calcul et la logique intuitionniste[END_REF], Alexis Dorra showed that constructive predicate logic also could be expressed in the λΠ-calculus modulo theory.

The first implementation of Dedukti was designed by Mathieu Boespflug [START_REF] Boespflug | Conception d'un noyau de vérification de preuves pour le lambda-Pi-calcul modulo[END_REF] between 2008 and 2011, during his thesis supervised by Gilles Dowek. A second implementation was designed in 2012 by Quentin Carbonneaux during his Master thesis [START_REF] Carbonneaux | Compilation jit des termes de preuve[END_REF], supervised by Olivier Hermant and Mathieu Boespflug. Finally, the current implementation has been designed by Ronan Saillard between 2012 and 2015 during his thesis [START_REF] Saillard | Type Checking in the Lambda-Pi-Calculus Modulo: Theory and Practice[END_REF], supervised by Pierre Jouvelot and Olivier Hermant.

A first expression of the Calculus of Inductive Constructions was proposed by Mathieu Boespflug and Guillaume Burel in 2011 [START_REF] Boespflug | CoqInE: Translating the calculus of inductive constructions into the lambda-Pi-calculus modulo[END_REF]. An expression of Simple type theory and of the Calculus of Inductive Constructions was then proposed by Ali Assaf between 2012 and 2015 during his thesis [START_REF] Assaf | A framework for defining computational higher-order logics[END_REF] advised by Gilles Dowek and Guillaume Burel. This led to the translations of the proofs of HOL Light and Matita in Dedukti. A graphical front-end for the translation of the proofs of Holide has been proposed by Shuai Wang during his Master thesis in 2015 [START_REF] Wang | Reverse engineering of higher order proofs[END_REF]. Guillaume Burel [START_REF] Burel | A shallow embedding of resolution and superposition proofs into the λΠ-calculus modulo[END_REF] showed in 2013 that iProverModulo could produce Dedukti proofs. During his thesis, started in 2013, advised by David Delahaye, Pierre Halmagrand showed that Zenon Modulo also could produce Dedukti proofs. Later Pierre Halmagrand, Frédéric Gilbert, and Raphaël Cauderlier, showed how classical proofs could be expressed in Dedukti without any axiom, introducing the classical connectives and quantifiers. During his thesis, started in 2013, advised by Catherine Dubois, Raphaël Cauderlier opened a new direction, with the expression of programs and properties of programs, in particular those expressed in FoCaLiZe.