I want to convert an SMT model written in python using z3 library in a file .smt2 to obtain a file which can be run from different solvers (for instance cvc4-solver).
The problem is that my model makes optimization and when there is a conversion from z3 to smt2 file the instruction (maximize x) is not recognized from cvc4 (other SMT solver).
Here there is an example where is possible to understand better the problem:
Model:
o = Optimize()
i = Int('x')
o.add (i > 5)
o.add (i < 10)
o.maximize(i)
to_write= "(set-option :produce-models true)\n(set-info :status unknown)\n(set-logic QF_UFLIA)\n"
to_write += o.sexpr()
with open('/content/file1.smt2', "w") as f:
f.write(to_write)
Now the output of my file is:
(set-option :produce-models true)
(set-info :status unknown)
(set-logic QF_UFLIA)
(declare-fun x () Int)
(assert (> x 5))
(assert (< x 10))
(maximize x)
(check-sat)
If I run in CMD this file smt2, using z3, the solver returns sat, but instead if I use cvc4 the solver gives me this error
(error "Parse Error: /content/file1.smt2:7.9: expected SMT-LIBv2 command, got `maximize'.
(maximize x)
^
")
cvc4 does not recognize the command (maximize x), there is another way to write this instruction for cvc4 solver ? Which are the SMT solvers that recognized the instructions maximize/minimize in an smt2 file?
I am expecting a file smt2 that can be used for each solver able to make optimization.