Jump to: navigation, search

Difference between revisions of "Henshin Transformation Meta-Model"

(Advanced concepts: Application conditions and rule nesting)
Line 21: Line 21:
 
''Examples:'' [https://www.eclipse.org/henshin/examples.php?example=bank Bank Accounts], [https://www.eclipse.org/henshin/examples.php?example=ecore2rdb Ecore2RDB], [https://www.eclipse.org/henshin/examples.php?example=java2statemachine Java2StateMachine],  [https://www.eclipse.org/henshin/examples.php?example=ecore2genmodel Ecore2Genmodel], [https://www.eclipse.org/henshin/examples.php?example=combpattern Grid & Comb Pattern], [https://www.eclipse.org/henshin/examples.php?example=gossipinggirls Gossiping Girls], [https://www.eclipse.org/henshin/examples.php?example=probbroadcast Probabilistic Broadcast], [https://www.eclipse.org/henshin/examples.php?example=giraph-movies Movies]
 
''Examples:'' [https://www.eclipse.org/henshin/examples.php?example=bank Bank Accounts], [https://www.eclipse.org/henshin/examples.php?example=ecore2rdb Ecore2RDB], [https://www.eclipse.org/henshin/examples.php?example=java2statemachine Java2StateMachine],  [https://www.eclipse.org/henshin/examples.php?example=ecore2genmodel Ecore2Genmodel], [https://www.eclipse.org/henshin/examples.php?example=combpattern Grid & Comb Pattern], [https://www.eclipse.org/henshin/examples.php?example=gossipinggirls Gossiping Girls], [https://www.eclipse.org/henshin/examples.php?example=probbroadcast Probabilistic Broadcast], [https://www.eclipse.org/henshin/examples.php?example=giraph-movies Movies]
  
'''Rule-nesting''' is a powerful concept providing a for-each operator for rules. In nested rules, the outer rule is referred to as ''kernel rule'' and an inner rule as ''multi rule''.  During execution of a nested rule, the kernel rule is matched and executed once and used as a starting point to apply the multi rule as often as possible. Multi mappings allow to specify identity between kernel and multi-rule nodes. In the [[Henshin Graphical Editor|graphical editor]], multi-rule nodes are indicated by a layered representation and an asterisk (*). Multiple layers of rule-nesting are allowed: They are indicated in the title bar of the respective nodes in terms of the path constituted by the nested rules.<br>
+
'''Rule-nesting''' is a powerful concept providing a for-each operator for rules. In nested rules, the outer rule is referred to as ''kernel rule'' and an inner rule as ''multi rule''.  During execution of a nested rule, the kernel rule is matched and executed once and used as a starting point to apply the multi rule as often as possible. Multi mappings allow to specify identity between kernel and multi-rule nodes. In the [[Henshin Graphical Editor|graphical editor]], multi-rule nodes are indicated by a layered representation and an asterisk (*). Multiple layers of rule-nesting are allowed: They are indicated in the title bar of the respective nodes in terms of the path constituted by the nested rules. For an example, please refer to [https://www.eclipse.org/henshin/examples.php?example=ecore2rdb Ecore2RDB].<br>
 
''Examples:'' [https://www.eclipse.org/henshin/examples.php?example=bank Bank Accounts], [https://www.eclipse.org/henshin/examples.php?example=ecore2rdb Ecore2RDB], [https://www.eclipse.org/henshin/examples.php?example=gossipinggirls Gossiping Girls], [https://www.eclipse.org/henshin/examples.php?example=probbroadcast Probabilistic Broadcast]
 
''Examples:'' [https://www.eclipse.org/henshin/examples.php?example=bank Bank Accounts], [https://www.eclipse.org/henshin/examples.php?example=ecore2rdb Ecore2RDB], [https://www.eclipse.org/henshin/examples.php?example=gossipinggirls Gossiping Girls], [https://www.eclipse.org/henshin/examples.php?example=probbroadcast Probabilistic Broadcast]
  

Revision as of 08:37, 3 June 2014

The Henshin transformation meta-model defines the concepts used for the specification of model transformations in Henshin.

Model transformations are specified in terms of modules that comprise a set of units, being either transformation rules - atomic units - or composite units that allow to define a control flow.

Basic building blocks: Rules

Henshin Transformation Modules.png

Rules are the basic building blocks for model transformations. A rule comprises two graphs, a left-hand side (LHS) and a right-hand side (RHS) graph. LHS and RHS specify model patterns on abstract syntax level. Nodes represent model elements, edges represent references between model elements. The LHS describes a pattern to be matched. The RHS specifies a change on the input model. Nodes and edges occurring in the LHS or RHS only are deleted or created, respectively. Node mappings between LHS and RHS declare identity, that is, nodes and edges being preserved. Nodes possess attributes representing the attributes of the respective model elements. Attribute conditions can be defined whose expressions are evaluated by a JavaScript engine at runtime.

For conciseness, the graphical editor merges LHS and RHS into one integrated representation. Nodes and edges are annotated with a «preserve», «create», or «delete» tag determined by their containment in LHS and RHS graphs.

Dangling condition: A common beginner-level problem is that rules are deemed unexecutable by the Henshin interpreter despite looking correct at the surface. This behavior is often connected to the dangling condition: A rule execution may not leave behind dangling edges, being edges with a missing source or target. It is possible to turn off the gluing condition check using the checkDangling Boolean flag.

Injective matching: The injectiveMatching flag specifies whether the match-finder is supposed to find matches that assign two or more LHS nodes to the same model element. Per default, matching is set injective (that is, not supposed to assign nodes to the same model element).

Advanced concepts: Application conditions and rule nesting

Henshin Application Conditions.png

Application conditions are graph patterns which restrict the LHS of a given rule. They may require the presence of additional elements or relationships not included in the LHS. In this case, they are referred to as positive application conditions (PACs). Furthermore, they may forbid the presence of elements or relationships. In this case, they are referred to as negative application conditions (NACs). Consequently, the graphical editor displays PAC elements with a «require» and NAC elements with a a «forbid» tag. Application conditions can be arbitarily nested using the propositional operators Or, And, Xor, and Not. Whether an application condition graph represents a NAC or a PAC is determined by its containment in a Not condition. There is one important distinction between model elements in the LHS graph and in a PAC graph of a rule: Model elements in PACs are not considered part of the match. The same holds for model elements in NACs.
Examples: Bank Accounts, Ecore2RDB, Java2StateMachine, Ecore2Genmodel, Grid & Comb Pattern, Gossiping Girls, Probabilistic Broadcast, Movies

Rule-nesting is a powerful concept providing a for-each operator for rules. In nested rules, the outer rule is referred to as kernel rule and an inner rule as multi rule. During execution of a nested rule, the kernel rule is matched and executed once and used as a starting point to apply the multi rule as often as possible. Multi mappings allow to specify identity between kernel and multi-rule nodes. In the graphical editor, multi-rule nodes are indicated by a layered representation and an asterisk (*). Multiple layers of rule-nesting are allowed: They are indicated in the title bar of the respective nodes in terms of the path constituted by the nested rules. For an example, please refer to Ecore2RDB.
Examples: Bank Accounts, Ecore2RDB, Gossiping Girls, Probabilistic Broadcast

Control flow: Units

Henshin Transformation Units.png

In Henshin, control flow is specified using units. Units have a fixed number of sub-units, allowing for arbitrary nesting. The following unit types are available:

Sequential units have an arbitrary number of sub-units that are executed in the given order. The Boolean flag strict determines the behavior if one of the sub-units cannot be executed: In strict mode, the execution stops, otherwise, the next sub-unit is executed. The Boolean flag rollback determines whether in the case of a stopped execution previous executions are reverted.
Examples: Ecore2RDB, Java2StateMachine, Ecore2Genmodel, Grid & Comb Pattern, Movies

Priority Units have an arbitrary number of sub-units that are checked in the given order for executability. One sub-unit - the first one found to be executable - is executed.
Examples: Java2StateMachine

Independent Units have an arbitrary number of sub-units that are checked in nondeterministic order for executability. One sub-unit - the first one found to be executable - is executed.
Examples: Ecore2Genmodel

Loop Units have one sub-unit. The sub-unit is executed as often as it is executable.
Examples: Java2StateMachine, Ecore2Genmodel

Iterated Units have one sub-unit. The sub-unit is executed as often as specified in the iterations property.
Examples: Grid & Comb Pattern

ConditionalUnits have either two or three sub-units: if, then, (and else). If a match for the if unit can be found, the then unit is executed. Otherwise, if present, the else unit is executed. Note that any changes specified in the if unit are ignored; it is used for matching only.
Examples: Java2StateMachine

Execution-time variability: Parametrization

Henshin Parameters.png

Parameters allow to shape the behavior of units and rules with variable information that is typically not present before execution time. Parameters are defined as part of the rule and can then be used in elements of the rule, e.g., as attribute values and in attribute conditions. Parameters can be set at execution time using the API or the graphical interpreter wizard. Parameters values that have been set externally are used during matching. In turn, parameters that were not set before the rule execution are set by the matchfinder to the values found in the respective objects. This can be used to propagate values between LHS and RHS elements. In the graphical editor, the parameter list is shown and edited in the title bar of a unit, following in brackets after the unit name.
Examples: Bank Accounts, Ecore2RDB, Ecore2Genmodel, Grid & Comb Pattern, Gossiping Girls, Probabilistic Broadcast

Parameter mappings: In order to pass parameter values from outer to inner units, it is required to define parameter mappings. A parameter mapping assigns a source parameter to a target parameter.
Examples: Ecore2RDB, Ecore2Genmodel, Grid & Comb Pattern