• Keine Ergebnisse gefunden

Summary

Definition 3.3. (Mapping Attributed Graphs with Object Models) An attribute graph AG conforms to an object model M iff: (i) they share

3.4 Triple Graph Grammars

Let a graph G0 be given. A sequence of direct derivationsG0 ⇒G1 ⇒. . .⇒ Gn by rules ofR is called a derivationfromG0 toGn by rules ofR. The set of all graphs labeled with symbols of T that can be derived from the initial graphS by rules ofR, is the languagegenerated by the graph grammar GG.

Definition 3.8. (Model Transformations Based on Graph Transfor-mation)

LetRbe a set of rules. Amodel transformation sequence (GS, GS GT, GT) consists of a source graph GS, a target graph GT, and a derivation fromGS to GT by rules of R.

SH, c = (cA, mA) : CG CH, and t = (tA, mA) : T G TH such that s◦sG=sH◦cand t◦tG=tH ◦t.

s1 : BoolExpr cmt=’Rains’

s3 : BoolExpr

cmt=’IfRainsThenTakeUmbrella’

s2 : BoolExpr cmt=’TakeUmbrella’

ImplFst

ImplSnd

t1 : BoolExpr cmt=’Rains’

t3 : BoolExpr cmt=’NotRains’

t2 : BoolExpr cmt=’TakeUmbrella’

t4 : BoolExpr

cmt=’NotRainsOrTakeUmbrella’

OrFst

Neg OrSnd

c2 : Corr c1 : Corr c3 : Corr

Figure 3.4: An attributed triple graph for aFLO2TLO integrated model Figure 3.4 shows an example attributed triple graph. This graph represents an integrated model of two logic languages. The source language, the so-called FLO language (FLO stands for ‘Four Logical Operators’), includes logic expressions by four operations , , ¬, and . The target language, the so-called TLO language (TLO stands for ‘Three Logical Operators’), includes logic expressions by three logical operations , , and ¬. A logic expression inFLO is logically equivalent to a corresponding logic expression inTLO. Such pairs of logic expressions can be represented by an integrated model in form of attributed triple graphs in the so-calledFLO2TLO language as depicted in Fig. 3.4.

In the left part of the example triple graph, the logic expression Rains T akeU mbrellais represented by theBoolExpr(‘Boolean Expression’) object s3 and two links ImplFst (‘Implication First’) and ImplSnd (‘Implication Second’). The first link represents the association between the hypothesiss1 (Rains) and the expression s3. The second link represents the association between the conclusion s2 (T akeU mbrella) and the expressions3.

In the right part of the example triple graph, a corresponding logic expression in the target language, ¬Rains∨T akeU mbrella, is shown. This expression is represented by the BoolExpr object t4 and two links OrFst (‘Or First’) andOrSnd(‘Or Second’) that connect the disjunction to the first and second literals,¬Rains and T akeU mbrella, respectively. The expression ¬Rains is represented by theBoolExpr t3 and the Neglink connectingt3 to t1.

TheCorrobjectsc1,c2, andc3 represent the correspondence between expres-sions of the source and target models. Here, the graph morphisms sG and tG in the example attributed triple graph are represented by links between the correspondence graph and the source and target graphs.

Definition 3.10. (Triple Rules)

A triple rule over a Σ-algebraAand a type-indexed family of sets of variables X = (Xt)t∈T is a pair of attributed triple graphs (L, R) over the term algebra TΣ(X) over Σ and X, provided with an attributed triple graph morphism tr :L→R as follows.

(SL (SR

CL CR

TL) TR)

s t

sR tR

tL sL

L = R =

tr c

where (SL,CL,TL) and (SR,CR,TR) are called the LHS and the RHS of the triple rule, respectively. The columns corresponding to (SL,SR) and (TL,TR) are called source and target parts of the rule, respectively. The middle column (CL,CR) is called the correspondence part of the triple rule.

sx : BoolExpr

cmt=X sy : BoolExpr cmt=Y

sx : BoolExpr cmt=X

sy : BoolExpr cmt=Y sxy : BoolExpr cmt=’If’||sx.cmt||’Then’||sy.cmt

ImplFst

ImplSnd

tnx : BoolExpr cmt=’Not’ || tx.cmt

txy : BoolExpr cmt=’Not’ ||tx.cmt||’Or’||ty.cmt

OrFst

Neg OrSnd

cy : Corr cx : Corr cxy : Corr

ty : BoolExpr cmt=Y tx : BoolExpr

cmt=X

ty : BoolExpr cmt=Y tx : BoolExpr

cmt=X cy : Corr

cx : Corr

SL CL TL

SR CR TR

Figure 3.5: A triple rule for a FLO2TLO integrated model

According to the definition, the RHS ‘contains’ the LHS due to the morphism tr. Hence, triple rules are non-deleting rules. Figure 3.5 shows a triple rule for an integrated model of models in FLO and TLO. The LHS and RHS

of the triple rule are triple graphs corresponding to models inFLO2TLO as shown in Fig. 3.4. We can employ OCL expressions to define the value of attributes of object nodes. Here, the ‘concat’ operator is denoted by ‘k’.

Definition 3.11. (Application of Triple Rules)

An application of a triple rule tr = (s, c, t) : L R to a given attributed triple graphG to yield a triple graph H consists of the following steps:

Choose an occurrence of the LHS L in G by defining a triple graph morphism m= (sm, cm, tm) :L→G, called a triple match.

Apply rules in each part of the rule: SG =s,sm SH, CG =c,cm CH, and T G =t,tm TH. We have the morphism n = (sn, cn, tn), where sn = SR →SH,cn=CR→CH, and tn=TR →TH

Induce morphisms sH : CH SH and tH : CH TH from the morphism n and morphisms in the triple graph (SR CR TR).

Therefore, H = (SH sH←CH tH TH, A) is an attributed triple graph.

(SG

(SH

CG

CH

TG)

TH)

t’

s’

sH tH

G =

H =

tr

SL

SR

CL

CR

TL

TR

sm tm

c’

cm

sn cn tn

The application of tr toG to yieldH is called a triple graph transformation step and denoted by G=tr,m⇒H.

Figure 3.6 shows an application of the triple rule specified in Fig. 3.5. Once graph morphisms between the parts of triple graphs are represented by links, the application of the triple rule can be seen as the application of a plain rule.

Definition 3.12. (Triple Graph Grammars)

A triple graph grammar is a structureT GG = (S,TR,TL, A), where S is an initial triple graph, T G = {r1, r2, . . . , rn} is a set of triple rules attributed overA, and TL is a set of terminal labels.

The set of all graphs labeled with symbols of TL that can be derived from the initial graph S by triple rules of TR is the language generated by the triple graph grammarT GG.

s1 : BoolExpr cmt=’Rains’

s3 : BoolExpr

cmt=’IfRainsThenTakeUmbrella’

s2 : BoolExpr cmt=’TakeUmbrella’

ImplFst

ImplSnd

t1 : BoolExpr cmt=’Rains’

t3 : BoolExpr cmt=’NotRains’

t2 : BoolExpr cmt=’TakeUmbrella’

t4 : BoolExpr

cmt=’NotRainsOrTakeUmbrella’

OrFst

Neg OrSnd

c2 : Corr c1 : Corr c3 : Corr s1 : BoolExpr

cmt=’Rains’

s2 : BoolExpr cmt=’TakeUmbrella’

t1 : BoolExpr cmt=’Rains’

t2 : BoolExpr cmt=’TakeUmbrella’

c2 : Corr c1 : Corr

Figure 3.6: Triple transformation step by the triple rule shown in Fig. 3.5 for a FLO2TLO integrated model