diff options
Diffstat (limited to 'subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/refinement/ConcreteSymbolRefiner.java')
-rw-r--r-- | subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/refinement/ConcreteSymbolRefiner.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/refinement/ConcreteSymbolRefiner.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/refinement/ConcreteSymbolRefiner.java new file mode 100644 index 00000000..ebb9b824 --- /dev/null +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/refinement/ConcreteSymbolRefiner.java | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | package tools.refinery.store.reasoning.refinement; | ||
7 | |||
8 | import tools.refinery.store.model.Interpretation; | ||
9 | import tools.refinery.store.reasoning.ReasoningAdapter; | ||
10 | import tools.refinery.store.reasoning.representation.PartialSymbol; | ||
11 | import tools.refinery.store.representation.Symbol; | ||
12 | import tools.refinery.store.tuple.Tuple; | ||
13 | |||
14 | import java.util.Objects; | ||
15 | |||
16 | public class ConcreteSymbolRefiner<A, C> extends AbstractPartialInterpretationRefiner<A, C> { | ||
17 | private final Interpretation<A> interpretation; | ||
18 | |||
19 | public ConcreteSymbolRefiner(ReasoningAdapter adapter, PartialSymbol<A, C> partialSymbol, | ||
20 | Symbol<A> concreteSymbol) { | ||
21 | super(adapter, partialSymbol); | ||
22 | interpretation = adapter.getModel().getInterpretation(concreteSymbol); | ||
23 | } | ||
24 | |||
25 | @Override | ||
26 | public boolean merge(Tuple key, A value) { | ||
27 | var currentValue = interpretation.get(key); | ||
28 | var mergedValue = getPartialSymbol().abstractDomain().commonRefinement(currentValue, value); | ||
29 | if (!Objects.equals(currentValue, mergedValue)) { | ||
30 | interpretation.put(key, mergedValue); | ||
31 | } | ||
32 | return true; | ||
33 | } | ||
34 | |||
35 | public static <A1, C1> Factory<A1, C1> of(Symbol<A1> concreteSymbol) { | ||
36 | return (adapter, partialSymbol) -> new ConcreteSymbolRefiner<>(adapter, partialSymbol, concreteSymbol); | ||
37 | } | ||
38 | } | ||