Pattern-based Model-to-Model Transformation: Long Version
We present a new, high-level approach for the specification of model-to-model transformations based on declarative patterns. These are (atomic or composite) constraints on triple graphs declaring the allowed or forbidden relationships between source …
Authors: Juan de Lara, Esther Guerra
P attern-based Mo del-to-Mo del T ransformation: Long V ersion Juan de Lara 1 and Esther Guerr a 2 ⋆⋆ 1 Universidad Aut´ onoma de Madrid (Sp a in), jdel ara@uam.es 2 Universidad Carlos II I de Madrid (Spain), eguer ra@inf.uc3m.es Abstract. W e present a new, high-level approac h for the sp ecificati on of mod el-t o -mo del transformations based on declarative patterns. These are (atomic or comp o site) constrai nts on triple graphs declaring t h e allo wed or forbidden relationships b etw een source and target mo d el s. In this wa y , a transformation is defined b y specifying a set of triple graph constraints that should b e satisfied b y the result of the t ra nsformation. The d es cription of the transformatio n is then compiled in to lo wer-lev el operational mec hanisms to p erform fo rward or backw ard transforma- tions, as w ell as to establish mapp i ngs b et ween t wo ex i stent mod e ls. In this pap er we study one of such mechanisms based on the generation of operational triple graph grammar rules. Moreo ver, w e exploit deduc- tion t echniques at the sp eci fication lev el to generate more specialized constrain ts (p re serving the sp ecificati on semantics) reflecting pattern d e - p endencies, from whic h add itional rules ca n b e derive d. This is an ext e nd ed version of th e pap er submitted to I C GT’08, with additional definitions and proofs. 1 In tro duction Mo del-Driv en Developmen t (MDD) [1] is a so f tw ar e engineering paradigm where mo dels are the core asset. They are used to sp e c if y , simulate, test, verify a nd generate co de for the application to b e built. Mo st of these activities include the sp ecification and ex ecution o f mo del transforma t io ns , some of them betw een different languages. The transfo r mation of a model co nf or man t to a meta- mo del int o another o n e conformant to a differe n t meta-mo del is called mo del-to-model (M2M) transforma t io n, and is the topic of this pap er. There are tw o main appro ac hes to M2M transformatio n: op er ational and de clar ative . The first o ne is based on rules or instructions tha t explicitly state how and when the elements o f the targ et model should b e cr eated starting from the elements of the source one . In declarative approaches, a de s cription of the mappings b et ween the so urce and tar get mo dels is provided. This descr ip tion states the rela t io n that should ho ld b et ween t wo mo dels rather than how to create and link their elemen ts. Declarative approaches are higher-level than op- erational ones since they form a compac t des c r iption of a set of (op erational) ⋆⋆ Extended v ersion of the pap er from the Pro c. of ICGT’0 8 (Leicester). rules. In addition, they are inheren tly bidirectional b ecause they do not s pecify any causa lit y . Thus, they bring together in a single s pecification fo r w ard (i.e. source-to - target) and backw ard (i.e. target-to- source) transfor m atio ns. The state-of-the-a rt o n declarative M2M transformatio n notations includes a handful o f langua ges (see Section 6). How ever, s o metimes they lack a formal foundation and analysis tec hniques able to prov e pro perties of the transforma- tion [2]. In other cases, spe c ifi ca t io ns are no t fully declarative and may r equire a control mechanism or defining a caus a lit y betw een existing elemen ts and those to b e created in a given relation [3,4], in tr oducing some degr ee of o perationality . The state-of-the-a rt o n declarative M2M transformatio n notations includes a handful o f langua ges (see Section 6). How ever, s o metimes they lack a formal foundation and analysis tec hniques able to prov e pro perties of the transforma- tion [2]. In other cases, spe c ifi ca t io ns are no t fully declarative and may r equire a control mechanism or defining a caus a lit y betw een existing elemen ts and those to b e created in a given relation [3,4], in tr oducing some degr ee of o perationality . In this pap er, w e prop ose a purely decla rativ e, formal approach to M2M transformatio n based on triple p atterns to express the r elations betw een source and target mo dels. These are similar to gr aph constraints [5] but for triple graphs, made of tw o gra phs related throug h an intermediate one. P atter ns can sp ecify po sitiv e (the re lation they declare m ust hold) o r negative informa t io n (the rela- tion must not hold) and can b e constra ined by p ositiv e and negative restrictions. This high-level sp ecification is compiled into low er- lev el mechanisms based on triple graph g rammar oper ational rules [4] to achiev e forward and backward transformatio ns, as well as to relate t wo existing models . The compila t io n is per formed in tw o steps. Fir s t , we employ deduction rules to deriv e additiona l patterns that reflect pa tt er n dep endencies and refine existing patterns with neg- ative restr ictions. Then, a rule for the chosen transfor mation direction is derived from each patter n. The adv antages of our tec hnique are the follo wing . First, it is purely declar- ative, based on patterns and constraints. This cont r a sts with other declarative approaches (such as T riple Graph Grammars (TGGs) [3,4,6]) where a causality has to b e given b et ween the existing elements a nd the o nes that ha ve to be created. As we c o nsider and exploit interactions betw een patterns, these dep en- dencies a re a ut o ma tically derived. Second, it has a formal fo unda t io n that allows the study o f the M2M sp ecification, in b oth declarative (i.e. patterns) a n d o pera- tional (i.e. derived rules) formats. Finally , w e ha ve devised deduction tec hniques, able to derive sema n tic informatio n from the very patterns. F or exa m ple, having a po s it ive pattern demanding a certain structure and a neg ativ e one forbidding its duplication allows g enerating t wo rules: o ne creating the structure if it is not present, a nd another o n e reusing it if it a lr eady exists. P ap er Organization . Section 2 introduces triple graphs a nd pa tter ns. Sectio n 3 presents the deduction rules. Section 4 shows how to derive o perational rules fr o m a patter n s pecification. Sectio n 5 propo ses some analy sis techniques for M2M sp ecifications. Sectio n 6 relates the most prominen t declar a tiv e a ppr oac hes to M2M transformation with o ur prop osal and Section 7 e n ds with the conclusions. 2 Sp ecifyi ng T ransformations: T riple P atterns This sec tio n in tro duces the differen t kinds of triple patterns, their sa t isfia bilit y and the c har acteristics o f the underlying op erational mechanisms. These con- cepts rely on the notion of triple graph, which w e introduce first. T r iple graphs are ma de of t wo graphs re la ted through an intermediate one. W e ca n use a n y gr aph mo del for thes e three graphs, from standard unattributed graphs ( V ; E ; s, t : E → V ) to mor e complex attributed graphs (e.g. E-g r aphs [5 ]) . Def. 1 (T riple Graph) A triple gr aph T rG = ( G s , G c , G t , cs : V G c → V G s , ct : V G c → V G t ) is made of two gr aphs G s and G t c al le d sour c e and t a r get, r elate d thr ough the no des of the c orr esp ondenc e gr aph G c . No d es in the co rrespondenc e graph G c hav e morphisms to no des of the source and target gra phs. If ∃ m ∈ V G c s.t. x cs ← − [ m ct 7− → y we write x r el y . Other kinds of mappings could b e used as well, for ex ample the simpler one in [3], where the corres p ondence functions ar e graph morphisms or the more complex one in [7] where the corresp ondence functions ca n r e la te edges or be undefined. W e use the no tation T rG | x (for x ∈ { s, t, c } ) to refer to the G x comp onen t of T rG , and write h G s , G t i for a triple graph w ith source and target graphs G s and G t , and h G s , ∅ , G t i for a triple graph with empt y c orrespo ndence. Next, w e define triple graph morphisms as a triple of graph mo r phisms that preserve the corresp ondence functions. Def. 2 (T riple Graph M orphism) A triple gr aph morphism f = ( f s , f c , f t ) : T rG 1 → T rG 2 is made of thr e e gr aph morphisms f x : T r G 1 | x → T rG 2 | x (with x = { s , c, t } ), wher e f s | V ◦ cs 1 = cs 2 ◦ f c | V and f t | V ◦ ct 1 = ct 2 ◦ f c | V . Source and target gra phs can b e t yp ed by a t yp e graph, or more in g eneral by a meta-mo del , which includes inheritance [8]. In the latter case, we use the term mo del instead of gra ph. Giv en meta-mo del M M , L ( M M ) refers to the set of all v alid mo dels confor m a nt to (t yp ed by) it. Similarly , w e use the notion o f meta-mo del tr iple [7] fo r the typing of triple gra phs . T r iple patterns a re similar to g raph constraints [5,9], but defined on triple graphs. W e use them to describ e the a llo wed and fo r bidden relationships b et ween source and target mo dels. W e consider b oth simple and compos it e patterns. Def. 3 (P attern) Given triple inje ctive morphism q : C → Q and sets N P re = { c i : Q → C i } i ∈ P re , N P ost = { c j : Q → C j } j ∈ P ost of ne gative pr e- and p ost- c onditions: – V i ∈ P re ← − N ( C i ) ⇒ P ( Q ) V j ∈ P ost − → N ( C j ) is a s imple p att e rn (S-Pattern). – V i ∈ P re ← − N ( C i ) ∧ ← − P ( C ) ⇒ P ( Q ) V j ∈ P ost − → N ( C j ) is a c omp osite p attern (C-Patt ern ). – − → N ( C j ) is a n e gative p attern (N-Pattern). Remark. The notatio n ← − P ( · ), ← − N ( · ) and − → N ( · ) is just sy ntactic sugar to indicate a po s it ive pre-condition, a negative pre-condition or a negativ e p ost-condition. Thu s, an S-Pattern is made o f a p ositiv e graph Q restr icted b y negative pre- and p ost-conditions ( P re a nd P ost sets). The in tuition is that Q sho uld be pres en t in triple graph T rG whenev er no negative pre-co n dition C i is found; and if Q is found, then no o ccurrence of the negative p ost-conditions should b e found. That is, while pre- conditions expres s r estrictions for the pattern Q to o ccur, post- conditions describe for bidden graphs. A C-Pattern is an S-Pattern with an additional po sitiv e pre-conditio n graph C . Thus a n S-Pattern is a C- Pattern with C and q empt y . Finally , an N-P attern is a C-Pattern where C and Q are empt y and ther e is o nly one nega tiv e pos t- c ondition, for bidd en to o ccur. A M2M spec ific a tion is a c o nj unction of simple a nd comp osite patterns. Def. 4 (M2M Sp ecification) A M2M sp e cific ation S = V i ∈ I P i is a c onjunc- tion o f p atterns, wher e e ach P i c an b e simple, c omp osite or ne gative. Remark. F or technical reasons, w e assume that initially in a specification only N-patterns ha ve neg ativ e p ost-conditions. This is not a restr ict io n , as a n y p ost- condition c a n b e express e d as a n N-pattern. In fa ct , a M2M sp ecification is usually made of just N- and S-patterns , from which w e auto m a tica lly derive C- patterns with p ositive pr e-conditions enco ding pa t tern dependencies, a nd tra n s- form N-patterns int o post-conditions for the other pa tter ns (see Section 3). Fig. 1. M2M Sp ecification. Example. Fig . 1 shows some patter ns in an ex- ample M2M sp ecification, inspire d b y the clas s to relational databa se transformation [2]. S-Pattern C-T states that a C no de (a class) that is not con- nected to another one (i.e. it do es no t have a par- ent ) should b e related to a T (ta ble). S-Pattern A-Co states that a C no de connected to an A (an attribute), should b e rela t ed to a T with a C o (col- umn). Differen tly from TGGs, w e don’t need to sp ecif y here a positive pre-condition stating that a relation betw een a C and a T should already exist. This dep endency is detected b y the deduc- tion rules we present in Sectio n 3. S-Pattern A-Co2 sp ecifies that in the cas e o f tw o C nodes connected through an R (a directed relation), the asso ciated T no de of the so urce C should hav e as foreign k ey ( F no de) an attribute o f the target class. Finally , N-Pattern notDupF forbids tw o F s betw een tw o T s. Next w e define the satisfaction of a pattern. As S- and N-Patterns are sp ecial cases of C-Patterns, it is enough to form ulate C-Pattern satisfaction. Def. 5 (P attern Satis faction) T riple gr aph T r G satisfies C P = [ V i ∈ P re ← − N ( C i ) ∧ ← − P ( C ) ⇒ P ( Q ) V j ∈ P ost − → N ( C j )] , written T rG | = C P , i ff: – C P i s forward satisfiable , T r G | = F C P : [ ∀ m s : P s → T rG s.t. ( ∀ i ∈ P re s.t. N s i ≇ P s , ∄ n s i : N s i → T r G with m s = n s i ◦ a s i ) , ∃ m : Q → T rG with m ◦ q s = m s , s.t. ∀ j ∈ P ost ∄ n j : C j → T rG wi th m = n j ◦ c j ] , – and C P is backw ards sa tis fia ble , T rG | = B C P : [ ∀ m t : P t → T r G s .t . ( ∀ i ∈ P re s.t. N t i ≇ P t , ∄ n t i : N t i → T r G with m t = n t i ◦ a t i ) , ∃ m : Q → T r G with m ◦ q t = m t , s.t. ∀ j ∈ P ost ∄ n j : C j → T rG wi th m = n j ◦ c j ] , with P x = C + C | x Q | x , N x i = C + C | x C i | x and N x i a x i ← − P x q x − → Q ( x ∈ { s, t } ) , se e the le ft of Fig. 2 3 . C i | s d i P .O . C | s n N } } { { { { q s " " F F F F b i s o o N s i / n s i 0 0 C = e s i o o c s ! ! C C C C C P .O . Q | s p s { { x x x x x P s = a s i [ [ m s q s / / Q = = c j / / m { { w w w w w C j / n j n n T rG Fig. 2. F o rward Satisfactio n of Pattern (left). F orward Satisfaction Exa mple (right). Remark . Morphisms q x : P x → Q ( x = { s, t } ) uniq ue ly exist due to the uni- versal pushout prop erty (as C | x ֒ → C q → Q = C | x q x → Q | x ֒ → Q ). F or the same reason, a x i : P x → N x i uniquely exist (as C | x ֒ → C e s i → N x i = C | x q x → Q | x c i | x → C i | x d i → N x i ). Moreov er , b i x = c i ◦ q x . C-Patterns have a univ ersa l quant ifica tio n, therefore we split them into tw o directed constraints. F or this purp ose w e demand that, in forw a rd satisfactio n, for each occur r ence of P s = Q | s + C | s C = h Q | s , C | c , C | t i satisfying the negativ e pre-conditions, an o ccurrence o f Q must be found satisfying the negative post- conditions, see the left of Fig. 2. A positive pattern graph Q is satisfied either bec ause no m s is found ( vacuous satisfaction ), beca use m s and some neg ative pre-conditions are found ( ne gative satisfaction ), or beca use m s and m are found and the negative pre- and p ost-co nditions are not fo und ( p ositive satisfaction ). Note that if the resulting directed ne g ative pre- condition N x i is isomor phic to P x , then it is not taken into account. This is needed as many pre-conditions express a restriction in either source or targ et but not on both. In addition to forward satisfaction, similar conditio ns a r e dema nded for the target gra ph (backwards satisfiability). A graph satisfies specification S if it satisfies all its patterns. Example. The r ight o f Fig. 2 shows the forward satisfaction o f S-Pattern C -T by a triple graph. T rG | = F C − T as there ar e t wo o ccur r ences of m s , the first o ne 3 A + B C is the p ushout ob ject of A a n d C through B . Similarly , A × B C is the pullback ob ject of A and C through C. is sho wn in the fig ure (up p er no de C in T r G ) and is positively satisfied, while the seco nd (low er C ) is negatively satisfied. W e also have T rG | = B C − T , as there is just one m t , p ositively satisfied. This is b ecause N t 1 ∼ = P t , as w e obtain a ba ckw ard negative pre-condition with one T , which is isomorphic to P t and th us the negativ e condition is not ev a luated. Th us, T rG | = C − T . Please note that the sp ecifica tion do e s no t explicitly state if a cla s s with a parent should b e co nnected with a table or no t. An a dditional pattern could de- scrib e such s ituation. The forward op erationa l mechanism, presented in Section 4 do es not add such table, a s it minimally enforces the sp ecifica tion. Starting from a specifica tion S , low er lev el op era tional mec hanisms ar e de- rived to perform forward ( − → S ) and backw ar d transformations ( ← − S ), as well as to relate tw o existing mo dels ( ← → S ). These mec hanisms ar e describ ed next. Def. 6 (Op erational Me chanisms) Sp e cific ation S has the fol lowing asso ci- ate d op er ational tr ansformations: – F orward: A function − → S : V S ( M M S ) → T r G with domain V S ( M M S ) = { M s ∈ L ( M M s ) |∃h M s , X i | = S } s.t. ∀ M s ∈ V S ( M M S ) [ − → S ( M s ) | = S ] ∧ [ − → S ( M s ) | s ∼ = M s ] . – Bac kwa rds: A function ← − S : V T ( M M T ) → T r G with domai n V T ( M M T ) = { M t ∈ L ( M M t ) |∃h X, M t i | = S } s.t. ∀ M t ∈ V T ( M M T ) [ ← − S ( M t ) | = S ] ∧ [ ← − S ( M t ) | t ∼ = M t ] . – Rel ating: A function ← → S : V S T ( M M s × M M t ) → T r G with domain V S T ( M M S × M M T ) = { ( M s , M t ) | M i ∈ L ( M M i ) ∧ ∃h M s , M t i | = S } s.t. ∀ ( M S , M T ) ∈ V S T ( M M S , M M T ) [ ← → S ( M S , M T ) | = S ] ∧ [ ← → S ( M S , M T ) | x ∼ = M x ] ( x = { s, t } ). The previous definit io ns are similar to the concept of c orr e ct tr ansformation given in [10], but in addition we forbid mo difying the source (r esp. tar get) mo del in forward (r esp. backw ards) transformatio ns . Next section presen ts some deduction rules , able to annotate patterns with depe ndencie s, and also genera te new ones. 3 Deduction and Annotation Mec hanisms for P att erns Next we pr esent the deductio n rules that we use to: (i) generate new patterns that take dependencies into acco unt, whic h guide the order o f pattern enfor cement by the opera tio nal mec ha nis m; (ii) enrich S- and C-Patterns with pre- and p ost- conditions derived from other patterns; and (iii) deduce p ositive informa tio n from N-Patterns. F or this pur po se, we use tw o main oper ations: de duction , whic h infers new patterns, and annotation , whic h mak es dep endencies among patterns explicit. F or example, from the sp ecificatio n in Fig. 1, the deduction r ules gener ate a new pattern to reflect the dependency b etw e en C-T a nd A-Co (to take into account whether a pair ( C, T ) is already r elated, b efo r e r elating a pair ( A, C o )). The deduction rules also add negative p o st-conditions derived from the n otDup F N-pattern to the rest o f patterns, and pr o duce new patterns that r euse part of notDup F s o that duplication of F ob jects is not po ssible. Most deduction rules are based on the maximal in tersection of t wo triple graphs, called maximal interse ction obje ct (MIO), which is defined next. Def. 7 (MIO) Given t riple gr aphs T r G 1 and T rG 2 , a maximal interse ction (MI) is given by a sp an of inje ctive morphisms ( T r G 1 m 1 ← − M m 2 − → T rG 2 ) , s.t. M ≇ ∅ ∧ ∄ M ′ ≇ M with ( T rG 1 m ′ 1 ← − M ′ m ′ 2 − → T rG 2 ) and m 12 : M → M ′ inje ctive s.t. t he diagr am to t he left of Fi g. 3 c ommutes. Obje ct M is c al le d MIO. MIOs are not unique, as the example to the right of Fig . 3 shows: M 1 and M 2 are b oth MIOs, but not M 3 as M 1 is bigg er. The set of all MIs (resp. MIOs) of T rG 1 and T rG 2 is denoted by M I ( T rG 1 , T rG 2 ) (resp. M I O ( T rG 1 , T rG 2 )). M ′ m ′ 1 u u u u u u u z z u u u u u u m ′ 2 I I I I I I I $ $ I I I I I I = = M / m 12 O O m 1 x x | | x x m 2 F F " " F F m ′ 1 ( M ′ ) = n ) ) m 1 ( M ) ? _ o o _ m 2 ( M ) / / _ m ′ 2 ( M ′ ) P p u u = T rG 1 T rG 2 Fig. 3. Conditions for MIO (left). Exa mple (right) . Patterns in a specificatio n ma y ha ve depe ndencie s that induce a certain or - der o f enforcement by the op era tio nal mech a nism. W e make such dependencie s explicit by annota ting patterns with additional gra phs, related to the p ositive graph Q . The dep endency graphs are calculated by the in terse c tio n of t wo pat- terns, and ca n b e interpreted as r estrictions that must not ho ld when the pattern is op eratio nally e nfo r ced. The notion of annotated pattern is defined next. Def. 8 (Annotated Pat tern) An annotate d p attern ( P, { n k : D k → Q } k ∈ K ) c ontains a p attern P and a set of dep endencies D k to P ’s p ositive gr aph Q . Before presenting the deduction rules, we define an op er ation called pr e- c ondition we akening (PW), which tests whether the pos itive gra ph of a C-Pattern is included in a nother one, and then adds the negative pre-conditions fr o m the former to the latter. Def. 9 (PW) Given V k ∈{ 1 , 2 } [ V i ∈ P r e k ← − N ( C k i ) ⇒ P ( Q k )] with Q 1 ֒ → Q 2 , P re 11 ⊆ P re 1 and function sub : P re 2 → P re 11 surje ct ive s.t. ∀ C 2 i ∈ P re 2 , ∃ sub ( C 2 i ) → C 2 i inje ctive; the PW op er ation r esults in [ V i ∈ P r e 1 ← − N ( C 1 i ) ⇒ P ( Q 1 )] ∧ [ V i ∈ P r e 2 ← − N ( C 2 i ) V i ∈ P r e 1 − P re 11 ← − N ( C 1 i + Q 1 Q 2 ) ⇒ P ( Q 2 )] , se e Fig. 4 C 1 i Q 1 c 1 i o o _ P.O . C 1 + Q 1 Q 2 Q 2 c 2 i o o Fig. 4. PW: T ransfer- ring the Negative Pre- Conditions. Remark. The specifica tion resulting from PW is not equiv alent to the original one. The seco nd pat- tern is added negative pre-conditions, so that it is satisfiable by mor e g raphs, namely by those in which ∃ n i : C 1 i + Q 1 Q 2 → T rG (injectiv e), as then Q 2 is not forced to o ccur . How ever, we use this op eration to make coheren t a specific a tion: a s a n o ccurrence of the second pattern implies an o c- currence of the firs t, b y adding the neg ative pre- conditions we ensure that a p os itive sa tisfaction of the second implies a pos itive satisfaction of the first. Example. As S-Pattern C- T is included in A-Co , PW adds the negative restric- tion ← − N ( noP arent ) fr o m the for mer to the latter. The resulting pattern is sho wn to the right of Fig . 5 (second row, to the le ft). Next, we show so me deduction rules that prese r ve the sp ecification semantics. W e first pres ent the deduction rule for tw o S-Patterns called S-De duction and its annota tion mechanism S A ( , ). S-Deduction creates a new pattern handling an intersection of tw o S-P a tter ns, while the annotation mechanism adds such int er sections dependencies to the t wo original patterns. Its cor r ectness pro of is shown in the appendix. Prop. 1 (S-Deduction) F r om V k ∈{ 1 , 2 } [ V i ∈ P r e k ← − N ( C k i ) ⇒ P ( Q k )] , we de duc e the new p attern s V M ∈ M I O ( Q 1 ,Q 2 ) [ V i ∈ P r e 1 ∪ P r e 2 ← − N ( C ′ i ) ∧ ← − P ( M ) ⇒ P ( Q 1 + M Q 2 )] , wher e the C ′ i ar e c alculate d as shown to t he left of Fig. 5. M m 1 v v v { { v v m 2 H H H # # H H P .O . Q 1 c 1 i # # F F F F F F Q 2 c 2 j { { x x x x x x Q 1 + M Q 2 P .O . P .O . C 1 i / / C ′ i C ′ j C 2 j o o Fig. 5. Nega tive Pre- Conditions in S-Deduction (left) . S-Annotation E x ample (right). Def. 10 (S-Annotation) Given two annotate d S-Patterns ( P i , D i ) with p osi- tive gr aphs Q i : S A (( P 1 , D 1 ) , ( P 2 , D 2 )) = { ( P i , D i S M ∈ M I O ( Q 1 ,Q 2 ) { M → Q i } ) } i =1 , 2 S M ∈ M I O ( Q 1 ,Q 2 ) { ( S D ( P 1 , P 2 , M ) , ∅ ) } , with S D ( P 1 , P 2 , M ) the r esulting p attern fr om applyi ng S -De duction us ing M . Example. The right o f Fig. 5 shows an exa mple of S- Annotation, where the newly g e nerated pattern (b ottom right) considers the fact that the relation de- manded by pa ttern C-T may a lready exist. The pro cedur e generates t wo ismor- phic negativ e pre-conditions, s o that one can b e eliminated. The added depe n- dencies ( D 1 ) ensure that the fir st and s econd pa tterns will only b e enfor ced by the operatio na l mec hanis ms when no occurr ence of D 1 is found. As we will s ee later, this makes the TGG o pe r ational rules gener ated for the first tw o patter ns m utually exclusive with the one of the third, as w ell as confluen t. Moreov er , the rule for the third pattern will be a ble to reuse the structure created b y the rule of the first. C-Deduction and its annotation mech a nism C A ( , ) are generaliza tions of the S- ca s e, with the difference that the new patter n integrates in its pre-condition the gluing of the orig inal patterns pre-conditions. Prop. 2 (C-Deduction) F r om V k ∈{ 1 , 2 } [ V i ∈ P r e k ← − N ( C k i ) ∧ ← − P ( C k ) ⇒ P ( Q k )] , we de duc e the new p attern V M ∈ M I O ( Q 1 ,Q 2 ) [ V i ∈ P r e 1 ∪ P r e 2 ← − N ( C ′ i ) ∧ ← − P ( P c ) ⇒ P ( Q 1 + M Q 2 )] , wher e t he C ′ i ar e c alculate d as shown to the left of Fig. 5, and P c is c alculate d as shown in Fig. 6. In t his diagr am, M c is the sub gr aph of M s.t. ( C 1 mc 1 ← − M c mc 2 − → C 2 ) ∈ M I ( C 1 , C 2 ) , squar es pc k ◦ m c k = pm k ◦ ( M c ֒ → M ) ar e P.O. and morphisms pq k : P k → Q k uniquely exist du e to the P.O. universal pr op erty. F or the same r e ason P c → Q 1 + M Q 2 uniquely exists. M c _ mc 1 } } mc 2 ! ! C 1 c 1 / / pc 1 A A A A A A Q 1 ( ( M P .O . m 1 o o m 2 / / pm 1 t t t t z z t t t t pm 2 J J J J $ $ J J J J Q 2 v v C 2 c 2 o o pc 2 } } } ~ ~ } } } P 1 pq 1 O O p 1 J J J J % % J J J J P 2 pq 2 O O p 2 t t t t y y t t t t P c Q 1 + M Q 2 Fig. 6. C-Deduction. Pr o of. In app endix. The annotation proce dure for C-Deduction is analo gous to the one for S- Deduction. Next deduction rule is used to take in to consideratio n the interaction o f N- patterns, w hich expre s s unconditional neg ative constraints, with other patterns. Prop. 3 (N-Deduction) [ V i ∈ P r e ← − N ( C i ) ⇒ P ( Q ) V j ∈ P ost − → N ( C j )] ∧ [ − → N ( C N )] is e quivalent to [ V i ∈ P r e ← − N ( C i ) ⇒ P ( Q ) V j ∈ P ost − → N ( C j ) V C r ∈ RS − → N ( C r )] with R S = { r n : Q → C r } C r ∈ P O ( M I ( Q,C N )) and P O ( M I ( Q, C N )) is the set of pushout ob- je cts of al l sp ans in M I ( Q, C N ) . Pr o of(Sketch). W e hav e related C N in all po ssible (maximal) w ays with Q , whic h is given by the pushout of each span in M I ( Q, C N ). T his is similar to the pro - cedure to conv ert a graph constraint into a post-co ndition [5,9]. Remark. Removing − → N ( C N ) do es not y ie ld an equiv alent sp e cification, as e.g. a g raph with no o ccurrence of Q is allowed to hav e an o ccurr ence of C N . Note how ever that we will delete N-Patterns when g enerating the TGG op erationa l rules, as these by c onstruction cannot genera te an y forbidden pattern. Fig. 7. N-Deduction Example. Example. Fig. 7 s hows how N-Pattern not DupF induces a negative constra int on S-Pattern A-Co 2 , resulting in the S-Pattern to its right. There are t wo isomor phic MIOs (both made of t wo T s a nd one F ) re sulting in tw o isomorphic neg ative constraints, s o that o ne is eliminated. The following deductio n rule detects N-Patterns that forbid a repetition of structures and gener ates a po sitive pattern that r euses suc h structure. First, w e define the completion of a triple gr aph M wit h resp ect to a graph T such that M ֒ → T . The completion adds to M | t all elements that ar e related to elemen ts of M | s and b elong to T − M , and similar for source elements. In addition, completion includes all unrelated elements of T . Def. 11 (Comple tion) C ( M , T ) = G iff G is the s m al lest gr aph s.t. M ֒ → G ֒ → T ∧ ( ∀ n ∈ V G | s , ∄ m ∈ V T | t − V G | t s.t. n r el m ) ∧ ( ∀ x ∈ V G | t , ∄ y ∈ V T | s − V G | s s.t. y rel x ) ∧ ( ∄ z ∈ ( V T | s ∪ V T | t ) − ( V G | s ∪ V G | t ) s .t. z is un r elate d ) . G also c ontains al l e dges of T with s our c e and t ar get in no des of G . Fig. 8. Example of Completion. Example. Fig. 8 s hows a n example of c ompletion, where gra ph M is completed with resp ect to g raph T , yielding gra ph C(M, T) . Note that M ֒ → C ( M , T ) ֒ → T . Prop. 4 (NP-Deduction) [ V i ∈ P r e ← − N ( C i ) ⇒ P ( Q )] ∧ [ − → N ( S )] , with S the pushout of two isomorphic gr aphs S 1 ∼ = S 2 and S 1 ∈ M I O ( Q, S ) , is e quivalent to [ V i ∈ P r e ← − N ( C i ) ⇒ P ( Q )] ∧ [ − → N ( S )] ∧ [ V i ∈ P r e ← − N ( C i ) ∧ ← − P ( C ( S 1 , Q )) ⇒ P ( Q )] . Pr o of. C ( S 1 , Q ) ֒ → Q , th us [ ← − P ( C ( S 1 , Q )) ⇒ P ( Q )] is subsumed b y P ( Q ). The NP-Deduction rule has an asso cia ted annotation rule N P ( , ), which adds a dep endency to the S- Pattern equal to the p o s itive pre-condition of the newly genera ted pattern. Def. 12 (NP-Annotation) N P (( V i ∈ P r e ← − N ( C i ) ⇒ P ( Q ) , D ) , ( − → N ( S ) , D ′ )) = { ( V i ∈ P r e ← − N ( C i ) ⇒ P ( Q ) , D ∪{ C ( S 1 , Q ) } ) , ( − → N ( S ) , D ′ ) , ( V i ∈ P r e ← − N ( C i ) ∧ ← − P ( C ( S 1 , Q )) ⇒ P ( Q ) , ∅ ) } , with S the P.O. of two isomorphic gr aphs S 1 ∼ = S 2 and S 1 ∈ M I O ( S, Q ) . Example. Fig. 9 shows the deriv ation of C-Pattern A -Co2. notDu pF fr om A-Co2 and no tDupF . The la tter is made of the pushout of t wo isomorphic g raphs made of t wo T s and one F , whic h belo ngs to MIO(A- Co2, NotDupF) . The completion of one of the isomorphic graphs with respec t to A- Co2 is the pre- condition graph ← − P () of A-C o2.no tDupF . The newly generated pattern reuses tw o T s and one F so that the rule to be generated from it will not produce the situation forbidden by notDu pF . The annotation pro cedure a dds a dep endency to A-Co2 so that the generated rule will b e mutually exclusiv e with the one for the deduced pattern. NP-Deduction has a genera lization, called CNP-Deduction which handles the case of a C-Pattern and a n N-Pattern. The main differe nc e with NP-Deduction is that the pre- c o ndition of the genera ted pattern has to glue the p o sitive pre- condition of the C-Pattern through the MIO (as in C-Deduction). Fig. 9. NP-Deduction a nd Annotation Example. Prop. 5 (CNP-Deduction) [ V i ∈ P r e ← − N ( C i ) ∧ ← − P ( C ) ⇒ P ( Q )] ∧ [ − → N ( S )] , with S the pushout of t wo isomorphic gr aphs S 1 ∼ = S 2 and S 1 ∈ M I O ( Q, S ) is e quivalent to [ V i ∈ P r e ← − N ( C i ) ∧ ← − P ( C ) ⇒ P ( Q )] ∧ [ − → N ( S )] ∧ [ V i ∈ P r e ← − N ( C i ) ∧ ← − P ( P s ) ⇒ P ( Q )] , wher e P s is c alculate d as shown in Fig. 10, with cp ◦ c = sp ◦ b a P.O. squar e. Pr o of. In app endix. S 12 } } | | | | | | | $ $ I I I I I I I I I P .O . P s $ $ H H H H H H H H H H S 2 B B B B B B B B S 1 z z u u u u u u u u u u # # G G G G G G G G G _ Q C q o o cp o o S C ( S 1 , Q ) / / Q C ( S 1 , Q ) ? O O sp R R B 1 b o o c O O P .B. Fig. 10. CNP-Deduction. 4 Generating the Op erational Rules This section details the generation of o p erational TGG rules from a M2 M spec- ification. Note that compilation int o other formalisms is p o ssible, e.g. to a con- straint satisfac tio n problem in the style of [1 1]. W e first introduce the structure of a non-deleting TGG rule. Def. 13 (Non-Dele ting Op er. TGG Rule) A TGG ru le r = ( L l → R, p re = { n i : L → N i L } i ∈ I , post = { n j : R → N j R } j ∈ J ) is mad e of an inje ctive morphism l of t riple gr aphs, and set s pre and p ost of ne gative pr e- and p ost-c onditions. Although negative p ost-co nditions can b e translated into nega tive pr e-conditions using the proce dur e in [5 ,9], we use a set for them for simplicity of pres e ntation. Next we sho w how to generate a TGG rule given an annota ted C-Pattern. The main idea is to use P s = C + C | s Q | s = h Q | s , C | c , C | t i as the LHS (for the forward rule) and Q as the RHS. The negative pre- and p ost- c o nditions of the C-Pattern are used as nega tive pre - and p ost-conditio ns of the rule. Note the similarities with the satisfiability of patterns (Def. 5 and Fig. 2 ). The rule’s RHS is used a s a negativ e pre-condition so that satisfiability is enforced only once. Finally , dependencies are c o nv erted in to nega tive pre-co nditions. Def. 14 (Deriv ed TGG Rule) Given annotate d p attern T = ( V i ∈ P r e ← − N ( C i ) ∧ ← − P ( C ) ⇒ P ( Q ) V j ∈ P ost − → N ( C j ) , D = { n k : D k → Q } k ∈ K ) , the fol lowing TGG op- er ational rules ar e de rive d: – F orward. − → r T : ( L = h Q | s , C | c , C | t i ( id,q c ,q t ) − → R = Q, pr e = { n : L → R } ∪ { a s i : L → N s i | L ≇ N s i } i ∈ P r e ∪ { s k : L → S k } k ∈ K , post = { n j : R → C j } j ∈ P ost ) . – Bac kwa rds. ← − r T : ( L = h C | s , C | c , Q | t i ( q | s ,q | c ,id ) − → R = Q, pr e = { n : L → R } ∪ { a t i : L → N t i | L ≇ N t i } i ∈ P r e ∪ { s k : L → S k } k ∈ K , post = { n j : R → C j } j ∈ P ost ) . wher e N x i ∼ = C i | x + C | x C , and a x i : L → N x i is uniquely determine d (se e Fig. 2, wher e P x = L ). S k is t he left-extension of D k , se e lef t of Fig. 11, wher e n k ◦ b k = r ◦ l k and d k ◦ b k = s k ◦ l k ar e pul lb ack and pusho ut squar es r esp e ctively. B k b k / / l k P .B. D k n k d k L s k - - r / / R = Q P .O . S k Fig. 11. Left Extensio n of D k → Q (left). Generated F orward Rule A-Co (rig ht). Example. The rig ht o f Fig. 11 shows the generated for ward rule from the an- notated pattern A -Co sho wn in Fig . 5. Note ho w the NA C S 1 forbids applying the r ule if the node C has an asso ciated T . In this case, the rule gene r ated from the derived pattern C-T .A-Co in Fig. 5 w ould b e applicable (see r ule C-T. A-Co in Fig. 12). Before ge ne r ating the rules we use the deduction and annotatio n mechanisms on the initial M2M pattern specification in order to transform N-patterns in to negative post-conditions of the other patterns , generate patterns that take into consideratio n the satisfaction of o ther patterns, and iden tify dep endencies b e- t ween patterns. As stated b efor e, w e assume that the initial sp ecifica tion doe s not include patterns with bo th a p ositive graph and a negative post-condition (as the latter can b e expres sed with N-P atterns ). Def. 15 (Generation of Op erational TGG Rules ) Given sp e cific ation S : 1. Use PW (D ef. 9) on al l p ossible p atterns. 2. Use C- or S-Annotation (Def. 10) fo r e ach p air of C- or S-Patterns . Do not derive a p attern if it alr e ady exists. 3. Use NP-Annotation (Def. 12) on al l p ossible p att erns (initial and derive d). 4. Use N-De duction ( Pr op. 3) on al l p ossible p att erns and eliminate N-Patterns. 5. T ake e ach derive d p attern, and add to it al l dep endencies of the p atterns it was derive d fr om. Do not add such d ep endencies if they ar e include d in the p ositive pr e-c ondition of t he derive d p attern, as the p attern would b e c ome useless. 6. Gener ate an op era tional TGG rule for e ach c ausal p attern (Def. 13). Fig. 12. Some of the Generated F o rward Operatio na l Rules. Example. Fig. 12 shows some of the gener ated forward rules. Rule C-T is gen- erated from pattern C-T . NAC1 results fro m a pre-c o ndition, while NAC2 is equal to the RHS. Rule A -Co results fro m pattern A- Co . NA C3 comes from the PW ope ration with pa tter n C-T , NAC2 is eq ual to RHS, and NAC1 is derived from a dep endency when making S-Deduction with C-T . Rule C-T.A- Co is gen- erated from a pattern der ived from C-T and A- Co throug h S-Deduction. Its first NA C co mes from a dependency induced by their source patterns. Finally , rule A-Co.n otDup F results from NP-Deduction (see Fig. 9), where NAC1 a nd NAC2 come fr om pr e-conditions o f the patterns from which it is derived, and NA C3 comes from a dependency . These t wo last rules hav e some additional NACs (not shown), stemming from N-Deduction with pattern notDup F . The pro cedure gen- erates a total of 10 rules, shown in Fig s. 13, 14 and 15. Fig. 13. Some of the Generated F o rward Operatio na l Rules. Fig. 14. Some of the Generated F o rward Operatio na l Rules. Fig. 15. Some of the Generated F o rward Operatio na l Rules. 4.1 Correctness of the Op erational Mec hanisms Now w e show the cor r ectness of the gener a ted rules, fo cuss ing on for ward rules as a similar reaso ning holds for the bac kwards case. The generated rules: (i) m ust pr o duce mo dels satisfying the sp ecification, (ii) must be confluent, (iii) m ust terminate, and (iv) m ust transform each sour c e mo del for which ther e is a correct target mo del. (i) follows from the constr uction of the TGG rules. Their L HS is h Q | s , C | c , C | t i = C + C | s Q | s = P s , whic h is the b ase graph from which forw ar d satisfaction is chec ked (see Fig. 2). As R = Q , morphism m : Q → T r G exists after the a p- plication of the rule. The r ule negative pre- and pos t-conditions are derived from the negative pre- and post-co nditions of the pattern. Thus, the rule ca n be applied iff the ba se morphism m s exists and the negativ e pre- and post- conditions of the pattern are satisfied. The additional NAC ∼ = R makes the rule enfor ce the pattern once. As initially all f o rbidden g r aphs ar e expresse d as N-Patterns, and we hav e p erformed N-Deduction, no rule can pro duce a forbidden result. Since we star t with an empty target gra ph, backwards satisfaction is also obtained. Finally , the r ule has additional NA Cs derived from dependencie s , how ever these just allow the ex e cution of exactly one of the rules enforcing a given pattern so that they are confluen t (see (ii)). (ii) follows b eca use S- and C-annotation add dependencies (whic h ar e trans- formed into NA Cs) to the initial pa tterns, and these a r e appropria tely prop- agated to their derived pa tter ns in step 5 of the rule generation proces s. Fig. 1 6 sho ws tha t a rule L 1 → R 1 and a deriv ed one through S-Deduction L 3 → R 3 are m utually exclusive. S 1 is the resulting NA C genera ted from the depe ndency of the first rule. In a situation where L 1 and L 3 are applicable, by the pusho ut univ ersa l proper ty , there is a matc h of the NA C S 1 . Th us, the first rule is not applicable. M | s } } z z z z z # # G G G G G P .O . M w w o o o o o o o o o o ' ' O O O O O O O O O O P .O . B 1 / / P .O . M " " E E E E E ~ ~ } } } } } R 3 | s { { w w w w w L 1 / / , , R 1 ' ' P P P P P P P P P ) ) R 2 w w o o o o o o o o o L 1 / / 0 0 S 1 0 0 L 3 / / R 3 R 1 + M R 2 = R 3 T rG T rG Fig. 16. Mutu a l Exclusio n of L 1 → R 1 and L 3 → R 3 (left). Applying first a nd third rule (right). Note how ever that initially we may have patterns included in others: [ P ( Q 1 )] ∧ [ P ( Q 2 )] with Q 1 ֒ → Q 2 . In this cas e, S-Deduction genera tes [ P ( Q 1 )] ∧ [ P ( Q 2 )] ∧ [ P ( Q 1 ) ⇒ P ( Q 1 + Q 1 Q 2 )] (assuming just one MIO), from which we genera te three rules. There is a c o nflict betw een the first t wo rules (i.e. a cr itical pa ir). Ho wev er in a situation where both the first and the second are applicable (e.g. if we hav e Q 2 | s ֒ → T rG ), applying the first and the third is equiv alent to applying the second. The right of Fig . 16 shows tha t the existence of R 1 → T rG and R 3 → T rG implies the existence of R 2 → T rG . Besides, we ca nnot apply the first and the second, b ecause of the generated NA Cs: the s econd rule is added R 1 as NA C (as Q 1 = R 1 ֒ → Q 2 = R 2 ). Example. Cons ider the rules for the pa tterns C-T and A-Co and their derived pattern ( C-T.A- Co see Fig. 12). Assume a situation where bo th C-T and A-Co are applicable. If C -T is applied first, then A-C o is disabled, but C-T.A- Co can b e a pplied. If A -Co is applied first, then no other rule is a pplica ble. How ever, in b oth ca ses w e reach the same result. (iii) follows fro m the fact tha t (a) ea ch rule has its RHS as a NAC, therefor e it can o nly be applied once for each initial matc h in the source mo del; and (b) a forward r ule only changes the ta rget mo del. (iv) ca nnot be a chieved for arbitra ry M2M s p e c ifications. W e r estrict to what we call In je ctive Positive Sp e cific ations , whic h co ntain enough p ositive patterns to pro duce the op er ational TGG r ule s . Next definition in tro duces the for ward case (FIP), the backw ar ds o ne is s imilar. Def. 16 (FIP Sp ec.) Sp e cific ation S = V i =1 ..n T i is FIP, iff ∀ M s ∈ L ( M M s ) s.t. ∃ T rG = h M s , X i | = S, ∃ k i ∈ N , ∃ P i s ← S ij uv → P j s with P m s = C m + C m | s Q m | s , u = { 1 ..k i } , v = { 1 ..k j } and S ij uv ≇ P i s if i = j , s.t. G is the c olimit of the diagr am to the left of Fig. 17 (with al l arr ows inje ctive) with G ֒ → T r G and G | t ∼ = T rG | t . Fig. 17. Condition for FIP (left ). Non-FIP Sp ecifica tion (center). In v a lid Graph (right). Remark. The definition considers k i o ccurrences of each pattern T i . Two o ccur - rences of patterns T i and T j can overlap, and this is mo delled by S ij uv . W e forbid P i be the o verlap of tw o o ccurrences of the same pattern Q i , as the op erationa l mechanism minimally enfor c es eac h pattern (i.e. rules hav e a NA C equal to the RHS). W e ha ve made a simplification in the diagram, but each o cc ur rence of T i should satisfy its negative pre- and post-conditions . Fig. 18. FIP Sp ecification. Example. Consider the sp ecification in the cen- ter of Fig. 17, and as sume we do not perfor m an y deduction. There is a v alid triple gra ph T rG with t wo As in its source, but the rules g enerated with- out deduction cannot cr eate such graph, a s they would pro duce t wo B s . The NP-Deduction rule can turn some no n- FIP spec ifica tions int o FIP . This is beca use it cr e- ates a new pattern that r e us es an alr eady cre- ated structure (in the target graph). The right of Fig. 1 7 s hows that if NP-Deduction is not applied, we ca nnot handle a graph with t wo As . Fig. 1 8 shows that after applying NP-Deduction, the re- sulting patter n can ha ndle such graph as it reuses a B and is applied twice. It is up to f uture work to determine further deduction rules to cov er additional non FIP-sp ecificatio ns . 5 Analysis of the T ransformation Specification This se c tio n gives an ov erv iew of so me of the prop erties that can be analys ed from a patter n- based specification S . W e distinguish three lev els: pattern, s p ec - ifications and op erational mechanisms. P attern Analysis . W e ca n analyse single patterns or pairs, for example: – P attern Conflict (PC). Tw o patterns are in conflict if they express con- tradictory constr aints. This is fo r example the case of spe c ification [ P ( Q P )] ∧ [ − → N ( Q N )] with Q N ֒ → Q P . In this ca se the gener ated TGG op era tional rule can nev er be applied. Th us, an initial gra ph of the form T r G ∼ = Q P | s do es not hav e a v alid targ et model, a nd cannot be tra nsformed accor ding to − → S . – T autolog y (T). A pattern is a tautology if it is alwa ys satisfiable. This is the ca se of patterns w ith the fo r ms: (i) [ ← − N ( Q ) ⇒ P ( Q )], a s it is a lwa ys either v a cuously or negatively satisfied, and (ii) [ ← − P ( Q ) ⇒ P ( Q )] as it is alwa ys either v acuously or p os itively sa tisfied. – Contra dictory (C). A pattern is cont ra dictory if it ca n nev er b e positively satisfied. This is the case o f a pattern with the form [ P ( Q ) ∧ − → N ( Q )], which can only b e v a cuously satisfied. Sp ecification Analysis . These define proper ties of the sp ecification a s a whole: – Language Co vering (LC). A pattern sp ecifica tion is s ource cov ering iff U P ∈ S + ty pe ( P | src ) is surjective, wher e S + is the set of p os itive patterns of S . This means, that we have patterns that handle eac h construct of the source language. A similar notion can b e defined for the targe t language. – F ul l F orw ard, Bac kw ards or Re lating (FF, FB, FR). A specifica tion S is FF (resp. FB) iff | Dom ( − → S ) | = | L ( M M s ) | (r esp. | D om ( ← − S ) | = | L ( M M t ) | ). A sp ecificatio n is FR iff it is FF and FB. If a spe c ification is not FF, it means that is not defined for all v alid mo dels o f the source langua ge. Obviously , if a specification is no t source LC it is neither FF nor FR (the con verse in not necessarily true). Similarly a sp ecifica tion that is not target LC is not FB nor FR. A pattern conflict makes the s pe cification not to b e FF or FB. – Contra dictio n(C). A sp ecification S is a con tradictio n if the empty gr aph is the only gra ph a ble to satisfy it (i.e. no gr aph p os itively sa tisfies S ). This is the case of a sp ecifica tion which is source LC with a ll patterns contradictory . – F orward, Bac kwards or Relating Univ alued (FU, BU, RU) . S is FU iff ∀ M s ∈ D om ( − → S ) , |{ M T |h M s , M t i | = S } | = 1. Note that all sp ecifications with our technique are FU, BU and R U. Op erational Me c hanisms. It is als o poss ible to study pro p erties of the gen- erated TGG rules, for example: – Hipp o cratic T ransformation (HP). (taken from [1 0]) If ∀ M s ∈ L ( M M s ) , M t ∈ L ( M M t ) s.t. h M s , M t i | = S = ⇒ [ − → S ( h M s , M t i ) | t ∼ = M t ∧ ← − S ( h M s , M t i ) | s ∼ = M s ]. This proper ty states that if a triple graph satisfies a specifica tion, the application of ← − S or − → S will not modify the triple graph. The tr ansformatio ns we gener ate are HP , as our rules minimally enforce each pa ttern (they hav e NA Cs eq ual to RHS). A formal pro of is left for future work. 6 Related W ork Some decla rative approaches to M2M tra nsformation use a textual s yntax, e.g. PMT [12] or T efk at [13]. These tw o particular nota tions are uni-dire c tional, whereas w e generate fo rward a nd bac kward transformations. Among the visual declar ative approaches, a prominent example is the stan- dard language QVT-r elational [2], which also has a textual syntax. The relations may include when and wher e clauses that identify pre- and p ost-conditions and can refer to other relations . F rom this sp ecifica tion, executable QVT-core is gen- erated that per forms for ward/backw ard transformations g iven a sour ce/targ et mo del. This appr oach is s imilar to ours , but we c ompile our patterns to TGG rules, allowing the analys is o f the gener ated transformation [5]. B esides, we can make analys is a t a higher-level a s our pa tterns have a formal founda tion. More- ov er, w e automatically detect pattern dep endencies and p erform pattern infer- ence. In the QVT-r e lations languag e , de p endencie s mu st b e made explicit in the when and wher e clauses, and ther e is no equiv alent to our N-Patterns. An attempt to formalize QVT-core is found in [14]. In [15], tr ansformatio ns are express e d throug h decla rative relations made of po sitive pa tterns, heavily relying o n OCL constra int s, but no op erationa l mechanism is given to e nfo r ce s uch relations. In BOTL [16], the mapping rules use a UML-ba sed notation that allows reaso ning ab out applicabilit y or meta- mo del conformance. W e can reason b o th at the sp ecifica tion and oper ational levels. TGGs [4] formalize the synchronized evolution of tw o graphs through declar- ative rules. F rom this specificatio n, lo w-level ope rational TGG rules ar e derived to p erform forward a nd bac kwards tra ns formations, as well as to rela te tw o exist- ing g raphs. W e also g enerate these op erationa l rules from our patterns. How ever, whereas in declarative TGG rules dep endencies must be made explicit (i.e. we m ust say which elements should exist and whic h ones a re created), in our pat- terns this infor mation is derived. F or instance, in TGGs, a rule like pattern C-T.A- Co has to b e s p e c ified, it is not enough to give C-T and A-Co . Although inspir ed b y TGGs, our patterns are a different appr oach to M2M transformatio n: pa tter ns sp ecify rela tio ns, not rules. Simila r to gr aph c o nstraints [9,17], a M2 M sp ecification by patterns describ es a la nguage of v alid triple g raphs. Moreov er , TGGs have some limitations . First, they do not a llow sp ecifying negative information, nor deriving p ositive infor mation from nega tive one (like NP-Deduction). In [6], the lack of negation is alleviated b y assigning execution priorities to rules. Howev er, this is insufficient to simulate gener al application conditions, it has an op era tional nature, and implies k nowing the rule genera- tion mechanism and execution eng ine. Second, a control mechanism is needed to guide the execution of the op era tional rules, suc h as priorities [6] o r their cou- pling to e diting rules [3]. One can see TGGs a s a subse t of our approach, where a TGG r ule is a pattern of the form ← − P ( L ) ⇒ P ( R ) without neg ative conditions or deduction techniques. In [18], a n algor ithm is g iven for the deriv atio n o f declarative TGGs from example pairs of mo dels. Interestingly , the user do es not have to sp ecify the corres p o ndence no des in thes e pa irs. The employed techniques r esemble o ur use of MIOs, ho wev er, our patterns a re r icher, as w e allow nega tive pr e- and po st-conditions, and we ha ve dev elop ed a theoretical framework whic h includes further deriv ation techniques (e.g . NP-Deduction). With r esp ect to graphical pa tterns, in the r ecent w o r k in [17], a logic o f constraints and so me deductio n techniques were prop osed. How ever, their ba- sic constraints are ex istentially satisfied, while ours are univ ers al. Moreov er, w e provide deduction tec hniques sp ecially tailo red for M2M spe c ifications and tr iple patterns. In [19] w e presen ted a simpler notion of patter n and use d it to ex tend normal rules to synchronous TGGs. W e applied it to the sync hro nization of the concrete and abstract syn tax of visual models. The patterns were restricted to work with p ositive information, and the executio n of the deriv ed r ule s w as asso- ciated to editing r ules (like traditional TGGs). Her e w e present a new co ncept of pattern, which allows expressing negative conditions, introduce deductio n rules and pre sent a new alg orithm for TGG rule deriv ation that is s uita ble for M2M transformatio n and do es not need a normal rule to start with. 7 Conclusions and F ut ure W ork In this pap er we ha ve present ed a new formal approach to declarative M2 M transformatio n. Relations b etw e en source a nd ta rget models ar e expr essed as different kinds of patterns, fr om which op erationa l TGG rules ar e derived im- plement ing f o rward/backw ards transforma tions a nd taking into acco unt pattern int er actions. This is done by deduction mechanisms that detect in terdep enden- cies a nd pro duce new patterns tha t reuse structures created b y other patterns. This is one of the s trengths of the pres e nt work: pattern dep endencies a r e au- tomatically calculated and not explicitly given by the desig ner such as with QVT and TGGs. W e ha ve identified analysis prop erties, b oth at the sp ecificatio n (e.g. languag e covering, pattern conflicts) and op era tional lev els (e.g. hipp o cra tic transformatio ns [10]). Although we gener ate op e rational TGG r ules from a pattern sp ecification, other targ et formalisms could b e used as well (e.g. OCL, Alloy). In fact, o ne of our next goals is expressing a specifica tion in terms o f a constraint satisfaction problem, in the lines of [11]. This w ould eliminate some problems of the compi- lation into rules, such as the restriction to handle FIP specifica tions only . Note that with the theory presented so far we can handle attributes, but not attribute conditions or computatio ns. Our aim is to use OCL a nd the analysis tec hniques we pro p o sed in [11]. W e a re also in vestigating additional analysis pro pe r ties at the sp ecification and op e rational lev els. It w ould be interesting to extend the set of derived op- erational rules to handle incremental sync hroniza tion and change propagation, using the techn iques in [20]. More complex patterns able to deal with recur s ion or hav e parameters are also under consideration. Finally , we aim to formalize a part of QVT using this technique. Ac kno wledg ements. W e thank the a nonymous reviewers of ICGT’08 for their useful comment s. W or k supp orted by the Spa nis h Ministry of Education and Science, pro jects TSI20 05-08 225- C0 7-06 and TIN2006-0967 8. References 1. V¨ olter, M., Stahl, T.: Mo del-driven soft ware dev elopment. Willey (200 6) 2. QVT. http://ww w.omg.org/docs/pt c/05-11-01.pdf (2005) 3. Ehrig, H., Ehrig, K., Ermel, C., Hermann, F., T aen tzer, G.: Informatio n preserving bidirectional mo del transfo rmations. In: Proc. F ASE’07. V olume 4422 of LNCS., Springer (2007) 72–86 4. Sch¨ urr, A.: Sp ecification of graph translators with triple graph grammars. In: Proc. WG’ 94. V olume 903 of LNCS., Springer (1994) 151–16 3 5. Ehrig, H., Ehrig, K., Prange, U., T aentzer , G.: F undamentals of algebraic graph transformation. Springer-V erlag (2006 ) 6. K¨ onigs, A.: Mo del transformation with t riple graph grammars. In: Proc. MTiP ’05. (2005) 7. Guerra, E., de Lara, J.: Even t-driven grammars: Relating abstract and concrete leve ls of visual languages. SoSyM, sp ecial section on ICGT’04 (200 7) 317–347 8. de Lara, J., Bardohl, R., Ehrig, H., Ehrig, K., Prange, U., T aen tzer, G.: Attributed graph transformation with node typ e in h eritance. TCS 376 (3) (2007) 1 39–163 9. Heck el, R ., W agner, A.: Ensuring consistency of conditional g raph rewriting - a constructive approac h. ENTCS 2 (199 5) 10. S tevens, P .: Bidirectional model transformations in QVT: Semantic issues and open questions. In: Proc. MoDELS’07. V olume 4735 of LNCS., Springer (2007) 1–15 11. Cab ot, J., Claris´ o, R., Guerra, E., de Lara, J.: Analysing graph transf ormation rules th rough OCL. In: T o app ear in Pro c. ICMT’08. LN CS, Sprin ger (2008) 12. T ratt, L.: A change propagating mod el transformati on language. JOT 7 (3) (2008) 107–126 13. Lawley , M., S teel, J.: Practica l declarative model transf ormation with T efk at. In : MoDELS Satell ite Ev ents. V olume 3844 of LNCS., Sp rin ger (2005 ) 139–150 14. Greenyer, J.: A study of mo del transformation technologies: Reconciling TGGs with Q VT. Master’s th esis, U niversit y of P aderb orn (2006) 15. A keh urst, D.H., Kent, S.: A relational ap p roac h to defining transformations in a metamodel. In: Proc. UML’02. V olume 2460 of LNCS., Springer (2002) 243–258 16. Braun, P ., Marsc hall, F.: T ransforming ob ject orien ted models with BOTL. ENTCS 72 (3) (2003) 17. O rejas, F., Ehrig, H., Prange, U .: A logic of graph constrain ts. In: Proc. F ASE’08. V olume 4961 of LNCS., Springer (2008) 179–1 98 18. K indler, E., W agner, R.: T riple graph grammars: Concepts, ex tensions, imp lemen- tations, and app lication scenarios. T ec hnical Rep ort TR-RI-07-284, P aderb orn Univ. ( 2007) 19. d e Lara , J., Guerra, E., Bottoni, P .: T riple patterns: Compact sp ecifications for the generatio n of op erational triple graph grammar rules. In: Pro c. GT-V MT’07. V olume 6 of Electronic Comm unications of the EASST. (2007) 20. Guerra, E., d e Lara, J.: Mod el view management with triple graph transformation systems. I n: Proc. ICGT’ 06. V olume 4178 of LNCS., Springer ( 2006) 3 51–366 App endix: Pro of of Some Results Pro of o f Pr op. 1. W e show the equiv alence o f forward s atisfiability , as a s imilar reasoning holds for the ba ckw ards one. W e ha ve to show that T rG | = F T 1 = V k ∈{ 1 , 2 } [ V i ∈ P r e k ← − N ( C k i ) ⇒ P ( Q k )] iff T r G | = F T 2 = ( V k = { 1 , 2 } [ V i ∈ P r e k ← − N ( C k i ) ⇒ P ( Q k )]) V M ∈ M I O ( Q 1 ,Q 2 ) [ V i ∈ P r e 1 ∪ P r e 2 ← − N ( C ′ i ) ∧ ← − P ( M ) ⇒ P ( Q 1 + M Q 2 )] . If T rG | = F T 2 , o bviously T rG | = F T 1 . Lets then assume that T rG | = F T 1 and chec k all pos s ible cases: (a) Both P ( Q i ) are p os itively satisfied and there is one o c c ur rence of b oth: ∃ m s i : Q i | s → T r G, m i : Q i → T r G with m s i = m i ◦ q s i (see left of Fig. 19). There are tw o po ssibilities: either ∃ M j ∈ M I O ( Q 1 , Q 2 ) ∼ = m 1 ( Q 1 ) × T r G m 2 ( Q 2 ) or not. In the firs t case, S j = [ ← − P ( M j ) ⇒ P ( Q 1 + M j Q 2 )] is p os- itively satisfied and the other [ ← − P ( M k ) ⇒ P ( Q 1 + M k Q 2 )] are v a cuously satisfied. This is so as w e firs t build the P .O. Q 1 + M j Q 2 , a nd then mo r- phism m s j : Q 1 + M j Q 2 → T rG exists due to the P .O. universal pro p erty (see left of Fig. 19). Mo reov er, m j : P s = M j + M j | s ( Q 1 + M j Q 2 ) | s → T rG exists for the same reaso n (see rig ht of Fig. 19). In the second ca s e, a ll patterns [ ← − P ( M k ) ⇒ P ( Q 1 + M k Q 2 )] are v a c uo usly satisfied. M j p 1 r r r y y r r r p 2 L L L % % L L L P .O . Q 1 | s / / m s 1 0 0 Q 1 % % K K K K K K K m 1 ' ' Q 2 y y s s s s s s s m 2 w w Q 2 | s o o m s 2 n n Q 1 + M j Q 2 m s j T rG M j | s | | z z z z z ' ' O O O O O O O P .O . M j " " E E E E E E m 1 ◦ p 1 % % ( Q 1 + M j Q 2 ) | s m s j | s u u w w o o o o o o o o P s m j T rG Fig. 19. Positiv e Satisfaction of P ( Q 1 + M j Q 2 ) g iven positive satisfa ction of P ( Q i ). (b) P ( Q 1 ) is po sitively satisfied and P ( Q 2 ) v acuo usly satisfied. In this case ∄ m s 2 : Q 2 | s → T r G , and therefore ∄ m k : M k + M k | s (( Q 1 + M k Q 2 ) | s ) → T rG (beca use Q 2 | s ֒ → M k + M k | s (( Q 1 + M k Q 2 ) | s )) and therefore eac h ← − P ( M k ) ⇒ P ( Q 1 + M k Q 2 ) is v a cuously satisfied. (c) If both P ( Q i ) a re v acuously satisfied by the sa me rea soning each ← − P ( M k ) ⇒ P ( Q 1 + M k Q 2 ) is v a cuously satisfied. (d) If P ( Q 1 ) is p os itively sa tisfied and P ( Q 2 ) is neg a tively satisfied (assume just one insta nce of each), then ∃ m s 1 : Q 1 | s → T rG, m s 2 : Q 2 | s → T rG, m 1 : Q 1 → T rG, ( C 2 i | s = N 2 s i ) n s i → T rG (see Fig. 2). Ther e are tw o p o s sibilities: either ∃ M j ∈ M I O ( Q 1 , Q 2 ) s.t. M j | s ∼ = m s 1 ( Q 1 | s ) × T r G m s 2 ( Q 2 | s ) or not. In the second case, all ← − P ( M k ) are v a c uo usly satisfied. In the first case we have that: • ∃ e j : Q 1 | s + M j | s Q 2 | s = ( Q 1 + M j Q 2 ) | s → T rG due to the P .O . universal prop erty . See the right o f Fig. 20. M j | s p 1 s | | ~ ~ | | p 2 s B B B B P .B. Q 1 m 1 / / Q 1 | s o o m s 1 , , Q 2 | s m s 2 r r / / C 2 i | s n s i o o T rG M j | s w w n n n n n n n n n ' ' P P P P P P P P P P .O . Q 1 | s ' ' O O O O O O O O m s 1 ) ) Q 2 | s m s 2 u u w w o o o o o o o o Q 1 | s + M j | s Q 2 | s e j T rG Fig. 20. Positive Satisfaction of P ( M j ) g iven p o sitive satisfaction of P ( Q 1 ) and negative satisfaction o f P ( Q 2 ). • ∃ m s j : M s j = M j + M j | s Q 1 + M Q 2 | s → T r G due to the P .O. universal prop erty , thus the ba se morphism of M j exists. See the left of Fig. 21. In this diagram, sq uare M j | s ֒ → M j → Q 1 → M ′ s j = M j | s → ( Q 1 + M j Q 2 ) | s → M ′ s j is a P .O. Then, m s j = m ′′ s j ◦ m ′ s j . • Mor phism f i : C ′ i | s → T r G (where C ′ i | s is the source comp onent of the pre-condition of M j derived from C 2 i ) exists due to the universal P .O . prop erty , see the rig ht of Fig. 21. Therefore M j is neg atively satisfied. The other P ( M k ) are v a c uo usly satisfied. M j | s p P $ $ I I I I I I I I P .O . M j = = = = = = Q 1 + M j Q 2 | s z z u u u u u u u u Q 1 & & M M M M M M M M M M ' ' M s j m ′ s j M ′ s j m ′′ s j T rG M j | s w w o o o o o o o o ' ' O O O O O O O O P .O . Q 1 | s ' ' N N N N N N N Q 2 | s w w p p p p p p p / / P .O . C 2 i | s } } { { { { { n s i n n Q 1 | s + M j | s Q 2 | s e j / / C ′ i | s f i o o T rG Fig. 21. Positive Satisfaction of P ( M j ) g iven p o sitive satisfaction of P ( Q 1 ) and negative satisfaction o f P ( Q 2 ). (e) A simila r r easoning follows if b oth P ( Q i ) are negatively satisfied. (f ) If P ( Q 1 ) is neg a tively satisfied (with just o ne instance) and P ( Q 2 ) is v acu- ously satisfied, then all P ( M j ) are v a c uo usly satisfied. If there is more than one occurr ence of a pattern either p o sitively or neg a - tively satisfied, we do all c ombinations but they reduce to the previous cases. Now let’s as sume that some T i is not satisfied. If T r G 2 F T 1 , obviously T rG 2 F T 2 . Let’s assume that T rG 2 F T 2 . W e check a ll the cases: (a) If T rG 2 F P ( Q i ), then T rG 2 T 1 . (b) If T r G 2 F ← − P ( M j ) ⇒ P ( Q 1 + M j Q 2 ), this mea ns that ∃ m s j : M j + M j | s (( Q 1 + M j Q 2 ) | s ) → T rG , ∄ m j : Q 1 + M j Q 2 → T rG and ∄ n ′ s u : N ′ u → T rG (where N ′ u are the der ived neg a tive pre-conditions ). As m s j exists, b oth m s i : Q i | s → T rG exist b eca use Q i | s ֒ → M j + M j | s (( Q 1 + M j Q 2 ) | s ). As no n ′ s u exists, the negative pre - conditions of Q i are satisfied. As m j do es not exist, some m i : Q i → T rG must not exis t be c ause Q i ֒ → Q 1 + M j Q 2 . Thus, either T rG 2 F P ( Q 1 ) or T rG 2 F P ( Q 2 ), therefore T rG 2 F T 1 . Pro of of Prop. 2. The proo f is simila r to the one for S-Deduction. W e show the equiv alence o f fo rward satisfia bility , as a similar r easoning holds for the backw ards one. W e have to sho w tha t T rG | = F T 1 = V k ∈{ 1 , 2 } [ V i ∈ P r e k ← − N ( C k i ) ∧ ← − P ( C k ) ⇒ P ( Q k )] iff T r G | = F T 2 = ( V k ∈{ 1 , 2 } [ V i ∈ P r e k ← − N ( C k i ) ∧ ← − P ( C k ) ⇒ P ( Q k )]) V M ∈ M I O ( Q 1 ,Q 2 ) [ V i ∈ P r e 1 ∪ P r e 2 ← − N ( C ′ i ) ∧ ← − P ( P c ) ⇒ P ( Q 1 + M Q 2 )] (see Fig. 6). If T rG | = F T 2 , ob vio usly T rG | = F T 1 . Lets then assume that T rG | = F T 1 and c heck all possible cases: (a) Both P ( Q i ) are p os itively satisfied and there is one o c c ur rence of b oth: ∃ m s i : P i s → T r G, m i : Q i → T r G with m s i = m i ◦ q s i . There are t wo pos si- bilities: either ∃ M j ∈ M I O ( Q 1 , Q 2 ) ∼ = m 1 ( Q 1 ) × T r G m 2 ( Q 2 ) o r not. In the second case, all S k = [ ← − P ( P c k ) ⇒ P ( Q 1 + M k Q 2 )] a re v acuously satisfied. In the first ca se, S j = [ ← − P ( P c j ) ⇒ P ( Q 1 + M j Q 2 )] is p ositively satisfied and the other [ ← − P ( P c k ) ⇒ P ( Q 1 + M k Q 2 )] are v acuous ly satisfied. This is so as (i) ∃ Q 1 + M j Q 2 due to the P .O . univ er sal prop erty , (ii) ∃ P c → T rG for the same reason and (iii) ∃ M s j → T rG . (b) P ( Q 1 ) is po sitively satisfied and P ( Q 2 ) v acuo usly satisfied. In this case ∄ m s 2 : P 2 s → T rG , and therefore ∄ m c j : P c j + P c j | s (( Q 1 + M j Q 2 ) | s ) → T rG (beca use Q 2 | s ֒ → P c j + P c j | s (( Q 1 + M j Q 2 ) | s )) and therefore each ← − P ( P c k ) ⇒ P ( Q 1 + M k Q 2 ) is v a cuously satisfied. (c) If b oth P ( Q i ) are v acuously sa tis fie d by the same reasoning each ← − P ( P c k ) ⇒ P ( Q 1 + M k Q 2 ) is v a cuously satisfied. (d) If P ( Q 1 ) is p os itively sa tisfied and P ( Q 2 ) is neg a tively satisfied (assume just one instance o f eac h), then either all ← − P ( P c k ) are v acuously satisfied, o r one ← − P ( P c j ) is negatively satisfied. (e) A simila r r easoning follows if b oth P ( Q i ) are negatively satisfied. (f ) If P ( Q 1 ) is neg a tively satisfied (with just o ne instance) and P ( Q 2 ) is v acu- ously satisfied, then all P ( P c j ) are v acuously sa tis fie d. If there is more than one occur rence of a pattern either p ositively or nega- tively satisfied, we do all combinations but they r e duce to the previous ca ses. If s ome T i is not satisfied the pro o f is analogous to the one for S-Deduction. Pro of of Prop. 5. W e have to pro of that if T 1 = ← − P ( C ) ⇒ P ( Q ) is satis- fied, so is T 2 = ← − P ( T s ) ⇒ P ( Q ) with C ֒ → T s ֒ → Q . Again, we show forward satisfaction, as a similar reas oning holds for the bac kwards one. If T rG | = F T 2 , then T rG | = F T 1 . Let’s assume that T r G | = F T 1 is sa tisfied and c heck all the cases: (a) If T 1 is positively satisfied, then so is T 2 , as Fig. 22 s hows. The left diagram shows that ∃ T s → T rG due to the P .O . universal pro pe r ty . The r ig ht diag ram shows that ∃ P 2 s = T s + T s | s Q | s → T rG for the same reaso n. C | s q Q < < < < < < P .O . B 1 } } | | | | | | | 7 7 7 7 7 7 P .O . C 8 8 8 8 8 8 Q | s C ( S, Q ) ! ! B B B B B B B C q q P 1 s / / / / Q T s o o r r T rG T s | s ~ ~ } } } } } ! ! C C C C C P .O . T s A A A A A $ $ Q | s } } { { { { { z z P 2 s T rG Fig. 22. Positiv e satisfaction of T 2 given p o sitive sa tisfaction of T 1 . (b) Lets a ssume that T 1 is nega tively satisfied. Then ∃ C i | s → N i → T rG . There are tw o o ptions, either ∃ Q → T rG or not. In the firs t case, by item (a ), we hav e that ∃ T s → T rG . But then, by the P .O. universal pro pe rty ∃ N ′ i → T rG , and hence T 2 is negativ ely satisfied. If ∄ Q → T rG , then either ∃ P 2 s → T rG or not. In the fir st cas e ∃ T s → T rG a nd therefore ∃ N ′ i → T rG a nd T 2 is negatively satisfied. In the second case T 2 is v a cuously satisfied. See the left of Fig. 23. C i | s P .O . . . T s | s o o ~ ~ } } } } } ! ! C C C C C P .O . N ′ i ) ) T s o o A A A A A $ $ Q | s } } { { { { { z z P 2 s T rG Fig. 23. Satisfaction of T 2 given neg ative satisfa ction of T 1 (left). (c) Lets a ssume that T 1 is v acuously satisfie d. Then (i) ∄ T s → T rG , b ecause, as ∃ C → T s if it w ould exist then we would hav e C → T rG ; (ii) ∄ P 2 s → T r G , as ∄ T s → T rG and T s → P 2 s . Hence, T 2 is v acuously sa tisfied.
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment