Z3 converting “small” BitVectors to Ints

Deadly 提交于 2019-12-11 00:26:43

问题


I know that both bv2int and int2bv are handled as uninterpreted functions in Z3. Still, I am looking for a best practice in solving the following problem: given a "small" (< 10 bits) bitvector index, how to efficiently cast it to Int, and use in queries like this one:

(declare-const s String)
(declare-const someInt                Int)
(declare-const someBitVec10 (_ BitVec 10))

(assert (= s "74g\x00!!#2#$$"))

;(assert (str.in.re (str.at s someBitVec10) (re.range "a" "z")))
( assert (str.in.re (str.at s someInt     ) (re.range "1" "3")))

(check-sat)
(get-value (s someInt))

Output:

sat
((s "74g\x00!!#2#$$")
 (someInt 7))

Thanks!

来源:https://stackoverflow.com/questions/47000109/z3-converting-small-bitvectors-to-ints

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!