scispace - formally typeset
Open AccessJournal ArticleDOI

Polymorphic higher-order recursive path orderings

TLDR
A family of recursive path orderings for terms of a typed lambda-calculus generated by a signature of polymorphic higher-order function symbols is defined, which can be generated from two given well-founded orderings, on the function symbols and on the type constructors.
Abstract
This article extends the termination proof techniques based on reduction orderings to a higher-order setting, by defining a family of recursive path orderings for terms of a typed lambda-calculus generated by a signature of polymorphic higher-order function symbols These relations can be generated from two given well-founded orderings, on the function symbols and on the type constructors The obtained orderings on terms are well founded, monotonic, stable under substitution and include β-reductions They can be used to prove the strong normalization property of higher-order calculi in which constants can be defined by higher-order rewrite rules using first-order pattern matching For example, the polymorphic version of Godel's recursor for the natural numbers is easily oriented And indeed, our ordering is polymorphic, in the sense that a single comparison allows to prove the termination property of all monomorphic instances of a polymorphic rewrite rule Many nontrivial examples are given that exemplify the expressive power of these orderings All have been checked by our implementationThis article is an extended and improved version of Jouannaud and Rubio [1999] Polymorphic algebras have been made more expressive than in our previous framework The intuitive notion of a polymorphic higher-order ordering has now been made precise The higher-order recursive path ordering itself has been made much more powerful by replacing the congruence on types used there by an ordering on types satisfying some abstract properties Besides, using a restriction of Dershowitz's recursive path ordering for comparing types, we can integrate both orderings into a single one operating uniformly on both terms and types

read more

Content maybe subject to copyright    Report

