I have a Python function that takes a real number and returns a string, e.g.
def fun(x):
if x == 0.5:
return "Hello"
else:
return "Bye"
I start a z3 solver:
from z3 import *
r = Real('r')
s = Solver()
Now I want to tell the solver find a value of r, such that fun(r) returns "Hello". I am facing the following problems:
- If
r = Real('r'), then I cannot callfun(r), becauseris a z3 variable - I cannot say
s.add(StringVal("Hello") == StringVal(fun(r)))as a constraint, because 1)ris a z3 variable, 2) the interpretation ofris not known yet. Hence, I have no model from which I could extract a value and pass it to thefun.
Is it possible to implement what I want?