• No results found

Graph Transformation Approaches

2.2 Graph Transformations

2.2.1 Graph Transformation Approaches

Next to the specific graph formalism in which program structures are modelled, the specific graph transformation approach being applied determines what kind of results can be achieved. Two main aspects are (i) the conditions under which

direct derivations are allowed and (ii) the fact whether they can be performed unidirectional or bidirectional. These two aspect are the main driving forces for

either applying the Double Pushout approach [72, 45] or the Single Pushout approach [134, 69]. A more recently developed approach is the Sesqui Pushout approach[42], which combines the interesting features of the DPO and SPO. In the following paragraphs we will discuss each of them and discuss for what graph category they are defined.

Other graph transformation approaches that are no longer in the focus of interest (and will therefore not be discussed here) are the fibre approach by Kahl [109], the double-pullback approach by Heckel [99], and the pullback approach by Bauderon [15].

2.2.1.1 Single Pushout Approach

A liberal approach to graph transformation is the Single Pushout (SPO) ap- proach [134, 69]. As the name indicates, the transformations are described by a single pushout construction. The SPO approach is based on graph categories

Chapter 2. Background in Graph Transformation

in which the arrows are partial graph morphisms, e.g., the category GraphPor

SGraph.

In the SPO approach, transformation rules are represented by two graphs L and R with a partial graph morphism p: L → R.

Definition 2.14 (SPO transformation rule). An SPO graph transformation rule p: L → R consists of a left-hand-side graph L, a right-hand-side graph R,

and a graph morphism p mapping elements from L to elements of R.

Applicability of an SPO transformation rule is based on the existence of a

total graph morphism m: L → G, also called a matching. This means that we

can only apply a rule, if all the elements of L are present in the graph G, often called the host graph. The application of a transformation rule is depicted in Fig. 2.10. The resulting graph H is constructed by removing those elements from G that are not in the domain of p and creating the elements in R that do not have a pre-image in L.

Definition 2.15 (direct SPO transformation). A direct SPO transformation G=⇒ H via a rule p and a matching m is given by the diagram in Fig. 2.10,p,m

where (1) is a pushout in the considered graph category.

L R G H (1) p p′ m m∗

Figure 2.10: Rule application in the SPO approach.

The interesting thing about the SPO approach is that the application of a rule p might have side-effects, i.e., the rule application removes more elements than specified by the rule explicitly. Previously, we have seen two side-effects that might both occur in the SPO approach, namely the deletion of dangling edges, and the deletion of nodes for which the preserve-delete conflict occurs.

2.2.1.2 Double Pushout Approach

Th second graph transformation approach is the Double Pushout (DPO) ap- proach [72, 45]. The DPO approach is based on the category Graph. In the DPOapproach, transformation rules are described by three graphs L, K, and R together with two total graph morphisms l: K → L and r: K → R.

2.2 Graph Transformations

Definition 2.16 (DPO transformation rule). A DPO graph transformation rule p : L← Kl → R consists of a left-hand-side graph L, an interface graph K,r

and a right-hand-side graph R, together with two total graph morphisms l: K →L and r: K → R, where l is required to be injective.

For a rule p to be applicable to a graph G, we have to find a matching m of the left-hand-side (LHS) of p. The application of a transformation rule p via a matching m is depicted in Fig. 2.11. The target graph H is constructed in two phases. First, we construct the pushout complement D of the diagram (K → L, Ll → G), if it exists and is unique. The pushout complement exists ifm and only if the following conditions are satisfied [45]:

dangling edge condition: no edge e ∈ (EG− m(EL)) is incident to any node

in m(NL− l(NK));

identification condition: there is no x, y ∈ (NL∪EL) such that m(x) = m(y)

and y /∈ l(NK∪ EK).

A matching that satisfies both the dangling edge and the identification con- dition is said to satisfy the gluing condition. The fact that l is injective, then guarantees that the pushout complement is unique (up to isomorphism). As mentioned above (and exemplified in Example 2.8), in the category SGraph, pushout complements are not always unique, regardless of the morphism l be- ing injective or not. Therefore, the DPO approach cannot be applied to the category SGraph.

Intuitively, the first phase of the DPO construction removes the elements that are specified to be deleted by the rule; the second phase then adds those elements to D that have to be created by the rule.

L K R G D H (1) (2) l r l′ r′ m m′ m

Figure 2.11: Rule application in the DPO approach.

Definition 2.17 (direct DPO transformation). A direct DPO transformation G=⇒ H via a rule p and a matching m is given by the diagram in Fig. 2.10,p,m

Chapter 2. Background in Graph Transformation

Whereas a rule application in the SPO approach might result in side-effects due to the removal of dangling edges and the identification conflict, DPO trans- formations will never have side-effects. Matchings that would lead to dangling edges or identification conflicts do not satisfy the gluing condition and are there- fore not allowed in direct derivations.

