Extensional Higher-Order Paramodulation in Leo-III
Alexander Steen Christoph Benzmüller
cs.AI cs.LO cs.SC math.LO 03B35, 03B15, 03B45, 68T15, 68T27, 68T30, 03Bxx I.2.3; F.4.1; I.2.4












A. Steen https://orcid.org/0000-0001-8781-9462[0000-0001-8781-9462] University of Luxembourg, FSTC,
              Esch-sur-Alzette, Luxembourg.

              
              alexander.steen@uni.lu
           C. Benzmüller https://orcid.org/0000-0002-3392-3093[0000-0002-3392-3093] Freie Universität Berlin, Dep. of Mathematics and Computer Science, Berlin, Germany, and

              University of Luxembourg, FSTC, Esch-sur-Alzette, Luxembourg.

              c.benzmueller@fu-berlin.de








Extensional Higher-Order Paramodulation in Leo-IIIThis work has
been supported by the DFG under grant BE 2501/11-1 (Leo-III) and by
the Volkswagenstiftung (”Consistent Rational Argumentation in Politics”).
    Alexander SteenChristoph Benzmüller

    , 
=============================================================================================================================================================================================================




Leo-III is an automated theorem prover for extensional type theory
with Henkin semantics and choice. Reasoning with primitive equality
is enabled by adapting paramodulation-based proof search to
higher-order logic. The prover may cooperate with multiple external
specialist reasoning systems such as first-order provers and SMT
solvers. Leo-III is compatible with the TPTP/TSTP
framework for input formats, reporting results and proofs,
and standardized communication between reasoning systems,
enabling e.g. proof reconstruction from within proof assistants
such as Isabelle/HOL.

Leo-III supports reasoning in polymorphic first-order and higher-order
logic, in many quantified normal modal logics, as well as in
different deontic logics.
Its development had initiated the ongoing extension of the TPTP
infrastructure to reasoning within non-classical logics.



Keywords Higher-Order Logic Henkin Semantics Extensionality
Leo-III
Equational Reasoning Automated Theorem Proving Non-Classical Logics
Quantified Modal Logics










§ INTRODUCTION
 


Leo-III is an automated theorem prover (ATP) for classical higher-order logic (HOL)
with Henkin semantics and choice. In contrast to its predecessors,
LEO and LEO-II <cit.>,
that were based on resolution proof search, Leo-III implements a higher-order
paramodulation calculus, which aims at improved performance for equational reasoning <cit.>.
In the tradition of the Leo prover family, Leo-III collaborates with external reasoning
systems, in particular, with first-order ATP systems, such as E <cit.>,
iProver <cit.> and Vampire <cit.>,
and with SMT solvers such as CVC4 <cit.>.
Cooperation is not restricted to first-order systems, and further specialized systems such as
higher-order (counter-)model finders may be utilized by Leo-III.

Leo-III accepts all common TPTP dialects <cit.>
as well as their recent extensions to polymorphic types <cit.>.
During the development of Leo-III, careful attention has been paid to providing maximal
compatibility with existing systems and conventions of the peer community, especially
to those of the TPTP infrastructure.
The prover returns results according to the standardized TPTP SZS ontology,
and it additionally produces verifiable TPTP-compatible proof certificates
for each proof that it finds.


The predecessor systems LEO and LEO-II
pioneered the area of cooperative resolution-based theorem proving for Henkin semantics.
LEO (or LEO-I) was designed as an ATP component of the
proof assistant and proof planner ΩMEGA <cit.>
and hard-wired to it.







Its successor, LEO-II, is a stand-alone HOL ATP system based on
Resolution by Unification and Extensionality (RUE) <cit.>,
and it supports reasoning with primitive equality.



The most recent incarnation of the Leo prover family, Leo-III,
comes with improved reasoning performance in particular for equational problems, and with a more flexible
and effective architecture for cooperation with external specialists.[
Note the different capitalization of Leo-III as opposed to LEO-I and LEO-II. This is motivated
by the fact that Leo-III is designed to be a general purpose system rather than a subcomponent
to another system. Hence, the original capitalization derived from the phrase
”Logical Engine for Omega” (LEO) is not continued.
]
Reasoning in higher-order quantified non-classical logics, including many normal modal logics,
and different versions of deontic logic is enabled by an integrated
shallow semantical embedding approach <cit.>.
In contrast to other HOL ATP systems, including LEO-II, 
for which it was necessary for the user to manually conduct the tedious and error-prone
encoding procedure before passing it to the prover, Leo-III is the first
ATP system to include a rich library of these embeddings, transparent
to the user <cit.>.
These broad logic competencies make Leo-III, up to the authors' knowledge,
the most widely applicable ATP system
for propositional and quantified, classical and non-classical logics 
available to date.
This work has also stimulated the currently ongoing extension of
the TPTP library to non-classical reasoning.[
See <http://tptp.org/TPTP/Proposals/LogicSpecification.html>.
]


Leo-III is implemented in Scala and its source code, and that of related projects presented
in this article, is publicly available under BSD-3 license on GitHub.[
    See the individual projects related to the Leo prover family
    at <https://github.com/leoprover>. Further information are available at 
    <http://inf.fu-berlin.de/ lex/leo3>.
]
Installing Leo-III does not require any special libraries, apart from a reasonably
current version of the JDK and Scala. Also, Leo-III is readily available via
the SystemOnTPTP web interface <cit.>, and
it can be called via Sledgehammer <cit.>,
from the interactive proof assistant Isabelle/HOL <cit.>
for automatically discharging user's proof goals.

In a recent evaluation study of 19 different first-order and higher-order ATP
systems, Leo-III was found the most versatile (in terms of supported
logic formalisms) and best performing ATP system overall <cit.>.


This article presents a consolidated summary of previous conference and workshop
contributions <cit.>
as well as contributions from the first author's PhD thesis <cit.>.

It is structured as follows: <ref> briefly introduces HOL and 
summarizes challenging automation aspects. In <ref> the basic paramodulation
calculus that is extended by Leo-III is presented, and practically
motivated extensions that are implemented in the prover are outlined. Subsequently,
the implementation of Leo-III is described in more detail in <ref>,
and <ref> presents the technology that enables Leo-III to reason
in various non-classical logics. An evaluation of Leo-III on a heterogeneous
set of benchmarks, including problems in non-classical logics,
is presented in <ref>.
Finally, <ref> concludes this article and sketches further work.








