aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-query/src/main/java/tools/refinery/store/query/literal/DnfCallLiteral.java
blob: 27917265cfaf853382705e0999286100ddb082cc (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
38
39
40
package tools.refinery.store.query.literal;

import tools.refinery.store.query.Dnf;
import tools.refinery.store.query.Variable;
import tools.refinery.store.query.equality.LiteralEqualityHelper;
import tools.refinery.store.query.substitution.Substitution;

import java.util.List;

public final class DnfCallLiteral extends CallLiteral<Dnf> implements PolarLiteral<DnfCallLiteral> {
	public DnfCallLiteral(CallPolarity polarity, Dnf target, List<Variable> arguments) {
		super(polarity, target, arguments);
	}

	@Override
	public Class<Dnf> getTargetType() {
		return Dnf.class;
	}

	@Override
	public DnfCallLiteral substitute(Substitution substitution) {
		return new DnfCallLiteral(getPolarity(), getTarget(), substituteArguments(substitution));
	}

	@Override
	public DnfCallLiteral negate() {
		return new DnfCallLiteral(getPolarity().negate(), getTarget(), getArguments());
	}

	@Override
	public LiteralReduction getReduction() {
		var dnfReduction = getTarget().getReduction();
		return getPolarity().isPositive() ? dnfReduction : dnfReduction.negate();
	}

	@Override
	protected boolean targetEquals(LiteralEqualityHelper helper, Dnf otherTarget) {
		return helper.dnfEqual(getTarget(), otherTarget);
	}
}