• Keine Ergebnisse gefunden

Variability-Based Model Transformation

4.4 Variability-Based Model Transformation

4.4.1 Variability-Based Rules

We denote variability using variability expressions, propositional ex-pressions over a set ofvariation points. We consider two kinds of vari-ability expressions: The varivari-ability model and varivari-ability conditions.

The variability model is used to express relationships between varia-tion points, such as mutual exclusion or implicavaria-tion. Variability condi-tions are used to specify when specific variants expressed using varia-tion points shall be active. The set of variavaria-tion points and the variability model are fixed for the set of rules and not changed by transformation steps.

Asubruleencapsulates a subset of actions on a substructure of a set of rules. If we want to identify substructures of the same rule, we talk about subruleembeddings. To identify common substructures of multi-ple rules, we talk aboutsubrule morphisms.

Definition 18(Subrule morphism). Given a pair of rulesr0 = (L0 ←−le0 I0 −→ri0 R0)andr1 = (L1 le1

←−I1 −→ri1 R1)(Def. 12) with injective mappings lei, rii fori ∈ {0,1}, asubrule morphism s : r0 → r1, s = (sL, sI, sR) consists of injective mappingssL : L0 → L1,sI : I0 → I1, andsR :R0 → R1s.t. in the diagram in Fig. 4.9(1)and(2)commute. In addition,

• the intersection ofsL(L0)andle1(I1)inL1is isomorphic toI0.

• the intersection ofsR(R0)andri1(I1)inR1is isomorphic toI0.

• L1−(sL(L0)−sL(le0(I0)))is a graph (Def. 1).

L0 I0 R0

L1 I1 R1

r0=

r1=

le0 ri0

le1 ri1

sL sI sR

s (1) (2)

Figure 4.9:A schematic depiction of subrule morphisms.

The conditions prefaced by “in addition“ ensure that a subrule per-forms the same actions on related elements as the original rule and that the larger pattern of the original rule does not prevent a subrule to be applied.

Definition 19(Subrule embedding). Subrule mappingsis called asubrule embeddingif all of its morphismssL,sI, andsRare inclusions. Given two subrule embeddingss:r0 →r1ands0:r00 →r01, we have thats⊆s0 if there are subrule embeddingst0 :r0 →r00 andt1:r1 →r01withs0◦t0 =t1◦s. In the example rule shown in Fig. 4.7, the rule comprising all nodes and edges with no visible presence condition, i.e., #47–53 and their interre-lating edges, is a subrule of the entire rule.

Definition 20(Language of variability expressions). Given a set of vari-ation points V, LV is the set of all propositional expressions over V, called language of variability expressions.

In the example,forallandquantifiedare variation points. The language of variability expressions includes the wordsforall∧quantified,¬forall, andtrue.

Definition 21(Variability model). Given a language of variability expres-sions LV, a variability model vm is an element of LV. A total function cfg : V → {true,false} is avariability configuration. A variability con-figuration cfg isvalidwrt. to a given variability modelvmiff ifvmevaluates to true when each variablevinvmis substituted by cfg(v).

In the example, theforallandquantifiedvariation points are orthogonal, hence, the variability model istrueand all four possible configurations are valid. IfRule C did not exist, forallandquantifiedmight be mutu-ally exclusive. The variability model would then beforallxorquantified, rendering the configuration{forall=true, quantified=true}invalid.

Definition 22(Variability condition). Given a language of variability ex-pressionsLV and a variability modelvm, avariability conditionis an ele-ment ofLV, i.e., a propositional expression overV. A variability configuration

4.4 Variability-Based Model Transformation 85

cfgsatisfiesa variability conditionvcifvcevaluates to true when each vari-ablevinvcis substituted by cfg(v). A variability condition isvalidif there is a valid variability configuration satisfying it. A variability conditionX is strongerthanY iffX =⇒ Y.

In the example,V ={forall,quantified}. Valid variability conditions in-cludetrue,¬quantified, andforall∧quantified;forall∧ ¬forallis not valid.

