Z3
Public Member Functions | Friends
context Class Reference

A Context manages all other Z3 objects, global configuration options, etc. More...

Public Member Functions

 context ()
 
 context (config &c)
 
 ~context ()
 
 operator Z3_context () const
 
Z3_error_code check_error () const
 Auxiliary method used to check for API usage errors. More...
 
void check_parser_error () const
 
void set_enable_exceptions (bool f)
 The C++ API uses by defaults exceptions on errors. For applications that don't work well with exceptions (there should be only few) you have the ability to turn off exceptions. The tradeoffs are that applications have to be very careful about using check_error() after calls that may result in an erroneous state. More...
 
bool enable_exceptions () const
 
void set (char const *param, char const *value)
 Update global parameter param with string value. More...
 
void set (char const *param, bool value)
 Update global parameter param with Boolean value. More...
 
void set (char const *param, int value)
 Update global parameter param with Integer value. More...
 
void interrupt ()
 Interrupt the current procedure being executed by any object managed by this context. This is a soft interruption: there is no guarantee the object will actually stop. More...
 
symbol str_symbol (char const *s)
 Create a Z3 symbol based on the given string. More...
 
symbol int_symbol (int n)
 Create a Z3 symbol based on the given integer. More...
 
sort bool_sort ()
 Return the Boolean sort. More...
 
sort int_sort ()
 Return the integer sort. More...
 
sort real_sort ()
 Return the Real sort. More...
 
sort bv_sort (unsigned sz)
 Return the Bit-vector sort of size sz. That is, the sort for bit-vectors of size sz. More...
 
sort char_sort ()
 Return the sort for Unicode characters. More...
 
sort string_sort ()
 Return the sort for Unicode strings. More...
 
sort seq_sort (sort &s)
 Return a sequence sort over base sort s. More...
 
sort re_sort (sort &seq_sort)
 Return a regular expression sort over sequences seq_sort. More...
 
sort array_sort (sort d, sort r)
 Return an array sort for arrays from d to r. More...
 
sort array_sort (sort_vector const &d, sort r)
 
sort fpa_sort (unsigned ebits, unsigned sbits)
 Return a floating point sort. ebits is a number of exponent bits, sbits is a number of significand bits,. More...
 
template<size_t precision>
sort fpa_sort ()
 Return a FloatingPoint sort with given precision bitwidth (16, 32, 64 or 128). More...
 
sort fpa_rounding_mode_sort ()
 Return a RoundingMode sort. More...
 
void set_rounding_mode (rounding_mode rm)
 Sets RoundingMode of FloatingPoints. More...
 
sort enumeration_sort (char const *name, unsigned n, char const *const *enum_names, func_decl_vector &cs, func_decl_vector &ts)
 Return an enumeration sort: enum_names[0], ..., enum_names[n-1]. cs and ts are output parameters. The method stores in cs the constants corresponding to the enumerated elements, and in ts the predicates for testing if terms of the enumeration sort correspond to an enumeration. More...
 
func_decl tuple_sort (char const *name, unsigned n, char const *const *names, sort const *sorts, func_decl_vector &projs)
 Return a tuple constructor. name is the name of the returned constructor, n are the number of arguments, names and sorts are their projected sorts. projs is an output parameter. It contains the set of projection functions. More...
 
sort uninterpreted_sort (char const *name)
 create an uninterpreted sort with the name given by the string or symbol. More...
 
sort uninterpreted_sort (symbol const &name)
 
func_decl function (symbol const &name, unsigned arity, sort const *domain, sort const &range)
 
func_decl function (char const *name, unsigned arity, sort const *domain, sort const &range)
 
func_decl function (symbol const &name, sort_vector const &domain, sort const &range)
 
func_decl function (char const *name, sort_vector const &domain, sort const &range)
 
func_decl function (char const *name, sort const &domain, sort const &range)
 
func_decl function (char const *name, sort const &d1, sort const &d2, sort const &range)
 
func_decl function (char const *name, sort const &d1, sort const &d2, sort const &d3, sort const &range)
 
func_decl function (char const *name, sort const &d1, sort const &d2, sort const &d3, sort const &d4, sort const &range)
 
func_decl function (char const *name, sort const &d1, sort const &d2, sort const &d3, sort const &d4, sort const &d5, sort const &range)
 
func_decl recfun (symbol const &name, unsigned arity, sort const *domain, sort const &range)
 
func_decl recfun (char const *name, unsigned arity, sort const *domain, sort const &range)
 
func_decl recfun (char const *name, sort const &domain, sort const &range)
 
func_decl recfun (char const *name, sort const &d1, sort const &d2, sort const &range)
 
void recdef (func_decl, expr_vector const &args, expr const &body)
 
func_decl user_propagate_function (symbol const &name, sort_vector const &domain, sort const &range)
 
expr constant (symbol const &name, sort const &s)
 
expr constant (char const *name, sort const &s)
 
expr bool_const (char const *name)
 
expr int_const (char const *name)
 
expr real_const (char const *name)
 
expr string_const (char const *name)
 
expr bv_const (char const *name, unsigned sz)
 
expr fpa_const (char const *name, unsigned ebits, unsigned sbits)
 
template<size_t precision>
expr fpa_const (char const *name)
 
expr fpa_rounding_mode ()
 
expr bool_val (bool b)
 
expr int_val (int n)
 
expr int_val (unsigned n)
 
expr int_val (int64_t n)
 
expr int_val (uint64_t n)
 
expr int_val (char const *n)
 
expr real_val (int n, int d)
 
expr real_val (int n)
 
