<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Reconstruction of SMT proofs with Lambdapi</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Alessio Coltellacci</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Gilles Dowek</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Stephan Merz</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>University of Lorraine</institution>
          ,
          <addr-line>CNRS, Inria, Nancy</addr-line>
          ,
          <country country="FR">France</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of Paris-Saclay, Inria, ENS Paris-Saclay</institution>
          ,
          <addr-line>CNRS, LMF, Gif-sur-Yvette</addr-line>
          ,
          <country country="FR">France</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>The Alethe format is a representation of unsatisfiability proofs that has been adopted by several SMT solvers. We describe work in progress for interpreting Alethe proofs and generating corresponding proofs that are accepted by the Lambdapi proof checker, a foundational proof assistant based on dependent type theory and rewriting rules that serve as a pivot for exchanging proofs between several interactive proof assistants. We give an overview of the encoding of SMT logic and Alethe proofs in Lambdapi and present initial results of the evaluation of the checker on benchmark examples.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <sec id="sec-1-1">
        <title>Overview of the paper</title>
        <sec id="sec-1-1-1">
          <title>Section 2 introduces the Alethe proof format and describes the elaborated proof produced by Carcara.</title>
        </sec>
        <sec id="sec-1-1-2">
          <title>In Section 3, we present first the embedding of Alethe logic in Lambdapi, and then how we extended</title>
          <p>22nd International Workshop on Satisfiability Modulo Theories (SMT 2024)</p>
          <p>© 2024 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0).</p>
          <p>Coq
PVS
vodk
lean</p>
          <p>2dk</p>
          <p>KaMeLo
K-framework</p>
          <p>SMT</p>
          <p>C
a
r
c
a
r
a
Lambdapi
Dedukti
o
n
o
j
a
r</p>
          <p>K
Matita
isabelle_dk
agda2dk</p>
          <p>Isabelle</p>
          <p>Agda
hol2dk</p>
          <p>HOL</p>
          <p>Zenon and ArchSAT</p>
        </sec>
        <sec id="sec-1-1-3">
          <title>Carcara to mechanically translate an elaborated Alethe proof into a Lambdapi proof script. In Section 4,</title>
          <p>we argue the soundness property of our work, and Section 5 provides an evaluation on a set of proofs
from the SMT-LIB benchmarks and proof obligations of a case study from the proof assistant TLAPS.</p>
        </sec>
        <sec id="sec-1-1-4">
          <title>We conclude and outline future work in Section 6.</title>
        </sec>
      </sec>
      <sec id="sec-1-2">
        <title>Related work</title>
        <sec id="sec-1-2-1">
          <title>Hammers are components of some proof assistants such as Sledgehammer [7] for Isabelle/HOL, and</title>
          <p>
            CoqHammer [
            <xref ref-type="bibr" rid="ref8 ref9">8, 9</xref>
            ] for Coq, that employ first-order automatic theorem provers (ATPs), including SMT
solvers, to discharge goals. The hammer translates the conjecture and any user-supplied facts to the
input language of the back-end, invokes it, and in the case of success attempts to reconstruct the proof
in the logic of the proof assistant, based on a trace of the proof found by the back-end. For example,
adoption by Sledgehammer of the Alethe format generated by the SMT solver veriT [
            <xref ref-type="bibr" rid="ref10 ref3">3, 10</xref>
            ] cut the
failure rate of reconstruction by 50% and reduced the checking time by 13%. These results encouraged
us to select the Alethe proof format to construct our solution.
          </p>
        </sec>
        <sec id="sec-1-2-2">
          <title>SMTCoq is a Coq plugin written in Coq and fully certified [ 11] that checks proof witnesses coming</title>
          <p>
            from external SAT and SMT solvers. For proof reconstruction, SMTCoq relies on computational
reflection: the certificate is directly processed by the reduction mechanism of Coq’s kernel. In our first
investigations, we attempted to convert the SMTCoq proof certificate to Lambdapi. However, we found
the proof term generated by computational reflection, including subterms corresponding to arithmetic
decision procedures in Micromega [
            <xref ref-type="bibr" rid="ref12">12</xref>
            ], to be too complex to be converted to Lambdapi. Moreover,
          </p>
        </sec>
        <sec id="sec-1-2-3">
          <title>SMTCoq supports at this point an old version of the Alethe proof format.</title>
          <p>
            Carcara [
            <xref ref-type="bibr" rid="ref5">5</xref>
            ] is an independent proof checker and proof elaborator for SMT proofs in the Alethe
format that is implemented in Rust. Although Carcara is not a certified checker like SMTCoq, it allows
a coarse-grained proof, containing implicit steps, to be elaborated to a fine-grained one that includes
more detailed steps or adds missing parameters. The resulting proof is intended to be easier to check
by an external proof assistant, in particular given the lack of meta-programming in the vernacular
language of Lambdapi.
          </p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>2. Alethe</title>
      <sec id="sec-2-1">
        <title>The Alethe proof format [13] for SMT solvers comprises two parts: the proof language based on</title>
        <p>SMT-LIB and a collection of proof rules. Alethe proofs are a sequence 1 . . . , 1, . . . ,  where the
