Skip to main content
Springer Nature - PMC COVID-19 Collection logoLink to Springer Nature - PMC COVID-19 Collection
. 2020 May 30;12166:259–277. doi: 10.1007/978-3-030-51074-9_15

A Knuth-Bendix-Like Ordering for Orienting Combinator Equations

Ahmed Bhayat ‡,, Giles Reger ‡,
Editors: Nicolas Peltier8, Viorica Sofronie-Stokkermans9
PMCID: PMC7324232

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 Inline graphic-expressions using combinators. It is well known that the set of combinators Inline graphic and Inline graphic is sufficient to translate any Inline graphic-expression. For purposes of completeness, these combinators must be axiomatised: Inline graphic, Inline graphic and Inline graphic. 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 Inline graphic axiom onto the right-hand of the Inline graphic axiom. The result is Inline graphic. 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 Inline graphic-, Inline graphic- and Inline graphic-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 Inline graphic-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 Inline graphic-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 Inline graphic introduced by Becker et al. [2]. Our new ordering, Inline graphic, 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 Inline graphic 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 Inline graphic-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 Inline graphic over lambda superposition as developed in [3].

  • A superposition calculus parameterised by Inline graphic 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 Inline graphic 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 Inline graphic 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 Inline graphic is to semantically lift a ground ordering, i.e., to define Inline graphic to hold iff Inline graphic for all grounding substitutions Inline graphic. Such an ordering in non-computable and both our methods attempt to approximate it (Sect. 3).

  • A set of proofs that the introduced Inline graphic 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 Inline graphic be a set of type variables and Inline graphic be a set of type constructors with fixed arities. It is assumed that a binary type constructor Inline graphic is present in Inline graphic which is written infix. The set of types is defined: graphic file with name 492926_1_En_15_Figa_HTML.jpg

The notation Inline graphic is used to denote a tuple or list of types or terms depending on the context. A type declaration is of the form Inline graphic where Inline graphic is a type and all type variables in Inline graphic appear in Inline graphic. Let Inline graphic be a set of typed function symbols and Inline graphic a set of variables with associated types. It is assumed that Inline graphic contains the following function symbols, known as basic combinators:

graphic file with name M39.gif

The set of terms over Inline graphic and Inline graphic is defined below. In what follows, type subscripts, and at times even type arguments, are omitted. graphic file with name 492926_1_En_15_Figb_HTML.jpg

