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

Public Member Functions

 model (context &c)
 
 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
 
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 1805 of file z3++.h.

Constructor & Destructor Documentation

§ model() [1/3]

model ( context c)
inline

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

1812 :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:362

§ model() [2/3]

model ( context c,
Z3_model  m 
)
inline

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

1813 :object(c) { init(m); }
object(context &c)
Definition: z3++.h:362

§ model() [3/3]

model ( model const &  s)
inline

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

1814 :object(s) { init(s.m_model); }
object(context &c)
Definition: z3++.h:362

§ ~model()

~model ( )
inline

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

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

Member Function Documentation

§ add_const_interp()

void add_const_interp ( func_decl f,
expr value 
)
inline

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

1874  {
1875  Z3_add_const_interp(ctx(), m_model, f, value);
1876  check_error();
1877  }
Z3_error_code check_error() const
Definition: z3++.h:365
void Z3_API Z3_add_const_interp(Z3_context c, Z3_model m, Z3_func_decl f, Z3_ast a)
Add a constant interpretation.
context & ctx() const
Definition: z3++.h:364

§ add_func_interp()

func_interp add_func_interp ( func_decl f,
expr else_val 
)
inline

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

1868  {
1869  Z3_func_interp r = Z3_add_func_interp(ctx(), m_model, f, else_val);
1870  check_error();
1871  return func_interp(ctx(), r);
1872  }
Z3_error_code check_error() const
Definition: z3++.h:365
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:364

§ eval()

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

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

1825  {
1826  check_context(*this, n);
1827  Z3_ast r = 0;
1828  Z3_bool status = Z3_model_eval(ctx(), m_model, n, model_completion, &r);
1829  check_error();
1830  if (status == Z3_FALSE && ctx().enable_exceptions())
1831  Z3_THROW(exception("failed to evaluate expression"));
1832  return expr(ctx(), r);
1833  }
Z3_error_code check_error() const
Definition: z3++.h:365
#define Z3_THROW(x)
Definition: z3++.h:93
int Z3_bool
Z3 Boolean type. It is just an alias for int.
Definition: z3_api.h:85
context & ctx() const
Definition: z3++.h:364
friend void check_context(object const &a, object const &b)
Definition: z3++.h:368
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:101

§ get_const_decl()

func_decl get_const_decl ( unsigned  i) const
inline

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

1837 { Z3_func_decl r = Z3_model_get_const_decl(ctx(), m_model, i); check_error(); return func_decl(ctx(), r); }
Z3_error_code check_error() const
Definition: z3++.h:365
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:364

§ get_const_interp()

expr get_const_interp ( func_decl  c) const
inline

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

1848  {
1849  check_context(*this, c);
1850  Z3_ast r = Z3_model_get_const_interp(ctx(), m_model, c);
1851  check_error();
1852  return expr(ctx(), r);
1853  }
Z3_error_code check_error() const
Definition: z3++.h:365
context & ctx() const
Definition: z3++.h:364
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:368

§ get_func_decl()

func_decl get_func_decl ( unsigned  i) const
inline

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

1838 { Z3_func_decl r = Z3_model_get_func_decl(ctx(), m_model, i); check_error(); return func_decl(ctx(), r); }
Z3_error_code check_error() const
Definition: z3++.h:365
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:364

§ get_func_interp()

func_interp get_func_interp ( func_decl  f) const
inline

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

1854  {
1855  check_context(*this, f);
1856  Z3_func_interp r = Z3_model_get_func_interp(ctx(), m_model, f);
1857  check_error();
1858  return func_interp(ctx(), r);
1859  }
Z3_error_code check_error() const
Definition: z3++.h:365
context & ctx() const
Definition: z3++.h:364
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:368

§ has_interp()

bool has_interp ( func_decl  f) const
inline

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

1863  {
1864  check_context(*this, f);
1865  return 0 != Z3_model_has_interp(ctx(), m_model, f);
1866  }
context & ctx() const
Definition: z3++.h:364
friend void check_context(object const &a, object const &b)
Definition: z3++.h:368
Z3_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.

§ num_consts()

unsigned num_consts ( ) const
inline

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

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

§ num_funcs()

unsigned num_funcs ( ) const
inline

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

1836 { return Z3_model_get_num_funcs(ctx(), m_model); }
context & ctx() const
Definition: z3++.h:364
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()

operator Z3_model ( ) const
inline

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

1816 { return m_model; }

§ operator=()

model& operator= ( model const &  s)
inline

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

1817  {
1818  Z3_model_inc_ref(s.ctx(), s.m_model);
1819  Z3_model_dec_ref(ctx(), m_model);
1820  m_ctx = s.m_ctx;
1821  m_model = s.m_model;
1822  return *this;
1823  }
context & ctx() const
Definition: z3++.h:364
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:360

§ operator[]()

func_decl operator[] ( int  i) const
inline

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

1840  {
1841  assert(0 <= i);
1842  return static_cast<unsigned>(i) < num_consts() ? get_const_decl(i) : get_func_decl(i - num_consts());
1843  }
func_decl get_const_decl(unsigned i) const
Definition: z3++.h:1837
func_decl get_func_decl(unsigned i) const
Definition: z3++.h:1838
unsigned num_consts() const
Definition: z3++.h:1835

§ size()

unsigned size ( ) const
inline

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

1839 { return num_consts() + num_funcs(); }
unsigned num_consts() const
Definition: z3++.h:1835
unsigned num_funcs() const
Definition: z3++.h:1836

Friends And Related Function Documentation

§ operator<<

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

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

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