-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathIntegerFormulaManager.java
69 lines (62 loc) · 2.72 KB
/
IntegerFormulaManager.java
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
// This file is part of JavaSMT,
// an API wrapper for a collection of SMT solvers:
// https://github.com/sosy-lab/java-smt
//
// SPDX-FileCopyrightText: 2020 Dirk Beyer <https://www.sosy-lab.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.sosy_lab.java_smt.api;
import java.math.BigInteger;
import org.sosy_lab.java_smt.api.NumeralFormula.IntegerFormula;
/**
* Interface which operates over {@link IntegerFormula}s.
*
* <p>Integer formulas always take integral formulas as arguments.
*/
public interface IntegerFormulaManager
extends NumeralFormulaManager<IntegerFormula, IntegerFormula> {
/**
* Create a term representing the constraint {@code number1 == number2 (mod n)}. Note: this is not
* formally defined by the SMTLib standard, but supported by many solvers. Please consult the
* documentation of the used solver for details.
*/
BooleanFormula modularCongruence(IntegerFormula number1, IntegerFormula number2, BigInteger n);
/**
* Create a term representing the constraint {@code number1 == number2 (mod n)}. Note: this is not
* formally defined by the SMTLib standard, but supported by many solvers. Please consult the
* documentation of the used solver for details.
*/
BooleanFormula modularCongruence(IntegerFormula number1, IntegerFormula number2, long n);
/**
* Create a formula representing the modulo of two operands according to Boute's Euclidean
* definition (DOI: 10.1145/128861.128862). The quotient (division of numerator by denominator) of
* the modulo calculation (numerator - quotient * denominator = remainder, with remainder being
* the result of this operation) is floored for positive denominators and rounded up for negative
* denominators.
*
* <p>If the denominator evaluates to zero (modulo-by-zero), either directly as value or
* indirectly via an additional constraint, then the solver is allowed to choose an arbitrary
* value for the result of the modulo operation (cf. SMTLib standard version 2.6 for the division
* operator in Int or Real theory). The details of this are implementation specific and may change
* solver by solver.
*
* <p>Examples:
*
* <ul>
* <li>modulo(10, 5) == 0
* <li>modulo(10, 3) == 1
* <li>modulo(10, -3) == 1
* <li>modulo(-10, 5) == 0
* <li>modulo(-10, 3) == 2
* <li>modulo(-10, -3) == 2
* </ul>
*
* <p>Note: Some solvers, e.g., Yices2, abort with an exception when exploring a modulo-by-zero
* during the SAT-check. This is not compliant to the SMTLIB standard, but sadly happens.
*/
IntegerFormula modulo(IntegerFormula numerator, IntegerFormula denominator);
@Override
default FormulaType<IntegerFormula> getFormulaType() {
return FormulaType.IntegerType;
}
}