bx tutorial: graph transformation - triple graph grammars · interrelated models in model driven...

62
Frank Hermann, [email protected] SECAN-Lab Interdisciplinary Centre for Security, Reliability and Trust Université du Luxembourg BANFF Bidirectional Transformations 02-DECEMBER-2013 BX Tutorial: Graph Transformation - Triple Graph Grammars -

Upload: others

Post on 20-Mar-2020

23 views

Category:

Documents


0 download

TRANSCRIPT

Frank Hermann, [email protected]

SECAN-LabInterdisciplinary Centre for Security, Reliability and Trust Université du Luxembourg

BANFF Bidirectional Transformations02-DECEMBER-2013

BX Tutorial: Graph Transformation- Triple Graph Grammars -

Basic terminology (<10 min.)

• Key idea and general approach

Core tutorial part (<25 min.)

• BX operations and analysis

Integration part (<10 min.)

• General concept for concurrent model synchronization

• Cross-disciplinary concepts

OVERVIEW

02-DEC-2013 Tutorial: Triple Graph Grammars content: 1 slide: 2

Interrelated Models in Model Driven Engineering

02-DEC-2013 Tutorial: Triple Graph Grammars

Model 2Model 1

PIM

2 2

1

1. PIM$PIM (horizontal): DSL1$DSL2, Model Translation/ Integration/ Synchronisation, e.g.:UML Class Diag.$ RDBMBPMN $ BPELSequence Diag. $ St. Machines

Model Transformations

1

1. PIM$PSM (vertical):Model/Code generation, reverse engineering, e.g.:Class Diag.$Class Diag.Class Diag.$Java

2

[HEO+13]

1PSM

Model 1b Model 2b

content: 2 slide: 3

Interrelated Models in Model Driven Engineering

02-DEC-2013 Tutorial: Triple Graph Grammars

Model 2Model 1

PIM

PSM

Code Aclass Person extends Object{

int age;

String name;

double wage;

Person(String name){

age=0;this.name=name;wage=0;}

public int getAge(){return age;}

public double getWage(){return

wage;}

public String getName(){return

name;}

}

Code Bclass Executer{

String name;

int runs=0;

boolean success=false;

Executer(String name){

this.name=name;}

public static void main(String[] args) {

// load file

final Resource.Factory.Registry reg =

Resource.Factory.Registry.INSTANCE;

execute(args,reg);

}

}

2 2

1

1. PIM$PIM (horizontal): DSL1$DSL2, Model Translation/ Integration/ Synchronisation, e.g.:UML Class Diag.$ RDBMBPMN $ BPELSequence Diag. $ St. Machines

Model Transformations

1

1. PIM$PSM (vertical):Model/Code generation, reverse engineering, e.g.:Class Diag.$Class Diag.Class Diag.$Java

2

[HEO+13]

1

content: 2 slide: 4

02-DEC-2013 Tutorial: Triple Graph Grammars content: 3 slide: 5

02-DEC-2013 Tutorial: Triple Graph Grammars content: 3 slide: 6

02-DEC-2013 Tutorial: Triple Graph Grammars content: 3 slide: 7

02-DEC-2013 Tutorial: Triple Graph Grammars content: 3 slide: 8

02-DEC-2013 Tutorial: Triple Graph Grammars content: 3 slide: 9

02-DEC-2013 Tutorial: Triple Graph Grammars

SourceModel

TargetModel

CorrespondenceModel

Triple Graph

• Specify pattern by pattern how consistent integrated models can be constructed simultaneously

Key Idea of Triple Graph Grammars (TGGs)

content: 3 slide: 10

02-DEC-2013 Tutorial: Triple Graph Grammars

SourceModel

TargetModel

CorrespondenceModel

Triple Graph

• Specify pattern by pattern how consistent integrated models can be constructed simultaneously

• Generate operations for interoperability: Model Translation/Integration/Synchronisation

Key Idea of Triple Graph Grammars (TGGs)

content: 3 slide: 11

02-DEC-2013 Tutorial: Triple Graph Grammars

SourceModel

TargetModel

CorrespondenceModel

Triple Graph

• Specify pattern by pattern how consistent integrated models can be constructed simultaneously

• Generate operations for interoperability: Model Translation/Integration/Synchronisation

Key Idea of Triple Graph Grammars (TGGs)

content: 3 slide: 12

Bidirectional Model TransformationsBased on TGGs: Concept

02-DEC-2013 Tutorial: Triple Graph Grammars

Forward Model Transformation

S

Input Output

T

Backward Model Transformation

S

Output Input

T

S S TC

S TC T

Integrated Models

content: 4 slide: 13

CD2RDBM: Integrated Model

02-DEC-2013 Tutorial: Triple Graph Grammars

Co

ncrete

Syntax

T5:FKey

S2:src

T4:fkeys

T10:cols

T9:pkey

S3:Association

name = "employee"

S1:Class name="Company"

S5:Class name="Person"

S7:Class name="Customer"

S11:PrimitiveDataType

name = "int" S9:Attribute

is_primary = Tname="cust_id"

T11:Column type = "int"name = "cust_id"

T3:Column type = "int"name = "employee_cust_id"

T2:cols

T7:references

S10:type

C1:CT

C4:CT

C2:AFK

C3:CT

C5:AC

GS GT

S4:dest

S8:attrs

S6:parentT8:Table

name="Person"

T1:Table name="Company"

T6:fcols

Ab

stractSyn

tax

Company

FK1 employee_cust_id

Person

PK cust_idemployeePersonCompany

cust_id : int

Customer

employee

content: 5 slide: 14

CD2RDBM: Integrated Model

02-DEC-2013 Tutorial: Triple Graph Grammars

T5:FKey

S2:src

T4:fkeys

T10:cols

T9:pkey

S3:Association

name = "employee"

S1:Class name="Company"

S5:Class name="Person"

S7:Class name="Customer"

S11:PrimitiveDataType

name = "int" S9:Attribute

is_primary = Tname="cust_id"

T11:Column type = "int"name = "cust_id"

T3:Column type = "int"name = "employee_cust_id"

T2:cols

T7:references

S10:type

C1:CT

C4:CT

C2:AFK

C3:CT

C5:AC

GS GT

S4:dest

S8:attrs

S6:parentT8:Table

name="Person"

T1:Table name="Company"

T6:fcols

Ab

stractSyn

tax

Triple Graph

SourceModel

TargetModel

CorrespondenceModel

content: 5 slide: 15

Triple Type Graph for CD2RDBM (Abstract Syntax)

• TGG=(TG,SG, TR), TG = type graph, SG=start graph (SG= ∅), TR = set oftriple rules

Triple Graph Grammar (TGG)

02-DEC-2013 Tutorial: Triple Graph Grammars

Source

meta model

Target

meta modelCorrespondence

src

Association

name: StringFKey cols

fkeysreferencesdest

fcols

pkeyattrs

type

parent

type

CT

AFK

AC

110..1

0..1

1

0..1Class

name: String

Attribute

name: String

is_primary: boolean

Table

name: String

Column

type: String

name: String

PrimitiveDataType

name: String

0..1

[Schürr94]

content: 6 slide: 16

2 Triple Rules for CD2RDBM

02-DEC-2013 Tutorial: Triple Graph Grammars

:Class

name=n:CT

:Table

name=n

Class2Table(n:String)

++ ++ ++++ ++++ ++

RHS

LHS

RHS:parent

S1:Class

:Class

name=n

:CT :Table

:CT++

++++

++ ++++

LHS

Subclass2Table(n:String)

S1:Class :CT :Table

content: 7 slide: 17

Compact Notation:

• 𝑳 and 𝑹 withing onefigure

• elements in 𝑹\L aremarked with "++"

2 Triple Rules for CD2RDBM (Compact)

02-DEC-2013 Tutorial: Triple Graph Grammars

:Class

name=n:CT

:Table

name=n

Class2Table(n:String)

++ ++ ++++ ++++ ++

:parentS1:Class

:Class

name=n

:CT :Table

:CT

Subclass2Table(n:String)

++

++++

++ ++++

content: 7 slide: 18

FORMAL: construction is a pushout (PO) of 𝒕𝒓 and 𝒎 in the category of triple graphs

1. Pattern matching:Find occurrence 𝑚(𝐿) of 𝐿 in 𝐺

Transformation Step: General Concept

02-DEC-2013 Tutorial: Triple Graph Grammars

Triple rule

L R

G H(PO)

C

tr C T

C T

A C

C

C T

C T

A C

content: 8 slide: 19

