Z3
Public Member Functions | Friends
solver Class Reference
+ Inheritance diagram for solver:

Public Member Functions

 solver (context &c)
 
 solver (context &c, Z3_solver s)
 
 solver (context &c, char const *logic)
 
 solver (solver const &s)
 
 ~solver ()
 
 operator Z3_solver () const
 
solveroperator= (solver const &s)
 
void set (params const &p)
 
void push ()
 
void pop (unsigned n=1)
 
void reset ()
 
void add (expr const &e)
 
void add (expr const &e, expr const &p)
 
void add (expr const &e, char const *p)
 
check_result check ()
 
check_result check (unsigned n, expr *const assumptions)
 
check_result check (expr_vector assumptions)
 
model get_model () const
 
std::string reason_unknown () const
 
stats statistics () const
 
expr_vector unsat_core () const
 
expr_vector assertions () const
 
expr proof () const
 
std::string to_smt2 (char const *status="unknown")
 
- Public Member Functions inherited from object
 object (context &c)
 
 object (object const &s)
 
contextctx () const
 
void check_error () const
 

Friends

std::ostream & operator<< (std::ostream &out, solver const &s)
 

Additional Inherited Members

- Protected Attributes inherited from object
contextm_ctx
 

Detailed Description

Definition at line 1258 of file z3++.h.

Constructor & Destructor Documentation

solver ( context c)
inline

Definition at line 1265 of file z3++.h.

1265 :object(c) { init(Z3_mk_solver(c)); }
object(context &c)
Definition: z3++.h:270
Z3_solver Z3_API Z3_mk_solver(__in Z3_context c)
Create a new (incremental) solver. This solver also uses a set of builtin tactics for handling the fi...
solver ( context c,
Z3_solver  s 
)
inline

Definition at line 1266 of file z3++.h.

1266 :object(c) { init(s); }
object(context &c)
Definition: z3++.h:270
solver ( context c,
char const *  logic 
)
inline

Definition at line 1267 of file z3++.h.

1267 :object(c) { init(Z3_mk_solver_for_logic(c, c.str_symbol(logic))); }
Z3_solver Z3_API Z3_mk_solver_for_logic(__in Z3_context c, __in Z3_symbol logic)
Create a new solver customized for the given logic. It behaves like Z3_mk_solver if the logic is unkn...
object(context &c)
Definition: z3++.h:270
solver ( solver const &  s)
inline

Definition at line 1268 of file z3++.h.

1268 :object(s) { init(s.m_solver); }
object(context &c)
Definition: z3++.h:270
~solver ( )
inline

Definition at line 1269 of file z3++.h.

1269 { Z3_solver_dec_ref(ctx(), m_solver); }
void Z3_API Z3_solver_dec_ref(__in Z3_context c, __in Z3_solver s)
Decrement the reference counter of the given solver.
context & ctx() const
Definition: z3++.h:272

Member Function Documentation

void add ( expr const &  e)
inline

Definition at line 1282 of file z3++.h.

Referenced by solver::add().

1282 { assert(e.is_bool()); Z3_solver_assert(ctx(), m_solver, e); check_error(); }
void Z3_API Z3_solver_assert(__in Z3_context c, __in Z3_solver s, __in Z3_ast a)
Assert a constraint into the solver.
context & ctx() const
Definition: z3++.h:272
void check_error() const
Definition: z3++.h:273
void add ( expr const &  e,
expr const &  p 
)
inline

Definition at line 1283 of file z3++.h.

1283  {
1284  assert(e.is_bool()); assert(p.is_bool()); assert(p.is_const());
1285  Z3_solver_assert_and_track(ctx(), m_solver, e, p);
1286  check_error();
1287  }
void Z3_API Z3_solver_assert_and_track(__in Z3_context c, __in Z3_solver s, __in Z3_ast a, __in Z3_ast p)
Assert a constraint a into the solver, and track it (in the unsat) core using the Boolean constant p...
context & ctx() const
Definition: z3++.h:272
void check_error() const
Definition: z3++.h:273
void add ( expr const &  e,
char const *  p 
)
inline

Definition at line 1288 of file z3++.h.

1288  {
1289  add(e, ctx().bool_const(p));
1290  }
context & ctx() const
Definition: z3++.h:272
void add(expr const &e)
Definition: z3++.h:1282
expr_vector assertions ( ) const
inline

Definition at line 1317 of file z3++.h.

Referenced by solver::to_smt2(), and Solver::to_smt2().