The type of the term Inline graphic is Inline graphic. Following [2], terms of the form Inline graphic are called applications. Non-application terms are called heads. A term can uniquely be decomposed into a head and n arguments. Let Inline graphic. Then Inline graphic where Inline graphic could be a variable or constant applied to possibly zero type arguments. The symbol Inline graphic denotes a member of Inline graphic, whilst Inline graphic denotes a member of Inline graphic. These symbols are only used when the combinator is assumed to have a full complement of arguments. Thus, in Inline graphic, Inline graphic is assumed. The symbols Inline graphic are reserved for variables, Inline graphic for non-combinator constants and Inline graphic 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 Inline graphic or Inline graphic, then Inline graphic (type arguments have no position). If Inline graphic then Inline graphic. 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 Inline graphic (denoted Inline graphic) if Inline graphic. Positions p and Inline graphic are incomparable (denoted Inline graphic) if neither Inline graphic nor Inline graphic, nor Inline graphic. By Inline graphic, the number of symbols occurring in t is denoted. By Inline graphic the multiset of variables in t is denoted. The expression Inline graphic 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 Inline graphic (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 Inline graphic of p such that Inline graphic is not a partially applied combinator if such a position exists. For a position Inline graphic, p is a stable position in t if Inline graphic is not defined or Inline graphic is not a combinator. A stable subterm is a subterm occurring at a stable position and is denoted Inline graphic. We call Inline graphic a stable context and drop the position where it is not relevant. For example, the subterm Inline graphic is not stable in Inline graphic, Inline graphic (in both cases, Inline graphic) and Inline graphic (Inline graphic is not a first-order subterm), but is in Inline graphic and Inline graphic. A subterm that is not stable is known as an unstable subterm.

The notation Inline graphic denotes an arbitrary subterm u of t that occurs at position p and may be unstable. The notation Inline graphic (or Inline graphic) denotes the term t containing n non-overlapping subterms Inline graphic to Inline graphic. By Inline graphic, 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; Inline graphic, Inline graphic Inline graphic, Inline graphic, Inline graphic and Inline graphic. A term t weak-reduces to a term Inline graphic in one step (denoted Inline graphic) if Inline graphic and there exists a combinator axiom Inline graphic and substitution Inline graphic such that Inline graphic and Inline graphic. The term Inline graphic in t is called a weak redex or just redex. By Inline graphic, the reflexive transitive closure of Inline graphic is denoted. If term t weak-reduces to term Inline graphic in n steps, we write Inline graphic. Further, if there exists a weak-reduction path from a term t of length n, we say that Inline graphic. Weak-reduction is terminating and confluent as proved in [13]. By Inline graphic, 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 Inline graphic. 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 Inline graphic 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 Inline graphic-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 Inline graphic-reduction strategy. We begin by proving the fundamental lemma of maximality for combinatory terms.

Lemma 1 (Fundamental Lemma of Maximality)

Inline graphic where Inline graphic if Inline graphic and is 0 otherwise. The lemma holds for Inline graphic if Inline graphic, Inline graphic if Inline graphic and Inline graphic otherwise.

Proof

Assume that Inline graphic. Then any maximal reduction from Inline graphic is of the form: Inline graphic where Inline graphic, Inline graphic, Inline graphic and Inline graphic. Thus, Inline graphic. There is another method of reducing Inline graphic to s:

graphic file with name M134.gif

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: Inline graphic

Conversely, assume that Inline graphic is not Inline graphic. We prove that the formula holds if Inline graphic. The other cases are similar. If Inline graphic, any maximal reduction from Inline graphic must be of the form: Inline graphic where Inline graphic, Inline graphic and Inline graphic. There is another method of reducing Inline graphic to s:

graphic file with name M146.gif

Thus, we have that Inline graphic. Since Inline graphic is the length of the maximal reduction, equality must hold.

Lemma 2

Define a map Inline graphic from Inline graphic to Inline graphic as follows: graphic file with name 492926_1_En_15_Figc_HTML.jpg

The reduction strategy Inline graphic 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 Inline graphic. 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 Inline graphic 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 Inline graphic. A substitution Inline graphic respects the mapping ghd, if for all variables x, Inline graphic.

Let Inline graphic be a total well-founded ordering or precedence on Inline graphic. The precedence Inline graphic is extended to arbitrary heads by defining Inline graphic iff Inline graphic and Inline graphic. Let Inline graphic be a function from Inline graphic to Inline graphic that denotes the weight of a function symbol and Inline graphic a function from Inline graphic to Inline graphic denoting the weight of a term. Let Inline graphic. For all constants Inline graphic, Inline graphic. The weight of a term is defined recursively:

graphic file with name 492926_1_En_15_Equ4_HTML.gif

The graceful higher-order basic Knuth-Bendix order Inline graphic is defined inductively as follows. Let Inline graphic and Inline graphic. Then Inline graphic if Inline graphic and any of the following are satisfied:

Z1

Inline graphic

Z2

Inline graphic and Inline graphic

Z3

Inline graphic and Inline graphic

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 Inline graphic. This simple approach runs into problems with regards to stability under substitution, a crucial feature for any ordering used in superposition.

Consider the terms Inline graphic and Inline graphic. As the length of the maximum reduction from both terms is 0, the terms would be compared using Inline graphic resulting in Inline graphic as Inline graphic. Now, consider the substitution Inline graphic. Then, Inline graphic whilst Inline graphic resulting in Inline graphic.

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, Inline graphic, ensures stability. However, this approach is over-constrained and prevents the comparison of terms such as Inline graphic and Inline graphic despite the fact that for all substitutions Inline graphic, Inline graphic. 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 Inline graphic ordering is not defined over typed terms, type arguments are replaced by equivalent term arguments before comparison. The translation Inline graphic from Inline graphic 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 Inline graphic. If there exists a position p such Inline graphic is a variable, then t is a type-1 term.

Definition 2 (Type-2 term)

A term Inline graphic where Inline graphic is a type-2 term.

The translation to untyped terms is defined as follows. If t is a type variable Inline graphic, then Inline graphic. If Inline graphic, then Inline graphic. If t is a term variable x, then Inline graphic. If t is a type-1 or type-2 term, then Inline graphic is a fresh variable Inline graphic. If Inline graphic, then Inline graphic. Finally, if Inline graphic, then Inline graphic.

An untyped term t weak reduces to an untyped term Inline graphic in one step if Inline graphic and there exists a combinator axiom Inline graphic and substitution Inline graphic such that Inline graphic and Inline graphic. The aim of the ordering presented here is to parametrise the superposition calculus. For this purpose, the property that for terms t and Inline graphic, Inline graphic, is desired. To this end, the following lemma is proved.

Lemma 3

For all term ground polymorphic terms t and Inline graphic, it is the case that Inline graphic.

Proof

The Inline graphic direction can be proved by a straightforward induction on the t. The opposite direction is proved by an induction on Inline graphic.

Corollary 1

A straightforward corollary of the above lemma is that for all term-ground polymorphic terms t, Inline graphic.

The combinator orienting Knuth-Bendix order (approach 1) Inline graphic is defined as follows. For terms t and s, let Inline graphic and Inline graphic. Then Inline graphic if Inline graphic and:

R1

Inline graphic or,

R2

Inline graphic and Inline graphic.

Approach 2. Using approach 1, terms Inline graphic and Inline graphic are incomparable. Both are type-2 terms and therefore Inline graphic and Inline graphic. The variable condition obviously fails to hold between Inline graphic and Inline graphic. Therefore, we consider another approach which does not replace subterms with fresh variables. We introduce a new translation Inline graphic from Inline graphic 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 Inline graphic occur in t at position p and let Inline graphic be the shortest prefix of p such that Inline graphic is a combinator and for all positions Inline graphic between p and Inline graphic, Inline graphic is a combinator. Let Inline graphic be a prefix of p of length one shorter than Inline graphic if such a position exists and Inline graphic otherwise. Then Inline graphic is safe in t if Inline graphic is ground and Inline graphic 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 Inline graphic are unsafe because they affect x, whilst the combinator in Inline graphic is safe. The combinators in Inline graphic 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 Inline graphic and Inline graphic be untyped terms. The predicate Inline graphic holds if for every position p in Inline graphic such that Inline graphic and Inline graphic (not necessarily fully applied) is unsafe, then Inline graphic and for Inline graphic, Inline graphic. Further, for all p in Inline graphic such that Inline graphic, then Inline graphic and for Inline graphic, Inline graphic.

The definition of safe ensures that if safe(ts) and Inline graphic, then Inline graphic for any substitution Inline graphic a result we prove in Lemma 13. Consider terms Inline graphic and Inline graphic. We have that Inline graphic. However, it is not the case that safe(ts) because the condition that Inline graphic for all i is not met. Inline graphic. Now consider the substitution Inline graphic. Because this substitution duplicates the second argument in s and t, Inline graphic 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 Inline graphic and Inline graphic, then Inline graphic. Secondly, the predicate is transitive; Inline graphic.

There is a useful property that holds for non-ground terms t and s such that safe(ts).

Definition 6 (Semisafe)

Let t and s be untyped terms. Let Inline graphic be a term that occurs in s at p such that all head symbols above Inline graphic in s are combinators. Then semisafe(ts) if Inline graphic and for Inline graphic, Inline graphic.

It is clearly the case that Inline graphic. 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 Inline graphic and Inline graphic respective, we have semisafe(ts), then we have Inline graphic.graphic file with name 492926_1_En_15_Figd_HTML.jpg

For example Inline graphic holds where Inline graphic and Inline graphic. In this case Inline graphic and Inline graphic. There exists and injective total function from A to B that matches the requirements by relating Inline graphic to Inline graphic. However, the variable condition does not hold in either direction if Inline graphic and Inline graphic. In this case, Inline graphic cannot be related to Inline graphic since the condition that Inline graphic is not fulfilled.

We now define the combinator orienting Knuth-Bendix order (approach 2) Inline graphic. For terms t and s, let Inline graphic and Inline graphic. Then Inline graphic if Inline graphic and:

R1

Inline graphic or,

R2

Inline graphic and Inline graphic.

Lemma 4

For all ground instances of combinator axioms Inline graphic, we have Inline graphic.

Proof

Since for all ground instances of the axioms Inline graphic, we have Inline graphic, the theorem follows by an application of R1.

It should be noted that for non-ground instances of an axiom Inline graphic, we do not necessarily have Inline graphic since l and r may be incomparable. This is no problem since the definition of Inline graphic could easily be amended to have Inline graphic by definition if Inline graphic 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 Inline graphic 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 Inline graphic 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 Inline graphic.

Proof

Let Inline graphic. It is obvious that Inline graphic. Therefore Inline graphic can only be derived by rule R2. However, this is precluded by the irreflexivity of Inline graphic.

Theorem 2 (Transitivity)

For terms s, t and u, if Inline graphic and Inline graphic then Inline graphic.

Proof

Let Inline graphic, Inline graphic and Inline graphic. From Inline graphic and Inline graphic, Inline graphic by the definition of Inline graphic and the application of the transitivity of safe. If Inline graphic or Inline graphic then Inline graphic and Inline graphic follows by an application of rule R1. Therefore, suppose that Inline graphic. Then it must be the case that Inline graphic and Inline graphic. It follows from the transitivity of Inline graphic that Inline graphic and thus Inline graphic.

Theorem 3 (Ground Totality)

Let s and t be ground terms that are not syntactically equal. Then either Inline graphic or Inline graphic.

Proof

Let Inline graphic and Inline graphic. If Inline graphic then by R1 either Inline graphic or Inline graphic. Otherwise, Inline graphic and Inline graphic are compared using Inline graphic and either Inline graphic or Inline graphic holds by the ground totality of Inline graphic and the injectivity of Inline graphic.

Theorem 4 (Subterm Property for Ground Terms)

If t and s are ground and t is a proper subterm of s then Inline graphic.

Proof

Let Inline graphic and Inline graphic. Since t is a subterm of s, Inline graphic is a subterm of Inline graphic and Inline graphic because any weak reduction in Inline graphic is also a weak reduction in Inline graphic. If Inline graphic, the theorem follows by an application of R1. Otherwise Inline graphic and Inline graphic are compared using Inline graphic and Inline graphic holds by the subterm property of Inline graphic. Thus Inline graphic.

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 Inline graphic and Inline graphic for t and s such that Inline graphic. 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 516 are all untyped, formed by translating polymorphic terms.

Lemma 5

Inline graphic if Inline graphic is not a fully applied combinator.

Lemma 6

Let Inline graphic. Then Inline graphic if Inline graphic is a fully applied combinator.

Lemma 7

Let Inline graphic be terms such that for each Inline graphic, Inline graphic. Let Inline graphic be terms with the same property. Moreover, let Inline graphic for Inline graphic. Let Inline graphic and Inline graphic where each Inline graphic and Inline graphic is at position Inline graphic in s and Inline graphic. If the Inline graphic redex in s is within Inline graphic for some i, then the Inline graphic redex in Inline graphic is within Inline graphic unless Inline graphic is in normal form.

Proof

Proof is by induction on Inline graphic. If u has a hole at head position, then Inline graphic and Inline graphic where Inline graphic and Inline graphic. Assume that the Inline graphic redex of s is in Inline graphic. Further, assume that Inline graphic. Then, for some i in Inline graphic, it must be the case that Inline graphic. Let j be the smallest index such that Inline graphic. Then by the definition of Inline graphic, Inline graphic and the Inline graphic redex of Inline graphic is in Inline graphic.

Suppose that the Inline graphic redex of s is not in Inline graphic. This can only be the case if Inline graphic in which case Inline graphic as well. In this case, by the definition of Inline graphic, Inline graphic where Inline graphic for Inline graphic. Without loss of generality, assume that the Inline graphic redex of Inline graphic occurs inside Inline graphic. Then Inline graphic must be a subterm of Inline graphic. Assume that Inline graphic and thus Inline graphic. Since for all i, Inline graphic and Inline graphic only differ at positions where one contains a Inline graphic and the other contains a Inline graphic and Inline graphic for Inline graphic, we have that Inline graphic implies Inline graphic. Thus, using the definition of Inline graphic, Inline graphic. The induction hypothesis can be applied to Inline graphic and Inline graphic to conclude that the Inline graphic redex of Inline graphic occurs inside Inline graphic. The lemma follows immediately.

If u does not have a hole at its head, then Inline graphic and Inline graphic where Inline graphic is not a fully applied combinator other than Inline graphic (if it was, the Inline graphic redex would be at the head).

If Inline graphic is not a combinator, the proof follows by a similar induction to above. Therefore, assume that Inline graphic. It must be the case that Inline graphic otherwise the Inline graphic redex in s would be at the head and not within a Inline graphic. By the definition of Inline graphic, Inline graphic. Let the Inline graphic redex of Inline graphic occur inside Inline graphic. Then Inline graphic is a subterm of Inline graphic. If Inline graphic then Inline graphic and Inline graphic. By the induction hypothesis, the Inline graphic redex of Inline graphic occurs in Inline graphic.

Lemma 8

Let Inline graphic be terms such that for Inline graphic, Inline graphic. Then for all contexts Inline graphic, if Inline graphic Inline graphic then either:

  1. Inline graphic where Inline graphic or

  2. Inline graphic where Inline graphic

Proof

Let Inline graphic and let Inline graphic be the positions of Inline graphic in s. Since s is reducible, there must exist a p such that Inline graphic is a redex.

If Inline graphic for some i, there exists a Inline graphic such that Inline graphic. Then, Inline graphic Inline graphic. Let Inline graphic. We thus have that Inline graphic and thus Inline graphic.

It cannot be the case that Inline graphic for any i because Inline graphic is not a combinator for any Inline graphic. In the case where Inline graphic or Inline graphic for all i, we have that Inline graphic and Inline graphic is a redex where Inline graphic. Let Inline graphic be formed from Inline graphic by reducing its redex at p. Then , Inline graphic

Lemma 9

Let Inline graphic be terms such that for each Inline graphic, Inline graphic. Let Inline graphic be terms with the same property. Then:

  1. If Inline graphic for all i in Inline graphic, then Inline graphic for all n holed contexts u.

  2. If Inline graphic for some Inline graphic and Inline graphic for Inline graphic, then Inline graphic for all n holed contexts u.

Proof

Let Inline graphic be the positions of the holes in u and let Inline graphic and Inline graphic. Proof is by induction on Inline graphic. We prove part (1) first:

Assume that Inline graphic. Then Inline graphic for Inline graphic. Now assume that Inline graphic. Then there must exist some position p such that Inline graphic is a redex. We have that Inline graphic for all Inline graphic as Inline graphic. Assume Inline graphic for some Inline graphic. But then, Inline graphic which contradicts the fact that Inline graphic for all i. Therefore, for all Inline graphic either Inline graphic or Inline graphic. But then, if Inline graphic is a redex, so must Inline graphic be, contradicting the fact that Inline graphic. Thus, we conclude that Inline graphic.

Assume that Inline graphic. Let Inline graphic. By Lemma 8 either Inline graphic Inline graphic where Inline graphic for Inline graphic or Inline graphic where Inline graphic. In the first case, by Lemma 7 and Inline graphic we have Inline graphic Inline graphic where Inline graphic. By the induction hypothesis Inline graphic and thus Inline graphic. In the second case, Inline graphic where Inline graphic. Again, the induction hypothesis can be used to show Inline graphic and the theorem follows.

We now prove part (2); Inline graphic must be greater than 0. Again, let Inline graphic and Inline graphic. If Inline graphic Inline graphic and Inline graphic, then by Lemma 7 Inline graphic Inline graphic where Inline graphic unless Inline graphic and the lemma follows by the induction hypothesis.

If Inline graphic, consider terms Inline graphic and Inline graphic. If Inline graphic or Inline graphic for some Inline graphic, then the induction hypothesis can be used to show Inline graphic and therefore Inline graphic. Otherwise, Inline graphic for all Inline graphic and Inline graphic. Part 1 of this lemma can be used to show that Inline graphic and thus Inline graphic. If Inline graphic, then Inline graphic 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) Inline graphic, and Inline graphic, then Inline graphic for all ground contexts Inline graphic.

