diff options
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 | 74 |
1 files changed, 45 insertions, 29 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 index 41e2137c..eed10656 100644 --- 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 | |||
@@ -11,6 +11,8 @@ import java.util.ArrayList | |||
11 | import java.util.Collection | 11 | import java.util.Collection |
12 | 12 | ||
13 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 13 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
14 | import java.util.List | ||
15 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VLSFunction | ||
14 | 16 | ||
15 | class Logic2VampireLanguageMapper_TypeMapper_FilteredTypes implements Logic2VampireLanguageMapper_TypeMapper { | 17 | class Logic2VampireLanguageMapper_TypeMapper_FilteredTypes implements Logic2VampireLanguageMapper_TypeMapper { |
16 | private val Logic2VampireLanguageMapper_Support support = new Logic2VampireLanguageMapper_Support | 18 | private val Logic2VampireLanguageMapper_Support support = new Logic2VampireLanguageMapper_Support |
@@ -25,50 +27,66 @@ class Logic2VampireLanguageMapper_TypeMapper_FilteredTypes implements Logic2Vamp | |||
25 | val typeTrace = new Logic2VampireLanguageMapper_TypeMapperTrace_FilteredTypes | 27 | val typeTrace = new Logic2VampireLanguageMapper_TypeMapperTrace_FilteredTypes |
26 | trace.typeMapperTrace = typeTrace | 28 | trace.typeMapperTrace = typeTrace |
27 | 29 | ||
28 | val VLSVariable variable = createVLSVariable => [it.name = "A"] // did not work | 30 | // The variable |
29 | // 1. store predicates for declarations in trace | 31 | val VLSVariable variable = createVLSVariable => [it.name = "A"] |
32 | |||
33 | // 1. Each type (class) is a predicate with a single variable as input | ||
30 | for (type : types) { | 34 | for (type : types) { |
31 | val typePred = createVLSFunction => [ | 35 | val typePred = createVLSFunction => [ |
32 | it.constant = support.toIDMultiple("type", type.name) | 36 | it.constant = support.toIDMultiple("t", type.name) |
33 | it.terms += createVLSVariable => [it.name = variable.name] | 37 | it.terms += support.duplicate(variable) |
34 | ] | 38 | ] |
35 | typeTrace.type2Predicate.put(type, typePred) | 39 | typeTrace.type2Predicate.put(type, typePred) |
36 | } | 40 | } |
37 | 41 | ||
38 | // 2. Map each type definition to fof formula | 42 | // 2. Map each ENUM type definition to fof formula |
39 | for (type : types.filter(TypeDefinition)) { | 43 | for (type : types.filter(TypeDefinition)) { |
44 | val List<VLSFunction> orElems = newArrayList | ||
45 | for (e : type.elements) { | ||
46 | val enumElemPred = createVLSFunction => [ | ||
47 | it.constant = support.toIDMultiple("e", e.name, type.name) | ||
48 | it.terms += support.duplicate(variable) | ||
49 | ] | ||
50 | typeTrace.element2Predicate.put(e, enumElemPred) | ||
51 | orElems.add(enumElemPred) | ||
52 | } | ||
40 | 53 | ||
41 | val res = createVLSFofFormula => [ | 54 | val res = createVLSFofFormula => [ |
42 | it.name = support.toIDMultiple("typeDef", type.name) | 55 | it.name = support.toIDMultiple("typeDef", type.name) |
43 | // below is temporary solution | 56 | // below is temporary solution |
44 | it.fofRole = "axiom" | 57 | it.fofRole = "axiom" |
45 | it.fofFormula = createVLSUniversalQuantifier => [ | 58 | it.fofFormula = createVLSUniversalQuantifier => [ |
46 | it.variables += createVLSVariable => [it.name = variable.name] | 59 | it.variables += support.duplicate(variable) |
47 | it.operand = createVLSEquivalent => [ | 60 | it.operand = createVLSEquivalent => [ |
48 | it.left = createVLSFunction => [ | 61 | // it.left = createVLSFunction => [ |
49 | it.constant = type.lookup(typeTrace.type2Predicate).constant | 62 | // it.constant = type.lookup(typeTrace.type2Predicate).constant |
50 | it.terms += createVLSVariable => [it.name = "A"] | 63 | // it.terms += createVLSVariable => [it.name = "A"] |
51 | ] | 64 | // ] |
52 | 65 | it.left = type.lookup(typeTrace.type2Predicate) | |
53 | type.lookup(typeTrace.type2Predicate) | 66 | |
54 | it.right = support.unfoldOr(type.elements.map [ e | | 67 | it.right = support.unfoldOr(orElems) |
55 | createVLSEquality => [ | 68 | |
56 | it.left = createVLSVariable => [it.name = variable.name] | 69 | // TEMPPPPPPP |
70 | // it.right = support.unfoldOr(type.elements.map [e | | ||
71 | // | ||
72 | // createVLSEquality => [ | ||
73 | // it.left = support.duplicate(variable) | ||
57 | // it.right = createVLSDoubleQuote => [ | 74 | // it.right = createVLSDoubleQuote => [ |
58 | // it.value = "\"" + e.name + "\"" | 75 | // it.value = "\"a" + e.name + "\"" |
59 | // ] | 76 | // ] |
60 | it.right = createVLSDoubleQuote => [ | 77 | // ] |
61 | it.value = "\"a" + e.name + "\"" | 78 | // ]) |
62 | ] | 79 | // END TEMPPPPP |
63 | ] | ||
64 | ]) | ||
65 | ] | 80 | ] |
66 | ] | 81 | ] |
67 | 82 | ||
68 | ] | 83 | ] |
69 | trace.specification.formulas += res | 84 | trace.specification.formulas += res |
70 | } | 85 | } |
71 | // 2.5. Currently allowing duplicate types. Not problematic cuz strings are by def unique | 86 | |
87 | //HIERARCHY HANDLER | ||
88 | |||
89 | |||
72 | // 3. For each non-abstract type, create an and sequence containing all typedeclaration predicates | 90 | // 3. For each non-abstract type, create an and sequence containing all typedeclaration predicates |
73 | // and store in a map | 91 | // and store in a map |
74 | // val List<VLSTerm> type2PossibleNot = new ArrayList | 92 | // val List<VLSTerm> type2PossibleNot = new ArrayList |
@@ -97,19 +115,17 @@ class Logic2VampireLanguageMapper_TypeMapper_FilteredTypes implements Logic2Vamp | |||
97 | } | 115 | } |
98 | 116 | ||
99 | // 5. create fof function that is an or with all the elements in map | 117 | // 5. create fof function that is an or with all the elements in map |
100 | // Do this only if there are more than 1 type | 118 | |
119 | |||
120 | |||
121 | |||
101 | val hierarch = createVLSFofFormula => [ | 122 | val hierarch = createVLSFofFormula => [ |
102 | it.name = "hierarchyHandler" | 123 | it.name = "hierarchyHandler" |
103 | it.fofRole = "axiom" | 124 | it.fofRole = "axiom" |
104 | it.fofFormula = createVLSUniversalQuantifier => [ | 125 | it.fofFormula = createVLSUniversalQuantifier => [ |
105 | it.variables += createVLSVariable => [it.name = "A"] | 126 | it.variables += createVLSVariable => [it.name = "A"] |
106 | it.operand = createVLSEquivalent => [ | 127 | it.operand = createVLSEquivalent => [ |
107 | it.left = createVLSFunction => [ | 128 | it.left = support.topLevelTypeFunc |
108 | it.constant = "object" | ||
109 | it.terms += createVLSVariable => [ | ||
110 | it.name = "A" | ||
111 | ] | ||
112 | ] | ||
113 | it.right = support.unfoldOr(new ArrayList<VLSTerm>(typeTrace.type2And.values)) | 129 | it.right = support.unfoldOr(new ArrayList<VLSTerm>(typeTrace.type2And.values)) |
114 | ] | 130 | ] |
115 | ] | 131 | ] |