Embedding of Conditional Graph Transformations

0 downloads 0 Views 224KB Size Report
?1(M ) de- notes the set of pre-images of m 2 M atch(R) resp. M. M atch(R) under r and r ?1 d (m ) resp. r ?1 d (M ) their biggest subsets that contain only d-.
Embedding of Conditional Graph Transformations Reiko Heckel Technische Universitat Berlin Fachbereich Informatik D-10587 Berlin

ABSTRACT

Single pushout graph transformations at injective matches are extended by negative application conditions. It is shown, how right-sided application conditions can be transformed into equivalent left-sided ones. Based on this result, conditional derived rules are introduced and a theorem, similiar to the double pushout embedding theorem is shown. Finally, three variants of contextual application conditions are discussed with respect to their expressive power and expected results.

1 Introduction

Graph transformations [Ehr79], [Low93] are a good means for describing the development of structured states in elementary steps. However, for the speci cation of more complex operations we have to provide some mechanism to control the transformation process. One way to do this, is to control applicability of rules directly by so-called application conditions. The basic idea is, that the graphs and matches involved in the transformation have to satisfy certain conditions. These can be speci ed on the left- and/or right-hand side of a rule and have to be checked at run-time before the rule can be applied. Application conditions were used in several approaches to graph rewriting (see e.g. [PR69], [Mon70], [vS84]), while the most evolved wrt. to expressive power can certainly be found in PROGRES [Sch91]. In the algebraic approach, application conditions have been introduced in [EH85] on a semantical level. In [HHT94] left-sided positive and negative contextual conditions are developed in the framework of single pushout graph transformations. They are studied with respect to their generative power and \classical" results from algebraic graph grammar theory, as the local Church-Rosser and the parallelism theorem, are extended to conditional graph transformations. Moreover a graphical representation of application conditions is proposed. In this paper we use a slightly changed de nition of application conditions, which has been suggested

in [HHT94], too. We don't consider positive application conditions but additionally allow right-sided ones. Moreover we restrict ourself to single-pushout transformations at injective matches and de ne so-called injective application conditions, which increase the expressive power by also allowing cardinality restrictions concerning, for example, the number of in- or outgoing edges for a given node. These injective application conditions have interesting technical properties, as we will show throughout this paper, that do not hold for the unrestricted case. They seem to be very natural and intuitive since all relationships between graph, rule and application condition can be understood as generalized subgraph embeddings. Restriction of transformations to injective matches means no loss of expressive power, because every graph grammar can be replaced by an equivalent one based on injective matches by building its closure wrt. minimal rule-derived rules (see e.g. [Low93]). Embedding of algebraic graph transformations is studied in [Ehr77]. From a sequence of direct transformations, a derived rule is constructed to summarize the e ect of the whole sequence within a single direct transformation. Applicability of this derived rule is restricted by a so-called JOIN-condition to ensure, that all the gluing conditions of the original rules are satis ed. In [Low93] this embedding theorem is generalized to single pushout transformations. In this framework, the JOIN-condition is no longer necessary since single pushout transformations work without gluing condition. For conditional single pushout transformations, the situation is very similar to the double pushout case. We construct a conditional derived rule for a given conditional transformation sequence and show, that the application condition of this rule is equivalent to the application conditions of the rules used in the given sequence. The paper is organized as follows. Section 2 provides us with basic de nitions and gives some connections between double and single pushout direct transformations. In section 3 we introduce conditional rules and transformations and show, how to anticipate right-sided application conditions within the left-hand side of the rule,

Page 1

i.e. how to nd an equivalent left-sided application condition for a given right-sided one. Using this result, an embedding theorem for conditonal graph transformations is developed in section 4. All concepts are illustrated by a small example of representing sets by data objects and references between them. Section 5 reviews three di erent versions of application conditions that have been suggested in the algebraic approach up to now and shows possible directions of future research in this area.

2 Basic Notions

In this section we provide the de nitions of graphs, rules und transformations etc. and compare them to double pushouts transformations.

De nition1 (Graphs and graph morphisms).

