diff options
Diffstat (limited to 'Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_ScopeMapper.xtend')
-rw-r--r-- | Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_ScopeMapper.xtend | 70 |
1 files changed, 58 insertions, 12 deletions
diff --git a/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_ScopeMapper.xtend b/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_ScopeMapper.xtend index c50aa770..ec841546 100644 --- a/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_ScopeMapper.xtend +++ b/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_ScopeMapper.xtend | |||
@@ -5,8 +5,10 @@ import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSTerm | |||
5 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSVariable | 5 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSVariable |
6 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VampireLanguageFactory | 6 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VampireLanguageFactory |
7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | 7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type |
8 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition | ||
8 | import java.util.ArrayList | 9 | import java.util.ArrayList |
9 | import java.util.HashMap | 10 | import java.util.HashMap |
11 | import java.util.List | ||
10 | import java.util.Map | 12 | import java.util.Map |
11 | 13 | ||
12 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 14 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
@@ -21,7 +23,7 @@ class Logic2VampireLanguageMapper_ScopeMapper { | |||
21 | this.base = base | 23 | this.base = base |
22 | } | 24 | } |
23 | 25 | ||
24 | def dispatch public void transformScope(VampireSolverConfiguration config, Logic2VampireLanguageMapperTrace trace) { | 26 | def dispatch public void transformScope(List<Type> types, VampireSolverConfiguration config, Logic2VampireLanguageMapperTrace trace) { |
25 | val ABSOLUTE_MIN = 0 | 27 | val ABSOLUTE_MIN = 0 |
26 | val ABSOLUTE_MAX = Integer.MAX_VALUE | 28 | val ABSOLUTE_MAX = Integer.MAX_VALUE |
27 | 29 | ||
@@ -31,8 +33,22 @@ class Logic2VampireLanguageMapper_ScopeMapper { | |||
31 | // 1. make a list of constants equaling the min number of specified objects | 33 | // 1. make a list of constants equaling the min number of specified objects |
32 | //These numbers do not include enums or initial model elements | 34 | //These numbers do not include enums or initial model elements |
33 | 35 | ||
34 | val GLOBAL_MIN = config.typeScopes.minNewElements | 36 | //Number of defined non-abstract elements that are not enum elements |
35 | val GLOBAL_MAX = config.typeScopes.maxNewElements | 37 | //Equals the number of elements in te initial model |
38 | var elemsInIM = trace.definedElement2String.size | ||
39 | // var elemsInIM = 0 | ||
40 | // | ||
41 | // for(t : types.filter(TypeDefinition).filter[!isIsAbstract]) { | ||
42 | // val len = t.name.length | ||
43 | // val isNotEnum = !t.name.substring(len-4, len).equals("enum") | ||
44 | // if (isNotEnum) { | ||
45 | // elemsInIM += 1 | ||
46 | // } | ||
47 | // } | ||
48 | |||
49 | //TODO handle errors related to GLOBAL_MIN/MAX < 0 | ||
50 | val GLOBAL_MIN = config.typeScopes.minNewElements-elemsInIM | ||
51 | val GLOBAL_MAX = config.typeScopes.maxNewElements-elemsInIM | ||
36 | 52 | ||
37 | val localInstances = newArrayList | 53 | val localInstances = newArrayList |
38 | 54 | ||
@@ -63,31 +79,61 @@ class Logic2VampireLanguageMapper_ScopeMapper { | |||
63 | 79 | ||
64 | // Handling Minimum_Specific | 80 | // Handling Minimum_Specific |
65 | var i = 1 | 81 | var i = 1 |
82 | if (trace.topLvlElementIsInInitialModel as Boolean){ | ||
83 | i = 0 | ||
84 | } | ||
66 | var minNum = -1 | 85 | var minNum = -1 |
67 | var Map<Type, Integer> startPoints = new HashMap | 86 | var Map<Type, Integer> startPoints = new HashMap |
68 | for (t : config.typeScopes.minNewElementsByType.keySet) { | 87 | // var inIM = false |
69 | minNum = t.lookup(config.typeScopes.minNewElementsByType) | 88 | for (tConfig : config.typeScopes.minNewElementsByType.keySet) { |
89 | // var numIniIntModel = 0 | ||
90 | // for (elem : trace.definedElement2String.keySet) { | ||
91 | // println(elem.definedInType) | ||
92 | // for (tDefined : elem.definedInType) { | ||
93 | // inIM = support.dfsSubtypeCheck(tConfig, tDefined) || tConfig.equals(tDefined) | ||
94 | // } | ||
95 | // if (inIM) { | ||
96 | // numIniIntModel += 1 | ||
97 | // } | ||
98 | // inIM = false | ||
99 | // } | ||
100 | |||
101 | minNum = tConfig.lookup(config.typeScopes.minNewElementsByType)//-numIniIntModel | ||
70 | if (minNum != 0) { | 102 | if (minNum != 0) { |
71 | getInstanceConstants(i + minNum, i, localInstances, trace, true, false) | 103 | getInstanceConstants(i + minNum, i, localInstances, trace, true, false) |
72 | startPoints.put(t, i) | 104 | startPoints.put(tConfig, i) |
73 | i += minNum | 105 | i += minNum |
74 | makeFofFormula(localInstances, trace, true, t) | 106 | makeFofFormula(localInstances, trace, true, tConfig) |
75 | } | 107 | } |
76 | } | 108 | } |
77 | 109 | ||
78 | // TODO: calc sum of mins, compare to current value of i | 110 | // TODO: calc sum of mins, compare to current value of i |
79 | // Handling Maximum_Specific | 111 | // Handling Maximum_Specific |
80 | for (t : config.typeScopes.maxNewElementsByType.keySet) { | 112 | for (tConfig : config.typeScopes.maxNewElementsByType.keySet) { |
81 | var maxNum = t.lookup(config.typeScopes.maxNewElementsByType) | 113 | |
82 | minNum = t.lookup(config.typeScopes.minNewElementsByType) | 114 | // var numIniIntModel = 0 |
83 | var startpoint = t.lookup(startPoints) | 115 | // for (elem : trace.definedElement2String.keySet) { |
116 | // println(elem.definedInType) | ||
117 | // for (tDefined : elem.definedInType) { | ||
118 | // inIM = support.dfsSubtypeCheck(tConfig, tDefined) || tConfig.equals(tDefined) | ||
119 | // } | ||
120 | // if (inIM) { | ||
121 | // numIniIntModel += 1 | ||
122 | // } | ||
123 | // inIM = false | ||
124 | // } | ||
125 | |||
126 | var maxNum = tConfig.lookup(config.typeScopes.maxNewElementsByType)//-numIniIntModel | ||
127 | minNum = tConfig.lookup(config.typeScopes.minNewElementsByType)//-numIniIntModel | ||
128 | var startpoint = tConfig.lookup(startPoints) | ||
84 | if (minNum != 0) { | 129 | if (minNum != 0) { |
85 | getInstanceConstants(startpoint + minNum, startpoint, localInstances, trace, true, false) | 130 | getInstanceConstants(startpoint + minNum, startpoint, localInstances, trace, true, false) |
86 | } | 131 | } |
132 | //I do not understand the line below | ||
87 | if (maxNum != minNum) { | 133 | if (maxNum != minNum) { |
88 | var instEndInd = Math.min(GLOBAL_MAX, i + maxNum - minNum) | 134 | var instEndInd = Math.min(GLOBAL_MAX, i + maxNum - minNum) |
89 | getInstanceConstants(instEndInd, i, localInstances, trace, false, false) | 135 | getInstanceConstants(instEndInd, i, localInstances, trace, false, false) |
90 | makeFofFormula(localInstances, trace, false, t) | 136 | makeFofFormula(localInstances, trace, false, tConfig) |
91 | } | 137 | } |
92 | } | 138 | } |
93 | 139 | ||