FORMAL: construction is a pushout (PO) of 𝒕𝒓 and 𝒎 in the category of triple graphs

1. Pattern matching:Find occurrence 𝑚(𝐿) of 𝐿 in 𝐺

2. Transformation:Replace 𝑚(𝐿) in 𝐺 by 𝑅

RESULT:

Transformation Step 𝐺𝑡𝑟,𝑚

𝐻

Transformation Step: General Concept

02-DEC-2013 Tutorial: Triple Graph Grammars

L R

G H(PO)

C

tr C T

C T

A C

C

C T

C T

A C

Added elements

content: 8 slide: 20

Triple rule

• A triple rule specifies how model elements in the source and target language can be created synchronously

• Each triple rule is interpreted as consistency pattern: a source and a target model are consistent, if they can be constructed by the TGG

• A TGG generates the language of consistentintegrated models:

𝐿(𝑇𝐺𝐺) = 𝐺 ∅ ⇒∗𝐺 𝑣𝑖𝑎 𝑇𝑅}

Language of Integrated Models

02-DEC-2013 Tutorial: Triple Graph Grammars content: 9 slide: 21

Derived TGG-Operations

Operational Rules

02-DEC-2013 Tutorial: Triple Graph Grammars

Backward Transformation

Forward Transformation

Forward Rules (FW Rules): to complete structuresin C- and T-components

Source Rules: parse the source model

Backward Rules (BW Rules)

Target Rules

Integration

Synchronization

Consistency Check

content: 10 slide: 22

Derived Source Rule

02-DEC-2013 Tutorial: Triple Graph Grammars

triple rule tr source rule trS

:cols

:AC

S1:Class

:Attribute

name=n

is_primary=true

:attrs

C1:CT

T1:Table

++

++

++

++

:Columnname=ntype=t

PrimaryAttr2Column(n:String, t:String)

:PrimitiveDataType

name=t

:type

++

:pKey++

++

++ ++++

++

++

++++

++

S1:Class

:Attribute

name=n

is_primary=true

:attrs ++

++

PrimaryAttr2ColumnS(n:String, t:String)

:PrimitiveDataType

name=t

:type

++

++

++

++

++

content: 11 slide: 23

:cols

:AC

S1:Class

:Attribute

name=n

is_primary=true

:attrs

C1:CT

T1:Table

++

++

:Columnname=ntype=t

PrimaryAttr2ColumnF(n:String, t:String)

:PrimitiveDataType

name=t

:type

:pKey++

++++++

++

Derived Forward Rule

02-DEC-2013 Tutorial: Triple Graph Grammars

triple rule tr forward rule trF

:cols

:AC

S1:Class

:Attribute

name=n

is_primary=true

:attrs

C1:CT

T1:Table

++

++

++

++

:Columnname=ntype=t

PrimaryAttr2Column(n:String, t:String)

:PrimitiveDataType

name=t

:type

++

:pKey++

++

++ ++++

++

++

++++

++

content: 12 slide: 24

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

cust_id : int

Customer

Person Company

employee

concrete syntax

abstract syntax

6:src

11:dest

16:parent

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

22:attrs

23:type

GS GT

content: 13 slide: 25

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT

6:src

11:dest

16:parent

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

22:attrs

23:type

GS GT

:Class

name=n

Class2TableS(n:String)

++++

:Class

name=n:CT

:Table

name=n

Class2TableF(n:String)

++ ++++ ++++

content: 14 slide: 26

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT

6:src

11:dest

16:parent

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

22:attrs

23:type

:CT

GS GT3:Table

name=“Company“

Matched

elements (from L)

Matched effective

elements (from RS)

Created

elements (RF)

Already matched

effective elements

:Class

name=n

Class2TableS(n:String)

++++

:Class

name=n:CT

:Table

name=n

Class2TableF(n:String)

++ ++++ ++++

content: 14 slide: 27

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT3:Table

name=“Company“6:src

11:dest

16:parent

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

22:attrs

23:type

:CT

GS GT

Matched

elements (from L)

Matched effective

elements (from RS)

Created

elements (RF)

Already matched

effective elements

:Class

name=n

Class2TableS(n:String)

++++

:Class

name=n:CT

:Table

name=n

Class2TableF(n:String)

++ ++++ ++++

content: 14 slide: 28

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT3:Table

