Scholarly article on topic 'Call-by-Need Reduction for Membership Conditional Term Rewriting Systems'

Call-by-Need Reduction for Membership Conditional Term Rewriting Systems Academic research paper on "Computer and information sciences"

CC BY-NC-ND
0
0
Share paper
Keywords
{}

Abstract of research paper on Computer and information sciences, author of scientific article — Mizuhito Ogawa

Abstract This paper proves that, for a normal membership conditional term rewriting system (MCTRS), (1) a reducible term has a needed redex if the MCTRS is nonoverlapping, and (2) whether a redex is nv-needed is decidable.

Academic research paper on topic "Call-by-Need Reduction for Membership Conditional Term Rewriting Systems"

URL : http ://www.elsevier.nl/locate/entcs/volume86.html 16 pages

Call-by-Need Reduction for Membership Conditional Term Rewriting Systems

Mizuhito Ogawa1

Japan Advanced Institute of Science and Technology 1-1 Asahidai Tatsunokuchi Nomi Ishikawa, Japan 923-1292

Abstract

This paper proves that, for a normal membership conditional term rewriting system (MCTRS), (1) a reducible term has a needed redex if the MCTRS is nonoverlapping, and (2) whether a redex is nv-needed is decidable.

1 Introduction

A membership conditional term rewriting systems (MCTRS) is a term rewriting system (TRS) in which substitutions are taken from some specific sets, typically, the set of normal forms. A normal MCTRS, which requires substitutions to be in normal form for each non-left-linear variable, is a useful example; this system can specify the positive part of the equality class of functional programming (e.g., Haskell, ML) without type information. (The negative part of the equality class cannot be deduced without algebraic information about the construction of the type.)

Nonoverlapping normal MCTRSs are the natural extension of orthogonal TRSs to nonlinearitv, and they retain many nice properties, such as Parallel Move Lemma and confluence [14]. In addition to these properties, this paper investigates call-bv-need reduction for normal MCTRSs. In general, a non-left-linear TRS does not have needed redexes even if it is nonoverlapping; for instance,

{d(x, x) —a, f(y, z) —y b, c —y cl}

is a nonoverlapping (and also strongly normalizing, right-ground) non-left-linear TRS and d(f(c,z),f(d,z)) does not have needed redexes. Thus, the membership restriction is essential; there seems to be no other choice when one explores the existence of needed redexes in non-left-linear TRSs. In fact, the membership condition precisely corresponds to the proof techniques in [10].

1 Email:mizuhitoQ jaist.ac.jp

©2003 Published by Elsevier Science B. V.

The main results are:

(i) A reducible term has a needed redex for a nonoverlapping normal MC-TRS.

(ii) Reachability and normalizability for a right-ground normal MCTES are decidable,

(iii) Whether a redex is nv-needed is decidable for a normal MCTES, where nv-neededness approximates neededness by relaxing the rewrite relation such that variables in the right-hand-side of a rule may be instantiated by any terms.

It is worth remarking that, unlike left-linear TESs, modern tree automata techniques [2,5,11] fail to produce decidability results of normal MCTESs, This is because the set of normal forms need not be regular; i.e., the set of normal forms of a normal MCTES is the same as that of the underlying TES, and the set of normal forms of a non-left-linear TES is known to be not regular [8].

Section 2 presents basic notations and Section 3 introduces previous results on confluence of a normal MCTES, Section 4 shows that a reducible term has a needed redex and Section 5 shows that needed reduction is normalizing, provided a normal MCTES is nonoverlapping. Section 6 shows that the reachability and normalizability of right-ground normal MCTESs are decidable, and Section 7 shows that whether a redex is nv-needed is decidable for normal MCTESs, Section 8 concludes the paper and discusses topics for future research,

2 Preliminaries

We assume that readers are familiar with rewriting terminology; for details, we refer to [7]. This section explains our notations. Throughout the paper, we will consider only finite term rewriting systems (TESs),

We will denote the set of function symbols by T^ the set of n-ary function symbols by Tn, the set of variables by V, and the set of terms over T and V by T{T, V). A term without variables is a ground term, and the set of ground terms is denoted by T(JF), A term t is linear if each variable x appears in t at most once, and a variable a: in a term t is linear if x appears once in t. The set of variables that appear in a term t is denoted by Vor(i), and the set of nonlinear variables that appear in a term t is denoted by Varnl (t), For a (possible nonlinear) term t, t is a linearization of t, i.e., t is obtained by replacing all occurrences of nonlinear variables in t by distinct fresh variables (thus, t is linear).

We denote the set of all positions in a term t by Vos(t), the subterm occurring at p in t by t\p, and the root symbol of t by root(t)(e TU V).

For terms t, s and position p e Vos(t), t[s]p is the term obtained from t by replacing the subterm at p with s. For positions p, q and a set U of positions,