s correspond to the original SMT instance being refuted, each  is a clause inferred from previous
elements of the sequence, and  is ⊥ (the empty clause). In the following sections, we designate the
SMT-LIB problem as the input problem.</p>
      </sec>
      <sec id="sec-2-2">
        <title>In the following, we will use the input problem example Listing 1 with its Alethe proof (found by</title>
      </sec>
      <sec id="sec-2-3">
        <title>CVC5) to provide an overview of Alethe concepts and to illustrate our embedding in Lambdapi.</title>
      </sec>
      <sec id="sec-2-4">
        <title>An Alethe proof inherits the declarations of its input problem. All symbols (sorts, functions, assertions,</title>
        <p>etc.) declared or defined in the input problem remain declared or defined, respectively. Furthermore,
the syntax for terms, sort, and annotations uses the syntactic rules defined in SMT-LIB [ 14, §3] and the</p>
      </sec>
      <sec id="sec-2-5">
        <title>SMT signature context Σ defined in [14, §5.1 and §5.2].</title>
        <sec id="sec-2-5-1">
          <title>2.1. The Alethe Language</title>
          <p>An Alethe proof is a list of steps representing forward reasoning whose general form is as follows:
clause
 . Γ
▷ 1, . . . ,</p>
          <p>( ℛ 1, . . . ,  ) [1, . . . , ]
index
context
rule
premises
arguments
(1)</p>
          <p>A step consists of an index  ∈ I where I is a countable infinite set of indices (e.g. a0, t1), and a
clause of literals 1, . . . ,  representing an -ary disjunction. A proof rule ℛ depends on a possibly
empty set of premises { 1, . . . ,  } ⊆ I that refer to earlier steps. A rule might also depend on a
list of arguments [1, . . . , ] where each argument  is either a term or a pair (, ) where 
is a variable and  is a term. The interpretation of the arguments is rule specific. The context Γ is
a list 1, . . . ,  where each element  is either a variable or a variable-term tuple denoted  ↦  .
Therefore steps with a non-empty context contain variables  in  that can be substituted by  . Proof
rules ℛ are structured around the introduction of theory lemmas and resolution which captures
hyper-resolution on ground first-order clauses.</p>
        </sec>
      </sec>
      <sec id="sec-2-6">
        <title>We now have the key components to explain the guiding proof Listing 1 that consists of seven steps.</title>
      </sec>
      <sec id="sec-2-7">
        <title>The proof starts with several assume steps a0, a1, a2 that restate the assertions from the input problem.</title>
        <p>Step t1 introduces with the rule equiv_pos2 a tautology of the general form ¬( 1 ≈  2)∨ ¬ 1 ∨  2.
Steps t2, t3, t4 use earlier premises that correspond to previous steps. Step t2 prove () ≈ ()
by congruence (rule cong ) by using the assumption a1. Step t3 derives () after applying the
resolution rule of propositional logic to the premises t1, t2, a0. Lastly, the step t4 concludes
the proof by generating the empty clause ⊥, concretely denoted as (cl) in Listing 1. Notice that the
contexts Γ of each step are all empty in this proof.</p>
      </sec>
      <sec id="sec-2-8">
        <title>Unfortunately, Alethe proofs provided by SMT solvers such as veriT and CVC5 can be challenging to reconstruct in a proof assistant. For instance, the order of literals in the clauses is not determined, symmetry of equality is sometimes used implicitly, and pivots for the resolution proof rule are not indicated explicitly.</title>
        <sec id="sec-2-8-1">
          <title>2.2. Elaborated proof with Carcara</title>
          <p>Carcara provides an elaboration mechanism for Alethe proofs and adds details that can make proof
reconstruction easier. For example, one possible elaboration is to mention the pivot(s) for resolution
steps. In our guiding example, Carcara elaborates part of the proof of Listing 1 by exposing the pivots
of the steps t3 and t4 as arguments of resolution proof rule with a Boolean flag to indicate if the
negation of the pivot is in the first or second premise:
(step t3 (cl (p b)) :rule resolution :premises (t1 t2 a0)</p>
          <p>:args ((= (p a) (p b)) false (p a) false))
(step t4 (cl) :rule resolution :premises (a2 t3) :args ((p b) false))</p>
        </sec>
      </sec>
      <sec id="sec-2-9">
        <title>Carcara can also shorten proofs by removing some trivial transient steps and rewriting the order of literals in a clause. The list of elaborations performed by Carcara can be found in [5, §3.2]. Our translation of Alethe proofs into Lambdapi is based on the elaboration performed by Carcara, relying on it for pre-checking the proof and applying the transformations for making it explicit.</title>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3. Proof reconstruction</title>
      <sec id="sec-3-1">
        <title>We now describe our embedding of Alethe in Lambdapi, and how we extended Carcara with a new</title>
        <p>module that can export elaborated Alethe proofs to Lambdapi. Our work applies to input problems
expressed in the logics UFLIA, UFNIA or their sub-logics.</p>
        <p>Notation (Alethe signature and judgment). We use Θ instead of Σ to denote the SMT signature context to
avoid conflicts with the Lambdapi signature context. Therefore, Θ  represents the set of SMT sort symbols,
Θ ℱ the set of function symbols, and Θ  the set of variables. We refer to step and assume as commands or
sometimes as Alethe judgments.</p>
        <sec id="sec-3-1-1">
          <title>3.1. Lambdapi</title>
          <p>
            Lambdapi is an implementation of  Π modulo theory ( Π /≡) [
            <xref ref-type="bibr" rid="ref15">15</xref>
            ], an extension of  Π , i.e., the
Edinburgh Logical Framework [
            <xref ref-type="bibr" rid="ref16">16</xref>
            ], a simply typed  -calculus with dependent types.  Π /≡ adds
