aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/logic/src/main/java/tools/refinery/logic/term/real/RealTerms.java
blob: 07dfa96b084720add50339d50031ec9fba71d9f4 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
 * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package tools.refinery.logic.term.real;

import tools.refinery.logic.term.Aggregator;
import tools.refinery.logic.term.ConstantTerm;
import tools.refinery.logic.term.ExtremeValueAggregator;
import tools.refinery.logic.term.Term;
import tools.refinery.logic.term.comparable.*;
import tools.refinery.logic.term.comparable.*;

import java.util.Comparator;

public final class RealTerms {
	public static final Aggregator<Double, Double> REAL_SUM = RealSumAggregator.INSTANCE;
	public static final Aggregator<Double, Double> REAL_MIN = new ExtremeValueAggregator<>(Double.class,
			Double.POSITIVE_INFINITY);
	public static final Aggregator<Double, Double> REAL_MAX = new ExtremeValueAggregator<>(Double.class,
			Double.NEGATIVE_INFINITY, Comparator.reverseOrder());

	private RealTerms() {
		throw new IllegalArgumentException("This is a static utility class and should not be instantiated directly");
	}

	public static Term<Double> constant(Double value) {
		return new ConstantTerm<>(Double.class, value);
	}

	public static Term<Double> plus(Term<Double> body) {
		return new RealPlusTerm(body);
	}

	public static Term<Double> minus(Term<Double> body) {
		return new RealMinusTerm(body);
	}

	public static Term<Double> add(Term<Double> left, Term<Double> right) {
		return new RealAddTerm(left, right);
	}

	public static Term<Double> sub(Term<Double> left, Term<Double> right) {
		return new RealSubTerm(left, right);
	}

	public static Term<Double> mul(Term<Double> left, Term<Double> right) {
		return new RealMulTerm(left, right);
	}

	public static Term<Double> div(Term<Double> left, Term<Double> right) {
		return new RealDivTerm(left, right);
	}

	public static Term<Double> pow(Term<Double> left, Term<Double> right) {
		return new RealPowTerm(left, right);
	}

	public static Term<Double> min(Term<Double> left, Term<Double> right) {
		return new RealMinTerm(left, right);
	}

	public static Term<Double> max(Term<Double> left, Term<Double> right) {
		return new RealMaxTerm(left, right);
	}

	public static Term<Boolean> eq(Term<Double> left, Term<Double> right) {
		return new EqTerm<>(Double.class, left, right);
	}

	public static Term<Boolean> notEq(Term<Double> left, Term<Double> right) {
		return new NotEqTerm<>(Double.class, left, right);
	}

	public static Term<Boolean> less(Term<Double> left, Term<Double> right) {
		return new LessTerm<>(Double.class, left, right);
	}

	public static Term<Boolean> lessEq(Term<Double> left, Term<Double> right) {
		return new LessEqTerm<>(Double.class, left, right);
	}

	public static Term<Boolean> greater(Term<Double> left, Term<Double> right) {
		return new GreaterTerm<>(Double.class, left, right);
	}

	public static Term<Boolean> greaterEq(Term<Double> left, Term<Double> right) {
		return new GreaterEqTerm<>(Double.class, left, right);
	}

	public static Term<Double> asReal(Term<Integer> body) {
		return new IntToRealTerm(body);
	}
}