§ HIGHER-ORDER THEOREM PROVING

The term higher-order logic refers to expressive logical formalisms that allow
for quantification over predicate and function variables; such a logic
was first studied by Frege in the 1870s <cit.>.
An alternative and more handy formulation was proposed by Church
in the 1940s <cit.>.
He defined a higher-order logic on 
top of the simply typed λ-calculus.
His particular formalism,
referred to as Simple Type Theory (STT), was later further studied and refined
by Henkin <cit.>,
Andrews <cit.>
and others <cit.>.
In the remainder, the term HOL is used synonymously to Henkin's Extensional Type Theory
(ExTT) <cit.>; it constitutes the foundation of many contemporary
higher-order automated reasoning systems.
HOL provides lambda-notation as an
elegant and useful means to denote unnamed functions, predicates and
sets (by their characteristic functions), and it comes with built-in principles
of Boolean and functional extensionality as well as type-restricted comprehension.

A more in-depth presentation of HOL, its historical development, metatheory and
automation is provided by Benzmüller and Miller <cit.>.



  
Syntax and Semantics.
HOL is a typed logic; every term of HOL is associated a fixed and unique type, written
as subscript. 
The set  of simple types is freely generated from a non-empty set S
of sort symbols (base types) and juxtaposition ντ of two types τ,ν∈,
the latter
denoting the type of functions from objects of type τ to objects of type ν.
Function types are assumed to associate to the left and parentheses may be dropped if
consistent with the intended reading.
The base types are usually chosen to be S := {ι, o},
where ι and o represent the type of individuals and the type of Boolean truth values,
respectively.

Let Σ be a typed signature and let  denote a set of typed variable symbols
such that there exist infinitely many variables for each type. Following
Andrews <cit.>, it is assumed that the only primitive logical
connective is equality, denoted =^τ_oττ∈Σ, for each type τ∈ (called Q
by Andrews).
In the extensional setting of HOL, all remaining logical connectives such as disjunction _ooo,
conjunction _ooo, negation _oo, etc., can be defined in terms of them.
The terms of HOL are given by the following abstract syntax (where τ,ν∈ are types):

    s,t ::= c_τ∈Σ  |   X_τ∈  |  (λ X_τ.  s_ν)_ντ  |  (s_ντ  t_τ)_ν

The terms are called constants, variables, abstractions
and applications, respectively. 
Application is assumed to associate to the left and parentheses may again be dropped whenever possible.
Conventionally, vector notation
f_ντ^n ⋯τ^1 t^i_τ^i is used to abbreviate
nested applications (f_ντ^n ⋯τ^1  t^1_τ^1 ⋯  t^n_τ^n),
where f is a function term and the t^i, 1 ≤ i ≤ n, are argument terms
of appropriate types.
The type of a term may be dropped for legibility reasons if obvious from the context.
Notions such as α-, β-, and η-conversion, denoted
⟶_⋆, for ⋆∈{α, β, η},
free variables (.) of a term, etc., are
defined as usual <cit.>. 
The notion s{t/X} is used to denote the (capture-free) substitution 
of variable X by term t in s.
Syntactical equality between HOL terms, denoted ≡_⋆,
for ⋆⊆{α, β, η}, is defined with respect to the assumed
underlying conversion rules.
Terms s_o of type o are formulas, and they are sentences if they are
closed. By convention, infix notation for fully applied logical connectives 
is used, e.g. s_o  t_o instead of (_ooo  s_o)   t_o.
 
As a consequence of Gödel's Incompleteness Theorem, HOL with standard semantics
is necessarily incomplete. In contrast, theorem proving in HOL is usually considered with respect
to so-called general semantics (or Henkin semantics) in which a meaningful notion of
completeness can be achieved <cit.>. 
The usual notions of general model structures, validity in these structures and related notions
are assumed in the following. Note that we do not assume that the general model structures
validate choice.
Intensional models have been described by Muskens <cit.>
and studies of further general notions of semantics have been presented by
Andrews <cit.> and
Benzmüller et al. <cit.>.



  
Challenges to HOL Automation.

HOL validates functional and Boolean extensionality principles,
referred to as EXT^ντ and EXT^o.
These principles
can be formulated within HOL's term language as

    EXT^ντ   := ∀ F_ντ. ∀ G_ντ. (∀ X_τ. F   X =^ν G   X) ⇒ F =^ντ G
    EXT^o   := ∀ P_o. ∀ Q_o. (P ⇔ Q) ⇒ P =^o Q

These principles state that two functions are equal if they correspond on every argument,
and that two formulas are equal if they are equivalent
(where ⇔_ooo denotes equivalence), respectively.
Using these principles, one can infer that two functions such as λ P_o.
and λ P_o.  P  P are in fact equal (where  denotes syntactical truth),
and that (λ P_o. λ Q_o. P  Q) = (λ P_o. λ Q_o.  Q  P)
is a theorem. 
Boolean Extensionality, in particular, poses a considerable challenge for HOL automation:
Two terms may be equal,
and thus subject to generating inferences, if 
the equivalence of all Boolean-typed subterms can be inferred. As a consequence,
a complete implementation of
non-ground proof calculi that make use of higher-order unification procedures
cannot simply use syntactical unification for locally deciding which inferences
are to be generated. 
In contrast to first-order theorem proving, it is hence
necessary to interleave syntactical unification and (semantical) proof search, which is
more difficult to control in practice.

As a further complication, higher-order unification is only semi-decidable and not
unitary <cit.>.
It is not clear how many and which unifiers produced by a higher-order unification routine should
be chosen during proof search, and the unification procedure may never terminate on non-unifiable
terms.

In the context of first-order logic with equality, 
superposition-based calculi have proven
an effective basis for reasoning systems and provide a powerful notion of redundancy <cit.>.





Reasoning with equality can also be addressed, e.g., by an RUE resolution
approach <cit.> and, in the higher-order case,
by reducing equality to equivalent formulas not containing
the equality predicate <cit.>, as done in LEO.
The latter approaches however lack effectivity in practical applications
of large scale equality reasoning.