Polymorphic Higher-Order Recursive Path
Orderings
Jean-Pierre Jouannaud
LIX,
´
Ecole Polytechnique
and
Albert Rubio
Technical University of Catalonia
This paper extends the termination proof techniques based on reduction orderings to a higher-
order setting, by defining a family of recursive path orderings for terms of a typed lambda-calculus
generated by a signature of polymorphic higher-order function symbols. These relations can be
generated from two given well-founded orderings, on the function symbols and on the type con-
structors. The obtained orderings on terms are well-founded, monotonic, stable under substitu-
tion and include β-reductions. They can be used to prove the strong normalization property of
higher-order calculi in which constants can be defined by higher-order rewrite rules using first-
order pattern matching. For example, the polymorphic version of odel’s recursor for t he natural
numbers is easily oriented. And indeed, our ordering is polymorphic, in the sense that a single
comparison allows to prove the termination property of all monomorphic instances of a polymor-
phic rewrite rul e. Many non-trivial examples are given which exemplify the expressive power of
these orderings. All have been checked by our implementation.
This paper is an extended and improved version of [ Jouann aud and Rubio 1999]. Polymorphic
algebras have been made more expressive than in our previous framework. The intuitive notion
of a polymorphic higher-order ordering has now been made precise. The higher-order recursive
path ordering itself has been made much more powerful by replacing the congruence on types used
there by an ordering on types satisfying some ab strac t properties. Besides, using a restriction of
Dershowitz’s recursive path ordering for comparing types, we can integrate both orderings into a
single one operating uniformly on both terms and types.
Categories and Subject Descriptors: F.4.1 [Mathematical Logic and Formal Languages]:
Mathematical Logic—Lambda Calculus and related Systems; I.1.3 [Symbolic and Algebraic
Manipulation]: Languages and Systems; I.2.4 [Artificial Intelligence]: Knowledge represen-
tation Formalisms and Methods—Representations (Procedural and Rule-based)
General Terms: Languages, Theory, Verification
Additional Key Words and Phrases: Automated termination prover tool, odel’s polymorphic
recursor, Higher-Order Rewriting, Termination orderings, Typed lambda calculus
This work was partly supported by th e RNTL project AVERROES, France-Telecom, and the
CICYT project LOGICTOOLS, ref. TIN2004-07925.
Project LogiCal, ole Commun de Recherche en Informatique du Plateau de Saclay, C NRS,
´
Ecole
Polytechnique, INRIA, Universit´e Paris-Sud.
Author’s address: J.-P. Jouannaud, LIX,
´
Ecole Polytechnique, 91400 Palaiseau, FRANCE;
A. Rubio, Dep. LSI, Universitat Polit`etica de Catalunya, Jordi Girona 1-3, 08034 Barcelona,
SPAIN.
Permission to make digital/hard copy of all or part of this material witho ut fee for personal
or classroom use provided that the copies are not made or distributed for profit or commercial
advantage, the ACM copyright/server notice, the title of the publication, and its date appear, and
notice is given that copying is by permission of the ACM, Inc. To copy otherwise, to republish,
to post on servers, or to redistribute to lists requires prior specific permission and/or a fee.
c
20YY ACM 0004-5411/20YY/0100-0001 $5.00
Journal of the ACM, Vol. V, No. N, Month 20YY, Pages 1–49.

2 · J.-P. Jouannaud and A. Rubio
1. INTRODUCTION
Rewrite rules are used in programming languages and logical systems, with three
main goals: defining functions by pattern matching; encoding rule-based decision
procedures; describing computations over lambda-terms used as a suitable abstract
syntax for encoding functional objects like programs or specifications. ML and
the current version of Coq based on the Calculus of Inductive Constructions [Co-
quand and Paulin-Mohring 1990] exemplify the first use. A prototype version of
Coq exemplifies the second use [Blanqui et al. 2005]. Alf [Coquand 1994] and Is-
abelle [Paulson 1990] exemplify the third use. In Isabelle, rules operate on terms
in β-normal, η-expanded form and use higher-order pattern matching. In ML and
Coq, they operate on arbitrary terms and use first-order pattern-matching. Both
kinds of rules target different needs, and should, of course, coexist.
The use of rules in logical syste ms is subject to three main meta-theoretic prop-
erties : type preservation, local confluence, and strong normalization. The first two
are usually easy. The last one is difficult, requiring the use of sophisticated proof
techniques based, for example, on Tait and Girard’s computability predicate tech-
nique [Girard et al. 1989]. Our ambition is to provide a remedy for this situation
by developing for the higher-order case the kind of automatable termination proof
techniques that are available for the first-order case, of which the most popular one
is the recursive path ordering [Dershowitz 1982].
Our contribution to this program is a reduction ordering for typed higher-order
terms following a typing discipline including polymorphic sort constructors, which
conservatively extends β-reductions for higher-order terms on the one hand, and on
the other hand Dershowitz’s recursive path ordering for first-order unisorted terms.
In the latter, the precedence rule allows to decreas e from the term s = f (s
1
, . . . , s
n
)
to the term g(t
1
, . . . , t
n
), provided that (i) f is bigger than g in the given precedence
on function symbols, and (ii) s is bigger than every t
i
. For typing reasons, in our
ordering the latter condition becomes: (ii) for e very t
i
, either s is bigger than t
i
or
some s
j
is bigger than or equal to t
i
. Indeed, we can instead allow t
i
to be obtained
from the subterms of s by computability prese rving operations. Here, computability
refers to Tait and Girard’s strong normalization proof technique which we have used
to show that our ordering is well-founded.
In a preliminary version of this work presented at the Federated Logic Conference
in Trento, our ordering could only compare terms of equal types (after identifying
sorts such as Nat or List). In the prese nt version, the ordering is capable of ordering
terms of decreasing types, the ordering on types being simply a slightly weakened
form of Dershowitz’s recursive path ordering. Several other improvements have
been made, which allow to prove a great variety of practical examples. To hint at
the strength of our ordering, let us mention that the polymorphic version of odel’s
recursor for the natural numbers is easily oriented. And indeed, our ordering can
prove at once the termination property of all monomorphic instances of a polymor-
phic rewrite rule. Many other examples are given which exemplify the expressive
power of the ordering.
In the literature, one can find several attempts at designing methods for proving
strong normalization of higher-order rewrite rules based on ordering comparisons.
These orderings are either quite weak [Lor´ıa-S´aenz and Steinbach 1992; Jouannaud
Journal of the ACM, Vol. V, No. N, Month 20Y Y.

Polymorphic Higher-Order Recursive Path Orderings · 3
and Rubio 1998], or need a heavy user interaction [van de Pol and Schwichtenberg
1995]. Besides, they operate on terms in η-long β-normal form, hence apply only to
the higher-order rewriting “`a la Nipkow” [Mayr and Nipkow 1998], based on higher-
order pattern matching modulo βη. To our knowledge, our ordering is the first to
operate on arbitrary higher-order terms, therefore applying to the other kind of
rewriting, based on plain pattern matching. It is also the first to be automatable:
an implementation is provided which does not require user-interaction. And indeed
we want to stress several important features of our approach. Firstly, it can be seen
as a way to lift an ordinal notation operating on a first-order language (here, the
set of labelled trees ordered by the recursive path ordering) to an ordinal notation
of higher type operating on a set of well-typed λ-expressions built over the first-
order language. Secondly, the analysis of our ordering, based on Tait and Girard’s
computability predicate proof technique, leads to hiding this technique away, by
allowing one to carry out future meta-theoretical investigations based on ordering
comparisons rather than by a direct use of the computability predicate technique.
Thirdly, a very elegant presentation of the whole ordering machinery obtained by
integrating both orderings on terms and types into a single one operating on both
kinds shows that this presentation can in turn be the basis for generalizing the
ordering to dependent type calculi. Last, a modification of our ordering described
in a companion paper can be used to prove strong normalization of higher-order
rewrite rules operating on terms in η-long β-normal form and using higher-order
pattern matching for firing rules [Jouannaud and Rubio 2006].
Described in Section 2, our framework for rewriting includes several novel as-
pects, among which two important notions of polymorphic higher-order rewriting
and of polymorphic higher-order rewrite orderings. In order to define these notions
precisely, we first introduce polymorphic higher-order algebras. Types will therefore
play a central role in this paper, but the reader should be aware that the paper is by
no means about polymorphic typing : it is about polymorphic higher-order order-
ings. In particular, we could have also considered inductive types, without having
to face unpredictable difficulties. We chose not to do so in the present framework,
which, we think, is already quite powerful and complex, to a point that those read-
ers who feel no particular interest in typing technicalities should probably restrict
their first reading of this s ec tion to the type system of Figure 1, Definition 2.28
and Theorem 2.29. The rest of the paper, we think, can be understood without
knowing the details of the typing apparatus. The basic version of our ordering is
defined and studied in Section 3, where se veral examples are given. The notion
of computability closure [Blanqui et al. 1999] used to boost the expressiveness of
the ordering is introduced and studied in Section 4. Our prototype implementation
is discussed in Section 5. Related work and potential extensions are discussed in
Section 6.
The reader is expected to have some familiarity with the basics of term rewriting
systems [Dershowitz and Jouannaud 1990; Klop 1992; Baader and Nipkow 1998;
Bezem et al. 2003] and typed lambda calculi [Barendregt 1990; 1992].
Journal of the ACM, Vol. V, No. N, Month 20Y Y.

