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

Ali Assaf, Guillaume Burel, Raphaël Cauderlier, David Delahaye, Gilles Dowek, Catherine Dubois, Frédéric Gilbert, Pierre Halmagrand, Olivier Hermant, Ronan Saillard

<figure><img src="image_1.png" /></figure>

## To cite this version:

Ali Assaf, Guillaume Burel, Raphaël Cauderlier, David Delahaye, Gilles Dowek, et al.. Dedukti: a Logical Framework based on the λΠ-Calculus Modulo Theory. 2016. [hal-04281492](https://hal-04281492)

HAL Id: hal-04281492

https://inria.hal.science/hal-04281492v1

Preprint submitted on 13 Nov 2023

HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d'enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

<figure><img src="image_2.png" /></figure>

Distributed under a Creative Commons CC BY 4.0 - Attribution - International License
# Dedukti: a Logical Framework based on the $\lambda\Pi$-Calculus Modulo Theory

Ali Assaf¹, Guillaume Burel², Raphaël Cauderlier³, David Delahaye⁴, Gilles Dowek⁵, Catherine Dubois², Frédéric Gilbert⁶, Pierre Halmagrand⁷, Olivier Hermant⁸, and Ronan Saillard⁸

1 Inria and École polytechnique, ali.assaf@inria.fr

2 ENSIIE, {guillaume.burel, catherine.dubois}@ensiie.fr

3 IRIF, University Paris Diderot, and CNRS, raphael.cauderlier@irif.fr

4 CNAM and Université de Montpellier, david.delahaye@umontpellier.fr

5 Inria and École Normale de Supérieure de Cachan, gilles.dowek@ens-cachan.fr

6 École des Ponts, Inria, and CEA, frederic.gilbert@inria.fr

7 CNAM and Inria, pierre.halmagrand@inria.fr

8 MINES ParisTech, {olivier.hermant, ronan.saillard}@mines-paristech.fr

## Abstract

DEDUKTI is a Logical Framework based on the $\lambda\Pi$-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, PROVER, FOCALIZE, HOL LIGHT, and MATITA.

## 1 Introduction

Defining a theory, such as arithmetic, geometry, or set theory, in predicate logic [49] 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, $\wedge$, $\vee$, $\forall$, 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 $\mathcal{T}$ is a theory expressed in a language $\mathcal{L}$ and $\mathcal{T}'$ a theory expressed in a language $\mathcal{L}'$, if $A$ is expressed in $\mathcal{L} \cap \mathcal{L}'$, $A \Rightarrow B$ is provable in $\mathcal{T}$, and $A$ is provable in $\mathcal{T}'$, then $B$ is provable in $\mathcal{T} \cup \mathcal{T}'$.

Despite these advantages, several logical systems have been defined, not as theories in predicate logic, but as independent systems: Simple type theory [29, 6], 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 [54], the
Calculus of constructions [31], the Calculus of inductive constructions [59], 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 $\mapsto$ that would bind a variable in its argument.

2. Predicate logic ignores the propositions-as-types principle, according to which a proof $\pi$ 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 \times 2$ into 4. To prove the theorem $2 \times 2 = 4$, several deduction steps need to be used while a simple computation would have sufficed [61].

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 [56] and ISABELLE [60]. Problems 1 and 2 have been solved in an extension of predicate logic, called the Logical framework [47], 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 [40]. Combining the λΠ-calculus and Deduction modulo theory yields the λΠ-calculus modulo theory [32], a variant of Martin-Löf's logical framework [58], which solves problems 1, 2, 3, and 4.

Problem 5 has been addressed [38, 48, 62] and will be discussed in Section 5.

The expressivity of the λΠ-calculus modulo theory has already been discussed [32]. We have shown that all functional Pure type systems [14], 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.

# 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.

## 2.1 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 *Type*, some symbols have the type *A* → *Type*, 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 *Type*, *A* → *Type*, etc. and the arrow *A* → *B* is extended to a dependent product Π*x* : *A* *B*. Finally, besides the usual typing judgements, 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

$$ \frac{\Gamma \vdash A : \mathit{Kind}}{\Gamma, x : A \text{ well-formed}} $$

Declaration of an object variable

$$ \frac{\Gamma \vdash A : \mathit{Type}}{\Gamma, x : A \text{ well-formed}} $$

Type

$$ \frac{\Gamma \text{ well-formed}}{\Gamma \vdash \mathit{Type} : \mathit{Kind}} $$

Variable

$$ \frac{\Gamma \text{ well-formed}}{\Gamma \vdash x : A} x : A \in \Gamma $$

Product (for kinds)

$$ \frac{\Gamma \vdash A : \mathit{Type} \quad \Gamma, x : A \vdash B : \mathit{Kind}}{\Gamma \vdash \Pi x : A B : \mathit{Kind}} $$
Product (for types)

$$ \frac{\Gamma \vdash A : \mathit{Type} \quad \Gamma, x : A \vdash B : \mathit{Type}}{\Gamma \vdash \Pi x : A B : \mathit{Type}} $$

Abstraction (for type families)

$$ \frac{\Gamma \vdash A : \mathit{Type} \quad \Gamma, x : A \vdash B : \mathit{Kind} \quad \Gamma, x : A \vdash t : B}{\Gamma \vdash \lambda x : A t : \Pi x : A B} $$

Abstraction (for objects)

$$ \frac{\Gamma \vdash A : \mathit{Type} \quad \Gamma, x : A \vdash B : \mathit{Type} \quad \Gamma, x : A \vdash t : B}{\Gamma \vdash \lambda x : A t : \Pi x : A B} $$

Application

$$ \frac{\Gamma \vdash t : \Pi x : A B \quad \Gamma \vdash t' : A}{\Gamma \vdash (t t') : (t'/x)B} $$

Conversion

$$ \frac{\Gamma \vdash t : A \quad \Gamma \vdash A : \mathit{Type} \quad \Gamma \vdash B : \mathit{Type}}{\Gamma \vdash t : B} \quad A \equiv_{\beta} B $$

$$ \frac{\Gamma \vdash t : A \quad \Gamma \vdash A : \mathit{Kind} \quad \Gamma \vdash B : \mathit{Kind}}{\Gamma \vdash t : B} \quad A \equiv_{\beta} B $$

## 2.2 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.

### 2.2.1 Local and global contexts

There are two notions of context in the λΠ-calculus modulo theory: *global contexts* and *local ones*. Global contexts contain variable declarations and rewrite rules, but local ones contain object variable declarations only, that is declaration of variables whose type has type *Type* and not *Kind*. A third kind of judgement is introduced to express that $\Delta$ is a local context in $\Gamma$, and two rules to derive such judgements.

**Locality of the empty context**

$$ \frac{\Gamma \text{ well-formed}}{\Gamma \vdash [] \text{ local}} $$

Declaration of an object variable in a local context

$$ \frac{\Gamma \vdash \Delta \text{ local} \quad \Gamma, \Delta \vdash A : \mathit{Type}}{\Gamma \vdash \Delta, x : A \text{ local}} $$

The following lemma is proved with a simple induction on the structure of the derivation of the judgment “$\Delta$ local”.

**► Lemma 1.** If $\Delta$ is local in $\Gamma$, then $\Gamma, \Delta$ 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 $\Gamma$ is a pair of terms $\langle l, r \rangle$, where $l$ is a term of the form $f u_1 \dots u_n$ for some variable $f$, together with a context $\Delta$ local in $\Gamma$. We note it $l \to^\Delta r$.
The notion of well-formed global context is extended to allow the declaration of rewrite rules

$$ \frac{\Gamma \text{ well-formed } \Gamma \vdash \Delta \text{ local} \\ \Gamma, l \longrightarrow \Delta r \text{ 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.

### 2.2.2 Conversion

If $l \longrightarrow \Delta r$ is a rewrite rule and $\sigma$ is a substitution binding the variables of $\Delta$, we say that the term $\sigma l$ rewrites to the term $\sigma r$.

If $\Gamma$ is a well-formed global context, then the rewriting relation generated by $\beta$-reduction and $\Gamma$, noted $\rightarrow_{\beta\Gamma}$, is the smallest relation, closed by context, such that if $t$ rewrites to $u$, for some rule in $\Gamma$, or if $t$ $\beta$-reduces to $u$, then $t \rightarrow_{\beta\Gamma} u$. The congruence $\equiv_{\beta\Gamma}$ is the reflexive-symmetric-transitive closure of the relation $\rightarrow_{\beta\Gamma}$.

The conversion rules of the $\lambda\Pi$-calculus modulo theory are the same as the conversion rules of the $\lambda\Pi$-calculus except that the congruence $\equiv_{\beta}$ is replaced by $\equiv_{\beta\Gamma}$

$$ \frac{\Gamma \vdash A : \text{Type} \quad \Gamma \vdash B : \text{Type} \quad \Gamma \vdash t : A}{\Gamma \vdash t : B} \quad A \equiv_{\beta\Gamma} B $$

$$ \frac{\Gamma \vdash A : \text{Kind} \quad \Gamma \vdash B : \text{Kind} \quad \Gamma \vdash t : A}{\Gamma \vdash t : B} \quad A \equiv_{\beta\Gamma} B $$

### 2.2.3 Subject reduction

Subject reduction expresses that reduction preserves the type of a term. This property does not hold in general in the $\lambda\Pi$-calculus modulo theory. However it does if we have the two following properties: *well-typedness* of rewrite rules and *product compatibility* [13]. Henceforth, unless stated otherwise, $\Gamma \vdash t : T$ stands for “the judgement $\Gamma \vdash t : T$ is derivable”.

A rewrite rule is *well-typed* if it is type preserving.

**Definition 2.** Let $l \longrightarrow^{\Delta_0} r$ be a rewrite rule in the context $\Gamma_0$ and $\Gamma$ be a well-formed extension of $\Gamma_0$. We say that $l \longrightarrow^{\Delta_0} r$ is *well-typed* for $\Gamma$ if for any substitution $\sigma$ binding the variables of $\Delta_0$

$$ \text{if } \Gamma \vdash \sigma l : T, \text{ then } \Gamma \vdash \sigma r : T $$

**Definition 3.** A well-formed global context $\Gamma$ satisfies the *product compatibility* property if for any products $\Pi x : A_1 B_1$ and $\Pi x : A_2 B_2$ well-typed in $\Gamma$

$$ \text{if } \Pi x : A_1 B_1 \equiv_{\beta\Gamma} \Pi x : A_2 B_2 \text{ then } A_1 \equiv_{\beta\Gamma} A_2 \text{ and } B_1 \equiv_{\beta\Gamma} B_2. $$

Note that this property immediately follows from the confluence of $\beta\Gamma$-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 [65]).** Let $\Gamma$ be a global context satisfying product compatibility and whose rewrite rules are well-typed. If $\Gamma \vdash t_1 : T$ and $t_1 \rightarrow_{\beta\Gamma} t_2$ then $\Gamma \vdash 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 [65]). Let $\Gamma$ be a global context satisfying the product compatibility property. If $\Gamma \vdash t : T_1$ and $\Gamma \vdash t : T_2$ then $T_1 \equiv_{\beta\Gamma} T_2$.

### 2.2.4 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 $\mathcal{T}$ having axiom schemes can either be defined as the fact that the infinite sequent $\mathcal{T} \vdash A$ has a proof, or as the fact that there exists a finite subset $\Gamma$ of $\mathcal{T}$, such that the finite sequent $\Gamma \vdash A$ has a proof.

In the same way, some theories in the $\lambda\Pi$-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 $\lambda\Pi$-calculus modulo theory, the derivability of a typing relation $t : A$ must be defined as the existence of a finite context $\Gamma$, such that the judgment $\Gamma \vdash t : A$ is derivable.

## 2.3 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,

$$ \frac{\Gamma \vdash A : s \quad \Gamma \vdash B : s \quad \Gamma \vdash t : A}{\Gamma \vdash t : B} \quad A \equiv_{\beta\Gamma} B $$

the conversion sequence justifying $A \equiv_{\beta\Gamma} 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 $\equiv_{\beta\Gamma}$ is decidable. A natural subsystem is obtained by restricting the rewrite rules to form, together with the $\beta$-reduction rule, a terminating and confluent rewrite system. This way, the congruence can be decided by checking equality of normal forms.

As $\beta$-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.

### 2.3.1 Higher-order rewriting

Confluence of the rewrite relation together with $\beta$-reduction is not general enough. Indeed, such a confluence result may easily be lost when allowing $\lambda$-abstraction in the left-hand side of a rewrite rule, a useful feature—see, for instance, Section 8.3.

For example, let $\Delta = f : Real \to Real$, and consider the rewrite rule explaining how to differentiate the function $\lambda x : Real (\sin (f x))$

$$ (D (\lambda x : Real (\sin (f x)))) \to^{\Delta} (\times (D (\lambda x : Real (f x)))) (\lambda x : Real (\cos (f x)))) $$
where $\times$ is the pointwise product of functions. This rule overlaps with $\beta$-reduction and creates the critical peak

$$(D (\lambda x (\sin x))) \leftarrow (D (\lambda x (\sin ((\lambda y y) x)))) \rightarrow (\times (D (\lambda x ((\lambda y y) x)))) (\lambda x (\cos ((\lambda y y) x))))$$

