I would like to create a Z3 model object such as the one that is returned by (get-model)
/s.model()
with s = Solver()
. I am starting with a list of tuples (name, value)
where name
is a string representing the Z3 variable that is used in the model and value
the value that is assigned to the variable (real or Boolean). So something like
def myZ3Model(tuples):
""" Returns a Z3 model based on the values of the given tuples. """
<magic>
return model
t = [('a', True), ('b', 42), ('c', False)]
myZ3Model(t) --> [a = True, b = 42, c = False]
I already came up with a quite 'hacky' way to do this: Initialize a formula that is the conjunction of all the variables equal to their assigned values and let a solver return a model for this formula. However, I would like to know if there is a more elegant way to achieve my goal...