name=“Company“6:src

11:dest

16:parent

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

22:attrs

23:type

:CT

GS GT

Matched

elements (from L)

Matched effective

elements (from RS)

Created

elements (RF)

Already matched

effective elements

:Class

name=n

Class2TableS(n:String)

++++

:Class

name=n:CT

:Table

name=n

Class2TableF(n:String)

++ ++++ ++++

content: 14 slide: 29

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT3:Table

name=“Company“6:src

11:dest

16:parent

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

22:attrs

17:Table

name=“Person“

23:type

:CT

:CT

GS GT

Matched

elements (from L)

Matched effective

elements (from RS)

Created

elements (RF)

Already matched

effective elements

:Class

name=n

Class2TableS(n:String)

++++

:Class

name=n:CT

:Table

name=n

Class2TableF(n:String)

++ ++++ ++++

content: 14 slide: 30

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT3:Table

name=“Company“6:src

11:dest

16:parent

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

22:attrs

17:Table

name=“Person“

23:type

:CT

:CT

GS GT

Matched

elements (from L)

Matched effective

elements (from RS)

Created

elements (RF)

Already matched

effective elements

:parentS1:Class

:Class

name=n

Subclass2TableS(n:String)

++

++

++

:parentS1:Class

:Class

name=n

:CT :Table

:CT

Subclass2TableF(n:String)

++++ ++

content: 15 slide: 31

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT3:Table

name=“Company“6:src

11:dest

16:parent

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

22:attrs

17:Table

name=“Person“

23:type

:CT

:CT

GS GT

Matched

elements (from L)

Matched effective

elements (from RS)

Created

elements (RF)

Already matched

effective elements

:parentS1:Class

:Class

name=n

Subclass2TableS(n:String)

++

++

++

:parentS1:Class

:Class

name=n

:CT :Table

:CT

Subclass2TableF(n:String)

++++ ++

content: 15 slide: 32

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT3:Table

name=“Company“6:src

11:dest

16:parent

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

22:attrs

17:Table

name=“Person“

23:type

:CT

:CT

:CT

GS GT

Matched

elements (from L)

Matched effective

elements (from RS)

Created

elements (RF)

Already matched

effective elements

:parentS1:Class

:Class

name=n

Subclass2TableS(n:String)

++

++

++

:parentS1:Class

:Class

name=n

:CT :Table

:CT

Subclass2TableF(n:String)

++++ ++

content: 15 slide: 33

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT3:Table

name=“Company“6:src

11:dest

16:parent

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

22:attrs

17:Table

name=“Person“

23:type

:CT

:CT

:CT

GS GT

Matched

elements (from L)

Matched effective

elements (from RS)

Created

elements (RF)

Already matched

effective elements

:parentS1:Class

:Class

name=n

Subclass2TableS(n:String)

++

++

++

:parentS1:Class

:Class

name=n

:CT :Table

:CT

Subclass2TableF(n:String)

++++ ++

content: 15 slide: 34

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT3:Table

name=“Company“6:src

11:dest

16:parent

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

22:attrs

17:Table

name=“Person“

23:type

:CT

:CT

:CT

GS GT

Matched

elements (from L)

Matched effective

elements (from RS)

Created

elements (RF)

Already matched

effective elements

S1:Class

:Attribute

name=n

is_primary=true

:attrs ++

++

PrimaryAttr2ColumnS(n:String, t:String)

:PrimitiveDataType

name=t

:type

++

++

++

++

++

:cols

:AC

S1:Class

:Attribute

name=n

is_primary=true

:attrs

C1:CT

T1:Table

++

++

:Columnname=ntype=t

PrimaryAttr2ColumnF(n:String, t:String)

:PrimitiveDataType

name=t

:type

:pKey++

++++++

++

content: 16 slide: 35

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT3:Table

name=“Company“

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

23:type

:CT

:CT

:CT

:AC

GS GT

Matched

elements (from L)

Matched effective

elements (from RS)

Created

elements (RF)

Already matched

effective elements

S1:Class

:Attribute

name=n

is_primary=true

:attrs ++

++

PrimaryAttr2ColumnS(n:String, t:String)

:PrimitiveDataType

name=t

:type

++

++

++

++

++

:cols

:AC

S1:Class

:Attribute

name=n

is_primary=true

:attrs