Let T = (N; A) be sets of node- and arctypes, respectively. 1. A graph G = (GV ; GE ; sG; tG ; nG; aG) of type T consists of a set GV of nodes, a set GE of edges, source and target mappings sG : GE ! GV and tG : GE ! GV , and two mappings nG : GV ! N and aG : GE ! A, typing nodes and edges, respectively. 2. G is called subgraph of G0 (G  G0 ), if GV  G0V , GE  G0E , and the mappings sG , tG , nG , and aG are restictions of the corresponding ones from G0. f 0 3. A total graph morphism f : G ! G0, G ! G or f for short, is a pair of functions fV : GV ! G0V 0 0 G G and fE : GE0 ! GE such that f0 V  s = s  fE0 , fV  tG = tG  fE , fV  nG = nG and fE  aG = aG . f is called injective (surjective, bijective) if both fV and fE are injective (surjective, bijective). The set of all total, injective graph morphisms starting from a graph L is denoted by Match(L). 4. A partial graph morphism f : G ! G0 is a total graph morphism from some subgraph df  G to G0, f G0 ). Alternatively, we can i.e. f = (G if? df ?! consider f to be a pair (fV ; fE ) of partial functions, satisfying the same commutativity conditions as in the total case but in the category of sets and partial functions. 5. The composition f 0  f : G ! G00 of two (partial) graph morphisms f : G ! G0 and f 0 : G0 ! G00 is de ned by f 0  f = (fV0  fV ; fE0  fE ), where \" is the composition from the category of sets and partial functions. 6. GraphsT denotes the category of graphs of type T and partial graph morphisms, where the identities are pairs of identity functions on the sets of nodes and edges, respectively. GraphstT is the subcategory of GraphsT that contains only total graph morphisms.

Beside from rules, matches and transformations, the de nition below introduces a so called transformation mapping r for every rule r, which provides us with a very compact notation for the constructions of the subsequent sections. Please note, that matches are injective! This ensures a total embedding of the right-hand side of the rule into the derived graph. De nition2 (Transformation). Let T be given as above. r R of type T is a morphism 1. A graph rule L ?! of GraphsT. If m is a match for r into am graph G, i.e. a total injective graph morphismr;m L ?! G 2 Match(L), the direct transformation G =) H from G to H is given by the pushout 1 of r and m in GraphsT as shown in gure 1 and r is called the r;m transformation morphism of G =) H. 2. m is called d-complete wrt. r if it satis es the dangling condition, i.e. if for all nodes v 2 mV (LV ? (dr )V ) holds that 9 e 2 GE : v = sG (e) _ v = tG (e) implies e 2 mE (LE ? (dr )E ). 3. r induces a transformation mapping r : Match(L) ! Match(R), de ned by m 7! m . r?1 (m ) resp. r?1 (M  ) denotes the set of pre-images of m 2 Match(R) resp. M   Match(R) under r and r?d 1 (m ) resp. r?d 1 (M  ) their biggest subsets that contain only dcomplete matches for r. 4. A transformation of lengthr n;m2 N isr a;msequence of n n direct transformations G1 =1 )1    = ) Gn+1. Its  transformation morphism r is given by rn    r1 if rk is the transformation morphism of the direct mk G . transformation Gk r=k) k+1

L m

r

-

(PO) ?

G

r

R m

-

?

H

r R Direct transformation from G to H based on L ?! m and L ?! G.

Fig. 1.

r is total and right unique (up to isomorphism) by the corresponding pushout property. Moreover, r is injective if r is injective. r?d 1 (m ) is a proper subset of r?1(m ) 1

For the fundamental de nitions and results of category theory | such as pushouts and their properties | we refer to [HS73].

Page 2

i r deletes at least one node. It has cardinality  1 if r is injective, due to injectivity of r in this case. Single pushout transformations at injective matches can be constructed in two steps: 1. Remove from G all dangling edges, i.e. all edges e 2 GE ? mE (LE ) whose source- or target-nodes are deleted. 2. Replace the image of L in G by R. Below the second step of this construction is characterized as double pushout transformation [Ehr79]. Then a construction is given, how to obtain a double pushout from a single pushout transformation if its match is not d-complete. These results are needed in section 3 to translate right-sided application conditions into leftsided ones. r L

ir

dr

m (PO) ?

G

ir

r (PO)

?

dr

r

r Fig. 2.

-

?

R

m ? -H 6

A double pushout transformation.

Lemma 3 (D-completeness). Let G =r;m ) H be a di-

rect transformation. 1. G =r;m ) H can be characterized as a double pushout (see gure 2) i m is d-complete wrt. r. 0 2. G =r;m ) H can be reduced to a transformation G0 =r;m) H s.t. m0 is d-complete wrt. r and G0 g  G, i.e. there is a total injective morphism G0 ?! G as in gure 3 s.t. (1) and (2) are commutative. Proof. 1. Single pushout transformations at d-complete,

