Abstract
We extend the graceful higher-order basic Knuth-Bendix order (KBO) of Becker et al. to an ordering that orients combinator equations left-to-right. The resultant ordering is highly suited to parameterising the first-order superposition calculus when dealing with the theory of higher-order logic, as it prevents inferences between the combinator axioms. We prove a number of desirable properties about the ordering including it having the subterm property for ground terms, being transitive and being well-founded. The ordering fails to be a reduction ordering as it lacks compatibility with certain contexts. We provide an intuition of why this need not be an obstacle when using it to parameterise superposition.
Introduction
There exists a wide range of methods for automated theorem proving in higher-order logic. Some provers such as AgsyHOL [17], Satallax [10] and Leo-II [4] implement dedicated higher-order proof calculi. A common approach, followed by the Leo-III prover [21], is to use a co-operative architecture with a dedicated higher-order prover working in conjunction with a first-order prover. It has long been part of theorem proving folklore that sound and complete translations from higher-order to first-order logic exist. Kerber [15] proves this result for a higher-order logic that does not assume comprehension axioms (otherwise known as applicative first-order logic). Thus, translating higher-order problems to first-order logic and running first-order provers on the translations is another method of automated higher-order theorem proving. Variations of this method are widely utilised by interactive theorem provers and their hammers such as Sledgehammer [18] and the CoqHammer [11].
Almost all translations to first-order logic translate
-expressions using combinators. It is well known that the set of combinators
and
is sufficient to translate any
-expression. For purposes of completeness, these combinators must be axiomatised:
,
and
. If translating to a monomorphic logic a finite set of axioms cannot achieve completeness.
However, till now, translation based methods have proven disappointing and only achieved decent results with interactive theorem provers when the problems are first-order or nearly first-order [22]. One major reason for this is that inferences between combinator axioms can be hugely explosive. A common first-order proof calculus is superposition [19]. Consider a superposition inference from the
axiom onto the right-hand of the
axiom. The result is
. There is little to restrict such inferences.
Superposition is parameterised by a simplification ordering and inferences are only carried out on the larger side of literals with respect to this ordering. Inferences are not carried out at variables. Consider the
-,
- and
-axioms given above. There can clearly be no unifiers between a subterm of the left side of one axiom and the left side of another except at a variable. Thus, if a simplification ordering exists that orients the axioms left-to-right, inferences amongst the axioms would be impossible.
Currently, no such simplification ordering is known to exist and the authors suspect that no such ordering can exist. Whilst there is a large body of work on higher-order orderings, all either lack some property required for them to be simplification orderings or are unsuitable for orienting the combinator axioms. Jouannaud and Rubio introduced a higher-order version of the recursive path order called HORPO [14]. HORPO is compatible with
-reduction which suggests that without much difficulty it could be modified to be compatible with weak reduction. However, the ordering does not enjoy the subterm property, nor is it transitive. Likewise, is the case for orderings based on HORPO such as the computability path ordering [8] and the iterative HOIPO of Kop and Van Raamsdonk [16]. More recently, a pair of orderings for
-free higher-order terms have been developed [2, 7]. These orderings lack a specific monotonicity property, but this does not prevent their use in superposition [3]. However, neither ordering orients combinator axioms directly.
We investigate an extension of the graceful higher-order basic KBO
introduced by Becker et al. [2]. Our new ordering,
, orients combinator equations left-to-right. Thus, if it is used to parameterise a superposition calculus, there can be no inferences among the axioms. The
ordering lacks full compatibility with contexts which is normally a requirement for an ordering to parameterise superposition. In particular, the ordering is not compatible with the so-called unstable contexts. In separate work we show that this is not an obstacle to achieving completeness [5].
A complete superposition calculus for HOL already exists [3]. This calculus has the
-calculus rather than combinatory logic as its underlying logic. It also employs higher-order unification. There appear to be two potential benefits to using a slightly modified first-order superposition calculus parameterised by our new ordering
over lambda superposition as developed in [3].
A superposition calculus parameterised by
is far closer to standard first-order superposition than lambda superposition. Unification is first-order and there is no need to deal with binders and bound variables. This allows the re-use of the well-studied data-structures and algorithms used in first-order superposition [12, 20].As discussed further in the conclusion (Sect. 6), the
ordering allows the comparison of a larger class of non-ground terms than the ordering used in [3]. This results in fewer superposition inferences.
In Sect. 2, we provide the necessary preliminaries and then move on to the main contributions of this paper which are:
Two approaches extending the
ordering by first comparing terms by the length of the longest weak reduction from them. The approaches differ in the manner in which they compare non-ground terms. A useful trait for an ordering that parameterises superposition is to be able to compare a large class of non-ground terms since this reduces the number of inferences carried out. The most powerful method of defining a non-ground ordering
is to semantically lift a ground ordering, i.e., to define
to hold iff
for all grounding substitutions
. Such an ordering in non-computable and both our methods attempt to approximate it (Sect. 3).A set of proofs that the introduced
ordering enjoys the necessary properties required for its use within the superposition calculus (Sect. 4) and a set of examples demonstrating how the ordering applies to certain terms (Sect. 5).
Preliminaries
Syntax of Types and Terms: We work in a polymorphic applicative first-order logic. Let
be a set of type variables and
be a set of type constructors with fixed arities. It is assumed that a binary type constructor
is present in
which is written infix. The set of types is defined:
The notation
is used to denote a tuple or list of types or terms depending on the context. A type declaration is of the form
where
is a type and all type variables in
appear in
. Let
be a set of typed function symbols and
a set of variables with associated types. It is assumed that
contains the following function symbols, known as basic combinators:
![]() |
The set of terms over
and
is defined below. In what follows, type subscripts, and at times even type arguments, are omitted.
The type of the term
is
. Following [2], terms of the form
are called applications. Non-application terms are called heads. A term can uniquely be decomposed into a head and n arguments. Let
. Then
where
could be a variable or constant applied to possibly zero type arguments. The symbol
denotes a member of
, whilst
denotes a member of
. These symbols are only used when the combinator is assumed to have a full complement of arguments. Thus, in
,
is assumed. The symbols
are reserved for variables,
for non-combinator constants and
range over arbitrary symbols and, by an abuse of notation, at times even terms. A term is ground if it contains no variables and term ground if it contains no term variables.
Positions over Terms: For a term t, if
or
, then
(type arguments have no position). If
then
. Subterms at positions of the form p.1 are called prefix subterms and subterms at positions of the form p.2 are known as first-order subterms. A position p is strictly above a position
(denoted
) if
. Positions p and
are incomparable (denoted
) if neither
nor
, nor
. By
, the number of symbols occurring in t is denoted. By
the multiset of variables in t is denoted. The expression
means that either A is a subset of B or A is a submultiset of B depending on whether A and B are sets or multisets.
Stable Subterms: We define a subset of first-order subterms called stable subterms. Let
(LPP stands for Longest Proper Prefix) be a partial function that takes a term t and a position p and returns the longest proper prefix
of p such that
is not a partially applied combinator if such a position exists. For a position
, p is a stable position in t if
is not defined or
is not a combinator. A stable subterm is a subterm occurring at a stable position and is denoted
. We call
a stable context and drop the position where it is not relevant. For example, the subterm
is not stable in
,
(in both cases,
) and
(
is not a first-order subterm), but is in
and
. A subterm that is not stable is known as an unstable subterm.
The notation
denotes an arbitrary subterm u of t that occurs at position p and may be unstable. The notation
(or
) denotes the term t containing n
non-overlapping subterms
to
. By
, we refer to a context with n non-overlapping holes. Whilst this resembles the notation for a term at position n, ambiguity is avoided by never using n to denote a position or p to denote a natural number.
Weak Reduction: Each combinator is defined by its characteristic equation;
,
,
,
and
. A term t
weak-reduces to a term
in one step (denoted
) if
and there exists a combinator axiom
and substitution
such that
and
. The term
in t is called a weak redex or just redex. By
, the reflexive transitive closure of
is denoted. If term t weak-reduces to term
in n steps, we write
. Further, if there exists a weak-reduction path from a term t of length n, we say that
. Weak-reduction is terminating and confluent as proved in [13]. By
, we denote the term formed from t by contracting its leftmost redex.
The length of the longest weak reduction from a term t is denoted
. This measure is one of the crucial features of the ordering investigated in this paper.
A Maximal Weak-Reduction Strategy
To show that the measure
is computable we provide a maximal weak-reduction strategy and prove its maximality. The strategy is used in a number of proofs later in the paper. It is in a sense equivalent to Barendregt’s ‘perpetual strategy’ in the
-calculus [1]. Our proof of its maximality follows the style of Van Raamsdonk et al. [23] in their proof of the maximality of a particular
-reduction strategy. We begin by proving the fundamental lemma of maximality for combinatory terms.
Lemma 1 (Fundamental Lemma of Maximality)
where
if
and is 0 otherwise. The lemma holds for
if
,
if
and
otherwise.
Proof
Assume that
. Then any maximal reduction from
is of the form:
where
,
,
and
. Thus,
. There is another method of reducing
to s:
![]() |
As the length of this reduction is the same as the previous reduction, it must be a maximal reduction as well. Therefore we have that: 
Conversely, assume that
is not
. We prove that the formula holds if
. The other cases are similar. If
, any maximal reduction from
must be of the form:
where
,
and
. There is another method of reducing
to s:
![]() |
Thus, we have that
. Since
is the length of the maximal reduction, equality must hold.
Lemma 2
Define a map
from
to
as follows:
The reduction strategy
is maximal.
Proof
As the Lemma is not of direct relevance to the paper, its proof is relegated to the accompanying technical report [6].
Term Order
First, Becker et al.’s [2] graceful higher-order basic KBO is presented as it is utilised within our ordering. The presentation here differs slightly from that in [2] because we do not allow ordinal weightings and all function symbols have finite arities. Furthermore, we do not allow the use of different operators for the comparison of tuples, but rather restrict the comparison of tuples to use only the length-lexicographic extension of the base order. This is denoted
. The length-lexicographic extension first compares the lengths of tuples and if these are equal, carries out a lexicographic comparison. For this section, terms are assumed to be untyped following the original presentation.
Graceful Higher-Order Basic KBO
Standard first-order KBO first compares the weights of terms, then compares their head-symbols and finally compares arguments recursively. When working with higher-order terms, the head symbol may be a variable. To allow the comparison of variable heads, a mapping ghd is introduced that maps variable heads to members of
that could possibly instantiate the head. This mapping respects arities if for any variable x, all members of ghd(x) have arities greater or equal to that of x. The mapping can be extended to constant heads by taking
. A substitution
respects the mapping ghd, if for all variables x,
.
Let
be a total well-founded ordering or precedence on
. The precedence
is extended to arbitrary heads by defining
iff
and
. Let
be a function from
to
that denotes the weight of a function symbol and
a function from
to
denoting the weight of a term. Let
. For all constants
,
. The weight of a term is defined recursively:
The graceful higher-order basic Knuth-Bendix order
is defined inductively as follows. Let
and
. Then
if
and any of the following are satisfied:
- Z1

