diff options
author | 2023-04-23 23:39:39 +0200 | |
---|---|---|
committer | 2023-04-23 23:42:53 +0200 | |
commit | 565de1cb116e5e4f116544aaa035be58336656ec (patch) | |
tree | 5d4cff8e77e280552f13b9c7f8aafa79a39a0090 /subprojects/store-reasoning/src/main | |
parent | refactor: simplify ModelAdapter (diff) | |
download | refinery-565de1cb116e5e4f116544aaa035be58336656ec.tar.gz refinery-565de1cb116e5e4f116544aaa035be58336656ec.tar.zst refinery-565de1cb116e5e4f116544aaa035be58336656ec.zip |
refactor: query terms
* Separate different operators into different classes to make it easier to add
functionality (e.g., simplification) later.
* Add UpperCardinality terms.
* Move UpperCardinality aggregator and tests into refinery-store-query.
Diffstat (limited to 'subprojects/store-reasoning/src/main')
-rw-r--r-- | subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/Advice.java | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/Advice.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/Advice.java index dd7a018d..d6a9e02c 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/Advice.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/Advice.java | |||
@@ -5,11 +5,11 @@ | |||
5 | */ | 5 | */ |
6 | package tools.refinery.store.reasoning.translator; | 6 | package tools.refinery.store.reasoning.translator; |
7 | 7 | ||
8 | import tools.refinery.store.query.substitution.Substitution; | ||
8 | import tools.refinery.store.reasoning.representation.AnyPartialSymbol; | 9 | import tools.refinery.store.reasoning.representation.AnyPartialSymbol; |
9 | import tools.refinery.store.reasoning.representation.PartialRelation; | 10 | import tools.refinery.store.reasoning.representation.PartialRelation; |
10 | import tools.refinery.store.query.term.Variable; | 11 | import tools.refinery.store.query.term.Variable; |
11 | import tools.refinery.store.query.literal.Literal; | 12 | import tools.refinery.store.query.literal.Literal; |
12 | import tools.refinery.store.query.substitution.Substitutions; | ||
13 | 13 | ||
14 | import java.util.*; | 14 | import java.util.*; |
15 | 15 | ||
@@ -66,14 +66,9 @@ public final class Advice { | |||
66 | public List<Literal> substitute(List<Variable> substituteParameters) { | 66 | public List<Literal> substitute(List<Variable> substituteParameters) { |
67 | checkArity(substituteParameters); | 67 | checkArity(substituteParameters); |
68 | markProcessed(); | 68 | markProcessed(); |
69 | int arity = parameters.size(); | ||
70 | var variableMap = new HashMap<Variable, Variable>(arity); | ||
71 | for (int i = 0; i < arity; i++) { | ||
72 | variableMap.put(parameters.get(i), substituteParameters.get(i)); | ||
73 | } | ||
74 | // Use a renewing substitution to remove any non-parameter variables and avoid clashed between variables | 69 | // Use a renewing substitution to remove any non-parameter variables and avoid clashed between variables |
75 | // coming from different advice in the same clause. | 70 | // coming from different advice in the same clause. |
76 | var substitution = Substitutions.renewing(variableMap); | 71 | var substitution = Substitution.builder().putManyChecked(parameters, substituteParameters).renewing().build(); |
77 | return literals.stream().map(literal -> literal.substitute(substitution)).toList(); | 72 | return literals.stream().map(literal -> literal.substitute(substitution)).toList(); |
78 | } | 73 | } |
79 | 74 | ||