d-injective matches are equivalent to double pushout transformations (see [Low93] for a proof). m is dinjective because it is injective. 2. If we removeg from G all dangling edges we obtain G0  G. Let G0 ?! G be the corresponding embedding. m(L)  G0 because dangling edges are not in the image of m. Therefore, m0 = mjG0 is total and g  m0 = m. Similarily we get ir0 = ir jG0 . It is total because dangling edges are deleted, i.e. they have no pre-image in



 

m  

L

ir

dr

m0 (PO) ?

ir0

r (PO)

?

dr G0   (1)  ?  (2)  g 

r

-

R m

? -H

?   ?  ir

 ) G Fig. 3.

Reduction of transformations to d-complete matches.

wrt. r i.e. the single pushout dr . Now, m0 is d-complete r;m0 0 transformation G =) H can be drawn as the double pushout in gure 3.

3 Negative Application Conditions

In [EH85] a very general notion of application conditions is presented. This is restricted to left-sided positive and negative contextual conditions in [HHT94] while below we de ne left- and right-sided negative conditions for injective matches only. For a discussion of the relationships between these di erent versions we refer to section 5.

De nition4 (Negative application conditions).

1. A negative application condition over a graph L is a nite set AL  Match(L) of total, injective morl L^ , called constraints. phisms L ?! l m G 2 2. Let L ?! L^ be a constraint and L ?! Match(L). We say that m satis es l, written m j= l, n G 2 Match(L^ ) such that if there is no L^ ?! n  l = m. 3. Let AL be an application condition over L and m 2 Match(L). Then m satis es AL , written m j= AL , if it satis es all negative constraints from AL, i.e. if 8 l 2 AL : m j=N l: r R; A(r)) 4. A conditional rule is a pair r^ = (L ?! consisting of a rule r, and an application condition A(r) = (AL ; AR ) for r. 5. Given a graph G, r^ is applicable to G (via m) if there exists a direct transformation G =r;m ) H as in gure 1 s.t. m satis es AL and m satis es AR . Then, the direct conditional transformation G =r^;m ) r;m H is the direct transformation G =) H. De ning negative application conditions in this way, they t exactly into the framework of application condi = tions given in [EH85]. An application condition A(r)

Page 3

r R in the sense of [EH85] (AL ; AR ) for a graph rule L ?! consists of two decidable classes of total graph morphisms starting from L and R respectively, i.e. AL  Match(L) and AR  Match(R). A total graph morm G (R ?! m H) satis es A (A ) if m 2 A phism L ?! L R L (m 2 AR ). An application condition A(r) = (AL ; AR ) as de ned above can be seen as a speci cation for these  classes of matches. For a given A(r) we can de ne A(r) as  = (fmj 8l 2 AL : m j= lg; fm j 8l 2 AR : m j= l g): A(r)

Now m (m ) satis es AL (AR ) i m 2 AL (m 2 AR ).

to the s-edge named d. If it is matched to a, l1 isn't satis ed and for b or d, the same holds for l2 . Note, that l2 contains a cardinality restriction, i.e. there must not exist a second s-edge. The following proposition contains the main technical result of this paper. It shows, how to anticipate a rightsided application condition by a left-sided one, whithout changing its meaning. This will be used in section 4 to construct the derived rule of a conditional transformation of length greater than one. r R be a Proposition5 (Anticipation.). Let L ?! rule and A an application condition over R. Then for m GR2 Match(L), we have all L ?! r(m) j= AR () m j= r?d (AR ): 1

L1

T vis S 1

L

l1

s S 2

L

R

r @l @ R @

m

? ?n ? ?

S 1

L

(2)

@l  @ R @ r^ m??n?  ? -H

R^

l2 S m s S 2 G T

S a:s

ir l

dr

r

-

R

@ l @  R @ (8) L^  dr^  m  m0 ? (7) (5) ? (4) m ?  ?n0 ? ?n ? ? ? ? ? ?  0  dr H  (1) G ir0 r  ?  (2)   g ?   ? ir  ) G  @

s

r

R

S 1=2

S 2

L2

S 1

(1)

L^

G

r s

-

vis S

S

@ R @

(6)

@ @ R @

(3)

R^

Fig. 5. Transformation of a right-sided into a left-sided application condition.

b:s c:s

d:s S

S

Fig. 4.

Applicability of a conditional rule.

Example 1 (Conditional rules). Figure 4 shows a conditional rule r^ = (r; (fl ; l g; ;)) with two left-sided 1

2

and no right-sided application condition. According to de nition 4, r^ is applicable to the graph G only if the single s-edge in the left-hand side of this rule is matched

