Z3
z3++.h
Go to the documentation of this file.
1 /*++
2 Copyright (c) 2012 Microsoft Corporation
3 
4  Thin C++ layer on top of the Z3 C API.
5  Main features:
6  - Smart pointers for all Z3 objects.
7  - Object-Oriented interface.
8  - Operator overloading.
9  - Exceptions for signaling Z3 errors
10 
11  The C API can be used simultaneously with the C++ layer.
12  However, if you use the C API directly, you will have to check the error conditions manually.
13  Of course, you can invoke the method check_error() of the context object.
14 Author:
15 
16  Leonardo (leonardo) 2012-03-28
17 
18 Notes:
19 
20 --*/
21 #ifndef Z3PP_H_
22 #define Z3PP_H_
23 
24 #include<cassert>
25 #include<iostream>
26 #include<string>
27 #include<sstream>
28 #include<z3.h>
29 #include<limits.h>
30 
31 #undef min
32 #undef max
33 
39 
44 
48 namespace z3 {
49 
50  class exception;
51  class config;
52  class context;
53  class symbol;
54  class params;
55  class param_descrs;
56  class ast;
57  class sort;
58  class func_decl;
59  class expr;
60  class solver;
61  class goal;
62  class tactic;
63  class probe;
64  class model;
65  class func_interp;
66  class func_entry;
67  class statistics;
68  class apply_result;
69  template<typename T> class cast_ast;
70  template<typename T> class ast_vector_tpl;
75 
76  inline void set_param(char const * param, char const * value) { Z3_global_param_set(param, value); }
77  inline void set_param(char const * param, bool value) { Z3_global_param_set(param, value ? "true" : "false"); }
78  inline void set_param(char const * param, int value) { std::ostringstream oss; oss << value; Z3_global_param_set(param, oss.str().c_str()); }
80 
84  class exception : public std::exception {
85  std::string m_msg;
86  public:
87  exception(char const * msg):m_msg(msg) {}
88  virtual ~exception() throw() {}
89  char const * msg() const { return m_msg.c_str(); }
90  char const * what() const throw() { return m_msg.c_str(); }
91  friend std::ostream & operator<<(std::ostream & out, exception const & e);
92  };
93  inline std::ostream & operator<<(std::ostream & out, exception const & e) { out << e.msg(); return out; }
94 
95 #if !defined(Z3_THROW)
96 #if __cpp_exceptions || _CPPUNWIND || __EXCEPTIONS
97 #define Z3_THROW(x) throw x
98 #else
99 #define Z3_THROW(x) {}
100 #endif
101 #endif // !defined(Z3_THROW)
102 
106  class config {
107  Z3_config m_cfg;
108  config(config const & s);
109  config & operator=(config const & s);
110  public:
111  config() { m_cfg = Z3_mk_config(); }
112  ~config() { Z3_del_config(m_cfg); }
113  operator Z3_config() const { return m_cfg; }
117  void set(char const * param, char const * value) { Z3_set_param_value(m_cfg, param, value); }
121  void set(char const * param, bool value) { Z3_set_param_value(m_cfg, param, value ? "true" : "false"); }
125  void set(char const * param, int value) {
126  std::ostringstream oss;
127  oss << value;
128  Z3_set_param_value(m_cfg, param, oss.str().c_str());
129  }
130  };
131 
134  };
135 
142  };
143 
145  if (l == Z3_L_TRUE) return sat;
146  else if (l == Z3_L_FALSE) return unsat;
147  return unknown;
148  }
149 
150 
156  class context {
157  private:
158  bool m_enable_exceptions;
159  rounding_mode m_rounding_mode;
160  Z3_context m_ctx;
161  void init(config & c) {
162  m_ctx = Z3_mk_context_rc(c);
163  m_enable_exceptions = true;
164  m_rounding_mode = RNA;
165  Z3_set_error_handler(m_ctx, 0);
167  }
168 
169 
170  context(context const & s);
171  context & operator=(context const & s);
172  public:
173  context() { config c; init(c); }
174  context(config & c) { init(c); }
175  ~context() { Z3_del_context(m_ctx); }
176  operator Z3_context() const { return m_ctx; }
177 
182  Z3_error_code e = Z3_get_error_code(m_ctx);
183  if (e != Z3_OK && enable_exceptions())
184  Z3_THROW(exception(Z3_get_error_msg(m_ctx, e)));
185  return e;
186  }
187 
188  void check_parser_error() const {
189  check_error();
190  }
191 
199  void set_enable_exceptions(bool f) { m_enable_exceptions = f; }
200 
201  bool enable_exceptions() const { return m_enable_exceptions; }
202 
206  void set(char const * param, char const * value) { Z3_update_param_value(m_ctx, param, value); }
210  void set(char const * param, bool value) { Z3_update_param_value(m_ctx, param, value ? "true" : "false"); }
214  void set(char const * param, int value) {
215  std::ostringstream oss;
216  oss << value;
217  Z3_update_param_value(m_ctx, param, oss.str().c_str());
218  }
219 
224  void interrupt() { Z3_interrupt(m_ctx); }
225 
229  symbol str_symbol(char const * s);
233  symbol int_symbol(int n);
237  sort bool_sort();
241  sort int_sort();
245  sort real_sort();
249  sort bv_sort(unsigned sz);
253  sort string_sort();
257  sort seq_sort(sort& s);
267  sort array_sort(sort d, sort r);
268  sort array_sort(sort_vector const& d, sort r);
275  sort fpa_sort(unsigned ebits, unsigned sbits);
279  template<size_t precision>
280  sort fpa_sort();
294  sort enumeration_sort(char const * name, unsigned n, char const * const * enum_names, func_decl_vector & cs, func_decl_vector & ts);
295 
302  func_decl tuple_sort(char const * name, unsigned n, char const * const * names, sort const* sorts, func_decl_vector & projs);
303 
307  sort uninterpreted_sort(char const* name);
308  sort uninterpreted_sort(symbol const& name);
309 
310  func_decl function(symbol const & name, unsigned arity, sort const * domain, sort const & range);
311  func_decl function(char const * name, unsigned arity, sort const * domain, sort const & range);
312  func_decl function(symbol const& name, sort_vector const& domain, sort const& range);
313  func_decl function(char const * name, sort_vector const& domain, sort const& range);
314  func_decl function(char const * name, sort const & domain, sort const & range);
315  func_decl function(char const * name, sort const & d1, sort const & d2, sort const & range);
316  func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range);
317  func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & d4, sort const & range);
318  func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & d4, sort const & d5, sort const & range);
319 
320  func_decl recfun(symbol const & name, unsigned arity, sort const * domain, sort const & range);
321  func_decl recfun(char const * name, unsigned arity, sort const * domain, sort const & range);
322  func_decl recfun(char const * name, sort const & domain, sort const & range);
323  func_decl recfun(char const * name, sort const & d1, sort const & d2, sort const & range);
324 
325  void recdef(func_decl, expr_vector const& args, expr const& body);
326 
327  expr constant(symbol const & name, sort const & s);
328  expr constant(char const * name, sort const & s);
329  expr bool_const(char const * name);
330  expr int_const(char const * name);
331  expr real_const(char const * name);
332  expr bv_const(char const * name, unsigned sz);
333  expr fpa_const(char const * name, unsigned ebits, unsigned sbits);
334 
335  template<size_t precision>
336  expr fpa_const(char const * name);
337 
338  expr bool_val(bool b);
339 
340  expr int_val(int n);
341  expr int_val(unsigned n);
342  expr int_val(int64_t n);
343  expr int_val(uint64_t n);
344  expr int_val(char const * n);
345 
346  expr real_val(int n, int d);
347  expr real_val(int n);
348  expr real_val(unsigned n);
349  expr real_val(int64_t n);
350  expr real_val(uint64_t n);
351  expr real_val(char const * n);
352 
353  expr bv_val(int n, unsigned sz);
354  expr bv_val(unsigned n, unsigned sz);
355  expr bv_val(int64_t n, unsigned sz);
356  expr bv_val(uint64_t n, unsigned sz);
357  expr bv_val(char const * n, unsigned sz);
358  expr bv_val(unsigned n, bool const* bits);
359 
360  expr fpa_val(double n);
361  expr fpa_val(float n);
362 
363  expr string_val(char const* s);
364  expr string_val(char const* s, unsigned n);
365  expr string_val(std::string const& s);
366 
367  expr num_val(int n, sort const & s);
368 
372  expr_vector parse_string(char const* s);
373  expr_vector parse_file(char const* file);
374 
375  expr_vector parse_string(char const* s, sort_vector const& sorts, func_decl_vector const& decls);
376  expr_vector parse_file(char const* s, sort_vector const& sorts, func_decl_vector const& decls);
377 
378 
379  };
380 
381 
382 
383 
384  template<typename T>
385  class array {
386  T * m_array;
387  unsigned m_size;
388  array(array const & s);
389  array & operator=(array const & s);
390  public:
391  array(unsigned sz):m_size(sz) { m_array = new T[sz]; }
392  template<typename T2>
393  array(ast_vector_tpl<T2> const & v);
394  ~array() { delete[] m_array; }
395  void resize(unsigned sz) { delete[] m_array; m_size = sz; m_array = new T[sz]; }
396  unsigned size() const { return m_size; }
397  T & operator[](int i) { assert(0 <= i); assert(static_cast<unsigned>(i) < m_size); return m_array[i]; }
398  T const & operator[](int i) const { assert(0 <= i); assert(static_cast<unsigned>(i) < m_size); return m_array[i]; }
399  T const * ptr() const { return m_array; }
400  T * ptr() { return m_array; }
401  };
402 
403  class object {
404  protected:
406  public:
407  object(context & c):m_ctx(&c) {}
408  object(object const & s):m_ctx(s.m_ctx) {}
409  context & ctx() const { return *m_ctx; }
411  friend void check_context(object const & a, object const & b);
412  };
413  inline void check_context(object const & a, object const & b) { (void)a; (void)b; assert(a.m_ctx == b.m_ctx); }
414 
415  class symbol : public object {
416  Z3_symbol m_sym;
417  public:
418  symbol(context & c, Z3_symbol s):object(c), m_sym(s) {}
419  symbol(symbol const & s):object(s), m_sym(s.m_sym) {}
420  symbol & operator=(symbol const & s) { m_ctx = s.m_ctx; m_sym = s.m_sym; return *this; }
421  operator Z3_symbol() const { return m_sym; }
422  Z3_symbol_kind kind() const { return Z3_get_symbol_kind(ctx(), m_sym); }
423  std::string str() const { assert(kind() == Z3_STRING_SYMBOL); return Z3_get_symbol_string(ctx(), m_sym); }
424  int to_int() const { assert(kind() == Z3_INT_SYMBOL); return Z3_get_symbol_int(ctx(), m_sym); }
425  friend std::ostream & operator<<(std::ostream & out, symbol const & s);
426  };
427 
428  inline std::ostream & operator<<(std::ostream & out, symbol const & s) {
429  if (s.kind() == Z3_INT_SYMBOL)
430  out << "k!" << s.to_int();
431  else
432  out << s.str();
433  return out;
434  }
435 
436 
437  class param_descrs : public object {
438  Z3_param_descrs m_descrs;
439  public:
440  param_descrs(context& c, Z3_param_descrs d): object(c), m_descrs(d) { Z3_param_descrs_inc_ref(c, d); }
441  param_descrs(param_descrs const& o): object(o.ctx()), m_descrs(o.m_descrs) { Z3_param_descrs_inc_ref(ctx(), m_descrs); }
443  Z3_param_descrs_inc_ref(o.ctx(), o.m_descrs);
444  Z3_param_descrs_dec_ref(ctx(), m_descrs);
445  m_descrs = o.m_descrs;
446  m_ctx = o.m_ctx;
447  return *this;
448  }
451 
452  unsigned size() { return Z3_param_descrs_size(ctx(), m_descrs); }
453  symbol name(unsigned i) { return symbol(ctx(), Z3_param_descrs_get_name(ctx(), m_descrs, i)); }
454  Z3_param_kind kind(symbol const& s) { return Z3_param_descrs_get_kind(ctx(), m_descrs, s); }
455  std::string documentation(symbol const& s) { char const* r = Z3_param_descrs_get_documentation(ctx(), m_descrs, s); check_error(); return r; }
456  std::string to_string() const { return Z3_param_descrs_to_string(ctx(), m_descrs); }
457  };
458 
459  inline std::ostream& operator<<(std::ostream & out, param_descrs const & d) { return out << d.to_string(); }
460 
461  class params : public object {
462  Z3_params m_params;
463  public:
464  params(context & c):object(c) { m_params = Z3_mk_params(c); Z3_params_inc_ref(ctx(), m_params); }
465  params(params const & s):object(s), m_params(s.m_params) { Z3_params_inc_ref(ctx(), m_params); }
466  ~params() { Z3_params_dec_ref(ctx(), m_params); }
467  operator Z3_params() const { return m_params; }
468  params & operator=(params const & s) {
469  Z3_params_inc_ref(s.ctx(), s.m_params);
470  Z3_params_dec_ref(ctx(), m_params);
471  m_ctx = s.m_ctx;
472  m_params = s.m_params;
473  return *this;
474  }
475  void set(char const * k, bool b) { Z3_params_set_bool(ctx(), m_params, ctx().str_symbol(k), b); }
476  void set(char const * k, unsigned n) { Z3_params_set_uint(ctx(), m_params, ctx().str_symbol(k), n); }
477  void set(char const * k, double n) { Z3_params_set_double(ctx(), m_params, ctx().str_symbol(k), n); }
478  void set(char const * k, symbol const & s) { Z3_params_set_symbol(ctx(), m_params, ctx().str_symbol(k), s); }
479  void set(char const * k, char const* s) { Z3_params_set_symbol(ctx(), m_params, ctx().str_symbol(k), ctx().str_symbol(s)); }
480  friend std::ostream & operator<<(std::ostream & out, params const & p);
481  };
482 
483  inline std::ostream & operator<<(std::ostream & out, params const & p) {
484  out << Z3_params_to_string(p.ctx(), p); return out;
485  }
486 
487  class ast : public object {
488  protected:
489  Z3_ast m_ast;
490  public:
491  ast(context & c):object(c), m_ast(0) {}
492  ast(context & c, Z3_ast n):object(c), m_ast(n) { Z3_inc_ref(ctx(), m_ast); }
493  ast(ast const & s):object(s), m_ast(s.m_ast) { Z3_inc_ref(ctx(), m_ast); }
494  ~ast() { if (m_ast) Z3_dec_ref(*m_ctx, m_ast); }
495  operator Z3_ast() const { return m_ast; }
496  operator bool() const { return m_ast != 0; }
497  ast & operator=(ast const & s) { Z3_inc_ref(s.ctx(), s.m_ast); if (m_ast) Z3_dec_ref(ctx(), m_ast); m_ctx = s.m_ctx; m_ast = s.m_ast; return *this; }
498  Z3_ast_kind kind() const { Z3_ast_kind r = Z3_get_ast_kind(ctx(), m_ast); check_error(); return r; }
499  unsigned hash() const { unsigned r = Z3_get_ast_hash(ctx(), m_ast); check_error(); return r; }
500  friend std::ostream & operator<<(std::ostream & out, ast const & n);
501  std::string to_string() const { return std::string(Z3_ast_to_string(ctx(), m_ast)); }
502 
503 
507  friend bool eq(ast const & a, ast const & b);
508  };
509  inline std::ostream & operator<<(std::ostream & out, ast const & n) {
510  out << Z3_ast_to_string(n.ctx(), n.m_ast); return out;
511  }
512 
513  inline bool eq(ast const & a, ast const & b) { return Z3_is_eq_ast(a.ctx(), a, b); }
514 
515  template<typename T>
516  class ast_vector_tpl : public object {
517  Z3_ast_vector m_vector;
518  void init(Z3_ast_vector v) { Z3_ast_vector_inc_ref(ctx(), v); m_vector = v; }
519  public:
521  ast_vector_tpl(context & c, Z3_ast_vector v):object(c) { init(v); }
522  ast_vector_tpl(ast_vector_tpl const & s):object(s), m_vector(s.m_vector) { Z3_ast_vector_inc_ref(ctx(), m_vector); }
523  ast_vector_tpl(context& c, ast_vector_tpl const& src): object(c) { init(Z3_ast_vector_translate(src.ctx(), src, c)); }
524 
525  ~ast_vector_tpl() { Z3_ast_vector_dec_ref(ctx(), m_vector); }
526  operator Z3_ast_vector() const { return m_vector; }
527  unsigned size() const { return Z3_ast_vector_size(ctx(), m_vector); }
528  T operator[](int i) const { assert(0 <= i); Z3_ast r = Z3_ast_vector_get(ctx(), m_vector, i); check_error(); return cast_ast<T>()(ctx(), r); }
529  void push_back(T const & e) { Z3_ast_vector_push(ctx(), m_vector, e); check_error(); }
530  void resize(unsigned sz) { Z3_ast_vector_resize(ctx(), m_vector, sz); check_error(); }
531  T back() const { return operator[](size() - 1); }
532  void pop_back() { assert(size() > 0); resize(size() - 1); }
533  bool empty() const { return size() == 0; }
535  Z3_ast_vector_inc_ref(s.ctx(), s.m_vector);
536  Z3_ast_vector_dec_ref(ctx(), m_vector);
537  m_ctx = s.m_ctx;
538  m_vector = s.m_vector;
539  return *this;
540  }
541  ast_vector_tpl& set(unsigned idx, ast& a) {
542  Z3_ast_vector_set(ctx(), m_vector, idx, a);
543  return *this;
544  }
545  /*
546  Disabled pending C++98 build upgrade
547  bool contains(T const& x) const {
548  for (T y : *this) if (eq(x, y)) return true;
549  return false;
550  }
551  */
552 
553  class iterator {
554  ast_vector_tpl const* m_vector;
555  unsigned m_index;
556  public:
557  iterator(ast_vector_tpl const* v, unsigned i): m_vector(v), m_index(i) {}
558  iterator(iterator const& other): m_vector(other.m_vector), m_index(other.m_index) {}
559  iterator operator=(iterator const& other) { m_vector = other.m_vector; m_index = other.m_index; return *this; }
560 
561  bool operator==(iterator const& other) const {
562  return other.m_index == m_index;
563  };
564  bool operator!=(iterator const& other) const {
565  return other.m_index != m_index;
566  };
568  ++m_index;
569  return *this;
570  }
571  void set(T& arg) {
572  Z3_ast_vector_set(m_vector->ctx(), *m_vector, m_index, arg);
573  }
574  iterator operator++(int) { iterator tmp = *this; ++m_index; return tmp; }
575  T * operator->() const { return &(operator*()); }
576  T operator*() const { return (*m_vector)[m_index]; }
577  };
578  iterator begin() const { return iterator(this, 0); }
579  iterator end() const { return iterator(this, size()); }
580  friend std::ostream & operator<<(std::ostream & out, ast_vector_tpl const & v) { out << Z3_ast_vector_to_string(v.ctx(), v); return out; }
581  };
582 
583 
587  class sort : public ast {
588  public:
589  sort(context & c):ast(c) {}
590  sort(context & c, Z3_sort s):ast(c, reinterpret_cast<Z3_ast>(s)) {}
591  sort(context & c, Z3_ast a):ast(c, a) {}
592  sort(sort const & s):ast(s) {}
593  operator Z3_sort() const { return reinterpret_cast<Z3_sort>(m_ast); }
594 
598  unsigned id() const { unsigned r = Z3_get_sort_id(ctx(), *this); check_error(); return r; }
599 
603  sort & operator=(sort const & s) { return static_cast<sort&>(ast::operator=(s)); }
607  Z3_sort_kind sort_kind() const { return Z3_get_sort_kind(*m_ctx, *this); }
611  symbol name() const { Z3_symbol s = Z3_get_sort_name(ctx(), *this); check_error(); return symbol(ctx(), s); }
615  bool is_bool() const { return sort_kind() == Z3_BOOL_SORT; }
619  bool is_int() const { return sort_kind() == Z3_INT_SORT; }
623  bool is_real() const { return sort_kind() == Z3_REAL_SORT; }
627  bool is_arith() const { return is_int() || is_real(); }
631  bool is_bv() const { return sort_kind() == Z3_BV_SORT; }
635  bool is_array() const { return sort_kind() == Z3_ARRAY_SORT; }
639  bool is_datatype() const { return sort_kind() == Z3_DATATYPE_SORT; }
643  bool is_relation() const { return sort_kind() == Z3_RELATION_SORT; }
647  bool is_seq() const { return sort_kind() == Z3_SEQ_SORT; }
651  bool is_re() const { return sort_kind() == Z3_RE_SORT; }
655  bool is_finite_domain() const { return sort_kind() == Z3_FINITE_DOMAIN_SORT; }
659  bool is_fpa() const { return sort_kind() == Z3_FLOATING_POINT_SORT; }
660 
666  unsigned bv_size() const { assert(is_bv()); unsigned r = Z3_get_bv_sort_size(ctx(), *this); check_error(); return r; }
667 
668  unsigned fpa_ebits() const { assert(is_fpa()); unsigned r = Z3_fpa_get_ebits(ctx(), *this); check_error(); return r; }
669 
670  unsigned fpa_sbits() const { assert(is_fpa()); unsigned r = Z3_fpa_get_sbits(ctx(), *this); check_error(); return r; }
676  sort array_domain() const { assert(is_array()); Z3_sort s = Z3_get_array_sort_domain(ctx(), *this); check_error(); return sort(ctx(), s); }
682  sort array_range() const { assert(is_array()); Z3_sort s = Z3_get_array_sort_range(ctx(), *this); check_error(); return sort(ctx(), s); }
683  };
684 
689  class func_decl : public ast {
690  public:
691  func_decl(context & c):ast(c) {}
692  func_decl(context & c, Z3_func_decl n):ast(c, reinterpret_cast<Z3_ast>(n)) {}
693  func_decl(func_decl const & s):ast(s) {}
694  operator Z3_func_decl() const { return reinterpret_cast<Z3_func_decl>(m_ast); }
695  func_decl & operator=(func_decl const & s) { return static_cast<func_decl&>(ast::operator=(s)); }
696 
700  unsigned id() const { unsigned r = Z3_get_func_decl_id(ctx(), *this); check_error(); return r; }
701 
702  unsigned arity() const { return Z3_get_arity(ctx(), *this); }
703  sort domain(unsigned i) const { assert(i < arity()); Z3_sort r = Z3_get_domain(ctx(), *this, i); check_error(); return sort(ctx(), r); }
704  sort range() const { Z3_sort r = Z3_get_range(ctx(), *this); check_error(); return sort(ctx(), r); }
705  symbol name() const { Z3_symbol s = Z3_get_decl_name(ctx(), *this); check_error(); return symbol(ctx(), s); }
706  Z3_decl_kind decl_kind() const { return Z3_get_decl_kind(ctx(), *this); }
707 
709  Z3_func_decl tc = Z3_mk_transitive_closure(ctx(), *this); check_error(); return func_decl(ctx(), tc);
710  }
711 
712  bool is_const() const { return arity() == 0; }
713 
714  expr operator()() const;
715  expr operator()(unsigned n, expr const * args) const;
716  expr operator()(expr_vector const& v) const;
717  expr operator()(expr const & a) const;
718  expr operator()(int a) const;
719  expr operator()(expr const & a1, expr const & a2) const;
720  expr operator()(expr const & a1, int a2) const;
721  expr operator()(int a1, expr const & a2) const;
722  expr operator()(expr const & a1, expr const & a2, expr const & a3) const;
723  expr operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4) const;
724  expr operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4, expr const & a5) const;
725  };
726 
730  expr select(expr const & a, expr const& i);
731  expr select(expr const & a, expr_vector const & i);
732 
737  class expr : public ast {
738  public:
739  expr(context & c):ast(c) {}
740  expr(context & c, Z3_ast n):ast(c, reinterpret_cast<Z3_ast>(n)) {}
741  expr(expr const & n):ast(n) {}
742  expr & operator=(expr const & n) { return static_cast<expr&>(ast::operator=(n)); }
743 
747  sort get_sort() const { Z3_sort s = Z3_get_sort(*m_ctx, m_ast); check_error(); return sort(*m_ctx, s); }
748 
752  bool is_bool() const { return get_sort().is_bool(); }
756  bool is_int() const { return get_sort().is_int(); }
760  bool is_real() const { return get_sort().is_real(); }
764  bool is_arith() const { return get_sort().is_arith(); }
768  bool is_bv() const { return get_sort().is_bv(); }
772  bool is_array() const { return get_sort().is_array(); }
776  bool is_datatype() const { return get_sort().is_datatype(); }
780  bool is_relation() const { return get_sort().is_relation(); }
784  bool is_seq() const { return get_sort().is_seq(); }
788  bool is_re() const { return get_sort().is_re(); }
789 
798  bool is_finite_domain() const { return get_sort().is_finite_domain(); }
802  bool is_fpa() const { return get_sort().is_fpa(); }
803 
809  bool is_numeral() const { return kind() == Z3_NUMERAL_AST; }
810  bool is_numeral_i64(int64_t& i) const { bool r = Z3_get_numeral_int64(ctx(), m_ast, &i); check_error(); return r;}
811  bool is_numeral_u64(uint64_t& i) const { bool r = Z3_get_numeral_uint64(ctx(), m_ast, &i); check_error(); return r;}
812  bool is_numeral_i(int& i) const { bool r = Z3_get_numeral_int(ctx(), m_ast, &i); check_error(); return r;}
813  bool is_numeral_u(unsigned& i) const { bool r = Z3_get_numeral_uint(ctx(), m_ast, &i); check_error(); return r;}
814  bool is_numeral(std::string& s) const { if (!is_numeral()) return false; s = Z3_get_numeral_string(ctx(), m_ast); check_error(); return true; }
815  bool is_numeral(std::string& s, unsigned precision) const { if (!is_numeral()) return false; s = Z3_get_numeral_decimal_string(ctx(), m_ast, precision); check_error(); return true; }
816  bool is_numeral(double& d) const { if (!is_numeral()) return false; d = Z3_get_numeral_double(ctx(), m_ast); check_error(); return true; }
817 
821  bool is_app() const { return kind() == Z3_APP_AST || kind() == Z3_NUMERAL_AST; }
825  bool is_const() const { return is_app() && num_args() == 0; }
829  bool is_quantifier() const { return kind() == Z3_QUANTIFIER_AST; }
830 
834  bool is_forall() const { return Z3_is_quantifier_forall(ctx(), m_ast); }
838  bool is_exists() const { return Z3_is_quantifier_exists(ctx(), m_ast); }
842  bool is_lambda() const { return Z3_is_lambda(ctx(), m_ast); }
847  bool is_var() const { return kind() == Z3_VAR_AST; }
851  bool is_algebraic() const { return Z3_is_algebraic_number(ctx(), m_ast); }
852 
856  bool is_well_sorted() const { bool r = Z3_is_well_sorted(ctx(), m_ast); check_error(); return r; }
857 
864  std::string get_decimal_string(int precision) const {
865  assert(is_numeral() || is_algebraic());
866  return std::string(Z3_get_numeral_decimal_string(ctx(), m_ast, precision));
867  }
868 
872  expr algebraic_lower(unsigned precision) const {
873  assert(is_algebraic());
874  Z3_ast r = Z3_get_algebraic_number_lower(ctx(), m_ast, precision);
875  check_error();
876  return expr(ctx(), r);
877  }
878 
879  expr algebraic_upper(unsigned precision) const {
880  assert(is_algebraic());
881  Z3_ast r = Z3_get_algebraic_number_upper(ctx(), m_ast, precision);
882  check_error();
883  return expr(ctx(), r);
884  }
885 
890  assert(is_algebraic());
891  Z3_ast_vector r = Z3_algebraic_get_poly(ctx(), m_ast);
892  check_error();
893  return expr_vector(ctx(), r);
894  }
895 
899  unsigned algebraic_i() const {
900  assert(is_algebraic());
901  unsigned i = Z3_algebraic_get_i(ctx(), m_ast);
902  check_error();
903  return i;
904  }
905 
909  unsigned id() const { unsigned r = Z3_get_ast_id(ctx(), m_ast); check_error(); return r; }
910 
921  int get_numeral_int() const {
922  int result = 0;
923  if (!is_numeral_i(result)) {
924  assert(ctx().enable_exceptions());
925  if (!ctx().enable_exceptions()) return 0;
926  Z3_THROW(exception("numeral does not fit in machine int"));
927  }
928  return result;
929  }
930 
940  unsigned get_numeral_uint() const {
941  assert(is_numeral());
942  unsigned result = 0;
943  if (!is_numeral_u(result)) {
944  assert(ctx().enable_exceptions());
945  if (!ctx().enable_exceptions()) return 0;
946  Z3_THROW(exception("numeral does not fit in machine uint"));
947  }
948  return result;
949  }
950 
957  int64_t get_numeral_int64() const {
958  assert(is_numeral());
959  int64_t result = 0;
960  if (!is_numeral_i64(result)) {
961  assert(ctx().enable_exceptions());
962  if (!ctx().enable_exceptions()) return 0;
963  Z3_THROW(exception("numeral does not fit in machine int64_t"));
964  }
965  return result;
966  }
967 
974  uint64_t get_numeral_uint64() const {
975  assert(is_numeral());
976  uint64_t result = 0;
977  if (!is_numeral_u64(result)) {
978  assert(ctx().enable_exceptions());
979  if (!ctx().enable_exceptions()) return 0;
980  Z3_THROW(exception("numeral does not fit in machine uint64_t"));
981  }
982  return result;
983  }
984 
986  return Z3_get_bool_value(ctx(), m_ast);
987  }
988 
989  expr numerator() const {
990  assert(is_numeral());
991  Z3_ast r = Z3_get_numerator(ctx(), m_ast);
992  check_error();
993  return expr(ctx(),r);
994  }
995 
996 
997  expr denominator() const {
998  assert(is_numeral());
999  Z3_ast r = Z3_get_denominator(ctx(), m_ast);
1000  check_error();
1001  return expr(ctx(),r);
1002  }
1003 
1004 
1009  bool is_string_value() const { return Z3_is_string(ctx(), m_ast); }
1010 
1016  std::string get_escaped_string() const {
1017  assert(is_string_value());
1018  char const* s = Z3_get_string(ctx(), m_ast);
1019  check_error();
1020  return std::string(s);
1021  }
1022 
1023  std::string get_string() const {
1024  assert(is_string_value());
1025  unsigned n;
1026  char const* s = Z3_get_lstring(ctx(), m_ast, &n);
1027  check_error();
1028  return std::string(s, n);
1029  }
1030 
1031  operator Z3_app() const { assert(is_app()); return reinterpret_cast<Z3_app>(m_ast); }
1032 
1037  assert(is_fpa());
1038  Z3_sort s = ctx().fpa_rounding_mode();
1039  check_error();
1040  return sort(ctx(), s);
1041  }
1042 
1043 
1050  func_decl decl() const { Z3_func_decl f = Z3_get_app_decl(ctx(), *this); check_error(); return func_decl(ctx(), f); }
1057  unsigned num_args() const { unsigned r = Z3_get_app_num_args(ctx(), *this); check_error(); return r; }
1065  expr arg(unsigned i) const { Z3_ast r = Z3_get_app_arg(ctx(), *this, i); check_error(); return expr(ctx(), r); }
1066 
1072  expr body() const { assert(is_quantifier()); Z3_ast r = Z3_get_quantifier_body(ctx(), *this); check_error(); return expr(ctx(), r); }
1073 
1079  friend expr operator!(expr const & a);
1080 
1087  friend expr operator&&(expr const & a, expr const & b);
1088 
1089 
1096  friend expr operator&&(expr const & a, bool b);
1103  friend expr operator&&(bool a, expr const & b);
1104 
1111  friend expr operator||(expr const & a, expr const & b);
1118  friend expr operator||(expr const & a, bool b);
1119 
1126  friend expr operator||(bool a, expr const & b);
1127 
1128  friend expr implies(expr const & a, expr const & b);
1129  friend expr implies(expr const & a, bool b);
1130  friend expr implies(bool a, expr const & b);
1131 
1132  friend expr mk_or(expr_vector const& args);
1133  friend expr mk_and(expr_vector const& args);
1134 
1135  friend expr ite(expr const & c, expr const & t, expr const & e);
1136 
1137  bool is_true() const { return is_app() && Z3_OP_TRUE == decl().decl_kind(); }
1138  bool is_false() const { return is_app() && Z3_OP_FALSE == decl().decl_kind(); }
1139  bool is_not() const { return is_app() && Z3_OP_NOT == decl().decl_kind(); }
1140  bool is_and() const { return is_app() && Z3_OP_AND == decl().decl_kind(); }
1141  bool is_or() const { return is_app() && Z3_OP_OR == decl().decl_kind(); }
1142  bool is_xor() const { return is_app() && Z3_OP_XOR == decl().decl_kind(); }
1143  bool is_implies() const { return is_app() && Z3_OP_IMPLIES == decl().decl_kind(); }
1144  bool is_eq() const { return is_app() && Z3_OP_EQ == decl().decl_kind(); }
1145  bool is_ite() const { return is_app() && Z3_OP_ITE == decl().decl_kind(); }
1146  bool is_distinct() const { return is_app() && Z3_OP_DISTINCT == decl().decl_kind(); }
1147 
1148  friend expr distinct(expr_vector const& args);
1149  friend expr concat(expr const& a, expr const& b);
1150  friend expr concat(expr_vector const& args);
1151 
1152  friend expr operator==(expr const & a, expr const & b);
1153  friend expr operator==(expr const & a, int b);
1154  friend expr operator==(int a, expr const & b);
1155 
1156  friend expr operator!=(expr const & a, expr const & b);
1157  friend expr operator!=(expr const & a, int b);
1158  friend expr operator!=(int a, expr const & b);
1159 
1160  friend expr operator+(expr const & a, expr const & b);
1161  friend expr operator+(expr const & a, int b);
1162  friend expr operator+(int a, expr const & b);
1163  friend expr sum(expr_vector const& args);
1164 
1165  friend expr operator*(expr const & a, expr const & b);
1166  friend expr operator*(expr const & a, int b);
1167  friend expr operator*(int a, expr const & b);
1168 
1169  /* \brief Power operator */
1170  friend expr pw(expr const & a, expr const & b);
1171  friend expr pw(expr const & a, int b);
1172  friend expr pw(int a, expr const & b);
1173 
1174  /* \brief mod operator */
1175  friend expr mod(expr const& a, expr const& b);
1176  friend expr mod(expr const& a, int b);
1177  friend expr mod(int a, expr const& b);
1178 
1179  /* \brief rem operator */
1180  friend expr rem(expr const& a, expr const& b);
1181  friend expr rem(expr const& a, int b);
1182  friend expr rem(int a, expr const& b);
1183 
1184  friend expr is_int(expr const& e);
1185 
1186  friend expr operator/(expr const & a, expr const & b);
1187  friend expr operator/(expr const & a, int b);
1188  friend expr operator/(int a, expr const & b);
1189 
1190  friend expr operator-(expr const & a);
1191 
1192  friend expr operator-(expr const & a, expr const & b);
1193  friend expr operator-(expr const & a, int b);
1194  friend expr operator-(int a, expr const & b);
1195 
1196  friend expr operator<=(expr const & a, expr const & b);
1197  friend expr operator<=(expr const & a, int b);
1198  friend expr operator<=(int a, expr const & b);
1199 
1200 
1201  friend expr operator>=(expr const & a, expr const & b);
1202  friend expr operator>=(expr const & a, int b);
1203  friend expr operator>=(int a, expr const & b);
1204 
1205  friend expr operator<(expr const & a, expr const & b);
1206  friend expr operator<(expr const & a, int b);
1207  friend expr operator<(int a, expr const & b);
1208 
1209  friend expr operator>(expr const & a, expr const & b);
1210  friend expr operator>(expr const & a, int b);
1211  friend expr operator>(int a, expr const & b);
1212 
1213  friend expr pble(expr_vector const& es, int const * coeffs, int bound);
1214  friend expr pbge(expr_vector const& es, int const * coeffs, int bound);
1215  friend expr pbeq(expr_vector const& es, int const * coeffs, int bound);
1216  friend expr atmost(expr_vector const& es, unsigned bound);
1217  friend expr atleast(expr_vector const& es, unsigned bound);
1218 
1219  friend expr operator&(expr const & a, expr const & b);
1220  friend expr operator&(expr const & a, int b);
1221  friend expr operator&(int a, expr const & b);
1222 
1223  friend expr operator^(expr const & a, expr const & b);
1224  friend expr operator^(expr const & a, int b);
1225  friend expr operator^(int a, expr const & b);
1226 
1227  friend expr operator|(expr const & a, expr const & b);
1228  friend expr operator|(expr const & a, int b);
1229  friend expr operator|(int a, expr const & b);
1230  friend expr nand(expr const& a, expr const& b);
1231  friend expr nor(expr const& a, expr const& b);
1232  friend expr xnor(expr const& a, expr const& b);
1233 
1234  friend expr min(expr const& a, expr const& b);
1235  friend expr max(expr const& a, expr const& b);
1236 
1237  friend expr bv2int(expr const& a, bool is_signed);
1238  friend expr int2bv(unsigned n, expr const& a);
1239  friend expr bvadd_no_overflow(expr const& a, expr const& b, bool is_signed);
1240  friend expr bvadd_no_underflow(expr const& a, expr const& b);
1241  friend expr bvsub_no_overflow(expr const& a, expr const& b);
1242  friend expr bvsub_no_underflow(expr const& a, expr const& b, bool is_signed);
1243  friend expr bvsdiv_no_overflow(expr const& a, expr const& b);
1244  friend expr bvneg_no_overflow(expr const& a);
1245  friend expr bvmul_no_overflow(expr const& a, expr const& b, bool is_signed);
1246  friend expr bvmul_no_underflow(expr const& a, expr const& b);
1247 
1248  expr rotate_left(unsigned i) { Z3_ast r = Z3_mk_rotate_left(ctx(), i, *this); ctx().check_error(); return expr(ctx(), r); }
1249  expr rotate_right(unsigned i) { Z3_ast r = Z3_mk_rotate_right(ctx(), i, *this); ctx().check_error(); return expr(ctx(), r); }
1250  expr repeat(unsigned i) { Z3_ast r = Z3_mk_repeat(ctx(), i, *this); ctx().check_error(); return expr(ctx(), r); }
1251 
1252  friend expr abs(expr const & a);
1253  friend expr sqrt(expr const & a, expr const & rm);
1254 
1255  friend expr operator~(expr const & a);
1256  expr extract(unsigned hi, unsigned lo) const { Z3_ast r = Z3_mk_extract(ctx(), hi, lo, *this); ctx().check_error(); return expr(ctx(), r); }
1257  unsigned lo() const { assert (is_app() && Z3_get_decl_num_parameters(ctx(), decl()) == 2); return static_cast<unsigned>(Z3_get_decl_int_parameter(ctx(), decl(), 1)); }
1258  unsigned hi() const { assert (is_app() && Z3_get_decl_num_parameters(ctx(), decl()) == 2); return static_cast<unsigned>(Z3_get_decl_int_parameter(ctx(), decl(), 0)); }
1259 
1263  friend expr fma(expr const& a, expr const& b, expr const& c, expr const& rm);
1264 
1270  expr extract(expr const& offset, expr const& length) const {
1271  check_context(*this, offset); check_context(offset, length);
1272  Z3_ast r = Z3_mk_seq_extract(ctx(), *this, offset, length); check_error(); return expr(ctx(), r);
1273  }
1274  expr replace(expr const& src, expr const& dst) const {
1275  check_context(*this, src); check_context(src, dst);
1276  Z3_ast r = Z3_mk_seq_replace(ctx(), *this, src, dst);
1277  check_error();
1278  return expr(ctx(), r);
1279  }
1280  expr unit() const {
1281  Z3_ast r = Z3_mk_seq_unit(ctx(), *this);
1282  check_error();
1283  return expr(ctx(), r);
1284  }
1285  expr contains(expr const& s) {
1286  check_context(*this, s);
1287  Z3_ast r = Z3_mk_seq_contains(ctx(), *this, s);
1288  check_error();
1289  return expr(ctx(), r);
1290  }
1291  expr at(expr const& index) const {
1292  check_context(*this, index);
1293  Z3_ast r = Z3_mk_seq_at(ctx(), *this, index);
1294  check_error();
1295  return expr(ctx(), r);
1296  }
1297  expr nth(expr const& index) const {
1298  check_context(*this, index);
1299  Z3_ast r = Z3_mk_seq_nth(ctx(), *this, index);
1300  check_error();
1301  return expr(ctx(), r);
1302  }
1303  expr length() const {
1304  Z3_ast r = Z3_mk_seq_length(ctx(), *this);
1305  check_error();
1306  return expr(ctx(), r);
1307  }
1308  expr stoi() const {
1309  Z3_ast r = Z3_mk_str_to_int(ctx(), *this);
1310  check_error();
1311  return expr(ctx(), r);
1312  }
1313  expr itos() const {
1314  Z3_ast r = Z3_mk_int_to_str(ctx(), *this);
1315  check_error();
1316  return expr(ctx(), r);
1317  }
1318 
1319  friend expr range(expr const& lo, expr const& hi);
1323  expr loop(unsigned lo) {
1324  Z3_ast r = Z3_mk_re_loop(ctx(), m_ast, lo, 0);
1325  check_error();
1326  return expr(ctx(), r);
1327  }
1328  expr loop(unsigned lo, unsigned hi) {
1329  Z3_ast r = Z3_mk_re_loop(ctx(), m_ast, lo, hi);
1330  check_error();
1331  return expr(ctx(), r);
1332  }
1333 
1337  expr operator[](expr const& index) const {
1338  assert(is_array() || is_seq());
1339  if (is_array()) {
1340  return select(*this, index);
1341  }
1342  return nth(index);
1343  }
1344 
1345  expr operator[](expr_vector const& index) const {
1346  return select(*this, index);
1347  }
1348 
1352  expr simplify() const { Z3_ast r = Z3_simplify(ctx(), m_ast); check_error(); return expr(ctx(), r); }
1356  expr simplify(params const & p) const { Z3_ast r = Z3_simplify_ex(ctx(), m_ast, p); check_error(); return expr(ctx(), r); }
1357 
1361  expr substitute(expr_vector const& src, expr_vector const& dst);
1362 
1366  expr substitute(expr_vector const& dst);
1367 
1368  };
1369 
1370 #define _Z3_MK_BIN_(a, b, binop) \
1371  check_context(a, b); \
1372  Z3_ast r = binop(a.ctx(), a, b); \
1373  a.check_error(); \
1374  return expr(a.ctx(), r); \
1375 
1376 
1377  inline expr implies(expr const & a, expr const & b) {
1378  assert(a.is_bool() && b.is_bool());
1379  _Z3_MK_BIN_(a, b, Z3_mk_implies);
1380  }
1381  inline expr implies(expr const & a, bool b) { return implies(a, a.ctx().bool_val(b)); }
1382  inline expr implies(bool a, expr const & b) { return implies(b.ctx().bool_val(a), b); }
1383 
1384 
1385  inline expr pw(expr const & a, expr const & b) { _Z3_MK_BIN_(a, b, Z3_mk_power); }
1386  inline expr pw(expr const & a, int b) { return pw(a, a.ctx().num_val(b, a.get_sort())); }
1387  inline expr pw(int a, expr const & b) { return pw(b.ctx().num_val(a, b.get_sort()), b); }
1388 
1389  inline expr mod(expr const& a, expr const& b) {
1390  if (a.is_bv()) {
1391  _Z3_MK_BIN_(a, b, Z3_mk_bvsmod);
1392  }
1393  else {
1394  _Z3_MK_BIN_(a, b, Z3_mk_mod);
1395  }
1396  }
1397  inline expr mod(expr const & a, int b) { return mod(a, a.ctx().num_val(b, a.get_sort())); }
1398  inline expr mod(int a, expr const & b) { return mod(b.ctx().num_val(a, b.get_sort()), b); }
1399 
1400  inline expr operator%(expr const& a, expr const& b) { return mod(a, b); }
1401  inline expr operator%(expr const& a, int b) { return mod(a, b); }
1402  inline expr operator%(int a, expr const& b) { return mod(a, b); }
1403 
1404 
1405  inline expr rem(expr const& a, expr const& b) {
1406  if (a.is_fpa() && b.is_fpa()) {
1407  _Z3_MK_BIN_(a, b, Z3_mk_fpa_rem);
1408  } else {
1409  _Z3_MK_BIN_(a, b, Z3_mk_rem);
1410  }
1411  }
1412  inline expr rem(expr const & a, int b) { return rem(a, a.ctx().num_val(b, a.get_sort())); }
1413  inline expr rem(int a, expr const & b) { return rem(b.ctx().num_val(a, b.get_sort()), b); }
1414 
1415 #undef _Z3_MK_BIN_
1416 
1417 #define _Z3_MK_UN_(a, mkun) \
1418  Z3_ast r = mkun(a.ctx(), a); \
1419  a.check_error(); \
1420  return expr(a.ctx(), r); \
1421 
1422 
1423  inline expr operator!(expr const & a) { assert(a.is_bool()); _Z3_MK_UN_(a, Z3_mk_not); }
1424 
1425  inline expr is_int(expr const& e) { _Z3_MK_UN_(e, Z3_mk_is_int); }
1426 
1427 #undef _Z3_MK_UN_
1428 
1429  inline expr operator&&(expr const & a, expr const & b) {
1430  check_context(a, b);
1431  assert(a.is_bool() && b.is_bool());
1432  Z3_ast args[2] = { a, b };
1433  Z3_ast r = Z3_mk_and(a.ctx(), 2, args);
1434  a.check_error();
1435  return expr(a.ctx(), r);
1436  }
1437 
1438  inline expr operator&&(expr const & a, bool b) { return a && a.ctx().bool_val(b); }
1439  inline expr operator&&(bool a, expr const & b) { return b.ctx().bool_val(a) && b; }
1440 
1441  inline expr operator||(expr const & a, expr const & b) {
1442  check_context(a, b);
1443  assert(a.is_bool() && b.is_bool());
1444  Z3_ast args[2] = { a, b };
1445  Z3_ast r = Z3_mk_or(a.ctx(), 2, args);
1446  a.check_error();
1447  return expr(a.ctx(), r);
1448  }
1449 
1450  inline expr operator||(expr const & a, bool b) { return a || a.ctx().bool_val(b); }
1451 
1452  inline expr operator||(bool a, expr const & b) { return b.ctx().bool_val(a) || b; }
1453 
1454  inline expr operator==(expr const & a, expr const & b) {
1455  check_context(a, b);
1456  Z3_ast r = Z3_mk_eq(a.ctx(), a, b);
1457  a.check_error();
1458  return expr(a.ctx(), r);
1459  }
1460  inline expr operator==(expr const & a, int b) { assert(a.is_arith() || a.is_bv() || a.is_fpa()); return a == a.ctx().num_val(b, a.get_sort()); }
1461  inline expr operator==(int a, expr const & b) { assert(b.is_arith() || b.is_bv() || b.is_fpa()); return b.ctx().num_val(a, b.get_sort()) == b; }
1462 
1463  inline expr operator!=(expr const & a, expr const & b) {
1464  check_context(a, b);
1465  Z3_ast args[2] = { a, b };
1466  Z3_ast r = Z3_mk_distinct(a.ctx(), 2, args);
1467  a.check_error();
1468  return expr(a.ctx(), r);
1469  }
1470  inline expr operator!=(expr const & a, int b) { assert(a.is_arith() || a.is_bv() || a.is_fpa()); return a != a.ctx().num_val(b, a.get_sort()); }
1471  inline expr operator!=(int a, expr const & b) { assert(b.is_arith() || b.is_bv() || b.is_fpa()); return b.ctx().num_val(a, b.get_sort()) != b; }
1472 
1473  inline expr operator+(expr const & a, expr const & b) {
1474  check_context(a, b);
1475  Z3_ast r = 0;
1476  if (a.is_arith() && b.is_arith()) {
1477  Z3_ast args[2] = { a, b };
1478  r = Z3_mk_add(a.ctx(), 2, args);
1479  }
1480  else if (a.is_bv() && b.is_bv()) {
1481  r = Z3_mk_bvadd(a.ctx(), a, b);
1482  }
1483  else if (a.is_seq() && b.is_seq()) {
1484  return concat(a, b);
1485  }
1486  else if (a.is_re() && b.is_re()) {
1487  Z3_ast _args[2] = { a, b };
1488  r = Z3_mk_re_union(a.ctx(), 2, _args);
1489  }
1490  else if (a.is_fpa() && b.is_fpa()) {
1491  r = Z3_mk_fpa_add(a.ctx(), a.ctx().fpa_rounding_mode(), a, b);
1492  }
1493  else {
1494  // operator is not supported by given arguments.
1495  assert(false);
1496  }
1497  a.check_error();
1498  return expr(a.ctx(), r);
1499  }
1500  inline expr operator+(expr const & a, int b) { return a + a.ctx().num_val(b, a.get_sort()); }
1501  inline expr operator+(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) + b; }
1502 
1503  inline expr operator*(expr const & a, expr const & b) {
1504  check_context(a, b);
1505  Z3_ast r = 0;
1506  if (a.is_arith() && b.is_arith()) {
1507  Z3_ast args[2] = { a, b };
1508  r = Z3_mk_mul(a.ctx(), 2, args);
1509  }
1510  else if (a.is_bv() && b.is_bv()) {
1511  r = Z3_mk_bvmul(a.ctx(), a, b);
1512  }
1513  else if (a.is_fpa() && b.is_fpa()) {
1514  r = Z3_mk_fpa_mul(a.ctx(), a.ctx().fpa_rounding_mode(), a, b);
1515  }
1516  else {
1517  // operator is not supported by given arguments.
1518  assert(false);
1519  }
1520  a.check_error();
1521  return expr(a.ctx(), r);
1522  }
1523  inline expr operator*(expr const & a, int b) { return a * a.ctx().num_val(b, a.get_sort()); }
1524  inline expr operator*(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) * b; }
1525 
1526 
1527  inline expr operator>=(expr const & a, expr const & b) {
1528  check_context(a, b);
1529  Z3_ast r = 0;
1530  if (a.is_arith() && b.is_arith()) {
1531  r = Z3_mk_ge(a.ctx(), a, b);
1532  }
1533  else if (a.is_bv() && b.is_bv()) {
1534  r = Z3_mk_bvsge(a.ctx(), a, b);
1535  }
1536  else {
1537  // operator is not supported by given arguments.
1538  assert(false);
1539  }
1540  a.check_error();
1541  return expr(a.ctx(), r);
1542  }
1543 
1544  inline expr operator/(expr const & a, expr const & b) {
1545  check_context(a, b);
1546  Z3_ast r = 0;
1547  if (a.is_arith() && b.is_arith()) {
1548  r = Z3_mk_div(a.ctx(), a, b);
1549  }
1550  else if (a.is_bv() && b.is_bv()) {
1551  r = Z3_mk_bvsdiv(a.ctx(), a, b);
1552  }
1553  else if (a.is_fpa() && b.is_fpa()) {
1554  r = Z3_mk_fpa_div(a.ctx(), a.ctx().fpa_rounding_mode(), a, b);
1555  }
1556  else {
1557  // operator is not supported by given arguments.
1558  assert(false);
1559  }
1560  a.check_error();
1561  return expr(a.ctx(), r);
1562  }
1563  inline expr operator/(expr const & a, int b) { return a / a.ctx().num_val(b, a.get_sort()); }
1564  inline expr operator/(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) / b; }
1565 
1566  inline expr operator-(expr const & a) {
1567  Z3_ast r = 0;
1568  if (a.is_arith()) {
1569  r = Z3_mk_unary_minus(a.ctx(), a);
1570  }
1571  else if (a.is_bv()) {
1572  r = Z3_mk_bvneg(a.ctx(), a);
1573  }
1574  else if (a.is_fpa()) {
1575  r = Z3_mk_fpa_neg(a.ctx(), a);
1576  }
1577  else {
1578  // operator is not supported by given arguments.
1579  assert(false);
1580  }
1581  a.check_error();
1582  return expr(a.ctx(), r);
1583  }
1584 
1585  inline expr operator-(expr const & a, expr const & b) {
1586  check_context(a, b);
1587  Z3_ast r = 0;
1588  if (a.is_arith() && b.is_arith()) {
1589  Z3_ast args[2] = { a, b };
1590  r = Z3_mk_sub(a.ctx(), 2, args);
1591  }
1592  else if (a.is_bv() && b.is_bv()) {
1593  r = Z3_mk_bvsub(a.ctx(), a, b);
1594  }
1595  else if (a.is_fpa() && b.is_fpa()) {
1596  r = Z3_mk_fpa_sub(a.ctx(), a.ctx().fpa_rounding_mode(), a, b);
1597  }
1598  else {
1599  // operator is not supported by given arguments.
1600  assert(false);
1601  }
1602  a.check_error();
1603  return expr(a.ctx(), r);
1604  }
1605  inline expr operator-(expr const & a, int b) { return a - a.ctx().num_val(b, a.get_sort()); }
1606  inline expr operator-(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) - b; }
1607 
1608  inline expr operator<=(expr const & a, expr const & b) {
1609  check_context(a, b);
1610  Z3_ast r = 0;
1611  if (a.is_arith() && b.is_arith()) {
1612  r = Z3_mk_le(a.ctx(), a, b);
1613  }
1614  else if (a.is_bv() && b.is_bv()) {
1615  r = Z3_mk_bvsle(a.ctx(), a, b);
1616  }
1617  else if (a.is_fpa() && b.is_fpa()) {
1618  r = Z3_mk_fpa_leq(a.ctx(), a, b);
1619  }
1620  else {
1621  // operator is not supported by given arguments.
1622  assert(false);
1623  }
1624  a.check_error();
1625  return expr(a.ctx(), r);
1626  }
1627  inline expr operator<=(expr const & a, int b) { return a <= a.ctx().num_val(b, a.get_sort()); }
1628  inline expr operator<=(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) <= b; }
1629 
1630  inline expr operator>=(expr const & a, int b) { return a >= a.ctx().num_val(b, a.get_sort()); }
1631  inline expr operator>=(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) >= b; }
1632 
1633  inline expr operator<(expr const & a, expr const & b) {
1634  check_context(a, b);
1635  Z3_ast r = 0;
1636  if (a.is_arith() && b.is_arith()) {
1637  r = Z3_mk_lt(a.ctx(), a, b);
1638  }
1639  else if (a.is_bv() && b.is_bv()) {
1640  r = Z3_mk_bvslt(a.ctx(), a, b);
1641  }
1642  else if (a.is_fpa() && b.is_fpa()) {
1643  r = Z3_mk_fpa_lt(a.ctx(), a, b);
1644  }
1645  else {
1646  // operator is not supported by given arguments.
1647  assert(false);
1648  }
1649  a.check_error();
1650  return expr(a.ctx(), r);
1651  }
1652  inline expr operator<(expr const & a, int b) { return a < a.ctx().num_val(b, a.get_sort()); }
1653  inline expr operator<(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) < b; }
1654 
1655  inline expr operator>(expr const & a, expr const & b) {
1656  check_context(a, b);
1657  Z3_ast r = 0;
1658  if (a.is_arith() && b.is_arith()) {
1659  r = Z3_mk_gt(a.ctx(), a, b);
1660  }
1661  else if (a.is_bv() && b.is_bv()) {
1662  r = Z3_mk_bvsgt(a.ctx(), a, b);
1663  }
1664  else if (a.is_fpa() && b.is_fpa()) {
1665  r = Z3_mk_fpa_gt(a.ctx(), a, b);
1666  }
1667  else {
1668  // operator is not supported by given arguments.
1669  assert(false);
1670  }
1671  a.check_error();
1672  return expr(a.ctx(), r);
1673  }
1674  inline expr operator>(expr const & a, int b) { return a > a.ctx().num_val(b, a.get_sort()); }
1675  inline expr operator>(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) > b; }
1676 
1677  inline expr operator&(expr const & a, expr const & b) { check_context(a, b); Z3_ast r = Z3_mk_bvand(a.ctx(), a, b); return expr(a.ctx(), r); }
1678  inline expr operator&(expr const & a, int b) { return a & a.ctx().num_val(b, a.get_sort()); }
1679  inline expr operator&(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) & b; }
1680 
1681  inline expr operator^(expr const & a, expr const & b) { check_context(a, b); Z3_ast r = Z3_mk_bvxor(a.ctx(), a, b); return expr(a.ctx(), r); }
1682  inline expr operator^(expr const & a, int b) { return a ^ a.ctx().num_val(b, a.get_sort()); }
1683  inline expr operator^(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) ^ b; }
1684 
1685  inline expr operator|(expr const & a, expr const & b) { check_context(a, b); Z3_ast r = Z3_mk_bvor(a.ctx(), a, b); return expr(a.ctx(), r); }
1686  inline expr operator|(expr const & a, int b) { return a | a.ctx().num_val(b, a.get_sort()); }
1687  inline expr operator|(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) | b; }
1688 
1689  inline expr nand(expr const& a, expr const& b) { check_context(a, b); Z3_ast r = Z3_mk_bvnand(a.ctx(), a, b); return expr(a.ctx(), r); }
1690  inline expr nor(expr const& a, expr const& b) { check_context(a, b); Z3_ast r = Z3_mk_bvnor(a.ctx(), a, b); return expr(a.ctx(), r); }
1691  inline expr xnor(expr const& a, expr const& b) { check_context(a, b); Z3_ast r = Z3_mk_bvxnor(a.ctx(), a, b); return expr(a.ctx(), r); }
1692  inline expr min(expr const& a, expr const& b) {
1693  check_context(a, b);
1694  Z3_ast r;
1695  if (a.is_arith()) {
1696  r = Z3_mk_ite(a.ctx(), Z3_mk_ge(a.ctx(), a, b), b, a);
1697  }
1698  else if (a.is_bv()) {
1699  r = Z3_mk_ite(a.ctx(), Z3_mk_bvuge(a.ctx(), a, b), b, a);
1700  }
1701  else {
1702  assert(a.is_fpa());
1703  r = Z3_mk_fpa_min(a.ctx(), a, b);
1704  }
1705  return expr(a.ctx(), r);
1706  }
1707  inline expr max(expr const& a, expr const& b) {
1708  check_context(a, b);
1709  Z3_ast r;
1710  if (a.is_arith()) {
1711  r = Z3_mk_ite(a.ctx(), Z3_mk_ge(a.ctx(), a, b), a, b);
1712  }
1713  else if (a.is_bv()) {
1714  r = Z3_mk_ite(a.ctx(), Z3_mk_bvuge(a.ctx(), a, b), a, b);
1715  }
1716  else {
1717  assert(a.is_fpa());
1718  r = Z3_mk_fpa_max(a.ctx(), a, b);
1719  }
1720  return expr(a.ctx(), r);
1721  }
1722  inline expr abs(expr const & a) {
1723  Z3_ast r;
1724  if (a.is_int()) {
1725  expr zero = a.ctx().int_val(0);
1726  r = Z3_mk_ite(a.ctx(), Z3_mk_ge(a.ctx(), a, zero), a, -a);
1727  }
1728  else if (a.is_real()) {
1729  expr zero = a.ctx().real_val(0);
1730  r = Z3_mk_ite(a.ctx(), Z3_mk_ge(a.ctx(), a, zero), a, -a);
1731  }
1732  else {
1733  r = Z3_mk_fpa_abs(a.ctx(), a);
1734  }
1735  a.check_error();
1736  return expr(a.ctx(), r);
1737  }
1738  inline expr sqrt(expr const & a, expr const& rm) {
1739  check_context(a, rm);
1740  assert(a.is_fpa());
1741  Z3_ast r = Z3_mk_fpa_sqrt(a.ctx(), rm, a);
1742  a.check_error();
1743  return expr(a.ctx(), r);
1744  }
1745  inline expr operator~(expr const & a) { Z3_ast r = Z3_mk_bvnot(a.ctx(), a); return expr(a.ctx(), r); }
1746 
1747  inline expr fma(expr const& a, expr const& b, expr const& c, expr const& rm) {
1748  check_context(a, b); check_context(a, c); check_context(a, rm);
1749  assert(a.is_fpa() && b.is_fpa() && c.is_fpa());
1750  Z3_ast r = Z3_mk_fpa_fma(a.ctx(), rm, a, b, c);
1751  a.check_error();
1752  return expr(a.ctx(), r);
1753  }
1754 
1755 
1761  inline expr ite(expr const & c, expr const & t, expr const & e) {
1762  check_context(c, t); check_context(c, e);
1763  assert(c.is_bool());
1764  Z3_ast r = Z3_mk_ite(c.ctx(), c, t, e);
1765  c.check_error();
1766  return expr(c.ctx(), r);
1767  }
1768 
1769 
1774  inline expr to_expr(context & c, Z3_ast a) {
1775  c.check_error();
1776  assert(Z3_get_ast_kind(c, a) == Z3_APP_AST ||
1777  Z3_get_ast_kind(c, a) == Z3_NUMERAL_AST ||
1778  Z3_get_ast_kind(c, a) == Z3_VAR_AST ||
1780  return expr(c, a);
1781  }
1782 
1783  inline sort to_sort(context & c, Z3_sort s) {
1784  c.check_error();
1785  return sort(c, s);
1786  }
1787 
1788  inline func_decl to_func_decl(context & c, Z3_func_decl f) {
1789  c.check_error();
1790  return func_decl(c, f);
1791  }
1792 
1796  inline expr sle(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvsle(a.ctx(), a, b)); }
1797  inline expr sle(expr const & a, int b) { return sle(a, a.ctx().num_val(b, a.get_sort())); }
1798  inline expr sle(int a, expr const & b) { return sle(b.ctx().num_val(a, b.get_sort()), b); }
1802  inline expr slt(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvslt(a.ctx(), a, b)); }
1803  inline expr slt(expr const & a, int b) { return slt(a, a.ctx().num_val(b, a.get_sort())); }
1804  inline expr slt(int a, expr const & b) { return slt(b.ctx().num_val(a, b.get_sort()), b); }
1805 
1806 
1810  inline expr ule(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvule(a.ctx(), a, b)); }
1811  inline expr ule(expr const & a, int b) { return ule(a, a.ctx().num_val(b, a.get_sort())); }
1812  inline expr ule(int a, expr const & b) { return ule(b.ctx().num_val(a, b.get_sort()), b); }
1816  inline expr ult(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvult(a.ctx(), a, b)); }
1817  inline expr ult(expr const & a, int b) { return ult(a, a.ctx().num_val(b, a.get_sort())); }
1818  inline expr ult(int a, expr const & b) { return ult(b.ctx().num_val(a, b.get_sort()), b); }
1822  inline expr uge(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvuge(a.ctx(), a, b)); }
1823  inline expr uge(expr const & a, int b) { return uge(a, a.ctx().num_val(b, a.get_sort())); }
1824  inline expr uge(int a, expr const & b) { return uge(b.ctx().num_val(a, b.get_sort()), b); }
1828  inline expr ugt(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvugt(a.ctx(), a, b)); }
1829  inline expr ugt(expr const & a, int b) { return ugt(a, a.ctx().num_val(b, a.get_sort())); }
1830  inline expr ugt(int a, expr const & b) { return ugt(b.ctx().num_val(a, b.get_sort()), b); }
1834  inline expr udiv(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvudiv(a.ctx(), a, b)); }
1835  inline expr udiv(expr const & a, int b) { return udiv(a, a.ctx().num_val(b, a.get_sort())); }
1836  inline expr udiv(int a, expr const & b) { return udiv(b.ctx().num_val(a, b.get_sort()), b); }
1837 
1841  inline expr srem(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvsrem(a.ctx(), a, b)); }
1842  inline expr srem(expr const & a, int b) { return srem(a, a.ctx().num_val(b, a.get_sort())); }
1843  inline expr srem(int a, expr const & b) { return srem(b.ctx().num_val(a, b.get_sort()), b); }
1844 
1848  inline expr smod(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvsmod(a.ctx(), a, b)); }
1849  inline expr smod(expr const & a, int b) { return smod(a, a.ctx().num_val(b, a.get_sort())); }
1850  inline expr smod(int a, expr const & b) { return smod(b.ctx().num_val(a, b.get_sort()), b); }
1851 
1855  inline expr urem(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvurem(a.ctx(), a, b)); }
1856  inline expr urem(expr const & a, int b) { return urem(a, a.ctx().num_val(b, a.get_sort())); }
1857  inline expr urem(int a, expr const & b) { return urem(b.ctx().num_val(a, b.get_sort()), b); }
1858 
1862  inline expr shl(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvshl(a.ctx(), a, b)); }
1863  inline expr shl(expr const & a, int b) { return shl(a, a.ctx().num_val(b, a.get_sort())); }
1864  inline expr shl(int a, expr const & b) { return shl(b.ctx().num_val(a, b.get_sort()), b); }
1865 
1869  inline expr lshr(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvlshr(a.ctx(), a, b)); }
1870  inline expr lshr(expr const & a, int b) { return lshr(a, a.ctx().num_val(b, a.get_sort())); }
1871  inline expr lshr(int a, expr const & b) { return lshr(b.ctx().num_val(a, b.get_sort()), b); }
1872 
1876  inline expr ashr(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvashr(a.ctx(), a, b)); }
1877  inline expr ashr(expr const & a, int b) { return ashr(a, a.ctx().num_val(b, a.get_sort())); }
1878  inline expr ashr(int a, expr const & b) { return ashr(b.ctx().num_val(a, b.get_sort()), b); }
1879 
1883  inline expr zext(expr const & a, unsigned i) { return to_expr(a.ctx(), Z3_mk_zero_ext(a.ctx(), i, a)); }
1884 
1888  inline expr bv2int(expr const& a, bool is_signed) { Z3_ast r = Z3_mk_bv2int(a.ctx(), a, is_signed); a.check_error(); return expr(a.ctx(), r); }
1889  inline expr int2bv(unsigned n, expr const& a) { Z3_ast r = Z3_mk_int2bv(a.ctx(), n, a); a.check_error(); return expr(a.ctx(), r); }
1890 
1894  inline expr bvadd_no_overflow(expr const& a, expr const& b, bool is_signed) {
1895  check_context(a, b); Z3_ast r = Z3_mk_bvadd_no_overflow(a.ctx(), a, b, is_signed); a.check_error(); return expr(a.ctx(), r);
1896  }
1897  inline expr bvadd_no_underflow(expr const& a, expr const& b) {
1898  check_context(a, b); Z3_ast r = Z3_mk_bvadd_no_underflow(a.ctx(), a, b); a.check_error(); return expr(a.ctx(), r);
1899  }
1900  inline expr bvsub_no_overflow(expr const& a, expr const& b) {
1901  check_context(a, b); Z3_ast r = Z3_mk_bvsub_no_overflow(a.ctx(), a, b); a.check_error(); return expr(a.ctx(), r);
1902  }
1903  inline expr bvsub_no_underflow(expr const& a, expr const& b, bool is_signed) {
1904  check_context(a, b); Z3_ast r = Z3_mk_bvsub_no_underflow(a.ctx(), a, b, is_signed); a.check_error(); return expr(a.ctx(), r);
1905  }
1906  inline expr bvsdiv_no_overflow(expr const& a, expr const& b) {
1907  check_context(a, b); Z3_ast r = Z3_mk_bvsdiv_no_overflow(a.ctx(), a, b); a.check_error(); return expr(a.ctx(), r);
1908  }
1909  inline expr bvneg_no_overflow(expr const& a) {
1910  Z3_ast r = Z3_mk_bvneg_no_overflow(a.ctx(), a); a.check_error(); return expr(a.ctx(), r);
1911  }
1912  inline expr bvmul_no_overflow(expr const& a, expr const& b, bool is_signed) {
1913  check_context(a, b); Z3_ast r = Z3_mk_bvmul_no_overflow(a.ctx(), a, b, is_signed); a.check_error(); return expr(a.ctx(), r);
1914  }
1915  inline expr bvmul_no_underflow(expr const& a, expr const& b) {
1916  check_context(a, b); Z3_ast r = Z3_mk_bvmul_no_underflow(a.ctx(), a, b); a.check_error(); return expr(a.ctx(), r);
1917  }
1918 
1919 
1923  inline expr sext(expr const & a, unsigned i) { return to_expr(a.ctx(), Z3_mk_sign_ext(a.ctx(), i, a)); }
1924 
1925  inline func_decl linear_order(sort const& a, unsigned index) {
1926  return to_func_decl(a.ctx(), Z3_mk_linear_order(a.ctx(), a, index));
1927  }
1928  inline func_decl partial_order(sort const& a, unsigned index) {
1929  return to_func_decl(a.ctx(), Z3_mk_partial_order(a.ctx(), a, index));
1930  }
1931  inline func_decl piecewise_linear_order(sort const& a, unsigned index) {
1932  return to_func_decl(a.ctx(), Z3_mk_piecewise_linear_order(a.ctx(), a, index));
1933  }
1934  inline func_decl tree_order(sort const& a, unsigned index) {
1935  return to_func_decl(a.ctx(), Z3_mk_tree_order(a.ctx(), a, index));
1936  }
1937 
1938  template<> class cast_ast<ast> {
1939  public:
1940  ast operator()(context & c, Z3_ast a) { return ast(c, a); }
1941  };
1942 
1943  template<> class cast_ast<expr> {
1944  public:
1945  expr operator()(context & c, Z3_ast a) {
1946  assert(Z3_get_ast_kind(c, a) == Z3_NUMERAL_AST ||
1947  Z3_get_ast_kind(c, a) == Z3_APP_AST ||
1949  Z3_get_ast_kind(c, a) == Z3_VAR_AST);
1950  return expr(c, a);
1951  }
1952  };
1953 
1954  template<> class cast_ast<sort> {
1955  public:
1956  sort operator()(context & c, Z3_ast a) {
1957  assert(Z3_get_ast_kind(c, a) == Z3_SORT_AST);
1958  return sort(c, reinterpret_cast<Z3_sort>(a));
1959  }
1960  };
1961 
1962  template<> class cast_ast<func_decl> {
1963  public:
1964  func_decl operator()(context & c, Z3_ast a) {
1965  assert(Z3_get_ast_kind(c, a) == Z3_FUNC_DECL_AST);
1966  return func_decl(c, reinterpret_cast<Z3_func_decl>(a));
1967  }
1968  };
1969 
1970  template<typename T>
1971  template<typename T2>
1973  m_array = new T[v.size()];
1974  m_size = v.size();
1975  for (unsigned i = 0; i < m_size; i++) {
1976  m_array[i] = v[i];
1977  }
1978  }
1979 
1980  // Basic functions for creating quantified formulas.
1981  // The C API should be used for creating quantifiers with patterns, weights, many variables, etc.
1982  inline expr forall(expr const & x, expr const & b) {
1983  check_context(x, b);
1984  Z3_app vars[] = {(Z3_app) x};
1985  Z3_ast r = Z3_mk_forall_const(b.ctx(), 0, 1, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
1986  }
1987  inline expr forall(expr const & x1, expr const & x2, expr const & b) {
1988  check_context(x1, b); check_context(x2, b);
1989  Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2};
1990  Z3_ast r = Z3_mk_forall_const(b.ctx(), 0, 2, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
1991  }
1992  inline expr forall(expr const & x1, expr const & x2, expr const & x3, expr const & b) {
1993  check_context(x1, b); check_context(x2, b); check_context(x3, b);
1994  Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3 };
1995  Z3_ast r = Z3_mk_forall_const(b.ctx(), 0, 3, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
1996  }
1997  inline expr forall(expr const & x1, expr const & x2, expr const & x3, expr const & x4, expr const & b) {
1998  check_context(x1, b); check_context(x2, b); check_context(x3, b); check_context(x4, b);
1999  Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3, (Z3_app) x4 };
2000  Z3_ast r = Z3_mk_forall_const(b.ctx(), 0, 4, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
2001  }
2002  inline expr forall(expr_vector const & xs, expr const & b) {
2003  array<Z3_app> vars(xs);
2004  Z3_ast r = Z3_mk_forall_const(b.ctx(), 0, vars.size(), vars.ptr(), 0, 0, b); b.check_error(); return expr(b.ctx(), r);
2005  }
2006  inline expr exists(expr const & x, expr const & b) {
2007  check_context(x, b);
2008  Z3_app vars[] = {(Z3_app) x};
2009  Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, 1, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
2010  }
2011  inline expr exists(expr const & x1, expr const & x2, expr const & b) {
2012  check_context(x1, b); check_context(x2, b);
2013  Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2};
2014  Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, 2, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
2015  }
2016  inline expr exists(expr const & x1, expr const & x2, expr const & x3, expr const & b) {
2017  check_context(x1, b); check_context(x2, b); check_context(x3, b);
2018  Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3 };
2019  Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, 3, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
2020  }
2021  inline expr exists(expr const & x1, expr const & x2, expr const & x3, expr const & x4, expr const & b) {
2022  check_context(x1, b); check_context(x2, b); check_context(x3, b); check_context(x4, b);
2023  Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3, (Z3_app) x4 };
2024  Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, 4, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
2025  }
2026  inline expr exists(expr_vector const & xs, expr const & b) {
2027  array<Z3_app> vars(xs);
2028  Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, vars.size(), vars.ptr(), 0, 0, b); b.check_error(); return expr(b.ctx(), r);
2029  }
2030  inline expr lambda(expr const & x, expr const & b) {
2031  check_context(x, b);
2032  Z3_app vars[] = {(Z3_app) x};
2033  Z3_ast r = Z3_mk_lambda_const(b.ctx(), 1, vars, b); b.check_error(); return expr(b.ctx(), r);
2034  }
2035  inline expr lambda(expr const & x1, expr const & x2, expr const & b) {
2036  check_context(x1, b); check_context(x2, b);
2037  Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2};
2038  Z3_ast r = Z3_mk_lambda_const(b.ctx(), 2, vars, b); b.check_error(); return expr(b.ctx(), r);
2039  }
2040  inline expr lambda(expr const & x1, expr const & x2, expr const & x3, expr const & b) {
2041  check_context(x1, b); check_context(x2, b); check_context(x3, b);
2042  Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3 };
2043  Z3_ast r = Z3_mk_lambda_const(b.ctx(), 3, vars, b); b.check_error(); return expr(b.ctx(), r);
2044  }
2045  inline expr lambda(expr const & x1, expr const & x2, expr const & x3, expr const & x4, expr const & b) {
2046  check_context(x1, b); check_context(x2, b); check_context(x3, b); check_context(x4, b);
2047  Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3, (Z3_app) x4 };
2048  Z3_ast r = Z3_mk_lambda_const(b.ctx(), 4, vars, b); b.check_error(); return expr(b.ctx(), r);
2049  }
2050  inline expr lambda(expr_vector const & xs, expr const & b) {
2051  array<Z3_app> vars(xs);
2052  Z3_ast r = Z3_mk_lambda_const(b.ctx(), vars.size(), vars.ptr(), b); b.check_error(); return expr(b.ctx(), r);
2053  }
2054 
2055  inline expr pble(expr_vector const& es, int const* coeffs, int bound) {
2056  assert(es.size() > 0);
2057  context& ctx = es[0].ctx();
2058  array<Z3_ast> _es(es);
2059  Z3_ast r = Z3_mk_pble(ctx, _es.size(), _es.ptr(), coeffs, bound);
2060  ctx.check_error();
2061  return expr(ctx, r);
2062  }
2063  inline expr pbge(expr_vector const& es, int const* coeffs, int bound) {
2064  assert(es.size() > 0);
2065  context& ctx = es[0].ctx();
2066  array<Z3_ast> _es(es);
2067  Z3_ast r = Z3_mk_pbge(ctx, _es.size(), _es.ptr(), coeffs, bound);
2068  ctx.check_error();
2069  return expr(ctx, r);
2070  }
2071  inline expr pbeq(expr_vector const& es, int const* coeffs, int bound) {
2072  assert(es.size() > 0);
2073  context& ctx = es[0].ctx();
2074  array<Z3_ast> _es(es);
2075  Z3_ast r = Z3_mk_pbeq(ctx, _es.size(), _es.ptr(), coeffs, bound);
2076  ctx.check_error();
2077  return expr(ctx, r);
2078  }
2079  inline expr atmost(expr_vector const& es, unsigned bound) {
2080  assert(es.size() > 0);
2081  context& ctx = es[0].ctx();
2082  array<Z3_ast> _es(es);
2083  Z3_ast r = Z3_mk_atmost(ctx, _es.size(), _es.ptr(), bound);
2084  ctx.check_error();
2085  return expr(ctx, r);
2086  }
2087  inline expr atleast(expr_vector const& es, unsigned bound) {
2088  assert(es.size() > 0);
2089  context& ctx = es[0].ctx();
2090  array<Z3_ast> _es(es);
2091  Z3_ast r = Z3_mk_atleast(ctx, _es.size(), _es.ptr(), bound);
2092  ctx.check_error();
2093  return expr(ctx, r);
2094  }
2095  inline expr sum(expr_vector const& args) {
2096  assert(args.size() > 0);
2097  context& ctx = args[0].ctx();
2098  array<Z3_ast> _args(args);
2099  Z3_ast r = Z3_mk_add(ctx, _args.size(), _args.ptr());
2100  ctx.check_error();
2101  return expr(ctx, r);
2102  }
2103 
2104  inline expr distinct(expr_vector const& args) {
2105  assert(args.size() > 0);
2106  context& ctx = args[0].ctx();
2107  array<Z3_ast> _args(args);
2108  Z3_ast r = Z3_mk_distinct(ctx, _args.size(), _args.ptr());
2109  ctx.check_error();
2110  return expr(ctx, r);
2111  }
2112 
2113  inline expr concat(expr const& a, expr const& b) {
2114  check_context(a, b);
2115  Z3_ast r;
2116  if (Z3_is_seq_sort(a.ctx(), a.get_sort())) {
2117  Z3_ast _args[2] = { a, b };
2118  r = Z3_mk_seq_concat(a.ctx(), 2, _args);
2119  }
2120  else if (Z3_is_re_sort(a.ctx(), a.get_sort())) {
2121  Z3_ast _args[2] = { a, b };
2122  r = Z3_mk_re_concat(a.ctx(), 2, _args);
2123  }
2124  else {
2125  r = Z3_mk_concat(a.ctx(), a, b);
2126  }
2127  a.ctx().check_error();
2128  return expr(a.ctx(), r);
2129  }
2130 
2131  inline expr concat(expr_vector const& args) {
2132  Z3_ast r;
2133  assert(args.size() > 0);
2134  if (args.size() == 1) {
2135  return args[0];
2136  }
2137  context& ctx = args[0].ctx();
2138  array<Z3_ast> _args(args);
2139  if (Z3_is_seq_sort(ctx, args[0].get_sort())) {
2140  r = Z3_mk_seq_concat(ctx, _args.size(), _args.ptr());
2141  }
2142  else if (Z3_is_re_sort(ctx, args[0].get_sort())) {
2143  r = Z3_mk_re_concat(ctx, _args.size(), _args.ptr());
2144  }
2145  else {
2146  r = _args[args.size()-1];
2147  for (unsigned i = args.size()-1; i > 0; ) {
2148  --i;
2149  r = Z3_mk_concat(ctx, _args[i], r);
2150  ctx.check_error();
2151  }
2152  }
2153  ctx.check_error();
2154  return expr(ctx, r);
2155  }
2156 
2157  inline expr mk_or(expr_vector const& args) {
2158  array<Z3_ast> _args(args);
2159  Z3_ast r = Z3_mk_or(args.ctx(), _args.size(), _args.ptr());
2160  args.check_error();
2161  return expr(args.ctx(), r);
2162  }
2163  inline expr mk_and(expr_vector const& args) {
2164  array<Z3_ast> _args(args);
2165  Z3_ast r = Z3_mk_and(args.ctx(), _args.size(), _args.ptr());
2166  args.check_error();
2167  return expr(args.ctx(), r);
2168  }
2169 
2170 
2171  class func_entry : public object {
2172  Z3_func_entry m_entry;
2173  void init(Z3_func_entry e) {
2174  m_entry = e;
2175  Z3_func_entry_inc_ref(ctx(), m_entry);
2176  }
2177  public:
2178  func_entry(context & c, Z3_func_entry e):object(c) { init(e); }
2179  func_entry(func_entry const & s):object(s) { init(s.m_entry); }
2181  operator Z3_func_entry() const { return m_entry; }
2183  Z3_func_entry_inc_ref(s.ctx(), s.m_entry);
2184  Z3_func_entry_dec_ref(ctx(), m_entry);
2185  m_ctx = s.m_ctx;
2186  m_entry = s.m_entry;
2187  return *this;
2188  }
2189  expr value() const { Z3_ast r = Z3_func_entry_get_value(ctx(), m_entry); check_error(); return expr(ctx(), r); }
2190  unsigned num_args() const { unsigned r = Z3_func_entry_get_num_args(ctx(), m_entry); check_error(); return r; }
2191  expr arg(unsigned i) const { Z3_ast r = Z3_func_entry_get_arg(ctx(), m_entry, i); check_error(); return expr(ctx(), r); }
2192  };
2193 
2194  class func_interp : public object {
2195  Z3_func_interp m_interp;
2196  void init(Z3_func_interp e) {
2197  m_interp = e;
2198  Z3_func_interp_inc_ref(ctx(), m_interp);
2199  }
2200  public:
2201  func_interp(context & c, Z3_func_interp e):object(c) { init(e); }
2202  func_interp(func_interp const & s):object(s) { init(s.m_interp); }
2204  operator Z3_func_interp() const { return m_interp; }
2206  Z3_func_interp_inc_ref(s.ctx(), s.m_interp);
2207  Z3_func_interp_dec_ref(ctx(), m_interp);
2208  m_ctx = s.m_ctx;
2209  m_interp = s.m_interp;
2210  return *this;
2211  }
2212  expr else_value() const { Z3_ast r = Z3_func_interp_get_else(ctx(), m_interp); check_error(); return expr(ctx(), r); }
2213  unsigned num_entries() const { unsigned r = Z3_func_interp_get_num_entries(ctx(), m_interp); check_error(); return r; }
2214  func_entry entry(unsigned i) const { Z3_func_entry e = Z3_func_interp_get_entry(ctx(), m_interp, i); check_error(); return func_entry(ctx(), e); }
2215  void add_entry(expr_vector const& args, expr& value) {
2216  Z3_func_interp_add_entry(ctx(), m_interp, args, value);
2217  check_error();
2218  }
2219  void set_else(expr& value) {
2220  Z3_func_interp_set_else(ctx(), m_interp, value);
2221  check_error();
2222  }
2223  };
2224 
2225  class model : public object {
2226  Z3_model m_model;
2227  void init(Z3_model m) {
2228  m_model = m;
2229  Z3_model_inc_ref(ctx(), m);
2230  }
2231  public:
2232  struct translate {};
2233  model(context & c):object(c) { init(Z3_mk_model(c)); }
2234  model(context & c, Z3_model m):object(c) { init(m); }
2235  model(model const & s):object(s) { init(s.m_model); }
2236  model(model& src, context& dst, translate) : object(dst) { init(Z3_model_translate(src.ctx(), src, dst)); }
2237  ~model() { Z3_model_dec_ref(ctx(), m_model); }
2238  operator Z3_model() const { return m_model; }
2239  model & operator=(model const & s) {
2240  Z3_model_inc_ref(s.ctx(), s.m_model);
2241  Z3_model_dec_ref(ctx(), m_model);
2242  m_ctx = s.m_ctx;
2243  m_model = s.m_model;
2244  return *this;
2245  }
2246 
2247  expr eval(expr const & n, bool model_completion=false) const {
2248  check_context(*this, n);
2249  Z3_ast r = 0;
2250  bool status = Z3_model_eval(ctx(), m_model, n, model_completion, &r);
2251  check_error();
2252  if (status == false && ctx().enable_exceptions())
2253  Z3_THROW(exception("failed to evaluate expression"));
2254  return expr(ctx(), r);
2255  }
2256 
2257  unsigned num_consts() const { return Z3_model_get_num_consts(ctx(), m_model); }
2258  unsigned num_funcs() const { return Z3_model_get_num_funcs(ctx(), m_model); }
2259  func_decl get_const_decl(unsigned i) const { Z3_func_decl r = Z3_model_get_const_decl(ctx(), m_model, i); check_error(); return func_decl(ctx(), r); }
2260  func_decl get_func_decl(unsigned i) const { Z3_func_decl r = Z3_model_get_func_decl(ctx(), m_model, i); check_error(); return func_decl(ctx(), r); }
2261  unsigned size() const { return num_consts() + num_funcs(); }
2262  func_decl operator[](int i) const {
2263  assert(0 <= i);
2264  return static_cast<unsigned>(i) < num_consts() ? get_const_decl(i) : get_func_decl(i - num_consts());
2265  }
2266 
2267  // returns interpretation of constant declaration c.
2268  // If c is not assigned any value in the model it returns
2269  // an expression with a null ast reference.
2271  check_context(*this, c);
2272  Z3_ast r = Z3_model_get_const_interp(ctx(), m_model, c);
2273  check_error();
2274  return expr(ctx(), r);
2275  }
2277  check_context(*this, f);
2278  Z3_func_interp r = Z3_model_get_func_interp(ctx(), m_model, f);
2279  check_error();
2280  return func_interp(ctx(), r);
2281  }
2282 
2283  // returns true iff the model contains an interpretation
2284  // for function f.
2285  bool has_interp(func_decl f) const {
2286  check_context(*this, f);
2287  return Z3_model_has_interp(ctx(), m_model, f);
2288  }
2289 
2291  Z3_func_interp r = Z3_add_func_interp(ctx(), m_model, f, else_val);
2292  check_error();
2293  return func_interp(ctx(), r);
2294  }
2295 
2296  void add_const_interp(func_decl& f, expr& value) {
2297  Z3_add_const_interp(ctx(), m_model, f, value);
2298  check_error();
2299  }
2300 
2301  friend std::ostream & operator<<(std::ostream & out, model const & m);
2302  };
2303  inline std::ostream & operator<<(std::ostream & out, model const & m) { out << Z3_model_to_string(m.ctx(), m); return out; }
2304 
2305  class stats : public object {
2306  Z3_stats m_stats;
2307  void init(Z3_stats e) {
2308  m_stats = e;
2309  Z3_stats_inc_ref(ctx(), m_stats);
2310  }
2311  public:
2312  stats(context & c):object(c), m_stats(0) {}
2313  stats(context & c, Z3_stats e):object(c) { init(e); }
2314  stats(stats const & s):object(s) { init(s.m_stats); }
2315  ~stats() { if (m_stats) Z3_stats_dec_ref(ctx(), m_stats); }
2316  operator Z3_stats() const { return m_stats; }
2317  stats & operator=(stats const & s) {
2318  Z3_stats_inc_ref(s.ctx(), s.m_stats);
2319  if (m_stats) Z3_stats_dec_ref(ctx(), m_stats);
2320  m_ctx = s.m_ctx;
2321  m_stats = s.m_stats;
2322  return *this;
2323  }
2324  unsigned size() const { return Z3_stats_size(ctx(), m_stats); }
2325  std::string key(unsigned i) const { Z3_string s = Z3_stats_get_key(ctx(), m_stats, i); check_error(); return s; }
2326  bool is_uint(unsigned i) const { bool r = Z3_stats_is_uint(ctx(), m_stats, i); check_error(); return r; }
2327  bool is_double(unsigned i) const { bool r = Z3_stats_is_double(ctx(), m_stats, i); check_error(); return r; }
2328  unsigned uint_value(unsigned i) const { unsigned r = Z3_stats_get_uint_value(ctx(), m_stats, i); check_error(); return r; }
2329  double double_value(unsigned i) const { double r = Z3_stats_get_double_value(ctx(), m_stats, i); check_error(); return r; }
2330  friend std::ostream & operator<<(std::ostream & out, stats const & s);
2331  };
2332  inline std::ostream & operator<<(std::ostream & out, stats const & s) { out << Z3_stats_to_string(s.ctx(), s); return out; }
2333 
2334 
2335  inline std::ostream & operator<<(std::ostream & out, check_result r) {
2336  if (r == unsat) out << "unsat";
2337  else if (r == sat) out << "sat";
2338  else out << "unknown";
2339  return out;
2340  }
2341 
2342 
2343  class solver : public object {
2344  Z3_solver m_solver;
2345  void init(Z3_solver s) {
2346  m_solver = s;
2347  Z3_solver_inc_ref(ctx(), s);
2348  }
2349  public:
2350  struct simple {};
2351  struct translate {};
2352  solver(context & c):object(c) { init(Z3_mk_solver(c)); }
2354  solver(context & c, Z3_solver s):object(c) { init(s); }
2355  solver(context & c, char const * logic):object(c) { init(Z3_mk_solver_for_logic(c, c.str_symbol(logic))); }
2356  solver(context & c, solver const& src, translate): object(c) { init(Z3_solver_translate(src.ctx(), src, c)); }
2357  solver(solver const & s):object(s) { init(s.m_solver); }
2358  ~solver() { Z3_solver_dec_ref(ctx(), m_solver); }
2359  operator Z3_solver() const { return m_solver; }
2360  solver & operator=(solver const & s) {
2361  Z3_solver_inc_ref(s.ctx(), s.m_solver);
2362  Z3_solver_dec_ref(ctx(), m_solver);
2363  m_ctx = s.m_ctx;
2364  m_solver = s.m_solver;
2365  return *this;
2366  }
2367  void set(params const & p) { Z3_solver_set_params(ctx(), m_solver, p); check_error(); }
2368  void set(char const * k, bool v) { params p(ctx()); p.set(k, v); set(p); }
2369  void set(char const * k, unsigned v) { params p(ctx()); p.set(k, v); set(p); }
2370  void set(char const * k, double v) { params p(ctx()); p.set(k, v); set(p); }
2371  void set(char const * k, symbol const & v) { params p(ctx()); p.set(k, v); set(p); }
2372  void set(char const * k, char const* v) { params p(ctx()); p.set(k, v); set(p); }
2373  void push() { Z3_solver_push(ctx(), m_solver); check_error(); }
2374  void pop(unsigned n = 1) { Z3_solver_pop(ctx(), m_solver, n); check_error(); }
2375  void reset() { Z3_solver_reset(ctx(), m_solver); check_error(); }
2376  void add(expr const & e) { assert(e.is_bool()); Z3_solver_assert(ctx(), m_solver, e); check_error(); }
2377  void add(expr const & e, expr const & p) {
2378  assert(e.is_bool()); assert(p.is_bool()); assert(p.is_const());
2379  Z3_solver_assert_and_track(ctx(), m_solver, e, p);
2380  check_error();
2381  }
2382  void add(expr const & e, char const * p) {
2383  add(e, ctx().bool_const(p));
2384  }
2385  // fails for some compilers:
2386  // void add(expr_vector const& v) { check_context(*this, v); for (expr e : v) add(e); }
2387  void from_file(char const* file) { Z3_solver_from_file(ctx(), m_solver, file); ctx().check_parser_error(); }
2388  void from_string(char const* s) { Z3_solver_from_string(ctx(), m_solver, s); ctx().check_parser_error(); }
2389 
2391  check_result check(unsigned n, expr * const assumptions) {
2392  array<Z3_ast> _assumptions(n);
2393  for (unsigned i = 0; i < n; i++) {
2394  check_context(*this, assumptions[i]);
2395  _assumptions[i] = assumptions[i];
2396  }
2397  Z3_lbool r = Z3_solver_check_assumptions(ctx(), m_solver, n, _assumptions.ptr());
2398  check_error();
2399  return to_check_result(r);
2400  }
2401  check_result check(expr_vector const& assumptions) {
2402  unsigned n = assumptions.size();
2403  array<Z3_ast> _assumptions(n);
2404  for (unsigned i = 0; i < n; i++) {
2405  check_context(*this, assumptions[i]);
2406  _assumptions[i] = assumptions[i];
2407  }
2408  Z3_lbool r = Z3_solver_check_assumptions(ctx(), m_solver, n, _assumptions.ptr());
2409  check_error();
2410  return to_check_result(r);
2411  }
2412  model get_model() const { Z3_model m = Z3_solver_get_model(ctx(), m_solver); check_error(); return model(ctx(), m); }
2414  Z3_lbool r = Z3_solver_get_consequences(ctx(), m_solver, assumptions, vars, conseq);
2415  check_error();
2416  return to_check_result(r);
2417  }
2418  std::string reason_unknown() const { Z3_string r = Z3_solver_get_reason_unknown(ctx(), m_solver); check_error(); return r; }
2419  stats statistics() const { Z3_stats r = Z3_solver_get_statistics(ctx(), m_solver); check_error(); return stats(ctx(), r); }
2420  expr_vector unsat_core() const { Z3_ast_vector r = Z3_solver_get_unsat_core(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
2421  expr_vector assertions() const { Z3_ast_vector r = Z3_solver_get_assertions(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
2422  expr_vector non_units() const { Z3_ast_vector r = Z3_solver_get_non_units(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
2423  expr_vector units() const { Z3_ast_vector r = Z3_solver_get_units(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
2424  expr_vector trail() const { Z3_ast_vector r = Z3_solver_get_trail(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
2426  Z3_ast_vector r = Z3_solver_get_trail(ctx(), m_solver);
2427  check_error();
2428  expr_vector result(ctx(), r);
2429  unsigned sz = result.size();
2430  levels.resize(sz);
2431  Z3_solver_get_levels(ctx(), m_solver, r, sz, levels.ptr());
2432  check_error();
2433  return result;
2434  }
2435  expr proof() const { Z3_ast r = Z3_solver_get_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); }
2436  friend std::ostream & operator<<(std::ostream & out, solver const & s);
2437 
2438  std::string to_smt2(char const* status = "unknown") {
2439  array<Z3_ast> es(assertions());
2440  Z3_ast const* fmls = es.ptr();
2441  Z3_ast fml = 0;
2442  unsigned sz = es.size();
2443  if (sz > 0) {
2444  --sz;
2445  fml = fmls[sz];
2446  }
2447  else {
2448  fml = ctx().bool_val(true);
2449  }
2450  return std::string(Z3_benchmark_to_smtlib_string(
2451  ctx(),
2452  "", "", status, "",
2453  sz,
2454  fmls,
2455  fml));
2456  }
2457 
2458  std::string dimacs(bool include_names = true) const { return std::string(Z3_solver_to_dimacs_string(ctx(), m_solver, include_names)); }
2459 
2461 
2462 
2463  expr_vector cube(expr_vector& vars, unsigned cutoff) {
2464  Z3_ast_vector r = Z3_solver_cube(ctx(), m_solver, vars, cutoff);
2465  check_error();
2466  return expr_vector(ctx(), r);
2467  }
2468 
2470  solver& m_solver;
2471  unsigned& m_cutoff;
2472  expr_vector& m_vars;
2473  expr_vector m_cube;
2474  bool m_end;
2475  bool m_empty;
2476 
2477  void inc() {
2478  assert(!m_end && !m_empty);
2479  m_cube = m_solver.cube(m_vars, m_cutoff);
2480  m_cutoff = 0xFFFFFFFF;
2481  if (m_cube.size() == 1 && m_cube[0].is_false()) {
2482  m_cube = z3::expr_vector(m_solver.ctx());
2483  m_end = true;
2484  }
2485  else if (m_cube.empty()) {
2486  m_empty = true;
2487  }
2488  }
2489  public:
2490  cube_iterator(solver& s, expr_vector& vars, unsigned& cutoff, bool end):
2491  m_solver(s),
2492  m_cutoff(cutoff),
2493  m_vars(vars),
2494  m_cube(s.ctx()),
2495  m_end(end),
2496  m_empty(false) {
2497  if (!m_end) {
2498  inc();
2499  }
2500  }
2501 
2503  assert(!m_end);
2504  if (m_empty) {
2505  m_end = true;
2506  }
2507  else {
2508  inc();
2509  }
2510  return *this;
2511  }
2512  cube_iterator operator++(int) { assert(false); return *this; }
2513  expr_vector const * operator->() const { return &(operator*()); }
2514  expr_vector const& operator*() const { return m_cube; }
2515 
2516  bool operator==(cube_iterator const& other) {
2517  return other.m_end == m_end;
2518  };
2519  bool operator!=(cube_iterator const& other) {
2520  return other.m_end != m_end;
2521  };
2522 
2523  };
2524 
2526  solver& m_solver;
2527  unsigned m_cutoff;
2528  expr_vector m_default_vars;
2529  expr_vector& m_vars;
2530  public:
2532  m_solver(s),
2533  m_cutoff(0xFFFFFFFF),
2534  m_default_vars(s.ctx()),
2535  m_vars(m_default_vars)
2536  {}
2537 
2539  m_solver(s),
2540  m_cutoff(0xFFFFFFFF),
2541  m_default_vars(s.ctx()),
2542  m_vars(vars)
2543  {}
2544 
2545  cube_iterator begin() { return cube_iterator(m_solver, m_vars, m_cutoff, false); }
2546  cube_iterator end() { return cube_iterator(m_solver, m_vars, m_cutoff, true); }
2547  void set_cutoff(unsigned c) { m_cutoff = c; }
2548  };
2549 
2550  cube_generator cubes() { return cube_generator(*this); }
2551  cube_generator cubes(expr_vector& vars) { return cube_generator(*this, vars); }
2552 
2553  };
2554  inline std::ostream & operator<<(std::ostream & out, solver const & s) { out << Z3_solver_to_string(s.ctx(), s); return out; }
2555 
2556  class goal : public object {
2557  Z3_goal m_goal;
2558  void init(Z3_goal s) {
2559  m_goal = s;
2560  Z3_goal_inc_ref(ctx(), s);
2561  }
2562  public:
2563  goal(context & c, bool models=true, bool unsat_cores=false, bool proofs=false):object(c) { init(Z3_mk_goal(c, models, unsat_cores, proofs)); }
2564  goal(context & c, Z3_goal s):object(c) { init(s); }
2565  goal(goal const & s):object(s) { init(s.m_goal); }
2566  ~goal() { Z3_goal_dec_ref(ctx(), m_goal); }
2567  operator Z3_goal() const { return m_goal; }
2568  goal & operator=(goal const & s) {
2569  Z3_goal_inc_ref(s.ctx(), s.m_goal);
2570  Z3_goal_dec_ref(ctx(), m_goal);
2571  m_ctx = s.m_ctx;
2572  m_goal = s.m_goal;
2573  return *this;
2574  }
2575  void add(expr const & f) { check_context(*this, f); Z3_goal_assert(ctx(), m_goal, f); check_error(); }
2576  void add(expr_vector const& v) { check_context(*this, v); for (unsigned i = 0; i < v.size(); ++i) add(v[i]); }
2577  unsigned size() const { return Z3_goal_size(ctx(), m_goal); }
2578  expr operator[](int i) const { assert(0 <= i); Z3_ast r = Z3_goal_formula(ctx(), m_goal, i); check_error(); return expr(ctx(), r); }
2579  Z3_goal_prec precision() const { return Z3_goal_precision(ctx(), m_goal); }
2580  bool inconsistent() const { return Z3_goal_inconsistent(ctx(), m_goal); }
2581  unsigned depth() const { return Z3_goal_depth(ctx(), m_goal); }
2582  void reset() { Z3_goal_reset(ctx(), m_goal); }
2583  unsigned num_exprs() const { return Z3_goal_num_exprs(ctx(), m_goal); }
2584  bool is_decided_sat() const { return Z3_goal_is_decided_sat(ctx(), m_goal); }
2585  bool is_decided_unsat() const { return Z3_goal_is_decided_unsat(ctx(), m_goal); }
2586  model convert_model(model const & m) const {
2587  check_context(*this, m);
2588  Z3_model new_m = Z3_goal_convert_model(ctx(), m_goal, m);
2589  check_error();
2590  return model(ctx(), new_m);
2591  }
2592  model get_model() const {
2593  Z3_model new_m = Z3_goal_convert_model(ctx(), m_goal, 0);
2594  check_error();
2595  return model(ctx(), new_m);
2596  }
2597  expr as_expr() const {
2598  unsigned n = size();
2599  if (n == 0)
2600  return ctx().bool_val(true);
2601  else if (n == 1)
2602  return operator[](0);
2603  else {
2604  array<Z3_ast> args(n);
2605  for (unsigned i = 0; i < n; i++)
2606  args[i] = operator[](i);
2607  return expr(ctx(), Z3_mk_and(ctx(), n, args.ptr()));
2608  }
2609  }
2610  std::string dimacs() const { return std::string(Z3_goal_to_dimacs_string(ctx(), m_goal)); }
2611  friend std::ostream & operator<<(std::ostream & out, goal const & g);
2612  };
2613  inline std::ostream & operator<<(std::ostream & out, goal const & g) { out << Z3_goal_to_string(g.ctx(), g); return out; }
2614 
2615  class apply_result : public object {
2616  Z3_apply_result m_apply_result;
2617  void init(Z3_apply_result s) {
2618  m_apply_result = s;
2620  }
2621  public:
2622  apply_result(context & c, Z3_apply_result s):object(c) { init(s); }
2623  apply_result(apply_result const & s):object(s) { init(s.m_apply_result); }
2624  ~apply_result() { Z3_apply_result_dec_ref(ctx(), m_apply_result); }
2625  operator Z3_apply_result() const { return m_apply_result; }
2627  Z3_apply_result_inc_ref(s.ctx(), s.m_apply_result);
2628  Z3_apply_result_dec_ref(ctx(), m_apply_result);
2629  m_ctx = s.m_ctx;
2630  m_apply_result = s.m_apply_result;
2631  return *this;
2632  }
2633  unsigned size() const { return Z3_apply_result_get_num_subgoals(ctx(), m_apply_result); }
2634  goal operator[](int i) const { assert(0 <= i); Z3_goal r = Z3_apply_result_get_subgoal(ctx(), m_apply_result, i); check_error(); return goal(ctx(), r); }
2635  friend std::ostream & operator<<(std::ostream & out, apply_result const & r);
2636  };
2637  inline std::ostream & operator<<(std::ostream & out, apply_result const & r) { out << Z3_apply_result_to_string(r.ctx(), r); return out; }
2638 
2639  class tactic : public object {
2640  Z3_tactic m_tactic;
2641  void init(Z3_tactic s) {
2642  m_tactic = s;
2643  Z3_tactic_inc_ref(ctx(), s);
2644  }
2645  public:
2646  tactic(context & c, char const * name):object(c) { Z3_tactic r = Z3_mk_tactic(c, name); check_error(); init(r); }
2647  tactic(context & c, Z3_tactic s):object(c) { init(s); }
2648  tactic(tactic const & s):object(s) { init(s.m_tactic); }
2649  ~tactic() { Z3_tactic_dec_ref(ctx(), m_tactic); }
2650  operator Z3_tactic() const { return m_tactic; }
2651  tactic & operator=(tactic const & s) {
2652  Z3_tactic_inc_ref(s.ctx(), s.m_tactic);
2653  Z3_tactic_dec_ref(ctx(), m_tactic);
2654  m_ctx = s.m_ctx;
2655  m_tactic = s.m_tactic;
2656  return *this;
2657  }
2658  solver mk_solver() const { Z3_solver r = Z3_mk_solver_from_tactic(ctx(), m_tactic); check_error(); return solver(ctx(), r); }
2659  apply_result apply(goal const & g) const {
2660  check_context(*this, g);
2661  Z3_apply_result r = Z3_tactic_apply(ctx(), m_tactic, g);
2662  check_error();
2663  return apply_result(ctx(), r);
2664  }
2665  apply_result operator()(goal const & g) const {
2666  return apply(g);
2667  }
2668  std::string help() const { char const * r = Z3_tactic_get_help(ctx(), m_tactic); check_error(); return r; }
2669  friend tactic operator&(tactic const & t1, tactic const & t2);
2670  friend tactic operator|(tactic const & t1, tactic const & t2);
2671  friend tactic repeat(tactic const & t, unsigned max);
2672  friend tactic with(tactic const & t, params const & p);
2673  friend tactic try_for(tactic const & t, unsigned ms);
2674  friend tactic par_or(unsigned n, tactic const* tactics);
2675  friend tactic par_and_then(tactic const& t1, tactic const& t2);
2677  };
2678 
2679  inline tactic operator&(tactic const & t1, tactic const & t2) {
2680  check_context(t1, t2);
2681  Z3_tactic r = Z3_tactic_and_then(t1.ctx(), t1, t2);
2682  t1.check_error();
2683  return tactic(t1.ctx(), r);
2684  }
2685 
2686  inline tactic operator|(tactic const & t1, tactic const & t2) {
2687  check_context(t1, t2);
2688  Z3_tactic r = Z3_tactic_or_else(t1.ctx(), t1, t2);
2689  t1.check_error();
2690  return tactic(t1.ctx(), r);
2691  }
2692 
2693  inline tactic repeat(tactic const & t, unsigned max=UINT_MAX) {
2694  Z3_tactic r = Z3_tactic_repeat(t.ctx(), t, max);
2695  t.check_error();
2696  return tactic(t.ctx(), r);
2697  }
2698 
2699  inline tactic with(tactic const & t, params const & p) {
2700  Z3_tactic r = Z3_tactic_using_params(t.ctx(), t, p);
2701  t.check_error();
2702  return tactic(t.ctx(), r);
2703  }
2704  inline tactic try_for(tactic const & t, unsigned ms) {
2705  Z3_tactic r = Z3_tactic_try_for(t.ctx(), t, ms);
2706  t.check_error();
2707  return tactic(t.ctx(), r);
2708  }
2709  inline tactic par_or(unsigned n, tactic const* tactics) {
2710  if (n == 0) {
2711  Z3_THROW(exception("a non-zero number of tactics need to be passed to par_or"));
2712  }
2713  array<Z3_tactic> buffer(n);
2714  for (unsigned i = 0; i < n; ++i) buffer[i] = tactics[i];
2715  return tactic(tactics[0].ctx(), Z3_tactic_par_or(tactics[0].ctx(), n, buffer.ptr()));
2716  }
2717 
2718  inline tactic par_and_then(tactic const & t1, tactic const & t2) {
2719  check_context(t1, t2);
2720  Z3_tactic r = Z3_tactic_par_and_then(t1.ctx(), t1, t2);
2721  t1.check_error();
2722  return tactic(t1.ctx(), r);
2723  }
2724 
2725  class probe : public object {
2726  Z3_probe m_probe;
2727  void init(Z3_probe s) {
2728  m_probe = s;
2729  Z3_probe_inc_ref(ctx(), s);
2730  }
2731  public:
2732  probe(context & c, char const * name):object(c) { Z3_probe r = Z3_mk_probe(c, name); check_error(); init(r); }
2733  probe(context & c, double val):object(c) { Z3_probe r = Z3_probe_const(c, val); check_error(); init(r); }
2734  probe(context & c, Z3_probe s):object(c) { init(s); }
2735  probe(probe const & s):object(s) { init(s.m_probe); }
2736  ~probe() { Z3_probe_dec_ref(ctx(), m_probe); }
2737  operator Z3_probe() const { return m_probe; }
2738  probe & operator=(probe const & s) {
2739  Z3_probe_inc_ref(s.ctx(), s.m_probe);
2740  Z3_probe_dec_ref(ctx(), m_probe);
2741  m_ctx = s.m_ctx;
2742  m_probe = s.m_probe;
2743  return *this;
2744  }
2745  double apply(goal const & g) const { double r = Z3_probe_apply(ctx(), m_probe, g); check_error(); return r; }
2746  double operator()(goal const & g) const { return apply(g); }
2747  friend probe operator<=(probe const & p1, probe const & p2);
2748  friend probe operator<=(probe const & p1, double p2);
2749  friend probe operator<=(double p1, probe const & p2);
2750  friend probe operator>=(probe const & p1, probe const & p2);
2751  friend probe operator>=(probe const & p1, double p2);
2752  friend probe operator>=(double p1, probe const & p2);
2753  friend probe operator<(probe const & p1, probe const & p2);
2754  friend probe operator<(probe const & p1, double p2);
2755  friend probe operator<(double p1, probe const & p2);
2756  friend probe operator>(probe const & p1, probe const & p2);
2757  friend probe operator>(probe const & p1, double p2);
2758  friend probe operator>(double p1, probe const & p2);
2759  friend probe operator==(probe const & p1, probe const & p2);
2760  friend probe operator==(probe const & p1, double p2);
2761  friend probe operator==(double p1, probe const & p2);
2762  friend probe operator&&(probe const & p1, probe const & p2);
2763  friend probe operator||(probe const & p1, probe const & p2);
2764  friend probe operator!(probe const & p);
2765  };
2766 
2767  inline probe operator<=(probe const & p1, probe const & p2) {
2768  check_context(p1, p2); Z3_probe r = Z3_probe_le(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
2769  }
2770  inline probe operator<=(probe const & p1, double p2) { return p1 <= probe(p1.ctx(), p2); }
2771  inline probe operator<=(double p1, probe const & p2) { return probe(p2.ctx(), p1) <= p2; }
2772  inline probe operator>=(probe const & p1, probe const & p2) {
2773  check_context(p1, p2); Z3_probe r = Z3_probe_ge(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
2774  }
2775  inline probe operator>=(probe const & p1, double p2) { return p1 >= probe(p1.ctx(), p2); }
2776  inline probe operator>=(double p1, probe const & p2) { return probe(p2.ctx(), p1) >= p2; }
2777  inline probe operator<(probe const & p1, probe const & p2) {
2778  check_context(p1, p2); Z3_probe r = Z3_probe_lt(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
2779  }
2780  inline probe operator<(probe const & p1, double p2) { return p1 < probe(p1.ctx(), p2); }
2781  inline probe operator<(double p1, probe const & p2) { return probe(p2.ctx(), p1) < p2; }
2782  inline probe operator>(probe const & p1, probe const & p2) {
2783  check_context(p1, p2); Z3_probe r = Z3_probe_gt(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
2784  }
2785  inline probe operator>(probe const & p1, double p2) { return p1 > probe(p1.ctx(), p2); }
2786  inline probe operator>(double p1, probe const & p2) { return probe(p2.ctx(), p1) > p2; }
2787  inline probe operator==(probe const & p1, probe const & p2) {
2788  check_context(p1, p2); Z3_probe r = Z3_probe_eq(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
2789  }
2790  inline probe operator==(probe const & p1, double p2) { return p1 == probe(p1.ctx(), p2); }
2791  inline probe operator==(double p1, probe const & p2) { return probe(p2.ctx(), p1) == p2; }
2792  inline probe operator&&(probe const & p1, probe const & p2) {
2793  check_context(p1, p2); Z3_probe r = Z3_probe_and(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
2794  }
2795  inline probe operator||(probe const & p1, probe const & p2) {
2796  check_context(p1, p2); Z3_probe r = Z3_probe_or(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
2797  }
2798  inline probe operator!(probe const & p) {
2799  Z3_probe r = Z3_probe_not(p.ctx(), p); p.check_error(); return probe(p.ctx(), r);
2800  }
2801 
2802  class optimize : public object {
2803  Z3_optimize m_opt;
2804 
2805  public:
2806  class handle {
2807  unsigned m_h;
2808  public:
2809  handle(unsigned h): m_h(h) {}
2810  unsigned h() const { return m_h; }
2811  };
2812  optimize(context& c):object(c) { m_opt = Z3_mk_optimize(c); Z3_optimize_inc_ref(c, m_opt); }
2814  Z3_optimize_inc_ref(o.ctx(), o.m_opt);
2815  m_opt = o.m_opt;
2816  }
2818  m_opt = Z3_mk_optimize(c);
2819  Z3_optimize_inc_ref(c, m_opt);
2820  add(expr_vector(c, src.assertions()));
2821  expr_vector v(c, src.objectives());
2822  for (expr_vector::iterator it = v.begin(); it != v.end(); ++it) minimize(*it);
2823  }
2825  Z3_optimize_inc_ref(o.ctx(), o.m_opt);
2826  Z3_optimize_dec_ref(ctx(), m_opt);
2827  m_opt = o.m_opt;
2828  m_ctx = o.m_ctx;
2829  return *this;
2830  }
2832  operator Z3_optimize() const { return m_opt; }
2833  void add(expr const& e) {
2834  assert(e.is_bool());
2835  Z3_optimize_assert(ctx(), m_opt, e);
2836  }
2837  void add(expr_vector const& es) {
2838  for (expr_vector::iterator it = es.begin(); it != es.end(); ++it) add(*it);
2839  }
2840  handle add(expr const& e, unsigned weight) {
2841  assert(e.is_bool());
2842  std::stringstream strm;
2843  strm << weight;
2844  return handle(Z3_optimize_assert_soft(ctx(), m_opt, e, strm.str().c_str(), 0));
2845  }
2846  void add(expr const& e, expr const& t) {
2847  assert(e.is_bool());
2848  Z3_optimize_assert_and_track(ctx(), m_opt, e, t);
2849  }
2850 
2851  handle add(expr const& e, char const* weight) {
2852  assert(e.is_bool());
2853  return handle(Z3_optimize_assert_soft(ctx(), m_opt, e, weight, 0));
2854  }
2855  handle maximize(expr const& e) {
2856  return handle(Z3_optimize_maximize(ctx(), m_opt, e));
2857  }
2858  handle minimize(expr const& e) {
2859  return handle(Z3_optimize_minimize(ctx(), m_opt, e));
2860  }
2861  void push() {
2862  Z3_optimize_push(ctx(), m_opt);
2863  }
2864  void pop() {
2865  Z3_optimize_pop(ctx(), m_opt);
2866  }
2869  unsigned n = asms.size();
2870  array<Z3_ast> _asms(n);
2871  for (unsigned i = 0; i < n; i++) {
2872  check_context(*this, asms[i]);
2873  _asms[i] = asms[i];
2874  }
2875  Z3_lbool r = Z3_optimize_check(ctx(), m_opt, n, _asms.ptr());
2876  check_error();
2877  return to_check_result(r);
2878  }
2879  model get_model() const { Z3_model m = Z3_optimize_get_model(ctx(), m_opt); check_error(); return model(ctx(), m); }
2880  expr_vector unsat_core() const { Z3_ast_vector r = Z3_optimize_get_unsat_core(ctx(), m_opt); check_error(); return expr_vector(ctx(), r); }
2881  void set(params const & p) { Z3_optimize_set_params(ctx(), m_opt, p); check_error(); }
2882  expr lower(handle const& h) {
2883  Z3_ast r = Z3_optimize_get_lower(ctx(), m_opt, h.h());
2884  check_error();
2885  return expr(ctx(), r);
2886  }
2887  expr upper(handle const& h) {
2888  Z3_ast r = Z3_optimize_get_upper(ctx(), m_opt, h.h());
2889  check_error();
2890  return expr(ctx(), r);
2891  }
2892  expr_vector assertions() const { Z3_ast_vector r = Z3_optimize_get_assertions(ctx(), m_opt); check_error(); return expr_vector(ctx(), r); }
2893  expr_vector objectives() const { Z3_ast_vector r = Z3_optimize_get_objectives(ctx(), m_opt); check_error(); return expr_vector(ctx(), r); }
2894  stats statistics() const { Z3_stats r = Z3_optimize_get_statistics(ctx(), m_opt); check_error(); return stats(ctx(), r); }
2895  friend std::ostream & operator<<(std::ostream & out, optimize const & s);
2896  void from_file(char const* filename) { Z3_optimize_from_file(ctx(), m_opt, filename); check_error(); }
2897  void from_string(char const* constraints) { Z3_optimize_from_string(ctx(), m_opt, constraints); check_error(); }
2898  std::string help() const { char const * r = Z3_optimize_get_help(ctx(), m_opt); check_error(); return r; }
2899  };
2900  inline std::ostream & operator<<(std::ostream & out, optimize const & s) { out << Z3_optimize_to_string(s.ctx(), s.m_opt); return out; }
2901 
2902  class fixedpoint : public object {
2903  Z3_fixedpoint m_fp;
2904  public:
2907  operator Z3_fixedpoint() const { return m_fp; }
2908  void from_string(char const* s) { Z3_fixedpoint_from_string(ctx(), m_fp, s); check_error(); }
2909  void from_file(char const* s) { Z3_fixedpoint_from_file(ctx(), m_fp, s); check_error(); }
2910  void add_rule(expr& rule, symbol const& name) { Z3_fixedpoint_add_rule(ctx(), m_fp, rule, name); check_error(); }
2911  void add_fact(func_decl& f, unsigned * args) { Z3_fixedpoint_add_fact(ctx(), m_fp, f, f.arity(), args); check_error(); }
2914  array<Z3_func_decl> rs(relations);
2915  Z3_lbool r = Z3_fixedpoint_query_relations(ctx(), m_fp, rs.size(), rs.ptr());
2916  check_error();
2917  return to_check_result(r);
2918  }
2919  expr get_answer() { Z3_ast r = Z3_fixedpoint_get_answer(ctx(), m_fp); check_error(); return expr(ctx(), r); }
2920  std::string reason_unknown() { return Z3_fixedpoint_get_reason_unknown(ctx(), m_fp); }
2921  void update_rule(expr& rule, symbol const& name) { Z3_fixedpoint_update_rule(ctx(), m_fp, rule, name); check_error(); }
2922  unsigned get_num_levels(func_decl& p) { unsigned r = Z3_fixedpoint_get_num_levels(ctx(), m_fp, p); check_error(); return r; }
2923  expr get_cover_delta(int level, func_decl& p) {
2924  Z3_ast r = Z3_fixedpoint_get_cover_delta(ctx(), m_fp, level, p);
2925  check_error();
2926  return expr(ctx(), r);
2927  }
2928  void add_cover(int level, func_decl& p, expr& property) { Z3_fixedpoint_add_cover(ctx(), m_fp, level, p, property); check_error(); }
2929  stats statistics() const { Z3_stats r = Z3_fixedpoint_get_statistics(ctx(), m_fp); check_error(); return stats(ctx(), r); }
2931  expr_vector assertions() const { Z3_ast_vector r = Z3_fixedpoint_get_assertions(ctx(), m_fp); check_error(); return expr_vector(ctx(), r); }
2932  expr_vector rules() const { Z3_ast_vector r = Z3_fixedpoint_get_rules(ctx(), m_fp); check_error(); return expr_vector(ctx(), r); }
2933  void set(params const & p) { Z3_fixedpoint_set_params(ctx(), m_fp, p); check_error(); }
2934  std::string help() const { return Z3_fixedpoint_get_help(ctx(), m_fp); }
2936  std::string to_string() { return Z3_fixedpoint_to_string(ctx(), m_fp, 0, 0); }
2937  std::string to_string(expr_vector const& queries) {
2938  array<Z3_ast> qs(queries);
2939  return Z3_fixedpoint_to_string(ctx(), m_fp, qs.size(), qs.ptr());
2940  }
2941  };
2942  inline std::ostream & operator<<(std::ostream & out, fixedpoint const & f) { return out << Z3_fixedpoint_to_string(f.ctx(), f, 0, 0); }
2943 
2944  inline tactic fail_if(probe const & p) {
2945  Z3_tactic r = Z3_tactic_fail_if(p.ctx(), p);
2946  p.check_error();
2947  return tactic(p.ctx(), r);
2948  }
2949  inline tactic when(probe const & p, tactic const & t) {
2950  check_context(p, t);
2951  Z3_tactic r = Z3_tactic_when(t.ctx(), p, t);
2952  t.check_error();
2953  return tactic(t.ctx(), r);
2954  }
2955  inline tactic cond(probe const & p, tactic const & t1, tactic const & t2) {
2956  check_context(p, t1); check_context(p, t2);
2957  Z3_tactic r = Z3_tactic_cond(t1.ctx(), p, t1, t2);
2958  t1.check_error();
2959  return tactic(t1.ctx(), r);
2960  }
2961 
2962  inline symbol context::str_symbol(char const * s) { Z3_symbol r = Z3_mk_string_symbol(m_ctx, s); check_error(); return symbol(*this, r); }
2963  inline symbol context::int_symbol(int n) { Z3_symbol r = Z3_mk_int_symbol(m_ctx, n); check_error(); return symbol(*this, r); }
2964 
2965  inline sort context::bool_sort() { Z3_sort s = Z3_mk_bool_sort(m_ctx); check_error(); return sort(*this, s); }
2966  inline sort context::int_sort() { Z3_sort s = Z3_mk_int_sort(m_ctx); check_error(); return sort(*this, s); }
2967  inline sort context::real_sort() { Z3_sort s = Z3_mk_real_sort(m_ctx); check_error(); return sort(*this, s); }
2968  inline sort context::bv_sort(unsigned sz) { Z3_sort s = Z3_mk_bv_sort(m_ctx, sz); check_error(); return sort(*this, s); }
2969  inline sort context::string_sort() { Z3_sort s = Z3_mk_string_sort(m_ctx); check_error(); return sort(*this, s); }
2970  inline sort context::seq_sort(sort& s) { Z3_sort r = Z3_mk_seq_sort(m_ctx, s); check_error(); return sort(*this, r); }
2971  inline sort context::re_sort(sort& s) { Z3_sort r = Z3_mk_re_sort(m_ctx, s); check_error(); return sort(*this, r); }
2972  inline sort context::fpa_sort(unsigned ebits, unsigned sbits) { Z3_sort s = Z3_mk_fpa_sort(m_ctx, ebits, sbits); check_error(); return sort(*this, s); }
2973 
2974  template<>
2975  inline sort context::fpa_sort<16>() { return fpa_sort(5, 11); }
2976 
2977  template<>
2978  inline sort context::fpa_sort<32>() { return fpa_sort(8, 24); }
2979 
2980  template<>
2981  inline sort context::fpa_sort<64>() { return fpa_sort(11, 53); }
2982 
2983  template<>
2984  inline sort context::fpa_sort<128>() { return fpa_sort(15, 113); }
2985 
2987  switch (m_rounding_mode) {
2988  case RNA: return sort(*this, Z3_mk_fpa_rna(m_ctx));
2989  case RNE: return sort(*this, Z3_mk_fpa_rne(m_ctx));
2990  case RTP: return sort(*this, Z3_mk_fpa_rtp(m_ctx));
2991  case RTN: return sort(*this, Z3_mk_fpa_rtn(m_ctx));
2992  case RTZ: return sort(*this, Z3_mk_fpa_rtz(m_ctx));
2993  default: return sort(*this);
2994  }
2995  }
2996 
2997  inline void context::set_rounding_mode(rounding_mode rm) { m_rounding_mode = rm; }
2998 
2999  inline sort context::array_sort(sort d, sort r) { Z3_sort s = Z3_mk_array_sort(m_ctx, d, r); check_error(); return sort(*this, s); }
3001  array<Z3_sort> dom(d);
3002  Z3_sort s = Z3_mk_array_sort_n(m_ctx, dom.size(), dom.ptr(), r); check_error(); return sort(*this, s);
3003  }
3004  inline sort context::enumeration_sort(char const * name, unsigned n, char const * const * enum_names, func_decl_vector & cs, func_decl_vector & ts) {
3005  array<Z3_symbol> _enum_names(n);
3006  for (unsigned i = 0; i < n; i++) { _enum_names[i] = Z3_mk_string_symbol(*this, enum_names[i]); }
3007  array<Z3_func_decl> _cs(n);
3008  array<Z3_func_decl> _ts(n);
3009  Z3_symbol _name = Z3_mk_string_symbol(*this, name);
3010  sort s = to_sort(*this, Z3_mk_enumeration_sort(*this, _name, n, _enum_names.ptr(), _cs.ptr(), _ts.ptr()));
3011  check_error();
3012  for (unsigned i = 0; i < n; i++) { cs.push_back(func_decl(*this, _cs[i])); ts.push_back(func_decl(*this, _ts[i])); }
3013  return s;
3014  }
3015  inline func_decl context::tuple_sort(char const * name, unsigned n, char const * const * names, sort const* sorts, func_decl_vector & projs) {
3016  array<Z3_symbol> _names(n);
3017  array<Z3_sort> _sorts(n);
3018  for (unsigned i = 0; i < n; i++) { _names[i] = Z3_mk_string_symbol(*this, names[i]); _sorts[i] = sorts[i]; }
3019  array<Z3_func_decl> _projs(n);
3020  Z3_symbol _name = Z3_mk_string_symbol(*this, name);
3021  Z3_func_decl tuple;
3022  sort _ignore_s = to_sort(*this, Z3_mk_tuple_sort(*this, _name, n, _names.ptr(), _sorts.ptr(), &tuple, _projs.ptr()));
3023  check_error();
3024  for (unsigned i = 0; i < n; i++) { projs.push_back(func_decl(*this, _projs[i])); }
3025  return func_decl(*this, tuple);
3026  }
3027 
3028  inline sort context::uninterpreted_sort(char const* name) {
3029  Z3_symbol _name = Z3_mk_string_symbol(*this, name);
3030  return to_sort(*this, Z3_mk_uninterpreted_sort(*this, _name));
3031  }
3033  return to_sort(*this, Z3_mk_uninterpreted_sort(*this, name));
3034  }
3035 
3036  inline func_decl context::function(symbol const & name, unsigned arity, sort const * domain, sort const & range) {
3037  array<Z3_sort> args(arity);
3038  for (unsigned i = 0; i < arity; i++) {
3039  check_context(domain[i], range);
3040  args[i] = domain[i];
3041  }
3042  Z3_func_decl f = Z3_mk_func_decl(m_ctx, name, arity, args.ptr(), range);
3043  check_error();
3044  return func_decl(*this, f);
3045  }
3046 
3047  inline func_decl context::function(char const * name, unsigned arity, sort const * domain, sort const & range) {
3048  return function(range.ctx().str_symbol(name), arity, domain, range);
3049  }
3050 
3051  inline func_decl context::function(symbol const& name, sort_vector const& domain, sort const& range) {
3052  array<Z3_sort> args(domain.size());
3053  for (unsigned i = 0; i < domain.size(); i++) {
3054  check_context(domain[i], range);
3055  args[i] = domain[i];
3056  }
3057  Z3_func_decl f = Z3_mk_func_decl(m_ctx, name, domain.size(), args.ptr(), range);
3058  check_error();
3059  return func_decl(*this, f);
3060  }
3061 
3062  inline func_decl context::function(char const * name, sort_vector const& domain, sort const& range) {
3063  return function(range.ctx().str_symbol(name), domain, range);
3064  }
3065 
3066 
3067  inline func_decl context::function(char const * name, sort const & domain, sort const & range) {
3068  check_context(domain, range);
3069  Z3_sort args[1] = { domain };
3070  Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 1, args, range);
3071  check_error();
3072  return func_decl(*this, f);
3073  }
3074 
3075  inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & range) {
3077  Z3_sort args[2] = { d1, d2 };
3078  Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 2, args, range);
3079  check_error();
3080  return func_decl(*this, f);
3081  }
3082 
3083  inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range) {
3085  Z3_sort args[3] = { d1, d2, d3 };
3086  Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 3, args, range);
3087  check_error();
3088  return func_decl(*this, f);
3089  }
3090 
3091  inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & d4, sort const & range) {
3093  Z3_sort args[4] = { d1, d2, d3, d4 };
3094  Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 4, args, range);
3095  check_error();
3096  return func_decl(*this, f);
3097  }
3098 
3099  inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & d4, sort const & d5, sort const & range) {
3101  Z3_sort args[5] = { d1, d2, d3, d4, d5 };
3102  Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 5, args, range);
3103  check_error();
3104  return func_decl(*this, f);
3105  }
3106 
3107  inline func_decl context::recfun(symbol const & name, unsigned arity, sort const * domain, sort const & range) {
3108  array<Z3_sort> args(arity);
3109  for (unsigned i = 0; i < arity; i++) {
3110  check_context(domain[i], range);
3111  args[i] = domain[i];
3112  }
3113  Z3_func_decl f = Z3_mk_rec_func_decl(m_ctx, name, arity, args.ptr(), range);
3114  check_error();
3115  return func_decl(*this, f);
3116 
3117  }
3118 
3119  inline func_decl context::recfun(char const * name, unsigned arity, sort const * domain, sort const & range) {
3120  return recfun(str_symbol(name), arity, domain, range);
3121  }
3122 
3123  inline func_decl context::recfun(char const * name, sort const& d1, sort const & range) {
3124  return recfun(str_symbol(name), 1, &d1, range);
3125  }
3126 
3127  inline func_decl context::recfun(char const * name, sort const& d1, sort const& d2, sort const & range) {
3128  sort dom[2] = { d1, d2 };
3129  return recfun(str_symbol(name), 2, dom, range);
3130  }
3131 
3132  inline void context::recdef(func_decl f, expr_vector const& args, expr const& body) {
3133  check_context(f, args); check_context(f, body);
3134  array<Z3_ast> vars(args);
3135  Z3_add_rec_def(f.ctx(), f, vars.size(), vars.ptr(), body);
3136  }
3137 
3138  inline expr context::constant(symbol const & name, sort const & s) {
3139  Z3_ast r = Z3_mk_const(m_ctx, name, s);
3140  check_error();
3141  return expr(*this, r);
3142  }
3143  inline expr context::constant(char const * name, sort const & s) { return constant(str_symbol(name), s); }
3144  inline expr context::bool_const(char const * name) { return constant(name, bool_sort()); }
3145  inline expr context::int_const(char const * name) { return constant(name, int_sort()); }
3146  inline expr context::real_const(char const * name) { return constant(name, real_sort()); }
3147  inline expr context::bv_const(char const * name, unsigned sz) { return constant(name, bv_sort(sz)); }
3148  inline expr context::fpa_const(char const * name, unsigned ebits, unsigned sbits) { return constant(name, fpa_sort(ebits, sbits)); }
3149 
3150  template<size_t precision>
3151  inline expr context::fpa_const(char const * name) { return constant(name, fpa_sort<precision>()); }
3152 
3153  inline expr context::bool_val(bool b) { return b ? expr(*this, Z3_mk_true(m_ctx)) : expr(*this, Z3_mk_false(m_ctx)); }
3154 
3155  inline expr context::int_val(int n) { Z3_ast r = Z3_mk_int(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }
3156  inline expr context::int_val(unsigned n) { Z3_ast r = Z3_mk_unsigned_int(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }
3157  inline expr context::int_val(int64_t n) { Z3_ast r = Z3_mk_int64(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }
3158  inline expr context::int_val(uint64_t n) { Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }
3159  inline expr context::int_val(char const * n) { Z3_ast r = Z3_mk_numeral(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }
3160 
3161  inline expr context::real_val(int n, int d) { Z3_ast r = Z3_mk_real(m_ctx, n, d); check_error(); return expr(*this, r); }
3162  inline expr context::real_val(int n) { Z3_ast r = Z3_mk_int(m_ctx, n, real_sort()); check_error(); return expr(*this, r); }
3163  inline expr context::real_val(unsigned n) { Z3_ast r = Z3_mk_unsigned_int(m_ctx, n, real_sort()); check_error(); return expr(*this, r); }
3164  inline expr context::real_val(int64_t n) { Z3_ast r = Z3_mk_int64(m_ctx, n, real_sort()); check_error(); return expr(*this, r); }
3165  inline expr context::real_val(uint64_t n) { Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, real_sort()); check_error(); return expr(*this, r); }
3166  inline expr context::real_val(char const * n) { Z3_ast r = Z3_mk_numeral(m_ctx, n, real_sort()); check_error(); return expr(*this, r); }
3167 
3168  inline expr context::bv_val(int n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_int(m_ctx, n, s); check_error(); return expr(*this, r); }
3169  inline expr context::bv_val(unsigned n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_unsigned_int(m_ctx, n, s); check_error(); return expr(*this, r); }
3170  inline expr context::bv_val(int64_t n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_int64(m_ctx, n, s); check_error(); return expr(*this, r); }
3171  inline expr context::bv_val(uint64_t n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, s); check_error(); return expr(*this, r); }
3172  inline expr context::bv_val(char const * n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_numeral(m_ctx, n, s); check_error(); return expr(*this, r); }
3173  inline expr context::bv_val(unsigned n, bool const* bits) {
3174  array<bool> _bits(n);
3175  for (unsigned i = 0; i < n; ++i) _bits[i] = bits[i] ? 1 : 0;
3176  Z3_ast r = Z3_mk_bv_numeral(m_ctx, n, _bits.ptr()); check_error(); return expr(*this, r);
3177  }
3178 
3179  inline expr context::fpa_val(double n) { sort s = fpa_sort<64>(); Z3_ast r = Z3_mk_fpa_numeral_double(m_ctx, n, s); check_error(); return expr(*this, r); }
3180  inline expr context::fpa_val(float n) { sort s = fpa_sort<32>(); Z3_ast r = Z3_mk_fpa_numeral_float(m_ctx, n, s); check_error(); return expr(*this, r); }
3181 
3182  inline expr context::string_val(char const* s, unsigned n) { Z3_ast r = Z3_mk_lstring(m_ctx, n, s); check_error(); return expr(*this, r); }
3183  inline expr context::string_val(char const* s) { Z3_ast r = Z3_mk_string(m_ctx, s); check_error(); return expr(*this, r); }
3184  inline expr context::string_val(std::string const& s) { Z3_ast r = Z3_mk_string(m_ctx, s.c_str()); check_error(); return expr(*this, r); }
3185 
3186  inline expr context::num_val(int n, sort const & s) { Z3_ast r = Z3_mk_int(m_ctx, n, s); check_error(); return expr(*this, r); }
3187 
3188  inline expr func_decl::operator()(unsigned n, expr const * args) const {
3189  array<Z3_ast> _args(n);
3190  for (unsigned i = 0; i < n; i++) {
3191  check_context(*this, args[i]);
3192  _args[i] = args[i];
3193  }
3194  Z3_ast r = Z3_mk_app(ctx(), *this, n, _args.ptr());
3195  check_error();
3196  return expr(ctx(), r);
3197 
3198  }
3199  inline expr func_decl::operator()(expr_vector const& args) const {
3200  array<Z3_ast> _args(args.size());
3201  for (unsigned i = 0; i < args.size(); i++) {
3202  check_context(*this, args[i]);
3203  _args[i] = args[i];
3204  }
3205  Z3_ast r = Z3_mk_app(ctx(), *this, args.size(), _args.ptr());
3206  check_error();
3207  return expr(ctx(), r);
3208  }
3209  inline expr func_decl::operator()() const {
3210  Z3_ast r = Z3_mk_app(ctx(), *this, 0, 0);
3211  ctx().check_error();
3212  return expr(ctx(), r);
3213  }
3214  inline expr func_decl::operator()(expr const & a) const {
3215  check_context(*this, a);
3216  Z3_ast args[1] = { a };
3217  Z3_ast r = Z3_mk_app(ctx(), *this, 1, args);
3218  ctx().check_error();
3219  return expr(ctx(), r);
3220  }
3221  inline expr func_decl::operator()(int a) const {
3222  Z3_ast args[1] = { ctx().num_val(a, domain(0)) };
3223  Z3_ast r = Z3_mk_app(ctx(), *this, 1, args);
3224  ctx().check_error();
3225  return expr(ctx(), r);
3226  }
3227  inline expr func_decl::operator()(expr const & a1, expr const & a2) const {
3228  check_context(*this, a1); check_context(*this, a2);
3229  Z3_ast args[2] = { a1, a2 };
3230  Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
3231  ctx().check_error();
3232  return expr(ctx(), r);
3233  }
3234  inline expr func_decl::operator()(expr const & a1, int a2) const {
3235  check_context(*this, a1);
3236  Z3_ast args[2] = { a1, ctx().num_val(a2, domain(1)) };
3237  Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
3238  ctx().check_error();
3239  return expr(ctx(), r);
3240  }
3241  inline expr func_decl::operator()(int a1, expr const & a2) const {
3242  check_context(*this, a2);
3243  Z3_ast args[2] = { ctx().num_val(a1, domain(0)), a2 };
3244  Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
3245  ctx().check_error();
3246  return expr(ctx(), r);
3247  }
3248  inline expr func_decl::operator()(expr const & a1, expr const & a2, expr const & a3) const {
3249  check_context(*this, a1); check_context(*this, a2); check_context(*this, a3);
3250  Z3_ast args[3] = { a1, a2, a3 };
3251  Z3_ast r = Z3_mk_app(ctx(), *this, 3, args);
3252  ctx().check_error();
3253  return expr(ctx(), r);
3254  }
3255  inline expr func_decl::operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4) const {
3256  check_context(*this, a1); check_context(*this, a2); check_context(*this, a3); check_context(*this, a4);
3257  Z3_ast args[4] = { a1, a2, a3, a4 };
3258  Z3_ast r = Z3_mk_app(ctx(), *this, 4, args);
3259  ctx().check_error();
3260  return expr(ctx(), r);
3261  }
3262  inline expr func_decl::operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4, expr const & a5) const {
3263  check_context(*this, a1); check_context(*this, a2); check_context(*this, a3); check_context(*this, a4); check_context(*this, a5);
3264  Z3_ast args[5] = { a1, a2, a3, a4, a5 };
3265  Z3_ast r = Z3_mk_app(ctx(), *this, 5, args);
3266  ctx().check_error();
3267  return expr(ctx(), r);
3268  }
3269 
3270  inline expr to_real(expr const & a) { Z3_ast r = Z3_mk_int2real(a.ctx(), a); a.check_error(); return expr(a.ctx(), r); }
3271 
3272  inline func_decl function(symbol const & name, unsigned arity, sort const * domain, sort const & range) {
3273  return range.ctx().function(name, arity, domain, range);
3274  }
3275  inline func_decl function(char const * name, unsigned arity, sort const * domain, sort const & range) {
3276  return range.ctx().function(name, arity, domain, range);
3277  }
3278  inline func_decl function(char const * name, sort const & domain, sort const & range) {
3279  return range.ctx().function(name, domain, range);
3280  }
3281  inline func_decl function(char const * name, sort const & d1, sort const & d2, sort const & range) {
3282  return range.ctx().function(name, d1, d2, range);
3283  }
3284  inline func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range) {
3285  return range.ctx().function(name, d1, d2, d3, range);
3286  }
3287  inline func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & d4, sort const & range) {
3288  return range.ctx().function(name, d1, d2, d3, d4, range);
3289  }
3290  inline func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & d4, sort const & d5, sort const & range) {
3291  return range.ctx().function(name, d1, d2, d3, d4, d5, range);
3292  }
3293  inline func_decl function(char const* name, sort_vector const& domain, sort const& range) {
3294  return range.ctx().function(name, domain, range);
3295  }
3296  inline func_decl function(std::string const& name, sort_vector const& domain, sort const& range) {
3297  return range.ctx().function(name.c_str(), domain, range);
3298  }
3299 
3300  inline func_decl recfun(symbol const & name, unsigned arity, sort const * domain, sort const & range) {
3301  return range.ctx().recfun(name, arity, domain, range);
3302  }
3303  inline func_decl recfun(char const * name, unsigned arity, sort const * domain, sort const & range) {
3304  return range.ctx().recfun(name, arity, domain, range);
3305  }
3306  inline func_decl recfun(char const * name, sort const& d1, sort const & range) {
3307  return range.ctx().recfun(name, d1, range);
3308  }
3309  inline func_decl recfun(char const * name, sort const& d1, sort const& d2, sort const & range) {
3310  return range.ctx().recfun(name, d1, d2, range);
3311  }
3312 
3313  inline expr select(expr const & a, expr const & i) {
3314  check_context(a, i);
3315  Z3_ast r = Z3_mk_select(a.ctx(), a, i);
3316  a.check_error();
3317  return expr(a.ctx(), r);
3318  }
3319  inline expr select(expr const & a, int i) {
3320  return select(a, a.ctx().num_val(i, a.get_sort().array_domain()));
3321  }
3322  inline expr select(expr const & a, expr_vector const & i) {
3323  check_context(a, i);
3324  array<Z3_ast> idxs(i);
3325  Z3_ast r = Z3_mk_select_n(a.ctx(), a, idxs.size(), idxs.ptr());
3326  a.check_error();
3327  return expr(a.ctx(), r);
3328  }
3329 
3330  inline expr store(expr const & a, expr const & i, expr const & v) {
3331  check_context(a, i); check_context(a, v);
3332  Z3_ast r = Z3_mk_store(a.ctx(), a, i, v);
3333  a.check_error();
3334  return expr(a.ctx(), r);
3335  }
3336 
3337  inline expr store(expr const & a, int i, expr const & v) { return store(a, a.ctx().num_val(i, a.get_sort().array_domain()), v); }
3338  inline expr store(expr const & a, expr i, int v) { return store(a, i, a.ctx().num_val(v, a.get_sort().array_range())); }
3339  inline expr store(expr const & a, int i, int v) {
3340  return store(a, a.ctx().num_val(i, a.get_sort().array_domain()), a.ctx().num_val(v, a.get_sort().array_range()));
3341  }
3342  inline expr store(expr const & a, expr_vector const & i, expr const & v) {
3343  check_context(a, i); check_context(a, v);
3344  array<Z3_ast> idxs(i);
3345  Z3_ast r = Z3_mk_store_n(a.ctx(), a, idxs.size(), idxs.ptr(), v);
3346  a.check_error();
3347  return expr(a.ctx(), r);
3348  }
3349 
3350  inline expr as_array(func_decl & f) {
3351  Z3_ast r = Z3_mk_as_array(f.ctx(), f);
3352  f.check_error();
3353  return expr(f.ctx(), r);
3354  }
3355 
3356 #define MK_EXPR1(_fn, _arg) \
3357  Z3_ast r = _fn(_arg.ctx(), _arg); \
3358  _arg.check_error(); \
3359  return expr(_arg.ctx(), r);
3360 
3361 #define MK_EXPR2(_fn, _arg1, _arg2) \
3362  check_context(_arg1, _arg2); \
3363  Z3_ast r = _fn(_arg1.ctx(), _arg1, _arg2); \
3364  _arg1.check_error(); \
3365  return expr(_arg1.ctx(), r);
3366 
3367  inline expr const_array(sort const & d, expr const & v) {
3368  MK_EXPR2(Z3_mk_const_array, d, v);
3369  }
3370 
3371  inline expr empty_set(sort const& s) {
3373  }
3374 
3375  inline expr full_set(sort const& s) {
3377  }
3378 
3379  inline expr set_add(expr const& s, expr const& e) {
3380  MK_EXPR2(Z3_mk_set_add, s, e);
3381  }
3382 
3383  inline expr set_del(expr const& s, expr const& e) {
3384  MK_EXPR2(Z3_mk_set_del, s, e);
3385  }
3386 
3387  inline expr set_union(expr const& a, expr const& b) {
3388  check_context(a, b);
3389  Z3_ast es[2] = { a, b };
3390  Z3_ast r = Z3_mk_set_union(a.ctx(), 2, es);
3391  a.check_error();
3392  return expr(a.ctx(), r);
3393  }
3394 
3395  inline expr set_intersect(expr const& a, expr const& b) {
3396  check_context(a, b);
3397  Z3_ast es[2] = { a, b };
3398  Z3_ast r = Z3_mk_set_intersect(a.ctx(), 2, es);
3399  a.check_error();
3400  return expr(a.ctx(), r);
3401  }
3402 
3403  inline expr set_difference(expr const& a, expr const& b) {
3405  }
3406 
3407  inline expr set_complement(expr const& a) {
3409  }
3410 
3411  inline expr set_member(expr const& s, expr const& e) {
3412  MK_EXPR2(Z3_mk_set_member, s, e);
3413  }
3414 
3415  inline expr set_subset(expr const& a, expr const& b) {
3416  MK_EXPR2(Z3_mk_set_subset, a, b);
3417  }
3418 
3419  // sequence and regular expression operations.
3420  // union is +
3421  // concat is overloaded to handle sequences and regular expressions
3422 
3423  inline expr empty(sort const& s) {
3424  Z3_ast r = Z3_mk_seq_empty(s.ctx(), s);
3425  s.check_error();
3426  return expr(s.ctx(), r);
3427  }
3428  inline expr suffixof(expr const& a, expr const& b) {
3429  check_context(a, b);
3430  Z3_ast r = Z3_mk_seq_suffix(a.ctx(), a, b);
3431  a.check_error();
3432  return expr(a.ctx(), r);
3433  }
3434  inline expr prefixof(expr const& a, expr const& b) {
3435  check_context(a, b);
3436  Z3_ast r = Z3_mk_seq_prefix(a.ctx(), a, b);
3437  a.check_error();
3438  return expr(a.ctx(), r);
3439  }
3440  inline expr indexof(expr const& s, expr const& substr, expr const& offset) {
3441  check_context(s, substr); check_context(s, offset);
3442  Z3_ast r = Z3_mk_seq_index(s.ctx(), s, substr, offset);
3443  s.check_error();
3444  return expr(s.ctx(), r);
3445  }
3446  inline expr last_indexof(expr const& s, expr const& substr) {
3447  check_context(s, substr);
3448  Z3_ast r = Z3_mk_seq_last_index(s.ctx(), s, substr);
3449  s.check_error();
3450  return expr(s.ctx(), r);
3451  }
3452  inline expr to_re(expr const& s) {
3454  }
3455  inline expr in_re(expr const& s, expr const& re) {
3456  MK_EXPR2(Z3_mk_seq_in_re, s, re);
3457  }
3458  inline expr plus(expr const& re) {
3459  MK_EXPR1(Z3_mk_re_plus, re);
3460  }
3461  inline expr option(expr const& re) {
3463  }
3464  inline expr star(expr const& re) {
3465  MK_EXPR1(Z3_mk_re_star, re);
3466  }
3467  inline expr re_empty(sort const& s) {
3468  Z3_ast r = Z3_mk_re_empty(s.ctx(), s);
3469  s.check_error();
3470  return expr(s.ctx(), r);
3471  }
3472  inline expr re_full(sort const& s) {
3473  Z3_ast r = Z3_mk_re_full(s.ctx(), s);
3474  s.check_error();
3475  return expr(s.ctx(), r);
3476  }
3477  inline expr re_intersect(expr_vector const& args) {
3478  assert(args.size() > 0);
3479  context& ctx = args[0].ctx();
3480  array<Z3_ast> _args(args);
3481  Z3_ast r = Z3_mk_re_intersect(ctx, _args.size(), _args.ptr());
3482  ctx.check_error();
3483  return expr(ctx, r);
3484  }
3485  inline expr re_complement(expr const& a) {
3487  }
3488  inline expr range(expr const& lo, expr const& hi) {
3489  check_context(lo, hi);
3490  Z3_ast r = Z3_mk_re_range(lo.ctx(), lo, hi);
3491  lo.check_error();
3492  return expr(lo.ctx(), r);
3493  }
3494 
3495 
3496 
3497 
3498 
3499  inline expr_vector context::parse_string(char const* s) {
3500  Z3_ast_vector r = Z3_parse_smtlib2_string(*this, s, 0, 0, 0, 0, 0, 0);
3501  check_error();
3502  return expr_vector(*this, r);
3503 
3504  }
3505  inline expr_vector context::parse_file(char const* s) {
3506  Z3_ast_vector r = Z3_parse_smtlib2_file(*this, s, 0, 0, 0, 0, 0, 0);
3507  check_error();
3508  return expr_vector(*this, r);
3509  }
3510 
3511  inline expr_vector context::parse_string(char const* s, sort_vector const& sorts, func_decl_vector const& decls) {
3512  array<Z3_symbol> sort_names(sorts.size());
3513  array<Z3_symbol> decl_names(decls.size());
3514  array<Z3_sort> sorts1(sorts);
3515  array<Z3_func_decl> decls1(decls);
3516  for (unsigned i = 0; i < sorts.size(); ++i) {
3517  sort_names[i] = sorts[i].name();
3518  }
3519  for (unsigned i = 0; i < decls.size(); ++i) {
3520  decl_names[i] = decls[i].name();
3521  }
3522 
3523  Z3_ast_vector r = Z3_parse_smtlib2_string(*this, s, sorts.size(), sort_names.ptr(), sorts1.ptr(), decls.size(), decl_names.ptr(), decls1.ptr());
3524  check_error();
3525  return expr_vector(*this, r);
3526  }
3527 
3528  inline expr_vector context::parse_file(char const* s, sort_vector const& sorts, func_decl_vector const& decls) {
3529  array<Z3_symbol> sort_names(sorts.size());
3530  array<Z3_symbol> decl_names(decls.size());
3531  array<Z3_sort> sorts1(sorts);
3532  array<Z3_func_decl> decls1(decls);
3533  for (unsigned i = 0; i < sorts.size(); ++i) {
3534  sort_names[i] = sorts[i].name();
3535  }
3536  for (unsigned i = 0; i < decls.size(); ++i) {
3537  decl_names[i] = decls[i].name();
3538  }
3539  Z3_ast_vector r = Z3_parse_smtlib2_file(*this, s, sorts.size(), sort_names.ptr(), sorts1.ptr(), decls.size(), decl_names.ptr(), decls1.ptr());
3540  check_error();
3541  return expr_vector(*this, r);
3542  }
3543 
3544 
3545  inline expr expr::substitute(expr_vector const& src, expr_vector const& dst) {
3546  assert(src.size() == dst.size());
3547  array<Z3_ast> _src(src.size());
3548  array<Z3_ast> _dst(dst.size());
3549  for (unsigned i = 0; i < src.size(); ++i) {
3550  _src[i] = src[i];
3551  _dst[i] = dst[i];
3552  }
3553  Z3_ast r = Z3_substitute(ctx(), m_ast, src.size(), _src.ptr(), _dst.ptr());
3554  check_error();
3555  return expr(ctx(), r);
3556  }
3557 
3558  inline expr expr::substitute(expr_vector const& dst) {
3559  array<Z3_ast> _dst(dst.size());
3560  for (unsigned i = 0; i < dst.size(); ++i) {
3561  _dst[i] = dst[i];
3562  }
3563  Z3_ast r = Z3_substitute_vars(ctx(), m_ast, dst.size(), _dst.ptr());
3564  check_error();
3565  return expr(ctx(), r);
3566  }
3567 
3568 
3569 
3570 }
3571 
3574 #undef Z3_THROW
3575 #endif
3576 
z3::optimize::check
check_result check()
Definition: z3++.h:2867
Z3_mk_re_plus
Z3_ast Z3_API Z3_mk_re_plus(Z3_context c, Z3_ast re)
Create the regular language re+.
z3::operator!=
expr operator!=(expr const &a, expr const &b)
Definition: z3++.h:1463
z3::array::~array
~array()
Definition: z3++.h:394
z3::expr::stoi
expr stoi() const
Definition: z3++.h:1308
Z3_model_get_func_interp
Z3_func_interp Z3_API Z3_model_get_func_interp(Z3_context c, Z3_model m, Z3_func_decl f)
Return the interpretation of the function f in the model m. Return NULL, if the model does not assign...
z3::params::~params
~params()
Definition: z3++.h:466
z3::ast::~ast
~ast()
Definition: z3++.h:494
Z3_model_eval
Z3_bool Z3_API Z3_model_eval(Z3_context c, Z3_model m, Z3_ast t, bool model_completion, Z3_ast *v)
Evaluate the AST node t in the given model. Return true if succeeded, and store the result in v.
Z3_global_param_reset_all
void Z3_API Z3_global_param_reset_all(void)
Restore the value of all global (and module) parameters. This command will not affect already created...
Z3_mk_unary_minus
Z3_ast Z3_API Z3_mk_unary_minus(Z3_context c, Z3_ast arg)
Create an AST node representing - arg.
z3::plus
expr plus(expr const &re)
Definition: z3++.h:3458
z3::xnor
expr xnor(expr const &a, expr const &b)
Definition: z3++.h:1691
z3::stats::double_value
double double_value(unsigned i) const
Definition: z3++.h:2329
z3::goal
Definition: z3++.h:2556
z3::goal::add
void add(expr_vector const &v)
Definition: z3++.h:2576
z3::ast::ast
ast(context &c, Z3_ast n)
Definition: z3++.h:492
z3::suffixof
expr suffixof(expr const &a, expr const &b)
Definition: z3++.h:3428
z3::fail_if
tactic fail_if(probe const &p)
Definition: z3++.h:2944
z3::expr::lo
unsigned lo() const
Definition: z3++.h:1257
Z3_mk_store_n
Z3_ast Z3_API Z3_mk_store_n(Z3_context c, Z3_ast a, unsigned n, Z3_ast const *idxs, Z3_ast v)
n-ary Array update.
z3::optimize::from_string
void from_string(char const *constraints)
Definition: z3++.h:2897
z3::pw
expr pw(expr const &a, expr const &b)
Definition: z3++.h:1385
Z3_model_dec_ref
void Z3_API Z3_model_dec_ref(Z3_context c, Z3_model m)
Decrement the reference counter of the given model.
Z3_model_translate
Z3_model Z3_API Z3_model_translate(Z3_context c, Z3_model m, Z3_context dst)
translate model from context c to context dst.
z3::ast::kind
Z3_ast_kind kind() const
Definition: z3++.h:498
z3::expr::at
expr at(expr const &index) const
Definition: z3++.h:1291
z3::expr::operator&
friend expr operator&(expr const &a, expr const &b)
Definition: z3++.h:1677
Z3_optimize_pop
void Z3_API Z3_optimize_pop(Z3_context c, Z3_optimize d)
Backtrack one level.
z3::set_difference
expr set_difference(expr const &a, expr const &b)
Definition: z3++.h:3403
Z3_mk_string_symbol
Z3_symbol Z3_API Z3_mk_string_symbol(Z3_context c, Z3_string s)
Create a Z3 symbol using a C string.
z3::ast_vector_tpl::back
T back() const
Definition: z3++.h:531
z3::as_array
expr as_array(func_decl &f)
Definition: z3++.h:3350
z3::fixedpoint::get_cover_delta
expr get_cover_delta(int level, func_decl &p)
Definition: z3++.h:2923
z3::context::interrupt
void interrupt()
Interrupt the current procedure being executed by any object managed by this context....
Definition: z3++.h:224
z3::expr::max
friend expr max(expr const &a, expr const &b)
Definition: z3++.h:1707
Z3_apply_result_to_string
Z3_string Z3_API Z3_apply_result_to_string(Z3_context c, Z3_apply_result r)
Convert the Z3_apply_result object returned by Z3_tactic_apply into a string.
Z3_mk_re_option
Z3_ast Z3_API Z3_mk_re_option(Z3_context c, Z3_ast re)
Create the regular language [re].
z3::bv2int
expr bv2int(expr const &a, bool is_signed)
bit-vector and integer conversions.
Definition: z3++.h:1888
Z3_mk_solver_from_tactic
Z3_solver Z3_API Z3_mk_solver_from_tactic(Z3_context c, Z3_tactic t)
Create a new solver that is implemented using the given tactic. The solver supports the commands Z3_s...
Z3_mk_bvshl
Z3_ast Z3_API Z3_mk_bvshl(Z3_context c, Z3_ast t1, Z3_ast t2)
Shift left.
z3::goal::add
void add(expr const &f)
Definition: z3++.h:2575
Z3_func_entry_inc_ref
void Z3_API Z3_func_entry_inc_ref(Z3_context c, Z3_func_entry e)
Increment the reference counter of the given Z3_func_entry object.
z3::solver::cube_iterator::operator!=
bool operator!=(cube_iterator const &other)
Definition: z3++.h:2519
z3::expr
A Z3 expression is used to represent formulas and terms. For Z3, a formula is any expression of sort ...
Definition: z3++.h:737
Z3_goal_is_decided_sat
bool Z3_API Z3_goal_is_decided_sat(Z3_context c, Z3_goal g)
Return true if the goal is empty, and it is precise or the product of a under approximation.
z3::solver::solver
solver(context &c, char const *logic)
Definition: z3++.h:2355
Z3_tactic_par_and_then
Z3_tactic Z3_API Z3_tactic_par_and_then(Z3_context c, Z3_tactic t1, Z3_tactic t2)
Return a tactic that applies t1 to a given goal and then t2 to every subgoal produced by t1....
Z3_model_has_interp
bool Z3_API Z3_model_has_interp(Z3_context c, Z3_model m, Z3_func_decl a)
Test if there exists an interpretation (i.e., assignment) for a in the model m.
z3::sort::sort_kind
Z3_sort_kind sort_kind() const
Return the internal sort kind.
Definition: z3++.h:607
z3::optimize::optimize
optimize(optimize &o)
Definition: z3++.h:2813
Z3_mk_forall_const
Z3_ast Z3_API Z3_mk_forall_const(Z3_context c, unsigned weight, unsigned num_bound, Z3_app const bound[], unsigned num_patterns, Z3_pattern const patterns[], Z3_ast body)
Create a universal quantifier using a list of constants that will form the set of bound variables.
z3::sort::is_fpa
bool is_fpa() const
Return true if this sort is a Floating point sort.
Definition: z3++.h:659
Z3_OP_XOR
@ Z3_OP_XOR
Definition: z3_api.h:1017
z3::ast_vector_tpl::end
iterator end() const
Definition: z3++.h:579
z3::goal::size
unsigned size() const
Definition: z3++.h:2577
z3::probe::operator()
double operator()(goal const &g) const
Definition: z3++.h:2746
Z3_mk_select
Z3_ast Z3_API Z3_mk_select(Z3_context c, Z3_ast a, Z3_ast i)
Array read. The argument a is the array and i is the index of the array that gets read.
z3::model::get_const_decl
func_decl get_const_decl(unsigned i) const
Definition: z3++.h:2259
z3::set_member
expr set_member(expr const &s, expr const &e)
Definition: z3++.h:3411
Z3_solver_to_string
Z3_string Z3_API Z3_solver_to_string(Z3_context c, Z3_solver s)
Convert a solver into a string.
Z3_mk_int_to_str
Z3_ast Z3_API Z3_mk_int_to_str(Z3_context c, Z3_ast s)
Integer to string conversion.
z3::config::config
config()
Definition: z3++.h:111
Z3_params_set_uint
void Z3_API Z3_params_set_uint(Z3_context c, Z3_params p, Z3_symbol k, unsigned v)
Add a unsigned parameter k with value v to the parameter set p.
Z3_mk_re_complement
Z3_ast Z3_API Z3_mk_re_complement(Z3_context c, Z3_ast re)
Create the complement of the regular language re.
Z3_params_set_double
void Z3_API Z3_params_set_double(Z3_context c, Z3_params p, Z3_symbol k, double v)
Add a double parameter k with value v to the parameter set p.
Z3_mk_bv_numeral
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.
z3::expr::operator>
friend expr operator>(expr const &a, expr const &b)
Definition: z3++.h:1655
Z3_goal_prec
Z3_goal_prec
A Goal is essentially a set of formulas. Z3 provide APIs for building strategies/tactics for solving ...
Definition: z3_api.h:1400
z3::context::fpa_sort
sort fpa_sort()
Definition: z3++.h:2975
z3::solver::assertions
expr_vector assertions() const
Definition: z3++.h:2421
z3::param_descrs::param_descrs
param_descrs(context &c, Z3_param_descrs d)
Definition: z3++.h:440
z3::solver::operator=
solver & operator=(solver const &s)
Definition: z3++.h:2360
Z3_tactic_inc_ref
void Z3_API Z3_tactic_inc_ref(Z3_context c, Z3_tactic t)
Increment the reference counter of the given tactic.
z3::sort::is_relation
bool is_relation() const
Return true if this sort is a Relation sort.
Definition: z3++.h:643
z3::symbol::to_int
int to_int() const
Definition: z3++.h:424
Z3_solver_get_levels
void Z3_API Z3_solver_get_levels(Z3_context c, Z3_solver s, Z3_ast_vector literals, unsigned sz, unsigned levels[])
retrieve the decision depth of Boolean literals (variables or their negations). Assumes a check-sat c...
Z3_mk_fpa_rtn
Z3_ast Z3_API Z3_mk_fpa_rtn(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardNegative rounding mode.
Z3_solver_check
Z3_lbool Z3_API Z3_solver_check(Z3_context c, Z3_solver s)
Check whether the assertions in a given solver are consistent or not.
z3::sort_vector
ast_vector_tpl< sort > sort_vector
Definition: z3++.h:73
Z3_optimize_assert_and_track
void Z3_API Z3_optimize_assert_and_track(Z3_context c, Z3_optimize o, Z3_ast a, Z3_ast t)
Assert tracked hard constraint to the optimization context.
z3::context::string_sort
sort string_sort()
Return the sort for ASCII strings.
Definition: z3++.h:2969
z3::context::array_sort
sort array_sort(sort d, sort r)
Return an array sort for arrays from d to r.
Definition: z3++.h:2999
Z3_stats_get_double_value
double Z3_API Z3_stats_get_double_value(Z3_context c, Z3_stats s, unsigned idx)
Return the double value of the given statistical data.
z3::ast_vector_tpl::resize
void resize(unsigned sz)
Definition: z3++.h:530
z3::expr::operator==
friend expr operator==(expr const &a, expr const &b)
Definition: z3++.h:1454
z3::stats::operator<<
friend std::ostream & operator<<(std::ostream &out, stats const &s)
Definition: z3++.h:2332
z3::sort::name
symbol name() const
Return name of sort.
Definition: z3++.h:611
z3::set_complement
expr set_complement(expr const &a)
Definition: z3++.h:3407
z3::ast_vector_tpl::iterator::operator=
iterator operator=(iterator const &other)
Definition: z3++.h:559
z3::bvadd_no_overflow
expr bvadd_no_overflow(expr const &a, expr const &b, bool is_signed)
bit-vector overflow/underflow checks
Definition: z3++.h:1894
z3::ult
expr ult(expr const &a, expr const &b)
unsigned less than operator for bitvectors.
Definition: z3++.h:1816
z3::to_re
expr to_re(expr const &s)
Definition: z3++.h:3452
Z3_mk_fpa_min
Z3_ast Z3_API Z3_mk_fpa_min(Z3_context c, Z3_ast t1, Z3_ast t2)
Minimum of floating-point numbers.
z3::ast_vector_tpl::iterator::iterator
iterator(iterator const &other)
Definition: z3++.h:558
z3::params::params
params(params const &s)
Definition: z3++.h:465
z3::operator^
expr operator^(expr const &a, expr const &b)
Definition: z3++.h:1681
Z3_mk_bvslt
Z3_ast Z3_API Z3_mk_bvslt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed less than.
z3::expr::is_const
bool is_const() const
Return true if this expression is a constant (i.e., an application with 0 arguments).
Definition: z3++.h:825
z3::par_and_then
tactic par_and_then(tactic const &t1, tactic const &t2)
Definition: z3++.h:2718
Z3_mk_ge
Z3_ast Z3_API Z3_mk_ge(Z3_context c, Z3_ast t1, Z3_ast t2)
Create greater than or equal to.
Z3_BV_SORT
@ Z3_BV_SORT
Definition: z3_api.h:153
Z3_solver_reset
void Z3_API Z3_solver_reset(Z3_context c, Z3_solver s)
Remove all assertions from the solver.
z3::model::add_const_interp
void add_const_interp(func_decl &f, expr &value)
Definition: z3++.h:2296
Z3_mk_true
Z3_ast Z3_API Z3_mk_true(Z3_context c)
Create an AST node representing true.
z3::solver::reason_unknown
std::string reason_unknown() const
Definition: z3++.h:2418
Z3_del_context
void Z3_API Z3_del_context(Z3_context c)
Delete the given logical context.
Z3_func_interp_set_else
void Z3_API Z3_func_interp_set_else(Z3_context c, Z3_func_interp f, Z3_ast else_value)
Return the 'else' value of the given function interpretation.
z3::expr::fma
friend expr fma(expr const &a, expr const &b, expr const &c, expr const &rm)
FloatingPoint fused multiply-add.
Definition: z3++.h:1747
Z3_dec_ref
void Z3_API Z3_dec_ref(Z3_context c, Z3_ast a)
Decrement the reference counter of the given AST. The context c should have been created using Z3_mk_...
Z3_parse_smtlib2_file
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.
Z3_OK
@ Z3_OK
Definition: z3_api.h:1365
Z3_update_param_value
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.
Z3_mk_bvmul_no_underflow
Z3_ast Z3_API Z3_mk_bvmul_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2)
Create a predicate that checks that the bit-wise signed multiplication of t1 and t2 does not underflo...
z3::operator%
expr operator%(expr const &a, expr const &b)
Definition: z3++.h:1400
Z3_param_descrs_get_name
Z3_symbol Z3_API Z3_param_descrs_get_name(Z3_context c, Z3_param_descrs p, unsigned i)
Return the name of the parameter at given index i.
z3::params::params
params(context &c)
Definition: z3++.h:464
Z3_ast_vector_translate
Z3_ast_vector Z3_API Z3_ast_vector_translate(Z3_context s, Z3_ast_vector v, Z3_context t)
Translate the AST vector v from context s into an AST vector in context t.
Z3_mk_bvmul_no_overflow
Z3_ast Z3_API Z3_mk_bvmul_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2, bool is_signed)
Create a predicate that checks that the bit-wise multiplication of t1 and t2 does not overflow.
z3::tactic::try_for
friend tactic try_for(tactic const &t, unsigned ms)
Definition: z3++.h:2704
Z3_probe_dec_ref
void Z3_API Z3_probe_dec_ref(Z3_context c, Z3_probe p)
Decrement the reference counter of the given probe.
Z3_mk_fpa_rem
Z3_ast Z3_API Z3_mk_fpa_rem(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point remainder.
Z3_probe_le
Z3_probe Z3_API Z3_probe_le(Z3_context x, Z3_probe p1, Z3_probe p2)
Return a probe that evaluates to "true" when the value returned by p1 is less than or equal to the va...
Z3_get_error_msg
Z3_string Z3_API Z3_get_error_msg(Z3_context c, Z3_error_code err)
Return a string describing the given error code.
z3::context::int_sort
sort int_sort()
Return the integer sort.
Definition: z3++.h:2966
_Z3_MK_BIN_
#define _Z3_MK_BIN_(a, b, binop)
Definition: z3++.h:1370
z3::model::model
model(context &c)
Definition: z3++.h:2233
z3::stats::key
std::string key(unsigned i) const
Definition: z3++.h:2325
Z3_get_ast_kind
Z3_ast_kind Z3_API Z3_get_ast_kind(Z3_context c, Z3_ast a)
Return the kind of the given AST.
z3::probe::probe
probe(context &c, Z3_probe s)
Definition: z3++.h:2734
Z3_OP_FALSE
@ Z3_OP_FALSE
Definition: z3_api.h:1010
Z3_optimize_dec_ref
void Z3_API Z3_optimize_dec_ref(Z3_context c, Z3_optimize d)
Decrement the reference counter of the given optimize context.
z3::func_decl::is_const
bool is_const() const
Definition: z3++.h:712
Z3_probe_and
Z3_probe Z3_API Z3_probe_and(Z3_context x, Z3_probe p1, Z3_probe p2)
Return a probe that evaluates to "true" when p1 and p2 evaluates to true.
z3::expr::is_numeral_i
bool is_numeral_i(int &i) const
Definition: z3++.h:812
z3::exception::msg
const char * msg() const
Definition: z3++.h:89
Z3_mk_zero_ext
Z3_ast Z3_API Z3_mk_zero_ext(Z3_context c, unsigned i, Z3_ast t1)
Extend the given bit-vector with zeros to the (unsigned) equivalent bit-vector of size m+i,...
z3::expr::replace
expr replace(expr const &src, expr const &dst) const
Definition: z3++.h:1274
Z3_fixedpoint_query
Z3_lbool Z3_API Z3_fixedpoint_query(Z3_context c, Z3_fixedpoint d, Z3_ast query)
Pose a query against the asserted rules.
z3::sort::is_re
bool is_re() const
Return true if this sort is a regular expression sort.
Definition: z3++.h:651
z3::param_descrs::simplify_param_descrs
static param_descrs simplify_param_descrs(context &c)
Definition: z3++.h:450
z3::expr::bvsdiv_no_overflow
friend expr bvsdiv_no_overflow(expr const &a, expr const &b)
Definition: z3++.h:1906
Z3_mk_seq_concat
Z3_ast Z3_API Z3_mk_seq_concat(Z3_context c, unsigned n, Z3_ast const args[])
Concatenate sequences.
z3::expr::operator&&
friend expr operator&&(expr const &a, expr const &b)
Return an expression representing a and b.
Definition: z3++.h:1429
z3::ast_vector_tpl::operator<<
friend std::ostream & operator<<(std::ostream &out, ast_vector_tpl const &v)
Definition: z3++.h:580
Z3_mk_config
Z3_config Z3_API Z3_mk_config(void)
Create a configuration object for the Z3 context object.
z3::solver::cube_iterator::cube_iterator
cube_iterator(solver &s, expr_vector &vars, unsigned &cutoff, bool end)
Definition: z3++.h:2490
z3::ast_vector_tpl::ast_vector_tpl
ast_vector_tpl(ast_vector_tpl const &s)
Definition: z3++.h:522
Z3_tactic_fail_if
Z3_tactic Z3_API Z3_tactic_fail_if(Z3_context c, Z3_probe p)
Return a tactic that fails if the probe p evaluates to false.
z3::goal::operator[]
expr operator[](int i) const
Definition: z3++.h:2578
Z3_mk_fpa_rtz
Z3_ast Z3_API Z3_mk_fpa_rtz(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardZero rounding mode.
z3::fixedpoint::rules
expr_vector rules() const
Definition: z3++.h:2932
z3::solver::translate
Definition: z3++.h:2351
z3::expr::is_forall
bool is_forall() const
Return true if this expression is a universal quantifier.
Definition: z3++.h:834
z3::cast_ast< func_decl >::operator()
func_decl operator()(context &c, Z3_ast a)
Definition: z3++.h:1964
Z3_inc_ref
void Z3_API Z3_inc_ref(Z3_context c, Z3_ast a)
Increment the reference counter of the given AST. The context c should have been created using Z3_mk_...
Z3_APP_AST
@ Z3_APP_AST
Definition: z3_api.h:180
z3::context::int_val
expr int_val(int n)
Definition: z3++.h:3155
Z3_FINITE_DOMAIN_SORT
@ Z3_FINITE_DOMAIN_SORT
Definition: z3_api.h:157
z3::context::str_symbol
symbol str_symbol(char const *s)
Create a Z3 symbol based on the given string.
Definition: z3++.h:2962
Z3_fixedpoint_update_rule
void Z3_API Z3_fixedpoint_update_rule(Z3_context c, Z3_fixedpoint d, Z3_ast a, Z3_symbol name)
Update a named rule. A rule with the same name must have been previously created.
z3::solver::add
void add(expr const &e, expr const &p)
Definition: z3++.h:2377
Z3_mk_gt
Z3_ast Z3_API Z3_mk_gt(Z3_context c, Z3_ast t1, Z3_ast t2)
Create greater than.
Z3_tactic_try_for
Z3_tactic Z3_API Z3_tactic_try_for(Z3_context c, Z3_tactic t, unsigned ms)
Return a tactic that applies t to a given goal for ms milliseconds. If t does not terminate in ms mil...
z3::tactic::with
friend tactic with(tactic const &t, params const &p)
Definition: z3++.h:2699
Z3_get_symbol_kind
Z3_symbol_kind Z3_API Z3_get_symbol_kind(Z3_context c, Z3_symbol s)
Return Z3_INT_SYMBOL if the symbol was constructed using Z3_mk_int_symbol, and Z3_STRING_SYMBOL if th...
z3::fixedpoint::from_file
void from_file(char const *s)
Definition: z3++.h:2909
z3::expr::algebraic_i
unsigned algebraic_i() const
Return i of an algebraic number (root-obj p i)
Definition: z3++.h:899
Z3_probe_const
Z3_probe Z3_API Z3_probe_const(Z3_context x, double val)
Return a probe that always evaluates to val.
Z3_solver_get_proof
Z3_ast Z3_API Z3_solver_get_proof(Z3_context c, Z3_solver s)
Retrieve the proof for the last Z3_solver_check or Z3_solver_check_assumptions.
Z3_fixedpoint_from_string
Z3_ast_vector Z3_API Z3_fixedpoint_from_string(Z3_context c, Z3_fixedpoint f, Z3_string s)
Parse an SMT-LIB2 string with fixedpoint rules. Add the rules to the current fixedpoint context....
Z3_param_descrs_to_string
Z3_string Z3_API Z3_param_descrs_to_string(Z3_context c, Z3_param_descrs p)
Convert a parameter description set into a string. This function is mainly used for printing the cont...
z3::model::model
model(context &c, Z3_model m)
Definition: z3++.h:2234
z3::expr::numerator
expr numerator() const
Definition: z3++.h:989
Z3_mk_fpa_fma
Z3_ast Z3_API Z3_mk_fpa_fma(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2, Z3_ast t3)
Floating-point fused multiply-add.
z3::bvsub_no_underflow
expr bvsub_no_underflow(expr const &a, expr const &b, bool is_signed)
Definition: z3++.h:1903
z3::sort::operator=
sort & operator=(sort const &s)
Return true if this sort and s are equal.
Definition: z3++.h:603
z3::solver::cube_generator
Definition: z3++.h:2525
z3::range
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3488
Z3_goal_precision
Z3_goal_prec Z3_API Z3_goal_precision(Z3_context c, Z3_goal g)
Return the "precision" of the given goal. Goals can be transformed using over and under approximation...
z3::expr::nand
friend expr nand(expr const &a, expr const &b)
Definition: z3++.h:1689
z3::expr::is_numeral
bool is_numeral(std::string &s, unsigned precision) const
Definition: z3++.h:815
z3::fixedpoint::set
void set(params const &p)
Definition: z3++.h:2933
z3::optimize::lower
expr lower(handle const &h)
Definition: z3++.h:2882
Z3_get_app_num_args
unsigned Z3_API Z3_get_app_num_args(Z3_context c, Z3_app a)
Return the number of argument of an application. If t is an constant, then the number of arguments is...
Z3_mk_re_full
Z3_ast Z3_API Z3_mk_re_full(Z3_context c, Z3_sort re)
Create an universal regular expression of sort re.
Z3_mk_rotate_left
Z3_ast Z3_API Z3_mk_rotate_left(Z3_context c, unsigned i, Z3_ast t1)
Rotate bits of t1 to the left i times.
z3::expr::is_relation
bool is_relation() const
Return true if this is a Relation expression.
Definition: z3++.h:780
z3::optimize::upper
expr upper(handle const &h)
Definition: z3++.h:2887
Z3_get_app_decl
Z3_func_decl Z3_API Z3_get_app_decl(Z3_context c, Z3_app a)
Return the declaration of a constant or function application.
Z3_param_kind
Z3_param_kind
The different kinds of parameters that can be associated with parameter sets. (see Z3_mk_params).
Definition: z3_api.h:1322
Z3_get_ast_hash
unsigned Z3_API Z3_get_ast_hash(Z3_context c, Z3_ast a)
Return a hash code for the given AST. The hash code is structural. You can use Z3_get_ast_id intercha...
Z3_mk_bv2int
Z3_ast Z3_API Z3_mk_bv2int(Z3_context c, Z3_ast t1, bool is_signed)
Create an integer from the bit-vector argument t1. If is_signed is false, then the bit-vector t1 is t...
Z3_get_lstring
Z3_char_ptr Z3_API Z3_get_lstring(Z3_context c, Z3_ast s, unsigned *length)
Retrieve the unescaped string constant stored in s.
z3::model::operator[]
func_decl operator[](int i) const
Definition: z3++.h:2262
z3::optimize::operator=
optimize & operator=(optimize const &o)
Definition: z3++.h:2824
z3::model::get_func_decl
func_decl get_func_decl(unsigned i) const
Definition: z3++.h:2260
z3::goal::get_model
model get_model() const
Definition: z3++.h:2592
z3::is_int
expr is_int(expr const &e)
Definition: z3++.h:1425
z3::lambda
expr lambda(expr const &x, expr const &b)
Definition: z3++.h:2030
z3::expr::arg
expr arg(unsigned i) const
Return the i-th argument of this application. This method assumes the expression is an application.
Definition: z3++.h:1065
Z3_mk_and
Z3_ast Z3_API Z3_mk_and(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] and ... and args[num_args-1].
z3::probe::operator||
friend probe operator||(probe const &p1, probe const &p2)
Definition: z3++.h:2795
Z3_mk_fpa_sqrt
Z3_ast Z3_API Z3_mk_fpa_sqrt(Z3_context c, Z3_ast rm, Z3_ast t)
Floating-point square root.
Z3_THROW
#define Z3_THROW(x)
Definition: z3++.h:99
z3::solver::dimacs
std::string dimacs(bool include_names=true) const
Definition: z3++.h:2458
Z3_apply_result_get_num_subgoals
unsigned Z3_API Z3_apply_result_get_num_subgoals(Z3_context c, Z3_apply_result r)
Return the number of subgoals in the Z3_apply_result object returned by Z3_tactic_apply.
z3::exception
Exception used to sign API usage errors.
Definition: z3++.h:84
z3::expr::is_numeral_u
bool is_numeral_u(unsigned &i) const
Definition: z3++.h:813
z3::bvmul_no_underflow
expr bvmul_no_underflow(expr const &a, expr const &b)
Definition: z3++.h:1915
Z3_solver_get_reason_unknown
Z3_string Z3_API Z3_solver_get_reason_unknown(Z3_context c, Z3_solver s)
Return a brief justification for an "unknown" result (i.e., Z3_L_UNDEF) for the commands Z3_solver_ch...
Z3_get_decl_int_parameter
int Z3_API Z3_get_decl_int_parameter(Z3_context c, Z3_func_decl d, unsigned idx)
Return the integer value associated with an integer parameter.
Z3_add_rec_def
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.
Z3_solver_pop
void Z3_API Z3_solver_pop(Z3_context c, Z3_solver s, unsigned n)
Backtrack n backtracking points.
z3::expr::id
unsigned id() const
retrieve unique identifier for expression.
Definition: z3++.h:909
z3::func_decl::func_decl
func_decl(context &c)
Definition: z3++.h:691
z3::goal::reset
void reset()
Definition: z3++.h:2582
z3::apply_result::operator[]
goal operator[](int i) const
Definition: z3++.h:2634
z3::solver::set
void set(char const *k, char const *v)
Definition: z3++.h:2372
z3::cast_ast< ast >::operator()
ast operator()(context &c, Z3_ast a)
Definition: z3++.h:1940
z3::optimize::set
void set(params const &p)
Definition: z3++.h:2881
z3::optimize::check
check_result check(expr_vector const &asms)
Definition: z3++.h:2868
z3::func_decl::domain
sort domain(unsigned i) const
Definition: z3++.h:703
Z3_params_to_string
Z3_string Z3_API Z3_params_to_string(Z3_context c, Z3_params p)
Convert a parameter set into a string. This function is mainly used for printing the contents of a pa...
z3::ast
Definition: z3++.h:487
Z3_fixedpoint_set_params
void Z3_API Z3_fixedpoint_set_params(Z3_context c, Z3_fixedpoint f, Z3_params p)
Set parameters on fixedpoint context.
Z3_interrupt
void Z3_API Z3_interrupt(Z3_context c)
Interrupt the execution of a Z3 procedure. This procedure can be used to interrupt: solvers,...
z3::context::re_sort
sort re_sort(sort &seq_sort)
Return a regular expression sort over sequences seq_sort.
Definition: z3++.h:2971
Z3_optimize_from_string
void Z3_API Z3_optimize_from_string(Z3_context c, Z3_optimize o, Z3_string s)
Parse an SMT-LIB2 string with assertions, soft constraints and optimization objectives....
z3::expr::pbeq
friend expr pbeq(expr_vector const &es, int const *coeffs, int bound)
Definition: z3++.h:2071
z3::optimize::get_model
model get_model() const
Definition: z3++.h:2879
z3py.tactics
def tactics(ctx=None)
Definition: z3py.py:7910
z3::expr::operator<
friend expr operator<(expr const &a, expr const &b)
Definition: z3++.h:1633
z3::ast_vector_tpl::iterator::operator*
T operator*() const
Definition: z3++.h:576
z3::recfun
func_decl recfun(symbol const &name, unsigned arity, sort const *domain, sort const &range)
Definition: z3++.h:3300
z3::expr::bvsub_no_overflow
friend expr bvsub_no_overflow(expr const &a, expr const &b)
Definition: z3++.h:1900
z3::ast::ast
ast(ast const &s)
Definition: z3++.h:493
Z3_optimize_get_objectives
Z3_ast_vector Z3_API Z3_optimize_get_objectives(Z3_context c, Z3_optimize o)
Return objectives on the optimization context. If the objective function is a max-sat objective it is...
z3::context::seq_sort
sort seq_sort(sort &s)
Return a sequence sort over base sort s.
Definition: z3++.h:2970
Z3_OP_IMPLIES
@ Z3_OP_IMPLIES
Definition: z3_api.h:1019
z3::tactic::operator=
tactic & operator=(tactic const &s)
Definition: z3++.h:2651
z3::exception::~exception
virtual ~exception()
Definition: z3++.h:88
Z3_goal_size
unsigned Z3_API Z3_goal_size(Z3_context c, Z3_goal g)
Return the number of formulas in the given goal.
z3::select
expr select(expr const &a, expr const &i)
forward declarations
Definition: z3++.h:3313
Z3_mk_set_del
Z3_ast Z3_API Z3_mk_set_del(Z3_context c, Z3_ast set, Z3_ast elem)
Remove an element to a set.
z3::abs
expr abs(expr const &a)
Definition: z3++.h:1722
z3::expr::rem
friend expr rem(expr const &a, expr const &b)
Definition: z3++.h:1405
z3::param_descrs::size
unsigned size()
Definition: z3++.h:452
z3::optimize::operator<<
friend std::ostream & operator<<(std::ostream &out, optimize const &s)
Definition: z3++.h:2900
Z3_set_param_value
void Z3_API Z3_set_param_value(Z3_config c, Z3_string param_id, Z3_string param_value)
Set a configuration parameter.
Z3_stats_is_uint
bool Z3_API Z3_stats_is_uint(Z3_context c, Z3_stats s, unsigned idx)
Return true if the given statistical data is a unsigned integer.
z3::context::set
void set(char const *param, int value)
Update global parameter param with Integer value.
Definition: z3++.h:214
Z3_mk_goal
Z3_goal Z3_API Z3_mk_goal(Z3_context c, bool models, bool unsat_cores, bool proofs)
Create a goal (aka problem). A goal is essentially a set of formulas, that can be solved and/or trans...
Z3_mk_seq_suffix
Z3_ast Z3_API Z3_mk_seq_suffix(Z3_context c, Z3_ast suffix, Z3_ast s)
Check if suffix is a suffix of s.
z3::sort::is_array
bool is_array() const
Return true if this sort is a Array sort.
Definition: z3++.h:635
z3::solver::check
check_result check(unsigned n, expr *const assumptions)
Definition: z3++.h:2391
z3::option
expr option(expr const &re)
Definition: z3++.h:3461
z3::model::model
model(model &src, context &dst, translate)
Definition: z3++.h:2236
Z3_mk_tactic
Z3_tactic Z3_API Z3_mk_tactic(Z3_context c, Z3_string name)
Return a tactic associated with the given name. The complete list of tactics may be obtained using th...
z3::func_interp::operator=
func_interp & operator=(func_interp const &s)
Definition: z3++.h:2205
Z3_mk_bvneg_no_overflow
Z3_ast Z3_API Z3_mk_bvneg_no_overflow(Z3_context c, Z3_ast t1)
Check that bit-wise negation does not overflow when t1 is interpreted as a signed bit-vector.
z3::expr::loop
expr loop(unsigned lo, unsigned hi)
Definition: z3++.h:1328
z3::solver::pop
void pop(unsigned n=1)
Definition: z3++.h:2374
z3::symbol
Definition: z3++.h:415
Z3_param_descrs_size
unsigned Z3_API Z3_param_descrs_size(Z3_context c, Z3_param_descrs p)
Return the number of parameters in the given parameter description set.
z3::udiv
expr udiv(expr const &a, expr const &b)
unsigned division operator for bitvectors.
Definition: z3++.h:1834
Z3_mk_bvmul
Z3_ast Z3_API Z3_mk_bvmul(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement multiplication.
z3::optimize::add
void add(expr_vector const &es)
Definition: z3++.h:2837
z3::sort::fpa_ebits
unsigned fpa_ebits() const
Definition: z3++.h:668
z3::solver::cube_iterator::operator++
cube_iterator operator++(int)
Definition: z3++.h:2512
Z3_solver_check_assumptions
Z3_lbool Z3_API Z3_solver_check_assumptions(Z3_context c, Z3_solver s, unsigned num_assumptions, Z3_ast const assumptions[])
Check whether the assertions in the given solver and optional assumptions are consistent or not.
Z3_optimize_get_statistics
Z3_stats Z3_API Z3_optimize_get_statistics(Z3_context c, Z3_optimize d)
Retrieve statistics information from the last call to Z3_optimize_check.
Z3_mk_full_set
Z3_ast Z3_API Z3_mk_full_set(Z3_context c, Z3_sort domain)
Create the full set.
Z3_optimize_get_assertions
Z3_ast_vector Z3_API Z3_optimize_get_assertions(Z3_context c, Z3_optimize o)
Return the set of asserted formulas on the optimization context.
z3::sext
expr sext(expr const &a, unsigned i)
Sign-extend of the given bit-vector to the (signed) equivalent bitvector of size m+i,...
Definition: z3++.h:1923
z3::optimize::optimize
optimize(context &c, optimize &src)
Definition: z3++.h:2817
Z3_is_eq_ast
bool Z3_API Z3_is_eq_ast(Z3_context c, Z3_ast t1, Z3_ast t2)
Compare terms.
z3::expr::pble
friend expr pble(expr_vector const &es, int const *coeffs, int bound)
Definition: z3++.h:2055
Z3_get_sort_id
unsigned Z3_API Z3_get_sort_id(Z3_context c, Z3_sort s)
Return a unique identifier for s.
Z3_mk_solver_for_logic
Z3_solver Z3_API Z3_mk_solver_for_logic(Z3_context c, Z3_symbol logic)
Create a new solver customized for the given logic. It behaves like Z3_mk_solver if the logic is unkn...
Z3_fixedpoint_inc_ref
void Z3_API Z3_fixedpoint_inc_ref(Z3_context c, Z3_fixedpoint d)
Increment the reference counter of the given fixedpoint context.
z3::solver::reset
void reset()
Definition: z3++.h:2375
Z3_mk_or
Z3_ast Z3_API Z3_mk_or(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] or ... or args[num_args-1].
z3::solver::to_smt2
std::string to_smt2(char const *status="unknown")
Definition: z3++.h:2438
Z3_algebraic_get_i
unsigned Z3_API Z3_algebraic_get_i(Z3_context c, Z3_ast a)
Return which root of the polynomial the algebraic number represents.
z3::ast::operator<<
friend std::ostream & operator<<(std::ostream &out, ast const &n)
Definition: z3++.h:509
z3::ashr
expr ashr(expr const &a, expr const &b)
arithmetic shift right operator for bitvectors
Definition: z3++.h:1876
z3::reset_params
void reset_params()
Definition: z3++.h:79
z3::expr::operator~
friend expr operator~(expr const &a)
Definition: z3++.h:1745
z3::solver::cube_generator::end
cube_iterator end()
Definition: z3++.h:2546
z3::expr::pbge
friend expr pbge(expr_vector const &es, int const *coeffs, int bound)
Definition: z3++.h:2063
z3::context::int_const
expr int_const(char const *name)
Definition: z3++.h:3145
z3::expr::hi
unsigned hi() const
Definition: z3++.h:1258
Z3_mk_set_union
Z3_ast Z3_API Z3_mk_set_union(Z3_context c, unsigned num_args, Z3_ast const args[])
Take the union of a list of sets.
z3::params::set
void set(char const *k, symbol const &s)
Definition: z3++.h:478
z3::expr::simplify
expr simplify() const
Return a simplified version of this expression.
Definition: z3++.h:1352
z3::tactic::apply
apply_result apply(goal const &g) const
Definition: z3++.h:2659
z3::context::bv_const
expr bv_const(char const *name, unsigned sz)
Definition: z3++.h:3147
Z3_mk_set_intersect
Z3_ast Z3_API Z3_mk_set_intersect(Z3_context c, unsigned num_args, Z3_ast const args[])
Take the intersection of a list of sets.
Z3_fixedpoint_get_help
Z3_string Z3_API Z3_fixedpoint_get_help(Z3_context c, Z3_fixedpoint f)
Return a string describing all fixedpoint available parameters.
z3::array::ptr
const T * ptr() const
Definition: z3++.h:399
Z3_goal_reset
void Z3_API Z3_goal_reset(Z3_context c, Z3_goal g)
Erase all formulas from the given goal.
z3::expr::algebraic_lower
expr algebraic_lower(unsigned precision) const
Definition: z3++.h:872
Z3_goal_num_exprs
unsigned Z3_API Z3_goal_num_exprs(Z3_context c, Z3_goal g)
Return the number of formulas, subformulas and terms in the given goal.
z3::expr::unit
expr unit() const
Definition: z3++.h:1280
z3::expr::abs
friend expr abs(expr const &a)
Definition: z3++.h:1722
Z3_ast_vector_push
void Z3_API Z3_ast_vector_push(Z3_context c, Z3_ast_vector v, Z3_ast a)
Add the AST a in the end of the AST vector v. The size of v is increased by one.
Z3_func_interp_get_else
Z3_ast Z3_API Z3_func_interp_get_else(Z3_context c, Z3_func_interp f)
Return the 'else' value of the given function interpretation.
Z3_fixedpoint_query_relations
Z3_lbool Z3_API Z3_fixedpoint_query_relations(Z3_context c, Z3_fixedpoint d, unsigned num_relations, Z3_func_decl const relations[])
Pose multiple queries against the asserted rules.
z3::params::set
void set(char const *k, unsigned n)
Definition: z3++.h:476
Z3_mk_distinct
Z3_ast Z3_API Z3_mk_distinct(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing distinct(args[0], ..., args[num_args-1]).
Z3_simplify_ex
Z3_ast Z3_API Z3_simplify_ex(Z3_context c, Z3_ast a, Z3_params p)
Interface to simplifier.
Z3_fixedpoint_from_file
Z3_ast_vector Z3_API Z3_fixedpoint_from_file(Z3_context c, Z3_fixedpoint f, Z3_string s)
Parse an SMT-LIB2 file with fixedpoint rules. Add the rules to the current fixedpoint context....
z3::probe::~probe
~probe()
Definition: z3++.h:2736
z3::expr::is_ite
bool is_ite() const
Definition: z3++.h:1145
Z3_solver_push
void Z3_API Z3_solver_push(Z3_context c, Z3_solver s)
Create a backtracking point.
Z3_mk_rec_func_decl
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.
Z3_model_get_const_decl
Z3_func_decl Z3_API Z3_model_get_const_decl(Z3_context c, Z3_model m, unsigned i)
Return the i-th constant in the given model.
Z3_mk_empty_set
Z3_ast Z3_API Z3_mk_empty_set(Z3_context c, Z3_sort domain)
Create the empty set.
z3::goal::dimacs
std::string dimacs() const
Definition: z3++.h:2610
z3::expr::ite
friend expr ite(expr const &c, expr const &t, expr const &e)
Create the if-then-else expression ite(c, t, e)
Definition: z3++.h:1761
z3::cast_ast< sort >::operator()
sort operator()(context &c, Z3_ast a)
Definition: z3++.h:1956
Z3_goal_formula
Z3_ast Z3_API Z3_goal_formula(Z3_context c, Z3_goal g, unsigned idx)
Return a formula from the given goal.
z3::bvmul_no_overflow
expr bvmul_no_overflow(expr const &a, expr const &b, bool is_signed)
Definition: z3++.h:1912
Z3_optimize_assert_soft
unsigned Z3_API Z3_optimize_assert_soft(Z3_context c, Z3_optimize o, Z3_ast a, Z3_string weight, Z3_symbol id)
Assert soft constraint to the optimization context.
Z3_mk_bvnor
Z3_ast Z3_API Z3_mk_bvnor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise nor.
z3::expr::nor
friend expr nor(expr const &a, expr const &b)
Definition: z3++.h:1690
z3::goal::operator=
goal & operator=(goal const &s)
Definition: z3++.h:2568
Z3_func_interp_add_entry
void Z3_API Z3_func_interp_add_entry(Z3_context c, Z3_func_interp fi, Z3_ast_vector args, Z3_ast value)
add a function entry to a function interpretation.
Z3_OP_DISTINCT
@ Z3_OP_DISTINCT
Definition: z3_api.h:1012
z3::lshr
expr lshr(expr const &a, expr const &b)
logic shift right operator for bitvectors
Definition: z3++.h:1869
Z3_L_TRUE
@ Z3_L_TRUE
Definition: z3_api.h:103
z3::fixedpoint::query
check_result query(func_decl_vector &relations)
Definition: z3++.h:2913
Z3_get_numeral_string
Z3_string Z3_API Z3_get_numeral_string(Z3_context c, Z3_ast a)
Return numeral value, as a string of a numeric constant term.
Z3_ast_vector_size
unsigned Z3_API Z3_ast_vector_size(Z3_context c, Z3_ast_vector v)
Return the size of the given AST vector.
z3::expr::num_args
unsigned num_args() const
Return the number of arguments in this application. This method assumes the expression is an applicat...
Definition: z3++.h:1057
Z3_mk_model
Z3_model Z3_API Z3_mk_model(Z3_context c)
Create a fresh model object. It has reference count 0.
Z3_mk_re_loop
Z3_ast Z3_API Z3_mk_re_loop(Z3_context c, Z3_ast r, unsigned lo, unsigned hi)
Create a regular expression loop. The supplied regular expression r is repeated between lo and hi tim...
Z3_mk_fpa_leq
Z3_ast Z3_API Z3_mk_fpa_leq(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point less than or equal.
z3::expr::is_not
bool is_not() const
Definition: z3++.h:1139
Z3_goal_depth
unsigned Z3_API Z3_goal_depth(Z3_context c, Z3_goal g)
Return the depth of the given goal. It tracks how many transformations were applied to it.
z3::optimize::add
void add(expr const &e, expr const &t)
Definition: z3++.h:2846
Z3_optimize_maximize
unsigned Z3_API Z3_optimize_maximize(Z3_context c, Z3_optimize o, Z3_ast t)
Add a maximization constraint.
z3::goal::is_decided_unsat
bool is_decided_unsat() const
Definition: z3++.h:2585
z3::solver::cubes
cube_generator cubes()
Definition: z3++.h:2550
Z3_mk_linear_order
Z3_func_decl Z3_API Z3_mk_linear_order(Z3_context c, Z3_sort a, unsigned id)
create a linear ordering relation over signature a. The relation is identified by the index id.
z3::tactic::operator()
apply_result operator()(goal const &g) const
Definition: z3++.h:2665
z3::array::array
array(unsigned sz)
Definition: z3++.h:391
z3::stats::size
unsigned size() const
Definition: z3++.h:2324
z3::expr::bvneg_no_overflow
friend expr bvneg_no_overflow(expr const &a)
Definition: z3++.h:1909
z3::exists
expr exists(expr const &x, expr const &b)
Definition: z3++.h:2006
Z3_lbool
Z3_lbool
Lifted Boolean type: false, undefined, true.
Definition: z3_api.h:99
z3::expr::sum
friend expr sum(expr_vector const &args)
Definition: z3++.h:2095
Z3_fixedpoint_get_answer
Z3_ast Z3_API Z3_fixedpoint_get_answer(Z3_context c, Z3_fixedpoint d)
Retrieve a formula that encodes satisfying answers to the query.
z3::symbol::str
std::string str() const
Definition: z3++.h:423
z3::expr::get_numeral_int
int get_numeral_int() const
Return int value of numeral, throw if result cannot fit in machine int.
Definition: z3++.h:921
z3::optimize::assertions
expr_vector assertions() const
Definition: z3++.h:2892
Z3_optimize_to_string
Z3_string Z3_API Z3_optimize_to_string(Z3_context c, Z3_optimize o)
Print the current context as a string.
z3::expr::operator!
friend expr operator!(expr const &a)
Return an expression representing not(a).
Definition: z3++.h:1423
z3::sort::is_bv
bool is_bv() const
Return true if this sort is a Bit-vector sort.
Definition: z3++.h:631
z3::solver::solver
solver(context &c, Z3_solver s)
Definition: z3++.h:2354
Z3_mk_add
Z3_ast Z3_API Z3_mk_add(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] + ... + args[num_args-1].
Z3_tactic_dec_ref
void Z3_API Z3_tactic_dec_ref(Z3_context c, Z3_tactic g)
Decrement the reference counter of the given tactic.
z3::check_result
check_result
Definition: z3++.h:132
Z3_OP_AND
@ Z3_OP_AND
Definition: z3_api.h:1014
Z3_is_quantifier_forall
bool Z3_API Z3_is_quantifier_forall(Z3_context c, Z3_ast a)
Determine if an ast is a universal quantifier.
Z3_is_string
bool Z3_API Z3_is_string(Z3_context c, Z3_ast s)
Determine if s is a string constant.
z3::ast_vector_tpl::iterator::operator++
iterator operator++(int)
Definition: z3++.h:574
z3::optimize::pop
void pop()
Definition: z3++.h:2864
z3::uge
expr uge(expr const &a, expr const &b)
unsigned greater than or equal to operator for bitvectors.
Definition: z3++.h:1822
z3::try_for
tactic try_for(tactic const &t, unsigned ms)
Definition: z3++.h:2704
z3::goal::goal
goal(goal const &s)
Definition: z3++.h:2565
z3::context::function
func_decl function(symbol const &name, unsigned arity, sort const *domain, sort const &range)
Definition: z3++.h:3036
z3::tactic
Definition: z3++.h:2639
z3::operator||
expr operator||(expr const &a, expr const &b)
Definition: z3++.h:1441
z3::context::constant
expr constant(symbol const &name, sort const &s)
Definition: z3++.h:3138
z3::expr::rotate_left
expr rotate_left(unsigned i)
Definition: z3++.h:1248
z3::config
Z3 global configuration object.
Definition: z3++.h:106
z3::fixedpoint::statistics
stats statistics() const
Definition: z3++.h:2929
Z3_probe_or
Z3_probe Z3_API Z3_probe_or(Z3_context x, Z3_probe p1, Z3_probe p2)
Return a probe that evaluates to "true" when p1 or p2 evaluates to true.
Z3_set_ast_print_mode
void Z3_API Z3_set_ast_print_mode(Z3_context c, Z3_ast_print_mode mode)
Select mode for the format used for pretty-printing AST nodes.
z3::apply_result::size
unsigned size() const
Definition: z3++.h:2633
Z3_mk_bvugt
Z3_ast Z3_API Z3_mk_bvugt(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned greater than.
z3::expr::is_var
bool is_var() const
Return true if this expression is a variable.
Definition: z3++.h:847
Z3_solver_get_assertions
Z3_ast_vector Z3_API Z3_solver_get_assertions(Z3_context c, Z3_solver s)
Return the set of asserted formulas on the solver.
Z3_FUNC_DECL_AST
@ Z3_FUNC_DECL_AST
Definition: z3_api.h:184
Z3_mk_seq_prefix
Z3_ast Z3_API Z3_mk_seq_prefix(Z3_context c, Z3_ast prefix, Z3_ast s)
Check if prefix is a prefix of s.
Z3_param_descrs_dec_ref
void Z3_API Z3_param_descrs_dec_ref(Z3_context c, Z3_param_descrs p)
Decrement the reference counter of the given parameter description set.
z3::stats::stats
stats(context &c)
Definition: z3++.h:2312
z3::expr::sqrt
friend expr sqrt(expr const &a, expr const &rm)
Definition: z3++.h:1738
Z3_mk_fpa_rna
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_vector_tpl::push_back
void push_back(T const &e)
Definition: z3++.h:529
z3::goal::operator<<
friend std::ostream & operator<<(std::ostream &out, goal const &g)
Definition: z3++.h:2613
Z3_get_algebraic_number_upper
Z3_ast Z3_API Z3_get_algebraic_number_upper(Z3_context c, Z3_ast a, unsigned precision)
Return a upper bound for the given real algebraic number. The interval isolating the number is smalle...
Z3_goal_to_dimacs_string
Z3_string Z3_API Z3_goal_to_dimacs_string(Z3_context c, Z3_goal g)
Convert a goal into a DIMACS formatted string. The goal must be in CNF. You can convert a goal to CNF...
z3::ast_vector_tpl::size
unsigned size() const
Definition: z3++.h:527
Z3_mk_app
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.
Z3_mk_concat
Z3_ast Z3_API Z3_mk_concat(Z3_context c, Z3_ast t1, Z3_ast t2)
Concatenate the given bit-vectors.
z3::solver::cube_iterator::operator==
bool operator==(cube_iterator const &other)
Definition: z3++.h:2516
z3::operator!
expr operator!(expr const &a)
Definition: z3++.h:1423
Z3_is_well_sorted
bool Z3_API Z3_is_well_sorted(Z3_context c, Z3_ast t)
Return true if the given expression t is well sorted.
z3::ast::operator=
ast & operator=(ast const &s)
Definition: z3++.h:497
Z3_mk_implies
Z3_ast Z3_API Z3_mk_implies(Z3_context c, Z3_ast t1, Z3_ast t2)
Create an AST node representing t1 implies t2.
z3::params::operator<<
friend std::ostream & operator<<(std::ostream &out, params const &p)
Definition: z3++.h:483
z3::optimize::optimize
optimize(context &c)
Definition: z3++.h:2812
z3::expr::get_numeral_uint64
uint64_t get_numeral_uint64() const
Return uint64_t value of numeral, throw if result cannot fit in uint64_t.
Definition: z3++.h:974
z3::solver::from_string
void from_string(char const *s)
Definition: z3++.h:2388
Z3_mk_rem
Z3_ast Z3_API Z3_mk_rem(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create an AST node representing arg1 rem arg2.
Z3_algebraic_get_poly
Z3_ast_vector Z3_API Z3_algebraic_get_poly(Z3_context c, Z3_ast a)
Return the coefficients of the defining polynomial.
z3::exception::exception
exception(char const *msg)
Definition: z3++.h:87
Z3_RELATION_SORT
@ Z3_RELATION_SORT
Definition: z3_api.h:156
Z3_mk_seq_unit
Z3_ast Z3_API Z3_mk_seq_unit(Z3_context c, Z3_ast a)
Create a unit sequence of a.
Z3_add_func_interp
Z3_func_interp Z3_API Z3_add_func_interp(Z3_context c, Z3_model m, Z3_func_decl f, Z3_ast default_value)
Create a fresh func_interp object, add it to a model for a specified function. It has reference count...
z3::context::fpa_const
expr fpa_const(char const *name, unsigned ebits, unsigned sbits)
Definition: z3++.h:3148
Z3_get_sort_kind
Z3_sort_kind Z3_API Z3_get_sort_kind(Z3_context c, Z3_sort t)
Return the sort kind (e.g., array, tuple, int, bool, etc).
Z3_mk_pbeq
Z3_ast Z3_API Z3_mk_pbeq(Z3_context c, unsigned num_args, Z3_ast const args[], int const coeffs[], int k)
Pseudo-Boolean relations.
Z3_is_re_sort
bool Z3_API Z3_is_re_sort(Z3_context c, Z3_sort s)
Check if s is a regular expression sort.
z3::expr::is_numeral
bool is_numeral(std::string &s) const
Definition: z3++.h:814
Z3_mk_numeral
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.
_Z3_MK_UN_
#define _Z3_MK_UN_(a, mkun)
Definition: z3++.h:1417
z3::apply_result::~apply_result
~apply_result()
Definition: z3++.h:2624
Z3_mk_bvadd_no_overflow
Z3_ast Z3_API Z3_mk_bvadd_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2, bool is_signed)
Create a predicate that checks that the bit-wise addition of t1 and t2 does not overflow.
z3::urem
expr urem(expr const &a, expr const &b)
unsigned reminder operator for bitvectors
Definition: z3++.h:1855
Z3_params_set_bool
void Z3_API Z3_params_set_bool(Z3_context c, Z3_params p, Z3_symbol k, bool v)
Add a Boolean parameter k with value v to the parameter set p.
Z3_fixedpoint_dec_ref
void Z3_API Z3_fixedpoint_dec_ref(Z3_context c, Z3_fixedpoint d)
Decrement the reference counter of the given fixedpoint context.
z3::context::set_enable_exceptions
void set_enable_exceptions(bool f)
The C++ API uses by defaults exceptions on errors. For applications that don't work well with excepti...
Definition: z3++.h:199
Z3_ARRAY_SORT
@ Z3_ARRAY_SORT
Definition: z3_api.h:154
Z3_mk_fpa_rne
Z3_ast Z3_API Z3_mk_fpa_rne(Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
Z3_mk_bvnot
Z3_ast Z3_API Z3_mk_bvnot(Z3_context c, Z3_ast t1)
Bitwise negation.
z3::optimize::objectives
expr_vector objectives() const
Definition: z3++.h:2893
z3::tactic::tactic
tactic(tactic const &s)
Definition: z3++.h:2648
Z3_stats_get_uint_value
unsigned Z3_API Z3_stats_get_uint_value(Z3_context c, Z3_stats s, unsigned idx)
Return the unsigned value of the given statistical data.
z3::solver::solver
solver(solver const &s)
Definition: z3++.h:2357
z3::fixedpoint::to_string
std::string to_string()
Definition: z3++.h:2936
z3::ast_vector_tpl::ast_vector_tpl
ast_vector_tpl(context &c)
Definition: z3++.h:520
Z3_mk_string
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.
z3::ast::to_string
std::string to_string() const
Definition: z3++.h:501
Z3_mk_fpa_sort
Z3_sort Z3_API Z3_mk_fpa_sort(Z3_context c, unsigned ebits, unsigned sbits)
Create a FloatingPoint sort.
Z3_mk_fpa_rtp
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_to_string
Z3_string Z3_API Z3_ast_to_string(Z3_context c, Z3_ast a)
Convert the given AST node into a string.
Z3_fpa_get_sbits
unsigned Z3_API Z3_fpa_get_sbits(Z3_context c, Z3_sort s)
Retrieves the number of bits reserved for the significand in a FloatingPoint sort.
z3::sort::sort
sort(context &c, Z3_ast a)
Definition: z3++.h:591
z3::expr::is_quantifier
bool is_quantifier() const
Return true if this expression is a quantifier.
Definition: z3++.h:829
Z3_mk_seq_length
Z3_ast Z3_API Z3_mk_seq_length(Z3_context c, Z3_ast s)
Return the length of the sequence s.
Z3_OP_TRUE
@ Z3_OP_TRUE
Definition: z3_api.h:1009
z3::solver::cube
expr_vector cube(expr_vector &vars, unsigned cutoff)
Definition: z3++.h:2463
Z3_mk_re_star
Z3_ast Z3_API Z3_mk_re_star(Z3_context c, Z3_ast re)
Create the regular language re*.
z3::stats::stats
stats(stats const &s)
Definition: z3++.h:2314
z3::probe::probe
probe(context &c, char const *name)
Definition: z3++.h:2732
z3::last_indexof
expr last_indexof(expr const &s, expr const &substr)
Definition: z3++.h:3446
Z3_func_interp_get_entry
Z3_func_entry Z3_API Z3_func_interp_get_entry(Z3_context c, Z3_func_interp f, unsigned i)
Return a "point" of the given function interpretation. It represents the value of f in a particular p...
z3::array
Definition: z3++.h:385
z3::config::~config
~config()
Definition: z3++.h:112
z3::context::recdef
void recdef(func_decl, expr_vector const &args, expr const &body)
Definition: z3++.h:3132
Z3_mk_eq
Z3_ast Z3_API Z3_mk_eq(Z3_context c, Z3_ast l, Z3_ast r)
Create an AST node representing l = r.
Z3_simplify_get_param_descrs
Z3_param_descrs Z3_API Z3_simplify_get_param_descrs(Z3_context c)
Return the parameter description set for the simplify procedure.
Z3_stats_size
unsigned Z3_API Z3_stats_size(Z3_context c, Z3_stats s)
Return the number of statistical data in s.
z3::expr::is_seq
bool is_seq() const
Return true if this is a sequence expression.
Definition: z3++.h:784
Z3_OP_ITE
@ Z3_OP_ITE
Definition: z3_api.h:1013
z3::RTN
@ RTN
Definition: z3++.h:140
Z3_solver_to_dimacs_string
Z3_string Z3_API Z3_solver_to_dimacs_string(Z3_context c, Z3_solver s, bool include_names)
Convert a solver into a DIMACS formatted string.
z3::tactic::get_param_descrs
param_descrs get_param_descrs()
Definition: z3++.h:2676
z3::context::enable_exceptions
bool enable_exceptions() const
Definition: z3++.h:201
z3::object::object
object(context &c)
Definition: z3++.h:407
Z3_mk_fpa_gt
Z3_ast Z3_API Z3_mk_fpa_gt(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point greater than.
z3::sqrt
expr sqrt(expr const &a, expr const &rm)
Definition: z3++.h:1738
Z3_get_string
Z3_string Z3_API Z3_get_string(Z3_context c, Z3_ast s)
Retrieve the string constant stored in s.
z3::operator<
expr operator<(expr const &a, expr const &b)
Definition: z3++.h:1633
Z3_add_const_interp
void Z3_API Z3_add_const_interp(Z3_context c, Z3_model m, Z3_func_decl f, Z3_ast a)
Add a constant interpretation.
z3::func_decl::id
unsigned id() const
retrieve unique identifier for func_decl.
Definition: z3++.h:700
Z3_solver_get_param_descrs
Z3_param_descrs Z3_API Z3_solver_get_param_descrs(Z3_context c, Z3_solver s)
Return the parameter description set for the given solver object.
z3::probe::operator!
friend probe operator!(probe const &p)
Definition: z3++.h:2798
z3::context::fpa_sort
sort fpa_sort()
Return a FloatingPoint sort with given precision bitwidth (16, 32, 64 or 128).
Z3_mk_set_complement
Z3_ast Z3_API Z3_mk_set_complement(Z3_context c, Z3_ast arg)
Take the complement of a set.
Z3_params_dec_ref
void Z3_API Z3_params_dec_ref(Z3_context c, Z3_params p)
Decrement the reference counter of the given parameter set.
Z3_mk_fpa_sub
Z3_ast Z3_API Z3_mk_fpa_sub(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2)
Floating-point subtraction.
Z3_mk_fpa_neg
Z3_ast Z3_API Z3_mk_fpa_neg(Z3_context c, Z3_ast t)
Floating-point negation.
z3::model::translate
Definition: z3++.h:2232
Z3_get_denominator
Z3_ast Z3_API Z3_get_denominator(Z3_context c, Z3_ast a)
Return the denominator (as a numeral AST) of a numeral AST of sort Real.
z3::solver::add
void add(expr const &e)
Definition: z3++.h:2376
Z3_tactic_using_params
Z3_tactic Z3_API Z3_tactic_using_params(Z3_context c, Z3_tactic t, Z3_params p)
Return a tactic that applies t using the given set of parameters.
z3::solver::solver
solver(context &c, simple)
Definition: z3++.h:2353
z3::func_interp::~func_interp
~func_interp()
Definition: z3++.h:2203
z3::solver
Definition: z3++.h:2343
Z3_mk_exists_const
Z3_ast Z3_API Z3_mk_exists_const(Z3_context c, unsigned weight, unsigned num_bound, Z3_app const bound[], unsigned num_patterns, Z3_pattern const patterns[], Z3_ast body)
Similar to Z3_mk_forall_const.
Z3_mk_bvsge
Z3_ast Z3_API Z3_mk_bvsge(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed greater than or equal to.
z3::shl
expr shl(expr const &a, expr const &b)
shift left operator for bitvectors
Definition: z3++.h:1862
z3::expr::get_escaped_string
std::string get_escaped_string() const
for a string value expression return an escaped or unescaped string value.
Definition: z3++.h:1016
z3::ast_vector_tpl::ast_vector_tpl
ast_vector_tpl(context &c, ast_vector_tpl const &src)
Definition: z3++.h:523
z3::func_entry::value
expr value() const
Definition: z3++.h:2189
Z3_mk_seq_last_index
Z3_ast Z3_API Z3_mk_seq_last_index(Z3_context c, Z3_ast, Z3_ast substr)
Return the last occurrence of substr in s. If s does not contain substr, then the value is -1,...
z3::object::m_ctx
context * m_ctx
Definition: z3++.h:405
z3::fixedpoint::register_relation
void register_relation(func_decl &p)
Definition: z3++.h:2930
Z3_mk_bvadd
Z3_ast Z3_API Z3_mk_bvadd(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement addition.
z3::optimize::handle::h
unsigned h() const
Definition: z3++.h:2810
Z3_stats_to_string
Z3_string Z3_API Z3_stats_to_string(Z3_context c, Z3_stats s)
Convert a statistics into a string.
z3::expr::is_xor
bool is_xor() const
Definition: z3++.h:1142
z3::ast::m_ast
Z3_ast m_ast
Definition: z3++.h:489
z3::expr::is_int
bool is_int() const
Return true if this is an integer expression.
Definition: z3++.h:756
Z3_is_quantifier_exists
bool Z3_API Z3_is_quantifier_exists(Z3_context c, Z3_ast a)
Determine if ast is an existential quantifier.
Z3_ast_vector_to_string
Z3_string Z3_API Z3_ast_vector_to_string(Z3_context c, Z3_ast_vector v)
Convert AST vector into a string.
z3::fixedpoint::add_rule
void add_rule(expr &rule, symbol const &name)
Definition: z3++.h:2910
z3::set_param
void set_param(char const *param, char const *value)
Definition: z3++.h:76
z3::solver::from_file
void from_file(char const *file)
Definition: z3++.h:2387
Z3_ast_vector_dec_ref
void Z3_API Z3_ast_vector_dec_ref(Z3_context c, Z3_ast_vector v)
Decrement the reference counter of the given AST vector.
z3::func_decl::decl_kind
Z3_decl_kind decl_kind() const
Definition: z3++.h:706
z3::context::string_val
expr string_val(char const *s)
Definition: z3++.h:3183
z3::param_descrs::~param_descrs
~param_descrs()
Definition: z3++.h:449
z3::expr::operator[]
expr operator[](expr_vector const &index) const
Definition: z3++.h:1345
z3::set_del
expr set_del(expr const &s, expr const &e)
Definition: z3++.h:3383
z3::empty_set
expr empty_set(sort const &s)
Definition: z3++.h:3371
Z3_optimize_get_lower
Z3_ast Z3_API Z3_optimize_get_lower(Z3_context c, Z3_optimize o, unsigned idx)
Retrieve lower bound value or approximation for the i'th optimization objective.
z3::optimize::maximize
handle maximize(expr const &e)
Definition: z3++.h:2855
z3::tactic::operator&
friend tactic operator&(tactic const &t1, tactic const &t2)
Definition: z3++.h:2679
Z3_get_domain
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.
z3::params
Definition: z3++.h:461
z3::expr::is_finite_domain
bool is_finite_domain() const
Return true if this is a Finite-domain expression.
Definition: z3++.h:798
z3::fixedpoint::get_param_descrs
param_descrs get_param_descrs()
Definition: z3++.h:2935
z3::ast_vector
ast_vector_tpl< ast > ast_vector
Definition: z3++.h:70
Z3_mk_bvneg
Z3_ast Z3_API Z3_mk_bvneg(Z3_context c, Z3_ast t1)
Standard two's complement unary minus.
z3::pble
expr pble(expr_vector const &es, int const *coeffs, int bound)
Definition: z3++.h:2055
z3::ugt
expr ugt(expr const &a, expr const &b)
unsigned greater than operator for bitvectors.
Definition: z3++.h:1828
Z3_mk_str_to_int
Z3_ast Z3_API Z3_mk_str_to_int(Z3_context c, Z3_ast s)
Convert string to integer.
Z3_goal_dec_ref
void Z3_API Z3_goal_dec_ref(Z3_context c, Z3_goal g)
Decrement the reference counter of the given goal.
z3::exception::operator<<
friend std::ostream & operator<<(std::ostream &out, exception const &e)
Definition: z3++.h:93
Z3_tactic_apply
Z3_apply_result Z3_API Z3_tactic_apply(Z3_context c, Z3_tactic t, Z3_goal g)
Apply tactic t to the goal g.
z3::symbol::operator=
symbol & operator=(symbol const &s)
Definition: z3++.h:420
z3::probe::operator>=
friend probe operator>=(probe const &p1, probe const &p2)
Definition: z3++.h:2772
z3::sort::is_datatype
bool is_datatype() const
Return true if this sort is a Datatype sort.
Definition: z3++.h:639
Z3_get_numerator
Z3_ast Z3_API Z3_get_numerator(Z3_context c, Z3_ast a)
Return the numerator (as a numeral AST) of a numeral AST of sort Real.
z3::func_decl::func_decl
func_decl(func_decl const &s)
Definition: z3++.h:693
Z3_mk_repeat
Z3_ast Z3_API Z3_mk_repeat(Z3_context c, unsigned i, Z3_ast t1)
Repeat the given bit-vector up length i.
z3::solver::cube_iterator
Definition: z3++.h:2469
z3::solver::cube_iterator::operator++
cube_iterator & operator++()
Definition: z3++.h:2502
z3::nor
expr nor(expr const &a, expr const &b)
Definition: z3++.h:1690
z3::sort
A Z3 sort (aka type). Every expression (i.e., formula or term) in Z3 has a sort.
Definition: z3++.h:587
z3::solver::~solver
~solver()
Definition: z3++.h:2358
z3::context::bool_val
expr bool_val(bool b)
Definition: z3++.h:3153
z3::RTP
@ RTP
Definition: z3++.h:139
Z3_optimize_get_upper
Z3_ast Z3_API Z3_optimize_get_upper(Z3_context c, Z3_optimize o, unsigned idx)
Retrieve upper bound value or approximation for the i'th optimization objective.
z3::sort::fpa_sbits
unsigned fpa_sbits() const
Definition: z3++.h:670
z3::operator&&
expr operator&&(expr const &a, expr const &b)
Definition: z3++.h:1429
z3::expr::algebraic_poly
expr_vector algebraic_poly() const
Return coefficients for p of an algebraic number (root-obj p i)
Definition: z3++.h:889
z3::expr::mk_or
friend expr mk_or(expr_vector const &args)
Definition: z3++.h:2157
Z3_mk_func_decl
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.
z3::func_entry::func_entry
func_entry(context &c, Z3_func_entry e)
Definition: z3++.h:2178
Z3_get_ast_id
unsigned Z3_API Z3_get_ast_id(Z3_context c, Z3_ast t)
Return a unique identifier for t. The identifier is unique up to structural equality....
z3::to_sort
sort to_sort(context &c, Z3_sort s)
Definition: z3++.h:1783
Z3_probe_inc_ref
void Z3_API Z3_probe_inc_ref(Z3_context c, Z3_probe p)
Increment the reference counter of the given probe.
z3::operator>
expr operator>(expr const &a, expr const &b)
Definition: z3++.h:1655
z3::context::set
void set(char const *param, char const *value)
Update global parameter param with string value.
Definition: z3++.h:206
Z3_goal_is_decided_unsat
bool Z3_API Z3_goal_is_decided_unsat(Z3_context c, Z3_goal g)
Return true if the goal contains false, and it is precise or the product of an over approximation.
Z3_solver_get_trail
Z3_ast_vector Z3_API Z3_solver_get_trail(Z3_context c, Z3_solver s)
Return the trail modulo model conversion, in order of decision level The decision level can be retrie...
Z3_param_descrs_inc_ref
void Z3_API Z3_param_descrs_inc_ref(Z3_context c, Z3_param_descrs p)
Increment the reference counter of the given parameter description set.
Z3_mk_re_range
Z3_ast Z3_API Z3_mk_re_range(Z3_context c, Z3_ast lo, Z3_ast hi)
Create the range regular expression over two sequences of length 1.
z3::func_decl::operator()
expr operator()() const
Definition: z3++.h:3209
z3::min
expr min(expr const &a, expr const &b)
Definition: z3++.h:1692
z3::ast_vector_tpl::iterator::operator==
bool operator==(iterator const &other) const
Definition: z3++.h:561
Z3_solver_dec_ref
void Z3_API Z3_solver_dec_ref(Z3_context c, Z3_solver s)
Decrement the reference counter of the given solver.
Z3_sort_kind
Z3_sort_kind
The different kinds of Z3 types (See Z3_get_sort_kind).
Definition: z3_api.h:147
Z3_mk_ite
Z3_ast Z3_API Z3_mk_ite(Z3_context c, Z3_ast t1, Z3_ast t2, Z3_ast t3)
Create an AST node representing an if-then-else: ite(t1, t2, t3).
Z3_mk_extract
Z3_ast Z3_API Z3_mk_extract(Z3_context c, unsigned high, unsigned low, Z3_ast t1)
Extract the bits high down to low from a bit-vector of size m to yield a new bit-vector of size n,...
z3::goal::goal
goal(context &c, bool models=true, bool unsat_cores=false, bool proofs=false)
Definition: z3++.h:2563
z3::expr::implies
friend expr implies(expr const &a, expr const &b)
Definition: z3++.h:1377
z3::stats::~stats
~stats()
Definition: z3++.h:2315
z3::optimize::from_file
void from_file(char const *filename)
Definition: z3++.h:2896
Z3_ast_vector_inc_ref
void Z3_API Z3_ast_vector_inc_ref(Z3_context c, Z3_ast_vector v)
Increment the reference counter of the given AST vector.
Z3_is_algebraic_number
bool Z3_API Z3_is_algebraic_number(Z3_context c, Z3_ast a)
Return true if the given AST is a real algebraic number.
z3::unsat
@ unsat
Definition: z3++.h:133
z3::expr::is_numeral
bool is_numeral() const
Return true if this expression is a numeral. Specialized functions also return representations for th...
Definition: z3++.h:809
Z3_get_numeral_uint64
bool Z3_API Z3_get_numeral_uint64(Z3_context c, Z3_ast v, uint64_t *u)
Similar to Z3_get_numeral_string, but only succeeds if the value can fit in a machine uint64_t int....
z3::unknown
@ unknown
Definition: z3++.h:133
z3::ast_vector_tpl::~ast_vector_tpl
~ast_vector_tpl()
Definition: z3++.h:525
Z3_INT_SYMBOL
@ Z3_INT_SYMBOL
Definition: z3_api.h:115
Z3_mk_seq_in_re
Z3_ast Z3_API Z3_mk_seq_in_re(Z3_context c, Z3_ast seq, Z3_ast re)
Check if seq is in the language generated by the regular expression re.
z3::mod
expr mod(expr const &a, expr const &b)
Definition: z3++.h:1389
Z3_OP_EQ
@ Z3_OP_EQ
Definition: z3_api.h:1011
z3::func_decl_vector
ast_vector_tpl< func_decl > func_decl_vector
Definition: z3++.h:74
Z3_mk_set_difference
Z3_ast Z3_API Z3_mk_set_difference(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Take the set difference between two sets.
z3::optimize::add
handle add(expr const &e, char const *weight)
Definition: z3++.h:2851
z3::func_interp::add_entry
void add_entry(expr_vector const &args, expr &value)
Definition: z3++.h:2215
Z3_mk_bvule
Z3_ast Z3_API Z3_mk_bvule(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned less than or equal to.
z3::ast::hash
unsigned hash() const
Definition: z3++.h:499
z3::expr::is_eq
bool is_eq() const
Definition: z3++.h:1144
Z3_func_interp_inc_ref
void Z3_API Z3_func_interp_inc_ref(Z3_context c, Z3_func_interp f)
Increment the reference counter of the given Z3_func_interp object.
z3::context::bv_sort
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:2968
z3::func_decl::range
sort range() const
Definition: z3++.h:704
z3::empty
expr empty(sort const &s)
Definition: z3++.h:3423
z3::goal::precision
Z3_goal_prec precision() const
Definition: z3++.h:2579
z3::param_descrs::param_descrs
param_descrs(param_descrs const &o)
Definition: z3++.h:441
z3::cast_ast< expr >::operator()
expr operator()(context &c, Z3_ast a)
Definition: z3++.h:1945
z3::tactic::repeat
friend tactic repeat(tactic const &t, unsigned max)
Definition: z3++.h:2693
z3::expr::is_distinct
bool is_distinct() const
Definition: z3++.h:1146
Z3_model_get_const_interp
Z3_ast Z3_API Z3_model_get_const_interp(Z3_context c, Z3_model m, Z3_func_decl a)
Return the interpretation (i.e., assignment) of constant a in the model m. Return NULL,...
z3::tactic::par_or
friend tactic par_or(unsigned n, tactic const *tactics)
Definition: z3++.h:2709
Z3_mk_bool_sort
Z3_sort Z3_API Z3_mk_bool_sort(Z3_context c)
Create the Boolean type.
Z3_optimize_check
Z3_lbool Z3_API Z3_optimize_check(Z3_context c, Z3_optimize o, unsigned num_assumptions, Z3_ast const assumptions[])
Check consistency and produce optimal values.
z3::context::recfun
func_decl recfun(symbol const &name, unsigned arity, sort const *domain, sort const &range)
Definition: z3++.h:3107
z3::goal::inconsistent
bool inconsistent() const
Definition: z3++.h:2580
z3::apply_result::apply_result
apply_result(apply_result const &s)
Definition: z3++.h:2623
z3::fixedpoint::add_fact
void add_fact(func_decl &f, unsigned *args)
Definition: z3++.h:2911
z3::to_expr
expr to_expr(context &c, Z3_ast a)
Wraps a Z3_ast as an expr object. It also checks for errors. This function allows the user to use the...
Definition: z3++.h:1774
Z3_VAR_AST
@ Z3_VAR_AST
Definition: z3_api.h:181
z3::operator<<
std::ostream & operator<<(std::ostream &out, exception const &e)
Definition: z3++.h:93
Z3_mk_fpa_numeral_float
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.
z3::expr::xnor
friend expr xnor(expr const &a, expr const &b)
Definition: z3++.h:1691
z3::optimize::unsat_core
expr_vector unsat_core() const
Definition: z3++.h:2880
z3::fma
expr fma(expr const &a, expr const &b, expr const &c, expr const &rm)
Definition: z3++.h:1747
z3::optimize
Definition: z3++.h:2802
Z3_tactic_cond
Z3_tactic Z3_API Z3_tactic_cond(Z3_context c, Z3_probe p, Z3_tactic t1, Z3_tactic t2)
Return a tactic that applies t1 to a given goal if the probe p evaluates to true, and t2 if p evaluat...
z3::ast_vector_tpl::pop_back
void pop_back()
Definition: z3++.h:532
Z3_func_interp_dec_ref
void Z3_API Z3_func_interp_dec_ref(Z3_context c, Z3_func_interp f)
Decrement the reference counter of the given Z3_func_interp object.
z3::bvsub_no_overflow
expr bvsub_no_overflow(expr const &a, expr const &b)
Definition: z3++.h:1900
Z3_mk_lstring
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...
z3::func_decl::operator=
func_decl & operator=(func_decl const &s)
Definition: z3++.h:695
Z3_mk_int
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.
z3::fixedpoint::get_num_levels
unsigned get_num_levels(func_decl &p)
Definition: z3++.h:2922
Z3_mk_power
Z3_ast Z3_API Z3_mk_power(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create an AST node representing arg1 ^ arg2.
z3::solver::cube_generator::cube_generator
cube_generator(solver &s)
Definition: z3++.h:2531
Z3_mk_fpa_div
Z3_ast Z3_API Z3_mk_fpa_div(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2)
Floating-point division.
Z3_fixedpoint_get_statistics
Z3_stats Z3_API Z3_fixedpoint_get_statistics(Z3_context c, Z3_fixedpoint d)
Retrieve statistics information from the last call to Z3_fixedpoint_query.
Z3_ast_vector_set
void Z3_API Z3_ast_vector_set(Z3_context c, Z3_ast_vector v, unsigned i, Z3_ast a)
Update position i of the AST vector v with the AST a.
z3::solver::add
void add(expr const &e, char const *p)
Definition: z3++.h:2382
Z3_mk_fpa_numeral_double
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.
Z3_goal_to_string
Z3_string Z3_API Z3_goal_to_string(Z3_context c, Z3_goal g)
Convert a goal into a string.
Z3_fixedpoint_register_relation
void Z3_API Z3_fixedpoint_register_relation(Z3_context c, Z3_fixedpoint d, Z3_func_decl f)
Register relation as Fixedpoint defined. Fixedpoint defined relations have least-fixedpoint semantics...
z3::config::set
void set(char const *param, bool value)
Set global parameter param with Boolean value.
Definition: z3++.h:121
z3::func_decl
Function declaration (aka function definition). It is the signature of interpreted and uninterpreted ...
Definition: z3++.h:689
z3::probe::operator>
friend probe operator>(probe const &p1, probe const &p2)
Definition: z3++.h:2782
z3::operator<=
expr operator<=(expr const &a, expr const &b)
Definition: z3++.h:1608
Z3_mk_div
Z3_ast Z3_API Z3_mk_div(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create an AST node representing arg1 div arg2.
Z3_goal_inc_ref
void Z3_API Z3_goal_inc_ref(Z3_context c, Z3_goal g)
Increment the reference counter of the given goal.
z3::solver::operator<<
friend std::ostream & operator<<(std::ostream &out, solver const &s)
Definition: z3++.h:2554
z3::params::set
void set(char const *k, char const *s)
Definition: z3++.h:479
z3::context::fpa_val
expr fpa_val(double n)
Definition: z3++.h:3179
Z3_REAL_SORT
@ Z3_REAL_SORT
Definition: z3_api.h:152
z3::expr::operator>=
friend expr operator>=(expr const &a, expr const &b)
Definition: z3++.h:1527
z3::symbol::kind
Z3_symbol_kind kind() const
Definition: z3++.h:422
Z3_tactic_repeat
Z3_tactic Z3_API Z3_tactic_repeat(Z3_context c, Z3_tactic t, unsigned max)
Return a tactic that keeps applying t until the goal is not modified anymore or the maximum number of...
z3::solver::non_units
expr_vector non_units() const
Definition: z3++.h:2422
z3::goal::as_expr
expr as_expr() const
Definition: z3++.h:2597
z3::goal::convert_model
model convert_model(model const &m) const
Definition: z3++.h:2586
z3::expr::bvmul_no_overflow
friend expr bvmul_no_overflow(expr const &a, expr const &b, bool is_signed)
Definition: z3++.h:1912
Z3_optimize_assert
void Z3_API Z3_optimize_assert(Z3_context c, Z3_optimize o, Z3_ast a)
Assert hard constraint to the optimization context.
z3::goal::depth
unsigned depth() const
Definition: z3++.h:2581
z3::context::real_val
expr real_val(int n, int d)
Definition: z3++.h:3161
Z3_mk_lt
Z3_ast Z3_API Z3_mk_lt(Z3_context c, Z3_ast t1, Z3_ast t2)
Create less than.
Z3_get_decl_num_parameters
unsigned Z3_API Z3_get_decl_num_parameters(Z3_context c, Z3_func_decl d)
Return the number of parameters associated with a declaration.
Z3_optimize_from_file
void Z3_API Z3_optimize_from_file(Z3_context c, Z3_optimize o, Z3_string s)
Parse an SMT-LIB2 file with assertions, soft constraints and optimization objectives....
z3::solver::check
check_result check(expr_vector const &assumptions)
Definition: z3++.h:2401
z3::func_decl::transitive_closure
func_decl transitive_closure(func_decl const &)
Definition: z3++.h:708
z3::mk_and
expr mk_and(expr_vector const &args)
Definition: z3++.h:2163
z3::solver::solver
solver(context &c)
Definition: z3++.h:2352
z3::expr::range
friend expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3488
Z3_mk_const
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.
z3::expr::extract
expr extract(expr const &offset, expr const &length) const
sequence and regular expression operations.
Definition: z3++.h:1270
z3::expr::is_false
bool is_false() const
Definition: z3++.h:1138
z3::zext
expr zext(expr const &a, unsigned i)
Extend the given bit-vector with zeros to the (unsigned) equivalent bitvector of size m+i,...
Definition: z3++.h:1883
Z3_stats_dec_ref
void Z3_API Z3_stats_dec_ref(Z3_context c, Z3_stats s)
Decrement the reference counter of the given statistics object.
z3::goal::goal
goal(context &c, Z3_goal s)
Definition: z3++.h:2564
z3::expr::contains
expr contains(expr const &s)
Definition: z3++.h:1285
Z3_model_get_num_funcs
unsigned Z3_API Z3_model_get_num_funcs(Z3_context c, Z3_model m)
Return the number of function interpretations in the given model.
z3::apply_result
Definition: z3++.h:2615
z3::expr::bvsub_no_underflow
friend expr bvsub_no_underflow(expr const &a, expr const &b, bool is_signed)
Definition: z3++.h:1903
z3::bvsdiv_no_overflow
expr bvsdiv_no_overflow(expr const &a, expr const &b)
Definition: z3++.h:1906
z3::set_add
expr set_add(expr const &s, expr const &e)
Definition: z3++.h:3379
Z3_FLOATING_POINT_SORT
@ Z3_FLOATING_POINT_SORT
Definition: z3_api.h:158
Z3_NUMERAL_AST
@ Z3_NUMERAL_AST
Definition: z3_api.h:179
z3::func_entry::num_args
unsigned num_args() const
Definition: z3++.h:2190
z3::model::operator=
model & operator=(model const &s)
Definition: z3++.h:2239
z3::expr::expr
expr(context &c)
Definition: z3++.h:739
Z3_mk_bv_sort
Z3_sort Z3_API Z3_mk_bv_sort(Z3_context c, unsigned sz)
Create a bit-vector type of the given size.
z3::func_entry::arg
expr arg(unsigned i) const
Definition: z3++.h:2191
z3::tactic::operator|
friend tactic operator|(tactic const &t1, tactic const &t2)
Definition: z3++.h:2686
Z3_mk_fixedpoint
Z3_fixedpoint Z3_API Z3_mk_fixedpoint(Z3_context c)
Create a new fixedpoint context.
Z3_solver_from_string
void Z3_API Z3_solver_from_string(Z3_context c, Z3_solver s, Z3_string file_name)
load solver assertions from a string.
Z3_mk_seq_to_re
Z3_ast Z3_API Z3_mk_seq_to_re(Z3_context c, Z3_ast seq)
Create a regular expression that accepts the sequence seq.
Z3_mk_int_sort
Z3_sort Z3_API Z3_mk_int_sort(Z3_context c)
Create the integer type.
Z3_probe_ge
Z3_probe Z3_API Z3_probe_ge(Z3_context x, Z3_probe p1, Z3_probe p2)
Return a probe that evaluates to "true" when the value returned by p1 is greater than or equal to the...
z3::func_interp
Definition: z3++.h:2194
Z3_mk_enumeration_sort
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::tactic::mk_solver
solver mk_solver() const
Definition: z3++.h:2658
z3::func_interp::num_entries
unsigned num_entries() const
Definition: z3++.h:2213
z3::ule
expr ule(expr const &a, expr const &b)
unsigned less than or equal to operator for bitvectors.
Definition: z3++.h:1810
z3::expr::operator|
friend expr operator|(expr const &a, expr const &b)
Definition: z3++.h:1685
Z3_INT_SORT
@ Z3_INT_SORT
Definition: z3_api.h:151
z3::array::operator[]
const T & operator[](int i) const
Definition: z3++.h:398
Z3_solver_get_unsat_core
Z3_ast_vector Z3_API Z3_solver_get_unsat_core(Z3_context c, Z3_solver s)
Retrieve the unsat core for the last Z3_solver_check_assumptions The unsat core is a subset of the as...
z3::context::set
void set(char const *param, bool value)
Update global parameter param with Boolean value.
Definition: z3++.h:210
z3::context::check_parser_error
void check_parser_error() const
Definition: z3++.h:188
Z3_mk_bvashr
Z3_ast Z3_API Z3_mk_bvashr(Z3_context c, Z3_ast t1, Z3_ast t2)
Arithmetic shift right.
z3::optimize::add
void add(expr const &e)
Definition: z3++.h:2833
Z3_mk_bvurem
Z3_ast Z3_API Z3_mk_bvurem(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned remainder.
z3::pbeq
expr pbeq(expr_vector const &es, int const *coeffs, int bound)
Definition: z3++.h:2071
z3::solver::set
void set(char const *k, symbol const &v)
Definition: z3++.h:2371
z3::context::tuple_sort
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 argumen...
Definition: z3++.h:3015
Z3_mk_bvsub_no_overflow
Z3_ast Z3_API Z3_mk_bvsub_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2)
Create a predicate that checks that the bit-wise signed subtraction of t1 and t2 does not overflow.
Z3_solver_get_units
Z3_ast_vector Z3_API Z3_solver_get_units(Z3_context c, Z3_solver s)
Return the set of units modulo model conversion.
Z3_get_numeral_uint
bool Z3_API Z3_get_numeral_uint(Z3_context c, Z3_ast v, unsigned *u)
Similar to Z3_get_numeral_string, but only succeeds if the value can fit in a machine unsigned int....
Z3_mk_bvsmod
Z3_ast Z3_API Z3_mk_bvsmod(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed remainder (sign follows divisor).
z3::params::set
void set(char const *k, bool b)
Definition: z3++.h:475
Z3_probe_eq
Z3_probe Z3_API Z3_probe_eq(Z3_context x, Z3_probe p1, Z3_probe p2)
Return a probe that evaluates to "true" when the value returned by p1 is equal to the value returned ...
z3::operator~
expr operator~(expr const &a)
Definition: z3++.h:1745
Z3_mk_seq_replace
Z3_ast Z3_API Z3_mk_seq_replace(Z3_context c, Z3_ast s, Z3_ast src, Z3_ast dst)
Replace the first occurrence of src with dst in s.
z3::context::set_rounding_mode
void set_rounding_mode(rounding_mode rm)
Sets RoundingMode of FloatingPoints.
Definition: z3++.h:2997
z3::expr::atmost
friend expr atmost(expr_vector const &es, unsigned bound)
Definition: z3++.h:2079
z3::sle
expr sle(expr const &a, expr const &b)
signed less than or equal to operator for bitvectors.
Definition: z3++.h:1796
z3::expr::bv2int
friend expr bv2int(expr const &a, bool is_signed)
bit-vector and integer conversions.
Definition: z3++.h:1888
z3::probe::probe
probe(probe const &s)
Definition: z3++.h:2735
z3::expr::operator+
friend expr operator+(expr const &a, expr const &b)
Definition: z3++.h:1473
z3::func_entry::~func_entry
~func_entry()
Definition: z3++.h:2180
Z3_get_arity
unsigned Z3_API Z3_get_arity(Z3_context c, Z3_func_decl d)
Alias for Z3_get_domain_size.
Z3_mk_context_rc
Z3_context Z3_API Z3_mk_context_rc(Z3_config c)
Create a context using the given configuration. This function is similar to Z3_mk_context....
z3::expr::pw
friend expr pw(expr const &a, expr const &b)
Definition: z3++.h:1385
Z3_mk_seq_contains
Z3_ast Z3_API Z3_mk_seq_contains(Z3_context c, Z3_ast container, Z3_ast containee)
Check if container contains containee.
z3::optimize::~optimize
~optimize()
Definition: z3++.h:2831
z3::model::operator<<
friend std::ostream & operator<<(std::ostream &out, model const &m)
Definition: z3++.h:2303
z3::expr::get_numeral_uint
unsigned get_numeral_uint() const
Return uint value of numeral, throw if result cannot fit in machine uint.
Definition: z3++.h:940
z3::sort::bv_size
unsigned bv_size() const
Return the size of this Bit-vector sort.
Definition: z3++.h:666
z3::apply_result::operator=
apply_result & operator=(apply_result const &s)
Definition: z3++.h:2626
Z3_RE_SORT
@ Z3_RE_SORT
Definition: z3_api.h:161
z3::sort::is_finite_domain
bool is_finite_domain() const
Return true if this sort is a Finite domain sort.
Definition: z3++.h:655
Z3_probe_apply
double Z3_API Z3_probe_apply(Z3_context c, Z3_probe p, Z3_goal g)
Execute the probe over the goal. The probe always produce a double value. "Boolean" probes return 0....
z3::expr::is_algebraic
bool is_algebraic() const
Return true if expression is an algebraic number.
Definition: z3++.h:851
z3::sort::sort
sort(context &c, Z3_sort s)
Definition: z3++.h:590
z3::mk_or
expr mk_or(expr_vector const &args)
Definition: z3++.h:2157
z3::array::ptr
T * ptr()
Definition: z3++.h:400
z3::solver::units
expr_vector units() const
Definition: z3++.h:2423
z3::expr::decl
func_decl decl() const
Return the declaration associated with this application. This method assumes the expression is an app...
Definition: z3++.h:1050
Z3_get_numeral_int64
bool Z3_API Z3_get_numeral_int64(Z3_context c, Z3_ast v, int64_t *i)
Similar to Z3_get_numeral_string, but only succeeds if the value can fit in a machine int64_t int....
z3::sort::is_int
bool is_int() const
Return true if this sort is the Integer sort.
Definition: z3++.h:619
Z3_ast_vector_get
Z3_ast Z3_API Z3_ast_vector_get(Z3_context c, Z3_ast_vector v, unsigned i)
Return the AST at position i in the AST vector v.
Z3_mk_as_array
Z3_ast Z3_API Z3_mk_as_array(Z3_context c, Z3_func_decl f)
Create array with the same interpretation as a function. The array satisfies the property (f x) = (se...
z3::re_empty
expr re_empty(sort const &s)
Definition: z3++.h:3467
Z3_mk_ast_vector
Z3_ast_vector Z3_API Z3_mk_ast_vector(Z3_context c)
Return an empty AST vector.
z3::expr::is_datatype
bool is_datatype() const
Return true if this is a Datatype expression.
Definition: z3++.h:776
z3::int2bv
expr int2bv(unsigned n, expr const &a)
Definition: z3++.h:1889
z3::context::enumeration_sort
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....
Definition: z3++.h:3004
Z3_tactic_get_param_descrs
Z3_param_descrs Z3_API Z3_tactic_get_param_descrs(Z3_context c, Z3_tactic t)
Return the parameter description set for the given tactic object.
Z3_mk_bvadd_no_underflow
Z3_ast Z3_API Z3_mk_bvadd_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2)
Create a predicate that checks that the bit-wise signed addition of t1 and t2 does not underflow.
Z3_goal_assert
void Z3_API Z3_goal_assert(Z3_context c, Z3_goal g, Z3_ast a)
Add a new formula a to the given goal. The formula is split according to the following procedure that...
z3::solver::set
void set(char const *k, unsigned v)
Definition: z3++.h:2369
z3::operator*
expr operator*(expr const &a, expr const &b)
Definition: z3++.h:1503
Z3_probe_lt
Z3_probe Z3_API Z3_probe_lt(Z3_context x, Z3_probe p1, Z3_probe p2)
Return a probe that evaluates to "true" when the value returned by p1 is less than the value returned...
z3::context::real_sort
sort real_sort()
Return the Real sort.
Definition: z3++.h:2967
Z3_mk_seq_empty
Z3_ast Z3_API Z3_mk_seq_empty(Z3_context c, Z3_sort seq)
Create an empty sequence of the sequence sort seq.
Z3_optimize_set_params
void Z3_API Z3_optimize_set_params(Z3_context c, Z3_optimize o, Z3_params p)
Set parameters on optimization context.
Z3_ast_vector_resize
void Z3_API Z3_ast_vector_resize(Z3_context c, Z3_ast_vector v, unsigned n)
Resize the AST vector v.
z3::probe::operator<=
friend probe operator<=(probe const &p1, probe const &p2)
Definition: z3++.h:2767
Z3_mk_params
Z3_params Z3_API Z3_mk_params(Z3_context c)
Create a Z3 (empty) parameter set. Starting at Z3 4.0, parameter sets are used to configure many comp...
Z3_solver_assert_and_track
void Z3_API Z3_solver_assert_and_track(Z3_context c, Z3_solver s, Z3_ast a, Z3_ast p)
Assert a constraint a into the solver, and track it (in the unsat) core using the Boolean constant p.
Z3_mk_probe
Z3_probe Z3_API Z3_mk_probe(Z3_context c, Z3_string name)
Return a probe associated with the given name. The complete list of probes may be obtained using the ...
z3::expr_vector
ast_vector_tpl< expr > expr_vector
Definition: z3++.h:72
Z3_tactic_get_help
Z3_string Z3_API Z3_tactic_get_help(Z3_context c, Z3_tactic t)
Return a string containing a description of parameters accepted by the given tactic.
z3::optimize::add
handle add(expr const &e, unsigned weight)
Definition: z3++.h:2840
z3::operator/
expr operator/(expr const &a, expr const &b)
Definition: z3++.h:1544
Z3_params_inc_ref
void Z3_API Z3_params_inc_ref(Z3_context c, Z3_params p)
Increment the reference counter of the given parameter set.
Z3_mk_string_sort
Z3_sort Z3_API Z3_mk_string_sort(Z3_context c)
Create a sort for 8 bit strings.
Z3_mk_select_n
Z3_ast Z3_API Z3_mk_select_n(Z3_context c, Z3_ast a, unsigned n, Z3_ast const *idxs)
n-ary Array read. The argument a is the array and idxs are the indices of the array that gets read.
z3::sum
expr sum(expr_vector const &args)
Definition: z3++.h:2095
z3::sort::is_seq
bool is_seq() const
Return true if this sort is a Sequence sort.
Definition: z3++.h:647
z3::solver::proof
expr proof() const
Definition: z3++.h:2435
Z3_mk_tuple_sort
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.
Z3_probe_not
Z3_probe Z3_API Z3_probe_not(Z3_context x, Z3_probe p)
Return a probe that evaluates to "true" when p does not evaluate to true.
z3::bvneg_no_overflow
expr bvneg_no_overflow(expr const &a)
Definition: z3++.h:1909
z3::linear_order
func_decl linear_order(sort const &a, unsigned index)
Definition: z3++.h:1925
z3::expr::concat
friend expr concat(expr const &a, expr const &b)
Definition: z3++.h:2113
Z3_fixedpoint_get_assertions
Z3_ast_vector Z3_API Z3_fixedpoint_get_assertions(Z3_context c, Z3_fixedpoint f)
Retrieve set of background assertions from fixedpoint context.
Z3_del_config
void Z3_API Z3_del_config(Z3_config c)
Delete the given configuration object.
Z3_apply_result_get_subgoal
Z3_goal Z3_API Z3_apply_result_get_subgoal(Z3_context c, Z3_apply_result r, unsigned i)
Return one of the subgoals in the Z3_apply_result object returned by Z3_tactic_apply.
Z3_is_lambda
bool Z3_API Z3_is_lambda(Z3_context c, Z3_ast a)
Determine if ast is a lambda expression.
z3::solver::check
check_result check()
Definition: z3++.h:2390
z3::expr::is_real
bool is_real() const
Return true if this is a real expression.
Definition: z3++.h:760
Z3_mk_array_sort
Z3_sort Z3_API Z3_mk_array_sort(Z3_context c, Z3_sort domain, Z3_sort range)
Create an array type.
Z3_mk_bvsle
Z3_ast Z3_API Z3_mk_bvsle(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed less than or equal to.
Z3_mk_int2bv
Z3_ast Z3_API Z3_mk_int2bv(Z3_context c, unsigned n, Z3_ast t1)
Create an n bit bit-vector from the integer argument t1.
Z3_solver_get_statistics
Z3_stats Z3_API Z3_solver_get_statistics(Z3_context c, Z3_solver s)
Return statistics for the given solver.
Z3_is_seq_sort
bool Z3_API Z3_is_seq_sort(Z3_context c, Z3_sort s)
Check if s is a sequence sort.
Z3_get_bv_sort_size
unsigned Z3_API Z3_get_bv_sort_size(Z3_context c, Z3_sort t)
Return the size of the given bit-vector sort.
z3::context::parse_file
expr_vector parse_file(char const *file)
Definition: z3++.h:3505
z3::expr::bvadd_no_underflow
friend expr bvadd_no_underflow(expr const &a, expr const &b)
Definition: z3++.h:1897
Z3_fixedpoint_to_string
Z3_string Z3_API Z3_fixedpoint_to_string(Z3_context c, Z3_fixedpoint f, unsigned num_queries, Z3_ast queries[])
Print the current rules and background axioms as a string.
Z3_get_numeral_decimal_string
Z3_string Z3_API Z3_get_numeral_decimal_string(Z3_context c, Z3_ast a, unsigned precision)
Return numeral as a string in decimal notation. The result has at most precision decimal places.
Z3_mk_false
Z3_ast Z3_API Z3_mk_false(Z3_context c)
Create an AST node representing false.
z3::smod
expr smod(expr const &a, expr const &b)
signed modulus operator for bitvectors
Definition: z3++.h:1848
Z3_get_numeral_int
bool Z3_API Z3_get_numeral_int(Z3_context c, Z3_ast v, int *i)
Similar to Z3_get_numeral_string, but only succeeds if the value can fit in a machine int....
Z3_get_array_sort_range
Z3_sort Z3_API Z3_get_array_sort_range(Z3_context c, Z3_sort t)
Return the range of the given array sort.
z3::params::set
void set(char const *k, double n)
Definition: z3++.h:477
z3::fixedpoint::fixedpoint
fixedpoint(context &c)
Definition: z3++.h:2905
z3::operator|
expr operator|(expr const &a, expr const &b)
Definition: z3++.h:1685
z3::goal::~goal
~goal()
Definition: z3++.h:2566
z3::context::~context
~context()
Definition: z3++.h:175
z3::max
expr max(expr const &a, expr const &b)
Definition: z3++.h:1707
z3::expr::fpa_rounding_mode
sort fpa_rounding_mode()
Return a RoundingMode sort.
Definition: z3++.h:1036
Z3_model_inc_ref
void Z3_API Z3_model_inc_ref(Z3_context c, Z3_model m)
Increment the reference counter of the given model.
z3::expr::operator!=
friend expr operator!=(expr const &a, expr const &b)
Definition: z3++.h:1463
z3::symbol::symbol
symbol(context &c, Z3_symbol s)
Definition: z3++.h:418
Z3_parse_smtlib2_string
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.
Z3_mk_atleast
Z3_ast Z3_API Z3_mk_atleast(Z3_context c, unsigned num_args, Z3_ast const args[], unsigned k)
Pseudo-Boolean relations.
Z3_mk_bvnand
Z3_ast Z3_API Z3_mk_bvnand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise nand.
Z3_solver_set_params
void Z3_API Z3_solver_set_params(Z3_context c, Z3_solver s, Z3_params p)
Set the given solver using the given parameters.
Z3_solver_get_non_units
Z3_ast_vector Z3_API Z3_solver_get_non_units(Z3_context c, Z3_solver s)
Return the set of non units in the solver state.
z3::sort::is_arith
bool is_arith() const
Return true if this sort is the Integer or Real sort.
Definition: z3++.h:627
Z3_mk_bvsdiv
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed division.
z3::expr::rotate_right
expr rotate_right(unsigned i)
Definition: z3++.h:1249
z3::context::real_const
expr real_const(char const *name)
Definition: z3++.h:3146
z3::context::uninterpreted_sort
sort uninterpreted_sort(char const *name)
create an uninterpreted sort with the name given by the string or symbol.
Definition: z3++.h:3028
Z3_mk_unsigned_int64
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.
Z3_get_range
Z3_sort Z3_API Z3_get_range(Z3_context c, Z3_func_decl d)
Return the range of the given declaration.
Z3_solver_cube
Z3_ast_vector Z3_API Z3_solver_cube(Z3_context c, Z3_solver s, Z3_ast_vector vars, unsigned backtrack_level)
extract a next cube for a solver. The last cube is the constant true or false. The number of (non-con...
z3::array::resize
void resize(unsigned sz)
Definition: z3++.h:395
z3::forall
expr forall(expr const &x, expr const &b)
Definition: z3++.h:1982
z3::expr::get_decimal_string
std::string get_decimal_string(int precision) const
Return string representation of numeral or algebraic number This method assumes the expression is num...
Definition: z3++.h:864
Z3_get_app_arg
Z3_ast Z3_API Z3_get_app_arg(Z3_context c, Z3_app a, unsigned i)
Return the i-th argument of the given application.
z3::rem
expr rem(expr const &a, expr const &b)
Definition: z3++.h:1405
z3::expr::bvadd_no_overflow
friend expr bvadd_no_overflow(expr const &a, expr const &b, bool is_signed)
bit-vector overflow/underflow checks
Definition: z3++.h:1894
z3::model::model
model(model const &s)
Definition: z3++.h:2235
z3::func_decl::name
symbol name() const
Definition: z3++.h:705
z3::expr::get_string
std::string get_string() const
Definition: z3++.h:1023
z3::sort::sort
sort(sort const &s)
Definition: z3++.h:592
Z3_mk_optimize
Z3_optimize Z3_API Z3_mk_optimize(Z3_context c)
Create a new optimize context.
Z3_apply_result_dec_ref
void Z3_API Z3_apply_result_dec_ref(Z3_context c, Z3_apply_result r)
Decrement the reference counter of the given Z3_apply_result object.
Z3_model_to_string
Z3_string Z3_API Z3_model_to_string(Z3_context c, Z3_model m)
Convert the given model into a string.
z3::ast_vector_tpl::ast_vector_tpl
ast_vector_tpl(context &c, Z3_ast_vector v)
Definition: z3++.h:521
Z3_symbol_kind
Z3_symbol_kind
The different kinds of symbol. In Z3, a symbol can be represented using integers and strings (See Z3_...
Definition: z3_api.h:113
z3::distinct
expr distinct(expr_vector const &args)
Definition: z3++.h:2104
z3::tactic::help
std::string help() const
Definition: z3++.h:2668
z3::expr::itos
expr itos() const
Definition: z3++.h:1313
z3::solver::solver
solver(context &c, solver const &src, translate)
Definition: z3++.h:2356
Z3_solver_assert
void Z3_API Z3_solver_assert(Z3_context c, Z3_solver s, Z3_ast a)
Assert a constraint into the solver.
Z3_mk_set_member
Z3_ast Z3_API Z3_mk_set_member(Z3_context c, Z3_ast elem, Z3_ast set)
Check for set membership.
z3::expr::is_numeral
bool is_numeral(double &d) const
Definition: z3++.h:816
z3::prefixof
expr prefixof(expr const &a, expr const &b)
Definition: z3++.h:3434
z3::expr::operator/
friend expr operator/(expr const &a, expr const &b)
Definition: z3++.h:1544
z3::expr::extract
expr extract(unsigned hi, unsigned lo) const
Definition: z3++.h:1256
Z3_func_entry_get_arg
Z3_ast Z3_API Z3_func_entry_get_arg(Z3_context c, Z3_func_entry e, unsigned i)
Return an argument of a Z3_func_entry object.
z3::operator-
expr operator-(expr const &a)
Definition: z3++.h:1566
z3::when
tactic when(probe const &p, tactic const &t)
Definition: z3++.h:2949
z3::func_decl::func_decl
func_decl(context &c, Z3_func_decl n)
Definition: z3++.h:692
Z3_tactic_par_or
Z3_tactic Z3_API Z3_tactic_par_or(Z3_context c, unsigned num, Z3_tactic const ts[])
Return a tactic that applies the given tactics in parallel.
Z3_fixedpoint_get_param_descrs
Z3_param_descrs Z3_API Z3_fixedpoint_get_param_descrs(Z3_context c, Z3_fixedpoint f)
Return the parameter description set for the given fixedpoint object.
z3::func_interp::func_interp
func_interp(func_interp const &s)
Definition: z3++.h:2202
z3::ast_vector_tpl
Definition: z3++.h:70
z3::check_context
void check_context(object const &a, object const &b)
Definition: z3++.h:413
Z3_mk_fpa_lt
Z3_ast Z3_API Z3_mk_fpa_lt(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point less than.
z3::bvadd_no_underflow
expr bvadd_no_underflow(expr const &a, expr const &b)
Definition: z3++.h:1897
z3::solver::cube_generator::set_cutoff
void set_cutoff(unsigned c)
Definition: z3++.h:2547
z3::object::check_context
friend void check_context(object const &a, object const &b)
Definition: z3++.h:413
Z3_fixedpoint_get_reason_unknown
Z3_string Z3_API Z3_fixedpoint_get_reason_unknown(Z3_context c, Z3_fixedpoint d)
Retrieve a string that describes the last status returned by Z3_fixedpoint_query.
z3::probe::operator<
friend probe operator<(probe const &p1, probe const &p2)
Definition: z3++.h:2777
Z3_mk_bvult
Z3_ast Z3_API Z3_mk_bvult(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned less than.
Z3_simplify
Z3_ast Z3_API Z3_simplify(Z3_context c, Z3_ast a)
Interface to simplifier.
Z3_OP_OR
@ Z3_OP_OR
Definition: z3_api.h:1015
z3::model::~model
~model()
Definition: z3++.h:2237
Z3_model_get_func_decl
Z3_func_decl Z3_API Z3_model_get_func_decl(Z3_context c, Z3_model m, unsigned i)
Return the declaration of the i-th function in the given model.
z3::expr::operator^
friend expr operator^(expr const &a, expr const &b)
Definition: z3++.h:1681
z3::concat
expr concat(expr const &a, expr const &b)
Definition: z3++.h:2113
z3::expr::mk_and
friend expr mk_and(expr_vector const &args)
Definition: z3++.h:2163
Z3_PRINT_SMTLIB2_COMPLIANT
@ Z3_PRINT_SMTLIB2_COMPLIANT
Definition: z3_api.h:1342
z3::param_descrs::documentation
std::string documentation(symbol const &s)
Definition: z3++.h:455
z3::func_interp::func_interp
func_interp(context &c, Z3_func_interp e)
Definition: z3++.h:2201
z3::probe::operator&&
friend probe operator&&(probe const &p1, probe const &p2)
Definition: z3++.h:2792
z3::expr::mod
friend expr mod(expr const &a, expr const &b)
Definition: z3++.h:1389
z3::tree_order
func_decl tree_order(sort const &a, unsigned index)
Definition: z3++.h:1934
Z3_solver_translate
Z3_solver Z3_API Z3_solver_translate(Z3_context source, Z3_solver s, Z3_context target)
Copy a solver s from the context source to the context target.
z3::fixedpoint::update_rule
void update_rule(expr &rule, symbol const &name)
Definition: z3++.h:2921
z3::atmost
expr atmost(expr_vector const &es, unsigned bound)
Definition: z3++.h:2079
Z3_func_entry_dec_ref
void Z3_API Z3_func_entry_dec_ref(Z3_context c, Z3_func_entry e)
Decrement the reference counter of the given Z3_func_entry object.
z3::solver::trail
expr_vector trail() const
Definition: z3++.h:2424
z3::solver::set
void set(char const *k, bool v)
Definition: z3++.h:2368
Z3_mk_re_union
Z3_ast Z3_API Z3_mk_re_union(Z3_context c, unsigned n, Z3_ast const args[])
Create the union of the regular languages.
Z3_mk_bvudiv
Z3_ast Z3_API Z3_mk_bvudiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned division.
z3::ast_vector_tpl::operator=
ast_vector_tpl & operator=(ast_vector_tpl const &s)
Definition: z3++.h:534
z3::expr::is_re
bool is_re() const
Return true if this is a regular expression.
Definition: z3++.h:788
z3::fixedpoint::to_string
std::string to_string(expr_vector const &queries)
Definition: z3++.h:2937
z3::fixedpoint::~fixedpoint
~fixedpoint()
Definition: z3++.h:2906
Z3_L_FALSE
@ Z3_L_FALSE
Definition: z3_api.h:101
Z3_optimize_push
void Z3_API Z3_optimize_push(Z3_context c, Z3_optimize d)
Create a backtracking point.
z3::tactic::~tactic
~tactic()
Definition: z3++.h:2649
z3::expr::is_bv
bool is_bv() const
Return true if this is a Bit-vector expression.
Definition: z3++.h:768
Z3_mk_re_sort
Z3_sort Z3_API Z3_mk_re_sort(Z3_context c, Z3_sort seq)
Create a regular expression sort out of a sequence sort.
z3::solver::cube_iterator::operator->
const expr_vector * operator->() const
Definition: z3++.h:2513
Z3_mk_bvsub
Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement subtraction.
z3::expr::expr
expr(context &c, Z3_ast n)
Definition: z3++.h:740
Z3_probe_gt
Z3_probe Z3_API Z3_probe_gt(Z3_context x, Z3_probe p1, Z3_probe p2)
Return a probe that evaluates to "true" when the value returned by p1 is greater than the value retur...
z3::solver::set
void set(params const &p)
Definition: z3++.h:2367
Z3_BOOL_SORT
@ Z3_BOOL_SORT
Definition: z3_api.h:150
z3::context::fpa_rounding_mode
sort fpa_rounding_mode()
Return a RoundingMode sort.
Definition: z3++.h:2986
z3::stats::is_double
bool is_double(unsigned i) const
Definition: z3++.h:2327
z3::eq
bool eq(ast const &a, ast const &b)
Definition: z3++.h:513
Z3_mk_sign_ext
Z3_ast Z3_API Z3_mk_sign_ext(Z3_context c, unsigned i, Z3_ast t1)
Sign-extend of the given bit-vector to the (signed) equivalent bit-vector of size m+i,...
z3::func_entry
Definition: z3++.h:2171
z3::expr::is_exists
bool is_exists() const
Return true if this expression is an existential quantifier.
Definition: z3++.h:838
z3::cast_ast
Definition: z3++.h:69
Z3_mk_tree_order
Z3_func_decl Z3_API Z3_mk_tree_order(Z3_context c, Z3_sort a, unsigned id)
create a tree ordering relation over signature a identified using index id.
z3::probe
Definition: z3++.h:2725
Z3_get_error_code
Z3_error_code Z3_API Z3_get_error_code(Z3_context c)
Return the error code for the last API call.
Z3_mk_seq_sort
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.
z3::fixedpoint::query
check_result query(expr &q)
Definition: z3++.h:2912
z3
Z3 C++ namespace.
Definition: z3++.h:48
Z3_stats_is_double
bool Z3_API Z3_stats_is_double(Z3_context c, Z3_stats s, unsigned idx)
Return true if the given statistical data is a double.
z3::solver::statistics
stats statistics() const
Definition: z3++.h:2419
z3::expr::is_array
bool is_array() const
Return true if this is a Array expression.
Definition: z3++.h:772
Z3_mk_pble
Z3_ast Z3_API Z3_mk_pble(Z3_context c, unsigned num_args, Z3_ast const args[], int const coeffs[], int k)
Pseudo-Boolean relations.
z3::fixedpoint::assertions
expr_vector assertions() const
Definition: z3++.h:2931
Z3_mk_bvand
Z3_ast Z3_API Z3_mk_bvand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise and.
Z3_mk_solver
Z3_solver Z3_API Z3_mk_solver(Z3_context c)
Create a new solver. This solver is a "combined solver" (see combined_solver module) that internally ...
z3::ast_vector_tpl::iterator::operator->
T * operator->() const
Definition: z3++.h:575
Z3_fpa_get_ebits
unsigned Z3_API Z3_fpa_get_ebits(Z3_context c, Z3_sort s)
Retrieves the number of bits reserved for the exponent in a FloatingPoint sort.
Z3_param_descrs_get_kind
Z3_param_kind Z3_API Z3_param_descrs_get_kind(Z3_context c, Z3_param_descrs p, Z3_symbol n)
Return the kind associated with the given parameter name n.
z3::expr::operator||
friend expr operator||(expr const &a, expr const &b)
Return an expression representing a or b.
Definition: z3++.h:1441
z3::apply_result::operator<<
friend std::ostream & operator<<(std::ostream &out, apply_result const &r)
Definition: z3++.h:2637
z3::optimize::handle::handle
handle(unsigned h)
Definition: z3++.h:2809
z3::implies
expr implies(expr const &a, expr const &b)
Definition: z3++.h:1377
z3::expr::int2bv
friend expr int2bv(unsigned n, expr const &a)
Definition: z3++.h:1889
Z3_substitute
Z3_ast Z3_API Z3_substitute(Z3_context c, Z3_ast a, unsigned num_exprs, Z3_ast const from[], Z3_ast const to[])
Substitute every occurrence of from[i] in a with to[i], for i smaller than num_exprs....
Z3_mk_simple_solver
Z3_solver Z3_API Z3_mk_simple_solver(Z3_context c)
Create a new incremental solver.
Z3_mk_bvxnor
Z3_ast Z3_API Z3_mk_bvxnor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise xnor.
Z3_get_bool_value
Z3_lbool Z3_API Z3_get_bool_value(Z3_context c, Z3_ast a)
Return Z3_L_TRUE if a is true, Z3_L_FALSE if it is false, and Z3_L_UNDEF otherwise.
z3::object::object
object(object const &s)
Definition: z3++.h:408
z3::sort::is_real
bool is_real() const
Return true if this sort is the Real sort.
Definition: z3++.h:623
Z3_get_algebraic_number_lower
Z3_ast Z3_API Z3_get_algebraic_number_lower(Z3_context c, Z3_ast a, unsigned precision)
Return a lower bound for the given real algebraic number. The interval isolating the number is smalle...
Z3_set_error_handler
void Z3_API Z3_set_error_handler(Z3_context c, Z3_error_handler h)
Register a Z3 error handler.
z3::expr::nth
expr nth(expr const &index) const
Definition: z3++.h:1297
z3::ast_vector_tpl::iterator::operator!=
bool operator!=(iterator const &other) const
Definition: z3++.h:564
Z3_mk_unsigned_int
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.
Z3_mk_bvsub_no_underflow
Z3_ast Z3_API Z3_mk_bvsub_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2, bool is_signed)
Create a predicate that checks that the bit-wise subtraction of t1 and t2 does not underflow.
Z3_mk_fpa_max
Z3_ast Z3_API Z3_mk_fpa_max(Z3_context c, Z3_ast t1, Z3_ast t2)
Maximum of floating-point numbers.
z3::nand
expr nand(expr const &a, expr const &b)
Definition: z3++.h:1689
z3::rounding_mode
rounding_mode
Definition: z3++.h:136
Z3_get_array_sort_domain
Z3_sort Z3_API Z3_get_array_sort_domain(Z3_context c, Z3_sort t)
Return the domain of the given array sort. In the case of a multi-dimensional array,...
z3::store
expr store(expr const &a, expr const &i, expr const &v)
Definition: z3++.h:3330
z3::ast::ast
ast(context &c)
Definition: z3++.h:491
z3::ast_vector_tpl::iterator
Definition: z3++.h:553
Z3_mk_store
Z3_ast Z3_API Z3_mk_store(Z3_context c, Z3_ast a, Z3_ast i, Z3_ast v)
Array update.
z3::symbol::symbol
symbol(symbol const &s)
Definition: z3++.h:419
z3::func_entry::func_entry
func_entry(func_entry const &s)
Definition: z3++.h:2179
Z3_get_sort_name
Z3_symbol Z3_API Z3_get_sort_name(Z3_context c, Z3_sort d)
Return the sort name as a symbol.
Z3_stats_inc_ref
void Z3_API Z3_stats_inc_ref(Z3_context c, Z3_stats s)
Increment the reference counter of the given statistics object.
z3::probe::apply
double apply(goal const &g) const
Definition: z3++.h:2745
z3::sort::is_bool
bool is_bool() const
Return true if this sort is the Boolean sort.
Definition: z3++.h:615
Z3_solver_from_file
void Z3_API Z3_solver_from_file(Z3_context c, Z3_solver s, Z3_string file_name)
load solver assertions from a file.
z3::model::num_consts
unsigned num_consts() const
Definition: z3++.h:2257
z3::expr::algebraic_upper
expr algebraic_upper(unsigned precision) const
Definition: z3++.h:879
z3::probe::operator==
friend probe operator==(probe const &p1, probe const &p2)
Definition: z3++.h:2787
z3::model::eval
expr eval(expr const &n, bool model_completion=false) const
Definition: z3++.h:2247
Z3_SORT_AST
@ Z3_SORT_AST
Definition: z3_api.h:183
z3::context
A Context manages all other Z3 objects, global configuration options, etc.
Definition: z3++.h:156
z3::model::add_func_interp
func_interp add_func_interp(func_decl &f, expr &else_val)
Definition: z3++.h:2290
z3::stats
Definition: z3++.h:2305
z3::atleast
expr atleast(expr_vector const &es, unsigned bound)
Definition: z3++.h:2087
Z3_model_get_num_consts
unsigned Z3_API Z3_model_get_num_consts(Z3_context c, Z3_model m)
Return the number of constants assigned by the given model.
z3::ast_vector_tpl::set
ast_vector_tpl & set(unsigned idx, ast &a)
Definition: z3++.h:541
z3::expr::simplify
expr simplify(params const &p) const
Return a simplified version of this expression. The parameter p is a set of parameters for the Z3 sim...
Definition: z3++.h:1356
z3::to_check_result
check_result to_check_result(Z3_lbool l)
Definition: z3++.h:144
z3::ast_vector_tpl::operator[]
T operator[](int i) const
Definition: z3++.h:528
z3::expr::operator=
expr & operator=(expr const &n)
Definition: z3++.h:742
z3::config::set
void set(char const *param, char const *value)
Set global parameter param with string value.
Definition: z3++.h:117
Z3_mk_rotate_right
Z3_ast Z3_API Z3_mk_rotate_right(Z3_context c, unsigned i, Z3_ast t1)
Rotate bits of t1 to the right i times.
Z3_get_symbol_int
int Z3_API Z3_get_symbol_int(Z3_context c, Z3_symbol s)
Return the symbol int value.
z3::ast_vector_tpl::iterator::set
void set(T &arg)
Definition: z3++.h:571
z3::partial_order
func_decl partial_order(sort const &a, unsigned index)
Definition: z3++.h:1928
Z3_mk_not
Z3_ast Z3_API Z3_mk_not(Z3_context c, Z3_ast a)
Create an AST node representing not(a).
z3::expr::operator[]
expr operator[](expr const &index) const
Definition: z3++.h:1337
z3::with
tactic with(tactic const &t, params const &p)
Definition: z3++.h:2699
z3::array::operator[]
T & operator[](int i)
Definition: z3++.h:397
Z3_mk_fpa_mul
Z3_ast Z3_API Z3_mk_fpa_mul(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2)
Floating-point multiplication.
MK_EXPR2
#define MK_EXPR2(_fn, _arg1, _arg2)
Definition: z3++.h:3361
z3::sort::id
unsigned id() const
retrieve unique identifier for func_decl.
Definition: z3++.h:598
z3::func_decl::arity
unsigned arity() const
Definition: z3++.h:702
z3::to_real
expr to_real(expr const &a)
Definition: z3++.h:3270
z3::context::num_val
expr num_val(int n, sort const &s)
Definition: z3++.h:3186
Z3_get_decl_name
Z3_symbol Z3_API Z3_get_decl_name(Z3_context c, Z3_func_decl d)
Return the constant declaration name as a symbol.
z3::object
Definition: z3++.h:403
z3::sort::array_range
sort array_range() const
Return the range of this Array sort.
Definition: z3++.h:682
z3::stats::operator=
stats & operator=(stats const &s)
Definition: z3++.h:2317
z3::tactic::par_and_then
friend tactic par_and_then(tactic const &t1, tactic const &t2)
Definition: z3++.h:2718
z3::fixedpoint::add_cover
void add_cover(int level, func_decl &p, expr &property)
Definition: z3++.h:2928
Z3_mk_real
Z3_ast Z3_API Z3_mk_real(Z3_context c, int num, int den)
Create a real from a fraction.
z3::solver::cube_iterator::operator*
expr_vector const & operator*() const
Definition: z3++.h:2514
Z3_mk_set_add
Z3_ast Z3_API Z3_mk_set_add(Z3_context c, Z3_ast set, Z3_ast elem)
Add an element to a set.
z3::param_descrs::kind
Z3_param_kind kind(symbol const &s)
Definition: z3++.h:454
z3::operator&
expr operator&(expr const &a, expr const &b)
Definition: z3++.h:1677
z3::expr::substitute
expr substitute(expr_vector const &src, expr_vector const &dst)
Apply substitution. Replace src expressions by dst.
Definition: z3++.h:3545
Z3_mk_seq_index
Z3_ast Z3_API Z3_mk_seq_index(Z3_context c, Z3_ast s, Z3_ast substr, Z3_ast offset)
Return index of first occurrence of substr in s starting from offset offset. If s does not contain su...
z3::model::size
unsigned size() const
Definition: z3++.h:2261
Z3_mk_const_array
Z3_ast Z3_API Z3_mk_const_array(Z3_context c, Z3_sort domain, Z3_ast v)
Create the constant array.
Z3_get_decl_kind
Z3_decl_kind Z3_API Z3_get_decl_kind(Z3_context c, Z3_func_decl d)
Return declaration kind corresponding to declaration.
z3::fixedpoint::reason_unknown
std::string reason_unknown()
Definition: z3++.h:2920
Z3_params_set_symbol
void Z3_API Z3_params_set_symbol(Z3_context c, Z3_params p, Z3_symbol k, Z3_symbol v)
Add a symbol parameter k with value v to the parameter set p.
Z3_substitute_vars
Z3_ast Z3_API Z3_substitute_vars(Z3_context c, Z3_ast a, unsigned num_exprs, Z3_ast const to[])
Substitute the free variables in a with the expressions in to. For every i smaller than num_exprs,...
z3::exception::what
const char * what() const
Definition: z3++.h:90
z3::model::has_interp
bool has_interp(func_decl f) const
Definition: z3++.h:2285
z3::to_func_decl
func_decl to_func_decl(context &c, Z3_func_decl f)
Definition: z3++.h:1788
Z3_mk_int2real
Z3_ast Z3_API Z3_mk_int2real(Z3_context c, Z3_ast t1)
Coerce an integer to a real.
Z3_apply_result_inc_ref
void Z3_API Z3_apply_result_inc_ref(Z3_context c, Z3_apply_result r)
Increment the reference counter of the given Z3_apply_result object.
z3::func_interp::else_value
expr else_value() const
Definition: z3++.h:2212
Z3_mk_re_intersect
Z3_ast Z3_API Z3_mk_re_intersect(Z3_context c, unsigned n, Z3_ast const args[])
Create the intersection of the regular languages.
z3::expr::is_lambda
bool is_lambda() const
Return true if this expression is a lambda expression.
Definition: z3++.h:842
Z3_mk_fpa_add
Z3_ast Z3_API Z3_mk_fpa_add(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2)
Floating-point addition.
z3::array::size
unsigned size() const
Definition: z3++.h:396
z3::cond
tactic cond(probe const &p, tactic const &t1, tactic const &t2)
Definition: z3++.h:2955
z3::expr::is_numeral_i64
bool is_numeral_i64(int64_t &i) const
Definition: z3++.h:810
z3::context::context
context()
Definition: z3++.h:173
z3::optimize::handle
Definition: z3++.h:2806
Z3_mk_bvxor
Z3_ast Z3_API Z3_mk_bvxor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise exclusive-or.
z3::set_intersect
expr set_intersect(expr const &a, expr const &b)
Definition: z3++.h:3395
z3::context::bool_const
expr bool_const(char const *name)
Definition: z3++.h:3144
z3::solver::cubes
cube_generator cubes(expr_vector &vars)
Definition: z3++.h:2551
z3::solver::trail
expr_vector trail(array< unsigned > &levels) const
Definition: z3++.h:2425
z3::stats::is_uint
bool is_uint(unsigned i) const
Definition: z3++.h:2326
z3::expr::operator-
friend expr operator-(expr const &a)
Definition: z3++.h:1566
z3::const_array
expr const_array(sort const &d, expr const &v)
Definition: z3++.h:3367
Z3_mk_fpa_abs
Z3_ast Z3_API Z3_mk_fpa_abs(Z3_context c, Z3_ast t)
Floating-point absolute value.
z3::model::get_func_interp
func_interp get_func_interp(func_decl f) const
Definition: z3++.h:2276
MK_EXPR1
#define MK_EXPR1(_fn, _arg)
Definition: z3++.h:3356
z3::expr::distinct
friend expr distinct(expr_vector const &args)
Definition: z3++.h:2104
Z3_fixedpoint_get_num_levels
unsigned Z3_API Z3_fixedpoint_get_num_levels(Z3_context c, Z3_fixedpoint d, Z3_func_decl pred)
Query the PDR engine for the maximal levels properties are known about predicate.
z3::sat
@ sat
Definition: z3++.h:133
Z3_mk_is_int
Z3_ast Z3_API Z3_mk_is_int(Z3_context c, Z3_ast t1)
Check if a real number is an integer.
z3::tactic::tactic
tactic(context &c, Z3_tactic s)
Definition: z3++.h:2647
Z3_get_func_decl_id
unsigned Z3_API Z3_get_func_decl_id(Z3_context c, Z3_func_decl f)
Return a unique identifier for f.
Z3_ast_kind
Z3_ast_kind
The different kinds of Z3 AST (abstract syntax trees). That is, terms, formulas and types.
Definition: z3_api.h:177
Z3_func_interp_get_num_entries
unsigned Z3_API Z3_func_interp_get_num_entries(Z3_context c, Z3_func_interp f)
Return the number of entries in the given function interpretation.
z3::stats::stats
stats(context &c, Z3_stats e)
Definition: z3++.h:2313
z3::operator>=
expr operator>=(expr const &a, expr const &b)
Definition: z3++.h:1527
z3::expr::operator*
friend expr operator*(expr const &a, expr const &b)
Definition: z3++.h:1503
Z3_global_param_set
void Z3_API Z3_global_param_set(Z3_string param_id, Z3_string param_value)
Set a global (or module) parameter. This setting is shared by all Z3 contexts.
z3::expr::bvmul_no_underflow
friend expr bvmul_no_underflow(expr const &a, expr const &b)
Definition: z3++.h:1915
z3::solver::get_param_descrs
param_descrs get_param_descrs()
Definition: z3++.h:2460
z3::expr::operator<=
friend expr operator<=(expr const &a, expr const &b)
Definition: z3++.h:1608
z3::ast_vector_tpl::iterator::iterator
iterator(ast_vector_tpl const *v, unsigned i)
Definition: z3++.h:557
z3::fixedpoint::get_answer
expr get_answer()
Definition: z3++.h:2919
Z3_mk_bvsdiv_no_overflow
Z3_ast Z3_API Z3_mk_bvsdiv_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2)
Create a predicate that checks that the bit-wise signed division of t1 and t2 does not overflow.
Z3_mk_bvuge
Z3_ast Z3_API Z3_mk_bvuge(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned greater than or equal to.
z3::func_interp::set_else
void set_else(expr &value)
Definition: z3++.h:2219
Z3_mk_array_sort_n
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.
Z3_get_numeral_double
double Z3_API Z3_get_numeral_double(Z3_context c, Z3_ast a)
Return numeral as a double.
z3::context::context
context(config &c)
Definition: z3++.h:174
z3::expr::min
friend expr min(expr const &a, expr const &b)
Definition: z3++.h:1692
Z3_get_sort
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.
z3::context::bool_sort
sort bool_sort()
Return the Boolean sort.
Definition: z3++.h:2965
z3::solver::get_model
model get_model() const
Definition: z3++.h:2412
z3::optimize::minimize
handle minimize(expr const &e)
Definition: z3++.h:2858
z3::solver::simple
Definition: z3++.h:2350
z3::expr::length
expr length() const
Definition: z3++.h:1303
z3::par_or
tactic par_or(unsigned n, tactic const *tactics)
Definition: z3++.h:2709
Z3_goal_convert_model
Z3_model Z3_API Z3_goal_convert_model(Z3_context c, Z3_goal g, Z3_model m)
Convert a model of the formulas of a goal to a model of an original goal. The model may be null,...
z3::solver::push
void push()
Definition: z3++.h:2373
z3::params::operator=
params & operator=(params const &s)
Definition: z3++.h:468
z3::symbol::operator<<
friend std::ostream & operator<<(std::ostream &out, symbol const &s)
Definition: z3++.h:428
z3::sort::array_domain
sort array_domain() const
Return the domain of this Array sort.
Definition: z3++.h:676
z3::param_descrs::name
symbol name(unsigned i)
Definition: z3++.h:453
z3::expr::denominator
expr denominator() const
Definition: z3++.h:997
z3::indexof
expr indexof(expr const &s, expr const &substr, expr const &offset)
Definition: z3++.h:3440
z3::expr::is_well_sorted
bool is_well_sorted() const
Return true if this expression is well sorted (aka type correct).
Definition: z3++.h:856
Z3_get_quantifier_body
Z3_ast Z3_API Z3_get_quantifier_body(Z3_context c, Z3_ast a)
Return body of quantifier.
Z3_mk_seq_at
Z3_ast Z3_API Z3_mk_seq_at(Z3_context c, Z3_ast s, Z3_ast index)
Retrieve from s the unit sequence positioned at position index. The sequence is empty if the index is...
Z3_mk_atmost
Z3_ast Z3_API Z3_mk_atmost(Z3_context c, unsigned num_args, Z3_ast const args[], unsigned k)
Pseudo-Boolean relations.
z3::config::set
void set(char const *param, int value)
Set global parameter param with integer value.
Definition: z3++.h:125
Z3_mk_bvsrem
Z3_ast Z3_API Z3_mk_bvsrem(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed remainder (sign follows dividend).
Z3_SEQ_SORT
@ Z3_SEQ_SORT
Definition: z3_api.h:160
Z3_fixedpoint_add_fact
void Z3_API Z3_fixedpoint_add_fact(Z3_context c, Z3_fixedpoint d, Z3_func_decl r, unsigned num_args, unsigned args[])
Add a Database fact.
Z3_mk_uninterpreted_sort
Z3_sort Z3_API Z3_mk_uninterpreted_sort(Z3_context c, Z3_symbol s)
Create a free (uninterpreted) type using the given name (symbol).
z3::tactic::tactic
tactic(context &c, char const *name)
Definition: z3++.h:2646
z3::star
expr star(expr const &re)
Definition: z3++.h:3464
z3::RTZ
@ RTZ
Definition: z3++.h:141
z3::full_set
expr full_set(sort const &s)
Definition: z3++.h:3375
z3::stats::uint_value
unsigned uint_value(unsigned i) const
Definition: z3++.h:2328
Z3_mk_mod
Z3_ast Z3_API Z3_mk_mod(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create an AST node representing arg1 mod arg2.
Z3_stats_get_key
Z3_string Z3_API Z3_stats_get_key(Z3_context c, Z3_stats s, unsigned idx)
Return the key (a string) for a particular statistical data.
z3::fixedpoint::help
std::string help() const
Definition: z3++.h:2934
Z3_fixedpoint_add_cover
void Z3_API Z3_fixedpoint_add_cover(Z3_context c, Z3_fixedpoint d, int level, Z3_func_decl pred, Z3_ast property)
Add property about the predicate pred. Add a property of predicate pred at level. It gets pushed forw...
z3::object::check_error
Z3_error_code check_error() const
Definition: z3++.h:410
Z3_optimize_get_unsat_core
Z3_ast_vector Z3_API Z3_optimize_get_unsat_core(Z3_context c, Z3_optimize o)
Retrieve the unsat core for the last Z3_optimize_check The unsat core is a subset of the assumptions ...
z3::set_union
expr set_union(expr const &a, expr const &b)
Definition: z3++.h:3387
z3::solver::consequences
check_result consequences(expr_vector &assumptions, expr_vector &vars, expr_vector &conseq)
Definition: z3++.h:2413
Z3_optimize_get_model
Z3_model Z3_API Z3_optimize_get_model(Z3_context c, Z3_optimize o)
Retrieve the model for the last Z3_optimize_check.
z3::repeat
tactic repeat(tactic const &t, unsigned max=UINT_MAX)
Definition: z3++.h:2693
z3::optimize::push
void push()
Definition: z3++.h:2861
z3::expr::is_implies
bool is_implies() const
Definition: z3++.h:1143
z3::ast_vector_tpl::begin
iterator begin() const
Definition: z3++.h:578
Z3_mk_lambda_const
Z3_ast Z3_API Z3_mk_lambda_const(Z3_context c, unsigned num_bound, Z3_app const bound[], Z3_ast body)
Create a lambda expression using a list of constants that form the set of bound variables.
Z3_mk_int64
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.
z3::context::check_error
Z3_error_code check_error() const
Auxiliary method used to check for API usage errors.
Definition: z3++.h:181
z3::fixedpoint::from_string
void from_string(char const *s)
Definition: z3++.h:2908
Z3_tactic_and_then
Z3_tactic Z3_API Z3_tactic_and_then(Z3_context c, Z3_tactic t1, Z3_tactic t2)
Return a tactic that applies t1 to a given goal and t2 to every subgoal produced by t1.
z3::model
Definition: z3++.h:2225
Z3_decl_kind
Z3_decl_kind
The different kinds of interpreted function kinds.
Definition: z3_api.h:1007
z3::expr::is_fpa
bool is_fpa() const
Return true if this is a FloatingPoint expression. .
Definition: z3++.h:802
z3::ast::eq
friend bool eq(ast const &a, ast const &b)
Return true if the ASTs are structurally identical.
Definition: z3++.h:513
z3::set_subset
expr set_subset(expr const &a, expr const &b)
Definition: z3++.h:3415
Z3_error_code
Z3_error_code
Z3 error codes (See Z3_get_error_code).
Definition: z3_api.h:1363
z3::solver::set
void set(char const *k, double v)
Definition: z3++.h:2370
Z3_func_entry_get_num_args
unsigned Z3_API Z3_func_entry_get_num_args(Z3_context c, Z3_func_entry e)
Return the number of arguments in a Z3_func_entry object.
z3::re_complement
expr re_complement(expr const &a)
Definition: z3++.h:3485
z3::re_full
expr re_full(sort const &s)
Definition: z3++.h:3472
Z3_tactic_or_else
Z3_tactic Z3_API Z3_tactic_or_else(Z3_context c, Z3_tactic t1, Z3_tactic t2)
Return a tactic that first applies t1 to a given goal, if it fails then returns the result of t2 appl...
Z3_mk_set_subset
Z3_ast Z3_API Z3_mk_set_subset(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Check for subsetness of sets.
Z3_solver_get_consequences
Z3_lbool Z3_API Z3_solver_get_consequences(Z3_context c, Z3_solver s, Z3_ast_vector assumptions, Z3_ast_vector variables, Z3_ast_vector consequences)
retrieve consequences from solver that determine values of the supplied function symbols.
Z3_DATATYPE_SORT
@ Z3_DATATYPE_SORT
Definition: z3_api.h:155
z3::piecewise_linear_order
func_decl piecewise_linear_order(sort const &a, unsigned index)
Definition: z3++.h:1931
Z3_mk_le
Z3_ast Z3_API Z3_mk_le(Z3_context c, Z3_ast t1, Z3_ast t2)
Create less than or equal to.
z3::optimize::statistics
stats statistics() const
Definition: z3++.h:2894
z3::apply_result::apply_result
apply_result(context &c, Z3_apply_result s)
Definition: z3++.h:2622
Z3_mk_bvsgt
Z3_ast Z3_API Z3_mk_bvsgt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed greater than.
Z3_mk_bvlshr
Z3_ast Z3_API Z3_mk_bvlshr(Z3_context c, Z3_ast t1, Z3_ast t2)
Logical shift right.
Z3_mk_pbge
Z3_ast Z3_API Z3_mk_pbge(Z3_context c, unsigned num_args, Z3_ast const args[], int const coeffs[], int k)
Pseudo-Boolean relations.
z3::ast_vector_tpl::empty
bool empty() const
Definition: z3++.h:533
Z3_mk_sub
Z3_ast Z3_API Z3_mk_sub(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] - ... - args[num_args - 1].
z3::param_descrs
Definition: z3++.h:437
z3::solver::cube_generator::begin
cube_iterator begin()
Definition: z3++.h:2545
z3::model::num_funcs
unsigned num_funcs() const
Definition: z3++.h:2258
Z3_mk_real_sort
Z3_sort Z3_API Z3_mk_real_sort(Z3_context c)
Create the real type.
Z3_get_symbol_string
Z3_string Z3_API Z3_get_symbol_string(Z3_context c, Z3_symbol s)
Return the symbol name.
z3::expr::is_true
bool is_true() const
Definition: z3++.h:1137
Z3_benchmark_to_smtlib_string
Z3_string Z3_API Z3_benchmark_to_smtlib_string(Z3_context c, Z3_string name, Z3_string logic, Z3_string status, Z3_string attributes, unsigned num_assumptions, Z3_ast const assumptions[], Z3_ast formula)
Convert the given benchmark into SMT-LIB formatted string.
z3::expr::is_bool
bool is_bool() const
Return true if this is a Boolean expression.
Definition: z3++.h:752
z3::re_intersect
expr re_intersect(expr_vector const &args)
Definition: z3++.h:3477
Z3_mk_re_empty
Z3_ast Z3_API Z3_mk_re_empty(Z3_context c, Z3_sort re)
Create an empty regular expression of sort re.
z3::solver::unsat_core
expr_vector unsat_core() const
Definition: z3++.h:2420
z3::object::ctx
context & ctx() const
Definition: z3++.h:409
z3::sort::sort
sort(context &c)
Definition: z3++.h:589
z3::param_descrs::to_string
std::string to_string() const
Definition: z3++.h:456
z3::optimize::help
std::string help() const
Definition: z3++.h:2898
z3::expr::body
expr body() const
Return the 'body' of this quantifier.
Definition: z3++.h:1072
z3::func_interp::entry
func_entry entry(unsigned i) const
Definition: z3++.h:2214
Z3_func_entry_get_value
Z3_ast Z3_API Z3_func_entry_get_value(Z3_context c, Z3_func_entry e)
Return the value of this point.
Z3_fixedpoint_get_rules
Z3_ast_vector Z3_API Z3_fixedpoint_get_rules(Z3_context c, Z3_fixedpoint f)
Retrieve set of rules from fixedpoint context.
Z3_mk_seq_nth
Z3_ast Z3_API Z3_mk_seq_nth(Z3_context c, Z3_ast s, Z3_ast index)
Retrieve from s the element positioned at position index. The function is under-specified if the inde...
z3::expr::atleast
friend expr atleast(expr_vector const &es, unsigned bound)
Definition: z3++.h:2087
Z3_string
const typedef char * Z3_string
Z3 string type. It is just an alias for const char *.
Definition: z3_api.h:82
z3::expr::repeat
expr repeat(unsigned i)
Definition: z3++.h:1250
Z3_QUANTIFIER_AST
@ Z3_QUANTIFIER_AST
Definition: z3_api.h:182
z3::pbge
expr pbge(expr_vector const &es, int const *coeffs, int bound)
Definition: z3++.h:2063
z3::probe::probe
probe(context &c, double val)
Definition: z3++.h:2733
z3::context::parse_string
expr_vector parse_string(char const *s)
parsing
Definition: z3++.h:3499
z3::expr::bool_value
Z3_lbool bool_value() const
Definition: z3++.h:985
z3::goal::num_exprs
unsigned num_exprs() const
Definition: z3++.h:2583
z3::func_entry::operator=
func_entry & operator=(func_entry const &s)
Definition: z3++.h:2182
z3::fixedpoint
Definition: z3++.h:2902
Z3_goal_inconsistent
bool Z3_API Z3_goal_inconsistent(Z3_context c, Z3_goal g)
Return true if the given goal contains the formula false.
Z3_solver_get_model
Z3_model Z3_API Z3_solver_get_model(Z3_context c, Z3_solver s)
Retrieve the model for the last Z3_solver_check or Z3_solver_check_assumptions.
Z3_tactic_when
Z3_tactic Z3_API Z3_tactic_when(Z3_context c, Z3_probe p, Z3_tactic t)
Return a tactic that applies t to a given goal is the probe p evaluates to true. If p evaluates to fa...
Z3_OP_NOT
@ Z3_OP_NOT
Definition: z3_api.h:1018
z3::expr::is_and
bool is_and() const
Definition: z3++.h:1140
z3::expr::loop
expr loop(unsigned lo)
create a looping regular expression.
Definition: z3++.h:1323
z3::operator==
expr operator==(expr const &a, expr const &b)
Definition: z3++.h:1454
z3::context::bv_val
expr bv_val(int n, unsigned sz)
Definition: z3++.h:3168
Z3_mk_re_concat
Z3_ast Z3_API Z3_mk_re_concat(Z3_context c, unsigned n, Z3_ast const args[])
Create the concatenation of the regular languages.
z3::in_re
expr in_re(expr const &s, expr const &re)
Definition: z3++.h:3455
z3::expr::expr
expr(expr const &n)
Definition: z3++.h:741
z3::srem
expr srem(expr const &a, expr const &b)
signed remainder operator for bitvectors
Definition: z3++.h:1841
Z3_optimize_get_help
Z3_string Z3_API Z3_optimize_get_help(Z3_context c, Z3_optimize t)
Return a string containing a description of parameters accepted by optimize.
Z3_mk_mul
Z3_ast Z3_API Z3_mk_mul(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] * ... * args[num_args-1].
z3::model::get_const_interp
expr get_const_interp(func_decl c) const
Definition: z3++.h:2270
Z3_mk_seq_extract
Z3_ast Z3_API Z3_mk_seq_extract(Z3_context c, Z3_ast s, Z3_ast offset, Z3_ast length)
Extract subsequence starting at offset of length.
Z3_optimize_minimize
unsigned Z3_API Z3_optimize_minimize(Z3_context c, Z3_optimize o, Z3_ast t)
Add a minimization constraint.
z3::expr::is_or
bool is_or() const
Definition: z3++.h:1141
Z3_solver_inc_ref
void Z3_API Z3_solver_inc_ref(Z3_context c, Z3_solver s)
Increment the reference counter of the given solver.
z3::operator+
expr operator+(expr const &a, expr const &b)
Definition: z3++.h:1473
Z3_fixedpoint_get_cover_delta
Z3_ast Z3_API Z3_fixedpoint_get_cover_delta(Z3_context c, Z3_fixedpoint d, int level, Z3_func_decl pred)
z3::expr::is_app
bool is_app() const
Return true if this expression is an application.
Definition: z3++.h:821
z3::RNA
@ RNA
Definition: z3++.h:137
z3::ite
expr ite(expr const &c, expr const &t, expr const &e)
Create the if-then-else expression ite(c, t, e)
Definition: z3++.h:1761
z3::ast_vector_tpl::iterator::operator++
iterator & operator++()
Definition: z3++.h:567
z3::solver::cube_generator::cube_generator
cube_generator(solver &s, expr_vector &vars)
Definition: z3++.h:2538
Z3_mk_transitive_closure
Z3_func_decl Z3_API Z3_mk_transitive_closure(Z3_context c, Z3_func_decl f)
create transitive closure of binary relation.
z3::param_descrs::operator=
param_descrs & operator=(param_descrs const &o)
Definition: z3++.h:442
Z3_mk_int_symbol
Z3_symbol Z3_API Z3_mk_int_symbol(Z3_context c, int i)
Create a Z3 symbol using an integer.
z3::expr::is_arith
bool is_arith() const
Return true if this is an integer or real expression.
Definition: z3++.h:764
z3::expr::is_string_value
bool is_string_value() const
Return true if this expression is a string literal. The string can be accessed using get_string() and...
Definition: z3++.h:1009
z3::RNE
@ RNE
Definition: z3++.h:138
z3::expr::is_numeral_u64
bool is_numeral_u64(uint64_t &i) const
Definition: z3++.h:811
Z3_fixedpoint_add_rule
void Z3_API Z3_fixedpoint_add_rule(Z3_context c, Z3_fixedpoint d, Z3_ast rule, Z3_symbol name)
Add a universal Horn clause as a named rule. The horn_rule should be of the form:
Z3_optimize_inc_ref
void Z3_API Z3_optimize_inc_ref(Z3_context c, Z3_optimize d)
Increment the reference counter of the given optimize context.
Z3_param_descrs_get_documentation
Z3_string Z3_API Z3_param_descrs_get_documentation(Z3_context c, Z3_param_descrs p, Z3_symbol s)
Retrieve documentation string corresponding to parameter name s.
z3::expr::get_sort
sort get_sort() const
Return the sort of this expression.
Definition: z3++.h:747
z3::expr::get_numeral_int64
int64_t get_numeral_int64() const
Return int64_t value of numeral, throw if result cannot fit in int64_t.
Definition: z3++.h:957
Z3_mk_bvor
Z3_ast Z3_API Z3_mk_bvor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise or.
Z3_mk_partial_order
Z3_func_decl Z3_API Z3_mk_partial_order(Z3_context c, Z3_sort a, unsigned id)
create a partial ordering relation over signature a and index id.
z3::context::int_symbol
symbol int_symbol(int n)
Create a Z3 symbol based on the given integer.
Definition: z3++.h:2963
z3::slt
expr slt(expr const &a, expr const &b)
signed less than operator for bitvectors.
Definition: z3++.h:1802
Z3_STRING_SYMBOL
@ Z3_STRING_SYMBOL
Definition: z3_api.h:116
z3::goal::is_decided_sat
bool is_decided_sat() const
Definition: z3++.h:2584
Z3_mk_piecewise_linear_order
Z3_func_decl Z3_API Z3_mk_piecewise_linear_order(Z3_context c, Z3_sort a, unsigned id)
create a piecewise linear ordering relation over signature a and index id.
z3::probe::operator=
probe & operator=(probe const &s)
Definition: z3++.h:2738