Z3
Public Member Functions
func_decl Class Reference

Function declaration (aka function definition). It is the signature of interpreted and uninterpreted functions in Z3. The basic building block in Z3 is the function application. More...

+ Inheritance diagram for func_decl:

Public Member Functions

 func_decl (context &c)
 
 func_decl (context &c, Z3_func_decl n)
 
 operator Z3_func_decl () const
 
unsigned id () const
 retrieve unique identifier for func_decl. More...
 
unsigned arity () const
 
sort domain (unsigned i) const
 
sort range () const
 
symbol name () const
 
Z3_decl_kind decl_kind () const
 
unsigned num_parameters () const
 
func_decl transitive_closure (func_decl const &)
 
bool is_const () const
 
expr operator() () const
 
expr operator() (unsigned n, expr const *args) const
 
expr operator() (expr_vector const &v) const
 
expr operator() (expr const &a) const
 
expr operator() (int a) const
 
expr operator() (expr const &a1, expr const &a2) const
 
expr operator() (expr const &a1, int a2) const
 
expr operator() (int a1, expr const &a2) const
 
expr operator() (expr const &a1, expr const &a2, expr const &a3) const
 
expr operator() (expr const &a1, expr const &a2, expr const &a3, expr const &a4) const
 
expr operator() (expr const &a1, expr const &a2, expr const &a3, expr const &a4, expr const &a5) const
 
func_decl_vector accessors ()
 
- Public Member Functions inherited from ast
 ast (context &c)
 
 ast (context &c, Z3_ast n)
 
 ast (ast const &s)
 
 ~ast () override
 
 operator Z3_ast () const
 
 operator bool () const
 
astoperator= (ast const &s)
 
Z3_ast_kind kind () const
 
unsigned hash () const
 
std::string to_string () const
 
- Public Member Functions inherited from object
 object (context &c)
 
virtual ~object ()=default
 
contextctx () const
 
Z3_error_code check_error () const
 

Additional Inherited Members

- Protected Attributes inherited from ast
Z3_ast m_ast
 
- Protected Attributes inherited from object
contextm_ctx
 

Detailed Description

Function declaration (aka function definition). It is the signature of interpreted and uninterpreted functions in Z3. The basic building block in Z3 is the function application.

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

Constructor & Destructor Documentation

func_decl ( context c)
inline

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

Referenced by func_decl::transitive_closure().

828 :ast(c) {}
ast(context &c)
Definition: z3++.h:621
func_decl ( context c,
Z3_func_decl  n 
)
inline

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

829 :ast(c, reinterpret_cast<Z3_ast>(n)) {}
ast(context &c)
Definition: z3++.h:621

Member Function Documentation

func_decl_vector accessors ( )
inline

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

4417  {
4418  sort s = range();
4419  assert(s.is_datatype());
4420  unsigned n = Z3_get_datatype_sort_num_constructors(ctx(), s);
4421  unsigned idx = 0;
4422  for (; idx < n; ++idx) {
4424  if (id() == f.id())
4425  break;
4426  }
4427  assert(idx < n);
4428  n = arity();
4429  func_decl_vector as(ctx());
4430  for (unsigned i = 0; i < n; ++i)
4431  as.push_back(func_decl(ctx(), Z3_get_datatype_sort_constructor_accessor(ctx(), s, idx, i)));
4432  return as;
4433  }
Z3_func_decl Z3_API Z3_get_datatype_sort_constructor_accessor(Z3_context c, Z3_sort t, unsigned idx_c, unsigned idx_a)
Return idx_a'th accessor for the idx_c'th constructor.
func_decl(context &c)
Definition: z3++.h:828
unsigned arity() const
Definition: z3++.h:837
ast_vector_tpl< func_decl > func_decl_vector
Definition: z3++.h:79
context & ctx() const
Definition: z3++.h:540
unsigned Z3_API Z3_get_datatype_sort_num_constructors(Z3_context c, Z3_sort t)
Return number of constructors for datatype.
sort range() const
Definition: z3++.h:839
Z3_func_decl Z3_API Z3_get_datatype_sort_constructor(Z3_context c, Z3_sort t, unsigned idx)
Return idx'th constructor.
unsigned arity ( ) const
inline

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

