On Constructor-based Graph Rewriting Systems R. Echahed J.C. Janodet IMAG-LSR, CNRS B.P.72 Cedex F-38402 Grenoble France fechahed,
[email protected] Research Report IMAG 985-I
Draft of October 8, 1997
Abstract
We address the problem of graph rewriting as the underlying operational semantics of rule-based programming languages. We de ne a new optimal graph rewriting strategy in the setting of orthogonal constructor-based graph rewriting systems. For this purpose, we rst characterize a subset of graphs, called admissible graphs. A graph is admissible if none of its de ned operations belongs to a cycle. We then prove the con uence, as well as the con uence modulo bisimilarity (unraveling), of the admissible graph rewriting relation. Finally, we de ne a sequential graph rewriting strategy by using Antoy's de nitional trees. We show that the resulting strategy computes only needed redexes and develops optimal derivations w.r.t. the number of steps.
On Constructor-based Graph Rewriting Systems R. Echahed J.C. Janodet IMAG-LSR, CNRS B.P.72 Cedex F-38402 Grenoble France fechahed,
[email protected]
Abstract
We address the problem of graph rewriting as the underlying operational semantics of rule-based programming languages. We de ne a new optimal graph rewriting strategy in the setting of orthogonal constructor-based graph rewriting systems. For this purpose, we rst characterize a subset of graphs, called admissible graphs. A graph is admissible if none of its de ned operations belongs to a cycle. We then prove the con uence, as well as the con uence modulo bisimilarity (unraveling), of the admissible graph rewriting relation. Finally, we de ne a sequential graph rewriting strategy by using Antoy's de nitional trees. We show that the resulting strategy computes only needed redexes and develops optimal derivations w.r.t. the number of steps.
1 Introduction Graph rewriting is being investigated in various areas nowadays (see for instance [Cou93, ET96, SPvE93]). In this paper, we consider graph rewriting as the underlying operational semantics of rule-based (functional or logic) programming languages (e.g. [PvE93, AEH+ 96]). There are many reasons that motivate the use of graphs. They actually allow sharing of subexpressions which leads to ecient computations. They also permit to go beyond the processing of rst-order terms by handling eciently real-world data types represented by cyclic graphs. Using a graph rewriting system (GRS) is not an easy task. Indeed, the classical properties of term rewriting systems (TRS) cannot be lifted without caution to GRSs. One of these properties is con uence. Let us consider the rule F (a; a; x) ! x where a is a constant and x is a variable. This rule, which constitutes an orthogonal TRS, generates a con uent rewrite relation over ( nite or in nite) terms whereas it generates a non con uent rewrite relation over graphs as it is witnessed by the following counter-example [KKSV94]. The graph K (cf. gure 1) rewrites into two syntactically dierent graphs K1 and K2 . But, K1 and K2 cannot rewrite to a same graph. It is well-known F a
F
F a
a
K1
F
a
K
F a
a
a
F a
a
K2
Figure 1: that this source of noncon uency of GRSs comes from the so-called \collapsing rules" in orthogonal GRSs. A rewrite rule is collapsing if its right-hand side is a variable. However, collapsing rules are very often used in programming and thus cannot be prohibited in any programming discipline. Most of access functions are de ned by means of collapsing rules, e.g.,
car (cons (x,u)) -> x cdr (cons (x,u)) -> u left-tree (bin-tree (l,x,r)) -> l right-tree (bin-tree (l,x,r)) -> r
In practice, many programming languages are constructor-based, i.e., operators called constructors, which are intended to construct data structures are distinguished from operators called de ned operators which are de ned by means of rewrite rules. In this paper, we follow this discipline and consider orthogonal constructor-based GRSs. We investigate the induced rewrite relation over a particular class of graphs called admissible graphs. An admissible graph is a graph whose cycles do not include de ned functions. We give a sucient (syntactic) condition which ensures that the set of admissible graphs is closed under rewriting. Then, we show the con uence of admissible graph rewriting relation even in the presence of an arbitrary amount of collapsing rules. It is notorious that nite graphs represent rational terms. Sometimes, one would like to equate two graphs if they represent the same rational term. In this case we say that the two graphs are bisimilar (if we refer to the theory of concurrency). We show the con uence modulo bisimilarity of the considered GRSs. This result is mandatory to prove the completeness of narrowing [EJ97]. The con uence of a rewrite relation allows to evaluate expressions in a deterministic and ecient way by using rewriting strategies. Such strategies have been well investigated in the setting of nite and in nite orthogonal TRSs (e.g., [O'D77, HL91, KKSV95]). In [Ant92], a strategy that computes outermost needed redexes based on de nitional trees has been designed in the framework of orthogonal constructor-based TRSs. In this article, we show that Antoy's strategy can be extended to orthogonal constructor-based GRSs with the same nice properties. We particularly prove that the resulting strategy is c-hyper-normalizing on the class of admissible graphs and develops shortest derivations. The rest of the paper is organized as follows. The next section contains some preliminaries on graphs. In section 3, we introduce the framework of constructor-based GRS. Section 4 exhibits the results concerning con uence and section 5 deals with con uence modulo bisimilarity. We de ne our rewriting strategy in section 6 and list its properties.
2 Preliminaries on graphs The aim of this section is to precise the de nitions we use in our paper. Many dierent notations are used in the literature to investigate graph rewriting : systems of equations [AK96], hypergraphs [HP95], graphs [KKSV94] among others. We are mostly consistent with [BvEG+ 87].
2.1 De nition of graphs
De nition 1 (Signature)
A many-sorted signature = hS; i consists of a set S of sorts and an S -indexed family = ]s2S s with s = ](w;s)2S S w;s of sets of operation symbols. We shall write f : s1 : : :sn ! s whenever f 2 s1 :::sn ;s and say that f is of sort s, rank s1 : : :sn and pro le s1 : : :sn ; s. 2 We consider a graph as a set of nodes and edges between the nodes. Each node is labeled with an operation symbol or a variable. Let X = ]s2S Xs be an S -indexed family of countable sets of variables and N = ]s2S Ns , an S -indexed family of countable sets of nodes. Both X and N are xed throughout the rest of the paper.
De nition 2 (Graph) A (rooted) graph g over h; N ; Xi is a tuple g = hNg ; Lg ; Sg ; Rootsg i such that : 2
1. Ng is the set of nodes of g , i.e., Ng = ]s2S (Ng )s with (Ng )s Ns . 2. Lg , the labeling function of g , is an S -indexed family of functions associating an operation symbol or a variable to each node of g , i.e., Lg = ]s2S (Lg )s with (Lg )s : (Ng )s ! s [ Xs . 3. Sg , the successor function of g , is an S -indexed family of functions associating a (possibly empty) string of nodes to each node of g , i.e., Sg = ]s2S (Sg )s with (Sg )s : (Ng )s ! Ng such that for every node n 2 (Ng )s : if (Lg )s(n) = f with f : s1 : : :sk ! s, then there exist n1; : : :; nk 2 Ng such that (Sg )s (n) = n1 : : :nk and ni 2 (Ng )si for all i 2 1::k. if (Lg )s(n) = c with c 2 ";s (c is a constant), then (Sg)s(n) = " (i.e., n has no successor). if (Lg )s(n) = x with x 2 Xs (x is a variable), then (Sg)s(n) = ". We write n 2 Sg (m) if n is a successor of m. 4. Rootsg is a nonempty set of distinguished nodes of g , called its roots : Rootsg Ng . 5. Every variable of g labels one and only one node, i.e., for all nodes n1 ; n2 of g , if Lg (n1 ) 2 X and Lg (n2 ) 2 X , then Lg (n1 ) = Lg (n2) implies n1 = n2 . 6. Connectivity condition : Each node of g is either a root or is accessible from a root (see de nition 3). A graph g is called term graph i it has one root Rootg (i.e., Rootsg = fRootg g). We write V(g ) for the set of variables appearing in g . 2
Example 1 In gure 2, we give two examples of graphs. Their roots are pointed by arrows
without any antecedent. The left-hand graph, G, represents a cyclic list alternating the expressions succ(0) + succ(0) and succ(0). G is a term graph, since it has just one root RootG = fx1g. Nodes of G are NG = fx1, . . . , x5g. Its labeling function is de ned by LG (x1) = LG (x5) = cons, LG (x2) = +, LG (x3) = succ, et LG (x4) = 0. Its successor function is de ned by SG(x1) = x2.x5 , SG (x2) = x3.x3 , SG (x3) = x4, SG (x4) = ", SG (x5) = x3.x1 . The right-hand graph, T represents the classical rewriting rule succ(x)+y ! succ(x+y) (cf. de nition 20). T has two roots RootsT = fl1,r1g. x1:cons
x5:cons
x2:+
l1:+ x3:succ
l2:succ
x4:0
l3:x
G
r1:succ r2:+ l4:y
T
Figure 2: Two examples of graphs.
De nition 3 (Paths)
Let g be a graph and n1 and n2 two nodes of g . We say that n2 is a successor of n1 if Sg (n1) = v1 : : :vk and there exists a j 2 1::k such that vj = n2. A path C from a node n1 to a node n2 in 3
a graph g is a sequence of nodes of g , C = [u0; u1; : : :; uk ], such that : u0 = n1 , uk = n2 , k 1, ui 2 Ng for all i 2 0::k, and ui is a successor of ui?1 for all i 2 1::k. We denote by Pg (n1 ; n2) the (possibly empty) set of paths from n1 to n2 in the graph g . We say that a node n2 is accessible from a node n1 in a graph g if there exists a path from n1 to n2 in g , i.e., if Pg (n1 ; n2) 6= ;. By de nition of a graph g , the connectivity condition says that each node is either a root or is accessible from a root : 8n 2 Ng ; n 2= Rootsg ) 9r 2 Rootsg such that Pg (r; n) 6= ;. 2 Drawings and the formal de nition of graphs are not always useful to give examples. Therefore, we de ne a linear notation. De nition 4 (Linear notation for graphs) In the following grammar, the variable A (resp. n) ranges over the set [X (resp. N ). The linear notation of a graph is de ned by : Graph ::= Node j Node + Graph Node ::= n:A(Node,. . . ,Node) j n If a graph is de ned with a linear expression, its roots are always composed of the rst node appearing in the expression and the nodes appearing just after a +. 2
Example 2 With this syntax, the graphs G and T of gure 2 are written : G = x1:cons(x2:+(x3:succ(x4:0),x3),x5:cons(x3,x1)), T = l1:+(l2:succ(l3:x),l4:y) r1:succ(r2:+(l3,l4)).
+
2.2 Subgraph, sum of graphs and graph replacement
A subgraph of a graph g rooted by a node p, denoted gjp , is built by considering p as a root and deleting all inaccessible nodes from p in g . De nition 5 (Subgraph) Let g be a graph and P a set of nodes of g . We de ne the subgraph of g rooted by P , denoted gjP , as the following graph : NgjP is the set of nodes of g accessible from nodes of P , i.e., NgjP = P [ fn 2 Ng j 9r 2 P; Pg (r; n) 6= ;g. For all nodes n of gjP , LgjP (n) = Lg (n), i.e., LgjP is the restriction of Lg to NgjP . For all nodes n of gjP , SgjP (n) = Sg(n), i.e., SgjP is the restriction of Sg to NgjP . RootsgjP = P . Given two graphs g1 and g2, we say that g2 is a subgraph of g1 if there exists a set P of nodes of g1 such that g2 = g1jP . Finally, we abbreviate g1 jfng by g1jn . 2
Example 3 In gure 2, the subgraph of G rooted by x2 is Gjx2 = x2:+(x3:succ(x4:0),x3) and the subgraph of T rooted by fl3,l4g is Tjfl3,l4g = l3:x + l4:y. The notion of replacement of a one-rooted subgraph by another term graph in a graph is essential for graph rewriting. Figure 3 shows the dierent stages of the replacement by D, whose root is r1, of the subgraph of G rooted by x2. First, as G and D share nodes (x3 and x4), we must not consider G and D as two dierent graphs but as one graph with two roots (H1 in g. 3). This operation is called the sum of graphs G and D. Second, we redirect all arrows pointing on x2 to point on r1 (H2). This operation is called pointer redirection. Notice that x2 became a root. 4
x1:cons
x5:cons
r1:succ r2:+
x2:+ x3:succ x4:0
G
D
x5:cons
x1:cons
x5:cons
x2:+
x3:succ x4:0
x1:cons
x1:cons
x5:cons
r1:succ
r1:succ
r1:succ
r2:+
r2:+
x2:+ r2:+ x3:succ
x3:succ
x3:succ
x4:0
x4:0
H1
H2
x4:0
G[x2
D]
Figure 3: Calculus of a replacement. Otherwise, the graph obtained after pointer redirection would not be connected. Finally, we ignore all uninteresting nodes such as x2 (garbage collection). The result of the replacement by D of the subgraph of G at node x2 is denoted G[x2 D]. Formally, we rst have to de ne the sum of graphs, which formalizes the fact that given two graphs, we can consider them just as one, doing the union of their nodes and of their roots. Without caution, the result of this calculus is not always a graph. This is the reason of the following technical de nition. De nition 6 (Compatibility between two graphs) Let g1 and g2 be two graphs. We say that g1 and g2 are compatible if : 1. Every node appearing both in g1 and g2 has the same label and the same successors : For all n 2 Ng1 \ Ng2 , Lg1 (n) = Lg2 (n) and Sg1 (n) = Sg2 (n). 2. Any variable appearing both in g1 and g2 labels a same node : For all x 2 V(g1) \ V(g2), if Lg1 (n) = x and Lg2 (m) = x, then n = m.
2
Example 4 Consider the graphs g1; g2 and g3 de ned by g1 = x1:f(x2:0), g2 = x2:f(x1:0) and
g3 = x3:0. The node x1 is labeled with f in g1 whereas it is labeled with 0 in g2. Hence, g1 and g2 are not compatible. The reader may check that g1 is compatible with g3, g3 is compatible with g2. From this example, we notice that the property of compatibility is not transitive.
De nition 7 (Sum of compatible graphs) Given two compatible graphs g1 and g2, by the sum, g1 + g2, we mean the graph such that : Ng1+g2 = Ng1 [ Ng2 . Lg1+g2 = Lg1 [1 Lg2 . Sg1+g2 = Sg1 [1 Sg2 . Rootsg1+g2 = Rootsg1 [ Rootsg2 .
2
1 The union of functions f and g, f [ g is to be considered as the union of the relations induced by these functions.
In our case
f [ g is still a function.
5
It is clear that a sum of graphs is a graph : the rst condition of compatibility insures Lg1 +g2 and Sg1+g2 are functions and the second condition insures a variable can label at most one node in the sum of graphs. We de ne below the notion of pointer redirection, which consists in substituting a node by another one in a graph.
De nition 8 (Pointer redirection) Let g be a graph and p , q two (not necessarily distinct) nodes of the same sort. The pointer redirection from p to q in g is a function : Ng ! Ng such that (p) = q and (n) = n for all nodes n 6= p. We de ne the graph (g ) obtained by pointer redirection as the graph (g ) such that all nodes having p as successor in g have q as successor in (g ) : N(g) = Ng . L(g) = Lg . For all nodes n, if Sg (n) = ", then S(g)(n) = ", else, if Sg (n) = n1 : : :nk , then S(g)(n) = (n1) : : :(nk). Roots(g) = fpg [ (Rootsg ), that is to say if Rootsg = fn1; : : :; nk g, then Roots(g) = fp; (n1); : : :; (nk)g. 2 It is clear that (g ) is well de ned : all conditions but connectivity are inherited from those of g ; connectivity is warranted by the fact that p 2 Roots(g). When p 2= Ng , (g ) = g . We are now ready to de ne the notion of replacement.
De nition 9 (Replacement)
Let g be a graph, u a term graph, such that g and u are compatible, and p a node of the same sort as Rootu . If p is a node of g , we de ne the replacement by u of the subgraph rooted by p in g , denoted g [p u], in three stages : 1. Let H = g + u. 2. Let be the pointer redirection, de ned on H , such that (p) = Rootu and (n) = n for all n 6= p. Let H 0 = (H ) and Q = (Rootsg ). 3. g [p u] = H 0 jQ. If p is not a node of g , then g [p u] = g . 2 Notice that if g is a graph and n is a node of g , then g [n
Example 5 We detailed in gure 3 the replacement by
D =
gjn ] = g.
r1:succ(r2:+(x4:0,x3:succ(x4))) of the subgraph rooted by x2 in the graph x1:cons(x2:+(x3:succ(x4:0),x3),x5:cons(x3,x1)). The result is the graph G[x2 x1:cons(r1:succ(r2:+(x4:0,x3:succ(x4))),x5:cons(x3,x1)).
The calculus of g [p
G = D] =
d] may have surprising results in some cases. Example 6 Let g = l1:+(l2:0,l3:0), d = r1:+(l1:+(l2:0,l3:0),r2:0), and p = l1. Then the reader may check that g [p d] = r1:+(r1,r2:0), whereas he could expect to obtain g [p d] = d. d is modi ed in g[p d] because p is a common node to g and d. 6
In the rest of this section, we give some technical properties concerning subgraphs and replacement that we use later in the proofs. These properties have rst been established in the framework of rst-order terms. Their use in our setting needs however some caution (cf. example 6). The vocabulary used is mostly borrowed from [Hue80]. We rst introduce new notations in order to compare the relative positions of two nodes in a graph. Let n1 , n2 be two nodes of a graph g . We write n1 n2 i n2 is accessible from n1 in g , i.e., Pg (n1; n2) 6= ;. We write n1 n2 i n1 n2 or n1 = n2. We say n1 and n2 are disjoint, denoted n1kn2 , i there exists no path from n1 to n2 nor from n2 to n1 in g, i.e., :(n1 n2 _ n2 n1 ), or equivalently, Pg (n1 ; n2) = Pg (n2 ; n1) = ;. Notice that is not a partial order, but just a preorder.
Proposition 1 (Double subgraph)
Let g be a graph and n1 and n2 two nodes of g . If n1 n2 , then (gjn1 )jn2 = gjn2 .
Proposition 2 (Persistence)
Let g be a graph, u a term graph compatible with g , n1 and n2 two nodes of g . If there is no path from n2 to n1 in g and there exists a path from a root of g to n2 which does not go through n1 , then (g [n1 u])jn2 = gjn2 . This proposition holds in particular when n1 kn2.
Proposition 3 (Embedding)
Let g be a graph, u a term graph compatible with g , n1 and n2 two nodes of g . If n1 2= Nu and n2 2 Nu , then (g[n1 u])jn2 = ujn2 . From the example 6, it appears that an expression such as (g [n1 u1])[n2 u2] may be not well de ned. Indeed, suppose that g is a graph compatible with two term graphs u1 and u2 . Since g is compatible with u1, g [n1 u1 ] is computable. However, this graph may be no more compatible with u2. Example 7 Let g = x1:f(x2:g(x3:0)), u1 = x4:1 and u2 = x5:h(x2:g(x3:0)) be three compatible term graphs. Then g [x3 u1 ] = x1:f(x2:g(x4:1)). This graph is no more compatible with u2 , since x2 has not the same successors in g [x3 u1 ] as in u2 . The problem is that x3 appears both in g and u2. The following proposition gives a sucient condition to avoid the above problem.
Proposition 4 Let g be a graph, n1 and n2 two nodes, u1 and u2 two term graphs such that g, u1 and u2 are compatible. If n1 2= Nu2 , then g [n1 u1] and u2 are compatible, thus (g [n1 u1 ])[n2
u2 ] is well de ned.
Proof Assume that g[n1 u1] and u2 are not compatible, whereas g, u1 and u2 are compatible.
By de nition of compatibility, there must exist a node p common to g [n1 u1 ] and u2 such that Sg+u1 (p) = Su2 (p) but Sg[n1 u1 ] (p) 6= Su2 (p). Suppose Sg+u1 (p) = p1 : : :pk . Let be the pointer redirection such that (n1) = Rootu1 and (n) = n for all n 6= n1 . Then, by de nition of replacement, Sg[n1 u1 ] (p) = (p1) : : :(pk ). Since Su2 (p) = p1 : : :pk and Sg[n1 u1 ] (p) 6= Su2 (p), there exists i 2 1::k such that (pi) 6= pi . Hence, there exists i 2 1::k such that pi = n1 . Since Su2 (p) = p1 : : :pk , then n1 2 Nu2 . Thus, if n1 is not a node of u2, then g[n1 u1] and u2 are compatible.
2
Proposition 5 (Associativity)
Let g be a graph, u1 and u2 two term graphs such that g , u1 and u2 are compatible, n1 and n2 two nodes of g such that n1 2= Nu2 . Then (g [n1 u1])[n2 u2 ] = (g [n2 u2 ])[n1 (u1[n2 u2 ])]. 7
Proof Hint : the proof is done in three stages : 1. Let 1(n1 ) = Rootu1 and 2(n2 ) = Rootu2 be two pointer redirections. Since n1 2= Nu2 , (g [n1 (g [n1
u1])[n2 u2 ] is well de ned. Then, we can show that u1])[n2 u2 ] = (2(1(g + u1 + u2)))j2 (1 (Rootsg )). 2. Let 3(n1 ) = 2 (Rootu1 ) be a new pointer redirection. (g [n2 u2 ])[n1 (u1[n2 u2 ])] is well de ned because if g and u1 are compatible, then g [n2 u2] and u1 [n2 u2 ] remain compatible. Then we can show that (g [n2 u2 ])[n1 u1 [n2 u2 ]] = (3(2(g + u1 + u2)))j3 (2 (Rootsg )).
3. Finally, we can show that for all p 2 Ng+u1 +u2 , 2(1(p)) = 3(2(p)). This proof is done by analysis of the dierent cases for p.
2
Proposition 6 (Commutativity)
Let g be a graph, u1 and u2 two term graphs such that g , u1 and u2 are compatible, n1 and n2 two nodes of g such that n1 2= Nu2 and n2 2= Nu1 . Then (g [n1 u1 ])[n2 u2 ] = (g [n2 u2])[n1 u1 ].
Proof Follows from Proposition 5 by taking into account the fact that n2 is not a node of u1. 2 Proposition 7 (Weak dominance)
Let g be a graph, u1 and u2 two term graphs such that g , u1, u2 are compatible and n1 and n2 two nodes of g such that n1 2= Nu2 and every path from a root of g to n1 go through n2 , i.e., 8r 2 Rootsg ; 8C 2 Pg (r; n1); n2 2 C . Then, (g[n1 u1])[n2 u2] = g[n2 u2].
Proof Hint : Prove that with these hypothesis, n1 is not a node of g[n2 the expression of associativity.
2.3 Homomorphisms
u2 ]. Then simplify 2
We now recall the notions about homomorphisms. They play almost the same r^ole as do substitutions for rst-order terms. De nition 10 (Homomorphism) Given two graphs g1 and g2, by a (rooted) homomorphism h : g1 ! g2 from g1 to g2, we mean any mapping h = ]s2S hs , hs : (Ng1 )s ! (Ng2 )s such that : 1. For every node of g1 which is not labeled with a variable, h preserves the labeling and the successor function : For all nodes n 2 (Ng1 )s ; (Lg )s (n) 2= X , (Lg2 )s(hs(n)) = (Lg1 )s(n). (Sg2 )s(hs(n)) = hs1:::sk ((Sg1 )s(n)), that is to say for all non variable nodes n, if (Sg1 )s (n) = ", then (Sg2 )s (hs (n)) = ", else if (Sg1 )s (n) = n1 : : :nk , where ni 2 (Ng )si for all i 2 1::k, then (Sg2 )s (hs (n)) = hs1 (n1 ) : : :hsk (nk ). 2. For all nodes n 2 (Ng1 )s ; (Lg )s (n) 2 X , hs (n) 2 (Ng2 )s . 3. The images of roots of g1 are the roots of g2 : Rootsg2 = h(Rootsg1 ), i.e., if Rootsg1 = fn1; : : :; nk g, where ni 2 (Ng )si for all i 2 1::k, then Rootsg2 = fhsi (ni) j i 2 1::kg. 8
We say that h is a variable-preserving homomorphism if h is a homomorphism between two graphs with variables treated as constants, i.e., Lg2 (h(n)) = Lg1 (n) for every node n of g1, in particular for every variable node n of g1. 2
Example 8 In gure 4, we give an example of homomorphism h from a graph
L = l1:+(l2:succ(l3:x),l4:y) to the subgraph of G rooted by x2. Formally, h is a mapping from NL to N(Gjx2 ) de ned by h(l1) = x2, h(l2) = h(l4) = x3 and h(l3) = x4. h is not a variable-preserving homomorphism since LL (l3) = x whereas LG (h(l3)) = LG (x4) 6= x. x1:cons
x5:cons l1:+
x2:+
h
x3:succ
l2:succ l4:y
l3:x
x4:0
G
L
Figure 4: Example of homomorphism. Given three graphs g1, g2 and g3 and two homomorphisms h1 : g1 ! g2 and h2 : g2 ! g3, by the composition of h1 and h2 , denoted h2 h1 , we mean the mapping h : Ng1 ! Ng3 , such that h(n) = h2(h1(n)) for all n 2 Ng1 . It is clear that h2 h1 is a homomorphism from g1 to g3. Finally, given a graph g , the identity function on Ng is a homomorphism from g to itself. An isomorphism is a bijective homomorphism.
De nition 11 (Restriction of a homomorphism) Let g1 and g2 be two graphs, h : g1 ! g2 a homomorphism, and P a set of nodes of g1 . Let hjP be the restriction of h to Ng1 jP (h is seen as a function between nodes). hjP , which remains a homomorphism from g1jP to g2jh(P ) , is called the restriction of h to g1jP . 2 Matching is essential for graph rewriting. An algorithm is given in appendix A.
De nition 12 (Matching) Given a graph g , a term graph l and a node n of g , we say that l matches g at node n, denoted l gjn , if there exists a homomorphism h : l ! gjn . h is called the matcher of l on g at node n. 2 Example 9 The homomorphism h of gure 4 is a matcher of L on G at node x2.
Finally, a precise de nition of a rewriting step requires the notion of \application" of a homomorphism h : g1 ! g2 on a graph g , denoted h(g ). This process corresponds to the application of the extension of a substitution on a rst-order term. Informally, computing h(g ) consists in replacing all shared subgraphs between g and g1 by their corresponding subgraphs in g2. This is done by pointer redirection.
Example 10 Consider the homomorphism h : L ! Gjx2 of example 8. Let R=
r1:succ(r2:+(l3:x,l4:y)).
Computing h(R) consists in replacing all subgraphs shared 9
between R and L by their corresponding subgraphs in Gjx2 . Here, R and L share subgraphs l3:x and l4:y. Their corresponding graphs by h in G are respectively x4:0 and x3:succ(x4:0). Hence, we obtain a graph h(R) = r1:succ(r2:+(x4:0,x3:succ(x4))), i.e., the graph D of gure 3. We now give a formal de nition of h(g ). First, we de ne the border between two graphs, i.e., the set of nodes where we shall execute the replacements. De nition 13 (Border) Let g and g 0 be two compatible graphs. We call border of g with respect to g 0 the set 2 B(g; g0) = fp 2 Ng \ Ng0 j p 2 Rootsg or 9q 2 (Ng ? Ng0 ); p 2 Sg (q)g. Example 11 Consider the compatible graphs g = x0:f(x1:+(x2:x,x3:y),x3) and g1 = x1:+(x2:x,x3:y). Then the border of g w.r.t. g1 is the set B(g; g1) = fx1,x3g. De nition 14 (Application of a homomorphism on a graph) Let g , g1 and g2 be three compatible graphs, h : g1 ! g2 a homomorphism and B = fp1; : : :; pk g the border of g w.r.t. g1. We suppose that B \ Ng2 = ;. The application of h on g , denoted h(g ), is de ned by : h(g) = g[p1 g2jh(p1 )] : : :[pk g2jh(pk )] Thanks to proposition 6, the condition B \ Ng2 = ; is sucient to insure the well de nedness of the expression g [p1 g2jh(p1 ) ] : : :[pk g2 jh(pk )]. 2 Example 12 Consider the three compatible graphs g = x0:f(x1:+(x2:x,x3:y),x3), g1 = x1:+(x2:x,x3:y) and g2 = y1:+(y2:0,y2), and the homomorphism h from the graph g1 to the graph g2. The reader may check that B(g; g1) \ Ng2 = ; and h(g ) = x0:f(y1:+(y2:0,y2),y2).
2.4 Graph equalities
Homomorphisms are also used to de ne equality relations on graphs. We already used the syntactic equality, denoted =, between graphs. Hereafter, we de ne two other equalities. De nition 15 (Equality up to renaming of nodes) Given two graphs g1 and g2 , we say that g1 is equal to g2 up to renaming of nodes if there exists a variable-preserving isomorphism : g1 ! g2 between g1 and g2 . We write g1 g2 or simply g1 g2. 2 With this notion of renaming, one can change nodes and variable nodes of a graph, but not variables names : the isomorphism is variable-preserving. Equality up to renaming of nodes is similar to -conversion in -calculus. We now de ne bisimilarity. Informally, two term graphs are bisimilar if they represent the same in nite tree when one unravels them. Bisimilarity is called tree-equivalence in [BvEG+ 87]. Bisimilarity between term graphs without variable is studied in [AK96]. De nition 16 (Bisimilarity) Let g1 and g2 be two term graphs. We say that g1 and g2 are bisimilar, denoted g1 =: g2, if there exists a graph g 0, and two variable-preserving homomorphisms h1 : g1 ! g 0 and h2 : g2 ! g 0. 2 Example 13 In gure 5, the left-hand and right-hand graphs are bisimilar, since there exists a variable-preserving homomorphism from each of them to the middle graph. Remark : In the de nition of graph bisimilarity, h1 and h2 are variable-preserving homomorphisms. Therefore, two graphs with dierent sets of variables cannot be bisimilar. Bisimilarity can be de ned by another way : one can prove that two bisimilar term graphs represent the same (in nite) tree when one unravels them [AK96]. 10
u1:cons
u3:cons
h1
u2:0
v1:cons
h2
w1:cons
w3:cons
w2:0
w4:0
v2:0
Figure 5: Three bisimilar graphs.
3 Constructor-based graph rewriting systems (cGRS) This section introduces the class of GRSs we consider. For practical reasons, many declarative languages use constructor-based signatures. De nition 17 (Constructor-based signature) By a constructor-based signature , we mean a triple = hS; C ; Di such that S is a set of sorts, C is an S -indexed family of sets of constructor symbols, D is an S -indexed family of sets of de ned operations, C \ D = ; and hS; C ] Di is a signature. 2 Example 14 Figure 6 shows a constructor-based signature de ning (cyclic) lists of naturals. signature list-of-nat sorts list nat
constructors
0 : ! nat succ : nat ! nat nil : ! list cons : nat list ! list
operations + : * : car cdr
nat nat ! nat nat nat ! nat : list ! nat : list ! list
end signature
Figure 6: list-of-nat signature. A graph g is called constructor if all its nodes are labeled either with variables or with constructor symbols. A term graph is said operation-rooted (resp. constructor-rooted) if its root is labeled with a de ned operation (resp. constructor symbol). In the rest of the paper, we investigate graph rewriting for the class of what we call admissible graphs. Roughly speaking, an admissible graph corresponds to nested procedures (functions) calls whose parameters are complex constructor graphs. De nition 18 (Admissible graph) A graph g is admissible i for all n 2 Ng , if Lg (n) 2 D, then Pg (n; n) = ;. 2 Example 15 The graphs G and T of gure 2 are admissible, whereas the graphs z:+(z,z) and z:cdr(cons(0,z)) are not. De nition 19 (Rewrite rule) A rewrite rule is a graph e with two roots, denoted l ! r. l (resp. r) is a term graph called the left-hand side (resp. the right-hand side) of the rule. l and r are compatible and e = l + r. We shall always assume that V(r) V(l). We say that a rule e0 is a variant of the rule e if e and e0 are isomorphic and all nodes and variables of e0 are new. 2 11
From the de nition of graphs, variables occurring in a rewrite rule are always shared between the left-hand side and the right-hand side. The graph T of gure 2 shows an example of rules. In this paper, we consider particular rewrite rules called admissible rewrite rules. Such rules are tailored so that the set of admissible graphs is stable by rewriting (see Example 19 and Proposition 9). In order to de ne these rewrite rules, we introduce below the notion of pattern.
De nition 20 (Pattern)
A term graph g is a pattern if : 1. It is operation-rooted : Lg (Rootg ) 2 D. 2. All its other nodes are labeled either with a constructor symbol or with a variable : For all n 2 Ng , if n 6= Rootg , then Lg (n) 2 X or Lg (n) 2 C . 3. There is no cycle including the root : Pg (Rootg ; Rootg ) = ;. 4. For all nodes n of g dierent from the root, there exists one and only one node m in g such that n is a successor of m : for all n 2 Ng , if n 6= Rootg , then cardinal(fm 2 Ng j n 2 Sg (m)g) = 1. In other words, a pattern is a term graph corresponding to a linear rst-order term (tree) which contains only one occurrence of de ned operation situated at its root. 2
Example 16 l1:+(l2:0,l3:0) is a pattern, whereas l1:+(l2:0,l2) is not. De nition 21 (Admissible rewrite rule) An admissible rewrite rule is a rewrite rule e = l ! r such that : 1. 2. 3. 4.
l is a pattern (thus an admissible term graph). r is an admissible term graph. l is not a subgraph of r. V(r) V(l).
2 We say that two admissible rewrite rules are non-overlapping if their left-hand sides are not uni able. This notion of uni cation is straightforward : it is the same as that for rst-order terms, since left-hand sides are patterns.
De nition 22 (cGRS)
A constructor-based graph rewriting system (cGRS) is a pair SP = h; Ri such that = hS; C ; Di is a constructor-based signature and R is a set of admissible rewrite rules such that every two distinct rules in R are non-overlapping. 2
Example 17 Figure 7 shows the set of admissible rewrite rules associated to the list-of-nat signature of gure 6.
Rewriting a graph is done in two stages. First, one computes the matcher of the left-hand side of a rule on a subgraph of the graph to be rewritten and second, the subgraph is replaced by the instantiated right-hand side of the rule. This de nition is consistent with [BvEG+ 87]. 12
rules list-of-nat
0 + l1:y ! l1 succ(l1:x) + l2:y ! l1:0 * x ! l1 succ(l1:x) * l2:y ! car( cons(l1:x,l2:l) cdr( cons(l1:x,l2:l)
end rules
Figure 7:
succ(l1 + l2) (l1 * l2) + l1 ) ! l1 ) ! l2
Rules for list-of-nat.
De nition 23 (Rewriting step) Let SP = h; Ri be a cGRS. Let g1 be an admissible graph, g2 a graph, e = l ! r a variant of a rewrite rule of R and p a node of g1 . We say that g1 rewrites to g2 at node p using the rule l ! r, denoted g1 ![p; l!r] g2, if : 1. l matches g1 at node p (i.e., l g1jp ) : there exists a homomorphism h : l ! g1 jp. 2. g2 = g1[p h(r)]. In this case, we say g1jp is a redex of g1 rooted by p. A graph is in normal form if it has no redex. A constructor graph is necessarily in normal form. !" denotes the re exive closure of ! and we + denotes the transitive say that g1 is rewritten in at most one step2 into g2 whenever g1 !" g2 . ! closure of ! and !, its transitive and re exive closure. We speak of a derivation from g1 to g2 whenever g1 ! g2. 2
Example 18 Consider the graph G and the rule T = L ! R of gure 2, where L =
l1:+(l2:succ(l3:x,l4:y)) and R = r1:succ(r2:+(l3:x,l4:y)). According to gx2 with homomorphism h. We saw in example 10 that h(R) = r1:succ(r2:+(x4:0,x3:succ(x4))). Finally, thanks to the calculus presented in gure 3, we have G[x2 h(R)] = x1:cons(r1:succ(r2:+(x4:0,x3:succ(x4))),x5:cons(x3,x1)). Let G0 be this last graph. Then, by de nition, G ![x2; L!R] G0.
ure 4, L matches G at node
We now prove the well de nedness of a rewriting step.
Proposition 8 Let SP = h; Ri be a cGRS, g1 an admissible graph, e = l ! r a variant of a rewrite rule of R and p be a node of g1 . If l matches g1 at node p, then there exists a graph g2 such that g1 ![p; l!r] g2. Proof Let h : l ! g1jp be the matcher. We must prove that the expression g1[p h(r)] is well de ned. By hypothesis, l, r and g1 jp are compatible because l and r are compatible, Nl!r \Ng1 = ; and V(l ! r) \ V(g1) = ;. Moreover, B(l; r) Nl!r so B(l; r) \ N(g1 jp ) = ;. Hence h(r) is well de ned. Let B(l; r) = fp1; : : :; pk g. By the de nition of the application of a homomorphism to a graph, h(r) = r[p1 (g1jp )jh(p1 ) ] : : :[pk (g1jp )jh(pk ) ]. This last graph is composed of nodes of r and of subgraphs of g1 , which are not modi ed by the pointer redirections (since pi 2= Ng1 for all i 2 1::k). So h(r) is compatible with g1, i.e., g1[p h(r)] is well de ned. 2 Now, we show the stability of the set of admissible graphs w.r.t. rewriting with admissible rules. The following lemma gives a sucient condition which ensures the stability of admissible graphs by replacement. 2 This notation is introduced in [Hue80]. In [Klo92], it is written
13
! .
Lemma 1 Let SP = h; Ri be a cGRS, g an admissible graph, u an admissible term graph compatible with g and p 2 Ng . If p 2= Nu , then g [p u] is an admissible graph. Proof Since p 2= Nu, we have Rootu 6 p in g + u. Thus, the pointer redirection from p to Rootu does not modify u to create a cycle on a node labeled with a de ned operation. 2 Proposition 9 Let SP = h; Ri be a cGRS, g1 an admissible graph, e = l ! r a variant of a rewrite rule of R, p a node of g1 and g2 a graph such that g1 ![p; l!r] g2. Then, g2 is an admissible graph.
Proof Let h : l ! g1jp be the matcher from the left-hand side of the rule on g1 at node p. Thanks to
Proposition 8, we know that g2 = g1 [p h(r)] is well de ned. Let us prove that g2 is admissible. Thanks to lemma 1, it is sucient to prove that p 2= Nh(r) . In the proof of proposition 8, we established that if P = B(l; r) = fp1 ; : : :; pk g then h(r) = r[p1 (g1jp )jh(p1 ) ] : : :[pk (g1jp )jh(pk ) ]. This last graph is composed of nodes of r and of subgraphs of g1 , which are not modi ed by the pointer redirections (since pi 2= Ng1 for all i 2 1::k). p is not a node of r, since p 2 Ng1 and Ng1 \ Nr = ;. Thus if p appears in h(r), then p is a node of (g1jp)jh(pi) for some i. As pi 2 P and P = B(l; r), pi 2 Nl , thus, Rootl pi in l. The matcher h being a homomorphism, we deduce that h(Rootl ) h(pi ) in g1 , and as h(Rootl ) = p, p h(pi ) in g1. Rootl is labeled with a de ned operation (since l is a pattern) and h(Rootl ) = p, so by de nition of a homomorphism, p is also labeled with a de ned operation. g1 is an admissible graph, so there exists no path from p to itself in g1 , hence p h(pi ) and h(pi ) 6 p in g1 . So the only possibility for p to be a node of (g1jp )jh(pi ) is that p = h(pi ). h : l ! g1 jp is a homomorphism, so h(Rootl ) = p and for all node n 2 Nl such that n 6= Rootl , h(n) 6= p (otherwise, there would be a cycle on p in g ). Thus, if h(pi ) = p, then pi = Rootl. However, pi 2 B(l; r) and Rootl 2= Nr by de nition of an admissible rule, so pi 6= Rootl. Thus p is not a node of h(r) and by lemma 1, g2 = g1 [p h(r)] is admissible.
2
In the following we give a counter-example for stability when using non admissible rules. Example 19 Consider the following rewrite rule l1:+(l2:0,l3:x) ! r1:+(l1,r2:0). This rule is not admissible since the root of its left-hand side is a node of its right-hand side and thus its left-hand side is a subgraph of its right-hand side. By using this rule, the reader may check that the admissible graph x1:+(x2:0,x3:0) rewrites to r1:+(r1,r2:0). This last graph is not admissible, since there is a cycle on the de ned operation +.
4 Con uence The con uence of GRSs is actually not a straightforward extension of that of TRSs, as shown in Figure 1. In this section, we establish the con uence of the graph rewriting relation with respect to admissible graphs, in presence of an arbitrary number of collapsing rules.
De nition 24 (Con uence) Let SP = h; Ri be a cGRS. We say that the rewriting relation ! is con uent w.r.t the class of
admissible graphs i for all admissible graphs g1, g2, g10 and g20 such that g1 and g2 are equal up to renaming of nodes (g1 g2), g1 ! g10 and g2 ! g20 , there exist two admissible graphs g100 and g200 such that g10 ! g100, g20 ! g200 and g100 g200. (see Figure 8). 2
Remark : In gures, a continuous line represents a hypothesis, whereas a dashed line represents a conclusion.
14
*
g1 g2
*
g20
g10 *
*
g100 g200
Figure 8: Con uence.
Theorem 1 Let SP = h; Ri be a cGRS. Then the rewriting relation ! is con uent w.r.t the class of admissible graphs.
In [AK96], it is proved that every GRS with non overlapping rules is con uent. But this surprising result is established for a particular rewriting relation, dierent from the one considered here. The rest of this section is dedicated to the proof of Theorem 1. We must rst establish a few technical results. The following proposition states that rewriting two graphs equal up to renaming of nodes induces two graphs equal up to renaming of nodes. Its proof is clear. Proposition 10 Let SP = h; Ri be a cGRS and g1 and g2 two admissible graphs equal up to g 0 ), then 0 renaming of nodes (g1 g2). If there exists a graph g10 such that g ! g (resp. g ! 1 1 1 1 there exists an admissible graph g20 such that g2 ! g20 (resp. g2 ! g20 ) and g10 and g20 are equal up to renaming of nodes (g1 g20 ). (see Figure 9). g1 g2
g1 g2 *
g10 g20
g10
*
g20
Figure 9: The following lemma is the key result to establish con uence. It states that if a graph is rewritten in two dierent ways, then the two resulting graphs can be rewritten in at most one step into a same third graph (up to renaming of nodes). Notice that this lemma does not hold in the general case (see Figure 1). Lemma 2 Let SP = h; Ri be a cGRS and g, g1 and g2 three admissible graphs. If g ! g1 and " 0 " 0 0 0 g ! g2 , then there exist two graphs g1 and g2 such that g1 ! g1, g2 ! g2 and g10 and g20 are equal up to renaming of nodes (g10 g20 ). (see Figure 10).
Proof This proof is done by case analysis. Let g, g1 and g2 be three admissible graphs such that g ![n1 ; l1!r1 ] g1 and g ![n2 ; l2!r2 ] g2. By de nition of a rewriting step, there exist a matcher h1 : l1 ! gjn1 such that g1 = g[n1 h1 (r1)] and a matcher h2 : l2 ! gjn2 such that g2 = g[n2 h2 (r2)]. If n1 = n2 , then necessarily l1 ! r1 is a variant of l2 ! r2 since R is non-overlapping, so g1 and g2 are equal up to renaming of nodes. Thus, the proposition is straightforward (i.e., g10 = g1 and 15
g g1 "
g10 g20
g2 "
Figure 10: Con uence : Lemma 2
g20 = g2).
From now on, we assume that n1 6= n2 . We consider two cases, depending on the position of n1 and n2 in g : either n1 and n2 are disjoint (i.e., n1 kn2 ) or there exists a path from n1 to n2 (i.e., n1 n2 ). The case n2 n1 is symmetric. Case 1 : n1 and n2 are disjoint (i.e., n1kn2) : By de nition of g1, g1jn2 = (g [n1 h1 (r1)])jn2 . Since n1 kn2 , there exists no path from n2 to n1 in g, and there exists a path from a root of g to n2 which does not go through n1 , so by Proposition 2 (persistence), (g [n1 h1 (r1)])jn2 = gjn2 , i.e., g1jn2 = gjn2 . By hypothesis, h2 is a homomorphism from l2 to gjn2 , so h2 is also a homomorphism from l2 to g1jn2 . In other words, l2 matches g1 at node n2 . Hence, g1 can be rewritten with the rule l2 ! r2 into the graph g10 = g1[n2 h2 (r2)], that is to say g10 = (g [n1 h1 (r1)])[n2 h2 (r2)]. For the same reason, g2 can be rewritten into g20 = (g[n2 h2(r2)])[n1 h1(r1)]. We now prove that g10 = g20 . Let us verify that n1 is not a node of h2 (r2) and n2 is not a node of h1 (r1) in order to use Proposition 6 (commutativity). The graph h2 (r2) is composed of nodes of r2 and of nodes introduced by h2 , that is to say nodes of gjn2 (since h2 is a homomorphism from l2 to gjn2 ). By hypothesis, Ng \ Nr2 = ;, so n1 is not a node of r2. Moreover, n1 is not a node of gjn2 because n1 and n2 are disjoint. So n1 is not a node of h2 (r2). With the similar reasoning, we can prove that n2 is not a node of h1 (r1). Thus, by Proposition 6, g10 = g20 . Case 2 : There exists a path from n1 to n2 (i.e., n1 n2) (see Figure 11) : Since n1 n2 , n2 is a node of gjn1 . By hypothesis h1 (l1) = gjn1 , so n2 is a node of h1 (l1). The fact that n2 is a node of h1 (l1) stems from the existence of at least one variable node p1 of l1 such that n2 is a node of gjh1(p1 ). The existence of p1 is due to the fact that l1 is a pattern, and h1(Rootl1 ) = n1 6= n2 . There may be other variable nodes in l1 like the node p1, Let P = fp1; p2 : : :pk g be the set of variable nodes pi of l1 such that n2 is a node of gjh1 (pi) . There are two sub-cases to study, depending on P \Nr1 = ; or not, i.e.,whether or not at least one variable node of P belongs to the right-hand side r1. Case 2.1 : (P \ Nr1 6= ;), i.e., there exists a node pk 2 P which is a common variable node of r1 and l1 : This sub-case is represented in Figure 11. By de nition of P , n2 is a node of gjh1 (pk ) . By hypothesis, pk is a variable node of r1, thus n2 is a node of the graph h1 (r1). n2 is also a node of g1 = g[n1 h1 (r1)]. Indeed, h1 (r1) is not modi ed by the pointer redirection from n1 to Rooth1 (r1 ) because n1 2= h1(r1) (cf. lemma 1). Let us show that g1jn2 = gjn2 . Since n1 2= Nh1 (r1 ) and n2 2 Nh1 (r1 ) , by proposition 3 (embedding), g1jn2 = (h1(r1))jn2 . Since n2 is a node of gjn1 and h1 (l1) = gjn1 , we obtain gjn2 = (h1(l1))jn2 . n2 being a common node of h1 (l1) and h1(r1), we get (h1 (l1))jn2 = (h1 (r1))jn2 . Hence g1 jn2 = gjn2 . By hypothesis, h2 is a homomorphism from l2 to gjn2 , so h2 is also a homomorphism from l2 to g1jn2 since gjn2 = g1 jn2 . In other words, l2 matches g1 at node n2 . Therefore, g1 can be rewritten with the rule l2 ! r2 into the graph g10 = g1[n2 h2(r2)], that is to say g10 = (g [n1 h1(r1)])[n2 h2 (r2)]. 16
g n1
l1 p1 : : :pk
r1
h1(p1 ) h1 (pk )
n2
Figure 11: We have just de ned g10 . We now de ne g20 . By hypothesis, n1 n2 and then n2 6 n1 since g is admissible. Thus n1 remains a node of g2 = g [n2 h2 (r2)]. In addition, there exists a matcher h01 : l1 ! g2jn1 because l1 is a pattern and the construction of g2 is obtained from g by a pointer redirection (replacement) at n2 , where n2 is labeled with a de ned operation. Hence, l1 matches g2 at node n1. So g2 can be rewritten into g20 = g2[n1 h01 (r1)]. By de nitions of h01 and h1 we deduce that h01(l1) = h1 (l1)[n2 h2 (r2)]. Indeed, h01 (l1) = (by de nition of h01 ) g2 jn1 = (By de nition of g2 ) g [n2 h2 (r2)]jn1 = (from n1 n2 ) gjn1 [n2 h2 (r2)] = (By de nition of h1 ) h1(l1)[n2 h2 (r2)]. Then, it is easy to see that h01 (r1) = h1 (r1)[n2 h2 (r2)]. Thus, g20 = (g [n2 h2 (r2)])[n1 (h1 (r1)[n2 h2 (r2)])]. Finally, g1 rewrites into g10 = (g [n1 h1 (r1)])[n2 h2(r2)] and g2 rewrites into g20 = (g [n2 h2 (r2)])[n1 (h1(r1)[n2 h2 (r2)])]. As n1 is not a node of h2 (r2) since n1 n2 , by proposition 5 (associativity), we obtain g10 = g20 . Case 2.2 : (P \ Nr1 = ;). There is no variable node of P which appears in r1 : In this case, n2 is not a node of h1 (r1). But n2 may remain a node of g [n1 h1(r1)] if there exists a path from a root of g to n2 which does not go through n1 . Hence, there are again two sub-cases. Case 2.2.1 : Every path from a root of g to n2 goes through n1 : Then n2 is no more a node of g1 = g [n1 h1 (r1)] : it is deleted by replacement since P \ Nr1 = ;. Concerning g2, by hypothesis n1 n2 and n2 6 n1 Which implies that n1 is a node of g2 = g [n2 h2 (r2)]. Moreover, there exists a homomorphism h01 : l1 ! g2jn1 (for the same reason as in Case 2.1). Hence, l1 matches g2 at node n1 and so g2 can be rewritten into g20 = g2 [n1 h01 (r1)]. By hypothesis, n2 is not a node of h1 (r1), so h01 (r1) = h1 (r1). Thus, g2 can be rewritten into g20 = (g[n2 h2(r2)])[n1 h1(r1)]. As n2 is not a node of h1(r1) and every path from a root of g to n2 goes through n1 , by proposition 7 (weak dominance), we obtain (g [n2 h2 (r2)])[n1 h1 (r1)] = g[n1 h1 (r1)], that is to say g2 ![n1 ; l1!r1 ] g1. Finally, let g10 = g20 = g1 and the lemma holds. Case 2.2.2 : There exists a path C from a root of g to n2 such that n1 2= C : Then n2 is not a node of h1 (r1) (P \ Nr1 = ;), but n2 remains a node of g1 = g [n1 h1 (r1)], since the path C is not modi ed by the replacement at node n1 . There is no path from n2 to n1 and there exists a path from a root of g to n2 which does not go through n1 , so by Proposition 2 (persistence), (g [n1 h1 (r1)])jn2 = gjn2 , i.e., g1jn2 = gjn2 . By hypothesis, l2 matches gjn2 , so 17
l2 matches g1jn2 . Hence, g1 can be rewritten into g10 = g1 [n2 h2 (r2)], that is to say g10 = (g [n1 h1 (r1)])[n2 h2 (r2)]. Concerning g2 , by hypothesis, n1 n2 and n2 6 n1 which implies that n1 is a node of g2 = g [n2 h2 (r2)]. Moreover, there exists a homomorphism h01 : l1 ! g2jn1 (for the same reason as in Case 2.1). Hence, l1 matches g2 at node n1 and so g2 can be rewritten into g20 = g2[n1 h01 (r1)]. By hypothesis, n2 is not a node of h1 (r1), so h01 (r1) = h1 (r1). Thus, g2 can be rewritten into g20 = (g [n2 h2 (r2)])[n1 h1 (r1)]. Finally, n1 is not a node of h2 (r2) (since n1 n2 in g) and n2 is not a node of h1(r1) (by hypothesis), so by proposition 6 (commutativity), g10 = g20 . 2 An immediate consequence of Lemma 2 is the following proposition. Proposition 11 Let SP = h; Ri be a cGRS and g1, g2, g10 and g20 four admissible graphs such that g1 and g2 are equal up to renaming of nodes (g1 g2 ), g1 ! g10 and g2 ! g20 . Then there exist " 00 0 " 00 00 00 0 two admissible graphs g1 and g2 such that g1 ! g1 , g2 ! g2 and g100 g200. (see Figure 12). g1 g2 g10 "
g20 "
g100 g200
Figure 12:
Proof Since g1 ! g10 and g1 g2, by Proposition 10, there exists an admissible graph d such that g2 ! d and g10 d. "Since g2 "! d and g2 ! g20 , by Lemma 2, there exist two admissible graphs d0 " 0 00 0 0 00 0 00 0 and g2 such that d ! d , g2 ! g2 and d g2 . Since g1 d and d ! d , by Proposition 10, there exists an admissible graph g100 such that g10 !" g100 and g100 d0 . Finally, since g100 d0 and d0 g200, we conclude that g100 g200. 2 We now generalize Lemma 2. Proposition 12 Let SP = h; Ri be a cGRS" and g, g1 and g2 three admissible graphs. If g ! g1 and g rewrites in" at most one step to g2 (g ! g2 ), then there exist two admissible graphs g10 and g20 such that g1 ! g10 , g2 ! g20 and g10 g20 . (see Figure 13). g *
g1 "
g10
" g20
Figure 13: 18
g2 *
g d
A " " g1 d d HR * C1 * 2 " 0 0 0 g1 d1 g2 n
g2
Figure 14:
Proof This proof is done by induction on the length of the derivation g ! g1 and it is sketched in
gure 14. For a null derivation, the proposition is straightforward (i.e., g10 = g20 = g2). We suppose +1 g and g ! " it is true for length n. Let g , g1 and g2 be three admissible graphs such that g n! g2 . If 1 0 0 g = g2, the proposition is straightforward (i.e., g1 = g2 = g1), so we suppose g ! g2. There exists n " a graph d such that g ! d ! g . By Lemma 2, there exist two graphs d and d such that d ! d1 , 1 1 2 n " g2 !" d2 and d1 d2 (see A in Figure 14). Since d ! g and d ! d , by induction hypothesis, 1 1 there exists two graphs g10 and d01 such that g1 !" g10 , d1 ! d01 and g10 d01 (see HR in Figure 14). Since d1 ! d01 and d1 d2, by Proposition 10, there exists a graph g20 such that d2 ! g20 and d01 g20 (see C in Figure 14). Finally, g10 d01 and d01 g20 , so g10 g20 , i.e., g10 and g20 are equal up to renaming of nodes.
2
The following proposition is a second generalization of Lemma 2. g Proposition 13 Let SP = h ; Ri be a cGRS and g , g and g three admissible graphs. If g ! 1 2 g0 , g ! g 0 and1 and g ! g2 , then there exist two admissible graphs g10 and g20 such that g1 ! 1 2 2 g10 g20 . (see Figure 15). g *
*
g1
g2
*
g10
g20
*
Figure 15:
Proof Let g, g1 and g2 be three admissible graphs such that g ! g1 and g ! g2 . We prove by induction on the length of the derivation g ! g2 that there exist two graphs g10 and g20 such that g1 ! g10 , g2 ! g20 and g10 g20 . This proof is sketched in gure 16. For a null derivation, the proposition is straightforward (i.e., g10 = g20 = g1). We suppose it is true for length n. Let g , g1 and g and g n! +1 g . Then there exists a graph d such that g2 be three admissible graphs such that g ! 1 2 n g ! d ! g2. By Proposition 12, there exist two graphs d1 and d2 such that g1 !" d1, d ! d2 and d1 d2 (see A in Figure 16). Since d ! d2 and d !n g2, by induction hypothesis, there existtwo graphs d02 and g20 such that d2 ! d02 , g2 ! g20 and d02 g20 (see HR in Figure 16). Since d2 ! d02 and d1 d2, by Proposition 10, there exists a graph g10 such that d1 ! g10 and g10 d02 (see C in 19
g g1
*
d A n * " g2 d1 d2 HR C * * * g10 d02 g20
Figure 16: Figure 16). Finally, g10 d02 and d02 g20 , so g10 g20 , i.e., g10 and g20 are equal up to renaming of nodes.
2
We are now ready to prove the con uence of cGRS w.r.t the class of admissible graphs : Proof of theorem 1 Let SP = h; Ri be a cGRS and g1 , g2 , g3 and g4 four admissible graphs such that g1 g2, g1 ! g10 and g2 !g20 . Since g1 ! g10 and g1 g , by Proposition 10, there exists d2and g ! g 0 , by Proposition 13, an admissible graph d such that g2 ! d and g10 d. Since g2 ! 2 2 there exist two admissible graphs d0 and g200 such that d ! d0 , g20 ! g200 and d0 g200. Since g10 d and d ! d0, by Proposition 10, there exists an admissible graph g100 such that g10 ! g100 and g100 d0. Finally, since g100 d0 and d0 g200, we conclude that g100 g200.
5 Con uence modulo bisimilarity Another interesting question is the con uence modulo bisimilarity of the graph rewriting relation with respect to admissible graphs. Beyond its theoretical interest, we need this result to establish the completeness of narrowing in the framework of cGRSs [EJ97].
De nition 25 (Con uence modulo bisimilarity) Let SP = h; Ri be a cGRS. We say that the rewriting relation ! is con uent modulo bisimilarity
w.r.t the class of admissible graphs i for all admissible graphs g1, g2 , g10 and g20 such that g1 and g2 are bisimilar (g1 =: g2), g1 ! g10 and g2 ! g20 . Then there exist two admissible graphs g100 and g200 : such that g10 ! g100, g20 ! g200 and g100 = g200. (see Figure 17). 2
*
g1 =: g2
*
g10
g20 *
g100 =: g200
*
Figure 17: Con uence modulo bisimilarity
Theorem 2 Let SP = h; Ri be a cGRS. Then the rewriting relation ! is con uent modulo
bisimilarity w.r.t the class of admissible graphs.
20
The rest of this section is dedicated to the proof of Theorem 2. We must rst establish a few technical results. The following proposition states that if two graphs are bisimilar and the left-hand side of a rule matches one of them, then it also matches the other. Proposition 14 Let SP = h; Ri be a cGRS, g1 and g2 two admissible graphs and l ! r a rewrite rule of R. 1. If there exists a homomorphism h : g1 ! g2 and l matches g1 at the root, then l matches g2 at the root. 2. If there exists a variable-preserving homomorphism h : g1 ! g2 and l matches g2 at the root, then l matches g1 at the root. 3. If g1 and g2 are bisimilar and l matches g1 at the root, then l matches g2 at the root. Proof The rst part of the proposition is straightforward : if there exists a homomorphism h1 : l ! g1 and a homomorphism h : g1 ! g2, then by composition, h h1 is a homomorphism from l to g2, and thus l matches g2 at the root. Let us prove the second part of the proposition. By de nition of a cGRS, l is a pattern, so l is a nite linear tree. Hereafter, we use this property, since the proof is done by induction on the height of l, i.e., the maximal length of paths from Rootl to the leaves of l. Base case: Let l be a linear tree of height = 0, g1 and g2 two admissible graphs and h : g1 ! g2 a variable-preserving homomorphism such that l matches g2 at the root. Since = 0, l is either a variable or a constant. If l is a variable, l trivial matches g1 at the root. If l is a constant, then g2 is the same constant because h2 : l ! g2 is a homomorphism. As h : g1 ! g2 is a variable-preserving homomorphism, g1 is also the same constant. Hence l matches g1 at the root. Induction step: Let > 0. We suppose that for every linear tree l of height less or equal to , for all admissible graphs g1 and g2 and variable-preserving homomorphism h : g1 ! g2, if l matches g2 at the root, then l matches g1 at the root. Let l be a linear tree of height + 1, g1 and g2 two admissible graphs and h : g1 ! g2 a variable-preserving homomorphism, such that there exists a homomorphism h2 : l ! g2. We build a homomorphism h1 : l ! g1. l is not a variable nor a constant, since it is of height +1. So its root is labeled with a non constant operation f . Since h2 : l ! g2 is a homomorphism, the root of g2 is also labeled with f . And as h : g1 ! g2 is a variable-preserving homomorphism, the root of g1 is also labeled with f . We now suppose Sl(Rootl ) = n1 : : :nk , Sg1 (Rootg1 ) = u1 : : :uk and Sg2 (Rootg2 ) = v1 : : :vk . For all i 2 1::k, hjui is a variable-preserving homomorphism from g1jui to g2 jvi . For all i 2 1::k, ljni is a linear tree of height less or equal to and h2 jni is a homomorphism from ljni to g2jvi . So by induction hypothesis, there exists a matcher i : ljni ! g1 jui for all i 2 1::k. Let h1 : Nl ! Ng1 be the function such that h1 (Rootl ) = Rootg1 and for all i 2 1::k, for all n 2 Nljni , h1 (n) = i (n). We now prove that h1 is a homomorphism from l to g1 . First, l is a linear tree, so for all i; j 2 1::k, if i 6= j , then N(ljni ) \ N(ljnj ) = ; and V(ljni ) \ V(ljnj ) = ;. Thus, for all nodes n of l, h1(n) is de ned once and only once, i.e., h1 is a well de ned function. Second, h1 preserves the labeling function of l, since Lg1 (h1(Rootl)) = Lg1 (Rootg1 ) = Ll(Rootl) = f , and every i preserves the labeling function of ljni . Third, h1 preserves the successor function of l, since Sg1 (Rootg1 ) = u1 : : :uk = 1 (n1 ) : : :k (nk ) = h1 (Sl(Rootl)), and every i preserves the successor function of ljni . So we conclude that h1 : l ! g1 is a homomorphism and thus, l matches g1 at the root. Finally, we prove the last part of the proposition. Let g1 and g2 be two bisimilar graphs such that l matches g1 at the root. By de nition of bisimilarity, there exist a graph g and two variablepreserving homomorphisms 1 : g1 ! g and 2 : g2 ! g . l matches g1 at the root, so l matches g at the root, with the rst part of this proposition. Then by the second part of this proposition, we obtain l matches g2 at the root 2 21
Note : The proposition above would not hold if the left-hand sides of the rules of a cGRS were not nite linear trees. Consider for instance the rule x1:+(x2:0,x2) ! x2. Its left-hand side l
does not match the graph g1 = y1:+(y2:0,y3:0), since there is no homomorphism from l to g1. Consequently, g1 cannot be rewritten. However, l and g1 are bisimilar and l can be rewritten into x2:0. Consider now the rule x1:+(x2:x,x3:s(x3)) ! x3. Its left-hand side matches the graph g3 = y1:+(x2:0,x3:s(x3)) but it does not match the graph g4 = z1:+(z2:0,z3:s(z4:s(z3))), whereas g3 and g4 are bisimilar. We now establish a key result for the proof of con uence modulo bisimilarity of our graph rewriting relation. A similar proposition is given in [AK96] (proposition 5.13) (for a dierent rewriting relation, as already said). Lemma 3 Let SP = h; Ri be a cGRS, g1 and g2 two admissible graphs and h : g1 ! g2 a variable-preserving homomorphism. If there exists a graph g20 such that g2 ! g20 , then there exist + g0 . an admissible graph g10 and a variable-preserving homomorphism h0 : g10 ! g20 such that g1 ! 1 (see Figure 18). g1 h
g2
+
0 g10 h
g20
Figure 18:
Proof We assume g2 ![q; l!r] g20 . By de nition, there exists a homomorphism : l ! g2jq , and
g20 = g2[q (r)]. Let P = h?1 (q ) = fp1; p2; : : :; png. All nodes of P are pairwise disjoint : otherwise, if pi pj and i = 6 j , then there exists a path C = [pi; n1; : : :; nk ; pj ] in g1 ; h being a homomorphism, h(C ) = [h(pi); h(u1); : : :; h(uk ); h(pj )] is a path of g2 ; but h(pi ) = h(pj ) = q, so there exists a cycle on q in g2, which is impossible since q is labeled with a de ned operation and g2 is admissible. Therefore all nodes of P are pairwise disjoint. Let fli ! ri j i 2 1::ng be a set of n variants of l ! r ; let i be the isomorphism from the graph li ! ri to the graph l ! r (i.e., i is the isomorphism from li + ri to l + r which renames all nodes and variables of li + ri). is a homomorphism from l to g2 jq and hjpi is a homomorphism from g1 jpi to g2jq for all i 2 1::n. So by proposition 14, there exists a homomorphism from l to g1 jpi . li ! ri is a variant of l ! r by isomorphism i and there exists a homomorphism from l to g1jpi , so there exist a homomorphism i from li to g1 jpi . Hence, for all i 2 1::n, g1 can be rewritten at node pi with rule li ! ri into g1[pi i(ri)]. All positions in P are pairwise disjoint, so by proposition
6 (commutativity), we can perform all these rewriting steps in any order and we obtain a graph + g0 . g10 = g1[p1 1 (r1)] : : :[pn n(rn)]. We clearly have g1 ! 1 Now, let us prove that there exists a variable-preserving homomorphism h0 : g10 ! g20 . We are going to decompose the construction of g10 and g20 in elementary stages (following the de nition of replacement) and prove that there exists a variable-preserving homomorphism at each stage. First stage, let G1 = g1 + 1 (r1) + : : : + n (rn ) and G2 = g2 + (r). There exists a homomorphism : G1 ! G2 such that for all nodes n 2 Ng1 , (n) = h(n) and for all i 2 1::k, for all nodes n 2 (Nri ? Nli ), (n) = i(n). 22
Second stage, we perform the multiple pointer redirection 1 on G1 and the pointer redirection 2 on G2, where 1 = fp1 7! Root1 (r1 ); : : :; pn 7! Rootn (rn)g and 2 = fq 7! Root (r) g. We must prove the is still a homomorphism from 1 (G1) to 2(G2). First, is a function from NG1 to NG2 , so is also a function from N1 (G1) to N2 (G2). Second, preserves the labeling function of G1 , so it does on 1(G1). Third, preserves the successor function of 1(G1) : we must verify that S2 (G2 ) ((n)) = (S1 (G1 ) (n)), for all node n 2 N1 (G1 ) . As N1 (G1 ) = NG1 , it is equivalent to prove that for all nodes n 2 NG1 , 2(SG2 ((n))) = (1(SG1 (n))). Since is a homomorphism from G1 to G2 , 2(SG2 ((n))) = 2((SG1 (n))). So, let us prove that for all nodes n 2 NG1 , (1(SG1 (n))) = 2 ((SG1 (n))). This result holds if 2((n)) = (1(n)) for all nodes n of G1. There are two cases for n. First case, if n 2= P . Then 1(n) = n and so (1 (n)) = (n). As n 2= P , (n) 6= q , so 2((n)) = (n). Hence, (1(n)) = 2 ((n)). Second case, if n 2 P . Then there exists an i 2 1::k such that n = pi . So 1(n) = 1(pi ) = Rooti (ri ) = i (Rootri ). So (1(n)) = (i (Rootri )). Moreover, 2((n)) = 2((pi )) = 2 (q ) = Root (r) = (Rootr ). By de nition of , (i (Rootri )) = (Rootr ). Hence, (1(n)) = 2((n)) and we obtain that preserves the successor function of 1(G1). Finally, (Roots1 (G1 ) ) = Roots2 (G2 ). So we conclude that is still a homomorphism from 1(G1) to 2(G2). Third and last stage, let g10 = 1(G1)j1 (Rootsg1 ) and g20 = 2(G2)j2 (Rootsg2 ) . Let h0 = jRootg0 . It 1 is clear that h0 is a variable-preserving homomorphism from g10 to g20 .
2
The following proposition is a generalization of Lemma 3. Proposition 15 Let SP = h; Ri be a cGRS, g1 and g2 two admissible graphs and h : g ! g a g 0 , then there1 exist2 a variable-preserving homomorphism. If there exists a graph g20 such that g2 ! 2 graph g10 and a variable-preserving homomorphism h0 : g10 ! g20 such that g1 ! g10 . (see Figure 19). g1 h
g2
*
*
0 g10 h
g20
Figure 19:
Proof This proof is done by induction on the length of the derivation g2 ! g20 . For a null
derivation, the proposition is straightforward (i.e., g10 = g1, g20 = g2 , h0 = h). We suppose the proposition is true for length n. Let g1 and g2 be two admissible graphs and h : g1 ! g2 a n+1 0 variable-preserving homomorphism such that g ! g2. Then, there exists a graph d0 such that 2 n 0 0 0 g2 ! d ! g2 . Since g2 ! d and there exists a variable-preserving homomorphism h : g1 ! g2, by Lemma 3, there exist a graph d and a variable-preserving homomorphism j : d ! d0 such + d. Since there exists a variable-preserving homomorphism j : d ! d0 and d0 ! n 0 that g1 ! g2, by 0 0 0 induction hypothesis, there exist a graph g1 and a variable-preserving homomorphism h : g1 ! g20 + d! g 0 , so g ! such that d ! g10 . Finally, g1 ! 1 g10 . 1
2
We now establish a second key result for the proof of con uence modulo bisimilarity of cGRSs. 23
Lemma 4 Let SP = h; Ri be a cGRS, g1 and g2 two admissible graphs and h : g1 ! g2 a variable-preserving homomorphism. If there exists a graph g10 such that g1 ! g10 , then there exist two admissible graphs g100 and g20 and a variable-preserving homomorphism h0 : g100 ! g20 such that g10 ! g100 and g2 ! g20 . (see Figure 20). g1 h
g2
0 g100 h
g20
g10 *
Figure 20:
Proof This proof is sketched in Figure 21. We assume g1 rewrites to g10 at node p1 with rule h
g1 g10
B + * g100 d
A j
g2
g20
Figure 21:
l ! r. Let q = h(p1 ) and P = h?1(q) = fp1; : : :png (i.e., P is the set of the antecedents of q by h). Since there exists a homomorphism from l to g1 jp1 (i.e., the matcher) and hjp1 is a homomorphism from g1jp1 to g2 jq , then by composition, there exists a homomorphism from l to g2jq . So there exists a graph g20 such that g2 ![q; l!r] g20 . Since g2 ![q; l!r] g20 and there exists a variable-preserving homomorphism h : g1 ! g2, by Lemma 3, there exists a graph d and a variable+ d (see A in Figure 21). From the proof preserving homomorphism j : d ! g20 such that g1 ! of Lemma 3, the nodes of P are pairwise disjoint in g1 and all rewriting steps of the derivation + d are performed at the nodes of P . Therefore, since p is a node of P and g ! g1 ! 1 1 [p1 ; l!r] g10 , there exists a graph g100 such that g10 ! g100 and g100 d (see B in Figure 21). The nodes used to perform the rewriting derivation g10 ! g100 are those of P ?fp1g, that is to say fp2; : : :; pn g. Finally, the isomorphism of renaming is a variable-preserving homomorphism from g100 to d and j is a variable-preserving homomorphism from d to g20 , so j is a variable-preserving homomorphism from g100 to g20 . 2 The following proposition is a generalization of lemma 4. Proposition 16 Let SP = h; Ri be a cGRS, g1 and g2 two admissible graphs and h : g1 ! g2 a 0 0 variable-preserving homomorphism. If there exists a graph g1 such that g1 ! g1 , then there exist twoadmissible graphs g100 and g20 and a variable-preserving homomorphism h0 : g100 ! g20 such that 0 00 0 g1 ! g1 and g2 ! g2 . (see Figure 22). 24
*
g1 h
g2 *
g10 *
0 g100 h
g20
Figure 22:
Proof This proof is done by induction on the length of the derivation g1 ! g10 and it is sketched
in Figure 23. For a null derivation, the proposition is straightforward (i.e., g100 = g1, g20 = g2
d g10 *
B
h
g1
n
g2
HR *
d1 "
f1 f2 * * D g100 e
*
j C j0
d2 " g20
Figure 23: and h0 = h). We suppose the proposition is true for length n. Let g1 and g2 be two admissible graphs and h : g1 ! g2 a variable-preserving homomorphism such that there exists a graph g10 with +1 g 0 . Then, there exists a graph d such that g ! n g1 n! 1 d ! g10 . Since h : g1 ! g2 is a variable1 n preserving homomorphism and g1 ! d, by induction hypothesis, there exists two graphs d1 and d2 and a variable-preserving homomorphism j : d1 ! d2 such that d ! d1 and g2 ! d2 (see HR in Figure 23). Since "d ! g10 and d ! d1 , by Proposition 12, there exists two graphs f1 and f2 such that g10 ! f1 , d1 ! f2 , and f1 f2 (see B in Figure 23). Since there exists a variable-preserving homomorphism j : d1 ! d2 and d1 !" f2 , we can deduce by using Lemma 4, the existence of "two graphs e and g20 and a variable-preserving homomorphism j 0 : e ! g20 such that f2 ! e and d2 ! g20 (see C in Figure 23). Since f2 ! e and f1 f2 , by Proposition 10, there exists a graph g100 such that f1 ! g100 and g100 e (see D in Figure 23). Finally, g100 e, so is a variable-preserving homomorphism from g100 to e. Moreover, j 0 : e ! g20 is a variable-preserving homomorphism. So j 0 : g100 ! g20 is a variable-preserving homomorphism.
2
We are now ready to prove Theorem 2.
Proof of theorem 2 Let SP = h; Ri be a cGRS. Let g1 and g2 be two admissible and bisimilar : graphs (g1 = g2 ) such that there exist two graphs g10 and g20 with g1 ! g10 and g2 ! g20 .: We prove that there exist two admissible graphs g100 and g200 such that g10 ! g100, g20 ! g200 and g100 = g200. This proof is direct thanks to the previous propositions. It is sketched in Figure 24. By de nition of bisimilarity, there exist a graph g , a variable-preserving homomorphism h1 : g1 ! g and a variablepreserving homomorphism h2 : g2 ! g (see A in Figure 24). Since g1 ! g10 and there exists a 25
: g2 A * h1 h2 * g0 g10 2 g B B0 * * * * 0 0 f1 h1 d1 d2 h2 f2 D * C * D0 * * g100 h00 d01 d02 h00 g200 g1
=
1
2
Figure 24: variable-preserving homomorphism h1 : g1 ! g , by Proposition 16, there exist two graphs f1 and d1 and a variable-preserving homomorphism h01 : f1 ! d1 such that g10 ! f1 and g ! d1 (see B in Figure 24). For the same reason, there exist two graphs f2 and d2 and a variable-preserving homomorphism h02 : f2 ! d2 such that g20 ! f2 and g ! d2 (see B 0 in Figure 24). Since g ! d1 and g ! d2, by Theorem 1, there exist two graphs d01 and d02 such that d1 ! d01, d2 ! d02 and d01 d02 (see C in Figure 24). Since d1 ! d01 and there exists a variable-preserving homomorphism h01 : f1 ! d1, by Proposition 15, there exist a graph g100 and a variable-preserving homomorphism 00 00 0 h1 : g1 ! d1 such that f1 ! g100 (see D in Figure 24). For the same reason, there exist a graph g200 and a variable-preserving homomorphism h002 : g200 ! d02 such that f2 ! g200 (see D0 in Figure 24). Finally, h001 is a variable-preserving homomorphism from g100 to d02 and h002 is a variable-preserving homomorphism from g200 to d02, so by de nition of bisimilarity, g100 =: g200.
6 Needed graph rewriting In this section, we de ne an optimal rewriting strategy for admissible graphs. We rst introduce some vocabulary.
De nition 26 (Strategy) Let SP = h; Ri be a cGRS. A (sequential) graph rewriting strategy is a partial function S which
takes an admissible graph g and returns a pair (p; R) such that p is a node of g , R is a rewrite rule of R and g can be rewritten at node p with rule R. We write g !S g 0 and speak of an S -step from g to g 0 whenever S (g) = (p; R) and g ![p; R] g0. ! S denotes the re exive and transitive closure of !S and we speak of an S -derivation from g to g0 whenever g ! S g0. A strategy S is c-normalizing i for all admissible graph g admitting a constructor normal form c, if g ! c, then there exists a constructor graph c0 such that g ! S c0 and c0 c. A strategy S is c-hyper-normalizing i for all admissible graphs g admitting a constructor normal form c, any derivation D starting with g which uses in nitely many times S -steps ends with a constructor normal form c0 such that c c0. 2
De nition 27 Let SP = h; Ri be a cGRS, g and g0 two admissible graphs and B = g ! g0 a
rewriting derivation. A node q labeled with a de ned operation in g is a residual node by B if q remains a node of g 0. Then, we call descendant of gjq the subgraph (g 0)jq . A redex u rooted by q in g is a needed redex i in every rewriting derivation from g to a constructor normal form, a descendant of gjq is rewritten at its root q . A node q labeled with a de ned operation in g is an outermost node of g i q 2 Rootsg or there exist a root r 2 Rootsg and a path C = [p0; : : :; pk ] from r to q such that p0 = r, pk = q and pi is a node of g labeled with a constructor symbol for all i 2 0::(k ? 1). A redex u rooted by q in g is an outermost redex i q 2 Rootsg or there exist a root 26
r 2 Rootsg and a path C = [p0; : : :; pk ] from r to q such that p0 = r, pk = q and gjpi is not a redex for all i 2 0::(k ? 1). 2
Example 20 Let g = x1:cons(x2:*(x3:0,x4:+(x3,x3)),x5:cons(x4,x6:nil)). By de nition, gjx2 and gjx4 are outermost needed redexes. However, there exist a path from x2 to x4. Notice that gjx4 does not vanish when gjx2 is rewritten.
Remark : The notions of outermost node and outermost redex are well-de ned in the framework of admissible graphs : if p and q are two nodes of an admissible graph labeled with de ned operations and such that there exist a path from p to q (i.e., p is outer than q ), then there is no path from q to p. Our graph rewriting strategy is based on de nitional trees and is a conservative extension to admissible graphs of Antoy's term rewriting strategy [Ant92]. A de nitional tree is a hierarchical structure whose leaves are the rules of a cGRS used to de ne a given operation. In the following de nition, branch and rule are uninterpreted symbols, used to construct the nodes of a de nitional tree. De nition 28 (De nitional tree) Let SP = h; Ri be a cGRS. A tree T is a partial de nitional tree, or pdt, with pattern i one
of the following cases holds : T = rule( ! r), where ! r is a variant of a rule of R. T = branch(; o; T1; : : :; Tk), where o is a variable node of , o is of sort s, c1; : : :; ck (k > 0) are dierent constructors of the sort s and for all j 2 1::k, Tj is a pdt with pattern [o p : cj (o1 : X1; : : :; on : Xn )], such that n is the number of arguments of cj , X1 ; : : :; Xn are new variables and p; o1; : : :; on are new nodes. We write pattern(T ) to denote the pattern argument of a pdt. A de nitional tree T of a de ned operation f is a nite pdt with a pattern of the form p : f (o1 : X1; : : :; on : Xn ) where n is the number of arguments of f , X1; : : :; Xn are new variables, p; o1; : : :; on are new nodes, and for every rule l ! r of R, with l of the form f (g1; : : :; gn), there exists a leaf rule(l0 ! r0) of T such that l0 ! r0 is a variant of l ! r. An inductively sequential cGRS is a GRS such that for every de ned operation f , there exists a de nitional tree of f . 2
Example 21 Consider the following cGRS which de nes the sum of positive integers : x1:+(x2:0,x3:x) -> x3 x4:+(x5:succ(x6:x),x7:y) -> x8:succ(x9:+(x6,x7))
The de nitional tree T+ of the operation + is
T+ = branch(
l1:+(l2:X,l3:Y); l2; rule(l4:+(l5:0,l6:U) ! l6); rule(l7:+(l8:succ(l9:V),l10:W) ! l11:succ(l12:+(l9,l10))))
Now, we are ready to de ne our graph rewriting strategy noted . The strategy is a partial function that operates on admissible graphs in presence of inductively sequential cGRS. (g ) returns, when it is possible, a pair (p; R) where p is a node of g and R is a rewrite rule such that g can be rewritten at node p with rule R. uses an auxiliary function ' which takes two arguments : an operation-rooted term graph and a pdt of this operation. 27
De nition 29 (Admissible graph rewriting strategy) Let SP = h; Ri be an inductively sequential cGRS and g an admissible graph. is the partial function de ned by (g ) = '(gjp; Tf ), where p is an outermost node of g labeled with a de ned operation f and Tf is a de nitional tree of f . Let g be an admissible operation-rooted term graph and T a pdt such that pattern(T ) g . We de ne the partial function ' : 8 (Root ; 0 ! r0) if T = rule( ! r) and >> g >> 0 ! r0 is a variant of ! r ; >> '(g; Ti) if T = branch(; o; T1; : : :; Tk ) and >< pattern(Ti ) g for some i 2 1::k ; if T = branch(; o; T1; : : :; Tk ); '(g; T ) = > (p; R) >> matches g at the root by homomorphism h : ! g, >> h(o) is labeled with a de ned operation f (in g), >> 0 is a de nitional tree of f and T : '(gjh(o); T 0) = (p; R):
2
Example 22 Consider the admissible graph g = x1:cons(x2:+(x3:+(x4:0,x4),x3),x1). Then (g ) = '( x2:+(x3:+(x4:0,x4),x3); T+ ) = '(
= '( =
x2:+(x3:+(x4:0,x4),x3); branch(l1:+(l2:X,l3:Y); l2; : : :)) x3:+(x4:0,x4); branch(l1:+(l2:X,l3:Y); l2; rule(l4:+(l5:0,l6:U) ! l6); : : :)) (x3; v1:+(v2:0,v3:Z) ! v3)
Lemma 5 Let SP = h; Ri be an inductively sequential cGRS, f a de ned operation, Tf a de nitional tree of f , and g an admissible term graph whose root is labeled with f . If '(g; Tf ) =
(p; R), then (i) in every rewriting derivation from g to a constructor-rooted term graph, a descendant of gjp is rewritten at the root, in one or more steps, into a constructor-rooted term graph ; (ii) gjp is a redex of g matched by the left-hand side of R ; (iii) gjp is an outermost redex of g . If '(g; T ) is not de ned, then g cannot be rewritten into a constructor-rooted term graph.
Proof In the sequel, @ denotes the Ntherian ordering de ned by : (g1; T1) @ (g2; T2) if and
only if either the graph g1 has fewer occurrences of de ned operations than the graph g2, or else g1 = g2 and T1 is a proper subtree of T2 . The proof is by Ntherian induction on @. We consider the dierent cases of the de nition of '. Base case : consider (g; T ) where g is an admissible operation-rooted term graph, T = rule( ! r) and ! r is a variant of a rule of R such that g. By de nition of ', '(g; T ) is de ned and '(g; T ) = (Rootg ; 0 ! r0), where 0 ! r0 is a variant of ! r. (i) Since g is operation-rooted, every rewriting derivation from g to a constructor-rooted term graph must contain a rewriting step at node Rootg . So in any rewriting derivation from g to a constructor-rooted term graph, a descendant of gjRootg must be rewritten at the root into a constructor-rooted term graph. (ii) By de nition of ', g and since 0 is a variant of , 0 g . So gjRootg is a redex matched by the left-hand side of 0 ! r0. (iii) It is obvious that gjRootg is an outermost redex of g . Induction step : consider (g; T ) where g is an admissible operation-rooted term graph, T = branch(; o; T1; : : :; Tk ), where o is a variable node of , o is of sort s, c1; : : :; ck (k > 0) are dierent constructors of the sort s and for all j 2 1::k, Tj is a pdt with pattern [o p : cj (o1 : X1; : : :; on : Xn)], such that n is the number of arguments of cj , X1 ; : : :; Xn are new 28
variables and p; o1; : : :; on are new nodes. We assume that pattern(T ) g , i.e., there exists a homomorphism h : ! g . There are three cases to consider. Case 1 : gjh(o) is constructor-rooted, say Lg (h(o)) = c. Then, there are two possibilities. If there exists an i 2 1::k such that pattern(Ti ) g , then by de nition of ', '(g; T ) = '(g; Ti). By induction hypothesis, all the claims hold already for '(g; Ti), so they also hold for '(g; T ). Else, there exists no i 2 1::k such that pattern(Ti ) g , then the operation Lg (Rootg ) is incompletely de ned by R. So g cannot be rewritten into a constructor-rooted term graph and '(g; T ) is not de ned. Case 2 : gjh(o) is operation-rooted, say Lg (h(o)) = f . Let T 0 be a de nitional tree of f . Then, either '(gjh(o); T 0 ) is de ned, or not. First sub-case, suppose '(gjh(o); T 0 ) = (p; R), where p is a node of gjh(o) and R is a variant of a rule of R. By the de nition of ', '(g; T ) = (p; R). (i) By the de nition of ', pattern(T ) g . By the de nition of a de nitional tree, for every rule l ! r of R whose left-hand side may match g at the root, there exists a leaf rule(l0 ! r0 ) of T , where l0 ! r0 is a variant of l ! r. By construction of a de nitional tree, if l ! r is a rule represented by a leaf of T , then pattern(T ) l, i.e., there exists a homomorphism h0 : ! l. By hypothesis, T is a branch pdt and not a rule pdt so pattern(T ) < l. This implies that l has a constructor symbol at node h0 (o). However, the case being considered assumes that g has a de ned operation at node h(o). Hence, there is no rule of R whose left-hand side matches g at the root, i.e., g is not a redex. Moreover, in any rewriting derivation from g that includes a rewriting step at the root, a descendant of gjh(o) must be rewritten into a constructorrooted term. Since g is operation-rooted, in any rewriting derivation from g to a constructor-rooted term graph, a descendant of g is rewritten at the root, and consequently, a descendant of gjh(o) is rewritten into a constructor-rooted term graph. By the induction hypothesis, in any rewriting derivation from gjh(o) to a constructor-rooted term graph, a descendant of (gjh(o))jp is rewritten into a constructor-rooted term graph. Since p is a node of gjh(o) , then by Proposition 1, (gjh(o))jp = gjp. So in any rewriting derivation from g to a constructor-rooted term graph, a descendant of gjp is rewritten into a constructor-rooted term graph. (ii) By induction hypothesis, gjp is a redex of gjh(o) matched by the left-hand side of R, thus gjp is a redex of g matched by the left-hand side of R. (iii) By the de nition of ', g , i.e., there exists a homomorphism h : ! g . By the de nition of a de nitional tree, is a pattern and o is a node of . These conditions imply that there exists a path from Rootg to h(o) along which all nodes are labeled with constructor symbols, except Rootg and h(o). In cGRS, redexes occur only at nodes labeled with de ned operations. We have just proved that g is not a redex. Thus, there is no redex in g above h(o). By induction hypothesis, gjp is an outermost redex in gjh(o) . So gjp is also an outermost redex in g . Second sub-case, suppose '(gjh(o); T 0) is not de ned. Then, '(g; T ) is not de ned too. Moreover, by induction hypothesis, gjh(o) cannot be rewritten into a constructor-rooted term graph. However, as before, g is not a redex and in any rewriting derivation from g to a constructor-rooted term graph, a descendant of gjh(o) must be rewritten into a constructor-rooted term graph. So g cannot be rewritten into a constructor-rooted term graph. Case 3 : gjh(o) is a variable. Then '(g; T ) is not de ned. On the other hand, by the de nition of ', g . Any rule whose left-hand side may match g at the root is represented by a leaf of T . If l ! r is a rule represented by a leaf of T , then by construction of a de nitional tree, pattern(T ) l, i.e., there exists a homomorphism h0 : ! l. Thus, by the de nition of a de nitional tree, l has a constructor symbol at node h0 (o). However, the case being considered assumes that g has a variable at node h(o). Hence, g is not a redex. Since in any rewriting derivation from g that includes a rewriting step at the root, a descendant of gjh(o) must be rewritten into a constructor-rooted term and gjh(o) is a variable, g has no constructor normal form.
2
29
Proposition 17 Let SP = h; Ri be a cGRSand g an admissible graph. If (g) = (p; R), then gjp is an outermost needed redex of g and g can be rewritten at node p with rule R. If (g) is not de ned, then g cannot be rewritten into a constructor graph.
Proof Follows immediately from Lemma 5 and the de nition of .
2
From the previous proposition, we deduce that if an admissible graph g has a constructor normal form c and (g ) = (p; R), then every derivation from g to c must contain a step at node p with rule R. The following lemma states that given a derivation D = g ! c, performing the step computed by (g ) rst leads to a new derivation of length less than (or equal to) the length of D. Lemma 6 Let SP = h; Ri be a cGRS, g an admissible non constructor graph and c a constructor graph, such that there exists a rewriting derivation g ! c of length n. Then, there exists an admissible graph g 0 such that g ! g 0 and a rewriting derivation g 0 ! c0 of length n0 such that n0 < n and c0 is a constructor graph with c c0.
Proof This proof is sketched in Figure 25. By hypothesis, there exists a rewriting derivation g ![u1 ;R1 ] a1 ![u2 ;R2 ] : : : ![uk?1 ;Rk?1 ] [p; R] [p; R] b1 " 0 g ![u1 ;R1 ] a01 !" [u02 ;R2 ] : : : !" [u0k?1 ;Rk?1 ]
ak?1 ![p;R] [p; R] bk?1 a0k?1 =
ak ![uk+1 ;Rk+1 ] : : : ![un ;Rn ] c
:::
a0k?1![u0k+1 ;Rk+1 ] : : : ![u0n ;Rn ] c0
Figure 25: from g to a constructor graph c. So by Proposition 17, (p; R) = (g ) exists, g can be rewritten at node p with rule R and in any rewriting derivation from g to c, a descendant of gjp is rewritten into a constructor-rooted term graph. Thus there exists a graph g 0 such that g ![p; R] g 0 and the derivation B is of the form B = g ![u1 ; R1] a1 ![u2 ; R2] : : : ![uk?1 ; Rk?1] ak?1 ![p; R] ak ![uk+1 ; Rk+1] : : : ![un ; Rn] c, with ui 6= p for all i 2 1::(k ? 1) and i 2 (k + 1)::n. First, according to Lemma 2, since g ![u1 ; R1] a1 , g ![p; R] g 0, there exist two graphs b1 and 0 a1 such that a1 !" [p; R] b1, g 0 !" [u1 ; R1] a01 , and b1 a01 . Since gjp is a needed redex of g, and p 6= u1 , p is a node of a1, so a1 6= b1 and a1 ![p; R] b1. More generally, according to Proposition 12, if g ![u1 ; R1] a1 : : : ![uk?1 ; Rk?1] ak?1 and g ![p; R] g 0, then there exist two graphs bk?1 ; a0k?1 such that ak?1 !" [p; R] bk?1 , g 0 !" [u1 ; R1 ] : : : !" [u0k?1 ; Rk?1] a0k?1 , and bk?1 a0k?1 . In this second derivation, u0i is the node corresponding to ui by renaming (when it exists). Since gjp is a needed redex of g and p 2= fu1 ; : : :; uk?1 g, p is a node of ak?1 so ak?1 ![p; R] bk?1 . The length of the derivation g ![u1 ; R1] : : : ![uk?1 ; Rk?1 ] ak?1 is exactly k ? 1, whereas the length of the derivation g 0 !" [u1 ; R1] : : : !" [u0k?1 ; Rk?1] a0k?1 is less or equal to k ? 1. Second, ak?1 ![p; R] ak and ak?1 ![p; R] bk?1 , hence ak bk?1 and since a0k?1 bk?1 , a0k?1 ak . Last, ak ![uk+1 ; Rk+1 ] : : : ![un ; Rn] c and a0k?1 ak , so it is clear that there exists a constructor graph c0 such c c0 and a0k?1 ![u0k+1 ; Rk+1] : : : ![u0n ; Rn] c0. The length of the derivation B is exactly n, whereas the length of the derivation g0 !" [u1 ; R1] : : : !" [u0k?1 ; Rk?1] a0k?1 ![u0k+1 ; Rk+1] : : : ![u0n ; Rn ] c0 is less or equal to n ? 1.
2
Theorem 3 The strategy is c-hyper-normalizing strategy (and thus c-normalizing). 30
g0
!
g00
n00 n0
n0 c0
!
c00
g1
!
: : : !
n1 n00 ? 1 c1
C0
0 :::
C0
Figure 26:
Proof This proof is sketched in Figure 26. Let g0 be an admissible graph, c0 a constructor graph such that there exists a rewriting derivation g0 ! c0 of length n0 . We prove this theorem by
induction on n0 . The case n0 = 0 is straightforward. Let n0 > 0 and suppose the theorem is true for all lengths p < n0 . Let D be a derivation starting with g which contains in nitely many times 0 0 -steps. D is of the form g0 ! g0 ! g1 ! g1 ! g2 ! : : : By con uence (see Theorem 1), since g0 ! g00 , g0 ! c0 is of length n0 and c0 is a constructor normal form, there exists a constructor 0 0 0 0 0 graph c0 c0 and a derivation g0 ! c0 of length n0 n0 . Since g0 ! c00 of length n00 , g00 ! g1, and c00 is a constructor graph, we deduce by Lemma 6 the existence of a constructor graph c1 c00 and a derivation g1 ! c1 of length n1 < n00 . Let D0 be the sub-derivation of D starting with g1. c is of length n < n and D0 contains in nitely many times -steps (since The derivation g1 ! 1 1 0 D contains in nitely many times -steps). So by induction hypothesis, D0 ends with a constructor graph C 0 c1, thus D ends with the constructor graph C 0 c0 .
2
Graph rewriting does not duplicate data. Thus the number of rewriting steps which are necessary to compute a constructor normal form may be optimized. We obtain the following result for the strategy . Theorem 4 Let g be an admissible graph and c a constructor graph such that there exists a rewriting derivation g ! c. Then there exists a constructor graph c0 with c0 c such that the length of the -derivation g ! c0 is less (or equal) to the length of the derivation g ! c.
Proof By induction on the length n of the derivation g ! c. The case n = 0 is straightforward.
Let n > 0 and suppose the theorem is true for all lengths p < n. Thanks to Lemma 6, there exist an admissible graph g 0 such that g ! g 0, a constructor graph c0 c and a rewriting derivation g0 ! c0 of length n0 < n. By induction hypothesis, there exist a constructor graph c00 c0 and a -derivation g 0 ! c00 of length n00 n0 . The length of the derivation g ! g 0 ! c00 is n00 + 1 n0 + 1 n and c00 c. 2
7 Conclusion We characterized the class of admissible graphs. For this class of graphs, we proved the classical con uence as well as the con uence modulo bisimilarity of the graph rewriting relation induced by orthogonal constructor-based GRSs, even in the presence of collapsing rules. We have also presented a new strategy for inductively sequential graph rewriting systems. This strategy has been de ned precisely and proved to be c-normalizing and optimal for the class of admissible graphs. The use of de nitional trees allows to combine the elegance of neededness with an ecient implementation by pattern-matching. In [KSvEP93], a lazy graph rewriting strategy close to ours is described, namely the annotated functional strategy, which combines the discriminating position strategy [PvE93] and 31
rewriting with priority [BBK87]. At our knowledge, no formal result has been proved regarding this strategy. The main motivation of this work was the de nition of an operational semantics of functional and logic languages based on narrowing. The extension to narrowing of the rewriting strategy presented in this paper can be found in [EJ97].
Acknowledgment The rst author is very indebted to Sergio Antoy and Michael Hanus for the many fruitful discussions.
A Matching Matching is essential for graph rewriting. We rst recall its de nition and then we give an algorithm. De nition 30 (Matching) Given a graph g , a term graph l and a node n of g , we say that l matches g at node n, denoted l gjn , if there exists a homomorphism h : l ! gjn . h is called the matcher of l on g at node n.
2
Here is a matching algorithm : Given two term graphs g1 , g2, it computes the relation on Ng1 Ng2 which induces a function h : Ng1 ! Ng2 such that h is a homomorphism from g1 to g2, when it exists, and fails otherwise. It begins with the pair (fRootg1 Rootg2 g; ;), and ends with the pair (;; h) in case of success, or 2 in case of failure. The rules are : fn1 n2 g[;h if n1 2= Dom(h) and Lg1 n1 2 X ; ;h[fn1 7!n2 g fn1 n2 g[;h fu1 v1 ;:::;uk vk g[;h[fn17!n2 g if n1 2= Dom(h), Lg1 (n1) 2= X , Lg1 (n1) = Lg2 (n2), Sg1 (n1) = u1 : : :uk and Sg2 (n2) = v1 : : :vk ; fn1 n2 g[;h if n1 2= Dom(h), 2 Lg1 n1 2= X and Lg1 (n1) =6 Lg2 (n2) ; fn1 n2 g[;h if n1 2 Dom(h) and h(n1 ) = n2 ; ;h fn1 n2 g[;h if n1 2 Dom(h) and h(n1 ) = 6 n2 . 2
References
[AEH+ 96] Marc Andries, Gregor Engels, Annegret Habel, Berthold Homann, Hans-Jorg Kreowski, Sabine Kuske, Detlef Plump, Andy Schurr, and Gabriele Taentzer. Graph transformation for speci cation and programming. ??, 1996. In preparation. [AK96] Z.M. Ariola and J.W. Klop. Equational term graph rewriting. Fundamenta Informaticae, 26(3-4), 1996. [Ant92] S. Antoy. De nitional trees. In Proc. of the 4th Intl. Conf. on Algebraic and Logic programming, pages 143{157. Springer Verlag LNCS 632, 1992. 32
[BBK87] [BvEG+ 87] [Cou93] [EJ97] [ET96] [HL91]
[HP95] [Hue80] [KKSV94]
[KKSV95] [Klo92]
[KSvEP93]
[O'D77] [PvE93]
J.C. Baeten, J.A. Bergstra, and J.W. Klop. Term rewriting systems with priorities. In Proc. of Conference on Rewriting Techniques and Applications, pages 83{94, Bordeaux, 1987. Springer Verlag LNCS 256. H. Barendregt, M. van Eekelen, J. Glauert, R. Kenneway, M. J. Plasmeijer, and M. Sleep. Term graph rewriting. In PARLE'87, pages 141{158. Springer Verlag LNCS 259, 1987. B. Courcelle. Reecriture de graphes: orientation bibliographique. Available via URL : http://www.labri.u-bordeaux.fr/ courcell/ActSci.html, 1993. R. Echahed and J. C. Janodet. Introducing graphs in functional logic programming languages. Technical report, IMAG, 1997. In preparation. H. Ehrig and G. Taentzer. Computing by graph transformation : A survey and annotated bibliography. Bulletin of the EATCS, 59:182{226, June 1996. G. Huet and J.-J. Levy. Computations in orthogonal term rewriting systems. In J.-L. Lassez and G. Plotkin, editors, Computational logic: essays in honour of Alan Robinson. MIT Press, Cambridge, MA, 1991. Previous version: Call by need computations in non-ambiguous linear term rewriting systems, Technical Report 359, INRIA, Le Chesnay, France, 1979. A. Habel and D. Plump. Uni cation, rewriting, and narrowing on term graphs. Electronic notes in Theoretical Computer Science 1, 1995. Available via URL : http://www.elsevier.nl/locate/tcs. Gerard Huet. Con uent reductions: Abstract properties and application to term rewriting systems. JACM, 27(4):797{821, 1980. J. R. Kennaway, J. K. Klop, M. R. Sleep, and F. J. De Vries. On the adequacy of graph rewriting for simulating term rewriting. ACM Transactions on Programming Languages and Systems, 16(3):493{523, 1994. Previous version: Technical Report CSR9204, CWI, Amsterdam, 1992. J. R. Kennaway, J. K. Klop, M. R. Sleep, and F. J. De Vries. Trans nite reduction in orthogonal term rewriting systems. Information and Computation, pages 18{38, 1995. J. W. Klop. Term rewriting systems. In S. Abramsky, D. Gabbay, and T. Maibaum, editors, Handbook of Logic in Computer Science, Vol. II, pages 1{112. Oxford University Press, 1992. Previous version: Term rewriting systems, Technical Report CS-R9073, Stichting Mathematisch Centrum, Amsterdam, 1990. P.W. Koopman, J.E. Smetsers, M.C. van Eekelen, and M.J. Plasmeijer. Graph rewriting using the annotated functional strategy. In Ronan Sleep, Rinus Plasmeijer, and Marko van Eekelen, editors, Term Graph Rewriting: Theory and Practice, chapter 23, pages 317{332. John Wiley, New York, 1993. M. J. O'Donnell. Computing in Systems Described by Equations. Springer Verlag LNCS 58, 1977. R. Plasmeijer and M. van Eekelen. Functional Programming and Parallel Graph Rewriting. Addison-Wesley, 1993. 33
[SPvE93] M. R. Sleep, M. J. Plasmeijer, and M. C. J. D. van Eekelen, editors. Term Graph Rewriting. Theory and Practice. J. Wiley & Sons, Chichester, UK, 1993.
34