There are further practical challenges as there are only few implementation techniques
available for efficient data structures and indexing methods.
This hampers the effectivity of HOL reasoning systems and their application in practice.



  
HOL ATP Systems. Next to the LEO prover family <cit.>, there
are further HOL ATP systems available: This includes
TPS <cit.> as one of the earliest systems,
as well as Satallax <cit.>,
coqATP <cit.>, agsyHOL <cit.>
and the higher-order (counter)model finder Nitpick <cit.>.
Additionally, there is ongoing work on extending the first-order theorem prover Vampire
to full higher-order reasoning <cit.>,
and some interactive proof assistants
such as Isabelle/HOL <cit.> can also be used for
automated reasoning in HOL. 
Further related systems include higher-order extensions
of SMT solvers <cit.>, and there is ongoing work
to lift first-order ATP systems based on superposition to fragments of HOL, 
including E <cit.>
and Zipperposition <cit.>.

Further notable higher-order reasoning systems include proof assistants such as 
PVS <cit.>, Isabelle/HOL, the HOL prover family including HOL4 <cit.>,
and the HOL Light system <cit.>. In contrast to ATP systems, proof assistants
do not finds proofs automatically but are rather used to formalize and verify hand-written proofs for
correctness.



  
Applications.
The expressivity of higher-order logic has been exploited
for encoding various expressive non-classical logics within HOL.
Semantical embeddings of, among others, higher-order modal
logics <cit.>,
conditional logics <cit.>,
many-valued logics <cit.>, deontic logic <cit.>,
free logics <cit.>, and combinations
of such logics <cit.> can be used to
automate reasoning within those logics
using ATP systems for classical HOL.
A prominent result from the applications of automated reasoning in non-classical
logics, here in quantified modal logics, was the detection of a major flaw
in Gödel's Ontological Argument <cit.>
as well as the verification of Scott's variant of that argument <cit.>
using LEO-II and Isabelle/HOL.
Similar and further enhanced techniques were used to assess
foundational questions in metaphysics <cit.>. 

Additionally, Isabelle/HOL and the Nitpick system were used
to assess the correctness of concurrent C++ programs against
a previously formalized memory model <cit.>.
The higher-order proof assistant HOL Light
played a key role in the verification of
Kepler's conjecture within the
Flyspeck project <cit.>.
  






§ EXTENSIONAL HIGHER-ORDER PARAMODULATION
 
Leo-III is a refutational ATP system. The initial, possibly empty, set of axioms and
the negated conjecture are transformed into an equisatisfiable set of formulas
in clause normal form (CNF), which is then iteratively saturated
until the empty clause is found.
Leo-III extends the complete, paramodulation-based calculus  for HOL
(cf. <ref>) with practically motivated, partly heuristic inference
rules.
Paramodulation extends resolution by a native treatment of equality at the calculus level.
In the context of first-order logic, it was developed in the late 1960s by G. Robinson and
L. Wos <cit.>
as an attempt to overcome the shortcomings of resolution-based approaches 
to handling equality. A paramodulation inference
incorporates the principle of replacing equals by equals and can
be regarded as a speculative conditional rewriting step.
In the context of first-order theorem proving, superposition-based calculi
<cit.>
improve the naive paramodulation approach by imposing ordering restrictions on the
inference rules such that only a relevant subset of all possible inferences are generated.
However, due to the more complex structure of the term language of HOL,
there do not exist suitable term orderings that allow a straightforward adaption
of this approach to the higher-order setting.[
  As a simple counterexample, consider a (strict) term ordering ≻ for HOL terms
  that satisfies the usual properties from first-order superposition (e.g.,
  the subterm property) and is compatible with β-reduction. For
  any nonempty signature Σ, c∈Σ, the chain 
  c≡_β (λ X. c)  c≻c
  can be constructed, implying c≻c and thus contradicting irreflexivity of ≻.
  Note that (λ X. c)  c≻c
  since the right-hand side is a proper subterm of the left-hand side
  (assuming an adequately lifted definition of subterm property to HO terms).
] However, there is recent work to overcome this situation by relaxing 
restrictions on the employed orderings <cit.>.



 §.§ The EP Calculus

