diff options
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.xtend | 46 |
1 files changed, 38 insertions, 8 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 48ee8789..395b4305 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 | |||
@@ -1,6 +1,6 @@ | |||
1 | package ca.mcgill.ecse.dslreasoner.vampire.reasoner.builder | 1 | package ca.mcgill.ecse.dslreasoner.vampire.reasoner.builder |
2 | 2 | ||
3 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSAnd | 3 | import ca.mcgill.ecse.dslreasoner.vampire.reasoner.VampireSolverConfiguration |
4 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSFunction | 4 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSFunction |
5 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSTerm | 5 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSTerm |
6 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSVariable | 6 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSVariable |
@@ -25,9 +25,9 @@ class Logic2VampireLanguageMapper_ContainmentMapper { | |||
25 | this.base = base | 25 | this.base = base |
26 | } | 26 | } |
27 | 27 | ||
28 | def public void transformContainment(List<ContainmentHierarchy> hierarchies, | 28 | def public void transformContainment(VampireSolverConfiguration config, List<ContainmentHierarchy> hierarchies, |
29 | Logic2VampireLanguageMapperTrace trace) { | 29 | Logic2VampireLanguageMapperTrace trace) { |
30 | //TODO throw error is there exists a circular containment that does not involve hierarchy | 30 | // TODO throw error is there exists a circular containment that does not involve hierarchy |
31 | // TODO CONSIDER CASE WHERE MULTIPLE CONTAINMMENT HIERARCHIES EXIST | 31 | // TODO CONSIDER CASE WHERE MULTIPLE CONTAINMMENT HIERARCHIES EXIST |
32 | // TEMP | 32 | // TEMP |
33 | val hierarchy = hierarchies.get(0) | 33 | val hierarchy = hierarchies.get(0) |
@@ -94,7 +94,6 @@ class Logic2VampireLanguageMapper_ContainmentMapper { | |||
94 | // for (c : support.listSubtypes(toType)) { | 94 | // for (c : support.listSubtypes(toType)) { |
95 | // addToMap(type2cont, toFunc, rel) | 95 | // addToMap(type2cont, toFunc, rel) |
96 | // } | 96 | // } |
97 | |||
98 | // val listForAnd = newArrayList | 97 | // val listForAnd = newArrayList |
99 | //// listForAnd.add(support.duplicate(fromType.lookup(trace.type2Predicate), varB)) | 98 | //// listForAnd.add(support.duplicate(fromType.lookup(trace.type2Predicate), varB)) |
100 | // listForAnd.add(support.duplicate((l as RelationDeclaration).lookup(trace.rel2Predicate), varList)) | 99 | // listForAnd.add(support.duplicate((l as RelationDeclaration).lookup(trace.rel2Predicate), varList)) |
@@ -111,7 +110,7 @@ class Logic2VampireLanguageMapper_ContainmentMapper { | |||
111 | // STEP 3 | 110 | // STEP 3 |
112 | // Ensure that an objct only has 1 parent | 111 | // Ensure that an objct only has 1 parent |
113 | val relFormula = createVLSFofFormula => [ | 112 | val relFormula = createVLSFofFormula => [ |
114 | it.name = support.toIDMultiple("noDupCont", rel.constant.toString) | 113 | it.name = support.toIDMultiple("containment_noDup", rel.constant.toString) |
115 | it.fofRole = "axiom" | 114 | it.fofRole = "axiom" |
116 | it.fofFormula = createVLSExistentialQuantifier => [ | 115 | it.fofFormula = createVLSExistentialQuantifier => [ |
117 | it.variables += support.duplicate(varA) | 116 | it.variables += support.duplicate(varA) |
@@ -133,7 +132,7 @@ class Logic2VampireLanguageMapper_ContainmentMapper { | |||
133 | 132 | ||
134 | } | 133 | } |
135 | 134 | ||
136 | // STEP CONT'D | 135 | // STEP 2 CONT'D |
137 | for (e : type2cont.entrySet) { | 136 | for (e : type2cont.entrySet) { |
138 | val relFormula = createVLSFofFormula => [ | 137 | val relFormula = createVLSFofFormula => [ |
139 | it.name = support.toIDMultiple("containment", e.key.constant.toString) | 138 | it.name = support.toIDMultiple("containment", e.key.constant.toString) |
@@ -159,8 +158,39 @@ class Logic2VampireLanguageMapper_ContainmentMapper { | |||
159 | 158 | ||
160 | } | 159 | } |
161 | 160 | ||
162 | // STEP 4 | 161 | // STEP 4 |
163 | // Ensure that there are no cycles in the hierarchy (maybe same as for step3?) | 162 | // Ensure that there are no cycles in the hierarchy (maybe same as for step3?) |
163 | // Attempt 1: all possibilities, even the impossible one, based on MM constraints, are listed | ||
164 | |||
165 | |||
166 | val variables = newArrayList | ||
167 | val disjunctionList = newArrayList | ||
168 | val conjunctionList = newArrayList | ||
169 | for (var i = 1; i <= config.contCycleLevel; i++) { | ||
170 | val ind = i | ||
171 | variables.add(createVLSVariable => [it.name = ("V"+Integer.toString(ind))]) | ||
172 | for ( var j = 0; j < i;j++){ | ||
173 | for (l : relationsList) { | ||
174 | val rel = support.duplicate((l as RelationDeclaration).lookup(trace.rel2Predicate), newArrayList(variables.get(j), variables.get((j+1)%i))) | ||
175 | disjunctionList.add(rel) | ||
176 | } | ||
177 | conjunctionList.add(support.unfoldOr(disjunctionList)) | ||
178 | disjunctionList.clear | ||
179 | } | ||
180 | |||
181 | val contCycleForm = createVLSFofFormula => [ | ||
182 | it.name = support.toIDMultiple("containment_noCycle", Integer.toString(ind)) | ||
183 | it.fofRole = "axiom" | ||
184 | it.fofFormula = createVLSUnaryNegation => [ | ||
185 | it.operand = createVLSExistentialQuantifier => [ | ||
186 | it.variables += support.duplicate(variables) | ||
187 | it.operand = support.unfoldAnd(conjunctionList) | ||
188 | ] | ||
189 | ] | ||
190 | ] | ||
191 | trace.specification.formulas += contCycleForm | ||
192 | conjunctionList.clear | ||
193 | } | ||
164 | } | 194 | } |
165 | 195 | ||
166 | protected def VLSTerm makeUnique(List<VLSFunction> list) { | 196 | protected def VLSTerm makeUnique(List<VLSFunction> list) { |