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
 
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
 
- Public Member Functions inherited from ast
 ast (context &c)
 
 ast (context &c, Z3_ast n)
 
 ast (ast const &s)
 
 ~ast ()
 
 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)
 
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 710 of file z3++.h.

Constructor & Destructor Documentation

◆ func_decl() [1/2]

func_decl ( context c)
inline

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

712 :ast(c) {}
ast(context &c)
Definition: z3++.h:509

Referenced by func_decl::transitive_closure().

◆ func_decl() [2/2]

func_decl ( context c,
Z3_func_decl  n 
)
inline

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

713 :ast(c, reinterpret_cast<Z3_ast>(n)) {}

Member Function Documentation

◆ arity()

unsigned arity ( ) const
inline

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

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

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

◆ decl_kind()

Z3_decl_kind decl_kind ( ) const
inline

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

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

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().

◆ domain()

sort domain ( unsigned  i) const
inline

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

722 { assert(i < arity()); Z3_sort r = Z3_get_domain(ctx(), *this, i); check_error(); return sort(ctx(), r); }
unsigned arity() const
Definition: z3++.h:721
Z3_error_code check_error() const
Definition: z3++.h:430
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.

Referenced by FuncDeclRef::__call__(), ArrayRef::__getitem__(), and func_decl::operator()().

◆ id()

unsigned id ( ) const
inline

retrieve unique identifier for func_decl.

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

719 { unsigned r = Z3_get_func_decl_id(ctx(), *this); check_error(); return r; }
unsigned Z3_API Z3_get_func_decl_id(Z3_context c, Z3_func_decl f)
Return a unique identifier for f.

◆ is_const()

bool is_const ( ) const
inline

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

731 { return arity() == 0; }

◆ name()

symbol name ( ) const
inline

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

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

Referenced by Datatype::__deepcopy__(), and Datatype::__repr__().

◆ operator Z3_func_decl()

operator Z3_func_decl ( ) const
inline

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

714 { return reinterpret_cast<Z3_func_decl>(m_ast); }
Z3_ast m_ast
Definition: z3++.h:507

◆ operator()() [1/11]

expr operator() ( ) const
inline

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

3524  {
3525  Z3_ast r = Z3_mk_app(ctx(), *this, 0, 0);
3526  ctx().check_error();
3527  return expr(ctx(), r);
3528  }
Z3_error_code check_error() const
Auxiliary method used to check for API usage errors.
Definition: z3++.h:188
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.

◆ operator()() [2/11]

expr operator() ( expr const &  a) const
inline

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

3529  {
3530  check_context(*this, a);
3531  Z3_ast args[1] = { a };
3532  Z3_ast r = Z3_mk_app(ctx(), *this, 1, args);
3533  ctx().check_error();
3534  return expr(ctx(), r);
3535  }
friend void check_context(object const &a, object const &b)
Definition: z3++.h:433

◆ operator()() [3/11]

expr operator() ( expr const &  a1,
expr const &  a2 
) const
inline

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

3542  {
3543  check_context(*this, a1); check_context(*this, a2);
3544  Z3_ast args[2] = { a1, a2 };
3545  Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
3546  ctx().check_error();
3547  return expr(ctx(), r);
3548  }

◆ operator()() [4/11]

expr operator() ( expr const &  a1,
expr const &  a2,
expr const &  a3 
) const
inline

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

3563  {
3564  check_context(*this, a1); check_context(*this, a2); check_context(*this, a3);
3565  Z3_ast args[3] = { a1, a2, a3 };
3566  Z3_ast r = Z3_mk_app(ctx(), *this, 3, args);
3567  ctx().check_error();
3568  return expr(ctx(), r);
3569  }

◆ operator()() [5/11]

expr operator() ( expr const &  a1,
expr const &  a2,
expr const &  a3,
expr const &  a4 
) const
inline

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

3570  {
3571  check_context(*this, a1); check_context(*this, a2); check_context(*this, a3); check_context(*this, a4);
3572  Z3_ast args[4] = { a1, a2, a3, a4 };
3573  Z3_ast r = Z3_mk_app(ctx(), *this, 4, args);
3574  ctx().check_error();
3575  return expr(ctx(), r);
3576  }

◆ operator()() [6/11]

expr operator() ( expr const &  a1,
expr const &  a2,
expr const &  a3,
expr const &  a4,
expr const &  a5 
) const
inline

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

3577  {
3578  check_context(*this, a1); check_context(*this, a2); check_context(*this, a3); check_context(*this, a4); check_context(*this, a5);
3579  Z3_ast args[5] = { a1, a2, a3, a4, a5 };
3580  Z3_ast r = Z3_mk_app(ctx(), *this, 5, args);
3581  ctx().check_error();
3582  return expr(ctx(), r);
3583  }

◆ operator()() [7/11]

expr operator() ( expr const &  a1,
int  a2 
) const
inline

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

3549  {
3550  check_context(*this, a1);
3551  Z3_ast args[2] = { a1, ctx().num_val(a2, domain(1)) };
3552  Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
3553  ctx().check_error();
3554  return expr(ctx(), r);
3555  }
expr num_val(int n, sort const &s)
Definition: z3++.h:3501
sort domain(unsigned i) const
Definition: z3++.h:722

◆ operator()() [8/11]

expr operator() ( expr_vector const &  v) const
inline

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

3514  {
3515  array<Z3_ast> _args(args.size());
3516  for (unsigned i = 0; i < args.size(); i++) {
3517  check_context(*this, args[i]);
3518  _args[i] = args[i];
3519  }
3520  Z3_ast r = Z3_mk_app(ctx(), *this, args.size(), _args.ptr());
3521  check_error();
3522  return expr(ctx(), r);
3523  }

◆ operator()() [9/11]

expr operator() ( int  a) const
inline

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

3536  {
3537  Z3_ast args[1] = { ctx().num_val(a, domain(0)) };
3538  Z3_ast r = Z3_mk_app(ctx(), *this, 1, args);
3539  ctx().check_error();
3540  return expr(ctx(), r);
3541  }

◆ operator()() [10/11]

expr operator() ( int  a1,
expr const &  a2 
) const
inline

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

3556  {
3557  check_context(*this, a2);
3558  Z3_ast args[2] = { ctx().num_val(a1, domain(0)), a2 };
3559  Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
3560  ctx().check_error();
3561  return expr(ctx(), r);
3562  }

◆ operator()() [11/11]

expr operator() ( unsigned  n,
expr const *  args 
) const
inline

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

3503  {
3504  array<Z3_ast> _args(n);
3505  for (unsigned i = 0; i < n; i++) {
3506  check_context(*this, args[i]);
3507  _args[i] = args[i];
3508  }
3509  Z3_ast r = Z3_mk_app(ctx(), *this, n, _args.ptr());
3510  check_error();
3511  return expr(ctx(), r);
3512 
3513  }

◆ range()

sort range ( ) const
inline

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

723 { Z3_sort r = Z3_get_range(ctx(), *this); check_error(); return sort(ctx(), r); }
Z3_sort Z3_API Z3_get_range(Z3_context c, Z3_func_decl d)
Return the range of the given declaration.

◆ transitive_closure()

func_decl transitive_closure ( func_decl const &  )
inline

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

727  {
728  Z3_func_decl tc = Z3_mk_transitive_closure(ctx(), *this); check_error(); return func_decl(ctx(), tc);
729  }
func_decl(context &c)
Definition: z3++.h:712
Z3_func_decl Z3_API Z3_mk_transitive_closure(Z3_context c, Z3_func_decl f)
create transitive closure of binary relation.