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 2543 of file z3++.h.

Constructor & Destructor Documentation

◆ model() [1/4]

model ( context c)
inline

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

2551 :object(c) { init(Z3_mk_model(c)); }

Referenced by FuncInterp::translate().

◆ model() [2/4]

model ( context c,
Z3_model  m 
)
inline

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

2552 :object(c) { init(m); }

Referenced by FuncInterp::translate().

◆ model() [3/4]

model ( model const &  s)
inline

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

2553 :object(s) { init(s.m_model); }

Referenced by FuncInterp::translate().

◆ model() [4/4]

model ( model src,
context dst,
translate   
)
inline

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

2554 : object(dst) { init(Z3_model_translate(src.ctx(), src, dst)); }

Referenced by FuncInterp::translate().

◆ ~model()

~model ( )
inline

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

2555 { Z3_model_dec_ref(ctx(), m_model); }

Member Function Documentation

◆ add_const_interp()

void add_const_interp ( func_decl f,
expr value 
)
inline

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

2614  {
2615  Z3_add_const_interp(ctx(), m_model, f, value);
2616  check_error();
2617  }

◆ add_func_interp()

func_interp add_func_interp ( func_decl f,
expr else_val 
)
inline

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

2608  {
2609  Z3_func_interp r = Z3_add_func_interp(ctx(), m_model, f, else_val);
2610  check_error();
2611  return func_interp(ctx(), r);
2612  }

◆ eval()

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

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

2565  {
2566  check_context(*this, n);
2567  Z3_ast r = 0;
2568  bool status = Z3_model_eval(ctx(), m_model, n, model_completion, &r);
2569  check_error();
2570  if (status == false && ctx().enable_exceptions())
2571  Z3_THROW(exception("failed to evaluate expression"));
2572  return expr(ctx(), r);
2573  }

◆ get_const_decl()

func_decl get_const_decl ( unsigned  i) const
inline

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

2577 { Z3_func_decl r = Z3_model_get_const_decl(ctx(), m_model, i); check_error(); return func_decl(ctx(), r); }

Referenced by model::operator[]().

◆ get_const_interp()

expr get_const_interp ( func_decl  c) const
inline

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

2588  {
2589  check_context(*this, c);
2590  Z3_ast r = Z3_model_get_const_interp(ctx(), m_model, c);
2591  check_error();
2592  return expr(ctx(), r);
2593  }

◆ get_func_decl()

func_decl get_func_decl ( unsigned  i) const
inline

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

2578 { Z3_func_decl r = Z3_model_get_func_decl(ctx(), m_model, i); check_error(); return func_decl(ctx(), r); }

Referenced by model::operator[]().

◆ get_func_interp()

func_interp get_func_interp ( func_decl  f) const
inline

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

2594  {
2595  check_context(*this, f);
2596  Z3_func_interp r = Z3_model_get_func_interp(ctx(), m_model, f);
2597  check_error();
2598  return func_interp(ctx(), r);
2599  }

◆ has_interp()

bool has_interp ( func_decl  f) const
inline

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

2603  {
2604  check_context(*this, f);
2605  return Z3_model_has_interp(ctx(), m_model, f);
2606  }

◆ num_consts()

unsigned num_consts ( ) const
inline

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

2575 { return Z3_model_get_num_consts(ctx(), m_model); }

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

◆ num_funcs()

unsigned num_funcs ( ) const
inline

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

2576 { return Z3_model_get_num_funcs(ctx(), m_model); }

Referenced by model::size().

◆ operator Z3_model()

operator Z3_model ( ) const
inline

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

2556 { return m_model; }

◆ operator=()

model& operator= ( model const &  s)
inline

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

2557  {
2558  Z3_model_inc_ref(s.ctx(), s.m_model);
2559  Z3_model_dec_ref(ctx(), m_model);
2560  object::operator=(s);
2561  m_model = s.m_model;
2562  return *this;
2563  }

◆ operator[]()

func_decl operator[] ( int  i) const
inline

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

2580  {
2581  assert(0 <= i);
2582  return static_cast<unsigned>(i) < num_consts() ? get_const_decl(i) : get_func_decl(i - num_consts());
2583  }

◆ size()

unsigned size ( ) const
inline

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

2579 { return num_consts() + num_funcs(); }

◆ to_string()

std::string to_string ( ) const
inline

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

2621 { return m_model ? std::string(Z3_model_to_string(ctx(), m_model)) : "null"; }

Referenced by z3::operator<<().

Friends And Related Function Documentation

◆ operator<<

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

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

2623 { return out << m.to_string(); }
Z3_model_get_const_interp
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,...
z3::model::get_const_decl
func_decl get_const_decl(unsigned i) const
Definition: z3++.h:2577
Z3_model_to_string
Z3_string Z3_API Z3_model_to_string(Z3_context c, Z3_model m)
Convert the given model into a string.
Z3_model_translate
Z3_model Z3_API Z3_model_translate(Z3_context c, Z3_model m, Z3_context dst)
translate model from context c to context dst.
Z3_model_get_func_decl
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::model::get_func_decl
func_decl get_func_decl(unsigned i) const
Definition: z3++.h:2578
Z3_THROW
#define Z3_THROW(x)
Definition: z3++.h:102
Microsoft.Z3.Z3_func_decl
System.IntPtr Z3_func_decl
Definition: NativeContext.cs:30
z3::object::object
object(context &c)
Definition: z3++.h:450
Z3_model_get_num_funcs
unsigned Z3_API Z3_model_get_num_funcs(Z3_context c, Z3_model m)
Return the number of function interpretations in the given model.
Z3_model_get_func_interp
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...
Z3_model_inc_ref
void Z3_API Z3_model_inc_ref(Z3_context c, Z3_model m)
Increment the reference counter of the given model.
Z3_model_get_const_decl
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_add_func_interp
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...
Z3_model_dec_ref
void Z3_API Z3_model_dec_ref(Z3_context c, Z3_model m)
Decrement the reference counter of the given model.
Microsoft.Z3.Z3_func_interp
System.IntPtr Z3_func_interp
Definition: NativeFuncInterp.cs:32
Z3_model_get_num_consts
unsigned Z3_API Z3_model_get_num_consts(Z3_context c, Z3_model m)
Return the number of constants assigned by the given model.
z3::object::check_context
friend void check_context(object const &a, object const &b)
Definition: z3++.h:455
z3::model::num_consts
unsigned num_consts() const
Definition: z3++.h:2575
Z3_add_const_interp
void Z3_API Z3_add_const_interp(Z3_context c, Z3_model m, Z3_func_decl f, Z3_ast a)
Add a constant interpretation.
Microsoft.Z3.Z3_ast
System.IntPtr Z3_ast
Definition: NativeContext.cs:28
Z3_model_has_interp
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.
Z3_mk_model
Z3_model Z3_API Z3_mk_model(Z3_context c)
Create a fresh model object. It has reference count 0.
z3::object::check_error
Z3_error_code check_error() const
Definition: z3++.h:452
Z3_model_eval
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.
z3::model::num_funcs
unsigned num_funcs() const
Definition: z3++.h:2576
z3::object::ctx
context & ctx() const
Definition: z3++.h:451