31
Higher-Order Transformation Eugene Syriani and Hans Vangheluwe

Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

Embed Size (px)

Citation preview

Page 1: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

Higher-Order Transformation

Eugene Syriani and Hans Vangheluwe

Page 2: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

2

Higher-Order TransformationOutline

1. What is a Higher-Order Transformation (HOT)?

2. Uses of HOT

3. Precise Modelling of Transformations

4. HOT in action

Page 3: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

3

Higher-Order Transformation1 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)

[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. 18-33 , Springer-Verlag. Enschede (The Netherlands), June 2009

Page 4: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

4

Higher-Order TransformationClassification

• 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.

Page 5: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

5

Higher-Order Transformation2 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]

TGG rule

TGG operational rules

[OMG08] OMG. Meta Object Facility 2.0 Query/View/Transformation Specification. April 2008.[Klar07] Klar, F.; Königs, A. & Schürr, A. Model transformation in the large. ESEC/FSE, pp. 285-294, ACM. Dubrovnik (Croatia), 2007.

Page 6: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

6

Higher-Order TransformationUses 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]

[Graaf07] Graaf, B. & van Deursen, A. Using MDE for generic comparison of views. Models in Software Engineering, INRIA. Nashville (USA), October 2007.

Page 7: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

7

Higher-Order TransformationUses 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.

[Lara10] de Lara, J. & Vangheluwe, H. Automating the transformation-based analysis of visual languages. Formal Aspects of Computing,22, no. 3-4, pp. 297-326, Springer. May 2010.

Page 8: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

8

Higher-Order TransformationUses 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

Page 9: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

9

Higher-Order TransformationUses of HOT

• Transformation Migration

Input: Model – Output: Transformation

• When a language evolves, all associated transformations must be adapted.

Page 10: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

10

Higher-Order TransformationUses 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

[0..1]

Page 11: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

11

Higher-Order Transformation3 Precise Modelling of Transformations

“A higher-order transformation is a model transformation such that its input and/or output models are themselves transformation

models.”

• The notion of model transformation

Manipulation of any model (see “Model Transformation” talk).

• 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?

Page 12: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

12

Higher-Order TransformationModels, Meta-Models, and Transformations

• T: operation that transforms the model M1 into M2.

• MT: model of a transformation that transforms any model of MM1 into a model of MM2.

• MMT: meta-model of all transformations that transform any meta-model.

• MMM: meta-model of the language used to describe meta-models.

M M’

T

MM1 MM2MMT

MMM

MT

conforms to

is modelled by

transformed to

Page 13: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

13

Higher-Order TransformationWhat is the most appropriate formalism for MMT?

• MMTU: meta-model of the transformation units (rules, primitive operators, ...)

• MMSC: meta-model of the scheduling language

• MMPL: meta-model of the pattern language

M M’

T

MM1 MM2MMT

MMM

MT

Page 14: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

14

Higher-Order TransformationPrecise Modelling of Transformations

MoTif transformation language [Syriani10]

[Syriani10] Syriani, E. & Vangheluwe, H. A Modular Timed Model Transformation Language. McGill University, no. SOCS-TR-2010.4,School of Computer Science. March 2010.

MMSC

MMTU

Page 15: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

15

Higher-Order TransformationWhat about MMPL? [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

[Kuhne09] Kühne, T.; Mezei, G.; Syriani, E.; Vangheluwe, H. & Wimmer, M. Explicit Transformation Modeling. MODELS 2009 Workshops,LNCS: 6002, pp. 240-255, Springer. Denver (USA) 2010.

Page 16: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

16

Higher-Order TransformationWhat about MMPL?

RAM process:

(quasi-)Automatically generated environment for pattern language

Input Meta-Model Output Meta-Model

Relax Augment Modify

Customized Pattern Meta-Model

Page 17: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

17

Higher-Order TransformationWhat about MMPL?

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

Page 18: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

18

Higher-Order TransformationWhat about MMPL?

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

Page 19: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

19

Higher-Order TransformationWhat about MMPL?

RAM process: generate pre-/post-condition patterns meta-models

Modification:

• Pre-condition pattern

• Attributes are of type constraint

• Post-condition pattern

• Attributes are of type action

• Concrete syntax

• Abstract classes

• Association ends

• Other (e.g., replace topological visual syntax constraints)

Page 20: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

20

Higher-Order TransformationWhat about MMPL?

RAM process: Generate the MMPL for Finite State Automata

Relax Augment Modify

Page 21: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

21

Higher-Order TransformationIs 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.

Page 22: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

22

Higher-Order Transformation4 HOT in Action [Kuhne09]

Translate

Simulate

Animate

[Kuhne09] Kühne, T.; Mezei, G.; Syriani, E.; Vangheluwe, H. & Wimmer, M. Explicit Transformation Modeling. MODELS 2009 Workshops,LNCS: 6002, pp. 240-255, Springer. Denver (USA) 2010.

Page 23: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

23

Higher-Order TransformationMeta-Model Definitions

The meta-models of the domain

Page 24: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

24

Higher-Order TransformationTransformation Meta-Model

The meta-model of the transformation language

Page 25: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

25

Higher-Order TransformationTransformation Meta-Model

The meta-model of the pattern language for the transformation (result of RAM)

Page 26: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

26

Higher-Order TransformationTranslation

Translate: Denotational Semantics of Finite State

Automata

Page 27: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

27

Higher-Order TransformationSimulation

Simulate: Operational Semantics of Petri-Net

Page 28: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

28

Higher-Order TransformationHOT 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.

HOT: Transform the Simulate transformation to include animation support.

Page 29: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

29

Higher-Order TransformationExpected outcome of HOT

The animation transformation

Page 30: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

30

Higher-Order TransformationHOT in Action

At the rule level, when an PN element is created from an FSA element,add a correspondence link between them.

Page 31: Higher-Order Transformation Eugene SyrianiandHans Vangheluwe

31

Higher-Order TransformationHOT in Action

At the scheduling level, add the animate rules at the last step of the simulator’s loop.