Z3: an exception with int2bv

2019-02-28 16:07发布

(declare-const a Int)
(declare-const b Int)
(declare-const c (_ BitVec 32))
(declare-const d (_ BitVec 32))

(assert (= b (bv2int c)))
(assert (= c (int2bv a)))

(check-sat)

I am confused about the exception "int2bv expects one parameter" caused by the code above, how to use function int2bv correctly?

标签: z3
1条回答
Evening l夕情丶
2楼-- · 2019-02-28 16:46

This is because int2bv is a parametric function and the SMT2 syntax for these is (_ f p1 p2 ...), so in this case the correct syntax is

((_ int2bv 32) a)

Note that int2bv is essentially treated as uninterpreted; the API documentation says:

"NB. This function is essentially treated as uninterpreted. So you cannot expect Z3 to precisely reflect the semantics of this function when solving constraints with this function." (from here)

查看更多
登录 后发表回答