On Modularity of Completeness in Order-Sorted

0 downloads 0 Views 204KB Size Report
ffs1!s1 : s1 !s1; fs2!s2 : s2 !s2; p!s2 :!s2; q!s2 :!s2g;. LD(R) = f(8x : s1)fs1!s1(x) !x; fs2!s2(p!s2) !q!s2; p!s2 !q!s2g: R is a con uent, but LD(R) is not, since fs2!s2(p!s2) ...
On Modularity of Completeness in Order-Sorted Term Rewriting Systems

Yoshinobu Kawabe? and Naohiro Ishii Department of Intelligence and Computer Science Nagoya Institute of Technology Gokiso-cho, Showa-ku, Nagoya 466, Japan E-Mail: fkawabe,[email protected] In this paper, we extend the results on the modularity of con uence and termination of single-sorted TRSs[3][6][7] to order-sorted ones. Order-sorted TRSs build a good framework for handling overloaded functions and subtypes. For proving modularity of completeness of ordersorted TRSs, we rst transform a TRS with overloaded functions to a non-overloaded one, and then we demonstrate that our transformation preserves completeness.

Abstract.

1

Introduction

Term rewriting system (TRS) can be viewed as a framework for implementing functional programming languages. Order-sorted TRS is a sorted model in which programs manipulate several kinds of objects, thus it is more suitable than the homogeneous one to treat computable objects in software systems. Moreover, order-sorted TRS has a good framework to handle partially de ned functions and inclusion of sorts. Hence, its importance is constantly increasing. Indeed, many executable speci cation languages like OBJ3[4] have an operational semantics based on order-sorted rewriting. A property P is called modular if two TRSs hold P i the \combined" TRS holds P . In single-sorted case, modularity of properties is discussed well; Toyama[3] proved that con uence was modular, and modularity of termination was treated by Rusinowitch[6] and Middeldorp[7]. However, modular properties of order-sorted TRSs have not been explored yet. The analysis of order-sorted TRSs is more dicult than that of single-sorted TRSs because of overloaded function symbols and subtype relations. The aim of this paper is to extend the results on modularity of con uence and termination to order-sorted TRSs. We rst introduce a transformation from an order-sorted TRS with overloaded function symbols to another TRS without such symbols. Then, we show that our transformation preserves con uence and termination. Finally, we prove the modularity of con uence and termination in order-sorted TRSs. ?

The rst author is currently with Nippon Telegraph and Telephone Corporation.

2

Order-Sorted TRSs

In this section, we give basic notions on order-sorted TRSs, following [1][2][5]. An order-sorted signature is a triple (S; ; 6 ), where S is a set of sorts,  is a partial ordering over S and 6 is a family f6w;s jw 2 S 3 ; s 2 S g of (not necessarily disjoint) set of operator symbols. Note that w is possibly an empty word . For any f 2 6w;s , a word w and a pair (w; s) are called arity and rank, respectively. We may simply write f : w ! s instead of f 2 6w;s and f :! s instead of f 2 6;s. We use 6 as an abbreviation for both (S; ; 6 ) and Sw;s 6w;s . The ordering  is extended to strings s1 1 1 1 sn 2 S 3 , by s1 1 1 1 sn  s01 1 1 1 s0n i si  s0i for 1  i  n;  is also extended to pairs (w; s) 2 S 3 2 S by (w; s)  (w0 ; s0) i w  w0; s  s0. We de ne < as  n =, and  and > are inverse relations of  and s2 > 1 1 1 for s1 ; s2 ; . . . 2 S . An S -sorted variable set is a family V = fVs js 2 S g of disjoint sets, which is disjoint from 6 . We write x : s for a variable x 2 Vs . The set T6 (V )s of terms over 6 and V with sort s is the least set with the following properties: (i) x 2 T6 (V )s if x : s0 2 V and s0  s, (ii) f 2 T6 (V )s if f :! s0 and s0  s, (iii) f (t1; . . . ; tn) 2 T6 (V )s if f : s1 1 11 sn ! s0 such that s0  s and ti 2 T6 (V )si for every 1  i  n. T6 (V ) = Ss2S T6 (V )s denotes the set of all terms over 6 and V . The set of all variables in a term t 2 T6 (V ) is written as V ar(t). Following [1], O(t) is the set of all occurrences of the term t. A symbol of t at ! 2 O(t) is described as t(!). tj! is a subterm of t at ! . The result of the replacement of the subterm at ! in t by t0 is denoted by t[! t0]; this term may be ill-formed, even if t and t0 are well-formed. Let (S; ; 6 ) be an order-sorted signature. A (S; ; 6 )-algebra(6 -algebra) A consists of a family fAsjs 2 S g of sets and a function Aw;s f : Aw ! As for every f 2 6w;s such that the following conditions are satis ed: (i) As  As0 , if w0 ;s0 0 0 s  s0 , (ii) Aw;s f equals Af on Aw if s  s ; w  w and f 2 6w;s \ 6w0 ;s0 , where As1 111sn = As1 2 1 1 1 2 Asn and A is a one-point set. A signature (S; ;6 ) is regular i for any w0 2 S 3 such that there is a f 2 6w;s with w0  w then there is a least (w0 ; s0) 2 S 3 2 S such that f 2 6w0;s0 and w0  w0 . If a signature is regular, every term t 2 T6 (V ) has a least sort s 2 S ; we de ne it as LS(t) = s. In this paper, we treat regular signatures. An assignment  from a variable set V into 6 -algebra A is a set of functions fs : Vs ! As js 2 S g. A substitution  is an assignment from a variable set X into the term algebra T6 (Y ); a substitution  : fx1 ; . . . ; xng ! T6 (Y ) that maps the variables x1 ; . . . ; xn to the terms t1 ; . . . ; tn , respectively, is written as  = fx1 7! t1 ; . . . ; xn 7! tng. We also write  for the extension 3 : T6 (X ) ! T6 (Y ) de ned by 3 (f (t1 ; . . . ; tn )) = f ( 3 (t1); . . . ; 3 (tn )). For a term t and a substitution , we write t for  (t). A substitution  : X ! T6 (Y ) is called a specialization if it is injective and if it maps every variable x : s from X to a variable (of the same or of a smaller sort). For a specialization  = fx1 7! y1; . . . ; xn 7! yn g, a substitution 0 = fy1 7! t1; . . . ; yn 7! tn g and a term t, we write t(  0 ) for  0( (t)).

