Download presentation
Presentation is loading. Please wait.
Published byPeregrine Fisher Modified over 9 years ago
1
Intermodeling, Queries and Kleisli categories Zinovy Diskin, Tom Maibaum, Krzysztof Czarnecki McMaster University, University of Waterloo
2
NECSIS and MDE Network for Engineering of Complex Software- Intensive Systems for Automotive Systems – Eight Canadian research institutions – Three industrial partners (GM Canada, IBM Canada, and Malina Software) WADT'12 Query languages are Cartesian monads 2
3
Intermodeling (termed coined by Guerra et al, at MoDELS’10): What: Specification and maintenance of intermodel relations (techniques and tools) Why: Modeling is multimodeling 3 Query languages are Cartesian monads M2 M3 M1 R 23 R 12 R 13 R 123 WADT'12
4
Why intermodeling, cont’d 4 Query languages are Cartesian monads M2 M3 M1 R 23 R 12 R 13 R 123 WADT'12 Scenarios: Consistency Sync/change propagation Merge There is much more to R’s than name correspondence!
5
Contents Specifying intermodel relations is difficult Main features of our framework by examples Q-mappings at work: Model merge Formalization via Cartesian monads Summary: model management via algebra (or, colors of model management) Query languages are Cartesian monads 5 WADT'12
6
Specifying intermodel relations is not easy s:Student name=Mr. Lee bdate=01/01/1990 a : Woman - Actor name=Ann age = 21 Model S Model A = ? semantic relativism homonymy ? ? WADT'126 The indirect link problem The Domain: Ms. Ann Lee, 01/01/1990, a student and an actor Query languages are Cartesian monads “part of”
7
Contents Specifying intermodel relations is difficult Main features of our framework by examples Q-mappings at work: Model merge Formalization via Cartesian monads Summary: model management via algebra (or, colors of model management) Query languages are Cartesian monads 7 WADT'12
8
Indirect links via direct Q-links (Kleisli’s idea) Replace indirect links by direct links into derived elements (computed by queries, Q-links) Query languages are Cartesian monads 8 s : Student name = Ms.Lee bdate = 01/01/90 a : Actor name = Ann age = 22 Model AModel S + WADT'12 = = ? /age = 2012-1990 = 22
9
But first relate metamodels Query languages are Cartesian monads 13 f Metamodel, A Metamodel S + Student name: {Ms,Mr} x Str bdate: Int 3 /age = Q (bdate) : Int WADT'12 Actor name = Str age = Int f: f Model, A: A Model S + : S + S: Student name = Ms.Lee bdate = 01/01/90 /age = exec Q (01/01/90) = 22: Int a: Actor name = Ann age = 22
10
Q-links vs. semantic relativism, 1 Query languages are Cartesian monads 10 Student name: {Mr, Ms} x Str Metamodel S Actor name: Str Metamodel A Woman Man ? WADT'12 Common intermodeling jargon: 1-to-M(any) link We say indirect 1-M link
11
Q-links vs. semantic relativism, 2 11 Student name: {Mr, Ms} x Str Metamodel S Actor name: Str Metamodel A + Woman Man WADT'12 /title = Q1(W-M typing) Query languages are Cartesian monads
12
12 Student name: {Mr, Ms} x Str Metamodel S Actor name: Str Metamodel A + Woman Man WADT'12 /title = Q1 (W-M typing) /tname = Q2 (name, /title) An indirect 1-M link x {y 1,…, y m } is replaced by a direct 1-1 q-link x Q(y 1,…, y m ) Q-links vs. semantic relativism, 3 Query languages are Cartesian monads
13
13 Student name: {Mr, Ms} x Str Metamodel S Actor name: Str Metamodel A + Woman Man WADT'12 /title = Q1 (W-M typing) /tname = Q2 (name, title) m SA A + = Q ( A ) m i Q-links and asymmetry of mappings m is an ordinary total mapping consisting of pairs of elements. S is a view of A Query languages are Cartesian monads
14
14/36 Actor Metamodel A + Woman Man WADT'12 /title = Q2 (W-M typing) m Derived-derived case. Partial mappings. Student name: {Mr, Ms} x Str Metamodel S + /title = Q1(name) S A S + = Q 1 ( S ) i1i1 m2 m1 A + = Q 2 ( S ) i2i2 Query languages are Cartesian monads x x
15
15/36 Actor Metamodel A + Woman Man WADT'12 /title = Q1 (W-M typing) From partial mappings to spans (Reifying intermodel links) Student name: {Mr, Ms} x Str Metamodel S + /title = Q1(name) SA S + = Q 1 ( S ) i1i1 m2m2 A + = Q 2 ( S ) i2i2 Query languages are Cartesian monads Metamodel R Person title: {Mr, Ms} R m1m1
16
Contents Specifying intermodel relations is difficult Main features of our framework by examples Q-mappings at work: Model merge Towards formalization via Cartesian monads Summary: model management via algebra (or, colors of model management) Query languages are Cartesian monads 16 WADT'12
17
General pattern for merge FASE'1228/36 M+M+ A r1 B C D R1 R2... r2 Colimit... Color Legend: Black -- given Green --- discovery/heuristics/AI Blue --- pure algebra! Intermodeling, Queries, and Kleisli categories …
18
Merge via colimit: Example FASE'12 Intermodeling, Queries, and Kleisli categories 23/36 Actor Metamodel A + Woman Man /title = Q2 (W-M typing) Student name: {Mr, Ms} x Str Metamodel S + /title = Q1(name) Metamodel R ? (Person) name: {Mr, Ms} x Str Metamodel M + Woman Man /title = Q1 (name) = Q2 (W-M typing) R2M Person title: {Mr, Ms} S2M A2M R2S R2A
19
Merge via colimit cont’d FASE'12 Intermodeling, Queries, and Kleisli categories 23/36 Actor Metamodel A + Woman Man /title = Q2 (W-M typing) Student name: {Mr, Ms} x Str Metamodel S + /title = Q1(name) Metamodel R **** R2M Person title: {Mr, Ms} S2M A2M R2S R2A ? (Person) name: {Mr, Ms} x Str Metamodel M Woman Man Q1 (name) = Q2 (W-M typing)
20
Another version of intermodel span 20 Person title: {Mr, Ms} x Str Metamodel R Actor Metamodel A Woman Man R2A /MsPerson /MrPerson FASE'12 Student name: {Mr, Ms} x Str Metamodel S + /title = Q1(name) R2S ? (Person) name: {Mr, Ms} x Str Metamodel M + /title = Q1 (name) /MsPerson /MrPerson Q2(/title) S2M A2M Q2(title)
21
Normalized merge 21/36 Person title: {Mr, Ms} x Str Metamodel R Actor Metamodel A Woman Man R2A /MsPerson /MrPerson FASE'12 Student name: {Mr, Ms} x Str Metamodel S + /title = Q1(name) R2S ? (Person) name: {Mr, Ms} x Str Metamodel M **** Q2(title) Intermodeling, Queries, and Kleisli categories
22
General pattern for merge FASE'1228/36 M+M+ A r1 B C D R1 R2... r2 Colimit... Color Legend: Black -- given Green --- discovery/heuristics/AI Blue --- pure algebra! Intermodeling, Queries, and Kleisli categories …
23
Three colors of model management Discovering (heuristics + AI): Model diff/matching/alignment Execution (pure algebra): Model merge/update propagation Mixture: Weaving Green and Blue in one algorithm/module often results in Red FASE'12 Intermodeling, Queries, and Kleisli categories
24
But… Algebraic techniques work well if the universe of models and Q-mappings between them is a category We need to define composition of Q-mappings It is not trivial Intermodeling, Queries, and Kleisli categories 24/36FASE'12
25
Q-mappings as Kleisli mappings WADT'12 Query languages are Cartesian monads 27/36 AB Q(B)Q(B) f iQiQ A B ******* m = (Q, f) AB m AB Q(B)Q(B) f iQiQ Thick (extensional) notation Thin (formula) notation Ordinary mappings Q-mappings
26
Problem of Q-mapping composition 26/36 BDBD Qf(AD)Qf(AD) Qg(BD)Qg(BD) CDCD fDfD gDgD gSgS fSfS ASAS BSBS Qf(AS )Qf(AS ) CSCS fSfS gSgS Qg(BS )Qg(BS ) C B A fg qExe Schemas (data & query/view definitions) S stands for “the schema part” Instances (data and query execs) Subindex D stands for “the Data part” Typing mapping (t is “the typing part”) ? ? AtAt BtBt CtCt qExe ADAD ASAS BSBS CSCS Metamodels (or schemas) WADT'12 Query languages are Cartesian monads Models and their maps Qf(At)Qf(At) Qg(Bt)Qg(Bt)
27
Solution: first, we manage syntax (the easy part) ADAD BDBD Q f (A D ) Q g (B D ) CDCD fDfD gDgD ASAS BSBS Q f (A S ) CSCS fSfS gSgS Q g # ( Q f (A S )) fS#fS# subst Qg (BS)Qg (BS) typing C B A fg WADT'12 Query languages are Cartesian monads Schemas (data & query/view definitions) S stands for “the schema part” Instances (data and query execs) Subindex D stands for “the Data part” ?
28
Solution: second, we manage semantics (the difficult part) ADAD BDBD Qf(AD)Qf(AD) Qg(BD)Qg(BD) CDCD fDfD gDgD ASAS BSBS Q f (A S ) CSCS fSfS gSgS Q g # ( Q f (A S )) fS#fS# subst Qg (BS)Qg (BS) typing C B A fg WADT'12 Query languages are Cartesian monads Schemas (data & query/view definitions) S stands for “the schema part” Instances (data and query execs) Subindex D stands for “the Data part” Q g # (Q f (A D )) qExe fD#fD# monot Fortunately, many useful queries are monotonic (e.g., SPJ)
29
Some formal details 1)Simple (no-queries) model translation from one metamodel to another (retyping) can be specified by a categorical construct called fibration, p: Mod -->MMod (by def). 2)A monotonic query language is specified by a monad over the fibration 1), Q : Mod-->Mod, Q def : MMod-->MMod, p: Q --> Q def. This monad is Cartesian! (by def) 3)Models and Q-mappings form the Kleisli category of the monad in 2) Corollary. If the cat of models and simple mappings is closed wrt. merge, then the cat of models and Q- mappings is closed wrt. merge as well. 4) Theorem. Model translations determined by Q-mappings (= view mechanism) again form a fibration. That is, querying followed by retyping is compositional. Intermodeling, Queries, and Kleisli categories 33/36FASE'12
30
Summary A (vast?) majority of intermodel relationships can be specified by Q-mappings With Kleisli construction, models and Q- mappings between them form a category, i.e., a universe of well-defined algebraic operations Model management scenarios include two basic stages: – Discovery of Q-mappings between models; – Execution of an algebraic operation over models and mappings Weaving green into blue often results in red Query languages are Cartesian monads WADT'12
31
THE END WADT'12 Query languages are Cartesian monads /30
32
s :Student name=Mr. Lee a : Woman - Actor name=Ann Model S Model A WADT'129 Query languages are Cartesian monads Solution 1: Annotate indirect links with correspondence rules (= expressions attached to links) If s = a, then if s.name.title = Mr, then a. class = Man, else a. class = Woman = Conflict!
33
Solution 1: another sample s :Student name=Mr. Lee bdate=01/01/1990 a : Woman - Actor name=Ann age = 21 Model S Model A = WADT'1210 Query languages are Cartesian monads if s = a, then if s.bdate.month&day current.month&day then a.age = 2012 s.bdate.year - 1, else a.age = 2012 – p.bdate.year Conflict!
34
Problems of Solution 1 Query languages are Cartesian monads 34 M1 M2 Partially ad hoc Or, use something universal, say, OCL or FOL, but Network structure is collapsed into one big model Mapping composition problem (well recognized in the DB literature, Bernstein et al.) WADT'12 M3 … R12R23 … … … … R13 ?
35
Grand statement Many (all?) 1-M indirect links are nothing but hidden 1-1 Q-links: A basic element of one model can be derived in another model and vv. Semantic relativism = Basic-Derived correspondence (= Q-links) WADT'12 Query languages are Cartesian monads /30
36
Grand indeed? What’s about M-M links, or the derived-derive case? WADT'12 Query languages are Cartesian monads /30
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.