diff options
author | 2019-03-06 14:18:35 -0500 | |
---|---|---|
committer | 2020-06-07 19:22:43 -0400 | |
commit | f4a37cba3665a9cb38982b978d81fd4d269dedf7 (patch) | |
tree | efe09d1dcea9b196c66f613d3e9c6b845a78c2e4 /Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_TypeMapper_FilteredTypes.xtend | |
parent | Continue improving code style (need sleep) (diff) | |
download | VIATRA-Generator-f4a37cba3665a9cb38982b978d81fd4d269dedf7.tar.gz VIATRA-Generator-f4a37cba3665a9cb38982b978d81fd4d269dedf7.tar.zst VIATRA-Generator-f4a37cba3665a9cb38982b978d81fd4d269dedf7.zip |
Restructure Vampire Reasoner project
Diffstat (limited to 'Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_TypeMapper_FilteredTypes.xtend')
-rw-r--r-- | Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_TypeMapper_FilteredTypes.xtend | 153 |
1 files changed, 0 insertions, 153 deletions
diff --git a/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_TypeMapper_FilteredTypes.xtend b/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_TypeMapper_FilteredTypes.xtend deleted file mode 100644 index ea72940e..00000000 --- a/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.reasoner/src/ca/mcgill/ecse/dslreasoner/vampire/reasoner/builder/Logic2VampireLanguageMapper_TypeMapper_FilteredTypes.xtend +++ /dev/null | |||
@@ -1,153 +0,0 @@ | |||
1 | package ca.mcgill.ecse.dslreasoner.vampire.reasoner.builder | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement | ||
4 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage | ||
7 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSTerm | ||
8 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSVariable | ||
9 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VampireLanguageFactory | ||
10 | import java.util.ArrayList | ||
11 | import java.util.Collection | ||
12 | |||
13 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | ||
14 | import java.util.List | ||
15 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSFunction | ||
16 | |||
17 | class Logic2VampireLanguageMapper_TypeMapper_FilteredTypes implements Logic2VampireLanguageMapper_TypeMapper { | ||
18 | private val Logic2VampireLanguageMapper_Support support = new Logic2VampireLanguageMapper_Support | ||
19 | private val extension VampireLanguageFactory factory = VampireLanguageFactory.eINSTANCE | ||
20 | |||
21 | new() { | ||
22 | LogicproblemPackage.eINSTANCE.class | ||
23 | } | ||
24 | |||
25 | override transformTypes(Collection<Type> types, Collection<DefinedElement> elements, Logic2VampireLanguageMapper mapper, Logic2VampireLanguageMapperTrace trace) { | ||
26 | |||
27 | // val typeTrace = new Logic2VampireLanguageMapper_TypeMapperTrace_FilteredTypes | ||
28 | // trace.typeMapperTrace = typeTrace | ||
29 | val VLSVariable variable = createVLSVariable => [it.name = "A"] | ||
30 | |||
31 | // 1. Each type (class) is a predicate with a single variable as input | ||
32 | for (type : types) { | ||
33 | val typePred = createVLSFunction => [ | ||
34 | it.constant = support.toIDMultiple("t", type.name.split(" ").get(0)) | ||
35 | it.terms += support.duplicate(variable) | ||
36 | ] | ||
37 | // typeTrace.type2Predicate.put(type, typePred) | ||
38 | trace.type2Predicate.put(type, typePred) | ||
39 | } | ||
40 | |||
41 | // 2. Map each ENUM type definition to fof formula | ||
42 | for (type : types.filter(TypeDefinition)) { | ||
43 | val List<VLSFunction> orElems = newArrayList | ||
44 | for (e : type.elements) { | ||
45 | val enumElemPred = createVLSFunction => [ | ||
46 | it.constant = support.toIDMultiple("e", e.name.split(" ").get(0), e.name.split(" ").get(2)) | ||
47 | it.terms += support.duplicate(variable) | ||
48 | ] | ||
49 | // typeTrace.element2Predicate.put(e, enumElemPred) | ||
50 | trace.element2Predicate.put(e, enumElemPred) | ||
51 | orElems.add(enumElemPred) | ||
52 | } | ||
53 | |||
54 | val res = createVLSFofFormula => [ | ||
55 | it.name = support.toIDMultiple("typeDef", type.name.split(" ").get(0)) | ||
56 | // below is temporary solution | ||
57 | it.fofRole = "axiom" | ||
58 | it.fofFormula = createVLSUniversalQuantifier => [ | ||
59 | it.variables += support.duplicate(variable) | ||
60 | it.operand = createVLSEquivalent => [ | ||
61 | // it.left = createVLSFunction => [ | ||
62 | // it.constant = type.lookup(typeTrace.type2Predicate).constant | ||
63 | // it.terms += createVLSVariable => [it.name = "A"] | ||
64 | // ] | ||
65 | // it.left = type.lookup(typeTrace.type2Predicate) | ||
66 | it.left = type.lookup(trace.type2Predicate) | ||
67 | |||
68 | it.right = support.unfoldOr(orElems) | ||
69 | |||
70 | // TEMPPPPPPP | ||
71 | // it.right = support.unfoldOr(type.elements.map [e | | ||
72 | // | ||
73 | // createVLSEquality => [ | ||
74 | // it.left = support.duplicate(variable) | ||
75 | // it.right = createVLSDoubleQuote => [ | ||
76 | // it.value = "\"a" + e.name + "\"" | ||
77 | // ] | ||
78 | // ] | ||
79 | // ]) | ||
80 | // END TEMPPPPP | ||
81 | ] | ||
82 | ] | ||
83 | |||
84 | ] | ||
85 | trace.specification.formulas += res | ||
86 | } | ||
87 | |||
88 | //HIERARCHY HANDLER | ||
89 | |||
90 | |||
91 | // 3. For each non-abstract type, create an and sequence containing all typedeclaration predicates | ||
92 | // and store in a map | ||
93 | for (t1 : types.filter[!isIsAbstract]) { | ||
94 | for (t2 : types) { | ||
95 | // possible improvement: check all supertypes and decide if negated or not based on negations/not negations of supertypes | ||
96 | if (t1 == t2 || support.dfsSupertypeCheck(t1, t2)) { | ||
97 | // typeTrace.type2PossibleNot.put(t2, support.duplicate(t2.lookup(typeTrace.type2Predicate))) | ||
98 | trace.type2PossibleNot.put(t2, support.duplicate(t2.lookup(trace.type2Predicate))) | ||
99 | } else { | ||
100 | // typeTrace.type2PossibleNot.put(t2, createVLSUnaryNegation => [ | ||
101 | trace.type2PossibleNot.put(t2, createVLSUnaryNegation => [ | ||
102 | it.operand = support.duplicate(t2.lookup(trace.type2Predicate)) | ||
103 | ]) | ||
104 | } | ||
105 | } | ||
106 | // typeTrace.type2And.put(t1, support.unfoldAnd(new ArrayList<VLSTerm>(typeTrace.type2PossibleNot.values))) | ||
107 | // typeTrace.type2PossibleNot.clear | ||
108 | trace.type2And.put(t1, support.unfoldAnd(new ArrayList<VLSTerm>(trace.type2PossibleNot.values))) | ||
109 | trace.type2PossibleNot.clear | ||
110 | } | ||
111 | |||
112 | // 5. create fof function that is an or with all the elements in map | ||
113 | val hierarch = createVLSFofFormula => [ | ||
114 | it.name = "hierarchyHandler" | ||
115 | it.fofRole = "axiom" | ||
116 | it.fofFormula = createVLSUniversalQuantifier => [ | ||
117 | it.variables += support.duplicate(variable) | ||
118 | it.operand = createVLSEquivalent => [ | ||
119 | it.left = support.topLevelTypeFunc | ||
120 | // it.right = support.unfoldOr(new ArrayList<VLSTerm>(typeTrace.type2And.values)) | ||
121 | it.right = support.unfoldOr(new ArrayList<VLSTerm>(trace.type2And.values)) | ||
122 | ] | ||
123 | ] | ||
124 | ] | ||
125 | |||
126 | trace.specification.formulas += hierarch | ||
127 | |||
128 | } | ||
129 | |||
130 | override transformTypeReference(Type referred, Logic2VampireLanguageMapper mapper, | ||
131 | Logic2VampireLanguageMapperTrace trace) { | ||
132 | throw new UnsupportedOperationException("TODO: auto-generated method stub") | ||
133 | } | ||
134 | |||
135 | override getUndefinedSupertype(Logic2VampireLanguageMapperTrace trace) { | ||
136 | throw new UnsupportedOperationException("TODO: auto-generated method stub") | ||
137 | } | ||
138 | |||
139 | override getUndefinedSupertypeScope(int undefinedScope, Logic2VampireLanguageMapperTrace trace) { | ||
140 | throw new UnsupportedOperationException("TODO: auto-generated method stub") | ||
141 | } | ||
142 | |||
143 | override transformReference(DefinedElement referred, Logic2VampireLanguageMapperTrace trace) { | ||
144 | createVLSDoubleQuote => [ | ||
145 | it.value = "\"a" + referred.name + "\"" | ||
146 | ] | ||
147 | } | ||
148 | |||
149 | override getTypeInterpreter() { | ||
150 | throw new UnsupportedOperationException("TODO: auto-generated method stub") | ||
151 | } | ||
152 | |||
153 | } | ||