Proof

Let Inline graphic, Inline graphic and Inline graphic. By Lemma 9 Part 2, we have that if Inline graphic, then Inline graphic. Thus, if Inline graphic was derived by R1, Inline graphic follows by R1. Otherwise, Inline graphic is derived by R2 and Inline graphic. By Lemma 9 Part 1, Inline graphic follows. Thus, Inline graphic is compared with Inline graphic by R2 and Inline graphic by the compatibility with contexts of Inline graphic.

Lemma 10

Inline graphic and Inline graphic.

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, Inline graphic is of the form Inline graphic . By the definition of a stable subterm Inline graphic cannot be a fully applied combinator and thus by Lemma 5 we have that Inline graphic. If Inline graphic is not a combinator, then Inline graphic Inline graphic Inline graphic Inline graphic follows from Lemma 9 Part 2. Otherwise, Inline graphic is a partially applied combinator and Inline graphic is a smaller stable context than u. The induction hypothesis can be used to conclude that Inline graphic Inline graphic Inline graphic Inline graphic and thus that Inline graphic. 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 Inline graphic and ground terms s and t, if Inline graphic then Inline graphic.

Proof

If Inline graphic then by Lemma 10, Inline graphic holds and then by an application of R1 we have Inline graphic. Otherwise, if Inline graphic, then by Lemma 10 we have that Inline graphic. Thus Inline graphic and Inline graphic are compared using Inline graphic. By the compatibility with contexts of Inline graphic, Inline graphic holds and then by ofan application of R2 Inline graphic 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 Inline graphic:

  1. Inline graphic implies Inline graphic.

  2. Inline graphic and Inline graphic imply Inline graphic

