diff options
Diffstat (limited to 'subprojects/store')
20 files changed, 115 insertions, 141 deletions
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 @@ | |||
1 | package tools.refinery.store.query; | ||
2 | |||
3 | import tools.refinery.store.query.atom.DNFAtom; | ||
4 | |||
5 | import java.util.List; | ||
6 | import java.util.Set; | ||
7 | |||
8 | public 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 @@ | |||
1 | package tools.refinery.store.query; | 1 | package tools.refinery.store.query; |
2 | 2 | ||
3 | import tools.refinery.store.query.atom.DNFAtom; | 3 | import tools.refinery.store.query.literal.Literal; |
4 | 4 | ||
5 | import java.util.*; | 5 | import java.util.*; |
6 | 6 | ||
7 | public final class DNF implements RelationLike { | 7 | public 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 @@ | |||
1 | package tools.refinery.store.query; | ||
2 | |||
3 | import tools.refinery.store.query.literal.Literal; | ||
4 | |||
5 | import java.util.List; | ||
6 | import java.util.Set; | ||
7 | |||
8 | public 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 | ||
3 | import java.util.UUID; | 3 | import java.util.UUID; |
4 | 4 | ||
5 | public final class DNFUtils { | 5 | public 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; | |||
5 | public interface ModelQueryAdapter extends ModelAdapter { | 5 | public 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; | |||
7 | import java.util.List; | 7 | import java.util.List; |
8 | 8 | ||
9 | public interface ModelQueryBuilder extends ModelAdapterBuilder { | 9 | public 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; | |||
9 | public interface ModelQueryStoreAdapter extends ModelStoreAdapter { | 9 | public 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 @@ | |||
1 | package tools.refinery.store.query.atom; | ||
2 | |||
3 | import tools.refinery.store.query.DNF; | ||
4 | import tools.refinery.store.query.Variable; | ||
5 | |||
6 | import java.util.List; | ||
7 | |||
8 | public 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 @@ | |||
1 | package tools.refinery.store.query.atom; | ||
2 | |||
3 | import tools.refinery.store.query.Variable; | ||
4 | import tools.refinery.store.query.view.AnyRelationView; | ||
5 | |||
6 | import java.util.List; | ||
7 | |||
8 | public 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 @@ | |||
1 | package tools.refinery.store.query.atom; | 1 | package tools.refinery.store.query.literal; |
2 | 2 | ||
3 | import tools.refinery.store.query.Variable; | 3 | import tools.refinery.store.query.Variable; |
4 | import tools.refinery.store.query.RelationLike; | 4 | import tools.refinery.store.query.RelationLike; |
@@ -7,12 +7,12 @@ import java.util.List; | |||
7 | import java.util.Objects; | 7 | import java.util.Objects; |
8 | import java.util.Set; | 8 | import java.util.Set; |
9 | 9 | ||
10 | public abstract class CallAtom<T extends RelationLike> implements DNFAtom { | 10 | public 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 @@ | |||
1 | package tools.refinery.store.query.atom; | 1 | package tools.refinery.store.query.literal; |
2 | 2 | ||
3 | public enum CallPolarity { | 3 | public 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 @@ | |||
1 | package tools.refinery.store.query.atom; | 1 | package tools.refinery.store.query.literal; |
2 | 2 | ||
3 | import tools.refinery.store.query.Variable; | 3 | import tools.refinery.store.query.Variable; |
4 | 4 | ||
5 | import java.util.Set; | 5 | import java.util.Set; |
6 | 6 | ||
7 | public record ConstantAtom(Variable variable, int nodeId) implements DNFAtom { | 7 | public 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 @@ | |||
1 | package tools.refinery.store.query.literal; | ||
2 | |||
3 | import tools.refinery.store.query.Dnf; | ||
4 | import tools.refinery.store.query.Variable; | ||
5 | |||
6 | import java.util.List; | ||
7 | |||
8 | public 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 @@ | |||
1 | package tools.refinery.store.query.atom; | 1 | package tools.refinery.store.query.literal; |
2 | 2 | ||
3 | import tools.refinery.store.query.Variable; | 3 | import tools.refinery.store.query.Variable; |
4 | 4 | ||
5 | import java.util.Set; | 5 | import java.util.Set; |
6 | 6 | ||
7 | public record EquivalenceAtom(boolean positive, Variable left, Variable right) implements DNFAtom { | 7 | public 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 @@ | |||
1 | package tools.refinery.store.query.atom; | 1 | package tools.refinery.store.query.literal; |
2 | 2 | ||
3 | import tools.refinery.store.query.Variable; | 3 | import tools.refinery.store.query.Variable; |
4 | 4 | ||
5 | import java.util.Set; | 5 | import java.util.Set; |
6 | 6 | ||
7 | public interface DNFAtom { | 7 | public 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 @@ | |||
1 | package tools.refinery.store.query.atom; | 1 | package tools.refinery.store.query.literal; |
2 | 2 | ||
3 | import java.util.Locale; | 3 | import 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 @@ | |||
1 | package tools.refinery.store.query.literal; | ||
2 | |||
3 | import tools.refinery.store.query.Variable; | ||
4 | import tools.refinery.store.query.view.AnyRelationView; | ||
5 | |||
6 | import java.util.List; | ||
7 | |||
8 | public 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 @@ | |||
1 | package tools.refinery.store.representation; | 1 | package tools.refinery.store.representation; |
2 | 2 | ||
3 | import java.util.Objects; | ||
4 | |||
5 | public record Symbol<T>(String name, int arity, Class<T> valueType, T defaultValue) implements AnySymbol { | 3 | public 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))); |