aboutsummaryrefslogtreecommitdiffstats
path: root/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <marussy@mit.bme.hu>2020-05-20 02:07:37 +0200
committerLibravatar Kristóf Marussy <marussy@mit.bme.hu>2020-05-20 02:07:37 +0200
commiteb081453e93e6e30c0b6bb92400275529ed3273b (patch)
treeaba071677812e49eb101a429f01f28aa4f58a226 /Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf
parentFIx Boolean export to gml (diff)
downloadVIATRA-Generator-eb081453e93e6e30c0b6bb92400275529ed3273b.tar.gz
VIATRA-Generator-eb081453e93e6e30c0b6bb92400275529ed3273b.tar.zst
VIATRA-Generator-eb081453e93e6e30c0b6bb92400275529ed3273b.zip
Fix attribute export to xmi
Diffstat (limited to 'Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf')
-rw-r--r--Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicModelInterpretation.xtend76
1 files changed, 56 insertions, 20 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 905859eb..cdcbb48a 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
@@ -3,22 +3,27 @@ package hu.bme.mit.inf.dslreasoner.logic.model.builder
3import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ConstantDeclaration 3import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ConstantDeclaration
4import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement 4import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement
5import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.FunctionDeclaration 5import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.FunctionDeclaration
6import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguageFactory
6import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration 7import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration
8import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TermDescription
7import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type 9import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
8import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration 10import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration
9import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition 11import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition
12import java.math.BigDecimal
10import java.util.List 13import java.util.List
14import java.util.Map
15import java.util.SortedSet
16import java.util.TreeSet
11 17
12import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* 18import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
13import java.util.SortedSet
14import java.math.BigDecimal
15 19
16interface LogicModelInterpretation{ 20interface LogicModelInterpretation {
17 21
18 /** 22 /**
19 * Returns the elements of a type. 23 * Returns the elements of a type.
20 */ 24 */
21 def List<DefinedElement> getElements(Type type) 25 def List<DefinedElement> getElements(Type type)
26
22 /** 27 /**
23 * Returns the interpretation of a function. The parameters and the return values are encoded to primitive java objects defined by the following table: 28 * Returns the interpretation of a function. The parameters and the return values are encoded to primitive java objects defined by the following table:
24 * <p><table> 29 * <p><table>
@@ -34,6 +39,7 @@ interface LogicModelInterpretation{
34 * @return The result of the function call encoded as defined in the table. 39 * @return The result of the function call encoded as defined in the table.
35 */ 40 */
36 def Object getInterpretation(FunctionDeclaration function, Object[] parameterSubstitution) 41 def Object getInterpretation(FunctionDeclaration function, Object[] parameterSubstitution)
42
37 /** 43 /**
38 * Returns the interpretation of a relation. The parameters are encoded to primitive java objects defined by the following table: 44 * Returns the interpretation of a relation. The parameters are encoded to primitive java objects defined by the following table:
39 * <p><table> 45 * <p><table>
@@ -49,6 +55,7 @@ interface LogicModelInterpretation{
49 * @return If the parameter tuple is in the relation. 55 * @return If the parameter tuple is in the relation.
50 */ 56 */
51 def boolean getInterpretation(RelationDeclaration relation, Object[] parameterSubstitution) 57 def boolean getInterpretation(RelationDeclaration relation, Object[] parameterSubstitution)
58
52 /** 59 /**
53 * Returns the interpretation of a constant. The value is encoded to primitive java objects defined by the following table: 60 * Returns the interpretation of a constant. The value is encoded to primitive java objects defined by the following table:
54 * <p><table> 61 * <p><table>
@@ -63,60 +70,89 @@ interface LogicModelInterpretation{
63 * @return The value of the constant encoded as specified in the table. 70 * @return The value of the constant encoded as specified in the table.
64 */ 71 */
65 def Object getInterpretation(ConstantDeclaration constant) 72 def Object getInterpretation(ConstantDeclaration constant)
66 73
67 /** 74 /**
68 * Returns all integers relevant to the logic structure. Not all integer is necessarily used. 75 * Returns all integers relevant to the logic structure. Not all integer is necessarily used.
69 */ 76 */
70 def SortedSet<Integer> getAllIntegersInStructure() 77 def SortedSet<Integer> getAllIntegersInStructure()
78
79 def Map<TermDescription, Integer> getAllIntegersWithInterpretation() {
80 allIntegersInStructure.toMap [ integer |
81 (LogiclanguageFactory.eINSTANCE.createIntLiteral => [value = integer]) as TermDescription
82 ]
83 }
84
71 /** 85 /**
72 * Returns all real numbers relevant to the logic structure. Not all integer is necessarily used. 86 * Returns all real numbers relevant to the logic structure. Not all integer is necessarily used.
73 */ 87 */
74 def SortedSet<BigDecimal> getAllRealsInStructure() 88 def SortedSet<BigDecimal> getAllRealsInStructure()
75 /** 89
90 def Map<TermDescription, BigDecimal> getAllRealsWithInterpretation() {
91 allRealsInStructure.toMap [ real |
92 (LogiclanguageFactory.eINSTANCE.createRealLiteral => [value = real]) as TermDescription
93 ]
94 }
95
96 /**
76 * Returns all string values relevant to the logic structure. Not all integer is necessarily used. 97 * Returns all string values relevant to the logic structure. Not all integer is necessarily used.
77 */ 98 */
78 def SortedSet<String> getAllStringsInStructure() 99 def SortedSet<String> getAllStringsInStructure()
100
101 def Map<TermDescription, String> getAllStringsWithInterpretation() {
102 allStringsInStructure.toMap [ string |
103 (LogiclanguageFactory.eINSTANCE.createStringLiteral => [value = string]) as TermDescription
104 ]
105 }
106
107 def SortedSet<Boolean> getAllBooleansInStructure() {
108 new TreeSet(#{true, false})
109 }
110
111 def Map<TermDescription, Boolean> getAllBooleansWithInterpretation() {
112 allBooleansInStructure.toMap [ bool |
113 (LogiclanguageFactory.eINSTANCE.createBoolLiteral => [value = bool]) as TermDescription
114 ]
115 }
79} 116}
80 117
81class Uninterpreted implements LogicModelInterpretation { 118class Uninterpreted implements LogicModelInterpretation {
82 /*private val static unknownBecauseUninterpreted = LogiclanguageFactory.eINSTANCE.createUnknownBecauseUninterpreted 119 /*private val static unknownBecauseUninterpreted = LogiclanguageFactory.eINSTANCE.createUnknownBecauseUninterpreted
83 public def static getUnknownBecauseUninterpreted() {return Uninterpreted.unknownBecauseUninterpreted}*/ 120 public def static getUnknownBecauseUninterpreted() {return Uninterpreted.unknownBecauseUninterpreted}*/
84
85 override getElements(Type type) { 121 override getElements(Type type) {
86 throw new UnsupportedOperationException("The interpteration is unknown.") 122 throw new UnsupportedOperationException("The interpteration is unknown.")
87 } 123 }
88 124
89 def getKnownElements(Type type) { 125 def getKnownElements(Type type) {
90 val allSubtypes = type.transitiveClosureStar[it.subtypes] 126 val allSubtypes = type.transitiveClosureStar[it.subtypes]
91 return allSubtypes.filter(TypeDefinition).map[elements].flatten.toList 127 return allSubtypes.filter(TypeDefinition).map[elements].flatten.toList
92 } 128 }
93 129
94 def allElementsAreInterpreted(Type type) { 130 def allElementsAreInterpreted(Type type) {
95 val allSubtypes = type.transitiveClosureStar[it.subtypes] 131 val allSubtypes = type.transitiveClosureStar[it.subtypes]
96 return allSubtypes.exists[it instanceof TypeDeclaration] 132 return allSubtypes.exists[it instanceof TypeDeclaration]
97 } 133 }
98 134
99 override getInterpretation(FunctionDeclaration function, Object[] parameterSubstitution) { 135 override getInterpretation(FunctionDeclaration function, Object[] parameterSubstitution) {
100 throw new UnsupportedOperationException("The interpteration is unknown.") 136 throw new UnsupportedOperationException("The interpteration is unknown.")
101 } 137 }
102 138
103 override getInterpretation(RelationDeclaration relation, Object[] parameterSubstitution) { 139 override getInterpretation(RelationDeclaration relation, Object[] parameterSubstitution) {
104 throw new UnsupportedOperationException("The interpteration is unknown.") 140 throw new UnsupportedOperationException("The interpteration is unknown.")
105 } 141 }
106 142
107 override getInterpretation(ConstantDeclaration constant) { 143 override getInterpretation(ConstantDeclaration constant) {
108 throw new UnsupportedOperationException("The interpteration is unknown.") 144 throw new UnsupportedOperationException("The interpteration is unknown.")
109 } 145 }
110 146
111 override getAllIntegersInStructure() { 147 override getAllIntegersInStructure() {
112 throw new UnsupportedOperationException("The interpteration is unknown.") 148 throw new UnsupportedOperationException("The interpteration is unknown.")
113 } 149 }
114 150
115 override getAllRealsInStructure() { 151 override getAllRealsInStructure() {
116 throw new UnsupportedOperationException("The interpteration is unknown.") 152 throw new UnsupportedOperationException("The interpteration is unknown.")
117 } 153 }
118 154
119 override getAllStringsInStructure() { 155 override getAllStringsInStructure() {
120 throw new UnsupportedOperationException("The interpteration is unknown.") 156 throw new UnsupportedOperationException("The interpteration is unknown.")
121 } 157 }
122} \ No newline at end of file 158}