Generic bitvector type of any length

丶灬走出姿态 提交于 2020-01-04 08:12:46

问题


For the same reasons than described here (user defined uninterpreted function) I want to define my own uninterpreted function

bvredxnor() : xnor over the bits of a given bitvector.

If I follow the example given here (example of universal quantifiers with C API) I don't know what sort to provide to the argument of my function (a bitvector)

I could create a bitvector sort of a given length, but I would like to have it for bitvectors of any length.

Looking at bitvector functions available in the C API, I noticed that the type of all arguments is Z3_ast, so I was thinking I could use the same generic type. But there is no function in the API that generate a Z3_ast sort... (writing this I feel i am touching the difference between types and sorts, but it is still a bit unclear)

Is the solution to use uninterpreted sorts? And if so, in doing that, wouldn't I loose some precision in my model by enlarging the type too much, while this artefact is only for debugging purpose? I mean, if I apply this function to a bitvector, will this work?

Thank you in advance,

AG.


回答1:


SMTLib does not allow bit-vectors with variable lengths. That is, you cannot express problems that are parameterized over the bitvector lengths. The reason for this is that properties about bit-vectors do not necessarily hold parametrically over lengths, due to cardinality issues. To wit, consider:

exists x0, x1, x2, x3, x4. distinct [x0, x1, x2, x3, x4]

This property says there are at least 5 distinct bit-vector values. That is true if the domain of x has length at least 3, but not otherwise. So, the validity of the statement depends on the domain. You can also view this as a limitation of the first-order nature of SMTLib in general.

Of course, the above applies to SMTLib, and not necessarily to Z3. Leo and co have always been ahead of the curve, and Z3 does have many tricks that go beyond what SMTLib calls for. It'd be a pleasant surprise if Z3 does support some notion of parametric bit-vector problems in the way you are describing.



来源:https://stackoverflow.com/questions/10329721/generic-bitvector-type-of-any-length

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