260 likes | 272 Views
Explore source-to-target model translation, metamodels, and mappings in the .NECSIS Workshop on March 10th. Understand the process and benefits of traceability mappings for model translations.
E N D
Source-to-target model transf. Metamodel M Transf. def. T Metamodel N T(A) :execute T A T(B) :execute T … B … … Space of M’s instances (models), [[ M]] Space of N’s instances (models), [[ N]] Space mapping [[T]]: [[M]] --> [[N]] • Color Legend: • given data • computed data
Towards Relational Algebra for Model Translations (just started) Waterloo: Krzysztof Czarnecki, Michal Antkiewicz, Peiyuan Sun McMaster: Hamid Gholizadeh, Sahar Kokaly, Tom Maibaum Zinovy Diskin
Content • New view of model translation • more abstract • transf. becomes a formal object manipulate analyze …..
Source-to-target model transf. Metamodel M Transf. def. T Metamodel N T(A) :execute T A T(B) :execute T … B … … Space of M’s instances (models), [[ M]] Space of N’s instances (models), [[ N]] Space mapping [[T]]: [[M]] --> [[N]] • Color Legend: • given data • computed data
Model translation w/out traceability mappings physical objects object roles Transf. T1: Car -> CV*LV Boat -> LV and Metamod. M Metamod. N Car Commut. Vehicle 1 idA 1 R 1 S 1 Boat idB Leisure Vehicle up to iso Model A Model T(A) c:Car cv:CV xy:S xy’:S cb:R aa:idA s:S ab:R b:Boat lv:LV lv’:LV bb:idB
Model translation w/out traceability mappings physical objects object roles Transf. T1: Car -> CV*LV Boat -> LV and Transf. T2: Car -> LV Boat -> CV*LV Metamod. M Metamod. N Car Commut. Vehicle 1 idA 1 R 1 S 1 Boat idB Leisure Vehicle Model A Model T(A) c:Car cv:CV cv:CV xy:S xy’:S cb:R aa:idA s:S ab:R b:Boat lv’:LV lv:LV lv:LV lv’:LV bb:idB up to iso Theorem. [[ T1]] ≅ [[ T2 ]], where [[T1,2]]: [[M]] --> [[N]] are space functionsgenerated by T1,2 T1(A) ≅T2(A) lv’:LV
Model translation with traceability mappings physical objects object roles Transf. T1: Car -> CV*LV Boat -> LV and Transf. T2: Car -> LV Boat -> CM*LV Metamod. M Metamod. N Car Commut. Vehicle 1 idA 1 R 1 S 1 Boat idB Leisure Vehicle Traceability mappings Traceability links Model A Tr1(A) ≠ Tr2(A) Model T(A) c:Car cv:CV cv:CV xy:S xy’:S cb:R aa:idA s:S ab:R b:Boat lv’:LV lv:LV lv:LV lv’:LV bb:idB Theorem. [[ T1]] ≅ [[ T2 ]], where T1,2: [[M]] --> [[N]] are space functionsgenerated by T1,2 T1(A) ≅T2(A) Theorem. [[ T1]] ≠ [[ T2 ]], where T1,2: [[M]] --> ([[N]] x Map([[ N]] ,[[ M]] )) are two-valued (instance x map) functionsgenerated by T1,2
Summary 1: Mappings • Traceability mappings are a semantic rather than just technological component of MTs • Provide several benefits: • hold useful info about MTs • carry basic Boolean operations • help to understand MTs • Should be treated as first-class citizens
Typing: What we have physical objects object roles Transf. T1: Car -> CV*LV, Boat -> LV Metamod. M Metamod. N Car Commut. Vehicle 1 R S 1 Boat Leisure Vehicle ?? • Color Legend: • given data • given data • computed data Typing mapping Typing mapping Traceability mapping xy:S Model A Model T(A) xy’:S aa:idA s:S c:Car ab:R cv:CV bb:idB cb:R b:Boat lv:LV lv’:LV
Typing: What we want Transf. T1: Car -> CV*LV, Boat -> LV physical objects object roles Transf. definition mappings Metamod. M Metamod. N Car Commut. Vehicle 1 R S 1 Boat Leisure Vehicle Typing mapping Typing mapping xy:S Model A Model T(A) xy’:S aa:idA s:S c:Car ab:R cv:CV bb:idB cb:R b:Boat lv:LV lv’:LV Traceability mapping
Issues to manage Transf. T1: Car -> CV*LV, Boat -> LV physical objects object roles Transf. definition mappings Metamod. M Metamod. N • Dynamic thing (a transf.) is encoded by a structural thing (a set of links) • The mapping that encodes a transf. [[M]]-->[[N]] is directed from N to M • We need associations between associations (beyond UML?) Commut. Vehicle Car Leisure Vehicle Boat Typing mapping Typing mapping Model A Model T(A) c:Car cv:CV cb:R b:Boat lv:LV lv’:LV Traceability mapping NECSIS Workshops 12
Dynamics via mappings: Queries Transf. T: Car -> CV*LV, Boat -> LV Metamod. T Metamod. N Metamod. M 1 Commut. Vehicle 0..1 Car CVinM 1 map.T 1 same R S Car+Boat 1 LVinM 0..1 Leisure Vehicle :relabel Boat • Given data: • metamodels & modesl • trans. definition • Computable data: • queries • relabeling [=] xy:S xy’:S aa:idA s:S ab:R Model A Model T(A) bb:idB c’: Car+Boat 1:CVinM c:Car 1:CV 2:LVinM 12:same 3:LVinM b’: Car+Boat b:Boat 2:LV 3:LV Traceability mapping
Algebra and reuse [inj] M Q(M) T1 N Definitions ... T2 Typing :PB [key] U2 A [[Q]] (A) Instances [inj] Relabeling as “pulling Q(M) back” (pullback)
Algebra of MTs: T1 \/disjT2 CVinM map.T LVinM T1 \/disj T2 Metamod. M Metamod. N T1 Car Leisure Vehicle Commut. Vehicle 1 R S • Given data: • metamodels & modesl • trans. definition • Computable data: • queries • relabeling Car+Boat 1 T2 Boat Typing mapping [=] xy:S xy’:S aa:idA Model T(A) s:S ab:R Model A bb:idB 1:CV c’: Car+Boat c:Car 2:LV 3:LV b’: Car+Boat 3’:LV b:Boat 2’:LV 1’:CV Traceability mapping
Algebra of MTs: T1 /\T2 and T1 \/ T2 Transf. T: Car -> CV*LV, Boat -> LV CVinM map.T LVinM Metamod. M T1 \/ T2 Metamod. N T1 Car Leisure Vehicle Commut. Vehicle • Given data: • metamodels & modesl • trans. definition • Computable data: • queries • relabeling 1 R T1/\ T2 S Car+Boat 1 T2 Boat Typing mapping [=] xy:S xy’:S aa:idA s:S ab:R Model A Model T(A) bb:idB c’: Car+Boat c:Car 1:CV 2:LV 3:LV 2:LV 3:LV b’: Car+Boat b:Boat 1’:CV Traceability mapping
Algebra of MTs: T1 /\T2 and T1 \/ T2 CVinM LVinM Metamod. M T1 \/ T2 Metamod. N T1 Car T1/\ T2 T1 /\ T2(A) = T1(A) /\ T2(A) Car+Boat Leisure Vehicle Commut. Vehicle 1 T2 R T1\/ T2(A) = T1(A) \/ T2(A) S 1 Boat T1 (A) \/ T2 (A) T1 \/ T2 T1(A) T1 T2(A) T2 xy:S T1(A)/\ T2(A) T1/\ T2 xy’:S aa:idA s:S ab:R Model A Model T(A) bb:idB c’: Car+Boat c:Car 1:CV 2:LV 3:LV b’: Car+Boat b:Boat 1’:CV Traceability mapping
Algebra of MTs. Chaining (seq. composition) [inj] T1oT2 T2 Definitions :PB Q2(N) Q1(M) O N M T1 T2 ... Typing :PB :PB [key] U2 Instances [inj] [[Q1]] (A) [[Q2]] (..) A
Chaining transf. via mapping composition How? [inj] T1oT2 T2 Definitions Q2(N) Q1(M) O N M T1 T2 ... Typing :PB :PB [key] U2 Instances [inj] [[Q1]] (A) [[Q2]] (..) A
Chaining trans. via query substitution T1*T2 [inj] Definitions Kleisli mapping composition T1oT2 Q2(Q1(M)) T2 :PB Q2(N) Q2(T1) Q1(M) O N M T1 T2 ... Typing :PB :PB [key] U2 Instances [inj] [[Q1]] (A) [[Q2]] (..) A
Example of chaining • Given data: • metamodels & modesl • trans. definition • Computable data: • queries • relabeling Metamod. Q2(N) Metamod. Q1(M) T1 T2 Metamod. O Metamod. O Car Comm Vehicle CVinM VinN SinM 2 Vehicle Vehicle CV+LV [2] S T1: A -> X*Y, R->S, IdA->S; B-> Y; * UinN * * LVinM Car+Boat * Leisure Vehicle +B [2] S’ U Boat • Given data: • metamodels • trafo definition • trafo definitions • Computable data: • applied query definition • applied query definition • derived mapping idA Traceability mappings Metamod. Q2(Q1(M)) R’ T1oT2 Car idA + R idA+B VinM 2 Car+(Car+Boat) R~ + idB :m_G [2] UinM Car+Boat [2] * idCar’ U Boat
Constraint transfer Transf. T: Car -> CV*LV, Boat -> LV Metamod. T Metamod. N Metamod. M 1 Commut. Vehicle 0..1 Car [0..1] CVinM 1 map.T [1] 1 [0..1] [cover] same R S Car+Boat [1] 1 [disj] LVinM 0..1 Leisure Vehicle [1] :relabel Boat [0..1] • Given data: • metamodels & modesl • trans. definition • Computable data: • queries • relabeling [=] xy:S xy’:S aa:idA s:S ab:R Model A Model T(A) bb:idB c’: Car+Boat 1:CVinM c:Car 1:CV 2:LVinM 12:same 3:LVinM b’: Car+Boat b:Boat 2:LV 3:LV Traceability mapping
Constraint transfer • Given data: • metamodels & modesl • trans. definition • Computable data: • queries • relabeling Metamod. N Metamod. M T1 T2 Metamod. O Metamod. O class A (Car) class X (commV) idX XinM [1] [1] ZinN * SinM [1] 2 class Z (Vehicle) class Z (Vehicle) [1] S X+Y T1: A -> X*Y, R->S, IdA->S; B-> Y; [2] idA +R UinN [1] [2] * R * YinM [1] * A+B [2] idY class Y (leisV) [2] +B S’ [1] R~+ idB [1] [2] U R’ class B (Boat) [1] • Computable data: • applied query definition • applied query definition • derived constraint • derived constraint • derived mapping • Given data: • metamodels • trafo definition • trafo definitions • constraints Traceability mappings Metamod. M T1oT2 class A (Car) idA [1] ZinM 2 A+(A+B) idA + R [2] :m_G R UinM [2] * * [1] [2] A+B idA+B R~ + idB idA’+ R’ [2] U class B (Boat) R’
Transf. = Querying + Relabeling (=View computation) • Separation of concern • Reuse of the same queries • Analysis
Content • Intro • Model merge (BM: choice) via colimit • Model join (BM: concurrency) via limit • Model translation via Cartesian monads :) • Composing operations into workflows
Composing operations into workflows V2 T /\ V2 view def. 2 System embed2 5:meet 1:meet view def. 1 2:merge 4:transf. T V1+V2 embed1 V1 traceability 3:univ.property integrated view • The diagram above (a megamodel) is an algebraic term in diagram algebra • -- continuity is to be respected! • Can be executed • Allow term rewriting (based on laws), hence, optimization