Proof. We show that r(m) j= l i m j= r?d 1(l ) for all

l  2 AR . \=)" holds, if from 9 l 2 r?d 1 (l ): m 6j= l follows r(m) 6j= l , i.e. we have to show, that there exists an n H s.t. n  l = m if there exists an injective R^ ?! n injective L^ ?! G s.t. n  l = m. Consider the upper diagram of gure 5 and let (1) and (1+2) be pushouts, i.e. r(l) = l and r(m) = m . Given n, we obtain n by the pushout of r^ and n. n is total since n is injective and due to inheritance of injectivity

Page 4

by pushouts, n is injective. Since m = n  l we have m = n  l by pushout compositionality. For \(=" we show, that r(m) 6j= l implies 9 l 2 ? rd 1 (l ): m 6j= l. Consider the lower part of gure 5. Given G =r;m ) H, there is a double pushout transformar;m0 0 tion G =) H s.t. g is injective and (1) and (2) are commutative due to lemma 3. Then, given injective l and n s.t. m = n  l , we have to show that there are l 2 r?d 1 (l ) and n injective, s.t. m = n  l. Using lemma 6 we construct pushout complements (3) and (4) s.t. (5) is commutative and then pushouts (6) and (7). Now l 2 r?d 1(l ) since (6) and (3) build a double pushout ^ i.e. l is d-complete wrt. r. (8) transformation L^ =r;l) R, commutes by pushout compositionality and we de ne n = g  n0, which satis es n  l = m by commutativity of (1) and (8). The construction of r?d 1(l ) for a right-sided constraint l can be seen as a generalized reverse transfor?1  mation. If r is injective r?d 1(l ) is equivalent to R^ r=);l L^ , i.e. it yields flg i l is d-complete wrt. r?1. If a node v 2 RV has two pre-images under r we additionally have to construct all distributions of the edges from the 1-context of v over its pre-image nodes. Below we state the decomposition lemma used in the proof of proposition 5.

Lemma 6 (Decomposition of PO complements).

Let the outer diagram of gure 6 be a pushout in GraphstT, c; d; e be injective and (1) commutative. Then there are morphisms h and injective a and b s.t. (2) commutes and (3) and (4) are pushouts in GraphstT.

show, that (3) is a pushout. Then, also (4) is a pushout by pushout decomposition. According to [Wag93], (3) is a pushout in GraphstT i (for nodes and edges) 1. (3) is commutative 2. h(x) = h(y) =) x = y _ 9 x0; y0 2 A: x = a(x0 ); y = a(y0 ); g(x0) = g(y0 ) 3. d(x) = d(y) =) x = y _ 9 x0 ; y0 2 A: x = g(x0 ); y = g(y0 ); a(x0) = a(y0 ) 4. h(x) = d(y) =) 9 x0 2 B; y0 2 D; z 2 A: h(x) = h(x0 ); d(y) = d(y0 ); x0 = a(z); y0 = g(z). 5. h and d are jointly surjective. If we consider all injective morphisms as embeddings, we have A  B  C, D  E  F and g  h  k. Therefore, 1. to 5. simplify as follows: 1. (3) is commutative 2. h(x) = h(y) =) x = y _ x; y 2 A ^ g(x) = g(y) 3. No longer necessary because d is injective. 4. h(x) = y =) 9 z 2 A: h(z) = h(x) ^ y = g(z) 5. x 2 E ^ x 62 D =) 9 z 2 B: x = h(z) Now we show that (3) satis es these conditions, assuming that (3+4) does. 1. (3) is commutative (by assumption) is PO x = hk 2. h(x) = h(y) = ) k(x) = k(y) (1+2)=) y _ x; y 2 A ^ g(x) = g(y) is PO 9 z 2 A:k(z) = hk 4. h(x) = y = ) k(x) = y (1+2)=) 2B 9 z 2 A:h(z) = h(x) ^ y = g(z) k(x) ^ y = g(z) x;z =) is PO x = 5. x 2 E ^ x 62 D E=)F x 2 F ^ x 62 D (1+2)=) k(z) h=k=jE);x2E x = h(z)

T

T

T

T

create

delete vis

A g -D a (3) d ? ? c (2) B h - E (1) f b (4)

-

Fig. 6.

?

C

e

S

S

T vis

vis insert S

S

Decomposition of pushout complements.

e E

Proof. First we build diagram (4) as a pullback (inverse image square) of e and k and get a and commutativity of (2) and (3) by universal property of the pullback object B. a is injective because c is injective and (2) commutes and b is injective because this is inherited from e. We