C1:CT

T1:Table

++

++

:Columnname=ntype=t

PrimaryAttr2ColumnF(n:String, t:String)

:PrimitiveDataType

name=t

:type

:pKey++

++++++

++

content: 16 slide: 36

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT3:Table

name=“Company“

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

23:type

:CT

:CT

:CT

:AC

GS GT

Matched

elements (from L)

Matched effective

elements (from RS)

Created

elements (RF)

Already matched

effective elements

:Association

name = an

:Class

:src

:Class

:dest

++

++

++

Association2ForeignKeyS(an:String)

++

:Association

name = an

:Class :Table

:src

:Class

:dest

:FKey

:Table

:cols:fkeys

:references

:pkey

:CT

:AFK

:CT

++

++

++

++

++:fcols

:Column

name = an+"_"+cntype = t++

:Column

name = cntype = t

Association2ForeignKeyF(an:String, cn:String)

++ ++

++

++++

content: 17 slide: 37

3:Table

name=“Company“

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

23:type

:CT

:CT

:CT

:AC

GS GT

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

Matched

elements (from L)

Matched effective

elements (from RS)

Created

elements (RF)

Already matched

effective elements

:Association

name = an

:Class

:src

:Class

:dest

++

++

++

Association2ForeignKeyS(an:String)

++

:Association

name = an

:Class :Table

:src

:Class

:dest

:FKey

:Table

:cols:fkeys

:references

:pkey

:CT

:AFK

:CT

++

++

++

++

++:fcols

:Column

name = an+"_"+cntype = t++

:Column

name = cntype = t

Association2ForeignKeyF(an:String, cn:String)

++ ++

++

++++

content: 17 slide: 38

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT

Matched

elements (from L)

Matched effective

elements (from RS)

Created

elements (RF)

Already matched

effective elements

:Association

name = an

:Class

:src

:Class

:dest

++

++

++

Association2ForeignKeyS(an:String)

++

:Association

name = an

:Class :Table

:src

:Class

:dest

:FKey

:Table

:cols:fkeys

:references

:pkey

:CT

:AFK

:CT

++

++

++

++

++:fcols

:Column

name = an+"_"+cntype = t++

:Column

name = cntype = t

Association2ForeignKeyF(an:String, cn:String)

++ ++

++

++++

content: 17 slide: 39

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT

Matched

elements (from L)

Matched effective

elements (from RS)

Created

elements (RF)

Already matched

effective elements

:Association

name = an

:Class

:src

:Class

:dest

++

++

++

Association2ForeignKeyS(an:String)

++

:Association

name = an

:Class :Table

:src

:Class

:dest

:FKey

:Table

:cols:fkeys

:references

:pkey

:CT

:AFK

:CT

++

++

++

++

++:fcols

:Column

name = an+"_"+cntype = t++

:Column

name = cntype = t

Association2ForeignKeyF(an:String, cn:String)

++ ++

++

++++

content: 17 slide: 40

Example: Translation of Class Diagram

02-DEC-2013 Tutorial: Triple Graph Grammars

concrete syntax

abstract syntax

3:Table

name=“Company“

10:FKey

7:fkeys

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17:Table

name=“Person“

5:Column

type = “int“

name = “employee_cust_id“

4:cols

12:fcols13:references

23:type

:CT

:CT

:AFK

:CT

:AC

GS GT

Customer

cust_id : int

Person Company

employee

Company

FK1 employee_cust_id

Person

PK cust_idemployee

content: 17 slide: 41

Person

Customer

PK customer_id

Company

Example: inconsistent FW-MT

Tutorial: Triple Graph Grammars

3:Table

name=“Company“

20:cols

6:src

11:dest

16:parent

21:pkey

8:Association

name = “employee“

1:Class

name=“Company“

14:Class

name=“Person“

18:Class

name=“Customer“

27:PrimitiveDataType

name = “int“

23:Attribute

is_primary = true

name=“cust_id“

25:Column

type = “int“

name = “cust_id“

22:attrs

17b:Table

name=“Customer“

23:type

:CT

:CT

:CT

:AC

GS GT

17a:Table

name=“Person“

cust_id : int

Customer

Person Company

employee

missing

wrong

02-DEC-2013 content: 18 slide: 42

𝑀𝑇 ∶ 𝐿 𝑇𝐺𝑆 V𝐿 𝑇𝐺𝑇 , is defined by source consistent

