diff options
author | 2017-08-16 17:13:22 +0200 | |
---|---|---|
committer | 2017-08-16 17:13:22 +0200 | |
commit | d1b2d628bf515f0a1772eaff7366f9c29c1b02ce (patch) | |
tree | 7bf46a1f850b3980b1d38c71a4cb3f791e81084d /Solvers | |
parent | Added separate symbolic objects to all primitive objects (diff) | |
download | VIATRA-Generator-d1b2d628bf515f0a1772eaff7366f9c29c1b02ce.tar.gz VIATRA-Generator-d1b2d628bf515f0a1772eaff7366f9c29c1b02ce.tar.zst VIATRA-Generator-d1b2d628bf515f0a1772eaff7366f9c29c1b02ce.zip |
Mapping of primitive types in patterns
Diffstat (limited to 'Solvers')
9 files changed, 128 insertions, 33 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/GenericTypeIndexer.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/GenericTypeIndexer.xtend index 23bdda35..a703ba4b 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/GenericTypeIndexer.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/GenericTypeIndexer.xtend | |||
@@ -7,7 +7,7 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality | |||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeAnalysisResult | 8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeAnalysisResult |
9 | 9 | ||
10 | class GenericTypeIndexer implements TypeIndexer { | 10 | class GenericTypeIndexer extends TypeIndexer { |
11 | val PatternGenerator base; | 11 | val PatternGenerator base; |
12 | 12 | ||
13 | new(PatternGenerator base) { | 13 | new(PatternGenerator base) { |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend index 2986e344..6e1e5765 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend | |||
@@ -21,6 +21,11 @@ import java.util.HashSet | |||
21 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.InverseRelationAssertion | 21 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.InverseRelationAssertion |
22 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation | 22 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation |
23 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.DefinedByDerivedFeature | 23 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.DefinedByDerivedFeature |
24 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeReference | ||
25 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolTypeReference | ||
26 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntTypeReference | ||
27 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealTypeReference | ||
28 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.StringTypeReference | ||
24 | 29 | ||
25 | class PatternGenerator { | 30 | class PatternGenerator { |
26 | @Accessors(PUBLIC_GETTER) val TypeIndexer typeIndexer //= new TypeIndexer(this) | 31 | @Accessors(PUBLIC_GETTER) val TypeIndexer typeIndexer //= new TypeIndexer(this) |
@@ -126,13 +131,28 @@ class PatternGenerator { | |||
126 | relation.annotations.filter(DefinedByDerivedFeature).head.query | 131 | relation.annotations.filter(DefinedByDerivedFeature).head.query |
127 | } | 132 | } |
128 | 133 | ||
134 | private def allTypeReferences(LogicProblem problem) { | ||
135 | problem.eAllContents.filter(TypeReference).toIterable | ||
136 | } | ||
137 | protected def hasBoolean(LogicProblem problem) { | ||
138 | problem.allTypeReferences.exists[it instanceof BoolTypeReference] | ||
139 | } | ||
140 | protected def hasInteger(LogicProblem problem) { | ||
141 | problem.allTypeReferences.exists[it instanceof IntTypeReference] | ||
142 | } | ||
143 | protected def hasReal(LogicProblem problem) { | ||
144 | problem.allTypeReferences.exists[it instanceof RealTypeReference] | ||
145 | } | ||
146 | protected def hasString(LogicProblem problem) { | ||
147 | problem.allTypeReferences.exists[it instanceof StringTypeReference] | ||
148 | } | ||
149 | |||
129 | public def transformBaseProperties( | 150 | public def transformBaseProperties( |
130 | LogicProblem problem, | 151 | LogicProblem problem, |
131 | PartialInterpretation emptySolution, | 152 | PartialInterpretation emptySolution, |
132 | Map<String,PQuery> fqn2PQuery, | 153 | Map<String,PQuery> fqn2PQuery, |
133 | TypeAnalysisResult typeAnalysisResult | 154 | TypeAnalysisResult typeAnalysisResult |
134 | ) { | 155 | ) { |
135 | |||
136 | return ''' | 156 | return ''' |
137 | import epackage "http://www.bme.hu/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage" | 157 | import epackage "http://www.bme.hu/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage" |
138 | import epackage "http://www.bme.hu/mit/inf/dslreasoner/logic/model/problem" | 158 | import epackage "http://www.bme.hu/mit/inf/dslreasoner/logic/model/problem" |
@@ -146,7 +166,7 @@ class PatternGenerator { | |||
146 | } | 166 | } |
147 | 167 | ||
148 | ///////////////////////// | 168 | ///////////////////////// |
149 | // 0.1 Existance | 169 | // 0.1 Existence |
150 | ///////////////////////// | 170 | ///////////////////////// |
151 | private pattern mustExist(problem:LogicProblem, interpetation:PartialInterpretation, element:DefinedElement) { | 171 | private pattern mustExist(problem:LogicProblem, interpetation:PartialInterpretation, element:DefinedElement) { |
152 | find interpretation(problem,interpetation); | 172 | find interpretation(problem,interpetation); |
@@ -154,19 +174,52 @@ class PatternGenerator { | |||
154 | } or { | 174 | } or { |
155 | find interpretation(problem,interpetation); | 175 | find interpretation(problem,interpetation); |
156 | PartialInterpretation.newElements(interpetation,element); | 176 | PartialInterpretation.newElements(interpetation,element); |
157 | } | 177 | } or { |
178 | find interpretation(problem,interpetation); | ||
179 | PartialInterpretation.booleanelements(interpetation,element); | ||
180 | } or { | ||
181 | find interpretation(problem,interpetation); | ||
182 | PartialInterpretation.integerelements(interpetation,element); | ||
183 | } or { | ||
184 | find interpretation(problem,interpetation); | ||
185 | PartialInterpretation.realelements(interpetation,element); | ||
186 | } | ||
187 | find interpretation(problem,interpetation); | ||
188 | PartialInterpretation.stringelements(interpetation,element); | ||
189 | } | ||
158 | 190 | ||
159 | private pattern mayExist(problem:LogicProblem, interpetation:PartialInterpretation, element:DefinedElement) { | 191 | private pattern mayExist(problem:LogicProblem, interpetation:PartialInterpretation, element:DefinedElement) { |
160 | find mustExist(problem,interpetation,element); | 192 | find mustExist(problem,interpetation,element); |
161 | } or { | 193 | } or { |
162 | find interpretation(problem,interpetation); | 194 | find interpretation(problem,interpetation); |
163 | neg find closeWorld(interpetation); | 195 | neg find elementCloseWorld(interpetation); |
164 | PartialInterpretation.openWorldElementPrototypes(interpetation,element); | 196 | PartialInterpretation.openWorldElementPrototypes(interpetation,element); |
197 | } or { | ||
198 | find interpretation(problem,interpetation); | ||
199 | neg find integerCloseWorld(interpetation); | ||
200 | PartialInterpretation.newIntegers(interpetation,element) | ||
201 | } or { | ||
202 | find interpretation(problem,interpetation); | ||
203 | neg find realCloseWorld(interpetation); | ||
204 | PartialInterpretation.newReals(interpetation,element) | ||
205 | } or { | ||
206 | find interpretation(problem,interpetation); | ||
207 | neg find stringCloseWorld(interpetation); | ||
208 | PartialInterpretation.newStrings(interpetation,element) | ||
165 | } | 209 | } |
166 | 210 | ||
167 | private pattern closeWorld(interpetation:PartialInterpretation) { | 211 | private pattern elementCloseWorld(interpetation:PartialInterpretation) { |
168 | PartialInterpretation.maxNewElements(interpetation,0); | 212 | PartialInterpretation.maxNewElements(interpetation,0); |
169 | } | 213 | } |
214 | private pattern integerCloseWorld(interpetation:PartialInterpretation) { | ||
215 | PartialInterpretation.maxNewIntegers(interpetation,0); | ||
216 | } | ||
217 | private pattern realCloseWorld(interpetation:PartialInterpretation) { | ||
218 | PartialInterpretation.maxNewReals(interpetation,0); | ||
219 | } | ||
220 | private pattern stringCloseWorld(interpetation:PartialInterpretation) { | ||
221 | PartialInterpretation.maxNewStrings(interpetation,0); | ||
222 | } | ||
170 | 223 | ||
171 | //////////////////////// | 224 | //////////////////////// |
172 | // 0.2 Equivalence | 225 | // 0.2 Equivalence |
@@ -187,6 +240,37 @@ class PatternGenerator { | |||
187 | ////////// | 240 | ////////// |
188 | // 1.1 Type Indexers | 241 | // 1.1 Type Indexers |
189 | ////////// | 242 | ////////// |
243 | // 1.1.1 primitive Type Indexers | ||
244 | ////////// | ||
245 | pattern instaneofBoolean(problem:LogicProblem, interpretation:PartialInterpretation, element:DefinedElement) { | ||
246 | find interpretation(problem,interpretation); | ||
247 | PartialInterpretation.booleanelements(interpretation,element); | ||
248 | } | ||
249 | pattern instaneofInteger(problem:LogicProblem, interpretation:PartialInterpretation, element:DefinedElement) { | ||
250 | find interpretation(problem,interpretation); | ||
251 | PartialInterpretation.integerelements(interpretation,element); | ||
252 | } or { | ||
253 | find interpretation(problem,interpretation); | ||
254 | PartialInterpretation.newIntegers(interpetation,element); | ||
255 | } | ||
256 | pattern instaneofReal(problem:LogicProblem, interpretation:PartialInterpretation, element:DefinedElement) { | ||
257 | find interpretation(problem,interpretation); | ||
258 | PartialInterpretation.realements(interpretation,element); | ||
259 | } or { | ||
260 | find interpretation(problem,interpretation); | ||
261 | PartialInterpretation.newReals(interpetation,element); | ||
262 | } | ||
263 | pattern instaneofString(problem:LogicProblem, interpretation:PartialInterpretation, element:DefinedElement) { | ||
264 | find interpretation(problem,interpretation); | ||
265 | PartialInterpretation.stringelements(interpretation,element); | ||
266 | } or { | ||
267 | find interpretation(problem,interpretation); | ||
268 | PartialInterpretation.newStrings(interpetation,element); | ||
269 | } | ||
270 | |||
271 | ////////// | ||
272 | // 1.1.2 domain-specific Type Indexers | ||
273 | ////////// | ||
190 | «typeIndexer.generateInstanceOfQueries(problem,emptySolution,typeAnalysisResult)» | 274 | «typeIndexer.generateInstanceOfQueries(problem,emptySolution,typeAnalysisResult)» |
191 | 275 | ||
192 | ////////// | 276 | ////////// |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDeclarationIndexer.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDeclarationIndexer.xtend index e6d92cc6..f384cd50 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDeclarationIndexer.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDeclarationIndexer.xtend | |||
@@ -1,10 +1,8 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns |
2 | 2 | ||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.UpperMultiplicityAssertion | 3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.UpperMultiplicityAssertion |
4 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation | 4 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation |
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration | 5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration |
7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeReference | ||
8 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem |
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality | 7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality |
10 | import java.util.HashMap | 8 | import java.util.HashMap |
@@ -86,8 +84,8 @@ class RelationDeclarationIndexer { | |||
86 | find mayExist(problem, interpretation, source); | 84 | find mayExist(problem, interpretation, source); |
87 | find mayExist(problem, interpretation, target); | 85 | find mayExist(problem, interpretation, target); |
88 | // Type consistency | 86 | // Type consistency |
89 | «transformTypeConsistency(relation.parameters.get(0),"source")» | 87 | «base.typeIndexer.referInstanceOfByReference(relation.parameters.get(0),Modality.MAY,"source")» |
90 | «transformTypeConsistency(relation.parameters.get(1),"target")» | 88 | «base.typeIndexer.referInstanceOfByReference(relation.parameters.get(1),Modality.MAY,"target")» |
91 | «IF upperMultiplicities.containsKey(relation)» | 89 | «IF upperMultiplicities.containsKey(relation)» |
92 | // There are "numberOfExistingReferences" currently existing instances of the reference from the source, | 90 | // There are "numberOfExistingReferences" currently existing instances of the reference from the source, |
93 | // the upper bound of the multiplicity should be considered. | 91 | // the upper bound of the multiplicity should be considered. |
@@ -142,13 +140,4 @@ class RelationDeclarationIndexer { | |||
142 | «base.relationDefinitionIndexer.referPattern(definition,#["source","target"],Modality::MAY,true,false)» | 140 | «base.relationDefinitionIndexer.referPattern(definition,#["source","target"],Modality::MAY,true,false)» |
143 | } | 141 | } |
144 | ''' | 142 | ''' |
145 | |||
146 | protected def CharSequence transformTypeConsistency(TypeReference reference, String name) { | ||
147 | if(reference instanceof ComplexTypeReference) { | ||
148 | this.base.typeIndexer.referInstanceOf(reference.referred,Modality.MAY,name) | ||
149 | } else { | ||
150 | return '''// Primitive type of «name» is already enforced''' | ||
151 | } | ||
152 | |||
153 | } | ||
154 | } \ No newline at end of file | 143 | } \ No newline at end of file |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDefinitionIndexer.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDefinitionIndexer.xtend index 7792eccb..b400652f 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDefinitionIndexer.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDefinitionIndexer.xtend | |||
@@ -103,7 +103,10 @@ class RelationDefinitionIndexer { | |||
103 | constraint.getVariableInTuple(1).canonizeName, | 103 | constraint.getVariableInTuple(1).canonizeName, |
104 | modality.toMustMay) | 104 | modality.toMustMay) |
105 | } else if (key instanceof EAttribute) { | 105 | } else if (key instanceof EAttribute) { |
106 | return '''// attribute reference omitted'''//base.referRelationByName() | 106 | return base.referAttributeByName(key, |
107 | constraint.getVariableInTuple(0).canonizeName, | ||
108 | constraint.getVariableInTuple(1).canonizeName, | ||
109 | modality.toMustMay) | ||
107 | } else throw new UnsupportedOperationException('''unknown key: «key.class»''') | 110 | } else throw new UnsupportedOperationException('''unknown key: «key.class»''') |
108 | } else { | 111 | } else { |
109 | throw new UnsupportedOperationException() | 112 | throw new UnsupportedOperationException() |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend index 7b175227..f9e9baea 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend | |||
@@ -30,8 +30,8 @@ class RelationRefinementGenerator { | |||
30 | «ENDIF» | 30 | «ENDIF» |
31 | find mustExist(problem, interpretation, from); | 31 | find mustExist(problem, interpretation, from); |
32 | find mustExist(problem, interpretation, to); | 32 | find mustExist(problem, interpretation, to); |
33 | «base.typeIndexer.referInstanceOf((relationRefinement.key.parameters.get(0) as ComplexTypeReference).referred, Modality::MUST,"from")» | 33 | «base.typeIndexer.referInstanceOfByReference(relationRefinement.key.parameters.get(0), Modality::MUST,"from")» |
34 | «base.typeIndexer.referInstanceOf((relationRefinement.key.parameters.get(1) as ComplexTypeReference).referred, Modality::MUST,"to")» | 34 | «base.typeIndexer.referInstanceOfByReference(relationRefinement.key.parameters.get(1), Modality::MUST,"to")» |
35 | «base.relationDeclarationIndexer.referRelation(relationRefinement.key,"from","to",Modality.MAY)» | 35 | «base.relationDeclarationIndexer.referRelation(relationRefinement.key,"from","to",Modality.MAY)» |
36 | neg «base.relationDeclarationIndexer.referRelation(relationRefinement.key,"from","to",Modality.MUST)» | 36 | neg «base.relationDeclarationIndexer.referRelation(relationRefinement.key,"from","to",Modality.MUST)» |
37 | } | 37 | } |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeIndexer.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeIndexer.xtend index 6c450664..9afec0de 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeIndexer.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeIndexer.xtend | |||
@@ -6,11 +6,33 @@ import org.eclipse.emf.ecore.EClass | |||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality | 6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality |
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeAnalysisResult | 8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeAnalysisResult |
9 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference | ||
10 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolTypeReference | ||
11 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntTypeReference | ||
12 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealTypeReference | ||
13 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.StringTypeReference | ||
9 | 14 | ||
10 | interface TypeIndexer { | 15 | abstract class TypeIndexer { |
11 | public def CharSequence getRequiredQueries() | 16 | public def CharSequence getRequiredQueries() |
12 | public def boolean requiresTypeAnalysis() | 17 | public def boolean requiresTypeAnalysis() |
13 | public def CharSequence generateInstanceOfQueries(LogicProblem problem,PartialInterpretation emptySolution,TypeAnalysisResult typeAnalysisResult) | 18 | public def CharSequence generateInstanceOfQueries(LogicProblem problem,PartialInterpretation emptySolution,TypeAnalysisResult typeAnalysisResult) |
14 | public def CharSequence referInstanceOf(Type type, Modality modality, String variableName) | 19 | public def CharSequence referInstanceOf(Type type, Modality modality, String variableName) |
15 | public def CharSequence referInstanceOf(EClass type, Modality modality, String variableName) | 20 | public def CharSequence referInstanceOf(EClass type, Modality modality, String variableName) |
21 | |||
22 | public def dispatch CharSequence referInstanceOfByReference(ComplexTypeReference reference, Modality modality, String variableName) { | ||
23 | reference.referred.referInstanceOf(modality,variableName) | ||
24 | } | ||
25 | public def dispatch CharSequence referInstanceOfByReference(BoolTypeReference reference, Modality modality, String variableName) { | ||
26 | '''find instaneofBoolean(problem, interpretation, «variableName»);''' | ||
27 | } | ||
28 | public def dispatch CharSequence referInstanceOfByReference(IntTypeReference reference, Modality modality, String variableName) { | ||
29 | '''find pattern instaneofInteger(problem, interpretation, «variableName»);''' | ||
30 | } | ||
31 | public def dispatch CharSequence referInstanceOfByReference(RealTypeReference reference, Modality modality, String variableName) { | ||
32 | '''find pattern instaneofReal(problem, interpretation, «variableName»);''' | ||
33 | } | ||
34 | public def dispatch CharSequence referInstanceOfByReference(StringTypeReference reference, Modality modality, String variableName) { | ||
35 | '''find pattern instaneofString(problem, interpretation, «variableName»);''' | ||
36 | } | ||
37 | |||
16 | } \ No newline at end of file | 38 | } \ No newline at end of file |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeIndexerWithPreliminaryTypeAnalysis.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeIndexerWithPreliminaryTypeAnalysis.xtend index 4e30ec78..73e43d52 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeIndexerWithPreliminaryTypeAnalysis.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeIndexerWithPreliminaryTypeAnalysis.xtend | |||
@@ -9,7 +9,7 @@ import org.eclipse.emf.ecore.EClass | |||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeRefinementPrecondition | 9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeRefinementPrecondition |
10 | import java.util.Collections | 10 | import java.util.Collections |
11 | 11 | ||
12 | class TypeIndexerWithPreliminaryTypeAnalysis implements TypeIndexer{ | 12 | class TypeIndexerWithPreliminaryTypeAnalysis extends TypeIndexer{ |
13 | val PatternGenerator base; | 13 | val PatternGenerator base; |
14 | 14 | ||
15 | new(PatternGenerator base) { | 15 | new(PatternGenerator base) { |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2Logic.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2Logic.xtend index 216ae348..d2b59754 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2Logic.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2Logic.xtend | |||
@@ -13,10 +13,9 @@ class InstanceModel2Logic { | |||
13 | 13 | ||
14 | public def transform( | 14 | public def transform( |
15 | TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult, | 15 | TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult, |
16 | List<EObject> objects, | 16 | List<EObject> objects) |
17 | TypeScopes typeScopes) | ||
18 | { | 17 | { |
19 | val res1 = this.instanceModel2PartialInterpretation.transform(metamodelTranslationResult,objects,true,typeScopes) | 18 | val res1 = instanceModel2PartialInterpretation.transform(metamodelTranslationResult,objects,true) |
20 | this.partialInterpretation2Logic.transformPartialIntepretation2Logic(metamodelTranslationResult.output,res1) | 19 | this.partialInterpretation2Logic.transformPartialIntepretation2Logic(metamodelTranslationResult.output,res1) |
21 | return metamodelTranslationResult//.output | 20 | return metamodelTranslationResult//.output |
22 | } | 21 | } |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend index 4c6cf769..080ad963 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend | |||
@@ -30,22 +30,20 @@ class InstanceModel2PartialInterpretation { | |||
30 | public def transform( | 30 | public def transform( |
31 | TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult, | 31 | TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult, |
32 | Resource resource, | 32 | Resource resource, |
33 | boolean withID, | 33 | boolean withID) |
34 | TypeScopes typeScopes) | ||
35 | { | 34 | { |
36 | val objects = resource.allContents.toList | 35 | val objects = resource.allContents.toList |
37 | return transform(metamodelTranslationResult,objects,withID,typeScopes) | 36 | return transform(metamodelTranslationResult,objects,withID) |
38 | } | 37 | } |
39 | 38 | ||
40 | public def transform( | 39 | public def transform( |
41 | TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult, | 40 | TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult, |
42 | List<EObject> objects, | 41 | List<EObject> objects, |
43 | boolean withID, | 42 | boolean withID) |
44 | TypeScopes typeScopes) | ||
45 | { | 43 | { |
46 | val problem = metamodelTranslationResult.output | 44 | val problem = metamodelTranslationResult.output |
47 | val ecore2LogicTrace = metamodelTranslationResult.trace | 45 | val ecore2LogicTrace = metamodelTranslationResult.trace |
48 | val tracedOutput = partialInterpretationInitialiser.initialisePartialInterpretation(problem, typeScopes) | 46 | val tracedOutput = partialInterpretationInitialiser.initialisePartialInterpretation(problem, new TypeScopes) |
49 | val partialInterpretation = tracedOutput.output | 47 | val partialInterpretation = tracedOutput.output |
50 | val partialInterpretationTrace = tracedOutput.trace | 48 | val partialInterpretationTrace = tracedOutput.trace |
51 | 49 | ||