A rewrite rule is a pair (l; r) (l; r 2 T6 (Y )) where (i) l is not a variable, (ii) All variables in r appear in l. We shall usually write l !R r instead of (l;r ). The label of the binary relations R is sometimes omitted. A rewrite rule l ! r is a c-rule if r is a variable. A rewrite rule l ! r is a d-rule if some variable has more occurrences in r than it has in l. An order-sorted TRS is a pair ((S; ; 6 ); R), where R is a set of rewrite rules; ((S; ; 6 ); R) is often abbreviated by R. A term t 2 T6 (X ) is rewrited to t0 2 T6 (X ) with a rewrite rule l ! r at the occurrence ! if the following conditions are satis ed: (i) There exists a substitution  : V ar (l) ! T6 (X ) such that l = tj! , (ii) t0 = t[! r ], (iii) there exists some variable x : s such that t[! x] is well-formed and !r ] l; r 2 T6 (X )s . We denote this rewrite as t [!;l0! t0 , possibly omitting the indices. In this de nition, a term tj! is called a redex of t. We need the well-typedness check of terms on rewriting. For omitting the check, we consider the following condition. A rule l ! r is called sort-decreasing, if LS (l )  LS (r ) for every substitution  : V ar (l) ! T6 (X ); we say R is sort-decreasing if all rules in R are sort-decreasing. In this study, we treat sortdecreasing TRSs. If a TRS is sort-decreasing, there is no redex of a term t i there is no term t0 such that t ! t0 ; such t is called a normal form. For terms t1; t2, if t1 !3 t2 and t2 is a normal form, then t2 is called a normal form of t1. Let ((S; ; 6 ); R) be an order-sorted TRS. R is con uent if for any terms a; b;c 2 T6 (X ) that a 3R b !3R c, there exists some d 2 T6 (X ) such that a !3R d 3R c. R is terminating if it has no in nite reduction sequences. R is called complete i it is con uent and terminating. We say ((S; ; 61 ); R1 ) and ((S; ;62 ); R2 ) are isomorphic if: (i) there is a bijection fi : T6i (V ) ! T630i (V ) and (ii) t !Ri t0 for any t; t0 2 T6i (V ) i fi (t) !R30i fi (t0 ), where i = 1; 2.

2.1 Modularity If two single-sorted TRSs have no common function or constant symbols, their signatures are called disjoint. In the order-sorted case, we extend disjointness of signatures as follows:

De nition 1. (S; ; 6 1 ) and (S; ; 6 2 ) are called disjoint i for any w;w 2 S 1 and f 2 6w2 0 ;s0 , w and w have no common predecessor. such that f 2 6w;s 0

3

0

Let ((S; ; 61 ); R1 ) and ((S; ; 62 ); R2 ) be order-sorted TRSs with disjoint signatures. The disjoint union R1 8 R2 is a TRS ((S; ; 61 [ 62 ); R1 [ R2 ). The property P is called modular if both R1 and R2 have P i R1 8 R2 has P .

2.2 Disambiguations We use the concept of disambiguated signatures introduced in [4]. Let (S; ; 6 ) be an order-sorted signature. For any set of function symbols 6w;s (w 2 S 3 ; s 2 # i f 2 6w;s . The set of function symbols 6 # is S ), we de ne fw!s 2 6w;s

# (w de ned as a family of sets 6w;s de ned as follows:

2 S ; s 2 S ). The set of rewrite rules M6 is 3

8(f : s1 . . . sn ! s); (f : s1 . . . sn ! s ) 2 6 si  si for (0  i  n) and s  s =) (8x1 : s1 2 X; . . . ; 8xn : sn 2 X ); fs01 ...s0n s0 (x1 ; . . . ; xn ) !M6 fs1 ...sn s (x1 ; . . . ; xn ): The term fs1 ...sn s (x1 ; . . . ; xn ) is called a disambiguation of f (x1 ; . . . ; xn ). 0

0

0

0

0

!

!

!

Lemma 2 [4]. Let (S; ; 6 ) be an order-sorted signature. If 6 is regular and < is terminating over S , then ((S; ; 6 # ); M6 ) is complete and sort-decreasing. Recall that the signature is regular and < is terminating over S in this work. For any term t 2 T6 (Y ), we introduce a particular disambiguation called the lowest disambiguation. The lowest disambiguation LD(t) of a term t 2 T6 (Y ) is the M6 -normal form of any disambiguation of t. We write t #M6 for the M6 -normal form of a disambiguation t 2 T6# (V ). By Lemma 2, we have a unique LD(t) for any term t 2 T6 (Y ). The operation calculating the lowest disambiguation can be seen as a bijection from T6 (V ) to fLD(t)jt 2 T6 (V )g. Let (S; ; 6 ) be an order-sorted signature and V an S -sorted variable set. We de ne a set of rewrite rules LD(R) = fLD(li ) ! LD(ri)j1  i  ng for any rule R = fli ! ri j1  i  ng. We de ne LD( ) = fxi 7! LD (ti )j1  i  ng for any substitution  = fxi 7! ti j1  i  n ^ xi 2 V ^ ti 2 T6 (V )g. 3

Elimination of Overloaded Function Symbols

3.1 Simpli cation of the Signature De nition 3. Let (S; ; 6 ) be a signature. We de ne a set of function symbols sm = ff jf 2 6w;s ^ 8s 2 S [f 2 6w;s0 =)s  s ]g. We 6 sm as a family of sets 6w;s call the signature (S; ; 6 sm ) the simpli cation of (S; ; 6 ). For any signature (S; ; 6 ), (S; ; 6 sm ) is uniquely determined. Let f 2 6w;s and f 2 6w;s0 be function symbols with s  s . Obviously, by removing all such function symbols f 2 6w;s0 , we get the set 6 sm from 6 . Lemma 4. (S; ; 6 ) is regular i (S; ;6 sm ) is regular. Lemma 5. T6 (V ) = T6 sm (V ) for any (S; ; 6 ) and S -sorted variable set V . Lemma 6. We denote LS (t)6 for the least sort of a term t 2 T6 (V ) and LS (t)6sm for the least sort of the term t 2 T6sm (V ), respectively. Then, LS (t)6 = LS (t)6sm for any t. Proposition 7. ((S; ; 6 ); R) and ((S; ; 6 sm ); R) are isomorphic. 0

0

0

Proof. By assumption, ((S; ; 6 ); R) is sort-decreasing. We get the regularity of (S; ; 6 sm ) by Lemma 4, so that every term of simpli ed signature has the

least sort. Moreover, by Lemma 6 and Lemma 5, for any rule l ! r and any substitution , we get LS (l )  LS (r), which implies that ((S; ; 6 sm ); R) is sort-decreasing. Therefore, we shall show the followings: (i) the existence of a bijective function F between T6 (V ) and T6sm (V ), (ii) for any term t 2 T6 (V ), occurrence ! 2 O(t), rule l ! r and substitution  = fx1 7! t1 ; . . . ; xn 7! tng(0 = fx1 7! F (t1); . . . ; xn 7! F (tn )g), tj! = l i F (t)j! = F (l)0 and (iii) F (t[! l]) = F (t)[! F (l)0]. By Lemma 5, we can easily prove them by taking F as an identity function. ut Proposition 7 states the equivalence of an order-sorted TRS to another TRS with the simpli ed signature. The following corollary can be proved from this proposition.

Corollary 8. Let P be a property of con uence or termination. ((S; ; 6 ); R) holds P i ((S; ; 6 sm ); R) holds P . Proposition 9. For any signature (S; ; 6 ), there are no function symbols f 2 sm and f 2 6 sm0 0 such that w < w and s < s. 6w;s w ;s sm Proof. Proof by contradiction. Assume that there are function symbols f 2 6w;s sm and f 2 6w0 ;s0 such that w < w and s < s, where w; w 2 S and s; s 2 S . By Lemma 4, the signature 6 sm is regular, then we can prove the existence of sm 00 for s 2 S such that s  s . Therefore, there are a function symbol f 2 6w;s two function symbols of the same arity f : w ! s and f : w ! s in 6 sm and 0

0

0

0

0

00

00

3

0

0

00

s < s. However, by De nition 3, there cannot exist such function symbols in 6sm | contradiction. ut sm By this proposition, we get w < w =)s  s for any function symbols f 2 6w;s sm and f 2 6w0 ;s0 . 00

0

0

3.2 Transformation to Non-overloaded TRS In this subsection, we treat the simpli ed signatures. The situation of ordersorted TRSs is more complicated than that of single-sorted or many-sorted TRSs because of subsort relations. Overloaded function symbols in a many-sorted TRS can be eliminated by renaming them, because for any many-sorted rule l ! r, the sort of l and that of r are the same and there are no subsort relations. However, in order-sorted case, we cannot apply the method that simply renames function symbols for elimination of overloadedness. Because, for example, con uence may be corrupted by the operation.

Example 1. We give an order-sorted TRS ((S; ; 6 ); R) as follows: (S; ) = fs2  s1 g; 6 = ff : s1 ! s1 ;f : s2 ! s2 ; p :! s2 ; q :! s2 g; R = f(8x : s1 )f (x) ! x; f (p) ! q; p ! qg:

Then, ((S; ; 6 # ); LD(R)) is given as follows:

6 # = ffs1 s1 : s1 ! s1 ; fs2 s2 : s2 ! s2 ; p s2 :! s2 ; q LD(R) = f(8x : s1)fs1 s1 (x) ! x; fs2 s2 (p s2 ) ! q s2 ; p !

!

!

!

!

!

!

s2 :! s2 g; s2 ! q s2 g:

!

!

!

R is a con uent, but LD(R) is not, since fs2 s2 (p s2 ) has two normal forms q s2 and fs2 s2 (q s2 ). What is worse, ((S; ; 6 # ); LD(R) [ M6 ) is not con!

!

!

!

!

uent neither. If there exist some rules R0 such that ((S; ; 6 ); R) is con uent or terminating i ((S; ; 6 # ); R0 ) is also con uent or terminating, respectively, then we can analyze order-sorted TRSs after eliminating overloaded function symbols. Fortunately, such R0 really exists; we give the de nition of the rules.

De nition 10. We construct a TRS ((S; ; 6 # ); LD(R) [ LD(R) [ M6 ) from ((S; ; 6 ); R), where M6 is the rule set for de ning the lowest disambiguations. 0

Step 1. Take LD(R) = ;, Step 2. Let fs1 sn s 2 6 # and fs01 s0n s0 2 6 # be function symbols with (s1 1 1 1 sn ; s) < (s1 1 1 1 sn ; s ). If there is a rule l ! r 2 LD(R) [ LD(R) with 0

111

! 0

111

0

!

0

0

the following conditions: 1. For any 2 S 3 that s1 1 1 1 sn < < s01 11 1 s0n , there is no symbol f ! 2 6# , 2. lj! = fs01 111s0n !s0 (t1 ; . . . ; tn ) for some occurrence !, 3. For a specialization  = fti 7! xij1  i  n and ti is a variable of sort s00i with si < s00i  s0i g (each xi : si ia a fresh variable), l0 and r0 are de ned as follows. An expression l0 is made from l with replacing l (!) = l(!) = fs01 111s0n!s0 by fs1 111sn!s , and a term r0 is r. Then, the term l0 is well-formed, then, add a rule l0 #M6 ! r 0 #M6 to LD(R)0 , Step 3. Repeat the \Step 2" until the set LD(R)0 gets no more larger. This operation corresponds to adding rules LD( 0) ! LD ( 0) to LD(R), where 0 and 0 are specialized by some specialization from terms and of a rule ! 2 R, respectively. In this study, we treat regular signature and nite rule set R, and we assume that < is terminating over S . Therefore, the process of De nition 10 terminates. The disambiguated rule set LD(R) [ LD(R)0 [ M6 is abbreviated by Dis(R).

Lemma 11. For any rewrite rule LD (p) ! LD(q ) 2 LD(R) [ LD(R) , there are some rule LD (l) ! LD(r) 2 LD(R) and some specialization  = fx1 7! y1; . . . xn 7! yng such that LD(p) = LD(l) #M6 = LD(l) and LD(q ) = LD(r) #M6 = LD(r), where V ar(l) = fx1 ; . . . ; xng. 0

Proposition 12. ((S; ; 6 ); R) is sort-decreasing, then ((S; ; 6 # ); Dis(R)) is sort-decreasing.

Proof. Let ((S; ; 6 ); R) be a sort-decreasing order-sorted TRS. From Lemma 2, rules in M6 are sort-decreasing. We now prove that rules in LD (R) are sort-decreasing. Let LD(l) ! LD(r) 2 LD(R) be a rewrite rule. We have LS(t) = LS(LD(t)) for any term t 2 T6 (V ), so that LS (LD(l)) = LS (l)  LS (r) = LS (LD(r)) holds. For any substitution , we get LS(LD(l)) = LS (LD(l)), because LD(l) is not a variable. We can easily prove LS (LD(r ))  LS (LD(r)). Therefore, LS (LD(l))  LS (LD(r)), that implies the sort-decreasingness of rules in LD(R). Sort-decreasingness of any rule l ! r 2 LD(R)0 is shown as follows. By Lemma 11, there are some rule LD(p) ! LD(q) 2 LD(R) and some specialization  = fx1 7! y1 ; . . . ; xn 7! yn g such that l = LD(p) #M6 = LD(p ) and r = LD(q ) #M6 = LD(q). By sort-decreasingness of R, we get LS (l) = LS(LD(p )) = LS(p )  LS(q) = LS (LD(q )) = LS(r). Since l is not a variable, we can show LS (l) = LS (l) for any substitution , and LS (r)  LS (r) holds. Therefore, LS (l) = LS (l)  LS (r)  LS (r), which implies that l ! r is sort-decreasing. ut

De nition 13. For any order-sorted signature (S; ; 6 ) and S -sorted variable set V , an ambiguation function Amb : T6# (V ) ! T6 (V ) is de ned as follows: (i) Amb(x : s) = x : s, (ii) Amb(fw!s (t1 ; . . . ; tn )) = f (Amb(t1 ); . . . ; Amb(tn )). De nition 14. Let (S; ; 6 ) be a signature and V an S -sorted variable set. For any term t# 2 T6# (V ), we write t# 2 [t] i Amb(t# ) = t, where t 2 T6 (V ). Obviously, t# 2 [t] implies t# !3M6 LD (t), and there is a term t 2 T6 (V ) such that t# 2 [t] for any term t# 2 T6 # (V ).

Theorem 15. Let ((S; ; 6 ); R) be an order-sorted TRS. We have t ! t for terms t; t 2 T6 (V ) i there is a t 2 [t ] such that LD(t) !LD( ) LD( )0 t . R

0

00

0

R [

Proof. (=)) Assume that tj! =

0

00

R

l and t = t[! r ] for a rule l ! r 2 R, an occurrence !, and a substitution  = fx1 7! t1 ; . . . ; xn 7! tn g. Note that LD(t)j! is a lowest disambiguation since LD(tj! ) = LD(t)j! . There is some rule l ! r 2 LD(R) [ LD(R) and some substitution  = fy1 7! t1 ; . . . ; yn 7! tn g such that LD(t)j! = l LD ( ), where l = l #M6 for some specialization  = fx1 7! y1; . . . ; xn 7! yn g, from Lemma 11. Next, we consider a term LD(t)[! r LD( )]. The term r is the lowest disambiguation of the specialized term r , then we can prove Amb(r LD( )) = Amb((LD(r) )LD( )) = Amb(LD(r)(  LD( ))) = Amb(LD(r)LD( )) = r. Therefore, we can say that Amb(LD(t)[! r LD( )]) = Amb(LD (t))[! Amb(r LD( ))] = t[! r] = t . Consequently, we get LD(t)[! r LD( )] 2 [t ]. ((=) Assume that LD (t)j! = LD(l) and t = LD(t)[! LD(r) ] for a rewrite rule LD(l) ! LD (r) 2 LD (R) [ LD(R) , an occurrence ! and a substitution . Since any subterm of LD(t)j! is a lowest disambiguation, the substitution  is expressed as  = fx1 7! LD(t1 ); . . . ; xn 7! LD(tn )g = LD( ). Then, we get Amb(LD(t)j! ) = Amb(LD(l)LD( )), hence tj! = l holds. We can easily see Amb(LD(r) ) = Amb(LD(r )LD( )) = r , then 0

0

0

0

0

0

0

0

00

00

0

0

0

00

0

00

0

0

0

00

0

0

0

0

0

0

0

0

00

0

0

0

0

0

0

we can say Amb(LD(t)[! LD(r )]) = Amb(LD(t)[! LD(r)LD( 0)]) = Amb(LD(t))[! Amb(LD(r )LD(0 ))] = t[! r0 ]. Let LD(l0 ) ! LD(r0) 2 LD(R) be a rule by which LD(l) ! LD(r) 2 LD(R) [ LD(R)0 is generated with some specialization  = fy1 7! x1 ; . . . ; yn 7! xn g such that LD(l) = LD(l0 ) #M6 and LD(r) = LD(r0) #M6 , where V ar(l0 ) = fy1 ; . . . ; yng. Then, for the substitution  00 = fy1 7! t1 ; . . . ; yn 7! tn g, we get tj! = l0 00 and t[! r000 ] = t[! r0]. Thus, a term t is reduced to t[! r0 00 ] by l0 ! r0 and t00 2 [t[! r0 00 ]] holds. ut

Theorem 16. Let ((S; ;6 ); R) be an order-sorted TRS and V an S -sorted variable set. For any terms t; t 2 T6 (V ), occurrence ! and rewrite rule l ! r 2 R, there is a term t 2 T6# (V ) such that: p) LD(q)] t [!;l0!r] t () LD(t) [!;LD(0! LD( ) LD( )0 t !M6 LD(t ); where p and q are specialized by some specialization from l and r, respectively. 0

00

!

R

!

0

R [

Proof. From Theorem 15, t !

00

R

0

3

i LD(t) !LD(R)[LD(R)0 t00 for some t00 2 [t0]. In these rewritings, from the discussion in the proof of Theorem 15, we can say that l ! r 2 R is applied to t at ! i LD(p) ! LD(q) 2 LD(R) [ LD(R)0 is applied to LD(t) at !. We can easily prove t00 !3M6 LD (t0 ) since t00 2 [t0 ] and from Lemma 2. ut R

t

0

Let ((S; ; 6 ); R) be a TRS with a simpli ed signature. We prove that the R is con uent or terminating i Dis(R) is con uent or terminating, respectively.

Lemma 17. Let (S; ; 6 ) be an order-sorted TRS. We have t ! t for terms t; t 2 T6 (V ) i there are tA 2 [t] and tB 2 [t ] such that tA !LD( ) LD( )0 tB . Proposition 18. ((S; ; 6 ); R) is con uent i ((S; ; 6 # ); Dis(R)) is so. Proof. Let ((S; ; 6 ); R) be a TRS and V an S -sorted variable set. (=)) Assume that R is con uent and t1 Dis( ) t2 !Dis( ) t3 for any terms t1 ; t2 ; t3 2 T6# (V ). Let tA !Dis( ) tB be a rewrite step in t1 Dis( ) t2 !Dis( ) t3 with a rule l ! r. There are two cases: (i) If l ! r 2 LD(R) [ LD(R) , we get Amb(tA ) ! Amb(tB ) from Lemma 17. (ii) If l ! r 2 M6 , Amb(t2 ) ! Amb(t3 ). Thus, Amb(tA )  Amb(tB ). Then, we get Amb(t1 ) LD(Amb(t1)) Dis( ) LD(Amb(t2 )) !Dis( ) LD(Amb(t3 )) is shown by Theorem 16. By assumption R is con uent, so there is some td 2 T6 (V ) such that Amb(t1 ) ! td Amb(t3). We get LD(Amb(t1)) !Dis( ) LD(td) Dis( ) LD(Amb(t3)) from Theorem 16 again. We have t1 !M6 LD(Amb(t1 )) and t3 !M6 LD(Amb(t3 )), then t1 !Dis( ) LD(td) Dis( ) t3 holds. ((=) Assume that Dis(R) is con uent and t1 t2 ! t3 for any terms t1 ; t2 ; t3 2 T6 (V ). From Theorem 16, LD(t1) Dis( ) LD(t2) !Dis( ) LD(t3) holds. There exists some td 2 T6 # (V ) such that LD (t1 ) !Dis( ) td Dis( ) LD(t3 ) because Dis(R) is con uent. For any rewrite step tA !Dis( ) tB in LD(t1 ) !Dis( ) td Dis( ) LD(t3), we can say that Amb(tA ) ! Amb(tB ) or Amb(tA )  Amb(tB ), which implies that t1 ! Amb(td) t3. ut R

0

0

0

R [

R

3

3

R

R

3

R

R

3

R

0

R

3

R

3 R

3 R

3 R

3

R

3 R

3

3

R

R

3

3

3

3

R

3

R 3 R

3 R

3

R

R

3

3

R

R

R

3

3

R

R

R

3 R

3 R

Proposition 19. ((S; ; 6 ); R) is terminating i ((S; ; 6 # ); Dis(R)) is so. Proof. Let ((S; ; 6 ); R) be a TRS and V an S -sorted variable set.

(=)) Assume that Dis(R) is not terminating. There is an in nite reduction sequence starting from t1 2 T6# (V ), t1 !Dis(R) t2 !Dis(R) t3 !Dis(R) 1 1 1. Let tA !Dis(R) tB be any rewrite step in this sequence. If it is a rewrite step with a rule of LD(R) [ LD(R)0 , then we get Amb(tA ) !R Amb(tB ) from Lemma 17. Otherwise, the case that a rule of M6 is applied, we get Amb(tA )  Amb(tB ). By Lemma 2, M6 is terminating. Therefore, there exists an in nite reduction sequence starting from Amb(t1 ) in R. ((=) Proof by contradiction. Assume that Dis(R) is terminating and that there exists an in nite reduction sequence t1 !R t2 !R t3 !R 1 1 1. By Theorem 16, there exists an in nite sequence LD(t1 ) !3Dis(R) LD(t2 ) !3Dis(R) LD(t3) !3Dis(R) 1 1 1, where each LD(ti ) !3Dis(R) LD(ti+1 ) (i  1) consists of a rewrite step with a rule of LD(R) [ LD(R)0 followed by a rewrite sequence with rules of M6 | contradiction. ut In the following theorem, we consider non-simpli ed signatures.

Theorem 20. Let R be a sort-decreasing TRS with a (non-simpli ed) signature (S; ;6 ). We have: (i) ((S; ; (6 sm )# ); Dis(R)) is sort-decreasing, (ii) Let P be a property of con uence or termination. Then, R holds P i ((S;  ; (6sm)# ); Dis(R))holds P . Proof. We can easily prove that ((S; ; 6 sm ); R) is sort-decreasing. (i) Sortdecreasingness of ((S; ; (6 sm )# ); Dis(R)) is shown by Proposition 12, (ii) From Corollary 8, we can say that ((S; ; 6 ); R) holds P i ((S; ; 6 sm ); R) holds P . Moreover, ((S; ; 6 sm ); R) is con uent i ((S; ; (6 sm )# );Dis(R)) is con uent from Proposition 18. Similarly, from Proposition 19, ((S; ; 6 sm ); R) is terminating i ((S; ; (6 sm )# ); Dis(R)) is terminating. ut 4

Modular Properties of Order-Sorted TRSs

4.1 Modularity of Well-formedness of Terms Order-sorted rewriting di ers from single-sorted or many-sorted rewriting in that the well-formedness of the resulting term must be explicitly checked. In this work, the modularity of con uence and termination is proved as in the single-sorted case (as in [3][6][7]). Hence, it shall hold that order-sorted TRSs R1 and R2 are sort-decreasing i R1 8 R2 is sort-decreasing. Thus, in this subsection, we show the modularity of sort-decreasingness.

Lemma 21. (S; ; 6 1 ) and (S; ; 6 2) are regular i (S; ; 6 1 [ 6 2 ) is regular. By Lemma 21, we can say that every term of the signature of disjoint union has a least sort; we write LS (t)i (i = 1; 2) for the least sort of a term t 2 T6 i (V ) and LS (u)8 for the least sort of the term u 2 T61 [62 (V ), respectively.

Lemma 22. Let (S; ; 6i ) (i = 1; 2) be order-sorted signatures and sorted variable set. Then, LS (t)i = LS (t) for any t 2 T6i (V ).

V

an S -

8

Theorem 23. Let ((S; ; 61); R1 ) and ((S; ; 62); R2 ) be order-sorted TRSs. Both R1 and R2 are sort-decreasing i R1 8 R2 is sort-decreasing.

Proof. (=)) ((S; ; 6i); Ri ) (i = 1; 2) has a regular signature, so that the least sort exists for any terms in Ri . Because Ri is sort-decreasing, we have LS (l)i  LS (r)i for any rule l ! r 2 Ri and any specialization  = fx1 7! y1 ; . . . xn 7! yng. From Lemma 21, ((S; ; 61 [62 ); R1 [R2 ) has a regular signature and every term in R1 8 R2 has a least sort. Then, we can say LS (l)8  LS (r)8 from Lemma 22. We can say LS (l(   ))8  LS (r(   ))8 for any substitution  = fy1 7! t1 ; . . . ; yn 7! tng such that LS (yj )8 = LS (tj )8 for j 2 f1; . . . ; ng, where each tj are terms of R1 8R2 . We can easily understand that any substitution  0 of R1 8 R2 can be used instead of (  ). Hence, we get LS (l0 )8  LS (r 0 )8 , which implies the sort-decreasingness of R1 8 R2 . ((=) ((S; ; 61 [ 62 ); R1 [ R2 ) has a regular signature, and for any rule l ! r 2 R1 [R2 and any substitution  of R1 8R2, we have LS(r)8  LS(l)8 . From Lemma 21, (S; ; 61 ) and (S; ; 62 ) are regular signatures. Thus, we shall say that LS (l0 )i  LS (r 0)i for any rule l ! r 2 Ri (i = 1; 2) and any substitution  0 of Ri . It is easily shown since LS (t)i = LS (t)8 for any term t of Ri from Lemma 22. ut A rule l ! r is called compatible, if for every t 2 T6 (X ) and every ! 2 O(t) we have: If l = tj! for some substitution  : V ar(l) ! T6 (X ), then t[! r ] is a well-formed term; we say R is compatible if all rules in R are compatible. We acquired a result that sort-decreasingness is modular by Theorem 23. However, the compatibility is not modular.

Example 2. Let ((S; ; 61 ); R1) and ((S; ; 62 ); R2 ) be TRSs as follows:

(S; ) = fs1  s2 g; 61 = ff : s1 ! s1 ; p :! s1 ; q :! s1 g; R1 = fp ! qg; 62 = fa :! s1 ; b :! s1 ; c :! s1 ; d :! s2 g; R2 = fa ! b; a ! c; b ! d; c ! dg:

Clearly, both R1 and R2 are compatible; R1 is also sort-decreasing. However, R1 8 R2 = ((S; ; 61 [ 62); R1 [ R2 ) is not compatible, because if we rewrite a term f (b) at an occurrence 1 by a rule b ! d, then the resulting expression f (d) is not well-formed. What is worse, R1 8 R2 is not con uent, though R1 and R2 are con uent, since f (a) has two normal forms f (b) and f (c).

4.2 Modularity of Completeness Lemma 24. Let (S; ; 6 1 ) and (S; ; 6 2 ) be disjoint signatures. The signatures (S; ; 6 1# ) and (S; ; 6 2# ) have no common function symbols. Lemma 25. For any the same.

R1 and R2 , Dis(R1 ) 8 Dis(R2 ) and Dis(R1 8 R2 ) are

Con uence Lemma 26. Let R1 and R2 be sort-decreasing order-sorted TRSs whose signatures are non-overloaded and have no function symbols in common. Then, both R1 and R2 are con uent i R1 8 R2 is con uent. We can prove Lemma 26 as same as in single-sorted case (as in [3]). Lemma 26 is extended as follows. Note that we assume sort-decreasingness and regularity of signatures.

Theorem 27. Con uence is a modular property of order-sorted TRSs. Proof. Let ((S; ; 61 ); R1 ) and ((S; ; 62); R2 ) be sort-decreasing order-sorted

TRSs. We shall prove that both R1 and R2 are con uent i R1 8R2 is con uent. From Theorem 20, we can say that ((S; ; 6i); Ri ) (i 2 f1; 2g) is con uent i ((S; ; (6ism )# ); Dis(Ri )) is con uent, and ((S; ; (6ism )# ); Dis(Ri )) is sort-decreasing. The signature (S; ; (6ism )# ) has no overloaded function symbols, and we can say that (61sm )# and (62sm )# has no function symbols in common from Lemma 24. Thus, we can apply Lemma 26 and we get that both ((S; ; (61sm )# ); Dis(R1 )) and ((S; ; (62sm )# ); Dis(R2 )) are con uent i ((S; ; (61sm )# [ (62sm )# ); Dis(R1 ) [ Dis(R2 )) is con uent. Then, from Lemma 25, the order-sorted TRS ((S; ; (61sm [ 62sm )# ); Dis(R1 [ R2 )) is con uent. We can see that R1 8R2 = ((S; ; 61 [ 62 ); R1 [R2 ) is sort-decreasing from Theorem 23. Thus, we can apply Theorem 20 again, we get ((S; ; 61 [ 62 ); R1 [ R2) is con uent i ((S; ; ((61 [ 62 )sm)#); Dis(R1 [ R2)) is con uent. Finally, order-sorted TRSs R1 and R2 are con uent i R1 8 R2 is con uent. ut

Termination and Completeness Lemma 28. Let R1 and R2 be sort-decreasing order-sorted TRSs whose signatures are non-overloaded and have no function symbols in common. Then, both R1 and R2 are terminating i R1 8 R2 is terminating, if one of the following conditions is satis ed: (i) Neither R1 nor R2 contain c-rules, (ii) Neither R1 nor R2 contain d-rules, (iii) One of the TRSs R1 ; R2 contains neither c-rules nor d-rules. We can prove Lemma 28 as in single-sorted case (as in [6][7]).

Theorem 29. Termination is modular if one of the conditions (i)(ii)(iii) of Lemma 28 is ful lled. Proof. Proof of modularity of termination is similar to that of con uence. Note

the following thing. Clearly, R contains no c-rule (d-rule) i Dis(R) contains no c-rule (d-rule). Then, ((S; ; (61sm )# ); Dis(R1 )) and ((S; ; (62sm )# ); Dis(R2 )) are terminating i ((S; ; (61sm )# [ (62sm )# );Dis(R1 ) [ Dis(R2 )) is terminating by Lemma 28. ut

Finally, we get a theorem on modularity of completeness in order-sorted TRSs.

Theorem 30. Completeness is modular in order-sorted TRSs if one of the conditions (i)(ii)(iii) of Lemma 28 is satis ed. Proof. It immediately follows from Theorem 27 and Theorem 29. 5

ut

Conclusion

In this study, we discussed modularity of completeness in order-sorted TRSs. We rst introduced a transformation from a TRS with overloaded function symbols to another TRS without overloaded symbols; this transformation preserves con uence and termination of TRSs. Next, we proved that sort-decreasingness is a modular property of order-sorted TRSs. Finally, we proved modularity of completeness. We also showed that con uence is generally not modular. If a TRS is not sort-decreasing, con uence may not be modular. The transformation between overloaded and non-overloaded TRSs is useful. It is expected that many properties of single-sorted TRSs are extended to ordersorted case by our transformation. References

1. Jan Willem Klop. Term rewriting systems. In S.Abramsky, D.M. Gabbai,and T.S.E. Maibaum, editors, Handbook of Logic in Computer Science, Volume 2, pages 1-116. Oxford University Press, 1992. 2. Isabelle Gnaedig, Termination of Order-sorted Rewriting. Algebraic and Logic Programming, volume 632 of Lecture Notes in Computer Science, pages 37-52 . SpringerVerlag, 1992. 3. Jan Willem Klop, Aart Middeldorp, Yoshihito Toyama, and Roel de Vrijer, Modularity of Con uence: A Simpli ed Proof. Information Processing Letters, Vol. 49, pp. 101-109, 1994. 4. C.Kirchner, H.Kirchner, and J.Meseguer, Operational semantics of OBJ-3. In Proceedings of 15th International Colloquium on Automata, Languages and Program-

ming, volume 317 of Lecture Notes in Computer Science, pages 287-301. SpringerVerlag, 1988. 5. Uwe Waldmann. Semantics of Order-Sorted Algebras. Theoretical Computer Science, 94, pages 1 - 33, 1992. 6. M. Rusinowitch. On termination of the direct sum of term rewriting systems. Information Processing Letters, 26:65-70, 1987. 7. A.Middeldorp. A sucient condition for the termination of direct sum of term rewriting systems. In Proc. 4th IEEE Symposium on Logic in Computer Science, pages 396-401, Paci c Grove, IEEE Press, 1989.