aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.xtend
diff options
context:
space:
mode:
authorLibravatar ArenBabikian <aren.babikian@mail.mcgill.ca>2019-03-06 02:59:19 -0500
committerLibravatar ArenBabikian <aren.babikian@mail.mcgill.ca>2020-06-07 19:22:42 -0400
commit54431d1418fd4133a49605b804c10dd523c4c30d (patch)
tree57447af926e347e0ea31953c73f23d33297734d5 /Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.xtend
parentPartially improve coding style (leaving for soccer) (diff)
downloadVIATRA-Generator-54431d1418fd4133a49605b804c10dd523c4c30d.tar.gz
VIATRA-Generator-54431d1418fd4133a49605b804c10dd523c4c30d.tar.zst
VIATRA-Generator-54431d1418fd4133a49605b804c10dd523c4c30d.zip
Continue improving code style (need sleep)
Diffstat (limited to 'Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.xtend')
-rw-r--r--Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.xtend92
1 files changed, 34 insertions, 58 deletions
diff --git a/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.xtend b/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.xtend
index 090cf916..d3595a73 100644
--- a/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.xtend
+++ b/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.xtend
@@ -17,6 +17,8 @@ import java.util.List
17import java.util.Map 17import java.util.Map
18import org.eclipse.emf.common.util.EList 18import org.eclipse.emf.common.util.EList
19 19
20import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
21
20class Logic2VampireLanguageMapper_Support { 22class Logic2VampireLanguageMapper_Support {
21 private val extension VampireLanguageFactory factory = VampireLanguageFactory.eINSTANCE 23 private val extension VampireLanguageFactory factory = VampireLanguageFactory.eINSTANCE
22 24
@@ -29,28 +31,27 @@ class Logic2VampireLanguageMapper_Support {
29 ids.split("\\s+").join("_") 31 ids.split("\\s+").join("_")
30 } 32 }
31 33
32 //Term Handling 34 // Term Handling
33 //TODO Make more general 35 // TODO Make more general
34 def protected VLSVariable duplicate(VLSVariable term) { 36 def protected VLSVariable duplicate(VLSVariable term) {
35 return createVLSVariable => [it.name = term.name] 37 return createVLSVariable => [it.name = term.name]
36 } 38 }
37 39
38 def protected VLSFunction duplicate(VLSFunction term) { 40 def protected VLSFunction duplicate(VLSFunction term) {
39 return createVLSFunction => [ 41 return createVLSFunction => [
40 it.constant = term.constant 42 it.constant = term.constant
41 for ( v : term.terms){ 43 for (v : term.terms) {
42 it.terms += duplicate(v as VLSVariable) 44 it.terms += duplicate(v as VLSVariable)
43 } 45 }
44 ] 46 ]
45 } 47 }
46 48
47 def protected VLSFunction duplicate(VLSFunction term, VLSVariable v) { 49 def protected VLSFunction duplicate(VLSFunction term, VLSVariable v) {
48 return createVLSFunction => [ 50 return createVLSFunction => [
49 it.constant = term.constant 51 it.constant = term.constant
50 it.terms += duplicate(v) 52 it.terms += duplicate(v)
51 ] 53 ]
52 } 54 }
53
54 55
55 def protected VLSFunction topLevelTypeFunc() { 56 def protected VLSFunction topLevelTypeFunc() {
56 return createVLSFunction => [ 57 return createVLSFunction => [
@@ -60,24 +61,22 @@ class Logic2VampireLanguageMapper_Support {
60 ] 61 ]
61 ] 62 ]
62 } 63 }
63 64
64 //TODO Make more general 65 // TODO Make more general
65 def establishUniqueness(List<VLSConstant> terms) { 66 def establishUniqueness(List<VLSConstant> terms) {
66 val List<VLSInequality> eqs = newArrayList 67 val List<VLSInequality> eqs = newArrayList
67 for (t1 : terms.subList(1, terms.length)){ 68 for (t1 : terms.subList(1, terms.length)) {
68 for (t2 : terms.subList(0, terms.indexOf(t1))){ 69 for (t2 : terms.subList(0, terms.indexOf(t1))) {
69 val eq = createVLSInequality => [ 70 val eq = createVLSInequality => [
70 //TEMP 71 // TEMP
71 it.left = createVLSConstant => [it.name = t2.name] 72 it.left = createVLSConstant => [it.name = t2.name]
72 it.right = createVLSConstant => [it.name = t1.name] 73 it.right = createVLSConstant => [it.name = t1.name]
73 //TEMP 74 // TEMP
74 ] 75 ]
75 eqs.add(eq) 76 eqs.add(eq)
76 } 77 }
77 } 78 }
78
79 return unfoldAnd(eqs) 79 return unfoldAnd(eqs)
80
81 } 80 }
82 81
83 // Support Functions 82 // Support Functions
@@ -108,6 +107,7 @@ class Logic2VampireLanguageMapper_Support {
108 throw new UnsupportedOperationException('''Logic operator with 0 operands!''') // TEMP 107 throw new UnsupportedOperationException('''Logic operator with 0 operands!''') // TEMP
109 } 108 }
110 109
110 // can delete below
111 def protected VLSTerm unfoldDistinctTerms(Logic2VampireLanguageMapper m, EList<Term> operands, 111 def protected VLSTerm unfoldDistinctTerms(Logic2VampireLanguageMapper m, EList<Term> operands,
112 Logic2VampireLanguageMapperTrace trace, Map<Variable, VLSVariable> variables) { 112 Logic2VampireLanguageMapperTrace trace, Map<Variable, VLSVariable> variables) {
113 if (operands.size == 1) { 113 if (operands.size == 1) {
@@ -143,58 +143,36 @@ class Logic2VampireLanguageMapper_Support {
143 * } 143 * }
144 */ 144 */
145 // QUANTIFIERS + VARIABLES 145 // QUANTIFIERS + VARIABLES
146 def protected VLSTerm createUniversallyQuantifiedExpression(Logic2VampireLanguageMapper mapper, 146 def protected VLSTerm createQuantifiedExpression(Logic2VampireLanguageMapper mapper,
147 QuantifiedExpression expression, Logic2VampireLanguageMapperTrace trace, Map<Variable, VLSVariable> variables) { 147 QuantifiedExpression expression, Logic2VampireLanguageMapperTrace trace, Map<Variable, VLSVariable> variables, boolean isUniversal) {
148 val variableMap = expression.quantifiedVariables.toInvertedMap [ v | 148 val variableMap = expression.quantifiedVariables.toInvertedMap [ v |
149 createVLSVariable => [it.name = toIDMultiple("Var", v.name)] 149 createVLSVariable => [it.name = toIDMultiple("V", v.name)]
150 ] 150 ]
151 151
152 val typedefs = new ArrayList<VLSTerm> 152 val typedefs = new ArrayList<VLSTerm>
153 for (variable : expression.quantifiedVariables) { 153 for (variable : expression.quantifiedVariables) {
154 val eq = createVLSFunction => [ 154 val eq = duplicate((variable.range as ComplexTypeReference).referred.lookup(trace.type2Predicate), variable.lookup(variableMap))
155 it.constant = toIDMultiple("t", (variable.range as ComplexTypeReference).referred.name)
156 it.terms += createVLSVariable => [
157 it.name = toIDMultiple("Var", variable.name)
158 ]
159
160 ]
161 typedefs.add(eq) 155 typedefs.add(eq)
162 } 156 }
163 157 if (isUniversal) {
164 createVLSUniversalQuantifier => [ 158 createVLSUniversalQuantifier => [
165 it.variables += variableMap.values 159 it.variables += variableMap.values
166 it.operand = createVLSImplies => [ 160 it.operand = createVLSImplies => [
167 it.left = unfoldAnd(typedefs) 161 it.left = unfoldAnd(typedefs)
168 it.right = mapper.transformTerm(expression.expression, trace, variables.withAddition(variableMap)) 162 it.right = mapper.transformTerm(expression.expression, trace, variables.withAddition(variableMap))
163 ]
169 ] 164 ]
170 ] 165 } else {
171 } 166 typedefs.add(mapper.transformTerm(expression.expression, trace, variables.withAddition(variableMap)))
167 createVLSExistentialQuantifier => [
168 it.variables += variableMap.values
169 it.operand = unfoldAnd(typedefs)
172 170
173 def protected VLSTerm createExistentiallyQuantifiedExpression(Logic2VampireLanguageMapper mapper,
174 QuantifiedExpression expression, Logic2VampireLanguageMapperTrace trace, Map<Variable, VLSVariable> variables) {
175 val variableMap = expression.quantifiedVariables.toInvertedMap [ v |
176 createVLSVariable => [it.name = toIDMultiple("Var", v.name)]
177 ]
178
179 val typedefs = new ArrayList<VLSTerm>
180 for (variable : expression.quantifiedVariables) {
181 val eq = createVLSFunction => [
182 it.constant = toIDMultiple("t", (variable.range as ComplexTypeReference).referred.name)
183 it.terms += createVLSVariable => [
184 it.name = toIDMultiple("Var", variable.name)
185 ]
186 ] 171 ]
187 typedefs.add(eq)
188 } 172 }
189 173
190 typedefs.add(mapper.transformTerm(expression.expression, trace, variables.withAddition(variableMap)))
191 createVLSExistentialQuantifier => [
192 it.variables += variableMap.values
193 it.operand = unfoldAnd(typedefs)
194
195 ]
196 } 174 }
197 175
198 def protected boolean dfsSupertypeCheck(Type type, Type type2) { 176 def protected boolean dfsSupertypeCheck(Type type, Type type2) {
199 // There is surely a better way to do this 177 // There is surely a better way to do this
200 if (type.supertypes.isEmpty) 178 if (type.supertypes.isEmpty)
@@ -213,7 +191,5 @@ class Logic2VampireLanguageMapper_Support {
213 def protected withAddition(Map<Variable, VLSVariable> map1, Map<Variable, VLSVariable> map2) { 191 def protected withAddition(Map<Variable, VLSVariable> map1, Map<Variable, VLSVariable> map2) {
214 new HashMap(map1) => [putAll(map2)] 192 new HashMap(map1) => [putAll(map2)]
215 } 193 }
216
217
218 194
219} 195}