• No results found

Characterizing and proving operational termination of deterministic conditional term rewriting systems

N/A
N/A
Protected

Academic year: 2021

Share "Characterizing and proving operational termination of deterministic conditional term rewriting systems"

Copied!
30
0
0

Loading.... (view fulltext now)

Full text

(1)

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

b

The 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.

(2)

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, with

cbeing 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, then

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 ordering

onT

(

,

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 termination

Context-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

and

lunify (l

r

Rand we assume thattandl

rdo not share any variables) with mgu

θ

ands

=

t

[

r

]p

θ

. We say that

sis 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

(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 all

f

, 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 symbolsD

C, 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

=

((

D

C

,

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

, μ)

where

DPo

(

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 rules

s1

t1

,

s2

t2

, . . .

fromDPis a

(

DP

,

R

, μ)

-chain if there is a substitution

σ

, such thatti

σ

R,μsi+1

σ

for alli

>

0. We

say that

σ

enablesthe chains1

t1

,

s2

t2

, . . .

We call a triple

(

DP

,

R

, μ)

, whereDPandRare TRSs and

μ

is a replacement map for the combined signatures ofDPand

R, 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 position

p

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 notion

cs-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

(4)

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].4

Definition 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

))

r

HereVar(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 function

tb

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 by

tb

(

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

c

whereVar

(

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.

(5)

Informally, the mapping

tb

translates back an evaluation of conditions to its start. Thus,

tb

(

u

)

=

ufor every term

u

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 of

tb

(

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 rules

f

(

x

)

U

(

x

,

x

)

U

(

b

,

x

)

a

Consider the termt

=

U(a,b). We have

tb

(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 original

term, i.e., a term fromT

(

,

V), only ifv1can be obtained (by reduction inU(R

)

) from the corresponding instance of the

left-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 by

a

c c

l h

(

x

,

x

)

g

(

x

,

x

,

f

(

k

))

a

d d

m g

(

d

,

x

,

x

)

A

b

c k

l A

h

(

f

(

a

),

f

(

b

))

b

d k

m

α

:

f

(

x

)

x

x

e c

e

The 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

σ

i

and

σ

i+1are not contradictory, i.e.,xσi

=

xσi+1for allx

Dom(σi

)

Dom(σi+1

)

. 5

(6)

Observation 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 have

tb

(

t

)

U

cs(R)tprovided thattis reachable byanyterms

T

(

,

V

)

(see Corollary2, below). This is

in general not true, if context-sensitivity is dropped.

Example 4. LetR

=

(

,

R

)

be the DCTRS of Example2extended by two unconditional rules

f

(

x

)

a

x

b a

b

a

c

The transformed systemU

(

R

)

is

f

(

x

)

U

(

x

,

x

)

U

(

b

,

x

)

a

a

b a

c

Consider 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

U

cs(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 from

tb

(

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 function

tb

, i.e.,t

sand

tb

(

t

)

=

tb

(

s

)

. This motivates the definition of

tb

-preserving reduction steps inUcs

(

R

)

. First, obviously reductions that occur strictly inside aU-termtdo not alter the result of

tb

. 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 of

tb

this first argument is irrelevant for the computation of

tb

.

Second, if a rule of the formUαi

(

s1

, ...,

sn

)

Uαi+1

(

s1

, ...,

sn

)

(whose right-hand side is aU-term) is applied totthen

tb

applied to the resulting term also yields the same result as

tb

(

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 reason

tb

(

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 step

s

→U

p cs(R) t6 is called

tb

-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 some

tb

-preserving step, we have

tb

(s)

=

tb

(

t

)

.

Proposition 3. LetRbe a DCTRS. If s

,

t

T

(

U

(

),

V

)

and s

→U

cs(R)t with a

tb

-preserving step, then

tb

(

s

)

=

tb

(

t

)

. 6 p

(7)

Proof. 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 have

tb

(

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 have

tb

(

s

|p

)

=

tb

(

t

|p

)

and thus

tb

(

s

)

=

tb

(

t

)

.

Example 5. Consider a CSRSR

f

(

x

)

U

(

b

,

x

)

U

(

c

,

x

)

x

b

c

with

μ(

U

)

=

μ(

f

)

= {

1

}

. The following reductions are

tb

-preserving:

f

(

a

)

μU

(

b

,

a

)

, as

tb

(

f

(

a

))

=

tb

(

U

(

b

,

a

))

=

f

(

a

)

U

(

b

,

a

)

μU

(

c

,

a

)

, as

tb

(

U

(

b

,

a

))

=

tb

(

U

(

c

,

a

))

=

f

(

a

)

while the following one is not:

U(c,a)

μa, due to

tb

(U(c,

a))

=

f

(a)

=

tb

(a)

=

a

Before 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. Whilesimulation

completeness, 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

+U

cs(R)t.

Theorem 2(simulation soundness). LetR

=

(

,

R)be a DCTRS. For every s,t

T

(U(

),

V)we have: If s

U

cs(R)t and s is reachable from an original term (i.e., s

U

cs(R)s for some s

T

(

,

V

)

), then

tb

(

s

)

R

tb

(

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 shape

s1

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+2

wheres1is 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

}

.

(8)

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

)

), because

U-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

U

cs(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) c

r

i

σ

noccur as

subreductions 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 that

1. scontains at least one antecedent oft

|p

, 2. all antecedents oft

|p

insareU-terms, and

3. 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

, because

scontains 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 an

application 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

(9)

Lets

|q

=

U1α

(

cl1

,

x1

1. By our choice ofsand the fact thats

|q

is a antecedent oft

|p

, every term betweensandtinD

contains 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)c

r

1

σ

1fromD.

The same argumentation applies also to all other conditions asUiα

(

cli

,

x

i

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

−→

−−

U

cs(R)t, wheresis an original term, then

for all positionspoftthere is also a parallel reductions

−−

−→

U

cs(R) t

|p

for some original terms

such 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-distance

oft(w.r.t. a DCTRSR) is given by

mpd

(

t

)

=

infn

| ∃

s

T

(

,

V

).

s

−→

−−

nU cs(R)t

where

−−

−→

nU

cs(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 tot

with 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

−→

−−

U

cs(R)twhereu

T

(

,

V)be a reduction sequence of lengthmpd

(t)

. We prove the result by induction

onmpd

(

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 writeDas

u

−→

−−

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,...,pn

Each 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 obtain

mpd

(

C

[

u1

, . . . ,

un]p1,...,pn)

m

1 (2)

Moreover, we haveui

−→

−−

U

cs(R)uiwith zero or one reduction steps and as alluiare parallel int

|p

we haveC

[

u

1

, . . . ,

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, thenui

(10)

occurs 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 by

f

(x)

U(g

(x,

x),x) U

(

a

,

x

)

b

Now consider the followingUcs

(

R

)

reduction sequence of length 2

f

(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))

=

t

However, 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

−→

−−

U

cs(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

−−

−→

U

cs(R)twiths,t

T

(U(

),

V)a

non-negative integer (its order)kwherek

=

mpd

(

s

)

+

landlis the length (i.e., the number of parallel reduction steps) of

S. 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 sequence

S

:

s

−→

−−

U cs(R)s

−→U

−−

cs(R)t. The induction hypothesis yields

tb

(

s

)

R

tb

(

s

)

. Thus, for

tb

(

s

)

R

tb

(

t

)

it suffices to show

that

tb

(

s

)

R

tb

(

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 thus

tb

(

s

)

=

tb

(

t

)

.

Otherwise, we splits

−→U

−−

cs(R)tintos

−→U

−−

cs(R) t

→U

cs(R)tand the induction hypothesis yields

tb

(s

)

R

tb

(t

)

. We distinguish 3 cases depending on the reduction fromttot.

1. Assume the step is

tb

-preserving. Then we have

tb

(

t

)

=

tb

(

t

)

and hence

tb

(

s

)

R

tb

(

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

=

. 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), hence

tb

(

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

R

tb

(

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

)

(say

t

|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 that

tb

(

cil

σ )

R

tb

(

cri

σ )

holds for everyi

∈ {

1

, . . . ,

m

}

.

We consider the following reduction sequenceSinUcs

(

R

)

S

:

u

−→

−−

U

cs(R)s

−→

−−

Ucs(R)s

References

Related documents

1.4.1 Comparison of head injuries and fatalities before and after helmet legislation took effect Data specific to British Columbia are available from the Motor Vehicle

The main technical component of this proof was Theorem 2.4, which states that for every k there is an mso transduction from graphs to tree decompositions, which given a graph of

The results show that a single Intel Xeon Phi Knights Landing processing node is able to compute the AO RTC for ELT-scale SCAO systems with latencies as low as 348 ± 12 µs for a

Note that each entity (e.g., # phone ) is not a unique literal value, unlike a keyword; instead, it is a large set of instance values (e.g., the numerous phone numbers on the Web).

In this study, we proposed a method that can be used to estimate marginal survival function and the corresponding covariate effects for data with competing risks.. The method uses

raciborskii taken from three reservoirs and one river in Portugal as well as the occurrence of this species in other water bodies used for potable and recreational purposes.. All

Allgemein lässt sich je- doch feststellen, dass die Austrittsbarrieren für Hochzeitsplaner nicht sonderlich hoch sind, was auch durch die hohe Fluktuation 190 in