we write p < q if p is a proper prefix of q, p _L q if neither p < q, p = q, nor p > q, U < q if Bp E U p < q, and U < q if Bp E U p < q. For a term t and a variable x, we denote the set of positions in t by Vos(t), the set of positions of function symbols in t by Vosjr(t), the set of positions of variables in t by Vosv(t), the set of positions where x occurs in t by Vos(t,x), and the number of positions in Vos(t) (i.e., size of t) by |i|. If s is a (proper) subterm of t, we denote s < t (s <t).

We denote A-jz if a rewrite occurs at a position p; ^y-ji if a rewrite

—>•7j occurs at a position larger than p; and if a rewrite occurs at the

position larger than or equal to p. For a set P of positions, we denote if a rewrite occurs at the position larger than or equal to some p E P. A parallel rewrite step s z t contracts a set of pairwise disjoint redexes, A term without redexes (of ^rn) is a normal form (more specifically, 1Z-normal form), and the set of 7?.-normal forms is denoted by NFn. We will often omit the index 1Z in NFn, —and z if they are apparent from the context,

3 Confluence of membership conditional TRS

A pair of rules (/ —r, l' —t r') is overlapping if there exists a position p such that

• p E Vosr{l),

• there exist substitutions a, a' such that l\p a = I'a', and

• either p ^ e, or I —t r and l' —r' are different rules,

A TRS is nonoverlapping if no pairs of rules in 7Z are overlapping.

Theorem 3.1 ([6]) Every left-linear nonoverlapping TRS is confluent.

Without left-linearitv, confluence may fail even for nonoverlapping TRSs, For instance, 1Z\ below is nonoverlapping, but not confluent.

d(x, x) —y 0 d(x, }'{x)) 1 2 ^ /(2)

When a TRS is non-left-linear, some restriction is required to recover confluence, A membership conditional TRS is such an example [14].

Definition 3.2 A membership conditional TRS (MCTRS) 1Z is a finite set of conditional rewrite rules

where the condition C is the form in x E Tx for x E V C Var(l) and Tx C T(^,V)).

An MCTRS U is normal if Tx is NFn for x E V and Varnl(l) Ç V Ç Var(l).

Remark 3.3 Since the membership condition is non-monotonic w.r.t, the inclusion of rewrite relations, it looks contradictory. But, this is not true; by induction on the size of a term, the rewrite relation is well-defined (we refer to Lemma 4,1 in [14]),

Definition 3.4 Let A : s —1 be a reduction contracting the redex at position p E Vos(s) using the rewrite rule I —r <= C. For q E Vos(s), the set of descendants of q is:

{q} if q < p or q ± p,

{P-P3-P2 I t |p3 = I |P1} iiq=P'Pi'P2 with pi e Vosv(l),

4> otherwise

For Q Ç Vos (s), we define Q\A = (q\A).

We naturally extend the notion q\A and Q\A for a rewrite sequence A.

Remark 3.5 For a normal MCTRS. each rewrite step does not destroy a redex of a non-left-linear rewrite rule. Therefore, descendants of a redex are again redexes.

Definition 3.6 For parallel rewrite steps A and B starting from the same term t, we denote the projection of A over B by A\B; i.e., A\B is a parallel rewrite step that contracts all redexes at position P\B, where P is the set of positions of redexes in t that are contracted in A.

Lemma 3.7 (Parallel Move Lemma) Let 1Z he a nonoverlapping normal MCTRS. If A and B are parallel rewrite steps starting from the same term t, then

• A; (B\A) and B; (A\B) have the same reduct, and

• p\(A; (B\A)) = p\(B; (A\B)) for each p E Vos(t).

Theorem 3.8 [14] Every nonoverlapping normal MCTRS is confluent.

Example 3.9 The normal MCTRS, IZi plus additional membership conditions,

d(x,x) —0 xeNF d(x,f(x)) x E NF

2 ^ /(2)

is confluent.

4 Needed redex of nonoverlapping normal MCTRS

A term may have several redexes, A reduction strategy is the choice of a redex to rewrite in a given term (i.e., a function from terms to redexes). Two especially important issues are, the normalizing strategy, which guarantees reaching a normal form (if one exists), and the optimal strategy, which selects a needed redex,

A redex is needed if either itself or its descendant is contracted in every rewrite sequence to a normal form.

In general, needed redexes may not exist. However, a left-linear nonoverlapping TES has a needed redex in a term that is not in normal form (although it may be not computable). The idea in [10] is; instead of a needed redex, a root-needed redex is considered, A redex is root-needed if either itself or some of its descendants are contracted in every rewrite sequence to a root-stable form (i.e., a term that cannot be reduced to a redex). Since a normal form is root-stable, a root-needed redex is a needed redex. In this section, similar to [10], we show that a reducible term has a needed redex if a normal MCTRS is nonoverlapping.

For a rewrite sequence A : to —>■•••—>■ tn and 0 < i < j < n, B : ij —

• • • —tj is a subsequence, C : t0 —• • • —U is a prefix sequence, and D : U • • • tn is a suffix sequence. For rewrite sequences A : s —>■* t and B : t —>•* u, the concatenation is denoted by A; B : s —>•* u.