Referenced by func_decl::accessors(), fixedpoint::add_fact(), func_decl::domain(), and func_decl::is_const().

837 { return Z3_get_arity(ctx(), *this); }
context & ctx() const
Definition: z3++.h:540
unsigned Z3_API Z3_get_arity(Z3_context c, Z3_func_decl d)
Alias for Z3_get_domain_size.
Z3_decl_kind decl_kind ( ) const
inline

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

Referenced by expr::is_and(), expr::is_distinct(), expr::is_eq(), expr::is_false(), expr::is_implies(), expr::is_ite(), expr::is_not(), expr::is_or(), expr::is_true(), and expr::is_xor().

841 { return Z3_get_decl_kind(ctx(), *this); }
Z3_decl_kind Z3_API Z3_get_decl_kind(Z3_context c, Z3_func_decl d)
Return declaration kind corresponding to declaration.
context & ctx() const
Definition: z3++.h:540
sort domain ( unsigned  i) const
inline

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

Referenced by func_decl::operator()().

838 { assert(i < arity()); Z3_sort r = Z3_get_domain(ctx(), *this, i); check_error(); return sort(ctx(), r); }
Z3_error_code check_error() const
Definition: z3++.h:541
unsigned arity() const
Definition: z3++.h:837
context & ctx() const
Definition: z3++.h:540
Z3_sort Z3_API Z3_get_domain(Z3_context c, Z3_func_decl d, unsigned i)
Return the sort of the i-th parameter of the given function declaration.
unsigned id ( ) const
inline

retrieve unique identifier for func_decl.

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

Referenced by func_decl::accessors().

835 { unsigned r = Z3_get_func_decl_id(ctx(), *this); check_error(); return r; }
Z3_error_code check_error() const
Definition: z3++.h:541
context & ctx() const
Definition: z3++.h:540
unsigned Z3_API Z3_get_func_decl_id(Z3_context c, Z3_func_decl f)
Return a unique identifier for f.
bool is_const ( ) const
inline

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

849 { return arity() == 0; }
unsigned arity() const
Definition: z3++.h:837
symbol name ( ) const
inline

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

840 { Z3_symbol s = Z3_get_decl_name(ctx(), *this); check_error(); return symbol(ctx(), s); }
Z3_symbol Z3_API Z3_get_decl_name(Z3_context c, Z3_func_decl d)
Return the constant declaration name as a symbol.
Z3_error_code check_error() const
Definition: z3++.h:541
context & ctx() const
Definition: z3++.h:540
unsigned num_parameters ( ) const
inline

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

Referenced by parameter::parameter().

842 { return Z3_get_decl_num_parameters(ctx(), *this); }
unsigned Z3_API Z3_get_decl_num_parameters(Z3_context c, Z3_func_decl d)
Return the number of parameters associated with a declaration.
context & ctx() const
Definition: z3++.h:540
operator Z3_func_decl ( ) const
inline

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

830 { return reinterpret_cast<Z3_func_decl>(m_ast); }
Z3_ast m_ast
Definition: z3++.h:619
expr operator() ( ) const
inline

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

4044  {
4045  Z3_ast r = Z3_mk_app(ctx(), *this, 0, 0);
4046  ctx().check_error();
4047  return expr(ctx(), r);
4048  }
Z3_ast Z3_API Z3_mk_app(Z3_context c, Z3_func_decl d, unsigned num_args, Z3_ast const args[])
Create a constant or function application.
context & ctx() const
Definition: z3++.h:540
Z3_error_code check_error() const
Auxiliary method used to check for API usage errors.
Definition: z3++.h:241
expr operator() ( unsigned  n,
expr const *  args 
) const
inline

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

4023  {
4024  array<Z3_ast> _args(n);
4025  for (unsigned i = 0; i < n; ++i) {
4026  check_context(*this, args[i]);
4027  _args[i] = args[i];
4028  }
4029  Z3_ast r = Z3_mk_app(ctx(), *this, n, _args.ptr());
4030  check_error();
4031  return expr(ctx(), r);
4032 
4033  }
Z3_ast Z3_API Z3_mk_app(Z3_context c, Z3_func_decl d, unsigned num_args, Z3_ast const args[])
Create a constant or function application.
Z3_error_code check_error() const
Definition: z3++.h:541
context & ctx() const
Definition: z3++.h:540
friend void check_context(object const &a, object const &b)
Definition: z3++.h:544
expr operator() ( expr_vector const &  v) const
inline

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