expr real_val (unsigned n)
 
expr real_val (int64_t n)
 
expr real_val (uint64_t n)
 
expr real_val (char const *n)
 
expr bv_val (int n, unsigned sz)
 
expr bv_val (unsigned n, unsigned sz)
 
expr bv_val (int64_t n, unsigned sz)
 
expr bv_val (uint64_t n, unsigned sz)
 
expr bv_val (char const *n, unsigned sz)
 
expr bv_val (unsigned n, bool const *bits)
 
expr fpa_val (double n)
 
expr fpa_val (float n)
 
expr fpa_nan (sort const &s)
 
expr fpa_inf (sort const &s, bool sgn)
 
expr string_val (char const *s)
 
expr string_val (char const *s, unsigned n)
 
expr string_val (std::string const &s)
 
expr string_val (std::u32string const &s)
 
expr num_val (int n, sort const &s)
 
expr_vector parse_string (char const *s)
 parsing More...
 
expr_vector parse_file (char const *file)
 
expr_vector parse_string (char const *s, sort_vector const &sorts, func_decl_vector const &decls)
 
expr_vector parse_file (char const *s, sort_vector const &sorts, func_decl_vector const &decls)
 
template<>
sort fpa_sort ()
 
template<>
sort fpa_sort ()
 
template<>
sort fpa_sort ()
 
template<>
sort fpa_sort ()
 

Friends

class user_propagator_base
 

Detailed Description

A Context manages all other Z3 objects, global configuration options, etc.

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

Constructor & Destructor Documentation

◆ context() [1/2]

context ( )
inline

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

181 { config c; init(c); }

◆ context() [2/2]

context ( config c)
inline

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

182 { init(c); }

◆ ~context()

~context ( )
inline

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

183 { if (m_ctx) Z3_del_context(m_ctx); }
void Z3_API Z3_del_context(Z3_context c)
Delete the given logical context.

Member Function Documentation

◆ array_sort() [1/2]

sort array_sort ( sort  d,
sort  r 
)
inline

Return an array sort for arrays from d to r.

Example: Given a context c, c.array_sort(c.int_sort(), c.bool_sort()) is an array sort from integer to Boolean.

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

3303 { Z3_sort s = Z3_mk_array_sort(m_ctx, d, r); check_error(); return sort(*this, s); }
Z3_error_code check_error() const
Auxiliary method used to check for API usage errors.
Definition: z3++.h:189
Z3_sort Z3_API Z3_mk_array_sort(Z3_context c, Z3_sort domain, Z3_sort range)
Create an array type.

◆ array_sort() [2/2]

sort array_sort ( sort_vector const &  d,
sort  r 
)
inline

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

3304  {
3305  array<Z3_sort> dom(d);
3306  Z3_sort s = Z3_mk_array_sort_n(m_ctx, dom.size(), dom.ptr(), r); check_error(); return sort(*this, s);
3307  }
Z3_sort Z3_API Z3_mk_array_sort_n(Z3_context c, unsigned n, Z3_sort const *domain, Z3_sort range)
Create an array type with N arguments.

◆ bool_const()

expr bool_const ( char const *  name)
inline

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

3456 { return constant(name, bool_sort()); }
sort bool_sort()
Return the Boolean sort.
Definition: z3++.h:3279
expr constant(symbol const &name, sort const &s)
Definition: z3++.h:3450

◆ bool_sort()

sort bool_sort ( )
inline

Return the Boolean sort.

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

3279 { Z3_sort s = Z3_mk_bool_sort(m_ctx); check_error(); return sort(*this, s); }
Z3_sort Z3_API Z3_mk_bool_sort(Z3_context c)
Create the Boolean type.

Referenced by context::bool_const().

◆ bool_val()

expr bool_val ( bool  b)
inline

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

3479 { return b ? expr(*this, Z3_mk_true(m_ctx)) : expr(*this, Z3_mk_false(m_ctx)); }
Z3_ast Z3_API Z3_mk_true(Z3_context c)
Create an AST node representing true.
Z3_ast Z3_API Z3_mk_false(Z3_context c)
Create an AST node representing false.

Referenced by goal::as_expr(), user_propagator_base::conflict(), and solver::to_smt2().

◆ bv_const()

expr bv_const ( char const *  name,
unsigned  sz 
)
inline

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

3460 { return constant(name, bv_sort(sz)); }
sort bv_sort(unsigned sz)
Return the Bit-vector sort of size sz. That is, the sort for bit-vectors of size sz.
Definition: z3++.h:3282

◆ bv_sort()

sort bv_sort ( unsigned  sz)
inline

Return the Bit-vector sort of size sz. That is, the sort for bit-vectors of size sz.

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

3282 { Z3_sort s = Z3_mk_bv_sort(m_ctx, sz); check_error(); return sort(*this, s); }
Z3_sort Z3_API Z3_mk_bv_sort(Z3_context c, unsigned sz)
Create a bit-vector type of the given size.

Referenced by context::bv_const(), and context::bv_val().

◆ bv_val() [1/6]

expr bv_val ( char const *  n,
unsigned  sz 
)
inline

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

3498 { sort s = bv_sort(sz); Z3_ast r = Z3_mk_numeral(m_ctx, n, s); check_error(); return expr(*this, r); }
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.

◆ bv_val() [2/6]

expr bv_val ( int  n,
unsigned  sz 
)
inline

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

3494 { sort s = bv_sort(sz); Z3_ast r = Z3_mk_int(m_ctx, n, s); check_error(); return expr(*this, r); }
Z3_ast Z3_API Z3_mk_int(Z3_context c, int v, Z3_sort ty)
Create a numeral of an int, bit-vector, or finite-domain sort.

