Skip to content

Commit b1075c7

Browse files
author
BaierD
committed
Extend documentation for Int/Real division, modulo and modular congruence
1 parent 3882ab0 commit b1075c7

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

src/org/sosy_lab/java_smt/api/IntegerFormulaManager.java

+23-12
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,42 @@
1919
public interface IntegerFormulaManager
2020
extends NumeralFormulaManager<IntegerFormula, IntegerFormula> {
2121

22-
/** Create a term representing the constraint {@code number1 == number2 (mod n)}. */
22+
/**
23+
* Create a term representing the constraint {@code number1 == number2 (mod n)}. Note: this is not
24+
* formally defined by the SMTLib standard, but supported by many solvers. Please consult the
25+
* documentation of the used solver for details.
26+
*/
2327
BooleanFormula modularCongruence(IntegerFormula number1, IntegerFormula number2, BigInteger n);
2428

25-
/** Create a term representing the constraint {@code number1 == number2 (mod n)}. */
29+
/**
30+
* Create a term representing the constraint {@code number1 == number2 (mod n)}. Note: this is not
31+
* formally defined by the SMTLib standard, but supported by many solvers. Please consult the
32+
* documentation of the used solver for details.
33+
*/
2634
BooleanFormula modularCongruence(IntegerFormula number1, IntegerFormula number2, long n);
2735

2836
/**
2937
* Create a formula representing the modulo of two operands according to Boute's Euclidean
30-
* definition. The quotient (div numerator denominator) of the internal modulo calculation is
31-
* floored for positive denominators and rounded up for negative denominators.
38+
* definition (DOI: 10.1145/128861.128862). The quotient (division of numerator by denominator) of
39+
* the modulo calculation (numerator - quotient * denominator = remainder, with remainder being
40+
* the result of this operation) is floored for positive denominators and rounded up for negative
41+
* denominators.
3242
*
3343
* <p>If the denominator evaluates to zero (modulo-by-zero), either directly as value or
3444
* indirectly via an additional constraint, then the solver is allowed to choose an arbitrary
35-
* value for the result of the modulo operation (cf. SMTLIB standard for the division operator in
36-
* Ints or Reals theory).
45+
* value for the result of the modulo operation (cf. SMTLib standard version 2.6 for the division
46+
* operator in Int or Real theory). The details of this are implementation specific and may change
47+
* solver by solver.
3748
*
3849
* <p>Examples:
3950
*
4051
* <ul>
41-
* <li>10 % 5 == 0
42-
* <li>10 % 3 == 1
43-
* <li>10 % (-3) == 1
44-
* <li>-10 % 5 == 0
45-
* <li>-10 % 3 == 2
46-
* <li>-10 % (-3) == 2
52+
* <li>modulo(10, 5) == 0
53+
* <li>modulo(10, 3) == 1
54+
* <li>modulo(10, -3) == 1
55+
* <li>modulo(-10, 5) == 0
56+
* <li>modulo(-10, 3) == 2
57+
* <li>modulo(-10, -3) == 2
4758
* </ul>
4859
*
4960
* <p>Note: Some solvers, e.g., Yices2, abort with an exception when exploring a modulo-by-zero

src/org/sosy_lab/java_smt/api/NumeralFormulaManager.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ public interface NumeralFormulaManager<
6969

7070
/**
7171
* Create a formula representing the division of two operands according to Boute's Euclidean
72-
* definition.
72+
* definition (DOI: 10.1145/128861.128862).
7373
*
7474
* <p>If the denominator evaluates to zero (division-by-zero), either directly as value or
7575
* indirectly via an additional constraint, then the solver is allowed to choose an arbitrary
76-
* value for the result of the division (cf. SMTLIB standard for the division operator in Ints or
77-
* Reals theory).
76+
* value for the result of the division (cf. SMTLib standard version 2.6 for the division operator
77+
* in Int or Real theory). The details of this are implementation specific and may change solver
78+
* by solver.
7879
*
7980
* <p>Note: Some solvers, e.g., Yices2, abort with an exception when exploring a division-by-zero
8081
* during the SAT-check. This is not compliant to the SMTLIB standard, but sadly happens.

0 commit comments

Comments
 (0)