- Z2
and 
- Z3
and 
Combinator Orienting KBO
The combinator orienting KBO is the focus of this paper. It has the property that all ground instances of combinator axioms are oriented by it left-to-right. This is achieved by first comparing terms by the length of the longest weak reduction from the term and then using
. This simple approach runs into problems with regards to stability under substitution, a crucial feature for any ordering used in superposition.
Consider the terms
and
. As the length of the maximum reduction from both terms is 0, the terms would be compared using
resulting in
as
. Now, consider the substitution
. Then,
whilst
resulting in
.
The easiest and most general way of obtaining an order which is stable under substitution would be to restrict the definition of the combinator orienting KBO to ground terms and then semantically lift it to non-ground terms as mentioned in the introduction. However, the semantic lifting of the ground order is non-computable and therefore useless for practical purposes. We therefore provide two approaches to achieving an ordering that can compare non-ground terms and is stable under substitution both of which approximate the semantic lifting. Both require some conditions on the forms of terms that can be compared. The first is simpler, but more conservative than the second.
First, in the spirit of Bentkamp et al. [3], we provide a translation that replaces “problematic” subterms of the terms to be compared with fresh variables. With this approach, the simple variable condition of the standard KBO,
, ensures stability. However, this approach is over-constrained and prevents the comparison of terms such as
and
despite the fact that for all substitutions
,
. Therefore, we present a second approach wherein no replacement of subterms occurs. This comes at the expense of a far more complex variable condition. Roughly, the condition stipulates that two terms are comparable if and only if the variables and relevant combinators are in identical positions in each.
Approach 1. Because the
ordering is not defined over typed terms, type arguments are replaced by equivalent term arguments before comparison. The translation
from
to untyped terms is given below. First we define precisely the subterms that require replacing by variables.
Definition 1 (Type-1 term)
Consider a term t of the form
. If there exists a position p such
is a variable, then t is a type-1 term.
Definition 2 (Type-2 term)
A term
where
is a type-2 term.
The translation to untyped terms is defined as follows. If t is a type variable
, then
. If
, then
. If t is a term variable x, then
. If t is a type-1 or type-2 term, then
is a fresh variable
. If
, then
. Finally, if
, then
.
An untyped term t weak reduces to an untyped term
in one step if
and there exists a combinator axiom
and substitution
such that
and
. The aim of the ordering presented here is to parametrise the superposition calculus. For this purpose, the property that for terms t and
,
, is desired. To this end, the following lemma is proved.
Lemma 3
For all term ground polymorphic terms t and
, it is the case that
.
Proof
The
direction can be proved by a straightforward induction on the t. The opposite direction is proved by an induction on
.
Corollary 1
A straightforward corollary of the above lemma is that for all term-ground polymorphic terms t,
.
The combinator orienting Knuth-Bendix order (approach 1)
is defined as follows. For terms t and s, let
and
. Then
if
and:
- R1
or,- R2
and
.
Approach 2. Using approach 1, terms
and
are incomparable. Both are type-2 terms and therefore
and
. The variable condition obviously fails to hold between
and
. Therefore, we consider another approach which does not replace subterms with fresh variables. We introduce a new translation
from
to untyped terms that merely replaces type arguments with equivalent term arguments and does not affect term arguments at all. The simpler translation comes at the cost of a more complex variable condition. Before the revised variable definition can be provided, some further terminology requires introduction.
Definition 3 (Safe Combinator)
Let
occur in t at position p and let
be the shortest prefix of p such that
is a combinator and for all positions
between p and
,
is a combinator. Let
be a prefix of p of length one shorter than
if such a position exists and
otherwise. Then
is safe in t if
is ground and
and unsafe otherwise.
Intuitively, unsafe combinators are those that could affect a variable on a longest reduction path or could become applied to a subterm of a substitution. For example, all combinators in the term
are unsafe because they affect x, whilst the combinator in
is safe. The combinators in
are unsafe because they could potentially interact with a term substituted for x.
Definition 4
We say a subterm is top-level in a term t if it doesn’t appear beneath an applied variable or fully applied combinator head in t.
Definition 5 (Safe)
Let
and
be untyped terms. The predicate
holds if for every position p in
such that
and
(not necessarily fully applied) is unsafe, then
and for
,
. Further, for all p in
such that
, then
and for
,
.
The definition of safe ensures that if safe(t, s) and
, then
for any substitution
a result we prove in Lemma 13. Consider terms
and
. We have that
. However, it is not the case that safe(t, s) because the condition that
for all i is not met.
. Now consider the substitution
. Because this substitution duplicates the second argument in s and t,
showing the importance of the safe predicate in ensuring stability.
We draw out some obvious consequences of the definition of safety. Firstly, the predicate enjoys the subterm property in the following sense. If p is a position defined in terms
and
, then
. Secondly, the predicate is transitive;
.
There is a useful property that holds for non-ground terms t and s such that safe(t, s).
Definition 6 (Semisafe)
Let t and s be untyped terms. Let
be a term that occurs in s at p such that all head symbols above
in s are combinators. Then semisafe(t, s) if
and for
,
.
It is clearly the case that
. The implication does not hold in the other direction. A useful property of semisafe is that it is stable under head reduction. If for terms t and s that reduce at their heads to
and
respective, we have semisafe(t, s), then we have
.
For example
holds where
and
. In this case
and
. There exists and injective total function from A to B that matches the requirements by relating
to
. However, the variable condition does not hold in either direction if
and
. In this case,
cannot be related to
since the condition that
is not fulfilled.
We now define the combinator orienting Knuth-Bendix order (approach 2)
. For terms t and s, let
and
. Then
if
and:
- R1
or,- R2
and
.
Lemma 4
For all ground instances of combinator axioms
, we have
.
Proof
Since for all ground instances of the axioms
, we have
, the theorem follows by an application of R1.
It should be noted that for non-ground instances of an axiom
, we do not necessarily have
since l and r may be incomparable. This is no problem since the definition of
could easily be amended to have
by definition if
is an instance of an axiom. Lemma 4 ensures that stability under substitution would not be affected by such an amendment.
Properties
Various properties of the order
are proved here. The proofs provided here lack detail, the full proofs can be found in our report [6]. The proofs can easily be modified to hold for the less powerful
ordering. In general, for an ordering to parameterise a superposition calculus, it needs to be a simplification ordering [19]. That is, superposition is parameterised by an irreflexive, transitive, total on ground-terms, compatible with contexts, stable under substitution and well-founded binary relation. Compatibility with contexts can be relaxed at the cost of extra inferences [3, 5, 9]. A desirable property to have in our case is coincidence with first-order KBO, since without this, the calculus would not behave on first-order problems as standard first-order superposition would.
Theorem 1 (Irreflexivity)
For all terms s, it is not the case that
.
Proof
Let
. It is obvious that
. Therefore
can only be derived by rule R2. However, this is precluded by the irreflexivity of
.
Theorem 2 (Transitivity)
For terms s, t and u, if
and
then
.
Proof
Let
,
and
. From
and
,
by the definition of
and the application of the transitivity of safe. If
or
then
and
follows by an application of rule R1. Therefore, suppose that
. Then it must be the case that
and
. It follows from the transitivity of
that
and thus
.
Theorem 3 (Ground Totality)
Let s and t be ground terms that are not syntactically equal. Then either
or
.
Proof
Let
and
. If
then by R1 either
or
. Otherwise,
and
are compared using
and either
or
holds by the ground totality of
and the injectivity of
.
Theorem 4 (Subterm Property for Ground Terms)
If t and s are ground and t is a proper subterm of s then
.
Proof
Let
and
. Since t is a subterm of s,
is a subterm of
and
because any weak reduction in
is also a weak reduction in
. If
, the theorem follows by an application of R1. Otherwise
and
are compared using
and
holds by the subterm property of
. Thus
.
Next, a series of lemmas are proved that are utilised in the proof of the ordering’s compatibility with contexts and stability under substitution. We prove two monotonicity properties Theorems 5 and 6. Both hold for non-ground terms, but to show this, it is required to show that the variable condition holds between terms
and
for t and s such that
. To avoid this complication, we prove the Lemmas for ground terms which suffices for our purposes. To avoid clutter, assume that terms mentioned in the statement of Lemmas 5–16 are all untyped, formed by translating polymorphic terms.
Lemma 5
if
is not a fully applied combinator.
Lemma 6
Let
. Then
if
is a fully applied combinator.
Lemma 7
Let
be terms such that for each
,
. Let
be terms with the same property. Moreover, let
for
. Let
and
where each
and
is at position
in s and
. If the
redex in s is within
for some i, then the
redex in
is within
unless
is in normal form.
Proof
Proof is by induction on
. If u has a hole at head position, then
and
where
and
. Assume that the
redex of s is in
. Further, assume that
. Then, for some i in
, it must be the case that
. Let j be the smallest index such that
. Then by the definition of
,
and the
redex of
is in
.
Suppose that the
redex of s is not in
. This can only be the case if
in which case
as well. In this case, by the definition of
,
where
for
. Without loss of generality, assume that the
redex of
occurs inside
. Then
must be a subterm of
. Assume that
and thus
. Since for all i,
and
only differ at positions where one contains a
and the other contains a
and
for
, we have that
implies
. Thus, using the definition of
,
. The induction hypothesis can be applied to
and
to conclude that the
redex of
occurs inside
. The lemma follows immediately.
If u does not have a hole at its head, then
and
where
is not a fully applied combinator other than
(if it was, the
redex would be at the head).
If
is not a combinator, the proof follows by a similar induction to above. Therefore, assume that
. It must be the case that
otherwise the
redex in s would be at the head and not within a
. By the definition of
,
. Let the
redex of
occur inside
. Then
is a subterm of
. If
then
and
. By the induction hypothesis, the
redex of
occurs in
.
Lemma 8
Let
be terms such that for
,
. Then for all contexts
, if
then either:
where
or
where 
Proof
Let
and let
be the positions of
in s. Since s is reducible, there must exist a p such that
is a redex.
If
for some i, there exists a
such that
. Then,
. Let
. We thus have that
and thus
.
It cannot be the case that
for any i because
is not a combinator for any
. In the case where
or
for all i, we have that
and
is a redex where
. Let
be formed from
by reducing its redex at p. Then , 
Lemma 9
Let
be terms such that for each
,
. Let
be terms with the same property. Then:
If
for all i in
, then
for all n holed contexts u.If
for some
and
for
, then
for all n holed contexts u.
Proof
Let
be the positions of the holes in u and let
and
. Proof is by induction on
. We prove part (1) first:
Assume that
. Then
for
. Now assume that
. Then there must exist some position p such that
is a redex. We have that
for all
as
. Assume
for some
. But then,
which contradicts the fact that
for all i. Therefore, for all
either
or
. But then, if
is a redex, so must
be, contradicting the fact that
. Thus, we conclude that
.
Assume that
. Let
. By Lemma 8 either
where
for
or
where
. In the first case, by Lemma 7 and
we have
where
. By the induction hypothesis
and thus
. In the second case,
where
. Again, the induction hypothesis can be used to show
and the theorem follows.
We now prove part (2);
must be greater than 0. Again, let
and
. If
and
, then by Lemma 7
where
unless
and the lemma follows by the induction hypothesis.
If
, consider terms
and
. If
or
for some
, then the induction hypothesis can be used to show
and therefore
. Otherwise,
for all
and
. Part 1 of this lemma can be used to show that
and thus
. If
, then
and the lemma follows by the induction hypothesis.
Theorem 5 (Compatibility with Contexts)
For ground terms s and t, such that head(s), head(t)
, and
, then
for all ground contexts
.
Proof
Let
,
and
. By Lemma 9 Part 2, we have that if
, then
. Thus, if
was derived by R1,
follows by R1. Otherwise,
is derived by R2 and
. By Lemma 9 Part 1,
follows. Thus,
is compared with
by R2 and
by the compatibility with contexts of
.
Lemma 10
and
.
Proof
Proceed by induction on the size of the context u. If u is the empty context, both parts of the theorem hold trivially.
The inductive case is proved for the first implication of the lemma first. If u is not the empty context,
is of the form
. By the definition of a stable subterm
cannot be a fully applied combinator and thus by Lemma 5 we have that
. If
is not a combinator, then
follows from Lemma 9 Part 2. Otherwise,
is a partially applied combinator and
is a smaller stable context than u. The induction hypothesis can be used to conclude that
and thus that
. The proof of the inductive case for the second implication of the lemma is almost identical.
Theorem 6 (Compatibility with Stable Contexts)
For all stable ground contexts
and ground terms s and t, if
then
.
Proof
If
then by Lemma 10,
holds and then by an application of R1 we have
. Otherwise, if
, then by Lemma 10 we have that
. Thus
and
are compared using
. By the compatibility with contexts of
,
holds and then by ofan application of R2
is true.
We next prove stability under substitution. In order to prove this, it needs to be shown that for untyped terms s and t and all substitutions
:
implies
.
and
imply 
The first is proved in Lemma 15. A slightly generalised version of (2) is proved in Lemma 14. Lemmas 11–13 are helper lemmas used in the proof of the above two properties.
Lemma 11
For a single hole context
such that the hole does not occur below a fully applied combinator and any term t,
.
Proof
Proof to be found in report.
Lemma 12
Let
and
be terms such that for
and for
,
. Further, let
and
. Assume that semisafe(t, s) holds. Then
.
Proof
Proof to be found in report.
Lemma 13
Let t and s be non-ground terms such that
for some
and safe(t, s). Then, for any substitution
,
and
.
Proof
Proof to be found in report.
Lemma 14
For terms t and s such that
holds and
for some
, for all substitutions
,
.
Proof
If s and t are ground, the theorem is trivial. If s is ground, then
. If s is not ground, then
implies that t is not ground. Therefore, assume that neither is ground. If head(s) (and therefore head(t) by the variable condition) are fully applied combinators or variables, then
implies safe(t, s) and Lemma 13 can be invoked to prove the lemma. Therefore, assume that both have non-variable, non-fully applied combinator heads.
Let
and
where
are all the non-ground, top-level, first-order subterms of the form
or
in s. By the variable condition, we have that there exists a total injective function respecting the given conditions from the
to non-ground, top-level, first-order subterms of t of the form
or
. Let
be the terms related to
by this function. Without loss of generality, assume that this function relates
to
,
to
and so on. For
,
for
. This follows from the fact that since
and
are both non-ground and
, we have
and can therefore invoke Lemma 12.
Let
. Note that
could be negative. By Lemma 11,
and
. Thus,
. Therefore,
. Lemma 13 can be used to show that for all i,
. Because
is ground, it follows
. To conclude the proof:
Lemma 15
For terms t and s such that
holds and for all substitutions
,
.
Proof
Let
and
where
are all the non-ground, top-level, first-order subterms of the form
or
in s. By the variable condition, we have that there exists a total injective function respecting the given conditions from the
to non-ground, top-level, first-order subterms of t of the form
or
. Let
be the terms related to
by this function. Without loss of generality, assume that this function relates
to
,
to
and so on. By the definition of the variable condition, we have that
must be ground. This implies that any non-ground subterms of
must be subterms of some
for
.
Assume that for some i and
,
is a non-ground, top-level, first-order subterm of the form
or
. We show that
is a non-ground, top-level, first-order subterm of
and
. This implies the existence of a total, injective function from the multiset of non-ground, top-level first-order subterms in
to the like multiset of
in turn proving
.
From Lemma 13, it can be shown that for
,
. By the subterm property of safety, this implies that
.
To show that
must be a non-ground, top-level, first-order subterm in
, it can be assumed that this not the case. This easily leads to a contradiction with
.
Lemma 16
Let t be a polymorphic term and
be a substitution. We define a new substitution
such that the domain of
is
. Define
. For all terms t,
.
Proof
Via a straightforward induction on t.
Theorem 7 (Stability under Substitution)
If
then
for all substitutions
that respect the ghd mapping.
Proof
Let
and
. Let
be defined as per Lemma 16. First, we show that if R1 was used to derive
and thus
then
and thus
because
and
.
From Lemma 15 and
,
holds. Furthermore, if
, then by Lemma 14
and
by an application of R1.
On the other hand, if
, then R2 was used to derive
. By Lemma 14
. If
, then this is the same as the former case. Otherwise
and
and
are compared using R2. From the stability under substitution of
,
follows and
can be concluded.
Theorem 8 (Well-foundedness)
There exists no infinite descending chain of comparisons
.
Proof
Assume that such a chain exists. For each
derived by R1, we have that
. For each
derived by R2, we have that
. Therefore the number of times
by R1 in the infinite chain must be finite and there must exist some m such that for all
,
by R2. Therefore, there exists an infinite sequence of
comparisons
. This contradicts the well-foundedness of
.
Theorem 9 (Coincidence with First-Order KBO)
Let
be the first-order KBO as described by Becker et al. in [2]. Assume that
and
are parameterised by the same precedence
and that
always compares tuples using the lexicographic extension operator. Then
and
always agree on first-order terms.
Proof
Let
and
. Since s and t are first-order,
and
. Thus,
and
will always be compared by
. Since
coincides with
on first-order terms, so does
.
Examples
To give a flavour of how the ordering behaves, we provide a number of examples.
Example 1
Consider the terms (ignoring type arguments)
and
. From the definition of the translation
, we have that
and
. Since
and
, we have that
.
Example 2
Consider the terms
and
. Here
despite the fact that s is syntactically smaller than t because s has a maximum reduction of 1 as opposed to 0 of t.
Example 3
Consider terms
and
. The two terms are comparable as the variable condition relates subterm
in s to subterm
in t. The unsafe combinator
and variable x are in the same position in each subterm. As
,
.
Example 4
Consider terms
and
. This is very similar to the previous example, but in this case the terms are incomparable. Let
be a name for the subterm
in s and
a name for the subterm
. The variable y occurs in different positions in
and
. Therefore,
cannot be related to t by the variable condition and the two terms are incomparable.
Example 5
Consider terms
and
. The variable condition holds between t and s by relating
to
. The combinator
in s is not unsafe and therefore does not need to be related to a combinator in t.
Since
,
. Intuitively, this is safe because a substitution for x in t can duplicate
whose maximum reduction length is 2 whilst a substitution for x in s can only duplicate
whose maximum reduction length is 0.
Conclusion and Discussion
We have presented an ordering that orients all ground instances of
,
,
,
and
axioms left-to-right. The ordering enjoys many other useful properties such as stability under substitution, compatibility with stable contexts, ground totality and transitivity. In as yet unpublished work, we have used this ordering to parameterise a complete superposition calculus for HOL [5]. Lack of full compatibility with context has not been an obstacle. In the standard first-order proof of the completeness of superposition, compatibility with contexts is used in model construction to rule out the need for superposition inferences beneath variables [19]. Thus, by utilising
, some superposition is required beneath variables. However, because terms with functional heads are compatible with all contexts, such inference are quite restricted.
The
ordering presented here is able to compare non-ground terms that cannot be compared by any ordering used to parameterise Bentkamp et al.’s lambda superposition calculus [3]. They define terms to be
-equivalence classes. Non-ground terms are compared using a quasiorder,
, such that
iff for all grounding substitutions
,
. Consider terms
and
and grounding substitutions
and
. By ground totality of
it must be the case that either
or
. Without loss of generality assume the first. Then, neither
nor
since
and
.
The
ordering allows weak reduction (or
-reduction) to be treated as part of the superposition calculus. This allows terms t and
such that
(or
) to be considered separate terms resulting in terms such as t and s given above being comparable. Since
, t and s are compared using
with stability under substitution ensured by the stability under substitution of
.
Many of the definitions that have been provided here are conservative and can be tightened to allow the comparison of a far larger class of non-ground terms without losing stability under substitution. We provide an example of how the definition of stable subterm could be refined in our report [6]. In further work, we hope to thoroughly explore such refinements.
Acknowledgements
Thanks to Jasmin Blanchette, Alexander Bentkamp and Petar Vukmirović for many discussions on aspects of this research. We would also like to thank reviewers of this paper, whose comments have done much to shape this paper. The first author thanks the family of James Elson for funding his research.
Contributor Information
Nicolas Peltier, Email: nicolas.peltier@univ-grenoble-alpes.fr.
Viorica Sofronie-Stokkermans, Email: sofronie@uni-koblenz.de.
Giles Reger, Email: giles.reger@manchester.ac.uk.
References
- 1.Barendregt HP. The Lambda Calculus: Its Syntax and Semantics. 2. Amsterdam: Elsevier Science Publishers B.V.; 1984. [Google Scholar]
- 2.Becker H, Blanchette JC, Waldmann U, Wand D. A transfinite Knuth–Bendix order for lambda-free higher-order terms. In: de Moura L, editor. Automated Deduction – CADE 26; Cham: Springer; 2017. pp. 432–453. [Google Scholar]
- 3.Bentkamp A, Blanchette J, Tourret S, Vukmirović P, Waldmann U. Superposition with lambdas. In: Fontaine P, editor. Automated Deduction – CADE 27; Cham: Springer; 2019. pp. 55–73. [Google Scholar]
- 4.Benzmüller C, Sultana N, Paulson LC, Theiß F. The higher-order prover Leo-II. J. Autom. Reasoning. 2015;55(4):389–404. doi: 10.1007/s10817-015-9348-y. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 5.Bhayat, A., Reger, G.: A combinator-based superposition calculus for higher-order logic. In: The 10th International Joint Conference on Automated Reasoning (IJCAR) (2020)
- 6.Bhayat, A., Reger, G.: A Knuth-Bendix-like ordering for orienting combinator equations (technical report). Technical report, University of Mancester (2020). https://easychair.org/publications/preprint_open/rXSk
- 7.Blanchette JC, Waldmann U, Wand D. A lambda-free higher-order recursive path order. In: Esparza J, Murawski AS, editors. Foundations of Software Science and Computation Structures; Heidelberg: Springer; 2017. pp. 461–479. [Google Scholar]
- 8.Blanqui F, Jouannaud J-P, Rubio A. The computability path ordering: the end of a quest. In: Kaminski M, Martini S, editors. Computer Science Logic; Heidelberg: Springer; 2008. pp. 1–14. [Google Scholar]
- 9.Bofill, M., Godoy, G., Nieuwenhuis, R., Rubio, A.: Paramodulation with non-monotonic orderings. In: Proceedings - Symposium on Logic in Computer Science, August 1999
- 10.Brown CE. Satallax: an automatic higher-order prover. In: Gramlich B, Miller D, Sattler U, editors. Automated Reasoning; Heidelberg: Springer; 2012. pp. 111–117. [Google Scholar]
- 11.Czajka Ł, Kaliszyk C. Hammer for Coq: automation for dependent type theory. J. Autom. Reasoning. 2018;61(1):423–453. doi: 10.1007/s10817-018-9458-4. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 12.Graf P. Substitution tree indexing. In: Hsiang J, editor. Rewriting Techniques and Applications; Heidelberg: Springer; 1995. pp. 117–131. [Google Scholar]
- 13.Hindley JR, Seldin JP. Lambda-Calculus and Combinators: An Introduction. 2. New York: Cambridge University Press; 2008. [Google Scholar]
- 14.Jouannaud, J.P., Rubio, A.: Polymorphic higher-order recursive path orderings. J. ACM 54(1) (2007). 10.1145/1206035.1206037
- 15.Kerber, M.: How to prove higher order theorems in first order logic. In: IJCAI, pp. 137–142, January 1991
- 16.Kop C, van Raamsdonk F. A higher-order iterative path ordering. In: Cervesato I, Veith H, Voronkov A, editors. Logic for Programming, Artificial Intelligence, and Reasoning; Heidelberg: Springer; 2008. pp. 697–711. [Google Scholar]
- 17.Lindblad, F.: https://github.com/frelindb/agsyHOL. Accessed 25 Sept 2019
- 18.Meng J, Paulson LC. Translating higher-order clauses to first-order clauses. J. Autom. Reasoning. 2008;40(1):35–60. doi: 10.1007/s10817-007-9085-y. [DOI] [Google Scholar]
- 19.Nieuwenhuis, R., Rubio, A.: Paramodulation-based theorem proving. In: Handbook of Automated Reasoning, vol. 1, pp. 371–443. Elsevier Press and MIT press, August 2001. 10.1016/B978-044450813-3/50009-6
- 20.Sekar, R., Ramakrishnan, I., Voronkov, A.: Term indexing, chap. 26. In: Robinson, A., Voronkov, A. (eds.) Handbook of Automated Reasoning, vol. II, pp. 1853–1964. Elsevier Science (2001)
- 21.Steen, A.: Extensional paramodulation for higher-order logic and its effective implementation Leo-III. Ph.D. thesis, Freie Universität Berlin (2018)
- 22.Sultana N, Blanchette JC, Paulson LC. Leo-II and Satallax on the Sledgehammer test bench. J. Appl. Logic. 2013;11(1):91–102. doi: 10.1016/j.jal.2012.12.002. [DOI] [Google Scholar]
- 23.van Raamsdonk F, Severi P, Sørensen M, Xi H. Perpetual reductions in lambda calculus. Inf. Comput. 1999;149(2):173–225. doi: 10.1006/inco.1998.2750. [DOI] [Google Scholar]



