An Innermost DP Framework for Constrained Higher-Order Rewriting
Abstract
Logically constrained simply-typed term rewriting systems (LCSTRSs) are a higher-order formalism for program analysis with support for primitive data types. The termination problem of LCSTRSs has been studied so far in the setting of full rewriting. This paper modifies the higher-order constrained dependency pair framework to prove innermost termination, which corresponds to the termination of programs under call by value. We also show that the notion of universal computability with respect to innermost rewriting can be effectively handled in the modified, innermost framework, which lays the foundation for open-world termination analysis of programs under call by value via LCSTRSs.
Keywords and phrases:
Higher-order term rewriting, constrained rewriting, innermost termination, call by value, open-world analysis, dependency pairsFunding:
Liye Guo: NWO VI.Vidi.193.075, project “CHORPE”.Copyright and License:
2012 ACM Subject Classification:
Theory of computation Equational logic and rewriting ; Theory of computation Logic and verificationAcknowledgements:
We thank the reviewers for helpful comments that allowed us to improve the presentation.Editors:
Maribel FernándezSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
In the study of term rewriting, termination has been an active area of research for decades. Hundreds of different termination techniques have been developed, along with a variety of (fully automatic) termination analyzers that compete against each other in an annual competition [6]. Many of those techniques have been adapted to different styles of term rewriting (e.g., context-sensitive, relative, constrained and higher-order).
In a recent work [22], we have introduced logically constrained simply-typed term rewriting systems (LCSTRSs): a variant of term rewriting that incorporates both higher-order terms and primitive data types such as integers and bit vectors. This formalism is proposed to be a stepping stone toward functional programming languages: by adapting analysis techniques from traditional term rewriting to LCSTRSs, we obtain many of the ingredients needed by the analysis of functional programs, without limiting ourselves to a particular language.
Our long-term goal is to use LCSTRSs as an intermediate verification language in a two-step process to prove correctness properties (e.g., termination, reachability and equivalence) of a program written in a real-world programming language with higher-order features (e.g., OCaml and Scala): (1) soundly translate to an LCSTRS (i.e., if is, say, terminating, then so is ), and (2) analyze . This approach has been successfully applied across paradigms to multiple languages, such as Prolog [44, 17], Haskell [16], Java [39] and C [14], via various flavors of term rewriting. We consider LCSTRSs a highly suitable intermediate language that allows for a direct representation of many programming language features. We particularly study termination, both for its own relevance, and due to the fact that it allows the reduction relation to be used as a decreasing measure in induction, which is a powerful aid to proving many other properties.
Most modern termination techniques for term rewriting are defined within the dependency pair (DP) framework [3, 18], which essentially studies groups of recursive function calls. In [21], a higher-order variant of this framework [35, 36, 34, 13] has been adapted to LCSTRSs, and its usefulness in open-world termination analysis has also been established through the notion of universal computability. However, this method still faces limitations: many commonly used DP processors (termination techniques within the DP framework) have not yet been extended to the higher-order and constrained setting, and whereas the first-order DP framework can deal with both full rewriting and innermost rewriting, most higher-order versions – including the one for LCSTRSs – only concern full rewriting. The incapability to handle innermost rewriting is particularly unfortunate since many functional languages use call-by-value evaluation, which largely corresponds to innermost rewriting.
In this paper, we define the first innermost DP framework for LCSTRSs. We shall present DP processors that explicitly benefit from innermost or call-by-value rewriting.
Contributions.
We start in Section 2 with the preliminaries on LCSTRSs and the notion of computability, which is fundamental to static dependency pairs. Then this paper’s contributions follow:
-
In Section 3, we discuss the innermost and the call-by-value strategies, and present a transformation that allows us to better utilize the call-by-value setting.
-
In Section 5, we present an innermost DP framework, which can be used to prove innermost (and call-by-value) termination through the use of various DP processors. We first review three classes of existing DP processors defined for full rewriting, and see how they adapt to the innermost setting. Then we define three more, specifically for the innermost DP framework:
-
–
In Section 5.2, following the idea of chaining from first-order rewriting with integer constraints [10, 11, 15], we propose a class of DP processors that merge call-by-value dependency pairs. These DP processors can be particularly useful in the analysis of automatically generated systems, which often give rise to a large body of dependency pairs representing intermediate steps of computation.
-
–
In Section 5.3, we extend the idea of usable rules [3, 19, 24]. While this idea has been applied to higher-order rewriting [2, 40], logical constraints still pose challenges. In the innermost setting, we are able to define this class of DP processors in their most powerful form, which permanently removes rewrite rules from a DP problem.
-
–
In Section 5.4, we show how usable rules with respect to an argument filtering may be defined, and how this technique makes first-order reduction pairs applicable. This way a large number of first-order techniques can be employed for higher-order termination without a higher-order modification; to be applied to LCSTRSs, those reduction pairs only need to adapt to logical constraints.
-
–
-
In Section 6, we discuss the notion of universal computability [21] with respect to innermost rewriting. We will see that the employment of usable rules significantly increases the potential of the innermost DP framework to analyze universal computability: now we can use fully-fledged reduction pair processors for open-world termination analysis, and thereby harness one of the main benefits of the DP framework in this practical setting.
-
We have implemented all the results in our open-source analyzer Cora. The implementation and the evaluation thereof are described in Section 7.
2 Preliminaries
This section collects the preliminaries from the literature. First, we recall the definition of an LCSTRS [22].111In contrast to [22] and following [21], we assume that is a pattern in every rewrite rule . For notational convenience, we also assume that , which can be guaranteed by a simple transformation and is also adopted in the second half of [22]. Then, we recollect from [13] the definition of computability (with accessibility), particularly under the strategies. We borrow several definitions from the phrasing in [21].
2.1 Logically Constrained STRSs
Terms Modulo Theories.
Given a non-empty set of sorts (or base types), the set of (simple) types over is generated by the grammar . Right-associativity is assigned to so we can omit some parentheses. Given disjoint sets and , whose elements we call function symbols and variables, respectively, the set of pre-terms over and is generated by the grammar . Left-associativity is assigned to the juxtaposition operation, called application, so for instance stands for .
We assume every function symbol and variable is assigned a unique type. Typing works as expected: if pre-terms and have types and , respectively, has type . The set of terms over and consists of pre-terms that have a type. We write if a term has type . We assume there are infinitely many variables of each type.
The set of variables in is defined by for , for and . A term is called ground if .
For constrained rewriting, we make further assumptions. First, we assume there is a distinguished subset of , called the set of theory sorts. The grammar generates the set of theory types over . Note that a theory type is essentially a non-empty list of theory sorts. Next, we assume there is a distinguished subset of , called the set of theory symbols, and the type of every theory symbol is in , which means the type of any argument passed to a theory symbol is a theory sort. Theory symbols whose type is a theory sort are called theory values.222Such theory symbols are simply called values in [22]. In this paper, we call them differently so that they are not to be confused with term values as in call by value. Elements of are called theory terms.
Theory symbols are interpreted in an underlying theory: given an -indexed family of sets , we extend it to a -indexed family by letting be the set of mappings from to ; an interpretation of theory symbols is a -indexed family of mappings where assigns to each theory symbol of type an element of and is bijective if . Given an interpretation of theory symbols , we extend each indexed mapping to one that assigns to each ground theory term of type an element of by letting be . We write just when the type can be deduced.
Example 1.
Let be . Then is a theory type over while is not. Let be where and for all . The theory values are the elements of . Let be , be the identity mapping and be the mapping . The interpretation of is the mapping (note that functions in our setting are curried).
Type-preserving mappings from to are called substitutions. The domain of a substitution is the set . Let denote the substitution such that and for all . Every substitution extends to a type-preserving mapping from to . We write for and define it as follows: for , for and .
A context is a term containing a hole. That is, if we let be a special symbol and assign to it a type , a context is an element of such that occurs in exactly once. Given a term , let denote the term produced by replacing in with .
A term is called a (maximally applied) subterm of a term , written as , if either , where , or where and ; i.e., for that is not of form . We write and call a proper subterm of if and .
Constrained Rewriting.
Constrained rewriting requires the theory sort : we henceforth assume that , , , and . Moreover, we require that includes symbols , and for each sort also a symbol , interpreted respectively as conjunction and equality operators.
A logical constraint is a theory term such that has type and the type of each variable in is a theory sort. A (constrained) rewrite rule is a triple where and are terms which have the same type, is a logical constraint, , and is a pattern that takes the form for some and contains at least one function symbol in . Here a pattern is a term whose subterms are either for some or a variable.333As usual in term rewriting, we do not require that each variable occurs at most once in a pattern. A substitution is said to respect a logical constraint if is a theory value for all and ; respects the rule if it respects .
A logically constrained simply-typed term rewriting system (LCSTRS) collects the above data – , , , , , and – along with a set of rewrite rules. We usually let alone stand for the system. The set induces the rewrite relation over terms: if and only if there exists a context such that one of the following holds:
-
(1)
and for some and substitution which respects , or
-
(2)
and for some theory symbol and some theory values with and .
If due to the second condition, we also write and call it a calculation step. Theory symbols that are not a theory value are called calculation symbols. Let denote the (unique) -normal form of , i.e., the term such that and for any . For example, if is not a calculation symbol, or if .
A term is in normal form if there is no term such that . Given an LCSTRS , the set contains all terms that are in normal form with respect to .
Given an LCSTRS , is called a defined symbol if there is at least one rewrite rule of the form . Let denote the set of defined symbols. Theory values and function symbols in are called constructors.
Example 2.
Consider the following LCSTRS , where , and :
We use infix notation for some binary operators, and omit logical constraints that are . Here is a rewrite sequence: .
Innermost Rewriting.
The innermost rewrite relation requires all the proper subterms of a redex to be in normal form: if and only if either (1) there exist a context , a substitution and a rewrite rule such that , for any proper subterm of and any , and respects , or (2) .
Similarly, for an LCSTRS we define the relation as reduction using where all proper subterms of a redex are in -normal form: if and only if either (1) there exist , and such that , for any proper subterm of and any , and respects , or (2) . Note that is the same as .
Call-By-Value Rewriting.
We may further restrict a redex by requiring each proper subterm to be a ground term value. Here a term value is either a variable or a term where is a function symbol, is a term value for all , and (1) if there is a rule , then ; (2) if is a calculation symbol, then it takes at least arguments (i.e., ). In this paper, we will typically refer to term values as just values. By definition, all theory values are values, and all values are in normal form.
The definition of the call-by-value rewrite relation follows the pattern of : if and only if either (1) there exist a context , a substitution and a rewrite rule such that , is a ground value for each proper subterm of , and respects , or (2) .
Example 3.
The rewrite sequence in Example 2 is not innermost (and therefore not call-by-value). An example of a call-by-value rewrite sequence is:
Note that the redex in the first step is , which does not have as subterm.
Example 4.
Consider the LCSTRS . Then the rewrite step is an innermost step, but not a call-by-value step. The reason is that the subterm of the redex is in normal form, but not a value: innermost rewriting also allows for rewriting above function calls that are not defined on the given arguments; in a language like OCaml, the computation would abort with an error.
2.2 Accessibility and Computability
Accessibility.
Assume given a sort ordering – a quasi-ordering over whose strict part is well-founded. We inductively define two relations and over and : for a sort and a type where is a sort and , if and for all , and if and for all .
Given a function symbol where is a sort, the set of the accessible argument positions of is defined as . A term is called an accessible subterm of a term , written as , if either , or for some and there exists such that . An LCSTRS is called accessible function passing (AFP) if there exists a sort ordering such that for all where and , there exists such that .
Example 5.
An LCSTRS is AFP (with equating all the sorts) if for all where and , the type of each proper subterm of is a sort. This is typical for many common examples of higher-order programs manipulating first-order data; e.g., integer recursion or list folding, mapping or filtering; hence, Example 2 is AFP.
Consider , where composes a list of functions. This system is AFP with .
Consider where and . This system encodes the untyped lambda-calculus, with serving as the application symbol and as a wrapper for abstractions. It is not AFP since cannot be true.
Computability.
A term is called neutral if it takes the form for some variable . A set of reducibility candidates, or an RC-set, for a type-preserving relation over terms – which may stand for , , but also – is an -indexed family of sets (let denote ) satisfying the following conditions:
-
(1)
Each element of is a terminating (with respect to ) term of type .
-
(2)
Given terms and such that , if is in , so is .
-
(3)
Given a neutral term , if is in for all such that , so is .
A term is called -computable if either the type of is a sort and , or the type of is and is -computable for all -computable .
We are interested in a specific RC-set :
Theorem 6 (see [13]).
Given a sort ordering and an RC-set for , let be the relation over terms such that if and only if both and have a base type, for some function symbol , for some and is -computable for all .
Given an LCSTRS with a sort ordering, there exists an RC-set for such that if and only if is terminating with respect to , and for all such that , if for some function symbol , is -computable for all .
3 The Transformation of Call-By-Value Systems
Let us reflect on the shape of call-by-value LCSTRSs. First, we observe that if a pattern is not a value, neither are its instances, i.e., is not a value for any substitution . Hence, under call by value, a rewrite rule where not all the proper subterms of are values is never applicable, and we can exclude such rewrite rules without loss of generality.
Second, programming languages hardly allow the addition of constructors to pre-defined (in particular, primitive) data types, such as integers. Given an LCSTRS, in practice, we would also expect, for example, that integer literals are the only constructors for . Formally, we call a theory sort inextensible if every function symbol is a theory symbol or a defined symbol. We do not require that all theory sorts are inextensible; rather, we assume that for each rewrite rule , all the variables in whose type is an inextensible theory sort are also in . We can do so without loss of generality because such a variable can only be instantiated to a theory value under call by value. We only consider inextensible theory sorts in examples below.
We write for , and conclude the above discussion:
Lemma 7.
We apply the below transformation to an LCSTRS and let be the outcome.
-
(1)
Remove all where has a proper subterm that is not a value.
-
(2)
Replace all remaining with where are the variables in whose type is an inextensible theory sort.
Then if and only if for all and .
Example 8.
The LCSTRS from Example 2 is transformed as follows: (1) no rewrite rules are removed, and (2) four rewrite rules are replaced by the ones below.
We will refer to the result of the transformation as .
We are particularly interested in call-by-value termination. However, innermost termination is more commonly considered in the term rewriting community, and has been studied extensively for first-order term rewriting. In practice, its difference from call-by-value termination is often irrelevant, and their respective techniques are generally similar. Since all values are in normal form, is terminating if is. Hence, we shall formulate our results in terms of innermost rewriting, for the sake of more generality and less bookkeeping.
4 Static Dependency Pairs and Chains
The dependency pair method [3] analyzes the recursive structure of function calls. Its variants are at the heart of most modern automatic termination analyzers for various styles of term rewriting. Static dependency pairs [35, 13], a higher-order generalization of the method, are adapted to LCSTRSs in [21]. Now we extend this adaptation for the evaluation strategies.
First, we recall a notation:
Definition 9.
Given an LCSTRS , let be where is the set of defined symbols in and is a fresh function symbol for all . Let be a fresh sort, and for each defined symbol where , we assign . Given a term where , let denote .
The definition of a static dependency pair is adapted as follows:
Definition 10.
A static dependency pair (SDP) is a triple where and are terms of type , and is a logical constraint. This SDP is considered call-by-value if all the proper subterms of are values. For a rewrite rule , let denote the set of SDPs of form such that
-
(1)
with fresh variables ,
-
(2)
for , and
-
(3)
with fresh variables .
Let be . For , we just write .
Compared to the quadruple definition in [21], this definition omits the component, because here its bookkeeping role can be assumed by the logical constraint.
Intuitively, every dependency pair in represents a function call in . If is non-terminating, there must be an infinite “chain” of function calls whose arguments are terminating (in other words, the chain is “minimal”: all the proper subterms are terminating). To distinguish the head symbols of those minimal potentially non-terminating terms, we write instead of at head positions in SDPs. Then calls to a defined symbol (the original) can be assumed to terminate, which is shown separately via . And the non-existence of an infinite chain starting from a call to any in implies the termination of .
Example 11.
Following Example 8, consists of the following SDPs:
-
(1)
-
(2)
-
(3)
-
(4)
-
(5)
-
(6)
In this paper, a set of rewrite rules plays two roles: (1) it specifies how to rewrite arguments in SDPs, and (2) it determines which rewrite steps are innermost and which terms are values. In Sections 5 and 6, a given set in its first role may be modified (with rewrite rules removed). In this process, if we do not keep the original set, there can be unintended consequences for its second role. For example, consider . Note that the first rewrite rule is not applicable to with respect to innermost rewriting. Now if we remove the second rewrite rule from and consider the new set, the remaining rewrite rule will be applicable, and the term will be a value, which is generally an unwanted change.
Hence, we keep a copy of the original set of rewrite rules to faithfully determine which rewrite steps are innermost and which terms are values. Following [18, 41], we let denote this copy. In contrast to the literature, we consider fixed throughout the analysis of a given system.444A fixed set suffices in this paper because our DP processors may remove rewrite rules, but may not add new rewrite rules or change the signature (e.g., with semantic labeling [45]). Now we formalize the idea of a chain of function calls in the innermost setting:
Definition 12.
Given a set of SDPs and a set of rewrite rules, an innermost -chain is a (finite or infinite) sequence such that for all , , is a substitution which respects , is in normal form with respect to , and if .
Example 13.
Following Example 11, is an innermost -chain.
In the above definition, the requirement that is in normal form implies that is in normal form for all , including fresh variables such as in SDP (1). Hence, the call-by-value (and therefore innermost) rewrite sequence in Example 3 does not directly translate to an innermost -chain. Nevertheless, we have the following result:
Theorem 14.
An AFP system is innermost (and therefore call-by-value) terminating if there exists no infinite innermost -chain.
Proof Idea.
The full proof is in Section A.2, and is very similar to its counterpart for termination with respect to full rewriting [21]: in a non-terminating LCSTRS, we can always identify a non-terminating base-type term such that all are -computable; and from an infinite reduction we can find such that , is an instance of a dependency pair, and is again non-terminating with -computable arguments. The primary difference from [21] is the need to ensure all variables are instantiated to normal forms, which for the fresh variables discussed above means that we must choose the right normal form that still yields non-termination.
5 The Innermost DP Framework
In this section, we modify the constrained DP framework [21] to prove innermost termination. The DP framework is a collection of DP processors, each of which represents a technique.
Definition 15.
A DP problem is a pair where is a set of SDPs and is a set of rewrite rules. If no infinite innermost -chain exists, is called finite. A DP processor is a partial mapping which possibly assigns to a DP problem a set of DP problems. A DP processor is called sound if is finite whenever all the elements of are.
Theorem 14 tells us that an AFP system is innermost terminating if is a finite DP problem. Given a collection of sound DP processors, we have the following procedure: (1) , ; (2) while contains a DP problem to which some sound DP processor is applicable, . If this procedure ends with , we can conclude that is innermost terminating.
5.1 Graph, Subterm Criterion and Integer Mapping Processors
Three classes of DP processors in [21] remain essentially unchanged in the innermost setting. Let us review their application to the system from Example 8, which is discussed by [21] in the form of Example 2. First, we consider a graph approximation for :
Definition 16.
For a DP problem , a graph approximation consists of a finite directed graph and a mapping from to the vertices of such that there is an edge from to whenever is an innermost -chain for some and .
Compared to [21], the main change is that we now check for innermost -chains to determine which edges must exist. A graph approximation for is in Figure 1. Despite the slightly different SDPs (due to the transformation of the call-by-value system), this graph approximation is the same as the one in [21].
Given a graph approximation, we can decompose the DP problem:
Definition 17.
Given a DP problem , a graph processor computes a graph approximation for and the strongly connected components (SCCs) of , then returns .
If a graph processor produces the graph approximation in Figure 1, it will return the set . Next, we observe that is defined by structural recursion, which can be handled by subterm criterion processors. Let denote the set of function symbols heading either side of an SDP in , and we have the following definition:
Definition 18.
A projection for a set of SDPs is a mapping from to integers such that if . Let denote . A projection is said to -orient a subset of if for all and for all . A subterm criterion processor maps to for some non-empty which is -oriented by some projection for .
Choosing , we have , so a subterm criterion processor maps to , and can (trivially) be removed by a graph processor. Now we are left with and , which involve recursion over integers. We deal with those by means of integer mappings:
Definition 19.
Given a set of SDPs, for all where , let be the subset of such that if and only if and the -th argument of any occurrence of in an SDP is in . Let be a set of fresh variables where for all . An integer mapping for is a mapping from to theory terms such that for all , and . Let denote .
Integer mapping processors handle decreasing integer values:
Definition 20.
Given a set of SDPs, an integer mapping is said to -orient a subset of if for all , and for all , where denotes that implies for each substitution which maps variables in to theory values. An integer mapping processor maps to for some non-empty which is -oriented by some integer mapping for .
To deal with , let be so , and . Then an integer mapping processor returns , and can (trivially) be removed by a graph processor.
Unlike [21], here an integer mapping processor is applicable to : and the processor returns . Then can be removed by a graph processor. This simpler proof is due to the transformation of the call-by-value system; in both SDPs, and can be instantiated only to theory values, which is not the case in [21], and a theory argument processor is needed there. To elaborate, we consider the system :
We have , and therefore is not terminating with respect to full rewriting. Under call by value, is terminating: the first rewrite rule with appended to the logical constraint gives the only SDP , then let be . Here we benefit from call by value.
5.2 The Chaining of Call-By-Value SDPs
Another benefit of call by value is that we may chain together consecutive SDPs, e.g., and may merge to form . This capability can be important for automatically generated systems.
Definition 21.
Given SDPs and where and variables are renamed if necessary to avoid name collisions, and are called chainable if is a call-by-value SDP and there exists a substitution such that , for all , and for all . The chaining of and is .
Note that in the context of call-by-value rewriting, all SDPs can be assumed to be call-by-value, and therefore it is not particularly restrictive to so require above. To see the importance of this requirement, consider the DP problem . If we dropped the call-by-value requirement for the second SDP, the two SDPs would be chainable and yield . However, is not reachable from initially, and replacing the original SDPs with the new one is not sound.
Definition 22.
Given a set of SDPs and such that , , and every pair in is chainable where and , a chaining processor assigns to a DP problem the singleton where .
Example 23.
Consider the below set of SDPs generated from an imperative program [14]:
Chaining processors can iteratively remove the occurrences of , and , and end with (1) , (2) , and (3) . Note that a chaining processor for removes all the occurrences of in , and therefore the process of iteratively applying chaining processors always terminates (on the assumption that is finite). In this example, the above outcome cannot be further chained; there is no chaining processor for because contains SDP (23).
Example 24.
Consider the following set of SDPs:
where is a constructor. Note that is a value. Chaining processors can remove the occurrences of , and end with (1) , (2) , (3) , and (4) .
5.3 Usable Rules
A key processor in the DP framework for full rewriting, which also applies in the innermost setting, is the reduction pair processor [21, Definition 25]. This processor is so powerful because it can potentially be used with a wide variety of different reduction pairs and does not require to be monotonic: we must show or for all SDPs , and for all rules , and we may then remove the SDPs oriented with .
The challenge is that, no matter how small , we must orient all rules in the DP problem – and all processors considered so far only modify the set of SDPs. Fortunately, in the innermost setting, we can see that only some of the rules could potentially be relevant.
To illustrate the idea, consider a system which includes at least the following rewrite rules and no other defining , , , or :
where and . To deal with the SDP , we need a reduction pair processor; roughly, we should show that is somehow “greater” than , which cannot be done by a subterm criterion or an integer mapping processor. However, since the variables are to be instantiated to normal forms, any rules other than the ones defining would not be used in a chain for this problem. Hence, only these three rules need to be oriented. This observation leads to the notion of usable rules [3, 13]. We base our formulation on a higher-order version [26] and start with two auxiliary definitions:
Definition 25.
For where for , let be where are fresh variables. Let denote .
Definition 26.
The set of usable symbols in a term with respect to a logical constraint , denoted by , is defined inductively as follows:
-
(1)
Suppose for . If , then ; otherwise .
-
(2)
Suppose for . If , then ; otherwise .
Here is a special symbol indicating that potentially any symbol could be usable.
The set of usable symbols for a set of SDPs and a set of rewrite rules, denoted by , is the smallest set such that (1) for all , and (2) for all and . Then exists because it is the least pre-fixed point of an order-preserving mapping on a complete lattice.
We present usable rules as a class of DP processors:
Definition 27.
Given sets of SDPs and of rules: if , the set of usable rules is defined as ; otherwise, is undefined. A usable-rules processor assigns to a DP problem with the singleton .
Example 28.
We continue the discussion about and . Consider the DP problem where . We have and can derive . Hence, consists of the three rules defining .
5.4 Argument Filterings
Let us consider the role of in the definition of usable rules: is undefined if – which occurs if the right-hand side of some SDP in , or the right-hand side of any rule with , is not a pattern. This is not a rare occasion in higher-order rewriting. For example, let us rework into :
where is defined by the same rules as before. Now we have , which produces .
However, observe that the problematic subterm and the decreasing subterm occur in different arguments of . If we use a reduction pair that considers only the fourth argument, intuitively we can disregard any rules that may be used to reduce the second. This is formalized via an argument filtering [3, 26], which temporarily removes certain subterms from both sides of an ordering requirement before computing usable rules, often drastically reducing the number of usable rules that the reduction pair must consider.
Traditionally, argument filterings are defined for function symbols with a fixed number of arguments. Extending this notion to our curried setting imposes new technical challenges; e.g., if we filter away the second argument of , what type to use for the filtering of , or ? Fortunately, this problem is solvable if we do not allow variables to occur at the head of an application in the result of a filtering. This is very different from the approach in [2], which heavily restricts what filtering can be used, to ensure that a variable of higher type and all its possible instances have the same filtering applied to them.
Definition 29.
We assume given a set of sorts such that , and a mapping from to such that for all . In addition, for each function symbol with , we assume given a set . Define:
The argument filtering with respect to a logical constraint is a mapping from to , defined as follows:
-
(1)
if and has a base type
-
(2)
otherwise, where and
-
(3)
for ; and if and
By definition, for all . Moreover, no subterm of has a variable at the head of an application, and all function symbols have a first-order type and occur maximally applied. Hence, is a (many-sorted) first-order term, just written in applicative notation. For , we may for instance choose , i.e., there is a single sort besides theory sorts.
Now we define usable rules with respect to an argument filtering:
Definition 30.
Given the mapping , is redefined as in the case where . The definition in other cases is unchanged, and so is the definition of .
Let be , and be .
We redefine as if , and for all , where and , and such that . Otherwise, is undefined.
That is, we consider usable rules only with respect to the positions that are not filtered away. The requirement that if is a usable symbol and is a technical limitation needed to ensure that applying a rewrite rule at the head of an application does not conflict with the argument filtering.
Next, we recall the notion of a constrained reduction pair from [21], but use a more liberal monotonicity requirement due to the first-order setting created by the filtering.
Definition 31.
A constrained relation is a set of triples where and are (first-order) terms which have the same sort and is a logical constraint. We write if . A binary relation over terms is said to cover a constrained relation if implies that for each substitution which respects .
A constrained reduction pair is a pair of constrained relations where is covered by some reflexive and transitive relation such that implies (i.e., monotonicity) for all and , is covered by some well-founded relation , and .
Having this, we can define reduction pair processors with respect to an argument filtering:
Definition 32.
A reduction pair processor with argument filterings assigns to a DP problem with the singleton for some non-empty if there exists a mapping and a constrained reduction pair such that (1) for all , (2) for all , and (3) for all .
Example 33.
Consider , with the following DP problem: Let be , be , and be . We are obliged to prove (1) , (2) , (3) , and (4) . The recursive path ordering for first-order LCTRSs [29] can be used to fulfill these obligations.
6 Universal Computability with Usable Rules
In this section, we study universal computability [21] with respect to innermost rewriting. This concept concerns a modular programming scenario where the LCSTRS represents a single module in a larger program, and corresponds to the termination of a function in all “reasonable” uses, including unknown uses. We recall the notion of a hierarchical combination [31, 32, 33, 9] rephrased in terms of LCSTRSs:
Definition 34 ([21]).
An LCSTRS is called an extension of a base system if the two systems’ interpretations of theory symbols coincide over all the theory symbols in common, and function symbols in are not defined by any rewrite rule in . Given a base system and an extension of , the system is called a hierarchical combination.
In a hierarchical combination, function symbols in the base system can occur in the extension, but cannot be (re)defined; one may think of as an imported module.
Universal computability is defined on the basis of hierarchical combinations:
Definition 35 ([21]).
Given an LCSTRS with a sort ordering , a term is called universally computable if for each extension of and each extension of to sorts in (i.e., coincides with over sorts in ), is -computable in with . is called universally computable if all its terms are.
In summary, we consider passing -computable arguments to a defined symbol in the “reasonable” way of calling the function. We use SDPs to establish universal computability:
Theorem 36.
An accessible function passing system with sort ordering is universally computable if there exists no infinite innermost -chain for any extension of and extension of to sorts in .
This is a more general version of Theorem 14 and will be proved alongside it in Appendix A.2. Note that the original set of rules, , in the definition of innermost chain is now . We modify the DP framework to prove universal computability for a fixed base system .
Definition 37.
A (universal) DP problem consists of a set of SDPs, a set of rewrite rules and a flag (for definite or indefinite). A DP problem is finite if either (1) and there exists no infinite innermost -chain (with ), or (2) and there exists no infinite innermost -chain for any extension of (with ).
DP processors are defined in the same way as before, now for universal DP problems. The goal is to show that is finite, and the procedure for termination in Section 5 still works if we change the initialization accordingly. Unlike [21], here we have the advantage of usable rules: if is defined, then for any extension (provided all symbols in and are from , which is typically the case as DP processors generally do not introduce new symbols). Hence a usable-rules processor assigns to a DP problem the singleton .
Even if usable-rules processors are not applicable, we may still use a reduction pair processor with an argument filtering: we do not have to orient the rules in since they cannot be usable. Referring to Definition 32, a reduction pair processor now assigns to a DP problem the singleton without changing the input flag because it does not permanently discard any rule. The other DP processors discussed in Section 5 apply to universal DP problems similarly; they just keep the input flag unchanged in the output.
7 Implementation and Evaluation
We have implemented our results in Cora [27], using a version of HORPO (based on the initial definition in [22]) and its first-order limitation RPO as the only reduction pair. Constraint validity checks are delegated to the SMT solver Z3 [8]. We also use Z3 to seek a good argument filtering and HORPO instance by encoding the requirements into an SMT problem.
Our implementation of the chaining processor from Definition 22 aims to minimize the number of DPs in the resulting problem. To this end, it chooses a function symbol such that the expression with the sets defined as in Definition 22 is minimized.
We evaluated Cora on three groups of benchmarks: our own collected LCSTRS benchmarks, the lambda-free problems from the higher-order category of the TPDB [7], and problems from the first-order “integer TRS innermost” category. The results are summarized below, where “full” considers the framework for full termination with the methods from [21], and “call-by-value” does the transformation of Lemma 7 before applying the innermost framework:
| Termination | Universal Computability | |||||
|---|---|---|---|---|---|---|
| Full | Innermost | Call-by-value | Full | Innermost | Call-by-value | |
| Total yes | 171 | 179 | 182 | 155 | 179 | 182 |
| Total maybe | 104 | 96 | 93 | 116 | 96 | 93 |
Note that we gain significant power compared to [21] when analyzing universal computability. This is largely due to the two usable-rules processors: the reduction pair processor cannot be applied on its own in an indefinite DP problem, so either changing the flag from to , or being able to omit the extra rules in a reduction pair, gives a lot of power.
However, the gains for termination are more modest. We suspect the reason is that the new processors primarily find their power in large systems (where it is essential to eliminate many rules when searching for a reduction pair), and automatically generated systems (where there are often many chainable rules), not in the handcrafted benchmarks of the TPDB.
Another observation is that there is no difference in proving power between termination or universal computability, both for innermost and for call-by-value reduction. This may be due to Cora having only one reduction pair (HORPO): on this benchmark set, when HORPO can be applied to simplify a DP problem, then it is also possible to filter away problematic subterms that would stop us from applying usable rules.
A detailed evaluation page is available through the following link:
Comparison to Other Analyzers.
While we have made progress, the additions of this paper are not yet sufficient for Cora to compete with dedicated analyzers for first-order integer rewriting, or unconstrained higher-order term rewriting.
In the “integer TRS innermost” category, AProVE [15] can prove innermost termination of 102 benchmarks, while Cora can handle 72 for innermost evaluation and 73 for call-by-value. The most important difference seems to be that AProVE has a much more sophisticated implementation of what we call the integer mapping processor as a reduction pair processor with polynomial interpretations and usable rules with respect to argument filterings [12]. In addition, these benchmarks often have rules such as , which would benefit from a transformation to turn the Boolean subterm into a proper constraint. Improving on these points is obvious future work.
In the “higher-order union beta” category, Wanda [25] can prove termination of full rewriting of 105 benchmarks, while Cora can handle 79 for innermost or call-by-value reduction. Since these benchmarks are unconstrained, Cora does not benefit here from any of the processors that consider the theory, while Wanda does have many more features to increase its prover ability; for example, polynomial interpretations, dynamic dependency pairs, and delegation of partial problems to a first-order termination tool.
8 Related Work
Dependency Pair frameworks are the cornerstone of most fully automated termination analysis tools for various flavors of first-order [1, 19, 23] and higher-order [2, 13, 30] rewriting. A common theme of these DP frameworks lies in the notions of a problem to be analyzed for presence of infinite chains and processors to advance the proofs of (non-)termination. The notion of DP frameworks has been lifted to constrained rewriting, both in the first-order [10, 12] and recently also in the higher-order [21] setting. The latter work also includes the notion of universal computability, allowing for termination proofs also in the presence of further library functions that are not known at the time of analysis.
Our present DP framework for innermost rewriting is specially designed with termination analysis of functional programs in call-by-value languages (e.g., Scala, OCaml) in mind as a target application. Such LCSTRSs may come from an automated syntactic translation and thus have more rewrite rules with “intermediate” defined symbols than hand-optimized rewrite systems. Our chaining processor renders the analysis of such problems feasible. This kind of program transformation is used also in other program analysis tools [4, 10, 14, 15]; here, we have adapted the technique to higher-order rewriting with constraints.
Usable rules w.r.t. an argument filtering were introduced for first-order rewriting in [19] and soon extended to simply-typed higher-order rewriting for arbitrary rewrite strategies in [2]. Our contribution here is to lift usable rules w.r.t. an argument filtering to a setting with theory constraints and to universal computability, thus opening up the door for applications in analysis of programs for real-world languages. Moreover, we adapt the technique to innermost rewriting and thus do not require that the constrained reduction pair satisfies and for fresh symbols .
9 Conclusion and Future Work
In this paper, we have extended the static dependency pair framework for LCSTRSs to innermost and call-by-value evaluation strategies. In doing so, we have adapted several existing processors for full termination and proposed three processors – chaining, usable rules, reduction pairs with usable rules w.r.t. argument filterings – that were not present for the setting of full termination. These processors apply not only to conventional closed-world termination analysis, but also to open-world termination analysis via universal computability, where the presence of further rewrite rules for library functions is assumed, thus broadening the set of potential start terms that must be considered. Our experimental results on several benchmark collections indicate improvements over the state of the art by exploiting the evaluation strategy via the new processors, most pronounced for universal computability.
There are several directions for future work. Our chaining processors could be improved, e.g., by using unification instead of matching, thus defining a form of narrowing for our constrained DPs in the higher-order setting. Moreover, so far our implementation prohibits chaining a DP with itself to prevent non-termination of repeated applications of the chaining processors. We might loosen this restriction via appropriate heuristics to detect cases in which such self-chaining could be beneficial. In addition, we could investigate chaining not just for DPs, but also for rewrite rules. The integer mapping processor could be improved by lifting polynomial interpretations [43] for higher-order rewriting to the constrained setting of LCSTRSs. Another improvement would consist of moving Boolean expressions from the right-hand side of rewrite rules into their constraints. Techniques like the integer mapping processor or the subterm criterion, which establish weak or strict decrease between certain arguments of dependency pairs, could also be improved by combining them with the size-change termination principle [37]. Size-change termination has been integrated into the first-order DP framework [42, 5], and a natural next step would be to lift this integration to the higher-order DP framework for LCSTRSs, both for innermost and for full termination.
A different avenue could be to research to what extent the termination analysis techniques in this paper can be ported from innermost or call-by-value evaluation to arbitrary evaluation strategies, or to lazy evaluation, as used in Haskell. For the latter, we might consider an approximation of lazy evaluation via a higher-order form of context-sensitive rewriting [1, 38].
Finally, to go back to one of the main motivations of this work, we could devise translations from higher-order functional programming languages with call-by-value semantics (e.g., Scala, OCaml) to LCSTRSs. This would allow for applying the contributions of this paper to prove termination of programs written in these languages, a long-term goal of this line of research.
References
- [1] B. Alarcón, R. Gutiérrez, and S. Lucas. Context-sensitive dependency pairs. IC, 208(8):922–968, 2010. doi:10.1016/J.IC.2010.03.003.
- [2] T. Aoto and T. Yamada. Argument filterings and usable rules for simply typed dependency pairs. In S. Ghilardi and R. Sebastiani, editors, Proc. FroCoS, pages 117–132, 2009. doi:10.1007/978-3-642-04222-5_7.
- [3] T. Arts and J. Giesl. Termination of term rewriting using dependency pairs. TCS, 236(1–2):133–178, 2000. doi:10.1016/S0304-3975(99)00207-8.
- [4] D. Beyer, A. Cimatti, A. Griggio, M. E. Keremoglu, and R. Sebastiani. Software model checking via large-block encoding. In A. Biere and C. Pixley, editors, Proc. FMCAD, pages 25–32, 2009. doi:10.1109/FMCAD.2009.5351147.
- [5] M. Codish, C. Fuhs, J. Giesl, and P. Schneider-Kamp. Lazy abstraction for size-change termination. In C. G. Fermüller and A. Voronkov, editors, Proc. LPAR (Yogyakarta), pages 217–232, 2010. doi:10.1007/978-3-642-16242-8_16.
- [6] Community. Termination competition (TermCOMP). URL: https://termination-portal.org/wiki/Termination_Competition.
- [7] Community. The termination problem database (TPDB). URL: https://github.com/TermCOMP/TPDB.
- [8] L. de Moura and N. Bjørner. Z3: An efficient SMT solver. In C.R. Ramakrishnan and J. Rehof, editors, Proc. TACAS, pages 337–340, 2008. doi:10.1007/978-3-540-78800-3_24.
- [9] N. Dershowitz. Hierarchical termination. In N. Dershowitz and N. Lindenstrauss, editors, Proc. CTRS, pages 89–105, 1995. doi:10.1007/3-540-60381-6_6.
- [10] S. Falke and D. Kapur. A term rewriting approach to the automated termination analysis of imperative programs. In R. A. Schmidt, editor, Proc. CADE, pages 277–293, 2009. doi:10.1007/978-3-642-02959-2_22.
- [11] S. Falke, D. Kapur, and C. Sinz. Termination analysis of C programs using compiler intermediate languages. In M. Schmidt-Schauß, editor, Proc. RTA, pages 41–50, 2011. doi:10.4230/LIPIcs.RTA.2011.41.
- [12] C. Fuhs, J. Giesl, M. Plücker, P. Schneider-Kamp, and S. Falke. Proving termination of integer term rewriting. In R. Treinen, editor, Proc. RTA, pages 32–47, 2009. doi:10.1007/978-3-642-02348-4_3.
- [13] C. Fuhs and C. Kop. A static higher-order dependency pair framework. In L. Caires, editor, Proc. ESOP, pages 752–782, 2019. doi:10.1007/978-3-030-17184-1_27.
- [14] C. Fuhs, C. Kop, and N. Nishida. Verifying procedural programs via constrained rewriting induction. ACM TOCL, 18(2):14:1–14:50, 2017. doi:10.1145/3060143.
- [15] J. Giesl, C. Aschermann, M. Brockschmidt, F. Emmes, F. Frohn, C. Fuhs, J. Hensel, C. Otto, M. Plücker, P. Schneider-Kamp, T. Ströder, S. Swiderski, and R. Thiemann. Analyzing program termination and complexity automatically with AProVE. JAR, 58(1):3–31, 2017. doi:10.1007/s10817-016-9388-y.
- [16] J. Giesl, M. Raffelsieper, P. Schneider-Kamp, S. Swiderski, and R. Thiemann. Automated termination proofs for Haskell by term rewriting. ACM TOPLAS, 33(2):7:1–7:39, 2011. doi:10.1145/1890028.1890030.
- [17] J. Giesl, T. Ströder, P. Schneider-Kamp, F. Emmes, and C. Fuhs. Symbolic evaluation graphs and term rewriting: a general methodology for analyzing logic programs. In A. King, editor, Proc. PPDP, pages 1–12, 2012. doi:10.1145/2370776.2370778.
- [18] J. Giesl, R. Thiemann, and P. Schneider-Kamp. The dependency pair framework: combining techniques for automated termination proofs. In F. Baader and A. Voronkov, editors, Proc. LPAR, pages 301–331, 2005. doi:10.1007/978-3-540-32275-7_21.
- [19] J. Giesl, R. Thiemann, P. Schneider-Kamp, and S. Falke. Mechanizing and improving dependency pairs. JAR, 37(3):155–203, 2006. doi:10.1007/s10817-006-9057-7.
- [20] L. Guo, K. Hagens, C. Kop, and D. Vale. Higher-order constrained dependency pairs for (universal) computability. pre-publication Arxiv copy of [21] with additional appendix. doi:10.48550/arXiv.2406.19379.
- [21] L. Guo, K. Hagens, C. Kop, and D. Vale. Higher-order constrained dependency pairs for (universal) computability. In R. Královič and A. Kučera, editors, Proc. MFCS, pages 57:1–57:15, 2024. doi:10.4230/LIPIcs.MFCS.2024.57.
- [22] L. Guo and C. Kop. Higher-order LCTRSs and their termination. In S. Weirich, editor, Proc. ESOP, pages 331–357, 2024. doi:10.1007/978-3-031-57267-8_13.
- [23] N. Hirokawa and A. Middeldorp. Automating the dependency pair method. IC, 199(1-2):172–199, 2005. doi:10.1016/J.IC.2004.10.004.
- [24] N. Hirokawa and A. Middeldorp. Tyrolean Termination Tool: techniques and features. IC, 205(4):474–511, 2007. doi:10.1016/j.ic.2006.08.010.
- [25] C. Kop. WANDA – a higher order termination tool (system description). In Z. M. Ariola, editor, Proc. FSCD, pages 36:1–36:19, 2020. doi:10.4230/LIPICS.FSCD.2020.36.
- [26] C. Kop. Cutting a proof into bite-sized chunks: incrementally proving termination in higher-order term rewriting. In A. P. Felty, editor, Proc. FSCD, pages 1:1–1:17, 2022. doi:10.4230/LIPIcs.FSCD.2022.1.
- [27] C. Kop et al. The Cora analyzer. URL: https://github.com/hezzel/cora.
- [28] C. Kop et al. hezzel/cora: FSCD 2025. doi:10.5281/zenodo.15318964.
- [29] C. Kop and N. Nishida. Term rewriting with logical constraints. In P. Fontaine, C. Ringeissen, and R. A. Schmidt, editors, Proc. FroCoS, pages 343–358, 2013. doi:10.1007/978-3-642-40885-4_24.
- [30] C. Kop and F. van Raamsdonk. Dynamic dependency pairs for algebraic functional systems. LMCS, 8(2), 2012. doi:10.2168/LMCS-8(2:10)2012.
- [31] M. R. K. Krishna Rao. Completeness of hierarchical combinations of term rewriting systems. In R. K. Shyamasundar, editor, Proc. FSTTCS, pages 125–138, 1993. doi:10.1007/3-540-57529-4_48.
- [32] M. R. K. Krishna Rao. Simple termination of hierarchical combinations of term rewriting systems. In M. Hagiya and J. C. Mitchell, editors, Proc. TACS, pages 203–223, 1994. doi:10.1007/3-540-57887-0_97.
- [33] M. R. K. Krishna Rao. Semi-completeness of hierarchical and super-hierarchical combinations of term rewriting systems. In P. D. Mosses, M. Nielsen, and M. I. Schwartzbach, editors, Proc. CAAP, pages 379–393, 1995. doi:10.1007/3-540-59293-8_208.
- [34] K. Kusakari, Y. Isogai, M. Sakai, and F. Blanqui. Static dependency pair method based on strong computability for higher-order rewrite systems. IEICE Trans. Inf. Syst., E92.D(10):2007–2015, 2009. doi:10.1587/transinf.E92.D.2007.
- [35] K. Kusakari and M. Sakai. Enhancing dependency pair method using strong computability in simply-typed term rewriting. AAECC, 18(5):407–431, 2007. doi:10.1007/s00200-007-0046-9.
- [36] K. Kusakari and M. Sakai. Static dependency pair method for simply-typed term rewriting and related techniques. IEICE Trans. Inf. Syst., E92.D(2):235–247, 2009. doi:10.1587/transinf.E92.D.235.
- [37] C. S. Lee, N. D. Jones, and A. M. Ben-Amram. The size-change principle for program termination. In C. Hankin and D. Schmidt, editors, Proc. POPL, pages 81–92, 2001. doi:10.1145/360204.360210.
- [38] S. Lucas. Context-sensitive computations in functional and functional logic programs. JFLP, 1998(1), 1998. URL: http://danae.uni-muenster.de/lehre/kuchen/JFLP/articles/1998/A98-01/A98-01.html.
- [39] C. Otto, M. Brockschmidt, C. von Essen, and J. Giesl. Automated termination analysis of Java bytecode by term rewriting. In C. Lynch, editor, Proc. RTA, pages 259–276, 2010. doi:10.4230/LIPIcs.RTA.2010.259.
- [40] S. Suzuki, K. Kusakari, and F. Blanqui. Argument filterings and usable rules in higher-order rewrite systems. IPSJ Online Trans., 4:114–125, 2011. doi:10.2197/ipsjtrans.4.114.
- [41] R. Thiemann. The DP framework for proving termination of term rewriting. PhD thesis, RWTH Aachen University, Germany, 2007. URL: http://darwin.bth.rwth-aachen.de/opus3/volltexte/2007/2066/.
- [42] R. Thiemann and J. Giesl. The size-change principle and dependency pairs for termination of term rewriting. AAECC, 16(4):229–270, 2005. doi:10.1007/S00200-005-0179-7.
- [43] J. van de Pol. Termination proofs for higher-order rewrite systems. In J. Heering, K. Meinke, B. Möller, and T. Nipkow, editors, Proc. HOA, pages 305–325, 1993. doi:10.1007/3-540-58233-9_14.
- [44] F. van Raamsdonk. Translating logic programs into conditional rewriting systems. In L. Naish, editor, Proc. ICLP, pages 168–182, 1997. doi:10.7551/mitpress/4299.003.0018.
- [45] H. Zantema. Termination of term rewriting by semantic labelling. FI, 24(1/2):89–105, 1995. doi:10.3233/FI-1995-24124.
Appendix A Full Proofs
A.1 Soundness for Section 5
For soundness of the graph, subterm criterion and integer mapping processors, we refer to Appendix A.2 in [20]; only minimal changes are needed. Below we address the rest.
Theorem 38.
Chaining processors are sound.
Proof of Theorem 38.
Given a DP problem , a defined symbol with the said properties and an infinite innermost -chain where variables are renamed to avoid name collisions between any two of the SDPs and for all , we consider such that and . By definition, for all . Because and are chainable, there exists a substitution such that , for all and for all . Hence, for all . Since is a value for all , for all . Now we show that replacing and by yields an infinite innermost chain. First, it is routine to verify that respects . Next, so it is in normal form. Last, .
We present some auxiliary results for the two classes of DP processors based on usable rules in a unified way, regardless of whether an argument filtering is applied. When no filtering is applied, let for each with .
Definition 39.
The set of actually usable symbols in a term is (1) if for , is not a ground theory term, and is not in normal form (with respect to ), or (2) otherwise.
Lemma 40.
Given a constraint and a substitution such that is in normal form for all and is a theory value if : for all with .
Proof of Lemma 40.
By induction on . If with , then because . Hence, is in normal form, and therefore . Otherwise, for . If is not a ground theory term, because is a theory value for all . So if , , and therefore for each such . By induction, . Hence, .
Lemma 41.
Given a set of SDPs and a set of rules such that and is defined: for all terms , , if and , .
Proof of Lemma 41.
By induction on .
-
(1)
for , and there exist a rewrite rule , substitution and number such that , , is in normal form for all and respects . Since , is not in -normal form, so , and therefore where are fresh variables. Since is defined, , and therefore . If , due to Lemma 40, . Otherwise, for . Then and . Since , for each such , due to Lemma 40. Since is defined, each , and therefore . Hence, .
-
(2)
where is a calculation symbol and are theory values, and has a base type. Then and is a theory value. Hence, .
-
(3)
for , and for some with . If is a ground theory term, so is , hence ; so assume otherwise. If , . If , . By induction, . Then .
-
(4)
for , and ; then .
Theorem 42.
Usable-rules processors are sound.
Proof of Theorem 42.
Given a DP problem such that and is defined, and an infinite innermost -chain : for all , since , , and due to Lemma 40, . Now due to Lemma 41, for all such that , , so any -step from is a -step, given the definition of .
Below we let denote – the argument filtering with respect to the Boolean – and define for each substitution by letting be .
Lemma 43.
Given a logical constraint and a substitution such that is a theory value for all , for each pattern such that all the variables in whose type is a theory sort are also in .
Proof of Lemma 43.
By induction on . If with , then because is a pattern. Hence, . Otherwise, for . If is in and has a base type, because is a theory value for all and for each theory value . Otherwise, if (with ), and . By induction, for all .
Lemma 44.
Given a set of SDPs, a set of rewrite rules and a constrained relation such that is defined, for all and is covered by some reflexive, transitive and monotonic relation : if and is a theory value for all , .
Proof of Lemma 44.
By induction on . If with then because . Hence, . Otherwise, for . If is in and has a base type, because each is a theory value so . Otherwise, we have where and . By induction, for all , and therefore . If is a ground theory term with a base type, ; because covers , . Otherwise, we have .
Lemma 45.
Given a set of SDPs, a set of rules and a constrained relation where (1) , (2) is defined, (3) for all , all whose type is a theory sort, , (4) for all and (5) is covered by a reflexive, transitive, monotonic : if and , .
Proof of Lemma 45.
By induction on .
-
(1)
is a base-type ground theory term; then so is , and . Hence, .
- (2)
-
(3)
() is not a base-type ground theory term, and there is such that and . Then where and . Let be for all . By induction, , and therefore . If is a ground theory term that has a base type, since , we have ; because covers , . Otherwise, .
-
(4)
for , and ; then .
Theorem 46.
If the rewrite rules are preprocessed by Lemma 7, and all theory sorts are inextensible, then reduction pair processors with an argument filtering are sound.
Proof of Theorem 46.
Following Theorem 42, for all and such that , . Due to Lemma 45, for all . For all , if , due to Lemmas 43 and 44, ; if , similarly . Since is well-founded, an infinite innermost -chain leads to an infinite innermost -chain.
A.2 The Proofs of Theorems 14 and 36
For the properties of -computability, see Appendix A in the extended version of [13]. The following proofs are largely based on Appendix A.3 in [20]; here the novelty lies on the innermostness of chains. Note that undefined function symbols are -computable (see [20]).
Lemma 47.
Assume given an AFP system with sort ordering , an extension of and a sort ordering which extends over sorts in . For each defined symbol in where is a sort, if is not -computable in with but is for all , then there exist an SDP , a substitution and a natural number such that (1) and is in normal form for all , (2) is a fresh variable ( does not occur in for any ) and for all , (3) respects , and (4) is not -computable in with but is for each proper subterm of .
Proof.
If the only reducts of were values or with for all then would be computable. Hence, there exist ( cannot be defined in ) and such that and is in normal form for all , and respects ; is thus a reduct of . At least one such reduct is uncomputable. Let be uncomputable, and therefore so is . Also all are computable, since these are accessible subterms of some , since is AFP.
Take a minimal subterm of such that is uncomputable. By minimality, each is computable. Hence, cannot be a variable, value or constructor, as then would be computable, implying computability of . Hence, is a defined symbol .
We have . Because is uncomputable, there exist computable terms such that is uncomputable. Let be such that for all , for all , and for any other . Let denote for and denote for ; then , and satisfy all requirements.
Corollary 48.
Given an AFP system with sort ordering , an extension of and a sort ordering which extends over sorts in , for each defined symbol in ( a sort), if is not -computable in with but each is, there exists an infinite innermost -chain
Proof.
Repeatedly applying Lemma 47 (on , then on and so on) we get three infinite sequences: one of SDPs in where , one of substitutions and one of natural numbers . Since is exactly , combining the SDPs and the substitutions almost gives us an infinite innermost -chain, except that may not be in normal form if .
We define so that, together with the SDPs, we obtain an infinite chain. For all with , is a fresh variable and is -computable. Let be for . To define for , let be and for , if exists and , let be the index (if any) with . There are two options:
-
(1)
If for all such that is defined, regardless of whether the sequence is finite, for all such that is defined. Let be an arbitrary normal form of , and let be for all where is defined.
-
(2)
Otherwise, the sequence is finite, and where is the last in the sequence. Then is in normal form. Let be for all .
Hence, we have built an infinite innermost -chain.
Theorem 14. [Restated, see original statement.]
An AFP system is innermost (and therefore call-by-value) terminating if there exists no infinite innermost -chain.
Proof.
Towards a contradiction, assume that is not innermost terminating. Then there is an uncomputable (not -computable) term . Take a minimal subterm of that is uncomputable; then where is defined and each is computable. Let for . Since is uncomputable, there exist computable with uncomputable. By Corollary 48 (with ), there is an infinite innermost -chain, giving the required contradiction.
Theorem 36. [Restated, see original statement.]
An accessible function passing system with sort ordering is universally computable if there exists no infinite innermost -chain for any extension of and extension of to sorts in .
Proof.
Towards a contradiction, assume that is not universally computable. There exist an extension of , sort ordering which extends over sorts in and term of that is not -computable in with . We consider -computability in . Take a minimal uncomputable subterm of ; then must take the form with a defined symbol in and each computable. Let . Because is uncomputable, there exist computable of with uncomputable. Corollary 48 gives the required chain to obtain a contradiction.