Higher-order paramodulation for extensional type theory was first presented by
Benzmüller <cit.>.
This calculus was mainly theoretically motivated and extended a resolution calculus with a
paramodulation rule instead of being based on a paramodulation rule alone. Additionally,
that calculus contained a rule that expanded equality literals
by their definition due to Leibniz.[
  The Identity of Indiscernibles (also known as Leibniz's law) refers to a principle
  first formulated
  by Gottfried Leibniz in the context of theoretical philosophy <cit.>.
  The principle states that if two objects X and Y coincide on every property P,
  then they are equal,
  i.e. ∀ X_τ. ∀ Y_τ. (∀ P_oτ. P   X ⇔ P   Y) ⇒ X = Y,
  where ”=”
  denotes the desired equality predicate.
  Since this principle can easily be formulated in HOL, it is possible
    to encode equality in higher-order logic without using the primitive equality
    predicate. An extensive analysis of the intricate differences between
    primitive equality and defined notions of equality is presented by
    Benzmüller et al. <cit.> to which the authors refer for further details.
]
As Leibniz equality formulas effectively enable
cut-simulation <cit.>, the proposed calculus seems unsuited for automation.
The calculus  presented in the following, in contrast, avoids the expansion of equality predicates but
adapts the use of dedicated calculus rules for extensionality principles from Benzmüller <cit.>.

An equation, denoted s ≃ t, is a pair of HOL terms of the same type,
where ≃ is assumed to be symmetric (i.e., s ≃ t represents
both s ≃ t and t ≃ s).
A literal ℓ is a signed equation, written [s ≃ t]^α,
where α∈{,} is the polarity of ℓ.
Literals of form [s_o]^α are shorthand for [s_o ≃]^α, and
negative literals [s ≃ t]^ are also referred to as unification constraints.
A negative literal ℓ is called a flex-flex unification constraint
if ℓ is of the
form [X  s^i≃ Y  t^j]^,
where X,Y are variables.
A clause C is a multiset of literals, denoting its disjunction.
For brevity, if C,D are 
clauses and ℓ is a literal, Cℓ
and CD denote the multi-union 
C∪{ℓ} and C∪D, respectively.
s|_π is the subterm of s at position π, and s[r]_π denotes the term
that is obtained by replacing the subterm of s at position π
by r; α-conversion is applied implicitly whenever necessary to avoid variable
capture.

The  calculus can be divided into four groups of inference rules:

  
  Clause normalization.
    The clausification rules of  are mostly standard, cf. Fig. <ref>. Every
    non-normal clause is transformed into an equisatisfiable set of clauses in CNF.
    Multiple conclusions are written one below the other. 
    Note that the clausification rules are proper inference rules rather than a dedicated
    meta operation. This is due to the fact that non-CNF clauses may be generated from
    the application of the remaining inferences rules, hence renormalization during
    proof search may be necessary. 
    In the following we use  to refer to the entirety of the CNF rules.
    
    For the elimination of existential quantifiers, see rule (CNFExists) in
    Fig. <ref>,
    the sound Skolemization technique
    of Miller <cit.> is assumed.
  
  Primary inferences.
    The primary inference rules of EP are paramodulation (Para),
    equality factoring (EqFac) and primitive substitution (PS),
    cf. Fig. <ref>.

    
    
    
    The paramodulation rule (Para) replaces subterms of literals within clauses
    by (potentially) equal terms given from a positive equality literal. Since the latter
    clause might not be a unit clause, the rewriting step can be considered conditional
    where the remaining literals represent the respective additional conditions.
    Factorization  contracts two literals that are semantically overlapping (i.e., 
    one is more general than the other) but not
    syntactically equal. This reduces the size of the clause, given that the unification
    of the respective two literals is successful.
    These two rules introduce unification constraints that are encoded as negative
    equality literals:
    A generating inference is semantically justified
    if the unification constraint(s) can be solved. Since higher-order unification is not decidable,
    these constraints are explicitly encoded into the result clause for subsequent analysis.
    Note that a resolution inference between clauses C≡C^' [p]^
    and D≡D^' [p]^ 
    can be simulated by the (Para) rule as the literals [p]^α are actually shorthands
    for [p ≃]^α and the clause [≃]^C^'D^' [p ≃ p]^, which eventually simplifies
    to C^'D^', is generated. 
    
    
    Moreover, note that both (Para) and (EqFac) are unordered and produce numerous redundant
    clauses. In practice, Leo-III tries to remedy this situation by using
    heuristics to restrict the number of generated clauses,
    including a higher-order term ordering, cf. <ref>. Such heuristics, e.g.,
    prevent redundant paramodulation inferences between positive propositional literals 
    in clauses C [p]^ and D [q]^.
    
    
    

    The primitive substitution inference  approximates the logical structure of literals
    with flexible heads. In contrast to early attempts that blindly guessed a concrete
    instance of head variables,  uses so-called general bindings,
    denoted 𝒢ℬ_τ^t <cit.>,
    to step-wise approximate the instantiated term structure and hence limit the 
    explosive growth of primitive substitution. Nevertheless,  still
    enumerates the whole universe of terms but, in practical applications,
    often few applications of the rule are sufficient to find a refutation.
    An example where
    primitive substitution is necessary is the following: Consider a clause C
    given by C≡ [P_o]^ where P is a Boolean variable. This clause
    corresponds to the formula ∀ P_o.  P which is clearly not a theorem.
    Neither  nor  or any other calculus rules presented so far or further below
    (except for ) allow to construct a derivation to the empty clause. However,
    using , there exists a derivation
    [P]^⊢_, [ P^']^⊢_CNFNeg [P^']^. 
    Note that { P^'/P} is a substitution applying a
    general binding from 𝒢ℬ_o^{, }∪{Π^τ, =^τ | τ∈} that approximates logical negation. Now, a simple refutation
    involving [P]^ and [P^']^ can be found.
    

    
  
  Extensionality rules.
    The rules (NBE) and (PBE) – for negative resp. positive Boolean extensionality –
    as well as (NFE) and (PFE) – for negative resp. positive functional extensionality –
    are the extensionality rules of , cf. Fig. <ref>.
    
    While the functional extensionality rules gradually ground the literals to base types
    and provide witnesses for the (in-)equality of function symbols to the search space,
    the Boolean extensionality rules enable the application of clausification
    rules to the Boolean-typed sides of the literal, thereby lifting them into
    semantical proof search.
    These rules eliminate the need for explicit
    extensionality axioms in the search space, which would
    enable cut-simulation <cit.> and hence drastically hamper proof search.
  
  Unification.
    The unification rules of  are a variant of
    Huet's unification rules and presented in Fig. <ref>.
    They can be eagerly applied to the unification constraints in clauses. In an extensional
    setting, syntactical search for unifiers and
    semantical proof search coincide, and unification transformations are regarded proper
    calculus rules.
    As a result, the unification rules might only partly solve
    (i.e., simplify) unification constraints and unification constraints themselves are
    eligible to subsequent inferences. The bundled unification rules are referred to
    as .





A set Φ of sentences has a refutation in , denoted
Φ⊢□, iff the empty clause can be derived in .
A clause is the empty clause, written ,
if it contains no or only
flex-flex unification constraints.
This is motivated
by the fact that flex-flex unification problems can always be solved,
and hence any clause consisting of only
flex-flex constraints is necessarily unsatisfiable <cit.>.





EP is sound and refutationally complete for HOL with Henkin semantics.


Soundness is guaranteed by <cit.>.
For completeness, the following argument is used 
(cf. <cit.> for the detailed
definitions and notions):
By <cit.> the set of sentences that cannot be refuted in is an abstract consistency class <cit.>, and by <cit.>
this abstract consistency class can be
extended to a Hintikka set.
The existence of a Henkin model that satisfies this Hintikka set is guaranteed 
by <cit.>.


An example for a refutation in EP is given in the following:

[Cantor's Theorem]
Cantor's Theorem states that, given a set A, the power set of A
has a strictly greater cardinality than A itself.
The core argument of the proof can be formalized as follows:

    ∃ f_oιι. ∀ Y_oι. ∃ X_ι.  f X = Y
      𝐂

Formula <ref> states that there exists no surjective function f from a set
to its power set.        
A proof of <ref> in EP makes use of
functional extensionality, Boolean extensionality, primitive substitution
as well as nontrivial higher-order pre-unification; it is given below.

By convention,
the application of a calculus rule (or of a compound rule) is stated with the respective
premise clauses enclosed in parentheses after the rule name. For rule ,
the second argument describes which general binding was used for the instantiation; e.g.,
(C, τt) denotes an instantiation
with an approximation of term t for goal type τ.[The set τt of
  approximating/partial bindings parametric to a type
  τ = βα^n…α^1 (for n≥ 0) and to a
  constant t of type βγ^m…γ^1 (for m≥ 0)
  is defined as follows (for further details see also <cit.>): Given
  a “name” k (where a name is either a constant or a variable)
  of type βγ^m…γ^1, the term l having form
  λX^1_α^1. …λ X^n_α^n. (k r^1…r^m) is a
  partial binding of type βα^n…α^1 and head
  k. Each r^i ≤ m has form H^i X^1_α^1… X^n_α^n
  where H^i≤ m are fresh variables typed
  γ^i≤ mα^n…α^1.  Projection bindings
  are partial bindings whose head k is one of X^i≤ l.
  Imitation bindings are partial bindings whose head k is
  identical to the given constant symbol t in the superscript of
  τt.
  τt is the set of all
  projection and imitation bindings modulo type
  τ and constant t. In our example derivation we twice use 
  imitation bindings of form λ X_ι. (H_oι X_ι) from oι.]
        =2.5pt
        
    [                                                                               (<ref>)                                                              C_1  [^1   (^2  ^1)≃^1]^;                                                                                 (C_1)                                                     C_2  [^1   (^2  ^1)  ^2 ≃^1  ^2]^;                                                                                 (C_2)                   C_3  [^1   (^2  ^1)  ^2]^
                                    [^1  ^2]^;                                                                                                       C_4  [^1   (^2  ^3)  ^4]^
                                      [^3  ^4]^;                                                                            (C_3, oι),   C_5  [^1  (^2   (λ Z_ι.  (^5   Z)))  ^2]^
                                    [^5  ^2]^;                                                                            (C_4, oι), C_6  [^1  (^2   (λ Z_ι.  (^6   Z)))  ^4]^
                                      [^6  ^4]^;                                                                                (C_5),                    C_7  [^1  (^2  λ Z_ι.  (^1   Z   Z))  (^2  λ Z_ι.  (^1   Z   Z))]^;                                                                                (C_6),                    C_8  [^1  (^2  λ Z_ι.  (^1   Z   Z))  (^2  λ Z_ι.  (^1   Z   Z))]^;                                                                           (C_7, C_8),                                                                                       ]

        

The Skolem symbols ^1 and ^2 used in the above proof have type
oιι and ι(oι), respectively and the ^i denote fresh free variables
of appropriate type.
A unifier σ_C_7 generated by  for producing C_7 is
given by (analogously for C_8):

    σ_C_7≡{^2  (λ Z_ι.  (^1   Z   Z))/^2,
        (λ Z_ι. ^1   Z   Z)/^5
      }

Note that, together with the substitution
σ_C_3≡{λ Z_ι.  (^5   Z) / ^1}
generated by approximating
_oo via  on C_3, the free variable ^1
in C_1 is instantiated
by σ_C_7∘σ_C_3(^1) ≡λ Z_ι.  (^1   Z   Z).
Intuitively, this instantiation encodes the diagonal set of ^1,
given by {x | x ∉^1(x) }, as used in the traditional proofs of Cantor's Theorem;
see, e.g., Andrews <cit.>.

The TSTP representation of Leo-III's proof for this problem is presented in Fig. <ref>.




 §.§ Extended Calculus

As indicated further above, Leo-III targets automation of HOL with Henkin semantics and choice.
The calculus EP from <ref>, however, does not address choice. To this end,
Leo-III implements several additional calculus rules that either accommodate further reasoning
capabilities (e.g.  reasoning with choice) or address the inevitable explosive growth of the search
space during proof search (e.g.  simplification routines).
The latter kind of rules are practically motivated, partly heuristic, and hence primarily
target technical issues that complicate effective automation in practice. Note that no completeness claims
are made for the extended calculus with respect to HOL with choice. Furthermore, some of the below
features of Leo-III are unsound with respect to HOL without choice. Since, however, Leo-III is designed
as a prover for HOL with choice, this is not a concern here.

The additional rules address the follows aspects (see an earlier
paper <cit.> and Steen's doctoral thesis <cit.>
for details and examples):





  
  Improved clausification.
    Leo-III employs definitional clausification <cit.>
    to reduce the number of clauses created during clause normalization.
    Moreover, miniscoping is employed prior to clausification.
  
  Clause contraction.
  Leo-III implements equational simplification procedures, including subsumption,
  destructive equality resolution, heuristic rewriting and contextual unit cutting
  (simplify-reflect) <cit.>.
  
  Defined equalities.
  Common notions of defined equality predicates (Leibniz equality, Andrews equality) are heuristically
  replaced with primitive equality predicates.
  
  Choice.
  Leo-III implements additional calculus rules for reasoning with choice.
  
  Function synthesis.
  If plain unification fails for a set of unification constraints,
  Leo-III may try to synthesize functions that meet the specifications represented
  by the unification constraint. This is done using
  special choice instances that simulate if-then-else terms which explicitly enumerate
  the desired input output relation of that function.
  In general, this rule tremendously increases the search
  space, but it also enables Leo-III to solve some hard problems with TPTP rating 1.0
  that were not solved by any ATP system before.
  
  Injective functions.
  Leo-III addresses improved reasoning with injective functions by postulating
  the existence of left inverses for function symbols that are inferred to be
  injective, see also below.
  
  Further rules.
  Prior to clause normalization, Leo-III might instantiate universally quantified
  variables with heuristically chosen terms. 
  This includes the exhaustive instantiation of finite types (such as o, oo, etc.)
  as well as partial instantiation for other interesting types (such as oτ for some
  type τ).
  
  The addition of the above calculus rules to EP in Leo-III enables the system to solve
  various problems that can otherwise not be solved (in reasonable resource limits).
  An example problem that could not be solved by any higher-order ATP system before
  is the following, cf. <cit.>:

[Cantor's Theorem, revisited]
  Another possibility to encode Cantor's theorem is by using a formulation based on injectivity:
  
    (∃ f_ι(oι). ∀ X_oι. ∀ Y_oι.  (f X = f Y) ⇒ X = Y)
        𝐂^'

  Here, the nonexistence of an injective function from a set's power set to the original
  set is postulated. This conjecture can easily be proved using Leo-III's injectivity rule (INJ)
  that, given a fact stating that some function symbol f is injective, introduces the left inverse
  of f, say f^inv, as fresh function symbol to the search space.
  The advantage is that f^inv is then available to subsequent inferences and can 
  act as an explicit evidence for the (assumed) existence of such a function which is then refuted.
  The full proof of <ref> is as follows:


  !=2.5pt
        [                                                                                     (<ref>)                                                                  C_0  [ ^1 ≃ ^2]^ [^1 ≃^2]^;                                                                                       (C_0)                                                          C_1  [ ^1 ≃ ^2]^ [^1  ^3 ≃^2  ^3]^;                                                                                    INJ(C_0)                                                                     C_2  [^inv  ( ^4) ≃^4]^;                                                                                       (C_2)                                                             C_3  [^inv  ( ^4)  ^5 ≃^4  ^5]^;                                                                                   (C_3,C_1)                          C_4  [ ^1 ≃ ^2]^
                                [^1  ^3 ≃^4  ^5]^;                                                                                                                                                              [^inv  ( ^4)  ^5 ≃^2  ^3]^;                                                                                       (C_4) C_5  [^inv (  (^7  ^3))   (^6  ^3)
                                    ≃^7  ^3   (^6  ^3)]^;                                                                                       (C_3)                         C_6  [^inv  ( ^4)  ^5]^
                                  [^4  ^5]^;                                                                                  (C_6, oι),        C_7  [^inv  (  (λ Z_ι.  (^6   Z)))  ^5]^
                                  [^6  ^5]^;                                                                                     (C_7),,                             C_8  [^inv ( λ Z_ι.  (^inv  Z   Z))  ( λ Z_ι.  (^inv  Z   Z))]^;                                                                                (C_5, C_8),,                             C_9  [^inv ( λ Z_ι.  (^inv  Z   Z))  ( λ Z_ι.  (^inv  Z   Z))]^;                                                                                 (C_9, C_8),                                                                                             ]

        
  The introduced Skolem symbol  is of type ι(oι)
  and its (assumed) left inverse, denoted ^inv of type oιι, is inferred by
  (INJ) based on the injectivity specification given by clause C_0.
  The inferred property of ^inv is given by C_2.
  The injective Cantor Theorem is part of the TPTP library as problem 
   and could
  not be solved
  by any existing HO ATP system before.








§ SYSTEM ARCHITECTURE AND IMPLEMENTATION

As mentioned before, the main goal of the Leo-III prover is to achieve
effective automation of reasoning in HOL, and, in particular, to address the
shortcomings of resolution-based approaches when handling equality. To
that end, the implementation of Leo-III uses the complete EP calculus presented in <ref>
as a starting point, and furthermore implements the rules from <ref>.
Although EP is still unordered
and Leo-III therefore generally suffers from the same drawbacks as experienced in first-order
paramodulation, including state space explosions and a prolific proof search, the idea is to use EP anyway
as a basis for Leo-III and to pragmatically tackle the problems with additional calculus rules
(cf. <ref>),
and optimizations and heuristics on the implementation level.
As a further
technical adjustment, the term representation data structures of Leo-III do not assume primitive
equality to be the only primitive logical connective. While this is handy from a theoretical point of view,
an explicit representation of further primitive logical connectives is beneficial from a practical side.




An overview of Leo-III's top level architecture is displayed in Fig. <ref>.
After parsing the problem statement, a symbol-based relevance filter adopted from Meng and Paulson <cit.>
is employed for premise selection. The input formulas that pass the relevance filter are translated
into polymorphically typed λ-terms (Interpreter) and are then passed to the Proof Search component.
In this component, the main top-level proof search algorithm is implemented.
Subsequent to initial pre-processing, this algorithm repeatedly invokes procedures from a dedicated component,
denoted Control, that acts as a facade to the concrete calculus rules, and moreover manages, selects
and applies different heuristics that may restrict or guide the application of the calculus rules.
These decisions are based on current features of the proof search progress
and user-provided parameter values; such information is bundled in a dedicated State object.
If the proof search is successful, the Proof Search component may output a proof object
that is constructed by the Control module on request. Indexing data structures are employed for speeding up
frequently used procedures.



Note that the proof search procedure itself does not have direct access to the Calculus module in Fig. <ref>:
Leo-III implements a layered multi-tier architecture in which lower tiers (e.g. the Calculus component)
are only accessed through a higher tier (e.g. the Control). This allows for a modular and more flexible
structure in which single components can be replaced or enriched without major changes to others. It furthermore
improves maintainability as individual components implement fewer functionality (separation of concerns).
Following this approach, the Calculus component merely implements the inference rules of Leo-III's
calculus but it does not specify when to apply them, nor does it provide functionality to 
decide whether individual calculus rules should be applied in a given situation (e.g.  with respect to some heuristics).
The functions provided by this module are low-level; invariantly, there are approximately as many
functions in the Calculus module as there are inference rules.
The Control component, in contrast, bundles certain inference rule applications with simplification routines,
indexing data structure updates, and heuristic decision procedures in single high-level procedures.
These procedures are then invoked by the Proof Search which passes its current search state
as an argument to the calls. The State component is then updated accordingly by
the Proof Search using the results of such function calls. The Proof Search
module implements a saturation loop that is discussed further below.

Leo-III makes use of external (mostly first-order) ATP systems for discharging proof obligations.
If any external reasoning system finds the submitted
proof obligation to be unsatisfiable, the original HOL problem is unsatisfiable as well
and a proof for the original conjecture is found.
Invocation, translation and utilization of the external results are also bundled by the Control module, 
cf. further below for details.













 §.§ Proof search

The overall proof search procedure of Leo-III consists of three consecutive phases:
preprocessing, saturation and proof reconstruction.

During preprocessing, the input formulas are transformed into a fully Skolemized βη-normal clausal normal form. In addition, 
methods including definition expansion, simplification, miniscoping,
replacement of defined equalities, and clause
renaming <cit.> are applied, cf. Steen's
thesis for details <cit.>.

Saturation is organized as a sequential procedure
that iteratively saturates the set of input clauses with respect to EP (and its extensions)
until the empty clause is derived.
The clausal search space is structured
using two sets U and P of unprocessed
clauses and processed clauses, respectively.
Initially, P is empty and U contains all clauses generated from the input 
problem. 
Intuitively, the algorithm iteratively selects an unprocessed clause g
(the given clause) from
U. If g is the empty clause, the initial clause set is shown to be
inconsistent and the algorithm terminates. If g is not the empty clause,
all inferences involving g and (possibly) clauses in P are generated
and inserted into U. The resulting invariant is that all inferences between
clauses in P have already been performed.
Since in most cases the number of clauses that can be generated during
proof search is infinite, the saturation process is limited artificially
using time resource bounds that can be configured by the user.

Leo-III employs a variant of the DISCOUNT <cit.> loop
that has its intellectual
roots in the E prover <cit.>.
Nevertheless, some modifications are necessary to address the specific
requirements of reasoning in HOL. 
Firstly, since formulas can occur within subterm positions and, in particular,
within proper equalities, many of the generating and modifying inferences may 
produce non-CNF clauses albeit having proper clauses as premises. This implies
that, during a proof loop iteration, potentially every clause needs to be renormalized.
Secondly, since higher-order unification is undecidable, unification procedures
cannot be used as an eager inference filtering mechanism (e.g., for paramodulation and
factoring) nor can they be integrated as an isolated procedure on the meta-level 
as done in first-order procedures.
As opposed to the first-order case, clauses that have unsolvable unification constraints
are not discarded but nevertheless inserted into the search space.
This is necessary in order to retain completeness. 



If the empty clause was inferred during saturation and the user requested a
proof output, a proof object is generated using backwards traversal of the
respective search subspace. Proofs in Leo-III are presented as
TSTP refutations <cit.>, cf. <ref> for details.



 §.§ Polymorphic Reasoning

Proof assistants such as Isabelle/HOL <cit.> and
Coq <cit.> are based on type systems that extend simple types
with, e.g., polymorphism, type classes, dependent types and further type concepts.
Such expressive type systems allow structuring knowledge
in terms of reusability and are of major importance in practice.

Leo-III supports reasoning in first-order and higher-order logic
with rank-1 polymorphism.
The support for polymorphism has been strongly
influenced by the recent development of the TH1 format for
representing problems in rank-1 polymorphic HOL <cit.>,
extending the standard THF syntax <cit.> for HOL.
The extension of Leo-III to polymorphic reasoning does not require modifications of the general proof
search process as presented further above. Also, the data structures of Leo-III are already expressive enough to
represent polymorphic formulas, cf. technical details in earlier work <cit.>.



Central to the polymorphic variant of Leo-III's calculus is the notion of type unification.
Type unification between two types τ and ν yields a substitution σ such that
τσ≡νσ, if such a substitution exists. The most general type unifier
is then defined analogously to term unifiers.
Since unification on rank-1 polymorphic types is essentially a first-order
unification problem, it is decidable and unitary, i.e., it yields
a unique most general unifier if one exists.
Intuitively, whenever a calculus rule of EP requires two premises to have the same
type,
it then suffices in the polymorphic extension of EP to require that the types are unifiable.
For a concrete inference, the type unification is then applied first to the clauses, followed
by the standard inference rule itself.


Additionally, Skolemization needs to be adapted to account for
free type variables in the scope of existentially quantified variables.
As a consequence, Skolem constants that are introduced, e.g., during clausification
are polymorphically typed symbols sk that are applied to the free type variables α^i
followed by the free term variables X^i, yielding the final Skolem term
(sk α^i X^i), where sk is the fresh
Skolem constant. A similar construction is used for general bindings that
are employed by primitive substitution or projection bindings during unification.
A related approach is employed by Wand in the extension of the first-order ATP system SPASS
to polymorphic types <cit.>.

A full investigation of the formal properties of these calculus extensions to polymorphic
HOL is further work.



 §.§ External Cooperation

Leo-III's saturation procedure periodically requests the invocation of 
external reasoning systems at the Control module for discharging proof obligations
that originate from its current search space. Upon request the Control module
checks, among other things, whether the set of processed clauses P changed significantly since the last
request. If this is the case and the request is granted, the search space is enqueued for
submission to external provers. If there are no external calls awaiting to be executed,
the request is automatically granted. This process is visualized in Fig. <ref>. 
The invocation of an external ATP system is executed asynchronously 
(non-blocking), hence the internal proof search continues while awaiting the result of the external system.
Furthermore, as a consequence of the non-blocking nature of external cooperation, multiple
external reasoning systems (or multiple instances of the same) may be employed in parallel.
To that end, a dedicated I/O driver is implemented that manages the asynchronous 
calls to external processes and collects the incoming results.



The use of different external reasoning systems is also challenging from
a practical perspective: Different ATP systems support different logics
and furthermore different syntactical fragments of these logics. This is addressed in Leo-III
using an encoding module (cf. Encoder in Fig. <ref> resp. Fig. <ref>)
that translates the polymorphically typed higher-order clauses to monomorphic higher-order formulas,
or to polymorphic or monomorphic typed first-order clauses. It also removes unsupported
language features and replaces them with equivalent formulations. 
Fig. <ref> displays the translation pipeline of Leo-III
for connecting to external ATP systems.
The Control module of Leo-III will automatically
select the encoding target to be the most expressive logical language that is still supported
by the external system <cit.>.
The translation process combines heuristic
monomorphization <cit.> steps
with standard encodings of higher-order language features <cit.> in first-order logic.
For some configurations there are multiple possible approaches (e.g., either monomorphize
from TH1 to TH0 and then encode to TF1, or encode directly to TF1), in these cases a default is 
fixed but the user may chose otherwise via command-line parameters.

While LEO-II relied on cooperation with untyped first-order provers, Leo-III
aims at exploiting the relatively young support of simple types in first-order ATP systems.
As a consequence, the translation of higher-order proof obligations 
does not require the encoding of types as terms, e.g.,
by type guards or type tags <cit.>.
This approach reduces clutter and hence promises more effective cooperation.
Cooperation within Leo-III is by no means limited to
first-order provers. Various different systems, including first-order and higher-order ATP systems and
model finders, can in fact be used simultaneously, provided that they comply
with some common TPTP language standard. 
Supported TPTP languages for external cooperation include the TPTP dialects TF0 <cit.>, TF1 <cit.>,
TH0 <cit.> and TH1 <cit.>.





 §.§ Input and Output

Leo-III accepts all common TPTP dialects <cit.>,
including untyped clause normal form (CNF), untyped and typed first-order logic
(FOF and TFF, respectively) and, as primary input format,
monomorphic higher-order logic (THF) <cit.>.
Additionally, Leo-III is one of the first higher-order ATP systems to support
reasoning in rank-1 polymorphic variants of these logics using the
TF1 <cit.> and TH1 <cit.> languages.

Leo-III rigorously implements the machine-readable
TSTP result standard <cit.>
and hence outputs appropriate SZS ontology values <cit.>.
The use of the TSTP output format allows for simple means of
communication and exchange of reasoning results between different reasoning tools
and, consequently, eases the employment of Leo-III within external tools.
Novel to the list of supported SZS result values for the Leo prover family is 
 <cit.>, which is reported if the input axioms 
were found to be inconsistent during the proof run
(i.e., if the empty clause could be derived without using the conjecture even once).
Using this simple approach, Leo-III identified 15 problems from the TPTP library to be inconsistent without any special setup.

Additional to the above described SZS result value,
Leo-III produces machine readable proof certificates if a proof was found
and such a certificate has been requested.
Proof certificates are an ASCII encoded, linearized, directed acyclic graph (DAG) of inferences
that refutes the negated input conjecture by ultimately generating the empty clause.
The root sources of the inference DAG are the given conjecture (if any) and
all axioms that have been used in the refutation.
The proof output records all intermediate inferences.
The representation again follows the TSTP format and records the inferences
using annotated  formulas.
Due to the fine granularity of Leo-III proofs, it is often possible to verify them
step-by-step using external tools such as GDV <cit.>.
A detailed description of Leo-III's proof output format and the information contained
therein can be found in Steen's PhD thesis <cit.>.
An example of such a proof output is displayed in Fig. <ref>.






 §.§ Data Structures


Leo-III implements a combination of term representation techniques;
term data structures are provided that 
admit expressive typing, efficient basic term operations and reasonable
memory consumption <cit.>.
Leo-III employs
a so-called spine notation <cit.>,
which imitates first-order-like terms
in a higher-order setting. Here, terms are either type abstractions,
term abstractions or applications
of the form f · (s_1;s_2;…), where the head f 
is either a constant symbol, a bound variable or a complex term, and
the spine (s_1;s_2;…) is a linear list of arguments that are, again, spine terms.
Note that if a term is β-normal, f cannot be a complex term. This observation
leads to an internal distinction between β-normal and (possibly) non-β-normal
spine terms. The first kind has an optimized representation, where the head is
only associated with an integer representing a constant symbol or variable.

Additionally,
the term representation incorporates explicit substitutions <cit.>.
In a setting of explicit substitutions,
substitutions are part of the term language and can thus be
postponed and composed before being applied to the term. This technique admits
more efficient β-normalization and substitution operations as terms
are traversed only once, regardless of the number of substitutions applied.

Furthermore, Leo-III implements a locally nameless
representation using de Bruijn indices <cit.>. 
In the setting of polymorphism <cit.>, types may also contain
variables. Consequently, the nameless representation of variables is extended
to type variables <cit.>. The definition of de Bruijn indices for type
 variables is analogous to the one for term variables. In fact, since only
rank-1 polymorphism is used, type indices are much easier to manage than
term indices. This is due to the fact that there are no type quantifications
except for those on top level.
One of the most important advantages
of nameless representations over representations with explicit variable names
is that α-equivalence is reduced to syntactical equality, i.e.,
two terms are α-equivalent if and only if their nameless representations are equal.

Terms are perfectly shared within
Leo-III, meaning that each term is only constructed once and then reused
between different occurrences. This reduces memory
consumption in large knowledge bases and it allows constant time
term comparison for syntactic equality using the term's pointer to its
unique physical representation. For fast basic term retrieval operations 
(such as access of a head symbol, subterm occurrences, etc.)
terms are kept in β-normal η-long form.


A collection of basic data structures and algorithms for the implementation of
higher-order reasoning systems has been isolated from the
implementation of Leo-III into a dedicated framework called
LeoPARD <cit.>, which is freely available
at GitHub.[
  Leo’s Parallel Architecture and Datastructures (LeoPARD) can be found at <https://github.com/leoprover/LeoPARD>.
]
This framework
provides many stand-alone components, including a term data
structure for polymorphic λ-terms, unification and subsumption
procedures, parsers for all TPTP languages, and further utility
procedures and pretty printers for TSTP compatible proof 
representations.








§ REASONING IN NON-CLASSICAL LOGICS

 

Computer-assisted reasoning in non-classical logics (NCL) is of increasing
relevance for applications in artificial intelligence, computer science,
mathematics and philosophy. 
However, with a few exceptions, most of the available reasoning systems
focus on classical logics only, including common contemporary first-order and
higher-order theorem proving systems. In particular for quantified
NCLs there are only very few systems available to
date.

As an alternative to the development of specialized theorem proving systems,
usually one for each targeted NCL, a shallow semantical embedding (SSE) approach allows
for a simple adaptation of existing higher-order reasoning systems 
to a broad variety of expressive logics <cit.>. 
In the SSE approach, the non-classical target logic is shallowly embedded
in HOL by providing a direct encoding of its semantics, typically
a set theoretic or relational semantics, within the term language of HOL.
As a consequence, showing validity in the target logic is reduced to higher-order
reasoning and HOL ATP systems can be applied for this task.
Note that this technique, in principle, also allows off-the-shelf automation
even for quantified NCLs as quantification and binding mechanisms of the
HOL meta logic can be utilized.
This is an interesting option in many application areas, e.g., in 
ethical and legal reasoning, as the respective communities
do not yet agree on which logical system should actually be preferred.
The resource-intensive implementation of dedicated new provers
for each potential system is not an adequate option for
rapid prototyping of prospective candidate logics and can be avoided using SSEs.

Leo-III is addressing this gap. In addition to its HOL reasoning capabilities,
it is the first system that natively supports reasoning in a wide range of
normal higher-order modal logics (HOMLs) <cit.>.
To achieve this, Leo-III internally implements the SSE approach
for quantified modal logics based on their Kripke-style
semantics <cit.>.

Quantified modal logics are associated with many different notions of semantics <cit.>.
Differences may, e.g., occur in the interaction between quantifiers and
the modal operators, as expressed by the Barcan formulas <cit.>,
or regarding the interpretation of constant symbols as rigid or non-rigid.
Hence, there are various subtle but meaningful variations in multiple individual facets of which many
combinations yield a distinct modal logic.
Since many of those variations have their particular applications, there is no
reasonably small subset of generally preferred modal logics to which a theorem proving system
should be restricted.
This, of course, poses a major practical challenge.
Leo-III, therefore, supports all quantified Kripke-complete normal modal logics <cit.>.
In contrast, other ATP systems for (first-order) quantified modal logics
such as MleanCoP <cit.> and MSPASS <cit.>
only support a comparably small subset of all possible semantic variants. 

