I am experimenting with OpenJML in combination with Z3, and I'm trying to reason about double
or float
values:
class Test {
//@ requires b > 0;
void a(double b) {
}
void b() {
a(2.4);
}
}
I have already found out OpenJML uses AUFLIA
as the default logic, which doesn't support reals
. I am now using AUFNIRA
.
Unfortunately, the tool is unable to prove this class:
→ java -jar openjml.jar -esc -prover z3_4_3 -exec ./z3 Test.java -noInternalSpecs -logic AUFNIRA
Test.java:8: warning: The prover cannot establish an assertion (Precondition: Test.java:3: ) in method b
a(2.4);
^
Test.java:3: warning: Associated declaration: Test.java:8:
//@ requires b > 0;
^
2 warnings
Why is this?
The SMT translation (used as input for
z3
) appears to be faulty when doubles are involved. In Program B below, which uses doubles instead of ints, the constants for either the call or the pre-condition never get translated into SMT.This is a fault of
openjml
, notz3
- sincez3
would need something of the form(define-fun _JML__tmp3 () Real 2345.0)
to work with (see verbose output of Program A), butopenjml
never generates it. In general, floating point support seems to be buggy.Program A (with ints):
Output (running with
-verbose | grep 234
, to search for mentions of1234
or2345
in the verbose output):Result:
Program B (with doubles):
Output (running with
-verbose | grep 234
, to search for mentions of1234.0
or2345.0
in the verbose output):Result: