extension functions for multiset orderings

6
Information Processing Letters 26 (1987/1988) 181-186 North-Holland 4 December 19&i EXTEl’dSION FUNCTIONS FOR MULTISET ‘ORDERINGS Ursula MARTIN Department of Computer Science, University of Manchester, Manchester, United Kingdom Ml3 9PL Communicated by P. Henderson Received 10 June 1986 Revised 8 April 1987 Keywords: Multiset ordering, termination ordering, ordered multiset 1. Introduction A multiset or bag on a set S is an unordered sequence of elements of S. In [2], Dershowitz ant; Manna showed how to construct an ordering B on d(S), the set of multisets in S, from any ordering > on the underlying set S. This order which we shall call the standard multiset ordering. has proved particularly useful in proofs of pro- gram termination and in constructing ordering! which prove the termination of term-rewriting sys- tems. In this paper we shall construct many other orderings on multisets which reflect the ordering on S, and share the useful properties of multiset orderings. For proving the termination of term-rewriting systems, an ordering on S is built up incremen- tally, which makes it important that the function which transforms orders on S into orders on mu1 - tisets on S be monotonic. Such a function is callea an extension function. Both the standard multiset orderings and our new multiset orderings arise from extension functions. However, we shall de- scribe below a general technique for constructing an extension function given any map from total orders on S to orders on multisets in S. .?ouannaud and Lescanne [3] showed that the standard multiset ordering is a maximal extension function, that is, there is no other extension func- tion which gives rise to strictly stronger orderings on multisets. In this paper we are able to char- acterise maximal extension functions; they are exactly those which arise from the construction described above in the case when we consider maps from total orders on S to total orders on d(S). This means that there are mazy maximal extension functions and our new multiset order- ings provide examples. 2. Theorems and examples We shall regard the multiset M on S as a function from S to l+J,the set of natural numbers (including 0), so that M(x) represents the number of times the element x of S occurs in the un- ordered sequence M. We may thus regard M as a vector whose entry in the coordinate correspond- ing to x is M, = M(x). For example, if M = (a, a, b), then M(a) = M, = 2. Throughout this paper, we shall assume that S is finite, although our results can obviously be extended to the in- finite case. The standard multiset ordering is defined as follows. Let > be any partial order on S, and M and N multisets. Then M B N if and only if M # N and if M(x) < N(x) for some x E S, then there is a y E S with y : x and M(y) > N(y). For example, if S = {a, b, c> and a > b, then {a, a, b} B {a, b, b, b), but {b, c} and {a, b} are not com- parable. A partial ordering > is called well founded if there is no infinite chain x, > x2 > . l * . Dersho- witz showed that if the order :, on S is well 0020-0190/87/$3.50 0 1987, Elsevier Science Publishers B.V. (North-Holland) 181

Upload: ursula-martin

Post on 28-Aug-2016

216 views

Category:

Documents


2 download

TRANSCRIPT

Information Processing Letters 26 (1987/1988) 181-186 North-Holland

4 December 19&i

EXTEl’dSION FUNCTIONS FOR MULTISET ‘ORDERINGS

Ursula MARTIN

Department of Computer Science, University of Manchester, Manchester, United Kingdom Ml3 9PL

Communicated by P. Henderson Received 10 June 1986 Revised 8 April 1987

Keywords: Multiset ordering, termination ordering, ordered multiset

1. Introduction

A multiset or bag on a set S is an unordered sequence of elements of S. In [2], Dershowitz ant; Manna showed how to construct an ordering B on d(S), the set of multisets in S, from any ordering > on the underlying set S. This order which we shall call the standard multiset ordering. has proved particularly useful in proofs of pro- gram termination and in constructing ordering! which prove the termination of term-rewriting sys- tems. In this paper we shall construct many other orderings on multisets which reflect the ordering on S, and share the useful properties of multiset orderings.

For proving the termination of term-rewriting systems, an ordering on S is built up incremen- tally, which makes it important that the function which transforms orders on S into orders on mu1 - tisets on S be monotonic. Such a function is callea an extension function. Both the standard multiset orderings and our new multiset orderings arise from extension functions. However, we shall de- scribe below a general technique for constructing an extension function given any map from total orders on S to orders on multisets in S.