4034  {
4035  array<Z3_ast> _args(args.size());
4036  for (unsigned i = 0; i < args.size(); ++i) {
4037  check_context(*this, args[i]);
4038  _args[i] = args[i];
4039  }
4040  Z3_ast r = Z3_mk_app(ctx(), *this, args.size(), _args.ptr());
4041  check_error();
4042  return expr(ctx(), r);
4043  }
Z3_ast Z3_API Z3_mk_app(Z3_context c, Z3_func_decl d, unsigned num_args, Z3_ast const args[])
Create a constant or function application.
Z3_error_code check_error() const
Definition: z3++.h:541
context & ctx() const
Definition: z3++.h:540
friend void check_context(object const &a, object const &b)
Definition: z3++.h:544
expr operator() ( expr const &  a) const
inline

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

4049  {
4050  check_context(*this, a);
4051  Z3_ast args[1] = { a };
4052  Z3_ast r = Z3_mk_app(ctx(), *this, 1, args);
4053  ctx().check_error();
4054  return expr(ctx(), r);
4055  }
Z3_ast Z3_API Z3_mk_app(Z3_context c, Z3_func_decl d, unsigned num_args, Z3_ast const args[])
Create a constant or function application.
context & ctx() const
Definition: z3++.h:540
friend void check_context(object const &a, object const &b)
Definition: z3++.h:544
Z3_error_code check_error() const
Auxiliary method used to check for API usage errors.
Definition: z3++.h:241
expr operator() ( int  a) const
inline

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

4056  {
4057  Z3_ast args[1] = { ctx().num_val(a, domain(0)) };
4058  Z3_ast r = Z3_mk_app(ctx(), *this, 1, args);
4059  ctx().check_error();
4060  return expr(ctx(), r);
4061  }
Z3_ast Z3_API Z3_mk_app(Z3_context c, Z3_func_decl d, unsigned num_args, Z3_ast const args[])
Create a constant or function application.
context & ctx() const
Definition: z3++.h:540
expr num_val(int n, sort const &s)
Definition: z3++.h:4021
sort domain(unsigned i) const
Definition: z3++.h:838
Z3_error_code check_error() const
Auxiliary method used to check for API usage errors.
Definition: z3++.h:241
expr operator() ( expr const &  a1,
expr const &  a2 
) const
inline

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

4062  {
4063  check_context(*this, a1); check_context(*this, a2);
4064  Z3_ast args[2] = { a1, a2 };
4065  Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
4066  ctx().check_error();
4067  return expr(ctx(), r);
4068  }
Z3_ast Z3_API Z3_mk_app(Z3_context c, Z3_func_decl d, unsigned num_args, Z3_ast const args[])
Create a constant or function application.
context & ctx() const
Definition: z3++.h:540
friend void check_context(object const &a, object const &b)
Definition: z3++.h:544
Z3_error_code check_error() const
Auxiliary method used to check for API usage errors.
Definition: z3++.h:241
expr operator() ( expr const &  a1,
int  a2 
) const
inline

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

4069  {
4070  check_context(*this, a1);
4071  Z3_ast args[2] = { a1, ctx().num_val(a2, domain(1)) };
4072  Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
4073  ctx().check_error();
4074  return expr(ctx(), r);
4075  }
Z3_ast Z3_API Z3_mk_app(Z3_context c, Z3_func_decl d, unsigned num_args, Z3_ast const args[])
Create a constant or function application.
context & ctx() const
Definition: z3++.h:540
friend void check_context(object const &a, object const &b)
Definition: z3++.h:544
expr num_val(int n, sort const &s)
Definition: z3++.h:4021
sort domain(unsigned i) const
Definition: z3++.h:838
Z3_error_code check_error() const
Auxiliary method used to check for API usage errors.
Definition: z3++.h:241
expr operator() ( int  a1,
expr const &  a2 
) const
inline

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

