This paper attempts to fill the lacuna using an elegant approach of Fitting, following Kripke[10] who brought together Kleene's multivalued logics [9], and Tarski's.
F i t t i n g Semantics for C o n d i t i o n a l T e r m R e w r i t i n g Chilukuri K. Mohan School of Computer and Information Science Syracuse University, Syracuse, NY 13244-4100
Abstract This paper investigates the semantics of conditional term rewriting systems w i t h negation, which may not satisfy desirable properties like termination. It is shown that the approach used by F i t t i n g [5] for Prolog-style logic programs is applicable in this context. A monotone operator is developed, whose fixpoints describe the semantics of conditional rewriting. Several examples illustrate this semantics for non-terminating rewrite systems which could not be easily handled by previous approaches.
1
Introduction
Conditional term rewriting systems ( C T R S ) have attracted much attention in the recent past as a useful generalization of the simpler formalism of term rewriting systems (TRS). B u t C T R S have not been unconditionally accepted, due to the absence of well defined semantics for conditional rewriting mechanisms. This paper suggests one remedy, following the approach of Melvin F i t t i n g , who suggested similar semantics for Prolog-style logic programs [5]. Past work on the semantics of conditional t e r m rewriting has followed three directions: 1. Impose restrictions on the syntax of the C T R S formalism to ensure termination and the existence of a unique precongruence which is considered to describe the meaning of the rewrite relation [8]. This approach does not define the meaning of rewriting when the C T R S does not satisfy the relevant termination criterion. Also, the termination criterion itself is undecidable, and is not a necessary condit i o n for each rewrite step and all rewrite sequences to terminate finitely. 2. Give logical semantics for a C T R S R as a set of conditional equations £(R) £(R) together w i t h a set of "default" negative equality literals [13]. This approach is useful if all rewrite sequences terminate or if the C T R S is intended to describe a specification based on a set of free constructor functions. 3. Transform C T R S into "equivalent" T R S , and ident i f y the semantics of the C T R S w i t h that of the
transformed systems [1]. Assign an " i n i t i a l algebra" semantics for T R S . The drawback of this approach is that it does not adequately describe the operational use of C T R S w i t h negative literals in the antecedents of rules. This paper attempts to fill the lacuna using an elegant approach of F i t t i n g , following Kripke[10] who brought together Kleene's multivalued logics [9], and Tarski's lattice-theoretical fixpoint theorem [16]. F i t t i n g [5] uses this approach to present an alternative to the semantics of logic programming given by A p t and Van Emden [2]. The main contribution of this paper is to show that this approach can also successfully explain the meaning of conditional rewriting systems w i t h negation, including the problematic C T R S whose semantics have eluded the grasp of previous approaches In the next section, we introduce C T R S and point out the deficiencies of a two-valued fixpoint semantics. In section 3, following some mathematical preliminaries, we describe the new semantics for conditional rewriting. Several examples are then given in section 4 to illustrate the semantics. References follow concluding remarks.
2 2.1
Preliminaries Conditional Rewriting
We define the formalism and operational use of a language for expressing data type and function specifications [13, 8]. D e f i n i t i o n 1 Equational-lnequational-Conditional Term Rewriting Systems (EI-CTRS) are finite sets of rules of the general f o r m
where Ihs and rhs are two terms, and the antecedent is a conjunction of zero or more equations s i = t i and negated equality literals Every variable occurring in each and rhs must also occur in Ihs. Following the notation of refers to the subterm o f p a t position j , and ' p [ q ] j ' refers t o the result of replacing by q in p. For instance, when positions are described in Dewey deci m a l notation, and
Mohan
857
Besides m a t c h i n g a n d r e p l a c e m e n t , c o n d i t i o n a l r e w r i t i n g requires c h e c k i n g t h a t t h e a n t e c e d e n t o f a r u l e h o l d s . T h e basic i d e a u n d e r l y i n g t h e d e f i n i t i o n o f E l - r e w r i t i n g i s t o c o n c l u d e t h a t t w o t e r m s are e q u a l i f t h e y have c o n v e r g i n g r e d u c t i o n sequences, a n d n o t e q u a l o t h e r w i s e (for g r o u n d t e r m s ) . N o t surprisingly, the a t t e m p t t o f i n d a v a l l e y - p r o o f f o r a n e q u a l i t y does n o t a l w a y s t e r m i n a t e . B u t i f r e d u c t i o n sequences f r o m t w o g r o u n d t e r m s p , q d o t e r m i n a t e w i t h o u t c o n v e r g i n g , t h e n w e can assert t h a t p = q has no ' v a l l e y - p r o o f u s i n g t h e g i v e n r e w r i t i n g system. V a r i a b l e s in d i f f e r e n t rules are f i r s t r e n a m e d to be dist i n c t f r o m each o t h e r a n d f r o m those i n t h e t e r m t o b e El-reduced. D e f i n i t i o n 2 : A t e r m m E I - R e d u c e s ( o r EI-Rewrites) to n using an E I - C T R S R ( w r i t t e n if R contains a rule a n d t h e r e is a s u b s t i t u t i o n a m a t c h i n g Ihs w i t h a s u b t e r such t h a t each of the f o l l o w i n g conditions h o l d :
1. Match and Replace: 2 . D e m o n s t r a b l e Convergence: For each e q u a l i t y cond, t h e r e is a c o m m o n t e r m to w h i c h and can b e E l - r e d u c e d i n a f i n i t e n u m b e r o f steps. 3. D e m o n s t r a b l e Non-Convergence: For every n e g a t e d equality literal cond, i t can b e d e m o n s t r a t e d b y f i n i t e E l - r e w r i t i n g sequences t h a t and are g r o u n d t e r m s w i t h n o c o m m o n r e d u c t . M o r e precisely, t h e f o l l o w i n g c o n d i t i o n s m u s t h o l d : (i) and are g r o u n d t e r m s ; ( i i ) a l l E l - r e w r i t i n g sequences f r o m and terminate; and ( i i i ) t h e set o f a l l r e d u c t s o f is disjoint f r o m that of For a m o r e d e t a i l e d d e s c r i p t i o n o f E l - r e w r i t i n g w i t h e x a m p l e s , see [14]. 2.2
Fixpoint Semantics
D e f i n i t i o n 3 If / is a f u n c t i o n ( o f one a r g u m e n t ) whose d o m a i n a n d r a n g e are t h e s a m e , t h e n S is a f i x p o i n t ( o r fixed p o i n t ) of / w h e n e v e r f(S) = 5. If t h e d o m a i n e l e m e n t s are p a r t i a l l y o r d e r e d , / m a y have zero o r m o r e p a r t i a l l y ordered fixpoints: - a f i x p o i n t S is m i n i m a l if t h e r e is no o t h e r f i x p o i n t T such in the ordering; - a m i n i m a l f i x p o i n t S is t h e least f i x p o i n t if , for every fixpoint; - a f i x p o i n t S is m a x i m a l if t h e r e is no o t h e r f i x p o i n t T such t h a t in the ordering; - t w o f i x p o i n t s S, T are c o m p a t i b l e if t h e y have a c o m m o n upper b o u n d which is a fixpoint, - a f i x p o i n t is intrinsic [10] (or o p t i m a l [12]) i f f it is c o m p a t i b l e w i t h every f i x p o i n t o f / . In the f i x p o i n t semantics approach, the 'meaning* of a p r o g r a m is considered to be t h e least fixpoint of a f u n c t i o n / r e l a t i o n w h i c h represents t h e b e h a v i o r o f t h e p r o g r a m on some i n p u t . T h e following fixpoint semantics can be suggested f o r c o n d i t i o n a l r e w r i t i n g , as in [8]. A function R is associated w i t h each C T R S R such t h a t if S is a b i n a r y r e l a t i o n , a n d is i t s reflexive t r a n s i t i v e
856
Logic Programming
Mohan
859
K e y O b s e r v a t i o n : The fixpoints of describe the semantics of conditional rewriting with an EI-CTRS R; particularly important are the least fixpoint and the largest intrinsic fixpoint. We now investigate the fixpoints of the monotone relation corresponding to each rewrite system R.
860
Logic Programming
Mohan
861
5
Conclusions
W e have i n v e s t i g a t e d t h e f i x p o i n t s e m a n t i c s o f c o n d i tional t e r m r e w r i t i n g systems w i t h negation. Twov a l u e d s e m a n t i c s does n o t ascribe a m e a n i n g t o C T R S ' s t h a t d o n o t s a t i s f y useful p r o p e r t i e s such a s t e r m i n a t i o n . W e have s h o w n t h a t a t h r e e - v a l u e d a p p r o a c h used b y F i t t i n g [5] f o r P r o l o g - s t y l e l o g i c p r o g r a m s i s a p p l i c a b l e i n t h i s c o n t e x t . A m o n o t o n e o p e r a t o r is d e v e l o p e d , whose f i x p o i n t s describe t h e s e m a n t i c s o f c o n d i t i o n a l r e w r i t i n g . Several e x a m p l e s i l l u s t r a t e t h i s s e m a n t i c s for ' t r o u b l e s o m e ' r e w r i t e s y s t e m s w h i c h c o u l d n o t b e h a n d l e d easily by previous approaches. T h i s w o r k supports the cont e n t i o n t h a t r e s u l t s achieved i n research o n P r o l o g - s t y l e logic p r o g r a m m i n g can b e u s e f u l i n t h e c o n t e x t o f c o n ditional term rewriting. W e have h e s i t a t e d t o say w h e t h e r i t i s t h e least f i x p o i n t o r t h e greatest i n t r i n s i c f i x p o i n t w h i c h b e t t e r describes t h e s e m a n t i c s o f t h e E I - C T R S . T h e e x a m p l e s m a y m o t i v a t e a preference for one o r t h e o t h e r . T h e o p e r a t i o n a l m e c h a n i s m described i n [13] a n d [8] c o m p u t e d m e m b e r s o f t h e least f i x p o i n t . T o c o m p u t e t h e greatest i n t r i n s i c f i x p o i n t , we need a d i f f e r e n t o p e r a t i o n a l m e c h a n i s m w h i c h uses " d i s j u n c t i v e r e w r i t i n g " [15] (cf. exa m p l e 9) as w e l l as a m e c h a n i s m w h i c h r e t u r n s f a i l u r e i n some cases w h e n n a i v e e v a l u a t i o n o f t h e antecedent leads t o n o n - t e r m i n a t i o n (cf. e x a m p l e 5 ) . T h e f o r m u l a t i o n o f such a r e w r i t i n g m e c h a n i s m , w h i c h c o m p u t e s precisely t h e greatest i n t r i n s i c fixpoint, is an issue f o r f u t u r e w o r k . I n n o n - c o n t r o v e r s i a l cases, w h e n t e r m i n a t i o n r e q u i r e m e n t s are s a t i s f i e d , t h e least f i x p o i n t a n d t h e greatest i n t r i n s i c f i x p o i n t c o i n c i d e (cf. e x a m p l e s 3 , 4 , 7 ) . a n d are e s s e n t i a l l y e q u i v a l e n t t o t h e s e m a n t i c s g i v e n i n p r e v i o u s w o r k for such w e l l - b e h a v e d r e w r i t e s y s t e m s .
Acknowledgements T h e a u t h o r t h a n k s M e l v i n F i t t i n g a n d a n o n y m o u s referees f o r t h e i r c o m m e n t s o n t h e p a p e r .
References [1] H . A i d a a n d J . M e s e g u e r . " G e t t i n g R i d o f C o n d i t i o n a l E q u a t i o n s " . P r o c . Second I n t ' l . W o r k s h o p o n C o n d i t i o n a l and T y p e d T e r m R e w r i t i n g Systems, M o n t r e a l , J u n e 1990. [2]
K . R . A p t and M.H.Van E m d e n . "Contributions to t h e T h e o r y of L o g i c P r o g r a m m i n g " . Journal of the Assoc. Computing M a c h . , v o l . 2 9 , p p . 8 4 1 - 8 6 2 , 1982.
[3]
K . L . C l a r k . "Negation as Failure" in H.Gallaire and J . M i n k e r ( e d s ) : "Logic and D a t a Bases". Plenum Press, N . Y . , 1978.
[4] N . D e r s h o w i t z a n d J . - P . J o u a n n a u d . " R e w r i t e Syst e m s " i n " H a n d b o o k o f T h e o r e t i c a l C o m p . Science". A c a d e m i c Press, 1989. [5] M . F i t t i n g . " A K r i p k e - K l e e n e S e m a n t i c s for L o g i c Programs". Journal of Logic Programming, vol.4, p p . 2 9 5 - 3 1 2 , 1985. [6]
M . F i t t i n g . "Notes on the M a t h e m a t i c a l Aspects of K r i p k e ' s T h e o r y of T r u t h " . Notre Dame Journal of Formal Logic, v o l . 2 7 , n o . l , p p . 7 5 - 8 8 , J a n . 1986.
[7] S . K a p l a n . " S i m p l i f y i n g C o n d i t i o n a l T e r m R e w r i t i n g Systems: U n i f i c a t i o n , T e r m i n a t i o n and Conflue n c e " . R a p p o r t d e Recherche n o . 194, U n i v e r s i t e d e P a r i s - S u d , N o v . 1984. [8] S . K a p l a n . " P o s i t i v e / N e g a t i v e C o n d i t i o n a l R e w r i t i n g " . Proc. First I n t ' l . Workshop on Conditional T e r m R e w r i t i n g Systems, Paris, Springer-Verlag L N C S 3 0 8 , 1987. [9] S . C . K l e e n e . " I n t r o d u c t i o n t o M e t a m a t h e m a t i c s " . V a n N o s t r a n d , N e w Y o r k , 1952. [10] S . K r i p k e . " O u t l i n e o f a T h e o r y o f T r u t h " . J . Philosophy v o l . 7 2 , p p . 6 9 0 - 7 1 6 , 1975. [11] R . K o w a l s k i . " P r e d i c a t e L o g i c as a P r o g r a m m i n g Language". 1FIP I n f o . Processing, N o r t h - H o l l a n d , p p . 5 6 9 - 5 7 4 , 1974. [12] Z . M a n n a a n d A . S h a m i r . " T h e T h e o r e t i c a l A s p e c t o f t h e O p t i m a l F i x e d P o i n t " . SIAM J. of Computing, v o l . 5 , p p . 4 1 4 - 4 2 6 , 1976. [13] C . K . M o h a n a n d M . K . S r i v a s . " C o n d i t i o n a l Specifications w i t h Inequational A s s u m p t i o n s " . Proc. First I n t ' l . Workshop on Conditional Term Rewriti n g S y s t e m s , P a r i s , S p r i n g e r - V e r l a g L N C S 308, 1987. [14] C . K . M o h a n a n d M . K . S r i v a s . " N e g a t i o n i n C o n d i t i o n a l T e r m R e w r i t i n g " , i n R.Wilkerson (ed.): " A d vances i n L o g i c P r o g r a m m i n g a n d A u t o m a t e d Reas o n i n g " ( t o a p p e a r ) , A b l e x Press, 1 9 9 1 . [15] D . P l a i s t e d . " C o n f l u e n c e a n d R e d u c t i o n P r o p e r ties o f C o n d i t i o n a l T e r m R e w r i t i n g S y s t e m s " . M a n u s c r i p t , 1985. [16] A . T a r s k i . " A l a t t i c e - t h e o r e t i c a l a n d i t s a p p l i c a t i o n s " . Pacific p p . 2 8 5 - 3 0 9 , 1955.
862
Logic Programming
fixpoint theorem J. Math., vol.5,