The first is proved in Lemma 15. A slightly generalised version of (2) is proved in Lemma 14. Lemmas 1113 are helper lemmas used in the proof of the above two properties.

Lemma 11

For a single hole context Inline graphic such that the hole does not occur below a fully applied combinator and any term t, Inline graphic.

Proof

Proof to be found in report.

Lemma 12

Let Inline graphic and Inline graphic be terms such that for Inline graphic and for Inline graphic, Inline graphic. Further, let Inline graphic and Inline graphic. Assume that semisafe(ts) holds. Then Inline graphic.

Proof

Proof to be found in report.

Lemma 13

Let t and s be non-ground terms such that Inline graphic for some Inline graphic and safe(ts). Then, for any substitution Inline graphic, Inline graphic and Inline graphic.

Proof

Proof to be found in report.

Lemma 14

For terms t and s such that Inline graphic holds and Inline graphic for some Inline graphic, for all substitutions Inline graphic, Inline graphic.

Proof

If s and t are ground, the theorem is trivial. If s is ground, then Inline graphic. If s is not ground, then Inline graphic 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 Inline graphic implies safe(ts) and Lemma 13 can be invoked to prove the lemma. Therefore, assume that both have non-variable, non-fully applied combinator heads.

Let Inline graphic and Inline graphic where Inline graphic are all the non-ground, top-level, first-order subterms of the form Inline graphic or Inline graphic in s. By the variable condition, we have that there exists a total injective function respecting the given conditions from the Inline graphic to non-ground, top-level, first-order subterms of t of the form Inline graphic or Inline graphic. Let Inline graphic be the terms related to Inline graphic by this function. Without loss of generality, assume that this function relates Inline graphic to Inline graphic, Inline graphic to Inline graphic and so on. For Inline graphic, Inline graphic for Inline graphic. This follows from the fact that since Inline graphic and Inline graphic are both non-ground and Inline graphic, we have Inline graphic and can therefore invoke Lemma 12.

