Z3
 
Loading...
Searching...
No Matches
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...

#include <z3++.h>

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

Constructor & Destructor Documentation

◆ func_decl() [1/2]

func_decl ( context c)
inline

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

832:ast(c) {}
ast(context &c)
Definition z3++.h:625

◆ func_decl() [2/2]

func_decl ( context c,
Z3_func_decl  n 
)
inline

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

833:ast(c, reinterpret_cast<Z3_ast>(n)) {}
System.IntPtr Z3_ast

Member Function Documentation

◆ accessors()

func_decl_vector accessors ( )
inline

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

4510 {
4511 sort s = range();
4512 assert(s.is_datatype());
4513 unsigned n = Z3_get_datatype_sort_num_constructors(ctx(), s);
4514 unsigned idx = 0;
4515 for (; idx < n; ++idx) {
4517 if (id() == f.id())
4518 break;
4519 }
4520 assert(idx < n);
4521 n = arity();
4522 func_decl_vector as(ctx());
4523 for (unsigned i = 0; i < n; ++i)
4524 as.push_back(func_decl(ctx(), Z3_get_datatype_sort_constructor_accessor(ctx(), s, idx, i)));
4525 return as;
4526 }
sort range() const
Definition z3++.h:843
func_decl(context &c)
Definition z3++.h:832
unsigned arity() const
Definition z3++.h:841
context & ctx() const
Definition z3++.h:544
unsigned Z3_API Z3_get_datatype_sort_num_constructors(Z3_context c, Z3_sort t)
Return number of constructors for datatype.
Z3_func_decl Z3_API Z3_get_datatype_sort_constructor(Z3_context c, Z3_sort t, unsigned idx)
Return idx'th constructor.
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.
ast_vector_tpl< func_decl > func_decl_vector
Definition z3++.h:79

◆ arity()

unsigned arity ( ) const
inline

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

841{ return Z3_get_arity(ctx(), *this); }
unsigned Z3_API Z3_get_arity(Z3_context c, Z3_func_decl d)
Alias for Z3_get_domain_size.

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

◆ decl_kind()

Z3_decl_kind decl_kind ( ) const
inline

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

845{ 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 842 of file z3++.h.

842{ 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:545
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.
System.IntPtr Z3_sort

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

◆ id()

unsigned id ( ) const
inline

retrieve unique identifier for func_decl.

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

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

Referenced by func_decl::accessors().

◆ is_const()

bool is_const ( ) const
inline

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

853{ return arity() == 0; }

◆ name()

symbol name ( ) const
inline

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

844{ 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.
System.IntPtr Z3_symbol

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

◆ num_parameters()

unsigned num_parameters ( ) const
inline

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

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

Referenced by parameter::parameter(), and parameter::parameter().

◆ operator Z3_func_decl()

operator Z3_func_decl ( ) const
inline

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

834{ return reinterpret_cast<Z3_func_decl>(m_ast); }
Z3_ast m_ast
Definition z3++.h:623
System.IntPtr Z3_func_decl

◆ operator()() [1/11]

expr operator() ( ) const
inline

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

4089 {
4090 Z3_ast r = Z3_mk_app(ctx(), *this, 0, 0);
4091 ctx().check_error();
4092 return expr(ctx(), r);
4093 }
Z3_error_code check_error() const
Auxiliary method used to check for API usage errors.
Definition z3++.h:241
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 4094 of file z3++.h.

4094 {
4095 check_context(*this, a);
4096 Z3_ast args[1] = { a };
4097 Z3_ast r = Z3_mk_app(ctx(), *this, 1, args);
4098 ctx().check_error();
4099 return expr(ctx(), r);
4100 }
friend void check_context(object const &a, object const &b)
Definition z3++.h:548

◆ operator()() [3/11]

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

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

4107 {
4108 check_context(*this, a1); check_context(*this, a2);
4109 Z3_ast args[2] = { a1, a2 };
4110 Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
4111 ctx().check_error();
4112 return expr(ctx(), r);
4113 }

◆ operator()() [4/11]

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

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

4128 {
4129 check_context(*this, a1); check_context(*this, a2); check_context(*this, a3);
4130 Z3_ast args[3] = { a1, a2, a3 };
4131 Z3_ast r = Z3_mk_app(ctx(), *this, 3, args);
4132 ctx().check_error();
4133 return expr(ctx(), r);
4134 }

◆ operator()() [5/11]

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

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

4135 {
4136 check_context(*this, a1); check_context(*this, a2); check_context(*this, a3); check_context(*this, a4);
4137 Z3_ast args[4] = { a1, a2, a3, a4 };
4138 Z3_ast r = Z3_mk_app(ctx(), *this, 4, args);
4139 ctx().check_error();
4140 return expr(ctx(), r);
4141 }

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

4142 {
4143 check_context(*this, a1); check_context(*this, a2); check_context(*this, a3); check_context(*this, a4); check_context(*this, a5);
4144 Z3_ast args[5] = { a1, a2, a3, a4, a5 };
4145 Z3_ast r = Z3_mk_app(ctx(), *this, 5, args);
4146 ctx().check_error();
4147 return expr(ctx(), r);
4148 }

◆ operator()() [7/11]

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

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

4114 {
4115 check_context(*this, a1);
4116 Z3_ast args[2] = { a1, ctx().num_val(a2, domain(1)) };
4117 Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
4118 ctx().check_error();
4119 return expr(ctx(), r);
4120 }
expr num_val(int n, sort const &s)
Definition z3++.h:4066
sort domain(unsigned i) const
Definition z3++.h:842

◆ operator()() [8/11]

expr operator() ( expr_vector const v) const
inline

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

4079 {
4080 array<Z3_ast> _args(args.size());
4081 for (unsigned i = 0; i < args.size(); ++i) {
4082 check_context(*this, args[i]);
4083 _args[i] = args[i];
4084 }
4085 Z3_ast r = Z3_mk_app(ctx(), *this, args.size(), _args.ptr());
4086 check_error();
4087 return expr(ctx(), r);
4088 }

◆ operator()() [9/11]

expr operator() ( int  a) const
inline

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

4101 {
4102 Z3_ast args[1] = { ctx().num_val(a, domain(0)) };
4103 Z3_ast r = Z3_mk_app(ctx(), *this, 1, args);
4104 ctx().check_error();
4105 return expr(ctx(), r);
4106 }

◆ operator()() [10/11]

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

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

4121 {
4122 check_context(*this, a2);
4123 Z3_ast args[2] = { ctx().num_val(a1, domain(0)), a2 };
4124 Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
4125 ctx().check_error();
4126 return expr(ctx(), r);
4127 }

◆ operator()() [11/11]

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

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

4068 {
4069 array<Z3_ast> _args(n);
4070 for (unsigned i = 0; i < n; ++i) {
4071 check_context(*this, args[i]);
4072 _args[i] = args[i];
4073 }
4074 Z3_ast r = Z3_mk_app(ctx(), *this, n, _args.ptr());
4075 check_error();
4076 return expr(ctx(), r);
4077
4078 }

◆ range()

sort range ( ) const
inline

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

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

Referenced by func_decl::accessors().

◆ transitive_closure()

func_decl transitive_closure ( func_decl const )
inline

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

849 {
850 Z3_func_decl tc = Z3_mk_transitive_closure(ctx(), *this); check_error(); return func_decl(ctx(), tc);
851 }
Z3_func_decl Z3_API Z3_mk_transitive_closure(Z3_context c, Z3_func_decl f)
create transitive closure of binary relation.