The Concat() function in the z3 python interface allows you to concatenate arbitrary bit vectors. Our application is using the C++ interface, though. Is there an easy way to get the same effect with the C++ interface? I'm trying to build up an output bitvector expression out of sub-expressions. I can do it with shift and or operations, but I'd like something simpler if it exists.
For example, one of the things I want to do is create a 4-bit bitvector representing the odd bits of an input 8-bit bitvector expression. The following works:
expr getOddBits8to4(context &c, expr &in) {
expr result = ite(in.extract(1, 1) == c.bv_val(1, 1), c.bv_val(1, 4), c.bv_val(0, 4)) |
ite(in.extract(3, 3) == c.bv_val(1, 1), c.bv_val(2, 4), c.bv_val(0, 4)) |
ite(in.extract(5, 5) == c.bv_val(1, 1), c.bv_val(4, 4), c.bv_val(0, 4)) |
ite(in.extract(7, 7) == c.bv_val(1, 1), c.bv_val(8, 4), c.bv_val(0, 4));
return result;
}
but I would rather be able to write something like:
expr result = Concat(in.extract(1,1), in.extract(3,3), in.extract(5,5), in.extract(7,7));
As far as I can tell, this is only available in the Python interface. Is there a way to create something similar from the C++ interface, or even just to simplify the above expression?