diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns')
3 files changed, 47 insertions, 0 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 d11b5960..d6a15c1a 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 | |||
@@ -155,6 +155,11 @@ class GenericTypeIndexer extends TypeIndexer { | |||
155 | find supertypeStar(type,definedSupertype); | 155 | find supertypeStar(type,definedSupertype); |
156 | TypeDefinition(definedSupertype); | 156 | TypeDefinition(definedSupertype); |
157 | } | 157 | } |
158 | |||
159 | private pattern scopeDisallowsNewElementsFromType(typeInterpretation:PartialComplexTypeInterpretation) { | ||
160 | Scope.targetTypeInterpretation(scope,typeInterpretation); | ||
161 | Scope.maxNewElements(scope,0); | ||
162 | } | ||
158 | ''' | 163 | ''' |
159 | 164 | ||
160 | public override generateInstanceOfQueries(LogicProblem problem, PartialInterpretation emptySolution,TypeAnalysisResult typeAnalysisResult) { | 165 | public override generateInstanceOfQueries(LogicProblem problem, PartialInterpretation emptySolution,TypeAnalysisResult typeAnalysisResult) { |
@@ -190,6 +195,7 @@ class GenericTypeIndexer extends TypeIndexer { | |||
190 | Type.name(type,"«type.name»"); | 195 | Type.name(type,"«type.name»"); |
191 | find possibleDynamicType(problem,interpretation,dynamic,element); | 196 | find possibleDynamicType(problem,interpretation,dynamic,element); |
192 | find supertypeStar(dynamic,type); | 197 | find supertypeStar(dynamic,type); |
198 | neg find scopeDisallowsNewElementsFromType(dynamic); | ||
193 | } | 199 | } |
194 | ''' | 200 | ''' |
195 | } | 201 | } |
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 39b6fbc0..329d3658 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 | |||
@@ -24,6 +24,7 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeCo | |||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | 24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery |
25 | 25 | ||
26 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 26 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint | ||
27 | 28 | ||
28 | class RelationDefinitionIndexer { | 29 | class RelationDefinitionIndexer { |
29 | val PatternGenerator base; | 30 | val PatternGenerator base; |
@@ -141,6 +142,35 @@ class RelationDefinitionIndexer { | |||
141 | throw new UnsupportedOperationException('''Unsupported touple size: «touple.size»''') | 142 | throw new UnsupportedOperationException('''Unsupported touple size: «touple.size»''') |
142 | } | 143 | } |
143 | } | 144 | } |
145 | private dispatch def transformConstraint(TypeFilterConstraint constraint, Modality modality) { | ||
146 | val touple = constraint.variablesTuple | ||
147 | if(touple.size == 1) { | ||
148 | val inputKey = constraint.equivalentJudgement.inputKey | ||
149 | if(inputKey instanceof EClassTransitiveInstancesKey) { | ||
150 | return base.typeIndexer.referInstanceOf(inputKey.emfKey,modality.toMustMay, | ||
151 | (constraint.getVariablesTuple.get(0) as PVariable).canonizeName) | ||
152 | } else if(inputKey instanceof EDataTypeInSlotsKey){ | ||
153 | return '''// type constraint is enforced by construction''' | ||
154 | } | ||
155 | |||
156 | } else if(touple.size == 2){ | ||
157 | val key = (constraint.equivalentJudgement.inputKey as EStructuralFeatureInstancesKey).emfKey | ||
158 | if(key instanceof EReference) { | ||
159 | return base.referRelationByName( | ||
160 | key, | ||
161 | (constraint.getVariablesTuple.get(0) as PVariable).canonizeName, | ||
162 | (constraint.getVariablesTuple.get(1) as PVariable).canonizeName, | ||
163 | modality.toMustMay) | ||
164 | } else if (key instanceof EAttribute) { | ||
165 | return base.referAttributeByName(key, | ||
166 | (constraint.getVariablesTuple.get(0) as PVariable).canonizeName, | ||
167 | (constraint.getVariablesTuple.get(1) as PVariable).canonizeName, | ||
168 | modality.toMustMay) | ||
169 | } else throw new UnsupportedOperationException('''unknown key: «key.class»''') | ||
170 | } else { | ||
171 | throw new UnsupportedOperationException('''Unsupported touple size: «touple.size»''') | ||
172 | } | ||
173 | } | ||
144 | 174 | ||
145 | private dispatch def transformConstraint(Equality equality, Modality modality) { | 175 | private dispatch def transformConstraint(Equality equality, Modality modality) { |
146 | val a = equality.who | 176 | val a = equality.who |
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 67a886d1..d3af0426 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 | |||
@@ -72,6 +72,15 @@ class TypeIndexerWithPreliminaryTypeAnalysis extends TypeIndexer{ | |||
72 | null | 72 | null |
73 | } | 73 | } |
74 | ''' | 74 | ''' |
75 | private pattern scopeDisallowsNew«base.canonizeName(type.name)»(problem:LogicProblem, interpretation:PartialInterpretation) { | ||
76 | find interpretation(problem,interpretation); | ||
77 | PartialInterpretation.scopes(interpretation,scope); | ||
78 | Scope.targetTypeInterpretation(scope,typeInterpretation); | ||
79 | Scope.maxNewElements(scope,0); | ||
80 | PartialComplexTypeInterpretation.interpretationOf(typeInterpretation,type); | ||
81 | Type.name(type,"«type.name»"); | ||
82 | } | ||
83 | |||
75 | /** | 84 | /** |
76 | * An element may be an instance of type "«type.name»". | 85 | * An element may be an instance of type "«type.name»". |
77 | */ | 86 | */ |
@@ -82,6 +91,7 @@ class TypeIndexerWithPreliminaryTypeAnalysis extends TypeIndexer{ | |||
82 | «FOR inhibitorType : inhibitorTypes» | 91 | «FOR inhibitorType : inhibitorTypes» |
83 | neg «referInstanceOf(inhibitorType,Modality.MUST,"element")» | 92 | neg «referInstanceOf(inhibitorType,Modality.MUST,"element")» |
84 | «ENDFOR» | 93 | «ENDFOR» |
94 | neg find scopeDisallowsNew«base.canonizeName(type.name)»(problem, interpretation); | ||
85 | neg find isPrimitive(element); | 95 | neg find isPrimitive(element); |
86 | } or { | 96 | } or { |
87 | find interpretation(problem,interpretation); | 97 | find interpretation(problem,interpretation); |
@@ -89,6 +99,7 @@ class TypeIndexerWithPreliminaryTypeAnalysis extends TypeIndexer{ | |||
89 | «FOR inhibitorType : inhibitorTypes» | 99 | «FOR inhibitorType : inhibitorTypes» |
90 | neg «referInstanceOf(inhibitorType,Modality.MUST,"element")» | 100 | neg «referInstanceOf(inhibitorType,Modality.MUST,"element")» |
91 | «ENDFOR» | 101 | «ENDFOR» |
102 | neg find scopeDisallowsNew«base.canonizeName(type.name)»(problem, interpretation); | ||
92 | neg find isPrimitive(element); | 103 | neg find isPrimitive(element); |
93 | } or | 104 | } or |
94 | «ENDIF» | 105 | «ENDIF» |