.?ouannaud and Lescanne [3] showed that the standard multiset ordering is a maximal extension function, that is, there is no other extension func- tion which gives rise to strictly stronger orderings on multisets. In this paper we are able to char- acterise maximal extension functions; they are

exactly those which arise from the construction described above in the case when we consider maps from total orders on S to total orders on d(S). This means that there are mazy maximal extension functions and our new multiset order- ings provide examples.

2. Theorems and examples

We shall regard the multiset M on S as a function from S to l+J, the set of natural numbers (including 0), so that M(x) represents the number of times the element x of S occurs in the un- ordered sequence M. We may thus regard M as a vector whose entry in the coordinate correspond- ing to x is M, = M(x). For example, if M = (a, a, b), then M(a) = M, = 2. Throughout this paper, we shall assume that S is finite, although our results can obviously be extended to the in- finite case.

The standard multiset ordering is defined as follows. Let > be any partial order on S, and M and N multisets. Then M B N if and only if M # N and if M(x) < N(x) for some x E S, then there is a y E S with y : x and M(y) > N(y). For example, if S = {a, b, c> and a > b, then {a, a, b} B {a, b, b, b), but {b, c} and {a, b} are not com- parable.

A partial ordering > is called well founded if there is no infinite chain x, > x2 > . l * . Dersho- witz showed that if the order :, on S is well

0020-0190/87/$3.50 0 1987, Elsevier Science Publishers B.V. (North-Holland) 181

Volume 26, Number 4 INFORMATION PROCESSING LETTERS 4 December 1987

founded, then the ordering Z+ on A(S) is also well founded, so that in particular B is well founded when S is finite. It is also very easy to see that B inherits the order > . In general, an order D on A(S) is said to inherit the order > on S if {x} D (y) whenever x > y. The inheritance prop-

erty ensures that the order on d(S) is related in some way to the order on S.

We regard the set of all partial orders on S, which we denote by O(S), as a set that is partially ordered by the inclusion relation C , where >1 c >2 if and only if M >r N implies M >2 N. We shall need to consider the intersection of two partial orders >r and >2 ; this is the partial order > 3 defined by M >3 N if and only if M >, N and M + N. If S is finite, then we shall prove the following theorem.

2.1. Theorem. If 1 S ] = n, then every partial order on S is the intersection of at most n total orders on S.

For example, the partial order a > b on the set (a, b, c) is the intersection of the two total orders a>b>candc>a>b.

We may regard the standard multiset ordering as a function f from U(S) to O( .&Y(S)), given by f(B)= z+ . It is a monotonic function, that is, if ‘, = ‘2 9 then f( >, ) c f( + ). We shall call a function from O(S) to 0(&(S)) an extension func- tion if it is monotonic, and an hereditary extension function if it is monotonic and each order > on S is inherited by f( > ). Thus, the multiset ordering is an heredl tary extension function. We shall prove the following result, which allows us to construct a great many other extension functions.

2.2. Theorem. Let f be a function which assigns to each total ordering > on S an ordering f ( B ) on A??(S). L&t

g,: W) + I

be defined @v

gfb)=nwh > a total ordering on E,

rc>).

Then, g, is an extension function, and if f( > ) al;uuys inherits > , then g f is an hereditary exten- sion fun&on .

182

AS an example, Jouannaud and Lescanne [3] showed that when f( > ) is the lexicographic order- ing on multisets regarded as lists, g, ( > ) is the usual multiset ordering z+ . The orderings we describe in this paper give rise to other examples.

An extension function g is said to be maximal if any extension function h with g( > ) E h( > ) for all orderings > E O(S) is equal to h. For example, Jouannaud and Lescanne showed that the multiset ordering is a maximal extension function. The next result characterises maximal extension fuqc- tions.

2.3. Theorem. Let k be an extension function. Then, k is a maximal extension function if and on4

if

