aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic
diff options
context:
space:
mode:
authorLibravatar OszkarSemerath <oszkar.semerath@gmail.com>2018-05-14 12:55:47 +0200
committerLibravatar OszkarSemerath <oszkar.semerath@gmail.com>2018-05-14 12:55:47 +0200
commita993b72eb3e038897767c79d054467a6986d2085 (patch)
tree6ebd0c0e4d074bc7a97651e780c228014dccf42d /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic
parentderived feature -> partial relation bugfix (diff)
downloadVIATRA-Generator-a993b72eb3e038897767c79d054467a6986d2085.tar.gz
VIATRA-Generator-a993b72eb3e038897767c79d054467a6986d2085.tar.zst
VIATRA-Generator-a993b72eb3e038897767c79d054467a6986d2085.zip
Moved partial model management is moved to one project (+1 PM edge fix)
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic')
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.classpath9
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.gitignore3
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.project34
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/META-INF/MANIFEST.MF15
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/build.properties6
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2Logic.xtend22
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend144
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/PartialInterpretation2Logic.xtend164
9 files changed, 0 insertions, 404 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.classpath b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.classpath
deleted file mode 100644
index 2b46fc9b..00000000
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
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="xtend-gen"/>
7 <classpathentry kind="src" path="src-gen/"/>
8 <classpathentry kind="output" path="bin"/>
9</classpath>
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.gitignore b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.gitignore
deleted file mode 100644
index f2741e97..00000000
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
1/bin/
2/vql-gen/
3/xtend-gen/
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.project b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.project
deleted file mode 100644
index 153ec5ab..00000000
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.project
+++ /dev/null
@@ -1,34 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<projectDescription>
3 <name>hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic</name>
4 <comment></comment>
5 <projects>
6 </projects>
7 <buildSpec>
8 <buildCommand>
9 <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
10 <arguments>
11 </arguments>
12 </buildCommand>
13 <buildCommand>
14 <name>org.eclipse.jdt.core.javabuilder</name>
15 <arguments>
16 </arguments>
17 </buildCommand>
18 <buildCommand>
19 <name>org.eclipse.pde.ManifestBuilder</name>
20 <arguments>
21 </arguments>
22 </buildCommand>
23 <buildCommand>
24 <name>org.eclipse.pde.SchemaBuilder</name>
25 <arguments>
26 </arguments>
27 </buildCommand>
28 </buildSpec>
29 <natures>
30 <nature>org.eclipse.pde.PluginNature</nature>
31 <nature>org.eclipse.jdt.core.javanature</nature>
32 <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
33 </natures>
34</projectDescription>
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.settings/org.eclipse.jdt.core.prefs b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 295926d9..00000000
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
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/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/META-INF/MANIFEST.MF b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/META-INF/MANIFEST.MF
deleted file mode 100644
index 703a1cef..00000000
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,15 +0,0 @@
1Manifest-Version: 1.0
2Bundle-ManifestVersion: 2
3Bundle-Name: Partialinterpretation2logic
4Bundle-SymbolicName: hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic
5Bundle-Version: 1.0.0.qualifier
6Export-Package: hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic
7Require-Bundle: com.google.guava,
8 org.eclipse.xtext.xbase.lib,
9 org.eclipse.xtend.lib,
10 org.eclipse.xtend.lib.macro,
11 hu.bme.mit.inf.dslreasoner.logic.model;bundle-version="1.0.0",
12 hu.bme.mit.inf.dslreasoner.ecore2logic;bundle-version="1.0.0",
13 hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage;bundle-version="1.0.0"
14Bundle-RequiredExecutionEnvironment: JavaSE-1.8
15Automatic-Module-Name: hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/build.properties b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/build.properties
deleted file mode 100644
index 704a86e2..00000000
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/build.properties
+++ /dev/null
@@ -1,6 +0,0 @@
1bin.includes = META-INF/,\
2 .
3source.. = src/,\
4 src-gen/,\
5 xtend-gen/
6output.. = bin/
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2Logic.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2Logic.xtend
deleted file mode 100644
index d2b59754..00000000
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2Logic.xtend
+++ /dev/null
@@ -1,22 +0,0 @@
1package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic
2
3import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace
4import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput
5import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
6import java.util.List
7import org.eclipse.emf.ecore.EObject
8import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes
9
10class InstanceModel2Logic {
11 val InstanceModel2PartialInterpretation instanceModel2PartialInterpretation = new InstanceModel2PartialInterpretation
12 val PartialInterpretation2Logic partialInterpretation2Logic = new PartialInterpretation2Logic
13
14 public def transform(
15 TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult,
16 List<EObject> objects)
17 {
18 val res1 = instanceModel2PartialInterpretation.transform(metamodelTranslationResult,objects,true)
19 this.partialInterpretation2Logic.transformPartialIntepretation2Logic(metamodelTranslationResult.output,res1)
20 return metamodelTranslationResult//.output
21 }
22} \ No newline at end of file
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend
deleted file mode 100644
index 9a737ab9..00000000
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend
+++ /dev/null
@@ -1,144 +0,0 @@
1package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic
2
3import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic
4import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace
5import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput
6import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes
7import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement
8import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguageFactory
9import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration
10import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
11import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.PartialInterpretationInitialiser
12import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.Problem2PartialInterpretationTrace
13import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation
14import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationFactory
15import java.util.HashMap
16import java.util.List
17import java.util.Map
18import org.eclipse.emf.common.util.Enumerator
19import org.eclipse.emf.ecore.EObject
20import org.eclipse.emf.ecore.resource.Resource
21
22import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
23
24class InstanceModel2PartialInterpretation {
25 val extension LogiclanguageFactory factory = LogiclanguageFactory.eINSTANCE
26 val extension PartialinterpretationFactory factory2 = PartialinterpretationFactory.eINSTANCE
27 val Ecore2Logic ecore2Logic = new Ecore2Logic
28 val partialInterpretationInitialiser = new PartialInterpretationInitialiser
29
30 public def transform(
31 TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult,
32 Resource resource,
33 boolean withID)
34 {
35 val objects = resource.allContents.toList
36 return transform(metamodelTranslationResult,objects,withID)
37 }
38
39 public def transform(
40 TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult,
41 List<EObject> objects,
42 boolean withID)
43 {
44 val problem = metamodelTranslationResult.output
45 val ecore2LogicTrace = metamodelTranslationResult.trace
46 val tracedOutput = partialInterpretationInitialiser.initialisePartialInterpretation(problem, new TypeScopes)
47 val partialInterpretation = tracedOutput.output
48 val partialInterpretationTrace = tracedOutput.trace
49
50 val Map<EObject,DefinedElement> object2DefinedElement = new HashMap
51
52 // EObject -> DefinedElement
53 for(objectIndex : 0..<objects.size) {
54 val object = objects.get(objectIndex)
55 val element = createDefinedElement => [
56 it.name = if(withID)
57 { '''PartialObject«objectIndex»''' } else
58 { null }
59 ]
60
61 // Add element to interpretation
62 partialInterpretation.newElements += element
63
64 // Define the types
65 val type = ecore2Logic.TypeofEClass(ecore2LogicTrace,object.eClass) as TypeDeclaration
66 val interpretation = type.lookup(partialInterpretationTrace.type2Interpretation)
67 interpretation.elements += element
68 interpretation.supertypeInterpretation.forEach[elements += element]
69
70 // Trace handling
71 object2DefinedElement.put(object, element)
72 }
73
74 val referencesUsed = ecore2Logic.allReferencesInScope(ecore2LogicTrace).toSet
75 val attributesUsed = ecore2Logic.allAttributesInScope(ecore2LogicTrace).toSet
76 for(source : objects) {
77 // Translating the references
78 for(reference : source.eClass.EAllReferences.filter[
79 referencesUsed.contains(it) && !it.derived])
80 {
81 val type = ecore2Logic.relationOfReference(ecore2LogicTrace,reference)
82 val interpretation = type.lookup(partialInterpretationTrace.relation2Interpretation)
83 val sourceElement = source.lookup(object2DefinedElement)
84 if(reference.isMany) {
85 val listOfTargets = source.eGet(reference) as List<? extends EObject>
86 for(target : listOfTargets) {
87 if(target !== null && object2DefinedElement.containsKey(target)) {
88 val targetElement = target.lookup(object2DefinedElement)
89 translateLink(interpretation,sourceElement,targetElement)
90 }
91 }
92 } else {
93 val target = source.eGet(reference) as EObject
94 if(target !== null && object2DefinedElement.containsKey(target)) {
95 val targetElement = target.lookup(object2DefinedElement)
96 translateLink(interpretation,sourceElement,targetElement)
97 }
98 }
99 }
100
101 // Transforming the attributes
102 for(attribute : source.eClass.EAllAttributes.filter[attributesUsed.contains(it) && !it.derived]) {
103 val type = ecore2Logic.relationOfAttribute(ecore2LogicTrace,attribute)
104 val interpretation = type.lookup(partialInterpretationTrace.relation2Interpretation)
105 val sourceElement = source.lookup(object2DefinedElement)
106 if(attribute.isMany) {
107 val listOfTargets = source.eGet(attribute) as List<? extends EObject>
108 for(target : listOfTargets) {
109 val value = translateValue(target,ecore2LogicTrace,partialInterpretationTrace)
110 if(value !== null) {
111 translateLink(interpretation,sourceElement,value)
112 }
113 }
114 } else {
115 val target = source.eGet(attribute)
116 if(target !== null) {
117 val value = translateValue(target,ecore2LogicTrace,partialInterpretationTrace)
118 if(value !== null) {
119 translateLink(interpretation,sourceElement,value)
120 }
121 }
122 }
123 }
124 }
125
126 return partialInterpretation
127 }
128
129 protected def translateLink(PartialRelationInterpretation interpretation, DefinedElement source, DefinedElement target) {
130 interpretation.relationlinks += createBinaryElementRelationLink => [it.param1 = source it.param2 = target]
131 }
132
133 dispatch protected def translateValue(Enumerator value, Ecore2Logic_Trace ecore2LogicTrace, Problem2PartialInterpretationTrace partialInterpretationTrace) {
134 val term = this.ecore2Logic.Literal(ecore2LogicTrace,value)
135 if(term instanceof DefinedElement) {
136 return term
137 }
138 else throw new AssertionError('''term should be a defined element?''')
139 }
140
141 dispatch protected def translateValue(Object value, Ecore2Logic_Trace ecore2LogicTrace, Problem2PartialInterpretationTrace partialInterpretationTrace) {
142 //throw new UnsupportedOperationException('''Mapping of «value.class.simpleName» in partial models is currently not supported!''')
143 }
144} \ No newline at end of file
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/PartialInterpretation2Logic.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/PartialInterpretation2Logic.xtend
deleted file mode 100644
index 09a7fa60..00000000
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/PartialInterpretation2Logic.xtend
+++ /dev/null
@@ -1,164 +0,0 @@
1package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic
2
3import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder
4import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguageFactory
5import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.SymbolicDeclaration
6import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
7import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration
8import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition
9import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
10import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BinaryElementRelationLink
11import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
12import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation
13import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialTypeInterpratation
14import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.RelationLink
15import java.util.ArrayList
16import java.util.HashMap
17import java.util.HashSet
18import java.util.Map
19import java.util.Set
20import org.eclipse.xtend.lib.annotations.Data
21
22import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
23import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement
24import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.SymbolicValue
25
26@Data class PartialInterpretation2Logic_Trace {
27 Map<DefinedElement,DefinedElement> new2Old = new HashMap
28
29 Map<TypeDeclaration, TypeDefinition> definedPart = new HashMap
30 Map<TypeDeclaration, TypeDeclaration> undefinedPart = new HashMap
31 Set<Type> originalTypes = new HashSet
32 Set<TypeDeclaration> splittedTypes = new HashSet
33}
34
35class PartialInterpretation2Logic {
36 val extension LogiclanguageFactory factory = LogiclanguageFactory.eINSTANCE
37 val extension LogicProblemBuilder builder = new LogicProblemBuilder
38
39 def transformPartialIntepretation2Logic(LogicProblem p, PartialInterpretation i) {
40 val trace = new PartialInterpretation2Logic_Trace()
41 trace.originalTypes.addAll(p.types)
42 if(! i.newElements.empty) {
43
44 // Elements adding
45 addExistingElementToProblem(p,i,trace)
46
47 // Types
48 for(partialTypeDeclaration : i.partialtypeinterpratation) {
49 splitTypeIntoTwo(p,partialTypeDeclaration,trace)
50 }
51 connectSplittings(p,trace)
52
53 // Relations
54 for(partialRelationInterpretation : i.partialrelationinterpretation) {
55 //println(partialRelationInterpretation.interpretationOf.name)
56 relationLinksToAssertion(p,partialRelationInterpretation,trace)
57 }
58 }
59 }
60
61 private def addExistingElementToProblem(LogicProblem p, PartialInterpretation i,PartialInterpretation2Logic_Trace trace) {
62 val newElements = new ArrayList(i.newElements)
63 var newElementIndex = 1
64 for(newElement : newElements) {
65 newElement.name = '''o «newElementIndex++»'''
66 p.elements += newElement
67 }
68 }
69
70 private def splitTypeIntoTwo(LogicProblem p, PartialTypeInterpratation partialTypeDeclaration,PartialInterpretation2Logic_Trace trace) {
71 if(!partialTypeDeclaration.elements.empty) {
72 val declaration = partialTypeDeclaration.interpretationOf
73
74 val definedPart = createTypeDefinition => [
75 it.name = '''«declaration.name» DefinedPart'''
76 it.elements += partialTypeDeclaration.elements
77 it.isAbstract = declaration.isIsAbstract
78 ]
79 val undefinedPart = createTypeDeclaration => [
80 it.name = '''«declaration.name» UndefinedPart'''
81 it.isAbstract = declaration.isIsAbstract
82 ]
83 declaration.isAbstract = true
84
85 trace.definedPart.put(declaration,definedPart)
86 trace.undefinedPart.put(declaration,undefinedPart)
87 trace.splittedTypes.add(declaration)
88 p.add(definedPart)
89 p.add(undefinedPart)
90 Supertype(definedPart,declaration)
91 Supertype(undefinedPart,declaration)
92
93 for(containment : p.containmentHierarchies) {
94 if(containment.typesOrderedInHierarchy.contains(declaration)) {
95 containment.typesOrderedInHierarchy += definedPart
96 containment.typesOrderedInHierarchy += undefinedPart
97 }
98 }
99 }
100 }
101
102 private def connectSplittings(LogicProblem p,PartialInterpretation2Logic_Trace trace) {
103 val originalTypes = p.types.filter[originalType(trace)].toList
104 for(type : originalTypes) {
105 val superTypes = new ArrayList(type.supertypes.filter[originalType(trace)].toList)
106 for(supertype : superTypes) {
107 if(type.isSplitted(trace)) {
108 if(supertype.isSplitted(trace)) {
109 Supertype((type as TypeDeclaration).lookup(trace.definedPart), (supertype as TypeDeclaration).lookup(trace.definedPart))
110 Supertype((type as TypeDeclaration).lookup(trace.undefinedPart), (supertype as TypeDeclaration).lookup(trace.undefinedPart))
111 } else {
112 // Do nothing
113 }
114 } else {
115 if(supertype.isSplitted(trace)) {
116 Supertype(type, (supertype as TypeDeclaration).lookup(trace.undefinedPart))
117 } else if(supertype instanceof TypeDefinition) {
118 // Do nothing
119 }
120 }
121 }
122 }
123 }
124
125 private def originalType(Type type,PartialInterpretation2Logic_Trace trace) {
126 return trace.originalTypes.contains(type)
127 }
128 private def isSplitted(Type t, PartialInterpretation2Logic_Trace trace) {
129 trace.splittedTypes.contains(t)
130 }
131
132 private def relationLinksToAssertion(LogicProblem p, PartialRelationInterpretation r,PartialInterpretation2Logic_Trace trace) {
133 val relation = r.interpretationOf
134 val links = r.relationlinks
135 if(links.size == 0) {
136 return
137 } else {
138 val term = if(links.size == 1) {
139 createLink(links.head,relation)
140 } else {
141 links.map[link|createLink(link,relation)].And
142 }
143 val assertion = Assertion('''PartialInterpretation «r.interpretationOf.name»''',term)
144 //val error= assertion.eAllContents.toIterable.filter(SymbolicValue).filter[it.symbolicReference === null]
145 //error.forEach[println("error")]
146 p.add(assertion)
147 }
148
149 }
150
151 def private createLink(RelationLink link, SymbolicDeclaration relationDeclaration) {
152 if(link instanceof BinaryElementRelationLink) {
153 if((link.param1 !== null) && (link.param2 !== null)) {
154 return createSymbolicValue=>[
155 it.symbolicReference=relationDeclaration
156 it.parameterSubstitutions += createSymbolicValue => [it.symbolicReference = link.param1]
157 it.parameterSubstitutions += createSymbolicValue => [it.symbolicReference = link.param2]
158 ]
159 } else {
160 throw new IllegalArgumentException
161 }
162 } else throw new UnsupportedOperationException
163 }
164} \ No newline at end of file