𝑀𝑇-sequences via 𝑇𝑅𝐹 :

where and

Definition (Model Transformation)

FW-Model Transformation

02-DEC-2013 Tutorial: Triple Graph Grammars content: 19 slide: 43

Each TGG-model transformation 𝑀𝑇 is

• syntactically correct: for each 𝑀𝑇-sequence

there is 𝐺 = (𝐺𝑆 ← 𝐺𝐶 → 𝐺𝑇) ∈

𝐿(𝑇𝐺𝐺)

• complete: for each source model 𝐺𝑆 ∈ 𝐿(𝑇𝐺𝐺)𝑆 there is an

𝑀𝑇-sequence

• terminating, if all rules are source creating

Theorem (Correctness, Completeness and Termination)

Guaranteed Results

02-DEC-2013 Tutorial: Triple Graph Grammars

[EEE+07, EEHP09]

[EEE+07] H. Ehrig, K. Ehrig, C. Ermel, F. Hermann, and G. Taentzer: Information Preserving BidirectionalModel Transformations. Proc. FASE‘07. Springer (2007).

[EEHP09] H. Ehrig, C. Ermel, F. Hermann, and U. Prange: On-the-Fly Construction, Correctness and Completenessof Model Transformations based on Triple Graph Grammars. Proc. MODELS'09. Springer (2009).

content: 20 slide: 44

• TASK: restrict the applicability of translation rules, such thatinvalid paths are not constructed

Aim: Avoid Backtracking

Tutorial: Triple Graph Grammars

Source Model

Target Model 2

02-DEC-2013

Target Model n

Target Model 1

content: 21 slide: 45

• TASK: restrict the applicability of translation rules, such thatinvalid paths are not constructed

Aim: Avoid Backtracking

Tutorial: Triple Graph Grammars

Theoretical Foundation:Translation Markers + Negative application

conditions NACs

02-DEC-2013

Source Model

Target Model 2

content: 21 slide: 46

Forward Translation Rule

:cols

:AC

S1:Class

:Attribute

name=n

is_primary=true

:attrs

C1:CT

T1:Table

++++++

:Columnname=ntype=t

:PrimitiveDataType

name=t

:type

:pKey++

++ ++++++

PrimaryAttr2ColumnFT(n:String, t:String)

<tr>

<tr><tr>

<tr>

<tr>

<tr>

<tr>

Triple Rule

Example: Translation Markers

02-DEC-2013 Tutorial: Triple Graph Grammars

translationmarkers<tr>

:cols

:AC

S1:Class

:Attribute

name=n

is_primary=true

:attrs

C1:CT

T1:Table

++

++++ ++++

:Columnname=ntype=t

:PrimitiveDataType

name=t

:type

++

:pKey++

++

++ ++++

++++++

PrimaryAttr2Column(n:String, t:String)

content: 22 slide: 47

• critical pair: (SC2TFT, C2TFT)

• K)P2 via C2TFT leads to backtracking in any bigger context• Tool support: AGG for critical pair analysis• Solution: K as filter NAC for C2TFT

S2:parenttr=F

S3:Class

tr=Fname=n

tr_name=F

:CT :TableS1:Class

tr=T

S3:Class

tr=Tname=n

tr_name=T

:CT :TableS1:Class

tr=T

:CT :Table

S2:parenttr=F

K

P2

S3:Class

tr=Tname=n

tr_name=T

:CT :TableS1:Class

tr=T

:CT

S2:parenttr=T

P1

SC2TFT C2TFT

Conflicting Rules

Tutorial: Triple Graph Grammars02-DEC-2013

S2 remainsuntranslated[tr=F]

content: 23 slide: 48

Formal Result for Efficiency and Functional Behaviour

02-DEC-2013 Tutorial: Triple Graph Grammars

Given: terminating MT via TRFT.

If all significant critical pairs are strictly confluent

)

MT has functional behaviour and does not require backtracking.

Theorem (Functional Behaviour + Efficiency)

[HEOG10] F. Hermann, H. Ehrig, F. Orejas, U. Golas: Formal analysis of functional behaviour formodel transformations based on triple graph grammars. In: Int. Conf. on Graph Transformations, Springer (2010).

=> Information Preservation

content: 24 slide: 49

