java - Reasoning about reals -
i experimenting openjml in combination z3, , i'm trying reason double
or float
values:
class test { //@ requires b > 0; void a(double b) { } void b() { a(2.4); } }
i have found out openjml uses auflia
default logic, doesn't support reals
. using aufnira
.
unfortunately, tool unable prove class:
→ java -jar openjml.jar -esc -prover z3_4_3 -exec ./z3 test.java -nointernalspecs -logic aufnira test.java:8: warning: prover cannot establish 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 this?
the smt translation (used input z3
) appears faulty when doubles involved. in program b below, uses doubles instead of ints, constants either call or pre-condition never translated smt.
this fault of openjml
, not z3
- since z3
need of form (define-fun _jml__tmp3 () real 2345.0)
work (see verbose output of program a), openjml
never generates it. in general, floating point support seems buggy.
program a (with ints):
class test { //@ requires b > 1234; void a(int b) { } void z() { a(2345); } }
output (running -verbose | grep 234
, search mentions of 1234
or 2345
in verbose output):
// requires b > 1234; pre_1 = b > 1234; // requires b > 1234; assume assignment pre_1_0_21___4 == b_55 > 1234; (assert (= bl_58bodybegin_2 (=> (= _jml___exception_49_49___1 null) (=> (= _jml___termination_49_49___2 0) (=> (distinct null) (=> (or (= null) (and (and (distinct null) (javasubtype (javatypeof this) t_test)) (jmlsubtype (jmltypeof this) jmlt_test))) (=> (and (<= (- 2147483648) b_55) (<= b_55 2147483647)) (=> (select _isalloc___0 this) (=> (= (select _alloc___0 this) 0) (=> (= pre_1_0_21___3 false) (=> (= pre_1_0_21___4 (> b_55 1234)) (=> pre_1_0_21___4 bl_49_afterlabel_3)))))))))))) a(2345); // a(2345) int _jml__tmp3 = 2345; boolean _jml__tmp6 = _jml__tmp3 > 1234; // a(2345) int _jml__tmp3 = 2345 boolean _jml__tmp6 = _jml__tmp3 > 1234 (define-fun _jml__tmp3 () int 2345) (define-fun _jml__tmp6 () bool (> _jml__tmp3 1234))
result:
execution proof result unsat method checked ok [total 427ms]
program b (with doubles):
class test { //@ requires b > 1234.0; void a(double b) { } void z() { a(2345.0); } }
output (running -verbose | grep 234
, search mentions of 1234.0
or 2345.0
in verbose output):
// requires b > 1234.0; pre_1 = b > 1234.0; // requires b > 1234.0; assume assignment pre_1_0_29___4 == b_72 > 1234.0; a(2345.0); // a(2345.0) double _jml__tmp3 = 2345.0; boolean _jml__tmp6 = _jml__tmp3 > 1234.0; // a(2345.0) double _jml__tmp3 = 2345.0 boolean _jml__tmp6 = _jml__tmp3 > 1234.0 void z() { a(2345.0); } //@ requires b > 1234.0; test.java:4: a(2345.0) value: 2345.0 === 0.0
result:
execution proof result sat assertion not valid test.java:4: warning: prover cannot establish assertion (precondition: test.java:2: ) in method z void z() { a(2345.0); } ^ test.java:2: warning: associated declaration: test.java:4: //@ requires b > 1234.0; ^
Comments
Post a Comment