2.2.1.3 Sesqui Pushout Approach

A more recently introduced approach to graph transformation is the so-called Sesqui Pushout (SqPO) approach [42] in the category Graph. ‘Sesqui’ is the Latin word for one-and-a-half, which indicates that this approach is a mixture of the DPO and SPO approach. In the SqPO approach, transformation rules are DPO-like spans of morphisms. A direct SqPO transformation step is defined comparable to a direct DPO transformation, where, however, pushout (1) in Fig. 2.11 is replaced by a pullback in which D is the final pullback complement. Properties of the l morphism determine whether the SqPO approach behaves like the DPO or the SPO approach. In the case l is an monomorphism, the fi- nal pullback complement coincides with the pushout complement D, if D exists, yielding a SqPO transformation which behaves equivalently to a DPO trans- formation. The non-existence of the pushout complement in combination with the existence of a final pullback complement results in SqPO transformations which behave equivalent to SPO transformations in which dangling edges are removed. For non-injective l morphisms, the SqPO approach models the effect of cloning graph elements. When the matching m does not satisfy the identifica- tion condition, the final pullback complement does not exist and transformation is not allowed.

2.2.1.4 Comparison

The main advantage of the SPO approach is that every match yields a direct derivation whereas in the DPO approach the gluing condition must be satisfied additionally. Stated differently, in the SPO approach one does not need to know the entire context of a match for a rule to be applicable; in the DPO approach a rule can only delete a node if it also deletes all incident edges.

The major advantage of the DPO approach is that rule applications never have side-effects. That is, a rule application only deletes elements for which deletion is specified explicitly. Suppose for a DPO rule p : L ← Kl → R wer define the reverse rule of p, denoted ¯p as the rule obtained by exchanging the roles of L and R, i.e., ¯p : R ← Kr → L. Then, if r is also injective (like l),l

2.2 Graph Transformations

it can be shown that every direct direction G =p,m==⇒ H there exists a direct derivation H ====⇒ Gp,m¯ ∗ ′, where m∗is the co-match of m, and Gis isomorphic to

G. Basically, this means that DPO transformations can be “undone”, in case r is injective.

As mentioned above, the SqPO approach is a mixture of the SPO and DPO approach. In fact, the SqPO approach combines the advantages of both the DPO and SPO approach depending on the injectivity of l and the existence of pushout complements and final pullback complements. Furthermore, SqPO transformations can specify graph elements to be cloned.

2.2.1.5 Application Conditions

So far, the applicability of graph transformation rules only depended on the existence of a matching m from the left-hand-side of the rule to the graph. In [96], Habel et al. introduced a way of equipping rules with so called positive and negative application conditions, independent of the underlying algebraic approach. In this thesis, we will equip the transformation rules with negative application conditions (NAC s, for short) in conjunctive form only. That is, all

NAC s have to be satisfied for the rule to be applicable. Then, a transformation

rule p is extended with a set N of negative application conditions with a total graph morphism n: L → N for each NAC N ∈ N .

Definition 2.18(NAC satisfaction). Given a transformation rule p with a left-

hand-side Lp and a set Np of negative application conditions, a graph G, and a

matching m: L → G. Let N ∈ Np be one of the negative application conditions of

p. Then, m is said to satisfy N if there does not exist a total graph morphism mN: N → G such that mN◦ n = m, where n: L → N is the graph morphism from

L to N .

In Fig. 2.12, NAC satisfaction is schematically depicted for a graph trans- formation rule in the SPO approach. A rule p for which the set N is non-empty is then said to be applicable to a graph G if there exists a matching m: L → P that satisfies all negative application conditions N ∈ N .

2.2.1.6 The GROOVE Approach

In the Groove Tool Set (which will be discussed in more detail in Section 2.3) graph transformations are performed on simple graphs using the SPO approach. The main advantages of applying the SPO approach is that we do not have to check whether the gluing conditions are satisfied and single transformation steps

Chapter 2. Background in Graph Transformation L G R N p m n ∄mN

Figure 2.12: A rule applications with negative application conditions.

can be constructed fairly easily by removing and adding graph elements. The advantage of using simple graphs is that they can be used to specify binary relations over objects very naturally, e.g., in the context of first-order predicate logic (see, e.g., [157]). Binary relations contain each pair of objects at most once, which is intuitively reflected by the fact that in simple graphs for every distinct label there can exist at most one edge between two nodes.

When transforming simple graphs, the DPO approach cannot be applied. For a DPO transformation to be well-defined, the pushout complement should exist and be unique. For simple graphs, satisfying the gluing conditions does not imply the uniqueness of the pushout complement. A simple example is a rule that deletes an edge without deleting its source or target nodes. For every such an edge, the pushout complement might not or might still have this edge. When applying the SPO approach, every match is guaranteed to produce a unique pushout object (upto isomorphism).