user-defined higher-order rewrite rules. Its syntax is given by
          </p>
        </sec>
      </sec>
      <sec id="sec-3-2">
        <title>Universes</title>
      </sec>
      <sec id="sec-3-3">
        <title>Terms</title>
      </sec>
      <sec id="sec-3-4">
        <title>Contexts Signatures</title>
        <p>∶∶= TYPE ∣ KIND
, , , ,  ∶∶=  ∣  ∣  ∣ Π ∶ .  ∣   ∶ .  ∣  
Γ ∶∶= ⟨⟩ ∣ Γ , ∶ 
Σ ∶∶= ⟨⟩ ∣ Σ , ∶  ∣ Σ ,  ∶=  ∶  ∣ Σ ,  ↪ 
where  is a constant and  is a variable (ranging over disjoint sets),  is a closed term. Universes are
constants used to verify if a type is well-formed – more details can be found in [16, §2.1]. Π ∶ . 
is the dependent product, and we write  →  when  does not appear free in ,   ∶ .  is an
abstraction, and   is an application. Signature Σ (global context) and contexts Γ (local contexts) are
ifnite sequences and ⟨⟩denotes the empty sequence. Assumptions are written ∶ , indicating that  is
of type . Definitions in Σ are written  ∶=  ∶ , indicating that  has the value  and type . In a
Lambdapi typing judgment Γ ⊢Σ ∶  a term  has type  in the context Γ and the signature Σ .</p>
        <p>
          A signature may contain rewrite rules  ↪  such that  =  1 . . .  with  a constant. The relation
↪ Σ is generated by  -reduction and by the rewrite rules of Σ . Conversion ≡ Σ is the reflexive,
symmetric, and transitive closure of ↪ Σ. Let ↪∗Σ be the reflexive and transitive closure of ↪ Σ. The
relation ↪ Σ must be confluent, i.e., whenever  ↪∗Σ 1 and  ↪∗Σ 2, there exists a term  such that
∗ ∗
1 ↪ Σ  and 2 ↪ Σ , and it must preserve typing, i.e., whenever Γ ⊢Σ  ∶  and  ↪ Σ  then
Γ ⊢Σ  ∶  [
          <xref ref-type="bibr" rid="ref17">17</xref>
          ].
        </p>
        <p>The typing rules in  Π /≡ are similar to those of  Π [16, §2], except for the additional rule (Conv)
that identifies types modulo ≡ Σ instead of just modulo ≡ .</p>
        <p>Γ , ⊢Σ  ∶ 
Γ ⊢Σ  ∶</p>
        <p>≡ Σ 
Γ ⊢Σ  ∶</p>
      </sec>
      <sec id="sec-3-5">
        <title>Conv</title>
        <sec id="sec-3-5-1">
          <title>3.2. A Prelude Encoding for Alethe</title>
          <p>Definition 1 (Prelude Encoding). Our signature context Σ contains the following definitions and rewrite
rules furnished by the standard library of Lambdapi that we use to encode Alethe proofs:
constant symbol Set : TYPE;
injective symbol El : Set → TYPE;
constant symbol 〜 : Set → Set → Set;
rule El ($x 〜 $y) ↪ El $x → El $y;
symbol o: Set;
constant symbol Prop : TYPE;
injective symbol Prf : Prop → TYPE;
rule El o ↪ Prop;</p>
          <p>The constants Set and Prop (lines 1 and 6) are type universes “à la Tarski” [18, §Universes] in  Π /≡.</p>
        </sec>
      </sec>
      <sec id="sec-3-6">
        <title>The type Set represents the universe of small types. We characterize small types as a subclass of types</title>
        <p>for which we can define equality. SMT sorts are represented in  Π /≡ as elements of type Set. Since
elements of type Set are not types themselves, we also introduce a decoding function El∶ Set → TYPE
which interpret SMT sorts as  Π /≡ types. Thus, we represent the terms of sort Bool of SMT by
elements of type El . The constructor 〜 is used to encode SMT functions and predicates.</p>
        <p>The type Prop represents the universe of propositions in  Π /≡. Like Set, elements of type Prop are
not types themselves, so we introduce the decoding function Prf∶ Prop → TYPE. By analogy with the</p>
      </sec>
      <sec id="sec-3-7">
        <title>Curry-de-Brujin-Howard isomorphism, it embeds propositions into types, mapping each proposition</title>
        <p>to the type Prf  of its proofs. Hence, Bool formulas of SMT are rewritten to  Π /≡ propositions with
the rewrite rule defined in line 8. Thereafter, we add the following definitions to those of the standard
library:
symbol Bool ≔ o;
injective symbol Index [a: Set] : N → El a;</p>
      </sec>
      <sec id="sec-3-8">
        <title>For convenience, we define an alias Bool for . The function Index is used to assign to SMT</title>
        <p>translated terms a unique identifier, so to compare that two terms are equal it is suficient to compare
their identifier. In Lambdapi syntax, an argument enclosed in square brackets e.g. [a] is declared
implicit.</p>
        <sec id="sec-3-8-1">
          <title>3.3. Classical connectives, quantifiers and facts</title>
          <p>Since SMT-solvers are based on classical logic, we use the constructive connectives and quantifiers
from the Lambdapi standard library and define the classical ones from them using the double-negation
translation [19] as a definition.
injective symbol Prf p ≔ Prf (¬¬ p);
symbol ∨ p q ≔ ¬¬ p ∨ ¬¬ q;
constant symbol = [a] : El a → El a → Prop;</p>
          <p>Therefore, Alethe classical proofs will be decoded by the decoding function Prf (line 1), defined as
