<html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>3.1.1. Graph Transformation Rule Definition</title><link href="style.css" rel="stylesheet" type="text/css"><meta content="DocBook XSL Stylesheets V1.72.0" name="generator"><link rel="start" href="index.html" title="The VIATRA2 Model Transformation Framework"><link rel="up" href="sec_DefGTRule.html" title="3.1. Definition of Graph Transformation Rules"><link rel="prev" href="sec_DefGTRule.html" title="3.1. Definition of Graph Transformation Rules"><link rel="next" href="sec_GTParamPass.html" title="3.2. Parameter passing at Graph Transformation Rules"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table summary="Navigation header" width="100%"><tr><th align="center" colspan="3">3.1.1. Graph Transformation Rule Definition</th></tr><tr><td align="left" width="20%"><a accesskey="p" href="sec_DefGTRule.html">Prev</a> </td><th align="center" width="60%">3.1. Definition of Graph Transformation Rules</th><td align="right" width="20%"> <a accesskey="n" href="sec_GTParamPass.html">Next</a></td></tr></table><hr></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="def_GTRuleDef"></a>3.1.1. Graph Transformation Rule Definition</h4></div></div></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip: Description"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left"><a name="def_GTRuleDef_Description"></a>Description</th></tr><tr><td valign="top" align="left"><p> | |
<span class="strong"><strong>Graph transformation</strong></span> | |
<a name="N10C14" class="indexterm"></a> | |
(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 | |
<span class="strong"><strong>precondition</strong></span> | |
<a name="N10C1D" class="indexterm"></a> | |
(left-hand side, LHS) pattern with an image of its | |
<span class="strong"><strong>postcondition</strong></span> | |
<a name="N10C26" class="indexterm"></a> | |
(right-hand side, RHS) pattern, and additional | |
<span class="strong"><strong>actions</strong></span> | |
<a name="N10C2F" class="indexterm"></a> | |
can be executed after that as further side effects. | |
</p></td></tr></table></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important: Syntax"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"><a name="def_GTRuleDef_Syntax"></a>Syntax</th></tr><tr><td valign="top" align="left"><pre class="programlisting"> | |
GTRuleDefAST ::= <a href="def_Annotation.html" title="1.2.2. Annotation">OptAnnotationsAST</a> <span class="token">gtrule</span> <a href="def_ModelElementName.html" title="5.7.1. Model Element Name">TypeNameAST</a> <a href="def_DirectedFormalParameter.html" title="5.8.2. Directed Formal Parameters">DirectedFormalParameterDefAST</a> <span class="token">=</span> GTRuleBodyAST | |
DirectedFormalParameterDefAST ::= <span class="token">(</span> <a href="def_FormalParameter.html" title="5.8.1. Formal Parameters">FormalParamsAST</a> <span class="token">)</span> | |
| <span class="token">(</span> <span class="token">)</span> | |
GTRuleBodyAST ::= <span class="token">{</span> PreconditionDefAST PostconditionOptAST ActionOptAST <span class="token">}</span> | |
PreconditionDefAST ::= precondition GraphPatternDefAST | |
| precondition PatternCompositionAST | |
PostconditionOptAST ::= $empty | |
| postcondition GraphPatternDefAST | |
| postcondition PatternCompositionAST | |
ActionOptAST ::= $empty | |
| action <span class="token">{</span> <a href="def_AsmRuleDef.html" title="4.1.1. ASM Rule Definition">AsmRulesAST</a> <span class="token">}</span> | |
</pre><p> | |
<a href="def_ModelElementName.html" title="5.7.1. Model Element Name">TypeNameAST</a> | |
is the identifier of the graph transformation rule. | |
</p><p> | |
Variables defined as part of the | |
<a href="def_DirectedFormalParameter.html" title="5.8.2. Directed Formal Parameters">directed formal params</a> | |
are the input or output parameters of the rule depending on its direction ( | |
<code class="computeroutput">in</code>, | |
<code class="computeroutput">out</code>, | |
<code class="computeroutput">inout</code>). | |
</p><p> | |
provides different ways for defining graph transformation rules in order to adapt to the different | |
programming style of transformation developers: | |
</p><div class="itemizedlist"><ul type="disc"><li><p> | |
The traditional way of defining GT rules is to provide a pair of graph patterns: the | |
<span class="strong"><strong>precondition</strong></span> | |
<a name="N10C8F" class="indexterm"></a> | |
(left-hand side, LHS) pattern and the | |
<span class="strong"><strong>postcondition</strong></span> | |
<a name="N10C98" class="indexterm"></a> | |
(right-hand side, RHS) pattern. | |
</p></li><li><p> | |
In VIATRA, there is also an | |
<span class="strong"><strong>action</strong></span> | |
<a name="N10CA4" class="indexterm"></a> | |
part executed after resolving the right hand side and left hand side where additional side-effects | |
for rules can be defined with ASM rules. | |
</p></li></ul></div><p>Thus, a GT rule can be composed of</p><div class="itemizedlist"><ul type="disc"><li><p> | |
a | |
<span class="strong"><strong>precondition</strong></span> | |
<a name="N10CB3" class="indexterm"></a>, a | |
<span class="strong"><strong>postcondition</strong></span> | |
<a name="N10CBC" class="indexterm"></a> | |
and an optional | |
<span class="strong"><strong>action</strong></span> | |
<a name="N10CC5" class="indexterm"></a> | |
part, | |
</p></li><li><p> | |
a | |
<span class="strong"><strong>precondition</strong></span> | |
<a name="N10CD1" class="indexterm"></a> | |
and an | |
<span class="strong"><strong>action</strong></span> | |
<a name="N10CDA" class="indexterm"></a> | |
part. | |
</p></li></ul></div><p> | |
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. | |
</p></td></tr></table></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note: Semantics"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"><a name="def_GTRuleDef_Semantics"></a>Semantics</th></tr><tr><td valign="top" align="left"><p> | |
Parameters of GT rules can be bound before calling the rule; these bindings are kept in case of input | |
parameters (<code class="computeroutput">in</code>, | |
<code class="computeroutput">inout</code>). Output-only parameters (that has the tag | |
<code class="computeroutput">out</code>) are always handled as unbound variables. | |
</p><p>Model manipulation can be defined by</p><div class="itemizedlist"><ul type="disc"><li><p>the difference of the precondition and the postcondition if both LHS and RHS are present,</p></li><li><p> | |
ASM rules, if an | |
<span class="strong"><strong>action</strong></span> | |
<a name="N10D00" class="indexterm"></a> | |
part is present. | |
</p></li></ul></div><p>Detailed semantics of GT rules is defined in the upcoming sections.</p></td></tr></table></div><div class="highlights"><a name="def_GTRuleDef_DefinedIn"></a><p><b>Defined In: </b> | |
<a href="def_Machine.html" title="1.2.1. GTASM Machine Definition">GTASM machine</a> | |
</p></div><div class="highlights"><a name="def_GTRuleDef_SeeAlso"></a><p><b>See Also: </b> | |
<a href="def_ChooseRule.html" title="4.3.6. Choose Rule">choose rule</a>, | |
<a href="def_ForallRule.html" title="4.3.7. Forall Rule">forall rule</a>, | |
<a href="def_GTRuleCall.html" title="3.4.1. GTRule Call">GT rule call</a>. | |
</p></div></div><div class="navfooter"><hr><table summary="Navigation footer" width="100%"><tr><td align="left" width="40%"><a accesskey="p" href="sec_DefGTRule.html">Prev</a> </td><td align="center" width="20%"><a accesskey="u" href="sec_DefGTRule.html">Up</a></td><td align="right" width="40%"> <a accesskey="n" href="sec_GTParamPass.html">Next</a></td></tr><tr><td valign="top" align="left" width="40%">3.1. Definition of Graph Transformation Rules </td><td align="center" width="20%"><a accesskey="h" href="index.html">Home</a></td><td valign="top" align="right" width="40%"> 3.2. Parameter passing at Graph Transformation Rules</td></tr></table></div></body></html> |