that cannot be joined. This rewrite system with $\beta$-reduction is therefore not confluent.

Still, $\equiv_{\beta\Gamma}$ is decidable, as some form of confluence holds. For this, we need a richer rewrite relation: rewriting modulo $\beta$-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 $\sigma$ such that $\sigma l$ is $\beta$-convertible to $t$. Higher-order matching is undecidable in general [36, 52], but it is decidable if we restrict to Miller's patterns [55]. Thus, we restrict the left-hand sides of the rewrite rules to be patterns.

**► Definition 6.** A $\beta$-normal term $f u_1 \dots u_n$ is a pattern with respect to $\Delta$ if $f$ is a variable not declared in $\Delta$, and the variables declared in $\Delta$ are applied to pairwise distinct bound variables.

For example, if $f$ is declared in $\Delta$, then the term $D (\lambda x (\sin (f x)))$ is a pattern, but neither $D (\lambda x (f (\sin x)))$ nor $D ((\lambda x (\sin x)) y)$ are.

Now, if we consider the derivative rule as a higher-order rule, we have

$$D (\lambda x (\sin x)) \rightarrow \times (D (\lambda x x)) (\lambda 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 $\sigma$ such that $\sigma l \equiv_{\beta\Gamma} t$ and some of them are not be well-typed. To get a precise and type-safe definition of higher-order-rewriting, we use the concepts of higher-order rewrite system [57]. Remark, however, that our notion of higher-order rewriting does not require the identification of $\eta$-equivalent terms as for higher-order rewrite systems. See [63] for more details. This also gives us powerful confluence criteria such as confluence for development-closed systems [67].

The reason why we are interested in the confluence of this extended higher-order rewrite relation is that, when combined with $\beta$-reduction, first- and higher-order rewriting yield the same congruence. Therefore, if higher-order rewriting is confluent and terminating, $\equiv_{\beta\Gamma}$ is decidable.

### 2.3.2 Typing rewrite rules

As we want reduction to preserve typing, we must check that the rewrite rules are well-typed in the sense of Definition 2. To do so, we introduce two new judgments: $\Gamma \vdash l \rightarrow^{\Delta} r$ expressing that the rule $l \rightarrow^{\Delta} r$ is well-typed in $\Gamma$ and $\Gamma$ strongly well-formed, expressing that all the rules declared in $\Gamma$ are well-typed. This judgment is defined by the rules

[] strongly well-formed

$\Gamma$ strongly well-formed $\Gamma \vdash A : Type$

$\Gamma, x : A$ strongly well-formed

$\Gamma$ strongly well-formed $\Gamma \vdash A : Kind$

$\Gamma, x : A$ strongly well-formed

$\Gamma$ strongly well-formed $\Gamma \vdash l \rightarrow^{\Delta} r$

$\Gamma, l \rightarrow^{\Delta} r$ strongly well-formed
Defining an effective rule for the judgment $\Gamma \vdash l \rightarrow^{\Delta} 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 $\Gamma, \Delta$

$$ \frac{l \text{ is a pattern } \Gamma, \Delta \vdash l : T \quad \Gamma, \Delta \vdash r : T \quad \text{dom}(\Delta) \subseteq \text{FV}(l)}{\Gamma \vdash l \rightarrow^{\Delta} r} $$

But this condition is too restrictive as shown by the following example.

Consider a context containing a variable $A$ of type $Type$, a variable $Vector$ of type $nat \rightarrow Type$, a variable $Nil$ of type $(Vector 0)$, and a variable $Cons$ of type $\Pi n : nat (A \rightarrow (Vector n) \rightarrow (Vector (S n)))$. Assume that we want to define the $Tail$ function of type $\Pi n : nat ((Vector (S n)) \rightarrow (Vector n))$.

A first possibility is to use the non left-linear rule

$$ (Tail n (Cons n a l)) \rightarrow 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

$$ (Tail n (Cons m a l)) \rightarrow 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 $(Vector (S m))$ and $(Tail n)$ expects a term of type $(Vector (S n))$. So we need a weaker condition, in order to accept this rule [16, 65]. Typing the term $\sigma(Tail n (Cons m a l))$ generates the constraint

$$ (Vector (S \sigma n)) \equiv (Vector (S \sigma m)) $$

Using the injectivity of the functions $Vector$ and $S$, this constraint boils down to

$$ \sigma n \equiv \sigma m $$

so all the substitutions $\sigma$, such that $\sigma(Tail n (Cons m a l))$ is well-typed, have the form $\eta\tau$ where $\eta$ is an arbitrary substitution and $\tau = p/m, p/n$. The substitution $\tau$ is the most general typing substitution for $l$. Both the terms $\tau(Tail n (Cons m a l))$ and $\tau l$ have type $(Vector p)$. So, for all $\eta, \eta\tau(Tail n (Cons m a l))$ and $\eta\tau l$ have the same type and the rule is well-typed.

Therefore, sufficient condition for the rule $l \rightarrow r$ to be well-typed is that $l$ has a most general typing substitution $\tau$ and $\tau l$ and $\tau r$ have the same type. This leads to the rule

$$ \frac{l \text{ is a pattern } \Gamma, \Delta \vdash \tau l : T \quad \Gamma, \Delta \vdash \tau r : T \quad \text{dom}(\Delta) \subseteq \text{FV}(l)}{\Gamma \vdash l \rightarrow^{\Delta} r} $$

where $\tau$ is the most general typing substitution for $l$ in $\Gamma, \Delta$.

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 [65]).** Let $\Gamma$ be a well-formed context satisfying the product compatibility. If $\Gamma \vdash l \rightarrow^{\Delta} r$, then $(l \rightarrow^{\Delta} r)$ is well-typed in $\Gamma$.