intuitionistic proof Prf of the doubly negated predicate. Similarly, classical connectives and quantifiers
will be defined as illustrated in line 2. Since we want to define equality restricted to small types, equality
has a single implicit parameter a: Set and two indices of type El .</p>
        </sec>
      </sec>
      <sec id="sec-3-9">
        <title>We prove the law of excluded middle and add the proposition of Boolean extensionality stating that classical equivalence coincides with equality over Booleans.</title>
        <p>constant symbol classic [p] : Prf (p ∨ ¬ p);
constant symbol prop_ext [p: El o] [q: El o]: Prf (p ⇔ q) → Prf (p = q);</p>
        <sec id="sec-3-9-1">
          <title>3.4. Translating functions</title>
          <p>We now describe how we reconstruct input problem definitions and an Alethe proof with Carcara. The
translation of Alethe to Lambdapi is built around four functions:
•  maps sorts from Θ  to Σ types,
• ℱ translates terms and formulas to  Π /≡ terms,
•  translates declarations of sorts and functions in Θ  and Θ ℱ into constants in Σ ,
• (1 . . . ) translates a list of commands 1 . . .  of the form . Γ ▷  (ℛ  )[] to typing
judgments Γ ⊢Σ  ∶=  ∶ Prf•( ), where Prf• represents the proof of a clause and will be
introduced in the next section.</p>
        </sec>
      </sec>
      <sec id="sec-3-10">
        <title>In the following we will only present examples of the application of these functions on Listing 1.</title>
        <p>Function  is a mapping function from sort in Θ  to Σ type. Sorts Bool and Int are mapped to
predefined Bool and int types. User sorts such as U or sort predicate (U Bool) are mapped to Set
and Set → Bool respectively.</p>
        <p>The function ℱ is recursively defined on the constructors for Alethe terms and formulas. The logical
connectives of SMT are mapped to the classical operators presented in the previous section. For example,
the formula (or x y (not z)) is translated into the term (x ∨ y ∨ ¬z). Terms are translated
to lambda terms, e.g. (f x y) is translated to f x y. The equality of Alethe noted  ≈  is translated
to  = .</p>
        <p>We translate declarations (declare-sort and declare-fun) to Lambdapi symbols by iterating
over elements in context Θ and using the function . This function creates a constant in the
context Σ for each sort and function declared. To illustrate how context embedding operates, the code
below depicts the translation of sort and function declarations of our guiding example Listing 1. The
context Θ for our example is as follows: Θ  = {, Bool} with  = { ↦ 0, Bool ↦ 0}, Θ ℱ =
{(,  ), (,  ), (,  Bool)}and  the map of sorts arity.</p>
        <p>symbol U : Set;
symbol a : El U ≔ Index 0;
symbol b : El U ≔ Index 1;
symbol p : El (U 〜 Bool) ≔ Index 2;
Remark (assert statement). The assertions at the end of Listing 1 remain untranslated initially, as they
will undergo translation when we process the assume command.</p>
        <sec id="sec-3-10-1">
          <title>3.5. Embedding Clauses</title>
          <p>Before presenting the function , we have to outline the challenge of formalizing the Alethe resolution
rule in  Π /≡. Alethe identifies clause (cl 1, . . . , ) in Equation (1) as a set of literals which can be
interpreted as an -ary disjunction of literals. Following this, an arbitrary clause such as  (1 2 3 4)
will be then translated into 1 ∨ (2 ∨ (3 ∨ 4))by our function ℱ . As mentioned in Section 2, Alethe
identifies clauses that difer only in the order of literals. Therefore, the concatenation of two clauses
(what is happening in the conclusion of resolution) need not unify with the translated clause of the
step given by ℱ . For example, taking 3 arbitrary steps:
. ▷ (cl 1, 2, 3)(..)[..]
. ▷ (cl 2, ¬1, 3)(..)[..]
. ▷ (cl 2, 3, 2, 3)(resolution A B)[(1 true)]</p>
          <p>Considering the interpretation of clause as disjunction we obtain the concatenation as follows ((2 ∨
3) ∨ (2 ∨ 3)) with the conclusion of resolution inference rule traditionally formalized as
 ∨  ; ¬ ∨  ⊢  ∨ . However, the clause in step  will be translated as (2 ∨ (3 ∨ (2 ∨ 3))),
hence we obtain two diferent representations of the clause. Moreover, the pivot ¬1 in step B does
not appear at the head of the clause whereas the inference rule for resolution expects the pivot to be
at the head. Thus, the resolution of clauses makes the structure of clauses involve reasoning modulo
associativity and commutativity. To address the problem of associativity, we provide a structure of
clauses with a canonical representation. We define clauses as lists à la Church:
symbol ⟇_to_∨_rw : Clause → Prop;
rule ⟇_to_∨_rw ($x ⟇ $y) ↪ $x ∨ (⟇_to_∨_rw $y)
with ⟇_to_∨_rw ■ ↪ ⊥;
symbol ++ : Clause → Clause → Clause; // concatenation
rule ■ ++ $m ↪ $m
with ($x ⟇ $l) ++ $m ↪ $x ⟇ ($l ++ $m);
injective symbol Prf• cl ≔ Prf (⟇_to_∨_rw cl); // Proof of clause</p>
          <p>At lines 1 to 3 above we define the Clause type with the two constructors similar to the common
