Skip to content

Commit 5942e43

Browse files
Fix bug #461 for Z3
1 parent f05d372 commit 5942e43

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/org/sosy_lab/java_smt/solvers/z3/Z3NumeralFormulaManager.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,16 @@ protected Long subtract(Long pNumber1, Long pNumber2) {
8282

8383
@Override
8484
protected Long divide(Long pNumber1, Long pNumber2) {
85-
return Native.mkDiv(z3context, pNumber1, pNumber2);
85+
// If one of the arguments is rational and the other integer, add an explicit cast
86+
long sort1 = Native.getSort(z3context, pNumber1);
87+
long sort2 = Native.getSort(z3context, pNumber2);
88+
long arg1 = pNumber1;
89+
long arg2 = pNumber2;
90+
if (sort1 != sort2) {
91+
arg1 = (sort1 == formulaCreator.getIntegerType()) ? Native.mkInt2real(z3context, arg1) : arg1;
92+
arg2 = (sort2 == formulaCreator.getIntegerType()) ? Native.mkInt2real(z3context, arg2) : arg2;
93+
}
94+
return Native.mkDiv(z3context, arg1, arg2);
8695
}
8796

8897
@Override

0 commit comments

Comments
 (0)