mixing reals and bit-vectors

后端 未结 1 1385
挽巷
挽巷 2021-01-06 09:04

I\'ve two SMT2-Lib scripts using reals, which are morally equivalent. The only difference is that one also uses bit-vectors while the other does not.

Here\'s the ve

1条回答
  •  抹茶落季
    2021-01-06 09:51

    The new nonlinear solver is not integrated with other theories yet. It supports only real variables and Booleans. Actually, it also allows integer variables, but it is very limited support for them. It actually solves nonlinear integer problems as real problems, and just checks in the end whether each integer variable is assigned to an integer value. Moreover, this solver is the only complete procedure for nonlinear (real) arithmetic available in Z3.

    Since your first problem contains Bit-vectors, the nonlinear solver is not used by Z3. Instead, Z3 uses a general purpose solver that combines many theories, but it is incomplete for nonlinear arithmetic.

    That being said, I understand this is a limitation, and I'm working on that. In the (not so near) future, Z3 will have a new solver that integrates nonlinear arithmetic, arrays, bit-vectors, etc.

    Finally, the bit-vector theory is a very special case, since we can easily reduce it to propositional logic in Z3. Z3 has tactic bit-blast that applies this reduction. This tactic can reduce any nonlinear+bit-vector problem into a problem that contains only reals and Booleans. Here is an example (http://rise4fun.com/Z3/0xl).

    ; uses both reals and bit-vectors
    (set-option :produce-models true)
    (define-fun s2 () Real (root-obj (+ (^ x 2) (- 2)) 2))
    (define-fun s3 () Real 0.0)
    (define-fun s6 () Real (/ 1.0 1.0))
    (declare-fun s0 () (_ BitVec 1))
    (declare-fun s1 () (_ BitVec 1))
    (declare-fun v2 () (_ BitVec 8))
    (assert
       (let ((s4 (- s3 s2)))
       (let ((s5 (ite (= #b1 s1) s2 s4)))
       (let ((s7 (+ s5 s6)))
       (let ((s8 (- s5 s6)))
       (let ((s9 (ite (= #b1 s0) s7 s8)))
       (let ((s10 (ite (>= s9 s3) #b1 #b0)))
       (= s10 #b1))))))))
    
    (assert (or (and (not (= v2 #x00)) (not (= v2 #x01))) (bvslt v2 #x00)))
    (assert (distinct (bvnot v2) #x00))
    (check-sat-using (then simplify bit-blast qfnra))
    (get-model)
    

    0 讨论(0)
提交回复
热议问题