blob: 44bd83b4d3138d4d2b5adc5b48685527e6bcf4a9 [file] [log] [blame]
<html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>2.1.5.&nbsp;Pattern Composition</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_PatternDefinition.html" title="2.1.&nbsp;Pattern Definition"><link rel="prev" href="def_GraphPatternCall.html" title="2.1.4.&nbsp;Graph Pattern Call"><link rel="next" href="def_PatternVariable.html" title="2.1.6.&nbsp;Pattern Variable"></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">2.1.5.&nbsp;Pattern Composition</th></tr><tr><td align="left" width="20%"><a accesskey="p" href="def_GraphPatternCall.html">Prev</a>&nbsp;</td><th align="center" width="60%">2.1.&nbsp;Pattern Definition</th><td align="right" width="20%">&nbsp;<a accesskey="n" href="def_PatternVariable.html">Next</a></td></tr></table><hr></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="def_PatternComposition"></a>2.1.5.&nbsp;Pattern Composition</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_PatternComposition_Description"></a>Description</th></tr><tr><td valign="top" align="left"><p>
<span class="strong"><strong>Pattern composition</strong></span>
<a name="N1060C" class="indexterm"></a>
enables the reusability of graph patterns by allowing to combine elementary graph patterns into complex
patterns in a declarative way.
</p><p>
<span class="strong"><strong>Pattern composition</strong></span>
can be initiated in the following contexts:
</p><div class="orderedlist"><ol type="1"><li><p>
from the body of another GT pattern as part of its
<a href="def_PatternBody.html" title="2.1.2.&nbsp;Pattern Body">pattern body</a>
</p></li><li><p>
as part of a <a href="def_NegativePattern.html" title="2.1.3.&nbsp;Negative Pattern">negative pattern</a>,
</p></li><li><p>
in the precondition of a
<a href="def_GTRuleDef.html" title="3.1.1.&nbsp;Graph Transformation Rule Definition">GT rule definition</a>,
</p></li><li><p>
in the postcondition part of a
<a href="def_GTRuleDef.html" title="3.1.1.&nbsp;Graph Transformation Rule Definition">GT rule definition</a>,
</p></li></ol></div></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_PatternComposition_Syntax"></a>Syntax</th></tr><tr><td valign="top" align="left"><pre class="programlisting">
PatternCompositionAST ::= <span class="token">find</span> <a href="def_ModelElementName.html" title="5.7.1.&nbsp;Model Element Name">QualifiedTypeNameAST</a> <a href="def_ActualParameter.html" title="5.8.3.&nbsp;Actual Parameters">ActualPatternParameterDefAST</a>
ActualPatternParameterDefAST ::= <span class="token">(</span> <a href="def_ActualParameter.html" title="5.8.3.&nbsp;Actual Parameters">ActualParamsPatternVariablesAST</a> <span class="token">)</span>
| <span class="token">(</span> <span class="token">)</span>
</pre><p>
The syntax of <span class="strong"><strong>pattern composition</strong></span> is formally identical to the
syntax of a <a href="def_GraphPatternCall.html" title="2.1.4.&nbsp;Graph Pattern Call">graph pattern call</a>. However, a main restriction is
that only <a href="def_PatternVariable.html" title="2.1.6.&nbsp;Pattern Variable">pattern variables</a> may appear as
<a href="def_ActualParameter.html" title="5.8.3.&nbsp;Actual Parameters">actual parameters</a>
in a <span class="strong"><strong>pattern composition</strong></span>, and not arbitrary terms as in case of
<a href="def_GraphPatternCall.html" title="2.1.4.&nbsp;Graph Pattern Call">graph pattern call</a>.
</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_PatternComposition_Semantics"></a>Semantics</th></tr><tr><td valign="top" align="left"><p>
The semantics of called graph patterns differs on the context in which the pattern call is initiated.
</p><div class="variablelist"><dl><dt><span class="term">Case 1: Pattern called from another pattern</span></dt><dd><p>
A graph pattern call (initiated from another pattern or as a precondition pattern of a
<a href="def_GTRuleDef.html" title="3.1.1.&nbsp;Graph Transformation Rule Definition">GT rule definition</a>
<span class="emphasis"><em>injects additional structural constraints</em></span>
to caller pattern in the following cases:
</p><div class="itemizedlist"><ul type="disc"><li><p>
from the body of another GT pattern, i.e. as part of a
<a href="def_PatternBody.html" title="2.1.2.&nbsp;Pattern Body">pattern body</a>
</p></li><li><p>
as part of a
<a href="def_NegativePattern.html" title="2.1.3.&nbsp;Negative Pattern">negative pattern</a>,
</p></li><li><p>
in the precondition of a
<a href="def_GTRuleDef.html" title="3.1.1.&nbsp;Graph Transformation Rule Definition">GT rule definition</a>,
</p></li></ul></div></dd><dt><span class="term">Case 2: Pattern called from postcondition of GT rule</span></dt><dd><p>
When
<span class="strong"><strong>pattern composition</strong></span>
<a name="N106A6" class="indexterm"></a>
is part of the postcondition of a
<a href="def_GTRuleDef.html" title="3.1.1.&nbsp;Graph Transformation Rule Definition">GT rule definition</a>, it
<span class="emphasis"><em>defines model manipulation</em></span>
(typically, bulk creation of model elements). This semantics is discussed in
<a href="def_GTRuleDef.html" title="3.1.1.&nbsp;Graph Transformation Rule Definition">GT rule definition</a>, and thus omitted here.
</p></dd></dl></div><p>
As in case of
<a href="def_GraphPatternCall.html" title="2.1.4.&nbsp;Graph Pattern Call">graph pattern call</a>,
the variables in the actual parameter list supplied to the called graph pattern from the caller pattern
can be either bound or unbound.
</p><div class="itemizedlist"><ul type="disc"><li><p>
If an actual parameter is bound then it is an
<span class="emphasis"><em>input parameter</em></span> for pattern matching.
The binding of all input parameters is kept unchanged during pattern matching.
</p></li><li><p>
If an actual parameter is unbound then it is an
<span class="emphasis"><em>output parameter</em></span>, and a binding is calculated during pattern matching.
</p></li></ul></div><p>
In case of
<span class="strong"><strong>pattern composition</strong></span>
<a name="N106CF" class="indexterm"></a>, each actual parameter is required to be a
<a href="def_PatternVariable.html" title="2.1.6.&nbsp;Pattern Variable">pattern variable</a>
(with respective semantics) instead of arbitrary
<a href="def_Term.html" title="5.1.1.&nbsp;ASM Term">ASM term</a>
as in case of
<a href="def_GraphPatternCall.html" title="2.1.4.&nbsp;Graph Pattern Call">graph pattern calls</a>.
</p><p>
As a general rule (i.e. in case of positive pattern composition), if the matching of a subpattern fails,
then the matching of the entire pattern also fails. However, if the subpattern is a negative pattern, then
the success of the caller is reversed, i.e. if the subpattern fails, then the caller succeeds, and vice
versa.
</p><p>
Pattern composition can also be
<span class="emphasis"><em>recursive</em></span>, i.e. a pattern may call itself as a subpattern in one or more pattern bodies.
Recursion is evaluated by bottom-up fixpoint calculation.
</p><p>
It is worth pointing out that a very general interpretation is allowed in VTCL: the only structural
restriction is that recursion in positive and negative patterns are not allowed to interfere, i.e. if a
pattern is called recursively in a negative pattern, than it is not allowed to be called recursively in the
positive pattern, and vice versa. Note that this restriction only applies to
<span class="emphasis"><em>recursive</em></span> pattern composition calls.
</p></td></tr></table></div><div class="highlights"><a name="def_PatternComposition_SeeAlso"></a><p><b>See also:&nbsp;</b>
<a href="def_GraphPatternCall.html" title="2.1.4.&nbsp;Graph Pattern Call">Graph pattern 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="def_GraphPatternCall.html">Prev</a>&nbsp;</td><td align="center" width="20%"><a accesskey="u" href="sec_PatternDefinition.html">Up</a></td><td align="right" width="40%">&nbsp;<a accesskey="n" href="def_PatternVariable.html">Next</a></td></tr><tr><td valign="top" align="left" width="40%">2.1.4.&nbsp;Graph Pattern Call&nbsp;</td><td align="center" width="20%"><a accesskey="h" href="index.html">Home</a></td><td valign="top" align="right" width="40%">&nbsp;2.1.6.&nbsp;Pattern Variable</td></tr></table></div></body></html>