How can I write the equivalent of this code using the Z3 python API ?
(define-fun mymax ((a Int) (b Int)) Int
(ite (> a b) a b))
(assert (= (mymax 100 7) 100))
(check-sat)
(get-model)
Unfortunately, the Function
method is the Python equivalent to declare_fun
, not define_fun
: it does not accept an argument containing the function definition. It would be nice if we could write something like:
mymax = Function('mymax', IntSort(), IntSort(), IntSort(),
Lambda([a,b], If(a>b, a, b))
(I could declare mymax
and add an appropriate constraint for it, but, when the function is large and complex, z3 must search for its definition, which does not seem very efficient. I'd rather give z3 the definition)