diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu')
3 files changed, 47 insertions, 8 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/GenericTypeRefinementGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/GenericTypeRefinementGenerator.xtend index 4b7af959..1081fafc 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/GenericTypeRefinementGenerator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/GenericTypeRefinementGenerator.xtend | |||
@@ -25,6 +25,12 @@ class GenericTypeRefinementGenerator extends TypeRefinementGenerator { | |||
25 | inverseRelations.put(it.inverseB,it.inverseA) | 25 | inverseRelations.put(it.inverseB,it.inverseA) |
26 | ] | 26 | ] |
27 | return ''' | 27 | return ''' |
28 | private pattern hasElementInContainment(problem:LogicProblem, interpretation:PartialInterpretation) | ||
29 | «FOR type :containment.typesOrderedInHierarchy SEPARATOR "or"»{ | ||
30 | find interpretation(problem,interpretation); | ||
31 | «base.typeIndexer.referInstanceOf(type,Modality.MAY,"root")» | ||
32 | find mustExist(problem, interpretation, root); | ||
33 | }«ENDFOR» | ||
28 | «FOR type:newObjectTypes» | 34 | «FOR type:newObjectTypes» |
29 | «IF(containment.typesOrderedInHierarchy.contains(type))» | 35 | «IF(containment.typesOrderedInHierarchy.contains(type))» |
30 | «FOR containmentRelation : containment.containmentRelations.filter[canBeContainedByRelation(it,type)]» | 36 | «FOR containmentRelation : containment.containmentRelations.filter[canBeContainedByRelation(it,type)]» |
@@ -66,6 +72,18 @@ class GenericTypeRefinementGenerator extends TypeRefinementGenerator { | |||
66 | } | 72 | } |
67 | «ENDIF» | 73 | «ENDIF» |
68 | «ENDFOR» | 74 | «ENDFOR» |
75 | pattern «patternName(null,null,type)»( | ||
76 | problem:LogicProblem, interpretation:PartialInterpretation, | ||
77 | typeInterpretation:PartialTypeInterpratation) | ||
78 | { | ||
79 | find interpretation(problem,interpretation); | ||
80 | neg find hasElementInContainment(problem,interpretation); | ||
81 | PartialInterpretation.partialtypeinterpratation(interpretation,typeInterpretation); | ||
82 | PartialTypeInterpratation.interpretationOf.name(type,"«type.name»"); | ||
83 | «base.typeIndexer.referInstanceOf(type,Modality.MAY,"newObject")» | ||
84 | find mayExist(problem, interpretation, newObject); | ||
85 | neg find mustExist(problem, interpretation, newObject); | ||
86 | } | ||
69 | «ELSE» | 87 | «ELSE» |
70 | pattern createObject_«this.patternName(null,null,type)»( | 88 | pattern createObject_«this.patternName(null,null,type)»( |
71 | problem:LogicProblem, interpretation:PartialInterpretation, | 89 | problem:LogicProblem, interpretation:PartialInterpretation, |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementGenerator.xtend index a9ce9d73..7e3fad91 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementGenerator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementGenerator.xtend | |||
@@ -1,19 +1,20 @@ | |||
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.InverseRelationAssertion | ||
4 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference | ||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation | 5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation |
4 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type |
7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration | ||
8 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.ContainmentHierarchy | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | 9 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem |
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeAnalysisResult | 10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeAnalysisResult |
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
8 | import java.util.Map | ||
9 | import org.eclipse.xtend.lib.annotations.Data | ||
10 | import java.util.HashMap | 12 | import java.util.HashMap |
11 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.InverseRelationAssertion | ||
12 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration | ||
13 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference | ||
14 | import java.util.LinkedHashMap | 13 | import java.util.LinkedHashMap |
14 | import java.util.Map | ||
15 | import org.eclipse.xtend.lib.annotations.Data | ||
16 | |||
15 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 17 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
16 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.ContainmentHierarchy | ||
17 | 18 | ||
18 | @Data | 19 | @Data |
19 | class ObjectCreationPrecondition { | 20 | class ObjectCreationPrecondition { |
@@ -54,6 +55,9 @@ abstract class TypeRefinementGenerator { | |||
54 | patternName(containmentRelation,null,type)) | 55 | patternName(containmentRelation,null,type)) |
55 | } | 56 | } |
56 | } | 57 | } |
58 | objectCreationQueries.put( | ||
59 | new ObjectCreationPrecondition(null,null,type), | ||
60 | patternName(null,null,type)) | ||
57 | } else { | 61 | } else { |
58 | objectCreationQueries.put( | 62 | objectCreationQueries.put( |
59 | new ObjectCreationPrecondition(null,null,type), | 63 | new ObjectCreationPrecondition(null,null,type), |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementWithPreliminaryTypeAnalysis.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementWithPreliminaryTypeAnalysis.xtend index be54d63c..81f2f7db 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementWithPreliminaryTypeAnalysis.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementWithPreliminaryTypeAnalysis.xtend | |||
@@ -15,7 +15,6 @@ class TypeRefinementWithPreliminaryTypeAnalysis extends TypeRefinementGenerator{ | |||
15 | } | 15 | } |
16 | override requiresTypeAnalysis() { true } | 16 | override requiresTypeAnalysis() { true } |
17 | 17 | ||
18 | |||
19 | override generateRefineObjectQueries(LogicProblem p, PartialInterpretation emptySolution, TypeAnalysisResult typeAnalysisResult) { | 18 | override generateRefineObjectQueries(LogicProblem p, PartialInterpretation emptySolution, TypeAnalysisResult typeAnalysisResult) { |
20 | val possibleNewDynamicType = typeAnalysisResult.possibleNewDynamicTypes | 19 | val possibleNewDynamicType = typeAnalysisResult.possibleNewDynamicTypes |
21 | val containment = p.containmentHierarchies.head | 20 | val containment = p.containmentHierarchies.head |
@@ -25,6 +24,12 @@ class TypeRefinementWithPreliminaryTypeAnalysis extends TypeRefinementGenerator{ | |||
25 | inverseRelations.put(it.inverseB,it.inverseA) | 24 | inverseRelations.put(it.inverseB,it.inverseA) |
26 | ] | 25 | ] |
27 | return ''' | 26 | return ''' |
27 | private pattern hasElementInContainment(problem:LogicProblem, interpretation:PartialInterpretation) | ||
28 | «FOR type :containment.typesOrderedInHierarchy SEPARATOR "or"»{ | ||
29 | find interpretation(problem,interpretation); | ||
30 | «base.typeIndexer.referInstanceOf(type,Modality.MAY,"root")» | ||
31 | find mustExist(problem, interpretation, root); | ||
32 | }«ENDFOR» | ||
28 | «FOR type:possibleNewDynamicType» | 33 | «FOR type:possibleNewDynamicType» |
29 | «IF(containment.typesOrderedInHierarchy.contains(type))» | 34 | «IF(containment.typesOrderedInHierarchy.contains(type))» |
30 | «FOR containmentRelation : containment.containmentRelations.filter[canBeContainedByRelation(it,type)]» | 35 | «FOR containmentRelation : containment.containmentRelations.filter[canBeContainedByRelation(it,type)]» |
@@ -66,8 +71,20 @@ class TypeRefinementWithPreliminaryTypeAnalysis extends TypeRefinementGenerator{ | |||
66 | } | 71 | } |
67 | «ENDIF» | 72 | «ENDIF» |
68 | «ENDFOR» | 73 | «ENDFOR» |
74 | pattern «patternName(null,null,type)»( | ||
75 | problem:LogicProblem, interpretation:PartialInterpretation, | ||
76 | typeInterpretation:PartialTypeInterpratation) | ||
77 | { | ||
78 | find interpretation(problem,interpretation); | ||
79 | neg find hasElementInContainment(problem,interpretation); | ||
80 | PartialInterpretation.partialtypeinterpratation(interpretation,typeInterpretation); | ||
81 | PartialTypeInterpratation.interpretationOf.name(type,"«type.name»"); | ||
82 | «base.typeIndexer.referInstanceOf(type,Modality.MAY,"newObject")» | ||
83 | find mayExist(problem, interpretation, newObject); | ||
84 | neg find mustExist(problem, interpretation, newObject); | ||
85 | } | ||
69 | «ELSE» | 86 | «ELSE» |
70 | pattern createObject_«base.canonizeName(type.name)»( | 87 | pattern «this.patternName(null,null,type)»( |
71 | problem:LogicProblem, interpretation:PartialInterpretation, | 88 | problem:LogicProblem, interpretation:PartialInterpretation, |
72 | typeInterpretation:PartialTypeInterpratation) | 89 | typeInterpretation:PartialTypeInterpratation) |
73 | { | 90 | { |