k=g,,

where f is a function from total orders on S to total orders on A!(S). Furthermore, the maximal exten- sion function k is hereditary if and only if, in addition, f( > ) inherits > for each total order > .

It follows from this result that the standard multiset ordering is a hereditary maxima! exten- sion function; we shall construct some others be- low.

Now for our new multiset orderings. Let A be an n x n matrix over I’V indexed by the elements of S. If i and j are in S, the (i, j)th entry of A will be denoted by a,. If M is a multisct on S, let [AM] denote the usual matrix product of A and M, so that [AM], =CjaijMj, dn element of f+J. Thus, [AM] is a multiset on S, with [AM](i), the number of times i occurs in the multiset, equal to [AM],. Then, define the ordering f,( > ) on A(S) by

Mf,( >)N if and only if [AM] > [AN].

If A is the identity matrix, then fA( >) is the standard multiset ordering but, in general, it is not.

For example, let S = (x, y} with x > y and let

A=; bd. ( 1

Then,

Mf,( >)N * aM, + bM, > aN, + bN,,

or aM, + bM, = aN, + bN,

and CM, + dM, > cN, + dN,.

Volume 26, Number 4 INFORMATION PROCESSING LETTERS 4 December 1987

If

Mf,(>)NoM,+M,>N,+‘iu,

orM,+M,=N,+N,

and M, > N,.

So, in this ordering (y, y ) is larger than (x}, whereas in the standard multiset ordering it is smaller.

We shall show that f,( > ) is a well founded ordering on A(S) provided that A is invertible, and that the map f, from O(S) to 0(&Y(S)) is a maximal extension function.

To see whether fA( >) inherits > we consider the columns of the matrix A, which can of course be regarded as multisets.

2.4. Theorem. Let A be an invertible matrix index- ed by the elements of S, and let the column with index i be A i. Then, fA( > ) inherits > if and only if Ai >> Aj whenever i > j.

For example, let S = (x, y ) with x >1 y and let

A=; II. ( 1

Then, fA( >1 ) izrherits >1 if and only if A, >, >, A,, that is, if and only if a > c or a = c and b > d. If y > 2 x, rhen fA( + ) inherits + if and only if A, + b2 A,, that is, if and only if d > c or d = c and b > a. Thus, if a > b and d > c (for example, if A is the identity), then both orderings are inherited, and fA is an hereditary maximal exten- sion function.

This example is a special case of the next rest&, which describes a class of matrices A for which fA is an hereditary maximal extension function.

2.5. Theorem. Let A be an invertible n x n matrix over N and suppose that for each i we have

ail = ai, = - l l = a, i_l = a, i+, = - -. = ai, < aii. .

Then, f, is an hereditary maximal extension func- tion.

There is another way of using these orderings f, to construct hereditary maximal extension func- tions; wt: apply Theorem 2.3. We obtain the fol- lowing result.

2.6. Theorem. Let S be a finite set with 1 S 1 = n.

For each possible total ordering > on S pick an n X n matrix A, with columns indexed by the elements of S and such that if i ) j, then (A , ) i >>

(A , )j. Then, let f( > ) be f, z ( > ) for each total ordering > , and g, be defined as in Theorem 2.3. Then, gf is an hereditary maximal extension func- tion.

3. Partially ordered sets

In this section we show that any partial order- ing can be embedded in a totaJ ordering with certain properties, and that any partial ordering on a finite set E is the intersection of at most 1 E 1

total orderings.

3.1. Lemma. Let > be a partial order on a set E, and let x be an element of E. Then there is a total order D on E such that if b > a, then br> a and if bDx, then b > x.

Proo!. Any partial order can be embedded in a total order. Let U = (u E E lu < x} with the order inherited from E; embed this order in a total order > on U. Let W = E\ (U U (x}} with the order inherited from E; embed this in a total order )1 on W. Now, let D be the transitive closure of

> u >, u ((x, w) Iw E w) u ((u, x) Ix E u).

It is easy to see that D has the required properties. Cl

NOW we can show that any partial order is an intersection of total orders.

