mirror of
https://github.com/Z3Prover/z3
synced 2025-04-29 03:45:51 +00:00
merge with master
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
commit
c513f3ca09
883 changed files with 13979 additions and 16480 deletions
|
@ -38,22 +38,22 @@ namespace subpaving {
|
|||
CTX m_ctx;
|
||||
public:
|
||||
context_wrapper(reslimit& lim, typename CTX::numeral_manager & m, params_ref const & p, small_object_allocator * a):m_ctx(lim, m, p, a) {}
|
||||
virtual ~context_wrapper() {}
|
||||
virtual unsigned num_vars() const { return m_ctx.num_vars(); }
|
||||
virtual var mk_var(bool is_int) { return m_ctx.mk_var(is_int); }
|
||||
virtual bool is_int(var x) const { return m_ctx.is_int(x); }
|
||||
virtual var mk_monomial(unsigned sz, power const * pws) { return m_ctx.mk_monomial(sz, pws); }
|
||||
virtual void inc_ref(ineq * a) { m_ctx.inc_ref(reinterpret_cast<typename CTX::ineq*>(a)); }
|
||||
virtual void dec_ref(ineq * a) { m_ctx.dec_ref(reinterpret_cast<typename CTX::ineq*>(a)); }
|
||||
virtual void add_clause(unsigned sz, ineq * const * atoms) { m_ctx.add_clause(sz, reinterpret_cast<typename CTX::ineq * const *>(atoms)); }
|
||||
virtual void display_constraints(std::ostream & out, bool use_star) const { m_ctx.display_constraints(out, use_star); }
|
||||
virtual void set_display_proc(display_var_proc * p) { m_ctx.set_display_proc(p); }
|
||||
virtual void reset_statistics() { m_ctx.reset_statistics(); }
|
||||
virtual void collect_statistics(statistics & st) const { m_ctx.collect_statistics(st); }
|
||||
virtual void collect_param_descrs(param_descrs & r) { m_ctx.collect_param_descrs(r); }
|
||||
virtual void updt_params(params_ref const & p) { m_ctx.updt_params(p); }
|
||||
virtual void operator()() { m_ctx(); }
|
||||
virtual void display_bounds(std::ostream & out) const { m_ctx.display_bounds(out); }
|
||||
~context_wrapper() override {}
|
||||
unsigned num_vars() const override { return m_ctx.num_vars(); }
|
||||
var mk_var(bool is_int) override { return m_ctx.mk_var(is_int); }
|
||||
bool is_int(var x) const override { return m_ctx.is_int(x); }
|
||||
var mk_monomial(unsigned sz, power const * pws) override { return m_ctx.mk_monomial(sz, pws); }
|
||||
void inc_ref(ineq * a) override { m_ctx.inc_ref(reinterpret_cast<typename CTX::ineq*>(a)); }
|
||||
void dec_ref(ineq * a) override { m_ctx.dec_ref(reinterpret_cast<typename CTX::ineq*>(a)); }
|
||||
void add_clause(unsigned sz, ineq * const * atoms) override { m_ctx.add_clause(sz, reinterpret_cast<typename CTX::ineq * const *>(atoms)); }
|
||||
void display_constraints(std::ostream & out, bool use_star) const override { m_ctx.display_constraints(out, use_star); }
|
||||
void set_display_proc(display_var_proc * p) override { m_ctx.set_display_proc(p); }
|
||||
void reset_statistics() override { m_ctx.reset_statistics(); }
|
||||
void collect_statistics(statistics & st) const override { m_ctx.collect_statistics(st); }
|
||||
void collect_param_descrs(param_descrs & r) override { m_ctx.collect_param_descrs(r); }
|
||||
void updt_params(params_ref const & p) override { m_ctx.updt_params(p); }
|
||||
void operator()() override { m_ctx(); }
|
||||
void display_bounds(std::ostream & out) const override { m_ctx.display_bounds(out); }
|
||||
};
|
||||
|
||||
class context_mpq_wrapper : public context_wrapper<context_mpq> {
|
||||
|
@ -66,11 +66,11 @@ namespace subpaving {
|
|||
m_as(m)
|
||||
{}
|
||||
|
||||
virtual ~context_mpq_wrapper() {}
|
||||
~context_mpq_wrapper() override {}
|
||||
|
||||
virtual unsynch_mpq_manager & qm() const { return m_ctx.nm(); }
|
||||
unsynch_mpq_manager & qm() const override { return m_ctx.nm(); }
|
||||
|
||||
virtual var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) {
|
||||
var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) override {
|
||||
m_as.reserve(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
m_ctx.nm().set(m_as[i], as[i]);
|
||||
|
@ -78,7 +78,7 @@ namespace subpaving {
|
|||
m_ctx.nm().set(m_c, c);
|
||||
return m_ctx.mk_sum(m_c, sz, m_as.c_ptr(), xs);
|
||||
}
|
||||
virtual ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) {
|
||||
ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) override {
|
||||
return reinterpret_cast<ineq*>(m_ctx.mk_ineq(x, k, lower, open));
|
||||
}
|
||||
};
|
||||
|
@ -108,11 +108,11 @@ namespace subpaving {
|
|||
m_q2(m_qm) {
|
||||
}
|
||||
|
||||
virtual ~context_mpf_wrapper() {}
|
||||
~context_mpf_wrapper() override {}
|
||||
|
||||
virtual unsynch_mpq_manager & qm() const { return m_qm; }
|
||||
unsynch_mpq_manager & qm() const override { return m_qm; }
|
||||
|
||||
virtual var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) {
|
||||
var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) override {
|
||||
try {
|
||||
m_as.reserve(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
|
@ -125,7 +125,7 @@ namespace subpaving {
|
|||
throw subpaving::exception();
|
||||
}
|
||||
}
|
||||
virtual ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) {
|
||||
ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) override {
|
||||
try {
|
||||
f2n<mpf_manager> & m = m_ctx.nm();
|
||||
if (lower)
|
||||
|
@ -165,11 +165,11 @@ namespace subpaving {
|
|||
m_qm(qm) {
|
||||
}
|
||||
|
||||
virtual ~context_hwf_wrapper() {}
|
||||
~context_hwf_wrapper() override {}
|
||||
|
||||
virtual unsynch_mpq_manager & qm() const { return m_qm; }
|
||||
unsynch_mpq_manager & qm() const override { return m_qm; }
|
||||
|
||||
virtual var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) {
|
||||
var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) override {
|
||||
try {
|
||||
m_as.reserve(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
|
@ -182,7 +182,7 @@ namespace subpaving {
|
|||
throw subpaving::exception();
|
||||
}
|
||||
}
|
||||
virtual ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) {
|
||||
ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) override {
|
||||
try {
|
||||
f2n<hwf_manager> & m = m_ctx.nm();
|
||||
if (lower)
|
||||
|
@ -223,11 +223,11 @@ namespace subpaving {
|
|||
m_z2(m_qm) {
|
||||
}
|
||||
|
||||
virtual ~context_fpoint_wrapper() {}
|
||||
~context_fpoint_wrapper() override {}
|
||||
|
||||
virtual unsynch_mpq_manager & qm() const { return m_qm; }
|
||||
unsynch_mpq_manager & qm() const override { return m_qm; }
|
||||
|
||||
virtual var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) {
|
||||
var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) override {
|
||||
try {
|
||||
m_as.reserve(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
|
@ -241,7 +241,7 @@ namespace subpaving {
|
|||
}
|
||||
}
|
||||
|
||||
virtual ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) {
|
||||
ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) override {
|
||||
try {
|
||||
typename context_fpoint::numeral_manager & m = this->m_ctx.nm();
|
||||
if (lower)
|
||||
|
|
|
@ -111,11 +111,11 @@ public:
|
|||
virtual void display_bounds(std::ostream & out) const = 0;
|
||||
};
|
||||
|
||||
context * mk_mpq_context(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0);
|
||||
context * mk_mpf_context(reslimit& lim, f2n<mpf_manager> & m, params_ref const & p = params_ref(), small_object_allocator * a = 0);
|
||||
context * mk_hwf_context(reslimit& lim, f2n<hwf_manager> & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = 0);
|
||||
context * mk_mpff_context(reslimit& lim, mpff_manager & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = 0);
|
||||
context * mk_mpfx_context(reslimit& lim, mpfx_manager & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = 0);
|
||||
context * mk_mpq_context(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = nullptr);
|
||||
context * mk_mpf_context(reslimit& lim, f2n<mpf_manager> & m, params_ref const & p = params_ref(), small_object_allocator * a = nullptr);
|
||||
context * mk_hwf_context(reslimit& lim, f2n<hwf_manager> & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = nullptr);
|
||||
context * mk_mpff_context(reslimit& lim, mpff_manager & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = nullptr);
|
||||
context * mk_mpfx_context(reslimit& lim, mpfx_manager & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = nullptr);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ public:
|
|||
bool inconsistent() const { return m_conflict != null_var; }
|
||||
void set_conflict(var x) { SASSERT(!inconsistent()); m_conflict = x; }
|
||||
bound * trail_stack() const { return m_trail; }
|
||||
bound * parent_trail_stack() const { return m_parent == 0 ? 0 : m_parent->m_trail; }
|
||||
bound * parent_trail_stack() const { return m_parent == nullptr ? nullptr : m_parent->m_trail; }
|
||||
bound * lower(var x) const { return bm().get(m_lowers, x); }
|
||||
bound * upper(var x) const { return bm().get(m_uppers, x); }
|
||||
node * parent() const { return m_parent; }
|
||||
|
@ -221,7 +221,7 @@ public:
|
|||
/**
|
||||
\brief Return true if x is unbounded in this node
|
||||
*/
|
||||
bool is_unbounded(var x) const { return lower(x) == 0 && upper(x) == 0; }
|
||||
bool is_unbounded(var x) const { return lower(x) == nullptr && upper(x) == nullptr; }
|
||||
void push(bound * b);
|
||||
|
||||
void set_first_child(node * n) { m_first_child = n; }
|
||||
|
@ -275,32 +275,32 @@ public:
|
|||
numeral const & lower(interval const & a) const {
|
||||
if (a.m_constant) {
|
||||
bound * b = a.m_node->lower(a.m_x);
|
||||
return b == 0 ? a.m_l_val /* don't care */ : b->value();
|
||||
return b == nullptr ? a.m_l_val /* don't care */ : b->value();
|
||||
}
|
||||
return a.m_l_val;
|
||||
}
|
||||
numeral const & upper(interval const & a) const {
|
||||
if (a.m_constant) {
|
||||
bound * b = a.m_node->upper(a.m_x);
|
||||
return b == 0 ? a.m_u_val /* don't care */ : b->value();
|
||||
return b == nullptr ? a.m_u_val /* don't care */ : b->value();
|
||||
}
|
||||
return a.m_u_val;
|
||||
}
|
||||
numeral & lower(interval & a) { SASSERT(!a.m_constant); return a.m_l_val; }
|
||||
numeral & upper(interval & a) { SASSERT(!a.m_constant); return a.m_u_val; }
|
||||
bool lower_is_inf(interval const & a) const { return a.m_constant ? a.m_node->lower(a.m_x) == 0 : a.m_l_inf; }
|
||||
bool upper_is_inf(interval const & a) const { return a.m_constant ? a.m_node->upper(a.m_x) == 0 : a.m_u_inf; }
|
||||
bool lower_is_inf(interval const & a) const { return a.m_constant ? a.m_node->lower(a.m_x) == nullptr : a.m_l_inf; }
|
||||
bool upper_is_inf(interval const & a) const { return a.m_constant ? a.m_node->upper(a.m_x) == nullptr : a.m_u_inf; }
|
||||
bool lower_is_open(interval const & a) const {
|
||||
if (a.m_constant) {
|
||||
bound * b = a.m_node->lower(a.m_x);
|
||||
return b == 0 || b->is_open();
|
||||
return b == nullptr || b->is_open();
|
||||
}
|
||||
return a.m_l_open;
|
||||
}
|
||||
bool upper_is_open(interval const & a) const {
|
||||
if (a.m_constant) {
|
||||
bound * b = a.m_node->upper(a.m_x);
|
||||
return b == 0 || b->is_open();
|
||||
return b == nullptr || b->is_open();
|
||||
}
|
||||
return a.m_u_open;
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ public:
|
|||
private:
|
||||
void * m_data;
|
||||
public:
|
||||
watched():m_data(0) {}
|
||||
watched():m_data(nullptr) {}
|
||||
explicit watched(var x) { m_data = BOXTAGINT(void*, x, DEFINITION); }
|
||||
explicit watched(clause * c) { m_data = TAG(void*, c, CLAUSE); }
|
||||
kind get_kind() const { return static_cast<kind>(GET_TAG(m_data)); }
|
||||
|
@ -563,7 +563,7 @@ private:
|
|||
void add_clause_core(unsigned sz, ineq * const * atoms, bool lemma, bool watched);
|
||||
void del_clause(clause * cls);
|
||||
|
||||
node * mk_node(node * parent = 0);
|
||||
node * mk_node(node * parent = nullptr);
|
||||
void del_node(node * n);
|
||||
void del_nodes();
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
context_t<C>::node_selector(ctx) {
|
||||
}
|
||||
|
||||
virtual node * operator()(node * front, node * back) {
|
||||
node * operator()(node * front, node * back) override {
|
||||
return back;
|
||||
}
|
||||
};
|
||||
|
@ -80,7 +80,7 @@ public:
|
|||
}
|
||||
|
||||
// Return the next variable to branch.
|
||||
virtual var operator()(typename context_t<C>::node * n) {
|
||||
var operator()(typename context_t<C>::node * n) override {
|
||||
typename context_t<C>::numeral_manager & nm = this->ctx()->nm();
|
||||
SASSERT(this->ctx()->num_vars() > 0);
|
||||
var x = this->ctx()->splitting_var(n);
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
if (!m_only_non_def || !this->ctx()->is_definition(x)) {
|
||||
bound * lower = n->lower(x);
|
||||
bound * upper = n->upper(x);
|
||||
if (lower == 0 || upper == 0 || !nm.eq(lower->value(), upper->value())) {
|
||||
if (lower == nullptr || upper == nullptr || !nm.eq(lower->value(), upper->value())) {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ public:
|
|||
SASSERT(m_delta < INT_MAX);
|
||||
}
|
||||
|
||||
virtual void operator()(node * n, var x) {
|
||||
void operator()(node * n, var x) override {
|
||||
SASSERT(!n->inconsistent());
|
||||
numeral_manager & nm = this->ctx()->nm();
|
||||
node * left = this->mk_node(n);
|
||||
|
@ -205,11 +205,11 @@ public:
|
|||
bound * lower = n->lower(x);
|
||||
bound * upper = n->upper(x);
|
||||
_scoped_numeral<numeral_manager> mid(nm);
|
||||
if (lower == 0 && upper == 0) {
|
||||
if (lower == nullptr && upper == nullptr) {
|
||||
nm.set(mid, 0);
|
||||
// mid == 0
|
||||
}
|
||||
else if (lower == 0) {
|
||||
else if (lower == nullptr) {
|
||||
_scoped_numeral<numeral_manager> delta(nm);
|
||||
SASSERT(upper != 0);
|
||||
nm.set(delta, static_cast<int>(m_delta));
|
||||
|
@ -218,7 +218,7 @@ public:
|
|||
nm.sub(mid, delta, mid);
|
||||
// mid == upper - delta
|
||||
}
|
||||
else if (upper == 0) {
|
||||
else if (upper == nullptr) {
|
||||
_scoped_numeral<numeral_manager> delta(nm);
|
||||
SASSERT(lower != 0);
|
||||
nm.set(delta, static_cast<int>(m_delta));
|
||||
|
@ -294,17 +294,17 @@ context_t<C>::node::node(context_t & s, unsigned id):
|
|||
m_depth = 0;
|
||||
unsigned num_vars = s.num_vars();
|
||||
m_conflict = null_var;
|
||||
m_trail = 0;
|
||||
m_parent = 0;
|
||||
m_first_child = 0;
|
||||
m_next_sibling = 0;
|
||||
m_prev = 0;
|
||||
m_next = 0;
|
||||
m_trail = nullptr;
|
||||
m_parent = nullptr;
|
||||
m_first_child = nullptr;
|
||||
m_next_sibling = nullptr;
|
||||
m_prev = nullptr;
|
||||
m_next = nullptr;
|
||||
bm().mk(m_lowers);
|
||||
bm().mk(m_uppers);
|
||||
for (unsigned i = 0; i < num_vars; i++) {
|
||||
bm().push_back(m_lowers, 0);
|
||||
bm().push_back(m_uppers, 0);
|
||||
bm().push_back(m_lowers, nullptr);
|
||||
bm().push_back(m_uppers, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,10 +318,10 @@ context_t<C>::node::node(node * parent, unsigned id):
|
|||
m_conflict = parent->m_conflict;
|
||||
m_trail = parent->m_trail;
|
||||
m_parent = parent;
|
||||
m_first_child = 0;
|
||||
m_first_child = nullptr;
|
||||
m_next_sibling = parent->m_first_child;
|
||||
m_prev = 0;
|
||||
m_next = 0;
|
||||
m_prev = nullptr;
|
||||
m_next = nullptr;
|
||||
parent->m_first_child = this;
|
||||
}
|
||||
|
||||
|
@ -350,7 +350,7 @@ var context_t<C>::splitting_var(node * n) const {
|
|||
if (n == m_root)
|
||||
return null_var;
|
||||
bound * b = n->trail_stack();
|
||||
while (b != 0) {
|
||||
while (b != nullptr) {
|
||||
if (b->jst().is_axiom())
|
||||
return b->x();
|
||||
b = b->prev();
|
||||
|
@ -416,16 +416,16 @@ template<typename C>
|
|||
context_t<C>::context_t(reslimit& lim, C const & c, params_ref const & p, small_object_allocator * a):
|
||||
m_limit(lim),
|
||||
m_c(c),
|
||||
m_own_allocator(a == 0),
|
||||
m_allocator(a == 0 ? alloc(small_object_allocator, "subpaving") : a),
|
||||
m_own_allocator(a == nullptr),
|
||||
m_allocator(a == nullptr ? alloc(small_object_allocator, "subpaving") : a),
|
||||
m_bm(*this, *m_allocator),
|
||||
m_im(lim, interval_config(m_c.m())),
|
||||
m_num_buffer(nm()) {
|
||||
m_arith_failed = false;
|
||||
m_timestamp = 0;
|
||||
m_root = 0;
|
||||
m_leaf_head = 0;
|
||||
m_leaf_tail = 0;
|
||||
m_root = nullptr;
|
||||
m_leaf_head = nullptr;
|
||||
m_leaf_tail = nullptr;
|
||||
m_conflict = null_var;
|
||||
m_qhead = 0;
|
||||
m_display_proc = &m_default_display_proc;
|
||||
|
@ -638,14 +638,14 @@ void context_t<C>::display_bounds(std::ostream & out, node * n) const {
|
|||
for (unsigned x = 0; x < num; x++) {
|
||||
bound * l = n->lower(x);
|
||||
bound * u = n->upper(x);
|
||||
if (l != 0) {
|
||||
if (l != nullptr) {
|
||||
display(out, l);
|
||||
out << " ";
|
||||
}
|
||||
if (u != 0) {
|
||||
if (u != nullptr) {
|
||||
display(out, u);
|
||||
}
|
||||
if (l != 0 || u != 0)
|
||||
if (l != nullptr || u != nullptr)
|
||||
out << "\n";
|
||||
}
|
||||
}
|
||||
|
@ -878,7 +878,7 @@ template<typename C>
|
|||
typename context_t<C>::node * context_t<C>::mk_node(node * parent) {
|
||||
void * mem = allocator().allocate(sizeof(node));
|
||||
node * r;
|
||||
if (parent == 0)
|
||||
if (parent == nullptr)
|
||||
r = new (mem) node(*this, m_node_id_gen.mk());
|
||||
else
|
||||
r = new (mem) node(parent, m_node_id_gen.mk());
|
||||
|
@ -910,7 +910,7 @@ void context_t<C>::del_node(node * n) {
|
|||
node * p = n->parent();
|
||||
bound * b = n->trail_stack();
|
||||
bound * b_old;
|
||||
if (p != 0) {
|
||||
if (p != nullptr) {
|
||||
node * c = p->first_child();
|
||||
if (c == n) {
|
||||
// n is the first child
|
||||
|
@ -928,7 +928,7 @@ void context_t<C>::del_node(node * n) {
|
|||
b_old = p->trail_stack();
|
||||
}
|
||||
else {
|
||||
b_old = 0;
|
||||
b_old = nullptr;
|
||||
}
|
||||
while (b != b_old) {
|
||||
bound * old = b;
|
||||
|
@ -944,18 +944,18 @@ void context_t<C>::del_node(node * n) {
|
|||
template<typename C>
|
||||
void context_t<C>::del_nodes() {
|
||||
ptr_buffer<node> todo;
|
||||
if (m_root == 0)
|
||||
if (m_root == nullptr)
|
||||
return;
|
||||
todo.push_back(m_root);
|
||||
while (!todo.empty()) {
|
||||
node * n = todo.back();
|
||||
node * c = n->first_child();
|
||||
if (c == 0) {
|
||||
if (c == nullptr) {
|
||||
del_node(n);
|
||||
todo.pop_back();
|
||||
}
|
||||
else {
|
||||
while (c != 0) {
|
||||
while (c != nullptr) {
|
||||
todo.push_back(c);
|
||||
c = c->next_sibling();
|
||||
}
|
||||
|
@ -969,7 +969,7 @@ void context_t<C>::push_front(node * n) {
|
|||
SASSERT(n->next() == 0);
|
||||
SASSERT(n->prev() == 0);
|
||||
n->set_next(m_leaf_head);
|
||||
if (m_leaf_head != 0) {
|
||||
if (m_leaf_head != nullptr) {
|
||||
SASSERT(m_leaf_head->prev() == 0);
|
||||
m_leaf_head->set_prev(n);
|
||||
}
|
||||
|
@ -986,7 +986,7 @@ void context_t<C>::push_back(node * n) {
|
|||
SASSERT(n->next() == 0);
|
||||
SASSERT(n->prev() == 0);
|
||||
n->set_prev(m_leaf_tail);
|
||||
if (m_leaf_tail != 0) {
|
||||
if (m_leaf_tail != nullptr) {
|
||||
SASSERT(m_leaf_tail->next() == 0);
|
||||
m_leaf_tail->set_next(n);
|
||||
}
|
||||
|
@ -1001,14 +1001,14 @@ template<typename C>
|
|||
void context_t<C>::reset_leaf_dlist() {
|
||||
// Remove all nodes from the lead doubly linked list
|
||||
node * n = m_leaf_head;
|
||||
while (n != 0) {
|
||||
while (n != nullptr) {
|
||||
node * next = n->next();
|
||||
n->set_next(0);
|
||||
n->set_prev(0);
|
||||
n->set_next(nullptr);
|
||||
n->set_prev(nullptr);
|
||||
n = next;
|
||||
}
|
||||
m_leaf_head = 0;
|
||||
m_leaf_tail = 0;
|
||||
m_leaf_head = nullptr;
|
||||
m_leaf_tail = nullptr;
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
|
@ -1016,18 +1016,18 @@ void context_t<C>::rebuild_leaf_dlist(node * n) {
|
|||
reset_leaf_dlist();
|
||||
// Reinsert all leaves in the leaf dlist.
|
||||
ptr_buffer<node, 1024> todo;
|
||||
if (m_root != 0)
|
||||
if (m_root != nullptr)
|
||||
todo.push_back(m_root);
|
||||
while (!todo.empty()) {
|
||||
node * n = todo.back();
|
||||
todo.pop_back();
|
||||
node * c = n->first_child();
|
||||
if (c == 0) {
|
||||
if (c == nullptr) {
|
||||
if (!n->inconsistent())
|
||||
push_front(n);
|
||||
}
|
||||
else {
|
||||
while (c != 0) {
|
||||
while (c != nullptr) {
|
||||
SASSERT(c->parent() == n);
|
||||
todo.push_back(c);
|
||||
c = c->next_sibling();
|
||||
|
@ -1043,19 +1043,19 @@ void context_t<C>::remove_from_leaf_dlist(node * n) {
|
|||
SASSERT(prev == 0 || prev != next);
|
||||
SASSERT(next == 0 || prev != next);
|
||||
SASSERT(prev != n); SASSERT(next != n);
|
||||
if (prev != 0) {
|
||||
if (prev != nullptr) {
|
||||
SASSERT(m_leaf_head != n);
|
||||
prev->set_next(next);
|
||||
n->set_prev(0);
|
||||
n->set_prev(nullptr);
|
||||
}
|
||||
else if (m_leaf_head == n) {
|
||||
m_leaf_head = next;
|
||||
}
|
||||
|
||||
if (next != 0) {
|
||||
if (next != nullptr) {
|
||||
SASSERT(m_leaf_tail != n);
|
||||
next->set_prev(prev);
|
||||
n->set_next(0);
|
||||
n->set_next(nullptr);
|
||||
}
|
||||
else if (m_leaf_tail == n) {
|
||||
m_leaf_tail = prev;
|
||||
|
@ -1067,18 +1067,18 @@ template<typename C>
|
|||
void context_t<C>::collect_leaves(ptr_vector<node> & leaves) const {
|
||||
// Copy all leaves to the given vector.
|
||||
ptr_buffer<node, 1024> todo;
|
||||
if (m_root != 0)
|
||||
if (m_root != nullptr)
|
||||
todo.push_back(m_root);
|
||||
while (!todo.empty()) {
|
||||
node * n = todo.back();
|
||||
todo.pop_back();
|
||||
node * c = n->first_child();
|
||||
if (c == 0) {
|
||||
if (c == nullptr) {
|
||||
if (!n->inconsistent())
|
||||
leaves.push_back(n);
|
||||
}
|
||||
else {
|
||||
while (c != 0) {
|
||||
while (c != nullptr) {
|
||||
SASSERT(c->parent() == n);
|
||||
todo.push_back(c);
|
||||
c = c->next_sibling();
|
||||
|
@ -1115,7 +1115,7 @@ void context_t<C>::del_definitions() {
|
|||
unsigned sz = num_vars();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
definition * d = m_defs[i];
|
||||
if (d == 0)
|
||||
if (d == nullptr)
|
||||
continue;
|
||||
switch (d->get_kind()) {
|
||||
case constraint::MONOMIAL:
|
||||
|
@ -1219,24 +1219,24 @@ bool context_t<C>::relevant_new_bound(var x, numeral const & k, bool lower, bool
|
|||
return true;
|
||||
}
|
||||
// If m_epsilon is zero, then bound is relevant only if it improves existing bound.
|
||||
if (m_zero_epsilon && curr_lower != 0 && (nm().lt(k, curr_lower->value()) || ((curr_lower->is_open() || !open) && nm().eq(k, curr_lower->value())))) {
|
||||
if (m_zero_epsilon && curr_lower != nullptr && (nm().lt(k, curr_lower->value()) || ((curr_lower->is_open() || !open) && nm().eq(k, curr_lower->value())))) {
|
||||
// new lower bound does not improve existing bound
|
||||
TRACE("subpaving_relevant_bound", tout << "irrelevant because does not improve existing bound.\n";);
|
||||
return false;
|
||||
}
|
||||
if (curr_upper == 0 && nm().lt(m_max_bound, k)) {
|
||||
if (curr_upper == nullptr && nm().lt(m_max_bound, k)) {
|
||||
// new lower bound exceeds the :max-bound threshold
|
||||
TRACE("subpaving_relevant_bound", tout << "irrelevant because exceeds :max-bound threshold.\n";);
|
||||
return false;
|
||||
}
|
||||
if (!m_zero_epsilon && curr_lower != 0) {
|
||||
if (!m_zero_epsilon && curr_lower != nullptr) {
|
||||
// check if:
|
||||
// new-lower > lower + m_epsilon * max(min(upper - lower, |lower|), 1)
|
||||
numeral & min = m_tmp1;
|
||||
numeral & abs_lower = m_tmp2;
|
||||
nm().set(abs_lower, curr_lower->value());
|
||||
nm().abs(abs_lower);
|
||||
if (curr_upper != 0) {
|
||||
if (curr_upper != nullptr) {
|
||||
nm().sub(curr_upper->value(), curr_lower->value(), min);
|
||||
if (nm().lt(abs_lower, min))
|
||||
nm().set(min, abs_lower);
|
||||
|
@ -1269,24 +1269,24 @@ bool context_t<C>::relevant_new_bound(var x, numeral const & k, bool lower, bool
|
|||
return true;
|
||||
}
|
||||
// If m_epsilon is zero, then bound is relevant only if it improves existing bound.
|
||||
if (m_zero_epsilon && curr_upper != 0 && (nm().lt(curr_upper->value(), k) || ((curr_upper->is_open() || !open) && nm().eq(k, curr_upper->value())))) {
|
||||
if (m_zero_epsilon && curr_upper != nullptr && (nm().lt(curr_upper->value(), k) || ((curr_upper->is_open() || !open) && nm().eq(k, curr_upper->value())))) {
|
||||
// new upper bound does not improve existing bound
|
||||
TRACE("subpaving_relevant_bound", tout << "irrelevant because does not improve existing bound.\n";);
|
||||
return false;
|
||||
}
|
||||
if (curr_lower == 0 && nm().lt(k, m_minus_max_bound)) {
|
||||
if (curr_lower == nullptr && nm().lt(k, m_minus_max_bound)) {
|
||||
// new upper bound exceeds the -:max-bound threshold
|
||||
TRACE("subpaving_relevant_bound", tout << "irrelevant because exceeds -:max-bound threshold.\n";);
|
||||
return false;
|
||||
}
|
||||
if (!m_zero_epsilon && curr_upper != 0) {
|
||||
if (!m_zero_epsilon && curr_upper != nullptr) {
|
||||
// check if:
|
||||
// new-upper < upper - m_epsilon * max(min(upper - lower, |upper|), 1)
|
||||
numeral & min = m_tmp1;
|
||||
numeral & abs_upper = m_tmp2;
|
||||
nm().set(abs_upper, curr_upper->value());
|
||||
nm().abs(abs_upper);
|
||||
if (curr_lower != 0) {
|
||||
if (curr_lower != nullptr) {
|
||||
nm().sub(curr_upper->value(), curr_lower->value(), min);
|
||||
if (nm().lt(abs_upper, min))
|
||||
nm().set(min, abs_upper);
|
||||
|
@ -1323,14 +1323,14 @@ bool context_t<C>::is_zero(var x, node * n) const {
|
|||
// Return true if lower(x) == upper(x) == 0 at n
|
||||
bound * l = n->lower(x);
|
||||
bound * u = n->upper(x);
|
||||
return l != 0 && u != 0 && nm().is_zero(l->value()) && nm().is_zero(u->value()) && !l->is_open() && !u->is_open();
|
||||
return l != nullptr && u != nullptr && nm().is_zero(l->value()) && nm().is_zero(u->value()) && !l->is_open() && !u->is_open();
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
bool context_t<C>::is_upper_zero(var x, node * n) const {
|
||||
// Return true if upper(x) is zero at node n
|
||||
bound * u = n->upper(x);
|
||||
return u != 0 && nm().is_zero(u->value()) && !u->is_open();
|
||||
return u != nullptr && nm().is_zero(u->value()) && !u->is_open();
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
|
@ -1338,7 +1338,7 @@ bool context_t<C>::conflicting_bounds(var x, node * n) const {
|
|||
// Return true if upper(x) < lower(x) at node n
|
||||
bound * l = n->lower(x);
|
||||
bound * u = n->upper(x);
|
||||
return l != 0 && u != 0 && (nm().lt(u->value(), l->value()) || ((l->is_open() || u->is_open()) && nm().eq(u->value(), l->value())));
|
||||
return l != nullptr && u != nullptr && (nm().lt(u->value(), l->value()) || ((l->is_open() || u->is_open()) && nm().eq(u->value(), l->value())));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1351,20 +1351,20 @@ lbool context_t<C>::value(ineq * t, node * n) {
|
|||
var x = t->x();
|
||||
bound * u = n->upper(x);
|
||||
bound * l = n->lower(x);
|
||||
if (u == 0 && l == 0)
|
||||
if (u == nullptr && l == nullptr)
|
||||
return l_undef;
|
||||
else if (t->is_lower()) {
|
||||
if (u != 0 && (nm().lt(u->value(), t->value()) || ((u->is_open() || t->is_open()) && nm().eq(u->value(), t->value()))))
|
||||
if (u != nullptr && (nm().lt(u->value(), t->value()) || ((u->is_open() || t->is_open()) && nm().eq(u->value(), t->value()))))
|
||||
return l_false;
|
||||
else if (l != 0 && (nm().gt(l->value(), t->value()) || ((l->is_open() || !t->is_open()) && nm().eq(l->value(), t->value()))))
|
||||
else if (l != nullptr && (nm().gt(l->value(), t->value()) || ((l->is_open() || !t->is_open()) && nm().eq(l->value(), t->value()))))
|
||||
return l_true;
|
||||
else
|
||||
return l_undef;
|
||||
}
|
||||
else {
|
||||
if (l != 0 && (nm().gt(l->value(), t->value()) || ((l->is_open() || t->is_open()) && nm().eq(l->value(), t->value()))))
|
||||
if (l != nullptr && (nm().gt(l->value(), t->value()) || ((l->is_open() || t->is_open()) && nm().eq(l->value(), t->value()))))
|
||||
return l_false;
|
||||
else if (u != 0 && (nm().lt(u->value(), t->value()) || ((u->is_open() || !t->is_open()) && nm().eq(u->value(), t->value()))))
|
||||
else if (u != nullptr && (nm().lt(u->value(), t->value()) || ((u->is_open() || !t->is_open()) && nm().eq(u->value(), t->value()))))
|
||||
return l_true;
|
||||
else
|
||||
return l_undef;
|
||||
|
@ -1804,17 +1804,17 @@ void context_t<C>::init() {
|
|||
|
||||
template<typename C>
|
||||
void context_t<C>::operator()() {
|
||||
if (m_root == 0)
|
||||
if (m_root == nullptr)
|
||||
init();
|
||||
TRACE("subpaving_stats", statistics st; collect_statistics(st); tout << "statistics:\n"; st.display_smt2(tout););
|
||||
TRACE("subpaving_main", display_params(tout););
|
||||
while (m_leaf_head != 0) {
|
||||
while (m_leaf_head != nullptr) {
|
||||
checkpoint();
|
||||
SASSERT(m_queue.empty());
|
||||
if (m_num_nodes > m_max_nodes)
|
||||
break;
|
||||
node * n = (*m_node_selector)(m_leaf_head, m_leaf_tail);
|
||||
if (n == 0)
|
||||
if (n == nullptr)
|
||||
break;
|
||||
TRACE("subpaving_main", tout << "selected node: #" << n->id() << ", depth: " << n->depth() << "\n";);
|
||||
remove_from_leaf_dlist(n);
|
||||
|
@ -1892,7 +1892,7 @@ void context_t<C>::collect_statistics(statistics & st) const {
|
|||
template<typename C>
|
||||
bool context_t<C>::is_bound_of(bound * b, node * n) const {
|
||||
bound * c = n->trail_stack();
|
||||
while (c != 0) {
|
||||
while (c != nullptr) {
|
||||
if (c == b)
|
||||
return true;
|
||||
if (c->timestamp() <= b->timestamp())
|
||||
|
@ -1905,7 +1905,7 @@ bool context_t<C>::is_bound_of(bound * b, node * n) const {
|
|||
template<typename C>
|
||||
bool context_t<C>::check_leaf_dlist() const {
|
||||
node * n = m_leaf_head;
|
||||
while (n != 0) {
|
||||
while (n != nullptr) {
|
||||
node * next = n->next();
|
||||
SASSERT(next != 0 || m_leaf_tail == n);
|
||||
SASSERT(next == 0 || next->prev() == n);
|
||||
|
@ -1917,13 +1917,13 @@ bool context_t<C>::check_leaf_dlist() const {
|
|||
template<typename C>
|
||||
bool context_t<C>::check_tree() const {
|
||||
ptr_buffer<node> todo;
|
||||
if (m_root != 0)
|
||||
if (m_root != nullptr)
|
||||
todo.push_back(m_root);
|
||||
while (!todo.empty()) {
|
||||
node * n = todo.back();
|
||||
todo.pop_back();
|
||||
node * c = n->first_child();
|
||||
while (c != 0) {
|
||||
while (c != nullptr) {
|
||||
SASSERT(c->parent() == n);
|
||||
todo.push_back(c);
|
||||
c = c->next_sibling();
|
||||
|
|
|
@ -30,7 +30,7 @@ struct expr2subpaving::imp {
|
|||
struct frame {
|
||||
app * m_curr;
|
||||
unsigned m_idx;
|
||||
frame():m_curr(0), m_idx(0) {}
|
||||
frame():m_curr(nullptr), m_idx(0) {}
|
||||
frame(app * t):m_curr(t), m_idx(0) {}
|
||||
};
|
||||
|
||||
|
@ -62,7 +62,7 @@ struct expr2subpaving::imp {
|
|||
m_cached_numerators(m_qm),
|
||||
m_cached_denominators(m_qm) {
|
||||
|
||||
if (e2v == 0) {
|
||||
if (e2v == nullptr) {
|
||||
m_expr2var = alloc(expr2var, m);
|
||||
m_expr2var_owner = true;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ struct expr2subpaving::imp {
|
|||
x = s().mk_var(is_int);
|
||||
m_expr2var->insert(t, x);
|
||||
if (x >= m_var2expr.size())
|
||||
m_var2expr.resize(x+1, 0);
|
||||
m_var2expr.resize(x+1, nullptr);
|
||||
m_var2expr.set(x, t);
|
||||
}
|
||||
return x;
|
||||
|
|
|
@ -29,7 +29,7 @@ class expr2subpaving {
|
|||
struct imp;
|
||||
imp * m_imp;
|
||||
public:
|
||||
expr2subpaving(ast_manager & m, subpaving::context & s, expr2var * e2v = 0);
|
||||
expr2subpaving(ast_manager & m, subpaving::context & s, expr2var * e2v = nullptr);
|
||||
~expr2subpaving();
|
||||
|
||||
ast_manager & m() const;
|
||||
|
|
|
@ -40,9 +40,9 @@ class subpaving_tactic : public tactic {
|
|||
|
||||
ast_manager & m() const { return m_inv.get_manager(); }
|
||||
|
||||
virtual void operator()(std::ostream & out, subpaving::var x) const {
|
||||
expr * t = m_inv.get(x, 0);
|
||||
if (t != 0)
|
||||
void operator()(std::ostream & out, subpaving::var x) const override {
|
||||
expr * t = m_inv.get(x, nullptr);
|
||||
if (t != nullptr)
|
||||
out << mk_ismt2_pp(t, m());
|
||||
else
|
||||
out << "k!" << x;
|
||||
|
@ -160,7 +160,7 @@ class subpaving_tactic : public tactic {
|
|||
}
|
||||
|
||||
void process_clause(expr * c) {
|
||||
expr * const * args = 0;
|
||||
expr * const * args = nullptr;
|
||||
unsigned sz;
|
||||
if (m().is_or(c)) {
|
||||
args = to_app(c)->get_args();
|
||||
|
@ -216,33 +216,33 @@ public:
|
|||
m_params(p) {
|
||||
}
|
||||
|
||||
virtual ~subpaving_tactic() {
|
||||
~subpaving_tactic() override {
|
||||
dealloc(m_imp);
|
||||
}
|
||||
|
||||
virtual tactic * translate(ast_manager & m) {
|
||||
tactic * translate(ast_manager & m) override {
|
||||
return alloc(subpaving_tactic, m, m_params);
|
||||
}
|
||||
|
||||
virtual void updt_params(params_ref const & p) {
|
||||
void updt_params(params_ref const & p) override {
|
||||
m_params = p;
|
||||
m_imp->updt_params(p);
|
||||
}
|
||||
|
||||
virtual void collect_param_descrs(param_descrs & r) {
|
||||
void collect_param_descrs(param_descrs & r) override {
|
||||
m_imp->collect_param_descrs(r);
|
||||
}
|
||||
|
||||
virtual void collect_statistics(statistics & st) const {
|
||||
void collect_statistics(statistics & st) const override {
|
||||
st.copy(m_stats);
|
||||
}
|
||||
|
||||
virtual void reset_statistics() {
|
||||
void reset_statistics() override {
|
||||
m_stats.reset();
|
||||
}
|
||||
|
||||
virtual void operator()(goal_ref const & in,
|
||||
goal_ref_buffer & result) {
|
||||
void operator()(goal_ref const & in,
|
||||
goal_ref_buffer & result) override {
|
||||
try {
|
||||
m_imp->process(*in);
|
||||
m_imp->collect_statistics(m_stats);
|
||||
|
@ -255,7 +255,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void cleanup() {
|
||||
void cleanup() override {
|
||||
ast_manager & m = m_imp->m();
|
||||
dealloc(m_imp);
|
||||
m_imp = alloc(imp, m, m_params);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue