I was trying to work with z3py. I came across a strange problem. I read that the operation /
is treated as signed division for bit vectors in z3py. I was trying to give the following commands:
a = z3.BitVec('a',2)
b = z3.BitVec('b',2)
solver = z3.Solver()
solver.add((a + b)/2 == 3)
solver.check()
The result z3 gives is unsat
In my views this is not correct because it has a solution a = 2, b = 0
, a = 2
in 2's complement means a = -2
, so (a+b)/2
must be equal to -1
i.e. 3
by signed representation.
Can anyone please help me what is wrong here?