Z3 Python 将两个位向量相乘

Z3 Python multiply two bitvectors

我正在尝试使用 Python + Z3 位向量进行一些计算,但我在 multiply 操作中遇到了一些问题。

例如:

a = BitVecVal(3, 2)
b = BitVecVal(3, 2)
c = a * b
print c.size()   <----- output is 2; but can I have a vector of length 2 + 2 = 4??

print simplify(c)  <---- of course, the output is 1, not 9

上面的例子应该很清楚了。如果有人能教我 如何在不削减某些最高位的情况下对位向量进行乘法运算,我将不胜感激。

谢谢!

尝试在相乘前扩展位向量的长度:

  from z3 import *

  a = BitVecVal(3, 2)
  b = BitVecVal(3, 2)
  c = ZeroExt(2, a) * ZeroExt(2, b)
  print c.size()

  print simplify(c)