Let Inline graphic. Note that Inline graphic could be negative. By Lemma 11, Inline graphic and Inline graphic. Thus, Inline graphic. Therefore, Inline graphic. Lemma 13 can be used to show that for all i, Inline graphic. Because Inline graphic is ground, it follows Inline graphic. To conclude the proof:graphic file with name 492926_1_En_15_Fige_HTML.jpg

Lemma 15

For terms t and s such that Inline graphic holds and for all substitutions Inline graphic, Inline graphic.

Proof

Let Inline graphic and Inline graphic where Inline graphic are all the non-ground, top-level, first-order subterms of the form Inline graphic or Inline graphic in s. By the variable condition, we have that there exists a total injective function respecting the given conditions from the Inline graphic to non-ground, top-level, first-order subterms of t of the form Inline graphic or Inline graphic. Let Inline graphic be the terms related to Inline graphic by this function. Without loss of generality, assume that this function relates Inline graphic to Inline graphic, Inline graphic to Inline graphic and so on. By the definition of the variable condition, we have that Inline graphic must be ground. This implies that any non-ground subterms of Inline graphic must be subterms of some Inline graphic for Inline graphic.

Assume that for some i and Inline graphic, Inline graphic is a non-ground, top-level, first-order subterm of the form Inline graphic or Inline graphic. We show that Inline graphic is a non-ground, top-level, first-order subterm of Inline graphic and Inline graphic. This implies the existence of a total, injective function from the multiset of non-ground, top-level first-order subterms in Inline graphic to the like multiset of Inline graphic in turn proving Inline graphic.