◆ bv_val() [3/6]

expr bv_val ( int64_t  n,
unsigned  sz 
)
inline

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

3496 { sort s = bv_sort(sz); Z3_ast r = Z3_mk_int64(m_ctx, n, s); check_error(); return expr(*this, r); }
Z3_ast Z3_API Z3_mk_int64(Z3_context c, int64_t v, Z3_sort ty)
Create a numeral of a int, bit-vector, or finite-domain sort.

◆ bv_val() [4/6]

expr bv_val ( uint64_t  n,
unsigned  sz 
)
inline

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

3497 { sort s = bv_sort(sz); Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, s); check_error(); return expr(*this, r); }
Z3_ast Z3_API Z3_mk_unsigned_int64(Z3_context c, uint64_t v, Z3_sort ty)
Create a numeral of a int, bit-vector, or finite-domain sort.

◆ bv_val() [5/6]

expr bv_val ( unsigned  n,
bool const *  bits 
)
inline

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

3499  {
3500  array<bool> _bits(n);
3501  for (unsigned i = 0; i < n; ++i) _bits[i] = bits[i] ? 1 : 0;
3502  Z3_ast r = Z3_mk_bv_numeral(m_ctx, n, _bits.ptr()); check_error(); return expr(*this, r);
3503  }
Z3_ast Z3_API Z3_mk_bv_numeral(Z3_context c, unsigned sz, bool const *bits)
create a bit-vector numeral from a vector of Booleans.

◆ bv_val() [6/6]

expr bv_val ( unsigned  n,
unsigned  sz 
)
inline

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

3495 { sort s = bv_sort(sz); Z3_ast r = Z3_mk_unsigned_int(m_ctx, n, s); check_error(); return expr(*this, r); }
Z3_ast Z3_API Z3_mk_unsigned_int(Z3_context c, unsigned v, Z3_sort ty)
Create a numeral of a int, bit-vector, or finite-domain sort.

◆ char_sort()

sort char_sort ( )
inline

Return the sort for Unicode characters.

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

3284 { Z3_sort s = Z3_mk_char_sort(m_ctx); check_error(); return sort(*this, s); }
Z3_sort Z3_API Z3_mk_char_sort(Z3_context c)
Create a sort for unicode characters.

◆ check_error()

Z3_error_code check_error ( ) const
inline

Auxiliary method used to check for API usage errors.

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

189  {
190  Z3_error_code e = Z3_get_error_code(m_ctx);
191  if (e != Z3_OK && enable_exceptions())
192  Z3_THROW(exception(Z3_get_error_msg(m_ctx, e)));
193  return e;
194  }
bool enable_exceptions() const
Definition: z3++.h:209
Z3_string Z3_API Z3_get_error_msg(Z3_context c, Z3_error_code err)
Return a string describing the given error code.
Z3_error_code
Z3 error codes (See Z3_get_error_code).
Definition: z3_api.h:1384
Z3_error_code Z3_API Z3_get_error_code(Z3_context c)
Return the error code for the last API call.
@ Z3_OK
Definition: z3_api.h:1385
#define Z3_THROW(x)
Definition: z3++.h:101

Referenced by context::array_sort(), expr::bit2bool(), context::bool_sort(), context::bv_sort(), context::bv_val(), context::char_sort(), object::check_error(), context::check_parser_error(), context::constant(), context::enumeration_sort(), expr::extract(), context::fpa_inf(), context::fpa_nan(), context::fpa_rounding_mode_sort(), context::fpa_sort(), context::fpa_val(), context::function(), context::int_sort(), context::int_symbol(), context::int_val(), context::num_val(), func_decl::operator()(), context::parse_file(), context::parse_string(), z3::re_diff(), z3::re_intersect(), context::re_sort(), context::real_sort(), context::real_val(), context::recfun(), expr::repeat(), expr::rotate_left(), expr::rotate_right(), context::seq_sort(), context::str_symbol(), context::string_sort(), context::string_val(), z3::to_expr(), z3::to_func_decl(), z3::to_sort(), context::tuple_sort(), and context::user_propagate_function().

◆ check_parser_error()

void check_parser_error ( ) const
inline

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

196  {
197  check_error();
198  }

Referenced by solver::from_file(), and solver::from_string().

◆ constant() [1/2]

expr constant ( char const *  name,
sort const &  s 
)
inline

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

3455 { return constant(str_symbol(name), s); }
symbol str_symbol(char const *s)
Create a Z3 symbol based on the given string.
Definition: z3++.h:3276

◆ constant() [2/2]

expr constant ( symbol const &  name,
sort const &  s 
)
inline

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

3450  {
3451  Z3_ast r = Z3_mk_const(m_ctx, name, s);
3452  check_error();
3453  return expr(*this, r);
3454  }
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.

Referenced by context::bool_const(), context::bv_const(), context::constant(), context::fpa_const(), context::int_const(), context::real_const(), and context::string_const().

◆ enable_exceptions()

bool enable_exceptions ( ) const
inline

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

209 { return m_enable_exceptions; }

Referenced by context::check_error().

◆ enumeration_sort()

sort enumeration_sort ( char const *  name,
unsigned  n,
char const *const *  enum_names,
func_decl_vector cs,
func_decl_vector ts 
)
inline

Return an enumeration sort: enum_names[0], ..., enum_names[n-1]. cs and ts are output parameters. The method stores in cs the constants corresponding to the enumerated elements, and in ts the predicates for testing if terms of the enumeration sort correspond to an enumeration.

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

