diff options
author | Kristóf Marussy <marussy@mit.bme.hu> | 2023-09-14 19:29:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-14 19:29:36 +0200 |
commit | 98ed3b6db5f4e51961a161050cc31c66015116e8 (patch) | |
tree | 8bfd6d9bc8d6ed23b9eb0f889dd40b6c24fe8f92 /subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/proxy/PartialRelationTranslatorProxy.java | |
parent | Merge pull request #38 from nagilooh/design-space-exploration (diff) | |
parent | Merge remote-tracking branch 'upstream/main' into partial-interpretation (diff) | |
download | refinery-98ed3b6db5f4e51961a161050cc31c66015116e8.tar.gz refinery-98ed3b6db5f4e51961a161050cc31c66015116e8.tar.zst refinery-98ed3b6db5f4e51961a161050cc31c66015116e8.zip |
Merge pull request #39 from kris7t/partial-interpretation
Implement partial interpretation based model generation
Diffstat (limited to 'subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/proxy/PartialRelationTranslatorProxy.java')
-rw-r--r-- | subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/proxy/PartialRelationTranslatorProxy.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/proxy/PartialRelationTranslatorProxy.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/proxy/PartialRelationTranslatorProxy.java new file mode 100644 index 00000000..45dc5bd2 --- /dev/null +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/proxy/PartialRelationTranslatorProxy.java | |||
@@ -0,0 +1,52 @@ | |||
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.translator.proxy; | ||
7 | |||
8 | import tools.refinery.store.model.ModelStoreBuilder; | ||
9 | import tools.refinery.store.model.ModelStoreConfiguration; | ||
10 | import tools.refinery.store.query.literal.AbstractCallLiteral; | ||
11 | import tools.refinery.store.query.literal.Literal; | ||
12 | import tools.refinery.store.query.term.Variable; | ||
13 | import tools.refinery.store.reasoning.interpretation.PartialRelationRewriter; | ||
14 | import tools.refinery.store.reasoning.literal.Concreteness; | ||
15 | import tools.refinery.store.reasoning.literal.ModalConstraint; | ||
16 | import tools.refinery.store.reasoning.literal.Modality; | ||
17 | import tools.refinery.store.reasoning.representation.PartialRelation; | ||
18 | import tools.refinery.store.reasoning.translator.PartialRelationTranslator; | ||
19 | |||
20 | import java.util.List; | ||
21 | import java.util.Set; | ||
22 | |||
23 | public class PartialRelationTranslatorProxy implements ModelStoreConfiguration, PartialRelationRewriter { | ||
24 | private final PartialRelation partialRelation; | ||
25 | private final PartialRelation targetRelation; | ||
26 | private final boolean mutable; | ||
27 | |||
28 | public PartialRelationTranslatorProxy(PartialRelation partialRelation, PartialRelation targetRelation, | ||
29 | boolean mutable) { | ||
30 | this.partialRelation = partialRelation; | ||
31 | this.targetRelation = targetRelation; | ||
32 | this.mutable = mutable; | ||
33 | } | ||
34 | |||
35 | @Override | ||
36 | public void apply(ModelStoreBuilder storeBuilder) { | ||
37 | var translator = PartialRelationTranslator.of(partialRelation) | ||
38 | .interpretation(((adapter, concreteness, partialSymbol) -> | ||
39 | adapter.getPartialInterpretation(concreteness, targetRelation))) | ||
40 | .rewriter(this); | ||
41 | if (mutable) { | ||
42 | translator.refiner((adapter, partialSymbol) -> adapter.getRefiner(targetRelation)); | ||
43 | } | ||
44 | storeBuilder.with(translator); | ||
45 | } | ||
46 | |||
47 | @Override | ||
48 | public List<Literal> rewriteLiteral(Set<Variable> positiveVariables, AbstractCallLiteral literal, | ||
49 | Modality modality, Concreteness concreteness) { | ||
50 | return List.of(literal.withTarget(ModalConstraint.of(modality, concreteness, targetRelation))); | ||
51 | } | ||
52 | } | ||