关于实际的推理

nha*_*man 21 java z3 openjml

我正在尝试将OpenJML与Z3结合使用,而我正试图推理doublefloat重视:

class Test {

  //@ requires b > 0;
  void a(double b) {
  }

  void b() {
    a(2.4);
  }
}
Run Code Online (Sandbox Code Playgroud)

我已经发现OpenJML AUFLIA用作默认逻辑,不支持reals.我现在正在使用AUFNIRA.

不幸的是,该工具无法证明此类:

? 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
Run Code Online (Sandbox Code Playgroud)

为什么是这样?

tuc*_*uxi 9

z3当涉及双打时,SMT翻译(用作输入)似乎有问题.在下面的程序B中,使用双精度而不是整数,调用或前置条件的常量永远不会转换为SMT.

这是一个错误openjml,而不是z3- 因为z3需要使用某种形式(define-fun _JML__tmp3 () Real 2345.0)(参见程序A的详细输出),但从openjml不生成它.一般来说,浮点支持似乎是错误的.

程序A(带有整数):

class Test {
    //@ requires b > 1234;
    void a(int b) { }
    void z() { a(2345); }
}
Run Code Online (Sandbox Code Playgroud)

输出(运行-verbose | grep 234,搜索详细输出12342345在详细输出中):

  // 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 THIS NULL) (=> (or (= THIS NULL) (and (and (distinct THIS 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))
Run Code Online (Sandbox Code Playgroud)

结果:

EXECUTION
Proof result is unsat
Method checked OK
[total 427ms]    
Run Code Online (Sandbox Code Playgroud)

计划B(双打):

class Test {
    //@ requires b > 1234.0;
    void a(double b) { }
    void z() { a(2345.0); }
}
Run Code Online (Sandbox Code Playgroud)

输出(运行-verbose | grep 234,搜索详细输出1234.02345.0在详细输出中):

// 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
Run Code Online (Sandbox Code Playgroud)

结果:

EXECUTION
Proof result is sat
Some assertion is not valid
Test.java:4: warning: The prover cannot establish an 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;
            ^
Run Code Online (Sandbox Code Playgroud)