3308  {
3309  array<Z3_symbol> _enum_names(n);
3310  for (unsigned i = 0; i < n; i++) { _enum_names[i] = Z3_mk_string_symbol(*this, enum_names[i]); }
3311  array<Z3_func_decl> _cs(n);
3312  array<Z3_func_decl> _ts(n);
3313  Z3_symbol _name = Z3_mk_string_symbol(*this, name);
3314  sort s = to_sort(*this, Z3_mk_enumeration_sort(*this, _name, n, _enum_names.ptr(), _cs.ptr(), _ts.ptr()));
3315  check_error();
3316  for (unsigned i = 0; i < n; i++) { cs.push_back(func_decl(*this, _cs[i])); ts.push_back(func_decl(*this, _ts[i])); }
3317  return s;
3318  }
Z3_sort Z3_API Z3_mk_enumeration_sort(Z3_context c, Z3_symbol name, unsigned n, Z3_symbol const enum_names[], Z3_func_decl enum_consts[], Z3_func_decl enum_testers[])
Create a enumeration sort.
Z3_symbol Z3_API Z3_mk_string_symbol(Z3_context c, Z3_string s)
Create a Z3 symbol using a C string.
sort to_sort(context &c, Z3_sort s)
Definition: z3++.h:2053

◆ fpa_const() [1/2]

expr fpa_const ( char const *  name)
inline

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

3464 { return constant(name, fpa_sort<precision>()); }

◆ fpa_const() [2/2]

expr fpa_const ( char const *  name,
unsigned  ebits,
unsigned  sbits 
)
inline

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

3461 { return constant(name, fpa_sort(ebits, sbits)); }
sort fpa_sort()
Return a FloatingPoint sort with given precision bitwidth (16, 32, 64 or 128).

◆ fpa_inf()

expr fpa_inf ( sort const &  s,
bool  sgn 
)
inline

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

3508 { Z3_ast r = Z3_mk_fpa_inf(m_ctx, s, sgn); check_error(); return expr(*this, r); }
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, bool negative)
Create a floating-point infinity of sort s.

◆ fpa_nan()

expr fpa_nan ( sort const &  s)
inline

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

3507 { Z3_ast r = Z3_mk_fpa_nan(m_ctx, s); check_error(); return expr(*this, r); }
Z3_ast Z3_API Z3_mk_fpa_nan(Z3_context c, Z3_sort s)
Create a floating-point NaN of sort s.

◆ fpa_rounding_mode()

expr fpa_rounding_mode ( )
inline

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