From Lemma 13, it can be shown that for Inline graphic, Inline graphic. By the subterm property of safety, this implies that Inline graphic.

To show that Inline graphic must be a non-ground, top-level, first-order subterm in Inline graphic, it can be assumed that this not the case. This easily leads to a contradiction with Inline graphic.

Lemma 16

Let t be a polymorphic term and Inline graphic be a substitution. We define a new substitution Inline graphic such that the domain of Inline graphic is Inline graphic. Define Inline graphic. For all terms t, Inline graphic.

Proof

Via a straightforward induction on t.

Theorem 7 (Stability under Substitution)

If Inline graphic then Inline graphic for all substitutions Inline graphic that respect the ghd mapping.

Proof

Let Inline graphic and Inline graphic. Let Inline graphic be defined as per Lemma 16. First, we show that if R1 was used to derive Inline graphic and thus Inline graphic then Inline graphic and thus Inline graphic because Inline graphic and Inline graphic.

From Lemma 15 and Inline graphic, Inline graphic holds. Furthermore, if Inline graphic, then by Lemma 14 Inline graphic and Inline graphic by an application of R1.

On the other hand, if Inline graphic, then R2 was used to derive Inline graphic. By Lemma 14 Inline graphic. If Inline graphic, then this is the same as the former case. Otherwise Inline graphic and Inline graphic and Inline graphic are compared using R2. From the stability under substitution of Inline graphic, Inline graphic follows and Inline graphic can be concluded.

