Theoretical Computer S c i e n c e ELSEVIER
Theoretical Computer Science 151 (1995) 487-512
Modular proofs for completeness of hierarchical term rewriting systems M . R . K . K r i s h n a Rao*
Computer Science Group, Tata Institute of Fundamental Research, Colaba, Bombay-400 005, India
Abstract
In this paper, we study modular aspects of hierarchical combinations of term rewriting systems. A combination ~0 td ~l is hierarchical if the defined symbols of the two subsystems ~0 and ~l are disjoint, some of the defined symbols of ~0 are constructors in ~l and the defined symbols of ~l do not occur in ~0. It is shown that in hierarchical combinations, a reduction can increase the rank of a term. Therefore, techniques employed in proving the modularity results for direct sums and constructor sharing systems are not applicable for hierarchical combinations. We propose a set of sufficient conditions for the modularity of completeness of hierarchical combinations. The sufficient conditions are syntactic ones (about recursion) and can be easily tested for finite systems. First, the modularity of strong innermost normalization (SIN) for a class of hierarchical combinations is established. By imposing a restriction that ~0 tJ ~l is an overlay system, the modularity of local confluence is established for this class. Then the modularity of completeness is obtained using a recent result relating strong innermost normalization and termination properties of locally confluent overlay systems.
1. I n t r o d u c t i o n
In the last few decades, term rewriting systems have played a fundamental role in the analysis and implementation o f abstract data type specifications, decidability o f word problems, theorem proving, computability theory, design o f functional programming languages (e.g. Miranda), integration o f functional and logic programming paradigms, etc. The study o f properties which are preserved under combinations o f term rewriting systems (called modular properties) is o f both theoretical and practical importance. A property P o f term rewriting systems is modular if the following holds: two
rewriting systems ~o and ~?1 have property P if and only if their union 9lo t3 ~1
~"This is a revised and extended version of [8, 9]. * E-mail:
[email protected]. 0304-3975/95/$09.50 (~) 1995--Elsevier Science B.V. All rights reserved SSDI 0304-3975(95)00075-5
488
M.R.K. Krishna Raol Theoretical Computer Science 151 (1995) 487 512
has property P. A knowledge that property P is modular gives the following advantages: 1. Analysis: To check whether a (large) system satisfies P, one can decompose it into a set of smaller subsystems and check whether these subsystems satisfy P. This is very important because most of the interesting properties of rewrite systems are intractable (some are even undecidable). In other words, the modularity results facilitate the applicability of divide-and-conquer approach in the analysis of properties of rewrite systems. 2. Synthesis: If a system Si satisfying a desirable property P is to be extended with a new set of rules, it is enough to check whether the new set of rules satisfy P for ensuring that the extended system still satisfies P. In other words, the modularity results facilitate incremental development of systems. In a seminal paper [26], Toyama introduced the notions of modularity and direct sum of rewrite systems. The union -~0U.~l of two rewrite systems -~'0 and -~l is called a direct sum if alphabets of ~0 and ~1 are disjoint. Toyama proved the modularity of confluence property in [26] and refuted the modularity of termination through a counterexample. Klop and Barendregt (cf. [27]) and Drosten [4] have independently shown that termination is not preserved even if the two components are complete (confluent and terminating). Rusinowitch [24] and Middeldorp [17] formulated sufficient conditions for the modularity of termination based on the distribution of collapsing and duplicating rules in the constituent systems. Toyama et al. [28] established that leftlinearity is sufficient for the modularity of completeness. Using a powerful technique, called alien-replacement, Kurihara and Ohuchi [14] proved an interesting result; simple termination is modular. All these results are for direct sums (i.e., sharing of function symbols is forbidden). Kurihara and Ohuchi [15] and Middeldorp and Toyama [19] have obtained a few results on the modularity of termination when the two constituent systems share constructors. Function symbol f is a constructor in :~ if f does not occur as outermost symbol of the left-hand side term of any rewrite rule in ~ , otherwise it is a defined symbol. Kurihara and Ohuchi [15] proved the modularity of simple termination for rewrite systems with shared constructors, whereas Middeldorp and Toyama [19] proved that completeness is modular for systems with constructor discipline. Although the above results are elegant and interesting, they are not applicable in situations where defined symbols of-J)/0 are used as constructor symbols in -~l (i.e., hierarchical combinations). This situation arises very naturally in an incremental development (or synthesis) of programs and algebraic specifications. This style of writing (and developing) programs is encouraged in logic and functional programming. Since termination of logic programs [12] and functional programs is closely related to that of term rewriting systems, the results which can be applied in this situation will be very useful and have a great significance from the practical point of view. However, the modular aspects of hierarchical combinations are not explored well in the literature.
M. R. K. Krishna Rao I Theoretical Computer Science 151 (1995) 487-512
489
The following diagram gives the pictorial view of direct sums, constructor sharing systems and hierarchical combinations. The sets of defined and constructor symbols of :~,i are denoted by Di and Ci respectively.
G (a) Direct sum
(b) Sharing Constructors
(c) Ilierarchical Combination
In this paper, we deal with modular aspects of hierarchical combinations, in particular completeness. A set of sufficient conditions for the modularity of completeness of hierarchical combinations is proposed. The conditions are syntactic ones (about recursion) and can be checked very easily. Our main result is a generalization of the main result of Middeldorp and Toyama [19]. It may be noted that techniques used in proving the modularity of termination for direct sums and constructor sharing systems are not applicable in hierarchical combinations because the following property is not valid for hierarchical combinations: if t =~*t' then rank(t)>~rank(tt). That is, in hierarchical combinations, a reduction can increase rank of the term. This complicates the proofs and necessitates a lot of machinery to deal with hierarchical combinations. We employ the following approach for studying the modularity of completeness for a class of hierarchical combinations, called proper-extensions. To make the proofs simpler and avoid mixing of many issues, we start with a proper subclass of properextensions called nice-extensions. Using a result on abstract reduction systems, we show that the hierarchical combination -~0U.~l is strongly innermost normalizing (SIN), i.e., terminates under the innermost reduction strategy, if .~0 and . ~ are strongly innermost normalizing systems and .~/~ is a nice-extension of-~0. That is, strong innermost normalization (SIN) is modular for this class of combinations. Then we point out that completeness is not modular for this class. To obtain the modularity of completeness, we impose a restriction that the combined system is an overlay system. Since overlay systems allow overlapping only at outermost level, it is very easy to prove the modularity of local confluence. Then, the modularity of completeness for this class follows from the modularity of innermost normalization and local confluence properties for this class and by a recent result of Gramlich. We then extend our results to the class of proper-extensions. In fact, we consider a larger class of combinations than the hierarchical combinations. This class is called super-hierarchical combinations and allows (i) defined symbols to be shared and (ii) defined symbols of the higher system (-~l) occurring on the left-hand sides of the base system (.~0) as constructors, unlike in hierarchical combinations.
490
M.R.K. Krishna Rao I Theoretical Computer Science 151 (1995) 487-512
The rest of the paper is organized as follows. Section 2 gives the preliminary definitions and the results needed later. In Section 3, we give a brief overview of the existing results on modular aspects of term rewriting systems. In Section 4, various classes of hierarchical and super-hierarchical combinations, such as nice and properextensions, are defined. Section 5 establishes the modularity of innermost normalization for nice-extensions. Using this result, the modularity o f completeness for a class of nice-extensions is established in Section 6. Section 7 relates proper-extensions with nice-extensions and establishes the modularity of completeness for a class of properextensions. Section 8 concludes with a discussion.
2. Preliminaries We assume that the reader is familiar with the basic terminology o f term rewriting systems, like contexts, substitutions and properties such as confluence (CR), local confluence (WCR), strong normalization (SN) and strong innermost normalization (SIN) etc. and give definitions only when they are required. The notations not defined in the paper can be found in [3, 7] or [18].
Definition 1 (Critical pairs). Let Ii --* rl and 12 ~ r2 be renamed versions of rewrite rules o f a term rewriting system ~ such that they have no variables in common. Suppose It Ip is not a variable for some position p and Ii Ip unifies with 12 through a most general unifier or. The pair of terms (ll[rz]pa, rla) is called a critical pair of .~. If Ii ~ rt and 12 ---, r2 are renamed versions of the same rewrite rule, we do not consider the case p = e. A critical pair (ll[r2]pa, rla) with p = e is called an overlay and a critical pair (s, t) is trivial if s -= t. The following definition defines the class of overlay systems.
Definition 2. A term rewriting system :~ is an overlay system (OS) if all its critical pairs are overlays. Definition 3. A reduction step C[la] ~ C[ra] is an innermost reduction step if no proper subterm of la is reducible. A rewriting derivation is an innermost derivation if every reduction step in it is innermost. A term rewriting system .~(,~-,R) is stronqly innermost normalizin,q (SIN) if every innermost derivation of :~(,~-,R) is of finite length. The following theorem is proved in [5].
Theorem 4. A locally confluent overlay system is complete if and only if it is stronyly
innermost normalizin9 (SIN).
M.R.K. Krishna Rao/ Theoretical Computer Science 151 (1995) 487-512
491
In the following, ~J-(,~-, 5 ) denotes the set of terms constructed from a set of function symbols ,~- and a set of variables 5 , and F(t) denotes the set of function symbols occurring in term t. The root of a term t is defined as: root(t) = f if t - f ( s l . . . . . s,,), and root(t) = t if t E 5 . Definition 5. The set D~ of defined symbols of a term rewriting system . ~ ( ~ , R ) is defined as {root(l) l l ~ r E R} and the set C~ of constructor symbols of .)¢(~,R) is defined as ~ - D~. To show the defined and constructor symbols explicitly, we often write the above rewrite system as . ~ ( D ~ , C ~ , R ) and omit the subscript when such omission does not cause any confusion. We need the following definitions in the sequel. Definition 6 (Dependency relation ~-a over defined symbols). The dependency relation of a rewrite system .~(D,C,R) is the smallest quasi-order ___a over D satisfying the following conditions: • f _ a f for each f E D (reflexivity), • f ___ah if f ~a ,q and g ___ah (transitivity), • f ~a ,q if there is a rewrite rule 1 ~ r E R such that f - root(l) and (/E F(r). We say that a defined symbol f E D depends on a defined symbol g E D if f _~a Y. The set of symbols depending on a set of symbols S is defined as { f If _d g and ,q E S}. Intuitively, f ___ay means that an evaluation of the defined function f for some arguments may involve an evaluation of the defined function g for some arguments (i.e., the definition of f depends in some sense on that of g). It also means that an appearance of f in a derivation might lead to a creation of g in the later part of the derivation. Definition 7. Let .~?(,~-,R) be a rewrite system and t be a term in 3 - ( ~ , 5 ) . A set of function symbols S C ,~- is unreachable (in -~) from t if S N F(t') = ~b whenever t =¢,.# * t/. Lemma 8. Let .~(.~-,R) be a rewrite system, S C ,~ be a set o f function symbols and t be a term in ,~(,~-,5). Then, S is unreachable f r o m t if no function symbol in t depends on S.
3. Brief overview of existing results on modularity In this section, we briefly discuss some of the major results (in our view) in the theory of modularity. This overview is meant for introducing the field of modularity to a general reader. We do not consider the conditional and higher order systems in this paper.
492
M. R. K. Krishna Rao / Theoretical Computer Science 151 (1995) 487-512
3.1. D i r e c t s u m
Toyama proved the modularity of c o n f l u e n c e property in [26] and refuted the modularity of t e r m i n a t i o n with the following counterexample [27]. Example I. It is easy to see that the following .~o and .~1 are terminating. :~0 : ~(0, l,x) ~ f ( x , x, x)
.~, :g(x, y) ~ x g(x, y) ~ y
But their direct sum has a cyclic derivation f(0, 1, g(0, 1)) :=~ f(g(0, 1), g(0, 1), g(0, 1)) =~ f(0, g(0, 1 ), g(0, 1 )) =:~ f(0, 1, g(0, 1)) =~ ... Rewrite system . ~ in the above counterexample is not confluent. So one might expect that termination of confluent systems is preserved (i.e., the modularity of completeness). However this was refuted by Klop and Barendregt with a counterexample (see [27]). Drosten [4] provided the following simple counterexample. Example 2. Following systems ~0 and -~1 are confluent and terminating. /~0 : f(0, l , x ) ~ f ( x , x , x ) f(x,y,z) ~ 2
~l : g(x,y,y) ~ x g(y,y,x) ~ x
042 1 ---~2 But the direct sum has the following cyclic derivation ~(0, 1,g(0, 1, l ) ) ~ ~(g(0, l, 1),g(0, 1, 1),g(0, 1,1)) ~ . . . ~ ~ ( 0 , 1 , g ( 0 , 1, l ) ) ~ . . .
In the above counterexample, both the left-hand side and the right-hand side terms of the first rule in ~0 are reducible by the second rule. This may give an impression that termination is modular for irreducible confluent systems. However, this conjecture (of Hsiang) was also refuted by a counterexample in [27]. The first positive result on the modularity of termination was presented in [24], where it is proved that termination is modular for (i) collapse-free (i.e., no rule has just a variable on the right-hand side) and (ii) non-duplicating (i.e., no variable has more occurrences on the fight-side than on the left-hand side of any rule) rewrite systems and conjectured that 'if direct sum of two terminating systems is non-terminating then one of them should contain collapsing rules and other contain duplicating rules'. Middeidorp [17] settled this conjecture positively and reformulated the result as 'direct sum of two terminating systems is terminating if one of them contains neither collapsing nor duplicating rules'. Toyama et al. [28] established the modularity of completeness for
M. R. K. Krishna Rao / Theoretieal Computer Science 151 (1995) 487-512
493
left-linear term rewriting systems. Marchiori [16] and Schmidt-Schauss and Pintz [25] independently provided a simpler proof of this result. Kurihara and Ohuchi [14] reported a nice result about the modularity of termination. The result is based on the nature of termination proofs rather than the syntactic properties of rewrite systems. The main theorem in [14] says that simple-termination is modular for finite systems. A term rewriting system .~ is simply-terminatiny if termination of .3 can be proved using some simplification-ordering. Inspired by the works of Kurihara and Ohuchi [14, 15], Gramlich [6] revisited the results of [24, 17, 14, 15] in a uniform framework, with an assumption that the systems are finitely branching. He proved that 'if the direct sum .30 U ~ t of two (finitely branching) terminating rewrite systems -~0 and -~l is non-terminating then one of the two systems (say .30) is not termination-preserving under non-deterministic collapses (i.e., .30 U { G ( x , y ) ~ x, G(x,y) ~ y} is non-terminating) and the other system JCl has a collapsing rule'. Ohlebusch [20, 21] proved this result without the assumption of finite branching (see [6, 20, 21,23] for more details). Kurihara and Kaji [13] took an alternative approach to the modularity by defining the notion of modular reductions and established very interesting results (e.g. they proved that there is no infinite sequence of modular reductions even if some of the modules are non-terminating).
3.2. Constructor sharing unions
We say that the union -~0 U : ~ of two systems .~to(Do, Co,Ro) and .~¢o(Dt,Ci,Ri) is a constructor sharing union if Ci N Do = Co n Dt --- Do N Di = ~b. Kurihara and Ohuchi [15] proved the modularity of simple-termination for (finite) rewrite systems with shared constructors. One of the surprising I results (negative) on rewrite systems with shared constructors is that confluence is not modular when constructors are shared as shown by Kurihara and Ohuchi [15] with the following counterexample. However, it can be easily shown that confluence is modular for constructor sharing unions of left-linear systems. Example 3. Following two systems with a shared constructor, h, are confluent. -30 : f ( x , x ) ~ a
. ~ : g --, h(g)
f(x, h(x))~b But .~otJ:~r is not confluent; term f ( g , g) has two different normal forms, a and b. Middeldorp and Toyama [19] proved that completeness is modular for shared constructor systems. A term rewriting system is called a constructor system (and said to have constructor discipline) if the defined symbols do not occur in the proper subterms I Surprising in view of the fact that confluenceis the first property shown to be modular for direct-sums.
494
M. R K. Krishna Rao / Theoretieal Computer Science 151 (1995) 487-512
of the left-hand sides. The above two results ([15, 19]) are not comparable because [15] assumes that termination proofs (of constituent systems) are given by simplification orderings whereas [19] assumes constructor discipline and confluence o f the constituent systems. There are systems whose termination can be established by one result but not by the other. See [15, 19] for such examples. Gramlich in a recent paper [5] reported some nice results relating innermost normalization and strong normalization properties of rewrite systems. Using these results, he has given a simpler proof for the result of Middeldorp and Toyama [19]. To be precise, he proved the modularity of termination for locally confluent overlay systems. The main result of [5] relating strong innermost normalization and termination properties of rewrite systems is very useful in establishing our results below. Kurihara and Ohuchi [15] proved that confluence is preserved if the constructor sharing systems are also simply terminating. That is, confluence + simple termination is a modular property for constructor sharing unions. Ohlebusch [22] established that semi-completeness (i.e., confluence + weak normalization) is modular for constructor sharing unions.
3.3. Composable unions We say that the union :~A0U ~ t of two systems .~o(Do, Co,Ro) and .~o(DI,CI,RI) is a composable union if (i) CI N Do = Co n Dt = tk and (ii) R0 n Ri = {l ~ r E RoURl[root(l) E DoNDI }. That is, sharing of defined symbols is allowed if the rules defining these symbols in the two systems are the same. Ohlebusch [23] has generalized all the above results to the composable unions. It is interesting to note that none of the interesting properties differ on the modularity for constructor sharing unions and composable unions (i.e., it is not yet known if there is any natural property which is modular for constructor sharing unions but not modular for composable unions).
4. Hierarchical combinations In this section, we define a few classes of hierarchical combinations for which the modularity of completeness is studied in later sections. Before defining these classes, we show that completeness is not modular for hierarchical combinations (of even constructor systems) in general. Example 4. It is easy to see that the following two systems ~o and .~l are complete. -~0 : f ( x ) ~ x
-~l : h(a) --~ h ( f ( a ) )
To wit, the combined system has a cyclic derivation: h(a) = ~ , h ( f ( a ) ) =~o h(a). • •
M. R.K. Krishna Rao / Theoretk'al Computer Science 151 (1995) 487-512
495
The following example shows that confluence is not modular for hierarchical combinations of lett-linear systems, even if they are (i) constructor systems and (ii) terminating.
Example 5. It is easy to see that the following two systems .~¢0 and -~l are complete. ;~¢o : a --* b
-~l : f ( a ) -~ c
But, the combined system is not confluent; term f ( a ) has two different normal forms, c and f(b). For the discussions in the sequel, it is convenient to classify defined symbols in D1 into two sets (i) D O --- { f I f E DI and f -----d g for some g E Do} consisting of function symbols depending on Do and (ii) D I = DI -- D O consisting of function symbols not depending on Do. All throughout the paper, ~d denotes the dependency relation of the combined system. The following definition characterizes the main class of hierarchical combinations we are interested in.
Definition 9. A term rewriting system .~l(Di,Ci,Ri ) is a proper-extension of another term rewriting system .~0(D0, Co, Ro) if the following conditions are satisfied: 1. Do n D1 = Co f3 Di = ~b (i.e., -~0 U ~ l is a hierarchical combination). 2. Each rewrite rule l ~ r E R l satisfies the following condition: (HI): For every subterm s of r, if root(s) E D O and root(s) ~'d root(l), then s contains no function symbol (in Do UD °) depending on Do except at the outermost level
(of s). The second (and the main) condition essentially says that no symbol depending on Do occurs below the defined symbols (in D °) which are in mutual recursion with root(l). The intuition behind this condition will be clear in the sequel.
Example 6. The following system -~'l is a proper-extension of-~0. -~0 : add(O, x) ~
x
add(S(x), y) --+ S(add(x, y))
-~l :mult(O, x) --+ 0 mult(S(x), y) ---+add(y, mult(x, y))
The diagram representing hierarchical combinations in the introduction suggests that the two components do not share any defined symbols and rewrite rules. In many practical situations a need might arise to allow two systems to share some rewrite rules (and hence defined symbols). This is in particular needed while studying properties like weak normalization, innermost normalization, confluence and semi-completeness, which do not have the following hereditary property; if R has property P and R' is a subsystem o f R then R' has property P. The lack of this property forces us to allow two components to share some rules (so that the subsystems have the property
496
M.R.K. Krishna Rao I Theoretical Computer Science 151 (1995) 487-512
(e.g. confluence) of the whole system) while studying (and proving) these properties in a modular way. So, we now consider the following situation: two systems .~,o(D0 ® D, Co, Ro) and .~l(Di t~ D, CI,RI) sharing the defined symbols in D and the rules Ro N R1 = { l ~ r Lroot(l) E D}. We also consider such combinations with a restriction Do N Dr = Co NDI --- q~ as hierarchical combinations since some of the defined symbols of-~0 are used as built-in functions in . ~ . It is interesting to note that this notion of hierarchical combinations is a generalization of composable unions. The notations, D I and D O need slight changes now.
Notation: D O = { f I f E ( D , U D ) and f k a y for some ~EDo} and D I = (D, U D ) - D °. We denote the set of constructors (Co U C1 ) - (Do U D1 U D) of the combined system by Constr. ,Y-i denotes ,~-"(D i U D U Constr,~) and cgi denotes the set of contexts of Di U D U Constr, i.e., terms in ,~-'(Oi U D U Constr U {IZ},.U). By ~ , we denote the set of contexts of (Constr U D U Do U DI1). We assume that D C_D I . Definition 10. A term rewriting system :~l(Di ~ D, CI,RI) is a generalized properextension of another term rewriting system -~o(D0 W D, Co, Ro) if the following conditions are satisfied: 1. D o n D i = CoNDI = q5 and RoMRt = {l ~ r l r o o t ( l ) E D }. 2. Each rewrite rule 1 ~ r ERt satisfies the following condition: (HI): For every subterm s of r, if root(s) E (D O - D ) and root(s) ~d root(l), then s contains no function symbol (in Do U D °) depending on Do except at the outermost level (of s).
4.1. Super-hierarchical combinations In hierarchical combinations, defined symbols of-~1 are not allowed to occur in -~¢0. In a few (very rare) situations, it may not be possible to divide a system into two subsystems :~,0 and :~l such that the combination is hierarchical, but it might be possible to divide that system into two subsystems -~0 and : ~ such that the defined symbols of-~¢0 do not depend on the defined symbols of .~t. Basically, the defined symbols of .?gl are allowed to occur on the left-hand side terms of .~¢0 and defined symbols of-~0 can occur on both the left and the right-hand side terms of .~¢I. Such combinations are called super-hierarchical combinations. It may be noted that such a situation can occur with the rewrite systems generated by completion procedures. Now, we generalize the notion of proper-extension to the super-hierarchical combinations.
Definition 11. A term rewriting system :~l(Di ~ D, Ct,R1) is a generalized properextension* of another term rewriting system .~0(D0 ~ D, Co, Ro) if the following conditions are satisfied: 1. Ro NRI = {l ~ r l r o o t ( l ) E D }. 2. V f E (DoUD), VgE Di, f ~ag (i.e.,-~0U.~l is a super-hierarchical combination).
M.R.K. Krishna Rao/ Theoretical Computer Science 151 (1995) 487-512
497
3. Each rewrite rule l --~ rERi satisfies the following condition: (HI): For every subterm s of r, if root(s)6 (D O - D ) and root(s) ~d root(l), then s contains no function symbol (in Do tO D °) depending on Do except at the outermost level (of s). Remark. Note that condition 2 implies Do fq DI = gb. Our main aim is to study modularity of completeness for the class of generalized proper-cxtension*s. To make the proofs simpler and avoid mixing up many issues, we first study modularity of completeness for a proper subclass of generalized properextensio~l*s, called generalized nice-extension*s, from which we derive the results for generali:ed proper-extension*s.
Definition 12. A term rewriting system .~l(Dl ~ D, CI,RI) is a generalized niceextenshm* (resp. nice-extension, generalized nice-extension) of another term rewriting system .~0(Di ~ D, CI,RI ) if-~'l is a generalized proper-extension* (resp. properextension, generalizedproper-extension) of-~0 and the following condition is satisfied: Each rewrite rule 1 ~ r ERl satisfies the following condition: (H2): For every subterm s of r, if root(s)E (D O- D ) , then s contains no function symbol (in Do tO D °) depending on Do except at the outermost level (of s). This condition essentially says that the nesting of defined symbols from (D O - D ) is not allowed on the right-hand side terms of rules and no symbol from Do occurs below (Dr1~-D)-symbols. The following example shows that the class of (generalized) nice-extension* is a proper subclass of (generalized) proper-extension*.
Example 7. The following system -~l is a (generalized) proper-extension* of J¢o. .~0 : add(0, x) ---~x add(S(x), y) -* S(add(x, y))
•~I : mult(O,x) --+ 0 mult(S(x),y) -*add(y, mult (x, y)) fact(0) ~ 1 f a c t ( S ( x ) ) ---~mult(S(x), f a c t ( x ) )
However, -~t is not a (generalized) nice-extension* of-~0; notice the occurrence of the function f a c t (which depends on Do) below function mult in the last rule violating condition H 1. Remark. Introduction of so many classes of combinations is justified as follows. The notion of hierarchical combinations is very natural from a programming point of view as one defines new functions in terms of the already defined functions. The need to allow sharing of rewrite rules (and hence defined symbols) arises in the analysis of systems, particularly while analyzing for the properties such as innermost normalization and confluence as explained above. We call the combinations sharing defined symbols such that the (non-shared) defined symbols of one system occur as constructors (or built-ins) in the other system but not vice versa, also as hierarchical combinations as the basic idea - some of the functions defined in one system are used as built-in
498
M.R.K. Krishna Rao/ Theoretical Computer Seiem'e 151 (1995) 487-512
functions (constructors) in the other system - is the same. The notion of superhierarchical combinations may look artificial at the first glance. However, one can be easily convinced about the practicality of super-hierarchical combinations by just looking at the following rewrite rules derived by the Knuth-Bendix completion procedure from the group axioms. Another motivation for introducing the notion of superhierarchical combinations is to characterize the largest class of combinations for which our techniques apply. This class is given a new name, super-hierarchical combinations, as it properly includes the class of hierarchical combinations and the defined symbols of ~ l are allowed to occur in -~0 as constructors (which is beyond the scope of hierarchical combinations). Example 8, The following system is a subsystem of the canonical term rewrite system derived by the Knuth-Bendix completion procedure from the group axioms. (x + 0) ~ x (x + i ( x ) ) ~ 0
i(x+y) ~ i(x)+i(y) i(i(x)) ~ x i(o) ~
0
If we want to study properties of this system in a modular fashion, it has to be divided into the following two systems. •~ o : (x + 0)--~ x
.9, : i(i(x))--* x
(x + i ( x ) ) --, 0
i(O) ~ 0 i(x+y) -~ i(x)+i(y)
This combination is not hierarchical as the defined symbol i o f - ~ l occurs on the left-hand sides of .~2o. But it is a super-hierarchical combination. The following lemma characterizes the rewrite rules on generalized nice-extension*s. Lemma 13. I f :~ i is a generalized nice-extension* o f .~Ao then f o r each rule l ~ r E R I, r is o f the f o r m C[tl . . . . . t,], where C E C ~ , r o o t ( t i ) E ( D ° - D) and tiE)--I, 1 <~i<~n (n >t 0). Further, no proper subterm o f ti contains any function symbol depending on Do. Proof. Follows from the condition (H2) of Definition 12.
[]
Example 9. It is easy to see that the following system is 3¢1 a nice-extension* of J¢0.
:~o : b--+ c
-~1 : a ----~b ~(x) ~ h(~(e)) f(x) ~
a
h(x) --+ d
M. R.K. Krishna Rao / Theoretical Computer Science 151 (1995) 487-512
499
Here, Do = {b}, Co = {c}, D, = {a, f , h}, C, = {b, c, d}, D I = {h}, D o = {a, f} and Constr = {c, d}. The right-hand sides of-~l are of the above form; (i) b E Do and d E Constr are contexts (without any [~) in rd~, (ii) h ( f ( c ) ) ~ C[f(c)], where C _= h([]) is a context in ~ and (iii) a =C[a], where C is a trivial context (i.e., =]) in ~ . Before proving the results about the modularity of completeness of hierarchical combinations (nice/proper-extension*s), we point out that the following property: 't =~* t ~ implies rank(t)>~rank(t')' is not valid in hierarchical combinations, as the example given below illustrates. This contributes to the difficulty in proving the modularity results for hierarchical combinations. Now, we define the notion of rank of a term.
Definition 14. Let path(t) denotes the set of paths from root to leaves in the tree representation of term t. Each path is a list of symbols ending in a variable or a constant. The rank of a path is the number of alternations of Do symbols and DI symbols (forgetting the other symbols) plus 1. The rank of a term t is the maximum rank of its paths. Rank of a term is basically a measure of layer structure of Dj symbols and Do symbols in the given term. Example 10. Consider example 6 again. Term mult(S(x),y) has rank 1 and can be rewrit'.en by the second rule in -#l to the term add(y, mult(x, y)), which has rank 2.
5. Innermost normalization In this section, we establish that strong innermost normalization (SIN) is modular for generalized nice-extension*s. We first prove that strong innermost normalization (SIN) is modular for a proper subclass of generalized nice-extension*s, called crosswise independent unions, where defined symbols of one system do not depend on the defined symbols of the other system. Then we establish the result for the whole class of generalized nice-extension*s as follows: (i) we identify a set 6 p of terms of a special form, (ii) show that ~0 U ~ is strongly innermost normalizing (over all the terms) if and only if it is strongly innermost normalizing over the set ~5a and then (iii) show that -~0 U.~l is strongly innermost normalizing over the set 5e. Throughout this section, (a) -~.i denotes . 5 ~ , i ( D i ~ D , Ci,Ri), (b) -~0, the subsystem "~/i = {1 ~ r lroot(l ) E (D I UD)} and .~l are strongly innermost-normalizing and (c) ~ l is a generalized nice-extension*s of -~0. 5.1. Innermost normalization o f crosswise independent unions In this subsection, we study modularity of strong innermost normalization (SIN) for crosswise independent unions. The notion of crosswise independent unions is a generalization of (i) constructor sharing unions, (ii) composable unions and (iii) Piump's crosswise disjoint unions.
500
M.R.K. Krishna Rao I Theoretical Computer Science 151 (1995) 487-512
Definition 15. We say that two term rewriting systems .~o(Do~D, Co, Ro) and ~I(DI D, C1,Rt) are crosswise independent if (i) R0 MRt = {1 ---* r l r o o t ( l ) E D } and (ii) f ~d .qJbr each f E D i UD and ,qcDI_ i, where iE{0, 1}. We say that .~0U~j is a crosswise independent union if :~lo and ~j are crosswise independent. In crosswise independent unions, the non-shared defined symbols of one system do not appear on the fight-hand sides of the other system, but they may appear in the left-hand sides. It is useful to note that the above definition implies (a) Do A Dt = and (b) .f ~d 9 for each f E D and g E (Do U D1 ). The following lemma is a characteristic of crosswise independent unions. Lemma 16. If .¢~o and .~l are crosswise independent term rewriting systems and t & a term such that no subterm (say, s) of t with root(s)EDi is reducible by -~o U .~l, then t ~ *.~1 -i t' implies that no subterm (say, s ~) o f t ' with root(sl)EDi is reducible by :~o U.~t for iE{O, 1}. Proof. Follows from the fact that the symbols from Di do not occur on the fight-hand side terms of :~l-i. [] In fact, we can replace 3 " •~'l - i by ~ *.#oU.~l in the above lemma as the condition that no subterm (say, s) of t with root(s)EDi is reducible by .@oU-@,l implies that no rule from {l --~ r I root(l)GDi} is applicable on any term derived from t. Lemma 17. If :~o and ~ l are crosswise independent term rewriting systems and t is a term such that no subterm (say, s) of t with root(s)EDi is reducible by #lo U .~t, then t ~ *•~ ' o U ..~ i t' implies that no subterm (say, s t) o f t ' with root(sl)EDi is reducible by -~0 U ?At for iE[O, 1]. The following theorem establishes the modularity of stron 9 innermost normalization (SIN) for crosswise independent unions.
Theorem 18. If :~o and ;$t are crossw&e &dependent strongly innermost normalizing (SIN) term rewritin,q systems, then #A0 U-~l is stronoly innermost normalizin9 too. Proof. Induction on term structure. Basis: It is obvious that there is no infinite innermost derivation starting from any constructor symbol of arity 0 (constant). Strong Innermost normalization of a defined symbol in Di U D of arity 0 follows from the strong innermost normalization of-~i (remember that no function symbol in Di-i is reachable from a term in J-(Di U D U G,.~)). Induction step: Consider a term t ~ f ( q . . . . . tn). By induction hypothesis, each t~ is strongly innermost normalizing. Then by K6nig's lemma, there can be only a finite
M.R.K. Krishna Rag~Theoretical Computer Science 151 (1995) 487-512
501
number of innermost reduction steps before the reduction at root (i.e., at f ( . . . ) ) takes place. Therefore, if there is an infinite innermost derivation from t, there must be an infinite innermost derivation from t' - f ( t ' l ..... t'), where each t~ is a normal form derived from tk, k E [I,n] using an innermost derivation. Now, we have three cases. 1. If f is a constructor, it is obvious that t' is a normal form and the theorem holds. 2. If f E D, no rule from {l --~ r [ root(l) E (Do U DI )} is applicable on any term derived from t', by Lemma 17. From this it follows that t' is strongly innermost normalizing. 3. If f E Di, i E [0, 1], no rule from {l --~ r [ root(l) E Dr-i} is applicable on any term derived from t', by Lemma 17. The strong innermost normalization of t' follows from the strong innermost normalization o f .~. Therefore, -~0 U :~l is strongly innermost normalizing. []
5.2. Innermost normalization o f nice-extensions Now, we consider strong innermost normalization of generalized nice-extension*s. We identify a set .5a o f terms o f a special form and show that :~0 U-~l is strongly innermost normalizing (over all the terms) if and only if it is strongly innermost normalizing over the set ,5a. Definition 19. Let ,5a be the set o f all terms o f the form C[st . . . . . sn], C E ~ , n~O such that for all i E [ l, n] (i) root(si)E(D ° - D) and (ii) if u is a proper subterm of si and root(u)E (Do U D °) then u is not reducible by -~0 U -~j. Condition (ii) implies that no rule from {1 ~ r l r o o t ( l ) E Do} is applicable on si and si contains no reducible proper subterms with root-symbol depending on Do. This ensures the following property: there are no two different positions p and q in a term tE.5 a such that (i) root(tlp)E(D ° - D ) and tip is reducible, (ii) root(tlq)E(D ° - D ) and tlq is reducible and (iii) p is above q or q is above p. That is, (D O - D ) symbols are not nested above any redex. In view o f this property, we call ,~, the set of single layered terms. Further, .Se is closed under =~aoU.~,. Now, we prove that -"~oU-~.l is strongly innermost normalizing (over all the terms) if and only if it is strongly innermost normalizing over ,5a. Theorem 20. l f :~l is a generalized nice-extension* o f .Yi.o, then the comb&ed system .~o U .~l is strongly innermost normalizing if and only if it is strongly innermost normalizing over ,~. Proof. The only-if part follows from the definition o f the strong innermost normalization (SIN) property of rewrite systems. The if-part is proved by establishing that every term is strongly innermost normalizing using induction on term structure.
502
M.R.K. Krishna Rao I Theoretical Computer Science 151 (1995) 487-512
Bas&: It is easy to see that every constant (in the signature, D U Do U Dt U Co U Ct ) is an element o f ,9~. Hence every constant is strongly innermost normalizing. Induction step: Consider a term t - f ( t l . . . . . t,). By induction hypothesis, each ti is strongly innermost normalizing. By KBnig's lemma, there can be only a finite number o f innermost reduction steps before the reduction at root (i.e., at f ( . . . ) ) takes place. Therefore, if there is an infinite innermost derivation from t, there must be an infinite innermost derivation from t' =- f(t~ . . . . . t'), where each t: is a normal form derived from ti, 1 <~i <~n using an innermost derivation. Now, we show that t t is an element in ST, thereby establishing its strong innermost normalization and hence stron9 innermost normalization o f t. Since each t[ is a normal form o f ~0 U :#z, it is obvious that t i e ,5: if f E (D O- D ) . That is, t I is of the form C[s], where C is the trivial context ([53) and s - t t. If f (D O - D ) , let sl . . . . . Sm be the maximal subterms (from left to right) in t t such that root(s~) E (D O - D ) , l<~j<~m. That is, t ~ can be written as C[sl . . . . . Sin] such that CEcg~ and r o o t ( s / ) E ( D ° - D ) . It is obvious that each Si is a subterm o f some t: and hence a normal form o f :~0 U ~ l . Therefore, t ' E ,9°. []
5.3. Innermost normalization o f .~o U .~l over .9~ In this subsection, we prove that :~0 U.~l is strongly innermost normalizing over ,9°, using a result on abstract reduction systems (ARS). First, we prove that ~9° is closed under ~.#oU.~¢, • The following lemma establishes that .~ is closed under ~.~,. The proof can be intuitively explained as follows. The reductions in C does not create any new (D o - D ) symbols and hence cannot increase the nesting o f (D o - D ) symbols. The reduction at the root o f any si does not increase the nesting o f (D o - D) symbols by condition H2 o f Definition 12. The reduction in a proper subterm o f si does not create any new ( D ° - D ) symbols and there is no nesting o f ( D ° - D ) symbols above this redex position (by Definition 19). Therefore, it can only result in a term in ,~.
Lemma 21. I f t E . ~ and t =~.#, t' then fiE.9 ~ too. Proof. By Definition 19, the term t is o f the form C[sl . . . . . s,], n~>0 with C E ~ and for all i E [I,n], si satisfying the above properties. Let l --, r E RI and a be the rule and the substitution respectively applied in the reduction step t =~a, t'. There are two cases: (a) r o o t ( l ) ~ ( D ° - D) and (b) r o o t ( l ) E ( D ° - D). Case (a): root(l) ff/ (D ° - D). That is, root(l) E D I U (D N DO). There are two subcases. ( l ) The reduction took place in C. By definition, no function symbol from (D o - D ) occurs in r and hence, t' is o f the form C'[tl . . . . . tin], C t E ~ , root(t/)E (D o - D) such that each ti is a (not necessarily proper) subterm of some Si. The lemma holds. (2) The reduction took place in a proper subterm o f some si and t p -C[sl . . . . . si-l,s~,si+l . . . . . sn]. In this case, by Definition 19, root(l) cannot be from
M. R K. Krishna Rag/Theoretical Computer Science 151 (1995) 487-512
503
D O and hence r o o t ( l ) E D I. Let si be of the form CI[Ul . . . . . urn] such that root(ui)E (DoUD °) and no symbol from ( D o U D °) occurs in Ci except at the root. By Definition 19, each Uk is irreducible. Since no function symbol in (Do U D °) occurs in r, s i' is of the form C~[vl . . . . . Vm'] such that root(v~)E (Do U D °) and no symbol from (Do U D °) occurs in C~ except at the root. Further, each v/ is a subterm of some uk and hence vi is irreducible. The lemma holds. Case (b): r o o t ( l ) E ( D ° - D ) . In this case, the reduction should take place at the root of some si. It follows from Lemma 13 and irreducibility o f proper subterms (with root in (Do U D ° ) ) o f si that r a is of the form C'[u~ . . . . . u,], f r e e 6 ~l, r o o t ( u i ) E ( O 0 - - D ) such that no proper subterm (say, s) o f ui, l ~ i < ~ m with r o o t ( s ) E (Do U D o ) is reducible by -~0 U .~l. It is easy to see that t ~ - C[s~ . . . . . s i - l , r a , si+l . . . . . sn] can be written as C"[vl . . . . . Vm+,,-l], C" Ergoj, r o o t ( v i ) E D ° such that no proper subterm (say, s) of vi, 1 < ~ i < ~ m + n - l with r o o t ( s ) E ( D o U D °) is reducible by -~oU.~l. The lemma holds. [] The case (b) o f the above proof is the technical origin of our condition H2 in Definition 12. The following lemma establishes that ,9~ is closed under =~.¢o.
Lemma 22. I f t E ,5a and t ~.~o t' then t' E ,~ too. Proof. Let 1 ~ r E R0 and tr be the rule and the substitution respectively applied in the reduction step t :=~o t'. If r o o t ( l ) E D , this rule is also in .~'~ and lemma holds in this case by the above lemma. Let us now consider the case root(l)ED0. By Definition 19, the term t is o f the form C[sl . . . . . sn] with CECgo1, r o o t ( s i ) E ( D ° - D ) for all i E [ l , n ] and the reduction must take place in C. Since no function symbol from (D O - D ) occurs in r, it follows that t t is o f the form C'[h . . . . . tm], C ' E ~ , r o o t ( t i ) E ( D ° - D ) such that each ti is a subterm of some s i. The lemma holds. [] Now, we establish that :~¢oU:~t is strongly innermost normalizing over terms in ~5e. This is done using a result on strong normalization and quasi-commutation of abstract reduction systems (ARSs). We need the following definition.
Definition 23. Let ---~o and ---~t be two relations on a set S. We say, relation ---*l quasicommutes over relation ---~o if f o r all terms s,u, t E S with s --*o u --~ t, there exists a term y E S such that s --~l v ---~l t. (---~1 is transitive-reflexive closure of ---~0 U --~l). The importance o f quasi-commutation can be seen from the following theorem o f Bachmair and Dershowitz [ 1].
Theorem 24. I f the relations ---*o and ~ i & an A R S (A, ---~o,--~ I ) are strongly normalizin9 and --q quasi-commutes over --~o, the relation --*o U --*t is strongly normalizing lo0.
Henceforth, abstract reduction system ~1 stands for the following.
504
M.R.K. Krishna Rao / Theoretical Computer Science 151 (1995) 487-512
Definition 25. We define abstract reduction system ,~¢ as ,~¢ -= (~9~,---~o,---'1), where --*i are the binary relations over ,9° defined as follows. Let s = C[sl . . . . . s,] be a term in ,9° such that C E c£~ and r o o t ( s i ) E (D O - D ) for each i E [I,n]. Then (a) s ---~0 t /f s =::'.Jcou~¢. t is an innermost reduction step and the reduction took place in C and (b) s ---q t i f s ~ ~¢ou.~ t is an innermost reduction step and the reduction took place in one o f the s u b t e r m s sl . . . . . s,. The relation ---~oU ---~1 is precisely the innermost reduction relation over ,5: of -~,0 U ~ l . The following lemma establish that ---~0 and ---~ are strongly normalizing relations. Therefore, to establish the strong innermost normalization o f - ~ 0 U :~¢~ over ,9°, it is enough to prove that the relation ---~l q u a s i - c o m m u t e s over the relation ---~0 in ARS ,~¢. Lemma 26. In A R S ~¢, the relations ---~o a n d ---~1 are strongly normalizing. Proof. Let s - C[sl . . . . . sn] be a term in ,9: such that CECg~ and r o o t ( s i ) E ( D ° - D ) for each i E [l,n]. By the definition of ,9:, no rule from {l ~ r [ r o o t ( l ) E Do} is applicable on si. Therefore, relation ---*l is a subrelation o f the innermost reduction relation o f term rewriting system .~l and hence strong normalization o f --~l follows from strong innermost normalization o f .~1. Now consider the subsystem -~'1 = {l --* r E . ~ t l r o o t ( l ) E (D I U D)}. It is easy to see that -~o and .)t'I are crosswise independent and hence .~o U ~ is strongly innermost normalizing by Lemma 18. From the definition of c~, it is easy to see that the relation -~0 is a subrelation o f the innermost reduction relation o f term rewriting system .~0 U "~'l and hence strong normalization of -~0 follows from strong innermost normalization of :~0 U .°)t't . [] From this lemma, it is clear that, to establish the innermost normalization of-)t0U.~tl over 5 a, it is enough to prove that the relation ---~ q u a s i - c o m m u t e s over the relation 4 0 in ARS ,~. Theorem 27.
In A R S , ~ , the relation ---~t quasi-commutes over the relation --*o.
Proof. We have to prove that f o r all terms s,u, t E , 9 ~ with s -*o u -'-~1 t, there exists a term v E , 9 ~ such that s - ' 1 v -*or t. Consider a term s - C[sl . . . . . sn] E,9 ~. Since s -~0 u, term u is o f the form C'[tl . . . . . tin], C ' E ~ , r o o t ( t i ) E ( D O - D ) such that each ti is a subterm of some s/. Since u --~j t, term t =- C'[h . . . . . t~. . . . . tin] (that is, tk :::~.~¢, t~). Now, assume that tk is a subterm o f sk,. Then s - C[sl . . . . . s,] E ,9° can be reduced to v - C[sl . . . . . sk,-t,s'k,,sk,+l . . . . . sn]E .9° (reduce the subterm tk in sk,). That is, s ~ t v. Let p and q be the positions at which two reductions s ::~ u and s ~ v took place. Since sk is reducible and the reduction s =~ u is innermost reduction (by the definition of--~o), p is not above q. Since p is in C and q is in sk, it is obvious that p is not below q. That is, p and q are disjoint positions. From the following diagram, it becomes clear that v ---~o t establishing that 4--.1 q u a s i - c o m m u t e s over ---+o. []
M.R.K. Krishna Rag~Theoretical Computer Science 151 (1995) 487-512
505
B
It may be noted that ---*o does not quasi-commute over ---~ as illustrated by the following example. The quasi-commutation o f - - n over ---~0 (and the absence of quasicommutation o f ---~0 over ---'l ) can be intuitively explained as follows: a ---~0-step does not create a new ---~-step whereas a ---~-step can create a new --*0-step. Example 11. Consider example 6 again. It is easy to see that s - - a d d ( m u i r ( y , 0 ) , x ) ---~tu-- add(0, x)---*0t-- x, but there is no v such that s ---*0 v --~l t. In fact, s is not reducible by .~0. Therefore, ---~0 does not quasi-commute over -"~
I •
Strong.innermost normalization o f - ~ 0 a - ~ l theorems.
over ,5a follows from the above two
Theorem 28. The combined system .~'0U.~fl is strongly innermost normalizing over ,fie. Now, we are in a position to state one of the main results o f the paper.
Theorem 29. I f .~o and .~l are two strongly innermost normalizing systems such that .~l is a generalized nice-extension* of-~o, then the combined system .~¢oU.~t is strongly innermost normalizing too. Proof. Follows from the above theorem and Theorem 20.
[]
6. Completeness of nice-extensions In this section, we study modularity of completeness nice-extension*s. Unlike strong innermost normalization, for the whole class of generalized nice-extension*s as examples, o f Kiop and Barendregt [27] and Drosten [4]
for the class completeness demonstrated (see Example
of generalized is not modular by the counter 2) - note that
506
M.R.K. Krishna Rao / Theoretical Computer Science 151 (1995) 487-512
the classes of direct-sums, constructor sharing unions and composable unions are subclasses of generalized nice-extension*s. The best result known about the modularity of completeness for composable unions is that completeness is modular for overlay systems. Now, we consider overlay systems and show that this result extends to the class of generalized nice-extension*s. By definition, every complete system is terminating and hence strongly innermost normalizing. In the previous section, we established the modularity of strong innermost normalization for the class of generalized nice-extension*s. Therefore, completeness of :~?0U-~t follows from Theorem 4, if we can establish local confluence of-~?o U-~?l. Lemma 30. I f .~¢o and .~l are two locally confluent systems such that (i) .~1 is a generalized nice-extension* o f :~o and (ii) :~¢oU .~1 is a overlay system then the combined system -~¢0U-~l is locally confluent. ProoL According to critical pair lemma, it is enough to prove that every critical pair is convergent. Since each ?~i is locally confluent, all the critical pairs obtained from overlapping of the left-hand sides of rules in ~i are convergent. So, we only have to prove convergence of critical pairs obtained from overlapping of the left-hand side of a rule in ~-'~i with the left-hand side of a rule in :~1-i, i E {0, l}. Since -~o U :~l is a overlay system, overlapping is only possible at the topmost level and since DoNDj ----(a, no overlapping is possible between the left-hand sides of {l --* r C :~i I root(l) E Di} and the left-hand sides of {l -~ r E . S l _ i l r o o t ( l ) c D l _ i } . Overlapping is possible only between the rules defining the symbols in D. Since the rules defining these symbols are the same in both the systems, these critical pairs are included in the critical pairs of individual components and hence are convergent. Therefore, ~0 U-~t is locally confluent. []
Now we state the main result of this section. Theorem 31. I f :~o and :~l are two complete systems such that (i) .~l is a generalized nice-extension* o f :~0 and (ii) :~o U .~l is a overlay system, then the combined system :~0 U :~'l is complete too.
Proof. Follows from Corollary 1, Theorem 29 and Lemma 30.
[]
This result is a generalization of the main result in [19]. The main result in [19] says that the composable union :80 U.~I of two constructor systems ~o(D0 t~D, C0,R0) and -~l(Di t~ D, CI,RI ) is complete if .~?0 and -~l are complete. By the composability restriction, it easily follows that none of the defined symbols in DI depend on Do and all the rules in : ~ obviously satisfy condition H2 of our Definition 12. Therefore, the above result is a generalization of the main result in [19]. For example, results of [19] are not applicable for the following set of rewrite systems as well as the rewrite systems given in Example 6.
M.R.K. Krishna Ruol Theoretical Computer Science 151 (1995) 487-512
507
Example 12. It is easy to see that the following two rewrite systems are complete.
-90: apnd(nil,y) -~ y .91: rev(nil) --+ nil apnd(c(x, xs ),y) --+c(x, apnd(xs, y) ) rev(c(x, xs )) --~apnd(rev(xs ),c(x, nil )) Using our result, we can establish the completeness o f - ~ 0 td : ~ whereas the result o f [19] is not applicable because the symbol apnd defined in .~80 is used as constructor in :~t. The following example demonstrates that we cannot weaken our condition H2 (in Definition 12) to 'For every subterm s o f t , if root(s)ED ° then s contains no function
symbol of Do except at the outermost level (of s)'. Example 13. It is easy to see that the following two systems ::~0 and -;Jl are com-
plete. •80 : f ( x ) ~
x
.~1 : g(Y) ---' f ( y ) h(a) ~ h ( g ( a ) )
To wit, the combined system has a cyclic derivation: h(a) ~ ,
h ( g ( a ) ) = ~ , h ( f ( a ) ) =~,¢o h ( a ) . - .
The above theorem is a generalization 2 o f the main results of Krishna Rao [9] and Dershowitz [2]. 3 The main result o f Dershowitz can be stated as follows.
Theorem 32. Let :~¢o and .~l be two complete overlay systems ( OS) such that 1. defined symbols of the two systems are disjoint, i.e., Do fq DI = ok; 2..~ll is fiat, i.e., no nesting o f defined symbols are allowed on the left and the right-hand-sides o f rewrite rules in ;~¢1; 3. defined symbols o f J¢o do not occur on the left-hand-sides o f rewrite rules in .~; 4. if t is a subterm o f the right-hand side o f a rewrite rule in .~1 such that root(t)E Di then no defined symbols o f - ~ o occur in t. Then the combined system :~2oU .~1 is complete too.
Remark. The main advantages o f our result over that o f Dershowitz is that we do not need flatness condition (we also do not need the above condition 3). This gives the following two additional advantages: (a) The flatness requirement means that Theorem 32 is not a generalization o f the known results (in particular, o f [19]),
2 In [8], no distinction is made between DO (defined symbols of .81 depending on Do) and D I (symbols not depending on Do) and (weaker) precondition root(s)E Dt is used in condition (H2) instead of the present precondition root(s) E D°. 3 The results of [8, 2] are obtained independently and contemporaneously.
508
M.R.K. Krishna Rao I Theoretical Computer Science 151 (1995) 487-512
whereas our result is a generalization of the known results. (b) Theorem 32 cannot be extended to many hierarchies as our result will be extended in the next section. In a revised version of [2], Dershowitz proposed some results orthogonal to our results on hierarchical combinations.
7. Completeness of proper-extensions In this section, we extend the results of the previous sections for the class of generalized proper-extension*s. Our approach is to relate the notions of generalized niceextension*s and generalized proper-extension*s and use induction. To relate the notion of generalized proper-extension* with generalized nice-extension*, we need the following definition.
Definition 33 (Equivalence relation ~ over (D O - D )
and partial order --3 over the equivalence classes). From the dependency relation, ~d (see Definition 6) of-~1, we define 1. Equivalence relation ~ ( f ,~ g if f ~d g and g ~d f ) on the set of defined symbols (D O - D ) . We denote the equivalence class containing f by [f]. 2. Partial ordering 3 ( [ f ] Z [ g ] if f ~d g and 9 ~d f ) on the set of equivalence classes.
Assumption. In the following we assume that the relation 5 on (D o - D ) is noetherian. Since signature of any term rewriting system is a countable set, the equivalence relation ~ partitions (D o - D ) into a countable set E of equivalence classes and this partition is called stratification. Since relation Z is noetherian, one can easily extend it to a well-ordering of order type )., where )~ is a countable ordinal.
Notation. For any ordinal ~, we denote the ctth element in the above well-ordering by E~ (for all ordinals ~t > 2, we let E~ = ~b) and the rewrite system {l --* r E R l l r o o t ( l ) E (D U DII U E~)} by R~ and the combined system (Up<~ R/I)U-~¢0 by S~. In particular, So is .~o and S~. is .N0 U -~¢t for any ordinal x above 2. The following theorem relates generalized proper-extension*s with generalized niceextension*s. Theorem 34. Let ,~,o and J~l be two term rewriting systems such that .~1 k a 9eneralized proper-extension* o f .No and -q is noetherian. Then R, is a generalized nice-extension* of S~ for every ordinal ~, where R~ and S~ denote the objects explained in the above notation. Proof. It is easy to see that the first two conditions in the definition of generalized nice-extension* (see Definition 12 and 11) are satisfied by R~ and S~. To prove condition 3, we have to prove that every rule l ~ r in R~ satisfies the following: if s is
M.R.K. Krishna Rao/ Theoretical Computer Science 151 (1995) 487-512
509
a subterm of r such that root(s)E E~, then no proper subterm of s contains any defined symbol depending on ( D e f ( S ~ ) - Def(R~)), where Def(R~) and Def(S~) are the sets of defined symbols of R~ and S~ respectively. Since root(s) E E~, it follows from the definition of the above equivalence relation, that root(s) ~-d root(1). Since (i) ~ l is a generalized proper-extension of-~'0, (ii) l ~ r E Ri, (iii) root(s)E D O and (iv) root(s) ~-d root(l), it follows from the definition of generalized properextension*s that no proper subterm of s contains any defined symbol depending on Do. Since ( D e f ( S ~ ) - Def(R~))c(Do U DO), any function symbol depending on ( D e f ( S ~ ) - Def(R~)) also depends on Do. Hence no proper subterm of s contains any defined symbol depending on ( D e f ( S ~ ) - Def(R~)). Therefore, R~ is a generalized nice-extension* of S~. [] Now, we are in a position to establish the main result of the paper. Theorem 35. I f .~?o and :~t are two complete systems such that (i) -~l is a generalized proper-extension* of :C#o, (ii) -~0 U ~1 is a overlay system and (iii) ~ is noetherian, then the combined system -~0 U -~?l is complete too.
Proof. Proving local confluence of the combined system -~0 U-~'l is again easy as in Lemma 30. Therefore, completeness of ~o U :El follows if we can establish its strong innermost normalization. We establish this by showing that S~ is strongly innermost normalizing for each ~ using transfinite induction. Basis: ~ -- 0. By assumption So = -~0 is (complete and hence) strongly innermost normalizing. Induction: There are two cases: (a) ~ ¢ 0 is a successor ordinal a n d ( b ) ~ ¢ 0 i s a limit ordinal. Case (a): Let :t = fl + 1. By definition, S~ = S# U R#. By the above theorem, R# is a generalized nice-extension* of S#. Since R# is a subsystem of-~'t, it is (strongly normalizing and hence) strongly innermost normalizing and S# is strongly innermost normalizing by induction hypothesis. Therefore, S~ = S# U R# is strongly innermost normalizing by Theorem 29. Case (b): ~t is a limit ordinal. By definition, S~ = U#<~ s#. By induction hypothesis, each S# is strongly innermost normalizing. We show that every term t is strongly innermost normalizing under S~. Since the set of function symbols occurring in t is finite, there exists a fl < :t such that every function symbol in D e f ( S ~ ) n F(t) is in E;.. Therefore, strong innermost normalization of t follows from strong innermost normalization of S#. []
U,.~<#
Since relation 3 is noetherian for any finite system, we have the following. Corollary 36. I f S~o and .El are two finite complete systems such that (i) :~t is a generalized proper-extension* of .~o, and (ii) :~0 U #¢1 is a overlay system, then the
combined system #¢o U .El is complete too.
510
M.R.K. Krishna Rao / Theoretical Computer Science 151 (1995) 487-512
Remark. It may be noted that the relation between the generalized proper-extension*s and the generalized nice-extension*s established in Theorem 34 does not hold between the proper-extensions and the nice-extensions as illustrated by the following example. That is, a proper-extension cannot be seen as a sequence o f nice-extensions. However, a generalized proper-extension can be seen as a sequence o f generalized nice-extensions. Example 14. Consider the following two systems. -~0:
~(x)~c(x)
~, : g2(c(x)) ~ g,(g2(h(x)) g~(x) ~ h(~(x)) h(x) ~ x
The system .~l is a proper-extension (but not a nice-extension) o f the system -~0. The dependency relation suggests the following stratification: Eo = {gl } and El = {g2}. Now, Si is { f ( x ) ~ c(x), gt(x) ---, h ( f ( x ) ) , h ( x ) --~ x} and Ri is {g2(c(x)) ---* gt(g2(h(x)), h(x) ~ x}. It is easy to see that Rj is not a nice-extension o f $1 as they share a defined symbol, h. Further, it is not possible to remove h(x) ~ x from either St of Ri. That is, !. Ri -- {h(x) --, x} is not a nice-extension o f Si as h is occurring below g2 on the right-hand-side o f the rule in Rl - {h(x) ~ x} and 2. Rt is not a nice-extension o f S~ - {h(x) ~ x} because the combination is first o f all not hierarchical as Si - {h(x) ~ x} uses h (defined in Rt) as constructor and Ri uses gl (defined in Si - {h(x) ~ x}) as constructor. Therefore, it may not be possible to see a proper-extension as a sequence o f niceextensions. [] Remark. In the above example, the main reason for the inability to view the properextension as a sequence o f nice-extensions is the presence o f functions in Dlt. If D I = ~b, a proper-extension can indeed be seen as a sequence o f nice-extensions - note that S~ and R~ do not share defined symbols and rewrite rules for each ct, in this case.
8. Conclusion The study o f modular aspects is very important in an incremental synthesis of programs and systems. If two systems Sj and $2 satisfy a property P and P is known to be modular, one can infer that P is satisfied by the union o f S1 and S~ without giving a separate proof. This is very important because most of the properties o f rewrite systems are intractable. The modularity results o f direct-sums can be used when two subsystems are defined over different domains, e.g. one on natural numbers and other on lists. The modularity results o f constructor sharin9 unions can be used when two subsystems define two independent functions (none of the two systems use the procedures defined in the other system) over some domain. The modularity results of hierarchical combinations can be used if new procedures (i.e., second system) use the
M. R.K. Krishna Rao / Theoretical Computer Science 151 (1995) 487-512
511
procedures defined in the other (first) system. This is the most important situation and these results are of great practical significance. In this paper, modular aspects of hierarchical combinations are investigated. We identified a class of hierarchical combinations for which completeness property is modular. Our result generalizes the main result of Middeldorp and Toyama [19]. The nontriviality of the result can be seen from the fact that the techniques employed in getting the modularity results over direct-sums and constructor sharing systems are not applicable in the case of hierarchical combinations as a reduction in hierarchical combinations can increase rank of a term. It would be interesting to extend our results for conditional term rewrite systems. Our investigations in this direction are presently at a very preliminary stage. Modularity of simple termination, weak normalization and semi-completeness of hierarchical combinations has been studied in [10, 11]. Though the classes of combinations considered in [10, !I] are comparable to the classes considered in this paper, the techniques applied/needed there are very different from the techniques used in this paper.
Acknowledgements The author gratefully acknowledges the discussions he had with Aart Middeldorp, Jan Willem Kiop, Nachum Dershowitz, Fred Otto, Enno Ohlebusch, Stefan Kahrs and Narayan Kumar. The author is grateful to the referees for many suggestions in improving the presentation very much.
References [I] L. Bachmair and N. Dershowitz, Commutation, transformation and termination, in: Proe of CADE'8, Lecture Notes in Computer Science, Vol. 230 (Springer, Berlin, 1986) 5-20. [2] N. Dershowitz, Hierarchical termination, draft, Hebrew University, Dec. 1992. Revised version to appear in Proc. CTRS'94, Lecture Notes in Computer Science (Springer, Berlin) to appear. [3] N. Dershowitz and J.-P. Jouannaud, Rewrite systems, in: J. van Leeuwen, ed., Handbook of Theoretical Computer Science, Vol. B (North-Holland, Amstredam, 1990) 243-320. [4] K. Drosten, Termerset:unyssysteme, Informatik-Fachberichte, Vol. 210 (Springer, Berlin, 1989). [5] B. Gramlich, Relating innermost, weak, uniform and modular termination of term rewrite systems, in: Proc. of Loyic Proy. and Automated Reasoning, LPAR'92, Lecture Notes in Computer Science Vol. 624 (Springer, Berlin, 1992) 285-296. Revised version to appear as Abstract relations between restricted termination and confluence properties of rewrite systems in a special issue of Fundamenta lnformatice on TRSs. [6] B. Gramlich, Generalized sufficient conditions for modular termination of rewriting, in: AAECC (Applicable Algebra in Engineering, Communication and Computing) 5 (1994) 131-158. Preliminary version in Proc of ALP'92, Lecture Notes in Computer Science Vol. 632 (Springer, Berlin, 1992) 53~8. [7] J.W. Klop, Term rewriting systems, Tech Rep. CS-R9073, CWI, Amsterdam. Also appears as a chapter in S. Abramsky, D. Gabbay and T. Maibaum, ed., Handbook of Loyic in Computer Science, Vol. 2 (Oxford Press, Oxford, 1992). [8] M.R.K. Krishna Rao, Modular proofs for completeness of hierarchical systems, Technical report, TIFR, Bombay, December 1992.
512
M.R.K. Krishna Rao/ Theoretical Computer Sctlence 151 (1995) 487-512
[9] M.R.K. Krishna Rao, completeness of hierarchical combinations of term rewriting systems, in: Proc.
o/ 13th Conference on Foumlations of St~]hrare Technology and Theoretical Computer Science. FST&TCS'93, Lecture Notes in Computer Science, Vol. 761 (Springer, Berlin, 1993) 125-138. [10] M.R.K. Krishna Rao, Simple termination of hierarchical combinations of term rewriting systems, in: Proc. t~' Theoretical Aspects of Computer Science, TACS'94, Lecture Notes in Computer Science Vol. 789 (Springer, Berlin, 1994) 203-223. [ll] MR.K. Krishna Rao, Semi-completeness of hierarchical and super-hierarchical combinations of term rewriting systems, in: Proc. t~" Theory and Practice t~" So[hrare Development, TAPSOFT'95, Lecture Notes in Computer Science, Vol. 915 (Springer, Berlin, 1995) 379-393. [12] M.R.K. Krishna Rao, D. Kapur and R.K. Shyamasundar, A Transformational methodology for proving termination of logic programs, in: Proc. ~?["Computer Science Loyic, CSL'91, Lecture Notes in Computer Science, Vol. 626 (Springer, Berlin, 1991 ) 213-226. [13] M. Kurihara and I. Kaji, Modular term rewriting systems and the termination, Infi)rm. Process. Lett. 34 (1990) I-4. [14] M. Kurihara and A. Ohuchi, Modularity of simple termination of term rewriting systems, ,LIPS, Japan 34 (1990) 632-642. [15] M. Kurihara and A. Ohuchi, Modularity of simple termination of term rewriting systems with shared constructors, Theoret. Comput. Sci. 103 (1992) 273-282. [16] M. Marchiori, Modularity of completeness revisited, Technical Report, University of Padova (1994). [17] A. Middeldorp, A sufficient condition for the termination of the direct sum of term rewriting systems, Proc. of LICS'89 (1989) 396-401. [18] A. Middeldorp, Modular properties of term rewriting systems, Ph.D. Thesis, Free University, Amsterdam, 1990. [19] A. Middeldorp and Y. Toyama, Completeness of combinations of constructor systems, in: Proc. o! RTA'91, Lecture Notes in Computer Science Vol. 488 (Springer, Berlin, 1991 ) 188-199 Also appears in J. Symbolic Comput. 15 (1991) 331-348. [20] E. Ohlebusch, A simple proof of sufficient conditions for the termination of disjoint union of TRSs, Bulletin of EA TCS 49 ( 1993 ) 178-183. [21] E. Ohlebusch, On the modularity of termination of term rewriting systems, Report no. 11, Universit& Bielefeld, 1993. [22] E. Ohlebusch, On the modularity of confluence of constructor-sharing term rewriting systems, in: Proc. of CAAP'94, Lecture Notes in Computer Science, Vol. 787 (Springer, Berlin, 1994) 261-275. [23] E. Ohlebusch, Modular properties of composable term rewriting systems, Ph.D. Thesis, Universit/it Bielefeld, 1994. [24] M. Rusinowitch, On termination of the direct sum of term rewriting systems, ln/brm. Process. Lett. 26 (1987) 65-70. [25] M. Schmidt-Schauss and S. Pintz, Modular termination of consistent and left-linear TRSs, Draft, May, 1994. [26] Y. Toyama, On the Church-Rosser property for the direct sum of term rewriting systems, J. ACM 34 (1987) 128-143. [27] Y. Toyama, Counterexamples to termination for the direct sum of term rewriting systems, In]brm. Process. Lett. 25 (1987) 141-143. [28] Y. Toyama, J.W. Klop and H.P. Barendregt, Termination for the direct sum of left-linear term rewriting systems, in: Proc. o[ RTA'89, Lecture Notes in Computer Science, Vol. 355 (Springer, Berlin, 1989) 477-491.