diff options
author | 2019-01-15 12:44:33 -0500 | |
---|---|---|
committer | 2020-06-07 19:06:26 -0400 | |
commit | f87b4233437f0900c19f462b5e443a3c81b27b6e (patch) | |
tree | fa5af86016db54e24f54e3d801424eb1216efc2f /Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/xtend-gen/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.java | |
parent | Fix numeric-solver-at-end (diff) | |
download | VIATRA-Generator-f87b4233437f0900c19f462b5e443a3c81b27b6e.tar.gz VIATRA-Generator-f87b4233437f0900c19f462b5e443a3c81b27b6e.tar.zst VIATRA-Generator-f87b4233437f0900c19f462b5e443a3c81b27b6e.zip |
Initial workspace setup
Diffstat (limited to 'Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/xtend-gen/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.java')
-rw-r--r-- | Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/xtend-gen/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.java | 242 |
1 files changed, 242 insertions, 0 deletions
diff --git a/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/xtend-gen/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.java b/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/xtend-gen/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.java new file mode 100644 index 00000000..e1be7df5 --- /dev/null +++ b/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/xtend-gen/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_Support.java | |||
@@ -0,0 +1,242 @@ | |||
1 | package ca.mcgill.ecse.dslreasoner.vampire.reasoner.builder; | ||
2 | |||
3 | import ca.mcgill.ecse.dslreasoner.vampire.reasoner.builder.Logic2VampireLanguageMapper; | ||
4 | import ca.mcgill.ecse.dslreasoner.vampire.reasoner.builder.Logic2VampireLanguageMapperTrace; | ||
5 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSAnd; | ||
6 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSExistentialQuantifier; | ||
7 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSFunction; | ||
8 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSImplies; | ||
9 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSInequality; | ||
10 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSOr; | ||
11 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSTerm; | ||
12 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSUniversalQuantifier; | ||
13 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSVariable; | ||
14 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VampireLanguageFactory; | ||
15 | import com.google.common.collect.Iterables; | ||
16 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference; | ||
17 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.QuantifiedExpression; | ||
18 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Term; | ||
19 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeReference; | ||
20 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Variable; | ||
21 | import java.util.ArrayList; | ||
22 | import java.util.Collection; | ||
23 | import java.util.HashMap; | ||
24 | import java.util.List; | ||
25 | import java.util.Map; | ||
26 | import org.eclipse.emf.common.util.EList; | ||
27 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
28 | import org.eclipse.xtext.xbase.lib.Conversions; | ||
29 | import org.eclipse.xtext.xbase.lib.ExclusiveRange; | ||
30 | import org.eclipse.xtext.xbase.lib.Extension; | ||
31 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
32 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
33 | import org.eclipse.xtext.xbase.lib.ListExtensions; | ||
34 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; | ||
35 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; | ||
36 | |||
37 | @SuppressWarnings("all") | ||
38 | public class Logic2VampireLanguageMapper_Support { | ||
39 | @Extension | ||
40 | private final VampireLanguageFactory factory = VampireLanguageFactory.eINSTANCE; | ||
41 | |||
42 | protected String toIDMultiple(final String... ids) { | ||
43 | final Function1<String, String> _function = (String it) -> { | ||
44 | return IterableExtensions.join(((Iterable<?>)Conversions.doWrapArray(it.split("\\s+"))), "_"); | ||
45 | }; | ||
46 | return IterableExtensions.join(ListExtensions.<String, String>map(((List<String>)Conversions.doWrapArray(ids)), _function), "_"); | ||
47 | } | ||
48 | |||
49 | protected String toID(final String ids) { | ||
50 | return IterableExtensions.join(((Iterable<?>)Conversions.doWrapArray(ids.split("\\s+"))), "_"); | ||
51 | } | ||
52 | |||
53 | protected VLSTerm unfoldAnd(final List<? extends VLSTerm> operands) { | ||
54 | int _size = operands.size(); | ||
55 | boolean _equals = (_size == 1); | ||
56 | if (_equals) { | ||
57 | return IterableExtensions.head(operands); | ||
58 | } else { | ||
59 | int _size_1 = operands.size(); | ||
60 | boolean _greaterThan = (_size_1 > 1); | ||
61 | if (_greaterThan) { | ||
62 | VLSAnd _createVLSAnd = this.factory.createVLSAnd(); | ||
63 | final Procedure1<VLSAnd> _function = (VLSAnd it) -> { | ||
64 | it.setLeft(IterableExtensions.head(operands)); | ||
65 | it.setRight(this.unfoldAnd(operands.subList(1, operands.size()))); | ||
66 | }; | ||
67 | return ObjectExtensions.<VLSAnd>operator_doubleArrow(_createVLSAnd, _function); | ||
68 | } else { | ||
69 | StringConcatenation _builder = new StringConcatenation(); | ||
70 | _builder.append("Logic operator with 0 operands!"); | ||
71 | throw new UnsupportedOperationException(_builder.toString()); | ||
72 | } | ||
73 | } | ||
74 | } | ||
75 | |||
76 | protected VLSTerm unfoldOr(final List<? extends VLSTerm> operands) { | ||
77 | int _size = operands.size(); | ||
78 | boolean _equals = (_size == 1); | ||
79 | if (_equals) { | ||
80 | return IterableExtensions.head(operands); | ||
81 | } else { | ||
82 | int _size_1 = operands.size(); | ||
83 | boolean _greaterThan = (_size_1 > 1); | ||
84 | if (_greaterThan) { | ||
85 | VLSOr _createVLSOr = this.factory.createVLSOr(); | ||
86 | final Procedure1<VLSOr> _function = (VLSOr it) -> { | ||
87 | it.setLeft(IterableExtensions.head(operands)); | ||
88 | it.setRight(this.unfoldOr(operands.subList(1, operands.size()))); | ||
89 | }; | ||
90 | return ObjectExtensions.<VLSOr>operator_doubleArrow(_createVLSOr, _function); | ||
91 | } else { | ||
92 | StringConcatenation _builder = new StringConcatenation(); | ||
93 | _builder.append("Logic operator with 0 operands!"); | ||
94 | throw new UnsupportedOperationException(_builder.toString()); | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | |||
99 | protected VLSTerm unfoldDistinctTerms(final Logic2VampireLanguageMapper m, final EList<Term> operands, final Logic2VampireLanguageMapperTrace trace, final Map<Variable, VLSVariable> variables) { | ||
100 | int _size = operands.size(); | ||
101 | boolean _equals = (_size == 1); | ||
102 | if (_equals) { | ||
103 | return m.transformTerm(IterableExtensions.<Term>head(operands), trace, variables); | ||
104 | } else { | ||
105 | int _size_1 = operands.size(); | ||
106 | boolean _greaterThan = (_size_1 > 1); | ||
107 | if (_greaterThan) { | ||
108 | int _size_2 = operands.size(); | ||
109 | int _size_3 = operands.size(); | ||
110 | int _multiply = (_size_2 * _size_3); | ||
111 | int _divide = (_multiply / 2); | ||
112 | final ArrayList<VLSTerm> notEquals = new ArrayList<VLSTerm>(_divide); | ||
113 | int _size_4 = operands.size(); | ||
114 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size_4, true); | ||
115 | for (final Integer i : _doubleDotLessThan) { | ||
116 | int _size_5 = operands.size(); | ||
117 | ExclusiveRange _doubleDotLessThan_1 = new ExclusiveRange(((i).intValue() + 1), _size_5, true); | ||
118 | for (final Integer j : _doubleDotLessThan_1) { | ||
119 | VLSInequality _createVLSInequality = this.factory.createVLSInequality(); | ||
120 | final Procedure1<VLSInequality> _function = (VLSInequality it) -> { | ||
121 | it.setLeft(m.transformTerm(operands.get((i).intValue()), trace, variables)); | ||
122 | it.setRight(m.transformTerm(operands.get((j).intValue()), trace, variables)); | ||
123 | }; | ||
124 | VLSInequality _doubleArrow = ObjectExtensions.<VLSInequality>operator_doubleArrow(_createVLSInequality, _function); | ||
125 | notEquals.add(_doubleArrow); | ||
126 | } | ||
127 | } | ||
128 | return this.unfoldAnd(notEquals); | ||
129 | } else { | ||
130 | StringConcatenation _builder = new StringConcatenation(); | ||
131 | _builder.append("Logic operator with 0 operands!"); | ||
132 | throw new UnsupportedOperationException(_builder.toString()); | ||
133 | } | ||
134 | } | ||
135 | } | ||
136 | |||
137 | /** | ||
138 | * def protected String toID(List<String> ids) { | ||
139 | * ids.map[it.split("\\s+").join("'")].join("'") | ||
140 | * } | ||
141 | */ | ||
142 | protected VLSTerm createUniversallyQuantifiedExpression(final Logic2VampireLanguageMapper mapper, final QuantifiedExpression expression, final Logic2VampireLanguageMapperTrace trace, final Map<Variable, VLSVariable> variables) { | ||
143 | VLSUniversalQuantifier _xblockexpression = null; | ||
144 | { | ||
145 | final Function1<Variable, VLSVariable> _function = (Variable v) -> { | ||
146 | VLSVariable _createVLSVariable = this.factory.createVLSVariable(); | ||
147 | final Procedure1<VLSVariable> _function_1 = (VLSVariable it) -> { | ||
148 | it.setName(this.toIDMultiple("Var", v.getName())); | ||
149 | }; | ||
150 | return ObjectExtensions.<VLSVariable>operator_doubleArrow(_createVLSVariable, _function_1); | ||
151 | }; | ||
152 | final Map<Variable, VLSVariable> variableMap = IterableExtensions.<Variable, VLSVariable>toInvertedMap(expression.getQuantifiedVariables(), _function); | ||
153 | final ArrayList<VLSTerm> typedefs = new ArrayList<VLSTerm>(); | ||
154 | EList<Variable> _quantifiedVariables = expression.getQuantifiedVariables(); | ||
155 | for (final Variable variable : _quantifiedVariables) { | ||
156 | { | ||
157 | VLSFunction _createVLSFunction = this.factory.createVLSFunction(); | ||
158 | final Procedure1<VLSFunction> _function_1 = (VLSFunction it) -> { | ||
159 | TypeReference _range = variable.getRange(); | ||
160 | it.setConstant(this.toIDMultiple("type", ((ComplexTypeReference) _range).getReferred().getName())); | ||
161 | EList<VLSTerm> _terms = it.getTerms(); | ||
162 | VLSVariable _createVLSVariable = this.factory.createVLSVariable(); | ||
163 | final Procedure1<VLSVariable> _function_2 = (VLSVariable it_1) -> { | ||
164 | it_1.setName(this.toIDMultiple("Var", variable.getName())); | ||
165 | }; | ||
166 | VLSVariable _doubleArrow = ObjectExtensions.<VLSVariable>operator_doubleArrow(_createVLSVariable, _function_2); | ||
167 | _terms.add(_doubleArrow); | ||
168 | }; | ||
169 | final VLSFunction eq = ObjectExtensions.<VLSFunction>operator_doubleArrow(_createVLSFunction, _function_1); | ||
170 | typedefs.add(eq); | ||
171 | } | ||
172 | } | ||
173 | VLSUniversalQuantifier _createVLSUniversalQuantifier = this.factory.createVLSUniversalQuantifier(); | ||
174 | final Procedure1<VLSUniversalQuantifier> _function_1 = (VLSUniversalQuantifier it) -> { | ||
175 | EList<VLSVariable> _variables = it.getVariables(); | ||
176 | Collection<VLSVariable> _values = variableMap.values(); | ||
177 | Iterables.<VLSVariable>addAll(_variables, _values); | ||
178 | VLSImplies _createVLSImplies = this.factory.createVLSImplies(); | ||
179 | final Procedure1<VLSImplies> _function_2 = (VLSImplies it_1) -> { | ||
180 | it_1.setLeft(this.unfoldAnd(typedefs)); | ||
181 | it_1.setRight(mapper.transformTerm(expression.getExpression(), trace, this.withAddition(variables, variableMap))); | ||
182 | }; | ||
183 | VLSImplies _doubleArrow = ObjectExtensions.<VLSImplies>operator_doubleArrow(_createVLSImplies, _function_2); | ||
184 | it.setOperand(_doubleArrow); | ||
185 | }; | ||
186 | _xblockexpression = ObjectExtensions.<VLSUniversalQuantifier>operator_doubleArrow(_createVLSUniversalQuantifier, _function_1); | ||
187 | } | ||
188 | return _xblockexpression; | ||
189 | } | ||
190 | |||
191 | protected VLSTerm createExistentiallyQuantifiedExpression(final Logic2VampireLanguageMapper mapper, final QuantifiedExpression expression, final Logic2VampireLanguageMapperTrace trace, final Map<Variable, VLSVariable> variables) { | ||
192 | VLSExistentialQuantifier _xblockexpression = null; | ||
193 | { | ||
194 | final Function1<Variable, VLSVariable> _function = (Variable v) -> { | ||
195 | VLSVariable _createVLSVariable = this.factory.createVLSVariable(); | ||
196 | final Procedure1<VLSVariable> _function_1 = (VLSVariable it) -> { | ||
197 | it.setName(this.toIDMultiple("Var", v.getName())); | ||
198 | }; | ||
199 | return ObjectExtensions.<VLSVariable>operator_doubleArrow(_createVLSVariable, _function_1); | ||
200 | }; | ||
201 | final Map<Variable, VLSVariable> variableMap = IterableExtensions.<Variable, VLSVariable>toInvertedMap(expression.getQuantifiedVariables(), _function); | ||
202 | final ArrayList<VLSTerm> typedefs = new ArrayList<VLSTerm>(); | ||
203 | EList<Variable> _quantifiedVariables = expression.getQuantifiedVariables(); | ||
204 | for (final Variable variable : _quantifiedVariables) { | ||
205 | { | ||
206 | VLSFunction _createVLSFunction = this.factory.createVLSFunction(); | ||
207 | final Procedure1<VLSFunction> _function_1 = (VLSFunction it) -> { | ||
208 | TypeReference _range = variable.getRange(); | ||
209 | it.setConstant(this.toIDMultiple("type", ((ComplexTypeReference) _range).getReferred().getName())); | ||
210 | EList<VLSTerm> _terms = it.getTerms(); | ||
211 | VLSVariable _createVLSVariable = this.factory.createVLSVariable(); | ||
212 | final Procedure1<VLSVariable> _function_2 = (VLSVariable it_1) -> { | ||
213 | it_1.setName(this.toIDMultiple("Var", variable.getName())); | ||
214 | }; | ||
215 | VLSVariable _doubleArrow = ObjectExtensions.<VLSVariable>operator_doubleArrow(_createVLSVariable, _function_2); | ||
216 | _terms.add(_doubleArrow); | ||
217 | }; | ||
218 | final VLSFunction eq = ObjectExtensions.<VLSFunction>operator_doubleArrow(_createVLSFunction, _function_1); | ||
219 | typedefs.add(eq); | ||
220 | } | ||
221 | } | ||
222 | typedefs.add(mapper.transformTerm(expression.getExpression(), trace, this.withAddition(variables, variableMap))); | ||
223 | VLSExistentialQuantifier _createVLSExistentialQuantifier = this.factory.createVLSExistentialQuantifier(); | ||
224 | final Procedure1<VLSExistentialQuantifier> _function_1 = (VLSExistentialQuantifier it) -> { | ||
225 | EList<VLSVariable> _variables = it.getVariables(); | ||
226 | Collection<VLSVariable> _values = variableMap.values(); | ||
227 | Iterables.<VLSVariable>addAll(_variables, _values); | ||
228 | it.setOperand(this.unfoldAnd(typedefs)); | ||
229 | }; | ||
230 | _xblockexpression = ObjectExtensions.<VLSExistentialQuantifier>operator_doubleArrow(_createVLSExistentialQuantifier, _function_1); | ||
231 | } | ||
232 | return _xblockexpression; | ||
233 | } | ||
234 | |||
235 | protected HashMap<Variable, VLSVariable> withAddition(final Map<Variable, VLSVariable> map1, final Map<Variable, VLSVariable> map2) { | ||
236 | HashMap<Variable, VLSVariable> _hashMap = new HashMap<Variable, VLSVariable>(map1); | ||
237 | final Procedure1<HashMap<Variable, VLSVariable>> _function = (HashMap<Variable, VLSVariable> it) -> { | ||
238 | it.putAll(map2); | ||
239 | }; | ||
240 | return ObjectExtensions.<HashMap<Variable, VLSVariable>>operator_doubleArrow(_hashMap, _function); | ||
241 | } | ||
242 | } | ||