Theorem 8 (Well-foundedness)

There exists no infinite descending chain of comparisons Inline graphic.

Proof

Assume that such a chain exists. For each Inline graphic derived by R1, we have that Inline graphic. For each Inline graphic derived by R2, we have that Inline graphic. Therefore the number of times Inline graphic by R1 in the infinite chain must be finite and there must exist some m such that for all Inline graphic, Inline graphic by R2. Therefore, there exists an infinite sequence of Inline graphic comparisons Inline graphic. This contradicts the well-foundedness of Inline graphic.

Theorem 9 (Coincidence with First-Order KBO)

Let Inline graphic be the first-order KBO as described by Becker et al. in [2]. Assume that Inline graphic and Inline graphic are parameterised by the same precedence Inline graphic and that Inline graphic always compares tuples using the lexicographic extension operator. Then Inline graphic and Inline graphic always agree on first-order terms.

Proof

Let Inline graphic and Inline graphic. Since s and t are first-order, Inline graphic and Inline graphic. Thus, Inline graphic and Inline graphic will always be compared by Inline graphic. Since Inline graphic coincides with Inline graphic on first-order terms, so does Inline graphic.

Examples

To give a flavour of how the ordering behaves, we provide a number of examples.

Example 1

Consider the terms (ignoring type arguments) Inline graphic and Inline graphic. From the definition of the translation Inline graphic, we have that Inline graphic and Inline graphic. Since Inline graphic and Inline graphic, we have that Inline graphic.