4 · J.-P. Jouannaud and A. Rubio
2. POLYMORPHIC HIGHER-ORDER ALGEBRAS
This section describes polymorphic higher-order algebras, a higher-order algebraic
framework with typing “`a la ML” which makes it pos sible to precisely define what
are polymorphic higher-order rewriting and polymorphic higher-order rewrite or-
derings. Our target is indeed to have higher-order rewrite rules in the calculus
of constructions and check their termination property by means of orderings, but,
although our results address polymorphic typing, they do not scale up yet to de-
pendent types.
We define our typing discipline in Sections 2.1 to 2.5, before investigating their
prop e rties in Section 2.6, and then define higher-order rew riting in Section 2.8 and
finally polymorphic higher-order rewrite orderings in Section 2.9. We conclude in
Section 2.10 that polymorphic higher-order rewrite orderings allow showing that
the derivation relation defined by a set of polymorphic rewrite rules is well-founded
by checking the rules for decreasingness.
2.1 Types
Given a set S of sort symbols of a fixed arity, denoted by s :
n
, and a
denumerable set S
of type variables, the set T
S
of (first-order) types is generated
by the following grammar:
T
S
:= α | s(T
n
S
) | (T
S
T
S
)
for α S
and s :
n
S
We denote by Var(σ) the set of type variables of the type σ T
S
, and by T
S
the
set of monomorphic or ground types, whose set of type variables is empty. Types
in T
S
\ T
S
are polymorphic.
Types are functional when headed by the symbol, and data types when headed
by a sort symbol. As usual, ass ociates to the right. We will often make explicit
the functional structure of an arbitrary type τ by writing it in the canonical form
σ
1
. . . σ
n
σ, with n 0, where n is the arity of τ and σ is a data type or
a type variable called canonical output type of τ . A basic type is either a data type
or a type variable.
A type substitution is a mapping from S
to T
S
extended to an endomorphism
of T
S
. We use postfix notation for their application to types or to other type
substitutions. We denote by Dom(ξ) = {α S
| αξ 6= α} the domain of ξ, and
by Ran(ξ) =
S
α∈Dom(ξ)
Var(αξ) its range. Note that all variables in Ran(ξ)
belong to S
by assumption, that is, they must be declared beforehand. A type
substitution σ is ground if Ran(σ) = , and a type renaming if it is bijective.
We use α, β for type variables, σ, τ, ρ, θ for arbitrary types and ξ for type substi-
tutions.
A unification problem is a conjunction of equation among types such as σ
1
=
τ
1
. . . σ
n
= τ
n
. A solution is a ground type substitution ξ such that σ
i
ξ = τ
i
ξ
for all i [1..n]. Solutions are ground instances of a unique (up to renaming of
type variables in its range) type substitution called the most general unifier of the
problem and denoted by mgu(σ
1
= τ
1
. . . σ
n
= τ
n
), a result due to Robinson.
Journal of the ACM, Vol. V, No. N, Month 20Y Y.

Polymorphic Higher-Order Recursive Path Orderings · 5
2.2 Signatures
We are given a set of function symbols denoted by the letters f, g, h, which are
meant to be algebraic operators equipped with a fixed number n of arguments
(called the arity) of respective types σ
1
T
S
, . . . , σ
n
T
S
, and output type
σ T
S
. Let F =
U
σ
1
,...,σ
n
F
σ
1
×...×σ
n
σ
be the set of all function symbols. The
membership of a given function symbol f to a s et F
σ
1
×...×σ
n
σ
is called a type
declaration and written f : σ
1
× . . . × σ
n
σ. This type declarations is not a type,
but corresponds to the type ∀Var(σ
1
) . . . ∀Var(σ
n
)∀Var(σ)σ
1
. . . σ
n
σ,
hence, the intended meaning of a polymorphic type declaration is the set of all
its monomorphic instances. In case n = 0, the declaration is written f : σ. A
type declaration is first-order if its constituent types are solely built from sort
symbols and variables, and higher-order otherwise. It is polymorphic if it uses some
polymorphic type, otherwise, it is monomorphic. F is said to be first-order if all
its type declarations are first-order, and higher-order otherwise. It is polymorphic
if some type declaration is polymorphic, and monomorphic otherwise.
The triple S; S
; F is called the signature. We sometimes say that the signa-
ture is first-order, higher-order, polymorphic, monomorphic when F satisfies the
corresponding prop erty.
2.3 Raw terms
The set T (F, X ) of raw algebraic λ-terms is generated from the signature F and a
denumerable set X of variables according to the grammar rules:
T := X | (λX : T
S
.T ) | @(T , T ) | F(T , . . . , T ).
Raw terms of the form λx : σ.u are called abstractions, while the other raw terms
are said to be neutral. @(u, v) denotes the application of u to v. We may sometimes
omit the type σ in λx : σ.u as well as the application operator, writing u(v) for
@(u, v), in particular when u is a higher-order variable. As a matter of convenience,
we may write u(v
1
, . . . , v
n
), or @(u, v
1
, . . . , v
n
) for u(v
1
) . . . (v
n
), ass uming n 1.
The raw term @(u, v
1
, . . . , v
n
) is called a (partial) left-flattening of s = u(v
1
) . . . (v
n
),
u being possibly an application itself (hence the word “partial”).
Note that our syntax requires using explicit applications for variables, since they
cannot take arguments. On the other hand, function symbols have arities, elimi-
nating the need for an explicit application of a function symbol to its arguments.
Curried function symbol have arity zero, hence must be applied.
Raw terms are identified with finite labeled trees by considering λx : σ.
, for each
variable x and type σ, as a unary function symbol taking a raw term u as argument
to construct the raw term λx : σ.u. We denote the set of free variables of the raw
term t by Var(t), its set of bound variables by BVar(t), its size (the number of
symbols occurring in t) by |t|. The notation s will be ambiguously used to denote
a list, or a multiset, or a set of raw terms s
1
, . . . , s
n
.
Positions are strings of positive integers. Λ and · denote respectively the empty
string (root position) and the concatenation of strings. We use Pos(t) for the set
of positions in t. The subterm of t at position p is denoted by t|
p
, and we write
t t|
p
for the subterm relationship. The result of replacing t|
p
at position p in t by
u is denoted by t[u]
p
. We sometimes use t[x : σ]
p
for a raw term with a (unique)
Journal of the ACM, Vol. V, No. N, Month 20Y Y.

Citations
More filters
Journal ArticleDOI

Journal of the ACM

Dan Suciu, +1 more
- 01 Jan 2006 - 
Book ChapterDOI

Term Rewriting Systems

TL;DR: This chapter presents the basic concepts of term rewriting that are needed in this book and suggests several survey articles that can be consulted.
Dissertation

The DP framework for proving termination of term rewriting

TL;DR: This thesis extends existing techniques and develops new methods for mechanized termination analysis of term rewrite systems and designs several novel techniques within the dependency pair framework, which can successfully be applied to prove termination of previously challenging programs.
Book ChapterDOI

The Termination and Complexity Competition

TL;DR: The terminated and complexity competition (termCOMP) focuses on automated termination and complexity analysis for various kinds of programming paradigms, including categories for term rewriting, integer transition systems, imperative programming, logic programming, and functional programming.
References
More filters
Book

Term rewriting and all that

TL;DR: This chapter discusses abstract reduction systems, universal algebra, and Grobner bases and Buchberger's algorithm, and a bluffer's guide to ML Bibliography Index.
Book

Proofs and types

TL;DR: In this paper, the Curry-Howard isomorphism and the normalisation theorem of a natural deduction system T coherence spaces have been studied in the context of linear logic and linear logic semantics.
Book ChapterDOI

CHAPTER 6 – Rewrite Systems

TL;DR: In this paper, the authors focus on rewrite systems, which are directed equations used to compute by repeatedly replacing sub-terms of a given formula with equal terms until the simplest form possible is obtained.
Book

Rewrite systems

TL;DR: In this article, the authors focus on rewrite systems, which are directed equations used to compute by repeatedly replacing sub-terms of a given formula with equal terms until the simplest form possible is obtained.
Journal ArticleDOI

Term rewriting and all that

TL;DR: Term Rewriting and All That is a self-contained introduction to the field of term rewriting and covers all the basic material including abstract reduction systems, termination, confluence, completion, and combination problems.
Frequently Asked Questions (14)
Q1. What contributions have the authors mentioned in the paper "Polymorphic higher-order recursive path orderings" ?

This paper extends the termination proof techniques based on reduction orderings to a higherorder setting, by defining a family of recursive path orderings for terms of a typed lambda-calculus generated by a signature of polymorphic higher-order function symbols. This paper is an extended and improved version of [ Jouannaud and Rubio 1999 ]. Besides, using a restriction of Dershowitz ’ s recursive path ordering for comparing types, the authors can integrate both orderings into a single one operating uniformly on both terms and types. 

The higher-order recursive path ordering should be seen as a firm step to undergo further developments in different directions. The authors suggest below a path to an extension of the higher-order recursive path ordering defined here to a dependent type framework. 

Rewrite rules are used in programming languages and logical systems, with three main goals: defining functions by pattern matching; encoding rule-based decision procedures; describing computations over lambda-terms used as a suitable abstract syntax for encoding functional objects like programs or specifications. 

a modification of their ordering described in a companion paper can be used to prove strong normalization of higher-order rewrite rules operating on terms in η-long β-normal form and using higher-order pattern matching for firing rules [Jouannaud and Rubio 2006]. 

Trying to type the term iter(F, l) in the environment Ran(γ) = {F : pair(IN, α′)→ α′, l : list(pair(α′, IB))} results again in a failure, since the Functions rule generates the very same unsolvable unification problem as before. 

Since the ordering computations involve subterms, a potential difficulty is that a term of a ground type may have subterms of a non-ground type. 

Two lemmas are needed to justify their coming construction of the candidate interpretations: preservation of groundness first; second, any type ordering is included into an ordering enjoying the subterm property. 

Their definition of computability for candidate terms of a ground type is standard, but the authors must make sure that it is compatible with the equivalence =TS on types. 

The trick is to invent a middle term, and show that the lefthand side is bigger than the righthand one in the transitive closure of the ordering. 

Computability of candidate terms of variable type is reduced to the computability of candidate terms of ground type by type instantiation. 

Other extensions are specific to the higher-order case: incorporating the computability closure into the ordering definition; enriching the type system with inductive types, a problem considered in the framework of the general schema by Blanqui [Blanqui et al. 2002; Blanqui 2003]; enriching the type system with dependent types, considered for the original version of the higher-order recursive path ordering [Jouannaud and Rubio 1999] by Walukiewicz [2003]. 

since the structure of terms is lost because of the translation, these methods must be based on an analysis of the flow of redexes in terms. 

This simple well-foundedness proof of RPO proof does not use Kruskal’s tree theorem, and of course, does not show that the recursive path ordering is a well-order. 

Let Σ = {IN, IB : ∗, pair : ∗2 ⇒ ∗, list : ∗ ⇒ ∗}; {α, β, α′ : ∗}; {iter : (α→ β)×list(α)⇒ list(β)}.Consider the term iter(F, l) in the environment {F : α → β, l : list(α)} which will be used in the rest of the example as the domain for a substitution γ.