0

I am trying to solve constraints using Z3 SMT solver in python. The constraints involve both integers and bit vectors. I am converting the BitVec to Int using Z3_mk_bv2int. I believe the following constraints are unsatisfiable but I get SAT from Z3 solver. I am not sure if I am converting it correctly or not. However if I replace the BitVecs variables with constrained integer variables then conversion is not required and I get expected results.

Example:

def get_int(var):

ctx = var.ctx

    return ArithRef(Z3_mk_bv2int(ctx.ref(), var.as_ast(), 0), ctx)

def main():

    var1 = BitVec('var1', 6)
    var2 = Int('var2')
    solve(var2 == get_int(var1)- var2, var2 > 32)

if __name__ == "__main__": main()

Results: [var1 = 0, var2 = 33]

I am new to SMT solvers. Please help me figure out the mistake or an alternative solution.

senshin
  • 10,022
  • 7
  • 46
  • 59
User1219
  • 1
  • 1

1 Answers1

1

Please have a look at this issue: https://z3.codeplex.com/workitem/187

Essentially, the issue is that Z3_mk_bv2int is not imported by default. Try adding
from z3 import *

at the beginning of the program.

Tushar
  • 357
  • 1
  • 14