Definition 4.1 A term s(< t) is root-stable if for any s' with s —>•* s', s' is not a redex.

Lemma 4.2 (Lemma 2.1 [10]) If is confluent, is also confluent.

Lemma 4.3 (Lemma 3.2 [10]) If a term s is root-stable, each term t with s —* t is also root-stable.

Lemma 4,2 and 4,3 hold for any TESs, The proofs of Lemma 3,3 and 4,2 in [10] require the left-linearitv and nonoverlappingness 2 to guarantee

• confluence, and

• if s is a redex, t with s —t t is also a redex,

A nonoverlapping normal MCTRS also satisfies these requirements, and the same proofs in [10] give the following Lemmas 4,4 and 4,5,

Lemma 4.4 For a nonoverlapping normal MCTRS IZ, if a term t is root-

■stable, each term s with s —t is also root-stable.

Lemma 4.5 For a nonoverlapping normal MCTRS 1Z and a term t, if there

exist a rule l-lrGK and a substitution a such that t —la then I is uniquely determined regardless of reduction sequences.

2 More precisely, the requirement of Lemma 3.3 in [10] can be relaxed to almost nonoverlapping.

Similar to Theorem 4,3 in [10], which states that for a left-linear nonover-lapping TES a term not root-stable has a root-needed redex, the next theorem holds.

Theorem 4.6 For a nonoverlapping normal MCTRS, a term that is not root-stable has a root-needed redex.

Proof. By induction on the size of a term. Without loss of generality, we can assume that t is neither a root-stable term nor a redex. Assume t t' for some root-stable form t'. ¿From lemma 4,4, a reduction sequence A : t —>•* t'

contains a reduction A : t A.4 -4- t" —>•* t' at the position e, ¿From lemma 4,5, a rule used in A.4 is uniquely determined. We denote it by I — r<=C where C = AxeV x E NF with Varnl(l) C V C Var(l).

Let P be the set of positions of proper non-root-stable subterms in t. There are two cases; (1) P fl Vosf(T) ^ <f>, and (2) P fl Vosp(l) = <f>. For (1) 3, let p be a minimal position in P fl Vosjr(T). Since t\p C t, from the induction hypothesis, there exists a root-needed redex A in t\p. We claim that

A is contracted in the subsequence B : t —A.4, ¿From minimality of p, t\p must be rewritten to A.4|p, which is root-stable (because 1Z is nonoverlapping). Thus, A is root-needed in t.

For (2), if each p E P is p E Vos(l,x) for some x E Var(l) \ V, t is a redex; thus, root-needed because 1Z is nonoverlapping. Assume there exists p E Vos(l,x) for x E V. Let B be a subsequence of A such that B : t\p A.4|p, Since C = AxeV x E NF, A.4|p is a normal form, ¿From the induction hypothesis, t\p has a root-needed redex, and this is also root-needed in t. □

Corollary 4.7 For a nonoverlapping normal MCTRS, a reducible term has a needed redex.

5 Normalization of nonoverlapping normal MCTRS

We expect the repeated evaluation of needed redexes (optimal reduction strategy) is also a normalizing strategy. The scenario given in [10] is:

• The repeated reduction of root-needed redexes is a (hyper) root-normalizing reduction strategy for orthogonal TESs (refer to Corollary 5,7 in [10]),

• A context-free root-normalizing reduction strategy is a normalizing reduction strategy for a confluent TES (refer to Theorem 6,5 in [10]), where a reduction strategy is context-free if the choice of a redex in a root-stable term is reduced to the choice of a redex in each direct subterm.

Since a nonoverlapping normal MCTRS satisfies the Parallel Move Lemma (Lemma 3,7), the same scenario in [10] works. However, later we will discuss on nv-needed reduction, which needs not be root-normalizing; thus, this scenario fails for normalization of nv-needed reduction. Instead, we directly show

3 For (1), the proof is same as in theorem 4.3 in [10].

that the repeated reduction of needed redexes is a normalizing strategy for nonoverlapping normal MCTES, The idea obeys to Section 5 in [10]; we just confirm that the same proof is also valid for nonoverlapping normal MCTESs, Throughout this section, we only consider nonoverlapping normal MCTESs,

Definition 5.1 (Definition 5.2 in [10]) For a parallel rewrite sequence A = Ai, A2; ■ ■ ■; An of length n, let

cost(A) = (Ki,---,!^!)

where \Aj\ is the number of redexes contracted in a parallel rewrite step Ai for each i with 1 < i < n.

For parallel rewrite sequences A, B of the same length, we define A > B if, and only if, there exists i with 1 < i < n such that \Aj\ > \Bj\ and \Aj\ = \Bj\ for each j with i < j < n.

Note that > is well-founded.

Definition 5.2 (Definition 5.3 in [10]) Let A be a parallel rewrite sequence and B be a parallel rewrite step starting from the same term t. We say B interferes A if a descendant of a redex contracted in B is contracted in A.