1317 { Z3_ast_vector r = Z3_solver_get_assertions(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
context & ctx() const
Definition: z3++.h:272
void check_error() const
Definition: z3++.h:273
Z3_ast_vector Z3_API Z3_solver_get_assertions(__in Z3_context c, __in Z3_solver s)
Return the set of asserted formulas as a goal object.
ast_vector_tpl< expr > expr_vector
Definition: z3++.h:68
check_result check ( )
inline

Definition at line 1291 of file z3++.h.

1291 { Z3_lbool r = Z3_solver_check(ctx(), m_solver); check_error(); return to_check_result(r); }
Z3_lbool Z3_API Z3_solver_check(__in Z3_context c, __in Z3_solver s)
Check whether the assertions in a given solver are consistent or not.
context & ctx() const
Definition: z3++.h:272
Z3_lbool
Lifted Boolean type: false, undefined, true.
Definition: z3_api.h:135
void check_error() const
Definition: z3++.h:273
check_result to_check_result(Z3_lbool l)
Definition: z3++.h:1252
check_result check ( unsigned  n,
expr *const  assumptions 
)
inline

Definition at line 1292 of file z3++.h.

1292  {
1293  array<Z3_ast> _assumptions(n);
1294  for (unsigned i = 0; i < n; i++) {
1295  check_context(*this, assumptions[i]);
1296  _assumptions[i] = assumptions[i];
1297  }
1298  Z3_lbool r = Z3_solver_check_assumptions(ctx(), m_solver, n, _assumptions.ptr());
1299  check_error();
1300  return to_check_result(r);
1301  }
context & ctx() const
Definition: z3++.h:272
Z3_lbool
Lifted Boolean type: false, undefined, true.
Definition: z3_api.h:135
void check_error() const
Definition: z3++.h:273
friend void check_context(object const &a, object const &b)
Definition: z3++.h:276
check_result to_check_result(Z3_lbool l)
Definition: z3++.h:1252
Z3_lbool Z3_API Z3_solver_check_assumptions(__in Z3_context c, __in Z3_solver s, __in unsigned num_assumptions, __in_ecount(num_assumptions) Z3_ast const assumptions[])
Check whether the assertions in the given solver and optional assumptions are consistent or not...
check_result check ( expr_vector  assumptions)
inline

Definition at line 1302 of file z3++.h.

1302  {
1303  unsigned n = assumptions.size();
1304  array<Z3_ast> _assumptions(n);
1305  for (unsigned i = 0; i < n; i++) {
1306  check_context(*this, assumptions[i]);
1307  _assumptions[i] = assumptions[i];
1308  }
1309  Z3_lbool r = Z3_solver_check_assumptions(ctx(), m_solver, n, _assumptions.ptr());
1310  check_error();
1311  return to_check_result(r);
1312  }
context & ctx() const
Definition: z3++.h:272
Z3_lbool
Lifted Boolean type: false, undefined, true.
Definition: z3_api.h:135
void check_error() const
Definition: z3++.h:273
friend void check_context(object const &a, object const &b)
Definition: z3++.h:276
check_result to_check_result(Z3_lbool l)
Definition: z3++.h:1252
Z3_lbool Z3_API Z3_solver_check_assumptions(__in Z3_context c, __in Z3_solver s, __in unsigned num_assumptions, __in_ecount(num_assumptions) Z3_ast const assumptions[])
Check whether the assertions in the given solver and optional assumptions are consistent or not...
model get_model ( ) const
inline

Definition at line 1313 of file z3++.h.

1313 { Z3_model m = Z3_solver_get_model(ctx(), m_solver); check_error(); return model(ctx(), m); }
Z3_model Z3_API Z3_solver_get_model(__in Z3_context c, __in Z3_solver s)
Retrieve the model for the last Z3_solver_check or Z3_solver_check_assumptions.
context & ctx() const
Definition: z3++.h:272
void check_error() const
Definition: z3++.h:273
operator Z3_solver ( ) const
inline

Definition at line 1270 of file z3++.h.

1270 { return m_solver; }
solver& operator= ( solver const &  s)
inline

Definition at line 1271 of file z3++.h.

1271  {
1272  Z3_solver_inc_ref(s.ctx(), s.m_solver);
1273  Z3_solver_dec_ref(ctx(), m_solver);
1274  m_ctx = s.m_ctx;
1275  m_solver = s.m_solver;
1276  return *this;
1277  }
void Z3_API Z3_solver_dec_ref(__in Z3_context c, __in Z3_solver s)
Decrement the reference counter of the given solver.
void Z3_API Z3_solver_inc_ref(__in Z3_context c, __in Z3_solver s)
Increment the reference counter of the given solver.
context & ctx() const
Definition: z3++.h:272
context * m_ctx
Definition: z3++.h:268
void pop ( unsigned  n = 1)
inline

Definition at line 1280 of file z3++.h.

1280 { Z3_solver_pop(ctx(), m_solver, n); check_error(); }
context & ctx() const
Definition: z3++.h:272
void check_error() const
Definition: z3++.h:273
void Z3_API Z3_solver_pop(__in Z3_context c, __in Z3_solver s, unsigned n)
Backtrack n backtracking points.
expr proof ( ) const
inline

Definition at line 1318 of file z3++.h.

1318 { Z3_ast r = Z3_solver_get_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); }
context & ctx() const
Definition: z3++.h:272
void check_error() const
Definition: z3++.h:273
Z3_ast Z3_API Z3_solver_get_proof(__in Z3_context c, __in Z3_solver s)
Retrieve the proof for the last Z3_solver_check or Z3_solver_check_assumptions.
void push ( )
inline

Definition at line 1279 of file z3++.h.

1279 { Z3_solver_push(ctx(), m_solver); check_error(); }
context & ctx() const
Definition: z3++.h:272
void Z3_API Z3_solver_push(__in Z3_context c, __in Z3_solver s)
Create a backtracking point.
void check_error() const
Definition: z3++.h:273
std::string reason_unknown ( ) const
inline

Definition at line 1314 of file z3++.h.

1314 { Z3_string r = Z3_solver_get_reason_unknown(ctx(), m_solver); check_error(); return r; }
context & ctx() const
Definition: z3++.h:272
void check_error() const
Definition: z3++.h:273
Z3_string Z3_API Z3_solver_get_reason_unknown(__in Z3_context c, __in Z3_solver s)
Return a brief justification for an "unknown" result (i.e., Z3_L_UNDEF) for the commands Z3_solver_ch...
const char * Z3_string
Z3 string type. It is just an alias for const char *.
Definition: z3_api.h:111
void reset ( )
inline

Definition at line 1281 of file z3++.h.

1281 { Z3_solver_reset(ctx(), m_solver); check_error(); }
context & ctx() const
Definition: z3++.h:272
void check_error() const
Definition: z3++.h:273
void Z3_API Z3_solver_reset(__in Z3_context c, __in Z3_solver s)
Remove all assertions from the solver.
void set ( params const &  p)
inline

Definition at line 1278 of file z3++.h.

1278 { Z3_solver_set_params(ctx(), m_solver, p); check_error(); }
context & ctx() const
Definition: z3++.h:272
void check_error() const
Definition: z3++.h:273
void Z3_API Z3_solver_set_params(__in Z3_context c, __in Z3_solver s, __in Z3_params p)
Set the given solver using the given parameters.
stats statistics ( ) const
inline

Definition at line 1315 of file z3++.h.

1315 { Z3_stats r = Z3_solver_get_statistics(ctx(), m_solver); check_error(); return stats(ctx(), r); }
context & ctx() const
Definition: z3++.h:272
void check_error() const
Definition: z3++.h:273
Z3_stats Z3_API Z3_solver_get_statistics(__in Z3_context c, __in Z3_solver s)
Return statistics for the given solver.
std::string to_smt2 ( char const *  status = "unknown")
inline

Definition at line 1321 of file z3++.h.

1321  {
1322  array<Z3_ast> es(assertions());
1323  Z3_ast const* fmls = es.ptr();
1324  Z3_ast fml = 0;
1325  unsigned sz = es.size();
1326  if (sz > 0) {
1327  --sz;
1328  fml = fmls[sz];
1329  }
1330  else {
1331  fml = ctx().bool_val(true);
1332  }
1333  return std::string(Z3_benchmark_to_smtlib_string(
1334  ctx(),
1335  "", "", status, "",
1336  sz,
1337  fmls,
1338  fml));
1339  }
context & ctx() const
Definition: z3++.h:272
Z3_string Z3_API Z3_benchmark_to_smtlib_string(__in Z3_context c, __in Z3_string name, __in Z3_string logic, __in Z3_string status, __in Z3_string attributes, __in unsigned num_assumptions, __in_ecount(num_assumptions) Z3_ast const assumptions[], __in Z3_ast formula)
Convert the given benchmark into SMT-LIB formatted string.
expr_vector assertions() const
Definition: z3++.h:1317
expr bool_val(bool b)
Definition: z3++.h:1659
expr_vector unsat_core ( ) const
inline

Definition at line 1316 of file z3++.h.

1316 { Z3_ast_vector r = Z3_solver_get_unsat_core(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
Z3_ast_vector Z3_API Z3_solver_get_unsat_core(__in Z3_context c, __in Z3_solver s)
Retrieve the unsat core for the last Z3_solver_check_assumptions The unsat core is a subset of the as...
context & ctx() const
Definition: z3++.h:272
void check_error() const
Definition: z3++.h:273
ast_vector_tpl< expr > expr_vector
Definition: z3++.h:68

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
solver const &  s 
)
friend

Definition at line 1319 of file z3++.h.

1319 { out << Z3_solver_to_string(s.ctx(), s); return out; }
Z3_string Z3_API Z3_solver_to_string(__in Z3_context c, __in Z3_solver s)
Convert a solver into a string.