algebraic data type of lists. The rewrite rules ⟇_to_∨_rw at lines 5-7 rewrite a clause into a disjunction
terminating with ⊥ symbolizing the empty list constructor. The symbol ++ defined at lines 9-11 computes
the concatenation of two clauses. To solve the issue of commutativity when Alethe performs a resolution,
we introduce intermediate lemmas of rearrangement of a clause where the pivot is moved, so pivots
appear at the head of the clause. A clause proof will be encoded as a proof of Prf• 1, . . . ,  defined as
a classical proof of disjunctions of literals with a trailing ⊥.</p>
        </sec>
        <sec id="sec-3-10-2">
          <title>3.6. Translation of Alethe proofs</title>
          <p>In the previous sections, we outlined how we embed Alethe logic in  Π /≡ and how we translate the input
problem definitions by using the function . We now provide an overview of how we reconstruct the
commands with function . Informally, the function represents each command .Γ ▷ 1 . . .  (  )[]
as an intermediate lemma Γ ⊢Σ  ∶=  ∶ Prf•(ℱ (1) ⟇ ⋅ ⋅ ⋅ ⟇ ℱ  ⟇ ■ ))where the proof term
 is constructed depending on the rule , the premises  and arguments . For example, if  =
equiv_pos2, we apply our generic proved lemma equiv_pos2∶ Π , Π , ¬( = ) ∨ ¬ ∨  to
produce a proof term for judgment . In the case that  = resolution, we refashion -ary resolution
into a chain of binary resolution steps. To do that, we fold in premises  from left to right, combining
intermediate lemmas to conclude the clause 1 . . .  of step .</p>
          <p>To illustrate the result of our main function , we introduce the translation of Listing 1 proof. In the
code below, all the assume commands are transformed as constants in Σ by the function . They are
treated as axioms and correspond to the asserts of the input problem.</p>
          <p>constant symbol a0 : Prf• (p a ⟇ ■ );
constant symbol a1 : Prf• (a = b ⟇ ■ );
constant symbol a2 : Prf• (¬ p b ⟇ ■ );
opaque symbol qf_unsat_05_predcc : Prf (¬ (p b)) ≔
begin
apply contradiction; assume goal;
have t1 : Prf• ((¬ (((p a) = (p b)))) ⟇ (¬ ((p a))) ⟇ (p b) ⟇ ■ ) { apply equiv_pos2; };
have t2 : Prf• (((p a) = (p b)) ⟇ ■ ) { apply ∨1; apply feq p (Prf• a1); };
have t3 : Prf• ((p b) ⟇ ■ ) {
have t1_t2 : Prf• ((¬ ((p a))) ⟇ (p b) ⟇ ■ ) { apply resolution _ _ _ t1 t2; };
have t1_t2_a0 : Prf• ((p b) ⟇ ■ ) { apply resolution _ _ _ t1_t2 a0; };
refine t1_t2_a0;
};
have t4 : Prf• ■ { have a2_t3 : Prf• ■ { apply resolution _ _ _ a2 t3; }; refine a2_t3;
};
apply t4;
end;</p>
          <p>Each judgment translated as an intermediate lemma Γ ⊢Σ  ∶=  ∶ Prf•(ℱ (1)⟇ ⋅ ⋅ ⋅ ⟇ ℱ ()⟇ ■ ))
generated by  is represented by the tactic have ∶  of Lambdapi that applies the cut rule. We wrap all
the translated steps in a lemma symbol where the last assert is the type and the last step (4 here)
should conclude Prf(⊥) and Prf•■ ≡ Σ Prf⊥. We derive a proof by contradiction because</p>
        </sec>
      </sec>
      <sec id="sec-3-11">
        <title>SMT solvers try to prove that the negation of the formula is unsatisfiable. The goal hypothesis assumed</title>
        <p>line 3 is left unused because we use its equivalent constant a2 coming from the translation of assume
commands by .</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. Soundness of the translation</title>
      <sec id="sec-4-1">
        <title>Intuitively, proving soundness of the translation amounts to showing that for any Alethe judgment ,</title>
        <p>the translation () produces a well-typed proof term whose type corresponds to the clause asserted
by . This is formally expressed by the following theorem.</p>
        <p>Theorem 1 (Soundness). For any Alethe judgment  = . Γ ▷ 1 . . .  (ℛ  )[] the translation ()
produce the typing judgment Γ ⊢Σ  ∶=  ∶ Prf•(ℱ (1) ⟇ ⋅ ⋅ ⋅ ⟇ ℱ () ⟇ ■ ) that is well-typed in
context Γ with the signature context Σ .</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>5. Evaluation</title>
      <p>Our benchmark is composed of files from the SMT-LIB benchmark 1 using the (sub-)logic UFNIA, and
proof obligations from TLAPS SMT backend verifier. TLA + [20] is a language based on set theory and a
linear-time temporal logic for formally specifying and verifying systems, in particular concurrent and
distributed algorithms. Its interactive proof environment TLAPS [21] relies on users guiding the proof
efort, it integrates automatic backends, including SMT solvers to discharge proof obligations [22, 23].</p>
      <p>A particular goal of our development was the reconstruction of TLA+ theorems in Lambdapi. The
Allocator module [24] is a case study for the specification and analysis of reactive systems in TLA +. The</p>
      <sec id="sec-5-1">
        <title>SMT proofs for the individual steps in this case study contain between 20 and 600 steps. The Cantor</title>
      </sec>
      <sec id="sec-5-2">
        <title>1https://smtlib.cs.uiowa.edu/benchmarks.shtml</title>
        <p>Name
