diff options
author | 2021-01-24 01:49:37 +0100 | |
---|---|---|
committer | 2021-01-24 01:49:37 +0100 | |
commit | 181d6443766d7b2212218b57183dce6af038c199 (patch) | |
tree | 5b19edfeb41bde2b8e4de48ddea679ade8158848 /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage | |
parent | Sorry, I forgot something last commit (diff) | |
download | VIATRA-Generator-181d6443766d7b2212218b57183dce6af038c199.tar.gz VIATRA-Generator-181d6443766d7b2212218b57183dce6af038c199.tar.zst VIATRA-Generator-181d6443766d7b2212218b57183dce6af038c199.zip |
Fix bug for ignored-attributes + better logic problem creation
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage')
1 files changed, 34 insertions, 9 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/PartialInterpretationInitialiser.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/PartialInterpretationInitialiser.xtend index 92db5c18..28fc6e31 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/PartialInterpretationInitialiser.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/PartialInterpretationInitialiser.xtend | |||
@@ -4,10 +4,15 @@ import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput | |||
4 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes | 4 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes |
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.And | 5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.And |
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolLiteral | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolLiteral |
7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolTypeReference | ||
8 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference | ||
7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement | 9 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement |
10 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Exists | ||
8 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntLiteral | 11 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntLiteral |
12 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntTypeReference | ||
9 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguageFactory | 13 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguageFactory |
10 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealLiteral | 14 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealLiteral |
15 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealTypeReference | ||
11 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration | 16 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration |
12 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDefinition | 17 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDefinition |
13 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.StringLiteral | 18 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.StringLiteral |
@@ -31,7 +36,6 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.par | |||
31 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationFactory | 36 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationFactory |
32 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.RealElement | 37 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.RealElement |
33 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.StringElement | 38 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.StringElement |
34 | import java.math.BigDecimal | ||
35 | import java.util.HashMap | 39 | import java.util.HashMap |
36 | import java.util.Map | 40 | import java.util.Map |
37 | import java.util.SortedSet | 41 | import java.util.SortedSet |
@@ -40,6 +44,7 @@ import org.eclipse.viatra.query.runtime.emf.EMFScope | |||
40 | import org.eclipse.xtend.lib.annotations.Data | 44 | import org.eclipse.xtend.lib.annotations.Data |
41 | 45 | ||
42 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 46 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
47 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeReference | ||
43 | 48 | ||
44 | @Data class Problem2PartialInterpretationTrace { | 49 | @Data class Problem2PartialInterpretationTrace { |
45 | Map<TypeDeclaration, PartialComplexTypeInterpretation> type2Interpretation | 50 | Map<TypeDeclaration, PartialComplexTypeInterpretation> type2Interpretation |
@@ -253,7 +258,7 @@ class PartialInterpretationInitialiser { | |||
253 | throw new UnsupportedOperationException('''Assertion describing partial model of "«r.interpretationOf.name»" contains unsupported constructs''') | 258 | throw new UnsupportedOperationException('''Assertion describing partial model of "«r.interpretationOf.name»" contains unsupported constructs''') |
254 | } | 259 | } |
255 | for(link:links) { | 260 | for(link:links) { |
256 | r.relationlinks += createLink(link,trace) | 261 | r.relationlinks += createLink(interpretation, link,trace) |
257 | } | 262 | } |
258 | } | 263 | } |
259 | 264 | ||
@@ -264,8 +269,8 @@ class PartialInterpretationInitialiser { | |||
264 | 269 | ||
265 | return relation2Interpretation | 270 | return relation2Interpretation |
266 | } | 271 | } |
267 | def private createLink(SymbolicValue v, PrimitiveValueTrace trace) { | 272 | def private createLink(PartialInterpretation interpretation, SymbolicValue v, PrimitiveValueTrace trace) { |
268 | val translatedValues = v.parameterSubstitutions.map[getElement(trace)].toList | 273 | val translatedValues = v.parameterSubstitutions.map[getElement(interpretation, trace)].toList |
269 | if(translatedValues.size == 1) { | 274 | if(translatedValues.size == 1) { |
270 | return createUnaryElementRelationLink => [it.param1 = translatedValues.get(0)] | 275 | return createUnaryElementRelationLink => [it.param1 = translatedValues.get(0)] |
271 | } else if(translatedValues.size == 2) { | 276 | } else if(translatedValues.size == 2) { |
@@ -282,21 +287,27 @@ class PartialInterpretationInitialiser { | |||
282 | } | 287 | } |
283 | } | 288 | } |
284 | 289 | ||
285 | def private dispatch getElement(SymbolicValue element, PrimitiveValueTrace trace) { | 290 | def private dispatch getElement(SymbolicValue element, PartialInterpretation interpretation, PrimitiveValueTrace trace) { |
286 | return element.symbolicReference as DefinedElement | 291 | return element.symbolicReference as DefinedElement |
287 | } | 292 | } |
288 | def private dispatch getElement(BoolLiteral element, PrimitiveValueTrace trace) { | 293 | def private dispatch getElement(BoolLiteral element, PartialInterpretation interpretation, PrimitiveValueTrace trace) { |
289 | element.value.lookup(trace.booleanMap) | 294 | element.value.lookup(trace.booleanMap) |
290 | } | 295 | } |
291 | def private dispatch getElement(IntLiteral element, PrimitiveValueTrace trace) { | 296 | def private dispatch getElement(IntLiteral element, PartialInterpretation interpretation, PrimitiveValueTrace trace) { |
292 | element.value.lookup(trace.integerMap) | 297 | element.value.lookup(trace.integerMap) |
293 | } | 298 | } |
294 | def private dispatch getElement(RealLiteral element, PrimitiveValueTrace trace) { | 299 | def private dispatch getElement(RealLiteral element, PartialInterpretation interpretation, PrimitiveValueTrace trace) { |
295 | element.value.lookup(trace.realMap) | 300 | element.value.lookup(trace.realMap) |
296 | } | 301 | } |
297 | def private dispatch getElement(StringLiteral element, PrimitiveValueTrace trace) { | 302 | def private dispatch getElement(StringLiteral element, PartialInterpretation interpretation, PrimitiveValueTrace trace) { |
298 | element.value.lookup(trace.stringMap) | 303 | element.value.lookup(trace.stringMap) |
299 | } | 304 | } |
305 | def private dispatch getElement(Exists element, PartialInterpretation interpretation, PrimitiveValueTrace trace) { | ||
306 | val type = element.quantifiedVariables.get(0).range | ||
307 | val e = createUnknownValueElement(type) | ||
308 | interpretation.newElements += e | ||
309 | return e | ||
310 | } | ||
300 | 311 | ||
301 | def private initialisePartialTypeInterpretation(TypeDeclaration t, ViatraQueryEngine engine) { | 312 | def private initialisePartialTypeInterpretation(TypeDeclaration t, ViatraQueryEngine engine) { |
302 | val supertypeMatcher = SupertypeStar.Matcher.on(engine) | 313 | val supertypeMatcher = SupertypeStar.Matcher.on(engine) |
@@ -319,4 +330,18 @@ class PartialInterpretationInitialiser { | |||
319 | ] | 330 | ] |
320 | return res | 331 | return res |
321 | } | 332 | } |
333 | |||
334 | def private dispatch createUnknownValueElement(BoolTypeReference element) { | ||
335 | createRealElement => [it.valueSet = false] | ||
336 | } | ||
337 | def private dispatch createUnknownValueElement(IntTypeReference element) { | ||
338 | createRealElement => [it.valueSet = false] | ||
339 | } | ||
340 | def private dispatch createUnknownValueElement(RealTypeReference element) { | ||
341 | createRealElement => [it.valueSet = false] | ||
342 | } | ||
343 | def private dispatch createUnknownValueElement(ComplexTypeReference element) { | ||
344 | //TODO Enum handling | ||
345 | } | ||
346 | |||
322 | } \ No newline at end of file | 347 | } \ No newline at end of file |