3.2. Theorem ( = Theorem 2.1). Any partial order on a finite set E is the intersection of at most ! E I

total orderings on E.

Volume 26, Number 4 INFORMATION PROCESSING LETTERS 4 December 1987

proof. We use induction on 1 E I. If 1 E 1 = 2, the result is clear. Now let m be a minimal element of E under the partial order > ) so that if s is in E, then s A m. Embed > in a total order >i on E with the property that if t + m, then t > m. Now delete m from E leaving an induced order > * on E* = E\(mj, with the property that >* = >; u - - l u >; , where XJ ,. . ., >x are total orders on E*. Construct new orders + ,. . . p >,, on E

by appending to each >r the relations x + m for all x # m. It is claimed by the present author that > =>i u *** U>“.

Clearly, >c>, and >C>i for2<i<n,so > c >i u l l - u >” = 9 . Suppose on the other hand that b 9 a. If a, bE E*, then b>T a for 2<i<n, so b>* a so b>a. If b>+ m, then b >i m so b > m. If m 9 b, then m + b which is impossible. Thus, 9 c > as required. 0

4. The orderings f,

In this section we show that fA( >) is an order- ing, and investigate when it inherits > .

4.1. Lemma. If A is invertible, then fA( > ) is a well founded ordering and f, is an extension function.

Proof. Since X+ is an ordering, f,( > ) will be an ordering provided that the map M + [AM] is in- jective, which it is since A is invertible. Since S is finite, s is well founded by Dershowitz and Manna’s result [2], and so f,( > ) is well founded, since any infinite chain under fA( > ) is also an infinite chain under B . If > c + and Mf,( > )N,

then [AM] z++ [ANj so [AM] X- [AN] since the multiset ordering is an extension function. Thus, Mf,( >-)N, and so f,% is monotonic; in other words, f, is an extension function. 51

4.2. Theorem ( = Theorem 2.4). Let A be QU invert- ible matrix over N indexed by the elements of S, and kt the column with index i be A i. Then, fA( =, ) inherits > if and only ~Ai >> A j whenever i > j.

I+&. Let M and N correspond to the multisets consisting of the single elements {i} and {j} re-

spectively, so that M(i) = N(j) = 1 and M(u) =

184

N(v) = 0 otherwise. Then, [AM] = Ai and [AN] = Aj, and the result follows from the definition. Cl

5. Extension functions

In this section we describe a way of construct- ing extension functions. We proceed as follows. Let f be a function which assigns to each total ordering > on S an ordering f( > ) on J?(S). ‘We define an extension function

g,: m) + +w) bY

gfb)=nw)l > a total ordering on S,

rc>}.

For example, Jouannaud and Lescanne [3] showed that when f( > ) is the lexicographic order- ing on multisets regarded as lists, gf( >) is the usual multiset ordering B .

We first show that g, is an extension function, and inherits ;__ ._1__ yrvrJrr cIvO from f. We then i6vtnin nrmwrt~~c

characterise maximal extension func!ions, and hereditary maximal extension functions, $?nd show that our extension functions f, are maximal, and in some circumstances hereditary.

5.1. Theorem ( = Theorem 2.2). Let f be a function which assigns to each total ordering > on S an ordering f( > ) on Al(S). Let

be given by

~r(~)=nub~l > a total ordering on S,

req.

Then the following hold: (1) g, is an extension function. (2) If f( > ) inherits > for each total order >

on S, then g, ( > ) inherits > for each order > on S.

(3) If f( > ) is well founded for each total order > on S, then g,. ( ) ) is well founded for each order > on S.

Volume 26, Number 4 INFORMATION PROCESSING LETTERS 4 December 1987

(4) If h is any extension function on S and h( > ) c f( > ) for all total orderings > , then h( > ) c g f( > ) for all orderings > . In particular, if f itself is an extension function, then f( > ) c g f ( > ) for all orderings > on S, and f( > ) = g, ( > ) if > is total.

Proof. (1) If >I c >z , then any total ordering which contains + also contains >i so that