3468  {
3469  switch (m_rounding_mode) {
3470  case RNA: return expr(*this, Z3_mk_fpa_rna(m_ctx));
3471  case RNE: return expr(*this, Z3_mk_fpa_rne(m_ctx));
3472  case RTP: return expr(*this, Z3_mk_fpa_rtp(m_ctx));
3473  case RTN: return expr(*this, Z3_mk_fpa_rtn(m_ctx));
3474  case RTZ: return expr(*this, Z3_mk_fpa_rtz(m_ctx));
3475  default: return expr(*this);
3476  }
3477  }
Z3_ast Z3_API Z3_mk_fpa_rna(Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
Z3_ast Z3_API Z3_mk_fpa_rtn(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardNegative rounding mode.
Z3_ast Z3_API Z3_mk_fpa_rtp(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardPositive rounding mode.
Z3_ast Z3_API Z3_mk_fpa_rtz(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardZero rounding mode.
Z3_ast Z3_API Z3_mk_fpa_rne(Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
@ RNE
Definition: z3++.h:139
@ RNA
Definition: z3++.h:138
@ RTZ
Definition: z3++.h:142
@ RTN
Definition: z3++.h:141
@ RTP
Definition: z3++.h:140

◆ fpa_rounding_mode_sort()

sort fpa_rounding_mode_sort ( )
inline

Return a RoundingMode sort.

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

3301 { Z3_sort r = Z3_mk_fpa_rounding_mode_sort(m_ctx); check_error(); return sort(*this, r); }
Z3_sort Z3_API Z3_mk_fpa_rounding_mode_sort(Z3_context c)
Create the RoundingMode sort.

◆ fpa_sort() [1/6]

sort fpa_sort ( )

Return a FloatingPoint sort with given precision bitwidth (16, 32, 64 or 128).

Referenced by context::fpa_const().

◆ fpa_sort() [2/6]

sort fpa_sort ( )
inline

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

3290 { return fpa_sort(5, 11); }

Referenced by context::fpa_sort().

◆ fpa_sort() [3/6]

sort fpa_sort ( )
inline

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

3293 { return fpa_sort(8, 24); }

Referenced by context::fpa_sort().

◆ fpa_sort() [4/6]

sort fpa_sort ( )
inline

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

3296 { return fpa_sort(11, 53); }

Referenced by context::fpa_sort().

◆ fpa_sort() [5/6]

sort fpa_sort ( )
inline

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

3299 { return fpa_sort(15, 113); }

Referenced by context::fpa_sort().

◆ fpa_sort() [6/6]

sort fpa_sort ( unsigned  ebits,
unsigned  sbits 
)
inline

Return a floating point sort. ebits is a number of exponent bits, sbits is a number of significand bits,.

Precondition
where ebits must be larger than 1 and sbits must be larger than 2.

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

3287 { Z3_sort s = Z3_mk_fpa_sort(m_ctx, ebits, sbits); check_error(); return sort(*this, s); }
Z3_sort Z3_API Z3_mk_fpa_sort(Z3_context c, unsigned ebits, unsigned sbits)
Create a FloatingPoint sort.

◆ fpa_val() [1/2]

expr fpa_val ( double  n)
inline

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

3505 { sort s = fpa_sort<64>(); Z3_ast r = Z3_mk_fpa_numeral_double(m_ctx, n, s); check_error(); return expr(*this, r); }
Z3_ast Z3_API Z3_mk_fpa_numeral_double(Z3_context c, double v, Z3_sort ty)
Create a numeral of FloatingPoint sort from a double.

Referenced by z3::operator!=(), and z3::operator==().

◆ fpa_val() [2/2]

expr fpa_val ( float  n)
inline

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

3506 { sort s = fpa_sort<32>(); Z3_ast r = Z3_mk_fpa_numeral_float(m_ctx, n, s); check_error(); return expr(*this, r); }
Z3_ast Z3_API Z3_mk_fpa_numeral_float(Z3_context c, float v, Z3_sort ty)
Create a numeral of FloatingPoint sort from a float.

◆ function() [1/9]

func_decl function ( char const *  name,
sort const &  d1,
sort const &  d2,
sort const &  d3,
sort const &  d4,
sort const &  d5,
sort const &  range 
)
inline

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

3403  {
3405  Z3_sort args[5] = { d1, d2, d3, d4, d5 };
3406  Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 5, args, range);
3407  check_error();
3408  return func_decl(*this, f);
3409  }
Z3_func_decl Z3_API Z3_mk_func_decl(Z3_context c, Z3_symbol s, unsigned domain_size, Z3_sort const domain[], Z3_sort range)
Declare a constant or function.
void check_context(object const &a, object const &b)
Definition: z3++.h:426
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3824

◆ function() [2/9]

func_decl function ( char const *  name,
sort const &  d1,
sort const &  d2,
sort const &  d3,
sort const &  d4,
sort const &  range 
)
inline

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

3395  {
3397  Z3_sort args[4] = { d1, d2, d3, d4 };
3398  Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 4, args, range);
3399  check_error();
3400  return func_decl(*this, f);
3401  }

◆ function() [3/9]

func_decl function ( char const *  name,
sort const &  d1,
sort const &  d2,
sort const &  d3,
sort const &  range 
)
inline

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

3387  {
3389  Z3_sort args[3] = { d1, d2, d3 };
3390  Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 3, args, range);
3391  check_error();
3392  return func_decl(*this, f);
3393  }

◆ function() [4/9]

func_decl function ( char const *  name,
sort const &  d1,
sort const &  d2,
sort const &  range 
)
inline

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

3379  {
3381  Z3_sort args[2] = { d1, d2 };
3382  Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 2, args, range);
3383  check_error();
3384  return func_decl(*this, f);
3385  }

◆ function() [5/9]

func_decl function ( char const *  name,
sort const &  domain,
sort const &  range 
)
inline

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

3371  {
3372  check_context(domain, range);
3373  Z3_sort args[1] = { domain };
3374  Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 1, args, range);
3375  check_error();
3376  return func_decl(*this, f);
3377  }

◆ function() [6/9]

func_decl function ( char const *  name,
sort_vector const &  domain,
sort const &  range 
)
inline

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

3366  {
3367  return function(range.ctx().str_symbol(name), domain, range);
3368  }
context & ctx() const
Definition: z3++.h:422

◆ function() [7/9]

func_decl function ( char const *  name,
unsigned  arity,
sort const *  domain,
sort const &  range 
)
inline

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

3351  {
3352  return function(range.ctx().str_symbol(name), arity, domain, range);
3353  }

◆ function() [8/9]

func_decl function ( symbol const &  name,
sort_vector const &  domain,
sort const &  range 
)
inline

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

3355  {
3356  array<Z3_sort> args(domain.size());
3357  for (unsigned i = 0; i < domain.size(); i++) {
3358  check_context(domain[i], range);
3359  args[i] = domain[i];
3360  }
3361  Z3_func_decl f = Z3_mk_func_decl(m_ctx, name, domain.size(), args.ptr(), range);
3362  check_error();
3363  return func_decl(*this, f);
3364  }

◆ function() [9/9]

func_decl function ( symbol const &  name,
unsigned  arity,
sort const *  domain,
sort const &  range 
)
inline

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

3340  {
3341  array<Z3_sort> args(arity);
3342  for (unsigned i = 0; i < arity; i++) {
3343  check_context(domain[i], range);
3344  args[i] = domain[i];
3345  }
3346  Z3_func_decl f = Z3_mk_func_decl(m_ctx, name, arity, args.ptr(), range);
3347  check_error();
3348  return func_decl(*this, f);
3349  }

Referenced by z3::function().

◆ int_const()

expr int_const ( char const *  name)
inline

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

3457 { return constant(name, int_sort()); }
sort int_sort()
Return the integer sort.
Definition: z3++.h:3280

◆ int_sort()

sort int_sort ( )
inline

Return the integer sort.

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

3280 { Z3_sort s = Z3_mk_int_sort(m_ctx); check_error(); return sort(*this, s); }
Z3_sort Z3_API Z3_mk_int_sort(Z3_context c)
Create the integer type.

Referenced by context::int_const(), and context::int_val().

◆ int_symbol()

symbol int_symbol ( int  n)
inline

Create a Z3 symbol based on the given integer.

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

3277 { Z3_symbol r = Z3_mk_int_symbol(m_ctx, n); check_error(); return symbol(*this, r); }
Z3_symbol Z3_API Z3_mk_int_symbol(Z3_context c, int i)
Create a Z3 symbol using an integer.

