Higher-Order Transformation Outline 1.What is a Higher-Order Transformation (HOT)? 2.Uses of HOT 3.Precise Modelling of Transformations 4.HOT in action 2
Higher-Order Transformation 1 What is a Higher-Order Transformation (HOT)? “A higher-order transformation is a model transformation such that its input and/or output models are themselves transformation models.” [Tisi09] At least one of the input or output artefacts of the HOT must be a transformation model. Transformation model Transformation model Model* Transformation Transformation Model* Transformation (generation through grammar) 3 [Tisi09] Tisi, M.; Jouault, F.; Fraternali, P.; Ceri, S. & Bézivin, J. On the Use of Higher-Order Model Transformations. ECMDA-FA, LNCS: 5562, pp , Springer-Verlag. Enschede (The Netherlands), June 2009
Higher-Order Transformation Classification A HOT is just a transformation: The same classification as for simple model transformations can be applied Keeping in mind that the input and/or output models are transformations themselves. 4
Higher-Order Transformation 2 Uses of HOT (inspiration from [Tisi09]) Transformation Synthesis Input: or Model – Output: Transformation Mapping Implementation Reduce abstraction level: QVT-Relations QVT-Core (w.r.t. traces) [OMG08] Declarative to Operational specification: TGG rules TGG operational rules [Klar07] 5 TGG rule TGG operational rules [OMG08] OMG. Meta Object Facility 2.0 Query/View/Transformation Specification. April [Klar07] Klar, F.; Königs, A. & Schürr, A. Model transformation in the large. ESEC/FSE, pp , ACM. Dubrovnik (Croatia), 2007.
Higher-Order Transformation Uses of HOT Transformation Synthesis Input: or Model – Output: Transformation Generic Transformation Input or output meta-models of a transformation is not known a priori: generate a transformation on-the-fly specific to the input or output meta-models. HOT takes as input a meta-model MM and outputs a transformation model T. T takes as input two models that conform to MM and outputs the difference model between them: union of both models + annotations (similar, from left, from right) [Graaf07] 6 [Graaf07] Graaf, B. & van Deursen, A. Using MDE for generic comparison of views. Models in Software Engineering, INRIA. Nashville (USA), October 2007.
Higher-Order Transformation Uses of HOT Transformation Analysis Input: Transformation – Output: Model* Generate data information from a transformation for analysis purposes Query a transformation model Transform the operational semantics of a Petri-Net-like language defined as a graph transformation, together with an instance model of the language into a Petri-Net. [Lara10] This Petri-Net can be used for analysis. 7 [Lara10] de Lara, J. & Vangheluwe, H. Automating the transformation-based analysis of visual languages. Formal Aspects of Computing, 22, no. 3-4, pp , Springer. May 2010.
Higher-Order Transformation Uses of HOT Transformation Composition / Decomposition Input: [1..*] Transformation – Output: [1..*] Transformation Compose two transformations into one: complex merge of the rules Weaving of transformations: chain transformations with separate concerns (e.g. multi-stage) See “Application” part of this lecture: adding animation concern to a Petri-Net simulator 8
Higher-Order Transformation Uses of HOT Transformation Migration Input: Model – Output: Transformation When a language evolves, all associated transformations must be adapted. 9
Higher-Order Transformation Uses of HOT Transformation Modification Input: Transformation – Output: Transformation (INPLACE) Modify the semantics of the transformation engine Add a copy operator rules Add a grouping mechanism in the patterns Transformation Optimization Improve the transformation definition for more efficient results Refactor a transformation with best practices 10 [0..1]
Higher-Order Transformation 3 Precise Modelling of Transformations “A higher-order transformation is a model transformation such that its input and/or output models are themselves transformation models.” model transformation The notion of model transformation Manipulation of any model (see “Model Transformation” talk). transformation model The notion of transformation model Transformations must be modelled and thus conform to a meta-model. Model everything explicitly... But in which formalism? Which meta-model? 11
Higher-Order Transformation Models, Meta-Models, and Transformations T: operation that transforms the model M 1 into M 2. M T : model of a transformation that transforms any model of MM 1 into a model of MM 2. MM T : meta-model of all transformations that transform any meta-model. MMM: meta-model of the language used to describe meta-models. 12 MM’ T MM 1 MM 2 MM T MMM MTMT conforms to is modelled by transformed to
Higher-Order Transformation What is the most appropriate formalism for MM T ? MM TU : meta-model of the transformation units (rules, primitive operators,...) MM SC : meta-model of the scheduling language MM PL : meta-model of the pattern language 13 MM’ T MM 1 MM 2 MM T MMM MTMT
Higher-Order Transformation Precise Modelling of Transformations MoTif transformation language [Syriani10] 14 [Syriani10] Syriani, E. & Vangheluwe, H. A Modular Timed Model Transformation Language. McGill University, no. SOCS-TR , School of Computer Science. March MM SC MM TU
Higher-Order Transformation What about MM PL ? [Kuhne09] Unlike the transformation units and scheduling sub-languages, the pattern language depends on other languages: the domains of the transformation. 1.Generic pattern language +Most economic solution -Generic concrete syntax (MOF-like) -Allow to specify patterns that will never occur 2.Customized pattern language +Concrete syntax adapted to the source/target languages (DSL) +Exclude patterns that do not have a chance to match -More work for the tool builder 15 [Kuhne09] Kühne, T.; Mezei, G.; Syriani, E.; Vangheluwe, H. & Wimmer, M. Explicit Transformation Modeling. MODELS 2009 Workshops, LNCS: 6002, pp , Springer. Denver (USA) 2010.
Higher-Order Transformation What about MM PL ? RAM process: (quasi-)Automatically generated environment for pattern language 16 Input Meta-ModelOutput Meta-Model Relax Augment Modify Customized Pattern Meta-Model
Higher-Order Transformation What about MM PL ? RAM process: generate pre-/post-condition patterns meta-models Relaxation: Concretize abstract entities Reduce minimal multiplicity constraint Constraints (automatic?) Free form: no constraints Valid elements: ensure typing Valid multiplicities: enforce (relaxed) multiplicities Valid constraints: enforce (a subset of) meta-model constraints 17
Higher-Order Transformation What about MM PL ? RAM process: generate pre-/post-condition patterns meta-models Augmentation: Type all meta-model entities to MT(pre/post)_Element Add model transformation specific properties Labels Parameter passing (pivots) Allow abstract rules* Other (e.g., isProcessed ) Generic elements Trace elements 18
Higher-Order Transformation What about MM PL ? RAM process: generate pre-/post-condition patterns meta-models Modification: Pre-condition pattern constraint Attributes are of type constraint Post-condition pattern action Attributes are of type action Concrete syntax Abstract classes Association ends Other (e.g., replace topological visual syntax constraints) 19
Higher-Order Transformation What about MM PL ? RAM process: Generate the MM PL for Finite State Automata 20 RelaxAugmentModify
Higher-Order Transformation Is RAM a HOT? Answer: It takes as input the meta-models of the source and target languages. It produces as output a meta-model of transformations models. So it doesn’t take as input nor generate a transformation. 21
Higher-Order Transformation 4 HOT in Action [Kuhne09] 22 Translate Simulate Animate [Kuhne09] Kühne, T.; Mezei, G.; Syriani, E.; Vangheluwe, H. & Wimmer, M. Explicit Transformation Modeling. MODELS 2009 Workshops, LNCS: 6002, pp , Springer. Denver (USA) 2010.
Higher-Order Transformation Meta-Model Definitions The meta-models of the domain 23
Higher-Order Transformation Transformation Meta-Model The meta-model of the transformation language 24
Higher-Order Transformation Transformation Meta-Model RAM The meta-model of the pattern language for the transformation (result of RAM) 25
Higher-Order Transformation Translation 26 Translate Translate: Denotational Semantics of Finite State Automata
Higher-Order Transformation HOT in Action Meta-Models must include animation support The user adds correspondence links. Therefore the meta-models have evolved. We want to evolve the transformations without affecting the existing transformations. Simulate HOT: Transform the Simulate transformation to include animation support. 28
Higher-Order Transformation Expected outcome of HOT 29 The animation transformation
Higher-Order Transformation HOT in Action 30 At the rule level, when an PN element is created from an FSA element, add a correspondence link between them.
Higher-Order Transformation HOT in Action 31 At the scheduling level, add the animate rules at the last step of the simulator’s loop.
Higher-Order Transformation Higher than first-order transformation second order transformation Can you think of a second order transformation? i.e., a transformation that takes as input and outputs a HOT. In model-based testing, a technique called mutation analysis proposes to test transformations on faulty models (mutants). It allows to assess how effective a transformation can detect faulty models. A mutation on a model can be easily defined by a transformation. first-order transformation The faults in the mutant models must be realistic. To ensure that, we can create a first-order transformation that takes as input a meta-model and outputs a transformation (mutation operator). The mutation operator takes as input a model and that generates realistic faulty models w.r.t the meta-model provided. But now we want a composite mutation operation that mutates models by combining primitive mutation operators: transforming mutation operators. This can be done with a second-order transformation. 32