Finally, we can prove the effectiveness theorem.

**► Theorem 8 (Effectiveness, Theorem 4.5.10 and Theorem 6.3.1 in [65].)** If $\Gamma$ is a strongly well-formed context such that higher-order rewriting is confluent then $\Gamma$ satisfies the subject reduction property. Moreover, if higher-order rewriting is terminating on well-typed terms, then typing is decidable.
# 3 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.

## 3.1 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 Type 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] 1 --> 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 [15], when it can be reconstructed by bidirectional typechecking [19, 28, 30]. 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 [33], for the details.

## 3.2 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 1) --> 1

is to compute the most general typing substitution for its left-hand side, tail n (Cons m a 1). 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, 1] tail n (Cons m a 1) --> 1.

is accepted.
## 3.3 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, 1] tail n (Cons _ a 1) --> 1.
```

or even

```
[1] tail _ (Cons _ _ 1) --> 1.
```

## 3.4 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, 1] tail n (Cons {n} a 1) --> 1.
```

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.

# 4 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 $\lambda\Pi$-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.

## 4.1 Minimal predicate logic

Even without rewrite rules, the $\lambda\Pi$-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 $\Rightarrow$ and the only quantifiers are the universal quantifiers $\forall_s$, one for each sort.

► **Definition 9 (Language embedding).** To each language $\mathcal{L}$ of predicate logic, we associate a context $\Sigma$ containing

