diff options
Diffstat (limited to 'Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.xtend')
-rw-r--r-- | Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.xtend | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.xtend b/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.xtend index d1ea2a15..b00dad42 100644 --- a/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.xtend +++ b/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.xtend | |||
@@ -23,7 +23,7 @@ import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | |||
23 | class Logic2VampireLanguageMapper_Support { | 23 | class Logic2VampireLanguageMapper_Support { |
24 | private val extension VampireLanguageFactory factory = VampireLanguageFactory.eINSTANCE | 24 | private val extension VampireLanguageFactory factory = VampireLanguageFactory.eINSTANCE |
25 | 25 | ||
26 | // ID Handler | 26 | // ID Handler |
27 | def protected String toIDMultiple(String... ids) { | 27 | def protected String toIDMultiple(String... ids) { |
28 | ids.map[it.split("\\s+").join("_")].join("_") | 28 | ids.map[it.split("\\s+").join("_")].join("_") |
29 | } | 29 | } |
@@ -32,8 +32,8 @@ class Logic2VampireLanguageMapper_Support { | |||
32 | ids.split("\\s+").join("_") | 32 | ids.split("\\s+").join("_") |
33 | } | 33 | } |
34 | 34 | ||
35 | // Term Handling | 35 | // Term Handling |
36 | // TODO Make more general | 36 | // TODO Make more general |
37 | def protected VLSVariable duplicate(VLSVariable term) { | 37 | def protected VLSVariable duplicate(VLSVariable term) { |
38 | return createVLSVariable => [it.name = term.name] | 38 | return createVLSVariable => [it.name = term.name] |
39 | } | 39 | } |
@@ -107,7 +107,7 @@ class Logic2VampireLanguageMapper_Support { | |||
107 | ] | 107 | ] |
108 | } | 108 | } |
109 | 109 | ||
110 | // TODO Make more general | 110 | // TODO Make more general |
111 | def establishUniqueness(List<VLSConstant> terms, VLSConstant t2) { | 111 | def establishUniqueness(List<VLSConstant> terms, VLSConstant t2) { |
112 | // val List<VLSInequality> eqs = newArrayList | 112 | // val List<VLSInequality> eqs = newArrayList |
113 | // for (t1 : terms.subList(1, terms.length)) { | 113 | // for (t1 : terms.subList(1, terms.length)) { |
@@ -135,9 +135,9 @@ class Logic2VampireLanguageMapper_Support { | |||
135 | return unfoldAnd(eqs) | 135 | return unfoldAnd(eqs) |
136 | } | 136 | } |
137 | 137 | ||
138 | // Support Functions | 138 | // Support Functions |
139 | // booleans | 139 | // booleans |
140 | // AND and OR | 140 | // AND and OR |
141 | def protected VLSTerm unfoldAnd(List<? extends VLSTerm> operands) { | 141 | def protected VLSTerm unfoldAnd(List<? extends VLSTerm> operands) { |
142 | if (operands.size == 1) { | 142 | if (operands.size == 1) { |
143 | return operands.head | 143 | return operands.head |
@@ -163,7 +163,7 @@ class Logic2VampireLanguageMapper_Support { | |||
163 | throw new UnsupportedOperationException('''Logic operator with 0 operands!''') // TEMP | 163 | throw new UnsupportedOperationException('''Logic operator with 0 operands!''') // TEMP |
164 | } | 164 | } |
165 | 165 | ||
166 | // can delete below | 166 | // can delete below |
167 | def protected VLSTerm unfoldDistinctTerms(Logic2VampireLanguageMapper m, EList<Term> operands, | 167 | def protected VLSTerm unfoldDistinctTerms(Logic2VampireLanguageMapper m, EList<Term> operands, |
168 | Logic2VampireLanguageMapperTrace trace, Map<Variable, VLSVariable> variables) { | 168 | Logic2VampireLanguageMapperTrace trace, Map<Variable, VLSVariable> variables) { |
169 | if (operands.size == 1) { | 169 | if (operands.size == 1) { |
@@ -183,8 +183,8 @@ class Logic2VampireLanguageMapper_Support { | |||
183 | throw new UnsupportedOperationException('''Logic operator with 0 operands!''') | 183 | throw new UnsupportedOperationException('''Logic operator with 0 operands!''') |
184 | } | 184 | } |
185 | 185 | ||
186 | // Symbolic | 186 | // Symbolic |
187 | // def postprocessResultOfSymbolicReference(TypeReference type, VLSTerm term, Logic2VampireLanguageMapperTrace trace) { | 187 | // def postprocessResultOfSymbolicReference(TypeReference type, VLSTerm term, Logic2VampireLanguageMapperTrace trace) { |
188 | // if(type instanceof BoolTypeReference) { | 188 | // if(type instanceof BoolTypeReference) { |
189 | // return booleanToLogicValue(term ,trace) | 189 | // return booleanToLogicValue(term ,trace) |
190 | // } | 190 | // } |
@@ -198,7 +198,7 @@ class Logic2VampireLanguageMapper_Support { | |||
198 | * ids.map[it.split("\\s+").join("'")].join("'") | 198 | * ids.map[it.split("\\s+").join("'")].join("'") |
199 | * } | 199 | * } |
200 | */ | 200 | */ |
201 | // QUANTIFIERS + VARIABLES | 201 | // QUANTIFIERS + VARIABLES |
202 | def protected VLSTerm createQuantifiedExpression(Logic2VampireLanguageMapper mapper, | 202 | def protected VLSTerm createQuantifiedExpression(Logic2VampireLanguageMapper mapper, |
203 | QuantifiedExpression expression, Logic2VampireLanguageMapperTrace trace, Map<Variable, VLSVariable> variables, | 203 | QuantifiedExpression expression, Logic2VampireLanguageMapperTrace trace, Map<Variable, VLSVariable> variables, |
204 | boolean isUniversal) { | 204 | boolean isUniversal) { |
@@ -245,6 +245,32 @@ class Logic2VampireLanguageMapper_Support { | |||
245 | } | 245 | } |
246 | } | 246 | } |
247 | } | 247 | } |
248 | //TODO rewrite such that it uses "listSubTypes" | ||
249 | def protected boolean dfsSubtypeCheck(Type type, Type type2) { | ||
250 | // There is surely a better way to do this | ||
251 | if (type.subtypes.isEmpty) | ||
252 | return false | ||
253 | else { | ||
254 | if (type.subtypes.contains(type2)) | ||
255 | return true | ||
256 | else { | ||
257 | for (subtype : type.subtypes) { | ||
258 | if(dfsSubtypeCheck(subtype, type2)) return true | ||
259 | } | ||
260 | } | ||
261 | } | ||
262 | } | ||
263 | |||
264 | def protected List<Type> listSubtypes(Type t) { | ||
265 | var List<Type> allSubtypes = newArrayList | ||
266 | if (!t.subtypes.isEmpty) { | ||
267 | for (subt : t.subtypes) { | ||
268 | allSubtypes.add(subt) | ||
269 | allSubtypes = listSubtypes(subt) | ||
270 | } | ||
271 | } | ||
272 | return allSubtypes | ||
273 | } | ||
248 | 274 | ||
249 | def protected withAddition(Map<Variable, VLSVariable> map1, Map<Variable, VLSVariable> map2) { | 275 | def protected withAddition(Map<Variable, VLSVariable> map1, Map<Variable, VLSVariable> map2) { |
250 | new HashMap(map1) => [putAll(map2)] | 276 | new HashMap(map1) => [putAll(map2)] |