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

Constructor & Destructor Documentation

◆ func_decl() [1/2]

func_decl ( context c)
inline

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

809:ast(c) {}
ast(context &c)
Definition z3++.h:602

◆ func_decl() [2/2]

func_decl ( context c,
Z3_func_decl  n 
)
inline

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

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

Member Function Documentation

◆ accessors()

func_decl_vector accessors ( )
inline

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

4367 {
4368 sort s = range();
4369 assert(s.is_datatype());
4370 unsigned n = Z3_get_datatype_sort_num_constructors(ctx(), s);
4371 unsigned idx = 0;
4372 for (; idx < n; ++idx) {
4374 if (id() == f.id())
4375 break;
4376 }
4377 assert(idx < n);
4378 n = arity();
4379 func_decl_vector as(ctx());
4380 for (unsigned i = 0; i < n; ++i)
4381 as.push_back(func_decl(ctx(), Z3_get_datatype_sort_constructor_accessor(ctx(), s, idx, i)));
4382 return as;
4383 }
sort range() const
Definition z3++.h:820
func_decl(context &c)
Definition z3++.h:809
unsigned arity() const
Definition z3++.h:818
context & ctx() const
Definition z3++.h:521
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:78

◆ arity()

unsigned arity ( ) const
inline

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

818{ 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 822 of file z3++.h.

822{ 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 819 of file z3++.h.

819{ 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:522
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 816 of file z3++.h.

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

830{ return arity() == 0; }

◆ name()

symbol name ( ) const
inline

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

821{ 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 823 of file z3++.h.

823{ 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 811 of file z3++.h.

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

◆ operator()() [1/11]

expr operator() ( ) const
inline

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

3994 {
3995 Z3_ast r = Z3_mk_app(ctx(), *this, 0, 0);
3996 ctx().check_error();
3997 return expr(ctx(), r);
3998 }
Z3_error_code check_error() const
Auxiliary method used to check for API usage errors.
Definition z3++.h:222
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 3999 of file z3++.h.

3999 {
4000 check_context(*this, a);
4001 Z3_ast args[1] = { a };
4002 Z3_ast r = Z3_mk_app(ctx(), *this, 1, args);
4003 ctx().check_error();
4004 return expr(ctx(), r);
4005 }
friend void check_context(object const &a, object const &b)
Definition z3++.h:525

◆ operator()() [3/11]

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

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

4012 {
4013 check_context(*this, a1); check_context(*this, a2);
4014 Z3_ast args[2] = { a1, a2 };
4015 Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
4016 ctx().check_error();
4017 return expr(ctx(), r);
4018 }

◆ operator()() [4/11]

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

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

4033 {
4034 check_context(*this, a1); check_context(*this, a2); check_context(*this, a3);
4035 Z3_ast args[3] = { a1, a2, a3 };
4036 Z3_ast r = Z3_mk_app(ctx(), *this, 3, args);
4037 ctx().check_error();
4038 return expr(ctx(), r);
4039 }

◆ operator()() [5/11]

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

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

4040 {
4041 check_context(*this, a1); check_context(*this, a2); check_context(*this, a3); check_context(*this, a4);
4042 Z3_ast args[4] = { a1, a2, a3, a4 };
4043 Z3_ast r = Z3_mk_app(ctx(), *this, 4, args);
4044 ctx().check_error();
4045 return expr(ctx(), r);
4046 }

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

4047 {
4048 check_context(*this, a1); check_context(*this, a2); check_context(*this, a3); check_context(*this, a4); check_context(*this, a5);
4049 Z3_ast args[5] = { a1, a2, a3, a4, a5 };
4050 Z3_ast r = Z3_mk_app(ctx(), *this, 5, args);
4051 ctx().check_error();
4052 return expr(ctx(), r);
4053 }

◆ operator()() [7/11]

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

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

4019 {
4020 check_context(*this, a1);
4021 Z3_ast args[2] = { a1, ctx().num_val(a2, domain(1)) };
4022 Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
4023 ctx().check_error();
4024 return expr(ctx(), r);
4025 }
expr num_val(int n, sort const &s)
Definition z3++.h:3971
sort domain(unsigned i) const
Definition z3++.h:819

◆ operator()() [8/11]

expr operator() ( expr_vector const v) const
inline

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

3984 {
3985 array<Z3_ast> _args(args.size());
3986 for (unsigned i = 0; i < args.size(); i++) {
3987 check_context(*this, args[i]);
3988 _args[i] = args[i];
3989 }
3990 Z3_ast r = Z3_mk_app(ctx(), *this, args.size(), _args.ptr());
3991 check_error();
3992 return expr(ctx(), r);
3993 }

◆ operator()() [9/11]

expr operator() ( int  a) const
inline

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

4006 {
4007 Z3_ast args[1] = { ctx().num_val(a, domain(0)) };
4008 Z3_ast r = Z3_mk_app(ctx(), *this, 1, args);
4009 ctx().check_error();
4010 return expr(ctx(), r);
4011 }

◆ operator()() [10/11]

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

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

4026 {
4027 check_context(*this, a2);
4028 Z3_ast args[2] = { ctx().num_val(a1, domain(0)), a2 };
4029 Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
4030 ctx().check_error();
4031 return expr(ctx(), r);
4032 }

◆ operator()() [11/11]

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

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

3973 {
3974 array<Z3_ast> _args(n);
3975 for (unsigned i = 0; i < n; i++) {
3976 check_context(*this, args[i]);
3977 _args[i] = args[i];
3978 }
3979 Z3_ast r = Z3_mk_app(ctx(), *this, n, _args.ptr());
3980 check_error();
3981 return expr(ctx(), r);
3982
3983 }

◆ range()

sort range ( ) const
inline

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

820{ 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 826 of file z3++.h.

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