aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/MODELS2020-CaseStudies/case.study.familyTree.run
diff options
context:
space:
mode:
authorLibravatar ArenBabikian <aren.babikian@mail.mcgill.ca>2020-04-27 10:45:28 -0400
committerLibravatar ArenBabikian <aren.babikian@mail.mcgill.ca>2020-04-27 10:45:28 -0400
commit36ca60e5b6bd047a4f444d96241bd60a01bbab17 (patch)
tree472ee15861945af6b7056d19250734ffab4c3aef /Tests/MODELS2020-CaseStudies/case.study.familyTree.run
parentMerge branch 'Attribute-Solver' (diff)
downloadVIATRA-Generator-36ca60e5b6bd047a4f444d96241bd60a01bbab17.tar.gz
VIATRA-Generator-36ca60e5b6bd047a4f444d96241bd60a01bbab17.tar.zst
VIATRA-Generator-36ca60e5b6bd047a4f444d96241bd60a01bbab17.zip
rename Pledge Case Studies and add familyTree case study
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.familyTree.run')
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/.classpath8
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/.project40
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/META-INF/MANIFEST.MF14
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.FamilyTreeConstraints.java._tracebin0 -> 333 bytes
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.MemberIsItsOwnParent.java._tracebin0 -> 3544 bytes
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/familyTreeConstraints.vql24
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/build.properties6
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/inputs/familytree.ecore17
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/inputs/familytreeGen.vsconfig23
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/generated3valued.vql_deactivated672
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/generation.logicproblem190
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/init.partialmodel51
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/log.txt1
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/models/1.gml1011
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/models/1.pngbin0 -> 93940 bytes
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/models/1.xmi8
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/plugin.xml7
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.FamilyTreeConstraints.java._tracebin0 -> 333 bytes
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.MemberIsItsOwnParent.java._tracebin0 -> 3544 bytes
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/FamilyTreeConstraints.java53
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/MemberIsItsOwnParent.java577
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src/queries/familyTreeConstraints.vql24
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src/run/FamilyTreeGen.java13
24 files changed, 2746 insertions, 0 deletions
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/.classpath b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/.classpath
new file mode 100644
index 00000000..4cc715d5
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/.classpath
@@ -0,0 +1,8 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<classpath>
3 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
4 <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5 <classpathentry kind="src" path="src"/>
6 <classpathentry kind="src" path="src-gen"/>
7 <classpathentry kind="output" path="bin"/>
8</classpath>
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/.project b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/.project
new file mode 100644
index 00000000..98c56323
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/.project
@@ -0,0 +1,40 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<projectDescription>
3 <name>case.study.familyTree.run</name>
4 <comment></comment>
5 <projects>
6 </projects>
7 <buildSpec>
8 <buildCommand>
9 <name>org.eclipse.viatra.query.tooling.ui.projectbuilder</name>
10 <arguments>
11 </arguments>
12 </buildCommand>
13 <buildCommand>
14 <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
15 <arguments>
16 </arguments>
17 </buildCommand>
18 <buildCommand>
19 <name>org.eclipse.jdt.core.javabuilder</name>
20 <arguments>
21 </arguments>
22 </buildCommand>
23 <buildCommand>
24 <name>org.eclipse.pde.ManifestBuilder</name>
25 <arguments>
26 </arguments>
27 </buildCommand>
28 <buildCommand>
29 <name>org.eclipse.pde.SchemaBuilder</name>
30 <arguments>
31 </arguments>
32 </buildCommand>
33 </buildSpec>
34 <natures>
35 <nature>org.eclipse.pde.PluginNature</nature>
36 <nature>org.eclipse.jdt.core.javanature</nature>
37 <nature>org.eclipse.viatra.query.projectnature</nature>
38 <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
39 </natures>
40</projectDescription>
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/.settings/org.eclipse.jdt.core.prefs b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..295926d9
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
1eclipse.preferences.version=1
2org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4org.eclipse.jdt.core.compiler.compliance=1.8
5org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7org.eclipse.jdt.core.compiler.source=1.8
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/META-INF/MANIFEST.MF b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..3f4abc65
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
1Manifest-Version: 1.0
2Bundle-ManifestVersion: 2
3Bundle-Name: case.study.familyTree.run
4Bundle-SymbolicName: case.study.familyTree.run;singleton:=true
5Bundle-Version: 0.0.1.qualifier
6Export-Package: queries
7Require-Bundle: org.eclipse.emf.ecore,
8 org.eclipse.viatra.query.runtime,
9 org.eclipse.viatra.query.runtime.rete,
10 org.eclipse.viatra.query.runtime.localsearch,
11 org.eclipse.xtext.xbase.lib,
12 case.study.familyTree.model;bundle-version="1.0.0"
13Import-Package: hu.bme.mit.inf.dslreasoner.application.execution,
14 org.apache.log4j
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.FamilyTreeConstraints.java._trace b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.FamilyTreeConstraints.java._trace
new file mode 100644
index 00000000..80158bd8
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.FamilyTreeConstraints.java._trace
Binary files differ
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.MemberIsItsOwnParent.java._trace b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.MemberIsItsOwnParent.java._trace
new file mode 100644
index 00000000..1b0dca98
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/.MemberIsItsOwnParent.java._trace
Binary files differ
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/familyTreeConstraints.vql b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/familyTreeConstraints.vql
new file mode 100644
index 00000000..1b9b6659
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/bin/queries/familyTreeConstraints.vql
@@ -0,0 +1,24 @@
1package queries
2
3import "http://www.example.org/familytree"
4
5@Constraint(message="memberIsItsOwnParent", severity="error", key={m})
6pattern memberIsItsOwnParent(m: Member) = {
7 FamilyTree.members(_, m);
8 Member.parents(m, p);
9 m == p;
10}
11
12//@Constraint(message="parentTooYoung", severity="error", key={m, p})
13//pattern parentTooYoung(m: Member, p: Member) = {
14// FamilyTree.members(_, m);
15// Member.parents(m, p);
16// Member.age(m, mAge);
17// Member.age(p, pAge);
18// check (mAge <= (pAge + 12));
19//}
20
21
22
23
24
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/build.properties b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/build.properties
new file mode 100644
index 00000000..efae4b07
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/build.properties
@@ -0,0 +1,6 @@
1bin.includes = META-INF/,\
2 .
3source.. = src/,\
4 src-gen/,\
5 src-gen/
6output.. = bin/
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/inputs/familytree.ecore b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/inputs/familytree.ecore
new file mode 100644
index 00000000..f2e51f65
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/inputs/familytree.ecore
@@ -0,0 +1,17 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="familytree" nsURI="http://www.example.org/familytree" nsPrefix="familytree">
4 <eClassifiers xsi:type="ecore:EClass" name="FamilyTree">
5 <eStructuralFeatures xsi:type="ecore:EReference" name="members" upperBound="-1"
6 eType="#//Member" containment="true"/>
7 </eClassifiers>
8 <eClassifiers xsi:type="ecore:EClass" name="Member">
9 <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
10 <eStructuralFeatures xsi:type="ecore:EAttribute" name="age" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
11 defaultValueLiteral="0"/>
12 <eStructuralFeatures xsi:type="ecore:EReference" name="children" upperBound="-1"
13 eType="#//Member" eOpposite="#//Member/parents"/>
14 <eStructuralFeatures xsi:type="ecore:EReference" name="parents" upperBound="2"
15 eType="#//Member" eOpposite="#//Member/children"/>
16 </eClassifiers>
17</ecore:EPackage>
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/inputs/familytreeGen.vsconfig b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/inputs/familytreeGen.vsconfig
new file mode 100644
index 00000000..140523bf
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/inputs/familytreeGen.vsconfig
@@ -0,0 +1,23 @@
1import epackage "inputs/familytree.ecore"
2import viatra "src/queries/familyTreeConstraints.vql"
3
4generate {
5 metamodel = { package familytree }
6 constraints = { package queries}
7 solver = ViatraSolver
8 scope = {
9 #node = 6,
10 #int = {1,2,3,4,5}
11 }
12
13 config = {
14 runtime = 10000,
15 log-level = normal
16 }
17
18 runs = 1
19
20 debug = "outputs/debug"
21 log = "outputs/log.txt"
22 output = "outputs/models"
23} \ No newline at end of file
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/generated3valued.vql_deactivated b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/generated3valued.vql_deactivated
new file mode 100644
index 00000000..bbaa6a26
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/generated3valued.vql_deactivated
@@ -0,0 +1,672 @@
1import epackage "http://www.bme.hu/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage"
2import epackage "http://www.bme.hu/mit/inf/dslreasoner/logic/model/problem"
3import epackage "http://www.bme.hu/mit/inf/dslreasoner/logic/model/language"
4
5//////////
6// 0. Util
7//////////
8private pattern interpretation(problem:LogicProblem, interpretation:PartialInterpretation) {
9 PartialInterpretation.problem(interpretation,problem);
10}
11
12/////////////////////////
13// 0.1 Existence
14/////////////////////////
15/** [[exist(element)]]=1 */
16private pattern mustExist(problem:LogicProblem, interpretation:PartialInterpretation, element:DefinedElement) {
17 find interpretation(problem,interpretation);
18 LogicProblem.elements(problem,element);
19} or {
20 find interpretation(problem,interpretation);
21 PartialInterpretation.newElements(interpretation,element);
22}
23
24/** [[exist(element)]]>=1/2 */
25private pattern mayExist(problem:LogicProblem, interpretation:PartialInterpretation, element:DefinedElement) {
26 find mustExist(problem,interpretation,element);
27} or {
28 find interpretation(problem,interpretation);
29 neg find elementCloseWorld(element);
30 PartialInterpretation.openWorldElements(interpretation,element);
31}
32
33private pattern elementCloseWorld(element:DefinedElement) {
34 PartialInterpretation.openWorldElements(i,element);
35 PartialInterpretation.maxNewElements(i,0);
36} or {
37 Scope.targetTypeInterpretation(scope,interpretation);
38 PartialTypeInterpratation.elements(interpretation,element);
39 Scope.maxNewElements(scope,0);
40}
41
42////////////////////////
43// 0.2 Equivalence
44////////////////////////
45pattern mayEquivalent(problem:LogicProblem, interpretation:PartialInterpretation, a: DefinedElement, b: DefinedElement)
46// For non-primitive type. Boolean types always must equivalent or cannot equivalent
47{
48 find mayExist(problem,interpretation,a);
49 find mayExist(problem,interpretation,b);
50 a == b;
51} or {
52 find mayExist(problem,interpretation,a);
53 find mayExist(problem,interpretation,b);
54 IntegerElement(a);
55 IntegerElement(b);
56 PrimitiveElement.valueSet(a,false);
57} or {
58 find mayExist(problem,interpretation,a);
59 find mayExist(problem,interpretation,b);
60 IntegerElement(a);
61 IntegerElement(b);
62 PrimitiveElement.valueSet(b,false);
63} or {
64 find mayExist(problem,interpretation,a);
65 find mayExist(problem,interpretation,b);
66 RealElement(a);
67 RealElement(b);
68 PrimitiveElement.valueSet(a,false);
69} or {
70 find mayExist(problem,interpretation,a);
71 find mayExist(problem,interpretation,b);
72 RealElement(a);
73 RealElement(b);
74 PrimitiveElement.valueSet(b,false);
75} or {
76 find mayExist(problem,interpretation,a);
77 find mayExist(problem,interpretation,b);
78 RealElement(a);
79 IntegerElement(b);
80 PrimitiveElement.valueSet(a,false);
81} or {
82 find mayExist(problem,interpretation,a);
83 find mayExist(problem,interpretation,b);
84 RealElement(a);
85 IntegerElement(b);
86 PrimitiveElement.valueSet(b,false);
87} or {
88 find mayExist(problem,interpretation,a);
89 find mayExist(problem,interpretation,b);
90 IntegerElement(a);
91 RealElement(b);
92 PrimitiveElement.valueSet(a,false);
93} or {
94 find mayExist(problem,interpretation,a);
95 find mayExist(problem,interpretation,b);
96 IntegerElement(a);
97 RealElement(b);
98 PrimitiveElement.valueSet(b,false);
99} or {
100 find mayExist(problem,interpretation,a);
101 find mayExist(problem,interpretation,b);
102 StringElement(a);
103 StringElement(b);
104 PrimitiveElement.valueSet(a,false);
105} or {
106 find mayExist(problem,interpretation,a);
107 find mayExist(problem,interpretation,b);
108 StringElement(a);
109 StringElement(b);
110 PrimitiveElement.valueSet(b,false);
111}
112
113pattern mustEquivalent(problem:LogicProblem, interpretation:PartialInterpretation, a: DefinedElement, b: DefinedElement) {
114// For non-primitive and Boolean primitive type
115 find mustExist(problem,interpretation,a);
116 find mustExist(problem,interpretation,b);
117 a == b;
118} or {
119 find mustExist(problem,interpretation,a);
120 find mustExist(problem,interpretation,b);
121 PrimitiveElement.valueSet(a,true);
122 PrimitiveElement.valueSet(b,true);
123 IntegerElement.value(a,value);
124 IntegerElement.value(b,value);
125} or {
126 find mustExist(problem,interpretation,a);
127 find mustExist(problem,interpretation,b);
128 PrimitiveElement.valueSet(a,true);
129 PrimitiveElement.valueSet(b,true);
130 RealElement.value(a,value);
131 RealElement.value(b,value);
132} or {
133 find mustExist(problem,interpretation,a);
134 find mustExist(problem,interpretation,b);
135 PrimitiveElement.valueSet(a,true);
136 PrimitiveElement.valueSet(b,true);
137 RealElement.value(a,value);
138 IntegerElement.value(b,value);
139} or {
140 find mustExist(problem,interpretation,a);
141 find mustExist(problem,interpretation,b);
142 PrimitiveElement.valueSet(a,true);
143 PrimitiveElement.valueSet(b,true);
144 IntegerElement.value(a,value);
145 RealElement.value(b,value);
146} or {
147 find mustExist(problem,interpretation,a);
148 find mustExist(problem,interpretation,b);
149 PrimitiveElement.valueSet(a,true);
150 PrimitiveElement.valueSet(b,true);
151 StringElement.value(a,value);
152 StringElement.value(b,value);
153}
154
155//////////
156// 1. Problem-Specific Base Indexers
157//////////
158// 1.1 Type Indexers
159//////////
160// 1.1.1 Required Patterns by TypeIndexer
161//////////
162private pattern typeInterpretation(problem:LogicProblem, interpretation:PartialInterpretation, type:TypeDeclaration, typeInterpretation:PartialComplexTypeInterpretation) {
163 find interpretation(problem,interpretation);
164 LogicProblem.types(problem,type);
165 PartialInterpretation.partialtypeinterpratation(interpretation,typeInterpretation);
166 PartialComplexTypeInterpretation.interpretationOf(typeInterpretation,type);
167}
168
169private pattern directInstanceOf(problem:LogicProblem, interpretation:PartialInterpretation, element:DefinedElement, type:Type) {
170 find interpretation(problem,interpretation);
171 LogicProblem.types(problem,type);
172 TypeDefinition.elements(type,element);
173} or {
174 find interpretation(problem,interpretation);
175 find typeInterpretation(problem,interpretation,type,typeInterpretation);
176 PartialComplexTypeInterpretation.elements(typeInterpretation,element);
177}
178
179private pattern isPrimitive(element: PrimitiveElement) {
180 PrimitiveElement(element);
181}
182//////////
183// 1.1.2 primitive Type Indexers
184//////////
185// Currently unused. Refer primitive types as:
186// > PrimitiveElement(element)
187// specific types are referred as:
188// > BooleanElement(variableName)
189// > IntegerElement(variableName)
190// > RealElement(variableName)
191// > StringElement(variableName)
192// And their value as
193// > BooleanElement.value(variableName,value)
194// > IntegerElement.value(variableName,value)
195// > RealElement.value(variableName,value)
196// > StringElement.value(variableName,value)
197// Whether a value is set is defined by:
198// > PrimitiveElement.valueSet(variableName,isFilled);
199//////////
200// 1.1.3 domain-specific Type Indexers
201//////////
202/**
203 * An element must be an instance of type "FamilyTree class".
204 */
205private pattern mustInstanceOfFamilyTree_class(problem:LogicProblem, interpretation:PartialInterpretation, element:DefinedElement) {
206 Type.name(type,"FamilyTree class");
207 find directInstanceOf(problem,interpretation,element,type);
208}
209private pattern scopeDisallowsNewFamilyTree_class(problem:LogicProblem, interpretation:PartialInterpretation) {
210 find interpretation(problem,interpretation);
211 PartialInterpretation.scopes(interpretation,scope);
212 Scope.targetTypeInterpretation(scope,typeInterpretation);
213 Scope.maxNewElements(scope,0);
214 PartialComplexTypeInterpretation.interpretationOf(typeInterpretation,type);
215 Type.name(type,"FamilyTree class");
216}
217
218/**
219 * An element may be an instance of type "FamilyTree class".
220 */
221private pattern mayInstanceOfFamilyTree_class(problem:LogicProblem, interpretation:PartialInterpretation, element:DefinedElement)
222{
223 find interpretation(problem,interpretation);
224 PartialInterpretation.newElements(interpretation,element);
225 neg find mustInstanceOfMember_class(problem,interpretation,element);
226 neg find scopeDisallowsNewFamilyTree_class(problem, interpretation);
227 neg find isPrimitive(element);
228} or {
229 find interpretation(problem,interpretation);
230 PartialInterpretation.openWorldElements(interpretation,element);
231 neg find mustInstanceOfMember_class(problem,interpretation,element);
232 neg find scopeDisallowsNewFamilyTree_class(problem, interpretation);
233 neg find isPrimitive(element);
234} or
235{ find mustInstanceOfFamilyTree_class(problem,interpretation,element); }
236/**
237 * An element must be an instance of type "Member class".
238 */
239private pattern mustInstanceOfMember_class(problem:LogicProblem, interpretation:PartialInterpretation, element:DefinedElement) {
240 Type.name(type,"Member class");
241 find directInstanceOf(problem,interpretation,element,type);
242}
243private pattern scopeDisallowsNewMember_class(problem:LogicProblem, interpretation:PartialInterpretation) {
244 find interpretation(problem,interpretation);
245 PartialInterpretation.scopes(interpretation,scope);
246 Scope.targetTypeInterpretation(scope,typeInterpretation);
247 Scope.maxNewElements(scope,0);
248 PartialComplexTypeInterpretation.interpretationOf(typeInterpretation,type);
249 Type.name(type,"Member class");
250}
251
252/**
253 * An element may be an instance of type "Member class".
254 */
255private pattern mayInstanceOfMember_class(problem:LogicProblem, interpretation:PartialInterpretation, element:DefinedElement)
256{
257 find interpretation(problem,interpretation);
258 PartialInterpretation.newElements(interpretation,element);
259 neg find mustInstanceOfFamilyTree_class(problem,interpretation,element);
260 neg find scopeDisallowsNewMember_class(problem, interpretation);
261 neg find isPrimitive(element);
262} or {
263 find interpretation(problem,interpretation);
264 PartialInterpretation.openWorldElements(interpretation,element);
265 neg find mustInstanceOfFamilyTree_class(problem,interpretation,element);
266 neg find scopeDisallowsNewMember_class(problem, interpretation);
267 neg find isPrimitive(element);
268} or
269{ find mustInstanceOfMember_class(problem,interpretation,element); }
270
271//////////
272// 1.2 Relation Declaration Indexers
273//////////
274/**
275 * Matcher for detecting tuples t where []members reference FamilyTree(source,target)
276 */
277private pattern mustInRelationmembers_reference_FamilyTree(
278 problem:LogicProblem, interpretation:PartialInterpretation,
279 source: DefinedElement, target:DefinedElement)
280{
281 find interpretation(problem,interpretation);
282 PartialInterpretation.partialrelationinterpretation(interpretation,relationIterpretation);
283 PartialRelationInterpretation.interpretationOf.name(relationIterpretation,"members reference FamilyTree");
284 PartialRelationInterpretation.relationlinks(relationIterpretation,link);
285 BinaryElementRelationLink.param1(link,source);
286 BinaryElementRelationLink.param2(link,target);
287}
288/**
289 * Matcher for detecting tuples t where <>members reference FamilyTree(source,target)
290 */
291private pattern mayInRelationmembers_reference_FamilyTree(
292 problem:LogicProblem, interpretation:PartialInterpretation,
293 source: DefinedElement, target:DefinedElement)
294{
295 find interpretation(problem,interpretation);
296 // The two endpoint of the link have to exist
297 find mayExist(problem, interpretation, source);
298 find mayExist(problem, interpretation, target);
299 // Type consistency
300 find mayInstanceOfFamilyTree_class(problem,interpretation,source);
301 find mayInstanceOfMember_class(problem,interpretation,target);
302 // The reference is containment, then a new reference cannot be create if:
303 // 1. Multiple parents
304 neg find mustContains4(problem,interpretation,_,target);
305 // 2. Circle in the containment hierarchy
306 neg find mustTransitiveContains(source,target);
307} or {
308 find mustInRelationmembers_reference_FamilyTree(problem,interpretation,source,target);
309}
310/**
311 * Matcher for detecting tuples t where []children reference Member(source,target)
312 */
313private pattern mustInRelationchildren_reference_Member(
314 problem:LogicProblem, interpretation:PartialInterpretation,
315 source: DefinedElement, target:DefinedElement)
316{
317 find interpretation(problem,interpretation);
318 PartialInterpretation.partialrelationinterpretation(interpretation,relationIterpretation);
319 PartialRelationInterpretation.interpretationOf.name(relationIterpretation,"children reference Member");
320 PartialRelationInterpretation.relationlinks(relationIterpretation,link);
321 BinaryElementRelationLink.param1(link,source);
322 BinaryElementRelationLink.param2(link,target);
323}
324/**
325 * Matcher for detecting tuples t where <>children reference Member(source,target)
326 */
327private pattern mayInRelationchildren_reference_Member(
328 problem:LogicProblem, interpretation:PartialInterpretation,
329 source: DefinedElement, target:DefinedElement)
330{
331 find interpretation(problem,interpretation);
332 // The two endpoint of the link have to exist
333 find mayExist(problem, interpretation, source);
334 find mayExist(problem, interpretation, target);
335 // Type consistency
336 find mayInstanceOfMember_class(problem,interpretation,source);
337 find mayInstanceOfMember_class(problem,interpretation,target);
338 // There are "numberOfExistingReferences" currently existing instances of the reference to the target,
339 // the upper bound of the opposite reference multiplicity should be considered.
340 numberOfExistingOppositeReferences == count find mustInRelationparents_reference_Member(problem,interpretation,target,_);
341 check(numberOfExistingOppositeReferences < 2);
342} or {
343 find mustInRelationchildren_reference_Member(problem,interpretation,source,target);
344}
345/**
346 * Matcher for detecting tuples t where []parents reference Member(source,target)
347 */
348private pattern mustInRelationparents_reference_Member(
349 problem:LogicProblem, interpretation:PartialInterpretation,
350 source: DefinedElement, target:DefinedElement)
351{
352 find interpretation(problem,interpretation);
353 PartialInterpretation.partialrelationinterpretation(interpretation,relationIterpretation);
354 PartialRelationInterpretation.interpretationOf.name(relationIterpretation,"parents reference Member");
355 PartialRelationInterpretation.relationlinks(relationIterpretation,link);
356 BinaryElementRelationLink.param1(link,source);
357 BinaryElementRelationLink.param2(link,target);
358}
359/**
360 * Matcher for detecting tuples t where <>parents reference Member(source,target)
361 */
362private pattern mayInRelationparents_reference_Member(
363 problem:LogicProblem, interpretation:PartialInterpretation,
364 source: DefinedElement, target:DefinedElement)
365{
366 find interpretation(problem,interpretation);
367 // The two endpoint of the link have to exist
368 find mayExist(problem, interpretation, source);
369 find mayExist(problem, interpretation, target);
370 // Type consistency
371 find mayInstanceOfMember_class(problem,interpretation,source);
372 find mayInstanceOfMember_class(problem,interpretation,target);
373 // There are "numberOfExistingReferences" currently existing instances of the reference from the source,
374 // the upper bound of the multiplicity should be considered.
375 numberOfExistingReferences == count find mustInRelationparents_reference_Member(problem,interpretation,source,_);
376 check(numberOfExistingReferences < 2);
377} or {
378 find mustInRelationparents_reference_Member(problem,interpretation,source,target);
379}
380/**
381 * Matcher for detecting tuples t where []name attribute Member(source,target)
382 */
383private pattern mustInRelationname_attribute_Member(
384 problem:LogicProblem, interpretation:PartialInterpretation,
385 source: DefinedElement, target:DefinedElement)
386{
387 find interpretation(problem,interpretation);
388 PartialInterpretation.partialrelationinterpretation(interpretation,relationIterpretation);
389 PartialRelationInterpretation.interpretationOf.name(relationIterpretation,"name attribute Member");
390 PartialRelationInterpretation.relationlinks(relationIterpretation,link);
391 BinaryElementRelationLink.param1(link,source);
392 BinaryElementRelationLink.param2(link,target);
393}
394/**
395 * Matcher for detecting tuples t where <>name attribute Member(source,target)
396 */
397private pattern mayInRelationname_attribute_Member(
398 problem:LogicProblem, interpretation:PartialInterpretation,
399 source: DefinedElement, target:DefinedElement)
400{
401 find interpretation(problem,interpretation);
402 // The two endpoint of the link have to exist
403 find mayExist(problem, interpretation, source);
404 find mayExist(problem, interpretation, target);
405 // Type consistency
406 find mayInstanceOfMember_class(problem,interpretation,source);
407 StringElement(target);
408 // There are "numberOfExistingReferences" currently existing instances of the reference from the source,
409 // the upper bound of the multiplicity should be considered.
410 numberOfExistingReferences == count find mustInRelationname_attribute_Member(problem,interpretation,source,_);
411 check(numberOfExistingReferences < 1);
412} or {
413 find mustInRelationname_attribute_Member(problem,interpretation,source,target);
414}
415/**
416 * Matcher for detecting tuples t where []age attribute Member(source,target)
417 */
418private pattern mustInRelationage_attribute_Member(
419 problem:LogicProblem, interpretation:PartialInterpretation,
420 source: DefinedElement, target:DefinedElement)
421{
422 find interpretation(problem,interpretation);
423 PartialInterpretation.partialrelationinterpretation(interpretation,relationIterpretation);
424 PartialRelationInterpretation.interpretationOf.name(relationIterpretation,"age attribute Member");
425 PartialRelationInterpretation.relationlinks(relationIterpretation,link);
426 BinaryElementRelationLink.param1(link,source);
427 BinaryElementRelationLink.param2(link,target);
428}
429/**
430 * Matcher for detecting tuples t where <>age attribute Member(source,target)
431 */
432private pattern mayInRelationage_attribute_Member(
433 problem:LogicProblem, interpretation:PartialInterpretation,
434 source: DefinedElement, target:DefinedElement)
435{
436 find interpretation(problem,interpretation);
437 // The two endpoint of the link have to exist
438 find mayExist(problem, interpretation, source);
439 find mayExist(problem, interpretation, target);
440 // Type consistency
441 find mayInstanceOfMember_class(problem,interpretation,source);
442 IntegerElement(target);
443 // There are "numberOfExistingReferences" currently existing instances of the reference from the source,
444 // the upper bound of the multiplicity should be considered.
445 numberOfExistingReferences == count find mustInRelationage_attribute_Member(problem,interpretation,source,_);
446 check(numberOfExistingReferences < 1);
447} or {
448 find mustInRelationage_attribute_Member(problem,interpretation,source,target);
449}
450
451//////////
452// 1.3 Relation Definition Indexers
453//////////
454// Must, May and Current queries for pattern queries memberIsItsOwnParent
455private pattern mustInRelation_pattern_queries_memberIsItsOwnParent(
456 problem:LogicProblem, interpretation:PartialInterpretation,
457 var_m)
458{
459 find interpretation(problem,interpretation);
460 find mustInstanceOfMember_class(problem,interpretation,var_m);
461 // m is exported
462 find mustInstanceOfFamilyTree_class(problem,interpretation,var__0);
463 find mustInRelationmembers_reference_FamilyTree(problem,interpretation,var__0,var_virtual0);
464 find mustInstanceOfMember_class(problem,interpretation,var_virtual0);
465 find mustEquivalent(problem, interpretation, var_virtual0, var_m);
466 find mustInstanceOfMember_class(problem,interpretation,var_m);
467 find mustInRelationparents_reference_Member(problem,interpretation,var_m,var_virtual1);
468 find mustInstanceOfMember_class(problem,interpretation,var_virtual1);
469 find mustEquivalent(problem, interpretation, var_virtual1, var_p);
470 find mustEquivalent(problem, interpretation, var_m, var_p);
471}
472private pattern mayInRelation_pattern_queries_memberIsItsOwnParent(
473 problem:LogicProblem, interpretation:PartialInterpretation,
474 var_m)
475{
476 find interpretation(problem,interpretation);
477 find mayInstanceOfMember_class(problem,interpretation,var_m);
478 // m is exported
479 find mayInstanceOfFamilyTree_class(problem,interpretation,var__0);
480 find mayInRelationmembers_reference_FamilyTree(problem,interpretation,var__0,var_virtual0);
481 find mayInstanceOfMember_class(problem,interpretation,var_virtual0);
482 find mayEquivalent(problem, interpretation, var_virtual0, var_m);
483 find mayInstanceOfMember_class(problem,interpretation,var_m);
484 find mayInRelationparents_reference_Member(problem,interpretation,var_m,var_virtual1);
485 find mayInstanceOfMember_class(problem,interpretation,var_virtual1);
486 find mayEquivalent(problem, interpretation, var_virtual1, var_p);
487 find mayEquivalent(problem, interpretation, var_m, var_p);
488}
489private pattern currentInRelation_pattern_queries_memberIsItsOwnParent(
490 problem:LogicProblem, interpretation:PartialInterpretation,
491 var_m)
492{
493 find interpretation(problem,interpretation);
494 find mustInstanceOfMember_class(problem,interpretation,var_m);
495 // m is exported
496 find mustInstanceOfFamilyTree_class(problem,interpretation,var__0);
497 find mustInRelationmembers_reference_FamilyTree(problem,interpretation,var__0,var_virtual0);
498 find mustInstanceOfMember_class(problem,interpretation,var_virtual0);
499 find mustEquivalent(problem, interpretation, var_virtual0, var_m);
500 find mustInstanceOfMember_class(problem,interpretation,var_m);
501 find mustInRelationparents_reference_Member(problem,interpretation,var_m,var_virtual1);
502 find mustInstanceOfMember_class(problem,interpretation,var_virtual1);
503 find mustEquivalent(problem, interpretation, var_virtual1, var_p);
504 find mustEquivalent(problem, interpretation, var_m, var_p);
505}
506
507//////////
508// 1.4 Containment Indexer
509//////////
510private pattern mustContains2(source: DefinedElement, target: DefinedElement) {
511 find mustContains4(_,_,source,target);
512}
513
514private pattern mustContains4(problem:LogicProblem, interpretation:PartialInterpretation,
515 source: DefinedElement, target: DefinedElement)
516 { find mustInRelationmembers_reference_FamilyTree(problem,interpretation,source,target); }
517
518private pattern mustTransitiveContains(source,target) {
519 find mustContains2+(source,target);
520}
521
522//////////
523// 2. Invalidation Indexers
524//////////
525// 2.1 Invalidated by WF Queries
526//////////
527pattern invalidatedBy_pattern_queries_memberIsItsOwnParent(problem:LogicProblem, interpretation:PartialInterpretation,
528 var_m)
529{
530 find mustInRelation_pattern_queries_memberIsItsOwnParent(problem,interpretation,var_m);
531}
532
533//////////
534// 3. Unfinishedness Indexers
535//////////
536// 3.1 Unfinishedness Measured by Multiplicity
537//////////
538
539//////////
540// 3.2 Unfinishedness Measured by WF Queries
541//////////
542pattern unfinishedBy_pattern_queries_memberIsItsOwnParent(problem:LogicProblem, interpretation:PartialInterpretation,
543 var_m)
544{
545 find currentInRelation_pattern_queries_memberIsItsOwnParent(problem,interpretation,var_m);
546}
547
548//////////
549// 4. Refinement Indexers
550//////////
551// 4.1 Object constructors
552//////////
553private pattern hasElementInContainment(problem:LogicProblem, interpretation:PartialInterpretation)
554{
555 find interpretation(problem,interpretation);
556 find mustInstanceOfFamilyTree_class(problem,interpretation,root);
557 find mustExist(problem, interpretation, root);
558}or{
559 find interpretation(problem,interpretation);
560 find mustInstanceOfMember_class(problem,interpretation,root);
561 find mustExist(problem, interpretation, root);
562}
563pattern createObject_FamilyTree_class(
564 problem:LogicProblem, interpretation:PartialInterpretation,
565 typeInterpretation:PartialComplexTypeInterpretation)
566{
567 find interpretation(problem,interpretation);
568 neg find hasElementInContainment(problem,interpretation);
569 PartialInterpretation.partialtypeinterpratation(interpretation,typeInterpretation);
570 PartialComplexTypeInterpretation.interpretationOf.name(typeInterpretation,"FamilyTree class");
571 find mayInstanceOfFamilyTree_class(problem,interpretation,newObject);
572 find mayExist(problem, interpretation, newObject);
573 neg find mustExist(problem, interpretation, newObject);
574}
575pattern createObject_Member_class_by_members_reference_FamilyTree(
576 problem:LogicProblem, interpretation:PartialInterpretation,
577 relationInterpretation:PartialRelationInterpretation, typeInterpretation:PartialComplexTypeInterpretation,
578 container:DefinedElement)
579{
580 find interpretation(problem,interpretation);
581 PartialInterpretation.partialtypeinterpratation(interpretation,typeInterpretation);
582 PartialComplexTypeInterpretation.interpretationOf.name(typeInterpretation,"Member class");
583 PartialInterpretation.partialrelationinterpretation(interpretation,relationInterpretation);
584 PartialRelationInterpretation.interpretationOf.name(relationInterpretation,"members reference FamilyTree");
585 find mustInstanceOfFamilyTree_class(problem,interpretation,container);
586 find mayInstanceOfMember_class(problem,interpretation,newObject);
587 find mayInRelationmembers_reference_FamilyTree(problem,interpretation,container,newObject);
588 find mustExist(problem, interpretation, container);
589 neg find mustExist(problem, interpretation, newObject);
590}
591pattern createObject_Member_class(
592 problem:LogicProblem, interpretation:PartialInterpretation,
593 typeInterpretation:PartialComplexTypeInterpretation)
594{
595 find interpretation(problem,interpretation);
596 neg find hasElementInContainment(problem,interpretation);
597 PartialInterpretation.partialtypeinterpratation(interpretation,typeInterpretation);
598 PartialComplexTypeInterpretation.interpretationOf.name(typeInterpretation,"Member class");
599 find mayInstanceOfMember_class(problem,interpretation,newObject);
600 find mayExist(problem, interpretation, newObject);
601 neg find mustExist(problem, interpretation, newObject);
602}
603
604//////////
605// 4.2 Type refinement
606//////////
607pattern refineTypeTo_FamilyTree_class(problem:LogicProblem, interpretation:PartialInterpretation, element: DefinedElement) {
608 find interpretation(problem,interpretation);
609 PartialInterpretation.newElements(interpretation,element);
610 find mayInstanceOfFamilyTree_class(problem,interpretation,element);
611 neg find mustInstanceOfFamilyTree_class(problem,interpretation,element);
612 neg find mustInstanceOfMember_class(problem,interpretation,element);
613}
614pattern refineTypeTo_Member_class(problem:LogicProblem, interpretation:PartialInterpretation, element: DefinedElement) {
615 find interpretation(problem,interpretation);
616 PartialInterpretation.newElements(interpretation,element);
617 find mayInstanceOfMember_class(problem,interpretation,element);
618 neg find mustInstanceOfFamilyTree_class(problem,interpretation,element);
619 neg find mustInstanceOfMember_class(problem,interpretation,element);
620}
621
622//////////
623// 4.3 Relation refinement
624//////////
625pattern refineRelation_children_reference_Member_and_parents_reference_Member(
626 problem:LogicProblem, interpretation:PartialInterpretation,
627 relationIterpretation:PartialRelationInterpretation, oppositeInterpretation:PartialRelationInterpretation,
628 from: DefinedElement, to: DefinedElement)
629{
630 find interpretation(problem,interpretation);
631 PartialInterpretation.partialrelationinterpretation(interpretation,relationIterpretation);
632 PartialRelationInterpretation.interpretationOf.name(relationIterpretation,"children reference Member");
633 PartialInterpretation.partialrelationinterpretation(interpretation,oppositeInterpretation);
634 PartialRelationInterpretation.interpretationOf.name(oppositeInterpretation,"parents reference Member");
635 find mustExist(problem, interpretation, from);
636 find mustExist(problem, interpretation, to);
637 find mustInstanceOfMember_class(problem,interpretation,from);
638 find mustInstanceOfMember_class(problem,interpretation,to);
639 find mayInRelationchildren_reference_Member(problem,interpretation,from,to);
640 neg find mustInRelationchildren_reference_Member(problem,interpretation,from,to);
641}
642pattern refineRelation_name_attribute_Member(
643 problem:LogicProblem, interpretation:PartialInterpretation,
644 relationIterpretation:PartialRelationInterpretation,
645 from: DefinedElement, to: DefinedElement)
646{
647 find interpretation(problem,interpretation);
648 PartialInterpretation.partialrelationinterpretation(interpretation,relationIterpretation);
649 PartialRelationInterpretation.interpretationOf.name(relationIterpretation,"name attribute Member");
650 find mustExist(problem, interpretation, from);
651 find mustExist(problem, interpretation, to);
652 find mustInstanceOfMember_class(problem,interpretation,from);
653 StringElement(to);
654 find mayInRelationname_attribute_Member(problem,interpretation,from,to);
655 neg find mustInRelationname_attribute_Member(problem,interpretation,from,to);
656}
657pattern refineRelation_age_attribute_Member(
658 problem:LogicProblem, interpretation:PartialInterpretation,
659 relationIterpretation:PartialRelationInterpretation,
660 from: DefinedElement, to: DefinedElement)
661{
662 find interpretation(problem,interpretation);
663 PartialInterpretation.partialrelationinterpretation(interpretation,relationIterpretation);
664 PartialRelationInterpretation.interpretationOf.name(relationIterpretation,"age attribute Member");
665 find mustExist(problem, interpretation, from);
666 find mustExist(problem, interpretation, to);
667 find mustInstanceOfMember_class(problem,interpretation,from);
668 IntegerElement(to);
669 find mayInRelationage_attribute_Member(problem,interpretation,from,to);
670 neg find mustInRelationage_attribute_Member(problem,interpretation,from,to);
671}
672
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/generation.logicproblem b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/generation.logicproblem
new file mode 100644
index 00000000..dd3b15b1
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/generation.logicproblem
@@ -0,0 +1,190 @@
1<?xml version="1.0" encoding="ASCII"?>
2<language:LogicProblem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore2logicannotations="http://www.bme.hu/mit/inf/dslreasoner/logic/model/language/ecore2logicannotation" xmlns:language="http://www.bme.hu/mit/inf/dslreasoner/logic/model/problem" xmlns:language_1="http://www.bme.hu/mit/inf/dslreasoner/logic/model/language" xmlns:viatra2logicannotations="http://www.bme.hu/mit/inf/dslreasoner/logic/model/language/viatra2logicannotation">
3 <types xsi:type="language_1:TypeDeclaration" name="FamilyTree class"/>
4 <types xsi:type="language_1:TypeDeclaration" name="Member class"/>
5 <assertions name="upperMultiplicity parents Member" annotations="//@annotations.0">
6 <value xsi:type="language_1:Forall">
7 <quantifiedVariables name="src">
8 <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
9 </quantifiedVariables>
10 <quantifiedVariables name="trg 1">
11 <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
12 </quantifiedVariables>
13 <quantifiedVariables name="trg 2">
14 <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
15 </quantifiedVariables>
16 <quantifiedVariables name="trg 3">
17 <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
18 </quantifiedVariables>
19 <expression xsi:type="language_1:Impl">
20 <leftOperand xsi:type="language_1:And">
21 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2">
22 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.0"/>
23 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.1"/>
24 </operands>
25 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2">
26 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.0"/>
27 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.2"/>
28 </operands>
29 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2">
30 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.0"/>
31 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.3"/>
32 </operands>
33 </leftOperand>
34 <rightOperand xsi:type="language_1:Not">
35 <operand xsi:type="language_1:Distinct">
36 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.1"/>
37 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.2"/>
38 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.0/@value/@quantifiedVariables.3"/>
39 </operand>
40 </rightOperand>
41 </expression>
42 </value>
43 </assertions>
44 <assertions name="oppositeReference children Member" annotations="//@annotations.1">
45 <value xsi:type="language_1:Forall">
46 <quantifiedVariables name="src">
47 <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
48 </quantifiedVariables>
49 <quantifiedVariables name="trg">
50 <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
51 </quantifiedVariables>
52 <expression xsi:type="language_1:Iff">
53 <leftOperand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.1">
54 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.1/@value/@quantifiedVariables.0"/>
55 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.1/@value/@quantifiedVariables.1"/>
56 </leftOperand>
57 <rightOperand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2">
58 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.1/@value/@quantifiedVariables.1"/>
59 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.1/@value/@quantifiedVariables.0"/>
60 </rightOperand>
61 </expression>
62 </value>
63 </assertions>
64 <assertions name="upperMultiplicity name Member" annotations="//@annotations.2">
65 <value xsi:type="language_1:Forall">
66 <quantifiedVariables name="src">
67 <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
68 </quantifiedVariables>
69 <quantifiedVariables name="trg 1">
70 <range xsi:type="language_1:StringTypeReference"/>
71 </quantifiedVariables>
72 <quantifiedVariables name="trg 2">
73 <range xsi:type="language_1:StringTypeReference"/>
74 </quantifiedVariables>
75 <expression xsi:type="language_1:Impl">
76 <leftOperand xsi:type="language_1:And">
77 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.3">
78 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.0"/>
79 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.1"/>
80 </operands>
81 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.3">
82 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.0"/>
83 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.2"/>
84 </operands>
85 </leftOperand>
86 <rightOperand xsi:type="language_1:Not">
87 <operand xsi:type="language_1:Distinct">
88 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.1"/>
89 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.2/@value/@quantifiedVariables.2"/>
90 </operand>
91 </rightOperand>
92 </expression>
93 </value>
94 </assertions>
95 <assertions name="upperMultiplicity age Member" annotations="//@annotations.3">
96 <value xsi:type="language_1:Forall">
97 <quantifiedVariables name="src">
98 <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
99 </quantifiedVariables>
100 <quantifiedVariables name="trg 1">
101 <range xsi:type="language_1:IntTypeReference"/>
102 </quantifiedVariables>
103 <quantifiedVariables name="trg 2">
104 <range xsi:type="language_1:IntTypeReference"/>
105 </quantifiedVariables>
106 <expression xsi:type="language_1:Impl">
107 <leftOperand xsi:type="language_1:And">
108 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.4">
109 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.0"/>
110 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.1"/>
111 </operands>
112 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.4">
113 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.0"/>
114 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.2"/>
115 </operands>
116 </leftOperand>
117 <rightOperand xsi:type="language_1:Not">
118 <operand xsi:type="language_1:Distinct">
119 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.1"/>
120 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.3/@value/@quantifiedVariables.2"/>
121 </operand>
122 </rightOperand>
123 </expression>
124 </value>
125 </assertions>
126 <assertions name="errorpattern queries memberIsItsOwnParent" annotations="//@annotations.5">
127 <value xsi:type="language_1:Forall">
128 <quantifiedVariables name="p0">
129 <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
130 </quantifiedVariables>
131 <expression xsi:type="language_1:Not">
132 <operand xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.5">
133 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@assertions.4/@value/@quantifiedVariables.0"/>
134 </operand>
135 </expression>
136 </value>
137 </assertions>
138 <relations xsi:type="language_1:RelationDeclaration" name="members reference FamilyTree">
139 <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.0"/>
140 <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
141 </relations>
142 <relations xsi:type="language_1:RelationDeclaration" name="children reference Member">
143 <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
144 <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
145 </relations>
146 <relations xsi:type="language_1:RelationDeclaration" name="parents reference Member">
147 <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
148 <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
149 </relations>
150 <relations xsi:type="language_1:RelationDeclaration" name="name attribute Member">
151 <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
152 <parameters xsi:type="language_1:StringTypeReference"/>
153 </relations>
154 <relations xsi:type="language_1:RelationDeclaration" name="age attribute Member">
155 <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
156 <parameters xsi:type="language_1:IntTypeReference"/>
157 </relations>
158 <relations xsi:type="language_1:RelationDefinition" name="pattern queries memberIsItsOwnParent" annotations="//@annotations.4">
159 <parameters xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
160 <variables name="parameter m">
161 <range xsi:type="language_1:ComplexTypeReference" referred="//@types.1"/>
162 </variables>
163 <value xsi:type="language_1:Or">
164 <operands xsi:type="language_1:Exists">
165 <quantifiedVariables name="variable 0">
166 <range xsi:type="language_1:ComplexTypeReference" referred="//@types.0"/>
167 </quantifiedVariables>
168 <expression xsi:type="language_1:And">
169 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.0">
170 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.5/@value/@operands.0/@quantifiedVariables.0"/>
171 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.5/@variables.0"/>
172 </operands>
173 <operands xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.2">
174 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.5/@variables.0"/>
175 <parameterSubstitutions xsi:type="language_1:SymbolicValue" symbolicReference="//@relations.5/@variables.0"/>
176 </operands>
177 </expression>
178 </operands>
179 </value>
180 </relations>
181 <containmentHierarchies typesOrderedInHierarchy="//@types.0 //@types.1" containmentRelations="//@relations.0"/>
182 <annotations xsi:type="ecore2logicannotations:UpperMultiplicityAssertion" target="//@assertions.0" relation="//@relations.2" upper="2"/>
183 <annotations xsi:type="ecore2logicannotations:InverseRelationAssertion" target="//@assertions.1" inverseA="//@relations.1" inverseB="//@relations.2"/>
184 <annotations xsi:type="ecore2logicannotations:UpperMultiplicityAssertion" target="//@assertions.2" relation="//@relations.3" upper="1"/>
185 <annotations xsi:type="ecore2logicannotations:UpperMultiplicityAssertion" target="//@assertions.3" relation="//@relations.4" upper="1"/>
186 <annotations xsi:type="viatra2logicannotations:TransfomedViatraQuery" target="//@relations.5" patternFullyQualifiedName="queries.memberIsItsOwnParent">
187 <variableTrace targetLogicVariable="//@relations.5/@value/@operands.0/@quantifiedVariables.0"/>
188 </annotations>
189 <annotations xsi:type="viatra2logicannotations:TransformedViatraWellformednessConstraint" target="//@assertions.4" query="//@annotations.4"/>
190</language:LogicProblem>
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/init.partialmodel b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/init.partialmodel
new file mode 100644
index 00000000..949d6b64
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/debug/init.partialmodel
@@ -0,0 +1,51 @@
1<?xml version="1.0" encoding="ASCII"?>
2<partialinterpretation:PartialInterpretation xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:language="http://www.bme.hu/mit/inf/dslreasoner/logic/model/language" xmlns:partialinterpretation="http://www.bme.hu/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage" minNewElements="6" maxNewElements="6">
3 <problem href="outputs/debug/generation.logicproblem#/"/>
4 <partialrelationinterpretation>
5 <interpretationOf href="outputs/debug/generation.logicproblem#//@relations.0"/>
6 <param1 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.0/@parameters.0"/>
7 <param2 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.0/@parameters.1"/>
8 </partialrelationinterpretation>
9 <partialrelationinterpretation>
10 <interpretationOf href="outputs/debug/generation.logicproblem#//@relations.1"/>
11 <param1 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.1/@parameters.0"/>
12 <param2 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.1/@parameters.1"/>
13 </partialrelationinterpretation>
14 <partialrelationinterpretation>
15 <interpretationOf href="outputs/debug/generation.logicproblem#//@relations.2"/>
16 <param1 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.2/@parameters.0"/>
17 <param2 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.2/@parameters.1"/>
18 </partialrelationinterpretation>
19 <partialrelationinterpretation>
20 <interpretationOf href="outputs/debug/generation.logicproblem#//@relations.3"/>
21 <param1 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.3/@parameters.0"/>
22 <param2 xsi:type="language:StringTypeReference" href="outputs/debug/generation.logicproblem#//@relations.3/@parameters.1"/>
23 </partialrelationinterpretation>
24 <partialrelationinterpretation>
25 <interpretationOf href="outputs/debug/generation.logicproblem#//@relations.4"/>
26 <param1 xsi:type="language:ComplexTypeReference" href="outputs/debug/generation.logicproblem#//@relations.4/@parameters.0"/>
27 <param2 xsi:type="language:IntTypeReference" href="outputs/debug/generation.logicproblem#//@relations.4/@parameters.1"/>
28 </partialrelationinterpretation>
29 <newElements xsi:type="partialinterpretation:BooleanElement" name="true" valueSet="true" value="true"/>
30 <newElements xsi:type="partialinterpretation:BooleanElement" name="false" valueSet="true"/>
31 <newElements xsi:type="partialinterpretation:IntegerElement" name="1" valueSet="true" value="1"/>
32 <newElements xsi:type="partialinterpretation:IntegerElement" name="2" valueSet="true" value="2"/>
33 <newElements xsi:type="partialinterpretation:IntegerElement" name="3" valueSet="true" value="3"/>
34 <newElements xsi:type="partialinterpretation:IntegerElement" name="4" valueSet="true" value="4"/>
35 <newElements xsi:type="partialinterpretation:IntegerElement" name="5" valueSet="true" value="5"/>
36 <partialtypeinterpratation xsi:type="partialinterpretation:PartialBooleanInterpretation" elements="//@newElements.0 //@newElements.1"/>
37 <partialtypeinterpratation xsi:type="partialinterpretation:PartialIntegerInterpretation" elements="//@newElements.2 //@newElements.3 //@newElements.4 //@newElements.5 //@newElements.6"/>
38 <partialtypeinterpratation xsi:type="partialinterpretation:PartialRealInterpretation" elements="//@openWorldElements.0"/>
39 <partialtypeinterpratation xsi:type="partialinterpretation:PartialStringInterpretation" elements="//@openWorldElements.1"/>
40 <partialtypeinterpratation xsi:type="partialinterpretation:PartialComplexTypeInterpretation" scopes="//@scopes.0">
41 <interpretationOf href="outputs/debug/generation.logicproblem#//@types.0"/>
42 </partialtypeinterpratation>
43 <partialtypeinterpratation xsi:type="partialinterpretation:PartialComplexTypeInterpretation" scopes="//@scopes.1">
44 <interpretationOf href="outputs/debug/generation.logicproblem#//@types.1"/>
45 </partialtypeinterpratation>
46 <openWorldElements xsi:type="partialinterpretation:RealElement" name="New Reals"/>
47 <openWorldElements xsi:type="partialinterpretation:StringElement" name="New Strings"/>
48 <openWorldElements name="New Objects"/>
49 <scopes targetTypeInterpretation="//@partialtypeinterpratation.4"/>
50 <scopes targetTypeInterpretation="//@partialtypeinterpratation.5"/>
51</partialinterpretation:PartialInterpretation>
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/log.txt b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/log.txt
new file mode 100644
index 00000000..6186ec60
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/log.txt
@@ -0,0 +1 @@
Model generation finished
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/models/1.gml b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/models/1.gml
new file mode 100644
index 00000000..0182add9
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/models/1.gml
@@ -0,0 +1,1011 @@
1graph
2[
3 node
4 [
5 id 0
6 graphics
7 [
8 w 41.800000000000004
9 h 26
10 type "rectangle"
11 fill "#FFFFFF"
12 fill2 "#FFFFFF"
13 outline "#000000"
14 ]
15 LabelGraphics
16 [
17 text "true"
18 outline "#000000"
19 fill "#FFFFFF"
20 fontSize 16
21 fontName "Monospace"
22 autoSizePolicy "node_width"
23 anchor "t"
24 borderDistance 0.0
25 ]
26 LabelGraphics
27 [
28 text "
29 "
30 fontSize 14
31 fontName "Consolas"
32 alignment "left"
33 anchor "tl"
34 borderDistance 6
35 ]
36 ]
37
38 node
39 [
40 id 1
41 graphics
42 [
43 w 50.6
44 h 26
45 type "rectangle"
46 fill "#FFFFFF"
47 fill2 "#FFFFFF"
48 outline "#000000"
49 ]
50 LabelGraphics
51 [
52 text "false"
53 outline "#000000"
54 fill "#FFFFFF"
55 fontSize 16
56 fontName "Monospace"
57 autoSizePolicy "node_width"
58 anchor "t"
59 borderDistance 0.0
60 ]
61 LabelGraphics
62 [
63 text "
64 "
65 fontSize 14
66 fontName "Consolas"
67 alignment "left"
68 anchor "tl"
69 borderDistance 6
70 ]
71 ]
72
73 node
74 [
75 id 2
76 graphics
77 [
78 w 15.400000000000002
79 h 26
80 type "rectangle"
81 fill "#FFFFFF"
82 fill2 "#FFFFFF"
83 outline "#000000"
84 ]
85 LabelGraphics
86 [
87 text "1"
88 outline "#000000"
89 fill "#FFFFFF"
90 fontSize 16
91 fontName "Monospace"
92 autoSizePolicy "node_width"
93 anchor "t"
94 borderDistance 0.0
95 ]
96 LabelGraphics
97 [
98 text "
99 "
100 fontSize 14
101 fontName "Consolas"
102 alignment "left"
103 anchor "tl"
104 borderDistance 6
105 ]
106 ]
107
108 node
109 [
110 id 3
111 graphics
112 [
113 w 15.400000000000002
114 h 26
115 type "rectangle"
116 fill "#FFFFFF"
117 fill2 "#FFFFFF"
118 outline "#000000"
119 ]
120 LabelGraphics
121 [
122 text "2"
123 outline "#000000"
124 fill "#FFFFFF"
125 fontSize 16
126 fontName "Monospace"
127 autoSizePolicy "node_width"
128 anchor "t"
129 borderDistance 0.0
130 ]
131 LabelGraphics
132 [
133 text "
134 "
135 fontSize 14
136 fontName "Consolas"
137 alignment "left"
138 anchor "tl"
139 borderDistance 6
140 ]
141 ]
142
143 node
144 [
145 id 4
146 graphics
147 [
148 w 15.400000000000002
149 h 26
150 type "rectangle"
151 fill "#FFFFFF"
152 fill2 "#FFFFFF"
153 outline "#000000"
154 ]
155 LabelGraphics
156 [
157 text "3"
158 outline "#000000"
159 fill "#FFFFFF"
160 fontSize 16
161 fontName "Monospace"
162 autoSizePolicy "node_width"
163 anchor "t"
164 borderDistance 0.0
165 ]
166 LabelGraphics
167 [
168 text "
169 "
170 fontSize 14
171 fontName "Consolas"
172 alignment "left"
173 anchor "tl"
174 borderDistance 6
175 ]
176 ]
177
178 node
179 [
180 id 5
181 graphics
182 [
183 w 15.400000000000002
184 h 26
185 type "rectangle"
186 fill "#FFFFFF"
187 fill2 "#FFFFFF"
188 outline "#000000"
189 ]
190 LabelGraphics
191 [
192 text "4"
193 outline "#000000"
194 fill "#FFFFFF"
195 fontSize 16
196 fontName "Monospace"
197 autoSizePolicy "node_width"
198 anchor "t"
199 borderDistance 0.0
200 ]
201 LabelGraphics
202 [
203 text "
204 "
205 fontSize 14
206 fontName "Consolas"
207 alignment "left"
208 anchor "tl"
209 borderDistance 6
210 ]
211 ]
212
213 node
214 [
215 id 6
216 graphics
217 [
218 w 15.400000000000002
219 h 26
220 type "rectangle"
221 fill "#FFFFFF"
222 fill2 "#FFFFFF"
223 outline "#000000"
224 ]
225 LabelGraphics
226 [
227 text "5"
228 outline "#000000"
229 fill "#FFFFFF"
230 fontSize 16
231 fontName "Monospace"
232 autoSizePolicy "node_width"
233 anchor "t"
234 borderDistance 0.0
235 ]
236 LabelGraphics
237 [
238 text "
239 "
240 fontSize 14
241 fontName "Consolas"
242 alignment "left"
243 anchor "tl"
244 borderDistance 6
245 ]
246 ]
247
248 node
249 [
250 id 7
251 graphics
252 [
253 w 138.60000000000002
254 h 40
255 type "rectangle"
256 fill "#FFFFFF"
257 fill2 "#FFFFFF"
258 outline "#000000"
259 ]
260 LabelGraphics
261 [
262 text "null"
263 outline "#000000"
264 fill "#FFFFFF"
265 fontSize 16
266 fontName "Monospace"
267 autoSizePolicy "node_width"
268 anchor "t"
269 borderDistance 0.0
270 ]
271 LabelGraphics
272 [
273 text "
274 FamilyTree class
275 "
276 fontSize 14
277 fontName "Consolas"
278 alignment "left"
279 anchor "tl"
280 borderDistance 6
281 ]
282 ]
283
284 node
285 [
286 id 8
287 graphics
288 [
289 w 107.80000000000001
290 h 40
291 type "rectangle"
292 fill "#FFFFFF"
293 fill2 "#FFFFFF"
294 outline "#000000"
295 ]
296 LabelGraphics
297 [
298 text "null"
299 outline "#000000"
300 fill "#FFFFFF"
301 fontSize 16
302 fontName "Monospace"
303 autoSizePolicy "node_width"
304 anchor "t"
305 borderDistance 0.0
306 ]
307 LabelGraphics
308 [
309 text "
310 Member class
311 "
312 fontSize 14
313 fontName "Consolas"
314 alignment "left"
315 anchor "tl"
316 borderDistance 6
317 ]
318 ]
319
320 node
321 [
322 id 9
323 graphics
324 [
325 w 107.80000000000001
326 h 40
327 type "rectangle"
328 fill "#FFFFFF"
329 fill2 "#FFFFFF"
330 outline "#000000"
331 ]
332 LabelGraphics
333 [
334 text "null"
335 outline "#000000"
336 fill "#FFFFFF"
337 fontSize 16
338 fontName "Monospace"
339 autoSizePolicy "node_width"
340 anchor "t"
341 borderDistance 0.0
342 ]
343 LabelGraphics
344 [
345 text "
346 Member class
347 "
348 fontSize 14
349 fontName "Consolas"
350 alignment "left"
351 anchor "tl"
352 borderDistance 6
353 ]
354 ]
355
356 node
357 [
358 id 10
359 graphics
360 [
361 w 107.80000000000001
362 h 40
363 type "rectangle"
364 fill "#FFFFFF"
365 fill2 "#FFFFFF"
366 outline "#000000"
367 ]
368 LabelGraphics
369 [
370 text "null"
371 outline "#000000"
372 fill "#FFFFFF"
373 fontSize 16
374 fontName "Monospace"
375 autoSizePolicy "node_width"
376 anchor "t"
377 borderDistance 0.0
378 ]
379 LabelGraphics
380 [
381 text "
382 Member class
383 "
384 fontSize 14
385 fontName "Consolas"
386 alignment "left"
387 anchor "tl"
388 borderDistance 6
389 ]
390 ]
391
392 node
393 [
394 id 11
395 graphics
396 [
397 w 107.80000000000001
398 h 40
399 type "rectangle"
400 fill "#FFFFFF"
401 fill2 "#FFFFFF"
402 outline "#000000"
403 ]
404 LabelGraphics
405 [
406 text "null"
407 outline "#000000"
408 fill "#FFFFFF"
409 fontSize 16
410 fontName "Monospace"
411 autoSizePolicy "node_width"
412 anchor "t"
413 borderDistance 0.0
414 ]
415 LabelGraphics
416 [
417 text "
418 Member class
419 "
420 fontSize 14
421 fontName "Consolas"
422 alignment "left"
423 anchor "tl"
424 borderDistance 6
425 ]
426 ]
427
428 node
429 [
430 id 12
431 graphics
432 [
433 w 107.80000000000001
434 h 40
435 type "rectangle"
436 fill "#FFFFFF"
437 fill2 "#FFFFFF"
438 outline "#000000"
439 ]
440 LabelGraphics
441 [
442 text "null"
443 outline "#000000"
444 fill "#FFFFFF"
445 fontSize 16
446 fontName "Monospace"
447 autoSizePolicy "node_width"
448 anchor "t"
449 borderDistance 0.0
450 ]
451 LabelGraphics
452 [
453 text "
454 Member class
455 "
456 fontSize 14
457 fontName "Consolas"
458 alignment "left"
459 anchor "tl"
460 borderDistance 6
461 ]
462 ]
463
464 node
465 [
466 id 13
467 graphics
468 [
469 w 85.80000000000001
470 h 26
471 type "rectangle"
472 fill "#FFFFFF"
473 fill2 "#FFFFFF"
474 outline "#000000"
475 ]
476 LabelGraphics
477 [
478 text "New Reals"
479 outline "#000000"
480 fill "#FFFFFF"
481 fontSize 16
482 fontName "Monospace"
483 autoSizePolicy "node_width"
484 anchor "t"
485 borderDistance 0.0
486 ]
487 LabelGraphics
488 [
489 text "
490 "
491 fontSize 14
492 fontName "Consolas"
493 alignment "left"
494 anchor "tl"
495 borderDistance 6
496 ]
497 ]
498
499 node
500 [
501 id 14
502 graphics
503 [
504 w 103.4
505 h 26
506 type "rectangle"
507 fill "#FFFFFF"
508 fill2 "#FFFFFF"
509 outline "#000000"
510 ]
511 LabelGraphics
512 [
513 text "New Strings"
514 outline "#000000"
515 fill "#FFFFFF"
516 fontSize 16
517 fontName "Monospace"
518 autoSizePolicy "node_width"
519 anchor "t"
520 borderDistance 0.0
521 ]
522 LabelGraphics
523 [
524 text "
525 "
526 fontSize 14
527 fontName "Consolas"
528 alignment "left"
529 anchor "tl"
530 borderDistance 6
531 ]
532 ]
533
534 node
535 [
536 id 15
537 graphics
538 [
539 w 103.4
540 h 26
541 type "rectangle"
542 fill "#FFFFFF"
543 fill2 "#FFFFFF"
544 outline "#000000"
545 ]
546 LabelGraphics
547 [
548 text "New Objects"
549 outline "#000000"
550 fill "#FFFFFF"
551 fontSize 16
552 fontName "Monospace"
553 autoSizePolicy "node_width"
554 anchor "t"
555 borderDistance 0.0
556 ]
557 LabelGraphics
558 [
559 text "
560 "
561 fontSize 14
562 fontName "Consolas"
563 alignment "left"
564 anchor "tl"
565 borderDistance 6
566 ]
567 ]
568 edge
569 [
570 source 7
571 target 8
572 graphics
573 [
574 fill "#000000"
575 width 3
576 targetArrow "standard"
577 ]
578 LabelGraphics
579 [
580 text "members reference FamilyTree"
581 fontSize 14
582 fontName "Consolas"
583 configuration "AutoFlippingLabel"
584 model "six_pos"
585 position "thead"
586 ]
587 ]
588 edge
589 [
590 source 7
591 target 9
592 graphics
593 [
594 fill "#000000"
595 width 3
596 targetArrow "standard"
597 ]
598 LabelGraphics
599 [
600 text "members reference FamilyTree"
601 fontSize 14
602 fontName "Consolas"
603 configuration "AutoFlippingLabel"
604 model "six_pos"
605 position "thead"
606 ]
607 ]
608 edge
609 [
610 source 7
611 target 10
612 graphics
613 [
614 fill "#000000"
615 width 3
616 targetArrow "standard"
617 ]
618 LabelGraphics
619 [
620 text "members reference FamilyTree"
621 fontSize 14
622 fontName "Consolas"
623 configuration "AutoFlippingLabel"
624 model "six_pos"
625 position "thead"
626 ]
627 ]
628 edge
629 [
630 source 7
631 target 11
632 graphics
633 [
634 fill "#000000"
635 width 3
636 targetArrow "standard"
637 ]
638 LabelGraphics
639 [
640 text "members reference FamilyTree"
641 fontSize 14
642 fontName "Consolas"
643 configuration "AutoFlippingLabel"
644 model "six_pos"
645 position "thead"
646 ]
647 ]
648 edge
649 [
650 source 7
651 target 12
652 graphics
653 [
654 fill "#000000"
655 width 3
656 targetArrow "standard"
657 ]
658 LabelGraphics
659 [
660 text "members reference FamilyTree"
661 fontSize 14
662 fontName "Consolas"
663 configuration "AutoFlippingLabel"
664 model "six_pos"
665 position "thead"
666 ]
667 ]
668 edge
669 [
670 source 9
671 target 8
672 graphics
673 [
674 fill "#000000"
675 targetArrow "standard"
676 ]
677 LabelGraphics
678 [
679 text "children reference Member"
680 fontSize 14
681 fontName "Consolas"
682 configuration "AutoFlippingLabel"
683 model "six_pos"
684 position "thead"
685 ]
686 ]
687 edge
688 [
689 source 8
690 target 9
691 graphics
692 [
693 fill "#000000"
694 targetArrow "standard"
695 ]
696 LabelGraphics
697 [
698 text "children reference Member"
699 fontSize 14
700 fontName "Consolas"
701 configuration "AutoFlippingLabel"
702 model "six_pos"
703 position "thead"
704 ]
705 ]
706 edge
707 [
708 source 10
709 target 11
710 graphics
711 [
712 fill "#000000"
713 targetArrow "standard"
714 ]
715 LabelGraphics
716 [
717 text "children reference Member"
718 fontSize 14
719 fontName "Consolas"
720 configuration "AutoFlippingLabel"
721 model "six_pos"
722 position "thead"
723 ]
724 ]
725 edge
726 [
727 source 8
728 target 10
729 graphics
730 [
731 fill "#000000"
732 targetArrow "standard"
733 ]
734 LabelGraphics
735 [
736 text "children reference Member"
737 fontSize 14
738 fontName "Consolas"
739 configuration "AutoFlippingLabel"
740 model "six_pos"
741 position "thead"
742 ]
743 ]
744 edge
745 [
746 source 11
747 target 9
748 graphics
749 [
750 fill "#000000"
751 targetArrow "standard"
752 ]
753 LabelGraphics
754 [
755 text "children reference Member"
756 fontSize 14
757 fontName "Consolas"
758 configuration "AutoFlippingLabel"
759 model "six_pos"
760 position "thead"
761 ]
762 ]
763 edge
764 [
765 source 11
766 target 10
767 graphics
768 [
769 fill "#000000"
770 targetArrow "standard"
771 ]
772 LabelGraphics
773 [
774 text "children reference Member"
775 fontSize 14
776 fontName "Consolas"
777 configuration "AutoFlippingLabel"
778 model "six_pos"
779 position "thead"
780 ]
781 ]
782 edge
783 [
784 source 10
785 target 8
786 graphics
787 [
788 fill "#000000"
789 targetArrow "standard"
790 ]
791 LabelGraphics
792 [
793 text "children reference Member"
794 fontSize 14
795 fontName "Consolas"
796 configuration "AutoFlippingLabel"
797 model "six_pos"
798 position "thead"
799 ]
800 ]
801 edge
802 [
803 source 8
804 target 9
805 graphics
806 [
807 fill "#000000"
808 targetArrow "standard"
809 ]
810 LabelGraphics
811 [
812 text "parents reference Member"
813 fontSize 14
814 fontName "Consolas"
815 configuration "AutoFlippingLabel"
816 model "six_pos"
817 position "thead"
818 ]
819 ]
820 edge
821 [
822 source 9
823 target 8
824 graphics
825 [
826 fill "#000000"
827 targetArrow "standard"
828 ]
829 LabelGraphics
830 [
831 text "parents reference Member"
832 fontSize 14
833 fontName "Consolas"
834 configuration "AutoFlippingLabel"
835 model "six_pos"
836 position "thead"
837 ]
838 ]
839 edge
840 [
841 source 11
842 target 10
843 graphics
844 [
845 fill "#000000"
846 targetArrow "standard"
847 ]
848 LabelGraphics
849 [
850 text "parents reference Member"
851 fontSize 14
852 fontName "Consolas"
853 configuration "AutoFlippingLabel"
854 model "six_pos"
855 position "thead"
856 ]
857 ]
858 edge
859 [
860 source 10
861 target 8
862 graphics
863 [
864 fill "#000000"
865 targetArrow "standard"
866 ]
867 LabelGraphics
868 [
869 text "parents reference Member"
870 fontSize 14
871 fontName "Consolas"
872 configuration "AutoFlippingLabel"
873 model "six_pos"
874 position "thead"
875 ]
876 ]
877 edge
878 [
879 source 9
880 target 11
881 graphics
882 [
883 fill "#000000"
884 targetArrow "standard"
885 ]
886 LabelGraphics
887 [
888 text "parents reference Member"
889 fontSize 14
890 fontName "Consolas"
891 configuration "AutoFlippingLabel"
892 model "six_pos"
893 position "thead"
894 ]
895 ]
896 edge
897 [
898 source 10
899 target 11
900 graphics
901 [
902 fill "#000000"
903 targetArrow "standard"
904 ]
905 LabelGraphics
906 [
907 text "parents reference Member"
908 fontSize 14
909 fontName "Consolas"
910 configuration "AutoFlippingLabel"
911 model "six_pos"
912 position "thead"
913 ]
914 ]
915 edge
916 [
917 source 8
918 target 10
919 graphics
920 [
921 fill "#000000"
922 targetArrow "standard"
923 ]
924 LabelGraphics
925 [
926 text "parents reference Member"
927 fontSize 14
928 fontName "Consolas"
929 configuration "AutoFlippingLabel"
930 model "six_pos"
931 position "thead"
932 ]
933 ]
934 edge
935 [
936 source 8
937 target 6
938 graphics
939 [
940 fill "#000000"
941 targetArrow "standard"
942 ]
943 LabelGraphics
944 [
945 text "age attribute Member"
946 fontSize 14
947 fontName "Consolas"
948 configuration "AutoFlippingLabel"
949 model "six_pos"
950 position "thead"
951 ]
952 ]
953 edge
954 [
955 source 9
956 target 5
957 graphics
958 [
959 fill "#000000"
960 targetArrow "standard"
961 ]
962 LabelGraphics
963 [
964 text "age attribute Member"
965 fontSize 14
966 fontName "Consolas"
967 configuration "AutoFlippingLabel"
968 model "six_pos"
969 position "thead"
970 ]
971 ]
972 edge
973 [
974 source 10
975 target 2
976 graphics
977 [
978 fill "#000000"
979 targetArrow "standard"
980 ]
981 LabelGraphics
982 [
983 text "age attribute Member"
984 fontSize 14
985 fontName "Consolas"
986 configuration "AutoFlippingLabel"
987 model "six_pos"
988 position "thead"
989 ]
990 ]
991 edge
992 [
993 source 11
994 target 4
995 graphics
996 [
997 fill "#000000"
998 targetArrow "standard"
999 ]
1000 LabelGraphics
1001 [
1002 text "age attribute Member"
1003 fontSize 14
1004 fontName "Consolas"
1005 configuration "AutoFlippingLabel"
1006 model "six_pos"
1007 position "thead"
1008 ]
1009 ]
1010]
1011
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/models/1.png b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/models/1.png
new file mode 100644
index 00000000..391d902b
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/models/1.png
Binary files differ
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/models/1.xmi b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/models/1.xmi
new file mode 100644
index 00000000..11e0e7c3
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/outputs/models/1.xmi
@@ -0,0 +1,8 @@
1<?xml version="1.0" encoding="ASCII"?>
2<familytree:FamilyTree xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:familytree="http://www.example.org/familytree" xsi:schemaLocation="http://www.example.org/familytree inputs/familytree.ecore">
3 <members age="4" children="//@members.4" parents="//@members.3 //@members.4"/>
4 <members/>
5 <members age="1" children="//@members.3 //@members.4" parents="//@members.3 //@members.4"/>
6 <members age="3" children="//@members.0 //@members.2" parents="//@members.2"/>
7 <members age="5" children="//@members.0 //@members.2" parents="//@members.0 //@members.2"/>
8</familytree:FamilyTree>
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/plugin.xml b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/plugin.xml
new file mode 100644
index 00000000..b32b0215
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/plugin.xml
@@ -0,0 +1,7 @@
1<?xml version="1.0" encoding="UTF-8"?><plugin>
2 <extension id="queries.FamilyTreeConstraints" point="org.eclipse.viatra.query.runtime.queryspecification">
3 <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:queries.FamilyTreeConstraints" id="queries.FamilyTreeConstraints">
4 <query-specification fqn="queries.memberIsItsOwnParent"/>
5 </group>
6 </extension>
7</plugin>
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.FamilyTreeConstraints.java._trace b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.FamilyTreeConstraints.java._trace
new file mode 100644
index 00000000..80158bd8
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.FamilyTreeConstraints.java._trace
Binary files differ
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.MemberIsItsOwnParent.java._trace b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.MemberIsItsOwnParent.java._trace
new file mode 100644
index 00000000..1b0dca98
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/.MemberIsItsOwnParent.java._trace
Binary files differ
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/FamilyTreeConstraints.java b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/FamilyTreeConstraints.java
new file mode 100644
index 00000000..a5c375c6
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/FamilyTreeConstraints.java
@@ -0,0 +1,53 @@
1/**
2 * Generated from platform:/resource/case.study.familyTree.run/src/queries/familyTreeConstraints.vql
3 */
4package queries;
5
6import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
7import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
8import queries.MemberIsItsOwnParent;
9
10/**
11 * A pattern group formed of all public patterns defined in familyTreeConstraints.vql.
12 *
13 * <p>Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare
14 * a VIATRA Query engine for matching all patterns originally defined in file familyTreeConstraints.vql,
15 * in order to achieve better performance than one-by-one on-demand matcher initialization.
16 *
17 * <p> From package queries, the group contains the definition of the following patterns: <ul>
18 * <li>memberIsItsOwnParent</li>
19 * </ul>
20 *
21 * @see IQueryGroup
22 *
23 */
24@SuppressWarnings("all")
25public final class FamilyTreeConstraints extends BaseGeneratedPatternGroup {
26 /**
27 * Access the pattern group.
28 *
29 * @return the singleton instance of the group
30 * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications
31 *
32 */
33 public static FamilyTreeConstraints instance() {
34 if (INSTANCE == null) {
35 INSTANCE = new FamilyTreeConstraints();
36 }
37 return INSTANCE;
38 }
39
40 private static FamilyTreeConstraints INSTANCE;
41
42 private FamilyTreeConstraints() {
43 querySpecifications.add(MemberIsItsOwnParent.instance());
44 }
45
46 public MemberIsItsOwnParent getMemberIsItsOwnParent() {
47 return MemberIsItsOwnParent.instance();
48 }
49
50 public MemberIsItsOwnParent.Matcher getMemberIsItsOwnParent(final ViatraQueryEngine engine) {
51 return MemberIsItsOwnParent.Matcher.on(engine);
52 }
53}
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/MemberIsItsOwnParent.java b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/MemberIsItsOwnParent.java
new file mode 100644
index 00000000..67cdafb5
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src-gen/queries/MemberIsItsOwnParent.java
@@ -0,0 +1,577 @@
1/**
2 * Generated from platform:/resource/case.study.familyTree.run/src/queries/familyTreeConstraints.vql
3 */
4package queries;
5
6import familytree.Member;
7import java.util.Arrays;
8import java.util.Collection;
9import java.util.LinkedHashSet;
10import java.util.List;
11import java.util.Objects;
12import java.util.Optional;
13import java.util.Set;
14import java.util.function.Consumer;
15import java.util.stream.Collectors;
16import java.util.stream.Stream;
17import org.apache.log4j.Logger;
18import org.eclipse.emf.ecore.EClass;
19import org.eclipse.viatra.query.runtime.api.IPatternMatch;
20import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
21import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
22import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
24import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
25import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
26import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
27import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
28import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
29import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
30import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
31import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
32import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
36import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
37import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
38import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
39import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
40import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
41import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
42
43/**
44 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
45 *
46 * <p>Original source:
47 * <code><pre>
48 * {@literal @}Constraint(message="memberIsItsOwnParent", severity="error", key={m})
49 * pattern memberIsItsOwnParent(m: Member) = {
50 * FamilyTree.members(_, m);
51 * Member.parents(m, p);
52 * m == p;
53 * }
54 * </pre></code>
55 *
56 * @see Matcher
57 * @see Match
58 *
59 */
60@SuppressWarnings("all")
61public final class MemberIsItsOwnParent extends BaseGeneratedEMFQuerySpecification<MemberIsItsOwnParent.Matcher> {
62 /**
63 * Pattern-specific match representation of the queries.memberIsItsOwnParent pattern,
64 * to be used in conjunction with {@link Matcher}.
65 *
66 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
67 * Each instance is a (possibly partial) substitution of pattern parameters,
68 * usable to represent a match of the pattern in the result of a query,
69 * or to specify the bound (fixed) input parameters when issuing a query.
70 *
71 * @see Matcher
72 *
73 */
74 public static abstract class Match extends BasePatternMatch {
75 private Member fM;
76
77 private static List<String> parameterNames = makeImmutableList("m");
78
79 private Match(final Member pM) {
80 this.fM = pM;
81 }
82
83 @Override
84 public Object get(final String parameterName) {
85 switch(parameterName) {
86 case "m": return this.fM;
87 default: return null;
88 }
89 }
90
91 @Override
92 public Object get(final int index) {
93 switch(index) {
94 case 0: return this.fM;
95 default: return null;
96 }
97 }
98
99 public Member getM() {
100 return this.fM;
101 }
102
103 @Override
104 public boolean set(final String parameterName, final Object newValue) {
105 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
106 if ("m".equals(parameterName) ) {
107 this.fM = (Member) newValue;
108 return true;
109 }
110 return false;
111 }
112
113 public void setM(final Member pM) {
114 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
115 this.fM = pM;
116 }
117
118 @Override
119 public String patternName() {
120 return "queries.memberIsItsOwnParent";
121 }
122
123 @Override
124 public List<String> parameterNames() {
125 return MemberIsItsOwnParent.Match.parameterNames;
126 }
127
128 @Override
129 public Object[] toArray() {
130 return new Object[]{fM};
131 }
132
133 @Override
134 public MemberIsItsOwnParent.Match toImmutable() {
135 return isMutable() ? newMatch(fM) : this;
136 }
137
138 @Override
139 public String prettyPrint() {
140 StringBuilder result = new StringBuilder();
141 result.append("\"m\"=" + prettyPrintValue(fM));
142 return result.toString();
143 }
144
145 @Override
146 public int hashCode() {
147 return Objects.hash(fM);
148 }
149
150 @Override
151 public boolean equals(final Object obj) {
152 if (this == obj)
153 return true;
154 if (obj == null) {
155 return false;
156 }
157 if ((obj instanceof MemberIsItsOwnParent.Match)) {
158 MemberIsItsOwnParent.Match other = (MemberIsItsOwnParent.Match) obj;
159 return Objects.equals(fM, other.fM);
160 } else {
161 // this should be infrequent
162 if (!(obj instanceof IPatternMatch)) {
163 return false;
164 }
165 IPatternMatch otherSig = (IPatternMatch) obj;
166 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
167 }
168 }
169
170 @Override
171 public MemberIsItsOwnParent specification() {
172 return MemberIsItsOwnParent.instance();
173 }
174
175 /**
176 * Returns an empty, mutable match.
177 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
178 *
179 * @return the empty match.
180 *
181 */
182 public static MemberIsItsOwnParent.Match newEmptyMatch() {
183 return new Mutable(null);
184 }
185
186 /**
187 * Returns a mutable (partial) match.
188 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
189 *
190 * @param pM the fixed value of pattern parameter m, or null if not bound.
191 * @return the new, mutable (partial) match object.
192 *
193 */
194 public static MemberIsItsOwnParent.Match newMutableMatch(final Member pM) {
195 return new Mutable(pM);
196 }
197
198 /**
199 * Returns a new (partial) match.
200 * This can be used e.g. to call the matcher with a partial match.
201 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
202 * @param pM the fixed value of pattern parameter m, or null if not bound.
203 * @return the (partial) match object.
204 *
205 */
206 public static MemberIsItsOwnParent.Match newMatch(final Member pM) {
207 return new Immutable(pM);
208 }
209
210 private static final class Mutable extends MemberIsItsOwnParent.Match {
211 Mutable(final Member pM) {
212 super(pM);
213 }
214
215 @Override
216 public boolean isMutable() {
217 return true;
218 }
219 }
220
221 private static final class Immutable extends MemberIsItsOwnParent.Match {
222 Immutable(final Member pM) {
223 super(pM);
224 }
225
226 @Override
227 public boolean isMutable() {
228 return false;
229 }
230 }
231 }
232
233 /**
234 * Generated pattern matcher API of the queries.memberIsItsOwnParent pattern,
235 * providing pattern-specific query methods.
236 *
237 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
238 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
239 *
240 * <p>Matches of the pattern will be represented as {@link Match}.
241 *
242 * <p>Original source:
243 * <code><pre>
244 * {@literal @}Constraint(message="memberIsItsOwnParent", severity="error", key={m})
245 * pattern memberIsItsOwnParent(m: Member) = {
246 * FamilyTree.members(_, m);
247 * Member.parents(m, p);
248 * m == p;
249 * }
250 * </pre></code>
251 *
252 * @see Match
253 * @see MemberIsItsOwnParent
254 *
255 */
256 public static class Matcher extends BaseMatcher<MemberIsItsOwnParent.Match> {
257 /**
258 * Initializes the pattern matcher within an existing VIATRA Query engine.
259 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
260 *
261 * @param engine the existing VIATRA Query engine in which this matcher will be created.
262 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
263 *
264 */
265 public static MemberIsItsOwnParent.Matcher on(final ViatraQueryEngine engine) {
266 // check if matcher already exists
267 Matcher matcher = engine.getExistingMatcher(querySpecification());
268 if (matcher == null) {
269 matcher = (Matcher)engine.getMatcher(querySpecification());
270 }
271 return matcher;
272 }
273
274 /**
275 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
276 * @return an initialized matcher
277 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
278 *
279 */
280 public static MemberIsItsOwnParent.Matcher create() {
281 return new Matcher();
282 }
283
284 private static final int POSITION_M = 0;
285
286 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(MemberIsItsOwnParent.Matcher.class);
287
288 /**
289 * Initializes the pattern matcher within an existing VIATRA Query engine.
290 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
291 *
292 * @param engine the existing VIATRA Query engine in which this matcher will be created.
293 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
294 *
295 */
296 private Matcher() {
297 super(querySpecification());
298 }
299
300 /**
301 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
302 * @param pM the fixed value of pattern parameter m, or null if not bound.
303 * @return matches represented as a Match object.
304 *
305 */
306 public Collection<MemberIsItsOwnParent.Match> getAllMatches(final Member pM) {
307 return rawStreamAllMatches(new Object[]{pM}).collect(Collectors.toSet());
308 }
309
310 /**
311 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
312 * </p>
313 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
314 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
315 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
316 * @param pM the fixed value of pattern parameter m, or null if not bound.
317 * @return a stream of matches represented as a Match object.
318 *
319 */
320 public Stream<MemberIsItsOwnParent.Match> streamAllMatches(final Member pM) {
321 return rawStreamAllMatches(new Object[]{pM});
322 }
323
324 /**
325 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
326 * Neither determinism nor randomness of selection is guaranteed.
327 * @param pM the fixed value of pattern parameter m, or null if not bound.
328 * @return a match represented as a Match object, or null if no match is found.
329 *
330 */
331 public Optional<MemberIsItsOwnParent.Match> getOneArbitraryMatch(final Member pM) {
332 return rawGetOneArbitraryMatch(new Object[]{pM});
333 }
334
335 /**
336 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
337 * under any possible substitution of the unspecified parameters (if any).
338 * @param pM the fixed value of pattern parameter m, or null if not bound.
339 * @return true if the input is a valid (partial) match of the pattern.
340 *
341 */
342 public boolean hasMatch(final Member pM) {
343 return rawHasMatch(new Object[]{pM});
344 }
345
346 /**
347 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
348 * @param pM the fixed value of pattern parameter m, or null if not bound.
349 * @return the number of pattern matches found.
350 *
351 */
352 public int countMatches(final Member pM) {
353 return rawCountMatches(new Object[]{pM});
354 }
355
356 /**
357 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
358 * Neither determinism nor randomness of selection is guaranteed.
359 * @param pM the fixed value of pattern parameter m, or null if not bound.
360 * @param processor the action that will process the selected match.
361 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
362 *
363 */
364 public boolean forOneArbitraryMatch(final Member pM, final Consumer<? super MemberIsItsOwnParent.Match> processor) {
365 return rawForOneArbitraryMatch(new Object[]{pM}, processor);
366 }
367
368 /**
369 * Returns a new (partial) match.
370 * This can be used e.g. to call the matcher with a partial match.
371 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
372 * @param pM the fixed value of pattern parameter m, or null if not bound.
373 * @return the (partial) match object.
374 *
375 */
376 public MemberIsItsOwnParent.Match newMatch(final Member pM) {
377 return MemberIsItsOwnParent.Match.newMatch(pM);
378 }
379
380 /**
381 * Retrieve the set of values that occur in matches for m.
382 * @return the Set of all values or empty set if there are no matches
383 *
384 */
385 protected Stream<Member> rawStreamAllValuesOfm(final Object[] parameters) {
386 return rawStreamAllValues(POSITION_M, parameters).map(Member.class::cast);
387 }
388
389 /**
390 * Retrieve the set of values that occur in matches for m.
391 * @return the Set of all values or empty set if there are no matches
392 *
393 */
394 public Set<Member> getAllValuesOfm() {
395 return rawStreamAllValuesOfm(emptyArray()).collect(Collectors.toSet());
396 }
397
398 /**
399 * Retrieve the set of values that occur in matches for m.
400 * @return the Set of all values or empty set if there are no matches
401 *
402 */
403 public Stream<Member> streamAllValuesOfm() {
404 return rawStreamAllValuesOfm(emptyArray());
405 }
406
407 @Override
408 protected MemberIsItsOwnParent.Match tupleToMatch(final Tuple t) {
409 try {
410 return MemberIsItsOwnParent.Match.newMatch((Member) t.get(POSITION_M));
411 } catch(ClassCastException e) {
412 LOGGER.error("Element(s) in tuple not properly typed!",e);
413 return null;
414 }
415 }
416
417 @Override
418 protected MemberIsItsOwnParent.Match arrayToMatch(final Object[] match) {
419 try {
420 return MemberIsItsOwnParent.Match.newMatch((Member) match[POSITION_M]);
421 } catch(ClassCastException e) {
422 LOGGER.error("Element(s) in array not properly typed!",e);
423 return null;
424 }
425 }
426
427 @Override
428 protected MemberIsItsOwnParent.Match arrayToMatchMutable(final Object[] match) {
429 try {
430 return MemberIsItsOwnParent.Match.newMutableMatch((Member) match[POSITION_M]);
431 } catch(ClassCastException e) {
432 LOGGER.error("Element(s) in array not properly typed!",e);
433 return null;
434 }
435 }
436
437 /**
438 * @return the singleton instance of the query specification of this pattern
439 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
440 *
441 */
442 public static IQuerySpecification<MemberIsItsOwnParent.Matcher> querySpecification() {
443 return MemberIsItsOwnParent.instance();
444 }
445 }
446
447 private MemberIsItsOwnParent() {
448 super(GeneratedPQuery.INSTANCE);
449 }
450
451 /**
452 * @return the singleton instance of the query specification
453 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
454 *
455 */
456 public static MemberIsItsOwnParent instance() {
457 try{
458 return LazyHolder.INSTANCE;
459 } catch (ExceptionInInitializerError err) {
460 throw processInitializerError(err);
461 }
462 }
463
464 @Override
465 protected MemberIsItsOwnParent.Matcher instantiate(final ViatraQueryEngine engine) {
466 return MemberIsItsOwnParent.Matcher.on(engine);
467 }
468
469 @Override
470 public MemberIsItsOwnParent.Matcher instantiate() {
471 return MemberIsItsOwnParent.Matcher.create();
472 }
473
474 @Override
475 public MemberIsItsOwnParent.Match newEmptyMatch() {
476 return MemberIsItsOwnParent.Match.newEmptyMatch();
477 }
478
479 @Override
480 public MemberIsItsOwnParent.Match newMatch(final Object... parameters) {
481 return MemberIsItsOwnParent.Match.newMatch((familytree.Member) parameters[0]);
482 }
483
484 /**
485 * Inner class allowing the singleton instance of {@link MemberIsItsOwnParent} to be created
486 * <b>not</b> at the class load time of the outer class,
487 * but rather at the first call to {@link MemberIsItsOwnParent#instance()}.
488 *
489 * <p> This workaround is required e.g. to support recursion.
490 *
491 */
492 private static class LazyHolder {
493 private static final MemberIsItsOwnParent INSTANCE = new MemberIsItsOwnParent();
494
495 /**
496 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
497 * This initialization order is required to support indirect recursion.
498 *
499 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
500 *
501 */
502 private static final Object STATIC_INITIALIZER = ensureInitialized();
503
504 public static Object ensureInitialized() {
505 INSTANCE.ensureInitializedInternal();
506 return null;
507 }
508 }
509
510 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
511 private static final MemberIsItsOwnParent.GeneratedPQuery INSTANCE = new GeneratedPQuery();
512
513 private final PParameter parameter_m = new PParameter("m", "familytree.Member", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/familytree", "Member")), PParameterDirection.INOUT);
514
515 private final List<PParameter> parameters = Arrays.asList(parameter_m);
516
517 private GeneratedPQuery() {
518 super(PVisibility.PUBLIC);
519 }
520
521 @Override
522 public String getFullyQualifiedName() {
523 return "queries.memberIsItsOwnParent";
524 }
525
526 @Override
527 public List<String> getParameterNames() {
528 return Arrays.asList("m");
529 }
530
531 @Override
532 public List<PParameter> getParameters() {
533 return parameters;
534 }
535
536 @Override
537 public Set<PBody> doGetContainedBodies() {
538 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
539 Set<PBody> bodies = new LinkedHashSet<>();
540 {
541 PBody body = new PBody(this);
542 PVariable var_m = body.getOrCreateVariableByName("m");
543 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
544 PVariable var_p = body.getOrCreateVariableByName("p");
545 new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member")));
546 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
547 new ExportedParameter(body, var_m, parameter_m)
548 ));
549 // FamilyTree.members(_, m)
550 new TypeConstraint(body, Tuples.flatTupleOf(var___0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "FamilyTree")));
551 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
552 new TypeConstraint(body, Tuples.flatTupleOf(var___0_, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "FamilyTree", "members")));
553 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member")));
554 new Equality(body, var__virtual_0_, var_m);
555 // Member.parents(m, p)
556 new TypeConstraint(body, Tuples.flatTupleOf(var_m), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member")));
557 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
558 new TypeConstraint(body, Tuples.flatTupleOf(var_m, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/familytree", "Member", "parents")));
559 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/familytree", "Member")));
560 new Equality(body, var__virtual_1_, var_p);
561 // m == p
562 new Equality(body, var_m, var_p);
563 bodies.add(body);
564 }
565 {
566 PAnnotation annotation = new PAnnotation("Constraint");
567 annotation.addAttribute("message", "memberIsItsOwnParent");
568 annotation.addAttribute("severity", "error");
569 annotation.addAttribute("key", Arrays.asList(new Object[] {
570 new ParameterReference("m")
571 }));
572 addAnnotation(annotation);
573 }
574 return bodies;
575 }
576 }
577}
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src/queries/familyTreeConstraints.vql b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src/queries/familyTreeConstraints.vql
new file mode 100644
index 00000000..1b9b6659
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src/queries/familyTreeConstraints.vql
@@ -0,0 +1,24 @@
1package queries
2
3import "http://www.example.org/familytree"
4
5@Constraint(message="memberIsItsOwnParent", severity="error", key={m})
6pattern memberIsItsOwnParent(m: Member) = {
7 FamilyTree.members(_, m);
8 Member.parents(m, p);
9 m == p;
10}
11
12//@Constraint(message="parentTooYoung", severity="error", key={m, p})
13//pattern parentTooYoung(m: Member, p: Member) = {
14// FamilyTree.members(_, m);
15// Member.parents(m, p);
16// Member.age(m, mAge);
17// Member.age(p, pAge);
18// check (mAge <= (pAge + 12));
19//}
20
21
22
23
24
diff --git a/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src/run/FamilyTreeGen.java b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src/run/FamilyTreeGen.java
new file mode 100644
index 00000000..4dcd77a5
--- /dev/null
+++ b/Tests/MODELS2020-CaseStudies/case.study.familyTree.run/src/run/FamilyTreeGen.java
@@ -0,0 +1,13 @@
1package run;
2
3import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor;
4
5public class FamilyTreeGen {
6 public static void main(String[] args) {
7 String errorMessages = StandaloneScriptExecutor.executeScript("inputs/familytreeGen.vsconfig");
8 if(errorMessages!=null) {
9 System.out.println(errorMessages);
10 }
11 }
12
13}