Example 2

Consider the terms Inline graphic and Inline graphic. Here Inline graphic 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 Inline graphic and Inline graphic. The two terms are comparable as the variable condition relates subterm Inline graphic in s to subterm Inline graphic in t. The unsafe combinator Inline graphic and variable x are in the same position in each subterm. As Inline graphic, Inline graphic.

Example 4

Consider terms Inline graphic and Inline graphic. This is very similar to the previous example, but in this case the terms are incomparable. Let Inline graphic be a name for the subterm Inline graphic in s and Inline graphic a name for the subterm Inline graphic. The variable y occurs in different positions in Inline graphic and Inline graphic. Therefore, Inline graphic cannot be related to t by the variable condition and the two terms are incomparable.

Example 5

Consider terms Inline graphic and Inline graphic. The variable condition holds between t and s by relating Inline graphic to Inline graphic. The combinator Inline graphic in s is not unsafe and therefore does not need to be related to a combinator in t.

Since Inline graphic, Inline graphic. Intuitively, this is safe because a substitution for x in t can duplicate Inline graphic whose maximum reduction length is 2 whilst a substitution for x in s can only duplicate Inline graphic whose maximum reduction length is 0.

Conclusion and Discussion

We have presented an ordering that orients all ground instances of Inline graphic, Inline graphic, Inline graphic, Inline graphic and Inline graphic 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 Inline graphic, some superposition is required beneath variables. However, because terms with functional heads are compatible with all contexts, such inference are quite restricted.

The Inline graphic 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 Inline graphic-equivalence classes. Non-ground terms are compared using a quasiorder, Inline graphic, such that Inline graphic iff for all grounding substitutions Inline graphic, Inline graphic. Consider terms Inline graphic and Inline graphic and grounding substitutions Inline graphic and Inline graphic. By ground totality of Inline graphic it must be the case that either Inline graphic or Inline graphic. Without loss of generality assume the first. Then, neither Inline graphic nor Inline graphic since Inline graphic and Inline graphic.

The Inline graphic ordering allows weak reduction (or Inline graphic-reduction) to be treated as part of the superposition calculus. This allows terms t and Inline graphic such that Inline graphic (or Inline graphic) to be considered separate terms resulting in terms such as t and s given above being comparable. Since Inline graphic, t and s are compared using Inline graphic with stability under substitution ensured by the stability under substitution of Inline graphic.

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]

Articles from Automated Reasoning are provided here courtesy of Nature Publishing Group

RESOURCES