k( > ) C g, ( > ) for each ordering > . It remains to show that k( > ) is a total order whenever > is. If not, define a new extension function h by h( > ) = k( > ) if > is not total, and h( > ) is any total ordering on d(S) which contains k( >) if > is total. Then, k( > ) c h( > ) for each > so, by maxi- malify, k( > ) = h( ) ). Thus, k( > ) is always total when > is,

g( +) = n (f( > ) 1 > total, >r c > 1

cn(f(>)] Btotal, + c>) =g(>,).

If f inherits every total order > , then, by (2) of Theorem. 5.1, g, = k is hereditary. Conversely, if g, is hereditary and > is total, then g, ( > ) = f( > ), so f( c) inherits > . q

Thus, g, is ail extension function. (2) If i >i j, then i > j for all total orders >

with )i c > , so that (i) f( > ) (j) and hence

(iI gOi ) (j)*

We can now show that the function fA defined in Section 2 is a maximal extension function, and hereditary under certain restrictions on A.

(3) This is immediate since anv infinite chain under g, ( )i ) must be an infinite chain under

f(‘)* (4) If >, c > where > is a total order. then

L(>,)c h( ) > since h is an extension function. Thus, h(>, ) c g,(>, )e 0

5.3. Theorem ( = Theorem 25). Let A be an invert- ible n x n matrix over N. Then, fA is a maximal extension function, and xf,(> )y if and only if x f,( ) )y for all total orderings > on S containing > . If further for each i we have

The theorem enables us to character&e maxi- mal extension functions.

ai, = a,, = - l . = ai i_, = ai i+l 9 . = . - l = ai, > aii,

thIen f, is an hereditary maximal extension func- tion.

5.2. Theorem ( = Theorem 2.3). Let k be an exten- sion function. Then, k is a maximal extension func- tion if and only if

k = g,,

where f is a function from total orders on S to total orders on A’(S). Furthermore, the maximal exten- sion function k is hereditary if and only if, in addition, f( > ) inherits > for each total order > .

Proof. Let f = f,. We shall show that f = g,. We know by (4) of Theorem 5.1 that f( >) c gf( >) for all orderings > on S, so it remains to show that

gfw c fP)* s uppose that Mg,( > )N, and that [AM]i <. LAN] i for some i in S. By Theorem 3.2 there is a total ordering + on S such thnt > c > and x > i whenever x > i. Since Mg, ( > )N, we have Mf( r )N, so there is an element j of S with j > i and [AM]j > [AN]j. Since j >- i we also have j >i, and so Mf(>)N. Thus, g,(:*)C f(>).

Proof. To show that gf is a maximal extension function, suppose that q is an extension function with g,( >) c q( >) for each ordering > on S. If > is total, then f( > ) = gf ( > ) = q( > ), since f( > ) is total. Thus, by (4) of Theorem 5.1, q( > ) c g, ( > ) for any ordering > , so that q = g,. Thus, g f is a maximal extension function.

To show that f is hereditary it suffices, by Theorem 4.2, to show that A i Z+ Aj whenew~

i > j. Thus, we need to show that if a,i < a tj, then there is an s > t with it,i > a,j. NOW the structure of A ensures that if a,i c a tjq then t = j, SO setting s = i will suffice. Cl

On the other hand, if k is a maximal extension Since the ordering f, is just the standard multi-

function, then k = gk since, by (3) of Theorem 5.1, set ordering when A is the identity matrix, we

185

Votume id, Number 4 INFORMATION PROCESSING LETTERS 4 December 1987

have an alternative proof of Jouannaud and Lescanne’s result.

References

[l] N. Dershowitz, Termination of rewriting, J. Symbolic Com- putation 3 (1987) 69-116.

5.4. Corolhy. The standard multiset ordering is a maximal hereditary extension function.

[2] N. Dershowitz and Z. Manna, Proving termination with multiset orderings, Comm. ACM 22 (1979) 465-476.

[3] J.-P. Jouannaud and P. Lescanne, On multiset orderings, Inform. Process. Lett. 15 (1982) 57-63.

186