Contents lists available atScienceDirect
The Journal of Logic and Algebraic Programming
j o u r n a l h o m e p a g e :w w w . e l s e v i e r . c o m / l o c a t e / j l a p
Characterizing and proving operational termination of deterministic
conditional term rewriting systems
<
Felix Schernhammer
∗
,1, Bernhard Gramlich
Arbeitsbereich Theoretische Informatik und Logik, Institut für Computersprachen, Technische Universität Wien, Favoritenstrasse 9 – E185/2, A-1040 Wien, Austria
A R T I C L E I N F O A B S T R A C T
Article history:
Available online 15 July 2010 Keywords:
Conditional term rewriting Operational termination
Transforming conditional rewrite systems Collapse extended termination Dependency pair framework
We investigate the practically crucial property of operational termination of deterministic conditional term rewriting systems (DCTRSs), an important declarative programming para-digm. We show that operational termination can be equivalently characterized by the newly introduced notion of context-sensitive quasi-reductivity. Based on this characterization and an unraveling transformation of DCTRSs into context-sensitive (unconditional) rewrite sys-tems (CSRSs), context-sensitive quasi-reductivity of a DCTRS is shown to be equivalent to termination of the resulting CSRS on original terms (i.e., terms over the signature of the DCTRS). This result enables both proving and disproving operational termination of given DCTRSs via transformation into CSRSs. A concrete procedure for this restricted termination analysis (on original terms) is proposed and encouraging benchmarks obtained by the ter-mination tool VMTL, that utilizes this approach, are presented. Finally, we show that the context-sensitive unraveling transformation is sound and complete for collapse-extended termination, thus solving an open problem of Duran et al. (2008) [10].
© 2010 Elsevier Inc. All rights reserved.
1. Introduction and overview
Conditional term rewriting systems (CTRSs) are a natural extension of unconditional such systems (TRSs) allowing rules to be guarded by conditions. Conditional rules tend to be very intuitive and easy to formulate and are therefore used in several declarative programming and specification languages, such as Maude [8] or ELAN [7]. Here we focus on the particularly interesting class ofdeterministic(oriented) CTRSs (DCTRSs) which allows for extra variables in conditions and right-hand sides to some extent (corresponding tolet-constructsorwhere-clausesin other functional-(logic) languages) and has been used for instance in proofs of termination of (well-moded) logic programs [14] (cf. also [30,32]).
When analyzing the termination behaviour of conditional TRSs, it turns out that the proof-theoretic notion ofoperational termination[23] is more adequate than ordinary termination in the sense that practical evaluations w.r.t. operationally terminating DCTRSs always terminate (which is indeed not true for other similar notions likeeffective termination[30]).
Example 1. Consider the following DCTRSR.
a
→
b⇐
a→
∗bThe induced rewrite relation is empty and thus in particular well-founded and decidable. Hence,Ris effectively terminating (cf. [30]). On the other hand a naive algorithm recursively evaluating conditions of conditional rules in order to check
< This article expands on the talk given at the 20th Nordic Workshop on Programming Theory, NWPT 2008, Tallinn, 19–21 November 2008. ∗ Corresponding author.
E-mail addresses:[email protected](F. Schernhammer),[email protected](B. Gramlich). 1 The author was supported by the Austrian Academy of Sciences under Grant 22.361. 1567-8326/$ - see front matter © 2010 Elsevier Inc. All rights reserved.
applicability might loop. This is taken into account in the notion of operational termination. IndeedRis not operationally terminating.
For the analysis of operational termination of DCTRSs the equivalent property of quasi-decreasingness is usually used [23]. In [29,30], based on the idea ofunravelingsof [25], a transformation from DCTRSs into TRSs is proposed such that termination of the transformed TRS impliesquasi-reductivityof the given DCTRS which in turn implies its quasi-decreasingness.
We propose an alternative definition ofquasi-reductivityusing context-sensitivity [21], that will be proved to be equiv-alent to operational termination of DCTRSs. Furthermore, we use a simple modification of Ohlebusch’s transformation [30] that allows us to completely characterize the new property of context-sensitive quasi-reductivity of a DCTRS by means of termination of the context-sensitive (unconditional) TRS, that is obtained by the transformation,on original terms(i.e., terms over the signature of the DCTRS).
This complete characterization yields a method for disproving operational termination of DCTRSs by disproving termi-nation of CSRSs on original terms. Moreover, we will show that the proposed transformation is sound and complete with respect tocollapse-extendedtermination even if this notion is not restricted to original terms in the transformed system. As a corollary we obtain modularity of collapse-extended operational termination of DCTRSs.
Finally, we present an approach, which is based on the dependency pair framework of [17] (cf. also [5]), for proving termination of a CSRS on original terms, thus exploiting the given equivalence result. This approach has been implemented in the tool VMTL [31]2 and evaluated on a set of 24 examples. Several of these examples, where other existing approaches fail, could be shown to be operationally terminating thanks to the new method.3
For the sake of readability, only selected proofs will be presented inline. All other proofs can be found in Appendix A.
2. Preliminaries
We assume familiarity with the basic concepts and notations of term rewriting and context-sensitive rewriting (cf. e.g., [6,21,34]). Throughout the paper we assume that all CTRSs, CSRSs and TRSs (i.e., their induced reduction relations) are
finitely branching.
ByVar
(
t)
we denote the set of variables occurring in the termt.Varμ(
t)
denotes the set of replacing variables andVarμ(
t)
the set of non-replacing variables w.r.t. a replacement map
μ
oft.Conditional rewriting. We are concerned withoriented3-CTRSs. Such systems consist of conditional rulesl
→
r⇐
c, withcbeing of the forms1
→
∗ t1, . . . ,
sn→
∗tnsuch thatlis not a variable andVar(
r)
⊆
Var(
l)
∪
Var(
c)
. The conditional rewrite relation induced by a CTRSRis inductively defined as follows:R0= ∅
,Rj+1= {
lσ
→
rσ
|
l→
r⇐
s1→
∗ t1, . . . ,
sn→
∗ tn∈
R∧
siσ
→
∗Rj tiσ
for all 1≤
i≤
n}
, and→
R=
j≥0
→R
j. We say that a reduction steps→
R thas depthiifs→
Ri tands→
Rj tfor allj<
i. A deterministic CTRS (DCTRS) is an oriented 3-CTRS where for each rule l→
r⇐
s1→
t1, . . . ,
sn→
tnit holds thatVar(
si)
⊆
Var(
l)
∪
ij=−11Var(
tj)
.A DCTRS
(
,
R)
is calledquasi-reductive, cf. [30], [14], if there exists an extensionofand a well-founded partial order onT(
,
V), which is monotonic, i.e., closed under contexts, such that for every rulel→
r⇐
s1→
∗t1, . . . ,
sn→
∗tn∈
R, everyσ
:
V→
T(
,
V)
and everyi∈ {
0, . . . ,
n−
1}
:•
Ifsjσ
tjσ
for every 1≤
j≤
i, thenlσst
si+1σ
.•
Ifsjσ
tjσ
for every 1≤
j≤
n, thenlσ
rσ
.Here
st
=
(
∪
)
+(denotes the proper subterm relation).A DCTRSR
=
(
,
R)
isquasi-decreasing[30] if there is a well-founded partial orderingonT(
,
V)
, such that→
R⊆
,= st
, and for every rulel→
r⇐
s1→
∗ t1, . . . ,
sn→
∗tn∈
R, every substitutionσ
and everyi∈ {
0, . . . ,
n−
1}
it holds thatsjσ
→
∗Rtjσ
for allj∈ {
1, . . . ,
i}
implieslσ
si+1σ
.In [23] the notion ofoperational terminationof (D)CTRSs is defined via the absence of infinite well-formed trees in a certain logical inference system. In the case of DCTRSs, this notion is shown to be equivalent to quasi-decreasingness [23].
The latter notions are related as follows [23,30]:
quasi-reductivity
⇒
quasi-decreasingness⇔
operational terminationContext-sensitive narrowing and orderings. Given a CSRSR
=
(
,
R)
with replacement mapμ
, the relation of context-sensitive narrowing (writtenμR) is defined ast μRsif there is a replacing non-variable positionpintsuch thatt|p
andlunify (l
→
r∈
Rand we assume thattandl→
rdo not share any variables) with mguθ
ands=
t[
r]p
θ
. We say thatsis aone-step, context-sensitive narrowingoft. Note that in contrast to ordinary rewriting, here we allow for rules inRto have extra variables in the right-hand sides and variable left-hand sides. The reason for this general definition of narrowing
2
<http://www.logic.at/vmtl/>. 3
is that we are going to use abackward narrowingrelation that is induced by reversing all rules of a TRS (cf. Lemma7and Definition13below).
An ordering
on termsT(
,
V)
is calledμ
-monotonic iffis monotonic in itsith argument wheneveri∈
μ(
f)
for allf
∈
, i.e.,si
ti⇒
f(
s1, . . . ,
si−1,
si,
si+1. . . ,
sn)
f(
s1, . . . ,
si−1,
ti,
si+1. . . ,
sn)
Context-sensitive dependency pairs. ([1] , cf. also [2,3,22]) Given a TRSR
=
(
,
R)
, the signatureis partitioned into its defined and constructor symbolsDC, where the defined symbols are exactly those that occur as root symbols of the left-hand sides of rules inR. A termtishiddenw.r.t. to a CSRS(
R=
((
DC,
R), μ))
ifroot(
t)
∈
Dandtappears non-μ
-replacing in the right-hand side of a rule ofR. Moreover, we say that a functionf hides a positioniif there is a rulel→
r∈
Rsuch that some termf(
r1, . . . ,
ri, . . . ,
rn)
occurs at a non-replacing position ofr,i∈
μ(
f)
andricontains a defined symbol or a variable at a replacing position.The set of context-sensitive dependency pairs [1] of a CSRS
(
R, μ)
, denotedDP(R, μ)
, isDPo(
R, μ)
∪
DPu(
R, μ)
whereDPo
(
R, μ)
= {
l→
s|
l→
r∈
R,
rμs
,
root(
s)
∈
D,
lμs}
andDPu(
R, μ)
is the union of the following “unhiding” dependency pairs:• {
l→
D(
x)
|
l→
r∈
R,
x∈
Varμ(
r)
−
Varμ(
l)
}
,•
D(
f(
x1, . . . ,
xi, . . . ,
xn))
→
D(
xi)
for every function symbolf of any aritynand every 1≤
i≤
nwheref hides positioni, and•
D(t)
→
tfor every hidden termt.Here,tdenotes the termf
(
t1, . . . ,
tn)
, ift=
f(
t1, . . . ,
tn)
andfis a newdependency pair symbol. Moreover,Dis a fresh function symbol. The relationμis defined ass
μtifs
=
s[
t]p
andp∈
Posμ(t)
.We denote bythe signatureplus all dependency pair symbols plus the new symbolD. The replacement map
μ
is extended intoμ
whereμ
(f
)
=
μ(f
)
iff∈
,μ
(f
)
=
μ(f
)
iffis a dependency pair symbol andμ(D
)
= ∅
.LetDPandRbe TRSs and
μ
be a replacement map for their combined signature. A (possibly infinite) sequence of ruless1
→
t1,
s2→
t2, . . .
fromDPis a(
DP,
R, μ)
-chain if there is a substitutionσ
, such thattiσ
→
∗R,μsi+1σ
for alli>
0. Wesay that
σ
enablesthe chains1→
t1,
s2→
t2, . . .
We call a triple
(
DP,
R, μ)
, whereDPandRare TRSs andμ
is a replacement map for the combined signatures ofDPandR, a(context-sensitive) dependency pair problem(CS-DP-problem). A context-sensitive dependency pair problem is finite if there is no infinite
(DP,
R, μ)
-chain.A CSRS
(
R, μ)
isμ
-terminating if and only if the dependency pair problem(
DP(
R, μ),
R, μ)
is finite [1].3. Context-sensitive quasi-reductivity
The goal of this work is to provide methods for proving operational terminationof DCTRSs. We define the notion of context-sensitive quasi-reductivity, which is equivalent to operational termination (cf. Corollary4below), and the key to several main results of this paper.
Definition 1(context-sensitive quasi-reductivity). A DCTRSR(R
=
(
,
R)
) is calledcontext-sensitively quasi-reductive( cs-quasi-reductive) if there is an extension of the signature(⊇
), a replacement mapμ
(s.t.μ(f
)
= {
1, . . . ,
ar(f)
}
for allf∈
) and aμ
-monotonic, well-founded partial orderμonT(
,
V)
satisfying for every rulel→
r⇐
s1→
∗ t1, . . . ,
sn→
∗tn, every substitutionσ
:
V→
T(
,
V)
and everyi∈ {
0, . . . ,
n−
1}
:•
Ifsjσ
μtjσ
for every 1≤
j≤
ithenlσ
stμsi+1σ
.•
Ifsjσ
μtjσ
for every 1≤
j≤
nthenlσ
μrσ
.The ordering
stμis defined as(
μ∪
μ)
+wheret μ sif and only ifsis a proper subterm oftat some positionp
∈
Posμ(
t)
. Moreover=
(
∪ =
)
.To be entirely precise, the notion of cs-quasi-reductivity should be parameterized by the set of function symbols that may not be restricted by the replacement map
μ
. However, as throughout the paper this set of function symbols is the set of functions of the signature of the DCTRS in question, we refrain from giving a reference to this parameter in the notioncs-quasi-reductivity for the sake of simplicity.
Cs-quasi-reductivity generalizes quasi-reductivity in the sense that the extended signature may be equipped with a replacement map (which must leave the original signature untouched, though) and the monotonicity requirement of the
ordering is relaxed accordingly. Furthermore, and this is crucial, in the ordering constraints for the conditional rules the sub-stitutions replace variables only by terms over the original signature, whereas in the original definition (of quasi-reductivity) terms over the extended signature are substituted.
The latter generalization appears to be quite natural, since the main implications of quasi-reductivity remain valid (cf. Proposition2). Moreover, it is the key to the completeness results that we will prove (cf. Corollary4).
Proposition 1. If a DCTRSRis quasi-reductive, then it is cs-quasi-reductive. Proposition 2. If a DCTRSRis cs-quasi-reductive, then it is quasi-decreasing.
Corollary 1. LetRbe DCTRS. IfRis cs-quasi-reductive, then it is operationally terminating. 4. Proving context-sensitive quasi-reductivity
In the following, we use a transformation from DCTRSs into CSRSs such that
μ
-termination of the transformed CSRS implies cs-quasi-reductivity of the original DCTRS. The transformation is actually a variant of the one in [30], which in turn was inspired by [25,26].4Definition 2(unraveling of DCTRSs[30]). LetRbe a DCTRS (R
=
(
,
R)
). For every ruleα
:
l→
r⇐
s1→
∗t1, . . . ,
sn→
∗tnwe usennew function symbolsUαi (i
∈ {
1, . . . ,
n}
). Thenα
is transformed into a set of unconditional rules in the following way:l
→
U1α(
s1,
Var(
l))
U1α
(t
1,
Var(l))→
U2α(s
2,
Var(l),EVar(t1))
...
Unα
(
tn,
Var(
l),
EVar(
t1), . . . ,
EVar(
tn−1))
→
rHereVar(s)denotes an arbitrary but fixed sequence of the set of variables of the terms. LetEVar(ti
)
beVar(ti)
\
(Var(l)
∪
i−1
j=1Var
(
tj))
. By abuse of notation, byEVar(
ti)
we denote an arbitrary but fixed sequence of the variables in the setEVar(
ti)
. Any unconditional rule ofRis transformed into itself. The transformed systemU(
R)
=
(
U(
),
U(
R))
is obtained by transforming each rule ofRwhereU(
)
isextended by all new function symbols. In caseRhas only one conditional ruleα
, we also writeUiinstead ofUiα.Henceforth, we use the notion ofU-symbols of a transformed signature, which are function symbols fromU(
)
\
. Moreover, byU-terms orU-rooted terms we mean terms with aU-symbol as their root.Next, we define the function
tb
, whose intended meaning is to undo non-finished meta-evaluations, i.e., evaluations of the forms→
∗U(R)U(v1, ...,
vl)
. We call reductions of this shapemeta-evaluations, because they are used for the evaluation of encoded conditions. This evaluation does not have an explicit counterpart in conditional rewrite sequences. The functiontb
and its properties will play a crucial role in understanding and proving the main results of this paper.Definition 3. The mapping
tb
:
T(U(
),
V)→
T(
,
V)(read “translate back”) which is equivalent to Ohlebusch’s mapping [30, Definition 7.
2.
53] is defined bytb
(
t)
=
⎧ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎩ x ift=
x∈
V f(
tb
(t
1), . . . ,
tb
(t
l))
ift=
f(t
1, . . . ,
tl)
andf∈
lσ
ift=
Ujα(
v1,
v2, . . . ,
vk+1, . . . ,
vmj) andα
=
l→
r⇐
cwhereVar
(
l)
=
x1, . . . ,
xkandσ
is defined asxiσ
=
tb
(
vi+1)
for 1≤
i≤
k. Note that from Definition2it follows that mj≥
k+
1.4 Note that there exist also various other transformations from conditional to unconditional TRSs in the literature, cf., e.g., [4,18,33] for more recent ones. However, for our purpose of analyzing operational termination of conditional systems, the chosen transformation appears to be the most appropriate one, as other transformations typically focus on efficiency in the simulation of conditional reductions and are thus more complicated and less suitable for termination analysis.
Informally, the mapping
tb
translates back an evaluation of conditions to its start. Thus,tb
(
u)
=
ufor every termu
∈
T(
,
V)
. Note that in generals=
tb
(
t)
does not implys→
U∗(R) t. The reason is that, for a termt=
Ujα(
v1, . . . ,
vl)
, the definition oftb
(
t)
completely ignores the first argumentt1ofUjα.Example 2. LetRbe a DCTRS consisting of one rule
f
(
x)
→
a⇐
x→
b U(R)
is given by the two rulesf
(
x)
→
U(
x,
x)
U(
b,
x)
→
aConsider the termt
=
U(a,b). We havetb
(t
)
=
f(b)
and clearlyf(b)
→
∗U(R) U(a,b).Informally, the termt
=
Ujα(
v1, . . . ,
vmj)
represents an intermediate state of a reduction inU(
R)
issuing from an originalterm, i.e., a term fromT
(
,
V), only ifv1can be obtained (by reduction inU(R)
) from the corresponding instance of theleft-hand side of the corresponding condition of the applied conditional rule
α
.The transformation of Definition2is suitable for verifying quasi-reductivity by proving termination of a TRS, as whenever the transformed systemU
(
R)
is terminating, the original DCTRSRisquasi-reductive[30]. However, the converse implication does not hold.Example 3[25]. Consider the DCTRSR
=
(
,
R)
given bya
→
c c→
l h(
x,
x)
→
g(
x,
x,
f(
k))
a→
d d→
m g(
d,
x,
x)
→
Ab
→
c k→
l A→
h(
f(
a),
f(
b))
b→
d k→
mα
:
f(
x)
→
x⇐
x→
∗e c→
eThe systemU
(
R)
=
(
U(
),
U(
R))
is given byU(
)
=
∪ {
U1α}
andU(
R)
=
Rexcept that ruleα
is replaced by the rulesf(
x)
→
U1α(
x,
x)
andU1α(
e,
x)
→
x.Ris quasi-reductive (and thus operationally terminating) (cf. Example7, below), neverthelessU(R)
is non-terminating [30].Roughly speaking, the problem in Example3is that subterms at the second position ofU1αare reduced, which is actually only supposed to “store” the variable bindings for future rewrite steps. These reductions can be prevented by using context-sensitivity. More precisely, we intend to forbid reductions of subterms which occur at or below a second, third, etc. argument position of an auxiliaryU-symbol, according to the intuition that during the evaluation of conditions, the variable bindings should remain untouched. This leads to the following modification of the transformation, which has already been proposed independently by several authors (e.g., [9,10,28]) with slight differences.5
Definition 4(context-sensitive unraveling of a DCTRS). LetR
=
(
,
R)
be a DCTRS. The context-sensitive rewrite sys-temUcs(
R)
uses the same signature and the same rules asU(R)
. Additionally, a replacement mapμ
Ucs(R)is used withμ
Ucs(R)(
U)
= {
1}
ifU∈
U(
)
\
andμ
Ucs(R)(
f)
= {
1, . . . ,
ar(
f)
}
iff∈
.For notational simplicity we refer to
μ
Ucs(R)just asμ
if no confusion arises, e.g., in “μ
-termination ofUcs(
R)
”. Moreover,we omit an explicit reference to the replacement map
μ
Ucs(R)if it is clear from the context, for instance in→U
cs(R)reductions.Consider the following reduction:
Ui
(
siσ
,
xiσ
i)
→
> ∗ Ucs(R) Ui(
tiσ
,
x i
σ
i)
→U
cs(R) Ui+1(s
i+1σ
,
xi+1σ
i+1)
where
xi(resp.xi+1) denotes the sequencex1, . . . ,
xki(resp.x1, . . . ,
xki+1) of variables. Context-sensitivity assures thatσ
iand
σ
i+1are not contradictory, i.e.,xσi=
xσi+1for allx∈
Dom(σi)
∩
Dom(σi+1)
. 5Observation 1. LetRbe a DCTRS. For every reduction Ui
(
siσ
,
xiσ
i)
→
> ∗ Ucs(R) Ui(
tiσ
,
x i
σ
i)
→U
cs(R) Ui+1(
si+1σ
,
xi+1σ
i+1)
it holds thatxσi
=
xσi+1for allx∈
Dom(σi)
∩
Dom(σi+1)
.In fact this is a crucial property ofUcs
(
R)
, because given a DCTRSR=
(
,
R)
it guarantees that for each termt∈
T
(
U(
),
V)
we havetb
(
t)
→
∗Ucs(R)tprovided thattis reachable byanyterms
∈
T(
,
V)
(see Corollary2, below). This isin general not true, if context-sensitivity is dropped.
Example 4. LetR
=
(
,
R)
be the DCTRS of Example2extended by two unconditional rulesf
(
x)
→
a⇐
x→
b a→
ba
→
cThe transformed systemU
(
R)
isf
(
x)
→
U(
x,
x)
U(
b,
x)
→
aa
→
b a→
cConsider the termt
=
U(b,c). It is reachable inU(R)
fromf(a)
∈
T(
,
V):f
(
a)
→U
(R)U(
a,
a)
→U
(R)U(
b,
a)
→U
(R)U(
b,
c)
However, it is obviously not reachable from
tb
(
t)
=
f(
c)
asbis not reachable fromc. On the other hand, withinUcs(
R)
,U
(
b,
c)
is not reachable byanyterm fromT(
,
V)
because inUcs(
R)
reachability of a termtby any terms∈
T(
,
V)
(i.e.,s
→
∗Ucs(R)t) coincides with reachability oftfrom
tb
(
t)
(cf. Corollary2below).The fact that in a CSRSsUcs
(
R)
, obtained by the context-sensitive transformation after transforming a DCTRSR=
(
,
R), each termtis reachable fromtb
(
t)
iftis part of reduction sequence issuing from a term ofT(
,
V)
, will be used extensively in the proofs of some of the main results of this paper (e.g., Theorems1and4).CertainUcs
(
R)
-reduction steps inside aU-termtwill have no effect on the result of the functiontb
, i.e.,t→
sandtb
(
t)
=
tb
(
s)
. This motivates the definition oftb
-preserving reduction steps inUcs(
R)
. First, obviously reductions that occur strictly inside aU-termtdo not alter the result oftb
. The reason is that because of context-sensitivity these reductions can only take place in the first argument of the rootU-symbol and furthermore according to the definition oftb
this first argument is irrelevant for the computation oftb
.Second, if a rule of the formUαi
(
s1, ...,
sn)
→
Uαi+1(
s1, ...,
sn)
(whose right-hand side is aU-term) is applied totthentb
applied to the resulting term also yields the same result astb
(
t)
. The reason is that the variable bindings inside theU-term are preserved in such a step and all the variables that are present inl(whereα
=
l→
r⇐
c) are already bound. For the same reasontb
(
t)
=
tb
(
s)
iftis not aU-term,sis aU-term andt→
s.Definition 5(
tb
-preserving reduction steps). LetRbe a DCTRS (R=
(
,
R)
) andUcs(
R)
its transformed CSRS. A steps
→U
p cs(R) t6 is calledtb
-preservingif eitherpis strictly below some positionqofs, whereroot(
s|q
)
is aU-symbol, or(
t|p
)
is aU-term.
The intuition behind
tb
-preserving steps is that whenevers→U
cs(R)twith sometb
-preserving step, we havetb
(s)
=
tb
(
t)
.Proposition 3. LetRbe a DCTRS. If s
,
t∈
T(
U(
),
V)
and s→U
cs(R)t with atb
-preserving step, thentb
(
s)
=
tb
(
t)
. 6 →pProof. If the reduction step fromstot, say at positionp, occurs strictly inside aU-term, then it occurs strictly inside the first argument of some maximalU-rooted subtermuat positionq
<
pins. According to Definition3we havetb
(
s|q
)
=
tb
(
t|q
)
and thus
tb
(
t)
=
tb
(
s)
.Otherwise,t
|p
is aU-term, this means that either a rule of the shapel→
U(
c,
x)
or a rule of the shapeU(
c1,
xi)
→
Ui+1
(
c2,
xi+1)
was applied. Sos|p
=
lσ
ors|p
=
U(
c1,
xi)σ
andt|p
=
U(
c,
x)σ
. Hence, according to Definition3we havetb
(
s|p
)
=
tb
(
t|p
)
and thustb
(
s)
=
tb
(
t)
.Example 5. Consider a CSRSR
f
(
x)
→
U(
b,
x)
U(
c,
x)
→
xb
→
cwith
μ(
U)
=
μ(
f)
= {
1}
. The following reductions aretb
-preserving:f
(
a)
→
μU(
b,
a)
, astb
(
f(
a))
=
tb
(
U(
b,
a))
=
f(
a)
U(
b,
a)
→
μU(
c,
a)
, astb
(
U(
b,
a))
=
tb
(
U(
c,
a))
=
f(
a)
while the following one is not:
U(c,a)
→
μa, due totb
(U(c,
a))=
f(a)
=
tb
(a)
=
aBefore investigating the effects of using context-sensitivity in the unraveling transformation of Definition4on the power of proving operational termination, let us consider the capability ofUcs
(
R)
to simulate reductions of a DCTRSR. Whilesimulationcompleteness, i.e., the property ofUcs
(
R)
being able to mimic reductions ofR, is easy to obtain,simulation soundness, i.e., the property ofUcs(
R)
to allowonlythose reductions (from original terms to original terms) that are also possible inR, is non-trivial.In [28] it was shown that simulation soundness is obtained for their version of the transformation if an additional restriction is imposed on reductions inUcs
(
R)
, which roughly states that only redexes withoutU-symbols (except at the root position) may be contracted. However, for our transformation this additional “membership condition” is not needed (see also Section7below for further details).Theorem 1(simulation completeness). LetR
=
(
,
R)
be a DCTRS. For every s,
t∈
T(
,
V)
we have: if s→
R t, then s→
+Ucs(R)t.
Theorem 2(simulation soundness). LetR
=
(
,
R)be a DCTRS. For every s,t∈
T(U(
),
V)we have: If s→
∗Ucs(R)t and s is reachable from an original term (i.e., s
→
∗Ucs(R)s for some s
∈
T(
,
V)
), thentb
(
s)
→
∗ Rtb
(
t)
. Moreover, if s,
t∈
T(
,
V)
, then s→
+U cs(R)t implies s→
+ R t.Before proving Theorem2we need two auxiliary lemmas. The first one (Lemma1below) states that whenever we have aUcs
(
R)
-reduction sequenceDof the shapes1
→
∗Ucs(R) s2[
lσ
]p
1→U
cs(R) s2[
U1α(
s1,
x1)σ
]p
1→
∗Ucs(R) s3[
U α 1(
t1,
x1)σ
]p
2→U
cs(R) s3[
U2α(
s2,
x2)σ
]p
2→
∗Ucs(R). . .
→
∗Ucs(R) sn+1[
U α n(
tn,
xn)σ
n]p
n→U
cs(R) sn+1[
rσ
n]p
n→
∗ Ucs(R) sn+2wheres1is an original term which means thatDcontains the complete simulation of the application of a conditional rule
α
:
l→
r⇐
s1→
∗ t1, . . . ,
sn→
∗ tn, the reductions satisfying its conditionssiσ
n→
∗Ucs(R) tiσ
noccur as subreductions ofDfor alli
∈ {
1, . . . ,
n}
.The second auxiliary result (Lemma2below) will be crucial for the overall inductive proof structure of Theorem2to work.
For the former we first introduce some terminology for tracing subterms (especiallyU-subterms) in reduction sequences, in a forward and backward manner. In the above reduction sequenceDthe positionspimarkdescendantsof the subterms
si−1
|p
i−1 ofsi−1. More formally, the set ofone-step descendantsof a subterm positionpoftw.r.t. a (one-step) reduction t=
C[
s]p
→
q tis the set of subterm positions intgiven by• {
p}
, ifq≥
porq||
p,• {
q.
o.
p|
t|q
=
lσ,
l|o
∈
Var,
q.
o.
p=
p,
l|o
=
r|o
}
, ifq<
pand (a superterm of)sis bound to a variable in the matching oft|q
with the left-hand side of the applied rule, and• ∅
, otherwise.Slightly abusing terminology, whent
=
C[
s]p
→
q twith set{
p1, . . . ,
pk}of one-step descendants int, we also say thatt|p
has descendantst
|p
iint. Thedescendant relation(w.r.t. given derivations) is obtained as the (reflexive-)transitive closure of the one-step descendant relation. Note that the set of one-step descendants of aU-subterm (w.r.t. a one-step derivation) is non-empty unless the subterm is erased by an erasing rule (i.e., a rulel→
rsuch thatx∈
Var(
l)
\
Var(
r)
), becauseU-symbols occur only at but not below the root position in left-hand sides of rules of systems obtained by the transformation of Definition4. The notions ofone-step(and many-step)antecedentsof a subterm position (w.r.t. a given reduction sequence) are defined analogously (in a backward manner).
Note that with a similar argument as for the existence of descendants ofU-subterms we get that everyU-subterm has at least one one-step antecedent w.r.t. every (one-step) reduction sequence.
Now we can express the notion of a complete simulated rule application more formally. By a complete simulated rule application we mean that all rules obtained by transforming one conditional rule are eventually applied to a certain subterm and its descendants during the reduction sequence in the right order. Yet, these (unconditional) rule applications need not be consecutive.
Note also that it makes sense to talk about descendants ofU-subterms, because they can only be copied, eliminated or duplicated but not otherwise modified by more outer reductions. This is due to the special shape of the rules in systems obtained by the transformation of Definition4. More precisely, it is due to the fact thatU-symbols occur only at, but not below the root of left-hand sides of rules.
Lemma 1. LetR
=
(
,
R)
be a DCTRS and letα
:
l→
r⇐
c1l→
∗ c1r, . . . ,
cln→
∗crnbe a rule from R. Moreover, assume that D:
s→
∗Ucs(R) t is a non-empty Ucs
(
R)
-reduction such that s∈
T(
,
V)
and the last step is due to an application of the rule Unα(
crn,
xn)
→
r∈
Ucs(
R)
(r∈
T(
,
V)
) with a substitutionσ
n. Then, the reductions Ci:
cliσ
n→
∗Ucs(R) cr
i
σ
noccur assubreductions of D7 for every i
∈ {
1, . . . ,
n}
.Proof. Let the last step ofDbet
→U
p cs(R)t. Hence,t|p
must be aU-term. We identify the first termsinDsuch that1. scontains at least one antecedent oft
|p
, 2. all antecedents oft|p
insareU-terms, and3. conditions (1) and (2) also hold for all terms occurring later (but beforet) inD.
Note thattitself has the demanded properties. Thus the existence ofsis guaranteed. We now claim:
Some antecedents
|q
oft|p
has the formU1α(
c1l,
x1)σ
1 (1)In order to show (1) assumesdid not contain a subterm of this shape. Then, considers0which is the subterm precedings
inD(this subterm exists asscontainsU-terms butsdoes not, sos
=
s). The terms0contains antecedents oft|p
, becausescontains antecedents oft
|p
which areU-terms. This in turn implies the existence of one-step antecedents ins0. Assume some antecedent oft|p
ins0is not aU-term. As this term has a one-step descendant insbeing in turn a antecedent oft|p
and thus aU-term, this veryU-term insmust be of the shapeU1α(c
l1,
x1)σ
1as it must have been introduced by anapplication of the rulel
→
U1α(
c1l,
x1)
. This contradicts our assumption that (1) does not hold fors. Thus all antecedents of t|p
ins0must beU-terms.This in turn contradicts the minimality ofs, i.e., being the first term onDcontaining onlyU-term antecedents oft
|p
. Hence, we derived a contradiction from¬
(
1)
. This concludes the proof of Claim1.7
Lets
|q
=
U1α(
cl1,
x1)σ
1. By our choice ofsand the fact thats|q
is a antecedent oft|p
, every term betweensandtinDcontains a descendant ofs
|q
which is also a antecedent oft|p
and aU-term.Some descendant (ofs
|q
) must be of the shapeU1α(
c1r,
x1)σ
1, because otherwiset|p
could not be reached (cf. Definition 4). We inspectDbetweensandswherescontains such a descendant ofs|q
say at positionq. Then,s|q
and its descendants which are also antecedents ofs|q
are only (syntactically) modified by rule applications below their roots. The reason is that a term rooted by someU-symbolUicannot be reduced to another term having the same root symbol with reduction steps containing at least one root step, unless the reduction sequence contains a non-U-term (cf. Definition4).Hence, we can extract the reductionc1l
σ
1→
∗U cs(R)cr
1
σ
1fromD.The same argumentation applies also to all other conditions asUiα
(
cli,
xi)σ
imust occur (by our choice ofsandq), as descendants ofs|q
and antecedents oft|p
inD(in particular in such a way thatσ
idoes not contradictσ
i−1). Moreover, by Observation1the used substitutions are not contradictory and their domains are subdomains of the one ofσ
n, which is due to the fact that the set of variables stored by aU-symbolUiαis a subset of the ones stored byUjαprovided thati≤
j(cf. Definition4).The second lemma states that if there exists a parallel reduction sequences
−→
−−
∗Ucs(R)t, wheresis an original term, then
for all positionspoftthere is also a parallel reductions
−−
−→
∗Ucs(R) t
|p
for some original termssuch that its length is less
than or equal to the length of the former parallel reduction sequence.
In order to formalize this proposition we introduce the notion of theminimal parallel-distanceof a term (overT
(U(
),
V)) (from any original term).Definition 6(minimal parallel-distance). LetR
=
(
,
R)be a DCTRS andt∈
T(U(
),
V). Theminimal parallel-distanceoft(w.r.t. a DCTRSR) is given by
mpd
(
t)
=
infn| ∃
s∈
T(
,
V).
s−→
−−
nU cs(R)twhere
−−
−→
nUcs(R)means thatnparallel reductions are performed.
Note thatinf
∅ = +∞
, so the minimal parallel-distance of any termtthat is not reachable from an original term is+∞
. Note on the other hand that iftis reachable from an original term, then theinf in Definition6is actually amin, as lengths of reductions are natural numbers and hence we can find a concrete (parallel) reduction from an original term totwith lengthmpd
(
t)
.Lemma 2. LetR
=
(
,
R)
be a DCTRS and t∈
T(
U(
),
V)
with mpd(
t) <
∞
. Then for every subterm t|p
of t we have mpd(
t|p
)
≤
mpd(
t)
. Moreover, if t|p
occurs strictly inside a U-term in t, then mpd(
t|p
) <
mpd(
t)
.Proof. LetD
:
u−→
−−
∗Ucs(R)twhereu
∈
T(
,
V)be a reduction sequence of lengthmpd(t)
. We prove the result by inductiononmpd
(
t)
. Ifmpd(
t)
=
0, the result holds vacuously astis an original term and thus every subterm oftis an original term as well.Assumempd
(
t)
=
m, then we can writeDasu
−→
−−
mU−1 cs(R)t−→U
−−
cs(R)t
We consider the maximalU-rooted subtermsu1
, . . . ,
unoft|p
s.t.t
|p
=
C[
u1, . . . ,
un]p1,...,pnEach subtermui has at least one one-step antecedentui in t and the induction hypothesis yields that mpd
(u
i)
≤
mpd
(
t)
≤
m−
1. Hence, as we are using parallel reduction we obtainmpd
(
C[
u1, . . . ,
un]p1,...,pn)≤
m−
1 (2)Moreover, we haveui
−→
−−
∗Ucs(R)uiwith zero or one reduction steps and as alluiare parallel int
|p
we haveC[
u1
, . . . ,
un]p1,...,pn−−
−→
∗Ucs(R)C
[
u1, . . . ,
un]p1,...,pn=
t|p
with zero or one steps. Thus,mpd(
t|p
)
≤
m.Now assume thatt
|p
occurs strictly inside aU-term int. We distinguish two cases.•
Ifui=
uifor somei∈ {
1, . . . ,
n}
(i.e., if some reduction step fromttotoccurred inside a antecedent of someui), then by the definition of the descendant relation and the shape of the rules inUcs(
R)
, i.e., the fact thatU-symbols occur only at but not below the root of left- and right-hand sides of all rules, we get that ifuioccurs at positionq≥
pint, thenuioccurs at positionqintand there must have been a reduction int
−→U
−−
cs(R)tat or belowq. Hence, in the same parallel step there was no reduction abovepand thus alluioccur inside aU-term intas they occur insidet|p
.Hence, the induction hypothesis yieldsmpd
(u
i)
≤
m−
2 and we getmpd(t
|p
)
≤
m−
1.•
Otherwise, ifui=
uifor alli∈ {
1, . . . ,
n}
,(
2)
andC[
u1, . . . ,
un]p1,...,pn=
t|p
yieldmpd(
t|p
)
≤
m−
1.Indeed Lemma2does not hold if one considers ordinaryUcs
(
R)
-reduction instead of parallel reduction.Example 6. Consider the following one-rule DCTRSR
f
(
x)
→
b⇐
g(
x,
x)
→
∗a Ucs(
R)
is given byf
(x)
→
U(g(x,
x),x) U(
a,
x)
→
bNow consider the followingUcs
(
R)
reduction sequence of length 2f
(f
(x))
→
f(U(g(x,
x),x))→
U(g(U(g(x,
x),x),U(g(x,x),x)),U(g(x,x),x))=
tHowever, it is easy to see that at least 2 reduction steps are necessary to derive
t
|
1=
g(
U(
g(
x,
x),
x),
U(
g(
x,
x),
x))
from an original term although it occurs as subterm strictly below aU-symbol int. Now we are ready to prove Theorem2.
Proof of Theorem2. For the first part of the theorem, we prove the equivalent result thats
−→
−−
∗Ucs(R)timplies
tb
(
s)
−→
−−
∗R
tb
(
t)
provided thats,
t∈
T(
U(
),
R)
andsis reachable from an original term.In order to prove this by induction, we associate to each reduction sequenceS
:
s−−
−→
∗Ucs(R)twiths,t
∈
T(U(
),
V)anon-negative integer (its order)kwherek
=
mpd(
s)
+
landlis the length (i.e., the number of parallel reduction steps) ofS. We use induction overk(note thatmpd
(s)
andlare both non-negative for every reduction sequenceS).For the base case (i.e.,k
=
0) the theorem holds trivially, sinces=
t. For the inductive step, consider a reduction sequenceS
:
s−→
−−
∗U cs(R)s−→U
−−
cs(R)t. The induction hypothesis yields
tb
(
s)
→
∗Rtb
(
s)
. Thus, fortb
(
s)
→
∗Rtb
(
t)
it suffices to showthat
tb
(
s)
→
∗Rtb
(
t)
(3)holds.
We prove this by (nested) induction over the number of single (non-parallel) reduction steps ins
−−
−→U
cs(R) t. If this number is zero, thens=
tand thustb
(
s)
=
tb
(
t)
.Otherwise, we splits
−→U
−−
cs(R)tintos−→U
−−
cs(R) t→U
cs(R)tand the induction hypothesis yieldstb
(s
)
→
∗Rtb
(t
)
. We distinguish 3 cases depending on the reduction fromttot.1. Assume the step is
tb
-preserving. Then we havetb
(
t)
=
tb
(
t)
and hencetb
(
s)
→
∗Rtb
(
t)
, i.e., (3).2. If the step is non-
tb
-preserving and using a rulel→
rwhich already occurred in the DCTRS (i.e., as unconditional rule) say at positionp, thent|p
=
lσ. As the reduction is non-tb
-preserving, there is noU-symbol intabovep(cf. Definition5). Moreover, there are noU-symbols inl(as it already occurred inR), hencetb
(
t)
|p
.q=
tb
(
t|p
.q)
for all variable positionsqofl, i.e.,tb
(
t)
|p
=
lσ
andxσ
=
tb
(
xσ )
for allx∈
Dom(σ )
. Thus,tb
(
t)
=
tb
(
t)
[
lσ
]p
→
Rtb
(
t)
[
rσ
]p
=
tb
(
t)
, and finally (3).3. Assume the step (at positionp) is non-
tb
-preserving and using a ruleU(
u,
x1, . . . ,
xo)
→
rwhereroot(
r)
∈
(sayt
|p
=
U(u,x1, . . . ,
xo)σ )
. This rule stems from a conditional ruleα
:
l→
r⇐
cl1→
∗cr1, . . . ,
cml→
∗ cmr∈
R. In order to perform the corresponding reduction in the conditional systemR, we need to make sure thattb
(
cilσ )
→
∗Rtb
(
criσ )
holds for everyi∈ {
1, . . . ,
m}
.We consider the following reduction sequenceSinUcs
(
R)
S
:
u−→
−−
∗Ucs(R)s
−→
−−
∗Ucs(R)s