I am playing around with z3 and other SMT solvers and want to examine the cases where other solvers like boolector triumph over z3 and vice-versa. For this purpose, I need a way to convert declarations and assertions to the SMT-LIB2 format that other SMT solvers can recognize.
For example, for this example
void print_as_smtlib2_string() {
context c;
expr x = c.int_const("x");
expr y = c.int_const("y");
solver s(c);
s.add(x >= 1);
s.add(y < x + 3);
std::cout << s.check() << "\n";
Z3_set_ast_print_mode(c, Z3_PRINT_SMTLIB_COMPLIANT);
std::cout << "\nSolver is:\n";
std::cout << s << "\n";
}
I get something like: sat
Solver is: (solver (>= x 1) (< y (+ x 3)))
What I want instead is something like this (rise4fun link: http://rise4fun.com/Z3/aznC8):
(declare-const x Int)
(declare-const y Int)
(assert (>= x 1))
(assert (< y (+ x 3)))
(check-sat)
I have tried C API functions such as Z3_set_ast_print_mode, Z3_ast_to_string but haven't been successful. I looked at Z3_benchmark_to_smtlib_string but this post Input arguments of Z3_benchmark_to_smtlib_string() suggests that it only supports SMTLIB 1.0.