- for each sort $s$ of $\mathcal{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 \rightarrow \dots \rightarrow s_n \rightarrow s'$,

- for each predicate symbol $P$ of arity $(s_1, ..., s_n)$, a variable $P$, of type $s_1 \rightarrow \dots \rightarrow s_n \rightarrow \text{Type}$.
For instance

s : Type.

P : s -> Type.

**► Definition 10 (Term embedding).** Let $t$ be a term in the language $\mathcal{L}$, we express the term $t$ as a $\lambda$-term as

- $|x| = x$,

- $|f(t_1, \dots, t_n)| = (f|_{t_1}| \dots |f|_{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 $\mathcal{L}$ and $\Gamma$ a context containing for each variable $x$ of sort $s'$ free in $t$, a variable $x$, of type $s'$, then $\Sigma, \Gamma \vdash |t| : s$.

**► Definition 12 (Proposition embedding).** Let $A$ be a proposition in the language $\mathcal{L}$, we express the proposition $A$ as the following $\lambda$-term

- $\|P(t_1, \dots, t_n)\| = (P|_{t_1}| \dots |P|_{t_n})|$,

- $\|A \Rightarrow B\| = \|A\| \rightarrow \|B\|$,

- $\|\forall_s x A\| = x:s \rightarrow \|A\|$.

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

**► Lemma 13.** If $A$ is a proposition in the language $\mathcal{L}$ and $\Gamma$ a context containing for each variable $x$ of sort $s$ free in $A$, a variable $x$, of type $s$, then $\Sigma, \Gamma \vdash \|A\| : \text{Type}$.

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

**► Theorem 14 (Proof embedding).** Let $\mathcal{L}$ be a language and $A_1, \dots, A_n \vdash B$ be a sequent in $\mathcal{L}$, $\Gamma_1$ a context containing for each variable $x$ of sort $s$ free in $A_1, \dots, A_n \vdash B$, a variable $x$, of type $s$, and $\Gamma_2$ be a context containing, for each hypothesis $A_i$, a variable $a_i$, of type $\|A_i\|$. Then, the sequent $A_1, \dots, A_n \vdash B$ has a proof in Natural deduction, if and only if there exists a $\lambda$-term $\pi$ such that $\Sigma, \Gamma_1, \Gamma_2 \vdash \pi : \|B\|$, if and only if there exists a normal $\lambda$-term $\pi$ such that $\Sigma, \Gamma_1, \Gamma_2 \vdash \pi : \|B\|$.

For instance, the proposition $\forall_T x (P(x) \Rightarrow P(x))$ is embedded as $x:T \rightarrow (P x) \rightarrow (P x)$ and it has the proof $x:T \Rightarrow a:(P x) \Rightarrow 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 $\text{Type}$ and that it is the type of the proofs of $B$. But not all terms of type $\text{Type}$ have the form $\|B\|$, for instance if $s$ is a sort of the language, then $s$ has type $\text{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.

## 4.2 Constructive predicate logic

The $\lambda\Pi$-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 $\top$, $\bot$, $\neg$, $\wedge$, $\vee$, and $\exists$ cannot be directly expressed as $\Rightarrow$ and $\forall$ in Section 4.1. One possibility is to extend the $\lambda\Pi$-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) \Rightarrow 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” [54]. The proposition $P(c) \Rightarrow 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

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

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 $\mathcal{L}$ of predicate logic, we associate a context $\Sigma$ containing

- for each sort $s$ of $\mathcal{L}$ a variable $s$ of type 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 $\mathcal{L}$ a variable `fa_s` and a variable `ex_s` of type $(s -> o) -> o$,

- a variable `eps` of type $o -> 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 $\mathcal{L}$. We express the proposition $A$ as a $\lambda$-term as

$$ \mid_P(t_1, \dots, t_n) \mid = (\mathbf{P} \mid t_1 \mid \dots \mid t_n), $$

$$ \mid\Gamma\mid = \mathbf{top}, \mid\bot\mid = \mathbf{bot}, $$

$$ \mid\neg A\mid = \mathbf{not} \mid A\mid, $$

$$ \mid A \Rightarrow B \mid = \mathbf{imp} \mid A \mid B \mid, \quad \mid A \wedge B \mid = \mathbf{and} \mid A \mid B \mid, \quad \mid A \vee B \mid = \mathbf{or} \mid A \mid B \mid, $$

$$ \mid\forall_s x A\mid = \mathbf{fa\_s} \ (x:s \Rightarrow \mid A\mid), \quad \mid\exists_s x A\mid = \mathbf{ex\_s} \ (x:s \Rightarrow \mid A\mid), $$

and finally

$$ \|A\| = \mathbf{eps} \mid A\mid. $$

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

**► Lemma 17.** If $A$ is a proposition in the language $\mathcal{L}$ and $\Gamma$ a context containing for each variable $x$ of sort $s$ free in $A$, a variable $x$, of type $s$, then $\Sigma, \Gamma \vdash \mid A \mid : o$ and $\Sigma, \Gamma \vdash \|A\| : \mathbf{Type}$.

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 $\mathbf{Type}$-level encoding.

```haskell
def top : o.
  [ ] eps top -- > z:o -> (eps z) -> (eps z).
```

```haskell
def bot : o.
  [ ] eps bot -- > z:o -> (eps z).
```

```haskell
def not : o -> o := x:o => imp x bot.
```

```haskell
def or : o -> o -> o.
[x, y] eps (or x y)
  -- > z:o -> (eps x -> eps z) -> (eps y -> eps z) -> eps z.
```

```haskell
def fa_s : (s -> o) -> o.
[y] eps (fa_s y) -- > x:s -> eps (y x).
```

```haskell
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, [35]).** Let $\mathcal{L}$ be a language, $\Sigma$ be the associated context, $V$ be a set of variables and $A_1, \dots, A_n, B$ be propositions in $\mathcal{L}$ such that the free variables of $A_1, \dots, A_n, B$ are in $V$. Let $\Gamma_1$ be a context containing for each variable $x$ of sort $s$ in $V$, a variable $x$, of type $s$, and $\Gamma_2$ be a context containing, for each hypothesis $A_i$ a variable $a_i$ of type $\|A_i\|$.

Then, the sequent $A_1, \dots, A_n \vdash B$ has a proof in Natural deduction if and only if there exists a $\lambda$-term $\pi$ such that $\Sigma, \Gamma_1, \Gamma_2 \vdash \pi : \|B\|$.

Again, not all terms of type $\mathbf{Type}$ have the form $\|B\|$, only those convertible to a term of the form $(\mathbf{eps} \ p)$, where $p$ is a term of type $o$, do. For instance $o$ has type $\mathbf{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 $\mathbf{Prop}$ or $\mathbf{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, $\mathbf{Type}$, through the explicit embedding $\mathbf{eps}$, of type $o \rightarrow \mathbf{Type}$. This way $o$ can have type $\mathbf{Type}$, without introducing inconsistencies.
## 4.3 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 $\iota$ and a sort $\kappa$ for the classes of elements of sort $\iota$ and a comprehension scheme

$$ \forall x_1 \dots \forall x_n \exists c \forall y (y \in c \Leftrightarrow A) $$

or its skolemized form

$$ \forall x_1 \dots \forall x_n \forall y (y \in f_{x_1, \dots, x_n, A}(x_1, \dots, x_n) \Leftrightarrow A) $$

In the $\lambda\Pi$-calculus modulo theory this sort can be omitted and replaced by the type $i -> o$.

For instance, Heyting arithmetic [41, 4] can be presented in Deduction modulo theory with nine rewrite rules defining addition, multiplication, equality, and numberness

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).

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 $\forall x N(x) \Rightarrow (x+0) = x$

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).

## 4.4 iProverModulo

In this section we present the DEDUKTI back-end of IPROVERMODULO, more information can be found about IPROVERMODULO in [21] and about the back-end in [22].
IPROVER [51] is a proof-search system for classical predicate logic, based on ordered resolution with selection [12]. An optional Instantiation-Generation rule [43] 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 $\lceil C \rceil$ for the proposition $\forall x_1 ... \forall x_m (L_1 \lor (\cdots \lor (L_{n-1} \lor L_n) ...))$ where $x_1, ..., x_m$ are the variables of $C$. To prove a proposition $A$, its negation $\neg 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 [21]. Proposition rewrite rules are simulated using so-called one-way clauses [37] 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 $\neg 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 $\lceil C_1 \rceil, ..., \lceil C_n \rceil \vdash \bot$ can be built, and this proof can then be transformed into a proof of the sequent $\vdash A$. The latter transformation is only possible in classical logic, but the proof of the sequent $\lceil C_1 \rceil, ..., \lceil C_n \rceil \vdash \bot$ itself is constructive. And indeed, since version 0.7-0.2, IPROVERMODULO has an export functionality that builds a DEDUKTI proof of $\lceil C_1 \rceil, ..., \lceil C_n \rceil \vdash \bot$, every time it derives the empty clause from $C_1, ..., C_n$.

A clause $C$ can be transformed into a proposition $\lceil C \rceil$ and then to a DEDUKTI term $||\lceil C \rceil||$, of type Type, as seen in Section 4.2. However, instead of using the binary disjunction $\lor$, 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||->(\text{eps bot})->...->(||L_n||->(\text{eps bot})->(\text{eps bot}))$$

where we use the sort $i$ for terms. In particular, the translation of the empty clause is $[[\emptyset]] = \text{eps bot} = ||\bot||$.

Proofs built by IPROVERMODULO are then expressed in DEDUKTI step by step. We first declare a variable $d_c$, of type $||\lceil C \rceil||$ for each clause $C$ in the set $C_1, ..., C_n$.

$$d_c: \text{eps} | \forall x_1 ... \forall x_m (L_1 \lor \cdots \lor (L_{n-1} \lor 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

$$\frac{C \cup \{P\} \qquad D \cup \{\neg Q\}}{\sigma(C \cup D)}$$

where $\sigma$ is the most general unifier of $P$ and $Q$, we have a term $c$ of type $[[C \cup \{P\}]]$, and a term $d$ of type $[[D \cup \{\neg Q\}]]$. We can combine them to define a term of the resolvant type $[[\sigma(C \cup D)]]$. See [22] for more details. As an example, the proof

$$\frac{\frac{\frac{\{P(a, x), P(y, b), P(y, x)\}}{P(a, b)} (1)}{\neg P(a, x)} \qquad \text{Factoring} \qquad \{\neg P(a, x), \neg P(y, b)\}}{\text{Resolution}}}{\emptyset}$$
is a derivation of the empty clause from the clauses $C_1 = \{P(a,x), P(y,b), P(y,x)\}$ and $C_2 = \{\neg P(a,x), \neg 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 => 11 => 12 => 13 => z =>
d1 x y z (11' => 11 11' z)
       (sb1 => sb1 z (12' => 12 12' z) (13' => 13 13' 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 => 11 => 12 => z =>
d2 x y z (11' => 11 11' z) (12' => 12 12' z).
def c3 : (eps (P a b) -> eps bot) -> eps bot
:= 11 => c1 b a 11 11 11.
def c4 : x : i -> ((eps (P a x) -> eps bot) -> eps bot) -> eps bot
:= x => 11 => c3 (tp => c2 x a 11 (tnp => tnp tp)).
def c5 : eps bot := c3 (tp => c4 b (tnp => tnp tp)).

where d1 (resp. d2) is the declaration of $||\Gamma C_1\Gamma||$ (resp. $||\Gamma C_2\Gamma||$); 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.

I'PROVERMODULO can be used to produce DEDUKTI proofs for 3383 problems of the TPTP problem library v6.3.0 [66]. The generated DEDUKTI files weight a total of 38.1 MB, when gzipped.

## 5 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 \lor \neg P$ has a classical proof and no constructive one. Instead, we shall say that the proposition $P \lor_c \neg_c P$ has a proof and the proposition $P \lor \neg P$ does not, distinguishing the classical connectives $\lor_c, \neg_c, \neg$, etc. from the constructive ones $\lor, \neg$, 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 \lor_c B$ as $\neg(\neg A \lor B)$. This approach has been investigated by Hermant, Allali, Dowek, Prawitz, etc. [5, 38, 62]. In all these works the main problem is that the translation of an atomic proposition $P$ needs to be $\neg\neg 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 [5], considering two entailment relations [38], incorporating the double negation to the predicate symbol at the root of $P$ [62].
We consider here another solution that fits better our goal to express classical proofs in a logical framework: the introduction of a new connective.

## 5.1 Classical connectives and quantifiers

The usual syntax for predicate logic distinguishes terms and propositions

$$ t ::= x | f(t, \dots, t) \\ A ::= P(t_1, \dots, t_n) | \top | \bot | \neg A | A \Rightarrow A | A \land A | A \lor A | \forall x A | \exists 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, \dots, t) \\ a ::= P(t_1, \dots, t_n) \\ A ::= a | \top | \bot | \neg A | A \Rightarrow A | A \land A | A \lor A | \forall x A | \exists 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 ::= \triangleright a | \top | \bot | \neg A | A \Rightarrow A | A \land A | A \lor A | \forall x A | \exists 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

$$ \begin{align*} \triangleright_c A &= \neg\neg\triangleright A \\ A \land_c B &= \neg\neg(A \land B) \\ A \lor_c B &= \neg\neg(A \lor B) \end{align*} $$

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

```
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)).
```

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 $\mathcal{L}$ we embed it constructively as a $\lambda$-term as

- $|P(t_1, \dots, t_n)| = \text{atom}(P|t_1| \dots |t_n|)$,

- $|\Gamma| = \text{top}, |\bot| = \text{bot},$

- $|\neg A| = \text{not } A|$,

- $|A \Rightarrow B| = \text{imp } |A| |B|, |A \wedge B| = \text{and } |A| |B|, |A \vee B| = \text{or } |A| |B|,$

- $|\forall_s x A| = \text{fa}_s c (x:s \Rightarrow |A|), |\exists_s x A| = \text{ex}_s c (x:s \Rightarrow |A|)$.

We embed $A$ classically as a $\lambda$-term as

- $|P(t_1, \dots, t_n)|_c = \text{atom}_c(P|t_1| \dots |t_n|)$,

- $|\Gamma|_c = \text{top}_c, |\bot|_c = \text{bot}_c,$

- $|\neg A|_c = \text{not}_c A|$,

- $|A \Rightarrow B|_c = \text{imp}_c |A|_c |B|_c, |A \wedge B|_c = \text{and}_c |A|_c |B|_c, |A \vee B|_c = \text{or}_c |A|_c |B|_c,$

- $|\forall_s x A|_c = \text{fa}_s c (x:s \Rightarrow |A|_c), |\exists_s x A|_c = \text{ex}_s c (x:s \Rightarrow |A|_c)$.

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

**► Lemma 20.** If $A$ is a proposition in the language $\mathcal{L}$ and $\Gamma$ a context containing for each variable $x$ of sort $s$ free in $A$, a variable $x$, of type $s$, then $\Sigma, \Gamma \vdash |A| : o$ and $\Sigma, \Gamma \vdash |A|_c : o$.

Note that the normal form of $|A|_c$ is the result of the Kolmogorov translation of $A$, constructively embedded with $|\cdot|$ . Thus, combining Kolmogorov’s results about his translation with Theorem 18, we get the following theorem.

**► 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 $|A|_c$ is inhabited.

For instance, the proposition

$$ \triangleright_c P \lor_c \neg_c \triangleright_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)).

Note that, since the symbols $\lor$ and $\vee_c$, $\triangleright$ and $\triangleright_c$, etc. have different meanings the propositions

$$ \begin{gathered} \forall x \forall y \forall z (\triangleright x \in \{y, z\} \Leftrightarrow (\triangleright x = y \lor \triangleright x = z)) \\ \forall_c x \forall_c y \forall_c z (\triangleright_c x \in \{y, z\} \Leftrightarrow (\triangleright_c x = y \lor \triangleright_c x = z)) \end{gathered} $$

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.
## 5.2 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

$$ \vdash_c x \in \{y, z\} \longrightarrow (\vdash_c x = y) \lor (\vdash_c x = z) $$

could be expressed directly in DEDUKTI, but it would introduce a critical pair because $\vdash_c P$ also reduces to $\neg\neg\vdash P$. To close this critical pair, we rather add the rule

$$ \vdash x \in \{y, z\} \longrightarrow (\vdash_c x = y) \lor (\vdash_c x = z) $$

that subsumes the first one as $\neg\neg\vdash x \in \{y, z\}$ then rewrites to $\neg\neg((\vdash_c x = y) \lor (\vdash_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

$$ \vdash x \in \{y, z\} \longrightarrow (\vdash x = y) \lor (\vdash x = z) $$

## 5.3 Zenon

In this section we present ZENON 0.8.2 and ZENON MODULO 0.4.2, more information about ZENON can be found at [20], and about ZENON MODULO at [34, 23].

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 Γ, $\neg G \vdash$.

As we have seen, a proposition G has a classical proof, if and only if the type $(\text{eps} | G|_c)$ is inhabited in DEDUKTI. When proving a proposition G, ZENON MODULO produces a DEDUKTI proof-term, of type $(\text{eps} | G|_c)$ [27].

More precisely it first produces a DEDUKTI term of type $\text{eps} (\text{not\_c} | G|_c) \rightarrow \text{eps bot}$. This term can then be turned into a term of type $(\text{eps} | G|_c)$ by applying the constructive theorem $\neg\neg\neg A \Rightarrow \neg A$ twice, because $|G|_c$ starts with a negation.

These proofs of $\text{eps} (\text{not\_c} | G|_c) \rightarrow \text{eps bot}$ are generated by stating in DEDUKTI one lemma per tableaux rule. For instance, the tableaux rule

$$ \frac{A \lor_c B}{A} \text{ Ror} $$

that corresponds to the sequent calculus rule

$$ \frac{\Gamma, A \vdash \quad \Gamma, B \vdash}{\Gamma, A \lor_c B \vdash} \quad \text{v-left} $$

is reflected by the following DEDUKTI lemma

def Ror : A : o -> B : o ->
(\text{eps A} -> \text{eps bot}) ->
(eps B -> eps bot) ->
eps (or_c A B) -> eps bot
:= A => B => HNA => HNB => HNNAB => HNNAB (HAB => HAB bot HNA HNB).

The translation of ZENON MODULO proofs to DEDUKTI has been tested using a bench-
mark of 9,994 B Method [3] proof obligations, representing 5.5 GiB of input files. The
generated DEDUKTI files weigh a total of 595 MB, when gzipped.

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

6.1 Expressing simple type theory

There are two ways to express Simple type theory [29], also known as Higher-order logic, in the λΠ-calculus modulo theory. First, Simple type theory can be expressed in Deduction modulo theory [39]. 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 [44, 45], hence in the λΠ-calculus modulo theory [32], 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 `∀<sub>A</sub>`, 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 *∀*.

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.

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

[a, b] term (arrow a b) --> term a -> term b.

► **Definition 22.** The terms of Simple type theory are embedded as DEDUKTI terms as
follows

x | = x,

| ⇒ | = imp,

| ∀A| = **forall** |A|,
- $|M N| = |M| |N|,$

- $|\lambda x : A M| = x : (\mathbf{term} |A|) \Rightarrow |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 $\Sigma_{STT}$—defines the logic of minimal constructive Simple type theory. For any proposition $A$, we define $\|A\| = \text{eps}|A|$, and for any context $\Gamma = A_1, \dots, A_n$, we define $\|\Gamma\| = h_1 : \|A_1\|, \dots, h_n : \|A_n\|$, where $h_1, \dots, 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 [8]).** $\Gamma \vdash A$ is provable in Simple type theory, if and only if there is a $\lambda$-term $\pi$ such that $\Sigma_{STT}, \|\Gamma\| \vdash \pi : \|A\|$.

Moreover, the term $\pi$ is a straightforward encoding of the original proof tree.

## 6.2 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$ [6], which is based on equality as a primitive connective and which is used in modern implementations of Simple type theory, like HOL LIGHT [10].

The system HOLIDEC—pronounced “holiday”—allows for the expression HOL LIGHT proofs in DEDUKTI, building on the Open theory project [50]. HOLIDEC 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.

# 7 Programming languages

Since rewriting is Turing-complete, we can also use the $\lambda\Pi$-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 $\lambda$-calculus, the $\zeta$-calculus and ML and then FOCALIZE that is a logic to reason about programs.

## 7.1 Lambda-calculus

For example, the untyped $\lambda$-calculus can be encoded by

- $|x| = x,$
- $|t u| = \text{app } |t| |u|,$

- $|\lambda x t| = \text{lam } (x:\text{term} \Rightarrow |t|).$

in the signature

```
Term : Type.
lam : (Term -> Term) -> Term.
def app : Term -> Term -> Term.

[f,t] app (lam f) t --> f t.
```

Encoding programming languages in the $\lambda\Pi$-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 non-terminating terms, DEDUKTI terminates.

- Even in presence of types depending on weakly-terminating terms, DEDUKTI's strategy—comparison of weak head normal forms—often terminates.

For instance, we can define a fixpoint operator in simply-typed $\lambda$-calculus

```
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.
```

and prove properties of recursive terminating functions defined using this fix operator, such as the function `mod2` defined below.

```
nat : type.
def Nat := term nat.
O : Nat.
S : Nat -> Nat.

def match : Nat -> Nat -> (Nat -> Nat) -> Nat.
[n0,nS] match nat 0 n0 nS --> n0
[n,n0,nS] match nat (S n) n0 nS --> nS n.

def mod2 := fix nat nat
  (m2 => n =>
    match nat n
```
```
0
(p => match p
   (S 0)
   (q => m2 q))).
```

```
#CONV mod2 (S (S (S (S 0))), 0.
```

The `#CONV` command in last line checks that the terms `mod2` `(S (S (S (S 0))))` and `0` are convertible.

## 7.2 The $\zeta$-calculus

Abadi and Cardelli [2] 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 `Obj1`. 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ᵢ : Aᵢ]ᵢ∈₁..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 \in 1...n, l_1 < ... < l_n}| = \text{typecons } l_1 |A_1| (\dots \text{typecons } l_n |A_n| \text{ typenil...})$$