Definition 23(Variability-based (VB) rule). Given LV, a VB rule rˇ = (r, S, v, vc)consists of a ruler, a setSof subrule embeddings tor, a variability modelvand a functionvc:S∪ {r} → LV. Functionvcdefinesvariability conditionsfor subrules s.t. vc(r)istrue and∀s⊆ s0 :vc(s0) =⇒ vc(s).

Thebase ruleis determined by the intersection of all subrule embeddings.

For example, Fig. 4.7 shows a VB rule in a compact representation: El-ements instead of subrules are annotated. Ruler is the entire rule ig-noring annotations, the variability modelvmistrue. SetSand function vcare derived easily by creating a subrule sconj for each conjunction conj=V

i∈V li of literals overV, and settingvc(sconj) =conj. Each sub-rulesconjincludes the elements whose presence condition is implicated byconj. For instance, subrules¬quantified∧forallcomprises the elements an-notated with¬quantified,forall, andtrue, i.e., it is isomorphic toRule A in Fig. 4.4.

We may further include arbitrary subrules inS. Doing so will be useful to us; it allows us to improve the performance of the application of VB rules. In the example, we add one additional rule toS: The base rulestrue, comprising all elements annotatedtrue. We then haveS = {squantified∧forall, s¬quantified∧forall, squantified∧¬forall, s¬quantified∧¬forall, strue}.

Application of Variability-Based Rules

We now show how to apply variability-based rules: (1) either by flatten-ing them to a set of classic rules and matchflatten-ing and applyflatten-ing these rules in the classic way, or (2) directly, using a suitable variability configura-tion to identify a corresponding match. We then prove the equivalence of these two approaches.

Variability-based transformation through flattening

We begin by showing how a variability-based rule can beflattened, i.e., represented by a set of classic rules.

Definition 24 (Configuration-induced rule). Let a VB rule rˇ = (r, S, v, vc) over LV be given. For a valid variability configuration c, there

exists a unique set of subrule embeddingsSc ⊆ S s.t. ∀s ∈ S :s ∈ Sc iff csatisfies vc(s). Theconfiguration-induced rulerc (Fig. 4.10) comprises multi-pushoutsLc,Ic andRc over multi-pullbacksLt,ItandRtoverLi,Ii andRi of each ruleri inSc. The multi-pullback and -pushout constructions can be performed inGRAPHS. Prop. 4 and the co-completeness ofGRAPHST G0

ensure that these objects are also contained in GRAPHST G0. Morphisms let andritexist sinceLtandRtare limits,lecandricexist sinceIc is a colimit.

rccan be embedded torsinceLc,IcandRcare colimits.

Lt sLi

~~ !!

It sIi



let

oo rit //Rt

sRi

}} !!

L1

sLci

sLr1

Li

Ln

~~

sLr n

I1

sIci

sIr1

Ii

In



sIr n

R1

sRci

!!

sRr1

Ri

Rn

}}

sRr n

Lc sLr

Ic lerc

rr

rirc

,,

sIr

Rc sRr

Lr Irleroo

rir

//Rr

Figure 4.10: Construction of configuration-induced rulercfor configu-rationc,1≤i≤nwithn=|Sc|.

For example, for the rule in Fig. 4.7, configuration {forall=true, quan-tified=true} yields a configuration-induced rule being isomorphic to Rule Cin Fig. 4.4.

Definition 25(Flattening of a VB rule). The flattening ofrˇis the set of all configuration-induced rules over all valid configurations: Flat(ˇr) ={rc |c : V → {true,false} ∧ cis valid}.

In the example, flattening the rule in Fig. 4.7 yields a set containing four rules isomorphic shown to the ones in Fig. 4.4.

Definition 26(Application of a rule set). Given a rule setRand a graphG, the application of R to G is the set of rule applications: Trans(R, G) = {G⇒r,m H}withr∈ Rand a matchm:L→G(Def. 13).

For example, applying the flattening of the rule in Fig. 4.7 on the graph of formula φin Fig. 4.6 yields a set of rule applications containing ex-actly one element: The application of the rule isomorphic toRule A us-ing the matchmA.

Direct application of variability-based rules.

In the following, we consider the direct application of variability-based rules by finding a suitable variability-based match on-the-fly. The

