Chapter 1 Introduction

advertisement
Chapter 1
Introduction
Rewriting is a relatively new technique developed in Computer Science; as its name indicates it
is a technique concerned with replacement of some objects by other objects following certain
rules. Rewriting arises very naturally when reasoning about equations. Consider for example
the natural numbers represented as 0; s(0); s(s(0)); : : : , and the following equations specifying
the maximum of two natural numbers
x; 0) = x
; x) = x
max(s(x); s(y )) = s(max(x; y ))
If we want to determine what max(s(s(0)); s(s(s(0)))) is, a possible way of doing it is to reason
max(
max(0
as follows:
max(
s(s(0)); s(s(s(0)))) = s(max(s(0); s(s(0))))
= s(s(max(0; s(0))))
= s(s(s(0)))
What is peculiar about the above reasoning is that the equations specifying max have been used
in one direction. This one-directional use of equations leads to rewriting. A rewrite system is
then a set of oriented equations or rules describing some relation between some objects. If our
objects are terms in a \term algebra", we talk about term rewriting systems.
Consider the next example of a rewriting system (where the symbol ! denotes in an obvious
way what the intended direction of the rule is)
white red ! red white
blue white ! white blue
blue red ! red blue
Our objects are sequences over the alphabet fblue; white; redg, and the rules dictate what
transformations can be applied to those sequences. This system represents the \Dutch National
Flag" game and traces its origins back to Dijkstra [30] (see also Dershowitz and Manna [27]).
We will use it to illustrate some of the main concepts involved in term rewriting.
Consider the term
blue white red white blue
1
2
Chapter 1. Introduction
In order to obtain a (one-step) reduction from the term, we have to identify a part of it that
matches the lefthand-side of some rewrite rule and then replace that matched part of the term
with the righthand-side of the rule matched (in the presence of variables this is a little more
complicated but the basic idea is the same). In Figure 1.1, we show all possible reductions for
the term considered.
blue white red white blue
9
white blue red white blue
XXXXX
XXXz
blue red white white blue
?
?
white red blue white blue
red blue white white blue
XXXX
XXXX
XXXX
XXXXXz ?
?
white red white blue blue
red white blue white blue
ZZ
ZZ
~
Z
=
red white white blue blue
Figure 1.1: All possible reductions of the term blue white red white blue.
From this example we see that there are terms that may admit more than one reduction
sequence. In our case, the term blue white red white blue admits the three reduction
sequences shown in Figure 1.1 (in the leftmost sequence we always reduce the underlined
terms, in the rightmost sequence we reduce the overlined terms and in the sequence going
from left to right we start by reducing underlined terms and then go on reducing overlined
terms). When several reduction sequences exist for a term, it may or may not be possible to
join the dierent reductions, i. e., to nd another term such that all reduction sequences end
in that term. Systems in which this is possible are called conuent or said to have the ChurchRosser property. There are also terms that admit no reduction sequences, i. e., they are normal
forms. Normal forms play an important role in the theory of rewriting and of particular interest
are the systems in which each term admits a normal form (especially if the normal form is
unique). Normal forms are related to another important property of rewriting systems, namely
termination. A rewriting system is said to be (uniformly) terminating, strongly normalizing or
noetherian, if no term admits an innite reduction sequence.
Term rewriting systems (TRS's) constitute a simple formalism useful for the study of com-
3
putational procedures. For equational reasoning, for example, term rewriting systems are used
as interpreters for equational programs O'Donnell [84], for solving unication problems, Fay
[31], in Knuth-Bendix completions, Knuth and Bendix [63] (where given an equational theory a
TRS is constructed proving the same equations as the original theory, and providing a solution
for the validity problem in the theory), proof by consistency procedures, Musser [80], abstract
data types specications and so forth.
Also of interest are several extensions of (rst-order) rewriting. We mention some: graphrewriting, Barendregt et al. [4], rewriting modulo equational theories, Jouannaud and Kirchner
[50], Bachmair [1], Dershowitz and Jouannaud [26], term rewriting with priorities, Baeten,
Bergstra and Klop [2], order-sorted rewriting, Goguen, Jouannaud and Meseguer [43], innite
rewriting, Kennaway, Klop, Sleep and de Vries [58], conditional rewriting, Brand, Darringer and
Joyner Jr. [10], Bergstra and Klop [7], Dershowitz, Okada and Sivakumar [28], higher-order
rewriting, Klop [60], Wolfram [105], Nipkow [83], van Oostrom [103]. Included in the last group
are -Calculus, Church [12], Barendregt [3], used to formalize the notion of computability, and
Combinatory Logic, Schonnkel [98], Curry [13, 14], Curry and Feys [15], Curry, Hindley and
Seldin [16], which has proved itself very useful in the implementation of programming languages.
Overview of the thesis
This thesis is about termination of rewriting. Our setting is rst-order term rewriting,
extended in the last chapter to rewriting modulo equations. In general, given a nite TRS
it is undecidable if the TRS terminates or not; there are nevertheless some techniques that
are successful in particular cases. Generally speaking those techniques can be divided into
two main groups: syntactical methods and semantical methods. In the rst class only the
syntactical structure of the terms is used to devise a proof of termination. The best known
method of this type is probably the recursive path order (rpo) of Dershowitz [22]. In the
second class, terms are interpreted compositionally in some (well-founded monotone) algebra
in order to prove termination of the system. However, at the core of both classes of methods
lies a well-founded order. Indeed, well-foundedness is the essential property needed for proving
termination. Unfortunately checking if a particular order is well-founded is usually a dicult
task. In chapter 3 we investigate this important property for orders on terms and give new
criteria, in the style of Kruskal's theorem, that can be used to infer well-foundedness. The
results obtained there can be applied, in particular, to prove well-foundedness of an extended
version of the recursive path order that is dened in chapter 4. It turns out that recursive path
order, though being a syntactic method, ts nicely in the semantic framework, as we see in
chapter 4. In this chapter we also investigate the problem of dening path orders recursively and
give a general framework for proving well-denedness of such orders. In chapter 5 we concentrate
on the study of TRS's for which a proof of termination can be given by interpretation of terms
in a total well-founded monotone algebra. TRS's having this property are said to be totally
terminating. Interestingly enough, the class of totally terminating TRS's contains the class of
TRS's for which a proof of termination using rpo can be given. Finally, in chapter 6 we present
a method for simplifying the task of proving termination of TRS's. The method consists of
transformations on TRS's induced by transformations on terms, that are sound with respect to
4
Chapter 1. Introduction
termination (i. e., if the transformed system terminates, so does the original one). The method
remains valid for rewriting modulo a set of equations as long as the equations satisfy some
minor restrictions.
We summarize what we believe are the main results in this thesis:
the new criteria for proving well-foundedness of term orderings; unlike Kruskal's theorem,
our criteria cover all terminating TRS's.
the characterization of the algebras associated to totally terminating TRS's and modularity of total termination.
a new transformational method for proving termination; we emphasize that, unlike most
syntactical methods, this approach remains valid in the presence of equations.
We review briey the chapters and subjects not yet mentioned. In chapter 2 we will introduce
the main concepts of the theory of rewriting and of orders. With respect to termination, we
will concentrate on the semantical framework; well-founded monotone algebras will be dened
and linked to termination of TRS's. Terminating TRS's can be divided in categories based on
the properties of the algebras used for termination proofs; such a classication is presented and
discussed. We will also discuss undecidability of termination. As mentioned before, in chapter
5 we will concentrate on total termination. A lot of the techniques used in this chapter come
from the theory of ordinals. In order to keep the thesis self-contained, we will give a summary
of the theory of ordinals needed.
In Appendix A we present a proof of a well-known result about extending well-founded
orders to total well-founded ones. The reason why we include such a well-known result is that
it is quite hard to nd a proof of it in the literature. Finally in Appendix B contains a proof of
undecidability of termination and a comparison between the proof given and the work of Huet
and Lankford [47].
Most of the results presented in this thesis have already been published elsewhere. Chapter
3 was presented in Ferreira and Zantema [34], chapter 4 is based on Ferreira and Zantema [33]
and chapter 5 on Ferreira and Zantema [32, 33]. Chapter 6 is unpublished (though it originates
in the work presented at Ferreira and Zantema [35]).
As far as dependecies between the chapters are concerned, chapter 2 contains most of the
notions needed to read the rest of the thesis so its reading should precede the reading of any
other chapter. As for chapters 3, 4, 5 and 6, and appendices A and B, though obviously
connected, they can be read as independent units, so no order is imposed. We suggest the
order in which they are presented since it seemed the most natural to us.
Download