S

T

? 

k-F

vis

Fig. 7.

s

S

e E

Creating and deleting sets and inserting elements.

Negative application conditions as de ned in 4 can express the dangling condition (see [HHT94] for an explicit

Page 5

construction). Therefore, conditional single pushout transformations can be used to simulate double pushout transformations at injective matches. In the following example however, more speci c application conditions are needed, because the dangling condition would be to strong in some situations and to weak in other ones. Example 2 (Sets as data structure). We want to demonstrate the expressive power of negative application conditions by a small graph speci cation concerning the representation of sets by a graph, consisting of data objects and references between them. Sets should be built over a xed domain D, i.e. at any given time the state graph should represent a subset A of the set P(D) of all sets over D. The root of the whole data structure is a single node of type T. Nodes of type S and E represent sets and elements, respectively. The element relation is modelled by edges of type e and an edge of type s between two distinct S-nodes means, that every element of the set represented by its target node is considered to be a member of the set represented by its source node. Finally, an Snode is visible to the outside world if it is referenced by an edge of type vis. The edge types s and vis are used to build up sets from auxiliary subsets, which are not necessarily visible to the outside world. Given the domain D and an interpretation I(x) 2 D for all E-nodes x, we de ne the interpretation I(X)  D of S-nodes X and I(A)  P(D) of T-node A in a correctly typed graph G by e x 2 Gg [ S s { I(X) = fI(x)j X ?! X ?!Y 2G I(Y ) and vis X 2 Gg. { I(A) = fI(X)j A ?!

T

S s

vis

4 Embedding of transformations

garbage

S

T vis S 1

S

glue S

s

s

1=2

S 2

Fig. 8.

hand, they can be used to generate representations of all sets A  P(D) from a start graph, consisting of a single T-node and E-nodes for all elements of the domain D. On the other hand, they should actually operate on these representations, modelling possible computations. Therefore, all operations should be local in the sense that they should e ect only the sets to which they are applied and leave all other sets unchanged. Since this requires a certain amount of redundancy, we additionally provide two garbage collection operations that do not modify the interpretation of any visible S-node in the graph but merely simplify the representation. We use the graphical representation of constraints that is suggested in [HHT94]. Constraints are distuingished by dashed borders. All nodes and edges outside the dashed-bordered parts form the left-hand side. l L^ is given by the union of the leftA constraints L ?! hand side with one of the dashed-bordered parts and the corresponding embedding. Figure 4 of example 1 above shows the formal representation of the rule glue in gure 8. The start graph contains a single T-node and E-nodes for every element x 2 D. Rules that specify the create, delete and insert operation are given in gure 7. Note that sets are not really deleted but hidden from the outside world because they can be used as auxiliary subsets. For the same reason, insert does not insert an element directly into a set but creates a new set, makes it to a superset of the given one and adds the element to the new set. A negative application condition ensures, that no e-edge is inserted twice. Garbage collection operations garbage and glue are speci ed by the rules of gure 8. garbage actually deletes an S-node if it is not referenced from above and glue identi es an S-node with its auxiliary S-node if the latter is not referenced by anyone else.

Garbage collection.

On these data structures we provide operations to create and delete sets and insert elements to it. On one

This section is restricted to rules with left-sided application conditions, only. Using proposition 5 we can consider them as \normal forms" of conditional rules, i.e. the results given throughout this section are also valid in the general case. For transformations in the pure single pushout approach, the following embedding theorem holds (see [Low93] for a proof).

)n )1    r=n ;m Theorem 7 (Embedding). Let G r=1 ;m Gn be a transformation of length n 2 N with transe formation morphism r = rn      r  and G ?! K 2 Match(G ). Then there are K =r );e Kn and 0 0 )1    r=n ;m )n Kn such that their transformation K r=1 ;m 1

+1

1

1

1

1

1

1

+1

+1

morphisms are isomorphic.

Page 6

The intention of this section is to extend this theorem to conditional transformations as far as possible. The following example shows that there is no general embedding of conditional transformations. G2

G1 T

G3 T

T

glue s

S

vis

vis

vis

insert

2

1

S

S 1=2

S

E

1=2

s

S

e E

E

e’

e

K

K’

T

T vis

S 1

vis

s

vis 1 S

S

2

s

S 2

e E

E

Fig. 9. Transformation of length 2 with \impossible" embeddings.