Allocator
Cantor
Rodin
TypeSafe</p>
        <p>Logic
UFNIA</p>
        <p>UF
QF_UF
QF_UF
benchmark is the TLAPS proof of Cantor’s theorem that asserts that there is no surjection from any set
to its powerset. The SMT proofs for the corresponding proof obligations contain between 10 and 100
steps. Rodin and TypeSafe are samples from the SMT-LIB benchmark that we can reconstruct. The time
needed for translation to Lambdapi by Carcara is negligibly small in this benchmark. For now, our work
is not able to reconstruct larger samples (up to 70k steps) in Goel, PEQ, or Sledgehammer benchmarks
from SMT-LIB repository because we are facing scalability problems such as high memory consumption
and our Lambdapi checker is running only on a single process. Also, we can not for now benefit from
term sharing because Lambdapi can not create local definitions in a proof, but we intend to implement
this feature. However, we believe that our encoding should be able to reconstruct these proofs if we
can scale because only the volume of steps and the size of terms increase but not the complexity. For
benchmarks using the LIA (sub-)logic, we are currently only reconstructing those proof steps where
arithmetic reasoning does not play an essential role, beyond simplification.</p>
      </sec>
      <sec id="sec-5-3">
        <title>Our work revealed that some proof obligation in Allocator and Cantor failed to be reconstructed, i.e.,</title>
        <p>the proof found by the SMT-solver had become incorrect after elaboration by Carcara. This revealed
multiple bugs in the Carcara checker and proof elaborator that have since been corrected. Moreover,
one reconstruction failure helped to detect that one of the set theory axioms of TLA+ was incorrectly
encoded in SMT, and this issue has also been fixed.</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>6. Conclusion and perspectives</title>
      <sec id="sec-6-1">
        <title>We presented an extension of Carcara to reconstruct Alethe proofs in the foundational proof assistant</title>
      </sec>
      <sec id="sec-6-2">
        <title>Lambdapi. Currently, this extension can reconstruct some SMT proofs that originate from the TLAPS</title>
        <p>proof assistant, as well as some samples from the SMT-lib benchmarks in the UF (sub-)logic. Failure to
reconstruct some proofs revealed bugs in the Carcara checker and in the SMT encoding of set theory in
the TLAPS proof assistant that have since been corrected, thus demonstrating the value of independent
proof checking.</p>
      </sec>
      <sec id="sec-6-3">
        <title>At this point in time, our proof checker is limited to handling relatively small proofs due to scalability</title>
        <p>issues. We plan to address them by following the approach in [25, §4] that translates HOL-Light to</p>
      </sec>
      <sec id="sec-6-4">
        <title>Lambdapi, using multiple processes for parallel proof checking. The idea is to generate individual files</title>
        <p>corresponding to disjoint segments of a proof, compute the dependencies between those segments,
check each file in a separate process, and finally merge all the results. Furthermore, we are restricted
to proofs without arithmetic reasoning. In the future, we intend to support reconstruction for linear
integer arithmetic. Lambdapi does not have a built-in decision procedure for it, but we consider using</p>
      </sec>
      <sec id="sec-6-5">
        <title>Zenon Modulo [26], a tableau-based first-order automated theorem prover that can generate proof certificates in Lambdapi.</title>
      </sec>
      <sec id="sec-6-6">
        <title>A further perspective that we plan to address in future work is to exploit Lambdapi’s capability for</title>
        <p>exporting proofs to other proof assistants that will then be able to benefit from automation through</p>
      </sec>
      <sec id="sec-6-7">
        <title>SMT solving.</title>
        <p>[19] G. Dowek, On the definition of the classical connectives and quantifiers, 2016.</p>
        <p>arXiv:1601.01782.
[20] L. Lamport, Specifying Systems, Addison-Wesley, Boston, Mass., 2002.
[21] D. Cousineau, D. Doligez, L. Lamport, S. Merz, D. Ricketts, H. Vanzetto, TLA+ proofs, in:</p>
      </sec>
      <sec id="sec-6-8">
        <title>D. Giannakopoulou, D. Méry (Eds.), 18th Intl. Symp. Formal Methods (FM 2012), volume 7436 of</title>
        <p>LNCS, Springer, 2012, pp. ‘47–154.
[22] S. Merz, H. Vanzetto, Automatic verification of TLA + proof obligations with SMT solvers, in: Logic
for Programming, Artificial Intelligence, and Reasoning - 18th , LPAR-18, volume 7180 of Lecture
Notes in Computer Science, Springer, 2012, pp. 289–303. doi:10.1007/978-3-642-28717-6\_23.
[23] R. Defourné, Encoding TLA+ proof obligations safely for SMT, in: Rigorous State-Based Methods
- 9th International Conference, ABZ 2023, Nancy, France, May 30 - June 2, 2023, Proceedings,
volume 14010 of Lecture Notes in Computer Science, Springer, 2023, pp. 88–106. URL: https://doi.
org/10.1007/978-3-031-33163-3_7. doi:10.1007/978-3-031-33163-3\_7.
[24] S. Merz, The Specification Language TLA +, in: D. Bjørner, M. Henson (Eds.), Logics of specification
languages, Springer, 2004, pp. 401–452.
[25] F. Blanqui, Translating HOL-Light proofs to Coq, in: 25rd Intl. Conf. Logic for Programming,</p>
      </sec>
      <sec id="sec-6-9">
        <title>Artificial Intelligence and Reasoning (LPAR-25), EPiC Series in Computing, Mauritius, 2024, p. 18</title>
        <p>pages.
