170 likes | 399 Views
Graph Transformation for Model Transformation. Arend Rensink University of Twente. Trafo Def Language. Language A. A-B Trafo Def. Language B. Overview. Scenario Outline of the presentation Requirements Principles Example Practice Next step Final words. A-Model. A-B Trafo.
E N D
Graph Transformation for Model Transformation Arend Rensink University of Twente Graph-Based State Spaces
Trafo Def Language Language A A-B Trafo Def Language B Overview • Scenario • Outline of the presentation • Requirements • Principles • Example • Practice • Next step • Final words A-Model A-B Trafo B-Model Graph-Based State Spaces
Requirements: What do we need? • Reasoning about models • Instances of different meta-models • Need common representation • Idea: graphs as common representation • Powerful yet simple • Natural for many models • Theory of graph transformation available • Some aspects not covered well • Cardinality and inheritance in meta-models • Ordered associations • Attributes Graph-Based State Spaces
Example: ASG to FG • Abstract Syntax Graph model 0..1 next Statement then else body 1 0..1 1 While If Assign Graph-Based State Spaces
Assign next While body If then else Assign Assign next Assign Example: ASG instance • Program ready = false;while (! ready) {if (x < max) { x = x*x; ready = true; } else { ready = false; }} • Graph Graph-Based State Spaces
Target model: Flow Graphs nondeterministic choice 1 2 Element flow flow Procedure Stop Predicate Graph-Based State Spaces
Assign Proc next flow While Pred flow flow body flow If Pred then else flow flow Assign Assign Proc Proc next flow Assign Proc Stop Example: FG instance • ASG • FG Graph-Based State Spaces
while assign start if-else if-no-else stop Trafo Def: set of rules Graph-Based State Spaces
Graph formalism • Graphs in this presentation: • flat (i.e., not hierarchical), untyped • directed, edge-labelled, no parallel edges • self-edges depicted as node labels • Formally: G = (L,N,E) with • L set of labels • N finite set of nodes • E N L N finite set of labelled edges • Partial morphisms • structure-preserving node mappings Graph-Based State Spaces
Production rule rule morphism LHS RHS NAC NAC (partial) NACs forbidden matching source graph morph(t) target graph src(t) tgt(t) Concrete transformation pushout Graph Productions (SPO = Single Pushout Approach) Graph-Based State Spaces
Example production rule Alternative single-graph representation green = creator: RHS, not LHS;to be added blue = eraser: LHS, not RHS;to be matched and deleted black = reader:LHS and RHS;to be matched and preserved red = embargo: NAC, not LHS;forbidden Graph-Based State Spaces
Lang A A-Type B-Type Lang B A-Model A-Graph B-Graph B-Model should be reversible Application scenario Graph Production Systems • Overhead: Transformation to and from graphs • Price for common representation • Graph transformations inefficient • Graph matching inherently complex (NP-complete) • Domain-specific transformations superior • Graph Trafo can serve as specification A-B Prod Syst A-B Trafo Graph-Based State Spaces
Graphs everywhere • Other modelling domains (meta-models) • XSD/XML • ERD schemas/databases • Class/object diagrams • Certain patterns emerge • Commonalities among modelling domains • Should be formulated on MOF level Graph-Based State Spaces
Practice: What is available? • BOTL (München) • Bidirectional O-o Transformation Language • Transforms object models to object models • FuJaBA (Paderborn, Kassel) • From UML to Java and Back Again • Generates Java code from enriched activity diagrams • ATOM3 (Madrid) • A Tool for Multi-Formalism Meta-Modelling • Transforms any model at any meta-level Graph-Based State Spaces
Next step: Dynamic Semantics • Current research mostly on static semantics • Models: Class diagrams, ERD schemes, XML schemas • Instances: Objects, ER databases, XML documents • Dynamic semantics: how do systems behave? • Can be expressed as changes on instance level • These can also be seen as transformations • Graph transformations for operational semantics • Aim: Semantics-preserving model transformations • NWO project: GRASLAND • Graphs for Software Language Definition • Aim: Generic semantic definition language Graph-Based State Spaces
meta-levelshift TAAL Experiment [Kleppe, Rensink, Kastenberg] • Example O-Olanguage • Transformations GROOVE ASG to FG dynamic semantics Graph-Based State Spaces
Final words • MDA: Cool idea • Good intuitions • Poor mathematical backing • Graph transformation: Promising approach • Good mathematical backing • Useful for formalizing principles • Questionable for practical transformations • State of the art • A lot of work at the stage of (small) case studies • We need engineering discipline(Who’s going to write the XSD meta-model in MOF?) Graph-Based State Spaces