简体   繁体   English

将值赋给位向量(SMTLIB2,Z3)?

[英]Assign value to a bitvector (SMTLIB2, Z3)?

I am using Z3 version 3.0. 我使用的是Z3 3.0版。 I want to assign a value to a bitvector variable, like below. 我想为bitvector变量赋值,如下所示。 But Z3 reports error "invalid function application, sort mismatch on argument at position 2 in line 3". 但Z3报告错误“无效的功能应用程序,排序第3行位置2的参数不匹配”。

It seems wrong with my constant #x0a? 我的常数#x0a似乎有问题? how can i fix this? 我怎样才能解决这个问题?

Thanks 谢谢

(set-logic QF_BV)
(declare-fun a () (_ BitVec 32))
(assert (= a #x0a))
(check-sat)

In the SMT-LIB 2.0 standard, #x0a is a bitvector of size 8. You get the sort mismatch error because the constant a is a bitvector of size 32. You can avoid the type/sort error message by rewriting your example as: 在SMT-LIB 2.0标准中, #x0a是大小为8的位向量。由于常量a是大小为32的位向量,因此会出现排序不匹配错误。您可以通过将示例重写为以下内容来避免类型/排序错误消息:

(set-logic QF_BV)
(declare-fun a () (_ BitVec 32))
(assert (= a #x0000000a))
(check-sat)

SMT-LIB also supports bitvector literals of the form (_ bv[num] [size]) , where [num] is in decimal notation, and [size] is the size of the bitvector. SMT-LIB还支持格式的位向量文字(_ bv[num] [size]) ,其中[num]是十进制表示法, [size]是位向量的大小。 Thus, you can also write the bitvector literal #x0000000a as (_ bv10 32) . 因此,您也可以将bitvector文字#x0000000a写为(_ bv10 32)

BTW, SMT-LIB also supports bitvector literals in binary notation. 顺便说一句,SMT-LIB也支持二进制表示法中的bitvector文字。 For example, #b010 is a bitvector of size 3. 例如, #b010是大小为3的位向量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM