aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2023-02-09 16:52:43 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2023-02-09 16:57:28 +0100
commit8d2d6359f3b47b36075ea5aad8b522c094f5a71c (patch)
treebf340983eb9d1665acafe1da494520e9754d55c7 /subprojects
parentrefactor: PartialInterpretation adapter naming (diff)
downloadrefinery-8d2d6359f3b47b36075ea5aad8b522c094f5a71c.tar.gz
refinery-8d2d6359f3b47b36075ea5aad8b522c094f5a71c.tar.zst
refinery-8d2d6359f3b47b36075ea5aad8b522c094f5a71c.zip
refactor: Atom -> Literal naming convention
Diffstat (limited to 'subprojects')
-rw-r--r--subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryBuilder.java14
-rw-r--r--subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryAdapterImpl.java6
-rw-r--r--subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryBuilderImpl.java16
-rw-r--r--subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryStoreAdapterImpl.java10
-rw-r--r--subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java (renamed from subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/DNF2PQuery.java)86
-rw-r--r--subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTest.java155
-rw-r--r--subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTransactionTest.java8
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/DNFAnd.java9
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/Dnf.java (renamed from subprojects/store/src/main/java/tools/refinery/store/query/DNF.java)36
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/DnfClause.java9
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/DnfUtils.java (renamed from subprojects/store/src/main/java/tools/refinery/store/query/DNFUtils.java)4
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/ModelQueryAdapter.java2
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/ModelQueryBuilder.java6
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/ModelQueryStoreAdapter.java2
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/Variable.java2
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/atom/DNFCallAtom.java32
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/atom/RelationViewAtom.java32
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/literal/CallLiteral.java (renamed from subprojects/store/src/main/java/tools/refinery/store/query/atom/CallAtom.java)32
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/literal/CallPolarity.java (renamed from subprojects/store/src/main/java/tools/refinery/store/query/atom/CallPolarity.java)2
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/literal/ConstantLiteral.java (renamed from subprojects/store/src/main/java/tools/refinery/store/query/atom/ConstantAtom.java)4
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/literal/DnfCallLiteral.java32
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/literal/EquivalenceLiteral.java (renamed from subprojects/store/src/main/java/tools/refinery/store/query/atom/EquivalenceAtom.java)6
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/literal/Literal.java (renamed from subprojects/store/src/main/java/tools/refinery/store/query/atom/DNFAtom.java)4
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/literal/Modality.java (renamed from subprojects/store/src/main/java/tools/refinery/store/query/atom/Modality.java)2
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/query/literal/RelationViewLiteral.java32
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/representation/Symbol.java6
-rw-r--r--subprojects/store/src/test/java/tools/refinery/store/model/tests/ModelTest.java2
27 files changed, 264 insertions, 287 deletions
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryBuilder.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryBuilder.java
index efc6146c..24aa52e2 100644
--- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryBuilder.java
+++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/ViatraModelQueryBuilder.java
@@ -4,7 +4,7 @@ import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions;
4import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory; 4import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory;
5import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; 5import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
6import tools.refinery.store.model.ModelStore; 6import tools.refinery.store.model.ModelStore;
7import tools.refinery.store.query.DNF; 7import tools.refinery.store.query.Dnf;
8import tools.refinery.store.query.ModelQueryBuilder; 8import tools.refinery.store.query.ModelQueryBuilder;
9 9
10import java.util.Collection; 10import java.util.Collection;
@@ -23,25 +23,25 @@ public interface ViatraModelQueryBuilder extends ModelQueryBuilder {
23 ViatraModelQueryBuilder searchBackend(IQueryBackendFactory queryBackendFactory); 23 ViatraModelQueryBuilder searchBackend(IQueryBackendFactory queryBackendFactory);
24 24
25 @Override 25 @Override
26 default ViatraModelQueryBuilder queries(DNF... queries) { 26 default ViatraModelQueryBuilder queries(Dnf... queries) {
27 ModelQueryBuilder.super.queries(queries); 27 ModelQueryBuilder.super.queries(queries);
28 return this; 28 return this;
29 } 29 }
30 30
31 @Override 31 @Override
32 default ViatraModelQueryBuilder queries(Collection<DNF> queries) { 32 default ViatraModelQueryBuilder queries(Collection<Dnf> queries) {
33 ModelQueryBuilder.super.queries(queries); 33 ModelQueryBuilder.super.queries(queries);
34 return this; 34 return this;
35 } 35 }
36 36
37 @Override 37 @Override
38 ViatraModelQueryBuilder query(DNF query); 38 ViatraModelQueryBuilder query(Dnf query);
39 39
40 ViatraModelQueryBuilder query(DNF query, QueryEvaluationHint queryEvaluationHint); 40 ViatraModelQueryBuilder query(Dnf query, QueryEvaluationHint queryEvaluationHint);
41 41
42 ViatraModelQueryBuilder computeHint(Function<DNF, QueryEvaluationHint> computeHint); 42 ViatraModelQueryBuilder computeHint(Function<Dnf, QueryEvaluationHint> computeHint);
43 43
44 ViatraModelQueryBuilder hint(DNF dnf, QueryEvaluationHint queryEvaluationHint); 44 ViatraModelQueryBuilder hint(Dnf dnf, QueryEvaluationHint queryEvaluationHint);
45 45
46 @Override 46 @Override
47 ViatraModelQueryStoreAdapter createStoreAdapter(ModelStore store); 47 ViatraModelQueryStoreAdapter createStoreAdapter(ModelStore store);
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryAdapterImpl.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryAdapterImpl.java
index 039f46fa..e5d8e2f6 100644
--- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryAdapterImpl.java
+++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryAdapterImpl.java
@@ -7,7 +7,7 @@ import org.eclipse.viatra.query.runtime.internal.apiimpl.ViatraQueryEngineImpl;
7import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackend; 7import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackend;
8import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory; 8import org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory;
9import tools.refinery.store.model.Model; 9import tools.refinery.store.model.Model;
10import tools.refinery.store.query.DNF; 10import tools.refinery.store.query.Dnf;
11import tools.refinery.store.query.ResultSet; 11import tools.refinery.store.query.ResultSet;
12import tools.refinery.store.query.viatra.ViatraModelQueryAdapter; 12import tools.refinery.store.query.viatra.ViatraModelQueryAdapter;
13 13
@@ -27,7 +27,7 @@ public class ViatraModelQueryAdapterImpl implements ViatraModelQueryAdapter {
27 private final ViatraQueryEngineImpl queryEngine; 27 private final ViatraQueryEngineImpl queryEngine;
28 private final MethodHandle setUpdatePropagationDelayedHandle; 28 private final MethodHandle setUpdatePropagationDelayedHandle;
29 private final MethodHandle getQueryBackendsHandle; 29 private final MethodHandle getQueryBackendsHandle;
30 private final Map<DNF, ResultSet> resultSets; 30 private final Map<Dnf, ResultSet> resultSets;
31 private boolean pendingChanges; 31 private boolean pendingChanges;
32 32
33 ViatraModelQueryAdapterImpl(Model model, ViatraModelQueryStoreAdapterImpl storeAdapter) { 33 ViatraModelQueryAdapterImpl(Model model, ViatraModelQueryStoreAdapterImpl storeAdapter) {
@@ -95,7 +95,7 @@ public class ViatraModelQueryAdapterImpl implements ViatraModelQueryAdapter {
95 } 95 }
96 96
97 @Override 97 @Override
98 public ResultSet getResultSet(DNF query) { 98 public ResultSet getResultSet(Dnf query) {
99 var resultSet = resultSets.get(query); 99 var resultSet = resultSets.get(query);
100 if (resultSet == null) { 100 if (resultSet == null) {
101 throw new IllegalArgumentException("No matcher for query %s in model".formatted(query.name())); 101 throw new IllegalArgumentException("No matcher for query %s in model".formatted(query.name()));
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryBuilderImpl.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryBuilderImpl.java
index 9f1e55b1..af20033a 100644
--- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryBuilderImpl.java
+++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryBuilderImpl.java
@@ -9,9 +9,9 @@ import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory;
9import tools.refinery.store.adapter.AbstractModelAdapterBuilder; 9import tools.refinery.store.adapter.AbstractModelAdapterBuilder;
10import tools.refinery.store.model.ModelStore; 10import tools.refinery.store.model.ModelStore;
11import tools.refinery.store.model.ModelStoreBuilder; 11import tools.refinery.store.model.ModelStoreBuilder;
12import tools.refinery.store.query.DNF; 12import tools.refinery.store.query.Dnf;
13import tools.refinery.store.query.viatra.ViatraModelQueryBuilder; 13import tools.refinery.store.query.viatra.ViatraModelQueryBuilder;
14import tools.refinery.store.query.viatra.internal.pquery.DNF2PQuery; 14import tools.refinery.store.query.viatra.internal.pquery.Dnf2PQuery;
15import tools.refinery.store.query.viatra.internal.pquery.RawPatternMatcher; 15import tools.refinery.store.query.viatra.internal.pquery.RawPatternMatcher;
16 16
17import java.util.Collections; 17import java.util.Collections;
@@ -21,8 +21,8 @@ import java.util.function.Function;
21 21
22public class ViatraModelQueryBuilderImpl extends AbstractModelAdapterBuilder implements ViatraModelQueryBuilder { 22public class ViatraModelQueryBuilderImpl extends AbstractModelAdapterBuilder implements ViatraModelQueryBuilder {
23 private ViatraQueryEngineOptions.Builder engineOptionsBuilder; 23 private ViatraQueryEngineOptions.Builder engineOptionsBuilder;
24 private final DNF2PQuery dnf2PQuery = new DNF2PQuery(); 24 private final Dnf2PQuery dnf2PQuery = new Dnf2PQuery();
25 private final Map<DNF, IQuerySpecification<RawPatternMatcher>> querySpecifications = new LinkedHashMap<>(); 25 private final Map<Dnf, IQuerySpecification<RawPatternMatcher>> querySpecifications = new LinkedHashMap<>();
26 26
27 public ViatraModelQueryBuilderImpl(ModelStoreBuilder storeBuilder) { 27 public ViatraModelQueryBuilderImpl(ModelStoreBuilder storeBuilder) {
28 super(storeBuilder); 28 super(storeBuilder);
@@ -63,7 +63,7 @@ public class ViatraModelQueryBuilderImpl extends AbstractModelAdapterBuilder imp
63 } 63 }
64 64
65 @Override 65 @Override
66 public ViatraModelQueryBuilder query(DNF query) { 66 public ViatraModelQueryBuilder query(Dnf query) {
67 if (querySpecifications.containsKey(query)) { 67 if (querySpecifications.containsKey(query)) {
68 throw new IllegalArgumentException("%s was already added to the query engine".formatted(query.name())); 68 throw new IllegalArgumentException("%s was already added to the query engine".formatted(query.name()));
69 } 69 }
@@ -73,20 +73,20 @@ public class ViatraModelQueryBuilderImpl extends AbstractModelAdapterBuilder imp
73 } 73 }
74 74
75 @Override 75 @Override
76 public ViatraModelQueryBuilder query(DNF query, QueryEvaluationHint queryEvaluationHint) { 76 public ViatraModelQueryBuilder query(Dnf query, QueryEvaluationHint queryEvaluationHint) {
77 query(query); 77 query(query);
78 hint(query, queryEvaluationHint); 78 hint(query, queryEvaluationHint);
79 return this; 79 return this;
80 } 80 }
81 81
82 @Override 82 @Override
83 public ViatraModelQueryBuilder computeHint(Function<DNF, QueryEvaluationHint> computeHint) { 83 public ViatraModelQueryBuilder computeHint(Function<Dnf, QueryEvaluationHint> computeHint) {
84 dnf2PQuery.setComputeHint(computeHint); 84 dnf2PQuery.setComputeHint(computeHint);
85 return this; 85 return this;
86 } 86 }
87 87
88 @Override 88 @Override
89 public ViatraModelQueryBuilder hint(DNF dnf, QueryEvaluationHint queryEvaluationHint) { 89 public ViatraModelQueryBuilder hint(Dnf dnf, QueryEvaluationHint queryEvaluationHint) {
90 var pQuery = dnf2PQuery.getAlreadyTranslated(dnf); 90 var pQuery = dnf2PQuery.getAlreadyTranslated(dnf);
91 if (pQuery == null) { 91 if (pQuery == null) {
92 throw new IllegalArgumentException( 92 throw new IllegalArgumentException(
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryStoreAdapterImpl.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryStoreAdapterImpl.java
index 394e407e..8323118b 100644
--- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryStoreAdapterImpl.java
+++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/ViatraModelQueryStoreAdapterImpl.java
@@ -5,7 +5,7 @@ import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions;
5import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; 5import org.eclipse.viatra.query.runtime.matchers.context.IInputKey;
6import tools.refinery.store.model.Model; 6import tools.refinery.store.model.Model;
7import tools.refinery.store.model.ModelStore; 7import tools.refinery.store.model.ModelStore;
8import tools.refinery.store.query.DNF; 8import tools.refinery.store.query.Dnf;
9import tools.refinery.store.query.viatra.ViatraModelQueryStoreAdapter; 9import tools.refinery.store.query.viatra.ViatraModelQueryStoreAdapter;
10import tools.refinery.store.query.viatra.internal.pquery.RawPatternMatcher; 10import tools.refinery.store.query.viatra.internal.pquery.RawPatternMatcher;
11import tools.refinery.store.query.view.AnyRelationView; 11import tools.refinery.store.query.view.AnyRelationView;
@@ -17,11 +17,11 @@ public class ViatraModelQueryStoreAdapterImpl implements ViatraModelQueryStoreAd
17 private final ModelStore store; 17 private final ModelStore store;
18 private final ViatraQueryEngineOptions engineOptions; 18 private final ViatraQueryEngineOptions engineOptions;
19 private final Map<AnyRelationView, IInputKey> inputKeys; 19 private final Map<AnyRelationView, IInputKey> inputKeys;
20 private final Map<DNF, IQuerySpecification<RawPatternMatcher>> querySpecifications; 20 private final Map<Dnf, IQuerySpecification<RawPatternMatcher>> querySpecifications;
21 21
22 ViatraModelQueryStoreAdapterImpl(ModelStore store, ViatraQueryEngineOptions engineOptions, 22 ViatraModelQueryStoreAdapterImpl(ModelStore store, ViatraQueryEngineOptions engineOptions,
23 Map<AnyRelationView, IInputKey> inputKeys, 23 Map<AnyRelationView, IInputKey> inputKeys,
24 Map<DNF, IQuerySpecification<RawPatternMatcher>> querySpecifications) { 24 Map<Dnf, IQuerySpecification<RawPatternMatcher>> querySpecifications) {
25 this.store = store; 25 this.store = store;
26 this.engineOptions = engineOptions; 26 this.engineOptions = engineOptions;
27 this.inputKeys = inputKeys; 27 this.inputKeys = inputKeys;
@@ -42,11 +42,11 @@ public class ViatraModelQueryStoreAdapterImpl implements ViatraModelQueryStoreAd
42 } 42 }
43 43
44 @Override 44 @Override
45 public Collection<DNF> getQueries() { 45 public Collection<Dnf> getQueries() {
46 return querySpecifications.keySet(); 46 return querySpecifications.keySet();
47 } 47 }
48 48
49 Map<DNF, IQuerySpecification<RawPatternMatcher>> getQuerySpecifications() { 49 Map<Dnf, IQuerySpecification<RawPatternMatcher>> getQuerySpecifications() {
50 return querySpecifications; 50 return querySpecifications;
51 } 51 }
52 52
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/DNF2PQuery.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java
index 60f1bcae..02e26bde 100644
--- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/DNF2PQuery.java
+++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java
@@ -17,38 +17,38 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
17import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; 17import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
18import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; 18import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
19import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; 19import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
20import tools.refinery.store.query.DNF; 20import tools.refinery.store.query.Dnf;
21import tools.refinery.store.query.DNFAnd; 21import tools.refinery.store.query.DnfClause;
22import tools.refinery.store.query.DNFUtils; 22import tools.refinery.store.query.DnfUtils;
23import tools.refinery.store.query.Variable; 23import tools.refinery.store.query.Variable;
24import tools.refinery.store.query.atom.*; 24import tools.refinery.store.query.literal.*;
25import tools.refinery.store.query.view.AnyRelationView; 25import tools.refinery.store.query.view.AnyRelationView;
26 26
27import java.util.*; 27import java.util.*;
28import java.util.function.Function; 28import java.util.function.Function;
29import java.util.stream.Collectors; 29import java.util.stream.Collectors;
30 30
31public class DNF2PQuery { 31public class Dnf2PQuery {
32 private static final Object P_CONSTRAINT_LOCK = new Object(); 32 private static final Object P_CONSTRAINT_LOCK = new Object();
33 33
34 private final Set<DNF> translating = new LinkedHashSet<>(); 34 private final Set<Dnf> translating = new LinkedHashSet<>();
35 35
36 private final Map<DNF, RawPQuery> dnf2PQueryMap = new HashMap<>(); 36 private final Map<Dnf, RawPQuery> dnf2PQueryMap = new HashMap<>();
37 37
38 private final Map<AnyRelationView, RelationViewWrapper> view2WrapperMap = new LinkedHashMap<>(); 38 private final Map<AnyRelationView, RelationViewWrapper> view2WrapperMap = new LinkedHashMap<>();
39 39
40 private final Map<AnyRelationView, RawPQuery> view2EmbeddedMap = new HashMap<>(); 40 private final Map<AnyRelationView, RawPQuery> view2EmbeddedMap = new HashMap<>();
41 41
42 private Function<DNF, QueryEvaluationHint> computeHint = dnf -> new QueryEvaluationHint(null, 42 private Function<Dnf, QueryEvaluationHint> computeHint = dnf -> new QueryEvaluationHint(null,
43 QueryEvaluationHint.BackendRequirement.UNSPECIFIED); 43 QueryEvaluationHint.BackendRequirement.UNSPECIFIED);
44 44
45 public void setComputeHint(Function<DNF, QueryEvaluationHint> computeHint) { 45 public void setComputeHint(Function<Dnf, QueryEvaluationHint> computeHint) {
46 this.computeHint = computeHint; 46 this.computeHint = computeHint;
47 } 47 }
48 48
49 public RawPQuery translate(DNF dnfQuery) { 49 public RawPQuery translate(Dnf dnfQuery) {
50 if (translating.contains(dnfQuery)) { 50 if (translating.contains(dnfQuery)) {
51 var path = translating.stream().map(DNF::name).collect(Collectors.joining(" -> ")); 51 var path = translating.stream().map(Dnf::name).collect(Collectors.joining(" -> "));
52 throw new IllegalStateException("Circular reference %s -> %s detected".formatted(path, 52 throw new IllegalStateException("Circular reference %s -> %s detected".formatted(path,
53 dnfQuery.name())); 53 dnfQuery.name()));
54 } 54 }
@@ -71,11 +71,11 @@ public class DNF2PQuery {
71 return Collections.unmodifiableMap(view2WrapperMap); 71 return Collections.unmodifiableMap(view2WrapperMap);
72 } 72 }
73 73
74 public RawPQuery getAlreadyTranslated(DNF dnfQuery) { 74 public RawPQuery getAlreadyTranslated(Dnf dnfQuery) {
75 return dnf2PQueryMap.get(dnfQuery); 75 return dnf2PQueryMap.get(dnfQuery);
76 } 76 }
77 77
78 private RawPQuery doTranslate(DNF dnfQuery) { 78 private RawPQuery doTranslate(Dnf dnfQuery) {
79 var pQuery = new RawPQuery(dnfQuery.getUniqueName()); 79 var pQuery = new RawPQuery(dnfQuery.getUniqueName());
80 pQuery.setEvaluationHints(computeHint.apply(dnfQuery)); 80 pQuery.setEvaluationHints(computeHint.apply(dnfQuery));
81 81
@@ -103,9 +103,9 @@ public class DNF2PQuery {
103 103
104 // The constructor of {@link org.eclipse.viatra.query.runtime.matchers.psystem.BasePConstraint} mutates 104 // The constructor of {@link org.eclipse.viatra.query.runtime.matchers.psystem.BasePConstraint} mutates
105 // global static state (<code>nextID</code>) without locking. Therefore, we need to synchronize before creating 105 // global static state (<code>nextID</code>) without locking. Therefore, we need to synchronize before creating
106 // any query constraints to avoid a data race. 106 // any query literals to avoid a data race.
107 synchronized (P_CONSTRAINT_LOCK) { 107 synchronized (P_CONSTRAINT_LOCK) {
108 for (DNFAnd clause : dnfQuery.getClauses()) { 108 for (DnfClause clause : dnfQuery.getClauses()) {
109 PBody body = new PBody(pQuery); 109 PBody body = new PBody(pQuery);
110 List<ExportedParameter> symbolicParameters = new ArrayList<>(); 110 List<ExportedParameter> symbolicParameters = new ArrayList<>();
111 for (var param : dnfQuery.getParameters()) { 111 for (var param : dnfQuery.getParameters()) {
@@ -114,8 +114,8 @@ public class DNF2PQuery {
114 } 114 }
115 body.setSymbolicParameters(symbolicParameters); 115 body.setSymbolicParameters(symbolicParameters);
116 pQuery.addBody(body); 116 pQuery.addBody(body);
117 for (DNFAtom constraint : clause.constraints()) { 117 for (Literal literal : clause.literals()) {
118 translateDNFAtom(constraint, body); 118 translateLiteral(literal, body);
119 } 119 }
120 } 120 }
121 } 121 }
@@ -123,34 +123,34 @@ public class DNF2PQuery {
123 return pQuery; 123 return pQuery;
124 } 124 }
125 125
126 private void translateDNFAtom(DNFAtom constraint, PBody body) { 126 private void translateLiteral(Literal literal, PBody body) {
127 if (constraint instanceof EquivalenceAtom equivalenceAtom) { 127 if (literal instanceof EquivalenceLiteral equivalenceLiteral) {
128 translateEquivalenceAtom(equivalenceAtom, body); 128 translateEquivalenceLiteral(equivalenceLiteral, body);
129 } else if (constraint instanceof RelationViewAtom relationViewAtom) { 129 } else if (literal instanceof RelationViewLiteral relationViewLiteral) {
130 translateRelationViewAtom(relationViewAtom, body); 130 translateRelationViewLiteral(relationViewLiteral, body);
131 } else if (constraint instanceof DNFCallAtom callAtom) { 131 } else if (literal instanceof DnfCallLiteral dnfCallLiteral) {
132 translateCallAtom(callAtom, body); 132 translateDnfCallLiteral(dnfCallLiteral, body);
133 } else if (constraint instanceof ConstantAtom constantAtom) { 133 } else if (literal instanceof ConstantLiteral constantLiteral) {
134 translateConstantAtom(constantAtom, body); 134 translateConstantLiteral(constantLiteral, body);
135 } else { 135 } else {
136 throw new IllegalArgumentException("Unknown constraint: " + constraint.toString()); 136 throw new IllegalArgumentException("Unknown literal: " + literal.toString());
137 } 137 }
138 } 138 }
139 139
140 private void translateEquivalenceAtom(EquivalenceAtom equivalence, PBody body) { 140 private void translateEquivalenceLiteral(EquivalenceLiteral equivalenceLiteral, PBody body) {
141 PVariable varSource = body.getOrCreateVariableByName(equivalence.left().getUniqueName()); 141 PVariable varSource = body.getOrCreateVariableByName(equivalenceLiteral.left().getUniqueName());
142 PVariable varTarget = body.getOrCreateVariableByName(equivalence.right().getUniqueName()); 142 PVariable varTarget = body.getOrCreateVariableByName(equivalenceLiteral.right().getUniqueName());
143 if (equivalence.positive()) { 143 if (equivalenceLiteral.positive()) {
144 new Equality(body, varSource, varTarget); 144 new Equality(body, varSource, varTarget);
145 } else { 145 } else {
146 new Inequality(body, varSource, varTarget); 146 new Inequality(body, varSource, varTarget);
147 } 147 }
148 } 148 }
149 149
150 private void translateRelationViewAtom(RelationViewAtom relationViewAtom, PBody body) { 150 private void translateRelationViewLiteral(RelationViewLiteral relationViewLiteral, PBody body) {
151 var substitution = translateSubstitution(relationViewAtom.getSubstitution(), body); 151 var substitution = translateSubstitution(relationViewLiteral.getSubstitution(), body);
152 var polarity = relationViewAtom.getPolarity(); 152 var polarity = relationViewLiteral.getPolarity();
153 var relationView = relationViewAtom.getTarget(); 153 var relationView = relationViewLiteral.getTarget();
154 if (polarity == CallPolarity.POSITIVE) { 154 if (polarity == CallPolarity.POSITIVE) {
155 new TypeConstraint(body, substitution, wrapView(relationView)); 155 new TypeConstraint(body, substitution, wrapView(relationView));
156 } else { 156 } else {
@@ -178,7 +178,7 @@ public class DNF2PQuery {
178 } 178 }
179 179
180 private RawPQuery doTranslateEmbeddedRelationViewPQuery(AnyRelationView relationView) { 180 private RawPQuery doTranslateEmbeddedRelationViewPQuery(AnyRelationView relationView) {
181 var embeddedPQuery = new RawPQuery(DNFUtils.generateUniqueName(relationView.name()), PVisibility.EMBEDDED); 181 var embeddedPQuery = new RawPQuery(DnfUtils.generateUniqueName(relationView.name()), PVisibility.EMBEDDED);
182 var body = new PBody(embeddedPQuery); 182 var body = new PBody(embeddedPQuery);
183 int arity = relationView.arity(); 183 int arity = relationView.arity();
184 var parameters = new ArrayList<PParameter>(arity); 184 var parameters = new ArrayList<PParameter>(arity);
@@ -204,10 +204,10 @@ public class DNF2PQuery {
204 return view2WrapperMap.computeIfAbsent(relationView, RelationViewWrapper::new); 204 return view2WrapperMap.computeIfAbsent(relationView, RelationViewWrapper::new);
205 } 205 }
206 206
207 private void translateCallAtom(DNFCallAtom callAtom, PBody body) { 207 private void translateDnfCallLiteral(DnfCallLiteral dnfCallLiteral, PBody body) {
208 var variablesTuple = translateSubstitution(callAtom.getSubstitution(), body); 208 var variablesTuple = translateSubstitution(dnfCallLiteral.getSubstitution(), body);
209 var translatedReferred = translate(callAtom.getTarget()); 209 var translatedReferred = translate(dnfCallLiteral.getTarget());
210 var polarity = callAtom.getPolarity(); 210 var polarity = dnfCallLiteral.getPolarity();
211 switch (polarity) { 211 switch (polarity) {
212 case POSITIVE -> new PositivePatternCall(body, variablesTuple, translatedReferred); 212 case POSITIVE -> new PositivePatternCall(body, variablesTuple, translatedReferred);
213 case TRANSITIVE -> new BinaryTransitiveClosure(body, variablesTuple, translatedReferred); 213 case TRANSITIVE -> new BinaryTransitiveClosure(body, variablesTuple, translatedReferred);
@@ -216,8 +216,8 @@ public class DNF2PQuery {
216 } 216 }
217 } 217 }
218 218
219 private void translateConstantAtom(ConstantAtom constantAtom, PBody body) { 219 private void translateConstantLiteral(ConstantLiteral constantLiteral, PBody body) {
220 var variable = body.getOrCreateVariableByName(constantAtom.variable().getUniqueName()); 220 var variable = body.getOrCreateVariableByName(constantLiteral.variable().getUniqueName());
221 new ConstantValue(body, variable, constantAtom.nodeId()); 221 new ConstantValue(body, variable, constantLiteral.nodeId());
222 } 222 }
223} 223}
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTest.java
index 6a37b54a..471fdfc9 100644
--- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTest.java
+++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTest.java
@@ -2,10 +2,13 @@ package tools.refinery.store.query.viatra;
2 2
3import org.junit.jupiter.api.Test; 3import org.junit.jupiter.api.Test;
4import tools.refinery.store.model.ModelStore; 4import tools.refinery.store.model.ModelStore;
5import tools.refinery.store.query.DNF; 5import tools.refinery.store.query.Dnf;
6import tools.refinery.store.query.ModelQuery; 6import tools.refinery.store.query.ModelQuery;
7import tools.refinery.store.query.Variable; 7import tools.refinery.store.query.Variable;
8import tools.refinery.store.query.atom.*; 8import tools.refinery.store.query.literal.CallPolarity;
9import tools.refinery.store.query.literal.DnfCallLiteral;
10import tools.refinery.store.query.literal.EquivalenceLiteral;
11import tools.refinery.store.query.literal.RelationViewLiteral;
9import tools.refinery.store.query.view.FilteredRelationView; 12import tools.refinery.store.query.view.FilteredRelationView;
10import tools.refinery.store.query.view.KeyOnlyRelationView; 13import tools.refinery.store.query.view.KeyOnlyRelationView;
11import tools.refinery.store.representation.Symbol; 14import tools.refinery.store.representation.Symbol;
@@ -27,9 +30,9 @@ class QueryTest {
27 var personView = new KeyOnlyRelationView<>(person); 30 var personView = new KeyOnlyRelationView<>(person);
28 31
29 var p1 = new Variable("p1"); 32 var p1 = new Variable("p1");
30 var predicate = DNF.builder("TypeConstraint") 33 var predicate = Dnf.builder("TypeConstraint")
31 .parameters(p1) 34 .parameters(p1)
32 .clause(new RelationViewAtom(personView, p1)) 35 .clause(new RelationViewLiteral(personView, p1))
33 .build(); 36 .build();
34 37
35 var store = ModelStore.builder() 38 var store = ModelStore.builder()
@@ -64,12 +67,12 @@ class QueryTest {
64 67
65 var p1 = new Variable("p1"); 68 var p1 = new Variable("p1");
66 var p2 = new Variable("p2"); 69 var p2 = new Variable("p2");
67 var predicate = DNF.builder("RelationConstraint") 70 var predicate = Dnf.builder("RelationConstraint")
68 .parameters(p1, p2) 71 .parameters(p1, p2)
69 .clause( 72 .clause(
70 new RelationViewAtom(personView, p1), 73 new RelationViewLiteral(personView, p1),
71 new RelationViewAtom(personView, p2), 74 new RelationViewLiteral(personView, p2),
72 new RelationViewAtom(friendMustView, p1, p2) 75 new RelationViewLiteral(friendMustView, p1, p2)
73 ) 76 )
74 .build(); 77 .build();
75 78
@@ -111,13 +114,13 @@ class QueryTest {
111 114
112 var p1 = new Variable("p1"); 115 var p1 = new Variable("p1");
113 var p2 = new Variable("p2"); 116 var p2 = new Variable("p2");
114 var predicate = DNF.builder("RelationConstraint") 117 var predicate = Dnf.builder("RelationConstraint")
115 .parameters(p1, p2) 118 .parameters(p1, p2)
116 .clause( 119 .clause(
117 new RelationViewAtom(personView, p1), 120 new RelationViewLiteral(personView, p1),
118 new RelationViewAtom(personView, p2), 121 new RelationViewLiteral(personView, p2),
119 new RelationViewAtom(friendMustView, p1, p2), 122 new RelationViewLiteral(friendMustView, p1, p2),
120 new RelationViewAtom(friendMustView, p2, p1) 123 new RelationViewLiteral(friendMustView, p2, p1)
121 ) 124 )
122 .build(); 125 .build();
123 126
@@ -166,12 +169,12 @@ class QueryTest {
166 169
167 var p1 = new Variable("p1"); 170 var p1 = new Variable("p1");
168 var p2 = new Variable("p2"); 171 var p2 = new Variable("p2");
169 var predicate = DNF.builder("RelationConstraint") 172 var predicate = Dnf.builder("RelationConstraint")
170 .parameters(p1) 173 .parameters(p1)
171 .clause( 174 .clause(
172 new RelationViewAtom(personView, p1), 175 new RelationViewLiteral(personView, p1),
173 new RelationViewAtom(personView, p2), 176 new RelationViewLiteral(personView, p2),
174 new RelationViewAtom(friendMustView, p1, p2) 177 new RelationViewLiteral(friendMustView, p1, p2)
175 ) 178 )
176 .build(); 179 .build();
177 180
@@ -213,17 +216,17 @@ class QueryTest {
213 216
214 var p1 = new Variable("p1"); 217 var p1 = new Variable("p1");
215 var p2 = new Variable("p2"); 218 var p2 = new Variable("p2");
216 var predicate = DNF.builder("Or") 219 var predicate = Dnf.builder("Or")
217 .parameters(p1, p2) 220 .parameters(p1, p2)
218 .clause( 221 .clause(
219 new RelationViewAtom(personView, p1), 222 new RelationViewLiteral(personView, p1),
220 new RelationViewAtom(personView, p2), 223 new RelationViewLiteral(personView, p2),
221 new RelationViewAtom(friendMustView, p1, p2) 224 new RelationViewLiteral(friendMustView, p1, p2)
222 ) 225 )
223 .clause( 226 .clause(
224 new RelationViewAtom(animalView, p1), 227 new RelationViewLiteral(animalView, p1),
225 new RelationViewAtom(animalView, p2), 228 new RelationViewLiteral(animalView, p2),
226 new RelationViewAtom(friendMustView, p1, p2) 229 new RelationViewLiteral(friendMustView, p1, p2)
227 ) 230 )
228 .build(); 231 .build();
229 232
@@ -263,12 +266,12 @@ class QueryTest {
263 266
264 var p1 = new Variable("p1"); 267 var p1 = new Variable("p1");
265 var p2 = new Variable("p2"); 268 var p2 = new Variable("p2");
266 var predicate = DNF.builder("Equality") 269 var predicate = Dnf.builder("Equality")
267 .parameters(p1, p2) 270 .parameters(p1, p2)
268 .clause( 271 .clause(
269 new RelationViewAtom(personView, p1), 272 new RelationViewLiteral(personView, p1),
270 new RelationViewAtom(personView, p2), 273 new RelationViewLiteral(personView, p2),
271 new EquivalenceAtom(p1, p2) 274 new EquivalenceLiteral(p1, p2)
272 ) 275 )
273 .build(); 276 .build();
274 277
@@ -302,14 +305,14 @@ class QueryTest {
302 var p1 = new Variable("p1"); 305 var p1 = new Variable("p1");
303 var p2 = new Variable("p2"); 306 var p2 = new Variable("p2");
304 var p3 = new Variable("p3"); 307 var p3 = new Variable("p3");
305 var predicate = DNF.builder("Inequality") 308 var predicate = Dnf.builder("Inequality")
306 .parameters(p1, p2, p3) 309 .parameters(p1, p2, p3)
307 .clause( 310 .clause(
308 new RelationViewAtom(personView, p1), 311 new RelationViewLiteral(personView, p1),
309 new RelationViewAtom(personView, p2), 312 new RelationViewLiteral(personView, p2),
310 new RelationViewAtom(friendMustView, p1, p3), 313 new RelationViewLiteral(friendMustView, p1, p3),
311 new RelationViewAtom(friendMustView, p2, p3), 314 new RelationViewLiteral(friendMustView, p2, p3),
312 new EquivalenceAtom(false, p1, p2) 315 new EquivalenceLiteral(false, p1, p2)
313 ) 316 )
314 .build(); 317 .build();
315 318
@@ -346,23 +349,23 @@ class QueryTest {
346 349
347 var p1 = new Variable("p1"); 350 var p1 = new Variable("p1");
348 var p2 = new Variable("p2"); 351 var p2 = new Variable("p2");
349 var friendPredicate = DNF.builder("RelationConstraint") 352 var friendPredicate = Dnf.builder("RelationConstraint")
350 .parameters(p1, p2) 353 .parameters(p1, p2)
351 .clause( 354 .clause(
352 new RelationViewAtom(personView, p1), 355 new RelationViewLiteral(personView, p1),
353 new RelationViewAtom(personView, p2), 356 new RelationViewLiteral(personView, p2),
354 new RelationViewAtom(friendMustView, p1, p2) 357 new RelationViewLiteral(friendMustView, p1, p2)
355 ) 358 )
356 .build(); 359 .build();
357 360
358 var p3 = new Variable("p3"); 361 var p3 = new Variable("p3");
359 var p4 = new Variable("p4"); 362 var p4 = new Variable("p4");
360 var predicate = DNF.builder("PositivePatternCall") 363 var predicate = Dnf.builder("PositivePatternCall")
361 .parameters(p3, p4) 364 .parameters(p3, p4)
362 .clause( 365 .clause(
363 new RelationViewAtom(personView, p3), 366 new RelationViewLiteral(personView, p3),
364 new RelationViewAtom(personView, p4), 367 new RelationViewLiteral(personView, p4),
365 new DNFCallAtom(friendPredicate, p3, p4) 368 new DnfCallLiteral(friendPredicate, p3, p4)
366 ) 369 )
367 .build(); 370 .build();
368 371
@@ -399,12 +402,12 @@ class QueryTest {
399 402
400 var p1 = new Variable("p1"); 403 var p1 = new Variable("p1");
401 var p2 = new Variable("p2"); 404 var p2 = new Variable("p2");
402 var predicate = DNF.builder("NegativePatternCall") 405 var predicate = Dnf.builder("NegativePatternCall")
403 .parameters(p1, p2) 406 .parameters(p1, p2)
404 .clause( 407 .clause(
405 new RelationViewAtom(personView, p1), 408 new RelationViewLiteral(personView, p1),
406 new RelationViewAtom(personView, p2), 409 new RelationViewLiteral(personView, p2),
407 new RelationViewAtom(false, friendMustView, p1, p2) 410 new RelationViewLiteral(false, friendMustView, p1, p2)
408 ) 411 )
409 .build(); 412 .build();
410 413
@@ -441,23 +444,23 @@ class QueryTest {
441 444
442 var p1 = new Variable("p1"); 445 var p1 = new Variable("p1");
443 var p2 = new Variable("p2"); 446 var p2 = new Variable("p2");
444 var friendPredicate = DNF.builder("RelationConstraint") 447 var friendPredicate = Dnf.builder("RelationConstraint")
445 .parameters(p1, p2) 448 .parameters(p1, p2)
446 .clause( 449 .clause(
447 new RelationViewAtom(personView, p1), 450 new RelationViewLiteral(personView, p1),
448 new RelationViewAtom(personView, p2), 451 new RelationViewLiteral(personView, p2),
449 new RelationViewAtom(friendMustView, p1, p2) 452 new RelationViewLiteral(friendMustView, p1, p2)
450 ) 453 )
451 .build(); 454 .build();
452 455
453 var p3 = new Variable("p3"); 456 var p3 = new Variable("p3");
454 var p4 = new Variable("p4"); 457 var p4 = new Variable("p4");
455 var predicate = DNF.builder("NegativePatternCall") 458 var predicate = Dnf.builder("NegativePatternCall")
456 .parameters(p3, p4) 459 .parameters(p3, p4)
457 .clause( 460 .clause(
458 new RelationViewAtom(personView, p3), 461 new RelationViewLiteral(personView, p3),
459 new RelationViewAtom(personView, p4), 462 new RelationViewLiteral(personView, p4),
460 new DNFCallAtom(false, friendPredicate, p3, p4) 463 new DnfCallLiteral(false, friendPredicate, p3, p4)
461 ) 464 )
462 .build(); 465 .build();
463 466
@@ -495,11 +498,11 @@ class QueryTest {
495 var p1 = new Variable("p1"); 498 var p1 = new Variable("p1");
496 var p2 = new Variable("p2"); 499 var p2 = new Variable("p2");
497 500
498 var predicate = DNF.builder("Count") 501 var predicate = Dnf.builder("Count")
499 .parameters(p1) 502 .parameters(p1)
500 .clause( 503 .clause(
501 new RelationViewAtom(personView, p1), 504 new RelationViewLiteral(personView, p1),
502 new RelationViewAtom(false, friendMustView, p1, p2) 505 new RelationViewLiteral(false, friendMustView, p1, p2)
503 ) 506 )
504 .build(); 507 .build();
505 508
@@ -536,20 +539,20 @@ class QueryTest {
536 var p1 = new Variable("p1"); 539 var p1 = new Variable("p1");
537 var p2 = new Variable("p2"); 540 var p2 = new Variable("p2");
538 541
539 var called = DNF.builder("Called") 542 var called = Dnf.builder("Called")
540 .parameters(p1, p2) 543 .parameters(p1, p2)
541 .clause( 544 .clause(
542 new RelationViewAtom(personView, p1), 545 new RelationViewLiteral(personView, p1),
543 new RelationViewAtom(personView, p2), 546 new RelationViewLiteral(personView, p2),
544 new RelationViewAtom(friendMustView, p1, p2) 547 new RelationViewLiteral(friendMustView, p1, p2)
545 ) 548 )
546 .build(); 549 .build();
547 550
548 var predicate = DNF.builder("Count") 551 var predicate = Dnf.builder("Count")
549 .parameters(p1) 552 .parameters(p1)
550 .clause( 553 .clause(
551 new RelationViewAtom(personView, p1), 554 new RelationViewLiteral(personView, p1),
552 new DNFCallAtom(false, called, p1, p2) 555 new DnfCallLiteral(false, called, p1, p2)
553 ) 556 )
554 .build(); 557 .build();
555 558
@@ -585,12 +588,12 @@ class QueryTest {
585 588
586 var p1 = new Variable("p1"); 589 var p1 = new Variable("p1");
587 var p2 = new Variable("p2"); 590 var p2 = new Variable("p2");
588 var predicate = DNF.builder("TransitivePatternCall") 591 var predicate = Dnf.builder("TransitivePatternCall")
589 .parameters(p1, p2) 592 .parameters(p1, p2)
590 .clause( 593 .clause(
591 new RelationViewAtom(personView, p1), 594 new RelationViewLiteral(personView, p1),
592 new RelationViewAtom(personView, p2), 595 new RelationViewLiteral(personView, p2),
593 new RelationViewAtom(CallPolarity.TRANSITIVE, friendMustView, p1, p2) 596 new RelationViewLiteral(CallPolarity.TRANSITIVE, friendMustView, p1, p2)
594 ) 597 )
595 .build(); 598 .build();
596 599
@@ -626,23 +629,23 @@ class QueryTest {
626 629
627 var p1 = new Variable("p1"); 630 var p1 = new Variable("p1");
628 var p2 = new Variable("p2"); 631 var p2 = new Variable("p2");
629 var friendPredicate = DNF.builder("RelationConstraint") 632 var friendPredicate = Dnf.builder("RelationConstraint")
630 .parameters(p1, p2) 633 .parameters(p1, p2)
631 .clause( 634 .clause(
632 new RelationViewAtom(personView, p1), 635 new RelationViewLiteral(personView, p1),
633 new RelationViewAtom(personView, p2), 636 new RelationViewLiteral(personView, p2),
634 new RelationViewAtom(friendMustView, p1, p2) 637 new RelationViewLiteral(friendMustView, p1, p2)
635 ) 638 )
636 .build(); 639 .build();
637 640
638 var p3 = new Variable("p3"); 641 var p3 = new Variable("p3");
639 var p4 = new Variable("p4"); 642 var p4 = new Variable("p4");
640 var predicate = DNF.builder("TransitivePatternCall") 643 var predicate = Dnf.builder("TransitivePatternCall")
641 .parameters(p3, p4) 644 .parameters(p3, p4)
642 .clause( 645 .clause(
643 new RelationViewAtom(personView, p3), 646 new RelationViewLiteral(personView, p3),
644 new RelationViewAtom(personView, p4), 647 new RelationViewLiteral(personView, p4),
645 new DNFCallAtom(CallPolarity.TRANSITIVE, friendPredicate, p3, p4) 648 new DnfCallLiteral(CallPolarity.TRANSITIVE, friendPredicate, p3, p4)
646 ) 649 )
647 .build(); 650 .build();
648 651
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTransactionTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTransactionTest.java
index 98995339..99b942d2 100644
--- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTransactionTest.java
+++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTransactionTest.java
@@ -2,10 +2,10 @@ package tools.refinery.store.query.viatra;
2 2
3import org.junit.jupiter.api.Test; 3import org.junit.jupiter.api.Test;
4import tools.refinery.store.model.ModelStore; 4import tools.refinery.store.model.ModelStore;
5import tools.refinery.store.query.DNF; 5import tools.refinery.store.query.Dnf;
6import tools.refinery.store.query.ModelQuery; 6import tools.refinery.store.query.ModelQuery;
7import tools.refinery.store.query.Variable; 7import tools.refinery.store.query.Variable;
8import tools.refinery.store.query.atom.RelationViewAtom; 8import tools.refinery.store.query.literal.RelationViewLiteral;
9import tools.refinery.store.query.view.KeyOnlyRelationView; 9import tools.refinery.store.query.view.KeyOnlyRelationView;
10import tools.refinery.store.representation.Symbol; 10import tools.refinery.store.representation.Symbol;
11import tools.refinery.store.tuple.Tuple; 11import tools.refinery.store.tuple.Tuple;
@@ -20,9 +20,9 @@ class QueryTransactionTest {
20 var personView = new KeyOnlyRelationView<>(person); 20 var personView = new KeyOnlyRelationView<>(person);
21 21
22 var p1 = new Variable("p1"); 22 var p1 = new Variable("p1");
23 var predicate = DNF.builder("TypeConstraint") 23 var predicate = Dnf.builder("TypeConstraint")
24 .parameters(p1) 24 .parameters(p1)
25 .clause(new RelationViewAtom(personView, p1)) 25 .clause(new RelationViewLiteral(personView, p1))
26 .build(); 26 .build();
27 27
28 var store = ModelStore.builder() 28 var store = ModelStore.builder()
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/DNFAnd.java b/subprojects/store/src/main/java/tools/refinery/store/query/DNFAnd.java
deleted file mode 100644
index 8c3bf05d..00000000
--- a/subprojects/store/src/main/java/tools/refinery/store/query/DNFAnd.java
+++ /dev/null
@@ -1,9 +0,0 @@
1package tools.refinery.store.query;
2
3import tools.refinery.store.query.atom.DNFAtom;
4
5import java.util.List;
6import java.util.Set;
7
8public record DNFAnd(Set<Variable> quantifiedVariables, List<DNFAtom> constraints) {
9}
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/DNF.java b/subprojects/store/src/main/java/tools/refinery/store/query/Dnf.java
index 95c5d787..f7b27b81 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/query/DNF.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/query/Dnf.java
@@ -1,10 +1,10 @@
1package tools.refinery.store.query; 1package tools.refinery.store.query;
2 2
3import tools.refinery.store.query.atom.DNFAtom; 3import tools.refinery.store.query.literal.Literal;
4 4
5import java.util.*; 5import java.util.*;
6 6
7public final class DNF implements RelationLike { 7public final class Dnf implements RelationLike {
8 private final String name; 8 private final String name;
9 9
10 private final String uniqueName; 10 private final String uniqueName;
@@ -13,13 +13,13 @@ public final class DNF implements RelationLike {
13 13
14 private final List<FunctionalDependency<Variable>> functionalDependencies; 14 private final List<FunctionalDependency<Variable>> functionalDependencies;
15 15
16 private final List<DNFAnd> clauses; 16 private final List<DnfClause> clauses;
17 17
18 private DNF(String name, List<Variable> parameters, List<FunctionalDependency<Variable>> functionalDependencies, 18 private Dnf(String name, List<Variable> parameters, List<FunctionalDependency<Variable>> functionalDependencies,
19 List<DNFAnd> clauses) { 19 List<DnfClause> clauses) {
20 validateFunctionalDependencies(parameters, functionalDependencies); 20 validateFunctionalDependencies(parameters, functionalDependencies);
21 this.name = name; 21 this.name = name;
22 this.uniqueName = DNFUtils.generateUniqueName(name); 22 this.uniqueName = DnfUtils.generateUniqueName(name);
23 this.parameters = parameters; 23 this.parameters = parameters;
24 this.functionalDependencies = functionalDependencies; 24 this.functionalDependencies = functionalDependencies;
25 this.clauses = clauses; 25 this.clauses = clauses;
@@ -68,7 +68,7 @@ public final class DNF implements RelationLike {
68 return parameters.size(); 68 return parameters.size();
69 } 69 }
70 70
71 public List<DNFAnd> getClauses() { 71 public List<DnfClause> getClauses() {
72 return clauses; 72 return clauses;
73 } 73 }
74 74
@@ -88,7 +88,7 @@ public final class DNF implements RelationLike {
88 88
89 private final List<FunctionalDependency<Variable>> functionalDependencies = new ArrayList<>(); 89 private final List<FunctionalDependency<Variable>> functionalDependencies = new ArrayList<>();
90 90
91 private final List<List<DNFAtom>> clauses = new ArrayList<>(); 91 private final List<List<Literal>> clauses = new ArrayList<>();
92 92
93 private Builder(String name) { 93 private Builder(String name) {
94 this.name = name; 94 this.name = name;
@@ -122,46 +122,46 @@ public final class DNF implements RelationLike {
122 return functionalDependency(new FunctionalDependency<>(forEach, unique)); 122 return functionalDependency(new FunctionalDependency<>(forEach, unique));
123 } 123 }
124 124
125 public Builder clause(DNFAtom... atoms) { 125 public Builder clause(Literal... atoms) {
126 clauses.add(List.of(atoms)); 126 clauses.add(List.of(atoms));
127 return this; 127 return this;
128 } 128 }
129 129
130 public Builder clause(Collection<DNFAtom> atoms) { 130 public Builder clause(Collection<Literal> atoms) {
131 clauses.add(List.copyOf(atoms)); 131 clauses.add(List.copyOf(atoms));
132 return this; 132 return this;
133 } 133 }
134 134
135 public Builder clause(DNFAnd clause) { 135 public Builder clause(DnfClause clause) {
136 return clause(clause.constraints()); 136 return clause(clause.literals());
137 } 137 }
138 138
139 public Builder clauses(DNFAnd... clauses) { 139 public Builder clauses(DnfClause... clauses) {
140 for (var clause : clauses) { 140 for (var clause : clauses) {
141 this.clause(clause); 141 this.clause(clause);
142 } 142 }
143 return this; 143 return this;
144 } 144 }
145 145
146 public Builder clauses(Collection<DNFAnd> clauses) { 146 public Builder clauses(Collection<DnfClause> clauses) {
147 for (var clause : clauses) { 147 for (var clause : clauses) {
148 this.clause(clause); 148 this.clause(clause);
149 } 149 }
150 return this; 150 return this;
151 } 151 }
152 152
153 public DNF build() { 153 public Dnf build() {
154 var postProcessedClauses = new ArrayList<DNFAnd>(); 154 var postProcessedClauses = new ArrayList<DnfClause>();
155 for (var constraints : clauses) { 155 for (var constraints : clauses) {
156 var variables = new HashSet<Variable>(); 156 var variables = new HashSet<Variable>();
157 for (var constraint : constraints) { 157 for (var constraint : constraints) {
158 constraint.collectAllVariables(variables); 158 constraint.collectAllVariables(variables);
159 } 159 }
160 parameters.forEach(variables::remove); 160 parameters.forEach(variables::remove);
161 postProcessedClauses.add(new DNFAnd(Collections.unmodifiableSet(variables), 161 postProcessedClauses.add(new DnfClause(Collections.unmodifiableSet(variables),
162 Collections.unmodifiableList(constraints))); 162 Collections.unmodifiableList(constraints)));
163 } 163 }
164 return new DNF(name, Collections.unmodifiableList(parameters), 164 return new Dnf(name, Collections.unmodifiableList(parameters),
165 Collections.unmodifiableList(functionalDependencies), 165 Collections.unmodifiableList(functionalDependencies),
166 Collections.unmodifiableList(postProcessedClauses)); 166 Collections.unmodifiableList(postProcessedClauses));
167 } 167 }
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/DnfClause.java b/subprojects/store/src/main/java/tools/refinery/store/query/DnfClause.java
new file mode 100644
index 00000000..2ba6becc
--- /dev/null
+++ b/subprojects/store/src/main/java/tools/refinery/store/query/DnfClause.java
@@ -0,0 +1,9 @@
1package tools.refinery.store.query;
2
3import tools.refinery.store.query.literal.Literal;
4
5import java.util.List;
6import java.util.Set;
7
8public record DnfClause(Set<Variable> quantifiedVariables, List<Literal> literals) {
9}
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/DNFUtils.java b/subprojects/store/src/main/java/tools/refinery/store/query/DnfUtils.java
index 0ef77d49..c7a2849c 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/query/DNFUtils.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/query/DnfUtils.java
@@ -2,8 +2,8 @@ package tools.refinery.store.query;
2 2
3import java.util.UUID; 3import java.util.UUID;
4 4
5public final class DNFUtils { 5public final class DnfUtils {
6 private DNFUtils() { 6 private DnfUtils() {
7 throw new IllegalStateException("This is a static utility class and should not be instantiated directly"); 7 throw new IllegalStateException("This is a static utility class and should not be instantiated directly");
8 } 8 }
9 9
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/ModelQueryAdapter.java b/subprojects/store/src/main/java/tools/refinery/store/query/ModelQueryAdapter.java
index 7449e39b..f7762444 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/query/ModelQueryAdapter.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/query/ModelQueryAdapter.java
@@ -5,7 +5,7 @@ import tools.refinery.store.adapter.ModelAdapter;
5public interface ModelQueryAdapter extends ModelAdapter { 5public interface ModelQueryAdapter extends ModelAdapter {
6 ModelQueryStoreAdapter getStoreAdapter(); 6 ModelQueryStoreAdapter getStoreAdapter();
7 7
8 ResultSet getResultSet(DNF query); 8 ResultSet getResultSet(Dnf query);
9 9
10 boolean hasPendingChanges(); 10 boolean hasPendingChanges();
11 11
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/ModelQueryBuilder.java b/subprojects/store/src/main/java/tools/refinery/store/query/ModelQueryBuilder.java
index 4364d844..b3cfb4b4 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/query/ModelQueryBuilder.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/query/ModelQueryBuilder.java
@@ -7,16 +7,16 @@ import java.util.Collection;
7import java.util.List; 7import java.util.List;
8 8
9public interface ModelQueryBuilder extends ModelAdapterBuilder { 9public interface ModelQueryBuilder extends ModelAdapterBuilder {
10 default ModelQueryBuilder queries(DNF... queries) { 10 default ModelQueryBuilder queries(Dnf... queries) {
11 return queries(List.of(queries)); 11 return queries(List.of(queries));
12 } 12 }
13 13
14 default ModelQueryBuilder queries(Collection<DNF> queries) { 14 default ModelQueryBuilder queries(Collection<Dnf> queries) {
15 queries.forEach(this::query); 15 queries.forEach(this::query);
16 return this; 16 return this;
17 } 17 }
18 18
19 ModelQueryBuilder query(DNF query); 19 ModelQueryBuilder query(Dnf query);
20 20
21 @Override 21 @Override
22 ModelQueryStoreAdapter createStoreAdapter(ModelStore store); 22 ModelQueryStoreAdapter createStoreAdapter(ModelStore store);
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/ModelQueryStoreAdapter.java b/subprojects/store/src/main/java/tools/refinery/store/query/ModelQueryStoreAdapter.java
index ef5a4587..3efeacaa 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/query/ModelQueryStoreAdapter.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/query/ModelQueryStoreAdapter.java
@@ -9,7 +9,7 @@ import java.util.Collection;
9public interface ModelQueryStoreAdapter extends ModelStoreAdapter { 9public interface ModelQueryStoreAdapter extends ModelStoreAdapter {
10 Collection<AnyRelationView> getRelationViews(); 10 Collection<AnyRelationView> getRelationViews();
11 11
12 Collection<DNF> getQueries(); 12 Collection<Dnf> getQueries();
13 13
14 @Override 14 @Override
15 ModelQueryAdapter createModelAdapter(Model model); 15 ModelQueryAdapter createModelAdapter(Model model);
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/Variable.java b/subprojects/store/src/main/java/tools/refinery/store/query/Variable.java
index 3632f3c5..6a6831ae 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/query/Variable.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/query/Variable.java
@@ -13,7 +13,7 @@ public class Variable {
13 public Variable(String name) { 13 public Variable(String name) {
14 super(); 14 super();
15 this.name = name; 15 this.name = name;
16 this.uniqueName = DNFUtils.generateUniqueName(name); 16 this.uniqueName = DnfUtils.generateUniqueName(name);
17 17
18 } 18 }
19 public String getName() { 19 public String getName() {
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/DNFCallAtom.java b/subprojects/store/src/main/java/tools/refinery/store/query/atom/DNFCallAtom.java
deleted file mode 100644
index 3b4f5cd1..00000000
--- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/DNFCallAtom.java
+++ /dev/null
@@ -1,32 +0,0 @@
1package tools.refinery.store.query.atom;
2
3import tools.refinery.store.query.DNF;
4import tools.refinery.store.query.Variable;
5
6import java.util.List;
7
8public class DNFCallAtom extends CallAtom<DNF> {
9 public DNFCallAtom(CallPolarity polarity, DNF target, List<Variable> substitution) {
10 super(polarity, target, substitution);
11 }
12
13 public DNFCallAtom(CallPolarity polarity, DNF target, Variable... substitution) {
14 super(polarity, target, substitution);
15 }
16
17 public DNFCallAtom(boolean positive, DNF target, List<Variable> substitution) {
18 super(positive, target, substitution);
19 }
20
21 public DNFCallAtom(boolean positive, DNF target, Variable... substitution) {
22 super(positive, target, substitution);
23 }
24
25 public DNFCallAtom(DNF target, List<Variable> substitution) {
26 super(target, substitution);
27 }
28
29 public DNFCallAtom(DNF target, Variable... substitution) {
30 super(target, substitution);
31 }
32}
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/RelationViewAtom.java b/subprojects/store/src/main/java/tools/refinery/store/query/atom/RelationViewAtom.java
deleted file mode 100644
index a2b176c4..00000000
--- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/RelationViewAtom.java
+++ /dev/null
@@ -1,32 +0,0 @@
1package tools.refinery.store.query.atom;
2
3import tools.refinery.store.query.Variable;
4import tools.refinery.store.query.view.AnyRelationView;
5
6import java.util.List;
7
8public final class RelationViewAtom extends CallAtom<AnyRelationView> {
9 public RelationViewAtom(CallPolarity polarity, AnyRelationView target, List<Variable> substitution) {
10 super(polarity, target, substitution);
11 }
12
13 public RelationViewAtom(CallPolarity polarity, AnyRelationView target, Variable... substitution) {
14 super(polarity, target, substitution);
15 }
16
17 public RelationViewAtom(boolean positive, AnyRelationView target, List<Variable> substitution) {
18 super(positive, target, substitution);
19 }
20
21 public RelationViewAtom(boolean positive, AnyRelationView target, Variable... substitution) {
22 super(positive, target, substitution);
23 }
24
25 public RelationViewAtom(AnyRelationView target, List<Variable> substitution) {
26 super(target, substitution);
27 }
28
29 public RelationViewAtom(AnyRelationView target, Variable... substitution) {
30 super(target, substitution);
31 }
32}
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallAtom.java b/subprojects/store/src/main/java/tools/refinery/store/query/literal/CallLiteral.java
index 47121870..59120434 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallAtom.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/query/literal/CallLiteral.java
@@ -1,4 +1,4 @@
1package tools.refinery.store.query.atom; 1package tools.refinery.store.query.literal;
2 2
3import tools.refinery.store.query.Variable; 3import tools.refinery.store.query.Variable;
4import tools.refinery.store.query.RelationLike; 4import tools.refinery.store.query.RelationLike;
@@ -7,12 +7,12 @@ import java.util.List;
7import java.util.Objects; 7import java.util.Objects;
8import java.util.Set; 8import java.util.Set;
9 9
10public abstract class CallAtom<T extends RelationLike> implements DNFAtom { 10public abstract class CallLiteral<T extends RelationLike> implements Literal {
11 private final CallPolarity polarity; 11 private final CallPolarity polarity;
12 private final T target; 12 private final T target;
13 private final List<Variable> substitution; 13 private final List<Variable> substitution;
14 14
15 protected CallAtom(CallPolarity polarity, T target, List<Variable> substitution) { 15 protected CallLiteral(CallPolarity polarity, T target, List<Variable> substitution) {
16 if (substitution.size() != target.arity()) { 16 if (substitution.size() != target.arity()) {
17 throw new IllegalArgumentException("%s needs %d arguments, but got %s".formatted(target.name(), 17 throw new IllegalArgumentException("%s needs %d arguments, but got %s".formatted(target.name(),
18 target.arity(), substitution.size())); 18 target.arity(), substitution.size()));
@@ -25,26 +25,6 @@ public abstract class CallAtom<T extends RelationLike> implements DNFAtom {
25 this.substitution = substitution; 25 this.substitution = substitution;
26 } 26 }
27 27
28 protected CallAtom(CallPolarity polarity, T target, Variable... substitution) {
29 this(polarity, target, List.of(substitution));
30 }
31
32 protected CallAtom(boolean positive, T target, List<Variable> substitution) {
33 this(CallPolarity.fromBoolean(positive), target, substitution);
34 }
35
36 protected CallAtom(boolean positive, T target, Variable... substitution) {
37 this(positive, target, List.of(substitution));
38 }
39
40 protected CallAtom(T target, List<Variable> substitution) {
41 this(true, target, substitution);
42 }
43
44 protected CallAtom(T target, Variable... substitution) {
45 this(target, List.of(substitution));
46 }
47
48 public CallPolarity getPolarity() { 28 public CallPolarity getPolarity() {
49 return polarity; 29 return polarity;
50 } 30 }
@@ -68,9 +48,9 @@ public abstract class CallAtom<T extends RelationLike> implements DNFAtom {
68 public boolean equals(Object o) { 48 public boolean equals(Object o) {
69 if (this == o) return true; 49 if (this == o) return true;
70 if (o == null || getClass() != o.getClass()) return false; 50 if (o == null || getClass() != o.getClass()) return false;
71 CallAtom<?> callAtom = (CallAtom<?>) o; 51 CallLiteral<?> callAtom = (CallLiteral<?>) o;
72 return polarity == callAtom.polarity && Objects.equals(target, callAtom.target) && Objects.equals(substitution 52 return polarity == callAtom.polarity && Objects.equals(target, callAtom.target) &&
73 , callAtom.substitution); 53 Objects.equals(substitution, callAtom.substitution);
74 } 54 }
75 55
76 @Override 56 @Override
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallPolarity.java b/subprojects/store/src/main/java/tools/refinery/store/query/literal/CallPolarity.java
index 957e9b7b..ddea0221 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallPolarity.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/query/literal/CallPolarity.java
@@ -1,4 +1,4 @@
1package tools.refinery.store.query.atom; 1package tools.refinery.store.query.literal;
2 2
3public enum CallPolarity { 3public enum CallPolarity {
4 POSITIVE(true, false), 4 POSITIVE(true, false),
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/ConstantAtom.java b/subprojects/store/src/main/java/tools/refinery/store/query/literal/ConstantLiteral.java
index 13dae7d0..41426fdd 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/ConstantAtom.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/query/literal/ConstantLiteral.java
@@ -1,10 +1,10 @@
1package tools.refinery.store.query.atom; 1package tools.refinery.store.query.literal;
2 2
3import tools.refinery.store.query.Variable; 3import tools.refinery.store.query.Variable;
4 4
5import java.util.Set; 5import java.util.Set;
6 6
7public record ConstantAtom(Variable variable, int nodeId) implements DNFAtom { 7public record ConstantLiteral(Variable variable, int nodeId) implements Literal {
8 @Override 8 @Override
9 public void collectAllVariables(Set<Variable> variables) { 9 public void collectAllVariables(Set<Variable> variables) {
10 variables.add(variable); 10 variables.add(variable);
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/literal/DnfCallLiteral.java b/subprojects/store/src/main/java/tools/refinery/store/query/literal/DnfCallLiteral.java
new file mode 100644
index 00000000..e3410c21
--- /dev/null
+++ b/subprojects/store/src/main/java/tools/refinery/store/query/literal/DnfCallLiteral.java
@@ -0,0 +1,32 @@
1package tools.refinery.store.query.literal;
2
3import tools.refinery.store.query.Dnf;
4import tools.refinery.store.query.Variable;
5
6import java.util.List;
7
8public final class DnfCallLiteral extends CallLiteral<Dnf> {
9 public DnfCallLiteral(CallPolarity polarity, Dnf target, List<Variable> substitution) {
10 super(polarity, target, substitution);
11 }
12
13 public DnfCallLiteral(CallPolarity polarity, Dnf target, Variable... substitution) {
14 this(polarity, target, List.of(substitution));
15 }
16
17 public DnfCallLiteral(boolean positive, Dnf target, List<Variable> substitution) {
18 this(CallPolarity.fromBoolean(positive), target, substitution);
19 }
20
21 public DnfCallLiteral(boolean positive, Dnf target, Variable... substitution) {
22 this(positive, target, List.of(substitution));
23 }
24
25 public DnfCallLiteral(Dnf target, List<Variable> substitution) {
26 this(CallPolarity.POSITIVE, target, substitution);
27 }
28
29 public DnfCallLiteral(Dnf target, Variable... substitution) {
30 this(target, List.of(substitution));
31 }
32}
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/EquivalenceAtom.java b/subprojects/store/src/main/java/tools/refinery/store/query/literal/EquivalenceLiteral.java
index b1b3a6f7..a1ec2c41 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/EquivalenceAtom.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/query/literal/EquivalenceLiteral.java
@@ -1,11 +1,11 @@
1package tools.refinery.store.query.atom; 1package tools.refinery.store.query.literal;
2 2
3import tools.refinery.store.query.Variable; 3import tools.refinery.store.query.Variable;
4 4
5import java.util.Set; 5import java.util.Set;
6 6
7public record EquivalenceAtom(boolean positive, Variable left, Variable right) implements DNFAtom { 7public record EquivalenceLiteral(boolean positive, Variable left, Variable right) implements Literal {
8 public EquivalenceAtom(Variable left, Variable right) { 8 public EquivalenceLiteral(Variable left, Variable right) {
9 this(true, left, right); 9 this(true, left, right);
10 } 10 }
11 11
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/DNFAtom.java b/subprojects/store/src/main/java/tools/refinery/store/query/literal/Literal.java
index ebf71236..676ac7fd 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/DNFAtom.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/query/literal/Literal.java
@@ -1,9 +1,9 @@
1package tools.refinery.store.query.atom; 1package tools.refinery.store.query.literal;
2 2
3import tools.refinery.store.query.Variable; 3import tools.refinery.store.query.Variable;
4 4
5import java.util.Set; 5import java.util.Set;
6 6
7public interface DNFAtom { 7public interface Literal {
8 void collectAllVariables(Set<Variable> variables); 8 void collectAllVariables(Set<Variable> variables);
9} 9}
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/Modality.java b/subprojects/store/src/main/java/tools/refinery/store/query/literal/Modality.java
index e389f563..93826161 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/Modality.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/query/literal/Modality.java
@@ -1,4 +1,4 @@
1package tools.refinery.store.query.atom; 1package tools.refinery.store.query.literal;
2 2
3import java.util.Locale; 3import java.util.Locale;
4 4
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/literal/RelationViewLiteral.java b/subprojects/store/src/main/java/tools/refinery/store/query/literal/RelationViewLiteral.java
new file mode 100644
index 00000000..e2106ba9
--- /dev/null
+++ b/subprojects/store/src/main/java/tools/refinery/store/query/literal/RelationViewLiteral.java
@@ -0,0 +1,32 @@
1package tools.refinery.store.query.literal;
2
3import tools.refinery.store.query.Variable;
4import tools.refinery.store.query.view.AnyRelationView;
5
6import java.util.List;
7
8public final class RelationViewLiteral extends CallLiteral<AnyRelationView> {
9 public RelationViewLiteral(CallPolarity polarity, AnyRelationView target, List<Variable> substitution) {
10 super(polarity, target, substitution);
11 }
12
13 public RelationViewLiteral(CallPolarity polarity, AnyRelationView target, Variable... substitution) {
14 this(polarity, target, List.of(substitution));
15 }
16
17 public RelationViewLiteral(boolean positive, AnyRelationView target, List<Variable> substitution) {
18 this(CallPolarity.fromBoolean(positive), target, substitution);
19 }
20
21 public RelationViewLiteral(boolean positive, AnyRelationView target, Variable... substitution) {
22 this(positive, target, List.of(substitution));
23 }
24
25 public RelationViewLiteral(AnyRelationView target, List<Variable> substitution) {
26 this(CallPolarity.POSITIVE, target, substitution);
27 }
28
29 public RelationViewLiteral(AnyRelationView target, Variable... substitution) {
30 this(target, List.of(substitution));
31 }
32}
diff --git a/subprojects/store/src/main/java/tools/refinery/store/representation/Symbol.java b/subprojects/store/src/main/java/tools/refinery/store/representation/Symbol.java
index 85ea15f4..30b1c03f 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/representation/Symbol.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/representation/Symbol.java
@@ -1,12 +1,6 @@
1package tools.refinery.store.representation; 1package tools.refinery.store.representation;
2 2
3import java.util.Objects;
4
5public record Symbol<T>(String name, int arity, Class<T> valueType, T defaultValue) implements AnySymbol { 3public record Symbol<T>(String name, int arity, Class<T> valueType, T defaultValue) implements AnySymbol {
6 public boolean isDefaultValue(T value) {
7 return Objects.equals(defaultValue, value);
8 }
9
10 @Override 4 @Override
11 public boolean equals(Object o) { 5 public boolean equals(Object o) {
12 return this == o; 6 return this == o;
diff --git a/subprojects/store/src/test/java/tools/refinery/store/model/tests/ModelTest.java b/subprojects/store/src/test/java/tools/refinery/store/model/tests/ModelTest.java
index 371b5e47..9536a444 100644
--- a/subprojects/store/src/test/java/tools/refinery/store/model/tests/ModelTest.java
+++ b/subprojects/store/src/test/java/tools/refinery/store/model/tests/ModelTest.java
@@ -49,7 +49,7 @@ class ModelTest {
49 49
50 assertEquals(3, ageInterpretation.get(Tuple.of(0))); 50 assertEquals(3, ageInterpretation.get(Tuple.of(0)));
51 assertEquals(1, ageInterpretation.get(Tuple.of(1))); 51 assertEquals(1, ageInterpretation.get(Tuple.of(1)));
52 assertNull(ageInterpretation.get( Tuple.of(2))); 52 assertNull(ageInterpretation.get(Tuple.of(2)));
53 53
54 assertTrue(friendInterpretation.get(Tuple.of(0, 1))); 54 assertTrue(friendInterpretation.get(Tuple.of(0, 1)));
55 assertFalse(friendInterpretation.get(Tuple.of(0, 5))); 55 assertFalse(friendInterpretation.get(Tuple.of(0, 5)));