Tool support

02-DEC-2013 Tutorial: Triple Graph Grammars

eMoflon

TU Darmstadt (D)

MDE LAB

HPI – Potsdam (D)

HenshinTGG

TU Berlin (D), Uni Luxembourg (LU),Uni Marburg (D)

ATOM3

Uni Madrid (ES),McGill University (CA)

TGG Interpreter

Uni Paderborn (D)

EMorF

Solunar GmbH –Gütersloh (D)

content: 25 slide: 50

• Example: CD2RDBM (without NACs)

• Synthetic benchmark – instances are generated

Benchmark

02-DEC-2013 Tutorial: Triple Graph Grammars

[HLG+13] S. Hildebrandt, L. Lambers, H. Giese, J. Rieke, J. Greenyer, W. Schäfer, M. Lauder, A. Anjorin, A. Schürr: A Survey of Triple Graph Grammar Tools. Preproceedings BX 2013.

content: 26 slide: 51

Pure TGG execution DC-layered TGG

Application of TGGs in the large at SES

02-DEC-2013 Tutorial: Triple Graph Grammars

0,1

1

10

100

1000

10000

0 4000 8000 12000 16000

Exec

uti

on

Tim

e [

sec]

Input graph size [nodes]

0,1

1

10

100

1000

10000

0 4000 8000

Exec

uti

on

Tim

e [s

ec]

Input graph size [nodes]

Source: SES - www.ses.com

ASTRA fleetof SES

Input size: 400 KLOC; 1.5 mio. nodes (4,000 per file)TGG: 249 rules + 235 initialization/refactoring rules

Scenario: Translation of satellite control procedures

• Filter NACs + DC-layering (order on minimal groups of rules)

Performance Improvement

content: 27 slide: 52

Concurrent Synchronization Problem

02-DEC-2013 Tutorial: Triple Graph Grammars

:CSynch

Source Domain Target Domain

content: 28 slide: 53

1. Consistency Law:result is always consistent

2. Identity Law:no change, if input is already consistent

Correctness

02-DEC-2013 Tutorial: Triple Graph Grammars content: 29 slide: 54

Concurrent Synchronization: General Concept

02-DEC-2013 Tutorial: Triple Graph Grammars

• 1:CCS = Consistency Checking on Source component

• 2:fPpg = FW-Propagation

• 3:Res = Conflict Resolution

• 4:CCT = Consistency Checking on Target component

• 5:bPpg = BW-Propagation

[HEEO12] H. Ehrig, C. Ermel, G. Taentzer: Concurrent Model Synchronization with Conflict Resolution Based on Triple Graph Grammars. In: Proc. FASE’12. Springer (2012).

content: 30 slide: 55

Concurrent Synchronization: General Concept

02-DEC-2013 Tutorial: Triple Graph Grammars

• 1:CCS = Consistency Checking on Source component

• 2:fPpg = FW-Propagation

• 3:Res = Conflict Resolution

• 4:CCT = Consistency Checking on Target component

• 5:bPpg = BW-Propagation

[HEEO12] H. Ehrig, C. Ermel, G. Taentzer: Concurrent Model Synchronization with Conflict Resolution Based on Triple Graph Grammars. In: Proc. FASE’12. Springer (2012).

content: 30 slide: 56

Result: Correctness and Completeness

02-DEC-2013 Tutorial: Triple Graph Grammars

Given a triple graph grammar TGG, the derived nondeterministic concurrent synchronisation framework CSync(TGG, CSync) is correct and complete.

Theorem (Correctness and Completeness)

[GHN+13]S. Gottmann, F. Hermann, N. Nachtigall, B. Braatz, C. Ermel, H. Ehrig, T. Engel: Correctness and Completeness of Generalised Concurrent Model Synchronisation Based on Triple Graph Grammars. In: Proc. AMT'13, CEUR 2013.

[HEEO12] H. Ehrig, C. Ermel, G. Taentzer: Concurrent Model Synchronization with Conflict Resolution Based on Triple Graph Grammars. In: Proc. FASE’12. Springer (2012).

Model synchronisation can be performed for any input.

Definition (Completeness)

content: 31 slide: 57

• Different strategies:

– Batch / incremental execution

– Deterministic / non-deterministic execution

– Single / concurrent updates

• Relationship between TGGs and lenses:

