blob: 90802864f729eefe0f5af04285fac2fe0e880537 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
/*
* SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
package tools.refinery.store.reasoning.translator.containment;
import tools.refinery.store.reasoning.representation.PartialRelation;
import tools.refinery.store.representation.TruthValue;
import java.util.Set;
record InferredContainment(TruthValue contains, Set<PartialRelation> mustLinks,
Set<PartialRelation> forbiddenLinks) {
public static final InferredContainment UNKNOWN = new InferredContainment(
TruthValue.UNKNOWN, Set.of(), Set.of());
public InferredContainment(TruthValue contains, Set<PartialRelation> mustLinks,
Set<PartialRelation> forbiddenLinks) {
this.contains = adjustContains(contains, mustLinks, forbiddenLinks);
this.mustLinks = mustLinks;
this.forbiddenLinks = forbiddenLinks;
}
private static TruthValue adjustContains(TruthValue contains, Set<PartialRelation> mustLinks,
Set<PartialRelation> forbiddenLinks) {
var result = contains;
if (!mustLinks.isEmpty()) {
result = result.merge(TruthValue.TRUE);
}
boolean hasErrorLink = mustLinks.stream().anyMatch(forbiddenLinks::contains);
if (mustLinks.size() >= 2 || hasErrorLink) {
result = result.merge(TruthValue.ERROR);
}
return result;
}
}
|