I want to create an expr
object from a given SMTLIB2 file. I can see a Z3_parse_smtlib_string
function in the C examples. Is there a wrapper for that in the expr
class?
Asked
Active
Viewed 575 times
4

Christoph Wintersteiger
- 8,234
- 1
- 16
- 30

Garvit Juniwal
- 195
- 1
- 6
1 Answers
3
The Z3 C++ API does not explicitly provide this functionality as part of the expr class. However, the C++ API can be used alongside the C API, i.e., the function Z3_parse_smtlib_string
(or ..._file
) can be used to achieve this. Note that this function returns a Z3_ast
, which must be converted to an expr
object to get back to the C++ "world".
A simple example:
#include <z3++.h>
...
context ctx;
Z3_ast a = Z3_parse_smtlib2_file(ctx, "test.smt2", 0, 0, 0, 0, 0, 0);
expr e(ctx, a);
std::cout << "Result = " << e << std::endl;
Since the Z3_parse_smtlib2_*
functions do not perform error checking, no exception will be thrown upon errors. This can be achieved by calls to context::check_error()
.

Christoph Wintersteiger
- 8,234
- 1
- 16
- 30
-
Related question: http://stackoverflow.com/questions/24523407/z3-parse-smtlib-string-usage-issues – d'alar'cop Jul 02 '14 at 05:22