aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_ContainmentMapper.xtend
diff options
context:
space:
mode:
Diffstat (limited to 'Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_ContainmentMapper.xtend')
-rw-r--r--Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_ContainmentMapper.xtend63
1 files changed, 32 insertions, 31 deletions
diff --git a/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_ContainmentMapper.xtend b/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_ContainmentMapper.xtend
index c56b54be..9f29ea49 100644
--- a/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_ContainmentMapper.xtend
+++ b/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_ContainmentMapper.xtend
@@ -15,6 +15,7 @@ import java.util.Map
15 15
16import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* 16import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
17import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition 17import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition
18import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.impl.TypeDefinitionImpl
18 19
19class Logic2VampireLanguageMapper_ContainmentMapper { 20class Logic2VampireLanguageMapper_ContainmentMapper {
20 val extension VampireLanguageFactory factory = VampireLanguageFactory.eINSTANCE 21 val extension VampireLanguageFactory factory = VampireLanguageFactory.eINSTANCE
@@ -36,7 +37,7 @@ class Logic2VampireLanguageMapper_ContainmentMapper {
36 val containmentListCopy = hierarchy.typesOrderedInHierarchy 37 val containmentListCopy = hierarchy.typesOrderedInHierarchy
37 val relationsList = hierarchy.containmentRelations 38 val relationsList = hierarchy.containmentRelations
38 val toRemove = newArrayList 39 val toRemove = newArrayList
39 40
40 // STEP 1 41 // STEP 1
41 // Find root element 42 // Find root element
42 for (l : relationsList) { 43 for (l : relationsList) {
@@ -48,7 +49,7 @@ class Logic2VampireLanguageMapper_ContainmentMapper {
48 containmentListCopy.remove(c) 49 containmentListCopy.remove(c)
49 } 50 }
50 } 51 }
51 52
52// OLD 53// OLD
53// for (c : containmentListCopy) { 54// for (c : containmentListCopy) {
54// if(c.isIsAbstract) { 55// if(c.isIsAbstract) {
@@ -58,42 +59,43 @@ class Logic2VampireLanguageMapper_ContainmentMapper {
58 // State that there must exist 1 and only 1 root element 59 // State that there must exist 1 and only 1 root element
59// val topName = containmentListCopy.get(0).lookup(trace.type2Predicate).constant.toString 60// val topName = containmentListCopy.get(0).lookup(trace.type2Predicate).constant.toString
60// val topTerm = support.duplicate(containmentListCopy.get(0).lookup(trace.type2Predicate)) 61// val topTerm = support.duplicate(containmentListCopy.get(0).lookup(trace.type2Predicate))
61
62 var topTermVar = containmentListCopy.get(0) 62 var topTermVar = containmentListCopy.get(0)
63 for (l : relationsList) { 63 for (l : relationsList) {
64 var pointingFrom = (l.parameters.get(0) as ComplexTypeReference).referred as Type 64 var pointingFrom = (l.parameters.get(0) as ComplexTypeReference).referred as Type
65 if(containmentListCopy.contains(pointingFrom)) { 65 if (containmentListCopy.contains(pointingFrom)) {
66 //The correct topTerm will be identified 66 // The correct topTerm will be identified
67 topTermVar = pointingFrom 67 topTermVar = pointingFrom
68 } 68 }
69 } 69 }
70 70
71 val topName = topTermVar.lookup(trace.type2Predicate).constant.toString 71 val topName = topTermVar.lookup(trace.type2Predicate).constant.toString
72 val topTerm = support.duplicate(topTermVar.lookup(trace.type2Predicate)) 72 val topTerm = support.duplicate(topTermVar.lookup(trace.type2Predicate))
73 73
74
75
76 var topLvlIsInInitModel = false 74 var topLvlIsInInitModel = false
77 var topLvlString = "" 75 var topLvlString = ""
78 for ( c : topTermVar.subtypes) { 76 var listToCheck = newArrayList(topTermVar)
79 if (c.class.simpleName.equals("TypeDefinitionImpl") ) { 77 listToCheck.addAll(topTermVar.subtypes)
78 for (c : listToCheck) {
79 if (c.class == typeof(TypeDefinitionImpl)) {
80 80
81 for (d : (c as TypeDefinition).elements) { 81 if((c as TypeDefinition).elements.length >1) {
82 if (trace.definedElement2String.containsKey(d)) { 82 throw new IllegalArgumentException("You cannot have multiple top-level elements in your initial model")
83 topLvlIsInInitModel = true 83 }
84 topLvlString = d.lookup(trace.definedElement2String) 84
85 for (d : (c as TypeDefinition).elements) {
86 if (trace.definedElement2String.containsKey(d)) {
87 topLvlIsInInitModel = true
88 topLvlString = d.lookup(trace.definedElement2String)
89 }
85 } 90 }
86 } 91 }
87 92
88 }
89
90
91 } 93 }
94
95 trace.topLvlElementIsInInitialModel = topLvlIsInInitModel
92 val topInIM = topLvlIsInInitModel 96 val topInIM = topLvlIsInInitModel
93 val topStr = topLvlString 97 val topStr = topLvlString
94 print(topInIM) 98
95 print(topStr)
96
97 val contTop = createVLSFofFormula => [ 99 val contTop = createVLSFofFormula => [
98 it.name = support.toIDMultiple("containment_topLevel", topName) 100 it.name = support.toIDMultiple("containment_topLevel", topName)
99 it.fofRole = "axiom" 101 it.fofRole = "axiom"
@@ -105,7 +107,7 @@ class Logic2VampireLanguageMapper_ContainmentMapper {
105 it.right = createVLSEquality => [ 107 it.right = createVLSEquality => [
106 it.left = support.duplicate(variable) 108 it.left = support.duplicate(variable)
107 it.right = createVLSConstant => [ 109 it.right = createVLSConstant => [
108 it.name = if (topInIM) topStr else "o1" 110 it.name = if(topInIM) topStr else "o1"
109 ] 111 ]
110 ] 112 ]
111 ] 113 ]
@@ -119,8 +121,8 @@ class Logic2VampireLanguageMapper_ContainmentMapper {
119 ] 121 ]
120 trace.specification.formulas += contTop 122 trace.specification.formulas += contTop
121 123
122 // STEP 2 124// STEP 2
123 // for each edge, if the pointedTo element exists,the edge must exist also 125// for each edge, if the pointedTo element exists,the edge must exist also
124 val varA = createVLSVariable => [it.name = "A"] 126 val varA = createVLSVariable => [it.name = "A"]
125 val varB = createVLSVariable => [it.name = "B"] 127 val varB = createVLSVariable => [it.name = "B"]
126 val varC = createVLSVariable => [it.name = "C"] 128 val varC = createVLSVariable => [it.name = "C"]
@@ -207,23 +209,22 @@ class Logic2VampireLanguageMapper_ContainmentMapper {
207 // STEP 4 209 // STEP 4
208 // Ensure that there are no cycles in the hierarchy (maybe same as for step3?) 210 // Ensure that there are no cycles in the hierarchy (maybe same as for step3?)
209 // Attempt 1: all possibilities, even the impossible one, based on MM constraints, are listed 211 // Attempt 1: all possibilities, even the impossible one, based on MM constraints, are listed
210
211
212 val variables = newArrayList 212 val variables = newArrayList
213 val disjunctionList = newArrayList 213 val disjunctionList = newArrayList
214 val conjunctionList = newArrayList 214 val conjunctionList = newArrayList
215 for (var i = 1; i <= config.contCycleLevel; i++) { 215 for (var i = 1; i <= config.contCycleLevel; i++) {
216 val ind = i 216 val ind = i
217 variables.add(createVLSVariable => [it.name = ("V"+Integer.toString(ind))]) 217 variables.add(createVLSVariable => [it.name = ("V" + Integer.toString(ind))])
218 for ( var j = 0; j < i;j++){ 218 for (var j = 0; j < i; j++) {
219 for (l : relationsList) { 219 for (l : relationsList) {
220 val rel = support.duplicate((l as RelationDeclaration).lookup(trace.rel2Predicate), newArrayList(variables.get(j), variables.get((j+1)%i))) 220 val rel = support.duplicate((l as RelationDeclaration).lookup(trace.rel2Predicate),
221 newArrayList(variables.get(j), variables.get((j + 1) % i)))
221 disjunctionList.add(rel) 222 disjunctionList.add(rel)
222 } 223 }
223 conjunctionList.add(support.unfoldOr(disjunctionList)) 224 conjunctionList.add(support.unfoldOr(disjunctionList))
224 disjunctionList.clear 225 disjunctionList.clear
225 } 226 }
226 227
227 val contCycleForm = createVLSFofFormula => [ 228 val contCycleForm = createVLSFofFormula => [
228 it.name = support.toIDMultiple("containment_noCycle", Integer.toString(ind)) 229 it.name = support.toIDMultiple("containment_noCycle", Integer.toString(ind))
229 it.fofRole = "axiom" 230 it.fofRole = "axiom"