diff options
author | OszkarSemerath <oszka@SEMERATH-LAPTOP> | 2017-08-08 16:11:45 +0200 |
---|---|---|
committer | OszkarSemerath <oszka@SEMERATH-LAPTOP> | 2017-08-08 16:11:45 +0200 |
commit | 30c205f552a9c66c69903d4f12dd09f3e27e06ea (patch) | |
tree | b61a9a692220b7fe25f8aaa54d5cdcc70b024254 /Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu | |
parent | added String to the logic problem, and representations returns the set (diff) | |
download | VIATRA-Generator-30c205f552a9c66c69903d4f12dd09f3e27e06ea.tar.gz VIATRA-Generator-30c205f552a9c66c69903d4f12dd09f3e27e06ea.tar.zst VIATRA-Generator-30c205f552a9c66c69903d4f12dd09f3e27e06ea.zip |
Support for double and string attributes
Diffstat (limited to 'Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu')
2 files changed, 40 insertions, 38 deletions
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicModelInterpretation.xtend b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicModelInterpretation.xtend index aa59836c..905859eb 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicModelInterpretation.xtend +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicModelInterpretation.xtend | |||
@@ -27,6 +27,7 @@ interface LogicModelInterpretation{ | |||
27 | * <tr><td>Boolean literal </td><td>Boolean </td></tr> | 27 | * <tr><td>Boolean literal </td><td>Boolean </td></tr> |
28 | * <tr><td>Integer literal </td><td>Integer </td></tr> | 28 | * <tr><td>Integer literal </td><td>Integer </td></tr> |
29 | * <tr><td>Real literal </td><td>BigDecimal </td></tr> | 29 | * <tr><td>Real literal </td><td>BigDecimal </td></tr> |
30 | * <tr><td>String literal </td><td>String </td></tr> | ||
30 | * </table></p> | 31 | * </table></p> |
31 | * @param function The target function to be interpreted. | 32 | * @param function The target function to be interpreted. |
32 | * @param parameterSubstitution The array of the substituted parameters encoded as defined in the table. | 33 | * @param parameterSubstitution The array of the substituted parameters encoded as defined in the table. |
@@ -41,6 +42,7 @@ interface LogicModelInterpretation{ | |||
41 | * <tr><td>Boolean literal </td><td>Boolean </td></tr> | 42 | * <tr><td>Boolean literal </td><td>Boolean </td></tr> |
42 | * <tr><td>Integer literal </td><td>Integer </td></tr> | 43 | * <tr><td>Integer literal </td><td>Integer </td></tr> |
43 | * <tr><td>Real literal </td><td>BigDecimal </td></tr> | 44 | * <tr><td>Real literal </td><td>BigDecimal </td></tr> |
45 | * <tr><td>String literal </td><td>String </td></tr> | ||
44 | * </table></p> | 46 | * </table></p> |
45 | * @param relation The target relation to be interpreted. | 47 | * @param relation The target relation to be interpreted. |
46 | * @param parameterSubstitution The array of the substituted parameters encoded as defined in the table. | 48 | * @param parameterSubstitution The array of the substituted parameters encoded as defined in the table. |
@@ -55,6 +57,7 @@ interface LogicModelInterpretation{ | |||
55 | * <tr><td>Boolean literal </td><td>Boolean </td></tr> | 57 | * <tr><td>Boolean literal </td><td>Boolean </td></tr> |
56 | * <tr><td>Integer literal </td><td>Integer </td></tr> | 58 | * <tr><td>Integer literal </td><td>Integer </td></tr> |
57 | * <tr><td>Real literal </td><td>BigDecimal </td></tr> | 59 | * <tr><td>Real literal </td><td>BigDecimal </td></tr> |
60 | * <tr><td>String literal </td><td>String </td></tr> | ||
58 | * </table></p> | 61 | * </table></p> |
59 | * @param constant The target constant to be interpreted. | 62 | * @param constant The target constant to be interpreted. |
60 | * @return The value of the constant encoded as specified in the table. | 63 | * @return The value of the constant encoded as specified in the table. |
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicStructureBuilder.xtend b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicStructureBuilder.xtend index 760aa8b8..42f85a2d 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicStructureBuilder.xtend +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicStructureBuilder.xtend | |||
@@ -55,6 +55,10 @@ import org.eclipse.xtend.lib.annotations.Data | |||
55 | 55 | ||
56 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 56 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
57 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.InstanceOf | 57 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.InstanceOf |
58 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeReference | ||
59 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolTypeReference | ||
60 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealTypeReference | ||
61 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.StringTypeReference | ||
58 | 62 | ||
59 | @Data class InterpretationValidationResult { | 63 | @Data class InterpretationValidationResult { |
60 | val List<String> problems; | 64 | val List<String> problems; |
@@ -381,14 +385,28 @@ class LogicStructureBuilder{ | |||
381 | return (left as Number).asInteger == (right as Number).asInteger | 385 | return (left as Number).asInteger == (right as Number).asInteger |
382 | } | 386 | } |
383 | } else return left.equals(right) | 387 | } else return left.equals(right) |
384 | } | 388 | } |
385 | 389 | ||
386 | def allIntegers(LogicModelInterpretation interpretation) { | 390 | private dispatch def allObjects(LogicModelInterpretation interpretation, ComplexTypeReference type) { |
387 | if(interpretation.minimalInteger <= interpretation.maximalInteger) { | 391 | return interpretation.getElements(type.referred) |
388 | (interpretation.minimalInteger .. interpretation.maximalInteger).map[asInteger] | 392 | } |
389 | } else return emptySet | 393 | private dispatch def allObjects(LogicModelInterpretation interpretation, BoolTypeReference type) { |
394 | return #[true,false] | ||
395 | } | ||
396 | private dispatch def allObjects(LogicModelInterpretation interpretation, IntTypeReference type) { | ||
397 | return interpretation.allIntegersInStructure | ||
398 | } | ||
399 | private dispatch def allObjects(LogicModelInterpretation interpretation, RealTypeReference type) { | ||
400 | return interpretation.allRealsInStructure | ||
401 | } | ||
402 | private dispatch def allObjects(LogicModelInterpretation interpretation, StringTypeReference type) { | ||
403 | return interpretation.allStringsInStructure | ||
404 | } | ||
405 | private dispatch def allObjects(LogicModelInterpretation interpretation, TypeReference type) { | ||
406 | throw new UnsupportedOperationException('''Unknown type :«type.class.simpleName»!''') | ||
390 | } | 407 | } |
391 | 408 | ||
409 | |||
392 | def private boolean executeExists( | 410 | def private boolean executeExists( |
393 | Term expression, | 411 | Term expression, |
394 | LogicModelInterpretation interpretation, | 412 | LogicModelInterpretation interpretation, |
@@ -401,23 +419,13 @@ class LogicStructureBuilder{ | |||
401 | } | 419 | } |
402 | else { | 420 | else { |
403 | val unfoldedVariable = variablesToBind.head | 421 | val unfoldedVariable = variablesToBind.head |
404 | val possibleValuesType = unfoldedVariable.range | 422 | val possibleValues = interpretation.allObjects(unfoldedVariable.range) |
405 | if(possibleValuesType instanceof ComplexTypeReference) { | 423 | return possibleValues.exists[newBinding | |
406 | return this.getElements(interpretation,possibleValuesType.referred).exists[newBinding | | 424 | executeExists( |
407 | executeExists( | 425 | expression, |
408 | expression, | 426 | interpretation, |
409 | interpretation, | 427 | new HashMap(variableBinding) => [put(unfoldedVariable,newBinding)], |
410 | new HashMap(variableBinding) => [put(unfoldedVariable,newBinding)], | 428 | variablesToBind.subList(1,variablesToBind.size))] |
411 | variablesToBind.subList(1,variablesToBind.size))] | ||
412 | } else if(possibleValuesType instanceof IntTypeReference) { | ||
413 | return interpretation.allIntegers.exists[newBinding | | ||
414 | executeExists( | ||
415 | expression, | ||
416 | interpretation, | ||
417 | new HashMap(variableBinding) => [put(unfoldedVariable,newBinding)], | ||
418 | variablesToBind.subList(1,variablesToBind.size))] | ||
419 | } | ||
420 | else throw new UnsupportedOperationException('''Quantifying over type "«possibleValuesType»" is unsupported.''') | ||
421 | } | 429 | } |
422 | } | 430 | } |
423 | 431 | ||
@@ -432,22 +440,13 @@ class LogicStructureBuilder{ | |||
432 | } | 440 | } |
433 | else { | 441 | else { |
434 | val unfoldedVariable = variablesToBind.head | 442 | val unfoldedVariable = variablesToBind.head |
435 | val possibleValuesType = unfoldedVariable.range | 443 | val possibleValues = interpretation.allObjects(unfoldedVariable.range) |
436 | if(possibleValuesType instanceof ComplexTypeReference) { | 444 | return possibleValues.forall[newBinding | |
437 | return this.getElements(interpretation,possibleValuesType.referred).forall[newBinding | | 445 | executeForall( |
438 | executeForall( | 446 | expression, |
439 | expression, | 447 | interpretation, |
440 | interpretation, | 448 | new HashMap(variableBinding) => [put(unfoldedVariable,newBinding)], |
441 | new HashMap(variableBinding) => [put(unfoldedVariable,newBinding)], | 449 | variablesToBind.subList(1,variablesToBind.size))] |
442 | variablesToBind.subList(1,variablesToBind.size))] | ||
443 | } else if(possibleValuesType instanceof IntTypeReference) { | ||
444 | return interpretation.allIntegers.forall[newBinding | | ||
445 | executeForall( | ||
446 | expression, | ||
447 | interpretation, | ||
448 | new HashMap(variableBinding) => [put(unfoldedVariable,newBinding)], | ||
449 | variablesToBind.subList(1,variablesToBind.size))] | ||
450 | } else throw new UnsupportedOperationException('''Quantifying over type "«possibleValuesType»" is unsupported.''') | ||
451 | } | 450 | } |
452 | } | 451 | } |
453 | } \ No newline at end of file | 452 | } \ No newline at end of file |