Objects are records of methods introduced by a special binder $\zeta$, binding the object itself inside the method's body. The primitive operations are method selection and method update:

$$ \begin{array}{l@{\hspace{2em}}l@{\hspace{2em}}l} a, b, \dots & ::= & x & (\text{variable}) \\ | & | & [l_i = \zeta(x_i : A)a_i]_{i \in 1 \dots n} & (\text{object}) \\ | & | & a.l & (\text{method selection}) \\ | & | & a.l \Leftarrow \zeta(x : A)b & (\text{method update}) \end{array} $$

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 $\zeta$ 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 ->
```
C : type ->
(Obj A -> Obj C) ->
Preobj A B -> Preobj A (typecons 1 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 : 1 : label -> A : type -> B : type -> mem 1 A (typecons 1 A B).
intail : 1 : label -> A : type -> l' : label -> A' : type
-> B : type -> mem 1 A B -> mem 1 A (typecons 1' A' B).
def preselect : A : type ->
B : type ->
l : label ->
C : type ->
mem 1 C B ->
Preobj A B ->
(Obj A -> Obj C).
def preupdate : A : type ->
B : type ->
l : label ->
C : type ->
mem 1 C B ->
Preobj A B ->
(Obj A -> Obj C) ->
Preobj A B.

Both functions are defined by structural induction on their argument of type mem 1 C B where mem is the inductive relation representing membership of the couple (1, 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 1 C A) (a : Obj A) : Obj C :=
preselect A A 1 C p a a.
def update (A : type) := preupdate A A.

► **Definition 24 (Expression of the $\zeta$-calculus).** The encoding of $\zeta$-terms is then defined by

$$ \lfloor x \rfloor = x, $$

$$ \lfloor [l_i = \zeta(x : A)a_i]_{i \in 1...n, l_1 < ... < l_n} \rfloor = \text{precons} |A| \lfloor [l_i : A_i]_{i \in 2...n} \rfloor \lfloor l_1 : A_1 \rfloor (x : \text{Obj } |A| \Rightarrow |a_1|) \rfloor \\ \qquad (\dots \text{precons } |A| \lfloor \lfloor \lfloor \lfloor \lfloor l_n : A_n \rfloor (x : \text{Obj } |A| \Rightarrow |a_n|) \rfloor \rfloor \rfloor \dots) \rfloor, $$

$$ \lfloor a \cdot l_i \rfloor = \text{select} |A| \lfloor l_i : A_i \rfloor \lfloor p_i : a \rfloor, $$

$$ \lfloor a \cdot l_i \rfloor \Leftarrow \zeta(x : A)c \rfloor = \text{update} |A| \lfloor l_i : A_i \rfloor \lfloor p_i : a \rfloor (x : \text{Obj } |A| \Rightarrow |c|). $$

where $p_i$ is a proof that A contains $l_i : A_i$.

► **Lemma 25 (Shallow encoding, Theorems 13 and 18 in [26]).** *This encoding preserves binding, typing, and the operational semantics of the simply-typed $\zeta$-calculus.*

This translation of the simply-typed $\zeta$-calculus in the $\lambda\Pi$-calculus modulo theories can be extended to subtyping, see [26].
## 7.3 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 $τ \to τ'$, the destructor associated with C is the symbol `destrC`, of type `R`: `type -> (eps τ' -> (eps τ -> eps R) -> eps R -> eps R)`, defined by the following rewrite rules:

$$ \begin{align*} \mathit{destrC} \ R \ (C \ t) \ f \ d &\rightarrow \ f \ t \\ \mathit{destrC} \ R \ (C' \ t') \ f \ d &\rightarrow \ d \quad (\text{for all other constructors } C' \text{ for type } \tau') \end{align*} $$

**Lemma 27 (Theorem 1 in [25]).** *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

$$ @ \tau' R f (C t) \rightarrow 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*|.*

## 7.4 FoCaLiZe

Our main motivation for translating programming languages to the λΠ-calculus modulo theory is to check program certificates. The FOCALIZE system [42] 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`. It can be defined in FOCALIZE by

```
type nat = | Zero | Succ (nat);
```

```
let rec mod2 (n) =
```
```hakomatch
match n with
  | Zero -> Zero
  | Succ(m) ->
      match m with
        | Zero -> Succ(Zero)
        | Succ(k) -> mod2(k)
;;
```

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:

```hakomatch
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.

```hakomatch
theorem mod2_twiceanimod2 : mod2(twice(Zero)) = Zero
proof = by type nat definition of mod2, twice;;

theorem twiceSucc : 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;;
```

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

```hakomatch
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
let mod2_twice_n_isima(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_isima mod2_twiceima 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.

8 The Calculus of inductive constructions with universes

**8.1 Pure type systems**

Pure type systems [14] 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 con-
structions. We can express functional Pure type systems in the λΠ-calculus modulo theory
[32] 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 [54]. We represent each
type *A* of sort *s* as a term |*A*|, of type *U*<sub>s</sub>, and each term *M* of type *A* as a term |*M*|, of
type *eps*<sub>s</sub> |*A*| [32].

Consider a Pure type system specification (*S*, *A*, *R*). For each sort *s* ∈ *S*, we declare the type *U*<sub>s</sub> whose inhabitants represent the types of sort *s*, and the dependent type *eps*<sub>s</sub> 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₁, s₂⟩ ∈ A, we declare the variable u<sub>s₁</sub> which is the term that represents
the sort s<sub>1</sub> in s<sub>2</sub>, 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₁, s₂, s₃⟩ ∈ ℝ, we declare the variable π<sub>s₁,s₂</sub> which is the term that represents dependent products such as Πx : A B in s₃, and we give its interpretation as a type using a rewrite rule.

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).

► **Definition 29.** 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₁ and Γ, x : A ⊢ B : s₂),

||A|| = e_s |A| (when Γ ⊢ A : s),

||s|| = U_s (when ≠s' such that Γ ⊢ s : s'),
■ $\| [ ] \| = [ ],$

■ $\| \Gamma, x : A \| = \| \Gamma \|, x : \| A \|.$

► **Lemma 30** (Preservation of computation, Proposition 1 in [32]). If $\Gamma \vdash M : A$ and $M \to_{\beta} M'$, then there exists $N'$ such that $|M| \to_{\beta} N' \equiv_{\beta\Sigma} |M'|$.

► **Lemma 31** (Preservation of typing, Proposition 3 in [32]). If $\Gamma \vdash M : A$, then $\Sigma, \|\Gamma\| \vdash |M| : \|A\|$.

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

► **Lemma 32** (Conservativity, adequacy, [9]). If $\Sigma, \|\Gamma\| \vdash M' : \|A\|$, then there exists $M$ such that $\Gamma \vdash M : A$ and $|M| \equiv_{\beta\eta\Sigma} |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 $\Gamma \vdash M : A$ if, and only if there exists $M$, such that $\Sigma, \|\Gamma\| \vdash M : \|A\|$.

As an example, the Calculus of constructions can be defined as the Pure type system

$$
\begin{align*}
S &::= \{Type, Kind\} \\
A &::= \{(Type, Kind)\} \\
R &::= \{(Type, Type, Type), (Type, Kind, Kind), \\
    & \qquad (Kind, Type, Type), (Kind, Kind, Kind)\}
\end{align*}
$$

and it is expressed in DEDUKTI as

U_Type : Type.
U_Kind : Type.

def e_Type : U_Type -> Type.
def e_Kind : U_Kind -> Type.

u_Type : U_Kind.

pi_TypeType : a : U_Type -> b : (e_Type a -> U_Type) -> U_Type.
pi_TypeKind : a : U_Type -> b : (e_Type a -> U_Kind) -> U_Kind.
pi_KindType : a : U_Kind -> b : (e_Kind a -> U_Type) -> U_Type.
pi_KindKind : a : U_Kind -> b : (e_Kind a -> U_Kind) -> U_Kind.

[ ] e_Kind u_Type --> U_Type.

[a, b]
e_Type (pi_TypeType a b) --> x : e_Type a -> e_Type (b x).
[a, b]
e_Kind (pi_TypeKind a b) --> x : e_Type a -> e_Kind (b x).
[a, b]
e_Type (pi_KindType a b) --> x : e_Kind a -> e_Type (b x).
[a, b]
e_Kind (pi_KindKind a b) --> x : e_Kind a -> e_Kind (b x).

Consider the context $\Gamma = a : Type, b : Type, x : a, f : \Pi p : (a \to Type) (p x \to b)$, in which the term $f (\lambda y : a a) x$ is a proof of $b$. This proof is represented in DEDUKTI as
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.

## 8.2 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 [46]. 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 -> 12 : e_Type (list A)
-> e_Type (P 12) -> e_Type (P (cons A x 12))) -> 1 : e_Type (list A)
-> e_Type (P 1).

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 `12:(list A)` and object of type `P 12`, an object of type `P (cons A x 12)`, then we can construct an object of type `P 1` for any list `1`. Finally, we express the computational behavior of the eliminator, that reduces when applied to a constructor.

[A, P, caseewhenever, case cons]
elim_list _ P caseNil case cons (nil A) -->
caseNil.

[A, P, caseNil, case cons, x, 1]
elim_list _ P caseNil case cons (cons A x 1) -->
case cons x 1 (elim_list A P caseNil case cons 1).

Recursive functions and inductive proofs can then be expressed using this elimination operator. For instance, the append function is

def append : A : U_Type -> List A -> List A -> List A :=
A : U_Type => 11 : List A => 12 : List A =>
elim_list A ( _ _ => list A) 12 (x => 13 => 1312 => cons A x 1312) 11.
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 [18]. 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.

## 8.3 Universes

Universes are the types of types in Intuitionistic type theory [54]. 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 : \dots$$

Second, the hierarchy is cumulative

$$U_0 \subseteq U_1 \subseteq U_2 : \dots$$

which is expressed by the typing rule

$$\frac{\Gamma \vdash M : U_i}{\Gamma \vdash 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$, $\pi$ 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 $\uparrow_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 $\Gamma \vdash A : U_i$ and $\Gamma, x : A \vdash B : U_i$ then the type $\Pi 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 [7], so we add the following rewrite rule to ensure that types have a unique representation as terms:
[i, a, b] pi_ (lift i a) (x => lift {i} (b x)) -->
lift i (pi i a (x => b x)).

These techniques can also be adapted to express the universes of the Calculus of inductive
constructions, which in particular include an impredicative universe *Prop* [7].

8.4 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 [1].

A closely related library comes from MATITA. It is expressed in a Calculus of con-
structions 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.

9 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 [32], together with an expression of Pure type systems in it, and a partial correctness proof. The framework was further refined in [64] and then in [65]. In 2010, during his undergrad internship [35], 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 [17] 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 [24], supervised by Olivier Hermant and Mathieu Boespflug. Finally, the current implementation has been designed by Ronan Saillard between 2012 and 2015 during his thesis [65], 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 [18]. 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 [8] 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 [68]. Guillaume Burel [22] 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.
## 10 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:

<table><tr><td>The iProverModulo TPTP library</td><td>38.1 MB</td></tr><tr><td>The Zenon modulo Set Theory Library</td><td>595 MB</td></tr><tr><td>The Focalide library</td><td>1.89 MB</td></tr><tr><td>The Holide library</td><td>21.5 MB</td></tr><tr><td>The Matita arithmetic library</td><td>1.11 MB</td></tr></table>

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 [11], 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?”

## 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.

## References

1. J.-P. Jouannaud A. Assaf, G. Dowek and J. Liu. Untyped confluence in dependent type theories. 2016.

2. M. Abadi and L. Cardelli. *A Theory of Objects*. Monographs in Computer Science. Springer New York, 1996.

3. J.-R. Abrial. *The B-Book, Assigning Programs to Meanings*. Cambridge University Press, 1996.

4. L. Allali. Algorithmic equality in Heyting arithmetic modulo. In *TYPES*, pages 1–17, 2007.

5. L. Allali and O. Hermant. Semantic A-translations and super-consistency entail classical cut elimination. In Ken McMillan, Aart Middeldorp, and Andreï Voronkov, editors, *LPAR*, volume 8312 of LNCS ARCoSS, pages 407–422. Springer, 2013.

6. P. B. Andrews. *An introduction to mathematical logic and type theory: to truth through proof*. Academic Press Professional, Inc., San Diego, CA, USA, 1986.

7. A. Assaf. A calculus of constructions with explicit subtyping. In *Post-proceedings of the 20th International Conference on Types for Proofs and Programs (TYPES 2014)*, Leibniz International Proceedings in Informatics (LIPIcs), Paris, 2014. Schloss Dagstuhl.
8 A. Assaf. *A framework for defining computational higher-order logics*. PhD thesis, École polytechnique, 2015.

9 A. Assaf. Conservativity of embeddings in the lambda-Pi calculus modulo rewriting. In Thorsten Altenkirch, editor, *Proceedings of the 13th International Conference on Typed Lambda Calculi and Applications (TLCA 2015)*, Leibniz International Proceedings in Informatics (LIPIcs), Warsaw, 2015. Schloss Dagstuhl.

10 A. Assaf and G. Burel. Translating HOL to Dedukti. In *Proceedings of the Fourth Workshop on Proof Exchange for Theorem Proving (PxTP 2015)*, Electronic Proceedings in Theoretical Computer Science, Berlin, 2015.

11 A. Assaf and R. Cauderlier. Mixing HOL and Coq in Dedukti. In Kaliszyk, Cezary and Paskevich, Andrei, editor, *Proceedings 4th Workshop on Proof eXchange for Theorem Proving*, Berlin, Germany, August 2-3, 2015, volume 186 of *Electronic Proceedings in Theoretical Computer Science*, pages 89–96, Berlin, Germany, August 2015. Open Publishing Association.

12 L. Bachmair and H. Ganzinger. Resolution theorem proving. In John Alan Robinson and Andrei Voronkov, editors, *Handbook of Automated Reasoning*, pages 19–99. Elsevier and MIT Press, 2001.

13 Franco Barbanera, Maribel Fernández, and Herman Geuvers. Modularity of strong normalization in the algebraic lambda-cube, 1996.

14 H. Barendregt. Lambda calculi with types. In Samson Abramsky, Dov M. Gabbay, and Thomas S. E. Maibaum, editors, *Handbook of Logic in Computer Science*, volume 2, pages 117–309. Oxford University Press, 1992.

15 G. Barthe and M.H. Sørensen. Domain-free pure type systems. In *J. Funct. Program.*, pages 9–20. Springer, 1993.

16 F. Blanqui. Definitions by rewriting in the calculus of constructions. *Mathematical Structures in Computer Science*, 15(1):37–92, 2005.

17 M. Boespflug. *Conception d'un noyau de vérification de preuves pour le lambda-Pi-calcul modulo*. PhD thesis, École Polytechnique, 2011.

18 M. Boespflug and G. Burel. CoqInE: Translating the calculus of inductive constructions into the lambda-Pi-calculus modulo. In *Proof Exchange for Theorem Proving—Second International Workshop, PxTP*, page 44, 2012.

19 M. Boespflug, Q. Carbonneaux, and O. Hermant. The λΠ-calculus modulo as a universal proof language. In David Pichardie and Tjark Weber, editors, *PxTP*, 2012.

20 R. Bonichon, D. Delahaye, and D. Doligez. Zenon: An extensible automated theorem prover producing checkable proofs. In *Logic for Programming, Artificial Intelligence, and Reasoning, 14th International Conference, LPAR 2007, Yerevan, Armenia, October 15-19, 2007, Proceedings*, pages 151–165, 2007.

21 G. Burel. Experimenting with deduction modulo. In Viorica Sofronie-Stokkermans and Nikolaj Bjørner, editors, *CADE*, volume 6803 of *Lecture Notes in Computer Science*, pages 162–176. Springer, 2011.

22 G. Burel. A shallow embedding of resolution and superposition proofs into the λΠ-calculus modulo. In Jasmin Christian Blanchette and Josef Urban, editors, *PxTP 2013*, volume 14 of *EPiC Series*, pages 43–57. EasyChair, 2013.

23 G. Bury, D. Delahaye, D. Doligez, P. Halmagrand, and O. Hermant. Automated Deduction in the B Set Theory using Typed Proof Search and Deduction Modulo. In *LPAR 20 : 20th International Conference on Logic for Programming, Artificial Intelligence and Reasoning*, Suva, Fiji, November 2015.

24 Q. Carbonneaux. Compilation jit des termes de preuve. Masters thesis, 2012.

25 R. Cauderlier and C. Dubois. ML pattern-matching, recursion, and rewriting: from Fo-CaLiZe to Dedukti. Submitted to FSCD 2016.
26 R. Cauderlier and C. Dubois. Objects and subtyping in the λΠ-calculus modulo. In *Post-proceedings of the 20th International Conference on Types for Proofs and Programs (TYPES 2014)*, Leibniz International Proceedings in Informatics (LIPIcs), Paris, 2014. Schloss Dagstuhl.

27 R. Cauderlier and P. Halmagrand. Checking Zenon Modulo Proofs in Dedukti. In Kaliszyk, Cezary and Paskevich, Andrei, editor, *Proceedings 4th Workshop on Proof eXchange for Theorem Proving*, Berlin, Germany, August 2-3, 2015, volume 186 of *Electronic Proceedings in Theoretical Computer Science*, pages 57-73, Berlin, Germany, August 2015. Open Publishing Association.

28 A. Chlipala, L. Petersen, and R. Harper. Strict bidirectional type checking. In J. Gregory Morrisett and Manuel Fähndrich, editors, *TLDI*, pages 71-78. ACM, 2005.

29 A. Church. A formulation of the simple theory of types. *The Journal of Symbolic Logic*, 5(2):56-68, 1940.

30 T. Coquand. An algorithm for type-checking dependent types. *Sci. Comput. Program.*, 26(1-3):167-177, 1996.

31 T. Coquand and G. Huet. The calculus of constructions. *Information and computation*, 76(2):95-120, 1988.

32 D. Cousineau and G. Dowek. Embedding pure type systems in the lambda-Pi-calculus modulo. In S. Ronchi Della Rocca, editor, *Typed Lambda Calculi and Applications*, pages 102-117. Springer-Verlag, 2007.

33 Deducteam. User manual for Dedukti. http://dedukti.gforge.inria.fr/manual_v2_5.html.

34 D. Delahaye, D. Doligez, F. Gilbert, P. Halmagrand, and O. Hermant. Zenon Modulo: When Achilles Outruns the Tortoise using Deduction Modulo. In *Logic for Programming Artificial Intelligence and Reasoning (LPAR)*, volume 8312 of LNCS/ARCoSS. Springer, 2013.

35 A. Dorra. Équivalence Curry-Howard entre le lambda-Pi-calcul et la logique intuitionniste. Undergrad research intership report, 2010.

36 G. 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). *Comptes rendus à l'Académie des Sciences I*, 312(12):951-956, 1991. Erratum, ibid. I, 318, 1994, p. 873.

37 G. Dowek. Polarized resolution modulo. In Cristian S. Calude and Vladimiro Sassone, editors, *IFIP TCS*, volume 323 of IFIP AICT, pages 182-196. Springer, 2010.

38 G. Dowek. On the definition of the classical connectives and quantifiers. In *Why is this a Proof? Festschrift for Luiz Carlos Pereira*. College Publication, 2015.

39 G. Dowek, T. Hardin, and C. Kirchner. Hol-lambda-sigma: an intentional first-order expression of higher-order logic. *Mathematical Structures in Computer Science*, 11(1):21-45, 2001.

40 G. Dowek, T. Hardin, and C. Kirchner. Theorem proving modulo. *Journal of Automated Reasoning*, 31(1):33-72, 2003.

41 G. Dowek and B. Werner. Arithmetic as a theory modulo. In J. Giesl, editor, *Term rewriting and applications*, pages 423-437. Springer-Verlag, 2005.

42 FoCaLiZe. http://focalize.inria.fr.

43 H. Ganzinger and K. Korovin. New directions in instantiation-based theorem proving. In *18th IEEE Symposium on Logic in Computer Science (LICS 2003)*, 22-25 June 2003, Ottawa, Canada, *Proceedings*, pages 55-64. IEEE Computer Society, 2003.

44 H. Geuvers. *Logics and Type systems*. PhD thesis, Nijmegen, 1993.

45 H. Geuvers. The calculus of constructions and higher order logic. In Ph. de Groote, editor, *The Curry-Howard isomorphism*, volume 8 of *Cahiers du Centre de logique*, pages 139-191. Université catholique de Louvain, 1995.
46 K. Gödel. Über eine bisher noch nicht benützte Erweiterung des finiten Standpunktes. *Dialectica*, pages 280–287, 1958.

47 R. Harper, F. Honsell, and G. Plotkin. A framework for defining logics. *Journal of the Association for Computing Machinery*, 40(1):143–184, 1993.

48 O. Hermant and F. Gilbert. Double negation translations as morphisms. Submitted to publication, 2015.

49 D. Hilbert and W. Ackermann. *Grundzüge der theoretischen Logik*. Springer-Verlag, 1928.

50 J. Hurd. The opentheory standard theory library. In Mihaela Bobaru, Klaus Havelund, Gerard J. Holzmann, and Rajeev Joshi, editors, *NASA Formal Methods*, volume 6617 of *Lecture Notes in Computer Science*, pages 177–191. Springer, 2011.

51 K. Korovin. iProver – an instantiation-based theorem prover for first-order logic (system description). In Alessandro Armando and Peter Baumgartner, editors, *IJCAR*, volume 5195 of *Lecture Notes in Artificial Intelligence*, pages 292–298. Springer, 2008.

52 R. Loader. Higher order beta matching is undecidable. *Logic Journal of the IGPL*, 11(1):51–68, 2003.

53 C. Marché, A. Rubio, and H. Zantema. https://www.lri.fr/~marche/tpdb/format.html.

54 P. Martin-Löf. *Intuitionistic type theory*, G. Sambin (Ed.). Bibliopolis, 1984.

55 D. Miller. A logic programming language with lambda-abstraction, function variables, and simple unification. *Journal of Logic and Computation*, 1:253–281, 1991.

56 D. Miller and G. Nadathur. An overview of λProlog. In *Proceedings of the 5th International Conference on Logic Programming*, MIT Press, 1988.

57 T. Nipkow. Higher-order critical pairs. In *Proc. 6th IEEE Symp. Logic in Computer Science*, pages 342–349. IEEE Press, 1991.

58 B. Nordström, K. Petersson, and J.M. Smith. *Programming in Martin-Löf's type theory*. Oxford University Press, 1990.

59 C. Paulin-Mohring. Inductive definitions in the system coq rules and properties. In M. Bezem and J.-F. Groote, editors, *Typed Lambda Calculus and Applications*, pages 328–345. Springer-Verlag, 1993.

60 L.C. Paulson. Isabelle: the next seven hundred theorem provers. In E. Lusk and R. Overbeek, editors, *9th International Conf. on Automated Deduction*, volume 310 of *Lecture Notes in Computer Science*, page 772–773. Springer, 1988.

61 H. Poincaré. *La science et l'hypothèse*. Flammarion, 1902.

62 D. Prawitz. Classical versus intuitionistic logic. In *Why is this a Proof? Festschrift for Luiz Carlos Pereira*. College Publication, 2015.

63 Saillard R. Rewriting modulo $\beta$ in the $\lambda\Pi$-calculus modulo. In Iliano Cervesato and Kaustuv Chaudhuri, editors, *Proceedings Tenth International Workshop on Logical Frameworks and Meta Languages: Theory and Practice, LFMTP 2015, Berlin, Germany, 1 August 2015.*, volume 185 of *EPTCS*, pages 87–101, 2015.

64 R. Saillard. Towards explicit rewrite rules in the lambda-Pi calculus modulo. In *IWIL*, 2013.

65 R. Saillard. *Type Checking in the Lambda-Pi-Calculus Modulo: Theory and Practice*. PhD thesis, École des Mines, 2015.

66 G. Sutcliffe. The TPTP Problem Library and Associated Infrastructure: The FOF and CNF Parts, v3.5.0. *Journal of Automated Reasoning*, 43(4):337–362, 2009.

67 V. van Oostrom. Development closed critical pairs. In *Higher-Order Algebra, Logic, and Term Rewriting, Second International Workshop, HOA '95, Paderborn, Germany, September 21-22, 1995, Selected Papers*, pages 185–200, 1995.

68 S. Wang. Reverse engineering of higher order proofs. Master thesis, 2015.