Lemma 5.3 (Lemma 5.5 in [10]) Let A : s sn and B : s -|> t such that B interferes A. If sn is root-stable, then there exists C : t tn such that A > C and tn is root-stable. Moreover, if sn is a normal form, we may assume that tn = sn.

The proof of the lemma depends on Parallel Move Lemma (Lemma 3,7); thus, the same proof works also for nonoverlapping normal MCTESs,

Corollary 5.4 Needed reduction is normalizing for nonoverlapping normal MCTRSs.

Proof. Let A : s t such that t is a normal form. If s = t, Corollary holds. Otherwise, assume that B : s t\ —t2 —... infinitely contracts needed redexes. By definition of needed redexes, each step in B interferes A. ¿From Lemma 5,3, there exists a parallel rewrite sequence C\ : t\ t such that A > C\. Similarly, we can construct parallel rewrite sequences Ci : U t such that A > Ci > • • • > Ci. Since > is well-founded, this is contradiction,□

6 Decidable results for right-ground normal MCTRS

In [12], Ovamaguchi proved that reachability and joinabilitv are decidable for a (possibly non-left-linear) right-ground TES, Similarly, in this section, we show that reachability and normal joinabilitv are decidable for a right-ground normal MCTES, The main difference is that we use normal joinabilitv {ii, • • •, tn}N instead of joinabilitv {¿i, • • •, tn}j, as used in [12], Otherwise, the translation of the proof in [12] is quite straightforward.

We say:

• For terms s, t, s is reachable to t if s —>•* t, and denoted by (s, t)u.

• Terms ti, ■ ■ ■ ,tn are joinable in normal form if there exists t E NF-ji with U —>•* t for each i, and denoted by {t\, • • • ,tn}N-

We call s —>•* t a witness of (s, t)u, and the existence of t E NFn with ti —>•* t for each i, a witness of {¿i, • • •, tn}N- Note that normalizabilitv of a term t is expressed as {t}N.