– View TGGs [ARDS13]

– Delta Lenses and TGGs [HEO+13]

Cross-disciplinary concepts

02-DEC-2013 Tutorial: Triple Graph Grammars

[ARDS13] Anjorin, A., Rose, S., Deckwerth, F., Schürr, A.: Asymmetric delta lenses with view triple graph grammars (to appear). ECEASST (2013)

[HEO+13] F Hermann, H Ehrig, F Orejas, K Czarnecki, Z Diskin, Y Xiong, S Gottmann, T Engel: Model synchronization based on triple graph grammars: correctness, completeness and invertibility. In: Software & Systems Modeling, 1-29, Springer 2013.

content: 32 slide: 58

Concepts and Methods for:

• Information preservation (DB, …)

• Data protection (DB, SE, …)

• Efficient updates, large scale systems (DB, SE, …)

• Exception handling (PL, SE, …)

• General framework via lenses (PL, SE, …)

• …

General results:

• Lenses properties (PL, SE, …)

• ...

Possible impact from other BX communities

02-DEC-2013 Tutorial: Triple Graph Grammars content: 33 slide: 59

• Formal Guarantees: syntactical correctness, completeness, termination,

• Formal Analysis: functional behavior, information preservation, invertibility, semantical correctness

• General concept:for concurrent model synchronization

• Tool support and industrial use

Summary

02-DEC-2013 Tutorial: Triple Graph Grammars content: 34 slide: 60

Further Reading

02-DEC-2013 Tutorial: Triple Graph Grammars

[EEE+07] H. Ehrig, K. Ehrig, C. Ermel, F. Hermann, and G. Taentzer: Information PreservingBidirectional Model Transformations. Proc. FASE‘07. Springer (2007).

[EEPT06] H. Ehrig, K. Ehrig, U. Prange, and G. Taentzer: Fundamentals of Algebraic Graph Transformation. EATCS Monographs in Theoretical Computer Science. Springer (2006).

[GHL12] Giese, H., Hildebrandt, S., Lambers, L.: Bridging the Gap Between Formal Semantics and Implementation of Triple Graph Grammars. Ensuring Conformance of Relational Model Transformation Specifications and Implementations. Software and Systems Modeling, Springer (2012).

[GW09] Giese, H., Wagner, R.: From model transformation to incremental bidirectional model synchronization. Software and Systems Modeling 8(1), Springer (2009).

[HEGO10] F. Hermann, H. Ehrig, U. Golas, Fernando Orejas: Efficient Analysis and Execution of Correct and Complete Model Transformations Based on Triple Graph Grammars. Proc. of MDI’10, ACM (2010).

[HEOG10] F. Hermann, H. Ehrig, F. Orejas, U. Golas: Formal analysis of functional behaviourfor model transformations based on triple graph grammars. In: Int. Conf. on Graph Transformations, Springer (2010).

content: slide: 61

Further Reading

02-DEC-2013 Tutorial: Triple Graph Grammars

[HEO+13] F. Hermann, H. Ehrig, F. Orejas, K. Czarnecki, Z. Diskin, Y. Xiong, S. Gottmann, T. Engel: Model synchronization based on triple graph grammars: correctness, completeness and invertibility. In: Software & Systems Modeling, Springer 2013.

[HEGO14] F. Hermann, H. Ehrig, U. Golas, F. Orejas: Formal Analysis of Model TransformationsBased on Triple Graph Grammars. In MSCS, to appear 2014.

[KW07] Kindler, E., Wagner, R.: Triple graph grammars. concepts, extensions, implementations, and application scenarios. Tech. Rep. TR-ri-07-284, Department of Computer Science, University of Paderborn (2007).

[LAVS12] Lauder, M., Anjorin, A., Varró, G., Schürr, A.: Bidirectional model transformation withprecedence triple graph grammars. In: Proc. Eur. Conf. on Modelling Foundationsand Applications (ECMFA'12), LNCS, vol. 7349. Springer (2012).

[Schürr94] Schürr, A.: Specication of Graph Translators with Triple Graph Grammars. Proc. ofWG 1994. LNCS, Springer (1995).

[SK08] Schürr, A., Klar, F.: 15 years of triple graph grammars. In: Int. Conf. on Graph Transformations (ICGT 2008). LNCS, vol. 5214, Springer (2008).

content: slide: 62