Z3
Loading...
Searching...
No Matches
z3++.h
Go to the documentation of this file.
1/*++
2Copyright (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.
14Author:
15
16 Leonardo (leonardo) 2012-03-28
17
18Notes:
19
20--*/
21#pragma once
22
23#include<cassert>
24#include<ostream>
25#include<string>
26#include<memory>
27#include<vector>
28#include<z3.h>
29#include<z3_rcf.h>
30#include<limits.h>
31#include<functional>
32
33#undef min
34#undef max
35
41
46
50namespace z3 {
51
52 class exception;
53 class config;
54 class context;
55 class symbol;
56 class params;
57 class param_descrs;
58 class ast;
59 class sort;
60 class constructors;
61 class constructor_list;
62 class func_decl;
63 class expr;
64 class solver;
65 class goal;
66 class tactic;
67 class simplifier;
68 class probe;
69 class model;
70 class func_interp;
71 class func_entry;
72 class statistics;
73 class apply_result;
74 template<typename T> class cast_ast;
75 template<typename T> class ast_vector_tpl;
80
81 inline void set_param(char const * param, char const * value) { Z3_global_param_set(param, value); }
82 inline void set_param(char const * param, bool value) { Z3_global_param_set(param, value ? "true" : "false"); }
83 inline void set_param(char const * param, int value) { auto str = std::to_string(value); Z3_global_param_set(param, str.c_str()); }
85
89 inline void get_version(unsigned& major, unsigned& minor, unsigned& build_number, unsigned& revision_number) {
90 Z3_get_version(&major, &minor, &build_number, &revision_number);
91 }
92
96 inline std::string get_full_version() {
97 return std::string(Z3_get_full_version());
98 }
99
104 inline void enable_trace(char const * tag) {
105 Z3_enable_trace(tag);
106 }
107
112 inline void disable_trace(char const * tag) {
113 Z3_disable_trace(tag);
114 }
115
119 class exception : public std::exception {
120 std::string m_msg;
121 public:
122 virtual ~exception() throw() = default;
123 exception(char const * msg):m_msg(msg) {}
124 char const * msg() const { return m_msg.c_str(); }
125 char const * what() const throw() { return m_msg.c_str(); }
126 friend std::ostream & operator<<(std::ostream & out, exception const & e);
127 };
128 inline std::ostream & operator<<(std::ostream & out, exception const & e) { out << e.msg(); return out; }
129
130#if !defined(Z3_THROW)
131#if __cpp_exceptions || _CPPUNWIND || __EXCEPTIONS
132#define Z3_THROW(x) throw x
133#else
134#define Z3_THROW(x) {}
135#endif
136#endif // !defined(Z3_THROW)
137
141 class config {
142 Z3_config m_cfg;
143 config(config const &) = delete;
144 config & operator=(config const &) = delete;
145 public:
146 config() { m_cfg = Z3_mk_config(); }
147 ~config() { Z3_del_config(m_cfg); }
148 operator Z3_config() const { return m_cfg; }
152 void set(char const * param, char const * value) { Z3_set_param_value(m_cfg, param, value); }
156 void set(char const * param, bool value) { Z3_set_param_value(m_cfg, param, value ? "true" : "false"); }
160 void set(char const * param, int value) {
161 auto str = std::to_string(value);
162 Z3_set_param_value(m_cfg, param, str.c_str());
163 }
164 };
165
169
177
179 if (l == Z3_L_TRUE) return sat;
180 else if (l == Z3_L_FALSE) return unsat;
181 return unknown;
182 }
183
184
185
189
190
191 class context {
192 private:
194 bool m_enable_exceptions = true;
195 rounding_mode m_rounding_mode;
196 Z3_context m_ctx = nullptr;
197 void init(config & c) {
198 set_context(Z3_mk_context_rc(c));
199 }
200 void set_context(Z3_context ctx) {
201 m_ctx = ctx;
202 m_enable_exceptions = true;
203 m_rounding_mode = RNE;
204 Z3_set_error_handler(m_ctx, 0);
206 }
207
208
209 context(context const &) = delete;
210 context & operator=(context const &) = delete;
211
212 context(Z3_context c) { set_context(c); }
213 void detach() { m_ctx = nullptr; }
214 public:
215 context() { config c; init(c); }
216 context(config & c) { init(c); }
217
218 context(context && other) noexcept
219 : m_enable_exceptions(other.m_enable_exceptions),
220 m_rounding_mode(other.m_rounding_mode),
221 m_ctx(other.m_ctx) {
222 other.m_ctx = nullptr;
223 }
224
225 context & operator=(context && other) noexcept {
226 if (this != &other) {
227 if (m_ctx) Z3_del_context(m_ctx);
228 m_enable_exceptions = other.m_enable_exceptions;
229 m_rounding_mode = other.m_rounding_mode;
230 m_ctx = other.m_ctx;
231 other.m_ctx = nullptr;
232 }
233 return *this;
234 }
235 ~context() { if (m_ctx) Z3_del_context(m_ctx); }
236 operator Z3_context() const { return m_ctx; }
237
243 if (e != Z3_OK && enable_exceptions())
245 return e;
246 }
247
248 void check_parser_error() const {
249 check_error();
250 }
251
259 void set_enable_exceptions(bool f) { m_enable_exceptions = f; }
260
261 bool enable_exceptions() const { return m_enable_exceptions; }
262
266 void set(char const * param, char const * value) { Z3_update_param_value(m_ctx, param, value); }
270 void set(char const * param, bool value) { Z3_update_param_value(m_ctx, param, value ? "true" : "false"); }
271
272 unsigned num_simplifiers() const {
273 unsigned r = Z3_get_num_simplifiers(m_ctx);
274 check_error();
275 return r;
276 }
277 std::string simplifier_name(unsigned i) const {
278 char const* r = Z3_get_simplifier_name(m_ctx, i);
279 check_error();
280 return r;
281 }
282 std::string simplifier_description(char const* name) const {
283 char const* r = Z3_simplifier_get_descr(m_ctx, name);
284 check_error();
285 return r;
286 }
287
290 void set(char const * param, int value) {
291 auto str = std::to_string(value);
292 Z3_update_param_value(m_ctx, param, str.c_str());
293 }
294
299 void interrupt() { Z3_interrupt(m_ctx); }
300
304 symbol str_symbol(char const * s);
308 symbol int_symbol(int n);
312 sort bool_sort();
316 sort int_sort();
320 sort real_sort();
324 sort finite_field_sort(char const* prime);
328 sort bv_sort(unsigned sz);
329
333 sort char_sort();
341 sort seq_sort(sort& s);
355 sort array_sort(sort d, sort r);
356 sort array_sort(sort_vector const& d, sort r);
363 sort fpa_sort(unsigned ebits, unsigned sbits);
367 template<size_t precision>
382 sort enumeration_sort(char const * name, unsigned n, char const * const * enum_names, func_decl_vector & cs, func_decl_vector & ts);
383
390 func_decl tuple_sort(char const * name, unsigned n, char const * const * names, sort const* sorts, func_decl_vector & projs);
391
392
401 sort datatype(symbol const& name, constructors const& cs);
402
410 sort datatype(symbol const &name, sort_vector const &params, constructors const &cs);
411
418 sort_vector datatypes(unsigned n, symbol const* names,
419 constructor_list *const* cons);
420
421
426 sort datatype_sort(symbol const& name);
427
434 sort datatype_sort(symbol const& name, sort_vector const& params);
435
436
440 sort uninterpreted_sort(char const* name);
441 sort uninterpreted_sort(symbol const& name);
442
443 func_decl function(symbol const & name, unsigned arity, sort const * domain, sort const & range);
444 func_decl function(char const * name, unsigned arity, sort const * domain, sort const & range);
445 func_decl function(symbol const& name, sort_vector const& domain, sort const& range);
446 func_decl function(char const * name, sort_vector const& domain, sort const& range);
447 func_decl function(char const * name, sort const & domain, sort const & range);
448 func_decl function(char const * name, sort const & d1, sort const & d2, sort const & range);
449 func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range);
450 func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & d4, sort const & range);
451 func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & d4, sort const & d5, sort const & range);
452
453 func_decl recfun(symbol const & name, unsigned arity, sort const * domain, sort const & range);
454 func_decl recfun(symbol const & name, const sort_vector& domain, sort const & range);
455 func_decl recfun(char const * name, sort_vector const& domain, sort const & range);
456 func_decl recfun(char const * name, unsigned arity, sort const * domain, sort const & range);
457 func_decl recfun(char const * name, sort const & domain, sort const & range);
458 func_decl recfun(char const * name, sort const & d1, sort const & d2, sort const & range);
459
466 void recdef(func_decl decl, expr_vector const& args, expr const& body);
467 func_decl user_propagate_function(symbol const& name, sort_vector const& domain, sort const& range);
468
472 expr constant(symbol const & name, sort const & s);
473 expr constant(char const * name, sort const & s);
477 expr bool_const(char const * name);
478 expr int_const(char const * name);
479 expr real_const(char const * name);
480 expr complex_const(char const * name);
481 expr string_const(char const * name);
482 expr bv_const(char const * name, unsigned sz);
483 expr fpa_const(char const * name, unsigned ebits, unsigned sbits);
484
485 template<size_t precision>
486 expr fpa_const(char const * name);
487
491 expr variable(unsigned index, sort const& s);
492
493
495
496 expr bool_val(bool b);
497
498 expr int_val(int n);
499 expr int_val(unsigned n);
500 expr int_val(int64_t n);
501 expr int_val(uint64_t n);
502 expr int_val(char const * n);
503
504 expr real_val(int n);
505 expr real_val(unsigned n);
506 expr real_val(int64_t n);
507 expr real_val(uint64_t n);
508 expr real_val(int64_t n, int64_t d);
509 expr real_val(char const * n);
510 expr complex_val(int re, int im = 0);
511 expr complex_val(char const * re, char const * im = "0");
512
513 expr bv_val(int n, unsigned sz);
514 expr bv_val(unsigned n, unsigned sz);
515 expr bv_val(int64_t n, unsigned sz);
516 expr bv_val(uint64_t n, unsigned sz);
517 expr bv_val(char const * n, unsigned sz);
518 expr bv_val(unsigned n, bool const* bits);
519
520 expr fpa_val(double n);
521 expr fpa_val(float n);
522 expr fpa_nan(sort const & s);
523 expr fpa_inf(sort const & s, bool sgn);
524
525 expr string_val(char const* s);
526 expr string_val(char const* s, unsigned n);
527 expr string_val(std::string const& s);
528 expr string_val(std::u32string const& s);
529
530 expr num_val(int n, sort const & s);
531
535 expr_vector parse_string(char const* s);
536 expr_vector parse_file(char const* file);
537
538 expr_vector parse_string(char const* s, sort_vector const& sorts, func_decl_vector const& decls);
539 expr_vector parse_file(char const* s, sort_vector const& sorts, func_decl_vector const& decls);
540 };
541
542
543 template<typename T>
544 class array {
545 std::unique_ptr<T[]> m_array;
546 unsigned m_size;
547 array(array const &) = delete;
548 array & operator=(array const &) = delete;
549 public:
550 array(unsigned sz):m_array(new T[sz]),m_size(sz) {}
551 template<typename T2>
552 array(ast_vector_tpl<T2> const & v);
553 void resize(unsigned sz) { m_array.reset(new T[sz]); m_size = sz; }
554 unsigned size() const { return m_size; }
555 T & operator[](int i) { assert(0 <= i); assert(static_cast<unsigned>(i) < m_size); return m_array[i]; }
556 T const & operator[](int i) const { assert(0 <= i); assert(static_cast<unsigned>(i) < m_size); return m_array[i]; }
557 T const * ptr() const { return m_array.get(); }
558 T * ptr() { return m_array.get(); }
559 };
560
561 class object {
562 protected:
564 public:
565 object(context & c):m_ctx(&c) {}
566 virtual ~object() = default;
567 context & ctx() const { return *m_ctx; }
569 friend void check_context(object const & a, object const & b);
570 };
571 inline void check_context(object const & a, object const & b) { (void)a; (void)b; assert(a.m_ctx == b.m_ctx); }
572
573 class symbol : public object {
574 Z3_symbol m_sym;
575 public:
576 symbol(context & c, Z3_symbol s):object(c), m_sym(s) {}
577 operator Z3_symbol() const { return m_sym; }
578 Z3_symbol_kind kind() const { return Z3_get_symbol_kind(ctx(), m_sym); }
579 std::string str() const { assert(kind() == Z3_STRING_SYMBOL); return Z3_get_symbol_string(ctx(), m_sym); }
580 int to_int() const { assert(kind() == Z3_INT_SYMBOL); return Z3_get_symbol_int(ctx(), m_sym); }
581 friend std::ostream & operator<<(std::ostream & out, symbol const & s);
582 };
583
584 inline std::ostream & operator<<(std::ostream & out, symbol const & s) {
585 if (s.kind() == Z3_INT_SYMBOL)
586 out << "k!" << s.to_int();
587 else
588 out << s.str();
589 return out;
590 }
591
592
593 class param_descrs : public object {
594 Z3_param_descrs m_descrs;
595 public:
596 param_descrs(context& c, Z3_param_descrs d): object(c), m_descrs(d) { Z3_param_descrs_inc_ref(c, d); }
597 param_descrs(param_descrs const& o): object(o.ctx()), m_descrs(o.m_descrs) { Z3_param_descrs_inc_ref(ctx(), m_descrs); }
599 Z3_param_descrs_inc_ref(o.ctx(), o.m_descrs);
600 Z3_param_descrs_dec_ref(ctx(), m_descrs);
601 m_descrs = o.m_descrs;
602 object::operator=(o);
603 return *this;
604 }
605 ~param_descrs() override { Z3_param_descrs_dec_ref(ctx(), m_descrs); }
608
609 unsigned size() { return Z3_param_descrs_size(ctx(), m_descrs); }
610 symbol name(unsigned i) { return symbol(ctx(), Z3_param_descrs_get_name(ctx(), m_descrs, i)); }
611 Z3_param_kind kind(symbol const& s) { return Z3_param_descrs_get_kind(ctx(), m_descrs, s); }
612 std::string documentation(symbol const& s) { char const* r = Z3_param_descrs_get_documentation(ctx(), m_descrs, s); check_error(); return r; }
613 std::string to_string() const { return Z3_param_descrs_to_string(ctx(), m_descrs); }
614 };
615
616 inline std::ostream& operator<<(std::ostream & out, param_descrs const & d) { return out << d.to_string(); }
617
618 class params : public object {
619 Z3_params m_params;
620 public:
621 params(context & c):object(c) { m_params = Z3_mk_params(c); Z3_params_inc_ref(ctx(), m_params); }
622 params(params const & s):object(s), m_params(s.m_params) { Z3_params_inc_ref(ctx(), m_params); }
623 ~params() override { Z3_params_dec_ref(ctx(), m_params); }
624 operator Z3_params() const { return m_params; }
625 params & operator=(params const & s) {
626 Z3_params_inc_ref(s.ctx(), s.m_params);
627 Z3_params_dec_ref(ctx(), m_params);
628 object::operator=(s);
629 m_params = s.m_params;
630 return *this;
631 }
632 void set(char const * k, bool b) { Z3_params_set_bool(ctx(), m_params, ctx().str_symbol(k), b); }
633 void set(char const * k, unsigned n) { Z3_params_set_uint(ctx(), m_params, ctx().str_symbol(k), n); }
634 void set(char const * k, double n) { Z3_params_set_double(ctx(), m_params, ctx().str_symbol(k), n); }
635 void set(char const * k, symbol const & s) { Z3_params_set_symbol(ctx(), m_params, ctx().str_symbol(k), s); }
636 void set(char const * k, char const* s) { Z3_params_set_symbol(ctx(), m_params, ctx().str_symbol(k), ctx().str_symbol(s)); }
637 friend std::ostream & operator<<(std::ostream & out, params const & p);
638 };
639
640 inline std::ostream & operator<<(std::ostream & out, params const & p) {
641 out << Z3_params_to_string(p.ctx(), p); return out;
642 }
643
644 class ast : public object {
645 protected:
646 Z3_ast m_ast;
647 public:
648 ast(context & c):object(c), m_ast(0) {}
649 ast(context & c, Z3_ast n):object(c), m_ast(n) { Z3_inc_ref(ctx(), m_ast); }
650 ast(ast const & s) :object(s), m_ast(s.m_ast) { Z3_inc_ref(ctx(), m_ast); }
651 ~ast() override { if (m_ast) { Z3_dec_ref(*m_ctx, m_ast); } }
652 operator Z3_ast() const { return m_ast; }
653 operator bool() const { return m_ast != 0; }
654 ast & operator=(ast const & s) {
655 Z3_inc_ref(s.ctx(), s.m_ast);
656 if (m_ast)
657 Z3_dec_ref(ctx(), m_ast);
658 object::operator=(s);
659 m_ast = s.m_ast;
660 return *this;
661 }
663 unsigned hash() const { unsigned r = Z3_get_ast_hash(ctx(), m_ast); check_error(); return r; }
664 friend std::ostream & operator<<(std::ostream & out, ast const & n);
665 std::string to_string() const { return std::string(Z3_ast_to_string(ctx(), m_ast)); }
666
667
671 friend bool eq(ast const & a, ast const & b);
672 };
673 inline std::ostream & operator<<(std::ostream & out, ast const & n) {
674 out << Z3_ast_to_string(n.ctx(), n.m_ast); return out;
675 }
676
677 inline bool eq(ast const & a, ast const & b) { return Z3_is_eq_ast(a.ctx(), a, b); }
678
679 template<typename T>
680 class ast_vector_tpl : public object {
681 Z3_ast_vector m_vector;
682 void init(Z3_ast_vector v) { Z3_ast_vector_inc_ref(ctx(), v); m_vector = v; }
683 public:
685 ast_vector_tpl(context & c, Z3_ast_vector v):object(c) { init(v); }
686 ast_vector_tpl(ast_vector_tpl const & s):object(s), m_vector(s.m_vector) { Z3_ast_vector_inc_ref(ctx(), m_vector); }
687 ast_vector_tpl(context& c, ast_vector_tpl const& src): object(c) { init(Z3_ast_vector_translate(src.ctx(), src, c)); }
688
689 ~ast_vector_tpl() override { Z3_ast_vector_dec_ref(ctx(), m_vector); }
690 operator Z3_ast_vector() const { return m_vector; }
691 unsigned size() const { return Z3_ast_vector_size(ctx(), m_vector); }
692 T operator[](unsigned i) const { Z3_ast r = Z3_ast_vector_get(ctx(), m_vector, i); check_error(); return cast_ast<T>()(ctx(), r); }
693 void push_back(T const & e) { Z3_ast_vector_push(ctx(), m_vector, e); check_error(); }
694 void resize(unsigned sz) { Z3_ast_vector_resize(ctx(), m_vector, sz); check_error(); }
695 T back() const { return operator[](size() - 1); }
696 void pop_back() { assert(size() > 0); resize(size() - 1); }
697 bool empty() const { return size() == 0; }
699 Z3_ast_vector_inc_ref(s.ctx(), s.m_vector);
700 Z3_ast_vector_dec_ref(ctx(), m_vector);
701 object::operator=(s);
702 m_vector = s.m_vector;
703 return *this;
704 }
705 ast_vector_tpl& set(unsigned idx, ast& a) {
706 Z3_ast_vector_set(ctx(), m_vector, idx, a);
707 return *this;
708 }
709 /*
710 Disabled pending C++98 build upgrade
711 bool contains(T const& x) const {
712 for (T y : *this) if (eq(x, y)) return true;
713 return false;
714 }
715 */
716
717 class iterator final {
718 ast_vector_tpl const* m_vector;
719 unsigned m_index;
720 public:
721 iterator(ast_vector_tpl const* v, unsigned i): m_vector(v), m_index(i) {}
722
723 bool operator==(iterator const& other) const noexcept {
724 return other.m_index == m_index;
725 };
726
727 bool operator!=(iterator const& other) const noexcept {
728 return other.m_index != m_index;
729 };
730 iterator& operator++() noexcept {
731 ++m_index;
732 return *this;
733 }
734 void set(T& arg) {
735 Z3_ast_vector_set(m_vector->ctx(), *m_vector, m_index, arg);
736 }
737 iterator operator++(int) noexcept { iterator tmp = *this; ++m_index; return tmp; }
738 T * operator->() const { return &(operator*()); }
739 T operator*() const { return (*m_vector)[m_index]; }
740 };
741 iterator begin() const noexcept { return iterator(this, 0); }
742 iterator end() const { return iterator(this, size()); }
743 friend std::ostream & operator<<(std::ostream & out, ast_vector_tpl const & v) { out << Z3_ast_vector_to_string(v.ctx(), v); return out; }
744 std::string to_string() const { return std::string(Z3_ast_vector_to_string(ctx(), m_vector)); }
745 };
746
750 class ast_map : public object {
751 Z3_ast_map m_map;
752 void init(Z3_ast_map m) {
754 m_map = m;
755 }
756 public:
757 ast_map(context& c): object(c) { init(Z3_mk_ast_map(c)); }
758 ast_map(context& c, Z3_ast_map m): object(c) { init(m); }
759 ast_map(ast_map const& s): object(s) { init(s.m_map); }
760 ~ast_map() override { Z3_ast_map_dec_ref(ctx(), m_map); }
761 operator Z3_ast_map() const { return m_map; }
763 Z3_ast_map_inc_ref(s.ctx(), s.m_map);
764 Z3_ast_map_dec_ref(ctx(), m_map);
765 object::operator=(s);
766 m_map = s.m_map;
767 return *this;
768 }
769 bool contains(ast const& k) const {
770 check_context(*this, k);
771 bool r = Z3_ast_map_contains(ctx(), m_map, k);
772 check_error();
773 return r;
774 }
775 ast find(ast const& k) const {
776 check_context(*this, k);
777 Z3_ast r = Z3_ast_map_find(ctx(), m_map, k);
778 check_error();
779 return ast(ctx(), r);
780 }
781 void insert(ast const& k, ast const& v) {
782 check_context(*this, k); check_context(*this, v);
783 Z3_ast_map_insert(ctx(), m_map, k, v);
784 check_error();
785 }
786 void erase(ast const& k) {
787 check_context(*this, k);
788 Z3_ast_map_erase(ctx(), m_map, k);
789 check_error();
790 }
791 void reset() { Z3_ast_map_reset(ctx(), m_map); check_error(); }
792 unsigned size() const {
793 unsigned r = Z3_ast_map_size(ctx(), m_map);
794 check_error();
795 return r;
796 }
797 ast_vector keys() const {
798 Z3_ast_vector r = Z3_ast_map_keys(ctx(), m_map);
799 check_error();
800 return ast_vector(ctx(), r);
801 }
802 };
803
804
808 class sort : public ast {
809 public:
810 sort(context & c):ast(c) {}
811 sort(context & c, Z3_sort s):ast(c, reinterpret_cast<Z3_ast>(s)) {}
812 sort(context & c, Z3_ast a):ast(c, a) {}
813 operator Z3_sort() const { return reinterpret_cast<Z3_sort>(m_ast); }
814
818 unsigned id() const { unsigned r = Z3_get_sort_id(ctx(), *this); check_error(); return r; }
819
823 Z3_sort_kind sort_kind() const { return Z3_get_sort_kind(*m_ctx, *this); }
827 symbol name() const { Z3_symbol s = Z3_get_sort_name(ctx(), *this); check_error(); return symbol(ctx(), s); }
831 bool is_bool() const { return sort_kind() == Z3_BOOL_SORT; }
835 bool is_int() const { return sort_kind() == Z3_INT_SORT; }
839 bool is_real() const { return sort_kind() == Z3_REAL_SORT; }
841 bool is_complex() const { return sort_kind() == Z3_COMPLEX_SORT; }
845 bool is_arith() const { return is_int() || is_real() || is_complex(); }
849 bool is_bv() const { return sort_kind() == Z3_BV_SORT; }
853 bool is_array() const { return sort_kind() == Z3_ARRAY_SORT; }
857 bool is_datatype() const { return sort_kind() == Z3_DATATYPE_SORT; }
861 bool is_relation() const { return sort_kind() == Z3_RELATION_SORT; }
865 bool is_seq() const { return sort_kind() == Z3_SEQ_SORT; }
869 bool is_re() const { return sort_kind() == Z3_RE_SORT; }
873 bool is_finite_field() const { return sort_kind() == Z3_FINITE_FIELD_SORT; }
878 bool is_fpa() const { return sort_kind() == Z3_FLOATING_POINT_SORT; }
879
885 unsigned bv_size() const { assert(is_bv()); unsigned r = Z3_get_bv_sort_size(ctx(), *this); check_error(); return r; }
886
887 unsigned fpa_ebits() const { assert(is_fpa()); unsigned r = Z3_fpa_get_ebits(ctx(), *this); check_error(); return r; }
888
889 unsigned fpa_sbits() const { assert(is_fpa()); unsigned r = Z3_fpa_get_sbits(ctx(), *this); check_error(); return r; }
895 sort array_domain() const { assert(is_array()); Z3_sort s = Z3_get_array_sort_domain(ctx(), *this); check_error(); return sort(ctx(), s); }
901 sort array_range() const { assert(is_array()); Z3_sort s = Z3_get_array_sort_range(ctx(), *this); check_error(); return sort(ctx(), s); }
902
903 friend std::ostream & operator<<(std::ostream & out, sort const & s) { return out << Z3_sort_to_string(s.ctx(), Z3_sort(s.m_ast)); }
904
907 };
908
909
914 class func_decl : public ast {
915 public:
917 func_decl(context & c, Z3_func_decl n):ast(c, reinterpret_cast<Z3_ast>(n)) {}
918 operator Z3_func_decl() const { return reinterpret_cast<Z3_func_decl>(m_ast); }
919
923 unsigned id() const { unsigned r = Z3_get_func_decl_id(ctx(), *this); check_error(); return r; }
924
925 unsigned arity() const { return Z3_get_arity(ctx(), *this); }
926 sort domain(unsigned i) const { assert(i < arity()); Z3_sort r = Z3_get_domain(ctx(), *this, i); check_error(); return sort(ctx(), r); }
927 sort range() const { Z3_sort r = Z3_get_range(ctx(), *this); check_error(); return sort(ctx(), r); }
928 symbol name() const { Z3_symbol s = Z3_get_decl_name(ctx(), *this); check_error(); return symbol(ctx(), s); }
929 Z3_decl_kind decl_kind() const { return Z3_get_decl_kind(ctx(), *this); }
930 unsigned num_parameters() const { return Z3_get_decl_num_parameters(ctx(), *this); }
931
932
934 Z3_func_decl tc = Z3_mk_transitive_closure(ctx(), *this); check_error(); return func_decl(ctx(), tc);
935 }
936
937 bool is_const() const { return arity() == 0; }
938
939 expr operator()() const;
940 expr operator()(unsigned n, expr const * args) const;
941 expr operator()(expr_vector const& v) const;
942 expr operator()(expr const & a) const;
943 expr operator()(int a) const;
944 expr operator()(expr const & a1, expr const & a2) const;
945 expr operator()(expr const & a1, int a2) const;
946 expr operator()(int a1, expr const & a2) const;
947 expr operator()(expr const & a1, expr const & a2, expr const & a3) const;
948 expr operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4) const;
949 expr operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4, expr const & a5) const;
950
952
953 };
954
955 class parser_context : public object {
956 Z3_parser_context m_pc;
957 public:
959 ~parser_context() override { if (m_pc) Z3_parser_context_dec_ref(ctx(), m_pc); }
960 explicit operator bool() const { return m_pc; }
961 operator Z3_parser_context() const { return m_pc; }
962 parser_context(const parser_context &o):object(o), m_pc(o.m_pc) { Z3_parser_context_inc_ref(ctx(), m_pc); }
964 if (this != &o) {
965 if (m_pc) Z3_parser_context_dec_ref(*m_ctx, m_pc);
967 object::operator=(o);
968 m_pc = o.m_pc;
969 }
970 return *this;
971 }
972
976 void add_sort(const sort & s) { Z3_parser_context_add_sort(ctx(), m_pc, s); check_error(); }
977
981 void add_sort(const func_decl & f) { Z3_parser_context_add_decl(ctx(), m_pc, f); check_error(); }
982
986 expr_vector parse_string(const char * s) {
987 auto result = Z3_parser_context_from_string(ctx(), m_pc, s);
988 m_ctx->check_error();
989 return expr_vector(ctx(), result);
990 }
991 };
992
996 expr select(expr const & a, expr const& i);
997 expr select(expr const & a, expr_vector const & i);
998
1003 class expr : public ast {
1004 public:
1005 expr(context & c):ast(c) {}
1006 expr(context & c, Z3_ast n):ast(c, reinterpret_cast<Z3_ast>(n)) {}
1007
1011 sort get_sort() const { Z3_sort s = Z3_get_sort(*m_ctx, m_ast); check_error(); return sort(*m_ctx, s); }
1012
1016 bool is_bool() const { return get_sort().is_bool(); }
1020 bool is_int() const { return get_sort().is_int(); }
1024 bool is_real() const { return get_sort().is_real(); }
1026 bool is_complex() const { return get_sort().is_complex(); }
1030 bool is_arith() const { return get_sort().is_arith(); }
1034 bool is_bv() const { return get_sort().is_bv(); }
1038 bool is_array() const { return get_sort().is_array(); }
1042 bool is_datatype() const { return get_sort().is_datatype(); }
1046 bool is_relation() const { return get_sort().is_relation(); }
1050 bool is_seq() const { return get_sort().is_seq(); }
1054 bool is_re() const { return get_sort().is_re(); }
1055
1064 bool is_finite_field() const { return get_sort().is_finite_field(); }
1065 bool is_finite_domain() const { return get_sort().is_finite_domain(); }
1069 bool is_fpa() const { return get_sort().is_fpa(); }
1070
1076 bool is_numeral() const { return kind() == Z3_NUMERAL_AST; }
1077 bool is_numeral_i64(int64_t& i) const { bool r = Z3_get_numeral_int64(ctx(), m_ast, &i); check_error(); return r;}
1078 bool is_numeral_u64(uint64_t& i) const { bool r = Z3_get_numeral_uint64(ctx(), m_ast, &i); check_error(); return r;}
1079 bool is_numeral_i(int& i) const { bool r = Z3_get_numeral_int(ctx(), m_ast, &i); check_error(); return r;}
1080 bool is_numeral_u(unsigned& i) const { bool r = Z3_get_numeral_uint(ctx(), m_ast, &i); check_error(); return r;}
1081 bool is_numeral(std::string& s) const { if (!is_numeral()) return false; s = Z3_get_numeral_string(ctx(), m_ast); check_error(); return true; }
1082 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; }
1083 bool is_numeral(double& d) const { if (!is_numeral()) return false; d = Z3_get_numeral_double(ctx(), m_ast); check_error(); return true; }
1084 bool as_binary(std::string& s) const { if (!is_numeral()) return false; s = Z3_get_numeral_binary_string(ctx(), m_ast); check_error(); return true; }
1085
1086 double as_double() const { double d = 0; is_numeral(d); return d; }
1087 uint64_t as_uint64() const { uint64_t r = 0; is_numeral_u64(r); return r; }
1088 int64_t as_int64() const { int64_t r = 0; is_numeral_i64(r); return r; }
1089
1090
1094 bool is_app() const { return kind() == Z3_APP_AST || kind() == Z3_NUMERAL_AST; }
1098 bool is_const() const { return is_app() && num_args() == 0; }
1102 bool is_quantifier() const { return kind() == Z3_QUANTIFIER_AST; }
1103
1107 bool is_forall() const { return Z3_is_quantifier_forall(ctx(), m_ast); }
1111 bool is_exists() const { return Z3_is_quantifier_exists(ctx(), m_ast); }
1115 bool is_lambda() const { return Z3_is_lambda(ctx(), m_ast); }
1120 bool is_var() const { return kind() == Z3_VAR_AST; }
1124 bool is_algebraic() const { return Z3_is_algebraic_number(ctx(), m_ast); }
1125
1129 bool is_well_sorted() const { bool r = Z3_is_well_sorted(ctx(), m_ast); check_error(); return r; }
1130
1134 expr mk_is_inf() const {
1135 assert(is_fpa());
1136 Z3_ast r = Z3_mk_fpa_is_infinite(ctx(), m_ast);
1137 check_error();
1138 return expr(ctx(), r);
1139 }
1140
1144 expr mk_is_nan() const {
1145 assert(is_fpa());
1146 Z3_ast r = Z3_mk_fpa_is_nan(ctx(), m_ast);
1147 check_error();
1148 return expr(ctx(), r);
1149 }
1150
1155 assert(is_fpa());
1156 Z3_ast r = Z3_mk_fpa_is_normal(ctx(), m_ast);
1157 check_error();
1158 return expr(ctx(), r);
1159 }
1160
1165 assert(is_fpa());
1166 Z3_ast r = Z3_mk_fpa_is_subnormal(ctx(), m_ast);
1167 check_error();
1168 return expr(ctx(), r);
1169 }
1170
1175 assert(is_fpa());
1176 Z3_ast r = Z3_mk_fpa_is_zero(ctx(), m_ast);
1177 check_error();
1178 return expr(ctx(), r);
1179 }
1180
1185 assert(is_fpa());
1186 Z3_ast r = Z3_mk_fpa_to_ieee_bv(ctx(), m_ast);
1187 check_error();
1188 return expr(ctx(), r);
1189 }
1190
1194 expr mk_from_ieee_bv(sort const &s) const {
1195 assert(is_bv());
1196 Z3_ast r = Z3_mk_fpa_to_fp_bv(ctx(), m_ast, s);
1197 check_error();
1198 return expr(ctx(), r);
1199 }
1200
1207 std::string get_decimal_string(int precision) const {
1208 assert(is_numeral() || is_algebraic());
1209 return std::string(Z3_get_numeral_decimal_string(ctx(), m_ast, precision));
1210 }
1211
1215 expr algebraic_lower(unsigned precision) const {
1216 assert(is_algebraic());
1217 Z3_ast r = Z3_get_algebraic_number_lower(ctx(), m_ast, precision);
1218 check_error();
1219 return expr(ctx(), r);
1220 }
1221
1222 expr algebraic_upper(unsigned precision) const {
1223 assert(is_algebraic());
1224 Z3_ast r = Z3_get_algebraic_number_upper(ctx(), m_ast, precision);
1225 check_error();
1226 return expr(ctx(), r);
1227 }
1228
1233 assert(is_algebraic());
1234 Z3_ast_vector r = Z3_algebraic_get_poly(ctx(), m_ast);
1235 check_error();
1236 return expr_vector(ctx(), r);
1237 }
1238
1242 unsigned algebraic_i() const {
1243 assert(is_algebraic());
1244 unsigned i = Z3_algebraic_get_i(ctx(), m_ast);
1245 check_error();
1246 return i;
1247 }
1248
1252 unsigned id() const { unsigned r = Z3_get_ast_id(ctx(), m_ast); check_error(); return r; }
1253
1264 int get_numeral_int() const {
1265 int result = 0;
1266 if (!is_numeral_i(result)) {
1267 assert(ctx().enable_exceptions());
1268 if (!ctx().enable_exceptions()) return 0;
1269 Z3_THROW(exception("numeral does not fit in machine int"));
1270 }
1271 return result;
1272 }
1273
1283 unsigned get_numeral_uint() const {
1284 assert(is_numeral());
1285 unsigned result = 0;
1286 if (!is_numeral_u(result)) {
1287 assert(ctx().enable_exceptions());
1288 if (!ctx().enable_exceptions()) return 0;
1289 Z3_THROW(exception("numeral does not fit in machine uint"));
1290 }
1291 return result;
1292 }
1293
1300 int64_t get_numeral_int64() const {
1301 assert(is_numeral());
1302 int64_t result = 0;
1303 if (!is_numeral_i64(result)) {
1304 assert(ctx().enable_exceptions());
1305 if (!ctx().enable_exceptions()) return 0;
1306 Z3_THROW(exception("numeral does not fit in machine int64_t"));
1307 }
1308 return result;
1309 }
1310
1317 uint64_t get_numeral_uint64() const {
1318 assert(is_numeral());
1319 uint64_t result = 0;
1320 if (!is_numeral_u64(result)) {
1321 assert(ctx().enable_exceptions());
1322 if (!ctx().enable_exceptions()) return 0;
1323 Z3_THROW(exception("numeral does not fit in machine uint64_t"));
1324 }
1325 return result;
1326 }
1327
1329 return Z3_get_bool_value(ctx(), m_ast);
1330 }
1331
1332 expr numerator() const {
1333 assert(is_numeral());
1334 Z3_ast r = Z3_get_numerator(ctx(), m_ast);
1335 check_error();
1336 return expr(ctx(),r);
1337 }
1338
1339
1341 assert(is_numeral());
1342 Z3_ast r = Z3_get_denominator(ctx(), m_ast);
1343 check_error();
1344 return expr(ctx(),r);
1345 }
1346
1347
1352 bool is_string_value() const { return Z3_is_string(ctx(), m_ast); }
1353
1358
1359 std::string get_string() const {
1360 assert(is_string_value());
1361 char const* s = Z3_get_string(ctx(), m_ast);
1362 check_error();
1363 return std::string(s);
1364 }
1365
1370
1371 std::u32string get_u32string() const {
1372 assert(is_string_value());
1373 unsigned n = Z3_get_string_length(ctx(), m_ast);
1374 std::u32string s;
1375 s.resize(n);
1376 Z3_get_string_contents(ctx(), m_ast, n, (unsigned*)s.data());
1377 return s;
1378 }
1379
1380 operator Z3_app() const { assert(is_app()); return reinterpret_cast<Z3_app>(m_ast); }
1381
1388 func_decl decl() const { Z3_func_decl f = Z3_get_app_decl(ctx(), *this); check_error(); return func_decl(ctx(), f); }
1395 unsigned num_args() const { unsigned r = Z3_get_app_num_args(ctx(), *this); check_error(); return r; }
1403 expr arg(unsigned i) const { Z3_ast r = Z3_get_app_arg(ctx(), *this, i); check_error(); return expr(ctx(), r); }
1411 expr_vector vec(ctx());
1412 unsigned argCnt = num_args();
1413 for (unsigned i = 0; i < argCnt; ++i)
1414 vec.push_back(arg(i));
1415 return vec;
1416 }
1417
1426 expr update(expr_vector const& args) const;
1427
1437 expr update_field(func_decl const& field_access, expr const& new_value) const;
1438
1444 expr body() const { assert(is_quantifier()); Z3_ast r = Z3_get_quantifier_body(ctx(), *this); check_error(); return expr(ctx(), r); }
1445
1451 friend expr operator!(expr const & a);
1452
1459 friend expr operator&&(expr const & a, expr const & b);
1460
1461
1468 friend expr operator&&(expr const & a, bool b);
1475 friend expr operator&&(bool a, expr const & b);
1476
1483 friend expr operator||(expr const & a, expr const & b);
1490 friend expr operator||(expr const & a, bool b);
1491
1498 friend expr operator||(bool a, expr const & b);
1499
1500 friend expr implies(expr const & a, expr const & b);
1501 friend expr implies(expr const & a, bool b);
1502 friend expr implies(bool a, expr const & b);
1503
1504 friend expr mk_or(expr_vector const& args);
1505 friend expr mk_xor(expr_vector const& args);
1506 friend expr mk_and(expr_vector const& args);
1507
1508 friend expr ite(expr const & c, expr const & t, expr const & e);
1509
1510 bool is_true() const { return is_app() && Z3_OP_TRUE == decl().decl_kind(); }
1511 bool is_false() const { return is_app() && Z3_OP_FALSE == decl().decl_kind(); }
1512 bool is_not() const { return is_app() && Z3_OP_NOT == decl().decl_kind(); }
1513 bool is_and() const { return is_app() && Z3_OP_AND == decl().decl_kind(); }
1514 bool is_or() const { return is_app() && Z3_OP_OR == decl().decl_kind(); }
1515 bool is_xor() const { return is_app() && Z3_OP_XOR == decl().decl_kind(); }
1516 bool is_implies() const { return is_app() && Z3_OP_IMPLIES == decl().decl_kind(); }
1517 bool is_eq() const { return is_app() && Z3_OP_EQ == decl().decl_kind(); }
1518 bool is_ite() const { return is_app() && Z3_OP_ITE == decl().decl_kind(); }
1519 bool is_distinct() const { return is_app() && Z3_OP_DISTINCT == decl().decl_kind(); }
1520
1521 friend expr distinct(expr_vector const& args);
1522 friend expr concat(expr const& a, expr const& b);
1523 friend expr concat(expr_vector const& args);
1524
1525 friend expr operator==(expr const & a, expr const & b);
1526 friend expr operator==(expr const & a, int b);
1527 friend expr operator==(int a, expr const & b);
1528
1529 friend expr operator!=(expr const & a, expr const & b);
1530 friend expr operator!=(expr const & a, int b);
1531 friend expr operator!=(int a, expr const & b);
1532
1533 friend expr operator+(expr const & a, expr const & b);
1534 friend expr operator+(expr const & a, int b);
1535 friend expr operator+(int a, expr const & b);
1536 friend expr sum(expr_vector const& args);
1537
1538 friend expr operator*(expr const & a, expr const & b);
1539 friend expr operator*(expr const & a, int b);
1540 friend expr operator*(int a, expr const & b);
1541
1542 /* \brief Power operator */
1543 friend expr pw(expr const & a, expr const & b);
1544 friend expr pw(expr const & a, int b);
1545 friend expr pw(int a, expr const & b);
1546
1547 /* \brief mod operator */
1548 friend expr mod(expr const& a, expr const& b);
1549 friend expr mod(expr const& a, int b);
1550 friend expr mod(int a, expr const& b);
1551
1552 /* \brief rem operator */
1553 friend expr rem(expr const& a, expr const& b);
1554 friend expr rem(expr const& a, int b);
1555 friend expr rem(int a, expr const& b);
1556
1557 friend expr is_int(expr const& e);
1558
1559 friend expr operator/(expr const & a, expr const & b);
1560 friend expr operator/(expr const & a, int b);
1561 friend expr operator/(int a, expr const & b);
1562
1563 friend expr operator-(expr const & a);
1564
1565 friend expr operator-(expr const & a, expr const & b);
1566 friend expr operator-(expr const & a, int b);
1567 friend expr operator-(int a, expr const & b);
1568
1569 friend expr operator<=(expr const & a, expr const & b);
1570 friend expr operator<=(expr const & a, int b);
1571 friend expr operator<=(int a, expr const & b);
1572
1573
1574 friend expr operator>=(expr const & a, expr const & b);
1575 friend expr operator>=(expr const & a, int b);
1576 friend expr operator>=(int a, expr const & b);
1577
1578 friend expr operator<(expr const & a, expr const & b);
1579 friend expr operator<(expr const & a, int b);
1580 friend expr operator<(int a, expr const & b);
1581
1582 friend expr operator>(expr const & a, expr const & b);
1583 friend expr operator>(expr const & a, int b);
1584 friend expr operator>(int a, expr const & b);
1585
1586 friend expr pble(expr_vector const& es, int const * coeffs, int bound);
1587 friend expr pbge(expr_vector const& es, int const * coeffs, int bound);
1588 friend expr pbeq(expr_vector const& es, int const * coeffs, int bound);
1589 friend expr atmost(expr_vector const& es, unsigned bound);
1590 friend expr atleast(expr_vector const& es, unsigned bound);
1591
1592 friend expr operator&(expr const & a, expr const & b);
1593 friend expr operator&(expr const & a, int b);
1594 friend expr operator&(int a, expr const & b);
1595
1596 friend expr operator^(expr const & a, expr const & b);
1597 friend expr operator^(expr const & a, int b);
1598 friend expr operator^(int a, expr const & b);
1599
1600 friend expr operator|(expr const & a, expr const & b);
1601 friend expr operator|(expr const & a, int b);
1602 friend expr operator|(int a, expr const & b);
1603 friend expr nand(expr const& a, expr const& b);
1604 friend expr nor(expr const& a, expr const& b);
1605 friend expr xnor(expr const& a, expr const& b);
1606
1607 friend expr min(expr const& a, expr const& b);
1608 friend expr max(expr const& a, expr const& b);
1609
1610 friend expr bv2int(expr const& a, bool is_signed);
1611 friend expr int2bv(unsigned n, expr const& a);
1612 friend expr bvadd_no_overflow(expr const& a, expr const& b, bool is_signed);
1613 friend expr bvadd_no_underflow(expr const& a, expr const& b);
1614 friend expr bvsub_no_overflow(expr const& a, expr const& b);
1615 friend expr bvsub_no_underflow(expr const& a, expr const& b, bool is_signed);
1616 friend expr bvsdiv_no_overflow(expr const& a, expr const& b);
1617 friend expr bvneg_no_overflow(expr const& a);
1618 friend expr bvmul_no_overflow(expr const& a, expr const& b, bool is_signed);
1619 friend expr bvmul_no_underflow(expr const& a, expr const& b);
1620
1621 expr rotate_left(unsigned i) const { Z3_ast r = Z3_mk_rotate_left(ctx(), i, *this); ctx().check_error(); return expr(ctx(), r); }
1622 expr rotate_right(unsigned i) const { Z3_ast r = Z3_mk_rotate_right(ctx(), i, *this); ctx().check_error(); return expr(ctx(), r); }
1623 expr ext_rotate_left(expr const& n) const { Z3_ast r = Z3_mk_ext_rotate_left(ctx(), *this, n); ctx().check_error(); return expr(ctx(), r); }
1624 expr ext_rotate_right(expr const& n) const { Z3_ast r = Z3_mk_ext_rotate_right(ctx(), *this, n); ctx().check_error(); return expr(ctx(), r); }
1625 expr repeat(unsigned i) const { Z3_ast r = Z3_mk_repeat(ctx(), i, *this); ctx().check_error(); return expr(ctx(), r); }
1626
1627 friend expr bvredor(expr const & a);
1628 friend expr bvredand(expr const & a);
1629
1630 friend expr abs(expr const & a);
1631 friend expr sqrt(expr const & a, expr const & rm);
1632 friend expr fp_eq(expr const & a, expr const & b);
1633
1634 friend expr operator~(expr const & a);
1635 expr extract(unsigned hi, unsigned lo) const { Z3_ast r = Z3_mk_extract(ctx(), hi, lo, *this); ctx().check_error(); return expr(ctx(), r); }
1636 expr bit2bool(unsigned i) const { Z3_ast r = Z3_mk_bit2bool(ctx(), i, *this); ctx().check_error(); return expr(ctx(), r); }
1637 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)); }
1638 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)); }
1639
1643 friend expr fma(expr const& a, expr const& b, expr const& c, expr const& rm);
1644
1648 friend expr fpa_fp(expr const& sgn, expr const& exp, expr const& sig);
1649
1653 friend expr fpa_to_sbv(expr const& t, unsigned sz);
1654
1658 friend expr fpa_to_ubv(expr const& t, unsigned sz);
1659
1663 friend expr sbv_to_fpa(expr const& t, sort s);
1664
1668 friend expr ubv_to_fpa(expr const& t, sort s);
1669
1673 friend expr fpa_to_fpa(expr const& t, sort s);
1674
1678 friend expr round_fpa_to_closest_integer(expr const& t);
1679
1685 expr extract(expr const& offset, expr const& length) const {
1686 check_context(*this, offset); check_context(offset, length);
1687 Z3_ast r = Z3_mk_seq_extract(ctx(), *this, offset, length); check_error(); return expr(ctx(), r);
1688 }
1689 expr replace(expr const& src, expr const& dst) const {
1690 check_context(*this, src); check_context(src, dst);
1691 Z3_ast r = Z3_mk_seq_replace(ctx(), *this, src, dst);
1692 check_error();
1693 return expr(ctx(), r);
1694 }
1695 expr unit() const {
1696 Z3_ast r = Z3_mk_seq_unit(ctx(), *this);
1697 check_error();
1698 return expr(ctx(), r);
1699 }
1700 expr contains(expr const& s) const {
1701 check_context(*this, s);
1702 Z3_ast r = Z3_mk_seq_contains(ctx(), *this, s);
1703 check_error();
1704 return expr(ctx(), r);
1705 }
1706 expr at(expr const& index) const {
1707 check_context(*this, index);
1708 Z3_ast r = Z3_mk_seq_at(ctx(), *this, index);
1709 check_error();
1710 return expr(ctx(), r);
1711 }
1712 expr nth(expr const& index) const {
1713 check_context(*this, index);
1714 Z3_ast r = Z3_mk_seq_nth(ctx(), *this, index);
1715 check_error();
1716 return expr(ctx(), r);
1717 }
1718 expr length() const {
1719 Z3_ast r = Z3_mk_seq_length(ctx(), *this);
1720 check_error();
1721 return expr(ctx(), r);
1722 }
1723 expr power(expr const& n) const {
1724 check_context(*this, n);
1725 Z3_ast r = Z3_mk_seq_power(ctx(), *this, n);
1726 check_error();
1727 return expr(ctx(), r);
1728 }
1729 expr stoi() const {
1730 Z3_ast r = Z3_mk_str_to_int(ctx(), *this);
1731 check_error();
1732 return expr(ctx(), r);
1733 }
1734 expr itos() const {
1735 Z3_ast r = Z3_mk_int_to_str(ctx(), *this);
1736 check_error();
1737 return expr(ctx(), r);
1738 }
1739 expr ubvtos() const {
1740 Z3_ast r = Z3_mk_ubv_to_str(ctx(), *this);
1741 check_error();
1742 return expr(ctx(), r);
1743 }
1744 expr sbvtos() const {
1745 Z3_ast r = Z3_mk_sbv_to_str(ctx(), *this);
1746 check_error();
1747 return expr(ctx(), r);
1748 }
1750 Z3_ast r = Z3_mk_char_to_int(ctx(), *this);
1751 check_error();
1752 return expr(ctx(), r);
1753 }
1755 Z3_ast r = Z3_mk_char_to_bv(ctx(), *this);
1756 check_error();
1757 return expr(ctx(), r);
1758 }
1760 Z3_ast r = Z3_mk_char_from_bv(ctx(), *this);
1761 check_error();
1762 return expr(ctx(), r);
1763 }
1764 expr is_digit() const {
1765 Z3_ast r = Z3_mk_char_is_digit(ctx(), *this);
1766 check_error();
1767 return expr(ctx(), r);
1768 }
1769
1770 friend expr range(expr const& lo, expr const& hi);
1774 expr loop(unsigned lo) {
1775 Z3_ast r = Z3_mk_re_loop(ctx(), m_ast, lo, 0);
1776 check_error();
1777 return expr(ctx(), r);
1778 }
1779 expr loop(unsigned lo, unsigned hi) {
1780 Z3_ast r = Z3_mk_re_loop(ctx(), m_ast, lo, hi);
1781 check_error();
1782 return expr(ctx(), r);
1783 }
1784
1788 expr operator[](expr const& index) const {
1789 assert(is_array() || is_seq());
1790 if (is_array()) {
1791 return select(*this, index);
1792 }
1793 return nth(index);
1794 }
1795
1796 expr operator[](expr_vector const& index) const {
1797 return select(*this, index);
1798 }
1799
1803 expr simplify() const { Z3_ast r = Z3_simplify(ctx(), m_ast); check_error(); return expr(ctx(), r); }
1807 expr simplify(params const & p) const { Z3_ast r = Z3_simplify_ex(ctx(), m_ast, p); check_error(); return expr(ctx(), r); }
1808
1812 expr substitute(expr_vector const& src, expr_vector const& dst);
1813
1817 expr substitute(expr_vector const& dst);
1818
1822 expr substitute(func_decl_vector const& funs, expr_vector const& bodies);
1823
1824
1825 class iterator {
1826 expr& e;
1827 unsigned i;
1828 public:
1829 iterator(expr& e, unsigned i): e(e), i(i) {}
1830 bool operator==(iterator const& other) const noexcept {
1831 return i == other.i;
1832 }
1833 bool operator!=(iterator const& other) const noexcept {
1834 return i != other.i;
1835 }
1836 expr operator*() const { return e.arg(i); }
1837 iterator& operator++() { ++i; return *this; }
1838 iterator operator++(int) { assert(false); return *this; }
1839 };
1840
1841 iterator begin() { return iterator(*this, 0); }
1842 iterator end() { return iterator(*this, is_app() ? num_args() : 0); }
1843
1844 };
1845
1846#define _Z3_MK_BIN_(a, b, binop) \
1847 check_context(a, b); \
1848 Z3_ast r = binop(a.ctx(), a, b); \
1849 a.check_error(); \
1850 return expr(a.ctx(), r); \
1851
1852
1853 inline expr implies(expr const & a, expr const & b) {
1854 assert(a.is_bool() && b.is_bool());
1856 }
1857 inline expr implies(expr const & a, bool b) { return implies(a, a.ctx().bool_val(b)); }
1858 inline expr implies(bool a, expr const & b) { return implies(b.ctx().bool_val(a), b); }
1859
1860
1861 inline expr pw(expr const & a, expr const & b) { _Z3_MK_BIN_(a, b, Z3_mk_power); }
1862 inline expr pw(expr const & a, int b) { return pw(a, a.ctx().num_val(b, a.get_sort())); }
1863 inline expr pw(int a, expr const & b) { return pw(b.ctx().num_val(a, b.get_sort()), b); }
1864
1865 inline expr mod(expr const& a, expr const& b) {
1866 if (a.is_bv()) {
1867 _Z3_MK_BIN_(a, b, Z3_mk_bvsmod);
1868 }
1869 else {
1870 _Z3_MK_BIN_(a, b, Z3_mk_mod);
1871 }
1872 }
1873 inline expr mod(expr const & a, int b) { return mod(a, a.ctx().num_val(b, a.get_sort())); }
1874 inline expr mod(int a, expr const & b) { return mod(b.ctx().num_val(a, b.get_sort()), b); }
1875
1876 inline expr operator%(expr const& a, expr const& b) { return mod(a, b); }
1877 inline expr operator%(expr const& a, int b) { return mod(a, b); }
1878 inline expr operator%(int a, expr const& b) { return mod(a, b); }
1879
1880
1881 inline expr rem(expr const& a, expr const& b) {
1882 if (a.is_fpa() && b.is_fpa()) {
1884 } else {
1885 _Z3_MK_BIN_(a, b, Z3_mk_rem);
1886 }
1887 }
1888 inline expr rem(expr const & a, int b) { return rem(a, a.ctx().num_val(b, a.get_sort())); }
1889 inline expr rem(int a, expr const & b) { return rem(b.ctx().num_val(a, b.get_sort()), b); }
1890
1891#undef _Z3_MK_BIN_
1892
1893#define _Z3_MK_UN_(a, mkun) \
1894 Z3_ast r = mkun(a.ctx(), a); \
1895 a.check_error(); \
1896 return expr(a.ctx(), r); \
1897
1898
1900 inline expr complex(expr const& re, expr const& im) {
1901 check_context(re, im);
1902 Z3_ast r = Z3_mk_complex(re.ctx(), re, im);
1903 re.check_error();
1904 return expr(re.ctx(), r);
1905 }
1906
1907 inline expr real_part(expr const& z) {
1908 Z3_ast r = Z3_mk_real_part(z.ctx(), z);
1909 z.check_error();
1910 return expr(z.ctx(), r);
1911 }
1912
1913 inline expr imag_part(expr const& z) {
1914 Z3_ast r = Z3_mk_imag_part(z.ctx(), z);
1915 z.check_error();
1916 return expr(z.ctx(), r);
1917 }
1918
1919 inline expr operator!(expr const & a) { assert(a.is_bool()); _Z3_MK_UN_(a, Z3_mk_not); }
1920
1921 inline expr is_int(expr const& e) { _Z3_MK_UN_(e, Z3_mk_is_int); }
1922
1923#undef _Z3_MK_UN_
1924
1925 inline expr operator&&(expr const & a, expr const & b) {
1926 check_context(a, b);
1927 assert(a.is_bool() && b.is_bool());
1928 Z3_ast args[2] = { a, b };
1929 Z3_ast r = Z3_mk_and(a.ctx(), 2, args);
1930 a.check_error();
1931 return expr(a.ctx(), r);
1932 }
1933
1934 inline expr operator&&(expr const & a, bool b) { return a && a.ctx().bool_val(b); }
1935 inline expr operator&&(bool a, expr const & b) { return b.ctx().bool_val(a) && b; }
1936
1937 inline expr operator||(expr const & a, expr const & b) {
1938 check_context(a, b);
1939 assert(a.is_bool() && b.is_bool());
1940 Z3_ast args[2] = { a, b };
1941 Z3_ast r = Z3_mk_or(a.ctx(), 2, args);
1942 a.check_error();
1943 return expr(a.ctx(), r);
1944 }
1945
1946 inline expr operator||(expr const & a, bool b) { return a || a.ctx().bool_val(b); }
1947
1948 inline expr operator||(bool a, expr const & b) { return b.ctx().bool_val(a) || b; }
1949
1950 inline expr operator==(expr const & a, expr const & b) {
1951 check_context(a, b);
1952 Z3_ast r = Z3_mk_eq(a.ctx(), a, b);
1953 a.check_error();
1954 return expr(a.ctx(), r);
1955 }
1956 inline expr operator==(expr const & a, int b) { assert(a.is_arith() || a.is_bv() || a.is_fpa() || a.is_finite_field()); return a == a.ctx().num_val(b, a.get_sort()); }
1957 inline expr operator==(int a, expr const & b) { assert(b.is_arith() || b.is_bv() || b.is_fpa() || b.is_finite_field()); return b.ctx().num_val(a, b.get_sort()) == b; }
1958 inline expr operator==(expr const & a, double b) { assert(a.is_fpa()); return a == a.ctx().fpa_val(b); }
1959 inline expr operator==(double a, expr const & b) { assert(b.is_fpa()); return b.ctx().fpa_val(a) == b; }
1960
1961 inline expr operator!=(expr const & a, expr const & b) {
1962 check_context(a, b);
1963 Z3_ast args[2] = { a, b };
1964 Z3_ast r = Z3_mk_distinct(a.ctx(), 2, args);
1965 a.check_error();
1966 return expr(a.ctx(), r);
1967 }
1968 inline expr operator!=(expr const & a, int b) { assert(a.is_arith() || a.is_bv() || a.is_fpa() || a.is_finite_field()); return a != a.ctx().num_val(b, a.get_sort()); }
1969 inline expr operator!=(int a, expr const & b) { assert(b.is_arith() || b.is_bv() || b.is_fpa() || b.is_finite_field()); return b.ctx().num_val(a, b.get_sort()) != b; }
1970 inline expr operator!=(expr const & a, double b) { assert(a.is_fpa()); return a != a.ctx().fpa_val(b); }
1971 inline expr operator!=(double a, expr const & b) { assert(b.is_fpa()); return b.ctx().fpa_val(a) != b; }
1972
1973 inline expr operator+(expr const & a, expr const & b) {
1974 check_context(a, b);
1975 Z3_ast r = 0;
1976 if (a.is_arith() && b.is_arith()) {
1977 Z3_ast args[2] = { a, b };
1978 r = Z3_mk_add(a.ctx(), 2, args);
1979 }
1980 else if (a.is_finite_field() && b.is_finite_field()) {
1981 Z3_ast args[2] = { a, b };
1982 r = Z3_mk_ff_add(a.ctx(), 2, args);
1983 }
1984 else if (a.is_bv() && b.is_bv()) {
1985 r = Z3_mk_bvadd(a.ctx(), a, b);
1986 }
1987 else if (a.is_seq() && b.is_seq()) {
1988 return concat(a, b);
1989 }
1990 else if (a.is_re() && b.is_re()) {
1991 Z3_ast _args[2] = { a, b };
1992 r = Z3_mk_re_union(a.ctx(), 2, _args);
1993 }
1994 else if (a.is_fpa() && b.is_fpa()) {
1995 r = Z3_mk_fpa_add(a.ctx(), a.ctx().fpa_rounding_mode(), a, b);
1996 }
1997 else {
1998 // operator is not supported by given arguments.
1999 assert(false);
2000 }
2001 a.check_error();
2002 return expr(a.ctx(), r);
2003 }
2004 inline expr operator+(expr const & a, int b) { return a + a.ctx().num_val(b, a.get_sort()); }
2005 inline expr operator+(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) + b; }
2006
2007 inline expr operator*(expr const & a, expr const & b) {
2008 check_context(a, b);
2009 Z3_ast r = 0;
2010 if (a.is_arith() && b.is_arith()) {
2011 Z3_ast args[2] = { a, b };
2012 r = Z3_mk_mul(a.ctx(), 2, args);
2013 }
2014 else if (a.is_finite_field() && b.is_finite_field()) {
2015 Z3_ast args[2] = { a, b };
2016 r = Z3_mk_ff_mul(a.ctx(), 2, args);
2017 }
2018 else if (a.is_bv() && b.is_bv()) {
2019 r = Z3_mk_bvmul(a.ctx(), a, b);
2020 }
2021 else if (a.is_fpa() && b.is_fpa()) {
2022 r = Z3_mk_fpa_mul(a.ctx(), a.ctx().fpa_rounding_mode(), a, b);
2023 }
2024 else {
2025 // operator is not supported by given arguments.
2026 assert(false);
2027 }
2028 a.check_error();
2029 return expr(a.ctx(), r);
2030 }
2031 inline expr operator*(expr const & a, int b) { return a * a.ctx().num_val(b, a.get_sort()); }
2032 inline expr operator*(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) * b; }
2033
2034
2035 inline expr operator>=(expr const & a, expr const & b) {
2036 check_context(a, b);
2037 Z3_ast r = 0;
2038 if (a.is_arith() && b.is_arith()) {
2039 r = Z3_mk_ge(a.ctx(), a, b);
2040 }
2041 else if (a.is_bv() && b.is_bv()) {
2042 r = Z3_mk_bvsge(a.ctx(), a, b);
2043 }
2044 else if (a.is_fpa() && b.is_fpa()) {
2045 r = Z3_mk_fpa_geq(a.ctx(), a, b);
2046 }
2047 else {
2048 // operator is not supported by given arguments.
2049 assert(false);
2050 }
2051 a.check_error();
2052 return expr(a.ctx(), r);
2053 }
2054
2055 inline expr operator/(expr const & a, expr const & b) {
2056 check_context(a, b);
2057 Z3_ast r = 0;
2058 if (a.is_arith() && b.is_arith()) {
2059 r = Z3_mk_div(a.ctx(), a, b);
2060 }
2061 else if (a.is_bv() && b.is_bv()) {
2062 r = Z3_mk_bvsdiv(a.ctx(), a, b);
2063 }
2064 else if (a.is_fpa() && b.is_fpa()) {
2065 r = Z3_mk_fpa_div(a.ctx(), a.ctx().fpa_rounding_mode(), a, b);
2066 }
2067 else {
2068 // operator is not supported by given arguments.
2069 assert(false);
2070 }
2071 a.check_error();
2072 return expr(a.ctx(), r);
2073 }
2074 inline expr operator/(expr const & a, int b) { return a / a.ctx().num_val(b, a.get_sort()); }
2075 inline expr operator/(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) / b; }
2076
2077 inline expr operator-(expr const & a) {
2078 Z3_ast r = 0;
2079 if (a.is_arith()) {
2080 r = Z3_mk_unary_minus(a.ctx(), a);
2081 }
2082 else if (a.is_finite_field()) { r = Z3_mk_ff_neg(a.ctx(), a); }
2083 else if (a.is_bv()) {
2084 r = Z3_mk_bvneg(a.ctx(), a);
2085 }
2086 else if (a.is_fpa()) {
2087 r = Z3_mk_fpa_neg(a.ctx(), a);
2088 }
2089 else {
2090 // operator is not supported by given arguments.
2091 assert(false);
2092 }
2093 a.check_error();
2094 return expr(a.ctx(), r);
2095 }
2096
2097 inline expr operator-(expr const & a, expr const & b) {
2098 check_context(a, b);
2099 if (a.is_finite_field() && b.is_finite_field()) return a + -b;
2100 Z3_ast r = 0;
2101 if (a.is_arith() && b.is_arith()) {
2102 Z3_ast args[2] = { a, b };
2103 r = Z3_mk_sub(a.ctx(), 2, args);
2104 }
2105 else if (a.is_bv() && b.is_bv()) {
2106 r = Z3_mk_bvsub(a.ctx(), a, b);
2107 }
2108 else if (a.is_fpa() && b.is_fpa()) {
2109 r = Z3_mk_fpa_sub(a.ctx(), a.ctx().fpa_rounding_mode(), a, b);
2110 }
2111 else {
2112 // operator is not supported by given arguments.
2113 assert(false);
2114 }
2115 a.check_error();
2116 return expr(a.ctx(), r);
2117 }
2118 inline expr operator-(expr const & a, int b) { return a - a.ctx().num_val(b, a.get_sort()); }
2119 inline expr operator-(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) - b; }
2120
2121 inline expr operator<=(expr const & a, expr const & b) {
2122 check_context(a, b);
2123 Z3_ast r = 0;
2124 if (a.is_arith() && b.is_arith()) {
2125 r = Z3_mk_le(a.ctx(), a, b);
2126 }
2127 else if (a.is_bv() && b.is_bv()) {
2128 r = Z3_mk_bvsle(a.ctx(), a, b);
2129 }
2130 else if (a.is_fpa() && b.is_fpa()) {
2131 r = Z3_mk_fpa_leq(a.ctx(), a, b);
2132 }
2133 else {
2134 // operator is not supported by given arguments.
2135 assert(false);
2136 }
2137 a.check_error();
2138 return expr(a.ctx(), r);
2139 }
2140 inline expr operator<=(expr const & a, int b) { return a <= a.ctx().num_val(b, a.get_sort()); }
2141 inline expr operator<=(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) <= b; }
2142
2143 inline expr operator>=(expr const & a, int b) { return a >= a.ctx().num_val(b, a.get_sort()); }
2144 inline expr operator>=(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) >= b; }
2145
2146 inline expr operator<(expr const & a, expr const & b) {
2147 check_context(a, b);
2148 Z3_ast r = 0;
2149 if (a.is_arith() && b.is_arith()) {
2150 r = Z3_mk_lt(a.ctx(), a, b);
2151 }
2152 else if (a.is_bv() && b.is_bv()) {
2153 r = Z3_mk_bvslt(a.ctx(), a, b);
2154 }
2155 else if (a.is_fpa() && b.is_fpa()) {
2156 r = Z3_mk_fpa_lt(a.ctx(), a, b);
2157 }
2158 else {
2159 // operator is not supported by given arguments.
2160 assert(false);
2161 }
2162 a.check_error();
2163 return expr(a.ctx(), r);
2164 }
2165 inline expr operator<(expr const & a, int b) { return a < a.ctx().num_val(b, a.get_sort()); }
2166 inline expr operator<(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) < b; }
2167
2168 inline expr operator>(expr const & a, expr const & b) {
2169 check_context(a, b);
2170 Z3_ast r = 0;
2171 if (a.is_arith() && b.is_arith()) {
2172 r = Z3_mk_gt(a.ctx(), a, b);
2173 }
2174 else if (a.is_bv() && b.is_bv()) {
2175 r = Z3_mk_bvsgt(a.ctx(), a, b);
2176 }
2177 else if (a.is_fpa() && b.is_fpa()) {
2178 r = Z3_mk_fpa_gt(a.ctx(), a, b);
2179 }
2180 else {
2181 // operator is not supported by given arguments.
2182 assert(false);
2183 }
2184 a.check_error();
2185 return expr(a.ctx(), r);
2186 }
2187 inline expr operator>(expr const & a, int b) { return a > a.ctx().num_val(b, a.get_sort()); }
2188 inline expr operator>(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) > b; }
2189
2190 inline expr operator&(expr const & a, expr const & b) { if (a.is_bool()) return a && b; check_context(a, b); Z3_ast r = Z3_mk_bvand(a.ctx(), a, b); a.check_error(); return expr(a.ctx(), r); }
2191 inline expr operator&(expr const & a, int b) { return a & a.ctx().num_val(b, a.get_sort()); }
2192 inline expr operator&(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) & b; }
2193
2194 inline expr operator^(expr const & a, expr const & b) { check_context(a, b); Z3_ast r = a.is_bool() ? Z3_mk_xor(a.ctx(), a, b) : Z3_mk_bvxor(a.ctx(), a, b); a.check_error(); return expr(a.ctx(), r); }
2195 inline expr operator^(expr const & a, int b) { return a ^ a.ctx().num_val(b, a.get_sort()); }
2196 inline expr operator^(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) ^ b; }
2197
2198 inline expr operator|(expr const & a, expr const & b) { if (a.is_bool()) return a || b; check_context(a, b); Z3_ast r = Z3_mk_bvor(a.ctx(), a, b); a.check_error(); return expr(a.ctx(), r); }
2199 inline expr operator|(expr const & a, int b) { return a | a.ctx().num_val(b, a.get_sort()); }
2200 inline expr operator|(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) | b; }
2201
2202 inline expr nand(expr const& a, expr const& b) { if (a.is_bool()) return !(a && b); check_context(a, b); Z3_ast r = Z3_mk_bvnand(a.ctx(), a, b); a.check_error(); return expr(a.ctx(), r); }
2203 inline expr nor(expr const& a, expr const& b) { if (a.is_bool()) return !(a || b); check_context(a, b); Z3_ast r = Z3_mk_bvnor(a.ctx(), a, b); a.check_error(); return expr(a.ctx(), r); }
2204 inline expr xnor(expr const& a, expr const& b) { if (a.is_bool()) return !(a ^ b); check_context(a, b); Z3_ast r = Z3_mk_bvxnor(a.ctx(), a, b); a.check_error(); return expr(a.ctx(), r); }
2205 inline expr min(expr const& a, expr const& b) {
2206 check_context(a, b);
2207 Z3_ast r;
2208 if (a.is_arith()) {
2209 r = Z3_mk_ite(a.ctx(), Z3_mk_ge(a.ctx(), a, b), b, a);
2210 }
2211 else if (a.is_bv()) {
2212 r = Z3_mk_ite(a.ctx(), Z3_mk_bvuge(a.ctx(), a, b), b, a);
2213 }
2214 else {
2215 assert(a.is_fpa());
2216 r = Z3_mk_fpa_min(a.ctx(), a, b);
2217 }
2218 a.check_error();
2219 return expr(a.ctx(), r);
2220 }
2221 inline expr max(expr const& a, expr const& b) {
2222 check_context(a, b);
2223 Z3_ast r;
2224 if (a.is_arith()) {
2225 r = Z3_mk_ite(a.ctx(), Z3_mk_ge(a.ctx(), a, b), a, b);
2226 }
2227 else if (a.is_bv()) {
2228 r = Z3_mk_ite(a.ctx(), Z3_mk_bvuge(a.ctx(), a, b), a, b);
2229 }
2230 else {
2231 assert(a.is_fpa());
2232 r = Z3_mk_fpa_max(a.ctx(), a, b);
2233 }
2234 a.check_error();
2235 return expr(a.ctx(), r);
2236 }
2237 inline expr bvredor(expr const & a) {
2238 assert(a.is_bv());
2239 Z3_ast r = Z3_mk_bvredor(a.ctx(), a);
2240 a.check_error();
2241 return expr(a.ctx(), r);
2242 }
2243 inline expr bvredand(expr const & a) {
2244 assert(a.is_bv());
2245 Z3_ast r = Z3_mk_bvredand(a.ctx(), a);
2246 a.check_error();
2247 return expr(a.ctx(), r);
2248 }
2249 inline expr abs(expr const & a) {
2250 Z3_ast r;
2251 if (a.is_int()) {
2252 expr zero = a.ctx().int_val(0);
2253 expr ge = a >= zero;
2254 expr na = -a;
2255 r = Z3_mk_ite(a.ctx(), ge, a, na);
2256 }
2257 else if (a.is_real()) {
2258 expr zero = a.ctx().real_val(0);
2259 expr ge = a >= zero;
2260 expr na = -a;
2261 r = Z3_mk_ite(a.ctx(), ge, a, na);
2262 }
2263 else {
2264 r = Z3_mk_fpa_abs(a.ctx(), a);
2265 }
2266 a.check_error();
2267 return expr(a.ctx(), r);
2268 }
2269 inline expr sqrt(expr const & a, expr const& rm) {
2270 check_context(a, rm);
2271 assert(a.is_fpa());
2272 Z3_ast r = Z3_mk_fpa_sqrt(a.ctx(), rm, a);
2273 a.check_error();
2274 return expr(a.ctx(), r);
2275 }
2276 inline expr fp_eq(expr const & a, expr const & b) {
2277 check_context(a, b);
2278 assert(a.is_fpa());
2279 Z3_ast r = Z3_mk_fpa_eq(a.ctx(), a, b);
2280 a.check_error();
2281 return expr(a.ctx(), r);
2282 }
2283 inline expr operator~(expr const & a) { Z3_ast r = Z3_mk_bvnot(a.ctx(), a); return expr(a.ctx(), r); }
2284
2285 inline expr fma(expr const& a, expr const& b, expr const& c, expr const& rm) {
2286 check_context(a, b); check_context(a, c); check_context(a, rm);
2287 assert(a.is_fpa() && b.is_fpa() && c.is_fpa());
2288 Z3_ast r = Z3_mk_fpa_fma(a.ctx(), rm, a, b, c);
2289 a.check_error();
2290 return expr(a.ctx(), r);
2291 }
2292
2293 inline expr fpa_fp(expr const& sgn, expr const& exp, expr const& sig) {
2294 check_context(sgn, exp); check_context(exp, sig);
2295 assert(sgn.is_bv() && exp.is_bv() && sig.is_bv());
2296 Z3_ast r = Z3_mk_fpa_fp(sgn.ctx(), sgn, exp, sig);
2297 sgn.check_error();
2298 return expr(sgn.ctx(), r);
2299 }
2300
2301 inline expr fpa_to_sbv(expr const& t, unsigned sz) {
2302 assert(t.is_fpa());
2303 Z3_ast r = Z3_mk_fpa_to_sbv(t.ctx(), t.ctx().fpa_rounding_mode(), t, sz);
2304 t.check_error();
2305 return expr(t.ctx(), r);
2306 }
2307
2308 inline expr fpa_to_ubv(expr const& t, unsigned sz) {
2309 assert(t.is_fpa());
2310 Z3_ast r = Z3_mk_fpa_to_ubv(t.ctx(), t.ctx().fpa_rounding_mode(), t, sz);
2311 t.check_error();
2312 return expr(t.ctx(), r);
2313 }
2314
2315 inline expr sbv_to_fpa(expr const& t, sort s) {
2316 assert(t.is_bv());
2317 Z3_ast r = Z3_mk_fpa_to_fp_signed(t.ctx(), t.ctx().fpa_rounding_mode(), t, s);
2318 t.check_error();
2319 return expr(t.ctx(), r);
2320 }
2321
2322 inline expr ubv_to_fpa(expr const& t, sort s) {
2323 assert(t.is_bv());
2324 Z3_ast r = Z3_mk_fpa_to_fp_unsigned(t.ctx(), t.ctx().fpa_rounding_mode(), t, s);
2325 t.check_error();
2326 return expr(t.ctx(), r);
2327 }
2328
2329 inline expr fpa_to_fpa(expr const& t, sort s) {
2330 assert(t.is_fpa());
2331 Z3_ast r = Z3_mk_fpa_to_fp_float(t.ctx(), t.ctx().fpa_rounding_mode(), t, s);
2332 t.check_error();
2333 return expr(t.ctx(), r);
2334 }
2335
2337 assert(t.is_fpa());
2338 Z3_ast r = Z3_mk_fpa_round_to_integral(t.ctx(), t.ctx().fpa_rounding_mode(), t);
2339 t.check_error();
2340 return expr(t.ctx(), r);
2341 }
2342
2348 inline expr ite(expr const & c, expr const & t, expr const & e) {
2349 check_context(c, t); check_context(c, e);
2350 assert(c.is_bool());
2351 Z3_ast r = Z3_mk_ite(c.ctx(), c, t, e);
2352 c.check_error();
2353 return expr(c.ctx(), r);
2354 }
2355
2356
2361 inline expr to_expr(context & c, Z3_ast a) {
2362 c.check_error();
2363 assert(Z3_get_ast_kind(c, a) == Z3_APP_AST ||
2365 Z3_get_ast_kind(c, a) == Z3_VAR_AST ||
2367 return expr(c, a);
2368 }
2369
2370 inline sort to_sort(context & c, Z3_sort s) {
2371 c.check_error();
2372 return sort(c, s);
2373 }
2374
2375 inline func_decl to_func_decl(context & c, Z3_func_decl f) {
2376 c.check_error();
2377 return func_decl(c, f);
2378 }
2379
2383 inline expr sle(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvsle(a.ctx(), a, b)); }
2384 inline expr sle(expr const & a, int b) { return sle(a, a.ctx().num_val(b, a.get_sort())); }
2385 inline expr sle(int a, expr const & b) { return sle(b.ctx().num_val(a, b.get_sort()), b); }
2389 inline expr slt(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvslt(a.ctx(), a, b)); }
2390 inline expr slt(expr const & a, int b) { return slt(a, a.ctx().num_val(b, a.get_sort())); }
2391 inline expr slt(int a, expr const & b) { return slt(b.ctx().num_val(a, b.get_sort()), b); }
2395 inline expr sge(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvsge(a.ctx(), a, b)); }
2396 inline expr sge(expr const & a, int b) { return sge(a, a.ctx().num_val(b, a.get_sort())); }
2397 inline expr sge(int a, expr const & b) { return sge(b.ctx().num_val(a, b.get_sort()), b); }
2401 inline expr sgt(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvsgt(a.ctx(), a, b)); }
2402 inline expr sgt(expr const & a, int b) { return sgt(a, a.ctx().num_val(b, a.get_sort())); }
2403 inline expr sgt(int a, expr const & b) { return sgt(b.ctx().num_val(a, b.get_sort()), b); }
2404
2405
2409 inline expr ule(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvule(a.ctx(), a, b)); }
2410 inline expr ule(expr const & a, int b) { return ule(a, a.ctx().num_val(b, a.get_sort())); }
2411 inline expr ule(int a, expr const & b) { return ule(b.ctx().num_val(a, b.get_sort()), b); }
2415 inline expr ult(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvult(a.ctx(), a, b)); }
2416 inline expr ult(expr const & a, int b) { return ult(a, a.ctx().num_val(b, a.get_sort())); }
2417 inline expr ult(int a, expr const & b) { return ult(b.ctx().num_val(a, b.get_sort()), b); }
2421 inline expr uge(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvuge(a.ctx(), a, b)); }
2422 inline expr uge(expr const & a, int b) { return uge(a, a.ctx().num_val(b, a.get_sort())); }
2423 inline expr uge(int a, expr const & b) { return uge(b.ctx().num_val(a, b.get_sort()), b); }
2427 inline expr ugt(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvugt(a.ctx(), a, b)); }
2428 inline expr ugt(expr const & a, int b) { return ugt(a, a.ctx().num_val(b, a.get_sort())); }
2429 inline expr ugt(int a, expr const & b) { return ugt(b.ctx().num_val(a, b.get_sort()), b); }
2430
2434 inline expr sdiv(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvsdiv(a.ctx(), a, b)); }
2435 inline expr sdiv(expr const & a, int b) { return sdiv(a, a.ctx().num_val(b, a.get_sort())); }
2436 inline expr sdiv(int a, expr const & b) { return sdiv(b.ctx().num_val(a, b.get_sort()), b); }
2437
2441 inline expr udiv(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvudiv(a.ctx(), a, b)); }
2442 inline expr udiv(expr const & a, int b) { return udiv(a, a.ctx().num_val(b, a.get_sort())); }
2443 inline expr udiv(int a, expr const & b) { return udiv(b.ctx().num_val(a, b.get_sort()), b); }
2444
2448 inline expr srem(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvsrem(a.ctx(), a, b)); }
2449 inline expr srem(expr const & a, int b) { return srem(a, a.ctx().num_val(b, a.get_sort())); }
2450 inline expr srem(int a, expr const & b) { return srem(b.ctx().num_val(a, b.get_sort()), b); }
2451
2455 inline expr smod(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvsmod(a.ctx(), a, b)); }
2456 inline expr smod(expr const & a, int b) { return smod(a, a.ctx().num_val(b, a.get_sort())); }
2457 inline expr smod(int a, expr const & b) { return smod(b.ctx().num_val(a, b.get_sort()), b); }
2458
2462 inline expr urem(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvurem(a.ctx(), a, b)); }
2463 inline expr urem(expr const & a, int b) { return urem(a, a.ctx().num_val(b, a.get_sort())); }
2464 inline expr urem(int a, expr const & b) { return urem(b.ctx().num_val(a, b.get_sort()), b); }
2465
2469 inline expr shl(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvshl(a.ctx(), a, b)); }
2470 inline expr shl(expr const & a, int b) { return shl(a, a.ctx().num_val(b, a.get_sort())); }
2471 inline expr shl(int a, expr const & b) { return shl(b.ctx().num_val(a, b.get_sort()), b); }
2472
2476 inline expr lshr(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvlshr(a.ctx(), a, b)); }
2477 inline expr lshr(expr const & a, int b) { return lshr(a, a.ctx().num_val(b, a.get_sort())); }
2478 inline expr lshr(int a, expr const & b) { return lshr(b.ctx().num_val(a, b.get_sort()), b); }
2479
2483 inline expr ashr(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvashr(a.ctx(), a, b)); }
2484 inline expr ashr(expr const & a, int b) { return ashr(a, a.ctx().num_val(b, a.get_sort())); }
2485 inline expr ashr(int a, expr const & b) { return ashr(b.ctx().num_val(a, b.get_sort()), b); }
2486
2490 inline expr zext(expr const & a, unsigned i) { return to_expr(a.ctx(), Z3_mk_zero_ext(a.ctx(), i, a)); }
2491
2495 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); }
2496 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); }
2497
2501 inline expr bvadd_no_overflow(expr const& a, expr const& b, bool is_signed) {
2502 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);
2503 }
2504 inline expr bvadd_no_underflow(expr const& a, expr const& b) {
2505 check_context(a, b); Z3_ast r = Z3_mk_bvadd_no_underflow(a.ctx(), a, b); a.check_error(); return expr(a.ctx(), r);
2506 }
2507 inline expr bvsub_no_overflow(expr const& a, expr const& b) {
2508 check_context(a, b); Z3_ast r = Z3_mk_bvsub_no_overflow(a.ctx(), a, b); a.check_error(); return expr(a.ctx(), r);
2509 }
2510 inline expr bvsub_no_underflow(expr const& a, expr const& b, bool is_signed) {
2511 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);
2512 }
2513 inline expr bvsdiv_no_overflow(expr const& a, expr const& b) {
2514 check_context(a, b); Z3_ast r = Z3_mk_bvsdiv_no_overflow(a.ctx(), a, b); a.check_error(); return expr(a.ctx(), r);
2515 }
2516 inline expr bvneg_no_overflow(expr const& a) {
2517 Z3_ast r = Z3_mk_bvneg_no_overflow(a.ctx(), a); a.check_error(); return expr(a.ctx(), r);
2518 }
2519 inline expr bvmul_no_overflow(expr const& a, expr const& b, bool is_signed) {
2520 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);
2521 }
2522 inline expr bvmul_no_underflow(expr const& a, expr const& b) {
2523 check_context(a, b); Z3_ast r = Z3_mk_bvmul_no_underflow(a.ctx(), a, b); a.check_error(); return expr(a.ctx(), r);
2524 }
2525
2526
2530 inline expr sext(expr const & a, unsigned i) { return to_expr(a.ctx(), Z3_mk_sign_ext(a.ctx(), i, a)); }
2531
2532 inline func_decl linear_order(sort const& a, unsigned index) {
2533 return to_func_decl(a.ctx(), Z3_mk_linear_order(a.ctx(), a, index));
2534 }
2535 inline func_decl partial_order(sort const& a, unsigned index) {
2536 return to_func_decl(a.ctx(), Z3_mk_partial_order(a.ctx(), a, index));
2537 }
2538 inline func_decl piecewise_linear_order(sort const& a, unsigned index) {
2539 return to_func_decl(a.ctx(), Z3_mk_piecewise_linear_order(a.ctx(), a, index));
2540 }
2541 inline func_decl tree_order(sort const& a, unsigned index) {
2542 return to_func_decl(a.ctx(), Z3_mk_tree_order(a.ctx(), a, index));
2543 }
2544
2551 inline expr_vector polynomial_subresultants(expr const& p, expr const& q, expr const& x) {
2552 check_context(p, q); check_context(p, x);
2553 Z3_ast_vector r = Z3_polynomial_subresultants(p.ctx(), p, q, x);
2554 p.check_error();
2555 return expr_vector(p.ctx(), r);
2556 }
2557
2558 template<> class cast_ast<ast> {
2559 public:
2560 ast operator()(context & c, Z3_ast a) { return ast(c, a); }
2561 };
2562
2563 template<> class cast_ast<expr> {
2564 public:
2565 expr operator()(context & c, Z3_ast a) {
2566 assert(Z3_get_ast_kind(c, a) == Z3_NUMERAL_AST ||
2567 Z3_get_ast_kind(c, a) == Z3_APP_AST ||
2569 Z3_get_ast_kind(c, a) == Z3_VAR_AST);
2570 return expr(c, a);
2571 }
2572 };
2573
2574 template<> class cast_ast<sort> {
2575 public:
2576 sort operator()(context & c, Z3_ast a) {
2577 assert(Z3_get_ast_kind(c, a) == Z3_SORT_AST);
2578 return sort(c, reinterpret_cast<Z3_sort>(a));
2579 }
2580 };
2581
2582 template<> class cast_ast<func_decl> {
2583 public:
2585 assert(Z3_get_ast_kind(c, a) == Z3_FUNC_DECL_AST);
2586 return func_decl(c, reinterpret_cast<Z3_func_decl>(a));
2587 }
2588 };
2589
2590 template<typename T>
2591 template<typename T2>
2592 array<T>::array(ast_vector_tpl<T2> const & v):m_array(new T[v.size()]), m_size(v.size()) {
2593 for (unsigned i = 0; i < m_size; ++i) {
2594 m_array[i] = v[i];
2595 }
2596 }
2597
2598 // Basic functions for creating quantified formulas.
2599 // The C API should be used for creating quantifiers with patterns, weights, many variables, etc.
2600 inline expr forall(expr const & x, expr const & b) {
2601 check_context(x, b);
2602 Z3_app vars[] = {(Z3_app) x};
2603 Z3_ast r = Z3_mk_forall_const(b.ctx(), 0, 1, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
2604 }
2605 inline expr forall(expr const & x1, expr const & x2, expr const & b) {
2606 check_context(x1, b); check_context(x2, b);
2607 Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2};
2608 Z3_ast r = Z3_mk_forall_const(b.ctx(), 0, 2, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
2609 }
2610 inline expr forall(expr const & x1, expr const & x2, expr const & x3, expr const & b) {
2611 check_context(x1, b); check_context(x2, b); check_context(x3, b);
2612 Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3 };
2613 Z3_ast r = Z3_mk_forall_const(b.ctx(), 0, 3, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
2614 }
2615 inline expr forall(expr const & x1, expr const & x2, expr const & x3, expr const & x4, expr const & b) {
2616 check_context(x1, b); check_context(x2, b); check_context(x3, b); check_context(x4, b);
2617 Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3, (Z3_app) x4 };
2618 Z3_ast r = Z3_mk_forall_const(b.ctx(), 0, 4, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
2619 }
2620 inline expr forall(expr_vector const & xs, expr const & b) {
2621 array<Z3_app> vars(xs);
2622 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);
2623 }
2624 inline expr exists(expr const & x, expr const & b) {
2625 check_context(x, b);
2626 Z3_app vars[] = {(Z3_app) x};
2627 Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, 1, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
2628 }
2629 inline expr exists(expr const & x1, expr const & x2, expr const & b) {
2630 check_context(x1, b); check_context(x2, b);
2631 Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2};
2632 Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, 2, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
2633 }
2634 inline expr exists(expr const & x1, expr const & x2, expr const & x3, expr const & b) {
2635 check_context(x1, b); check_context(x2, b); check_context(x3, b);
2636 Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3 };
2637 Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, 3, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
2638 }
2639 inline expr exists(expr const & x1, expr const & x2, expr const & x3, expr const & x4, expr const & b) {
2640 check_context(x1, b); check_context(x2, b); check_context(x3, b); check_context(x4, b);
2641 Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3, (Z3_app) x4 };
2642 Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, 4, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);
2643 }
2644 inline expr exists(expr_vector const & xs, expr const & b) {
2645 array<Z3_app> vars(xs);
2646 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);
2647 }
2648 inline expr lambda(expr const & x, expr const & b) {
2649 check_context(x, b);
2650 Z3_app vars[] = {(Z3_app) x};
2651 Z3_ast r = Z3_mk_lambda_const(b.ctx(), 1, vars, b); b.check_error(); return expr(b.ctx(), r);
2652 }
2653 inline expr lambda(expr const & x1, expr const & x2, expr const & b) {
2654 check_context(x1, b); check_context(x2, b);
2655 Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2};
2656 Z3_ast r = Z3_mk_lambda_const(b.ctx(), 2, vars, b); b.check_error(); return expr(b.ctx(), r);
2657 }
2658 inline expr lambda(expr const & x1, expr const & x2, expr const & x3, expr const & b) {
2659 check_context(x1, b); check_context(x2, b); check_context(x3, b);
2660 Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3 };
2661 Z3_ast r = Z3_mk_lambda_const(b.ctx(), 3, vars, b); b.check_error(); return expr(b.ctx(), r);
2662 }
2663 inline expr lambda(expr const & x1, expr const & x2, expr const & x3, expr const & x4, expr const & b) {
2664 check_context(x1, b); check_context(x2, b); check_context(x3, b); check_context(x4, b);
2665 Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3, (Z3_app) x4 };
2666 Z3_ast r = Z3_mk_lambda_const(b.ctx(), 4, vars, b); b.check_error(); return expr(b.ctx(), r);
2667 }
2668 inline expr lambda(expr_vector const & xs, expr const & b) {
2669 array<Z3_app> vars(xs);
2670 Z3_ast r = Z3_mk_lambda_const(b.ctx(), vars.size(), vars.ptr(), b); b.check_error(); return expr(b.ctx(), r);
2671 }
2672
2673 inline expr pble(expr_vector const& es, int const* coeffs, int bound) {
2674 assert(es.size() > 0);
2675 context& ctx = es[0u].ctx();
2676 array<Z3_ast> _es(es);
2677 Z3_ast r = Z3_mk_pble(ctx, _es.size(), _es.ptr(), coeffs, bound);
2678 ctx.check_error();
2679 return expr(ctx, r);
2680 }
2681 inline expr pbge(expr_vector const& es, int const* coeffs, int bound) {
2682 assert(es.size() > 0);
2683 context& ctx = es[0u].ctx();
2684 array<Z3_ast> _es(es);
2685 Z3_ast r = Z3_mk_pbge(ctx, _es.size(), _es.ptr(), coeffs, bound);
2686 ctx.check_error();
2687 return expr(ctx, r);
2688 }
2689 inline expr pbeq(expr_vector const& es, int const* coeffs, int bound) {
2690 assert(es.size() > 0);
2691 context& ctx = es[0u].ctx();
2692 array<Z3_ast> _es(es);
2693 Z3_ast r = Z3_mk_pbeq(ctx, _es.size(), _es.ptr(), coeffs, bound);
2694 ctx.check_error();
2695 return expr(ctx, r);
2696 }
2697 inline expr atmost(expr_vector const& es, unsigned bound) {
2698 assert(es.size() > 0);
2699 context& ctx = es[0u].ctx();
2700 array<Z3_ast> _es(es);
2701 Z3_ast r = Z3_mk_atmost(ctx, _es.size(), _es.ptr(), bound);
2702 ctx.check_error();
2703 return expr(ctx, r);
2704 }
2705 inline expr atleast(expr_vector const& es, unsigned bound) {
2706 assert(es.size() > 0);
2707 context& ctx = es[0u].ctx();
2708 array<Z3_ast> _es(es);
2709 Z3_ast r = Z3_mk_atleast(ctx, _es.size(), _es.ptr(), bound);
2710 ctx.check_error();
2711 return expr(ctx, r);
2712 }
2713 inline expr sum(expr_vector const& args) {
2714 assert(args.size() > 0);
2715 context& ctx = args[0u].ctx();
2716 array<Z3_ast> _args(args);
2717 Z3_ast r = Z3_mk_add(ctx, _args.size(), _args.ptr());
2718 ctx.check_error();
2719 return expr(ctx, r);
2720 }
2721
2723 assert(args.size() > 0);
2724 context& ctx = args[0u].ctx();
2725 array<Z3_ast> _args(args);
2726 Z3_ast r = Z3_mk_distinct(ctx, _args.size(), _args.ptr());
2727 ctx.check_error();
2728 return expr(ctx, r);
2729 }
2730
2731 inline expr concat(expr const& a, expr const& b) {
2732 check_context(a, b);
2733 Z3_ast r;
2734 if (Z3_is_seq_sort(a.ctx(), a.get_sort())) {
2735 Z3_ast _args[2] = { a, b };
2736 r = Z3_mk_seq_concat(a.ctx(), 2, _args);
2737 }
2738 else if (Z3_is_re_sort(a.ctx(), a.get_sort())) {
2739 Z3_ast _args[2] = { a, b };
2740 r = Z3_mk_re_concat(a.ctx(), 2, _args);
2741 }
2742 else {
2743 r = Z3_mk_concat(a.ctx(), a, b);
2744 }
2745 a.ctx().check_error();
2746 return expr(a.ctx(), r);
2747 }
2748
2749 inline expr concat(expr_vector const& args) {
2750 Z3_ast r;
2751 assert(args.size() > 0);
2752 if (args.size() == 1) {
2753 return args[0u];
2754 }
2755 context& ctx = args[0u].ctx();
2756 array<Z3_ast> _args(args);
2757 if (Z3_is_seq_sort(ctx, args[0u].get_sort())) {
2758 r = Z3_mk_seq_concat(ctx, _args.size(), _args.ptr());
2759 }
2760 else if (Z3_is_re_sort(ctx, args[0u].get_sort())) {
2761 r = Z3_mk_re_concat(ctx, _args.size(), _args.ptr());
2762 }
2763 else {
2764 r = _args[args.size()-1];
2765 for (unsigned i = args.size()-1; i > 0; ) {
2766 --i;
2767 r = Z3_mk_concat(ctx, _args[i], r);
2768 ctx.check_error();
2769 }
2770 }
2771 ctx.check_error();
2772 return expr(ctx, r);
2773 }
2774
2775 inline expr map(expr const& f, expr const& list) {
2776 context& ctx = f.ctx();
2777 Z3_ast r = Z3_mk_seq_map(ctx, f, list);
2778 ctx.check_error();
2779 return expr(ctx, r);
2780 }
2781
2782 inline expr mapi(expr const& f, expr const& i, expr const& list) {
2783 context& ctx = f.ctx();
2784 Z3_ast r = Z3_mk_seq_mapi(ctx, f, i, list);
2785 ctx.check_error();
2786 return expr(ctx, r);
2787 }
2788
2789 inline expr foldl(expr const& f, expr const& a, expr const& list) {
2790 context& ctx = f.ctx();
2791 Z3_ast r = Z3_mk_seq_foldl(ctx, f, a, list);
2792 ctx.check_error();
2793 return expr(ctx, r);
2794 }
2795
2796 inline expr foldli(expr const& f, expr const& i, expr const& a, expr const& list) {
2797 context& ctx = f.ctx();
2798 Z3_ast r = Z3_mk_seq_foldli(ctx, f, i, a, list);
2799 ctx.check_error();
2800 return expr(ctx, r);
2801 }
2802
2803 inline expr mk_or(expr_vector const& args) {
2804 array<Z3_ast> _args(args);
2805 Z3_ast r = Z3_mk_or(args.ctx(), _args.size(), _args.ptr());
2806 args.check_error();
2807 return expr(args.ctx(), r);
2808 }
2809 inline expr mk_and(expr_vector const& args) {
2810 array<Z3_ast> _args(args);
2811 Z3_ast r = Z3_mk_and(args.ctx(), _args.size(), _args.ptr());
2812 args.check_error();
2813 return expr(args.ctx(), r);
2814 }
2815 inline expr mk_xor(expr_vector const& args) {
2816 if (args.empty())
2817 return args.ctx().bool_val(false);
2818 expr r = args[0u];
2819 for (unsigned i = 1; i < args.size(); ++i)
2820 r = r ^ args[i];
2821 return r;
2822 }
2823
2824
2825 class func_entry : public object {
2826 Z3_func_entry m_entry;
2827 void init(Z3_func_entry e) {
2828 m_entry = e;
2829 Z3_func_entry_inc_ref(ctx(), m_entry);
2830 }
2831 public:
2832 func_entry(context & c, Z3_func_entry e):object(c) { init(e); }
2833 func_entry(func_entry const & s):object(s) { init(s.m_entry); }
2834 ~func_entry() override { Z3_func_entry_dec_ref(ctx(), m_entry); }
2835 operator Z3_func_entry() const { return m_entry; }
2837 Z3_func_entry_inc_ref(s.ctx(), s.m_entry);
2838 Z3_func_entry_dec_ref(ctx(), m_entry);
2839 object::operator=(s);
2840 m_entry = s.m_entry;
2841 return *this;
2842 }
2843 expr value() const { Z3_ast r = Z3_func_entry_get_value(ctx(), m_entry); check_error(); return expr(ctx(), r); }
2844 unsigned num_args() const { unsigned r = Z3_func_entry_get_num_args(ctx(), m_entry); check_error(); return r; }
2845 expr arg(unsigned i) const { Z3_ast r = Z3_func_entry_get_arg(ctx(), m_entry, i); check_error(); return expr(ctx(), r); }
2846 };
2847
2848 class func_interp : public object {
2849 Z3_func_interp m_interp;
2850 void init(Z3_func_interp e) {
2851 m_interp = e;
2852 Z3_func_interp_inc_ref(ctx(), m_interp);
2853 }
2854 public:
2855 func_interp(context & c, Z3_func_interp e):object(c) { init(e); }
2856 func_interp(func_interp const & s):object(s) { init(s.m_interp); }
2857 ~func_interp() override { Z3_func_interp_dec_ref(ctx(), m_interp); }
2858 operator Z3_func_interp() const { return m_interp; }
2860 Z3_func_interp_inc_ref(s.ctx(), s.m_interp);
2861 Z3_func_interp_dec_ref(ctx(), m_interp);
2862 object::operator=(s);
2863 m_interp = s.m_interp;
2864 return *this;
2865 }
2866 expr else_value() const { Z3_ast r = Z3_func_interp_get_else(ctx(), m_interp); check_error(); return expr(ctx(), r); }
2867 unsigned num_entries() const { unsigned r = Z3_func_interp_get_num_entries(ctx(), m_interp); check_error(); return r; }
2868 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); }
2869 void add_entry(expr_vector const& args, expr& value) {
2870 Z3_func_interp_add_entry(ctx(), m_interp, args, value);
2871 check_error();
2872 }
2873 void set_else(expr& value) {
2874 Z3_func_interp_set_else(ctx(), m_interp, value);
2875 check_error();
2876 }
2877 };
2878
2879 class model : public object {
2880 Z3_model m_model;
2881 void init(Z3_model m) {
2882 m_model = m;
2883 Z3_model_inc_ref(ctx(), m);
2884 }
2885 public:
2886 struct translate {};
2887 model(context & c):object(c) { init(Z3_mk_model(c)); }
2888 model(context & c, Z3_model m):object(c) { init(m); }
2889 model(model const & s):object(s) { init(s.m_model); }
2890 model(model& src, context& dst, translate) : object(dst) { init(Z3_model_translate(src.ctx(), src, dst)); }
2891 ~model() override { Z3_model_dec_ref(ctx(), m_model); }
2892 operator Z3_model() const { return m_model; }
2893 model & operator=(model const & s) {
2894 Z3_model_inc_ref(s.ctx(), s.m_model);
2895 Z3_model_dec_ref(ctx(), m_model);
2896 object::operator=(s);
2897 m_model = s.m_model;
2898 return *this;
2899 }
2900
2901 expr eval(expr const & n, bool model_completion=false) const {
2902 check_context(*this, n);
2903 Z3_ast r = 0;
2904 bool status = Z3_model_eval(ctx(), m_model, n, model_completion, &r);
2905 check_error();
2906 if (status == false && ctx().enable_exceptions())
2907 Z3_THROW(exception("failed to evaluate expression"));
2908 return expr(ctx(), r);
2909 }
2910
2911 unsigned num_consts() const { return Z3_model_get_num_consts(ctx(), m_model); }
2912 unsigned num_funcs() const { return Z3_model_get_num_funcs(ctx(), m_model); }
2913 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); }
2914 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); }
2915 unsigned size() const { return num_consts() + num_funcs(); }
2916 func_decl operator[](int i) const {
2917 assert(0 <= i);
2918 return static_cast<unsigned>(i) < num_consts() ? get_const_decl(i) : get_func_decl(i - num_consts());
2919 }
2920
2921 // returns interpretation of constant declaration c.
2922 // If c is not assigned any value in the model it returns
2923 // an expression with a null ast reference.
2925 check_context(*this, c);
2926 Z3_ast r = Z3_model_get_const_interp(ctx(), m_model, c);
2927 check_error();
2928 return expr(ctx(), r);
2929 }
2931 check_context(*this, f);
2932 Z3_func_interp r = Z3_model_get_func_interp(ctx(), m_model, f);
2933 check_error();
2934 return func_interp(ctx(), r);
2935 }
2936
2937 // returns true iff the model contains an interpretation
2938 // for function f.
2939 bool has_interp(func_decl f) const {
2940 check_context(*this, f);
2941 return Z3_model_has_interp(ctx(), m_model, f);
2942 }
2943
2945 Z3_func_interp r = Z3_add_func_interp(ctx(), m_model, f, else_val);
2946 check_error();
2947 return func_interp(ctx(), r);
2948 }
2949
2951 Z3_add_const_interp(ctx(), m_model, f, value);
2952 check_error();
2953 }
2954
2955 unsigned num_sorts() const {
2956 unsigned r = Z3_model_get_num_sorts(ctx(), m_model);
2957 check_error();
2958 return r;
2959 }
2960
2965 sort get_sort(unsigned i) const {
2966 Z3_sort s = Z3_model_get_sort(ctx(), m_model, i);
2967 check_error();
2968 return sort(ctx(), s);
2969 }
2970
2972 check_context(*this, s);
2973 Z3_ast_vector r = Z3_model_get_sort_universe(ctx(), m_model, s);
2974 check_error();
2975 return expr_vector(ctx(), r);
2976 }
2977
2978 friend std::ostream & operator<<(std::ostream & out, model const & m);
2979
2980 std::string to_string() const { return m_model ? std::string(Z3_model_to_string(ctx(), m_model)) : "null"; }
2981 };
2982
2983 inline expr qe_lite(expr_vector const& vars, expr const& body) {
2984 check_context(vars, body);
2985 Z3_ast r = Z3_qe_lite(body.ctx(), vars, body);
2986 body.check_error();
2987 return expr(body.ctx(), r);
2988 }
2989
2990 inline std::vector<Z3_app> to_apps(expr_vector const& bounds) {
2991 std::vector<Z3_app> apps;
2992 for (unsigned i = 0; i < bounds.size(); ++i) {
2993 if (!Z3_is_app(bounds.ctx(), bounds[i]))
2994 Z3_THROW(exception("model projection bounds must be applications"));
2995 apps.push_back(Z3_to_app(bounds.ctx(), bounds[i]));
2996 }
2997 return apps;
2998 }
2999
3000 inline expr qe_model_project(model const& m, expr_vector const& bounds, expr const& body) {
3001 check_context(m, bounds); check_context(m, body);
3002 std::vector<Z3_app> apps = to_apps(bounds);
3003 Z3_ast r = Z3_qe_model_project(m.ctx(), m, bounds.size(), apps.data(), body);
3004 m.check_error();
3005 return expr(m.ctx(), r);
3006 }
3007
3011 inline expr qe_model_project_skolem(model const& m, expr_vector const& bounds, expr const& body, ast_map& map) {
3012 check_context(m, bounds); check_context(m, body); check_context(m, map);
3013 std::vector<Z3_app> apps = to_apps(bounds);
3014 Z3_ast r = Z3_qe_model_project_skolem(m.ctx(), m, bounds.size(), apps.data(), body, map);
3015 m.check_error();
3016 return expr(m.ctx(), r);
3017 }
3018
3022 inline expr qe_model_project_with_witness(model const& m, expr_vector const& bounds, expr const& body, ast_map& map) {
3023 check_context(m, bounds); check_context(m, body); check_context(m, map);
3024 std::vector<Z3_app> apps = to_apps(bounds);
3025 Z3_ast r = Z3_qe_model_project_with_witness(m.ctx(), m, bounds.size(), apps.data(), body, map);
3026 m.check_error();
3027 return expr(m.ctx(), r);
3028 }
3029
3030 inline std::ostream & operator<<(std::ostream & out, model const & m) { return out << m.to_string(); }
3031
3032 class stats : public object {
3033 Z3_stats m_stats;
3034 void init(Z3_stats e) {
3035 m_stats = e;
3036 Z3_stats_inc_ref(ctx(), m_stats);
3037 }
3038 public:
3039 stats(context & c):object(c), m_stats(0) {}
3040 stats(context & c, Z3_stats e):object(c) { init(e); }
3041 stats(stats const & s):object(s) { init(s.m_stats); }
3042 ~stats() override { if (m_stats) Z3_stats_dec_ref(ctx(), m_stats); }
3043 operator Z3_stats() const { return m_stats; }
3044 stats & operator=(stats const & s) {
3045 Z3_stats_inc_ref(s.ctx(), s.m_stats);
3046 if (m_stats) Z3_stats_dec_ref(ctx(), m_stats);
3047 object::operator=(s);
3048 m_stats = s.m_stats;
3049 return *this;
3050 }
3051 unsigned size() const { return Z3_stats_size(ctx(), m_stats); }
3052 std::string key(unsigned i) const { Z3_string s = Z3_stats_get_key(ctx(), m_stats, i); check_error(); return s; }
3053 bool is_uint(unsigned i) const { bool r = Z3_stats_is_uint(ctx(), m_stats, i); check_error(); return r; }
3054 bool is_double(unsigned i) const { bool r = Z3_stats_is_double(ctx(), m_stats, i); check_error(); return r; }
3055 unsigned uint_value(unsigned i) const { unsigned r = Z3_stats_get_uint_value(ctx(), m_stats, i); check_error(); return r; }
3056 double double_value(unsigned i) const { double r = Z3_stats_get_double_value(ctx(), m_stats, i); check_error(); return r; }
3057 friend std::ostream & operator<<(std::ostream & out, stats const & s);
3058 };
3059 inline std::ostream & operator<<(std::ostream & out, stats const & s) { out << Z3_stats_to_string(s.ctx(), s); return out; }
3060
3061
3062 inline std::ostream & operator<<(std::ostream & out, check_result r) {
3063 if (r == unsat) out << "unsat";
3064 else if (r == sat) out << "sat";
3065 else out << "unknown";
3066 return out;
3067 }
3068
3080 Z3_parameter_kind m_kind;
3081 func_decl m_decl;
3082 unsigned m_index;
3083 context& ctx() const { return m_decl.ctx(); }
3084 void check_error() const { ctx().check_error(); }
3085 public:
3086 parameter(func_decl const& d, unsigned idx) : m_decl(d), m_index(idx) {
3087 if (ctx().enable_exceptions() && idx >= d.num_parameters())
3088 Z3_THROW(exception("parameter index is out of bounds"));
3089 m_kind = Z3_get_decl_parameter_kind(ctx(), d, idx);
3090 }
3091 parameter(expr const& e, unsigned idx) : m_decl(e.decl()), m_index(idx) {
3092 if (ctx().enable_exceptions() && idx >= m_decl.num_parameters())
3093 Z3_THROW(exception("parameter index is out of bounds"));
3094 m_kind = Z3_get_decl_parameter_kind(ctx(), m_decl, idx);
3095 }
3096 Z3_parameter_kind kind() const { return m_kind; }
3097 expr get_expr() const { Z3_ast a = Z3_get_decl_ast_parameter(ctx(), m_decl, m_index); check_error(); return expr(ctx(), a); }
3098 sort get_sort() const { Z3_sort s = Z3_get_decl_sort_parameter(ctx(), m_decl, m_index); check_error(); return sort(ctx(), s); }
3099 func_decl get_decl() const { Z3_func_decl f = Z3_get_decl_func_decl_parameter(ctx(), m_decl, m_index); check_error(); return func_decl(ctx(), f); }
3100 symbol get_symbol() const { Z3_symbol s = Z3_get_decl_symbol_parameter(ctx(), m_decl, m_index); check_error(); return symbol(ctx(), s); }
3101 std::string get_rational() const { Z3_string s = Z3_get_decl_rational_parameter(ctx(), m_decl, m_index); check_error(); return s; }
3102 double get_double() const { double d = Z3_get_decl_double_parameter(ctx(), m_decl, m_index); check_error(); return d; }
3103 int get_int() const { int i = Z3_get_decl_int_parameter(ctx(), m_decl, m_index); check_error(); return i; }
3104 };
3105
3106
3107 class solver : public object {
3108 Z3_solver m_solver;
3109 void init(Z3_solver s) {
3110 m_solver = s;
3111 if (s)
3112 Z3_solver_inc_ref(ctx(), s);
3113 }
3114 public:
3115 struct simple {};
3116 struct translate {};
3119 solver(context & c, Z3_solver s):object(c) { init(s); }
3120 solver(context & c, char const * logic):object(c) { init(Z3_mk_solver_for_logic(c, c.str_symbol(logic))); check_error(); }
3121 solver(context & c, solver const& src, translate): object(c) { Z3_solver s = Z3_solver_translate(src.ctx(), src, c); check_error(); init(s); }
3122 solver(solver const & s):object(s) { init(s.m_solver); }
3123 solver(solver const& s, simplifier const& simp);
3124 ~solver() override { Z3_solver_dec_ref(ctx(), m_solver); }
3125 operator Z3_solver() const { return m_solver; }
3126 solver & operator=(solver const & s) {
3127 Z3_solver_inc_ref(s.ctx(), s.m_solver);
3128 Z3_solver_dec_ref(ctx(), m_solver);
3129 object::operator=(s);
3130 m_solver = s.m_solver;
3131 return *this;
3132 }
3133 void set(params const & p) { Z3_solver_set_params(ctx(), m_solver, p); check_error(); }
3134 void set(char const * k, bool v) { params p(ctx()); p.set(k, v); set(p); }
3135 void set(char const * k, unsigned v) { params p(ctx()); p.set(k, v); set(p); }
3136 void set(char const * k, double v) { params p(ctx()); p.set(k, v); set(p); }
3137 void set(char const * k, symbol const & v) { params p(ctx()); p.set(k, v); set(p); }
3138 void set(char const * k, char const* v) { params p(ctx()); p.set(k, v); set(p); }
3149 void push() { Z3_solver_push(ctx(), m_solver); check_error(); }
3150 void pop(unsigned n = 1) { Z3_solver_pop(ctx(), m_solver, n); check_error(); }
3151 void reset() { Z3_solver_reset(ctx(), m_solver); check_error(); }
3152 void add(expr const & e) { assert(e.is_bool()); Z3_solver_assert(ctx(), m_solver, e); check_error(); }
3153 void add(expr const & e, expr const & p) {
3154 assert(e.is_bool()); assert(p.is_bool()); assert(p.is_const());
3155 Z3_solver_assert_and_track(ctx(), m_solver, e, p);
3156 check_error();
3157 }
3158 void add(expr const & e, char const * p) {
3159 add(e, ctx().bool_const(p));
3160 }
3161 void add(expr_vector const& v) {
3162 check_context(*this, v);
3163 for (unsigned i = 0; i < v.size(); ++i)
3164 add(v[i]);
3165 }
3166 void from_file(char const* file) { Z3_solver_from_file(ctx(), m_solver, file); ctx().check_parser_error(); }
3167 void from_string(char const* s) { Z3_solver_from_string(ctx(), m_solver, s); ctx().check_parser_error(); }
3168
3170 check_result check(unsigned n, expr * const assumptions) {
3171 array<Z3_ast> _assumptions(n);
3172 for (unsigned i = 0; i < n; ++i) {
3173 check_context(*this, assumptions[i]);
3174 _assumptions[i] = assumptions[i];
3175 }
3176 Z3_lbool r = Z3_solver_check_assumptions(ctx(), m_solver, n, _assumptions.ptr());
3177 check_error();
3178 return to_check_result(r);
3179 }
3180 check_result check(expr_vector const& assumptions) {
3181 unsigned n = assumptions.size();
3182 array<Z3_ast> _assumptions(n);
3183 for (unsigned i = 0; i < n; ++i) {
3184 check_context(*this, assumptions[i]);
3185 _assumptions[i] = assumptions[i];
3186 }
3187 Z3_lbool r = Z3_solver_check_assumptions(ctx(), m_solver, n, _assumptions.ptr());
3188 check_error();
3189 return to_check_result(r);
3190 }
3191 model get_model() const { Z3_model m = Z3_solver_get_model(ctx(), m_solver); check_error(); return model(ctx(), m); }
3193 Z3_lbool r = Z3_solver_get_consequences(ctx(), m_solver, assumptions, vars, conseq);
3194 check_error();
3195 return to_check_result(r);
3196 }
3197 std::string reason_unknown() const { Z3_string r = Z3_solver_get_reason_unknown(ctx(), m_solver); check_error(); return r; }
3198 stats statistics() const { Z3_stats r = Z3_solver_get_statistics(ctx(), m_solver); check_error(); return stats(ctx(), r); }
3199 expr_vector unsat_core() const { Z3_ast_vector r = Z3_solver_get_unsat_core(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
3200 expr_vector assertions() const { Z3_ast_vector r = Z3_solver_get_assertions(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
3201 expr_vector non_units() const { Z3_ast_vector r = Z3_solver_get_non_units(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
3202 expr_vector units() const { Z3_ast_vector r = Z3_solver_get_units(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
3203 expr_vector trail() const { Z3_ast_vector r = Z3_solver_get_trail(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
3205 Z3_ast_vector r = Z3_solver_get_trail(ctx(), m_solver);
3206 check_error();
3207 expr_vector result(ctx(), r);
3208 unsigned sz = result.size();
3209 levels.resize(sz);
3210 Z3_solver_get_levels(ctx(), m_solver, r, sz, levels.ptr());
3211 check_error();
3212 return result;
3213 }
3214 expr congruence_root(expr const& t) const {
3215 check_context(*this, t);
3216 Z3_ast r = Z3_solver_congruence_root(ctx(), m_solver, t);
3217 check_error();
3218 return expr(ctx(), r);
3219 }
3220 expr congruence_next(expr const& t) const {
3221 check_context(*this, t);
3222 Z3_ast r = Z3_solver_congruence_next(ctx(), m_solver, t);
3223 check_error();
3224 return expr(ctx(), r);
3225 }
3226 expr congruence_explain(expr const& a, expr const& b) const {
3227 check_context(*this, a);
3228 check_context(*this, b);
3229 Z3_ast r = Z3_solver_congruence_explain(ctx(), m_solver, a, b);
3230 check_error();
3231 return expr(ctx(), r);
3232 }
3233 void set_initial_value(expr const& var, expr const& value) {
3234 Z3_solver_set_initial_value(ctx(), m_solver, var, value);
3235 check_error();
3236 }
3237 void set_initial_value(expr const& var, int i) {
3238 set_initial_value(var, ctx().num_val(i, var.get_sort()));
3239 }
3240 void set_initial_value(expr const& var, bool b) {
3241 set_initial_value(var, ctx().bool_val(b));
3242 }
3243
3244 void solve_for(expr_vector const& vars, expr_vector& terms, expr_vector& guards) {
3245 // Create a copy of vars since the C API modifies the variables vector
3246 expr_vector variables(ctx());
3247 for (unsigned i = 0; i < vars.size(); ++i) {
3248 check_context(*this, vars[i]);
3249 variables.push_back(vars[i]);
3250 }
3251 // Clear output vectors before calling C API
3252 terms = expr_vector(ctx());
3253 guards = expr_vector(ctx());
3254 Z3_solver_solve_for(ctx(), m_solver, variables, terms, guards);
3255 check_error();
3256 }
3257
3259 check_context(*this, src);
3260 Z3_solver_import_model_converter(ctx(), src.m_solver, m_solver);
3261 check_error();
3262 }
3263
3264 expr proof() const { Z3_ast r = Z3_solver_get_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); }
3265 friend std::ostream & operator<<(std::ostream & out, solver const & s);
3266
3267 std::string to_smt2(char const* status = "unknown") {
3269 Z3_ast const* fmls = es.ptr();
3270 Z3_ast fml = 0;
3271 unsigned sz = es.size();
3272 if (sz > 0) {
3273 --sz;
3274 fml = fmls[sz];
3275 }
3276 else {
3277 fml = ctx().bool_val(true);
3278 }
3279 return std::string(Z3_benchmark_to_smtlib_string(
3280 ctx(),
3281 "", "", status, "",
3282 sz,
3283 fmls,
3284 fml));
3285 }
3286
3287 std::string dimacs(bool include_names = true) const { return std::string(Z3_solver_to_dimacs_string(ctx(), m_solver, include_names)); }
3288
3290
3291
3292 expr_vector cube(expr_vector& vars, unsigned cutoff) {
3293 Z3_ast_vector r = Z3_solver_cube(ctx(), m_solver, vars, cutoff);
3294 check_error();
3295 return expr_vector(ctx(), r);
3296 }
3297
3299 solver& m_solver;
3300 unsigned& m_cutoff;
3301 expr_vector& m_vars;
3302 expr_vector m_cube;
3303 bool m_end;
3304 bool m_empty;
3305
3306 void inc() {
3307 assert(!m_end && !m_empty);
3308 m_cube = m_solver.cube(m_vars, m_cutoff);
3309 m_cutoff = 0xFFFFFFFF;
3310 if (m_cube.size() == 1 && m_cube[0u].is_false()) {
3311 m_cube = z3::expr_vector(m_solver.ctx());
3312 m_end = true;
3313 }
3314 else if (m_cube.empty()) {
3315 m_empty = true;
3316 }
3317 }
3318 public:
3319 cube_iterator(solver& s, expr_vector& vars, unsigned& cutoff, bool end):
3320 m_solver(s),
3321 m_cutoff(cutoff),
3322 m_vars(vars),
3323 m_cube(s.ctx()),
3324 m_end(end),
3325 m_empty(false) {
3326 if (!m_end) {
3327 inc();
3328 }
3329 }
3330
3332 assert(!m_end);
3333 if (m_empty) {
3334 m_end = true;
3335 }
3336 else {
3337 inc();
3338 }
3339 return *this;
3340 }
3341 cube_iterator operator++(int) { assert(false); return *this; }
3342 expr_vector const * operator->() const { return &(operator*()); }
3343 expr_vector const& operator*() const noexcept { return m_cube; }
3344
3345 bool operator==(cube_iterator const& other) const noexcept {
3346 return other.m_end == m_end;
3347 };
3348 bool operator!=(cube_iterator const& other) const noexcept {
3349 return other.m_end != m_end;
3350 };
3351
3352 };
3353
3355 solver& m_solver;
3356 unsigned m_cutoff;
3357 expr_vector m_default_vars;
3358 expr_vector& m_vars;
3359 public:
3361 m_solver(s),
3362 m_cutoff(0xFFFFFFFF),
3363 m_default_vars(s.ctx()),
3364 m_vars(m_default_vars)
3365 {}
3366
3368 m_solver(s),
3369 m_cutoff(0xFFFFFFFF),
3370 m_default_vars(s.ctx()),
3371 m_vars(vars)
3372 {}
3373
3374 cube_iterator begin() { return cube_iterator(m_solver, m_vars, m_cutoff, false); }
3375 cube_iterator end() { return cube_iterator(m_solver, m_vars, m_cutoff, true); }
3376 void set_cutoff(unsigned c) noexcept { m_cutoff = c; }
3377 };
3378
3380 cube_generator cubes(expr_vector& vars) { return cube_generator(*this, vars); }
3381
3382 };
3383 inline std::ostream & operator<<(std::ostream & out, solver const & s) { out << Z3_solver_to_string(s.ctx(), s); return out; }
3384
3385 class goal : public object {
3386 Z3_goal m_goal;
3387 void init(Z3_goal s) {
3388 m_goal = s;
3389 Z3_goal_inc_ref(ctx(), s);
3390 }
3391 public:
3392 goal(context & c, bool models=true, bool unsat_cores=false, bool proofs=false):object(c) { init(Z3_mk_goal(c, models, unsat_cores, proofs)); }
3393 goal(context & c, Z3_goal s):object(c) { init(s); }
3394 goal(goal const & s):object(s) { init(s.m_goal); }
3395 ~goal() override { Z3_goal_dec_ref(ctx(), m_goal); }
3396 operator Z3_goal() const { return m_goal; }
3397 goal & operator=(goal const & s) {
3398 Z3_goal_inc_ref(s.ctx(), s.m_goal);
3399 Z3_goal_dec_ref(ctx(), m_goal);
3400 object::operator=(s);
3401 m_goal = s.m_goal;
3402 return *this;
3403 }
3404 void add(expr const & f) { check_context(*this, f); Z3_goal_assert(ctx(), m_goal, f); check_error(); }
3405 void add(expr_vector const& v) { check_context(*this, v); for (unsigned i = 0; i < v.size(); ++i) add(v[i]); }
3406 unsigned size() const { return Z3_goal_size(ctx(), m_goal); }
3407 expr operator[](int i) const { assert(0 <= i); Z3_ast r = Z3_goal_formula(ctx(), m_goal, i); check_error(); return expr(ctx(), r); }
3408 Z3_goal_prec precision() const { return Z3_goal_precision(ctx(), m_goal); }
3409 bool inconsistent() const { return Z3_goal_inconsistent(ctx(), m_goal); }
3410 unsigned depth() const { return Z3_goal_depth(ctx(), m_goal); }
3411 void reset() { Z3_goal_reset(ctx(), m_goal); }
3412 unsigned num_exprs() const { return Z3_goal_num_exprs(ctx(), m_goal); }
3413 bool is_decided_sat() const { return Z3_goal_is_decided_sat(ctx(), m_goal); }
3414 bool is_decided_unsat() const { return Z3_goal_is_decided_unsat(ctx(), m_goal); }
3415 model convert_model(model const & m) const {
3416 check_context(*this, m);
3417 Z3_model new_m = Z3_goal_convert_model(ctx(), m_goal, m);
3418 check_error();
3419 return model(ctx(), new_m);
3420 }
3422 Z3_model new_m = Z3_goal_convert_model(ctx(), m_goal, 0);
3423 check_error();
3424 return model(ctx(), new_m);
3425 }
3426 expr as_expr() const {
3427 unsigned n = size();
3428 if (n == 0)
3429 return ctx().bool_val(true);
3430 else if (n == 1)
3431 return operator[](0u);
3432 else {
3433 array<Z3_ast> args(n);
3434 for (unsigned i = 0; i < n; ++i)
3435 args[i] = operator[](i);
3436 return expr(ctx(), Z3_mk_and(ctx(), n, args.ptr()));
3437 }
3438 }
3439 std::string dimacs(bool include_names = true) const { return std::string(Z3_goal_to_dimacs_string(ctx(), m_goal, include_names)); }
3440 friend std::ostream & operator<<(std::ostream & out, goal const & g);
3441 };
3442 inline std::ostream & operator<<(std::ostream & out, goal const & g) { out << Z3_goal_to_string(g.ctx(), g); return out; }
3443
3444 class apply_result : public object {
3445 Z3_apply_result m_apply_result;
3446 void init(Z3_apply_result s) {
3447 m_apply_result = s;
3449 }
3450 public:
3451 apply_result(context & c, Z3_apply_result s):object(c) { init(s); }
3452 apply_result(apply_result const & s):object(s) { init(s.m_apply_result); }
3453 ~apply_result() override { Z3_apply_result_dec_ref(ctx(), m_apply_result); }
3454 operator Z3_apply_result() const { return m_apply_result; }
3456 Z3_apply_result_inc_ref(s.ctx(), s.m_apply_result);
3457 Z3_apply_result_dec_ref(ctx(), m_apply_result);
3458 object::operator=(s);
3459 m_apply_result = s.m_apply_result;
3460 return *this;
3461 }
3462 unsigned size() const { return Z3_apply_result_get_num_subgoals(ctx(), m_apply_result); }
3463 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); }
3464 friend std::ostream & operator<<(std::ostream & out, apply_result const & r);
3465 };
3466 inline std::ostream & operator<<(std::ostream & out, apply_result const & r) { out << Z3_apply_result_to_string(r.ctx(), r); return out; }
3467
3468 class tactic : public object {
3469 Z3_tactic m_tactic;
3470 void init(Z3_tactic s) {
3471 m_tactic = s;
3472 Z3_tactic_inc_ref(ctx(), s);
3473 }
3474 public:
3475 tactic(context & c, char const * name):object(c) { Z3_tactic r = Z3_mk_tactic(c, name); check_error(); init(r); }
3476 tactic(context & c, Z3_tactic s):object(c) { init(s); }
3477 tactic(tactic const & s):object(s) { init(s.m_tactic); }
3478 ~tactic() override { Z3_tactic_dec_ref(ctx(), m_tactic); }
3479 operator Z3_tactic() const { return m_tactic; }
3480 tactic & operator=(tactic const & s) {
3481 Z3_tactic_inc_ref(s.ctx(), s.m_tactic);
3482 Z3_tactic_dec_ref(ctx(), m_tactic);
3483 object::operator=(s);
3484 m_tactic = s.m_tactic;
3485 return *this;
3486 }
3487 solver mk_solver() const { Z3_solver r = Z3_mk_solver_from_tactic(ctx(), m_tactic); check_error(); return solver(ctx(), r); }
3488 apply_result apply(goal const & g) const {
3489 check_context(*this, g);
3490 Z3_apply_result r = Z3_tactic_apply(ctx(), m_tactic, g);
3491 check_error();
3492 return apply_result(ctx(), r);
3493 }
3494 apply_result operator()(goal const & g) const {
3495 return apply(g);
3496 }
3497 std::string help() const { char const * r = Z3_tactic_get_help(ctx(), m_tactic); check_error(); return r; }
3498 friend tactic operator&(tactic const & t1, tactic const & t2);
3499 friend tactic operator|(tactic const & t1, tactic const & t2);
3500 friend tactic repeat(tactic const & t, unsigned max);
3501 friend tactic with(tactic const & t, params const & p);
3502 friend tactic try_for(tactic const & t, unsigned ms);
3503 friend tactic par_or(unsigned n, tactic const* tactics);
3504 friend tactic par_and_then(tactic const& t1, tactic const& t2);
3506 };
3507
3508 inline tactic operator&(tactic const & t1, tactic const & t2) {
3509 check_context(t1, t2);
3510 Z3_tactic r = Z3_tactic_and_then(t1.ctx(), t1, t2);
3511 t1.check_error();
3512 return tactic(t1.ctx(), r);
3513 }
3514
3515 inline tactic operator|(tactic const & t1, tactic const & t2) {
3516 check_context(t1, t2);
3517 Z3_tactic r = Z3_tactic_or_else(t1.ctx(), t1, t2);
3518 t1.check_error();
3519 return tactic(t1.ctx(), r);
3520 }
3521
3522 inline tactic repeat(tactic const & t, unsigned max=UINT_MAX) {
3523 Z3_tactic r = Z3_tactic_repeat(t.ctx(), t, max);
3524 t.check_error();
3525 return tactic(t.ctx(), r);
3526 }
3527
3528 inline tactic with(tactic const & t, params const & p) {
3529 Z3_tactic r = Z3_tactic_using_params(t.ctx(), t, p);
3530 t.check_error();
3531 return tactic(t.ctx(), r);
3532 }
3533 inline tactic try_for(tactic const & t, unsigned ms) {
3534 Z3_tactic r = Z3_tactic_try_for(t.ctx(), t, ms);
3535 t.check_error();
3536 return tactic(t.ctx(), r);
3537 }
3538 inline tactic par_or(unsigned n, tactic const* tactics) {
3539 if (n == 0) {
3540 Z3_THROW(exception("a non-zero number of tactics need to be passed to par_or"));
3541 }
3542 array<Z3_tactic> buffer(n);
3543 for (unsigned i = 0; i < n; ++i) buffer[i] = tactics[i];
3544 return tactic(tactics[0u].ctx(), Z3_tactic_par_or(tactics[0u].ctx(), n, buffer.ptr()));
3545 }
3546
3547 inline tactic par_and_then(tactic const & t1, tactic const & t2) {
3548 check_context(t1, t2);
3549 Z3_tactic r = Z3_tactic_par_and_then(t1.ctx(), t1, t2);
3550 t1.check_error();
3551 return tactic(t1.ctx(), r);
3552 }
3553
3554 class simplifier : public object {
3555 Z3_simplifier m_simplifier;
3556 void init(Z3_simplifier s) {
3557 m_simplifier = s;
3559 }
3560 public:
3561 simplifier(context & c, char const * name):object(c) { Z3_simplifier r = Z3_mk_simplifier(c, name); check_error(); init(r); }
3562 simplifier(context & c, Z3_simplifier s):object(c) { init(s); }
3563 simplifier(simplifier const & s):object(s) { init(s.m_simplifier); }
3564 ~simplifier() override { Z3_simplifier_dec_ref(ctx(), m_simplifier); }
3565 operator Z3_simplifier() const { return m_simplifier; }
3567 Z3_simplifier_inc_ref(s.ctx(), s.m_simplifier);
3568 Z3_simplifier_dec_ref(ctx(), m_simplifier);
3569 object::operator=(s);
3570 m_simplifier = s.m_simplifier;
3571 return *this;
3572 }
3573 std::string help() const { char const * r = Z3_simplifier_get_help(ctx(), m_simplifier); check_error(); return r; }
3574 friend simplifier operator&(simplifier const & t1, simplifier const & t2);
3575 friend simplifier with(simplifier const & t, params const & p);
3577 };
3578
3579 inline solver::solver(solver const& s, simplifier const& simp):object(s) { init(Z3_solver_add_simplifier(s.ctx(), s, simp)); }
3580
3581
3582 inline simplifier operator&(simplifier const & t1, simplifier const & t2) {
3583 check_context(t1, t2);
3584 Z3_simplifier r = Z3_simplifier_and_then(t1.ctx(), t1, t2);
3585 t1.check_error();
3586 return simplifier(t1.ctx(), r);
3587 }
3588
3589 inline simplifier with(simplifier const & t, params const & p) {
3590 Z3_simplifier r = Z3_simplifier_using_params(t.ctx(), t, p);
3591 t.check_error();
3592 return simplifier(t.ctx(), r);
3593 }
3594
3595 class probe : public object {
3596 Z3_probe m_probe;
3597 void init(Z3_probe s) {
3598 m_probe = s;
3599 Z3_probe_inc_ref(ctx(), s);
3600 }
3601 public:
3602 probe(context & c, char const * name):object(c) { Z3_probe r = Z3_mk_probe(c, name); check_error(); init(r); }
3603 probe(context & c, double val):object(c) { Z3_probe r = Z3_probe_const(c, val); check_error(); init(r); }
3604 probe(context & c, Z3_probe s):object(c) { init(s); }
3605 probe(probe const & s):object(s) { init(s.m_probe); }
3606 ~probe() override { Z3_probe_dec_ref(ctx(), m_probe); }
3607 operator Z3_probe() const { return m_probe; }
3608 probe & operator=(probe const & s) {
3609 Z3_probe_inc_ref(s.ctx(), s.m_probe);
3610 Z3_probe_dec_ref(ctx(), m_probe);
3611 object::operator=(s);
3612 m_probe = s.m_probe;
3613 return *this;
3614 }
3615 double apply(goal const & g) const { double r = Z3_probe_apply(ctx(), m_probe, g); check_error(); return r; }
3616 double operator()(goal const & g) const { return apply(g); }
3617 friend probe operator<=(probe const & p1, probe const & p2);
3618 friend probe operator<=(probe const & p1, double p2);
3619 friend probe operator<=(double p1, probe const & p2);
3620 friend probe operator>=(probe const & p1, probe const & p2);
3621 friend probe operator>=(probe const & p1, double p2);
3622 friend probe operator>=(double p1, probe const & p2);
3623 friend probe operator<(probe const & p1, probe const & p2);
3624 friend probe operator<(probe const & p1, double p2);
3625 friend probe operator<(double p1, probe const & p2);
3626 friend probe operator>(probe const & p1, probe const & p2);
3627 friend probe operator>(probe const & p1, double p2);
3628 friend probe operator>(double p1, probe const & p2);
3629 friend probe operator==(probe const & p1, probe const & p2);
3630 friend probe operator==(probe const & p1, double p2);
3631 friend probe operator==(double p1, probe const & p2);
3632 friend probe operator&&(probe const & p1, probe const & p2);
3633 friend probe operator||(probe const & p1, probe const & p2);
3634 friend probe operator!(probe const & p);
3635 };
3636
3637 inline probe operator<=(probe const & p1, probe const & p2) {
3638 check_context(p1, p2); Z3_probe r = Z3_probe_le(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
3639 }
3640 inline probe operator<=(probe const & p1, double p2) { return p1 <= probe(p1.ctx(), p2); }
3641 inline probe operator<=(double p1, probe const & p2) { return probe(p2.ctx(), p1) <= p2; }
3642 inline probe operator>=(probe const & p1, probe const & p2) {
3643 check_context(p1, p2); Z3_probe r = Z3_probe_ge(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
3644 }
3645 inline probe operator>=(probe const & p1, double p2) { return p1 >= probe(p1.ctx(), p2); }
3646 inline probe operator>=(double p1, probe const & p2) { return probe(p2.ctx(), p1) >= p2; }
3647 inline probe operator<(probe const & p1, probe const & p2) {
3648 check_context(p1, p2); Z3_probe r = Z3_probe_lt(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
3649 }
3650 inline probe operator<(probe const & p1, double p2) { return p1 < probe(p1.ctx(), p2); }
3651 inline probe operator<(double p1, probe const & p2) { return probe(p2.ctx(), p1) < p2; }
3652 inline probe operator>(probe const & p1, probe const & p2) {
3653 check_context(p1, p2); Z3_probe r = Z3_probe_gt(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
3654 }
3655 inline probe operator>(probe const & p1, double p2) { return p1 > probe(p1.ctx(), p2); }
3656 inline probe operator>(double p1, probe const & p2) { return probe(p2.ctx(), p1) > p2; }
3657 inline probe operator==(probe const & p1, probe const & p2) {
3658 check_context(p1, p2); Z3_probe r = Z3_probe_eq(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
3659 }
3660 inline probe operator==(probe const & p1, double p2) { return p1 == probe(p1.ctx(), p2); }
3661 inline probe operator==(double p1, probe const & p2) { return probe(p2.ctx(), p1) == p2; }
3662 inline probe operator&&(probe const & p1, probe const & p2) {
3663 check_context(p1, p2); Z3_probe r = Z3_probe_and(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
3664 }
3665 inline probe operator||(probe const & p1, probe const & p2) {
3666 check_context(p1, p2); Z3_probe r = Z3_probe_or(p1.ctx(), p1, p2); p1.check_error(); return probe(p1.ctx(), r);
3667 }
3668 inline probe operator!(probe const & p) {
3669 Z3_probe r = Z3_probe_not(p.ctx(), p); p.check_error(); return probe(p.ctx(), r);
3670 }
3671
3672 class optimize : public object {
3673 Z3_optimize m_opt;
3674
3675 public:
3676 struct translate {};
3677 class handle final {
3678 unsigned m_h;
3679 public:
3680 handle(unsigned h): m_h(h) {}
3681 unsigned h() const { return m_h; }
3682 };
3684 optimize(context & c, optimize const& src, translate): object(c) {
3685 Z3_optimize o = Z3_optimize_translate(src.ctx(), src, c);
3686 check_error();
3687 m_opt = o;
3688 Z3_optimize_inc_ref(c, m_opt);
3689 }
3690 optimize(optimize const & o):object(o), m_opt(o.m_opt) {
3691 Z3_optimize_inc_ref(o.ctx(), o.m_opt);
3692 }
3694 m_opt = Z3_mk_optimize(c);
3695 Z3_optimize_inc_ref(c, m_opt);
3696 add(expr_vector(c, src.assertions()));
3697 expr_vector v(c, src.objectives());
3698 for (expr_vector::iterator it = v.begin(); it != v.end(); ++it) minimize(*it);
3699 }
3701 Z3_optimize_inc_ref(o.ctx(), o.m_opt);
3702 Z3_optimize_dec_ref(ctx(), m_opt);
3703 m_opt = o.m_opt;
3704 object::operator=(o);
3705 return *this;
3706 }
3707 ~optimize() override { Z3_optimize_dec_ref(ctx(), m_opt); }
3708 operator Z3_optimize() const { return m_opt; }
3709 void add(expr const& e) {
3710 assert(e.is_bool());
3711 Z3_optimize_assert(ctx(), m_opt, e);
3712 }
3713 void add(expr_vector const& es) {
3714 for (expr_vector::iterator it = es.begin(); it != es.end(); ++it) add(*it);
3715 }
3716 void add(expr const& e, expr const& t) {
3717 assert(e.is_bool());
3718 Z3_optimize_assert_and_track(ctx(), m_opt, e, t);
3719 }
3720 void add(expr const& e, char const* p) {
3721 assert(e.is_bool());
3722 add(e, ctx().bool_const(p));
3723 }
3724 handle add_soft(expr const& e, unsigned weight) {
3725 assert(e.is_bool());
3726 auto str = std::to_string(weight);
3727 return handle(Z3_optimize_assert_soft(ctx(), m_opt, e, str.c_str(), 0));
3728 }
3729 handle add_soft(expr const& e, char const* weight) {
3730 assert(e.is_bool());
3731 return handle(Z3_optimize_assert_soft(ctx(), m_opt, e, weight, 0));
3732 }
3733 handle add(expr const& e, unsigned weight) {
3734 return add_soft(e, weight);
3735 }
3736 void set_initial_value(expr const& var, expr const& value) {
3737 Z3_optimize_set_initial_value(ctx(), m_opt, var, value);
3738 check_error();
3739 }
3740 void set_initial_value(expr const& var, int i) {
3741 set_initial_value(var, ctx().num_val(i, var.get_sort()));
3742 }
3743 void set_initial_value(expr const& var, bool b) {
3744 set_initial_value(var, ctx().bool_val(b));
3745 }
3746
3748 return handle(Z3_optimize_maximize(ctx(), m_opt, e));
3749 }
3751 return handle(Z3_optimize_minimize(ctx(), m_opt, e));
3752 }
3753 void push() {
3754 Z3_optimize_push(ctx(), m_opt);
3755 }
3756 void pop() {
3757 Z3_optimize_pop(ctx(), m_opt);
3758 }
3761 unsigned n = asms.size();
3762 array<Z3_ast> _asms(n);
3763 for (unsigned i = 0; i < n; ++i) {
3764 check_context(*this, asms[i]);
3765 _asms[i] = asms[i];
3766 }
3767 Z3_lbool r = Z3_optimize_check(ctx(), m_opt, n, _asms.ptr());
3768 check_error();
3769 return to_check_result(r);
3770 }
3771 model get_model() const { Z3_model m = Z3_optimize_get_model(ctx(), m_opt); check_error(); return model(ctx(), m); }
3772 expr_vector unsat_core() const { Z3_ast_vector r = Z3_optimize_get_unsat_core(ctx(), m_opt); check_error(); return expr_vector(ctx(), r); }
3773 void set(params const & p) { Z3_optimize_set_params(ctx(), m_opt, p); check_error(); }
3774 expr lower(handle const& h) {
3775 Z3_ast r = Z3_optimize_get_lower(ctx(), m_opt, h.h());
3776 check_error();
3777 return expr(ctx(), r);
3778 }
3780 Z3_ast_vector r = Z3_optimize_get_lower_as_vector(ctx(), m_opt, h.h());
3781 check_error();
3782 return expr_vector(ctx(), r);
3783 }
3784 expr upper(handle const& h) {
3785 Z3_ast r = Z3_optimize_get_upper(ctx(), m_opt, h.h());
3786 check_error();
3787 return expr(ctx(), r);
3788 }
3790 Z3_ast_vector r = Z3_optimize_get_upper_as_vector(ctx(), m_opt, h.h());
3791 check_error();
3792 return expr_vector(ctx(), r);
3793 }
3794 expr_vector assertions() const { Z3_ast_vector r = Z3_optimize_get_assertions(ctx(), m_opt); check_error(); return expr_vector(ctx(), r); }
3795 expr_vector objectives() const { Z3_ast_vector r = Z3_optimize_get_objectives(ctx(), m_opt); check_error(); return expr_vector(ctx(), r); }
3796 stats statistics() const { Z3_stats r = Z3_optimize_get_statistics(ctx(), m_opt); check_error(); return stats(ctx(), r); }
3797 friend std::ostream & operator<<(std::ostream & out, optimize const & s);
3798 void from_file(char const* filename) { Z3_optimize_from_file(ctx(), m_opt, filename); check_error(); }
3799 void from_string(char const* constraints) { Z3_optimize_from_string(ctx(), m_opt, constraints); check_error(); }
3800 std::string help() const { char const * r = Z3_optimize_get_help(ctx(), m_opt); check_error(); return r; }
3801 };
3802 inline std::ostream & operator<<(std::ostream & out, optimize const & s) { out << Z3_optimize_to_string(s.ctx(), s.m_opt); return out; }
3803
3804 class fixedpoint : public object {
3805 Z3_fixedpoint m_fp;
3806 public:
3808 fixedpoint(fixedpoint const & o):object(o), m_fp(o.m_fp) { Z3_fixedpoint_inc_ref(ctx(), m_fp); }
3809 ~fixedpoint() override { Z3_fixedpoint_dec_ref(ctx(), m_fp); }
3811 Z3_fixedpoint_inc_ref(o.ctx(), o.m_fp);
3812 Z3_fixedpoint_dec_ref(ctx(), m_fp);
3813 m_fp = o.m_fp;
3814 object::operator=(o);
3815 return *this;
3816 }
3817 operator Z3_fixedpoint() const { return m_fp; }
3818 expr_vector from_string(char const* s) {
3819 Z3_ast_vector r = Z3_fixedpoint_from_string(ctx(), m_fp, s);
3820 check_error();
3821 return expr_vector(ctx(), r);
3822 }
3823 expr_vector from_file(char const* s) {
3824 Z3_ast_vector r = Z3_fixedpoint_from_file(ctx(), m_fp, s);
3825 check_error();
3826 return expr_vector(ctx(), r);
3827 }
3828 void add_rule(expr& rule, symbol const& name) { Z3_fixedpoint_add_rule(ctx(), m_fp, rule, name); check_error(); }
3829 void add_fact(func_decl& f, unsigned * args) { Z3_fixedpoint_add_fact(ctx(), m_fp, f, f.arity(), args); check_error(); }
3832 array<Z3_func_decl> rs(relations);
3833 Z3_lbool r = Z3_fixedpoint_query_relations(ctx(), m_fp, rs.size(), rs.ptr());
3834 check_error();
3835 return to_check_result(r);
3836 }
3837 expr get_answer() { Z3_ast r = Z3_fixedpoint_get_answer(ctx(), m_fp); check_error(); return expr(ctx(), r); }
3838 std::string reason_unknown() { return Z3_fixedpoint_get_reason_unknown(ctx(), m_fp); }
3839 void update_rule(expr& rule, symbol const& name) { Z3_fixedpoint_update_rule(ctx(), m_fp, rule, name); check_error(); }
3840 unsigned get_num_levels(func_decl& p) { unsigned r = Z3_fixedpoint_get_num_levels(ctx(), m_fp, p); check_error(); return r; }
3842 Z3_ast r = Z3_fixedpoint_get_cover_delta(ctx(), m_fp, level, p);
3843 check_error();
3844 return expr(ctx(), r);
3845 }
3846 void add_cover(int level, func_decl& p, expr& property) { Z3_fixedpoint_add_cover(ctx(), m_fp, level, p, property); check_error(); }
3847 stats statistics() const { Z3_stats r = Z3_fixedpoint_get_statistics(ctx(), m_fp); check_error(); return stats(ctx(), r); }
3849 expr_vector assertions() const { Z3_ast_vector r = Z3_fixedpoint_get_assertions(ctx(), m_fp); check_error(); return expr_vector(ctx(), r); }
3850 expr_vector rules() const { Z3_ast_vector r = Z3_fixedpoint_get_rules(ctx(), m_fp); check_error(); return expr_vector(ctx(), r); }
3851 void set(params const & p) { Z3_fixedpoint_set_params(ctx(), m_fp, p); check_error(); }
3852 std::string help() const { return Z3_fixedpoint_get_help(ctx(), m_fp); }
3854 std::string to_string() { return Z3_fixedpoint_to_string(ctx(), m_fp, 0, 0); }
3855 std::string to_string(expr_vector const& queries) {
3856 array<Z3_ast> qs(queries);
3857 return Z3_fixedpoint_to_string(ctx(), m_fp, qs.size(), qs.ptr());
3858 }
3859 };
3860 inline std::ostream & operator<<(std::ostream & out, fixedpoint const & f) { return out << Z3_fixedpoint_to_string(f.ctx(), f, 0, 0); }
3861
3862 inline tactic fail_if(probe const & p) {
3863 Z3_tactic r = Z3_tactic_fail_if(p.ctx(), p);
3864 p.check_error();
3865 return tactic(p.ctx(), r);
3866 }
3867 inline tactic when(probe const & p, tactic const & t) {
3868 check_context(p, t);
3869 Z3_tactic r = Z3_tactic_when(t.ctx(), p, t);
3870 t.check_error();
3871 return tactic(t.ctx(), r);
3872 }
3873 inline tactic cond(probe const & p, tactic const & t1, tactic const & t2) {
3874 check_context(p, t1); check_context(p, t2);
3875 Z3_tactic r = Z3_tactic_cond(t1.ctx(), p, t1, t2);
3876 t1.check_error();
3877 return tactic(t1.ctx(), r);
3878 }
3879
3880 inline symbol context::str_symbol(char const * s) { Z3_symbol r = Z3_mk_string_symbol(m_ctx, s); check_error(); return symbol(*this, r); }
3881 inline symbol context::int_symbol(int n) { Z3_symbol r = Z3_mk_int_symbol(m_ctx, n); check_error(); return symbol(*this, r); }
3882
3883 inline sort context::bool_sort() { Z3_sort s = Z3_mk_bool_sort(m_ctx); check_error(); return sort(*this, s); }
3884 inline sort context::int_sort() { Z3_sort s = Z3_mk_int_sort(m_ctx); check_error(); return sort(*this, s); }
3885 inline sort context::real_sort() { Z3_sort s = Z3_mk_real_sort(m_ctx); check_error(); return sort(*this, s); }
3886 inline sort context::complex_sort() { Z3_sort s = Z3_mk_complex_sort(m_ctx); check_error(); return sort(*this, s); }
3887 inline sort context::finite_field_sort(char const* prime) { Z3_sort s = Z3_mk_finite_field_sort(m_ctx, prime); check_error(); return sort(*this, s); }
3888 inline sort context::bv_sort(unsigned sz) { Z3_sort s = Z3_mk_bv_sort(m_ctx, sz); check_error(); return sort(*this, s); }
3889 inline sort context::string_sort() { Z3_sort s = Z3_mk_string_sort(m_ctx); check_error(); return sort(*this, s); }
3890 inline sort context::char_sort() { Z3_sort s = Z3_mk_char_sort(m_ctx); check_error(); return sort(*this, s); }
3891 inline sort context::seq_sort(sort& s) { Z3_sort r = Z3_mk_seq_sort(m_ctx, s); check_error(); return sort(*this, r); }
3892 inline sort context::re_sort(sort& s) { Z3_sort r = Z3_mk_re_sort(m_ctx, s); check_error(); return sort(*this, r); }
3893 inline sort context::finite_set_sort(sort& s) { Z3_sort r = Z3_mk_finite_set_sort(m_ctx, s); check_error(); return sort(*this, r); }
3894 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); }
3895
3896 template<>
3897 inline sort context::fpa_sort<16>() { return fpa_sort(5, 11); }
3898
3899 template<>
3900 inline sort context::fpa_sort<32>() { return fpa_sort(8, 24); }
3901
3902 template<>
3903 inline sort context::fpa_sort<64>() { return fpa_sort(11, 53); }
3904
3905 template<>
3906 inline sort context::fpa_sort<128>() { return fpa_sort(15, 113); }
3907
3908 inline sort context::fpa_rounding_mode_sort() { Z3_sort r = Z3_mk_fpa_rounding_mode_sort(m_ctx); check_error(); return sort(*this, r); }
3909
3910 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); }
3912 array<Z3_sort> dom(d);
3913 Z3_sort s = Z3_mk_array_sort_n(m_ctx, dom.size(), dom.ptr(), r); check_error(); return sort(*this, s);
3914 }
3915 inline sort context::enumeration_sort(char const * name, unsigned n, char const * const * enum_names, func_decl_vector & cs, func_decl_vector & ts) {
3916 array<Z3_symbol> _enum_names(n);
3917 for (unsigned i = 0; i < n; ++i) { _enum_names[i] = Z3_mk_string_symbol(*this, enum_names[i]); }
3918 array<Z3_func_decl> _cs(n);
3919 array<Z3_func_decl> _ts(n);
3920 Z3_symbol _name = Z3_mk_string_symbol(*this, name);
3921 sort s = to_sort(*this, Z3_mk_enumeration_sort(*this, _name, n, _enum_names.ptr(), _cs.ptr(), _ts.ptr()));
3922 check_error();
3923 for (unsigned i = 0; i < n; ++i) { cs.push_back(func_decl(*this, _cs[i])); ts.push_back(func_decl(*this, _ts[i])); }
3924 return s;
3925 }
3926 inline func_decl context::tuple_sort(char const * name, unsigned n, char const * const * names, sort const* sorts, func_decl_vector & projs) {
3927 array<Z3_symbol> _names(n);
3928 array<Z3_sort> _sorts(n);
3929 for (unsigned i = 0; i < n; ++i) { _names[i] = Z3_mk_string_symbol(*this, names[i]); _sorts[i] = sorts[i]; }
3930 array<Z3_func_decl> _projs(n);
3931 Z3_symbol _name = Z3_mk_string_symbol(*this, name);
3932 Z3_func_decl tuple;
3933 sort _ignore_s = to_sort(*this, Z3_mk_tuple_sort(*this, _name, n, _names.ptr(), _sorts.ptr(), &tuple, _projs.ptr()));
3934 check_error();
3935 for (unsigned i = 0; i < n; ++i) { projs.push_back(func_decl(*this, _projs[i])); }
3936 return func_decl(*this, tuple);
3937 }
3938
3940 context& ctx;
3941 Z3_constructor_list clist;
3942 public:
3943 constructor_list(constructors const& cs);
3945 operator Z3_constructor_list() const { return clist; }
3946 };
3947
3949 friend class constructor_list;
3950 context& ctx;
3951 std::vector<Z3_constructor> cons;
3952 std::vector<unsigned> num_fields;
3953 public:
3954 constructors(context& ctx): ctx(ctx) {}
3955
3957 for (auto con : cons)
3958 Z3_del_constructor(ctx, con);
3959 }
3960
3961 void add(symbol const& name, symbol const& rec, unsigned n, symbol const* names, sort const* fields) {
3962 array<unsigned> sort_refs(n);
3963 array<Z3_sort> sorts(n);
3964 array<Z3_symbol> _names(n);
3965 for (unsigned i = 0; i < n; ++i) sorts[i] = fields[i], _names[i] = names[i];
3966 cons.push_back(Z3_mk_constructor(ctx, name, rec, n, _names.ptr(), sorts.ptr(), sort_refs.ptr()));
3967 num_fields.push_back(n);
3968 }
3969
3970 Z3_constructor operator[](unsigned i) const { return cons[i]; }
3971
3972 unsigned size() const { return (unsigned)cons.size(); }
3973
3974 void query(unsigned i, func_decl& constructor, func_decl& test, func_decl_vector& accs) {
3975 Z3_func_decl _constructor;
3976 Z3_func_decl _test;
3977 array<Z3_func_decl> accessors(num_fields[i]);
3978 accs.resize(0);
3980 cons[i],
3981 num_fields[i],
3982 &_constructor,
3983 &_test,
3984 accessors.ptr());
3985 constructor = func_decl(ctx, _constructor);
3986
3987 test = func_decl(ctx, _test);
3988 for (unsigned j = 0; j < num_fields[i]; ++j)
3989 accs.push_back(func_decl(ctx, accessors[j]));
3990 }
3991 };
3992
3993 inline constructor_list::constructor_list(constructors const& cs): ctx(cs.ctx) {
3994 array<Z3_constructor> cons(cs.size());
3995 for (unsigned i = 0; i < cs.size(); ++i)
3996 cons[i] = cs[i];
3997 clist = Z3_mk_constructor_list(ctx, cs.size(), cons.ptr());
3998 }
3999
4000 inline sort context::datatype(symbol const& name, constructors const& cs) {
4001 array<Z3_constructor> _cs(cs.size());
4002 for (unsigned i = 0; i < cs.size(); ++i) _cs[i] = cs[i];
4003 Z3_sort s = Z3_mk_datatype(*this, name, cs.size(), _cs.ptr());
4004 check_error();
4005 return sort(*this, s);
4006 }
4007
4008 inline sort context::datatype(symbol const &name, sort_vector const& params, constructors const &cs) {
4009 array<Z3_sort> _params(params);
4010 array<Z3_constructor> _cs(cs.size());
4011 for (unsigned i = 0; i < cs.size(); ++i)
4012 _cs[i] = cs[i];
4013 Z3_sort s = Z3_mk_polymorphic_datatype(*this, name, _params.size(), _params.ptr(), cs.size(), _cs.ptr());
4014 check_error();
4015 return sort(*this, s);
4016 }
4017
4019 unsigned n, symbol const* names,
4020 constructor_list *const* cons) {
4021 sort_vector result(*this);
4022 array<Z3_symbol> _names(n);
4023 array<Z3_sort> _sorts(n);
4025 for (unsigned i = 0; i < n; ++i)
4026 _names[i] = names[i], _cons[i] = *cons[i];
4027 Z3_mk_datatypes(*this, n, _names.ptr(), _sorts.ptr(), _cons.ptr());
4028 for (unsigned i = 0; i < n; ++i)
4029 result.push_back(sort(*this, _sorts[i]));
4030 return result;
4031 }
4032
4033
4034 inline sort context::datatype_sort(symbol const& name) {
4035 Z3_sort s = Z3_mk_datatype_sort(*this, name, 0, nullptr);
4036 check_error();
4037 return sort(*this, s);
4038 }
4039
4041 array<Z3_sort> _params(params);
4042 Z3_sort s = Z3_mk_datatype_sort(*this, name, _params.size(), _params.ptr());
4043 check_error();
4044 return sort(*this, s);
4045 }
4046
4047
4048 inline sort context::uninterpreted_sort(char const* name) {
4049 Z3_symbol _name = Z3_mk_string_symbol(*this, name);
4050 return to_sort(*this, Z3_mk_uninterpreted_sort(*this, _name));
4051 }
4053 return to_sort(*this, Z3_mk_uninterpreted_sort(*this, name));
4054 }
4055
4056 inline func_decl context::function(symbol const & name, unsigned arity, sort const * domain, sort const & range) {
4057 array<Z3_sort> args(arity);
4058 for (unsigned i = 0; i < arity; ++i) {
4059 check_context(domain[i], range);
4060 args[i] = domain[i];
4061 }
4062 Z3_func_decl f = Z3_mk_func_decl(m_ctx, name, arity, args.ptr(), range);
4063 check_error();
4064 return func_decl(*this, f);
4065 }
4066
4067 inline func_decl context::function(char const * name, unsigned arity, sort const * domain, sort const & range) {
4068 return function(range.ctx().str_symbol(name), arity, domain, range);
4069 }
4070
4071 inline func_decl context::function(symbol const& name, sort_vector const& domain, sort const& range) {
4072 array<Z3_sort> args(domain.size());
4073 for (unsigned i = 0; i < domain.size(); ++i) {
4074 check_context(domain[i], range);
4075 args[i] = domain[i];
4076 }
4077 Z3_func_decl f = Z3_mk_func_decl(m_ctx, name, domain.size(), args.ptr(), range);
4078 check_error();
4079 return func_decl(*this, f);
4080 }
4081
4082 inline func_decl context::function(char const * name, sort_vector const& domain, sort const& range) {
4083 return function(range.ctx().str_symbol(name), domain, range);
4084 }
4085
4086
4087 inline func_decl context::function(char const * name, sort const & domain, sort const & range) {
4088 check_context(domain, range);
4089 Z3_sort args[1] = { domain };
4090 Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 1, args, range);
4091 check_error();
4092 return func_decl(*this, f);
4093 }
4094
4095 inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & range) {
4097 Z3_sort args[2] = { d1, d2 };
4098 Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 2, args, range);
4099 check_error();
4100 return func_decl(*this, f);
4101 }
4102
4103 inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range) {
4105 Z3_sort args[3] = { d1, d2, d3 };
4106 Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 3, args, range);
4107 check_error();
4108 return func_decl(*this, f);
4109 }
4110
4111 inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & d4, sort const & range) {
4113 Z3_sort args[4] = { d1, d2, d3, d4 };
4114 Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 4, args, range);
4115 check_error();
4116 return func_decl(*this, f);
4117 }
4118
4119 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) {
4121 Z3_sort args[5] = { d1, d2, d3, d4, d5 };
4122 Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 5, args, range);
4123 check_error();
4124 return func_decl(*this, f);
4125 }
4126
4127 inline func_decl context::recfun(symbol const & name, unsigned arity, sort const * domain, sort const & range) {
4128 array<Z3_sort> args(arity);
4129 for (unsigned i = 0; i < arity; ++i) {
4130 check_context(domain[i], range);
4131 args[i] = domain[i];
4132 }
4133 Z3_func_decl f = Z3_mk_rec_func_decl(m_ctx, name, arity, args.ptr(), range);
4134 check_error();
4135 return func_decl(*this, f);
4136
4137 }
4138
4139 inline func_decl context::recfun(symbol const & name, sort_vector const& domain, sort const & range) {
4140 check_context(domain, range);
4141 array<Z3_sort> domain1(domain);
4142 Z3_func_decl f = Z3_mk_rec_func_decl(m_ctx, name, domain1.size(), domain1.ptr(), range);
4143 check_error();
4144 return func_decl(*this, f);
4145 }
4146
4147 inline func_decl context::recfun(char const * name, sort_vector const& domain, sort const & range) {
4148 return recfun(str_symbol(name), domain, range);
4149
4150 }
4151
4152 inline func_decl context::recfun(char const * name, unsigned arity, sort const * domain, sort const & range) {
4153 return recfun(str_symbol(name), arity, domain, range);
4154 }
4155
4156 inline func_decl context::recfun(char const * name, sort const& d1, sort const & range) {
4157 return recfun(str_symbol(name), 1, &d1, range);
4158 }
4159
4160 inline func_decl context::recfun(char const * name, sort const& d1, sort const& d2, sort const & range) {
4161 sort dom[2] = { d1, d2 };
4162 return recfun(str_symbol(name), 2, dom, range);
4163 }
4164
4165 inline void context::recdef(func_decl f, expr_vector const& args, expr const& body) {
4166 check_context(f, args); check_context(f, body);
4167 array<Z3_ast> vars(args);
4168 Z3_add_rec_def(f.ctx(), f, vars.size(), vars.ptr(), body);
4169 }
4170
4171 inline func_decl context::user_propagate_function(symbol const& name, sort_vector const& domain, sort const& range) {
4172 check_context(domain, range);
4173 array<Z3_sort> domain1(domain);
4174 Z3_func_decl f = Z3_solver_propagate_declare(range.ctx(), name, domain1.size(), domain1.ptr(), range);
4175 check_error();
4176 return func_decl(*this, f);
4177 }
4178
4179 inline expr context::constant(symbol const & name, sort const & s) {
4180 Z3_ast r = Z3_mk_const(m_ctx, name, s);
4181 check_error();
4182 return expr(*this, r);
4183 }
4184 inline expr context::constant(char const * name, sort const & s) { return constant(str_symbol(name), s); }
4185 inline expr context::variable(unsigned idx, sort const& s) {
4186 Z3_ast r = Z3_mk_bound(m_ctx, idx, s);
4187 check_error();
4188 return expr(*this, r);
4189 }
4190 inline expr context::bool_const(char const * name) { return constant(name, bool_sort()); }
4191 inline expr context::int_const(char const * name) { return constant(name, int_sort()); }
4192 inline expr context::real_const(char const * name) { return constant(name, real_sort()); }
4193 inline expr context::complex_const(char const * name) { return constant(name, complex_sort()); }
4194 inline expr context::string_const(char const * name) { return constant(name, string_sort()); }
4195 inline expr context::bv_const(char const * name, unsigned sz) { return constant(name, bv_sort(sz)); }
4196 inline expr context::fpa_const(char const * name, unsigned ebits, unsigned sbits) { return constant(name, fpa_sort(ebits, sbits)); }
4197
4198 template<size_t precision>
4199 inline expr context::fpa_const(char const * name) { return constant(name, fpa_sort<precision>()); }
4200
4201 inline void context::set_rounding_mode(rounding_mode rm) { m_rounding_mode = rm; }
4202
4204 switch (m_rounding_mode) {
4205 case RNA: return expr(*this, Z3_mk_fpa_rna(m_ctx));
4206 case RNE: return expr(*this, Z3_mk_fpa_rne(m_ctx));
4207 case RTP: return expr(*this, Z3_mk_fpa_rtp(m_ctx));
4208 case RTN: return expr(*this, Z3_mk_fpa_rtn(m_ctx));
4209 case RTZ: return expr(*this, Z3_mk_fpa_rtz(m_ctx));
4210 }
4211 assert(false);
4212 return expr(*this, Z3_mk_fpa_rne(m_ctx));
4213 }
4214
4215 inline expr context::bool_val(bool b) { return b ? expr(*this, Z3_mk_true(m_ctx)) : expr(*this, Z3_mk_false(m_ctx)); }
4216
4217 inline expr context::int_val(int n) { Z3_ast r = Z3_mk_int(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }
4218 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); }
4219 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); }
4220 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); }
4221 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); }
4222
4223 inline expr context::real_val(int64_t n, int64_t d) { Z3_ast r = Z3_mk_real_int64(m_ctx, n, d); check_error(); return expr(*this, r); }
4224 inline expr context::real_val(int n) { Z3_ast r = Z3_mk_int(m_ctx, n, real_sort()); check_error(); return expr(*this, r); }
4225 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); }
4226 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); }
4227 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); }
4228 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); }
4229 inline expr context::complex_val(int re, int im) {
4230 expr r = real_val(re);
4231 expr i = real_val(im);
4232 return complex(r, i);
4233 }
4234 inline expr context::complex_val(char const* re, char const* im) {
4235 expr r = real_val(re);
4236 expr i = real_val(im);
4237 return complex(r, i);
4238 }
4239
4240 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); }
4241 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); }
4242 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); }
4243 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); }
4244 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); }
4245 inline expr context::bv_val(unsigned n, bool const* bits) {
4246 array<bool> _bits(n);
4247 for (unsigned i = 0; i < n; ++i) _bits[i] = bits[i] ? 1 : 0;
4248 Z3_ast r = Z3_mk_bv_numeral(m_ctx, n, _bits.ptr()); check_error(); return expr(*this, r);
4249 }
4250
4251 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); }
4252 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); }
4253 inline expr context::fpa_nan(sort const & s) { Z3_ast r = Z3_mk_fpa_nan(m_ctx, s); check_error(); return expr(*this, r); }
4254 inline expr context::fpa_inf(sort const & s, bool sgn) { Z3_ast r = Z3_mk_fpa_inf(m_ctx, s, sgn); check_error(); return expr(*this, r); }
4255
4256 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); }
4257 inline expr context::string_val(char const* s) { Z3_ast r = Z3_mk_string(m_ctx, s); check_error(); return expr(*this, r); }
4258 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); }
4259 inline expr context::string_val(std::u32string const& s) { Z3_ast r = Z3_mk_u32string(m_ctx, (unsigned)s.size(), (unsigned const*)s.c_str()); check_error(); return expr(*this, r); }
4260
4261 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); }
4262
4263 inline expr func_decl::operator()(unsigned n, expr const * args) const {
4264 array<Z3_ast> _args(n);
4265 for (unsigned i = 0; i < n; ++i) {
4266 check_context(*this, args[i]);
4267 _args[i] = args[i];
4268 }
4269 Z3_ast r = Z3_mk_app(ctx(), *this, n, _args.ptr());
4270 check_error();
4271 return expr(ctx(), r);
4272
4273 }
4274 inline expr func_decl::operator()(expr_vector const& args) const {
4275 array<Z3_ast> _args(args.size());
4276 for (unsigned i = 0; i < args.size(); ++i) {
4277 check_context(*this, args[i]);
4278 _args[i] = args[i];
4279 }
4280 Z3_ast r = Z3_mk_app(ctx(), *this, args.size(), _args.ptr());
4281 check_error();
4282 return expr(ctx(), r);
4283 }
4285 Z3_ast r = Z3_mk_app(ctx(), *this, 0, 0);
4286 ctx().check_error();
4287 return expr(ctx(), r);
4288 }
4289 inline expr func_decl::operator()(expr const & a) const {
4290 check_context(*this, a);
4291 Z3_ast args[1] = { a };
4292 Z3_ast r = Z3_mk_app(ctx(), *this, 1, args);
4293 ctx().check_error();
4294 return expr(ctx(), r);
4295 }
4296 inline expr func_decl::operator()(int a) const {
4297 Z3_ast args[1] = { ctx().num_val(a, domain(0)) };
4298 Z3_ast r = Z3_mk_app(ctx(), *this, 1, args);
4299 ctx().check_error();
4300 return expr(ctx(), r);
4301 }
4302 inline expr func_decl::operator()(expr const & a1, expr const & a2) const {
4303 check_context(*this, a1); check_context(*this, a2);
4304 Z3_ast args[2] = { a1, a2 };
4305 Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
4306 ctx().check_error();
4307 return expr(ctx(), r);
4308 }
4309 inline expr func_decl::operator()(expr const & a1, int a2) const {
4310 check_context(*this, a1);
4311 Z3_ast args[2] = { a1, ctx().num_val(a2, domain(1)) };
4312 Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
4313 ctx().check_error();
4314 return expr(ctx(), r);
4315 }
4316 inline expr func_decl::operator()(int a1, expr const & a2) const {
4317 check_context(*this, a2);
4318 Z3_ast args[2] = { ctx().num_val(a1, domain(0)), a2 };
4319 Z3_ast r = Z3_mk_app(ctx(), *this, 2, args);
4320 ctx().check_error();
4321 return expr(ctx(), r);
4322 }
4323 inline expr func_decl::operator()(expr const & a1, expr const & a2, expr const & a3) const {
4324 check_context(*this, a1); check_context(*this, a2); check_context(*this, a3);
4325 Z3_ast args[3] = { a1, a2, a3 };
4326 Z3_ast r = Z3_mk_app(ctx(), *this, 3, args);
4327 ctx().check_error();
4328 return expr(ctx(), r);
4329 }
4330 inline expr func_decl::operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4) const {
4331 check_context(*this, a1); check_context(*this, a2); check_context(*this, a3); check_context(*this, a4);
4332 Z3_ast args[4] = { a1, a2, a3, a4 };
4333 Z3_ast r = Z3_mk_app(ctx(), *this, 4, args);
4334 ctx().check_error();
4335 return expr(ctx(), r);
4336 }
4337 inline expr func_decl::operator()(expr const & a1, expr const & a2, expr const & a3, expr const & a4, expr const & a5) const {
4338 check_context(*this, a1); check_context(*this, a2); check_context(*this, a3); check_context(*this, a4); check_context(*this, a5);
4339 Z3_ast args[5] = { a1, a2, a3, a4, a5 };
4340 Z3_ast r = Z3_mk_app(ctx(), *this, 5, args);
4341 ctx().check_error();
4342 return expr(ctx(), r);
4343 }
4344
4345 inline expr to_real(expr const & a) { Z3_ast r = Z3_mk_int2real(a.ctx(), a); a.check_error(); return expr(a.ctx(), r); }
4346
4347 inline func_decl function(symbol const & name, unsigned arity, sort const * domain, sort const & range) {
4348 return range.ctx().function(name, arity, domain, range);
4349 }
4350 inline func_decl function(char const * name, unsigned arity, sort const * domain, sort const & range) {
4351 return range.ctx().function(name, arity, domain, range);
4352 }
4353 inline func_decl function(char const * name, sort const & domain, sort const & range) {
4354 return range.ctx().function(name, domain, range);
4355 }
4356 inline func_decl function(char const * name, sort const & d1, sort const & d2, sort const & range) {
4357 return range.ctx().function(name, d1, d2, range);
4358 }
4359 inline func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range) {
4360 return range.ctx().function(name, d1, d2, d3, range);
4361 }
4362 inline func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & d4, sort const & range) {
4363 return range.ctx().function(name, d1, d2, d3, d4, range);
4364 }
4365 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) {
4366 return range.ctx().function(name, d1, d2, d3, d4, d5, range);
4367 }
4368 inline func_decl function(char const* name, sort_vector const& domain, sort const& range) {
4369 return range.ctx().function(name, domain, range);
4370 }
4371 inline func_decl function(std::string const& name, sort_vector const& domain, sort const& range) {
4372 return range.ctx().function(name.c_str(), domain, range);
4373 }
4374
4375 inline func_decl recfun(symbol const & name, unsigned arity, sort const * domain, sort const & range) {
4376 return range.ctx().recfun(name, arity, domain, range);
4377 }
4378 inline func_decl recfun(char const * name, unsigned arity, sort const * domain, sort const & range) {
4379 return range.ctx().recfun(name, arity, domain, range);
4380 }
4381 inline func_decl recfun(char const * name, sort const& d1, sort const & range) {
4382 return range.ctx().recfun(name, d1, range);
4383 }
4384 inline func_decl recfun(char const * name, sort const& d1, sort const& d2, sort const & range) {
4385 return range.ctx().recfun(name, d1, d2, range);
4386 }
4387
4388 inline expr select(expr const & a, expr const & i) {
4389 check_context(a, i);
4390 Z3_ast r = Z3_mk_select(a.ctx(), a, i);
4391 a.check_error();
4392 return expr(a.ctx(), r);
4393 }
4394 inline expr select(expr const & a, int i) {
4395 return select(a, a.ctx().num_val(i, a.get_sort().array_domain()));
4396 }
4397 inline expr select(expr const & a, expr_vector const & i) {
4398 check_context(a, i);
4399 array<Z3_ast> idxs(i);
4400 Z3_ast r = Z3_mk_select_n(a.ctx(), a, idxs.size(), idxs.ptr());
4401 a.check_error();
4402 return expr(a.ctx(), r);
4403 }
4404
4405 inline expr store(expr const & a, expr const & i, expr const & v) {
4406 check_context(a, i); check_context(a, v);
4407 Z3_ast r = Z3_mk_store(a.ctx(), a, i, v);
4408 a.check_error();
4409 return expr(a.ctx(), r);
4410 }
4411
4412 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); }
4413 inline expr store(expr const & a, expr i, int v) { return store(a, i, a.ctx().num_val(v, a.get_sort().array_range())); }
4414 inline expr store(expr const & a, int i, int v) {
4415 return store(a, a.ctx().num_val(i, a.get_sort().array_domain()), a.ctx().num_val(v, a.get_sort().array_range()));
4416 }
4417 inline expr store(expr const & a, expr_vector const & i, expr const & v) {
4418 check_context(a, i); check_context(a, v);
4419 array<Z3_ast> idxs(i);
4420 Z3_ast r = Z3_mk_store_n(a.ctx(), a, idxs.size(), idxs.ptr(), v);
4421 a.check_error();
4422 return expr(a.ctx(), r);
4423 }
4424
4426 Z3_ast r = Z3_mk_as_array(f.ctx(), f);
4427 f.check_error();
4428 return expr(f.ctx(), r);
4429 }
4430
4431 inline expr array_default(expr const & a) {
4432 Z3_ast r = Z3_mk_array_default(a.ctx(), a);
4433 a.check_error();
4434 return expr(a.ctx(), r);
4435 }
4436
4437 inline expr array_ext(expr const & a, expr const & b) {
4438 check_context(a, b);
4439 Z3_ast r = Z3_mk_array_ext(a.ctx(), a, b);
4440 a.check_error();
4441 return expr(a.ctx(), r);
4442 }
4443
4444#define MK_EXPR1(_fn, _arg) \
4445 Z3_ast r = _fn(_arg.ctx(), _arg); \
4446 _arg.check_error(); \
4447 return expr(_arg.ctx(), r);
4448
4449#define MK_EXPR2(_fn, _arg1, _arg2) \
4450 check_context(_arg1, _arg2); \
4451 Z3_ast r = _fn(_arg1.ctx(), _arg1, _arg2); \
4452 _arg1.check_error(); \
4453 return expr(_arg1.ctx(), r);
4454
4455 inline expr const_array(sort const & d, expr const & v) {
4457 }
4458
4459 inline expr empty_set(sort const& s) {
4461 }
4462
4463 inline expr full_set(sort const& s) {
4465 }
4466
4467 inline expr set_add(expr const& s, expr const& e) {
4468 MK_EXPR2(Z3_mk_set_add, s, e);
4469 }
4470
4471 inline expr set_del(expr const& s, expr const& e) {
4472 MK_EXPR2(Z3_mk_set_del, s, e);
4473 }
4474
4475 inline expr set_union(expr const& a, expr const& b) {
4476 check_context(a, b);
4477 Z3_ast es[2] = { a, b };
4478 Z3_ast r = Z3_mk_set_union(a.ctx(), 2, es);
4479 a.check_error();
4480 return expr(a.ctx(), r);
4481 }
4482
4483 inline expr set_intersect(expr const& a, expr const& b) {
4484 check_context(a, b);
4485 Z3_ast es[2] = { a, b };
4486 Z3_ast r = Z3_mk_set_intersect(a.ctx(), 2, es);
4487 a.check_error();
4488 return expr(a.ctx(), r);
4489 }
4490
4491 inline expr set_difference(expr const& a, expr const& b) {
4493 }
4494
4495 inline expr set_complement(expr const& a) {
4497 }
4498
4499 inline expr set_member(expr const& s, expr const& e) {
4501 }
4502
4503 inline expr set_subset(expr const& a, expr const& b) {
4505 }
4506
4507 // finite set operations
4508
4509 inline expr finite_set_empty(sort const& s) {
4510 Z3_ast r = Z3_mk_finite_set_empty(s.ctx(), s);
4511 s.check_error();
4512 return expr(s.ctx(), r);
4513 }
4514
4518
4519 inline expr finite_set_union(expr const& a, expr const& b) {
4521 }
4522
4523 inline expr finite_set_intersect(expr const& a, expr const& b) {
4525 }
4526
4527 inline expr finite_set_difference(expr const& a, expr const& b) {
4529 }
4530
4531 inline expr finite_set_member(expr const& e, expr const& s) {
4533 }
4534
4535 inline expr finite_set_size(expr const& s) {
4537 }
4538
4539 inline expr finite_set_subset(expr const& a, expr const& b) {
4541 }
4542
4543 inline expr finite_set_map(expr const& f, expr const& s) {
4545 }
4546
4547 inline expr finite_set_filter(expr const& f, expr const& s) {
4549 }
4550
4551 inline expr finite_set_range(expr const& low, expr const& high) {
4552 MK_EXPR2(Z3_mk_finite_set_range, low, high);
4553 }
4554
4555 // sequence and regular expression operations.
4556 // union is +
4557 // concat is overloaded to handle sequences and regular expressions
4558
4559 inline expr empty(sort const& s) {
4560 Z3_ast r = Z3_mk_seq_empty(s.ctx(), s);
4561 s.check_error();
4562 return expr(s.ctx(), r);
4563 }
4564 inline expr suffixof(expr const& a, expr const& b) {
4565 check_context(a, b);
4566 Z3_ast r = Z3_mk_seq_suffix(a.ctx(), a, b);
4567 a.check_error();
4568 return expr(a.ctx(), r);
4569 }
4570 inline expr prefixof(expr const& a, expr const& b) {
4571 check_context(a, b);
4572 Z3_ast r = Z3_mk_seq_prefix(a.ctx(), a, b);
4573 a.check_error();
4574 return expr(a.ctx(), r);
4575 }
4576 inline expr indexof(expr const& s, expr const& substr, expr const& offset) {
4577 check_context(s, substr); check_context(s, offset);
4578 Z3_ast r = Z3_mk_seq_index(s.ctx(), s, substr, offset);
4579 s.check_error();
4580 return expr(s.ctx(), r);
4581 }
4582 inline expr last_indexof(expr const& s, expr const& substr) {
4583 check_context(s, substr);
4584 Z3_ast r = Z3_mk_seq_last_index(s.ctx(), s, substr);
4585 s.check_error();
4586 return expr(s.ctx(), r);
4587 }
4588 inline expr to_re(expr const& s) {
4590 }
4591 inline expr in_re(expr const& s, expr const& re) {
4592 MK_EXPR2(Z3_mk_seq_in_re, s, re);
4593 }
4594 inline expr plus(expr const& re) {
4596 }
4597 inline expr option(expr const& re) {
4599 }
4600 inline expr star(expr const& re) {
4602 }
4603 inline expr re_empty(sort const& s) {
4604 Z3_ast r = Z3_mk_re_empty(s.ctx(), s);
4605 s.check_error();
4606 return expr(s.ctx(), r);
4607 }
4608 inline expr re_full(sort const& s) {
4609 Z3_ast r = Z3_mk_re_full(s.ctx(), s);
4610 s.check_error();
4611 return expr(s.ctx(), r);
4612 }
4613 inline expr re_intersect(expr_vector const& args) {
4614 assert(args.size() > 0);
4615 context& ctx = args[0u].ctx();
4616 array<Z3_ast> _args(args);
4617 Z3_ast r = Z3_mk_re_intersect(ctx, _args.size(), _args.ptr());
4618 ctx.check_error();
4619 return expr(ctx, r);
4620 }
4621 inline expr re_diff(expr const& a, expr const& b) {
4622 check_context(a, b);
4623 context& ctx = a.ctx();
4624 Z3_ast r = Z3_mk_re_diff(ctx, a, b);
4625 ctx.check_error();
4626 return expr(ctx, r);
4627 }
4628 inline expr re_complement(expr const& a) {
4630 }
4631 inline expr range(expr const& lo, expr const& hi) {
4633 Z3_ast r = Z3_mk_re_range(lo.ctx(), lo, hi);
4634 lo.check_error();
4635 return expr(lo.ctx(), r);
4636 }
4637
4638
4639
4640
4641
4642 inline expr_vector context::parse_string(char const* s) {
4643 Z3_ast_vector r = Z3_parse_smtlib2_string(*this, s, 0, 0, 0, 0, 0, 0);
4644 check_error();
4645 return expr_vector(*this, r);
4646
4647 }
4648 inline expr_vector context::parse_file(char const* s) {
4649 Z3_ast_vector r = Z3_parse_smtlib2_file(*this, s, 0, 0, 0, 0, 0, 0);
4650 check_error();
4651 return expr_vector(*this, r);
4652 }
4653
4654 inline expr_vector context::parse_string(char const* s, sort_vector const& sorts, func_decl_vector const& decls) {
4655 array<Z3_symbol> sort_names(sorts.size());
4656 array<Z3_symbol> decl_names(decls.size());
4657 array<Z3_sort> sorts1(sorts);
4658 array<Z3_func_decl> decls1(decls);
4659 for (unsigned i = 0; i < sorts.size(); ++i) {
4660 sort_names[i] = sorts[i].name();
4661 }
4662 for (unsigned i = 0; i < decls.size(); ++i) {
4663 decl_names[i] = decls[i].name();
4664 }
4665
4666 Z3_ast_vector r = Z3_parse_smtlib2_string(*this, s, sorts.size(), sort_names.ptr(), sorts1.ptr(), decls.size(), decl_names.ptr(), decls1.ptr());
4667 check_error();
4668 return expr_vector(*this, r);
4669 }
4670
4671 inline expr_vector context::parse_file(char const* s, sort_vector const& sorts, func_decl_vector const& decls) {
4672 array<Z3_symbol> sort_names(sorts.size());
4673 array<Z3_symbol> decl_names(decls.size());
4674 array<Z3_sort> sorts1(sorts);
4675 array<Z3_func_decl> decls1(decls);
4676 for (unsigned i = 0; i < sorts.size(); ++i) {
4677 sort_names[i] = sorts[i].name();
4678 }
4679 for (unsigned i = 0; i < decls.size(); ++i) {
4680 decl_names[i] = decls[i].name();
4681 }
4682 Z3_ast_vector r = Z3_parse_smtlib2_file(*this, s, sorts.size(), sort_names.ptr(), sorts1.ptr(), decls.size(), decl_names.ptr(), decls1.ptr());
4683 check_error();
4684 return expr_vector(*this, r);
4685 }
4686
4688 assert(is_datatype());
4689 func_decl_vector cs(ctx());
4690 unsigned n = Z3_get_datatype_sort_num_constructors(ctx(), *this);
4691 for (unsigned i = 0; i < n; ++i)
4693 return cs;
4694 }
4695
4697 assert(is_datatype());
4698 func_decl_vector rs(ctx());
4699 unsigned n = Z3_get_datatype_sort_num_constructors(ctx(), *this);
4700 for (unsigned i = 0; i < n; ++i)
4702 return rs;
4703 }
4704
4706 sort s = range();
4707 assert(s.is_datatype());
4708 unsigned n = Z3_get_datatype_sort_num_constructors(ctx(), s);
4709 unsigned idx = 0;
4710 for (; idx < n; ++idx) {
4712 if (id() == f.id())
4713 break;
4714 }
4715 assert(idx < n);
4716 n = arity();
4717 func_decl_vector as(ctx());
4718 for (unsigned i = 0; i < n; ++i)
4720 return as;
4721 }
4722
4723
4724 inline expr expr::substitute(expr_vector const& src, expr_vector const& dst) {
4725 assert(src.size() == dst.size());
4726 array<Z3_ast> _src(src.size());
4727 array<Z3_ast> _dst(dst.size());
4728 for (unsigned i = 0; i < src.size(); ++i) {
4729 _src[i] = src[i];
4730 _dst[i] = dst[i];
4731 }
4732 Z3_ast r = Z3_substitute(ctx(), m_ast, src.size(), _src.ptr(), _dst.ptr());
4733 check_error();
4734 return expr(ctx(), r);
4735 }
4736
4737 inline expr expr::substitute(expr_vector const& dst) {
4738 array<Z3_ast> _dst(dst.size());
4739 for (unsigned i = 0; i < dst.size(); ++i) {
4740 _dst[i] = dst[i];
4741 }
4742 Z3_ast r = Z3_substitute_vars(ctx(), m_ast, dst.size(), _dst.ptr());
4743 check_error();
4744 return expr(ctx(), r);
4745 }
4746
4747 inline expr expr::substitute(func_decl_vector const& funs, expr_vector const& dst) {
4748 array<Z3_ast> _dst(dst.size());
4749 array<Z3_func_decl> _funs(funs.size());
4750 if (dst.size() != funs.size()) {
4751 Z3_THROW(exception("length of argument lists don't align"));
4752 return expr(ctx(), nullptr);
4753 }
4754 for (unsigned i = 0; i < dst.size(); ++i) {
4755 _dst[i] = dst[i];
4756 _funs[i] = funs[i];
4757 }
4758 Z3_ast r = Z3_substitute_funs(ctx(), m_ast, dst.size(), _funs.ptr(), _dst.ptr());
4759 check_error();
4760 return expr(ctx(), r);
4761 }
4762
4763 inline expr expr::update(expr_vector const& args) const {
4764 array<Z3_ast> _args(args.size());
4765 for (unsigned i = 0; i < args.size(); ++i) {
4766 _args[i] = args[i];
4767 }
4768 Z3_ast r = Z3_update_term(ctx(), m_ast, args.size(), _args.ptr());
4769 check_error();
4770 return expr(ctx(), r);
4771 }
4772
4773 inline expr expr::update_field(func_decl const& field_access, expr const& new_value) const {
4774 assert(is_datatype());
4775 Z3_ast r = Z3_datatype_update_field(ctx(), field_access, m_ast, new_value);
4776 check_error();
4777 return expr(ctx(), r);
4778 }
4779
4780 typedef std::function<void(expr const& proof, std::vector<unsigned> const& deps, expr_vector const& clause)> on_clause_eh_t;
4781
4783 context& c;
4784 on_clause_eh_t m_on_clause;
4785
4786 static void _on_clause_eh(void* _ctx, Z3_ast _proof, unsigned n, unsigned const* dep, Z3_ast_vector _literals) {
4787 on_clause* ctx = static_cast<on_clause*>(_ctx);
4788 expr_vector lits(ctx->c, _literals);
4789 expr proof(ctx->c, _proof);
4790 std::vector<unsigned> deps;
4791 for (unsigned i = 0; i < n; ++i)
4792 deps.push_back(dep[i]);
4793 ctx->m_on_clause(proof, deps, lits);
4794 }
4795 public:
4796 on_clause(solver& s, on_clause_eh_t& on_clause_eh): c(s.ctx()) {
4797 m_on_clause = on_clause_eh;
4798 Z3_solver_register_on_clause(c, s, this, _on_clause_eh);
4799 c.check_error();
4800 }
4801 };
4802
4804
4805 typedef std::function<void(expr const&, expr const&)> fixed_eh_t;
4806 typedef std::function<void(void)> final_eh_t;
4807 typedef std::function<void(expr const&, expr const&)> eq_eh_t;
4808 typedef std::function<void(expr const&)> created_eh_t;
4809 typedef std::function<void(expr, unsigned, bool)> decide_eh_t;
4810 typedef std::function<bool(expr const&, expr const&)> on_binding_eh_t;
4811
4812 final_eh_t m_final_eh;
4813 eq_eh_t m_eq_eh;
4814 fixed_eh_t m_fixed_eh;
4815 created_eh_t m_created_eh;
4816 decide_eh_t m_decide_eh;
4817 on_binding_eh_t m_on_binding_eh;
4818 solver* s;
4819 context* c;
4820 std::vector<z3::context*> subcontexts;
4821
4822 unsigned m_callbackNesting = 0;
4823 Z3_solver_callback cb { nullptr };
4824
4825 struct scoped_cb {
4827 scoped_cb(void* _p, Z3_solver_callback cb):p(*static_cast<user_propagator_base*>(_p)) {
4828 p.cb = cb;
4829 p.m_callbackNesting++;
4830 }
4831 ~scoped_cb() {
4832 if (--p.m_callbackNesting == 0)
4833 p.cb = nullptr;
4834 }
4835 };
4836
4837 static void push_eh(void* _p, Z3_solver_callback cb) {
4838 user_propagator_base* p = static_cast<user_propagator_base*>(_p);
4839 scoped_cb _cb(p, cb);
4840 static_cast<user_propagator_base*>(p)->push();
4841 }
4842
4843 static void pop_eh(void* _p, Z3_solver_callback cb, unsigned num_scopes) {
4844 user_propagator_base* p = static_cast<user_propagator_base*>(_p);
4845 scoped_cb _cb(p, cb);
4846 static_cast<user_propagator_base*>(_p)->pop(num_scopes);
4847 }
4848
4849 static void* fresh_eh(void* _p, Z3_context ctx) {
4850 user_propagator_base* p = static_cast<user_propagator_base*>(_p);
4851 context* c = new context(ctx);
4852 p->subcontexts.push_back(c);
4853 return p->fresh(*c);
4854 }
4855
4856 static void fixed_eh(void* _p, Z3_solver_callback cb, Z3_ast _var, Z3_ast _value) {
4857 user_propagator_base* p = static_cast<user_propagator_base*>(_p);
4858 scoped_cb _cb(p, cb);
4859 expr value(p->ctx(), _value);
4860 expr var(p->ctx(), _var);
4861 p->m_fixed_eh(var, value);
4862 }
4863
4864 static void eq_eh(void* _p, Z3_solver_callback cb, Z3_ast _x, Z3_ast _y) {
4865 user_propagator_base* p = static_cast<user_propagator_base*>(_p);
4866 scoped_cb _cb(p, cb);
4867 expr x(p->ctx(), _x), y(p->ctx(), _y);
4868 p->m_eq_eh(x, y);
4869 }
4870
4871 static void final_eh(void* p, Z3_solver_callback cb) {
4872 scoped_cb _cb(p, cb);
4873 static_cast<user_propagator_base*>(p)->m_final_eh();
4874 }
4875
4876 static void created_eh(void* _p, Z3_solver_callback cb, Z3_ast _e) {
4877 user_propagator_base* p = static_cast<user_propagator_base*>(_p);
4878 scoped_cb _cb(p, cb);
4879 expr e(p->ctx(), _e);
4880 p->m_created_eh(e);
4881 }
4882
4883 static void decide_eh(void* _p, Z3_solver_callback cb, Z3_ast _val, unsigned bit, bool is_pos) {
4884 user_propagator_base* p = static_cast<user_propagator_base*>(_p);
4885 scoped_cb _cb(p, cb);
4886 expr val(p->ctx(), _val);
4887 p->m_decide_eh(val, bit, is_pos);
4888 }
4889
4890 static bool on_binding_eh(void* _p, Z3_solver_callback cb, Z3_ast _q, Z3_ast _inst) {
4891 user_propagator_base* p = static_cast<user_propagator_base*>(_p);
4892 scoped_cb _cb(p, cb);
4893 expr q(p->ctx(), _q), inst(p->ctx(), _inst);
4894 return p->m_on_binding_eh(q, inst);
4895 }
4896
4897 public:
4898 user_propagator_base(context& c) : s(nullptr), c(&c) {}
4899
4900 user_propagator_base(solver* s): s(s), c(nullptr) {
4901 Z3_solver_propagate_init(ctx(), *s, this, push_eh, pop_eh, fresh_eh);
4902 }
4903
4904 virtual void push() = 0;
4905 virtual void pop(unsigned num_scopes) = 0;
4906
4908 for (auto& subcontext : subcontexts) {
4909 subcontext->detach(); // detach first; the subcontexts will be freed internally!
4910 delete subcontext;
4911 }
4912 }
4913
4915 return c ? *c : s->ctx();
4916 }
4917
4927
4933
4934 void register_fixed(fixed_eh_t& f) {
4935 m_fixed_eh = f;
4936 if (s) {
4937 Z3_solver_propagate_fixed(ctx(), *s, fixed_eh);
4938 }
4939 }
4940
4942 m_fixed_eh = [this](expr const &id, expr const &e) {
4943 fixed(id, e);
4944 };
4945 if (s) {
4946 Z3_solver_propagate_fixed(ctx(), *s, fixed_eh);
4947 }
4948 }
4949
4950 void register_eq(eq_eh_t& f) {
4951 m_eq_eh = f;
4952 if (s) {
4953 Z3_solver_propagate_eq(ctx(), *s, eq_eh);
4954 }
4955 }
4956
4958 m_eq_eh = [this](expr const& x, expr const& y) {
4959 eq(x, y);
4960 };
4961 if (s) {
4962 Z3_solver_propagate_eq(ctx(), *s, eq_eh);
4963 }
4964 }
4965
4973
4974 void register_final(final_eh_t& f) {
4975 m_final_eh = f;
4976 if (s) {
4977 Z3_solver_propagate_final(ctx(), *s, final_eh);
4978 }
4979 }
4980
4982 m_final_eh = [this]() {
4983 final();
4984 };
4985 if (s) {
4986 Z3_solver_propagate_final(ctx(), *s, final_eh);
4987 }
4988 }
4989
4990 void register_created(created_eh_t& c) {
4991 m_created_eh = c;
4992 if (s) {
4993 Z3_solver_propagate_created(ctx(), *s, created_eh);
4994 }
4995 }
4996
4998 m_created_eh = [this](expr const& e) {
4999 created(e);
5000 };
5001 if (s) {
5002 Z3_solver_propagate_created(ctx(), *s, created_eh);
5003 }
5004 }
5005
5006 void register_decide(decide_eh_t& c) {
5007 m_decide_eh = c;
5008 if (s) {
5009 Z3_solver_propagate_decide(ctx(), *s, decide_eh);
5010 }
5011 }
5012
5014 m_decide_eh = [this](expr val, unsigned bit, bool is_pos) {
5015 decide(val, bit, is_pos);
5016 };
5017 if (s) {
5018 Z3_solver_propagate_decide(ctx(), *s, decide_eh);
5019 }
5020 }
5021
5023 m_on_binding_eh = [this](expr const& q, expr const& inst) {
5024 return on_binding(q, inst);
5025 };
5026 if (s)
5027 Z3_solver_propagate_on_binding(ctx(), *s, on_binding_eh);
5028 }
5029
5030 virtual void fixed(expr const& /*id*/, expr const& /*e*/) { }
5031
5032 virtual void eq(expr const& /*x*/, expr const& /*y*/) { }
5033
5034 virtual void final() { }
5035
5036 virtual void created(expr const& /*e*/) {}
5037
5038 virtual void decide(expr const& /*val*/, unsigned /*bit*/, bool /*is_pos*/) {}
5039
5040 virtual bool on_binding(expr const& /*q*/, expr const& /*inst*/) { return true; }
5041
5042 bool next_split(expr const& e, unsigned idx, Z3_lbool phase) {
5043 assert(cb);
5044 return Z3_solver_next_split(ctx(), cb, e, idx, phase);
5045 }
5046
5060
5061 void add(expr const& e) {
5062 if (cb)
5064 else if (s)
5066 else
5067 assert(false);
5068 }
5069
5071 assert(cb);
5072 expr conseq = ctx().bool_val(false);
5073 array<Z3_ast> _fixed(fixed);
5074 Z3_solver_propagate_consequence(ctx(), cb, fixed.size(), _fixed.ptr(), 0, nullptr, nullptr, conseq);
5075 }
5076
5077 void conflict(expr_vector const& fixed, expr_vector const& lhs, expr_vector const& rhs) {
5078 assert(cb);
5079 assert(lhs.size() == rhs.size());
5080 expr conseq = ctx().bool_val(false);
5081 array<Z3_ast> _fixed(fixed);
5082 array<Z3_ast> _lhs(lhs);
5083 array<Z3_ast> _rhs(rhs);
5084 Z3_solver_propagate_consequence(ctx(), cb, fixed.size(), _fixed.ptr(), lhs.size(), _lhs.ptr(), _rhs.ptr(), conseq);
5085 }
5086
5087 bool propagate(expr_vector const& fixed, expr const& conseq) {
5088 assert(cb);
5089 assert((Z3_context)conseq.ctx() == (Z3_context)ctx());
5090 array<Z3_ast> _fixed(fixed);
5091 return Z3_solver_propagate_consequence(ctx(), cb, _fixed.size(), _fixed.ptr(), 0, nullptr, nullptr, conseq);
5092 }
5093
5095 expr_vector const& lhs, expr_vector const& rhs,
5096 expr const& conseq) {
5097 assert(cb);
5098 assert((Z3_context)conseq.ctx() == (Z3_context)ctx());
5099 assert(lhs.size() == rhs.size());
5100 array<Z3_ast> _fixed(fixed);
5101 array<Z3_ast> _lhs(lhs);
5102 array<Z3_ast> _rhs(rhs);
5103
5104 return Z3_solver_propagate_consequence(ctx(), cb, _fixed.size(), _fixed.ptr(), lhs.size(), _lhs.ptr(), _rhs.ptr(), conseq);
5105 }
5106 };
5107
5117 class rcf_num {
5118 Z3_context m_ctx;
5119 Z3_rcf_num m_num;
5120
5121 void check_context(rcf_num const& other) const {
5122 if (m_ctx != other.m_ctx) {
5123 Z3_THROW(exception("rcf_num objects from different contexts"));
5124 }
5125 }
5126
5127 public:
5128 rcf_num(context& c, Z3_rcf_num n): m_ctx(c), m_num(n) {}
5129
5130 rcf_num(context& c, int val): m_ctx(c) {
5131 m_num = Z3_rcf_mk_small_int(c, val);
5132 }
5133
5134 rcf_num(context& c, char const* val): m_ctx(c) {
5135 m_num = Z3_rcf_mk_rational(c, val);
5136 }
5137
5138 rcf_num(rcf_num const& other): m_ctx(other.m_ctx) {
5139 // Create a copy by converting to string and back
5140 std::string str = Z3_rcf_num_to_string(m_ctx, other.m_num, false, false);
5141 m_num = Z3_rcf_mk_rational(m_ctx, str.c_str());
5142 }
5143
5144 rcf_num& operator=(rcf_num const& other) {
5145 if (this != &other) {
5146 Z3_rcf_del(m_ctx, m_num);
5147 m_ctx = other.m_ctx;
5148 std::string str = Z3_rcf_num_to_string(m_ctx, other.m_num, false, false);
5149 m_num = Z3_rcf_mk_rational(m_ctx, str.c_str());
5150 }
5151 return *this;
5152 }
5153
5155 Z3_rcf_del(m_ctx, m_num);
5156 }
5157
5158 operator Z3_rcf_num() const { return m_num; }
5159 Z3_context ctx() const { return m_ctx; }
5160
5164 std::string to_string(bool compact = false) const {
5165 return std::string(Z3_rcf_num_to_string(m_ctx, m_num, compact, false));
5166 }
5167
5171 std::string to_decimal(unsigned precision = 10) const {
5172 return std::string(Z3_rcf_num_to_decimal_string(m_ctx, m_num, precision));
5173 }
5174
5175 // Arithmetic operations
5176 rcf_num operator+(rcf_num const& other) const {
5177 check_context(other);
5178 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5179 Z3_rcf_add(m_ctx, m_num, other.m_num));
5180 }
5181
5182 rcf_num operator-(rcf_num const& other) const {
5183 check_context(other);
5184 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5185 Z3_rcf_sub(m_ctx, m_num, other.m_num));
5186 }
5187
5188 rcf_num operator*(rcf_num const& other) const {
5189 check_context(other);
5190 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5191 Z3_rcf_mul(m_ctx, m_num, other.m_num));
5192 }
5193
5194 rcf_num operator/(rcf_num const& other) const {
5195 check_context(other);
5196 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5197 Z3_rcf_div(m_ctx, m_num, other.m_num));
5198 }
5199
5201 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5202 Z3_rcf_neg(m_ctx, m_num));
5203 }
5204
5208 rcf_num power(unsigned k) const {
5209 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5210 Z3_rcf_power(m_ctx, m_num, k));
5211 }
5212
5216 rcf_num inv() const {
5217 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5218 Z3_rcf_inv(m_ctx, m_num));
5219 }
5220
5221 // Comparison operations
5222 bool operator<(rcf_num const& other) const {
5223 check_context(other);
5224 return Z3_rcf_lt(m_ctx, m_num, other.m_num);
5225 }
5226
5227 bool operator>(rcf_num const& other) const {
5228 check_context(other);
5229 return Z3_rcf_gt(m_ctx, m_num, other.m_num);
5230 }
5231
5232 bool operator<=(rcf_num const& other) const {
5233 check_context(other);
5234 return Z3_rcf_le(m_ctx, m_num, other.m_num);
5235 }
5236
5237 bool operator>=(rcf_num const& other) const {
5238 check_context(other);
5239 return Z3_rcf_ge(m_ctx, m_num, other.m_num);
5240 }
5241
5242 bool operator==(rcf_num const& other) const {
5243 check_context(other);
5244 return Z3_rcf_eq(m_ctx, m_num, other.m_num);
5245 }
5246
5247 bool operator!=(rcf_num const& other) const {
5248 check_context(other);
5249 return Z3_rcf_neq(m_ctx, m_num, other.m_num);
5250 }
5251
5252 // Type queries
5253 bool is_rational() const {
5254 return Z3_rcf_is_rational(m_ctx, m_num);
5255 }
5256
5257 bool is_algebraic() const {
5258 return Z3_rcf_is_algebraic(m_ctx, m_num);
5259 }
5260
5261 bool is_infinitesimal() const {
5262 return Z3_rcf_is_infinitesimal(m_ctx, m_num);
5263 }
5264
5265 bool is_transcendental() const {
5266 return Z3_rcf_is_transcendental(m_ctx, m_num);
5267 }
5268
5269 friend std::ostream& operator<<(std::ostream& out, rcf_num const& n) {
5270 return out << n.to_string();
5271 }
5272 };
5273
5278 return rcf_num(c, Z3_rcf_mk_pi(c));
5279 }
5280
5284 inline rcf_num rcf_e(context& c) {
5285 return rcf_num(c, Z3_rcf_mk_e(c));
5286 }
5287
5292 return rcf_num(c, Z3_rcf_mk_infinitesimal(c));
5293 }
5294
5301 inline std::vector<rcf_num> rcf_roots(context& c, std::vector<rcf_num> const& coeffs) {
5302 if (coeffs.empty()) {
5303 Z3_THROW(exception("polynomial coefficients cannot be empty"));
5304 }
5305
5306 unsigned n = static_cast<unsigned>(coeffs.size());
5307 std::vector<Z3_rcf_num> a(n);
5308 std::vector<Z3_rcf_num> roots(n);
5309
5310 for (unsigned i = 0; i < n; ++i) {
5311 a[i] = coeffs[i];
5312 }
5313
5314 unsigned num_roots = Z3_rcf_mk_roots(c, n, a.data(), roots.data());
5315
5316 std::vector<rcf_num> result;
5317 result.reserve(num_roots);
5318 for (unsigned i = 0; i < num_roots; ++i) {
5319 result.push_back(rcf_num(c, roots[i]));
5320 }
5321
5322 return result;
5323 }
5324
5325}
5326
5329#undef Z3_THROW
unsigned size() const
Definition z3++.h:3462
apply_result & operator=(apply_result const &s)
Definition z3++.h:3455
apply_result(context &c, Z3_apply_result s)
Definition z3++.h:3451
goal operator[](int i) const
Definition z3++.h:3463
friend std::ostream & operator<<(std::ostream &out, apply_result const &r)
Definition z3++.h:3466
~apply_result() override
Definition z3++.h:3453
apply_result(apply_result const &s)
Definition z3++.h:3452
unsigned size() const
Definition z3++.h:554
void resize(unsigned sz)
Definition z3++.h:553
T const & operator[](int i) const
Definition z3++.h:556
array(unsigned sz)
Definition z3++.h:550
T const * ptr() const
Definition z3++.h:557
T * ptr()
Definition z3++.h:558
T & operator[](int i)
Definition z3++.h:555
A map from ASTs to ASTs.
Definition z3++.h:750
unsigned size() const
Definition z3++.h:792
void erase(ast const &k)
Definition z3++.h:786
ast_map(context &c, Z3_ast_map m)
Definition z3++.h:758
ast_vector keys() const
Definition z3++.h:797
ast_map(context &c)
Definition z3++.h:757
ast_map & operator=(ast_map const &s)
Definition z3++.h:762
ast find(ast const &k) const
Definition z3++.h:775
void reset()
Definition z3++.h:791
void insert(ast const &k, ast const &v)
Definition z3++.h:781
~ast_map() override
Definition z3++.h:760
ast_map(ast_map const &s)
Definition z3++.h:759
bool contains(ast const &k) const
Definition z3++.h:769
iterator(ast_vector_tpl const *v, unsigned i)
Definition z3++.h:721
bool operator==(iterator const &other) const noexcept
Definition z3++.h:723
iterator operator++(int) noexcept
Definition z3++.h:737
bool operator!=(iterator const &other) const noexcept
Definition z3++.h:727
iterator & operator++() noexcept
Definition z3++.h:730
void pop_back()
Definition z3++.h:696
friend std::ostream & operator<<(std::ostream &out, ast_vector_tpl const &v)
Definition z3++.h:743
unsigned size() const
Definition z3++.h:691
void resize(unsigned sz)
Definition z3++.h:694
ast_vector_tpl & operator=(ast_vector_tpl const &s)
Definition z3++.h:698
~ast_vector_tpl() override
Definition z3++.h:689
ast_vector_tpl(ast_vector_tpl const &s)
Definition z3++.h:686
bool empty() const
Definition z3++.h:697
iterator end() const
Definition z3++.h:742
ast_vector_tpl(context &c, Z3_ast_vector v)
Definition z3++.h:685
void push_back(T const &e)
Definition z3++.h:693
T back() const
Definition z3++.h:695
std::string to_string() const
Definition z3++.h:744
T operator[](unsigned i) const
Definition z3++.h:692
ast_vector_tpl & set(unsigned idx, ast &a)
Definition z3++.h:705
ast_vector_tpl(context &c, ast_vector_tpl const &src)
Definition z3++.h:687
ast_vector_tpl(context &c)
Definition z3++.h:684
iterator begin() const noexcept
Definition z3++.h:741
friend std::ostream & operator<<(std::ostream &out, ast const &n)
Definition z3++.h:673
ast(ast const &s)
Definition z3++.h:650
~ast() override
Definition z3++.h:651
ast & operator=(ast const &s)
Definition z3++.h:654
friend bool eq(ast const &a, ast const &b)
Return true if the ASTs are structurally identical.
Definition z3++.h:677
Z3_ast_kind kind() const
Definition z3++.h:662
Z3_ast m_ast
Definition z3++.h:646
ast(context &c)
Definition z3++.h:648
std::string to_string() const
Definition z3++.h:665
ast(context &c, Z3_ast n)
Definition z3++.h:649
unsigned hash() const
Definition z3++.h:663
ast operator()(context &c, Z3_ast a)
Definition z3++.h:2560
expr operator()(context &c, Z3_ast a)
Definition z3++.h:2565
func_decl operator()(context &c, Z3_ast a)
Definition z3++.h:2584
sort operator()(context &c, Z3_ast a)
Definition z3++.h:2576
Z3 global configuration object.
Definition z3++.h:141
~config()
Definition z3++.h:147
void set(char const *param, int value)
Set global parameter param with integer value.
Definition z3++.h:160
void set(char const *param, char const *value)
Set global parameter param with string value.
Definition z3++.h:152
config()
Definition z3++.h:146
void set(char const *param, bool value)
Set global parameter param with Boolean value.
Definition z3++.h:156
constructor_list(constructors const &cs)
Definition z3++.h:3993
void query(unsigned i, func_decl &constructor, func_decl &test, func_decl_vector &accs)
Definition z3++.h:3974
unsigned size() const
Definition z3++.h:3972
friend class constructor_list
Definition z3++.h:3949
constructors(context &ctx)
Definition z3++.h:3954
Z3_constructor operator[](unsigned i) const
Definition z3++.h:3970
void add(symbol const &name, symbol const &rec, unsigned n, symbol const *names, sort const *fields)
Definition z3++.h:3961
A Context manages all other Z3 objects, global configuration options, etc.
Definition z3++.h:191
sort complex_sort()
Return the Complex sort (pairs of Reals).
Definition z3++.h:3886
symbol str_symbol(char const *s)
Create a Z3 symbol based on the given string.
Definition z3++.h:3880
void recdef(func_decl decl, expr_vector const &args, expr const &body)
add function definition body to declaration decl. decl needs to be declared using context::recfun.
Definition z3++.h:4165
expr num_val(int n, sort const &s)
Definition z3++.h:4261
expr fpa_rounding_mode()
Definition z3++.h:4203
std::string simplifier_name(unsigned i) const
Definition z3++.h:277
context()
Definition z3++.h:215
expr bv_val(int n, unsigned sz)
Definition z3++.h:4240
func_decl recfun(symbol const &name, unsigned arity, sort const *domain, sort const &range)
Definition z3++.h:4127
expr bool_val(bool b)
Definition z3++.h:4215
expr fpa_const(char const *name, unsigned ebits, unsigned sbits)
Definition z3++.h:4196
expr string_val(char const *s)
Definition z3++.h:4257
sort real_sort()
Return the Real sort.
Definition z3++.h:3885
Z3_error_code check_error() const
Auxiliary method used to check for API usage errors.
Definition z3++.h:241
expr bv_const(char const *name, unsigned sz)
Definition z3++.h:4195
expr string_const(char const *name)
Definition z3++.h:4194
sort array_sort(sort d, sort r)
Return an array sort for arrays from d to r.
Definition z3++.h:3910
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:259
sort string_sort()
Return the sort for Unicode strings.
Definition z3++.h:3889
sort re_sort(sort &seq_sort)
Return a regular expression sort over sequences seq_sort.
Definition z3++.h:3892
sort uninterpreted_sort(char const *name)
create an uninterpreted sort with the name given by the string or symbol.
Definition z3++.h:4048
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:3915
void set(char const *param, int value)
Update global parameter param with Integer value.
Definition z3++.h:290
sort bool_sort()
Return the Boolean sort.
Definition z3++.h:3883
void set(char const *param, char const *value)
Update global parameter param with string value.
Definition z3++.h:266
~context()
Definition z3++.h:235
expr complex_val(int re, int im=0)
Definition z3++.h:4229
context & operator=(context &&other) noexcept
Definition z3++.h:225
unsigned num_simplifiers() const
Definition z3++.h:272
expr complex_const(char const *name)
Definition z3++.h:4193
sort fpa_sort(unsigned ebits, unsigned sbits)
Return a floating point sort. ebits is a number of exponent bits, sbits is a number of significand bi...
Definition z3++.h:3894
expr bool_const(char const *name)
create uninterpreted constants of a given sort.
Definition z3++.h:4190
context(context &&other) noexcept
Definition z3++.h:218
void check_parser_error() const
Definition z3++.h:248
expr variable(unsigned index, sort const &s)
create a de-Bruijn variable.
Definition z3++.h:4185
expr_vector parse_string(char const *s)
parsing
Definition z3++.h:4642
sort fpa_sort()
Definition z3++.h:3897
symbol int_symbol(int n)
Create a Z3 symbol based on the given integer.
Definition z3++.h:3881
expr real_const(char const *name)
Definition z3++.h:4192
sort datatype(symbol const &name, constructors const &cs)
Create a recursive datatype over a single sort. name is the name of the recursive datatype n - the nu...
Definition z3++.h:4000
expr int_const(char const *name)
Definition z3++.h:4191
expr fpa_nan(sort const &s)
Definition z3++.h:4253
expr fpa_val(double n)
Definition z3++.h:4251
bool enable_exceptions() const
Definition z3++.h:261
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:3888
expr int_val(int n)
Definition z3++.h:4217
expr fpa_inf(sort const &s, bool sgn)
Definition z3++.h:4254
func_decl function(symbol const &name, unsigned arity, sort const *domain, sort const &range)
Definition z3++.h:4056
sort fpa_rounding_mode_sort()
Return a RoundingMode sort.
Definition z3++.h:3908
expr_vector parse_file(char const *file)
Definition z3++.h:4648
sort finite_field_sort(char const *prime)
Return the prime finite-field sort with the given decimal modulus.
Definition z3++.h:3887
expr constant(symbol const &name, sort const &s)
create an uninterpreted constant.
Definition z3++.h:4179
sort finite_set_sort(sort &s)
Return a finite set sort over element sort s.
Definition z3++.h:3893
sort char_sort()
Return the sort for Unicode characters.
Definition z3++.h:3890
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:3926
void set(char const *param, bool value)
Update global parameter param with Boolean value.
Definition z3++.h:270
sort int_sort()
Return the integer sort.
Definition z3++.h:3884
void interrupt()
Interrupt the current procedure being executed by any object managed by this context....
Definition z3++.h:299
void set_rounding_mode(rounding_mode rm)
Sets RoundingMode of FloatingPoints.
Definition z3++.h:4201
func_decl user_propagate_function(symbol const &name, sort_vector const &domain, sort const &range)
Definition z3++.h:4171
sort fpa_sort()
Return a FloatingPoint sort with given precision bitwidth (16, 32, 64 or 128).
expr real_val(int n)
Definition z3++.h:4224
std::string simplifier_description(char const *name) const
Definition z3++.h:282
sort_vector datatypes(unsigned n, symbol const *names, constructor_list *const *cons)
Create a set of mutually recursive datatypes. n - number of recursive datatypes names - array of name...
Definition z3++.h:4018
friend class user_propagator_base
Definition z3++.h:193
sort datatype_sort(symbol const &name)
a reference to a recursively defined datatype. Expect that it gets defined as a datatype.
Definition z3++.h:4034
context(config &c)
Definition z3++.h:216
sort seq_sort(sort &s)
Return a sequence sort over base sort s.
Definition z3++.h:3891
Exception used to sign API usage errors.
Definition z3++.h:119
char const * what() const
Definition z3++.h:125
virtual ~exception()=default
friend std::ostream & operator<<(std::ostream &out, exception const &e)
Definition z3++.h:128
char const * msg() const
Definition z3++.h:124
exception(char const *msg)
Definition z3++.h:123
bool operator==(iterator const &other) const noexcept
Definition z3++.h:1830
iterator operator++(int)
Definition z3++.h:1838
iterator(expr &e, unsigned i)
Definition z3++.h:1829
expr operator*() const
Definition z3++.h:1836
iterator & operator++()
Definition z3++.h:1837
bool operator!=(iterator const &other) const noexcept
Definition z3++.h:1833
A Z3 expression is used to represent formulas and terms. For Z3, a formula is any expression of sort ...
Definition z3++.h:1003
bool is_lambda() const
Return true if this expression is a lambda expression.
Definition z3++.h:1115
expr numerator() const
Definition z3++.h:1332
friend expr pw(expr const &a, expr const &b)
Definition z3++.h:1861
friend expr sbv_to_fpa(expr const &t, sort s)
Conversion of a signed bit-vector term into a floating-point.
Definition z3++.h:2315
friend expr bvneg_no_overflow(expr const &a)
Definition z3++.h:2516
expr loop(unsigned lo, unsigned hi)
Definition z3++.h:1779
expr body() const
Return the 'body' of this quantifier.
Definition z3++.h:1444
friend expr bvadd_no_underflow(expr const &a, expr const &b)
Definition z3++.h:2504
expr ubvtos() const
Definition z3++.h:1739
friend expr sum(expr_vector const &args)
Definition z3++.h:2713
expr substitute(expr_vector const &src, expr_vector const &dst)
Apply substitution. Replace src expressions by dst.
Definition z3++.h:4724
bool is_quantifier() const
Return true if this expression is a quantifier.
Definition z3++.h:1102
bool is_exists() const
Return true if this expression is an existential quantifier.
Definition z3++.h:1111
bool is_numeral_u64(uint64_t &i) const
Definition z3++.h:1078
bool is_int() const
Return true if this is an integer expression.
Definition z3++.h:1020
friend expr operator/(expr const &a, expr const &b)
Definition z3++.h:2055
friend expr fp_eq(expr const &a, expr const &b)
Definition z3++.h:2276
friend expr concat(expr const &a, expr const &b)
Definition z3++.h:2731
friend expr bvmul_no_underflow(expr const &a, expr const &b)
Definition z3++.h:2522
int64_t get_numeral_int64() const
Return int64_t value of numeral, throw if result cannot fit in int64_t.
Definition z3++.h:1300
bool is_app() const
Return true if this expression is an application.
Definition z3++.h:1094
friend expr fpa_to_fpa(expr const &t, sort s)
Conversion of a floating-point term into another floating-point.
Definition z3++.h:2329
friend expr operator&&(expr const &a, expr const &b)
Return an expression representing a and b.
Definition z3++.h:1925
friend expr operator!=(expr const &a, expr const &b)
Definition z3++.h:1961
friend expr operator+(expr const &a, expr const &b)
Definition z3++.h:1973
std::string get_string() const
for a string value expression return an escaped string value.
Definition z3++.h:1359
bool is_numeral(std::string &s) const
Definition z3++.h:1081
expr char_to_int() const
Definition z3++.h:1749
bool is_var() const
Return true if this expression is a variable.
Definition z3++.h:1120
bool is_numeral_u(unsigned &i) const
Definition z3++.h:1080
friend expr min(expr const &a, expr const &b)
Definition z3++.h:2205
expr at(expr const &index) const
Definition z3++.h:1706
expr_vector args() const
Return a vector of all the arguments of this application. This method assumes the expression is an ap...
Definition z3++.h:1410
expr ext_rotate_left(expr const &n) const
Definition z3++.h:1623
expr denominator() const
Definition z3++.h:1340
bool is_real() const
Return true if this is a real expression.
Definition z3++.h:1024
bool is_numeral_i(int &i) const
Definition z3++.h:1079
friend expr operator>(expr const &a, expr const &b)
Definition z3++.h:2168
expr mk_is_nan() const
Return Boolean expression to test for whether an FP expression is a NaN.
Definition z3++.h:1144
int get_numeral_int() const
Return int value of numeral, throw if result cannot fit in machine int.
Definition z3++.h:1264
expr is_digit() const
Definition z3++.h:1764
friend expr bv2int(expr const &a, bool is_signed)
bit-vector and integer conversions.
Definition z3++.h:2495
friend expr operator~(expr const &a)
Definition z3++.h:2283
unsigned num_args() const
Return the number of arguments in this application. This method assumes the expression is an applicat...
Definition z3++.h:1395
friend expr nor(expr const &a, expr const &b)
Definition z3++.h:2203
friend expr fpa_fp(expr const &sgn, expr const &exp, expr const &sig)
Create an expression of FloatingPoint sort from three bit-vector expressions.
Definition z3++.h:2293
expr arg(unsigned i) const
Return the i-th argument of this application. This method assumes the expression is an application.
Definition z3++.h:1403
expr mk_is_normal() const
Return Boolean expression to test for whether an FP expression is a normal.
Definition z3++.h:1154
friend expr bvsub_no_underflow(expr const &a, expr const &b, bool is_signed)
Definition z3++.h:2510
expr repeat(unsigned i) const
Definition z3++.h:1625
bool is_true() const
Definition z3++.h:1510
expr(context &c)
Definition z3++.h:1005
friend expr mk_xor(expr_vector const &args)
Definition z3++.h:2815
bool is_numeral(std::string &s, unsigned precision) const
Definition z3++.h:1082
unsigned get_numeral_uint() const
Return uint value of numeral, throw if result cannot fit in machine uint.
Definition z3++.h:1283
bool is_distinct() const
Definition z3++.h:1519
bool is_numeral(double &d) const
Definition z3++.h:1083
expr rotate_left(unsigned i) const
Definition z3++.h:1621
friend expr operator*(expr const &a, expr const &b)
Definition z3++.h:2007
sort get_sort() const
Return the sort of this expression.
Definition z3++.h:1011
friend expr nand(expr const &a, expr const &b)
Definition z3++.h:2202
bool is_and() const
Definition z3++.h:1513
friend expr fpa_to_ubv(expr const &t, unsigned sz)
Conversion of a floating-point term into an unsigned bit-vector.
Definition z3++.h:2308
friend expr bvredor(expr const &a)
Definition z3++.h:2237
expr extract(unsigned hi, unsigned lo) const
Definition z3++.h:1635
expr rotate_right(unsigned i) const
Definition z3++.h:1622
friend expr int2bv(unsigned n, expr const &a)
Definition z3++.h:2496
expr ext_rotate_right(expr const &n) const
Definition z3++.h:1624
friend expr max(expr const &a, expr const &b)
Definition z3++.h:2221
bool is_relation() const
Return true if this is a Relation expression.
Definition z3++.h:1046
friend expr xnor(expr const &a, expr const &b)
Definition z3++.h:2204
friend expr abs(expr const &a)
Definition z3++.h:2249
friend expr pbge(expr_vector const &es, int const *coeffs, int bound)
Definition z3++.h:2681
bool is_well_sorted() const
Return true if this expression is well sorted (aka type correct).
Definition z3++.h:1129
bool is_or() const
Definition z3++.h:1514
friend expr round_fpa_to_closest_integer(expr const &t)
Round a floating-point term into its closest integer.
Definition z3++.h:2336
friend expr distinct(expr_vector const &args)
Definition z3++.h:2722
bool is_complex() const
Return true if this expression is Complex.
Definition z3++.h:1026
friend expr bvmul_no_overflow(expr const &a, expr const &b, bool is_signed)
Definition z3++.h:2519
friend expr bvsub_no_overflow(expr const &a, expr const &b)
Definition z3++.h:2507
bool is_const() const
Return true if this expression is a constant (i.e., an application with 0 arguments).
Definition z3++.h:1098
expr length() const
Definition z3++.h:1718
friend expr mod(expr const &a, expr const &b)
Definition z3++.h:1865
friend expr fma(expr const &a, expr const &b, expr const &c, expr const &rm)
FloatingPoint fused multiply-add.
Definition z3++.h:2285
bool is_bool() const
Return true if this is a Boolean expression.
Definition z3++.h:1016
expr update(expr_vector const &args) const
Update the arguments of this application. Return a new expression with the same function declaration ...
Definition z3++.h:4763
friend expr mk_or(expr_vector const &args)
Definition z3++.h:2803
expr contains(expr const &s) const
Definition z3++.h:1700
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:2348
expr algebraic_lower(unsigned precision) const
Definition z3++.h:1215
unsigned hi() const
Definition z3++.h:1638
expr simplify() const
Return a simplified version of this expression.
Definition z3++.h:1803
bool is_arith() const
Return true if this is an Integer, Real, or Complex expression.
Definition z3++.h:1030
expr mk_is_inf() const
Return Boolean expression to test for whether an FP expression is inf.
Definition z3++.h:1134
expr stoi() const
Definition z3++.h:1729
expr_vector algebraic_poly() const
Return coefficients for p of an algebraic number (root-obj p i).
Definition z3++.h:1232
bool is_ite() const
Definition z3++.h:1518
bool is_bv() const
Return true if this is a Bit-vector expression.
Definition z3++.h:1034
friend expr pbeq(expr_vector const &es, int const *coeffs, int bound)
Definition z3++.h:2689
friend expr operator^(expr const &a, expr const &b)
Definition z3++.h:2194
friend expr operator<=(expr const &a, expr const &b)
Definition z3++.h:2121
friend expr operator>=(expr const &a, expr const &b)
Definition z3++.h:2035
friend expr sqrt(expr const &a, expr const &rm)
Definition z3++.h:2269
friend expr pble(expr_vector const &es, int const *coeffs, int bound)
Definition z3++.h:2673
friend expr operator==(expr const &a, expr const &b)
Definition z3++.h:1950
bool is_finite_domain() const
Definition z3++.h:1065
expr operator[](expr_vector const &index) const
Definition z3++.h:1796
bool is_forall() const
Return true if this expression is a universal quantifier.
Definition z3++.h:1107
bool is_implies() const
Definition z3++.h:1516
uint64_t as_uint64() const
Definition z3++.h:1087
friend expr implies(expr const &a, expr const &b)
Definition z3++.h:1853
expr mk_is_subnormal() const
Return Boolean expression to test for whether an FP expression is a subnormal.
Definition z3++.h:1164
uint64_t get_numeral_uint64() const
Return uint64_t value of numeral, throw if result cannot fit in uint64_t.
Definition z3++.h:1317
expr(context &c, Z3_ast n)
Definition z3++.h:1006
friend expr bvadd_no_overflow(expr const &a, expr const &b, bool is_signed)
bit-vector overflow/underflow checks
Definition z3++.h:2501
bool is_datatype() const
Return true if this is a Datatype expression.
Definition z3++.h:1042
bool is_not() const
Definition z3++.h:1512
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:1352
expr power(expr const &n) const
Definition z3++.h:1723
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:1807
expr loop(unsigned lo)
create a looping regular expression.
Definition z3++.h:1774
expr sbvtos() const
Definition z3++.h:1744
expr mk_from_ieee_bv(sort const &s) const
Convert this IEEE BV into a fpa.
Definition z3++.h:1194
friend expr bvredand(expr const &a)
Definition z3++.h:2243
friend expr operator&(expr const &a, expr const &b)
Definition z3++.h:2190
friend expr operator-(expr const &a)
Definition z3++.h:2077
friend expr bvsdiv_no_overflow(expr const &a, expr const &b)
Definition z3++.h:2513
expr extract(expr const &offset, expr const &length) const
sequence and regular expression operations.
Definition z3++.h:1685
bool is_eq() const
Definition z3++.h:1517
expr unit() const
Definition z3++.h:1695
bool is_re() const
Return true if this is a regular expression.
Definition z3++.h:1054
bool is_numeral_i64(int64_t &i) const
Definition z3++.h:1077
bool as_binary(std::string &s) const
Definition z3++.h:1084
unsigned id() const
retrieve unique identifier for expression.
Definition z3++.h:1252
friend expr rem(expr const &a, expr const &b)
Definition z3++.h:1881
friend expr operator!(expr const &a)
Return an expression representing not(a).
Definition z3++.h:1919
bool is_algebraic() const
Return true if expression is an algebraic number.
Definition z3++.h:1124
friend expr mk_and(expr_vector const &args)
Definition z3++.h:2809
expr itos() const
Definition z3++.h:1734
bool is_false() const
Definition z3++.h:1511
int64_t as_int64() const
Definition z3++.h:1088
double as_double() const
Definition z3++.h:1086
iterator end()
Definition z3++.h:1842
expr mk_is_zero() const
Return Boolean expression to test for whether an FP expression is a zero.
Definition z3++.h:1174
std::u32string get_u32string() const
for a string value expression return an unespaced string value.
Definition z3++.h:1371
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:1207
Z3_lbool bool_value() const
Definition z3++.h:1328
expr replace(expr const &src, expr const &dst) const
Definition z3++.h:1689
iterator begin()
Definition z3++.h:1841
friend expr operator||(expr const &a, expr const &b)
Return an expression representing a or b.
Definition z3++.h:1937
bool is_finite_field() const
Return true if this is a Finite-domain expression.
Definition z3++.h:1064
bool is_array() const
Return true if this is a Array expression.
Definition z3++.h:1038
bool is_xor() const
Definition z3++.h:1515
unsigned algebraic_i() const
Return i of an algebraic number (root-obj p i).
Definition z3++.h:1242
expr update_field(func_decl const &field_access, expr const &new_value) const
Update a datatype field. Return a new datatype expression with the specified field updated to the new...
Definition z3++.h:4773
unsigned lo() const
Definition z3++.h:1637
friend expr ubv_to_fpa(expr const &t, sort s)
Conversion of an unsigned bit-vector term into a floating-point.
Definition z3++.h:2322
expr nth(expr const &index) const
Definition z3++.h:1712
friend expr fpa_to_sbv(expr const &t, unsigned sz)
Conversion of a floating-point term into a signed bit-vector.
Definition z3++.h:2301
bool is_seq() const
Return true if this is a sequence expression.
Definition z3++.h:1050
friend expr operator|(expr const &a, expr const &b)
Definition z3++.h:2198
expr bit2bool(unsigned i) const
Definition z3++.h:1636
friend expr atmost(expr_vector const &es, unsigned bound)
Definition z3++.h:2697
friend expr range(expr const &lo, expr const &hi)
Definition z3++.h:4631
expr char_from_bv() const
Definition z3++.h:1759
friend expr atleast(expr_vector const &es, unsigned bound)
Definition z3++.h:2705
friend expr operator<(expr const &a, expr const &b)
Definition z3++.h:2146
expr mk_to_ieee_bv() const
Convert this fpa into an IEEE BV.
Definition z3++.h:1184
expr operator[](expr const &index) const
Definition z3++.h:1788
expr algebraic_upper(unsigned precision) const
Definition z3++.h:1222
bool is_numeral() const
Return true if this expression is a numeral. Specialized functions also return representations for th...
Definition z3++.h:1076
bool is_fpa() const
Return true if this is a FloatingPoint expression. .
Definition z3++.h:1069
func_decl decl() const
Return the declaration associated with this application. This method assumes the expression is an app...
Definition z3++.h:1388
expr char_to_bv() const
Definition z3++.h:1754
std::string to_string(expr_vector const &queries)
Definition z3++.h:3855
std::string help() const
Definition z3++.h:3852
fixedpoint & operator=(fixedpoint const &o)
Definition z3++.h:3810
expr_vector from_string(char const *s)
Definition z3++.h:3818
void add_fact(func_decl &f, unsigned *args)
Definition z3++.h:3829
void add_cover(int level, func_decl &p, expr &property)
Definition z3++.h:3846
expr_vector rules() const
Definition z3++.h:3850
stats statistics() const
Definition z3++.h:3847
expr get_answer()
Definition z3++.h:3837
~fixedpoint() override
Definition z3++.h:3809
expr get_cover_delta(int level, func_decl &p)
Definition z3++.h:3841
fixedpoint(context &c)
Definition z3++.h:3807
std::string reason_unknown()
Definition z3++.h:3838
check_result query(func_decl_vector &relations)
Definition z3++.h:3831
void register_relation(func_decl &p)
Definition z3++.h:3848
std::string to_string()
Definition z3++.h:3854
check_result query(expr &q)
Definition z3++.h:3830
param_descrs get_param_descrs()
Definition z3++.h:3853
expr_vector from_file(char const *s)
Definition z3++.h:3823
void update_rule(expr &rule, symbol const &name)
Definition z3++.h:3839
expr_vector assertions() const
Definition z3++.h:3849
fixedpoint(fixedpoint const &o)
Definition z3++.h:3808
unsigned get_num_levels(func_decl &p)
Definition z3++.h:3840
void add_rule(expr &rule, symbol const &name)
Definition z3++.h:3828
void set(params const &p)
Definition z3++.h:3851
Function declaration (aka function definition). It is the signature of interpreted and uninterpreted ...
Definition z3++.h:914
func_decl transitive_closure(func_decl const &)
Definition z3++.h:933
func_decl(context &c, Z3_func_decl n)
Definition z3++.h:917
symbol name() const
Definition z3++.h:928
expr operator()() const
Definition z3++.h:4284
bool is_const() const
Definition z3++.h:937
func_decl_vector accessors()
Definition z3++.h:4705
sort range() const
Definition z3++.h:927
func_decl(context &c)
Definition z3++.h:916
Z3_decl_kind decl_kind() const
Definition z3++.h:929
sort domain(unsigned i) const
Definition z3++.h:926
unsigned id() const
retrieve unique identifier for func_decl.
Definition z3++.h:923
unsigned num_parameters() const
Definition z3++.h:930
unsigned arity() const
Definition z3++.h:925
Definition z3++.h:2825
unsigned num_args() const
Definition z3++.h:2844
expr arg(unsigned i) const
Definition z3++.h:2845
~func_entry() override
Definition z3++.h:2834
func_entry(context &c, Z3_func_entry e)
Definition z3++.h:2832
expr value() const
Definition z3++.h:2843
func_entry & operator=(func_entry const &s)
Definition z3++.h:2836
func_entry(func_entry const &s)
Definition z3++.h:2833
expr else_value() const
Definition z3++.h:2866
void set_else(expr &value)
Definition z3++.h:2873
func_interp(context &c, Z3_func_interp e)
Definition z3++.h:2855
func_interp(func_interp const &s)
Definition z3++.h:2856
func_entry entry(unsigned i) const
Definition z3++.h:2868
void add_entry(expr_vector const &args, expr &value)
Definition z3++.h:2869
unsigned num_entries() const
Definition z3++.h:2867
func_interp & operator=(func_interp const &s)
Definition z3++.h:2859
~func_interp() override
Definition z3++.h:2857
void add(expr const &f)
Definition z3++.h:3404
unsigned size() const
Definition z3++.h:3406
Z3_goal_prec precision() const
Definition z3++.h:3408
model convert_model(model const &m) const
Definition z3++.h:3415
bool is_decided_unsat() const
Definition z3++.h:3414
goal(goal const &s)
Definition z3++.h:3394
bool inconsistent() const
Definition z3++.h:3409
~goal() override
Definition z3++.h:3395
model get_model() const
Definition z3++.h:3421
std::string dimacs(bool include_names=true) const
Definition z3++.h:3439
unsigned num_exprs() const
Definition z3++.h:3412
goal(context &c, Z3_goal s)
Definition z3++.h:3393
goal(context &c, bool models=true, bool unsat_cores=false, bool proofs=false)
Definition z3++.h:3392
void add(expr_vector const &v)
Definition z3++.h:3405
goal & operator=(goal const &s)
Definition z3++.h:3397
void reset()
Definition z3++.h:3411
friend std::ostream & operator<<(std::ostream &out, goal const &g)
Definition z3++.h:3442
unsigned depth() const
Definition z3++.h:3410
bool is_decided_sat() const
Definition z3++.h:3413
expr as_expr() const
Definition z3++.h:3426
expr operator[](int i) const
Definition z3++.h:3407
expr eval(expr const &n, bool model_completion=false) const
Definition z3++.h:2901
unsigned size() const
Definition z3++.h:2915
sort get_sort(unsigned i) const
Return the uninterpreted sort at position i.
Definition z3++.h:2965
expr get_const_interp(func_decl c) const
Definition z3++.h:2924
unsigned num_consts() const
Definition z3++.h:2911
model & operator=(model const &s)
Definition z3++.h:2893
unsigned num_funcs() const
Definition z3++.h:2912
expr_vector sort_universe(sort const &s) const
Definition z3++.h:2971
func_interp get_func_interp(func_decl f) const
Definition z3++.h:2930
func_decl get_func_decl(unsigned i) const
Definition z3++.h:2914
func_interp add_func_interp(func_decl &f, expr &else_val)
Definition z3++.h:2944
func_decl operator[](int i) const
Definition z3++.h:2916
friend std::ostream & operator<<(std::ostream &out, model const &m)
Definition z3++.h:3030
~model() override
Definition z3++.h:2891
model(model const &s)
Definition z3++.h:2889
unsigned num_sorts() const
Definition z3++.h:2955
model(context &c)
Definition z3++.h:2887
void add_const_interp(func_decl &f, expr &value)
Definition z3++.h:2950
func_decl get_const_decl(unsigned i) const
Definition z3++.h:2913
bool has_interp(func_decl f) const
Definition z3++.h:2939
std::string to_string() const
Definition z3++.h:2980
model(model &src, context &dst, translate)
Definition z3++.h:2890
model(context &c, Z3_model m)
Definition z3++.h:2888
context * m_ctx
Definition z3++.h:563
Z3_error_code check_error() const
Definition z3++.h:568
context & ctx() const
Definition z3++.h:567
object(context &c)
Definition z3++.h:565
friend void check_context(object const &a, object const &b)
Definition z3++.h:571
virtual ~object()=default
on_clause(solver &s, on_clause_eh_t &on_clause_eh)
Definition z3++.h:4796
handle(unsigned h)
Definition z3++.h:3680
unsigned h() const
Definition z3++.h:3681
std::string help() const
Definition z3++.h:3800
handle add_soft(expr const &e, char const *weight)
Definition z3++.h:3729
expr_vector lower_as_vector(handle const &h) const
Definition z3++.h:3779
friend std::ostream & operator<<(std::ostream &out, optimize const &s)
Definition z3++.h:3802
~optimize() override
Definition z3++.h:3707
void add(expr const &e, expr const &t)
Definition z3++.h:3716
expr lower(handle const &h)
Definition z3++.h:3774
void pop()
Definition z3++.h:3756
expr_vector objectives() const
Definition z3++.h:3795
void add(expr_vector const &es)
Definition z3++.h:3713
void add(expr const &e, char const *p)
Definition z3++.h:3720
void set_initial_value(expr const &var, expr const &value)
Definition z3++.h:3736
model get_model() const
Definition z3++.h:3771
handle add(expr const &e, unsigned weight)
Definition z3++.h:3733
check_result check()
Definition z3++.h:3759
check_result check(expr_vector const &asms)
Definition z3++.h:3760
stats statistics() const
Definition z3++.h:3796
expr_vector upper_as_vector(handle const &h) const
Definition z3++.h:3789
void add(expr const &e)
Definition z3++.h:3709
void set_initial_value(expr const &var, int i)
Definition z3++.h:3740
void push()
Definition z3++.h:3753
void set_initial_value(expr const &var, bool b)
Definition z3++.h:3743
optimize(context &c, optimize const &src, translate)
Definition z3++.h:3684
handle add_soft(expr const &e, unsigned weight)
Definition z3++.h:3724
handle maximize(expr const &e)
Definition z3++.h:3747
optimize(optimize const &o)
Definition z3++.h:3690
void from_file(char const *filename)
Definition z3++.h:3798
expr_vector assertions() const
Definition z3++.h:3794
optimize & operator=(optimize const &o)
Definition z3++.h:3700
void from_string(char const *constraints)
Definition z3++.h:3799
expr upper(handle const &h)
Definition z3++.h:3784
optimize(context &c, optimize &src)
Definition z3++.h:3693
handle minimize(expr const &e)
Definition z3++.h:3750
optimize(context &c)
Definition z3++.h:3683
void set(params const &p)
Definition z3++.h:3773
expr_vector unsat_core() const
Definition z3++.h:3772
param_descrs(param_descrs const &o)
Definition z3++.h:597
param_descrs(context &c, Z3_param_descrs d)
Definition z3++.h:596
Z3_param_kind kind(symbol const &s)
Definition z3++.h:611
std::string documentation(symbol const &s)
Definition z3++.h:612
symbol name(unsigned i)
Definition z3++.h:610
static param_descrs simplify_param_descrs(context &c)
Definition z3++.h:606
unsigned size()
Definition z3++.h:609
std::string to_string() const
Definition z3++.h:613
~param_descrs() override
Definition z3++.h:605
param_descrs & operator=(param_descrs const &o)
Definition z3++.h:598
static param_descrs global_param_descrs(context &c)
Definition z3++.h:607
int get_int() const
Definition z3++.h:3103
func_decl get_decl() const
Definition z3++.h:3099
sort get_sort() const
Definition z3++.h:3098
std::string get_rational() const
Definition z3++.h:3101
symbol get_symbol() const
Definition z3++.h:3100
Z3_parameter_kind kind() const
Definition z3++.h:3096
double get_double() const
Definition z3++.h:3102
parameter(func_decl const &d, unsigned idx)
Definition z3++.h:3086
expr get_expr() const
Definition z3++.h:3097
parameter(expr const &e, unsigned idx)
Definition z3++.h:3091
void set(char const *k, char const *s)
Definition z3++.h:636
params(context &c)
Definition z3++.h:621
params(params const &s)
Definition z3++.h:622
~params() override
Definition z3++.h:623
void set(char const *k, bool b)
Definition z3++.h:632
void set(char const *k, unsigned n)
Definition z3++.h:633
void set(char const *k, symbol const &s)
Definition z3++.h:635
params & operator=(params const &s)
Definition z3++.h:625
void set(char const *k, double n)
Definition z3++.h:634
friend std::ostream & operator<<(std::ostream &out, params const &p)
Definition z3++.h:640
~parser_context() override
Definition z3++.h:959
expr_vector parse_string(const char *s)
Parse a string of SMTLIB2 commands. Return assertions.
Definition z3++.h:986
void add_sort(const func_decl &f)
Add a function declaration.
Definition z3++.h:981
parser_context(context &c)
Definition z3++.h:958
parser_context & operator=(const parser_context &o)
Definition z3++.h:963
void add_sort(const sort &s)
Add a sort declaration.
Definition z3++.h:976
parser_context(const parser_context &o)
Definition z3++.h:962
probe & operator=(probe const &s)
Definition z3++.h:3608
friend probe operator<(probe const &p1, probe const &p2)
Definition z3++.h:3647
double operator()(goal const &g) const
Definition z3++.h:3616
friend probe operator==(probe const &p1, probe const &p2)
Definition z3++.h:3657
friend probe operator<=(probe const &p1, probe const &p2)
Definition z3++.h:3637
probe(context &c, Z3_probe s)
Definition z3++.h:3604
probe(context &c, double val)
Definition z3++.h:3603
probe(context &c, char const *name)
Definition z3++.h:3602
friend probe operator&&(probe const &p1, probe const &p2)
Definition z3++.h:3662
probe(probe const &s)
Definition z3++.h:3605
~probe() override
Definition z3++.h:3606
friend probe operator!(probe const &p)
Definition z3++.h:3668
double apply(goal const &g) const
Definition z3++.h:3615
friend probe operator>=(probe const &p1, probe const &p2)
Definition z3++.h:3642
friend probe operator>(probe const &p1, probe const &p2)
Definition z3++.h:3652
friend probe operator||(probe const &p1, probe const &p2)
Definition z3++.h:3665
Wrapper for Z3 Real Closed Field (RCF) numerals.
Definition z3++.h:5117
bool operator==(rcf_num const &other) const
Definition z3++.h:5242
bool is_transcendental() const
Definition z3++.h:5265
bool operator<=(rcf_num const &other) const
Definition z3++.h:5232
std::string to_decimal(unsigned precision=10) const
Return decimal string representation with given precision.
Definition z3++.h:5171
std::string to_string(bool compact=false) const
Return string representation of the RCF numeral.
Definition z3++.h:5164
rcf_num(rcf_num const &other)
Definition z3++.h:5138
rcf_num(context &c, Z3_rcf_num n)
Definition z3++.h:5128
bool operator>(rcf_num const &other) const
Definition z3++.h:5227
rcf_num operator*(rcf_num const &other) const
Definition z3++.h:5188
rcf_num operator/(rcf_num const &other) const
Definition z3++.h:5194
rcf_num inv() const
Return the multiplicative inverse (1/this).
Definition z3++.h:5216
rcf_num power(unsigned k) const
Return the power of this number raised to k.
Definition z3++.h:5208
rcf_num & operator=(rcf_num const &other)
Definition z3++.h:5144
friend std::ostream & operator<<(std::ostream &out, rcf_num const &n)
Definition z3++.h:5269
bool is_rational() const
Definition z3++.h:5253
rcf_num(context &c, int val)
Definition z3++.h:5130
bool is_algebraic() const
Definition z3++.h:5257
rcf_num(context &c, char const *val)
Definition z3++.h:5134
Z3_context ctx() const
Definition z3++.h:5159
bool is_infinitesimal() const
Definition z3++.h:5261
bool operator!=(rcf_num const &other) const
Definition z3++.h:5247
rcf_num operator-() const
Definition z3++.h:5200
bool operator>=(rcf_num const &other) const
Definition z3++.h:5237
rcf_num operator-(rcf_num const &other) const
Definition z3++.h:5182
bool operator<(rcf_num const &other) const
Definition z3++.h:5222
rcf_num operator+(rcf_num const &other) const
Definition z3++.h:5176
std::string help() const
Definition z3++.h:3573
~simplifier() override
Definition z3++.h:3564
simplifier(context &c, char const *name)
Definition z3++.h:3561
friend simplifier with(simplifier const &t, params const &p)
Definition z3++.h:3589
simplifier(context &c, Z3_simplifier s)
Definition z3++.h:3562
simplifier(simplifier const &s)
Definition z3++.h:3563
param_descrs get_param_descrs()
Definition z3++.h:3576
simplifier & operator=(simplifier const &s)
Definition z3++.h:3566
friend simplifier operator&(simplifier const &t1, simplifier const &t2)
Definition z3++.h:3582
cube_iterator end()
Definition z3++.h:3375
cube_generator(solver &s, expr_vector &vars)
Definition z3++.h:3367
cube_iterator begin()
Definition z3++.h:3374
cube_generator(solver &s)
Definition z3++.h:3360
void set_cutoff(unsigned c) noexcept
Definition z3++.h:3376
expr_vector const * operator->() const
Definition z3++.h:3342
bool operator==(cube_iterator const &other) const noexcept
Definition z3++.h:3345
cube_iterator operator++(int)
Definition z3++.h:3341
cube_iterator & operator++()
Definition z3++.h:3331
bool operator!=(cube_iterator const &other) const noexcept
Definition z3++.h:3348
cube_iterator(solver &s, expr_vector &vars, unsigned &cutoff, bool end)
Definition z3++.h:3319
expr_vector const & operator*() const noexcept
Definition z3++.h:3343
void from_string(char const *s)
Definition z3++.h:3167
expr proof() const
Definition z3++.h:3264
cube_generator cubes(expr_vector &vars)
Definition z3++.h:3380
friend std::ostream & operator<<(std::ostream &out, solver const &s)
Definition z3++.h:3383
solver(context &c, solver const &src, translate)
Definition z3++.h:3121
expr_vector non_units() const
Definition z3++.h:3201
solver(context &c, simple)
Definition z3++.h:3118
solver(context &c, Z3_solver s)
Definition z3++.h:3119
solver(context &c, char const *logic)
Definition z3++.h:3120
void set(char const *k, bool v)
Definition z3++.h:3134
void add(expr const &e, expr const &p)
Definition z3++.h:3153
void add(expr const &e, char const *p)
Definition z3++.h:3158
check_result consequences(expr_vector &assumptions, expr_vector &vars, expr_vector &conseq)
Definition z3++.h:3192
void set_initial_value(expr const &var, expr const &value)
Definition z3++.h:3233
void set(char const *k, char const *v)
Definition z3++.h:3138
check_result check(unsigned n, expr *const assumptions)
Definition z3++.h:3170
expr congruence_explain(expr const &a, expr const &b) const
Definition z3++.h:3226
model get_model() const
Definition z3++.h:3191
std::string dimacs(bool include_names=true) const
Definition z3++.h:3287
void import_model_converter(solver const &src)
Definition z3++.h:3258
check_result check()
Definition z3++.h:3169
expr congruence_next(expr const &t) const
Definition z3++.h:3220
stats statistics() const
Definition z3++.h:3198
expr_vector units() const
Definition z3++.h:3202
expr_vector trail() const
Definition z3++.h:3203
void add(expr const &e)
Definition z3++.h:3152
void set_initial_value(expr const &var, int i)
Definition z3++.h:3237
solver & operator=(solver const &s)
Definition z3++.h:3126
void set(char const *k, double v)
Definition z3++.h:3136
void pop(unsigned n=1)
Definition z3++.h:3150
void push()
Create a backtracking point.
Definition z3++.h:3149
void set_initial_value(expr const &var, bool b)
Definition z3++.h:3240
~solver() override
Definition z3++.h:3124
std::string to_smt2(char const *status="unknown")
Definition z3++.h:3267
solver(context &c)
Definition z3++.h:3117
param_descrs get_param_descrs()
Definition z3++.h:3289
void set(char const *k, unsigned v)
Definition z3++.h:3135
void add(expr_vector const &v)
Definition z3++.h:3161
expr_vector assertions() const
Definition z3++.h:3200
void from_file(char const *file)
Definition z3++.h:3166
expr_vector trail(array< unsigned > &levels) const
Definition z3++.h:3204
void reset()
Definition z3++.h:3151
void solve_for(expr_vector const &vars, expr_vector &terms, expr_vector &guards)
Definition z3++.h:3244
std::string reason_unknown() const
Definition z3++.h:3197
void set(params const &p)
Definition z3++.h:3133
expr_vector cube(expr_vector &vars, unsigned cutoff)
Definition z3++.h:3292
cube_generator cubes()
Definition z3++.h:3379
expr_vector unsat_core() const
Definition z3++.h:3199
expr congruence_root(expr const &t) const
Definition z3++.h:3214
solver(solver const &s)
Definition z3++.h:3122
void set(char const *k, symbol const &v)
Definition z3++.h:3137
check_result check(expr_vector const &assumptions)
Definition z3++.h:3180
A Z3 sort (aka type). Every expression (i.e., formula or term) in Z3 has a sort.
Definition z3++.h:808
sort(context &c, Z3_sort s)
Definition z3++.h:811
func_decl_vector constructors()
Definition z3++.h:4687
Z3_sort_kind sort_kind() const
Return the internal sort kind.
Definition z3++.h:823
unsigned bv_size() const
Return the size of this Bit-vector sort.
Definition z3++.h:885
bool is_int() const
Return true if this sort is the Integer sort.
Definition z3++.h:835
sort(context &c)
Definition z3++.h:810
bool is_real() const
Return true if this sort is the Real sort.
Definition z3++.h:839
sort(context &c, Z3_ast a)
Definition z3++.h:812
friend std::ostream & operator<<(std::ostream &out, sort const &s)
Definition z3++.h:903
func_decl_vector recognizers()
Definition z3++.h:4696
symbol name() const
Return name of sort.
Definition z3++.h:827
bool is_relation() const
Return true if this sort is a Relation sort.
Definition z3++.h:861
unsigned fpa_ebits() const
Definition z3++.h:887
bool is_complex() const
Return true if this sort is Complex.
Definition z3++.h:841
sort array_range() const
Return the range of this Array sort.
Definition z3++.h:901
bool is_bool() const
Return true if this sort is the Boolean sort.
Definition z3++.h:831
bool is_arith() const
Return true if this sort is Integer, Real, or Complex.
Definition z3++.h:845
bool is_bv() const
Return true if this sort is a Bit-vector sort.
Definition z3++.h:849
sort array_domain() const
Return the domain of this Array sort.
Definition z3++.h:895
bool is_finite_domain() const
Definition z3++.h:874
bool is_datatype() const
Return true if this sort is a Datatype sort.
Definition z3++.h:857
bool is_re() const
Return true if this sort is a regular expression sort.
Definition z3++.h:869
unsigned id() const
retrieve unique identifier for func_decl.
Definition z3++.h:818
bool is_finite_field() const
Return true if this sort is a Finite domain sort.
Definition z3++.h:873
bool is_array() const
Return true if this sort is a Array sort.
Definition z3++.h:853
bool is_seq() const
Return true if this sort is a Sequence sort.
Definition z3++.h:865
unsigned fpa_sbits() const
Definition z3++.h:889
bool is_fpa() const
Return true if this sort is a Floating point sort.
Definition z3++.h:878
stats & operator=(stats const &s)
Definition z3++.h:3044
unsigned size() const
Definition z3++.h:3051
bool is_uint(unsigned i) const
Definition z3++.h:3053
bool is_double(unsigned i) const
Definition z3++.h:3054
~stats() override
Definition z3++.h:3042
stats(stats const &s)
Definition z3++.h:3041
double double_value(unsigned i) const
Definition z3++.h:3056
unsigned uint_value(unsigned i) const
Definition z3++.h:3055
stats(context &c, Z3_stats e)
Definition z3++.h:3040
friend std::ostream & operator<<(std::ostream &out, stats const &s)
Definition z3++.h:3059
std::string key(unsigned i) const
Definition z3++.h:3052
stats(context &c)
Definition z3++.h:3039
Z3_symbol_kind kind() const
Definition z3++.h:578
symbol(context &c, Z3_symbol s)
Definition z3++.h:576
int to_int() const
Definition z3++.h:580
friend std::ostream & operator<<(std::ostream &out, symbol const &s)
Definition z3++.h:584
std::string str() const
Definition z3++.h:579
friend tactic par_or(unsigned n, tactic const *tactics)
Definition z3++.h:3538
friend tactic par_and_then(tactic const &t1, tactic const &t2)
Definition z3++.h:3547
std::string help() const
Definition z3++.h:3497
solver mk_solver() const
Definition z3++.h:3487
tactic(context &c, char const *name)
Definition z3++.h:3475
tactic(context &c, Z3_tactic s)
Definition z3++.h:3476
friend tactic repeat(tactic const &t, unsigned max)
Definition z3++.h:3522
friend tactic with(tactic const &t, params const &p)
Definition z3++.h:3528
apply_result apply(goal const &g) const
Definition z3++.h:3488
friend tactic operator&(tactic const &t1, tactic const &t2)
Definition z3++.h:3508
friend tactic try_for(tactic const &t, unsigned ms)
Definition z3++.h:3533
param_descrs get_param_descrs()
Definition z3++.h:3505
~tactic() override
Definition z3++.h:3478
tactic & operator=(tactic const &s)
Definition z3++.h:3480
apply_result operator()(goal const &g) const
Definition z3++.h:3494
tactic(tactic const &s)
Definition z3++.h:3477
friend tactic operator|(tactic const &t1, tactic const &t2)
Definition z3++.h:3515
void register_decide(decide_eh_t &c)
Definition z3++.h:5006
bool propagate(expr_vector const &fixed, expr_vector const &lhs, expr_vector const &rhs, expr const &conseq)
Definition z3++.h:5094
void register_created(created_eh_t &c)
Definition z3++.h:4990
virtual ~user_propagator_base()
Definition z3++.h:4907
virtual void decide(expr const &, unsigned, bool)
Definition z3++.h:5038
virtual void eq(expr const &, expr const &)
Definition z3++.h:5032
void register_eq(eq_eh_t &f)
Definition z3++.h:4950
void add(expr const &e)
tracks e by a unique identifier that is returned by the call.
Definition z3++.h:5061
virtual void created(expr const &)
Definition z3++.h:5036
virtual void push()=0
void register_final(final_eh_t &f)
register a callback on final-check. During the final check stage, all propagations have been processe...
Definition z3++.h:4974
virtual void pop(unsigned num_scopes)=0
virtual bool on_binding(expr const &, expr const &)
Definition z3++.h:5040
virtual void fixed(expr const &, expr const &)
Definition z3++.h:5030
void conflict(expr_vector const &fixed)
Definition z3++.h:5070
bool propagate(expr_vector const &fixed, expr const &conseq)
Definition z3++.h:5087
user_propagator_base(solver *s)
Definition z3++.h:4900
virtual user_propagator_base * fresh(context &ctx)=0
user_propagators created using fresh() are created during search and their lifetimes are restricted t...
user_propagator_base(context &c)
Definition z3++.h:4898
void conflict(expr_vector const &fixed, expr_vector const &lhs, expr_vector const &rhs)
Definition z3++.h:5077
bool next_split(expr const &e, unsigned idx, Z3_lbool phase)
Definition z3++.h:5042
void register_fixed(fixed_eh_t &f)
register callbacks. Callbacks can only be registered with user_propagators that were created using a ...
Definition z3++.h:4934
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.
void Z3_API Z3_solver_propagate_on_binding(Z3_context c, Z3_solver s, Z3_on_binding_eh on_binding_eh)
register a callback when the solver instantiates a quantifier. If the callback returns false,...
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_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_ast_kind
The different kinds of Z3 AST (abstract syntax trees). That is, terms, formulas and types.
Definition z3_api.h:144
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_sort Z3_API Z3_mk_int_sort(Z3_context c)
Create the integer type.
Z3_simplifier Z3_API Z3_simplifier_and_then(Z3_context c, Z3_simplifier t1, Z3_simplifier t2)
Return a simplifier that applies t1 to a given goal and t2 to every subgoal produced by t1.
Z3_ast Z3_API Z3_mk_fpa_is_infinite(Z3_context c, Z3_ast t)
Predicate indicating whether t is a floating-point number representing +oo or -oo.
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_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_ast Z3_API Z3_mk_bvxnor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise xnor.
Z3_string Z3_API Z3_get_error_msg(Z3_context c, Z3_error_code err)
Return a string describing the given error code.
Z3_parameter_kind Z3_API Z3_get_decl_parameter_kind(Z3_context c, Z3_func_decl d, unsigned idx)
Return the parameter type associated with a declaration.
bool Z3_API Z3_is_seq_sort(Z3_context c, Z3_sort s)
Check if s is a sequence sort.
Z3_ast Z3_API Z3_mk_bvnor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise nor.
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_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_decl_kind Z3_API Z3_get_decl_kind(Z3_context c, Z3_func_decl d)
Return declaration kind corresponding to declaration.
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_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_ast Z3_API Z3_mk_char_to_bv(Z3_context c, Z3_ast ch)
Create a bit-vector (code point) from character.
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.
void Z3_API Z3_ast_map_inc_ref(Z3_context c, Z3_ast_map m)
Increment the reference counter of the given AST map.
void Z3_API Z3_fixedpoint_inc_ref(Z3_context c, Z3_fixedpoint d)
Increment the reference counter of the given fixedpoint context.
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_ast Z3_API Z3_mk_const_array(Z3_context c, Z3_sort domain, Z3_ast v)
Create the constant array.
Z3_rcf_num Z3_API Z3_rcf_div(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return the value a / b.
void Z3_API Z3_simplifier_inc_ref(Z3_context c, Z3_simplifier t)
Increment the reference counter of the given simplifier.
unsigned Z3_API Z3_rcf_mk_roots(Z3_context c, unsigned n, Z3_rcf_num const a[], Z3_rcf_num roots[])
Store in roots the roots of the polynomial a[n-1]*x^{n-1} + ... + a[0]. The output vector roots must ...
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_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_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_sort Z3_API Z3_mk_char_sort(Z3_context c)
Create a sort for unicode characters.
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_ast Z3_API Z3_mk_re_option(Z3_context c, Z3_ast re)
Create the regular language [re].
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.
void Z3_API Z3_query_constructor(Z3_context c, Z3_constructor constr, unsigned num_fields, Z3_func_decl *constructor, Z3_func_decl *tester, Z3_func_decl accessors[])
Query constructor for declared functions.
Z3_func_decl Z3_API Z3_get_app_decl(Z3_context c, Z3_app a)
Return the declaration of a constant or function application.
void Z3_API Z3_optimize_set_initial_value(Z3_context c, Z3_optimize o, Z3_ast v, Z3_ast val)
provide an initialization hint to the solver. The initialization hint is used to calibrate an initial...
void Z3_API Z3_del_context(Z3_context c)
Delete the given logical context.
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_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_func_decl Z3_API Z3_get_decl_func_decl_parameter(Z3_context c, Z3_func_decl d, unsigned idx)
Return the expression value associated with an expression parameter.
Z3_goal_prec
Z3 custom error handler (See Z3_set_error_handler).
Definition z3_api.h:1466
Z3_ast Z3_API Z3_mk_fpa_to_fp_bv(Z3_context c, Z3_ast bv, Z3_sort s)
Conversion of a single IEEE 754-2008 bit-vector into a floating-point number.
Z3_ast Z3_API Z3_ast_map_find(Z3_context c, Z3_ast_map m, Z3_ast k)
Return the value associated with the key k.
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_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_ast_vector Z3_API Z3_polynomial_subresultants(Z3_context c, Z3_ast p, Z3_ast q, Z3_ast x)
Return the nonzero subresultants of p and q with respect to the "variable" x.
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,...
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_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_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_ast Z3_API Z3_mk_fpa_is_subnormal(Z3_context c, Z3_ast t)
Predicate indicating whether t is a subnormal floating-point number.
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_ast Z3_API Z3_mk_set_subset(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Check for subsetness of sets.
Z3_ast Z3_API Z3_simplify(Z3_context c, Z3_ast a)
Interface to simplifier.
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_ast Z3_API Z3_mk_fpa_to_ieee_bv(Z3_context c, Z3_ast t)
Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
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_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....
void Z3_API Z3_get_string_contents(Z3_context c, Z3_ast s, unsigned length, unsigned contents[])
Retrieve the unescaped string constant stored in s.
Z3_ast Z3_API Z3_mk_bvule(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned less than or equal to.
Z3_ast Z3_API Z3_mk_full_set(Z3_context c, Z3_sort domain)
Create the full set.
Z3_rcf_num Z3_API Z3_rcf_mk_rational(Z3_context c, Z3_string val)
Return a RCF rational using the given string.
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_ast Z3_API Z3_mk_ff_neg(Z3_context c, Z3_ast a)
Additive inverse in a prime field.
Z3_ast Z3_API Z3_mk_fpa_to_fp_signed(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a 2's complement signed bit-vector term into a term of FloatingPoint sort.
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_ast_vector Z3_API Z3_optimize_get_upper_as_vector(Z3_context c, Z3_optimize o, unsigned idx)
Retrieve upper bound value or approximation for the i'th optimization objective.
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_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_ast Z3_API Z3_mk_fpa_to_sbv(Z3_context c, Z3_ast rm, Z3_ast t, unsigned sz)
Conversion of a floating-point term into a signed bit-vector.
Z3_ast Z3_API Z3_mk_true(Z3_context c)
Create an AST node representing true.
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_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_model Z3_API Z3_optimize_get_model(Z3_context c, Z3_optimize o)
Retrieve the model for the last Z3_optimize_check.
Z3_ast Z3_API Z3_mk_finite_set_empty(Z3_context c, Z3_sort set_sort)
Create an empty finite set of the given sort.
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 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_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_decl_kind
The different kinds of interpreted function kinds.
Definition z3_api.h:998
void Z3_API Z3_parser_context_add_decl(Z3_context c, Z3_parser_context pc, Z3_func_decl f)
Add a function declaration.
unsigned Z3_API Z3_get_arity(Z3_context c, Z3_func_decl d)
Alias for Z3_get_domain_size.
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_ast Z3_API Z3_mk_bvxor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise exclusive-or.
Z3_string Z3_API Z3_stats_to_string(Z3_context c, Z3_stats s)
Convert a statistics into a string.
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_sort Z3_API Z3_mk_real_sort(Z3_context c)
Create the real type.
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_ast Z3_API Z3_mk_le(Z3_context c, Z3_ast t1, Z3_ast t2)
Create less than or equal to.
Z3_string Z3_API Z3_simplifier_get_help(Z3_context c, Z3_simplifier t)
Return a string containing a description of parameters accepted by the given simplifier.
bool Z3_API Z3_goal_inconsistent(Z3_context c, Z3_goal g)
Return true if the given goal contains the formula false.
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_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....
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.
void Z3_API Z3_solver_dec_ref(Z3_context c, Z3_solver s)
Decrement the reference counter of the given solver.
Z3_ast Z3_API Z3_mk_bvslt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed less than.
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.
bool Z3_API Z3_ast_map_contains(Z3_context c, Z3_ast_map m, Z3_ast k)
Return true if the map m contains the AST key k.
Z3_ast Z3_API Z3_mk_seq_length(Z3_context c, Z3_ast s)
Return the length of the sequence s.
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.
Z3_ast Z3_API Z3_mk_finite_set_difference(Z3_context c, Z3_ast s1, Z3_ast s2)
Create the set difference of two finite sets.
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_ast Z3_API Z3_simplify_ex(Z3_context c, Z3_ast a, Z3_params p)
Interface to simplifier.
Z3_rcf_num Z3_API Z3_rcf_add(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return the value a + b.
Z3_symbol Z3_API Z3_get_decl_symbol_parameter(Z3_context c, Z3_func_decl d, unsigned idx)
Return the double value associated with an double parameter.
void Z3_API Z3_solver_from_string(Z3_context c, Z3_solver s, Z3_string str)
load solver assertions from a string.
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_ast Z3_API Z3_mk_unary_minus(Z3_context c, Z3_ast arg)
Create an AST node representing - arg.
Z3_ast Z3_API Z3_mk_fpa_rna(Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
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_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_ast Z3_API Z3_mk_finite_set_subset(Z3_context c, Z3_ast s1, Z3_ast s2)
Check if one finite set is a subset of another.
void Z3_API Z3_simplifier_dec_ref(Z3_context c, Z3_simplifier g)
Decrement the reference counter of the given simplifier.
void Z3_API Z3_interrupt(Z3_context c)
Interrupt the execution of a Z3 procedure. This procedure can be used to interrupt: solvers,...
Z3_ast Z3_API Z3_mk_str_to_int(Z3_context c, Z3_ast s)
Convert string to integer.
Z3_ast Z3_API Z3_mk_fpa_sub(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2)
Floating-point subtraction.
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_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_sort Z3_API Z3_mk_polymorphic_datatype(Z3_context c, Z3_symbol name, unsigned num_parameters, Z3_sort parameters[], unsigned num_constructors, Z3_constructor constructors[])
Create a parametric datatype with explicit type parameters.
Z3_ast Z3_API Z3_func_entry_get_value(Z3_context c, Z3_func_entry e)
Return the value of this point.
bool Z3_API Z3_is_quantifier_exists(Z3_context c, Z3_ast a)
Determine if ast is an existential quantifier.
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_sort Z3_API Z3_mk_uninterpreted_sort(Z3_context c, Z3_symbol s)
Create a free (uninterpreted) type using the given name (symbol).
void Z3_API Z3_optimize_pop(Z3_context c, Z3_optimize d)
Backtrack one level.
Z3_ast Z3_API Z3_mk_fpa_is_normal(Z3_context c, Z3_ast t)
Predicate indicating whether t is a normal floating-point number.
Z3_ast Z3_API Z3_mk_false(Z3_context c)
Create an AST node representing false.
Z3_sort Z3_API Z3_mk_datatype(Z3_context c, Z3_symbol name, unsigned num_constructors, Z3_constructor constructors[])
Create datatype, such as lists, trees, records, enumerations or unions of records....
Z3_ast_vector Z3_API Z3_ast_map_keys(Z3_context c, Z3_ast_map m)
Return the keys stored in the given map.
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_ast Z3_API Z3_mk_fpa_to_ubv(Z3_context c, Z3_ast rm, Z3_ast t, unsigned sz)
Conversion of a floating-point term into an unsigned bit-vector.
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_ast Z3_API Z3_mk_bvmul(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement multiplication.
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_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,...
void Z3_API Z3_del_constructor(Z3_context c, Z3_constructor constr)
Reclaim memory allocated to constructor.
Z3_ast Z3_API Z3_mk_bvsgt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed greater than.
Z3_string Z3_API Z3_ast_to_string(Z3_context c, Z3_ast a)
Convert the given AST node into a string.
Z3_ast Z3_API Z3_mk_re_complement(Z3_context c, Z3_ast re)
Create the complement of the regular language re.
bool Z3_API Z3_rcf_eq(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a == b.
Z3_ast_vector Z3_API Z3_fixedpoint_get_assertions(Z3_context c, Z3_fixedpoint f)
Retrieve set of background assertions from fixedpoint context.
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....
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_ast_vector Z3_API Z3_solver_get_assertions(Z3_context c, Z3_solver s)
Return the set of asserted formulas on the solver.
Z3_string Z3_API Z3_get_full_version(void)
Return a string that fully describes the version of Z3 in use.
void Z3_API Z3_enable_trace(Z3_string tag)
Enable tracing messages tagged as tag when Z3 is compiled in debug mode. It is a NOOP otherwise.
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_ast Z3_API Z3_mk_set_complement(Z3_context c, Z3_ast arg)
Take the complement of a set.
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.
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_ast Z3_API Z3_mk_fpa_rtn(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardNegative rounding mode.
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 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...
bool Z3_API Z3_rcf_lt(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a < b.
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_ast Z3_API Z3_mk_mod(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create an AST node representing arg1 mod arg2.
Z3_ast Z3_API Z3_mk_bvredand(Z3_context c, Z3_ast t1)
Take conjunction of bits in vector, return vector of length 1.
Z3_ast Z3_API Z3_mk_set_add(Z3_context c, Z3_ast set, Z3_ast elem)
Add an element to a set.
Z3_ast Z3_API Z3_mk_ge(Z3_context c, Z3_ast t1, Z3_ast t2)
Create greater than or equal to.
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_ast Z3_API Z3_mk_fpa_rtp(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardPositive rounding mode.
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_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.
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.
bool Z3_API Z3_solver_propagate_consequence(Z3_context c, Z3_solver_callback cb, unsigned num_fixed, Z3_ast const *fixed, unsigned num_eqs, Z3_ast const *eq_lhs, Z3_ast const *eq_rhs, Z3_ast conseq)
propagate a consequence based on fixed values and equalities. A client may invoke it during the pro...
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_ast_vector Z3_API Z3_optimize_get_lower_as_vector(Z3_context c, Z3_optimize o, unsigned idx)
Retrieve lower bound value or approximation for the i'th optimization objective. The returned vector ...
Z3_rcf_num Z3_API Z3_rcf_inv(Z3_context c, Z3_rcf_num a)
Return the value 1/a.
Z3_ast Z3_API Z3_mk_array_default(Z3_context c, Z3_ast array)
Access the array default value. Produces the default range value, for arrays that can be represented ...
Z3_ast Z3_API Z3_datatype_update_field(Z3_context c, Z3_func_decl field_access, Z3_ast t, Z3_ast value)
Update record field with a value.
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.
unsigned Z3_API Z3_model_get_num_sorts(Z3_context c, Z3_model m)
Return the number of uninterpreted sorts that m assigns an interpretation to.
Z3_param_kind
The different kinds of parameters that can be associated with parameter sets. (see Z3_mk_params).
Definition z3_api.h:1369
bool Z3_API Z3_rcf_gt(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a > b.
const char * Z3_string
Z3 string type. It is just an alias for const char *.
Definition z3_api.h:50
void Z3_API Z3_parser_context_dec_ref(Z3_context c, Z3_parser_context pc)
Decrement the reference counter of the given Z3_parser_context object.
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_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_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.
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_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_sort_kind
The different kinds of Z3 types (See Z3_get_sort_kind).
Definition z3_api.h:110
void Z3_API Z3_solver_push(Z3_context c, Z3_solver s)
Create a backtracking point.
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_rcf_num Z3_API Z3_rcf_sub(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return the value a - b.
Z3_ast Z3_API Z3_mk_fpa_max(Z3_context c, Z3_ast t1, Z3_ast t2)
Maximum of floating-point numbers.
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.
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_app Z3_API Z3_to_app(Z3_context c, Z3_ast a)
Convert an ast into an APP_AST. This is just type casting.
Z3_ast Z3_API Z3_mk_bvudiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned division.
Z3_string Z3_API Z3_ast_vector_to_string(Z3_context c, Z3_ast_vector v)
Convert AST vector into a string.
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...
bool Z3_API Z3_rcf_le(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a <= b.
Z3_ast Z3_API Z3_mk_bvshl(Z3_context c, Z3_ast t1, Z3_ast t2)
Shift left.
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_ast Z3_API Z3_mk_finite_set_filter(Z3_context c, Z3_ast f, Z3_ast set)
Filter a finite set using a predicate.
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_ast Z3_API Z3_solver_congruence_next(Z3_context c, Z3_solver s, Z3_ast a)
retrieve the next expression in the congruence class. The set of congruent siblings form a cyclic lis...
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.
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_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_ast Z3_API Z3_mk_is_int(Z3_context c, Z3_ast t1)
Check if a real number is an integer.
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.
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.
bool Z3_API Z3_rcf_is_infinitesimal(Z3_context c, Z3_rcf_num a)
Return true if a represents an infinitesimal.
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_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_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_ast Z3_API Z3_mk_seq_unit(Z3_context c, Z3_ast a)
Create a unit sequence of a.
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_ast Z3_API Z3_mk_finite_set_member(Z3_context c, Z3_ast elem, Z3_ast set)
Check if an element is a member of a finite set.
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_ast Z3_API Z3_mk_u32string(Z3_context c, unsigned len, unsigned const chars[])
Create a string constant out of the string that is passed in It takes the length of the string as wel...
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.
unsigned Z3_API Z3_goal_size(Z3_context c, Z3_goal g)
Return the number of formulas in the given goal.
Z3_func_decl Z3_API Z3_solver_propagate_declare(Z3_context c, Z3_symbol name, unsigned n, Z3_sort *domain, Z3_sort range)
void Z3_API Z3_stats_inc_ref(Z3_context c, Z3_stats s)
Increment the reference counter of the given statistics object.
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_ast_vector Z3_API Z3_algebraic_get_poly(Z3_context c, Z3_ast a)
Return the coefficients of the defining polynomial.
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_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_sort Z3_API Z3_mk_re_sort(Z3_context c, Z3_sort seq)
Create a regular expression sort out of a sequence sort.
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.
void Z3_API Z3_optimize_inc_ref(Z3_context c, Z3_optimize d)
Increment the reference counter of the given optimize context.
void Z3_API Z3_model_dec_ref(Z3_context c, Z3_model m)
Decrement the reference counter of the given model.
Z3_sort Z3_API Z3_mk_datatype_sort(Z3_context c, Z3_symbol name, unsigned num_params, Z3_sort const params[])
create a forward reference to a recursive datatype being declared. The forward reference can be used ...
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, bool negative)
Create a floating-point infinity of sort s.
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_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_rcf_num Z3_API Z3_rcf_mk_infinitesimal(Z3_context c)
Return a new infinitesimal that is smaller than all elements in the Z3 field.
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_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_ast Z3_API Z3_mk_finite_set_union(Z3_context c, Z3_ast s1, Z3_ast s2)
Create the union of two finite sets.
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_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.
int Z3_API Z3_get_symbol_int(Z3_context c, Z3_symbol s)
Return the symbol int value.
Z3_ast Z3_API Z3_mk_ext_rotate_left(Z3_context c, Z3_ast t1, Z3_ast t2)
Rotate bits of t1 to the left t2 times.
void Z3_API Z3_goal_inc_ref(Z3_context c, Z3_goal g)
Increment the reference counter of the given goal.
Z3_string Z3_API Z3_simplifier_get_descr(Z3_context c, Z3_string name)
Return a string containing a description of the simplifier with the given name.
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_ast Z3_API Z3_mk_implies(Z3_context c, Z3_ast t1, Z3_ast t2)
Create an AST node representing t1 implies t2.
Z3_ast Z3_API Z3_mk_fpa_nan(Z3_context c, Z3_sort s)
Create a floating-point NaN of sort s.
unsigned Z3_API Z3_get_datatype_sort_num_constructors(Z3_context c, Z3_sort t)
Return number of constructors for datatype.
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.
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_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_ast Z3_API Z3_mk_fpa_gt(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point greater than.
Z3_sort Z3_API Z3_model_get_sort(Z3_context c, Z3_model m, unsigned i)
Return a uninterpreted sort that m assigns an interpretation.
Z3_ast Z3_API Z3_mk_bvashr(Z3_context c, Z3_ast t1, Z3_ast t2)
Arithmetic shift right.
Z3_simplifier Z3_API Z3_simplifier_using_params(Z3_context c, Z3_simplifier t, Z3_params p)
Return a simplifier that applies t using the given set of parameters.
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_ast Z3_API Z3_mk_sbv_to_str(Z3_context c, Z3_ast s)
Signed bit-vector to string conversion.
void Z3_API Z3_solver_import_model_converter(Z3_context ctx, Z3_solver src, Z3_solver dst)
Ad-hoc method for importing model conversion from solver.
Z3_ast Z3_API Z3_mk_fpa_is_zero(Z3_context c, Z3_ast t)
Predicate indicating whether t is a floating-point number with zero value, i.e., +zero or -zero.
bool Z3_API Z3_rcf_ge(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a >= b.
Z3_ast Z3_API Z3_mk_set_del(Z3_context c, Z3_ast set, Z3_ast elem)
Remove an element to a set.
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_ast Z3_API Z3_mk_re_union(Z3_context c, unsigned n, Z3_ast const args[])
Create the union of the regular languages.
Z3_param_descrs Z3_API Z3_simplifier_get_param_descrs(Z3_context c, Z3_simplifier t)
Return the parameter description set for the given simplifier object.
void Z3_API Z3_optimize_set_params(Z3_context c, Z3_optimize o, Z3_params p)
Set parameters on optimization context, including parameters for the underlying SMT solver.
Z3_ast Z3_API Z3_mk_finite_set_intersect(Z3_context c, Z3_ast s1, Z3_ast s2)
Create the intersection of two finite sets.
Z3_ast Z3_API Z3_mk_bvor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise or.
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.
unsigned Z3_API Z3_get_num_simplifiers(Z3_context c)
Return the number of builtin simplifiers available in Z3.
Z3_func_decl Z3_API Z3_get_datatype_sort_constructor(Z3_context c, Z3_sort t, unsigned idx)
Return idx'th constructor.
void Z3_API Z3_ast_vector_resize(Z3_context c, Z3_ast_vector v, unsigned n)
Resize the AST vector v.
Z3_lbool
Lifted Boolean type: false, undefined, true.
Definition z3_api.h:58
Z3_ast Z3_API Z3_mk_seq_empty(Z3_context c, Z3_sort seq)
Create an empty sequence of the sequence sort seq.
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_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_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_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...
void Z3_API Z3_solver_set_initial_value(Z3_context c, Z3_solver s, Z3_ast v, Z3_ast val)
provide an initialization hint to the solver. The initialization hint is used to calibrate an initial...
bool Z3_API Z3_is_lambda(Z3_context c, Z3_ast a)
Determine if ast is a lambda expression.
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.
void Z3_API Z3_optimize_push(Z3_context c, Z3_optimize d)
Create a backtracking point.
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.
void Z3_API Z3_probe_inc_ref(Z3_context c, Z3_probe p)
Increment the reference counter of the given probe.
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_ast Z3_API Z3_mk_fpa_eq(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point equality.
void Z3_API Z3_solver_propagate_register_cb(Z3_context c, Z3_solver_callback cb, Z3_ast e)
register an expression to propagate on with the solver. Only expressions of type Bool and type Bit-Ve...
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...
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....
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_string Z3_API Z3_sort_to_string(Z3_context c, Z3_sort s)
Z3_ast Z3_API Z3_mk_bvadd(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement addition.
unsigned Z3_API Z3_algebraic_get_i(Z3_context c, Z3_ast a)
Return which root of the polynomial the algebraic number represents.
void Z3_API Z3_params_dec_ref(Z3_context c, Z3_params p)
Decrement the reference counter of the given parameter set.
void Z3_API Z3_fixedpoint_dec_ref(Z3_context c, Z3_fixedpoint d)
Decrement the reference counter of the given fixedpoint context.
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_ast Z3_API Z3_solver_congruence_root(Z3_context c, Z3_solver s, Z3_ast a)
retrieve the congruence closure root of an expression. The root is retrieved relative to the state wh...
Z3_string Z3_API Z3_model_to_string(Z3_context c, Z3_model m)
Convert the given model into a string.
unsigned Z3_API Z3_get_string_length(Z3_context c, Z3_ast s)
Retrieve the length of the unescaped string constant stored in s.
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.
void Z3_API Z3_solver_propagate_final(Z3_context c, Z3_solver s, Z3_final_eh final_eh)
register a callback on final check. This provides freedom to the propagator to delay actions or imple...
unsigned Z3_API Z3_ast_map_size(Z3_context c, Z3_ast_map m)
Return the size of the given map.
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_parameter_kind
The different kinds of parameters that can be associated with function symbols.
Definition z3_api.h:94
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_ast Z3_API Z3_mk_fpa_geq(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point greater than or equal.
Z3_ast Z3_API Z3_mk_bit2bool(Z3_context c, unsigned i, Z3_ast t1)
Extracts the bit at position i of a bit-vector and yields a boolean.
void Z3_API Z3_solver_register_on_clause(Z3_context c, Z3_solver s, void *user_context, Z3_on_clause_eh on_clause_eh)
register a callback to that retrieves assumed, inferred and deleted clauses during search.
Z3_string Z3_API Z3_goal_to_dimacs_string(Z3_context c, Z3_goal g, bool include_names)
Convert a goal into a DIMACS formatted string. The goal must be in CNF. You can convert a goal to CNF...
Z3_ast Z3_API Z3_mk_lt(Z3_context c, Z3_ast t1, Z3_ast t2)
Create less than.
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 Z3_API Z3_mk_fpa_numeral_float(Z3_context c, float v, Z3_sort ty)
Create an expression of FloatingPoint sort from three bit-vector expressions.
Z3_ast Z3_API Z3_mk_bvugt(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned greater than.
Z3_lbool Z3_API Z3_fixedpoint_query(Z3_context c, Z3_fixedpoint d, Z3_ast query)
Pose a query against the asserted rules.
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_ast Z3_API Z3_update_term(Z3_context c, Z3_ast a, unsigned num_args, Z3_ast const args[])
Update the arguments of term a using the arguments args. The number of arguments num_args should coin...
Z3_ast Z3_API Z3_mk_fpa_rtz(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardZero rounding mode.
Z3_string Z3_API Z3_get_symbol_string(Z3_context c, Z3_symbol s)
Return the symbol name.
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_simplifier Z3_API Z3_mk_simplifier(Z3_context c, Z3_string name)
Return a simplifier associated with the given name. The complete list of simplifiers may be obtained ...
Z3_ast Z3_API Z3_mk_bvnot(Z3_context c, Z3_ast t1)
Bitwise negation.
Z3_ast Z3_API Z3_mk_bvurem(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned remainder.
Z3_ast Z3_API Z3_mk_seq_foldli(Z3_context c, Z3_ast f, Z3_ast i, Z3_ast a, Z3_ast s)
Create a fold with index tracking of the function f over the sequence s with accumulator a starting a...
void Z3_API Z3_mk_datatypes(Z3_context c, unsigned num_sorts, Z3_symbol const sort_names[], Z3_sort sorts[], Z3_constructor_list constructor_lists[])
Create mutually recursive datatypes.
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_ast Z3_API Z3_mk_seq_to_re(Z3_context c, Z3_ast seq)
Create a regular expression that accepts the sequence seq.
Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement subtraction.
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_ast Z3_API Z3_mk_seq_index(Z3_context c, Z3_ast s, Z3_ast substr, Z3_ast offset)
Return index of the first occurrence of substr in s starting from offset offset. If s does not contai...
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_ast Z3_API Z3_mk_power(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create an AST node representing arg1 ^ arg2.
Z3_ast Z3_API Z3_mk_seq_concat(Z3_context c, unsigned n, Z3_ast const args[])
Concatenate sequences.
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_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.
unsigned Z3_API Z3_get_bv_sort_size(Z3_context c, Z3_sort t)
Return the size of the given bit-vector sort.
Z3_ast_vector Z3_API Z3_fixedpoint_get_rules(Z3_context c, Z3_fixedpoint f)
Retrieve set of rules from fixedpoint context.
Z3_ast Z3_API Z3_mk_ff_add(Z3_context c, unsigned n, Z3_ast const args[])
Sum at least two elements of the same prime field.
Z3_ast Z3_API Z3_mk_set_member(Z3_context c, Z3_ast elem, Z3_ast set)
Check for set membership.
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_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.
void Z3_API Z3_goal_reset(Z3_context c, Z3_goal g)
Erase all formulas from the given goal.
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.
void Z3_API Z3_probe_dec_ref(Z3_context c, Z3_probe p)
Decrement the reference counter of the given probe.
void Z3_API Z3_params_inc_ref(Z3_context c, Z3_params p)
Increment the reference counter of the given parameter set.
void Z3_API Z3_set_error_handler(Z3_context c, Z3_error_handler h)
Register a Z3 error handler.
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_string Z3_API Z3_rcf_num_to_decimal_string(Z3_context c, Z3_rcf_num a, unsigned prec)
Convert the RCF numeral into a string in decimal notation.
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_config Z3_API Z3_mk_config(void)
Create a configuration object for the Z3 context object.
void Z3_API Z3_set_param_value(Z3_config c, Z3_string param_id, Z3_string param_value)
Set a configuration parameter.
Z3_rcf_num Z3_API Z3_rcf_power(Z3_context c, Z3_rcf_num a, unsigned k)
Return the value a^k.
Z3_ast Z3_API Z3_solver_congruence_explain(Z3_context c, Z3_solver s, Z3_ast a, Z3_ast b)
retrieve explanation for congruence.
Z3_sort Z3_API Z3_mk_bv_sort(Z3_context c, unsigned sz)
Create a bit-vector type of the given size.
Z3_ast Z3_API Z3_mk_fpa_rem(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point remainder.
Z3_ast Z3_API Z3_mk_bvult(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned less than.
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.
void Z3_API Z3_ast_map_dec_ref(Z3_context c, Z3_ast_map m)
Decrement the reference counter of the given AST map.
Z3_fixedpoint Z3_API Z3_mk_fixedpoint(Z3_context c)
Create a new fixedpoint context.
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_param_descrs Z3_API Z3_get_global_param_descrs(Z3_context c)
Retrieve description of global parameters.
void Z3_API Z3_solver_propagate_init(Z3_context c, Z3_solver s, void *user_context, Z3_push_eh push_eh, Z3_pop_eh pop_eh, Z3_fresh_eh fresh_eh)
register a user-propagator with the solver.
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.
void Z3_API Z3_tactic_dec_ref(Z3_context c, Z3_tactic g)
Decrement the reference counter of the given tactic.
Z3_ast Z3_API Z3_mk_bvnand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise nand.
Z3_solver Z3_API Z3_mk_simple_solver(Z3_context c)
Create a new incremental solver.
Z3_sort Z3_API Z3_get_range(Z3_context c, Z3_func_decl d)
Return the range of the given declaration.
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.
void Z3_API Z3_optimize_assert(Z3_context c, Z3_optimize o, Z3_ast a)
Assert hard constraint to the optimization context.
Z3_ast_vector Z3_API Z3_model_get_sort_universe(Z3_context c, Z3_model m, Z3_sort s)
Return the finite set of distinct values that represent the interpretation for sort s.
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_ast Z3_API Z3_mk_re_star(Z3_context c, Z3_ast re)
Create the regular language re*.
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.
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.
unsigned Z3_API Z3_stats_size(Z3_context c, Z3_stats s)
Return the number of statistical data in s.
Z3_string Z3_API Z3_optimize_to_string(Z3_context c, Z3_optimize o)
Print the current context as a string.
Z3_ast Z3_API Z3_get_quantifier_body(Z3_context c, Z3_ast a)
Return body of quantifier.
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_ast Z3_API Z3_mk_re_full(Z3_context c, Z3_sort re)
Create an universal regular expression of sort re.
Z3_ast Z3_API Z3_mk_fpa_min(Z3_context c, Z3_ast t1, Z3_ast t2)
Minimum of floating-point numbers.
Z3_model Z3_API Z3_mk_model(Z3_context c)
Create a fresh model object. It has reference count 0.
Z3_symbol Z3_API Z3_get_decl_name(Z3_context c, Z3_func_decl d)
Return the constant declaration name as a symbol.
Z3_ast Z3_API Z3_mk_seq_mapi(Z3_context c, Z3_ast f, Z3_ast i, Z3_ast s)
Create a map of the function f over the sequence s starting at index i.
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_ast Z3_API Z3_mk_fpa_round_to_integral(Z3_context c, Z3_ast rm, Z3_ast t)
Floating-point roundToIntegral. Rounds a floating-point number to the closest integer,...
Z3_rcf_num Z3_API Z3_rcf_mk_small_int(Z3_context c, int val)
Return a RCF small integer.
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_ast Z3_API Z3_mk_re_diff(Z3_context c, Z3_ast re1, Z3_ast re2)
Create the difference of regular expressions.
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_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_sort Z3_API Z3_mk_complex_sort(Z3_context c)
Create the Complex sort. Complex numbers are pairs of Reals.
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:72
Z3_ast Z3_API Z3_mk_re_empty(Z3_context c, Z3_sort re)
Create an empty regular expression of sort re.
Z3_ast Z3_API Z3_mk_fpa_add(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2)
Floating-point addition.
Z3_ast Z3_API Z3_mk_bvand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise and.
Z3_param_descrs Z3_API Z3_simplify_get_param_descrs(Z3_context c)
Return the parameter description set for the simplify procedure.
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_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_ast_kind Z3_API Z3_get_ast_kind(Z3_context c, Z3_ast a)
Return the kind of the given AST.
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_ast Z3_API Z3_mk_bvsmod(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed remainder (sign follows divisor).
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_model Z3_API Z3_model_translate(Z3_context c, Z3_model m, Z3_context dst)
translate model from context c to context dst.
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.
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...
void Z3_API Z3_get_version(unsigned *major, unsigned *minor, unsigned *build_number, unsigned *revision_number)
Return Z3 version number information.
Z3_ast Z3_API Z3_fixedpoint_get_cover_delta(Z3_context c, Z3_fixedpoint d, int level, Z3_func_decl pred)
Z3_ast Z3_API Z3_mk_fpa_to_fp_unsigned(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a 2's complement unsigned bit-vector term into a term of FloatingPoint sort.
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.
void Z3_API Z3_solver_assert(Z3_context c, Z3_solver s, Z3_ast a)
Assert a constraint into the solver.
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_ast Z3_API Z3_mk_fpa_abs(Z3_context c, Z3_ast t)
Floating-point absolute value.
unsigned Z3_API Z3_ast_vector_size(Z3_context c, Z3_ast_vector v)
Return the size of the given AST vector.
Z3_optimize Z3_API Z3_mk_optimize(Z3_context c)
Create a new optimize context.
void Z3_API Z3_parser_context_add_sort(Z3_context c, Z3_parser_context pc, Z3_sort s)
Add a sort declaration.
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_sort Z3_API Z3_get_array_sort_range(Z3_context c, Z3_sort t)
Return the range of the given array sort.
void Z3_API Z3_del_constructor_list(Z3_context c, Z3_constructor_list clist)
Reclaim memory allocated for constructor list.
Z3_ast Z3_API Z3_mk_bound(Z3_context c, unsigned index, Z3_sort ty)
Create a variable.
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_ast Z3_API Z3_substitute_funs(Z3_context c, Z3_ast a, unsigned num_funs, Z3_func_decl const from[], Z3_ast const to[])
Substitute functions in from with new expressions in to.
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_error_code
Z3 error codes (See Z3_get_error_code).
Definition z3_api.h:1411
Z3_ast Z3_API Z3_mk_eq(Z3_context c, Z3_ast l, Z3_ast r)
Create an AST node representing l = r.
Z3_ast Z3_API Z3_mk_atleast(Z3_context c, unsigned num_args, Z3_ast const args[], unsigned k)
Pseudo-Boolean relations.
void Z3_API Z3_ast_vector_inc_ref(Z3_context c, Z3_ast_vector v)
Increment the reference counter of the given AST vector.
unsigned Z3_API Z3_model_get_num_funcs(Z3_context c, Z3_model m)
Return the number of function interpretations in the given model.
void Z3_API Z3_parser_context_inc_ref(Z3_context c, Z3_parser_context pc)
Increment the reference counter of the given Z3_parser_context object.
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_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_ast_vector Z3_API Z3_mk_ast_vector(Z3_context c)
Return an empty AST vector.
Z3_string Z3_API Z3_get_simplifier_name(Z3_context c, unsigned i)
Return the name of the idx simplifier.
void Z3_API Z3_optimize_dec_ref(Z3_context c, Z3_optimize d)
Decrement the reference counter of the given optimize context.
Z3_string Z3_API Z3_get_string(Z3_context c, Z3_ast s)
Retrieve the string constant stored in s. Characters outside the basic printable ASCII range are esca...
Z3_ast Z3_API Z3_mk_fpa_is_nan(Z3_context c, Z3_ast t)
Predicate indicating whether t is a NaN.
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_string Z3_API Z3_rcf_num_to_string(Z3_context c, Z3_rcf_num a, bool compact, bool html)
Convert the RCF numeral into a string.
Z3_error_code Z3_API Z3_get_error_code(Z3_context c)
Return the error code for the last API call.
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_ast Z3_API Z3_mk_empty_set(Z3_context c, Z3_sort domain)
Create the empty set.
bool Z3_API Z3_rcf_neq(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a != b.
void Z3_API Z3_solver_solve_for(Z3_context c, Z3_solver s, Z3_ast_vector variables, Z3_ast_vector terms, Z3_ast_vector guards)
retrieve a 'solution' for variables as defined by equalities in maintained by solvers....
bool Z3_API Z3_is_string(Z3_context c, Z3_ast s)
Determine if s is a string constant.
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_ast Z3_API Z3_mk_char_to_int(Z3_context c, Z3_ast ch)
Create an integer (code point) from character.
Z3_ast Z3_API Z3_mk_fpa_neg(Z3_context c, Z3_ast t)
Floating-point negation.
Z3_ast Z3_API Z3_mk_ff_mul(Z3_context c, unsigned n, Z3_ast const args[])
Multiply at least two elements of the same prime field.
Z3_ast Z3_API Z3_mk_repeat(Z3_context c, unsigned i, Z3_ast t1)
Repeat the given bit-vector up length i.
void Z3_API Z3_rcf_del(Z3_context c, Z3_rcf_num a)
Delete a RCF numeral created using the RCF API.
Z3_ast Z3_API Z3_mk_re_plus(Z3_context c, Z3_ast re)
Create the regular language re+.
Z3_sort Z3_API Z3_mk_finite_field_sort(Z3_context c, Z3_string prime)
Create a prime-field sort. Large moduli undergo probable-prime screening.
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...
void Z3_API Z3_solver_pop(Z3_context c, Z3_solver s, unsigned n)
Backtrack n backtracking points.
void Z3_API Z3_ast_map_erase(Z3_context c, Z3_ast_map m, Z3_ast k)
Erase a key from the map.
Z3_ast Z3_API Z3_mk_int2real(Z3_context c, Z3_ast t1)
Coerce an integer to a real.
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...
double Z3_API Z3_get_decl_double_parameter(Z3_context c, Z3_func_decl d, unsigned idx)
Return the double value associated with an double parameter.
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 but two different AST objects can m...
Z3_ast Z3_API Z3_mk_fpa_lt(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point less than.
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_rcf_num Z3_API Z3_rcf_mk_pi(Z3_context c)
Return Pi.
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_symbol Z3_API Z3_get_sort_name(Z3_context c, Z3_sort d)
Return the sort name as a symbol.
Z3_func_decl Z3_API Z3_get_datatype_sort_recognizer(Z3_context c, Z3_sort t, unsigned idx)
Return idx'th recognizer.
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_ast Z3_API Z3_mk_gt(Z3_context c, Z3_ast t1, Z3_ast t2)
Create greater than.
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_ast Z3_API Z3_mk_store(Z3_context c, Z3_ast a, Z3_ast i, Z3_ast v)
Array update.
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_ast Z3_API Z3_mk_complex(Z3_context c, Z3_ast re, Z3_ast im)
Create a complex number with the given real and imaginary components. Integer components are coerced ...
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_string Z3_API Z3_get_decl_rational_parameter(Z3_context c, Z3_func_decl d, unsigned idx)
Return the rational value, as a string, associated with a rational parameter.
unsigned Z3_API Z3_optimize_minimize(Z3_context c, Z3_optimize o, Z3_ast t)
Add a minimization constraint.
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.
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.
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.
bool Z3_API Z3_is_eq_ast(Z3_context c, Z3_ast t1, Z3_ast t2)
Compare terms.
bool Z3_API Z3_is_quantifier_forall(Z3_context c, Z3_ast a)
Determine if an ast is a universal quantifier.
void Z3_API Z3_tactic_inc_ref(Z3_context c, Z3_tactic t)
Increment the reference counter of the given tactic.
Z3_parser_context Z3_API Z3_mk_parser_context(Z3_context c)
Create a parser context.
Z3_ast Z3_API Z3_mk_real_int64(Z3_context c, int64_t num, int64_t den)
Create a real from a fraction of int64.
Z3_ast_map Z3_API Z3_mk_ast_map(Z3_context c)
Return an empty mapping from AST to AST.
void Z3_API Z3_solver_from_file(Z3_context c, Z3_solver s, Z3_string file_name)
load solver assertions from a file.
Z3_ast Z3_API Z3_mk_seq_last_index(Z3_context c, Z3_ast s, Z3_ast substr)
Return index of the last occurrence of substr in s. If s does not contain substr, then the value is -...
Z3_ast Z3_API Z3_mk_xor(Z3_context c, Z3_ast t1, Z3_ast t2)
Create an AST node representing t1 xor t2.
void Z3_API Z3_solver_propagate_eq(Z3_context c, Z3_solver s, Z3_eq_eh eq_eh)
register a callback on expression equalities.
Z3_ast Z3_API Z3_mk_string(Z3_context c, Z3_string s)
Create a string constant out of the string that is passed in The string may contain escape encoding f...
Z3_func_decl Z3_API Z3_mk_transitive_closure(Z3_context c, Z3_func_decl f)
create transitive closure of binary relation.
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_ast Z3_API Z3_mk_rotate_left(Z3_context c, unsigned i, Z3_ast t1)
Rotate bits of t1 to the left i times.
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_ast Z3_API Z3_mk_finite_set_singleton(Z3_context c, Z3_ast elem)
Create a singleton finite set.
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.
unsigned Z3_API Z3_optimize_maximize(Z3_context c, Z3_optimize o, Z3_ast t)
Add a maximization constraint.
Z3_ast_vector Z3_API Z3_solver_get_units(Z3_context c, Z3_solver s)
Return the set of units modulo model conversion.
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.
Z3_symbol Z3_API Z3_mk_string_symbol(Z3_context c, Z3_string s)
Create a Z3 symbol using a C string.
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_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_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...
void Z3_API Z3_stats_dec_ref(Z3_context c, Z3_stats s)
Decrement the reference counter of the given statistics object.
Z3_rcf_num Z3_API Z3_rcf_neg(Z3_context c, Z3_rcf_num a)
Return the value -a.
Z3_ast Z3_API Z3_mk_array_ext(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create array extensionality index given two arrays with the same sort. The meaning is given by the ax...
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_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_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.
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_ast Z3_API Z3_mk_seq_power(Z3_context c, Z3_ast s, Z3_ast n)
Create the sequence s concatenated n times with itself. The result is the empty sequence when n is no...
Z3_ast Z3_API Z3_mk_concat(Z3_context c, Z3_ast t1, Z3_ast t2)
Concatenate the given bit-vectors.
Z3_ast Z3_API Z3_mk_fpa_to_fp_float(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a FloatingPoint term into another term of different FloatingPoint sort.
Z3_sort Z3_API Z3_get_decl_sort_parameter(Z3_context c, Z3_func_decl d, unsigned idx)
Return the sort value associated with a sort parameter.
Z3_constructor_list Z3_API Z3_mk_constructor_list(Z3_context c, unsigned num_constructors, Z3_constructor const constructors[])
Create list of constructors.
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_ast Z3_API Z3_mk_fpa_leq(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point less than or equal.
Z3_ast Z3_API Z3_mk_finite_set_map(Z3_context c, Z3_ast f, Z3_ast set)
Apply a function to all elements of a finite set.
void Z3_API Z3_solver_propagate_created(Z3_context c, Z3_solver s, Z3_created_eh created_eh)
register a callback when a new expression with a registered function is used by the solver The regist...
bool Z3_API Z3_rcf_is_algebraic(Z3_context c, Z3_rcf_num a)
Return true if a represents an algebraic number.
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.
unsigned Z3_API Z3_get_sort_id(Z3_context c, Z3_sort s)
Return a unique identifier for s.
Z3_ast Z3_API Z3_mk_fpa_mul(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2)
Floating-point multiplication.
Z3_ast_vector Z3_API Z3_parser_context_from_string(Z3_context c, Z3_parser_context pc, Z3_string s)
Parse a string of SMTLIB2 commands. Return assertions.
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_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_stats Z3_API Z3_solver_get_statistics(Z3_context c, Z3_solver s)
Return statistics for the given solver.
Z3_ast Z3_API Z3_mk_bvneg(Z3_context c, Z3_ast t1)
Standard two's complement unary minus.
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_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_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_string Z3_API Z3_fixedpoint_get_help(Z3_context c, Z3_fixedpoint f)
Return a string describing all fixedpoint available parameters.
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_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_sort Z3_API Z3_mk_bool_sort(Z3_context c)
Create the Boolean type.
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_sort Z3_API Z3_mk_finite_set_sort(Z3_context c, Z3_sort elem_sort)
Create a finite set sort.
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_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_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_ast Z3_API Z3_mk_imag_part(Z3_context c, Z3_ast z)
Return the imaginary component of a Complex expression.
Z3_ast Z3_API Z3_mk_finite_set_size(Z3_context c, Z3_ast set)
Get the size (cardinality) of a finite set.
unsigned Z3_API Z3_get_func_decl_id(Z3_context c, Z3_func_decl f)
Return a unique identifier for f.
Z3_ast Z3_API Z3_mk_set_difference(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Take the set difference between two sets.
void Z3_API Z3_solver_propagate_decide(Z3_context c, Z3_solver s, Z3_decide_eh decide_eh)
register a callback when the solver decides to split on a registered expression. The callback may cha...
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_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed division.
Z3_ast Z3_API Z3_mk_bvlshr(Z3_context c, Z3_ast t1, Z3_ast t2)
Logical shift right.
Z3_ast Z3_API Z3_get_decl_ast_parameter(Z3_context c, Z3_func_decl d, unsigned idx)
Return the expression value associated with an expression parameter.
Z3_ast Z3_API Z3_mk_finite_set_range(Z3_context c, Z3_ast low, Z3_ast high)
Create a finite set of integers in the range [low, high].
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....
bool Z3_API Z3_rcf_is_transcendental(Z3_context c, Z3_rcf_num a)
Return true if a represents a transcendental number.
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.
void Z3_API Z3_goal_dec_ref(Z3_context c, Z3_goal g)
Decrement the reference counter of the given goal.
Z3_ast Z3_API Z3_mk_not(Z3_context c, Z3_ast a)
Create an AST node representing not(a).
void Z3_API Z3_solver_propagate_register(Z3_context c, Z3_solver s, Z3_ast e)
register an expression to propagate on with the solver. Only expressions of type Bool and type Bit-Ve...
Z3_ast Z3_API Z3_substitute_vars(Z3_context c, Z3_ast a, unsigned num_exprs, Z3_ast const to[])
Substitute the variables in a with the expressions in to. For every i smaller than num_exprs,...
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_sort Z3_API Z3_mk_array_sort(Z3_context c, Z3_sort domain, Z3_sort range)
Create an array type.
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...
void Z3_API Z3_model_inc_ref(Z3_context c, Z3_model m)
Increment the reference counter of the given model.
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_ast Z3_API Z3_mk_fpa_div(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2)
Floating-point division.
Z3_sort Z3_API Z3_mk_fpa_sort(Z3_context c, unsigned ebits, unsigned sbits)
Create a FloatingPoint sort.
Z3_ast Z3_API Z3_mk_fpa_sqrt(Z3_context c, Z3_ast rm, Z3_ast t)
Floating-point square root.
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.
void Z3_API Z3_fixedpoint_set_params(Z3_context c, Z3_fixedpoint f, Z3_params p)
Set parameters on fixedpoint context.
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_solver Z3_API Z3_solver_add_simplifier(Z3_context c, Z3_solver solver, Z3_simplifier simplifier)
Attach simplifier to a solver. The solver will use the simplifier for incremental pre-processing.
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_ast Z3_API Z3_fixedpoint_get_answer(Z3_context c, Z3_fixedpoint d)
Retrieve a formula that encodes satisfying answers to the query.
Z3_ast Z3_API Z3_mk_int_to_str(Z3_context c, Z3_ast s)
Integer to string conversion.
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_string Z3_API Z3_get_numeral_string(Z3_context c, Z3_ast a)
Return numeral value, as a decimal string of a numeric constant term.
bool Z3_API Z3_rcf_is_rational(Z3_context c, Z3_rcf_num a)
Return true if a represents a rational number.
void Z3_API Z3_solver_propagate_fixed(Z3_context c, Z3_solver s, Z3_fixed_eh fixed_eh)
register a callback for when an expression is bound to a fixed value. The supported expression types ...
Z3_ast Z3_API Z3_mk_seq_map(Z3_context c, Z3_ast f, Z3_ast s)
Create a map of the function f over the sequence s.
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_ast Z3_API Z3_mk_char_is_digit(Z3_context c, Z3_ast ch)
Create a check if the character is a digit.
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...
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.
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 Z3_API Z3_mk_bvuge(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned greater than or equal to.
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_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_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_string Z3_API Z3_solver_to_string(Z3_context c, Z3_solver s)
Convert a solver into a string.
Z3_ast Z3_API Z3_mk_seq_foldl(Z3_context c, Z3_ast f, Z3_ast a, Z3_ast s)
Create a fold of the function f over the sequence s with accumulator a.
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_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_string Z3_API Z3_get_numeral_binary_string(Z3_context c, Z3_ast a)
Return numeral value, as a binary string of a numeric constant term.
Z3_rcf_num Z3_API Z3_rcf_mk_e(Z3_context c)
Return e (Euler's constant).
void Z3_API Z3_disable_trace(Z3_string tag)
Disable tracing messages tagged as tag when Z3 is compiled in debug mode. It is a NOOP otherwise.
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_ast Z3_API Z3_mk_real_part(Z3_context c, Z3_ast z)
Return the real component of a Complex expression.
Z3_ast Z3_API Z3_goal_formula(Z3_context c, Z3_goal g, unsigned idx)
Return a formula from the given goal.
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_symbol Z3_API Z3_mk_int_symbol(Z3_context c, int i)
Create a Z3 symbol using an integer.
Z3_ast Z3_API Z3_mk_char_from_bv(Z3_context c, Z3_ast bv)
Create a character from a bit-vector (code point).
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.
void Z3_API Z3_ast_map_insert(Z3_context c, Z3_ast_map m, Z3_ast k, Z3_ast v)
Store/Replace a new key, value pair in the given map.
Z3_probe Z3_API Z3_probe_const(Z3_context x, double val)
Return a probe that always evaluates to val.
Z3_constructor Z3_API Z3_mk_constructor(Z3_context c, Z3_symbol name, Z3_symbol recognizer, unsigned num_fields, Z3_symbol const field_names[], Z3_sort const sorts[], unsigned sort_refs[])
Create a constructor.
Z3_sort Z3_API Z3_mk_fpa_rounding_mode_sort(Z3_context c)
Create the RoundingMode sort.
Z3_string Z3_API Z3_goal_to_string(Z3_context c, Z3_goal g)
Convert a goal into a string.
Z3_ast Z3_API Z3_mk_fpa_rne(Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
Z3_ast Z3_API Z3_mk_atmost(Z3_context c, unsigned num_args, Z3_ast const args[], unsigned k)
Pseudo-Boolean relations.
void Z3_API Z3_del_config(Z3_config c)
Delete the given configuration object.
double Z3_API Z3_get_numeral_double(Z3_context c, Z3_ast a)
Return numeral as a double.
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_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_optimize Z3_API Z3_optimize_translate(Z3_context c, Z3_optimize o, Z3_context target)
Copy an optimization context from a source to a target context.
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...
void Z3_API Z3_solver_inc_ref(Z3_context c, Z3_solver s)
Increment the reference counter of the given solver.
bool Z3_API Z3_is_app(Z3_context c, Z3_ast a)
bool Z3_API Z3_solver_next_split(Z3_context c, Z3_solver_callback cb, Z3_ast t, unsigned idx, Z3_lbool phase)
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.
bool Z3_API Z3_is_re_sort(Z3_context c, Z3_sort s)
Check if s is a regular expression sort.
Z3_ast Z3_API Z3_mk_ubv_to_str(Z3_context c, Z3_ast s)
Unsigned bit-vector to string conversion.
Z3_sort Z3_API Z3_mk_string_sort(Z3_context c)
Create a sort for unicode strings.
Z3_ast Z3_API Z3_mk_ext_rotate_right(Z3_context c, Z3_ast t1, Z3_ast t2)
Rotate bits of t1 to the right t2 times.
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_rcf_num Z3_API Z3_rcf_mul(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return the value a * b.
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.
Z3_func_decl Z3_API Z3_get_datatype_sort_constructor_accessor(Z3_context c, Z3_sort t, unsigned idx_c, unsigned idx_a)
Return idx_a'th accessor for the idx_c'th constructor.
Z3_ast Z3_API Z3_mk_bvredor(Z3_context c, Z3_ast t1)
Take disjunction of bits in vector, return vector of length 1.
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_ast Z3_API Z3_mk_seq_contains(Z3_context c, Z3_ast container, Z3_ast containee)
Check if container contains containee.
void Z3_API Z3_ast_map_reset(Z3_context c, Z3_ast_map m)
Remove all keys from the given map.
void Z3_API Z3_solver_reset(Z3_context c, Z3_solver s)
Remove all assertions from the solver.
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_PRINT_SMTLIB2_COMPLIANT
Definition z3_api.h:1389
@ Z3_APP_AST
Definition z3_api.h:146
@ Z3_VAR_AST
Definition z3_api.h:147
@ Z3_SORT_AST
Definition z3_api.h:149
@ Z3_NUMERAL_AST
Definition z3_api.h:145
@ Z3_FUNC_DECL_AST
Definition z3_api.h:150
@ Z3_QUANTIFIER_AST
Definition z3_api.h:148
@ Z3_OP_DISTINCT
Definition z3_api.h:1003
@ Z3_OP_AND
Definition z3_api.h:1005
@ Z3_OP_FALSE
Definition z3_api.h:1001
@ Z3_OP_XOR
Definition z3_api.h:1008
@ Z3_OP_IMPLIES
Definition z3_api.h:1010
@ Z3_OP_ITE
Definition z3_api.h:1004
@ Z3_OP_EQ
Definition z3_api.h:1002
@ Z3_OP_OR
Definition z3_api.h:1006
@ Z3_OP_NOT
Definition z3_api.h:1009
@ Z3_OP_TRUE
Definition z3_api.h:1000
@ Z3_RELATION_SORT
Definition z3_api.h:118
@ Z3_BOOL_SORT
Definition z3_api.h:112
@ Z3_BV_SORT
Definition z3_api.h:115
@ Z3_DATATYPE_SORT
Definition z3_api.h:117
@ Z3_INT_SORT
Definition z3_api.h:113
@ Z3_FINITE_DOMAIN_SORT
Definition z3_api.h:119
@ Z3_COMPLEX_SORT
Definition z3_api.h:127
@ Z3_RE_SORT
Definition z3_api.h:123
@ Z3_FINITE_FIELD_SORT
Definition z3_api.h:126
@ Z3_FLOATING_POINT_SORT
Definition z3_api.h:120
@ Z3_ARRAY_SORT
Definition z3_api.h:116
@ Z3_REAL_SORT
Definition z3_api.h:114
@ Z3_SEQ_SORT
Definition z3_api.h:122
@ Z3_L_TRUE
Definition z3_api.h:61
@ Z3_L_FALSE
Definition z3_api.h:59
@ Z3_STRING_SYMBOL
Definition z3_api.h:74
@ Z3_INT_SYMBOL
Definition z3_api.h:73
@ Z3_OK
Definition z3_api.h:1412
Z3 C++ namespace.
Definition z3++.h:50
expr set_intersect(expr const &a, expr const &b)
Definition z3++.h:4483
expr re_intersect(expr_vector const &args)
Definition z3++.h:4613
expr store(expr const &a, expr const &i, expr const &v)
Definition z3++.h:4405
expr pw(expr const &a, expr const &b)
Definition z3++.h:1861
expr sbv_to_fpa(expr const &t, sort s)
Definition z3++.h:2315
expr bvneg_no_overflow(expr const &a)
Definition z3++.h:2516
expr finite_set_difference(expr const &a, expr const &b)
Definition z3++.h:4527
expr indexof(expr const &s, expr const &substr, expr const &offset)
Definition z3++.h:4576
tactic par_or(unsigned n, tactic const *tactics)
Definition z3++.h:3538
tactic par_and_then(tactic const &t1, tactic const &t2)
Definition z3++.h:3547
expr srem(expr const &a, expr const &b)
signed remainder operator for bitvectors
Definition z3++.h:2448
expr bvadd_no_underflow(expr const &a, expr const &b)
Definition z3++.h:2504
expr prefixof(expr const &a, expr const &b)
Definition z3++.h:4570
expr sum(expr_vector const &args)
Definition z3++.h:2713
expr ugt(expr const &a, expr const &b)
unsigned greater than operator for bitvectors.
Definition z3++.h:2427
expr operator/(expr const &a, expr const &b)
Definition z3++.h:2055
expr exists(expr const &x, expr const &b)
Definition z3++.h:2624
expr fp_eq(expr const &a, expr const &b)
Definition z3++.h:2276
func_decl tree_order(sort const &a, unsigned index)
Definition z3++.h:2541
expr concat(expr const &a, expr const &b)
Definition z3++.h:2731
expr bvmul_no_underflow(expr const &a, expr const &b)
Definition z3++.h:2522
expr lambda(expr const &x, expr const &b)
Definition z3++.h:2648
ast_vector_tpl< func_decl > func_decl_vector
Definition z3++.h:79
expr fpa_to_fpa(expr const &t, sort s)
Definition z3++.h:2329
expr qe_model_project(model const &m, expr_vector const &bounds, expr const &body)
Definition z3++.h:3000
void reset_params()
Definition z3++.h:84
expr operator&&(expr const &a, expr const &b)
Definition z3++.h:1925
std::function< void(expr const &proof, std::vector< unsigned > const &deps, expr_vector const &clause)> on_clause_eh_t
Definition z3++.h:4780
expr operator!=(expr const &a, expr const &b)
Definition z3++.h:1961
expr operator+(expr const &a, expr const &b)
Definition z3++.h:1973
expr set_complement(expr const &a)
Definition z3++.h:4495
check_result
Definition z3++.h:166
@ unknown
Definition z3++.h:167
@ sat
Definition z3++.h:167
@ unsat
Definition z3++.h:167
std::string get_full_version()
Return a string that fully describes the version of Z3 in use.
Definition z3++.h:96
bool eq(ast const &a, ast const &b)
Definition z3++.h:677
func_decl recfun(symbol const &name, unsigned arity, sort const *domain, sort const &range)
Definition z3++.h:4375
expr const_array(sort const &d, expr const &v)
Definition z3++.h:4455
expr min(expr const &a, expr const &b)
Definition z3++.h:2205
expr set_difference(expr const &a, expr const &b)
Definition z3++.h:4491
expr forall(expr const &x, expr const &b)
Definition z3++.h:2600
expr array_default(expr const &a)
Definition z3++.h:4431
expr array_ext(expr const &a, expr const &b)
Definition z3++.h:4437
expr qe_lite(expr_vector const &vars, expr const &body)
Definition z3++.h:2983
expr operator>(expr const &a, expr const &b)
Definition z3++.h:2168
sort to_sort(context &c, Z3_sort s)
Definition z3++.h:2370
expr finite_set_map(expr const &f, expr const &s)
Definition z3++.h:4543
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:2361
expr bv2int(expr const &a, bool is_signed)
bit-vector and integer conversions.
Definition z3++.h:2495
expr operator%(expr const &a, expr const &b)
Definition z3++.h:1876
expr operator~(expr const &a)
Definition z3++.h:2283
expr sle(expr const &a, expr const &b)
signed less than or equal to operator for bitvectors.
Definition z3++.h:2383
expr nor(expr const &a, expr const &b)
Definition z3++.h:2203
expr fpa_fp(expr const &sgn, expr const &exp, expr const &sig)
Definition z3++.h:2293
expr bvsub_no_underflow(expr const &a, expr const &b, bool is_signed)
Definition z3++.h:2510
expr finite_set_singleton(expr const &e)
Definition z3++.h:4515
expr mk_xor(expr_vector const &args)
Definition z3++.h:2815
expr lshr(expr const &a, expr const &b)
logic shift right operator for bitvectors
Definition z3++.h:2476
expr operator*(expr const &a, expr const &b)
Definition z3++.h:2007
expr nand(expr const &a, expr const &b)
Definition z3++.h:2202
expr fpa_to_ubv(expr const &t, unsigned sz)
Definition z3++.h:2308
expr bvredor(expr const &a)
Definition z3++.h:2237
ast_vector_tpl< sort > sort_vector
Definition z3++.h:78
expr finite_set_subset(expr const &a, expr const &b)
Definition z3++.h:4539
func_decl piecewise_linear_order(sort const &a, unsigned index)
Definition z3++.h:2538
expr slt(expr const &a, expr const &b)
signed less than operator for bitvectors.
Definition z3++.h:2389
tactic when(probe const &p, tactic const &t)
Definition z3++.h:3867
expr last_indexof(expr const &s, expr const &substr)
Definition z3++.h:4582
expr int2bv(unsigned n, expr const &a)
Definition z3++.h:2496
expr max(expr const &a, expr const &b)
Definition z3++.h:2221
expr xnor(expr const &a, expr const &b)
Definition z3++.h:2204
expr udiv(expr const &a, expr const &b)
unsigned division operator for bitvectors.
Definition z3++.h:2441
expr abs(expr const &a)
Definition z3++.h:2249
expr pbge(expr_vector const &es, int const *coeffs, int bound)
Definition z3++.h:2681
void disable_trace(char const *tag)
Disable tracing messages tagged as tag when Z3 is compiled in debug mode. It is a NOOP otherwise.
Definition z3++.h:112
expr round_fpa_to_closest_integer(expr const &t)
Definition z3++.h:2336
expr distinct(expr_vector const &args)
Definition z3++.h:2722
expr ashr(expr const &a, expr const &b)
arithmetic shift right operator for bitvectors
Definition z3++.h:2483
expr bvmul_no_overflow(expr const &a, expr const &b, bool is_signed)
Definition z3++.h:2519
expr bvsub_no_overflow(expr const &a, expr const &b)
Definition z3++.h:2507
expr star(expr const &re)
Definition z3++.h:4600
expr urem(expr const &a, expr const &b)
unsigned reminder operator for bitvectors
Definition z3++.h:2462
tactic repeat(tactic const &t, unsigned max=UINT_MAX)
Definition z3++.h:3522
expr mod(expr const &a, expr const &b)
Definition z3++.h:1865
expr fma(expr const &a, expr const &b, expr const &c, expr const &rm)
Definition z3++.h:2285
void get_version(unsigned &major, unsigned &minor, unsigned &build_number, unsigned &revision_number)
Return Z3 version number information.
Definition z3++.h:89
check_result to_check_result(Z3_lbool l)
Definition z3++.h:178
expr mk_or(expr_vector const &args)
Definition z3++.h:2803
expr to_re(expr const &s)
Definition z3++.h:4588
void check_context(object const &a, object const &b)
Definition z3++.h:571
expr_vector polynomial_subresultants(expr const &p, expr const &q, expr const &x)
Return the nonzero subresultants of p and q with respect to the "variable" x.
Definition z3++.h:2551
std::ostream & operator<<(std::ostream &out, exception const &e)
Definition z3++.h:128
expr ule(expr const &a, expr const &b)
unsigned less than or equal to operator for bitvectors.
Definition z3++.h:2409
func_decl to_func_decl(context &c, Z3_func_decl f)
Definition z3++.h:2375
tactic with(tactic const &t, params const &p)
Definition z3++.h:3528
expr ite(expr const &c, expr const &t, expr const &e)
Create the if-then-else expression ite(c, t, e).
Definition z3++.h:2348
expr finite_set_filter(expr const &f, expr const &s)
Definition z3++.h:4547
expr ult(expr const &a, expr const &b)
unsigned less than operator for bitvectors.
Definition z3++.h:2415
expr finite_set_union(expr const &a, expr const &b)
Definition z3++.h:4519
expr qe_model_project_skolem(model const &m, expr_vector const &bounds, expr const &body, ast_map &map)
Project variables and write the introduced Skolem terms to map.
Definition z3++.h:3011
expr pbeq(expr_vector const &es, int const *coeffs, int bound)
Definition z3++.h:2689
expr operator^(expr const &a, expr const &b)
Definition z3++.h:2194
expr operator<=(expr const &a, expr const &b)
Definition z3++.h:2121
expr set_union(expr const &a, expr const &b)
Definition z3++.h:4475
expr imag_part(expr const &z)
Definition z3++.h:1913
expr operator>=(expr const &a, expr const &b)
Definition z3++.h:2035
func_decl linear_order(sort const &a, unsigned index)
Definition z3++.h:2532
expr sqrt(expr const &a, expr const &rm)
Definition z3++.h:2269
expr pble(expr_vector const &es, int const *coeffs, int bound)
Definition z3++.h:2673
expr operator==(expr const &a, expr const &b)
Definition z3++.h:1950
expr foldli(expr const &f, expr const &i, expr const &a, expr const &list)
Definition z3++.h:2796
expr full_set(sort const &s)
Definition z3++.h:4463
std::vector< rcf_num > rcf_roots(context &c, std::vector< rcf_num > const &coeffs)
Find roots of a polynomial with given coefficients.
Definition z3++.h:5301
expr smod(expr const &a, expr const &b)
signed modulus operator for bitvectors
Definition z3++.h:2455
expr implies(expr const &a, expr const &b)
Definition z3++.h:1853
expr finite_set_range(expr const &low, expr const &high)
Definition z3++.h:4551
expr empty_set(sort const &s)
Definition z3++.h:4459
expr complex(expr const &re, expr const &im)
Construct a Complex expression from Int or Real components.
Definition z3++.h:1900
expr in_re(expr const &s, expr const &re)
Definition z3++.h:4591
expr finite_set_member(expr const &e, expr const &s)
Definition z3++.h:4531
expr bvadd_no_overflow(expr const &a, expr const &b, bool is_signed)
bit-vector overflow/underflow checks
Definition z3++.h:2501
expr suffixof(expr const &a, expr const &b)
Definition z3++.h:4564
expr re_diff(expr const &a, expr const &b)
Definition z3++.h:4621
expr set_add(expr const &s, expr const &e)
Definition z3++.h:4467
rcf_num rcf_e(context &c)
Create an RCF numeral representing e (Euler's constant).
Definition z3++.h:5284
expr plus(expr const &re)
Definition z3++.h:4594
expr set_subset(expr const &a, expr const &b)
Definition z3++.h:4503
expr select(expr const &a, expr const &i)
forward declarations
Definition z3++.h:4388
expr bvredand(expr const &a)
Definition z3++.h:2243
expr operator&(expr const &a, expr const &b)
Definition z3++.h:2190
expr operator-(expr const &a)
Definition z3++.h:2077
expr set_member(expr const &s, expr const &e)
Definition z3++.h:4499
expr bvsdiv_no_overflow(expr const &a, expr const &b)
Definition z3++.h:2513
tactic try_for(tactic const &t, unsigned ms)
Definition z3++.h:3533
void set_param(char const *param, char const *value)
Definition z3++.h:81
expr finite_set_size(expr const &s)
Definition z3++.h:4535
expr real_part(expr const &z)
Definition z3++.h:1907
expr sdiv(expr const &a, expr const &b)
signed division operator for bitvectors.
Definition z3++.h:2434
func_decl function(symbol const &name, unsigned arity, sort const *domain, sort const &range)
Definition z3++.h:4347
func_decl partial_order(sort const &a, unsigned index)
Definition z3++.h:2535
ast_vector_tpl< expr > expr_vector
Definition z3++.h:77
expr rem(expr const &a, expr const &b)
Definition z3++.h:1881
expr sge(expr const &a, expr const &b)
signed greater than or equal to operator for bitvectors.
Definition z3++.h:2395
expr is_int(expr const &e)
Definition z3++.h:1921
expr operator!(expr const &a)
Definition z3++.h:1919
expr re_empty(sort const &s)
Definition z3++.h:4603
expr foldl(expr const &f, expr const &a, expr const &list)
Definition z3++.h:2789
rcf_num rcf_pi(context &c)
Create an RCF numeral representing pi.
Definition z3++.h:5277
expr mk_and(expr_vector const &args)
Definition z3++.h:2809
rounding_mode
Definition z3++.h:170
@ RNE
Definition z3++.h:172
@ RNA
Definition z3++.h:171
@ RTZ
Definition z3++.h:175
@ RTN
Definition z3++.h:174
@ RTP
Definition z3++.h:173
expr finite_set_empty(sort const &s)
Definition z3++.h:4509
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:2530
expr to_real(expr const &a)
Definition z3++.h:4345
expr shl(expr const &a, expr const &b)
shift left operator for bitvectors
Definition z3++.h:2469
std::vector< Z3_app > to_apps(expr_vector const &bounds)
Definition z3++.h:2990
expr operator||(expr const &a, expr const &b)
Definition z3++.h:1937
expr finite_set_intersect(expr const &a, expr const &b)
Definition z3++.h:4523
expr set_del(expr const &s, expr const &e)
Definition z3++.h:4471
expr ubv_to_fpa(expr const &t, sort s)
Definition z3++.h:2322
expr map(expr const &f, expr const &list)
Definition z3++.h:2775
tactic cond(probe const &p, tactic const &t1, tactic const &t2)
Definition z3++.h:3873
expr as_array(func_decl &f)
Definition z3++.h:4425
expr sgt(expr const &a, expr const &b)
signed greater than operator for bitvectors.
Definition z3++.h:2401
expr fpa_to_sbv(expr const &t, unsigned sz)
Definition z3++.h:2301
ast_vector_tpl< ast > ast_vector
Definition z3++.h:76
void enable_trace(char const *tag)
Enable tracing messages tagged as tag when Z3 is compiled in debug mode. It is a NOOP otherwise.
Definition z3++.h:104
expr operator|(expr const &a, expr const &b)
Definition z3++.h:2198
expr atmost(expr_vector const &es, unsigned bound)
Definition z3++.h:2697
expr range(expr const &lo, expr const &hi)
Definition z3++.h:4631
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:2490
expr atleast(expr_vector const &es, unsigned bound)
Definition z3++.h:2705
expr qe_model_project_with_witness(model const &m, expr_vector const &bounds, expr const &body, ast_map &map)
Project variables and write the introduced witnesses to map.
Definition z3++.h:3022
expr uge(expr const &a, expr const &b)
unsigned greater than or equal to operator for bitvectors.
Definition z3++.h:2421
expr mapi(expr const &f, expr const &i, expr const &list)
Definition z3++.h:2782
expr operator<(expr const &a, expr const &b)
Definition z3++.h:2146
expr option(expr const &re)
Definition z3++.h:4597
expr re_full(sort const &s)
Definition z3++.h:4608
expr re_complement(expr const &a)
Definition z3++.h:4628
expr empty(sort const &s)
Definition z3++.h:4559
rcf_num rcf_infinitesimal(context &c)
Create an RCF numeral representing an infinitesimal.
Definition z3++.h:5291
tactic fail_if(probe const &p)
Definition z3++.h:3862
#define _Z3_MK_BIN_(a, b, binop)
Definition z3++.h:1846
#define MK_EXPR1(_fn, _arg)
Definition z3++.h:4444
#define MK_EXPR2(_fn, _arg1, _arg2)
Definition z3++.h:4449
#define Z3_THROW(x)
Definition z3++.h:134
#define _Z3_MK_UN_(a, mkun)
Definition z3++.h:1893