every single application condition of the whole transformation. The answer is to construct a conditional derived rule for the transformation under consideration, having as the rule morphism the transformation morphism and an application condition that is satis ed by a match e if and only if the conditional transformation can be embedded via this match. For the case of a direct transformation the derived rule is called rule-derived and its application condition is constructed by so called gluing diagrams which translate a constraint over L via m into a set of constraints over G. De nition8 (Set of gluing diagrams). Let C c? a A ?! B be total and injective morphisms. A gluing diagram over a and c is a commutative rectangle with d D b? B, s.t. b and d together total and injective C ?! are surjective. The set of gluing diagrams GD(a; c) is the set of pairs (d; b), s.t. (a; b; c; d) is a gluing diagram. GD(a; c)1 (GD(a; c)2) denotes the projection to the rst (second) component, i.e. the set of all morphisms d (b) s.t. (a; b; c; d) is a gluing diagram. In [HHT94], pushouts are used to translate constraints via total morphisms. Since all morphisms are restricted to injective ones, the universal property of pushouts is lost here. Gluing diagrams solve this problem by considering a set, where all possible overlappings of morphisms b and d are present, i.e. they adapt the concept of pushouts to injective morphisms.

De nition9 (Conditional rule-derived rule). r R; A(r)) be a conditional rule and Let r^ = (L ?! G =r;m ) H a transformation via r^. Then, the condi r  tional rule r^ = (G ?! H; A(r )) is called rule-derived via G =r ;m ) H if r is the transformation morphism of transformation from G to H and A(r ) is Sthe direct GD(l; m) (see diagram 10). ^

Example 3. Figure 9 shows a transformation, where glue and insert from example 2 are applied to a graph G1 , producing a graph G30 . Total and injective more K and G ?! e K 0 are given to illustrate phisms G ?! the problems, associated with embedding of conditional transformation. Considering e, the embedding of the transformation via this morphism fails, because the target S-node of the s-edge is still referenced by a vis edge, wich contradicts the application condition of glue. A little bit more complicated is e0 . Here, the condition of glue is satis ed and its application identi es the two S-nodes and deletes the s-edge. But then insert is not applicable to the resulting graph, because of the e-edge between the S- and the E-node. It remains the question, under which conditions an embedding exists for a given transformation and an injective morphism e as above. In other words: How can we know, wether a given e gives rise to an embedding of a conditional transformation or not, without checking

^

l2A(r)

1

L^



B B

BBN

l

Fig. 10.

r

(GD) m (PO) 1 ? ygX G^ 1 X

n  ? g 9  

G^ n

L

G

r

-

R m

-

?

H

Conditional rule-derived rule.

The conditional rule-derived rule behaves just like its un-conditional counterpart, i.e. it is applicable to a

Page 7

match i the corresponding embedding exists and leads to the same result.

Proposition10 (Conditional rule-derived rule). r H; A(r)) the conditional rule-derived Let r^ = (G ?! e K 2 rule of G =r;m ) H as above. Then for all G ?!  r ;em Match(G) we have K =) S if and only if K =r );e S . Proof. We show me j= A(r) i e j= A(r ). Then lemma 10 follows from theorem 7 for n = 1. The above equivalence holds for A(r) if it holds for all l 2 A(r ), i.e. if m  e j= l i e j= g for all g 2 GD(l; m) . ^

^

^

1

Assume the gluing diagram (1) and f total and injective s.t. (2) in the left diagram of gure 11 commutes, i.e. e 6j= g. Then we have n = f  m^ with n  l = e  m by commutativity of (1) and (2). n is injective because f and m^ are, i.e. e  m 6j= l. L^



m^ ? G^ 

l

L

(1)

m

g

?

G

@ (2) @ e f@ @ R ? @

K

Fig. 11.

L^

n

m  l L G  Z 0  Zm ^ 0 (1) g Z  Z =  ~ Z (2)

^0 s G

 /

G^ (4) f 0

A fA ? AAU - K 

