z3py - Check overflow with Z3 -
i'm new z3 , checking online python tutorial.
then thought check overflow behavior in bitvecs.
i wrote code:
x = bitvec('x', 3) y = int('y') solve(bv2int(x) == y, not(bv2int(x + 1) == (y + 1)))
and expecting [y = 7, x = 7] (i.e. when values equal successors not because x + 1 0 , y + 1 8)
but z3 answers [y = 0, x = 0].
what doing wrong?
i don't think you're doing wrong, looks bv2int
buggy:
x = bitvec('x', 3) prove(x <= 3) prove(bv2int(x) <= 3)
z3py proves first one, gives counter-example x=0
second. doesn't sound right. (the explanation might weird python thing, don't see how.)
also note model depend on whether +
treats bit-vector signed number in python bindings, believe case. however, bv2int
might not so, treating unsigned value. further complicate matters.
in case, looks bv2int
not quite kosher; i'd stay away until there's official answer z3 folks.
Comments
Post a Comment