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)
 
std::string to_string () const
 
- Public Member Functions inherited from object
 object (context &c)
 
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 2499 of file z3++.h.

Constructor & Destructor Documentation

model ( context c)
inline

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

2507 :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:427
model ( context c,
Z3_model  m 
)
inline

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

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

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

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

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

2510 : object(dst) { init(Z3_model_translate(src.ctx(), src, dst)); }
object(context &c)
Definition: z3++.h:427
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 2511 of file z3++.h.

2511 { Z3_model_dec_ref(ctx(), m_model); }
context & ctx() const
Definition: z3++.h:428
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 2570 of file z3++.h.

2570  {
2571  Z3_add_const_interp(ctx(), m_model, f, value);
2572  check_error();
2573  }
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:429
context & ctx() const
Definition: z3++.h:428
func_interp add_func_interp ( func_decl f,
expr else_val 
)
inline

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

2564  {
2565  Z3_func_interp r = Z3_add_func_interp(ctx(), m_model, f, else_val);
2566  check_error();
2567  return func_interp(ctx(), r);
2568  }
Z3_error_code check_error() const
Definition: z3++.h:429
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:428
expr eval ( expr const &  n,
bool  model_completion = false 
) const
inline

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

2521  {
2522  check_context(*this, n);
2523  Z3_ast r = 0;
2524  bool status = Z3_model_eval(ctx(), m_model, n, model_completion, &r);
2525  check_error();
2526  if (status == false && ctx().enable_exceptions())
2527  Z3_THROW(exception("failed to evaluate expression"));
2528  return expr(ctx(), r);
2529  }
#define Z3_THROW(x)
Definition: z3++.h:100
Z3_error_code check_error() const
Definition: z3++.h:429
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:428
friend void check_context(object const &a, object const &b)
Definition: z3++.h:432
func_decl get_const_decl ( unsigned  i) const
inline

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

Referenced by model::operator[]().

2533 { 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:429
context & ctx() const
Definition: z3++.h:428
expr get_const_interp ( func_decl  c) const
inline

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

2544  {
2545  check_context(*this, c);
2546  Z3_ast r = Z3_model_get_const_interp(ctx(), m_model, c);
2547  check_error();
2548  return expr(ctx(), r);
2549  }
Z3_error_code check_error() const
Definition: z3++.h:429
context & ctx() const
Definition: z3++.h:428
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:432
func_decl get_func_decl ( unsigned  i) const
inline

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

Referenced by model::operator[]().

2534 { 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:429
context & ctx() const
Definition: z3++.h:428
func_interp get_func_interp ( func_decl  f) const
inline

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

2550  {
2551  check_context(*this, f);
2552  Z3_func_interp r = Z3_model_get_func_interp(ctx(), m_model, f);
2553  check_error();
2554  return func_interp(ctx(), r);
2555  }
Z3_error_code check_error() const
Definition: z3++.h:429
context & ctx() const
Definition: z3++.h:428
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:432
bool has_interp ( func_decl  f) const
inline

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

2559  {
2560  check_context(*this, f);
2561  return Z3_model_has_interp(ctx(), m_model, f);
2562  }
context & ctx() const
Definition: z3++.h:428
friend void check_context(object const &a, object const &b)
Definition: z3++.h:432
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 2531 of file z3++.h.

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

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

Referenced by model::size().

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

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

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

2513  {
2514  Z3_model_inc_ref(s.ctx(), s.m_model);
2515  Z3_model_dec_ref(ctx(), m_model);
2516  object::operator=(s);
2517  m_model = s.m_model;
2518  return *this;
2519  }
context & ctx() const
Definition: z3++.h:428
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.
func_decl operator[] ( int  i) const
inline

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

2536  {
2537  assert(0 <= i);
2538  return static_cast<unsigned>(i) < num_consts() ? get_const_decl(i) : get_func_decl(i - num_consts());
2539  }
func_decl get_const_decl(unsigned i) const
Definition: z3++.h:2533
func_decl get_func_decl(unsigned i) const
Definition: z3++.h:2534
unsigned num_consts() const
Definition: z3++.h:2531
unsigned size ( ) const
inline

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

2535 { return num_consts() + num_funcs(); }
unsigned num_consts() const
Definition: z3++.h:2531
unsigned num_funcs() const
Definition: z3++.h:2532
std::string to_string ( ) const
inline

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

2577 { return std::string(Z3_model_to_string(ctx(), m_model)); }
context & ctx() const
Definition: z3++.h:428
Z3_string Z3_API Z3_model_to_string(Z3_context c, Z3_model m)
Convert the given model into a string.

Friends And Related Function Documentation

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

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

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