is constructed in two steps. First we buld rule-derived rules for all direct transformations. Then we obtain the rule morphism of the derived rule by composing all rule morphisms of the rule-derived rules. Its application condition is given by the union of all translations of application conditions from the rule-derived rules to the rst graph of the given transformation. De nition11 (Conditional derived rule). Let )1    r^=n ;m G1 r^=1 ;m )n Gn+1 be a conditional transformation of length n 2 N and (ri ; A(ri )) for i = 1 : : :n the corresponding rule-derived rules. The conditional derived  r  rule r^ = (G1 ?! Gn+1 ; A(r)) of the above transformation is given by { r = rn S    r1 and { A(r ) = k=1:::n (rk?1      r1 )?d 1(A(rk )). For k = 1 the composition rk?1  r1 yields idG1 , i.e. the application condition A(r1 ) of the rst rule-derived rule is translated into itself. Again, this conditional derived rule behaves very similiar to the usual derived rule.

Theorem 12 (Conditional derived rule). )1    rn=;m Let G r=1 ;m )n Gn be a conditional transforr G ; A(r)) the corresponding e mation, r^ = (G ?! n e K 2 Match(G ). conditional derived rule and G ?!  r ;e ) Kn if and only if there is Now, there is K = r1 ;m01 rn ;m0n K =)    =) Kn such that their transformation 1

(3)

Proof of conditional rule-derived rule lemma.

Conversely assume n total and injective s.t. n  l = e  m in the right diagram of gure 11. We show, that there is a gluing diagram (m; g; l; m) ^ and a total, injecf ^ tive morphism G ?! K s.t. n = f  m^ and e = f  g. Constructing the pushout diagram (1) we obtain total and injective m^ 0 and g0 . By universal property we 0 f have G^ 0 ?! K s.t. (2+4) and (3) are commutative. In general f 0 is not injective. Therefore, we factorize f 0 f s G^ and injective G^ ?! into surjective G^ 0 ?! K. Now, 0 0 (m; s  g ; l; s  m^ ) is no longer a pushout but still a gluing diagram because it commutes by commutativity of (1) and s  g0 and s  m^ 0 are injective because f 0 is injective on g0 (G) and m^ 0 (L^ ) by commutativity of (2+4) and (3) and injectivity of n and e, i.e. we get g = s  g0 and m^ = s  m^ 0 . Then, e = f  g resp. n = f  m^ by commutativity of (3) and (4) resp. (2). Now we extend this result to transformations of lenght greater than one. The derived rule for this case

^

^

+1

+1

1

1

1

^

1

^

1

1

+1

^

+1

morphisms are isomorphic. Proof. We de ne m0k = ek  mk with e1 = e and

ek+1 = rk (ek ) for k = 1 : : :n. From lemma 10 we conclude m0k j= A(rk ) i ek j= A(rk ) (*). Furthermore ek = rk?1      r1 (e) due to compositionality of pushouts. Then by proposition 5 we have, ek j= A(rk ) i e j= (rk?1      r1 )?d 1 (A(rk )). With (*) and de nition 11 we conclude e j= A(r ) i 8 k 2 f1; : : :; ng: m0k j= A(rk ). This shows, that r^ is applicable to e i all r^k are applicable to m0k . Equivalence of K1 =r^ );e Kn+1 and 0 0 )1    r^n=;m )n Kn+1 now follows from theorem 7. K1 r^=1 ;m If we simulate double pushout transformations at injective matches by conditional single pushout transformations, i.e. if all application conditions express the dangling condition, the application condition of the derived rule is equivalent to the JOIN-condition of the double pushout embedding theorem [Ehr77], [PT93]. Example 4. Figure 12 shows the two steps of constructing the conditional derived rule for the transformation shown in gure 9. In the upper part the application conditions of glue and insert are embedded via

Page 8

their matches into G1 and G2, respectively, leading to the rule-derived rules glue and insert . Then, the single constraint over G2 is translated to G1 by constructing all its d-complete pre-images according to de nition 11. Now, the derived rule is applicable via a match e i the original transformation can be embedded via this morphism. G1 T

G2 T

vis

S vis

s

S

s

1

T

T vis

vis

glue *

S 2

G3

insert * S 1=2

1=2

s

S

e

e E

S

E

E

G1 T

G3 T

vis

vis s

1 S e

T

S vis

s * * glue ; insert S

1=2 S

s

S

2 e

e E

E

Fig. 12.

Construction of the derived rule.

5 Conclusions Beside the one presented here, there are (at least) two more possibilities to express negative contextual application conditions for graph rules in the algebraic approach. They all share the overall structure, i.e. in evl L^ and ery case a constraint is a totalmmorphism L ?! it is satis ed byn a match L ?! G if there is no total morphism L^ ?! G s.t. n  l = m, but each of these three versions imposes di erent restrictions on l; m and n, respectively. The simplest one is certainly the de nition from [HHT94], which will be called general application conditions in the following. There, l; m and n are allowed to be arbitrary total morphisms. The main advantage l L^ can of this de nition is, that a constraint Lm ?! be translated via a total morphism L ?! G simply