cen-4.4 Variability-Based Model Transformation 87

tral task is to find variability configurations that induce a match for the left-hand side of one variant contained in the variability-based rule. If the resulting morphism of the left-hand side to graph Gsatisfies the gluing condition for the corresponding flat rule, the rule application can take place.

Definition 27(Variability-based match family). Given a variability-based ruleˇroverLV, a graphG, and a valid variability configuration c, yielding the set of subrule embeddingsSc ⊆ S s.t. ∀s ∈ S :s ∈ Sc iffcsatisfies vc(s). Avariability-based match familyis a family of matchesms∈Sc :Ls → G s.t. ∀mi, mj ∈ ms,1 ≤ i, j ≤ |Sc|the following holds: ∀x ∈ dom(mi)∩ dom(mj) :mi(x) =mj(x)(Fig. 4.11).

The condition ensures that matches within a family are compatible: An element contained in multiple subrules is always mapped to the same element in graphG.

L1

m1

Li mi

Ln mn

}}G

Figure 4.11:Variability-based match family,1≤i≤nwithn=|Sc|.

This definition entails that the identification of matches can terminate as soon as one of the subrules cannot be matched, enabling a perfor-mance benefit of VB rule application: We can match the base rulestrue first and only need to go on if this subrule can be matched.

To match the rule in Fig. 4.7 to the graph for formulaφin Fig. 4.6, we choose the variability configuration{quantified=false; forall=true}, which yields the subrule embeddings strue and s¬quantif ied∧f orall. The left-hand side of each of this subrule embeddings can be matched to G, yielding a variability-based match family.

Definition 28(Variability-based match). Given a variability-based match familyms∈Scfor a variability-based ruleˇr, a configuration c and a graphG, a variability-based matchmˇ is a pair(mc,c)wherem:Lc → Gis obtained by the colimit property ofLc(Fig. 4.12).

In the example, again considering the configuration {quantified=false;

forall=true}, a VB match is obtained from considering the VB match fam-ily described after Def. 27 and gluing their mappings together. This VB match has the same mappings asmA.

L1

m1

sc1

&&

Li mi

~~

sci

Ln mn

vv scnxx

G m Lc

oo c

Figure 4.12:Variability-based match,1≤i≤nwithn=|Sc|.

Definition 29 (Application of a variability-based rule). Given a match ˇ

m = (mc, c)for variability-based rulerˇand graphG, theapplication of ˇr atmˇ is the classic rule applicationG⇒rc,mc H of the configuration-induced rulerctomc. To obtain all applications ofr, we consider all variability-basedˇ matches: DirectTrans(rˇ, G) = {G ⇒rc,mˇ H | c is a valid configuration,

ˇ

m= (mc, c)is a variability-based match}.

For example, applying the rule in Fig. 4.7 to the graph of formula φ in Fig. 4.6 at the VB match with the same mappings asmA yields the graph structure of formulaφ0described at the end of Sec. 4.3.

Now, we show that the set of all applications of a variability-based rule ˇr to a graph Gis equal to the set of classic rule applications ob-tained from flatteningˇrand applying these rules toG.

Theorem 1 (Equivalence of rule applications). Given a variability-based rule rˇ and a graph G, the following holds: DirectTrans(ˇr, G) = Trans(Flat(ˇr), G).

Proof. SinceDirectTrans(p,ˇ G) andTrans(Flat(ˇr), G)are both constructed over all valid configurations, we can assume a particular valid config-urationc:V → {true,false}without loss of generality.

From Trans(F lat(ˇr), G), we consider the rule application G ⇒rc,m H of a configuration-induced rulerc ∈ F lat(ˇr)to a matchm : Lc → G.

The colimit property ofLcensures thatms∈Sc :Ls→Gis a variability-based match family. Thus, match m paired with configuration c is a variability-based matchm, being applied with ruleˇ rc.

FromDirectTrans(ˇr, G) , we consider rule applicationG ⇒rc,mˇ H of a configuration-induced rule rc to a variability-based matchm.ˇ rc is an element of F lat(ˇr). mˇ provides a match mc : Lc → G, being applied with rulerc.

4.4 Variability-Based Model Transformation 89