We say that a rewrite sequence s —>•* t is top-invariant if st. For a right-ground normal MCTES R = {/,-—>• r, ■== (}■. we denote the set {/¿} (resp,{ri}) of the left-hand-sides (resp, right-hand-sides) of rules in 1Z by 7Zl (resp, 1ZT). Throughout this section, 1Z is a right-ground normal MCTES,

Definition 6.1 For a term t, Sn(t) = {t' \ t'<t V t' < r E 7Zr}. A substitution 9 is a 5ft(t)-substitution, if for each variable x, x9 E S-ji(t).

Remark 6.2 S-ji(t) is always a finite set.

Example 6.3 Let 1Z be the same as in Example 3,9, Sn(d(2, 2)) = {/(2), 2,1, 0},

The intuition for a (^(^-substitution is the possible substitution for variables in a redex that is reachable from t.

We start with an explicit construction of the search space, i.e., possible reduction of (s,t)u and {t\, • • • ,tn}n to "smaller" problems. During the construction, the following lemma is the key.

Lemma 6.4 If a rewrite sequence A : s t is not top-invariant, there exist I —r <= C E 1Z, a substitution a, and a 6-jz (s)-substitution 9 such that

D >£* fa >-P0Sy(lf , € *

-D : s —y 19 la —y /• —y I

with the same rewrite steps. (Recall that I is a linearization of I.)

Proof. Since A is not top-invariant, there exists a rewrite at the root e. Let Icr 4 r be the first such rewrite. Let A' be the prefix sequence of A from s to la, and let A" be the suffix sequence of from la to t. Then, A' : s la. Let {Ph ''' iPn} = Vosv(T) and let Ajt be the maximum suffix sequence in A' such that all rewrites are below or equal to Pi. Then, by interchanging the order of parallel rewrites, we can decompose A' as C;Ai; • • •; An. By construction of Ai, • • •, An, there exists a substitution 9 such that C : s 19 and, for each Pi,

(i) either all rewrite steps in C are parallel to pi, or

(ii) the last rewrite step in C that is not parallel to pi occurs above pi.

Let Xi E Vor(f) with {pi} = Vos(l,Xi). For (i), Xi9 = s\Pi, and for (ii), Xi9 is a subterm of r' for some r' E 7Zr (recall that 1Z is right-ground). Thus, 9 is a (^(¿^-substitution. □

Definition 6.5 Let s, t,t\,---, tn be terms and let 9 be a (^(^-substitution. Define $R((s,t)R) = $R,i((s,t)R) U $R,2((s,t)R) and $N({ti, ■ ■ •, tn}N) = $N,i({ti,--,tn}N) U $iv,2({ii,---,4}iv) where

l((s,t)R) = { {(Si,ti)R | S = f(su- ■ ■ ,Sn),t = f(tu- ■ ■ ,tn)} }

if root(s) = root(t)

®R,2((s,t)R)

I r <=(' e 'R

\/x.x6 e Sn(s)

{{s,W)R,{r,t)R} U

(^x£Varnl(l), piEVosil ,x Pi l\Pm $}iv})|

®N,i({h,---,tn}N) = { {{h\j, - • • ,tn\j}N I 1 <j < arity(root(ti))} }

if root(ti) = ■ ■ ■ = root(tn) $N,2({h,---,tn}N) = { {(U,r)R, {il, • • * , ¿i-l, r, ii+i, - • • , i„}jv} | r E Ur}

We assume that redundancy in <frR and $jv is removed as

• to eliminate (s, s)R, and

• to reduce {• • • ,t,t,- • -}n to {• • •,t, • • -}at.

Example 6.6 Let 1Z be the same as in Example 3,9, <frR((d(2, 2), 0)R) is

{(d(2,2 ((d(2,2 ((d(2,2 ((d(2,2 ((d(2,2 ((d(2,2 ((d(2,2 {{2}iv} {(d( 2,2 ((d(2,2 ((d(2,2 ((d(2,2 ((d(2,2 ((d(2,2 {{(d( 2,2

d(f(2)J(2)))R,{f(2)}N}, d(f(2),2))R,{f(2),2}N},

d(f(2),l))R,{f(2),l}N}, d(f(2), 0))R, {/(2), 0}jv}, d(2,/(2)))^,{/(2),2}JV}, d(l,f(2)))R,{f(2),l}N}, d(0,/(2)))^,{/(2),0}JV},

d(2, l))fl,{2,l}iv}, d(2, 0))b,{2,0}jv},

d(0, 2))H,{2,0>JV>, d(l,l))R,{l}N}, d{l,0))R,{l,0}N}, d( 0,0))fl,{0}iv},

{(d(2,2),d(f(2)J(f(2))))R,(l,0)R,{f(2)}N},

{(d(2,2), d(/(2), f(2)))R, (1, 0)R, {/(2), 2}jv},

{(d(2,2), d(f(2), /(1)))*, (1,0)R, {/(2), l>isr>,

{(d(2,2), d(f(2), f(0)))R, (1,0)*, {/(2), 0}*},

((d(2,2), d(2, /(/(2))))*, (1,0)*, {/(2), 2}jv},

((d(2,2), d( 1, f(f(2))))R, (1,0)*, {/(2), l>isr>,

((d(2, 2), d(0, f(f(2))))R, (1,0)*, {/(2), 0}*},

((1,0)*, (2}*},

((d(2, 2), d(2,f(l)))R, (1,0)^,(2,1}^},

((d(2, 2), d(2,/(0)))^(l, 0)^(2,0}*},

{(d(2, 2), d(l,/(2)))fl, (1,0)^,(2,1}^},

((d(2, 2), d(0,f(2)))R, (1,0)^,(2,0}^},

((d(2, 2), d(l,/(l)))fl, (1,0)^,(1}^},

((d(2, 2), d(l,/(0)))fl, (1,0)^,(1,0}^},

((d(2, 2), d(0,/(0)))fl,(l, 0)^,(0}*}

The intuition for $R((s,t)R) and $jv({ii, • • •, in}iv) is the set of candidates of the reduction of the problem. For instance, $R,i((s,t)R) corresponds to the case that the witness s —>•* t of (s,t)R is top-invariant, and $_r,2((s, t)R) corresponds to the case that it is not top-invariant. They enumerate all possible reductions, based on Lemma 6,4, Similarly, $jv,i({ii, • • •, in}iv) corresponds to the case that the witness, for t E NFn with ti —>•* t for each i, is top-invariant for each i. $jv,2({ii, • • •, ¿n}iv) corresponds to the case that some ti —>•* t is not top-invariant.

Let either p = (s, t)R or p = • • •, tn}N. Next, we define the search path ^a(p) for a sequence a of pairs of integers. The interpretation is as follows: If ^a(p) is empty or only consists of the form {i}jv with t E NFn, then the witness is found at a. If ^a(p) contains either (s, t)R with s E NFn and s ^ t, or {t}N with t 0 NFn, then the witness does not exist at a (and later).

Definition 6.7 Let

, ( ®r(p) if P=(s,t)R,

Hp) = \

[$Ar(p) if p={tl,---,tn}N.

and let a be a sequence of pairs of integers. Then, a search path ^a(p) is inductively defined as:

Mp) = {p}

^a.(i,j)(p) = {n, ■■■ ,Ti_i,Ti+i, ■■■ ,Trn} U fj

where {n, • • •, rm} = Va(p) and {n, • • •, fk} =

We will show that to decide p, it is enough to check finitely many ^a(p) whether they have witness.

Definition 6.8 Let s, t, t\, • • •, tn be terms. Assume that (s, t)R and {ti, • • •, i„}jv have a witness. We denote the minimal (sum of) rewrite steps of the witness of (s, t)R and {¿i, • • •, tn}N by step((s, t)R) and step({ti, • • •, i„}jv), respectively. Define weight ui by

u((s,t)R) = (step((s,t)R),\s\), u({ti, ■ ■ -,tn}N) = (step({ti, ■ ■ -,tn}N), \ti\ H-----b \tn\).

Weights are compared lexicographically:

(i,j) > (»',/) ^ i > i' V (i = i' A j > /).

The next lemma is immediate.

Lemma 6.9 Let either p = (s, t)R or p = {¿i, • • •, tn}N, and let f E $(p). If each r E f has a witness and they give p a witness, then ui{t) < ui{p).

We denote the maximum multiplicity of (nonlinear) variables in I in 7Zl by an, and {10 \ I E 7Zl,0 is a (^(^-substitution} by An(s).

Definition 6.10 Let s, t, t\, • • •, tn be terms,

SR((s,t)R) = {(s',t')R | s' < s V s' <r ElZr and

t' <uE An(s) Vt'<tVt'<rE TZr} SN((s,t)R) = H/,--••-//,)• V I 1 < k < an and tt<s V tt < r E Kr}

SR({ti, • • •, tn}N) = {(«', t')R | s' < ti V s' < rEW and

t' <UE Ui^A^fe) V f<reKr}

^({ti, • • •, tn}N) = {{t[, ■■■, t'k}N I 1 < k < max(n, an) and

(Vi<i<„ Hj < U) V

Example 6.11 Let 1Z be the same as in Example 3,9, SR((d(2,2),0)R) = {(s',t')R} where

s'E{d(2,2), /(2), 2, 1, 0},

t'E {d(/(2),/(2)), d(/(2),2), d(/(2),l), d(f(2),0),

d(2,/(2)), d(l,/(2)), d(0,/(2)), d(2,2), d(2,l), d(2,0), d(l,2), d(0,2), d(l,l), d(l,0), d(0,l), d(0,0)}

SN((d(2,2),0)R) = {{t[,---,tik}N}wheret>E{f(2), 2, 1, 0}.

Lemma 6.12 Let either p = (s,t)R or p = {¿i, • • • ,i„}jv- Then, for each a, ^a(p) C SR(p) U SN(p).

Proof. Since s E 5ft(t) implies ^(s) C 5n(t), by induction on the length of a, ®a(p) C SR(p)USN(p). □

Now, we show that it is enough to consider a search path $Q(p) with the upper bound for the length of a; i.e., if we cannot decide yet whether the witness exists at a that is longer than the upper bound, then ^(p) and ^(7) are the same for some different suffixes /3 and 7 of a.

Lemma 6.13 Let either p = (s,t)R or p = {ti, ■ ■ ■ ,tn}N■ There exists an upper hound ML such that if $«(p) 4> M > ML, then, for any ¡3 that contains a as a prefix, does not give a witness of p.

Proof. Since Aft(s), An(ti), • • •, An(tn) are finite, SR(p) and SN(p) are finite by construction. Let ML = 2l*s'-Rfpiu*s'JV , Assume that <&p(p) gives a witness of p for some /3 that contains a as a prefix. Without loss of generality, we

assume /3 = a. Then, $Q(p) also gives <&a'(p) a witness for each prefix a' of a.

Let < be the multiset extension of <, Then, from Lemma 6,9, for each prefix a' and a" of a, if a" is a proper prefix of a', then ^ ^a"(p)-

Thus, $Q'(p) # $a"(p)- However, from Lemma 6,12, this is a contradiction to |a| > ML bv the pigeon hole principle, □

At last, we give an upper bound Mw for branching of a search path.

Lemma 6.14 Let either p = (s,t)R or p = {ti, ■ ■ ■ ,tn}There is an upper hound Mw such that, for each t ET E^a{p), |$(r)| < Mw-

Proof. Let vn = max {\Var(l)\ \ I E 1Z1} and m, = max (| \Sn(ti)\, •••,

\Sn(tn)\}- Define Mw = mVn • \7l\ +I. Since s E S-ji(t) implies ^(s) C 5n(t), if T = (s,t)R), IMMWI < rnVn ■ \n\ + 1, and if T = {tir--,tn}N, |$iv({ii, • • • ,Uiv)l < \K\ + 1- Thus, |$(r)| < Mw. □

Theorem 6.15 For a right-ground normal MCTRS, reachability and normal joinability are decidable.

Proof. Let either p = (s,t)R or p = {ti, • • • ,tn}n- ¿From Lemma 6,13, it is enough to consider $Q(/9) with |a| < ML. The number of candidates for the next $a.(i,j)(p) is at most l-S^p) U x Mw, because the possible choice

of? is at most from Lemma 6,12, and that of j is at most Mw

from Lemma 6,14, Thus, the set of search paths to check is finite, and the theorem follows, □

Corollary 6.16 For a right-ground normal MCTRS, normalizability is decidable.

Remark 6.17 Since a normal form may not be preserved when adding context, even if $Q(p) has a witness, this does not mean p has a witness. We need to check further that $Q(p) actually gives p a witness. For instance, the witness of {ii,i, i2,i}iv, {¿1,2,^2,2}n that there exist ti,t2 E NFn such that ii,1,^2,1 ti and th2,t2,2 t2, does not mean that /(ii,i, th2), f(t2,i, tV2) ->•* f(ti,t2) is a witness of {/(ii,i, ¿1,2), f(t2,i, t2,2)}N, because it may be f(t\,t2) 0 NFn. However, this search path is produced for a top-invariant case, and {/(¿1,1, ¿1,2), f(t2,i,t2,2)}N will be analyzed in another search path for a not top-invariant case (note that ti,t2 E NFn implies f(ti,t2) is a redex). Thus, we simply judge this search path fails,

7 NV-needed redex of normal MCTRS

In this section, we provide an alternative definition of a needed redex as in [5], and show that whether a redex is nv-needed is decidable for a normal MCTRS, The equivalence of two definitions for a nonoverlapping normal MCTRS is obtained similar to Lemma 4,1 in [5].

Definition 7.1 Let • ^ IF. * e V). A redex s|p (in s) is needed if s[»]p does not rewrite to a normal form without •,

Definition 7.2 Let F) be a fresh constant and let i be a term, tn is a term obtained by replacing each variable in a term t with il

For terms t, u E T{TU {il}, V), we denote t < u if t is obtained from u by replacing the subterms in u by fi's.

Definition 7.3 Let TZ be a normal MCTES, and s,t be terms. Let p E Vos(s). If s\p is a redex of I —r 4= C E TZ,

s —nv t t = where /•<> < it E T(!F)

Definition 7.4 A redex is nv-needed if it is needed under

¿From now on, we concentrate on rewrite sequences starting from ground terms, and we assume Tq ^ <f>. This restriction does not lose generality, because for a rewrite sequence starting from a non-ground term t, we can regard the variables in t as additional constants.

Definition 7.5 Assume Tq ^ <f>. For a normal MCTES TZ, we define right-ground normal MCTESs TZq, TZq, and TZq as follows,

TZn = TZln U TZ2n

= {I m <= C \ I r <= C E H} Kl = {il^f(il,---,il) \fETn, n > 0}

We denote (resp, —^^^, z2) by —(resp, -4-q, —

Lemma 7.6 Let s,t be ground terms. Assume Tq ^ <f>. If s —^ t and il gt s. then, for each term t' with t -<t' and il , s t'.

Proof. By induction on the number m, of the occurrences of —^'s in s —^ t. Since lFt\ ^ <f>, it is easy for m = 1,

Assume m > 1 and let s u An v (^n)* Without loss of generality, we can assume that every rewrite in v (^n)* t occurs at a position larger-than-or-equal-to p.

Since u\p is a redex of TZq, for each u' with u\p < u' and il ¿1 u', u' is a redex of TZq. (Note that il 0 NFn(1; thus il does not appear below non-left-linear variable positions in the rewrite u\p —v\p.) Thus, we can modify the

rewrite sequence as s q u (^-q)* u[u']p An v (^-q)* t.

For each t' with t' with t ^ t' and il ^ t', u[u% t'[u% and il ^ t'[u%. Thus, from the induction hypothesis, s —,>*nv t'[u']p, and u' —t'\p. This concludes s —t'. □

Lemma 7.7 Let s,t be ground terms with il ¿1 s. If s —t, then s —^ t.

Proof. By induction on the number m, of rewrite steps of s —t. For m, = 1, the proof is easy, (Note that s —t implicitly implies ^ <f>.) Assume m, > 1, Let s —u —t. Since the reduction of —does not produce il, O ¿1 u. Thus, the induction hypothesis implies s —^ u —^ t. □

Lemma 7.8 For a term t with il ¿] t, t is normalizahle w.r.t. —>nv, if, and only if, t is normalizahle w.r.t.

Proof. A term without il is a normal form w.r.t, —if, and only if, a normal form w.r.t. —Yq. Thus, from Lemma 7.6 and 7.7. □

Since Rq —V •} is a right-ground normal MCTES, Theorem 7.9 follows immediately from Corollary 6.16 and Lemma 7.8.

Theorem 7.9 For a normal MCTRS, whether a redex is nv-needed is decid-able.

Remark 7.10 —approximates (i.e., NF.= NF^nv and C thus Lemma 4.5 in [5] shows that nv-needed redexes are really needed.

Thus, from Corollary 5.4, the repeated reduction of nv-needed redexes is a normalizing strategy (provided that nv-needed redexes exist in every reducible term).

Remark 7.11 The repeated reduction of nv-needed redexes needs not be root normalizing. For instance, consider a (normal MC)TRS (Example 5.11 of [9])

{f(x) 9(f(x)), a ^ a}.

f(a) has no —normal forms; therefore

f(a) ^ f(a) ^ f(a)

is the reduction of nv-needed redexes. But, this is not root-normalizing.

8 Conclusion

This paper investigated call-bv-need reductions for a normal membership conditional term rewriting system (MCTRS). Its main results are:

(i) A reducible term has a needed redex for a nonoverlapping normal MCTRS.

(ii) Reachability and normalizabilitv for a right-ground normal MCTRS are decidable.

(iii) Whether a redex is nv-needed is decidable for a normal MCTRS.

For the second and the third result, we expect that reachability and normalizabilitv of a shallow [2,3] and right-linear normal MCTRS are decidable, and that nv-neededness can be extended to shallow-neededness.

Note that, although decidability results hold for left-linear and growing TESs (Theorem 4,2 and 4,3 in [11]), growing neededness is undecidable for normal MCTESs, because Post's Correspondence Problem (PCP) can be described as a reachability (or normalizabilitv) problem of a growing and right-linear normal MCTES (either with or without membership conditions). Let Pi) | 1 < i < n} be an instance of PCP, Solvability of this instance is equivalent to whether b is reachable from a where

a d(ai(c),/3i(c)), d(x,y) d(ai(x), ¡3i(y)), < >

a d(an(c), ¡3n(c)), d(x,y) d(an(x), ¡3n(y)),

d(x,x) ->• b <= x E NF.

Here, we assume that the symbols a,b,c,d do not appear in c^ and and we regard a finite sequence a as applications of unary function symbols (e.g., = f(g(h(x))) for a = fgh). There remains another decidability problem: in a normal MCTRS, whether every reducible term has a nv-needed redex is decidable. A similar result for left-linear TESs is found in [13] in the context of sequentially. However, the proof of Assertion 1 in Theorem 6,6 in [13] does not work (at least not directly), and the gap has not been filled.

If a normal MCTES has only shallow non-left-linear variables (i.e., each occurrence of a nonlinear variable in the left-hand-side of a rule in a normal TES is at depth 1), tree automata with brotherhood equality [1] would work similar to [5], which is in principle the same as a classical tree automata. We expect reduction automata [4] would further help for this direction.

Acknowledgment

The author thanks the TES meeting members, especially Aart Middeldorp, Michio Ovamaguchi, Masahiko Sakai, and Yoshihito Toyama for many fruitful discussions, and anonymous referees of WES'03 for their detailed comments, which greatly improved the previous version of this paper. This research was supported by PRESTO, Japan Science and Technology Corporation,

References

[1] B. Bogaert, F. Seynheave, and S. Tison. The recognizability problem for tree automata with comparisons between brothers. In FoSSaCS 99, pages 150-164, 1999. Lecture Notes in Computer Science, Vol. 1578, Springer-Verlag.

[2] H. Comon. Sequentiality, monadic second-order logic and tree automata. Information and Computation, 157(1 & 2):25—51, 2000.

[3] H. Comon, M. Haberstrau, and J.-P. Jouannaud. Syntacticness, cycle-syntacticness, and shallow theories. Information and Computation, 111(1):154-191, 1994.

[4] M. Dauchet, A.-C. Caron, and J.-L. Coquide. Automata for reduction properties solving. Journal of Symbolic Computation, 20:215-233, 1995.

[5] I. Durand and A. Middeldorp. Decidable call by need computations in term rewriting (extended abstract). In Proc. 14-th International Conference on Automated Deduction, CADE-14, pages 4-18, 1997. Lecture Notes in Artificial Intelligence, Vol. 1249, Springer-Verlag.

[6] G. Huet. Confluent reductions: Abstract properties and applications to term rewriting systems. Journal of the ACM, 27:797-821, 1980.

[7] J.W. Klop. Term rewriting systems. In Handbook of Logic in Computer Science, volume 2, pages 1-116. Oxford Univ. Press, 1992.

[8] G. Kucherov and M. Tajine. Decidability of regularity and related properties of ground normal form languages. Information and Computation, 118:91-100, 1995.

[9] S. Lucas. Root-neededness and approximations of neededness. Information Processing Letters, 67(5):245-254, 1998.

[10] A. Middeldorp. Call by need computations to root-stable form. In Proc. 24th ACM SIGPLAN-SIGACT Symposium, on Principles of Programming Languages, POPL'97, pages 94-105, 1997.

[11] T. Nagaya and Y. Toyama. Decidability for left-linear growing term rewriting systems. Information and Computation, 178(2):499-514, 2002.

[12] M. Oyamaguchi. The reachability and joinability problems for right-ground term-rewriting systems. Journal of Information Processing, 13(3):347-354, 1990.

[13] M. Oyamaguchi. NV-sequentiality: a decidable condition for call-by-need computations in term rewriting systems. SIAM Journal on Computing, 22(1): 114—135, 1993.

[14] Y. Toyama. Membership conditional term rewriting systems. Trans. IEICE, E72(ll):1224-1229, 1989. previously presented in Proc. 1st International Workshop on Conditional Term Rewriting Systems, CTRS 1987, pp.228-241, Lecture Notes in Computer Science, Vol. 308, Springer-Verlag.