![]() | Description |
---|---|
Pattern body is the basic part of the graph pattern definition. It determines a constraint set that identifies a part of the model space. |
![]() | Syntax |
---|---|
PatternBodiesAST ::= PatternBodyAST | PatternBodiesAST or PatternBodyAST PatternBodyAST ::= { PatternBodyContentsAST } PatternBodyContentsAST ::= $empty | PatternBodyContentsAST PatternBodyContentDefAST PatternBodyContentDefAST ::= PatternBodyContentAST ; | neg GraphPatternDefAST PatternBodyContentAST ::= LocalPatternBodyElementAST | PatternCompositionAST | NegativePatternAST | PatternVariableAssignmentAST | CheckConditionAST LocalPatternBodyElementAST ::= ModelElementAST | RelationshipAST ModelElementAST ::= EntityAST| RelationAST A pattern body mainly consists of local pattern body elements . These defines the typed structure of the pattern. A local pattern body element can be either a model element or a relationship definition between model elements. A model element is either an entity or a relation. Model element are identified by pattern variables: these are either the parameters of the pattern or internal variables. From a pattern body , another graph pattern can be invoked by pattern composition or as a negative pattern. Within a pattern body the unification of variables can be defined: it is called pattern variable assignment. Extra conditions can be states in addition to those that defines the typed structure. These are called check condition s and are formulated by ASM terms. |
![]() | Semantics |
---|---|
A pattern body defines a conjunction of constraints which has to be fulfilled by a part of the model space during pattern matching. The following list of core constraints are interpreted by the pattern matcher:
Here the In case of pattern composition, a predicate representing the invoked pattern is derived as a conjunction of the core constraints of its body. A negative pattern defines negative constraints: the pattern body can match only if none of the negative patterns can be satisfied. In case of recursion, the fixpoint of the recursive predicate is calculated. In case of multiple pattern bodies (OR-patterns), a different set of constraints is derived, and one of them needs to be matched for a successful match of the pattern. The pattern matching engine implements injective pattern matching, i.e. each pattern variable has to be bound to different model elements in the model space unless (i) two pattern variables are explicitly assigned to the same model element by pattern variable assignment or (ii) both variables appear in as actual parameters of called subpatterns. |
![]() | Constraints |
---|---|
All variables in the head of the pattern must appear in the pattern body
otherwise a compile-time error is generated. In case of OR-patterns, this rule applies to all pattern bodies. This is a significant change wrt. the previous versions of VIATRA where all pattern variables had to appear locally or in the check condition. The actual parameters of a pattern composition inside a pattern body are restricted to pattern variables . |
Example 2.3. Overview of pattern body contents
pattern myPattern(A,B,C,D) = { myType(A); // local pattern body element B = A; // variable assignment neg find myNestedPattern(C); // negative pattern composition check (name(B) = D); // check condition }
Defined In: graph pattern definition