Is there an UnsignedIntSort in Z3?

前端 未结 2 1347
情深已故
情深已故 2021-01-22 12:31

I am using functions in my solver to model discrete time. The problem is that right now we use functions like z3.Function(\'f\', IntSort(), IntSort()) and negative

相关标签:
2条回答
  • 2021-01-22 12:49

    There is no unsigned sort in SMT or Z3, because bit-vectors can trivially be used for this purpose. Bit-vectors hemselves are neither unsigned nor signed, but they are strings of bits. Signed and unsigned semantics are then implemented in separate functions, i.e., there is no generic less-than operator for bit-vectors, but there are bvult and bvslt for unsigned and signed less-than. Thus, as long as you stick to the unsigned flavours of all BV functions, you will always preserve unsigned semantics.

    Also, in models, bit-vectors are usually provided as bit-strings (in binary or hex), i.e., there are no negative values. Insofar, in your application, you can always assume all bit-vectors are unsigned until you start using the *s* functions.

    0 讨论(0)
  • 2021-01-22 13:06

    As pointed out in the comments, there's no such sort; and your best bet is to make sure you have t >= 0 assertions for all uses.

    Note that this is actually trickier in practice. Not only you need to make this assertion for all your "fresh" variables, but also whenever you do any arithmetic with such variables to ensure the results remain within the domain. That is, if you ever compute t-1, then you'll want t >= 1 as an assertion appearing, assuming the result of that expression is used as a time value itself.

    This can get really tedious really quick, so having a mechanism ("overloaded arithmetic") can simplify life. But of course, that depends on exactly how you are programming your constraints, whether you're using SMT-Lib, or one of the APIs via a higher-level language.

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