3.1.1. Graph Transformation Rule Definition

[Tip]Description

Graph transformation (GT) is the primary means for elementary model transformation steps in VIATRA. Graph transformation provides a rule and pattern-based manipulation of graph-based models. The application of a GT rule on a given VPM model (i.e. part of the model space) replaces an image of its precondition (left-hand side, LHS) pattern with an image of its postcondition (right-hand side, RHS) pattern, and additional actions can be executed after that as further side effects.

[Important]Syntax
	GTRuleDefAST ::= OptAnnotationsAST gtrule TypeNameAST DirectedFormalParameterDefAST = GTRuleBodyAST 

  DirectedFormalParameterDefAST ::= ( FormalParamsAST ) 
                                  | ( ) 

	GTRuleBodyAST ::= { PreconditionDefAST PostconditionOptAST ActionOptAST }
	
	PreconditionDefAST ::= precondition GraphPatternDefAST
	                     | precondition PatternCompositionAST

	PostconditionOptAST ::= $empty 
	                      | postcondition GraphPatternDefAST
	                      | postcondition PatternCompositionAST
	                
	ActionOptAST ::= $empty 
				   | action { AsmRulesAST }  	                	               

TypeNameAST is the identifier of the graph transformation rule.

Variables defined as part of the directed formal params are the input or output parameters of the rule depending on its direction ( in, out, inout).

provides different ways for defining graph transformation rules in order to adapt to the different programming style of transformation developers:

  • The traditional way of defining GT rules is to provide a pair of graph patterns: the precondition (left-hand side, LHS) pattern and the postcondition (right-hand side, RHS) pattern.

  • In VIATRA, there is also an action part executed after resolving the right hand side and left hand side where additional side-effects for rules can be defined with ASM rules.

Thus, a GT rule can be composed of

  • a precondition , a postcondition and an optional action part,

  • a precondition and an action part.

Each of the precondition and postcondition parts of a GT rule can be defined either locally or somewhere else, i.e. the appropriate keyword is followed by either a pattern definition or a pattern call.

[Note]Semantics

Parameters of GT rules can be bound before calling the rule; these bindings are kept in case of input parameters (in, inout). Output-only parameters (that has the tag out) are always handled as unbound variables.

Model manipulation can be defined by

  • the difference of the precondition and the postcondition if both LHS and RHS are present,

  • ASM rules, if an action part is present.

Detailed semantics of GT rules is defined in the upcoming sections.

Defined In:  GTASM machine

See Also:  choose rule, forall rule, GT rule call.