4076  {
4077  check_context(*this, a2);
4078  Z3_ast args[2] = { ctx().num_val(a1, domain(0)), a2 };
4079  Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
4080  ctx().check_error();
4081  return expr(ctx(), r);
4082  }
Z3_ast Z3_API Z3_mk_app(Z3_context c, Z3_func_decl d, unsigned num_args, Z3_ast const args[])
Create a constant or function application.
context & ctx() const
Definition: z3++.h:540
friend void check_context(object const &a, object const &b)
Definition: z3++.h:544
expr num_val(int n, sort const &s)
Definition: z3++.h:4021
sort domain(unsigned i) const
Definition: z3++.h:838
Z3_error_code check_error() const
Auxiliary method used to check for API usage errors.
Definition: z3++.h:241
expr operator() ( expr const &  a1,
expr const &  a2,
expr const &  a3 
) const
inline

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

4083  {
4084  check_context(*this, a1); check_context(*this, a2); check_context(*this, a3);
4085  Z3_ast args[3] = { a1, a2, a3 };
4086  Z3_ast r = Z3_mk_app(ctx(), *this, 3, args);
4087  ctx().check_error();
4088  return expr(ctx(), r);
4089  }
Z3_ast Z3_API Z3_mk_app(Z3_context c, Z3_func_decl d, unsigned num_args, Z3_ast const args[])
Create a constant or function application.
context & ctx() const
Definition: z3++.h:540
friend void check_context(object const &a, object const &b)
Definition: z3++.h:544
Z3_error_code check_error() const
Auxiliary method used to check for API usage errors.
Definition: z3++.h:241
expr operator() ( expr const &  a1,
expr const &  a2,
expr const &  a3,
expr const &  a4 
) const
inline

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

4090  {
4091  check_context(*this, a1); check_context(*this, a2); check_context(*this, a3); check_context(*this, a4);
4092  Z3_ast args[4] = { a1, a2, a3, a4 };
4093  Z3_ast r = Z3_mk_app(ctx(), *this, 4, args);
4094  ctx().check_error();
4095  return expr(ctx(), r);
4096  }
Z3_ast Z3_API Z3_mk_app(Z3_context c, Z3_func_decl d, unsigned num_args, Z3_ast const args[])
Create a constant or function application.
context & ctx() const
Definition: z3++.h:540
friend void check_context(object const &a, object const &b)
Definition: z3++.h:544
Z3_error_code check_error() const
Auxiliary method used to check for API usage errors.
Definition: z3++.h:241
expr operator() ( expr const &  a1,
expr const &  a2,
expr const &  a3,
expr const &  a4,
expr const &  a5 
) const
inline

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

4097  {
4098  check_context(*this, a1); check_context(*this, a2); check_context(*this, a3); check_context(*this, a4); check_context(*this, a5);
4099  Z3_ast args[5] = { a1, a2, a3, a4, a5 };
4100  Z3_ast r = Z3_mk_app(ctx(), *this, 5, args);
4101  ctx().check_error();
4102  return expr(ctx(), r);
4103  }
Z3_ast Z3_API Z3_mk_app(Z3_context c, Z3_func_decl d, unsigned num_args, Z3_ast const args[])
Create a constant or function application.
context & ctx() const
Definition: z3++.h:540
friend void check_context(object const &a, object const &b)
Definition: z3++.h:544
Z3_error_code check_error() const
Auxiliary method used to check for API usage errors.
Definition: z3++.h:241
sort range ( ) const
inline

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

Referenced by func_decl::accessors().

839 { Z3_sort r = Z3_get_range(ctx(), *this); check_error(); return sort(ctx(), r); }
Z3_error_code check_error() const
Definition: z3++.h:541
context & ctx() const
Definition: z3++.h:540
Z3_sort Z3_API Z3_get_range(Z3_context c, Z3_func_decl d)
Return the range of the given declaration.
func_decl transitive_closure ( func_decl const &  )
inline

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

845  {
846  Z3_func_decl tc = Z3_mk_transitive_closure(ctx(), *this); check_error(); return func_decl(ctx(), tc);
847  }
Z3_func_decl Z3_API Z3_mk_transitive_closure(Z3_context c, Z3_func_decl f)
create transitive closure of binary relation.
func_decl(context &c)
Definition: z3++.h:828
Z3_error_code check_error() const
Definition: z3++.h:541
context & ctx() const
Definition: z3++.h:540