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

Public Member Functions

 model (context &c, Z3_model m)
 
 model (model const &s)
 
 ~model ()
 
 operator Z3_model () const
 
modeloperator= (model const &s)
 
expr eval (expr const &n, bool model_completion=false) const
 
unsigned num_consts () const
 
unsigned num_funcs () const
 
func_decl get_const_decl (unsigned i) const
 
func_decl get_func_decl (unsigned i) const
 
unsigned size () const
 
func_decl operator[] (int i) const
 
expr get_const_interp (func_decl c) const
 
func_interp get_func_interp (func_decl f) const
 
- 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, model const &m)
 

Additional Inherited Members

- Protected Attributes inherited from object
contextm_ctx
 

Detailed Description

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

Constructor & Destructor Documentation

model ( context c,
Z3_model  m 
)
inline

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

1178 :object(c) { init(m); }
object(context &c)
Definition: z3++.h:275
model ( model const &  s)
inline

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

1179 :object(s) { init(s.m_model); }
object(context &c)
Definition: z3++.h:275
~model ( )
inline

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

1180 { Z3_model_dec_ref(ctx(), m_model); }
context & ctx() const
Definition: z3++.h:277
void Z3_API Z3_model_dec_ref(Z3_context c, Z3_model m)
Decrement the reference counter of the given model.

Member Function Documentation

expr eval ( expr const &  n,
bool  model_completion = false 
) const
inline

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

1190  {
1191  check_context(*this, n);
1192  Z3_ast r = 0;
1193  Z3_bool status = Z3_model_eval(ctx(), m_model, n, model_completion, &r);
1194  check_error();
1195  if (status == Z3_FALSE)
1196  throw exception("failed to evaluate expression");
1197  return expr(ctx(), r);
1198  }
int Z3_bool
Z3 Boolean type. It is just an alias for int.
Definition: z3_api.h:110
context & ctx() const
Definition: z3++.h:277
void check_error() const
Definition: z3++.h:278
friend void check_context(object const &a, object const &b)
Definition: z3++.h:281
Z3_bool Z3_API Z3_model_eval(Z3_context c, Z3_model m, Z3_ast t, Z3_bool model_completion, Z3_ast *v)
Evaluate the AST node t in the given model. Return Z3_TRUE if succeeded, and store the result in v...
#define Z3_FALSE
False value. It is just an alias for 0.
Definition: z3_api.h:135
func_decl get_const_decl ( unsigned  i) const
inline

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

1202 { Z3_func_decl r = Z3_model_get_const_decl(ctx(), m_model, i); check_error(); return func_decl(ctx(), r); }
Z3_func_decl Z3_API Z3_model_get_const_decl(Z3_context c, Z3_model m, unsigned i)
Return the i-th constant in the given model.
context & ctx() const
Definition: z3++.h:277
void check_error() const
Definition: z3++.h:278
expr get_const_interp ( func_decl  c) const
inline

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

1210  {
1211  check_context(*this, c);
1212  Z3_ast r = Z3_model_get_const_interp(ctx(), m_model, c);
1213  check_error();
1214  return expr(ctx(), r);
1215  }
context & ctx() const
Definition: z3++.h:277
void check_error() const
Definition: z3++.h:278
Z3_ast Z3_API Z3_model_get_const_interp(Z3_context c, Z3_model m, Z3_func_decl a)
Return the interpretation (i.e., assignment) of constant a in the model m. Return NULL...
friend void check_context(object const &a, object const &b)
Definition: z3++.h:281
func_decl get_func_decl ( unsigned  i) const
inline

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

1203 { Z3_func_decl r = Z3_model_get_func_decl(ctx(), m_model, i); check_error(); return func_decl(ctx(), r); }
Z3_func_decl Z3_API Z3_model_get_func_decl(Z3_context c, Z3_model m, unsigned i)
Return the declaration of the i-th function in the given model.
context & ctx() const
Definition: z3++.h:277
void check_error() const
Definition: z3++.h:278
func_interp get_func_interp ( func_decl  f) const
inline

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

1216  {
1217  check_context(*this, f);
1218  Z3_func_interp r = Z3_model_get_func_interp(ctx(), m_model, f);
1219  check_error();
1220  return func_interp(ctx(), r);
1221  }
context & ctx() const
Definition: z3++.h:277
void check_error() const
Definition: z3++.h:278
Z3_func_interp Z3_API Z3_model_get_func_interp(Z3_context c, Z3_model m, Z3_func_decl f)
Return the interpretation of the function f in the model m. Return NULL, if the model does not assign...
friend void check_context(object const &a, object const &b)
Definition: z3++.h:281
unsigned num_consts ( ) const
inline

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

1200 { return Z3_model_get_num_consts(ctx(), m_model); }
context & ctx() const
Definition: z3++.h:277
unsigned Z3_API Z3_model_get_num_consts(Z3_context c, Z3_model m)
Return the number of constants assigned by the given model.
unsigned num_funcs ( ) const
inline

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

1201 { return Z3_model_get_num_funcs(ctx(), m_model); }
context & ctx() const
Definition: z3++.h:277
unsigned Z3_API Z3_model_get_num_funcs(Z3_context c, Z3_model m)
Return the number of function interpretations in the given model.
operator Z3_model ( ) const
inline

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

1181 { return m_model; }
model& operator= ( model const &  s)
inline

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

1182  {
1183  Z3_model_inc_ref(s.ctx(), s.m_model);
1184  Z3_model_dec_ref(ctx(), m_model);
1185  m_ctx = s.m_ctx;
1186  m_model = s.m_model;
1187  return *this;
1188  }
context & ctx() const
Definition: z3++.h:277
void Z3_API Z3_model_dec_ref(Z3_context c, Z3_model m)
Decrement the reference counter of the given model.
void Z3_API Z3_model_inc_ref(Z3_context c, Z3_model m)
Increment the reference counter of the given model.
context * m_ctx
Definition: z3++.h:273
func_decl operator[] ( int  i) const
inline

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

1205  {
1206  assert(0 <= i);
1207  return static_cast<unsigned>(i) < num_consts() ? get_const_decl(i) : get_func_decl(i - num_consts());
1208  }
func_decl get_const_decl(unsigned i) const
Definition: z3++.h:1202
func_decl get_func_decl(unsigned i) const
Definition: z3++.h:1203
unsigned num_consts() const
Definition: z3++.h:1200
unsigned size ( ) const
inline

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

1204 { return num_consts() + num_funcs(); }
unsigned num_consts() const
Definition: z3++.h:1200
unsigned num_funcs() const
Definition: z3++.h:1201

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
model const &  m 
)
friend

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

1223 { out << Z3_model_to_string(m.ctx(), m); return out; }
Z3_string Z3_API Z3_model_to_string(Z3_context c, Z3_model m)
Convert the given model into a string.