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

Data Structures

struct  translate
 

Public Member Functions

 model (context &c)
 
 model (context &c, Z3_model m)
 
 model (model const &s)
 
 model (model &src, context &dst, translate)
 
 ~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
 
bool has_interp (func_decl f) const
 
func_interp add_func_interp (func_decl &f, expr &else_val)
 
void add_const_interp (func_decl &f, expr &value)
 
- Public Member Functions inherited from object
 object (context &c)
 
 object (object const &s)
 
contextctx () const
 
Z3_error_code 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 2178 of file z3++.h.

Constructor & Destructor Documentation

model ( context c)
inline

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

2186 :object(c) { init(Z3_mk_model(c)); }
Z3_model Z3_API Z3_mk_model(Z3_context c)
Create a fresh model object. It has reference count 0.
object(context &c)
Definition: z3++.h:404
model ( context c,
Z3_model  m 
)
inline

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

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

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

2188 :object(s) { init(s.m_model); }
object(context &c)
Definition: z3++.h:404
model ( model src,
context dst,
translate   
)
inline

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

2189 : object(dst) { init(Z3_model_translate(src.ctx(), src, dst)); }
object(context &c)
Definition: z3++.h:404
Z3_model Z3_API Z3_model_translate(Z3_context c, Z3_model m, Z3_context dst)
translate model from context c to context dst.
~model ( )
inline

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

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

Member Function Documentation

void add_const_interp ( func_decl f,
expr value 
)
inline

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

2249  {
2250  Z3_add_const_interp(ctx(), m_model, f, value);
2251  check_error();
2252  }
void Z3_API Z3_add_const_interp(Z3_context c, Z3_model m, Z3_func_decl f, Z3_ast a)
Add a constant interpretation.
Z3_error_code check_error() const
Definition: z3++.h:407
context & ctx() const
Definition: z3++.h:406
func_interp add_func_interp ( func_decl f,
expr else_val 
)
inline

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

2243  {
2244  Z3_func_interp r = Z3_add_func_interp(ctx(), m_model, f, else_val);
2245  check_error();
2246  return func_interp(ctx(), r);
2247  }
Z3_error_code check_error() const
Definition: z3++.h:407
Z3_func_interp Z3_API Z3_add_func_interp(Z3_context c, Z3_model m, Z3_func_decl f, Z3_ast default_value)
Create a fresh func_interp object, add it to a model for a specified function. It has reference count...
context & ctx() const
Definition: z3++.h:406
expr eval ( expr const &  n,
bool  model_completion = false 
) const
inline

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

2200  {
2201  check_context(*this, n);
2202  Z3_ast r = 0;
2203  bool status = Z3_model_eval(ctx(), m_model, n, model_completion, &r);
2204  check_error();
2205  if (status == false && ctx().enable_exceptions())
2206  Z3_THROW(exception("failed to evaluate expression"));
2207  return expr(ctx(), r);
2208  }
#define Z3_THROW(x)
Definition: z3++.h:96
Z3_error_code check_error() const
Definition: z3++.h:407
Z3_bool Z3_API Z3_model_eval(Z3_context c, Z3_model m, Z3_ast t, bool model_completion, Z3_ast *v)
Evaluate the AST node t in the given model. Return true if succeeded, and store the result in v...
context & ctx() const
Definition: z3++.h:406
friend void check_context(object const &a, object const &b)
Definition: z3++.h:410
func_decl get_const_decl ( unsigned  i) const
inline

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

Referenced by model::operator[]().

2212 { 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.
Z3_error_code check_error() const
Definition: z3++.h:407
context & ctx() const
Definition: z3++.h:406
expr get_const_interp ( func_decl  c) const
inline

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

2223  {
2224  check_context(*this, c);
2225  Z3_ast r = Z3_model_get_const_interp(ctx(), m_model, c);
2226  check_error();
2227  return expr(ctx(), r);
2228  }
Z3_error_code check_error() const
Definition: z3++.h:407
context & ctx() const
Definition: z3++.h:406
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:410
func_decl get_func_decl ( unsigned  i) const
inline

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

Referenced by model::operator[]().

2213 { 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.
Z3_error_code check_error() const
Definition: z3++.h:407
context & ctx() const
Definition: z3++.h:406
func_interp get_func_interp ( func_decl  f) const
inline

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

2229  {
2230  check_context(*this, f);
2231  Z3_func_interp r = Z3_model_get_func_interp(ctx(), m_model, f);
2232  check_error();
2233  return func_interp(ctx(), r);
2234  }
Z3_error_code check_error() const
Definition: z3++.h:407
context & ctx() const
Definition: z3++.h:406
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:410
bool has_interp ( func_decl  f) const
inline

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

2238  {
2239  check_context(*this, f);
2240  return Z3_model_has_interp(ctx(), m_model, f);
2241  }
context & ctx() const
Definition: z3++.h:406
friend void check_context(object const &a, object const &b)
Definition: z3++.h:410
bool Z3_API Z3_model_has_interp(Z3_context c, Z3_model m, Z3_func_decl a)
Test if there exists an interpretation (i.e., assignment) for a in the model m.
unsigned num_consts ( ) const
inline

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

Referenced by model::operator[](), and model::size().

2210 { return Z3_model_get_num_consts(ctx(), m_model); }
context & ctx() const
Definition: z3++.h:406
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 2211 of file z3++.h.

Referenced by model::size().

2211 { return Z3_model_get_num_funcs(ctx(), m_model); }
context & ctx() const
Definition: z3++.h:406
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 2191 of file z3++.h.

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

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

2192  {
2193  Z3_model_inc_ref(s.ctx(), s.m_model);
2194  Z3_model_dec_ref(ctx(), m_model);
2195  m_ctx = s.m_ctx;
2196  m_model = s.m_model;
2197  return *this;
2198  }
context & ctx() const
Definition: z3++.h:406
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:402
func_decl operator[] ( int  i) const
inline

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

2215  {
2216  assert(0 <= i);
2217  return static_cast<unsigned>(i) < num_consts() ? get_const_decl(i) : get_func_decl(i - num_consts());
2218  }
func_decl get_const_decl(unsigned i) const
Definition: z3++.h:2212
func_decl get_func_decl(unsigned i) const
Definition: z3++.h:2213
unsigned num_consts() const
Definition: z3++.h:2210
unsigned size ( ) const
inline

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

2214 { return num_consts() + num_funcs(); }
unsigned num_consts() const
Definition: z3++.h:2210
unsigned num_funcs() const
Definition: z3++.h:2211

Friends And Related Function Documentation

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

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

2256 { 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.