[26] D. Delahaye, D. Doligez, F. Gilbert, P. Halmagrand, O. Hermant, Zenon Modulo: When Achilles</p>
      </sec>
      <sec id="sec-6-10">
        <title>Outruns the Tortoise using Deduction Modulo, in: LPAR - Logic for Programming Artificial</title>
      </sec>
      <sec id="sec-6-11">
        <title>Intelligence and Reasoning - 2013, volume 8312 of LNCS, Springer, 2013, pp. 274–290. doi:10.</title>
        <p>1007/978-3-642-45221-5\_20.</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>R.</given-names>
            <surname>Brummayer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Biere</surname>
          </string-name>
          ,
          <article-title>Fuzzing and delta-debugging SMT solvers</article-title>
          ,
          <source>in: Proceedings of the 7th International Workshop on Satisfiability Modulo Theories, SMT '09</source>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>S.</given-names>
            <surname>Böhme</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Weber</surname>
          </string-name>
          ,
          <article-title>Fast LCF-style proof reconstruction for Z3</article-title>
          , in: M. Kaufmann, L. C. Paulson (Eds.),
          <source>First Intl. Conf. Interactive Theorem Proving (ITP</source>
          <year>2010</year>
          ), volume
          <volume>6172</volume>
          <source>of LNCS</source>
          , Springer,
          <year>2010</year>
          , pp.
          <fpage>179</fpage>
          -
          <lpage>194</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>H.-J.</given-names>
            <surname>Schurr</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Fleury</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Desharnais</surname>
          </string-name>
          ,
          <article-title>Reliable reconstruction of fine-grained proofs in a proof assistant</article-title>
          , in: A.
          <string-name>
            <surname>Platzer</surname>
          </string-name>
          , G. Sutclife (Eds.),
          <source>Automated Deduction - CADE 28</source>
          , Springer International Publishing, Cham,
          <year>2021</year>
          , pp.
          <fpage>450</fpage>
          -
          <lpage>467</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>G.</given-names>
            <surname>Hondet</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Blanqui</surname>
          </string-name>
          , The New Rewriting Engine of Dedukti,
          <source>in: 5th International Conference on Formal Structures for Computation and Deduction (FSCD</source>
          <year>2020</year>
          ), volume
          <volume>167</volume>
          of Leibniz International Proceedings in Informatics (LIPIcs),
          <source>Schloss Dagstuhl - Leibniz-Zentrum für Informatik</source>
          ,
          <year>2020</year>
          , pp.
          <volume>35</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>35</lpage>
          :
          <fpage>16</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>B.</given-names>
            <surname>Andreotti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Lachnitt</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Barbosa</surname>
          </string-name>
          ,
          <string-name>
            <surname>Carcara:</surname>
          </string-name>
          <article-title>An eficient proof checker and elaborator for SMT proofs in the Alethe format</article-title>
          ,
          <source>in: Tools and Algorithms for the Construction and Analysis of Systems: 29th International Conference, TACAS 2023</source>
          , Springer-Verlag,
          <year>2023</year>
          , p.
          <fpage>367</fpage>
          -
          <lpage>386</lpage>
          . URL: https://doi.org/10.1007/978-3-
          <fpage>031</fpage>
          -30823-9_
          <fpage>19</fpage>
          . doi:
          <volume>10</volume>
          .1007/978-3-
          <fpage>031</fpage>
          -30823-9_
          <fpage>19</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>H.</given-names>
            <surname>Barbosa</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Reynolds</surname>
          </string-name>
          , G. Kremer,
          <string-name>
            <given-names>H.</given-names>
            <surname>Lachnitt</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Niemetz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Nötzli</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Ozdemir</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Preiner</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Viswanathan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Viteri</surname>
          </string-name>
          , et al.,
          <article-title>Flexible proof production in an industrial-strength SMT solver</article-title>
          ,
          <source>in: International Joint Conference on Automated Reasoning</source>
          , Springer International Publishing Cham,
          <year>2022</year>
          , pp.
          <fpage>15</fpage>
          -
          <lpage>35</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>J. C.</given-names>
            <surname>Blanchette</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Böhme</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L. C.</given-names>
            <surname>Paulson</surname>
          </string-name>
          ,
          <article-title>Extending Sledgehammer with SMT solvers</article-title>
          , in: N.
          <string-name>
            <given-names>S.</given-names>
            <surname>Bjørner</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Sofronie-Stokkermans</surname>
          </string-name>
          (Eds.),
          <source>23rd Intl. Conf. Automated Deduction (CADE-23)</source>
          , volume
          <volume>6803</volume>
          <source>of LNCS</source>
          , Springer, Wroclaw, Poland,
          <year>2011</year>
          , pp.
          <fpage>116</fpage>
          -
          <lpage>130</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>Ł.</given-names>
            <surname>Czajka</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Kaliszyk</surname>
          </string-name>
          ,
          <article-title>Hammer for Coq: Automation for dependent type theory</article-title>
          ,
          <source>Journal of Automated Reasoning</source>
          <volume>61</volume>
          (
          <year>2018</year>
          )
          <fpage>423</fpage>
          -
          <lpage>453</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>L.</given-names>
            <surname>Czajka</surname>
          </string-name>
          ,
          <article-title>A Shallow Embedding of Pure Type Systems into First-Order Logic</article-title>
          ,
          <source>in: 22nd International Conference on Types for Proofs and Programs (TYPES</source>
          <year>2016</year>
          ), volume
          <volume>97</volume>
          <source>of Leibniz International Proceedings in Informatics (LIPIcs)</source>
          ,
          <year>2018</year>
          , pp.
          <volume>9</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>9</lpage>
          :
          <fpage>39</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>H.</given-names>
            <surname>Barbosa</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. C.</given-names>
            <surname>Blanchette</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Fleury</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Fontaine</surname>
          </string-name>
          ,
          <article-title>Scalable fine-grained proofs for formula processing</article-title>
          ,
          <source>Journal of Automated Reasoning</source>
          <volume>64</volume>
          (
          <year>2020</year>
          )
          <fpage>485</fpage>
          -
          <lpage>510</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>M.</given-names>
            <surname>Armand</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Faure</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Grégoire</surname>
          </string-name>
          , C. Keller, L. Thery,
          <string-name>
            <given-names>B.</given-names>
            <surname>Werner</surname>
          </string-name>
          ,
          <article-title>A Modular Integration of SAT/SMT Solvers to Coq through Proof Witnesses</article-title>
          , in: Jouannaud,
          <string-name>
            <surname>Jean-Pierre</surname>
          </string-name>
          , Shao, Zhong (Eds.),
          <source>First Intl. Conf. Certified Programs and Proofs (CPP</source>
          <year>2011</year>
          ), volume
          <volume>7086</volume>
          <source>of LNCS</source>
          , Springer, Lenting, Taiwan,
          <year>2011</year>
          , pp.
          <fpage>135</fpage>
          -
          <lpage>150</lpage>
          . doi:
          <volume>10</volume>
          .1007/978-3-
          <fpage>642</fpage>
          -25379-9\_
          <fpage>12</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>F.</given-names>
            <surname>Besson</surname>
          </string-name>
          ,
          <article-title>Fast reflexive arithmetic tactics the linear case and beyond</article-title>
          , in: T. Altenkirch,
          <string-name>
            <surname>C.</surname>
          </string-name>
          <article-title>McBride (Eds</article-title>
          .),
          <source>Intl. Workshop Types for Proofs and Programs (TYPES</source>
          <year>2006</year>
          ), LNCS, Springer,
          <year>2006</year>
          , pp.
          <fpage>48</fpage>
          -
          <lpage>62</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>H.</given-names>
            <surname>Barbosa</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Fleury</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Fontaine</surname>
          </string-name>
          , H.
          <article-title>-</article-title>
          <string-name>
            <surname>J. Schurr</surname>
          </string-name>
          ,
          <source>The Alethe Proof Format An Evolving Specification and Reference</source>
          ,
          <year>2024</year>
          . https://verit.gitlabpages.uliege.be/alethe/specification.pdf.
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>C.</given-names>
            <surname>Barrett</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Fontaine</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Tinelli</surname>
          </string-name>
          ,
          <source>The SMT-LIB Standard: Version 2</source>
          .6,
          <string-name>
            <surname>Technical</surname>
            <given-names>Report</given-names>
          </string-name>
          , Department of Computer Science, The University of Iowa,
          <year>2017</year>
          . URL: https://smtlib.cs.uiowa.edu/papers/ smt-lib
          <source>-reference-v2</source>
          .
          <fpage>6</fpage>
          -r2021-
          <fpage>05</fpage>
          -12.pdf, available at www.
          <source>SMT-LIB.org.</source>
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>D.</given-names>
            <surname>Cousineau</surname>
          </string-name>
          , G. Dowek,
          <article-title>Embedding pure type systems in the Lambda-Pi-Calculus Modulo</article-title>
          ,
          <source>in: Typed Lambda Calculi and Applications</source>
          , Springer, Berlin, Heidelberg,
          <year>2007</year>
          , pp.
          <fpage>102</fpage>
          -
          <lpage>117</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [16]
          <string-name>
            <given-names>R.</given-names>
            <surname>Harper</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Honsell</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. D.</given-names>
            <surname>Plotkin</surname>
          </string-name>
          ,
          <article-title>A framework for defining logics</article-title>
          ,
          <source>J. ACM</source>
          <volume>40</volume>
          (
          <year>1993</year>
          )
          <fpage>143</fpage>
          -
          <lpage>184</lpage>
          . URL: https://api.semanticscholar.org/CorpusID:13375103.
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          [17]
          <string-name>
            <given-names>F.</given-names>
            <surname>Blanqui</surname>
          </string-name>
          ,
          <article-title>Type Safety of Rewrite Rules in Dependent Types</article-title>
          ,
          <source>in: 5th International Conference on Formal Structures for Computation and Deduction (FSCD</source>
          <year>2020</year>
          ), volume
          <volume>167</volume>
          <source>of Leibniz International Proceedings in Informatics (LIPIcs)</source>
          ,
          <year>2020</year>
          , pp.
          <volume>13</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>13</lpage>
          :
          <fpage>14</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          [18]
          <string-name>
            <given-names>P.</given-names>
            <surname>Martin-Löf</surname>
          </string-name>
          ,
          <article-title>Intuitionistic Type Theory, volume 1 of Studies in proof theory</article-title>
          ,
          <source>Bibliopolis</source>
          ,
          <year>1980</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>