aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/literal/ModalDnfCallLiteral.java
blob: 1090f1aef348f34df24ac43e700c89f678b01a0c (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
41
42
43
44
45
46
47
48
package tools.refinery.store.reasoning.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.literal.CallPolarity;
import tools.refinery.store.query.literal.DnfCallLiteral;
import tools.refinery.store.query.literal.LiteralReduction;
import tools.refinery.store.query.literal.PolarLiteral;
import tools.refinery.store.query.substitution.Substitution;

import java.util.List;

public class ModalDnfCallLiteral extends ModalLiteral<Dnf> implements PolarLiteral<ModalDnfCallLiteral> {
	public ModalDnfCallLiteral(CallPolarity polarity, Modality modality, Dnf target, List<Variable> arguments) {
		super(polarity, modality, target, arguments);
	}

	public ModalDnfCallLiteral(Modality modality, DnfCallLiteral baseLiteral) {
		super(modality.commute(baseLiteral.getPolarity()), baseLiteral);
	}

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

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

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

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

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