Restrictions of rewriting can eventually achieve termination
by pruning all infinite rewrite sequences issued from every term.
However, proving that such an improvement is actually achieved
is challenging.
Context-sensitive rewriting (CSR) is a restriction of
rewriting which is useful for describing
semantic aspects of programming languages (e.g., Maude, OBJ2, OBJ3, or CafeOBJ) and
analyzing the computational properties (e.g., termination
or completeness) of the corresponding programs
[Luc01a,
Luc01b,
Luc03].
In CSR, a replacement map, i.e., a mapping µ from symbols into
subsets of their argument positions, is used to
discriminate the argument positions on which replacements are allowed;
in this way, a restriction of rewriting is obtained.
Example 1: Consider the TRS [Luc98, Example 6]:
first(0,X) -> nil
first(s(X),cons(Y,Z)) -> cons(Y,first(X,Z))
from(X) -> cons(X,from(s(X)))
In order to avoid infinite rewritings with expressions involving calls to
from, it is natural to forbid
rewritings on the second argument of the list constructor cons
(i.e., we let µ(cons)={1}).
It is possible to prove that such context-sensitive computations
are terminating.
In Lazy Rewriting, a replacement map is also used to distinguish between arguments
which can be freely eveluated from those which are evaluated only
on-demand. Thus, in contrast to CSR, reductions are
eventually allowed on non-replacing arguments of symbols f, i.e., arguments
i which do not belong to µ(f). See [Luc02] for further details about the connections
between CSR and Lazy Rewriting.
|
Structure and functionality
|
MU-TERM provides a simple way to deal with Term Rewriting Systems and replacement
maps. The application is written in Haskell
and has been developed with GHC,
a popular Haskell compiler.
The tool has a graphical user interface which has been developed by using the
wxHaskell graphics library.
With MU-TERM you can:
- Load TRSs, extract the corresponding signature, and associate a replacement map
to the symbols of the signature.
- Modify a replacement map previously associated to the symbols of the signature.
- Prove termination of Context-Sensitive
Rewriting for a
given TRS R and replacement map µ. Most available
techniques for proving termination of CSR (direct proofs via
polynomial oderings, modular decompositions, transformations, etc.) have
been implemented.
- Prove termination of Innermost Context-Sensitive Rewriting for a
given TRS R and replacement map µ.
- Prove termination of Lazy
Rewriting for a
given TRS R and replacement map µ.
- Prove termination of
Rewriting by using the techniques
which have been developed for proving termination of CSR
(polynomials over the rational numbers, weakly monotonic orderings
together with the Dependency Pairs approach, etc.).
We provide two different ways to associate a replacement map µ to a
given TRS:
Example 2: The TRS R and replacement map µ in
Example 1 can be specified by the following TPDB
module:
(VAR X Y Z)
(STRATEGY CONTEXTSENSITIVE
(first 1 2)
(0)
(nil)
(s 1)
(cons 1)
(from 1)
)
(RULES
first(0,X) -> nil
first(s(X),cons(Y,Z)) -> cons(Y,first(X,Z))
from(X) -> cons(X,from(s(X)))
)
You can also do it as an OBJ module:
obj Ex6_Luc98 is
sort S .
op first : S S -> S .
op 0 : -> S .
op nil : -> S .
op s : S -> S .
op cons : S S -> S [strat (1 0)] .
op from : S -> S .
vars X Y Z : S .
eq first(0,X) = nil .
eq first(s(X),cons(Y,Z)) = cons(Y,first(X,Z)) .
eq from(X) = cons(X,from(s(X))) .
endo
The following à la Maude version would also be accepted:
fmod Ex6_Luc98 is
sort S .
op first : S S -> S .
op 0 : -> S .
op nil : -> S .
op s : S -> S .
op cons : S S -> S [strat (1 0)] .
op from : S -> S .
vars X Y Z : S .
eq first(0,X) = nil .
eq first(s(X),cons(Y,Z)) = cons(Y,first(X,Z)) .
eq from(X) = cons(X,from(s(X))) .
endfm
We refer to [AGIL07,Luc04a]
for further details.
|
Termination of
CSR with MU-TERM
|
A number of methods have been developed for proving the
µ-termination of a TRS R (i.e., termination of
CSR for R and the replacement map µ). Basically, we have:
- Direct methods, i.e., orderings > on terms which can be
used to directly compare the left-hand sides and right-hand sides of the
rules in order to conclude the µ-termination of the TRS, see
[BLR02,
Bor03,
GL02b,
Luc04b,
Zan97].
MU-TERM implements the techniques described in
[BLR02] (CSRPO) and
[Luc04b,Luc05]
(polynomial orderings).
- Context-sensitive dependency pairs:
We have also adapted Arts and Giesl's dependency pairs method
[AG00]
to CSR
leading to a context-sensitive dependency pairs approach
[AGL06].
MU-TERM implements all techniques described in
[AGL06].
- Transformations from TRSs R and
replacement maps µ that obtain a TRS R'. If we are able to prove
termination of R' (using the standard methods), then
the µ-termination of R is ensured, see
[FR99,
GM04,
Luc96a,
Zan97].
Our tool, MU-TERM,
implements these transformations using a common environment
that eases their combination and comparison.
Examples of CS-TRSs and the corresponding termination proofs by using these
techniques can be found
here.
|
Termination of
Lazy Rewriting with MU-TERM
|
In [Luc02], termination of Lazy Rewriting is
proved by using a transformation which permits to use any available
technique for proving termination of CSR:
Example 3: The termination of Lazy Rewriting for the
following module:
obj Ex1_2_Luc02c is
sort S .
op 2nd : S -> S .
op cons : S S -> S [strat (1 0)] .
op from : S -> S .
op s : S -> S .
vars X Y Z : S .
eq 2nd(cons(X,cons(Y,Z))) = Y .
eq from(X) = cons(X,from(s(X))) .
endo
can be proved by proving termination of CSR for the following system:
obj Ex1_2_Luc02c_LR is
sort S .
op 2nd : S -> S .
op cons : S S -> S [strat (1 0)] .
op from : S -> S .
op s : S -> S .
op cons1 : S S -> S .
vars X Y Z X1 : S .
eq 2nd(cons1(X,cons(Y,Z))) = Y .
eq 2nd(cons(X,X1)) = 2nd(cons1(X,X1)) .
eq from(X) = cons(X,from(s(X))) .
endo
which is obtained by applying the transformation in [Luc02] (implemented in MU-TERM).
|
Termination of
rewriting with MU-TERM
|
Since termination of rewriting is a particular case of termination of
CSR (where µ(f)={1,...,k} for each k-ary symbol
f), we can also use MU-TERM to prove termination of
rewriting.
Nowadays, MU-TERM is the only tool which implements the
automatic generation of polynomial orderings based on polynomial
intepretations which use rational coefficients. This can be used
for proving termination of rewriting.
Example 4: The following TRS R
f(X) -> u1(X,X)
u1(h(Y),X) -> u2(i(X),X,Y)
u2(Y,X,Y) -> g(Y)
i(X) -> a
a -> u(c)
u(d) -> b
c -> d
can be automatically proved terminating by using the following polynomial
interpretation computed by MU-TERM:
[f](X) = 3.X + 1
[u1](X1,X2) = X1 + 2.X2
[h](X) = X + 3
[u2](X1,X2,X3) = X1 + X2 + X3 + 1
[i](X) = X + 3/2
[g](X) = X
[a] = 1
[u](X) = X + 1/2
[c] = 1/3
[d] = 0
[b] = 0
On the other hand, µ-reduction orderings based on polynomial
interpretations over the rationals are also used together
with Arts and Giesl's dependency pairs approach to prove
termination of rewriting.
Example 5: The µ-termination of Ex1_2_Luc02c_LR in
Example 3 above can be proved by using Ferreira and Ribeiro's
transformation. The TRS Ex1_2_Luc02c_LR_FR:
2nd(cons1(X,cons(Y,Z))) -> Y
2nd(cons(X,X1)) -> 2nd(cons1(X,activate(X1)))
from(X) -> cons(X,n__from(n__s(X)))
from(X) -> n__from(X)
s(X) -> n__s(X)
activate(n__from(X)) -> from(activate(X))
activate(n__s(X)) -> s(activate(X))
activate(X) -> X
can be proved terminating by using
the following polynomial interpretation
computed by MU-TERM:
[2nd](X) = 3.X
[cons](X1,X2) = X1 + 1/3.X2 + 1
[from](X) = 2.X + 3
[s](X) = X + 1
[cons1](X1,X2) = 1/3.X2
[n__from](X) = 2.X + 3
[n__s](X) = X + 1
[activate](X) = X
[nF_2nd](X) = X
[nF_from](X) = 0
[nF_activate](X) = 1/3.X
where nF_2nd, nF_from, and
nF_activate are new symbols which have been automatically introduced to compute the
dependency pairs that correspond to Ex1_2_Luc02c_LR_FR.
A more detailed justification of these techniques is given in this note:
Luc05.
Download
Examples in TPDB format
and OBJ/Maude format
Proofs of termination with the previous examples
using MU-TERM
Previous versions
[AG00]
Termination of Term Rewriting Using Dependency Pairs
T. Arts and
J. Giesl
Theoretical Computer Science 236:133-178, 2000.
Available:
Abstract
PDF
[AGIL07]
Proving Termination of Context-Sensitive Rewriting With
MU-TERM
B. Alarcón,
R. Gutiérrez,
J. Iborra, and
S. Lucas
© Elsevier
Proc. of the
Sixth Spanish Conference on Programming and Computer Languages,
PROLE 2006
- Selected papers
Electronic Notes in Theoretical Computer Science, to appear, 2006.
Available:
Abstract
[AGL06]
Context-Sensitive Dependency Pairs
B. Alarcón,
R. Gutiérrez, and
S. Lucas
© Springer-Verlag
Proc. of the
26th Conference on Foundations of Software Technology and Theoretical Computer Science,
FSTTCS'06
LNCS 4337:298-309, Springer-Verlag, Berlin, 2006.
Available:
Abstract
PDF
[BLR02]
Recursive Path Orderings can be Context-Sensitive
C. Borralleras,
S. Lucas, and
A. Rubio
© Springer-Verlag
Proc. of 18th International Conference on Automated Deduction, CADE'02,
LNAI 2392:314-331, Springer-Verlag, Berlin, 2002.
Available:
Abstract
PDF
PostScript
BibTeX
entry.
[Bor03]
Ordering-based methods for proving termination
automatically
C. Borralleras,
PhD Thesis, Departament de Llenguagtes i Sistemes Informàtics de
la Universitat Politècnica de Catalunya, May 2003.
[FR99]
Context-Sensitive AC-Rewriting
M.C.F. Ferreira and A.L. Ribeiro
© Springer-Verlag
Proc. of 10th International Conference on Rewriting Techniques and
Applications, RTA'99,
LNCS 1631:173-181, Springer-Verlag, Berlin, 1999.
[GL02a]
Modular Termination of Context-Sensitive Rewriting
B. Gramlich and
S. Lucas
© ACM Press
Proc. of 4th International Conference on Principles
and Practice of Declarative Programming, PPDP'02,
pages 50-61, ACM Press 2002.
Available:
Abstract
PDF
PostScript
Slides
BibTeX
entry.
[GL02b]
Simple Termination of Context-Sensitive Rewriting
B. Gramlich and
S. Lucas
© ACM Press
Proc. of 3rd ACM Sigplan Workshop on Rule-based Programming, RULE'02,
pages 29-41, ACM Press, 2002.
Available:
Abstract
PDF
PostScript
Slides
BibTeX
entry.
[GM99]
Transforming Context-Sensitive Rewrite Systems
J. Giesl and
A. Middeldorp
© Springer-Verlag
Proc. of 10th International Conference on Rewriting Techniques and
Applications, RTA'99,
LNCS 1631:271-287, Springer-Verlag, Berlin, 1999.
Available:
Abstract
PostScript
BibTeX
entry
[GM02]
Innermost Termination of Context-Sensitive Rewriting
J. Giesl and
A. Middeldorp
Technical Report AIB 2002-04, RWTH Aachen, 2002.
[GM03]
Innermost Termination of Context-Sensitive Rewriting
J. Giesl and
A. Middeldorp
© Springer-Verlag
Proc. of 6th International Conference on Developments of Language Theory,
DLT'02,
LNCS 2450:231-244, 2003.
[GM04]
Transformation Techniques for Context-Sensitive Rewrite Systems
J. Giesl and
A. Middeldorp
Journal of Functional Programming, 14(4):379-427, 2004.
Available:
Abstract
PDF
(preprint)
BibTeX
entry
[Luc96b]
Termination of Context-Sensitive Rewriting by
Rewriting
S. Lucas
© Springer-Verlag
23rd International Colloquium on Automata, Languages and Programming,
ICALP'96,
LNCS 1099:122-133, Springer-Verlag, Berlin, 1996.
Available:
Abstract
PostScript
BibTeX
entry.
[Luc98]
Context-sensitive computations in functional and functional logic
programs
S.
Lucas
Journal of Functional and Logic Programming, 1998(1):1-61, January
1998.
Available:
Abstract
Paper
BibTeX
entry
[Luc01a]
Termination of on-demand rewriting and termination of
OBJ programs
S. Lucas
© ACM Press
Proc. of 3rd International Conference on Principles
and Practice of Declarative Programming, PPDP'01,
pages 82-93, ACM Press, 2001.
Available:
Abstract
PostScript
BibTeX
entry.
[Luc01b]
Termination of Rewriting With Strategy Annotations
S. Lucas
© Springer-Verlag
Proc. of 8th International Conference on Logic for Programming,
Artificial Intelligence and Reasoning, LPAR'01
LNAI 2250:666-680, Springer-Verlag, Berlin, 2001.
Available:
Abstract
PostScript
BibTeX
entry.
Extended and revised version in [Luc03]
[Luc02]
Lazy Rewriting and Context-Sensitive Rewriting
S. Lucas
© Elsevier
International Workshop on Functional and (Constraint) Logic Programming,
WFLP 2001 (selected papers)
Electronic
Notes in Theoretical Computer Science, volume 64, 2002.
Available:
Abstract
PDF
PostScript
BibTeX
entry.
[Luc03]
Termination of programs with strategy annotations
S. Lucas
Technical Report DSIC II/20/03, 47 pages.
Departamento de Sistemas Informáticos y Computación, UPV,
September 2003.
Available:
Abstract
PDF
PostScript
BibTeX
entry.
[Luc04a]
MU-TERM: A Tool for Proving Termination of Context-Sensitive Rewriting
S. Lucas
© Springer-Verlag
Proc. of 15th International Conference on Rewriting Techniques and
Applications, RTA'04,
LNCS 3091:200-209, Springer-Verlag, Berlin, 2004.
Available:
Abstract
PDF
PostScript
[Luc04b]
Polynomials for Proving Termination of Context-Sensitive
Rewriting
S. Lucas
© Springer-Verlag
Proc. of 7th International Conference on
Foundations of Software Science and Computation Structures,
FOSSACS'04,
LNCS 2987:318-332, 2004.
Available:
Abstract
PDF
PostScript
BibTeX entry
[Luc05]
Polynomials over the reals in proofs of termination: from
theory to practice
S. Lucas
©
EDP Sciences
RAIRO Theoretical Informatics and Applications,
39(3):547-586, July 2005.
Available:
Abstract
PDF
[Zan97]
Termination of Context-Sensitive Rewriting
H. Zantema
© Springer-Verlag
Proc. of 8th International Conference on Rewriting Techniques and
Applications, RTA'97,
LNCS 1232:172-186, Springer-Verlag, Berlin, 1997.
Salvador Lucas
Please, report any bug, comment, or suggestion to: slucas@dsic.upv.es