I had the same problem and it was solved without changing Z3. Here is an example in python. (Based on Leonardo.)
from z3 import BitVec, BitVecSort, Goal, If, Then, Bool, solve import math x = BitVec('x', 16) y = BitVec('y', 16) z = BitVec('z', 16) g = Goal() bitmap = {} for i in range(16): bitmap[(x,i)] = Bool('x'+str(i)) mask = BitVecSort(16).cast(math.pow(2,i)) g.add(bitmap[(x,i)] == ((x & mask) == mask)) g.add(x == y, z > If(x < 0, x, -x)) print g
For each position i of the bitvector x, we introduce a new logical variable xi and require that xi be equal to the ith position of the bitvector. The names of boolean variables are saved during bit blasting.
source share