◆ int_val() [1/5]

expr int_val ( char const *  n)
inline

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

3485 { Z3_ast r = Z3_mk_numeral(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }

◆ int_val() [2/5]

expr int_val ( int  n)
inline

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

3481 { Z3_ast r = Z3_mk_int(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }

◆ int_val() [3/5]

expr int_val ( int64_t  n)
inline

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

3483 { Z3_ast r = Z3_mk_int64(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }

◆ int_val() [4/5]

expr int_val ( uint64_t  n)
inline

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

3484 { Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }

◆ int_val() [5/5]

expr int_val ( unsigned  n)
inline

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

3482 { Z3_ast r = Z3_mk_unsigned_int(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }

◆ interrupt()

void interrupt ( )
inline

Interrupt the current procedure being executed by any object managed by this context. This is a soft interruption: there is no guarantee the object will actually stop.

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

231 { Z3_interrupt(m_ctx); }
void Z3_API Z3_interrupt(Z3_context c)
Interrupt the execution of a Z3 procedure. This procedure can be used to interrupt: solvers,...

◆ num_val()

expr num_val ( int  n,
sort const &  s 
)
inline

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

3515 { Z3_ast r = Z3_mk_int(m_ctx, n, s); check_error(); return expr(*this, r); }

Referenced by z3::ashr(), z3::lshr(), func_decl::operator()(), z3::select(), z3::sge(), z3::sgt(), z3::shl(), z3::sle(), z3::slt(), z3::smod(), z3::srem(), z3::store(), z3::udiv(), z3::uge(), z3::ugt(), z3::ule(), z3::ult(), and z3::urem().

◆ operator Z3_context()

operator Z3_context ( ) const
inline

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

184 { return m_ctx; }

◆ parse_file() [1/2]

expr_vector parse_file ( char const *  file)
inline

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

3841  {
3842  Z3_ast_vector r = Z3_parse_smtlib2_file(*this, s, 0, 0, 0, 0, 0, 0);
3843  check_error();
3844  return expr_vector(*this, r);
3845  }
Z3_ast_vector Z3_API Z3_parse_smtlib2_file(Z3_context c, Z3_string file_name, unsigned num_sorts, Z3_symbol const sort_names[], Z3_sort const sorts[], unsigned num_decls, Z3_symbol const decl_names[], Z3_func_decl const decls[])
Similar to Z3_parse_smtlib2_string, but reads the benchmark from a file.
ast_vector_tpl< expr > expr_vector
Definition: z3++.h:74

◆ parse_file() [2/2]

expr_vector parse_file ( char const *  s,
sort_vector const &  sorts,
func_decl_vector const &  decls 
)
inline

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

3864  {
3865  array<Z3_symbol> sort_names(sorts.size());
3866  array<Z3_symbol> decl_names(decls.size());
3867  array<Z3_sort> sorts1(sorts);
3868  array<Z3_func_decl> decls1(decls);
3869  for (unsigned i = 0; i < sorts.size(); ++i) {
3870  sort_names[i] = sorts[i].name();
3871  }
3872  for (unsigned i = 0; i < decls.size(); ++i) {
3873  decl_names[i] = decls[i].name();
3874  }
3875  Z3_ast_vector r = Z3_parse_smtlib2_file(*this, s, sorts.size(), sort_names.ptr(), sorts1.ptr(), decls.size(), decl_names.ptr(), decls1.ptr());
3876  check_error();
3877  return expr_vector(*this, r);
3878  }

◆ parse_string() [1/2]

expr_vector parse_string ( char const *  s)
inline

parsing

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

3835  {
3836  Z3_ast_vector r = Z3_parse_smtlib2_string(*this, s, 0, 0, 0, 0, 0, 0);
3837  check_error();
3838  return expr_vector(*this, r);
3839 
3840  }
Z3_ast_vector Z3_API Z3_parse_smtlib2_string(Z3_context c, Z3_string str, unsigned num_sorts, Z3_symbol const sort_names[], Z3_sort const sorts[], unsigned num_decls, Z3_symbol const decl_names[], Z3_func_decl const decls[])
Parse the given string using the SMT-LIB2 parser.

◆ parse_string() [2/2]

expr_vector parse_string ( char const *  s,
sort_vector const &  sorts,
func_decl_vector const &  decls 
)
inline

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

3847  {
3848  array<Z3_symbol> sort_names(sorts.size());
3849  array<Z3_symbol> decl_names(decls.size());
3850  array<Z3_sort> sorts1(sorts);
3851  array<Z3_func_decl> decls1(decls);
3852  for (unsigned i = 0; i < sorts.size(); ++i) {
3853  sort_names[i] = sorts[i].name();
3854  }
3855  for (unsigned i = 0; i < decls.size(); ++i) {
3856  decl_names[i] = decls[i].name();
3857  }
3858 
3859  Z3_ast_vector r = Z3_parse_smtlib2_string(*this, s, sorts.size(), sort_names.ptr(), sorts1.ptr(), decls.size(), decl_names.ptr(), decls1.ptr());
3860  check_error();
3861  return expr_vector(*this, r);
3862  }

◆ re_sort()

sort re_sort ( sort seq_sort)
inline

Return a regular expression sort over sequences seq_sort.

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

3286 { Z3_sort r = Z3_mk_re_sort(m_ctx, s); check_error(); return sort(*this, r); }
Z3_sort Z3_API Z3_mk_re_sort(Z3_context c, Z3_sort seq)
Create a regular expression sort out of a sequence sort.

◆ real_const()

expr real_const ( char const *  name)
inline

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

3458 { return constant(name, real_sort()); }
sort real_sort()
Return the Real sort.
Definition: z3++.h:3281

◆ real_sort()

sort real_sort ( )
inline

Return the Real sort.

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

3281 { Z3_sort s = Z3_mk_real_sort(m_ctx); check_error(); return sort(*this, s); }
Z3_sort Z3_API Z3_mk_real_sort(Z3_context c)
Create the real type.

Referenced by context::real_const(), and context::real_val().

◆ real_val() [1/6]

expr real_val ( char const *  n)
inline

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

3492 { Z3_ast r = Z3_mk_numeral(m_ctx, n, real_sort()); check_error(); return expr(*this, r); }

◆ real_val() [2/6]

expr real_val ( int  n)
inline

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

3488 { Z3_ast r = Z3_mk_int(m_ctx, n, real_sort()); check_error(); return expr(*this, r); }

◆ real_val() [3/6]

expr real_val ( int  n,
int  d 
)
inline

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

3487 { Z3_ast r = Z3_mk_real(m_ctx, n, d); check_error(); return expr(*this, r); }
Z3_ast Z3_API Z3_mk_real(Z3_context c, int num, int den)
Create a real from a fraction.

◆ real_val() [4/6]

expr real_val ( int64_t  n)
inline

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

3490 { Z3_ast r = Z3_mk_int64(m_ctx, n, real_sort()); check_error(); return expr(*this, r); }

◆ real_val() [5/6]

expr real_val ( uint64_t  n)
inline

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

3491 { Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, real_sort()); check_error(); return expr(*this, r); }

◆ real_val() [6/6]

expr real_val ( unsigned  n)
inline

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

3489 { Z3_ast r = Z3_mk_unsigned_int(m_ctx, n, real_sort()); check_error(); return expr(*this, r); }

◆ recdef()

void recdef ( func_decl  f,
expr_vector const &  args,
expr const &  body 
)
inline

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

3436  {
3437  check_context(f, args); check_context(f, body);
3438  array<Z3_ast> vars(args);
3439  Z3_add_rec_def(f.ctx(), f, vars.size(), vars.ptr(), body);
3440  }
void Z3_API Z3_add_rec_def(Z3_context c, Z3_func_decl f, unsigned n, Z3_ast args[], Z3_ast body)
Define the body of a recursive function.

◆ recfun() [1/4]

func_decl recfun ( char const *  name,
sort const &  d1,
sort const &  d2,
sort const &  range 
)
inline

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

3431  {
3432  sort dom[2] = { d1, d2 };
3433  return recfun(str_symbol(name), 2, dom, range);
3434  }
func_decl recfun(symbol const &name, unsigned arity, sort const *domain, sort const &range)
Definition: z3++.h:3411

◆ recfun() [2/4]

func_decl recfun ( char const *  name,
sort const &  domain,
sort const &  range 
)
inline

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

3427  {
3428  return recfun(str_symbol(name), 1, &d1, range);
3429  }

◆ recfun() [3/4]

func_decl recfun ( char const *  name,
unsigned  arity,
sort const *  domain,
sort const &  range 
)
inline

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

3423  {
3424  return recfun(str_symbol(name), arity, domain, range);
3425  }

◆ recfun() [4/4]

func_decl recfun ( symbol const &  name,
unsigned  arity,
sort const *  domain,
sort const &  range 
)
inline

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

3411  {
3412  array<Z3_sort> args(arity);
3413  for (unsigned i = 0; i < arity; i++) {
3414  check_context(domain[i], range);
3415  args[i] = domain[i];
3416  }
3417  Z3_func_decl f = Z3_mk_rec_func_decl(m_ctx, name, arity, args.ptr(), range);
3418  check_error();
3419  return func_decl(*this, f);
3420 
3421  }
Z3_func_decl Z3_API Z3_mk_rec_func_decl(Z3_context c, Z3_symbol s, unsigned domain_size, Z3_sort const domain[], Z3_sort range)
Declare a recursive function.

Referenced by context::recfun(), and z3::recfun().

◆ seq_sort()

sort seq_sort ( sort s)
inline

Return a sequence sort over base sort s.

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

3285 { Z3_sort r = Z3_mk_seq_sort(m_ctx, s); check_error(); return sort(*this, r); }
Z3_sort Z3_API Z3_mk_seq_sort(Z3_context c, Z3_sort s)
Create a sequence sort out of the sort for the elements.

◆ set() [1/3]

void set ( char const *  param,
bool  value 
)
inline

Update global parameter param with Boolean value.

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

218 { Z3_update_param_value(m_ctx, param, value ? "true" : "false"); }
void Z3_API Z3_update_param_value(Z3_context c, Z3_string param_id, Z3_string param_value)
Set a value of a context parameter.

◆ set() [2/3]

void set ( char const *  param,
char const *  value 
)
inline

Update global parameter param with string value.

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

214 { Z3_update_param_value(m_ctx, param, value); }

◆ set() [3/3]

void set ( char const *  param,
int  value 
)
inline

Update global parameter param with Integer value.

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

222  {
223  auto str = std::to_string(value);
224  Z3_update_param_value(m_ctx, param, str.c_str());
225  }

◆ set_enable_exceptions()

void set_enable_exceptions ( bool  f)
inline

The C++ API uses by defaults exceptions on errors. For applications that don't work well with exceptions (there should be only few) you have the ability to turn off exceptions. The tradeoffs are that applications have to be very careful about using check_error() after calls that may result in an erroneous state.

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

207 { m_enable_exceptions = f; }

◆ set_rounding_mode()

void set_rounding_mode ( rounding_mode  rm)
inline

Sets RoundingMode of FloatingPoints.

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

3466 { m_rounding_mode = rm; }

◆ str_symbol()

symbol str_symbol ( char const *  s)
inline

Create a Z3 symbol based on the given string.

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

3276 { Z3_symbol r = Z3_mk_string_symbol(m_ctx, s); check_error(); return symbol(*this, r); }

Referenced by context::constant(), context::function(), context::recfun(), and solver::solver().

◆ string_const()

expr string_const ( char const *  name)
inline

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

3459 { return constant(name, string_sort()); }
sort string_sort()
Return the sort for Unicode strings.
Definition: z3++.h:3283

◆ string_sort()

sort string_sort ( )
inline

Return the sort for Unicode strings.

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

3283 { Z3_sort s = Z3_mk_string_sort(m_ctx); check_error(); return sort(*this, s); }
Z3_sort Z3_API Z3_mk_string_sort(Z3_context c)
Create a sort for unicode strings.

Referenced by context::string_const().

◆ string_val() [1/4]

expr string_val ( char const *  s)
inline

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

3511 { Z3_ast r = Z3_mk_string(m_ctx, s); check_error(); return expr(*this, r); }
Z3_ast Z3_API Z3_mk_string(Z3_context c, Z3_string s)
Create a string constant out of the string that is passed in The string may contain escape encoding f...

◆ string_val() [2/4]

expr string_val ( char const *  s,
unsigned  n 
)
inline

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

3510 { Z3_ast r = Z3_mk_lstring(m_ctx, n, s); check_error(); return expr(*this, r); }
Z3_ast Z3_API Z3_mk_lstring(Z3_context c, unsigned len, Z3_string s)
Create a string constant out of the string that is passed in It takes the length of the string as wel...

◆ string_val() [3/4]

expr string_val ( std::string const &  s)
inline

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

3512 { Z3_ast r = Z3_mk_string(m_ctx, s.c_str()); check_error(); return expr(*this, r); }

◆ string_val() [4/4]

expr string_val ( std::u32string const &  s)
inline

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

3513 { Z3_ast r = Z3_mk_u32string(m_ctx, (unsigned)s.size(), (unsigned const*)s.c_str()); check_error(); return expr(*this, r); }
Z3_ast Z3_API Z3_mk_u32string(Z3_context c, unsigned len, unsigned const chars[])
Create a string constant out of the string that is passed in It takes the length of the string as wel...

◆ tuple_sort()

func_decl tuple_sort ( char const *  name,
unsigned  n,
char const *const *  names,
sort const *  sorts,
func_decl_vector projs 
)
inline

Return a tuple constructor. name is the name of the returned constructor, n are the number of arguments, names and sorts are their projected sorts. projs is an output parameter. It contains the set of projection functions.

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

3319  {
3320  array<Z3_symbol> _names(n);
3321  array<Z3_sort> _sorts(n);
3322  for (unsigned i = 0; i < n; i++) { _names[i] = Z3_mk_string_symbol(*this, names[i]); _sorts[i] = sorts[i]; }
3323  array<Z3_func_decl> _projs(n);
3324  Z3_symbol _name = Z3_mk_string_symbol(*this, name);
3325  Z3_func_decl tuple;
3326  sort _ignore_s = to_sort(*this, Z3_mk_tuple_sort(*this, _name, n, _names.ptr(), _sorts.ptr(), &tuple, _projs.ptr()));
3327  check_error();
3328  for (unsigned i = 0; i < n; i++) { projs.push_back(func_decl(*this, _projs[i])); }
3329  return func_decl(*this, tuple);
3330  }
Z3_sort Z3_API Z3_mk_tuple_sort(Z3_context c, Z3_symbol mk_tuple_name, unsigned num_fields, Z3_symbol const field_names[], Z3_sort const field_sorts[], Z3_func_decl *mk_tuple_decl, Z3_func_decl proj_decl[])
Create a tuple type.

◆ uninterpreted_sort() [1/2]

sort uninterpreted_sort ( char const *  name)
inline

create an uninterpreted sort with the name given by the string or symbol.

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

3332  {
3333  Z3_symbol _name = Z3_mk_string_symbol(*this, name);
3334  return to_sort(*this, Z3_mk_uninterpreted_sort(*this, _name));
3335  }
Z3_sort Z3_API Z3_mk_uninterpreted_sort(Z3_context c, Z3_symbol s)
Create a free (uninterpreted) type using the given name (symbol).

◆ uninterpreted_sort() [2/2]

sort uninterpreted_sort ( symbol const &  name)
inline

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

3336  {
3337  return to_sort(*this, Z3_mk_uninterpreted_sort(*this, name));
3338  }

◆ user_propagate_function()

func_decl user_propagate_function ( symbol const &  name,
sort_vector const &  domain,
sort const &  range 
)
inline

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

3442  {
3443  check_context(domain, range);
3444  array<Z3_sort> domain1(domain);
3445  Z3_func_decl f = Z3_solver_propagate_declare(range.ctx(), name, domain1.size(), domain1.ptr(), range);
3446  check_error();
3447  return func_decl(*this, f);
3448  }
Z3_func_decl Z3_API Z3_solver_propagate_declare(Z3_context c, Z3_symbol name, unsigned n, Z3_sort *domain, Z3_sort range)

Friends And Related Function Documentation

◆ user_propagator_base

friend class user_propagator_base
friend

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