Z3
Loading...
Searching...
No Matches
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 904 of file z3++.h.

Constructor & Destructor Documentation

◆ func_decl() [1/2]

func_decl ( context & c)
inline

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

906:ast(c) {}

Referenced by accessors(), and transitive_closure().

◆ func_decl() [2/2]

func_decl ( context & c,
Z3_func_decl n )
inline

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

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

Member Function Documentation

◆ accessors()

func_decl_vector accessors ( )
inline

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

4641 {
4642 sort s = range();
4643 assert(s.is_datatype());
4644 unsigned n = Z3_get_datatype_sort_num_constructors(ctx(), s);
4645 unsigned idx = 0;
4646 for (; idx < n; ++idx) {
4647 func_decl f(ctx(), Z3_get_datatype_sort_constructor(ctx(), s, idx));
4648 if (id() == f.id())
4649 break;
4650 }
4651 assert(idx < n);
4652 n = arity();
4653 func_decl_vector as(ctx());
4654 for (unsigned i = 0; i < n; ++i)
4655 as.push_back(func_decl(ctx(), Z3_get_datatype_sort_constructor_accessor(ctx(), s, idx, i)));
4656 return as;
4657 }
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
expr range(expr const &lo, expr const &hi)
Definition z3++.h:4567

◆ arity()

unsigned arity ( ) const
inline

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

915{ 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 accessors(), fixedpoint::add_fact(), domain(), and is_const().

◆ decl_kind()

Z3_decl_kind decl_kind ( ) const
inline

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

919{ 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 916 of file z3++.h.

916{ assert(i < arity()); Z3_sort r = Z3_get_domain(ctx(), *this, i); check_error(); return sort(ctx(), r); }
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 operator()(), operator()(), and operator()().

◆ id()

unsigned id ( ) const
inline

retrieve unique identifier for func_decl.

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

913{ 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 accessors().

◆ is_const()

bool is_const ( ) const
inline

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

927{ return arity() == 0; }

◆ name()

symbol name ( ) const
inline

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

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

◆ num_parameters()

unsigned num_parameters ( ) const
inline

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

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

◆ operator Z3_func_decl()

operator Z3_func_decl ( ) const
inline

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

908{ return reinterpret_cast<Z3_func_decl>(m_ast); }

◆ operator()() [1/11]

expr operator() ( ) const
inline

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

4220 {
4221 Z3_ast r = Z3_mk_app(ctx(), *this, 0, 0);
4222 ctx().check_error();
4223 return expr(ctx(), r);
4224 }
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 4225 of file z3++.h.

4225 {
4226 check_context(*this, a);
4227 Z3_ast args[1] = { a };
4228 Z3_ast r = Z3_mk_app(ctx(), *this, 1, args);
4229 ctx().check_error();
4230 return expr(ctx(), r);
4231 }
void check_context(object const &a, object const &b)
Definition z3++.h:564

◆ operator()() [3/11]

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

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

4238 {
4239 check_context(*this, a1); check_context(*this, a2);
4240 Z3_ast args[2] = { a1, a2 };
4241 Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
4242 ctx().check_error();
4243 return expr(ctx(), r);
4244 }

◆ operator()() [4/11]

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

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

4259 {
4260 check_context(*this, a1); check_context(*this, a2); check_context(*this, a3);
4261 Z3_ast args[3] = { a1, a2, a3 };
4262 Z3_ast r = Z3_mk_app(ctx(), *this, 3, args);
4263 ctx().check_error();
4264 return expr(ctx(), r);
4265 }

◆ operator()() [5/11]

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

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

4266 {
4267 check_context(*this, a1); check_context(*this, a2); check_context(*this, a3); check_context(*this, a4);
4268 Z3_ast args[4] = { a1, a2, a3, a4 };
4269 Z3_ast r = Z3_mk_app(ctx(), *this, 4, args);
4270 ctx().check_error();
4271 return expr(ctx(), r);
4272 }

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

4273 {
4274 check_context(*this, a1); check_context(*this, a2); check_context(*this, a3); check_context(*this, a4); check_context(*this, a5);
4275 Z3_ast args[5] = { a1, a2, a3, a4, a5 };
4276 Z3_ast r = Z3_mk_app(ctx(), *this, 5, args);
4277 ctx().check_error();
4278 return expr(ctx(), r);
4279 }

◆ operator()() [7/11]

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

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

4245 {
4246 check_context(*this, a1);
4247 Z3_ast args[2] = { a1, ctx().num_val(a2, domain(1)) };
4248 Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
4249 ctx().check_error();
4250 return expr(ctx(), r);
4251 }

◆ operator()() [8/11]

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

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

4210 {
4211 array<Z3_ast> _args(args.size());
4212 for (unsigned i = 0; i < args.size(); ++i) {
4213 check_context(*this, args[i]);
4214 _args[i] = args[i];
4215 }
4216 Z3_ast r = Z3_mk_app(ctx(), *this, args.size(), _args.ptr());
4217 check_error();
4218 return expr(ctx(), r);
4219 }

◆ operator()() [9/11]

expr operator() ( int a) const
inline

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

4232 {
4233 Z3_ast args[1] = { ctx().num_val(a, domain(0)) };
4234 Z3_ast r = Z3_mk_app(ctx(), *this, 1, args);
4235 ctx().check_error();
4236 return expr(ctx(), r);
4237 }

◆ operator()() [10/11]

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

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

4252 {
4253 check_context(*this, a2);
4254 Z3_ast args[2] = { ctx().num_val(a1, domain(0)), a2 };
4255 Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
4256 ctx().check_error();
4257 return expr(ctx(), r);
4258 }

◆ operator()() [11/11]

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

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

4199 {
4200 array<Z3_ast> _args(n);
4201 for (unsigned i = 0; i < n; ++i) {
4202 check_context(*this, args[i]);
4203 _args[i] = args[i];
4204 }
4205 Z3_ast r = Z3_mk_app(ctx(), *this, n, _args.ptr());
4206 check_error();
4207 return expr(ctx(), r);
4208
4209 }

◆ range()

sort range ( ) const
inline

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

917{ 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 accessors().

◆ transitive_closure()

func_decl transitive_closure ( func_decl const & )
inline

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

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