by constructing their pushout. Therefore, all \vertical" constructions, like that of rule-derived, parallel and amalgamated rules can be extended to conditional rules very easily. But there are two circumstances, that count against this de nition. First, its expressive power is not sucient to express the dangling condition, which is part of the gluing condition and seems to be very popular in the algebraic graph grammar community. The problem is that, because of the unrestricted nature of n G we can not distinguish between the existence L^ ?! of one or two edges in the context of a node if they have the same type and direction, i.e. we can not express cardinality conditions. A more technical drawback is, that for general application conditions there is no equivalent translation of right-sided constraints into left-sided ones. But this is needed for some \horizontal" constructions as for example the derived rule for transformations of length greater than one and for the sequentialization of amalgamated graph transformations. The present de nition of injective application conditions, where l; m and n are assumed to be injective, requires more e ort for the translation of constraints via total (injective) morphisms (see de nition 8 and 9). Nevertheless all the vertical construction mentioned above are possible. Moreover right-sided application conditions can be anticipated within the left-hand side as shown in proposition 5. Both translations together were used in this paper to construct the derived rule and show a conditional embedding theorem. Since conditional graph transformations in the sense of this paper can simulate double pushout transformations at injective matches, this is a generalization of the embedding theorem in [Ehr77] for the injective case. The restriction to injective matches, however, is still a problem. On one hand the parallelism theorem is not valid for injective matches. This can be solved by constructing a special amalgamated rule instead of a parallel rule for every given pair of overlapping matches. On the other hand, it would be nice to have a full simulation of double pushout graph transformations that include a generalization of well-known results. One way out is suggested by Annegret Habel and will be the third version of application condition that we will discuss here. In this de nition, l and m are arbin G has to be injective trary total morphisms and L^ ?! on L^ ? l(L), i.e. it must not identify negative nodes and edges with each other or with positive ones. These n-injective application conditions are a direct generalization of injective ones to arbitrairy matches, i.e. they have the expressive power to express cardinality restrictions and the dangling condition and can be used to simulate the full range of double pushout transformations by conditional single pushout ones. Unfortunately, they are no good candidates for any of the constructions mentioned above since they already fail to permit equiv-

Page 9

alent translations via total morphisms. A compromise between injective and n-injective application conditions seem to be the best solution. We can use n-injective application conditions in speci cations if we want to allow non-injective matches, provide theoretical results for injective matches and application conditions and give a translation from the rst to the latter based on the construction of minimal rule-derived rules from [Low93]. Then, one piece of work in the eld of contextual conditions is, to investigate this translation and to nd out which \injective" notions of independency, parallelism, embedding etc. are needed to re ect the corresponding notions for the original \n-injective" speci cation.

This article was processed using the LATEX macro package with LLNCS style

REFERENCES

[EH85] H. Ehrig and A. Habel, Graph grammars with application conditions, The Book of L (G. Rozenberg and A. Salomaa, eds.), 1985, pp. 87{100. [Ehr77] H. Ehrig, Embedding theorems in the algebraic theory of graph grammars, 1977, pp. 245{255. [Ehr79] H. Ehrig, Introduction to the algebraic theory of graph grammars, 1st Graph Grammar Workshop, Lecture Notes in Computer Science 73, 1979, pp. 1{69. [HHT94] Annegret Habel, Reiko Heckel, and Gabriele Taentzer, Graph grammars with negative application conditions, submitted to special issue of Fundamenta Informaticae, 1994. [HS73] H. Herrlich and G. Strecker, Category Theory, Allyn and Bacon, Rockleigh, New Jersey, 1973. [Low93] M. Lowe, Algebraic approach to single-pushout graph transformation, TCS 109 (1993), 181{224. [Mon70] U. Montanari, Separable graphs, planar graphs and web grammars, Information and Control 16 (1970), 243{267. [PR69] J. L. Pfaltz and A. Rosenfeld, Web grammars, Int. Joint Confenence on Arti cial Intelligence (1969), 609{619. [PT93] J. Padberg and G. Taentzer, Embedding of derivations in high-level replacement systems, Tech. Report 93/9, 1993. [Sch91] A. Schurr, Progress: A vhl-language based on graph grammars, LNCS532, Springer, 1991. [vS84] S. H. von Solms, Node-label controlled graph grammars with context conditions, Intern. J. Computer Math 15 (1984), 39{49. [Wag93] A. Wagner, Vergleich von High-Level-Replacement-Systemen basierend auf dem Double- bzw. SinglePushout-Ansatz, Diplomarbeit, 1993.

Page 10