mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +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
|
@ -43,7 +43,7 @@ public:
|
|||
unsigned m_src;
|
||||
unsigned m_dst;
|
||||
public:
|
||||
move(M& m, unsigned s, unsigned d, T* t = 0): m(m), m_t(t), m_src(s), m_dst(d) {
|
||||
move(M& m, unsigned s, unsigned d, T* t = nullptr): m(m), m_t(t), m_src(s), m_dst(d) {
|
||||
if (t) m.inc_ref(t);
|
||||
}
|
||||
~move() {
|
||||
|
@ -69,7 +69,7 @@ public:
|
|||
unsigned src() const { return m_src; }
|
||||
T* t() const { return m_t; }
|
||||
|
||||
bool is_epsilon() const { return m_t == 0; }
|
||||
bool is_epsilon() const { return m_t == nullptr; }
|
||||
};
|
||||
typedef vector<move> moves;
|
||||
private:
|
||||
|
@ -407,7 +407,7 @@ public:
|
|||
mvs1.push_back(move(m, mv1.src(), dst1, t));
|
||||
}
|
||||
for (move const& mv1 : mvs1) {
|
||||
remove(mv1.src(), dst, 0);
|
||||
remove(mv1.src(), dst, nullptr);
|
||||
add(mv1);
|
||||
}
|
||||
remove(dst, dst1, t);
|
||||
|
@ -431,7 +431,7 @@ public:
|
|||
else {
|
||||
continue;
|
||||
}
|
||||
remove(src, dst, 0);
|
||||
remove(src, dst, nullptr);
|
||||
--j;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
template<class T>
|
||||
class boolean_algebra : public positive_boolean_algebra<T> {
|
||||
public:
|
||||
virtual ~boolean_algebra() {}
|
||||
~boolean_algebra() override {}
|
||||
virtual T mk_not(T x) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -399,7 +399,7 @@ typename symbolic_automata<T, M>::automaton_t* symbolic_automata<T, M>::mk_produ
|
|||
continue;
|
||||
}
|
||||
else if (is_sat == l_undef) {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
unsigned_pair tgt_pair(mvsA[i].dst(), mvsB[j].dst());
|
||||
unsigned tgt;
|
||||
|
|
|
@ -506,8 +506,8 @@ struct euclidean_solver::imp {
|
|||
}
|
||||
|
||||
imp(numeral_manager * m):
|
||||
m_manager(m == 0 ? alloc(numeral_manager) : m),
|
||||
m_owns_m(m == 0),
|
||||
m_manager(m == nullptr ? alloc(numeral_manager) : m),
|
||||
m_owns_m(m == nullptr),
|
||||
m_decompose_buffer(*m_manager),
|
||||
m_as_buffer(*m_manager),
|
||||
m_bs_buffer(*m_manager),
|
||||
|
@ -550,7 +550,7 @@ struct euclidean_solver::imp {
|
|||
return;
|
||||
equation * eq;
|
||||
if (j == null_justification) {
|
||||
eq = mk_eq(num, as, xs, c, 0, 0, 0);
|
||||
eq = mk_eq(num, as, xs, c, 0, nullptr, nullptr);
|
||||
}
|
||||
else {
|
||||
mpq one(1);
|
||||
|
@ -694,7 +694,7 @@ struct euclidean_solver::imp {
|
|||
mpz new_c;
|
||||
decompose(m_next_pos_a, m_next_a, eq.m_c, new_c, eq.m_c);
|
||||
// create auxiliary equation
|
||||
equation * new_eq = mk_eq(m_tmp_xs.size(), buffer.c_ptr(), m_tmp_xs.c_ptr(), new_c, 0, 0, 0, false);
|
||||
equation * new_eq = mk_eq(m_tmp_xs.size(), buffer.c_ptr(), m_tmp_xs.c_ptr(), new_c, 0, nullptr, nullptr, false);
|
||||
// new_eq doesn't need to normalized, since it has unit coefficients
|
||||
TRACE("euclidean_solver", tout << "decomposition: new parameter x" << p << " aux eq:\n";
|
||||
display(tout, *new_eq); tout << "\n";
|
||||
|
|
|
@ -29,7 +29,7 @@ grobner::grobner(ast_manager & m, v_dependency_manager & d):
|
|||
m_var_lt(m_var2weight),
|
||||
m_monomial_lt(m_var_lt),
|
||||
m_changed_leading_term(false),
|
||||
m_unsat(0) {
|
||||
m_unsat(nullptr) {
|
||||
}
|
||||
|
||||
grobner::~grobner() {
|
||||
|
@ -116,7 +116,7 @@ void grobner::reset() {
|
|||
m_to_process.reset();
|
||||
m_equations_to_unfreeze.reset();
|
||||
m_equations_to_delete.reset();
|
||||
m_unsat = 0;
|
||||
m_unsat = nullptr;
|
||||
}
|
||||
|
||||
void grobner::display_var(std::ostream & out, expr * var) const {
|
||||
|
@ -410,7 +410,7 @@ void grobner::assert_monomial_tautology(expr * m) {
|
|||
m1->m_vars.push_back(m);
|
||||
eq->m_monomials.push_back(m1);
|
||||
normalize_coeff(eq->m_monomials);
|
||||
init_equation(eq, static_cast<v_dependency*>(0)); \
|
||||
init_equation(eq, static_cast<v_dependency*>(nullptr)); \
|
||||
m_to_process.insert(eq);
|
||||
}
|
||||
|
||||
|
@ -625,7 +625,7 @@ grobner::equation * grobner::copy_equation(equation const * eq) {
|
|||
grobner::equation * grobner::simplify(equation const * source, equation * target) {
|
||||
TRACE("grobner", tout << "simplifying: "; display_equation(tout, *target); tout << "using: "; display_equation(tout, *source););
|
||||
if (source->get_num_monomials() == 0)
|
||||
return 0;
|
||||
return nullptr;
|
||||
m_stats.m_simplify++;
|
||||
bool result = false;
|
||||
bool simplified;
|
||||
|
@ -676,7 +676,7 @@ grobner::equation * grobner::simplify(equation const * source, equation * target
|
|||
}
|
||||
while (simplified && !m_manager.canceled());
|
||||
TRACE("grobner", tout << "result: "; display_equation(tout, *target););
|
||||
return result ? target : 0;
|
||||
return result ? target : nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -702,13 +702,13 @@ grobner::equation * grobner::simplify_using_processed(equation * eq) {
|
|||
eq = new_eq;
|
||||
}
|
||||
if (m_manager.canceled()) {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (simplified);
|
||||
TRACE("grobner", tout << "simplification result: "; display_equation(tout, *eq););
|
||||
return result ? eq : 0;
|
||||
return result ? eq : nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -732,7 +732,7 @@ bool grobner::is_better_choice(equation * eq1, equation * eq2) {
|
|||
\brief Pick next unprocessed equation
|
||||
*/
|
||||
grobner::equation * grobner::pick_next() {
|
||||
equation * r = 0;
|
||||
equation * r = nullptr;
|
||||
ptr_buffer<equation> to_delete;
|
||||
equation_set::iterator it = m_to_process.begin();
|
||||
equation_set::iterator end = m_to_process.end();
|
||||
|
@ -767,7 +767,7 @@ bool grobner::simplify_processed(equation * eq) {
|
|||
m_changed_leading_term = false;
|
||||
// if the leading term is simplified, then the equation has to be moved to m_to_process
|
||||
equation * new_curr = simplify(eq, curr);
|
||||
if (new_curr != 0) {
|
||||
if (new_curr != nullptr) {
|
||||
if (new_curr != curr) {
|
||||
m_equations_to_unfreeze.push_back(curr);
|
||||
to_remove.push_back(curr);
|
||||
|
@ -817,7 +817,7 @@ void grobner::simplify_to_process(equation * eq) {
|
|||
for (; it != end; ++it) {
|
||||
equation * curr = *it;
|
||||
equation * new_curr = simplify(eq, curr);
|
||||
if (new_curr != 0 && new_curr != curr) {
|
||||
if (new_curr != nullptr && new_curr != curr) {
|
||||
m_equations_to_unfreeze.push_back(curr);
|
||||
to_insert.push_back(new_curr);
|
||||
to_remove.push_back(curr);
|
||||
|
@ -947,7 +947,7 @@ bool grobner::compute_basis_step() {
|
|||
}
|
||||
#endif
|
||||
equation * new_eq = simplify_using_processed(eq);
|
||||
if (new_eq != 0 && eq != new_eq) {
|
||||
if (new_eq != nullptr && eq != new_eq) {
|
||||
// equation was updated using non destructive updates
|
||||
m_equations_to_unfreeze.push_back(eq);
|
||||
eq = new_eq;
|
||||
|
|
|
@ -220,25 +220,25 @@ public:
|
|||
\brief Assert the given equality.
|
||||
This method assumes eq is simplified.
|
||||
*/
|
||||
void assert_eq(expr * eq, v_dependency * ex = 0);
|
||||
void assert_eq(expr * eq, v_dependency * ex = nullptr);
|
||||
|
||||
/**
|
||||
\brief Assert the equality monomials[0] + ... + monomials[num_monomials - 1] = 0.
|
||||
This method assumes the monomials were simplified.
|
||||
*/
|
||||
void assert_eq_0(unsigned num_monomials, expr * const * monomials, v_dependency * ex = 0);
|
||||
void assert_eq_0(unsigned num_monomials, expr * const * monomials, v_dependency * ex = nullptr);
|
||||
|
||||
/**
|
||||
\brief Assert the equality monomials[0] + ... + monomials[num_monomials - 1] = 0.
|
||||
This method assumes the monomials were simplified.
|
||||
*/
|
||||
void assert_eq_0(unsigned num_monomials, monomial * const * monomials, v_dependency * ex = 0);
|
||||
void assert_eq_0(unsigned num_monomials, monomial * const * monomials, v_dependency * ex = nullptr);
|
||||
|
||||
/**
|
||||
\brief Assert the equality coeffs[0] * monomials[0] + ... + coeffs[num_monomials-1] * monomials[num_monomials - 1] = 0.
|
||||
This method assumes the monomials were simplified.
|
||||
*/
|
||||
void assert_eq_0(unsigned num_monomials, rational const * coeffs, expr * const * monomials, v_dependency * ex = 0);
|
||||
void assert_eq_0(unsigned num_monomials, rational const * coeffs, expr * const * monomials, v_dependency * ex = nullptr);
|
||||
|
||||
/**
|
||||
\brief Assert the monomial tautology (quote (x_1 * ... * x_n)) - x_1 * ... * x_n = 0
|
||||
|
@ -263,7 +263,7 @@ public:
|
|||
/**
|
||||
\brief Return true if an inconsistency was detected.
|
||||
*/
|
||||
bool inconsistent() const { return m_unsat != 0; }
|
||||
bool inconsistent() const { return m_unsat != nullptr; }
|
||||
|
||||
/**
|
||||
\brief Simplify the given expression using the equalities asserted
|
||||
|
|
|
@ -81,14 +81,14 @@ class heap_trie {
|
|||
Value m_value;
|
||||
public:
|
||||
leaf(): node(leaf_t) {}
|
||||
virtual ~leaf() {}
|
||||
~leaf() override {}
|
||||
Value const& get_value() const { return m_value; }
|
||||
void set_value(Value const& v) { m_value = v; }
|
||||
virtual void display(std::ostream& out, unsigned indent) const {
|
||||
void display(std::ostream& out, unsigned indent) const override {
|
||||
out << " value: " << m_value;
|
||||
}
|
||||
virtual unsigned num_nodes() const { return 1; }
|
||||
virtual unsigned num_leaves() const { return this->ref_count()>0?1:0; }
|
||||
unsigned num_nodes() const override { return 1; }
|
||||
unsigned num_leaves() const override { return this->ref_count()>0?1:0; }
|
||||
};
|
||||
|
||||
typedef buffer<std::pair<Key,node*>, true, 2> children_t;
|
||||
|
@ -99,7 +99,7 @@ class heap_trie {
|
|||
public:
|
||||
trie(): node(trie_t) {}
|
||||
|
||||
virtual ~trie() {
|
||||
~trie() override {
|
||||
}
|
||||
|
||||
node* find_or_insert(Key k, node* n) {
|
||||
|
@ -137,7 +137,7 @@ class heap_trie {
|
|||
children_t const& nodes() const { return m_nodes; }
|
||||
children_t & nodes() { return m_nodes; }
|
||||
|
||||
virtual void display(std::ostream& out, unsigned indent) const {
|
||||
void display(std::ostream& out, unsigned indent) const override {
|
||||
for (unsigned j = 0; j < m_nodes.size(); ++j) {
|
||||
if (j != 0 || indent > 0) {
|
||||
out << "\n";
|
||||
|
@ -151,7 +151,7 @@ class heap_trie {
|
|||
}
|
||||
}
|
||||
|
||||
virtual unsigned num_nodes() const {
|
||||
unsigned num_nodes() const override {
|
||||
unsigned sz = 1;
|
||||
for (unsigned j = 0; j < m_nodes.size(); ++j) {
|
||||
sz += m_nodes[j].second->num_nodes();
|
||||
|
@ -159,7 +159,7 @@ class heap_trie {
|
|||
return sz;
|
||||
}
|
||||
|
||||
virtual unsigned num_leaves() const {
|
||||
unsigned num_leaves() const override {
|
||||
unsigned sz = 0;
|
||||
for (unsigned j = 0; j < m_nodes.size(); ++j) {
|
||||
sz += m_nodes[j].second->num_leaves();
|
||||
|
@ -195,9 +195,9 @@ public:
|
|||
m_le(le),
|
||||
m_num_keys(0),
|
||||
m_do_reshuffle(4),
|
||||
m_root(0),
|
||||
m_spare_leaf(0),
|
||||
m_spare_trie(0)
|
||||
m_root(nullptr),
|
||||
m_spare_leaf(nullptr),
|
||||
m_spare_trie(nullptr)
|
||||
{}
|
||||
|
||||
~heap_trie() {
|
||||
|
@ -283,7 +283,7 @@ public:
|
|||
++m_stats.m_num_removes;
|
||||
// assumption: key is in table.
|
||||
node* n = m_root;
|
||||
node* m = 0;
|
||||
node* m = nullptr;
|
||||
for (unsigned i = 0; i < num_keys(); ++i) {
|
||||
n->dec_ref();
|
||||
VERIFY (to_trie(n)->find(get_key(keys, i), m));
|
||||
|
|
|
@ -174,8 +174,8 @@ class hilbert_basis::value_index2 {
|
|||
struct checker : public ht::check_value {
|
||||
hilbert_basis* hb;
|
||||
offset_t m_value;
|
||||
checker(): hb(0) {}
|
||||
virtual bool operator()(unsigned const& v) {
|
||||
checker(): hb(nullptr) {}
|
||||
bool operator()(unsigned const& v) override {
|
||||
if (m_value.m_offset != v) { // && hb->is_subsumed(m_value, offset_t(v))) {
|
||||
return true;
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ public:
|
|||
m_zero.insert(idx, vs);
|
||||
}
|
||||
else {
|
||||
value_index* map = 0;
|
||||
value_index* map = nullptr;
|
||||
if (!m_neg.find(vs.weight(), map)) {
|
||||
map = alloc(value_index, hb);
|
||||
map->reset(m_num_ineqs);
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace algebraic_numbers {
|
|||
unsigned m_sign_lower:1;
|
||||
unsigned m_not_rational:1; // if true we know for sure it is not a rational
|
||||
unsigned m_i:29; // number is the i-th root of p, 0 if it is not known which root of p the number is.
|
||||
algebraic_cell():m_p_sz(0), m_p(0), m_minimal(false), m_not_rational(false), m_i(0) {}
|
||||
algebraic_cell():m_p_sz(0), m_p(nullptr), m_minimal(false), m_not_rational(false), m_i(0) {}
|
||||
bool is_minimal() const { return m_minimal != 0; }
|
||||
};
|
||||
|
||||
|
@ -186,7 +186,7 @@ namespace algebraic_numbers {
|
|||
for (unsigned i = 0; i < c->m_p_sz; i++)
|
||||
qm().del(c->m_p[i]);
|
||||
m_allocator.deallocate(sizeof(mpz)*c->m_p_sz, c->m_p);
|
||||
c->m_p = 0;
|
||||
c->m_p = nullptr;
|
||||
c->m_p_sz = 0;
|
||||
}
|
||||
|
||||
|
@ -201,13 +201,13 @@ namespace algebraic_numbers {
|
|||
}
|
||||
|
||||
void del(numeral & a) {
|
||||
if (a.m_cell == 0)
|
||||
if (a.m_cell == nullptr)
|
||||
return;
|
||||
if (a.is_basic())
|
||||
del(a.to_basic());
|
||||
else
|
||||
del(a.to_algebraic());
|
||||
a.m_cell = 0;
|
||||
a.m_cell = nullptr;
|
||||
}
|
||||
|
||||
void reset(numeral & a) {
|
||||
|
@ -215,7 +215,7 @@ namespace algebraic_numbers {
|
|||
}
|
||||
|
||||
bool is_zero(numeral const & a) {
|
||||
return a.m_cell == 0;
|
||||
return a.m_cell == nullptr;
|
||||
}
|
||||
|
||||
bool is_pos(numeral const & a) {
|
||||
|
@ -361,7 +361,7 @@ namespace algebraic_numbers {
|
|||
|
||||
basic_cell * mk_basic_cell(mpq & n) {
|
||||
if (qm().is_zero(n))
|
||||
return 0;
|
||||
return nullptr;
|
||||
void * mem = static_cast<basic_cell*>(m_allocator.allocate(sizeof(basic_cell)));
|
||||
basic_cell * c = new (mem) basic_cell();
|
||||
qm().swap(c->m_value, n);
|
||||
|
@ -1037,7 +1037,7 @@ namespace algebraic_numbers {
|
|||
unsigned target_i = UINT_MAX; // index of sequence that is isolating
|
||||
int target_lV = 0, target_uV = 0;
|
||||
for (unsigned i = 0; i < num_fs; i++) {
|
||||
if (seqs[i] == 0)
|
||||
if (seqs[i] == nullptr)
|
||||
continue; // sequence was discarded because it does not contain the root.
|
||||
TRACE("anum_mk_binary", tout << "sequence " << i << "\n"; upm().display(tout, *(seqs[i])); tout << "\n";);
|
||||
int lV = upm().sign_variations_at(*(seqs[i]), r_i.lower());
|
||||
|
@ -1050,7 +1050,7 @@ namespace algebraic_numbers {
|
|||
);
|
||||
if (V <= 0) {
|
||||
// discard sequence, since factor does not contain the root
|
||||
seqs.set(i, 0);
|
||||
seqs.set(i, nullptr);
|
||||
}
|
||||
else if (V == 1) {
|
||||
target_i = i;
|
||||
|
@ -1115,7 +1115,7 @@ namespace algebraic_numbers {
|
|||
unsigned target_i = UINT_MAX; // index of sequence that is isolating
|
||||
int target_lV = 0, target_uV = 0;
|
||||
for (unsigned i = 0; i < num_fs; i++) {
|
||||
if (seqs[i] == 0)
|
||||
if (seqs[i] == nullptr)
|
||||
continue; // sequence was discarded because it does not contain the root.
|
||||
int lV = upm().sign_variations_at(*(seqs[i]), r_i.lower());
|
||||
int uV = upm().sign_variations_at(*(seqs[i]), r_i.upper());
|
||||
|
@ -1126,7 +1126,7 @@ namespace algebraic_numbers {
|
|||
);
|
||||
if (V <= 0) {
|
||||
// discard sequence, since factor does not contain the root
|
||||
seqs.set(i, 0);
|
||||
seqs.set(i, nullptr);
|
||||
}
|
||||
else if (V == 1) {
|
||||
target_i = i;
|
||||
|
@ -1932,9 +1932,9 @@ namespace algebraic_numbers {
|
|||
imp & m_imp;
|
||||
polynomial::var2anum const & m_x2v;
|
||||
opt_var2basic(imp & i, polynomial::var2anum const & x2v):m_imp(i), m_x2v(x2v) {}
|
||||
virtual unsynch_mpq_manager & m() const { return m_imp.qm(); }
|
||||
virtual bool contains(polynomial::var x) const { return m_x2v.contains(x); }
|
||||
virtual mpq const & operator()(polynomial::var x) const {
|
||||
unsynch_mpq_manager & m() const override { return m_imp.qm(); }
|
||||
bool contains(polynomial::var x) const override { return m_x2v.contains(x); }
|
||||
mpq const & operator()(polynomial::var x) const override {
|
||||
anum const & v = m_x2v(x);
|
||||
if (!v.is_basic())
|
||||
throw failed();
|
||||
|
@ -1949,9 +1949,9 @@ namespace algebraic_numbers {
|
|||
imp & m_imp;
|
||||
polynomial::var2anum const & m_x2v;
|
||||
var2basic(imp & i, polynomial::var2anum const & x2v):m_imp(i), m_x2v(x2v) {}
|
||||
virtual unsynch_mpq_manager & m() const { return m_imp.qm(); }
|
||||
virtual bool contains(polynomial::var x) const { return m_x2v.contains(x) && m_x2v(x).is_basic(); }
|
||||
virtual mpq const & operator()(polynomial::var x) const {
|
||||
unsynch_mpq_manager & m() const override { return m_imp.qm(); }
|
||||
bool contains(polynomial::var x) const override { return m_x2v.contains(x) && m_x2v(x).is_basic(); }
|
||||
mpq const & operator()(polynomial::var x) const override {
|
||||
anum const & v = m_x2v(x);
|
||||
SASSERT(v.is_basic());
|
||||
TRACE("var2basic", tout << "getting value of x" << x << " -> " << m().to_string(m_imp.basic_value(v)) << "\n";);
|
||||
|
@ -1966,9 +1966,9 @@ namespace algebraic_numbers {
|
|||
imp & m_imp;
|
||||
polynomial::var2anum const & m_x2v;
|
||||
var2interval(imp & i, polynomial::var2anum const & x2v):m_imp(i), m_x2v(x2v) {}
|
||||
virtual mpbqi_manager & m() const { return m_imp.bqim(); }
|
||||
virtual bool contains(polynomial::var x) const { return m_x2v.contains(x) && !m_x2v(x).is_basic(); }
|
||||
virtual mpbqi const & operator()(polynomial::var x) const {
|
||||
mpbqi_manager & m() const override { return m_imp.bqim(); }
|
||||
bool contains(polynomial::var x) const override { return m_x2v.contains(x) && !m_x2v(x).is_basic(); }
|
||||
mpbqi const & operator()(polynomial::var x) const override {
|
||||
anum const & v = m_x2v(x);
|
||||
SASSERT(!v.is_basic());
|
||||
return v.to_algebraic()->m_interval;
|
||||
|
@ -2220,9 +2220,9 @@ namespace algebraic_numbers {
|
|||
m_x(x),
|
||||
m_v(v) {
|
||||
}
|
||||
virtual manager & m() const { return m_am; }
|
||||
virtual bool contains(polynomial::var x) const { return x == m_x || m_x2v.contains(x); }
|
||||
virtual anum const & operator()(polynomial::var x) const {
|
||||
manager & m() const override { return m_am; }
|
||||
bool contains(polynomial::var x) const override { return x == m_x || m_x2v.contains(x); }
|
||||
anum const & operator()(polynomial::var x) const override {
|
||||
if (x == m_x)
|
||||
return m_v;
|
||||
else
|
||||
|
@ -2553,9 +2553,9 @@ namespace algebraic_numbers {
|
|||
m_x2v(x2v),
|
||||
m_v(v) {
|
||||
}
|
||||
virtual manager & m() const { return m_am; }
|
||||
virtual bool contains(polynomial::var x) const { return true; }
|
||||
virtual anum const & operator()(polynomial::var x) const {
|
||||
manager & m() const override { return m_am; }
|
||||
bool contains(polynomial::var x) const override { return true; }
|
||||
anum const & operator()(polynomial::var x) const override {
|
||||
if (m_x2v.contains(x))
|
||||
return m_x2v(x);
|
||||
else
|
||||
|
@ -2772,7 +2772,7 @@ namespace algebraic_numbers {
|
|||
manager::manager(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p, small_object_allocator * a) {
|
||||
m_own_allocator = false;
|
||||
m_allocator = a;
|
||||
if (m_allocator == 0) {
|
||||
if (m_allocator == nullptr) {
|
||||
m_own_allocator = true;
|
||||
m_allocator = alloc(small_object_allocator, "algebraic");
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace algebraic_numbers {
|
|||
typedef _scoped_numeral<manager> scoped_numeral;
|
||||
typedef _scoped_numeral_vector<manager> scoped_numeral_vector;
|
||||
|
||||
manager(reslimit& rl, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0);
|
||||
manager(reslimit& rl, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = nullptr);
|
||||
~manager();
|
||||
|
||||
static void get_param_descrs(param_descrs & r);
|
||||
|
@ -372,7 +372,7 @@ namespace algebraic_numbers {
|
|||
basic_cell * to_basic() const { SASSERT(is_basic()); return UNTAG(basic_cell*, m_cell); }
|
||||
algebraic_cell * to_algebraic() const { SASSERT(!is_basic()); return UNTAG(algebraic_cell*, m_cell); }
|
||||
public:
|
||||
anum():m_cell(0) {}
|
||||
anum():m_cell(nullptr) {}
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -150,7 +150,6 @@ namespace polynomial {
|
|||
return r;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Monomials (power products)
|
||||
*/
|
||||
|
@ -192,7 +191,7 @@ namespace polynomial {
|
|||
};
|
||||
|
||||
static unsigned get_obj_size(unsigned sz) { return sizeof(monomial) + sz * sizeof(power); }
|
||||
|
||||
|
||||
monomial(unsigned id, unsigned sz, power const * pws, unsigned h):
|
||||
m_ref_count(0),
|
||||
m_id(id),
|
||||
|
@ -257,9 +256,7 @@ namespace polynomial {
|
|||
if (m_size < SMALL_MONOMIAL) {
|
||||
// use linear search for small monomials
|
||||
// search backwards since we usually ask for the degree of "big" variables
|
||||
unsigned i = last;
|
||||
while (i > 0) {
|
||||
--i;
|
||||
for (unsigned i = last; i-- > 0; ) {
|
||||
if (get_var(i) == x)
|
||||
return i;
|
||||
}
|
||||
|
@ -513,7 +510,7 @@ namespace polynomial {
|
|||
|
||||
monomial * allocate(unsigned capacity) {
|
||||
void * mem = memory::allocate(monomial::get_obj_size(capacity));
|
||||
return new (mem) monomial(UINT_MAX, 0, 0, 0);
|
||||
return new (mem) monomial(UINT_MAX, 0, nullptr, 0);
|
||||
}
|
||||
|
||||
void deallocate(monomial * ptr, unsigned capacity) {
|
||||
|
@ -779,10 +776,10 @@ namespace polynomial {
|
|||
tmp_monomial m_tmp3;
|
||||
svector<power> m_powers_tmp;
|
||||
public:
|
||||
monomial_manager(small_object_allocator * a = 0) {
|
||||
monomial_manager(small_object_allocator * a = nullptr) {
|
||||
m_ref_count = 0;
|
||||
m_next_var = 0;
|
||||
if (a == 0) {
|
||||
if (a == nullptr) {
|
||||
m_allocator = alloc(small_object_allocator, "polynomial");
|
||||
m_own_allocator = true;
|
||||
}
|
||||
|
@ -790,7 +787,7 @@ namespace polynomial {
|
|||
m_allocator = a;
|
||||
m_own_allocator = false;
|
||||
}
|
||||
m_unit = mk_monomial(0, static_cast<power const *>(0));
|
||||
m_unit = mk_monomial(0, static_cast<power const *>(nullptr));
|
||||
inc_ref(m_unit);
|
||||
}
|
||||
|
||||
|
@ -798,9 +795,8 @@ namespace polynomial {
|
|||
dec_ref(m_unit);
|
||||
CTRACE("polynomial", !m_monomials.empty(),
|
||||
tout << "monomials leaked\n";
|
||||
monomial_table::iterator it = m_monomials.begin(); monomial_table::iterator end = m_monomials.end();
|
||||
for (; it != end; ++it) {
|
||||
(*it)->display(tout); tout << "\n";
|
||||
for (auto * m : m_monomials) {
|
||||
m->display(tout); tout << "\n";
|
||||
});
|
||||
SASSERT(m_monomials.empty());
|
||||
if (m_own_allocator)
|
||||
|
@ -1189,7 +1185,7 @@ namespace polynomial {
|
|||
sqrt_tmp.reserve(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
if (m->degree(i) % 2 == 1)
|
||||
return 0;
|
||||
return nullptr;
|
||||
sqrt_tmp.set_power(i, power(m->get_var(i), m->degree(i) / 2));
|
||||
}
|
||||
sqrt_tmp.set_size(sz);
|
||||
|
@ -1425,7 +1421,7 @@ namespace polynomial {
|
|||
}
|
||||
}
|
||||
|
||||
// Return the maximal variable y occuring in [m_ms + start, m_ms + end) that is smaller than x
|
||||
// Return the maximal variable y occurring in [m_ms + start, m_ms + end) that is smaller than x
|
||||
var max_smaller_than(unsigned start, unsigned end, var x) {
|
||||
var max = null_var;
|
||||
for (unsigned i = start; i < end; i++) {
|
||||
|
@ -1460,7 +1456,7 @@ namespace polynomial {
|
|||
}
|
||||
|
||||
/**
|
||||
\brief Make sure that the first monomial contains the maximal variable x occuring in the polynomial,
|
||||
\brief Make sure that the first monomial contains the maximal variable x occurring in the polynomial,
|
||||
and x occurs with maximal degree.
|
||||
*/
|
||||
void make_first_maximal() {
|
||||
|
@ -1510,6 +1506,8 @@ namespace polynomial {
|
|||
unsigned id() const { return m_id; }
|
||||
unsigned size() const { return m_size; }
|
||||
monomial * m(unsigned idx) const { SASSERT(idx < size()); return m_ms[idx]; }
|
||||
monomial *const* begin() const { return m_ms; }
|
||||
monomial *const* end() const { return m_ms + size(); }
|
||||
numeral const & a(unsigned idx) const { SASSERT(idx < size()); return m_as[idx]; }
|
||||
numeral & a(unsigned idx) { SASSERT(idx < size()); return m_as[idx]; }
|
||||
numeral const * as() const { return m_as; }
|
||||
|
@ -1773,11 +1771,9 @@ namespace polynomial {
|
|||
}
|
||||
|
||||
bool manager::is_linear(polynomial const * p) {
|
||||
unsigned sz = p->size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
if (!is_linear(p->m(0)))
|
||||
for (monomial* m : *p)
|
||||
if (!is_linear(m))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1931,7 +1927,7 @@ namespace polynomial {
|
|||
}
|
||||
|
||||
public:
|
||||
som_buffer():m_owner(0) {}
|
||||
som_buffer():m_owner(nullptr) {}
|
||||
|
||||
void reset() {
|
||||
if (empty())
|
||||
|
@ -2177,7 +2173,7 @@ namespace polynomial {
|
|||
|
||||
public:
|
||||
som_buffer_vector() {
|
||||
m_owner = 0;
|
||||
m_owner = nullptr;
|
||||
}
|
||||
|
||||
~som_buffer_vector() {
|
||||
|
@ -2189,7 +2185,7 @@ namespace polynomial {
|
|||
|
||||
void set_owner(imp * owner) {
|
||||
SASSERT(m_owner == owner || m_owner == 0);
|
||||
if (m_owner == 0) {
|
||||
if (m_owner == nullptr) {
|
||||
m_owner = owner;
|
||||
unsigned sz = m_buffers.size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
|
@ -2226,7 +2222,7 @@ namespace polynomial {
|
|||
numeral_vector m_tmp_as;
|
||||
monomial_vector m_tmp_ms;
|
||||
public:
|
||||
cheap_som_buffer():m_owner(0) {}
|
||||
cheap_som_buffer():m_owner(nullptr) {}
|
||||
|
||||
void set_owner(imp * o) { m_owner = o; }
|
||||
bool empty() const { return m_tmp_ms.empty(); }
|
||||
|
@ -2310,12 +2306,12 @@ namespace polynomial {
|
|||
cheap_som_buffer m_cheap_som_buffer2;
|
||||
|
||||
void init() {
|
||||
m_del_eh = 0;
|
||||
m_del_eh = nullptr;
|
||||
m_som_buffer.set_owner(this);
|
||||
m_som_buffer2.set_owner(this);
|
||||
m_cheap_som_buffer.set_owner(this);
|
||||
m_cheap_som_buffer2.set_owner(this);
|
||||
m_zero = mk_polynomial_core(0, 0, 0);
|
||||
m_zero = mk_polynomial_core(0, nullptr, nullptr);
|
||||
m().set(m_zero_numeral, 0);
|
||||
inc_ref(m_zero);
|
||||
numeral one(1);
|
||||
|
@ -2330,7 +2326,7 @@ namespace polynomial {
|
|||
m_wrapper(w),
|
||||
m_manager(m),
|
||||
m_upm(lim, m) {
|
||||
if (mm == 0)
|
||||
if (mm == nullptr)
|
||||
mm = alloc(monomial_manager);
|
||||
m_monomial_manager = mm;
|
||||
m_monomial_manager->inc_ref();
|
||||
|
@ -2396,6 +2392,7 @@ namespace polynomial {
|
|||
return mm().is_valid(x);
|
||||
}
|
||||
|
||||
|
||||
void add_del_eh(del_eh * eh) {
|
||||
eh->m_next = m_del_eh;
|
||||
m_del_eh = eh;
|
||||
|
@ -2422,13 +2419,13 @@ namespace polynomial {
|
|||
|
||||
void del(polynomial * p) {
|
||||
TRACE("polynomial", tout << "deleting: "; p->display(tout, m_manager); tout << "\n";);
|
||||
if (m_del_eh != 0) {
|
||||
if (m_del_eh != nullptr) {
|
||||
del_eh * curr = m_del_eh;
|
||||
do {
|
||||
(*curr)(p);
|
||||
curr = curr->m_next;
|
||||
}
|
||||
while (curr != 0);
|
||||
while (curr != nullptr);
|
||||
}
|
||||
unsigned sz = p->size();
|
||||
unsigned obj_sz = polynomial::get_obj_size(sz);
|
||||
|
@ -2927,7 +2924,7 @@ namespace polynomial {
|
|||
imp * m_imp;
|
||||
ptr_vector<newton_interpolator> m_data;
|
||||
public:
|
||||
newton_interpolator_vector():m_imp(0) {}
|
||||
newton_interpolator_vector():m_imp(nullptr) {}
|
||||
|
||||
~newton_interpolator_vector() {
|
||||
flush();
|
||||
|
@ -2986,7 +2983,7 @@ namespace polynomial {
|
|||
ms.push_back(p->m(i));
|
||||
}
|
||||
std::sort(ms.begin(), ms.end(), lex_lt2(x));
|
||||
monomial * prev = 0;
|
||||
monomial * prev = nullptr;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
monomial * orig_m = ms[i];
|
||||
monomial * m;
|
||||
|
@ -3212,7 +3209,7 @@ namespace polynomial {
|
|||
typedef sbuffer<var, 32> var_buffer;
|
||||
|
||||
/**
|
||||
Store in pws the variables occuring in p and their (minimal or maximal) degrees.
|
||||
Store in pws the variables occurring in p and their (minimal or maximal) degrees.
|
||||
*/
|
||||
unsigned_vector m_var_degrees_tmp;
|
||||
template<bool Max>
|
||||
|
@ -3473,7 +3470,7 @@ namespace polynomial {
|
|||
pp = mk_one();
|
||||
return;
|
||||
}
|
||||
// Apply filter and collect powers of x occuring in p
|
||||
// Apply filter and collect powers of x occurring in p
|
||||
// The quick filter is the following:
|
||||
// If p contains a monomial x^k and no monomial of the form m*x^k m != 1, then
|
||||
// c = m_unit_poly
|
||||
|
@ -3482,7 +3479,7 @@ namespace polynomial {
|
|||
// - found monomial x^k then iccp_powers[k]++;
|
||||
// - found monomial m*x^k then iccp_powers[k]+=2;
|
||||
// If after traversing p, there is a k s.t. iccp_powers[k] == 1, we know c == 1
|
||||
// We store iccp_powers the powers of x occuring in p.
|
||||
// We store iccp_powers the powers of x occurring in p.
|
||||
sbuffer<unsigned, 128> iccp_filter;
|
||||
sbuffer<unsigned, 128> iccp_powers;
|
||||
iccp_filter.resize(d+1, 0);
|
||||
|
@ -3834,7 +3831,7 @@ namespace polynomial {
|
|||
r = mk_const(d_a);
|
||||
return;
|
||||
}
|
||||
if (C_star.get() == 0) {
|
||||
if (C_star.get() == nullptr) {
|
||||
C_star = q;
|
||||
m().set(bound, p);
|
||||
}
|
||||
|
@ -4156,7 +4153,7 @@ namespace polynomial {
|
|||
counter = 0;
|
||||
min_deg_q = deg_q;
|
||||
// start from scratch
|
||||
if (sk == 0) {
|
||||
if (sk == nullptr) {
|
||||
interpolator.reset();
|
||||
interpolator.add(val, q);
|
||||
}
|
||||
|
@ -4168,7 +4165,7 @@ namespace polynomial {
|
|||
}
|
||||
else if (deg_q == min_deg_q) {
|
||||
TRACE("mgcd_detail", tout << "adding sample point...\n";);
|
||||
if (sk == 0) {
|
||||
if (sk == nullptr) {
|
||||
interpolator.add(val, q);
|
||||
}
|
||||
else {
|
||||
|
@ -4181,7 +4178,7 @@ namespace polynomial {
|
|||
continue;
|
||||
}
|
||||
bool found_candidate = false;
|
||||
if (sk == 0) {
|
||||
if (sk == nullptr) {
|
||||
SASSERT(interpolator.num_sample_points() > 0);
|
||||
interpolator.mk(x, H);
|
||||
TRACE("mgcd_detail", tout << "idx: " << idx << "\ncandidate H: " << H << "\n";);
|
||||
|
@ -4217,14 +4214,14 @@ namespace polynomial {
|
|||
r = mul(ci_g, r);
|
||||
done = true;
|
||||
}
|
||||
else if (sk != 0) {
|
||||
else if (sk != nullptr) {
|
||||
throw sparse_mgcd_failed();
|
||||
}
|
||||
}
|
||||
|
||||
if (done) {
|
||||
TRACE("mgcd", tout << "idx: " << idx << "\nresult: " << r << "\n";);
|
||||
if (sk == 0 && m_use_sparse_gcd) {
|
||||
if (sk == nullptr && m_use_sparse_gcd) {
|
||||
// save skeleton
|
||||
skeleton * new_sk = alloc(skeleton, *this, H, x);
|
||||
m_mgcd_skeletons.set(idx, new_sk);
|
||||
|
@ -4258,7 +4255,7 @@ namespace polynomial {
|
|||
m_mgcd_skeletons.reset();
|
||||
for (unsigned i = 0; i < num_vars; i++) {
|
||||
vars.push_back(var_min_degrees[i].get_var());
|
||||
m_mgcd_skeletons.push_back(0);
|
||||
m_mgcd_skeletons.push_back(nullptr);
|
||||
}
|
||||
|
||||
scoped_numeral c_u(m()), c_v(m());
|
||||
|
@ -4314,7 +4311,7 @@ namespace polynomial {
|
|||
r = mk_const(d_a);
|
||||
return;
|
||||
}
|
||||
if (C_star.get() == 0) {
|
||||
if (C_star.get() == nullptr) {
|
||||
C_star = q;
|
||||
m().set(bound, p);
|
||||
}
|
||||
|
@ -4906,7 +4903,7 @@ namespace polynomial {
|
|||
*/
|
||||
template<bool Exact_d, bool Quotient, bool ModD>
|
||||
void pseudo_division_core(polynomial const * p, polynomial const * q, var x, unsigned & d, polynomial_ref & Q, polynomial_ref & R,
|
||||
var2degree const * x2d = 0) {
|
||||
var2degree const * x2d = nullptr) {
|
||||
SASSERT(is_valid(x));
|
||||
SASSERT(!ModD || x2d != 0);
|
||||
TRACE("polynomial", tout << "pseudo_division\np: "; p->display(tout, m_manager);
|
||||
|
@ -5141,7 +5138,7 @@ namespace polynomial {
|
|||
}
|
||||
monomial const * m_r = R.m(max_R);
|
||||
numeral const & a_r = R.a(max_R);
|
||||
monomial * m_r_q = 0;
|
||||
monomial * m_r_q = nullptr;
|
||||
VERIFY(div(m_r, m_q, m_r_q));
|
||||
TRACE("polynomial", tout << "m_r: "; m_r->display(tout); tout << "\nm_q: "; m_q->display(tout); tout << "\n";
|
||||
if (m_r_q) { tout << "m_r_q: "; m_r_q->display(tout); tout << "\n"; });
|
||||
|
@ -5178,7 +5175,7 @@ namespace polynomial {
|
|||
}
|
||||
monomial const * m_r = R.m(max_R);
|
||||
numeral const & a_r = R.a(max_R);
|
||||
monomial * m_r_q = 0;
|
||||
monomial * m_r_q = nullptr;
|
||||
bool q_div_r = div(m_r, m_q, m_r_q);
|
||||
m_r_q_ref = m_r_q;
|
||||
TRACE("polynomial", tout << "m_r: "; m_r->display(tout); tout << "\nm_q: "; m_q->display(tout); tout << "\n";
|
||||
|
@ -5642,7 +5639,7 @@ namespace polynomial {
|
|||
pw(h1, d1, hs1);
|
||||
hs1 = mul(g1, hs1);
|
||||
G3 = exact_div(Gh3, hs1);
|
||||
hs1 = 0;
|
||||
hs1 = nullptr;
|
||||
}
|
||||
|
||||
// prepare for next iteration
|
||||
|
@ -6086,7 +6083,7 @@ namespace polynomial {
|
|||
polynomial_vector::iterator end2 = m_polynomials.end();
|
||||
for (; it2 != end2; ++it2) {
|
||||
polynomial * p = *it2;
|
||||
if (p == 0)
|
||||
if (p == nullptr)
|
||||
continue;
|
||||
p->make_first_maximal();
|
||||
SASSERT(p->size() <= 1 || !p->lex_sorted());
|
||||
|
@ -6101,6 +6098,33 @@ namespace polynomial {
|
|||
});
|
||||
}
|
||||
|
||||
lbool sign(monomial* m, numeral const& c, svector<lbool> const& sign_of_vars) {
|
||||
unsigned sz = size(m);
|
||||
lbool sign1 = m_manager.is_pos(c) ? l_true : l_false;
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var v = get_var(m, i);
|
||||
unsigned d = degree(m, i);
|
||||
lbool sign2 = sign_of_vars.get(v, l_undef);
|
||||
if (sign2 == l_undef)
|
||||
return l_undef;
|
||||
else if (1 == (d % 2) && sign2 == l_false) {
|
||||
sign1 = sign1 == l_true ? l_false : l_true;
|
||||
}
|
||||
}
|
||||
return sign1;
|
||||
}
|
||||
|
||||
lbool sign(polynomial const * p, svector<lbool> const& sign_of_vars) {
|
||||
unsigned sz = size(p);
|
||||
if (sz == 0) return l_undef;
|
||||
lbool sign1 = sign(p->m(0), p->a(0), sign_of_vars);
|
||||
for (unsigned i = 1; sign1 != l_undef && i < sz; ++i) {
|
||||
if (sign(p->m(i), p->a(i), sign_of_vars) != sign1)
|
||||
return l_undef;
|
||||
}
|
||||
return sign1;
|
||||
}
|
||||
|
||||
bool is_pos(polynomial const * p) {
|
||||
bool found_unit = false;
|
||||
unsigned sz = p->size();
|
||||
|
@ -6326,9 +6350,9 @@ namespace polynomial {
|
|||
m_var_pos(buffer, xs_sz, xs),
|
||||
m_vs(vs) {
|
||||
}
|
||||
virtual unsynch_mpq_manager & m() const { UNREACHABLE(); static unsynch_mpq_manager m; return m; }
|
||||
virtual bool contains(var x) const { return m_var_pos(x) != UINT_MAX; }
|
||||
virtual mpq const & operator()(var x) const { return m_vs[m_var_pos(x)]; }
|
||||
unsynch_mpq_manager & m() const override { UNREACHABLE(); static unsynch_mpq_manager m; return m; }
|
||||
bool contains(var x) const override { return m_var_pos(x) != UINT_MAX; }
|
||||
mpq const & operator()(var x) const override { return m_vs[m_var_pos(x)]; }
|
||||
};
|
||||
|
||||
polynomial * substitute(polynomial const * p, unsigned xs_sz, var const * xs, mpq const * vs) {
|
||||
|
@ -6372,6 +6396,31 @@ namespace polynomial {
|
|||
R.add(new_a, mk_monomial(new_m));
|
||||
}
|
||||
return R.mk();
|
||||
}
|
||||
|
||||
void substitute(polynomial const* r, var x, polynomial const* p, polynomial const* q, polynomial_ref& result) {
|
||||
unsigned md = degree(r, x);
|
||||
if (md == 0) {
|
||||
result = const_cast<polynomial*>(r);
|
||||
return;
|
||||
}
|
||||
result = nullptr;
|
||||
polynomial_ref p1(pm()), q1(pm());
|
||||
polynomial_ref_buffer ps(pm());
|
||||
unsigned sz = r->size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
monomial * m0 = r->m(i);
|
||||
unsigned dm = m0->degree_of(x);
|
||||
SASSERT(md >= dm);
|
||||
monomial_ref m1(div_x(m0, x), pm());
|
||||
pw(p, dm, p1);
|
||||
pw(q, md - dm, q1);
|
||||
p1 = mul(r->a(i), m1, p1 * q1);
|
||||
if (result)
|
||||
result = add(result, p1);
|
||||
else
|
||||
result = p1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -6478,9 +6527,9 @@ namespace polynomial {
|
|||
numeral const & m_val;
|
||||
public:
|
||||
single_var2value(numeral_manager & m, var x, numeral const & val):m_manager(m), m_x(x), m_val(val) {}
|
||||
virtual numeral_manager & m() const { return m_manager; }
|
||||
virtual bool contains(var x) const { return m_x == x; }
|
||||
virtual numeral const & operator()(var x) const { SASSERT(m_x == x); return m_val; }
|
||||
numeral_manager & m() const override { return m_manager; }
|
||||
bool contains(var x) const override { return m_x == x; }
|
||||
numeral const & operator()(var x) const override { SASSERT(m_x == x); return m_val; }
|
||||
};
|
||||
|
||||
void univ_eval(polynomial const * p, var x, numeral const & val, numeral & r) {
|
||||
|
@ -6918,6 +6967,18 @@ namespace polynomial {
|
|||
return m_imp->m().set_zp(p);
|
||||
}
|
||||
|
||||
bool manager::is_var(polynomial const* p, var& v) {
|
||||
return p->size() == 1 && is_var(p->m(0), v) && m_imp->m().is_one(p->a(0));
|
||||
}
|
||||
|
||||
bool manager::is_var(monomial const* m, var& v) {
|
||||
return m->size() == 1 && m->degree(0) == 1 && (v = m->get_var(0), true);
|
||||
}
|
||||
|
||||
bool manager::is_var_num(polynomial const* p, var& v, scoped_numeral& n) {
|
||||
return p->size() == 2 && m_imp->m().is_one(p->a(0)) && is_var(p->m(0), v) && is_unit(p->m(1)) && (n = p->a(1), true);
|
||||
}
|
||||
|
||||
small_object_allocator & manager::allocator() const {
|
||||
return m_imp->mm().allocator();
|
||||
}
|
||||
|
@ -7271,6 +7332,10 @@ namespace polynomial {
|
|||
void manager::psc_chain(polynomial const * p, polynomial const * q, var x, polynomial_ref_vector & S) {
|
||||
m_imp->psc_chain(p, q, x, S);
|
||||
}
|
||||
|
||||
lbool manager::sign(polynomial const * p, svector<lbool> const& sign_of_vars) {
|
||||
return m_imp->sign(p, sign_of_vars);
|
||||
}
|
||||
|
||||
bool manager::is_pos(polynomial const * p) {
|
||||
return m_imp->is_pos(p);
|
||||
|
@ -7307,6 +7372,10 @@ namespace polynomial {
|
|||
polynomial * manager::substitute(polynomial const * p, unsigned xs_sz, var const * xs, numeral const * vs) {
|
||||
return m_imp->substitute(p, xs_sz, xs, vs);
|
||||
}
|
||||
|
||||
void manager::substitute(polynomial const* r, var x, polynomial const* p, polynomial const* q, polynomial_ref& result) {
|
||||
m_imp->substitute(r, x, p, q, result);
|
||||
}
|
||||
|
||||
void manager::factor(polynomial const * p, factors & r, factor_params const & params) {
|
||||
m_imp->factor(p, r, params);
|
||||
|
|
|
@ -29,6 +29,7 @@ Notes:
|
|||
#include "util/params.h"
|
||||
#include "util/mpbqi.h"
|
||||
#include "util/rlimit.h"
|
||||
#include "util/lbool.h"
|
||||
|
||||
class small_object_allocator;
|
||||
|
||||
|
@ -98,7 +99,7 @@ namespace polynomial {
|
|||
};
|
||||
|
||||
struct display_var_proc {
|
||||
virtual void operator()(std::ostream & out, var x) const { out << "x" << x; }
|
||||
virtual std::ostream& operator()(std::ostream & out, var x) const { return out << "x" << x; }
|
||||
};
|
||||
|
||||
class polynomial;
|
||||
|
@ -191,7 +192,7 @@ namespace polynomial {
|
|||
private:
|
||||
imp * m_imp;
|
||||
public:
|
||||
manager(reslimit& lim, numeral_manager & m, monomial_manager * mm = 0);
|
||||
manager(reslimit& lim, numeral_manager & m, monomial_manager * mm = nullptr);
|
||||
manager(reslimit& lim, numeral_manager & m, small_object_allocator * a);
|
||||
~manager();
|
||||
|
||||
|
@ -226,13 +227,13 @@ namespace polynomial {
|
|||
friend class manager;
|
||||
del_eh * m_next;
|
||||
public:
|
||||
del_eh():m_next(0) {}
|
||||
del_eh():m_next(nullptr) {}
|
||||
virtual void operator()(polynomial * p) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Install a "delete polynomial" event handler.
|
||||
The even hanlder is not owned by the polynomial manager.
|
||||
The event handler is not owned by the polynomial manager.
|
||||
If eh = 0, then it uninstall the event handler.
|
||||
*/
|
||||
void add_del_eh(del_eh * eh);
|
||||
|
@ -306,12 +307,27 @@ namespace polynomial {
|
|||
\brief Return true if m is linear (i.e., it is of the form 1 or x).
|
||||
*/
|
||||
static bool is_linear(monomial const * m);
|
||||
|
||||
|
||||
/**
|
||||
\brief Return true if all monomials in p are linear.
|
||||
*/
|
||||
static bool is_linear(polynomial const * p);
|
||||
|
||||
/**
|
||||
\brief Return true if the monomial is a variable.
|
||||
*/
|
||||
static bool is_var(monomial const* p, var& v);
|
||||
|
||||
/**
|
||||
\brief Return true if the polynomial is a variable.
|
||||
*/
|
||||
bool is_var(polynomial const* p, var& v);
|
||||
|
||||
/**
|
||||
\brief Return true if the polynomial is of the form x + k
|
||||
*/
|
||||
bool is_var_num(polynomial const* p, var& v, scoped_numeral& n);
|
||||
|
||||
/**
|
||||
\brief Return the degree of variable x in p.
|
||||
*/
|
||||
|
@ -410,7 +426,7 @@ namespace polynomial {
|
|||
polynomial * flip_sign_if_lm_neg(polynomial const * p);
|
||||
|
||||
/**
|
||||
\breif Return the gcd g of p and q.
|
||||
\brief Return the gcd g of p and q.
|
||||
*/
|
||||
void gcd(polynomial const * p, polynomial const * q, polynomial_ref & g);
|
||||
|
||||
|
@ -837,7 +853,7 @@ namespace polynomial {
|
|||
void resultant(polynomial const * p, polynomial const * q, var x, polynomial_ref & r);
|
||||
|
||||
/**
|
||||
\brief Stroe in r the discriminant of p with respect to variable x.
|
||||
\brief Store in r the discriminant of p with respect to variable x.
|
||||
discriminant(p, x, r) == resultant(p, derivative(p, x), x, r)
|
||||
*/
|
||||
void discriminant(polynomial const * p, var x, polynomial_ref & r);
|
||||
|
@ -860,7 +876,13 @@ namespace polynomial {
|
|||
\brief Return true if p is a square, and store its square root in r.
|
||||
*/
|
||||
bool sqrt(polynomial const * p, polynomial_ref & r);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\brief obtain the sign of the polynomial given sign of variables.
|
||||
*/
|
||||
lbool sign(polynomial const* p, svector<lbool> const& sign_of_vars);
|
||||
|
||||
/**
|
||||
\brief Return true if p is always positive for any assignment of its variables.
|
||||
|
||||
|
@ -936,6 +958,13 @@ namespace polynomial {
|
|||
return substitute(p, 1, &x, &v);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Apply substitution [x -> p/q] in r.
|
||||
That is, given r \in Z[x, y_1, .., y_m] return
|
||||
polynomial q^k * r(p/q, y_1, .., y_m), where k is the maximal degree of x in r.
|
||||
*/
|
||||
void substitute(polynomial const* r, var x, polynomial const* p, polynomial const* q, polynomial_ref& result);
|
||||
|
||||
/**
|
||||
\brief Factorize the given polynomial p and store its factors in r.
|
||||
*/
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace polynomial {
|
|||
m_x(x),
|
||||
m_hash(h),
|
||||
m_result_sz(0),
|
||||
m_result(0) {
|
||||
m_result(nullptr) {
|
||||
}
|
||||
|
||||
struct hash_proc { unsigned operator()(psc_chain_entry const * entry) const { return entry->m_hash; } };
|
||||
|
@ -69,7 +69,7 @@ namespace polynomial {
|
|||
m_p(p),
|
||||
m_hash(h),
|
||||
m_result_sz(0),
|
||||
m_result(0) {
|
||||
m_result(nullptr) {
|
||||
}
|
||||
|
||||
struct hash_proc { unsigned operator()(factor_entry const * entry) const { return entry->m_hash; } };
|
||||
|
|
|
@ -32,9 +32,9 @@ namespace polynomial {
|
|||
public:
|
||||
simple_var2value(ValManager & m):m_vs(m) {}
|
||||
void push_back(var x, typename ValManager::numeral const & v) { m_xs.push_back(x); m_vs.push_back(v); }
|
||||
virtual ValManager & m() const { return m_vs.m(); }
|
||||
virtual bool contains(var x) const { return std::find(m_xs.begin(), m_xs.end(), x) != m_xs.end(); }
|
||||
virtual typename ValManager::numeral const & operator()(var x) const {
|
||||
ValManager & m() const override { return m_vs.m(); }
|
||||
bool contains(var x) const override { return std::find(m_xs.begin(), m_xs.end(), x) != m_xs.end(); }
|
||||
typename ValManager::numeral const & operator()(var x) const override {
|
||||
for (unsigned i = 0; i < m_xs.size(); i++)
|
||||
if (m_xs[i] == x)
|
||||
return m_vs[i];
|
||||
|
|
|
@ -63,8 +63,8 @@ namespace rpolynomial {
|
|||
m_wrapper(w),
|
||||
m_manager(m),
|
||||
m_allocator(a),
|
||||
m_own_allocator(a == 0) {
|
||||
if (a == 0)
|
||||
m_own_allocator(a == nullptr) {
|
||||
if (a == nullptr)
|
||||
m_allocator = alloc(small_object_allocator, "rpolynomial");
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ namespace rpolynomial {
|
|||
unsigned sz = p->size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
poly_or_num * pn = p->arg(i);
|
||||
if (pn == 0)
|
||||
if (pn == nullptr)
|
||||
continue;
|
||||
if (is_num(pn)) {
|
||||
del_numeral(to_num_ptr(pn));
|
||||
|
@ -141,11 +141,11 @@ namespace rpolynomial {
|
|||
|
||||
static bool is_const(polynomial const * p) {
|
||||
SASSERT(p == 0 || (p->max_var() == null_var) == (p->size() == 1 && p->arg(0) != 0 && is_num(p->arg(0))));
|
||||
return p == 0 || p->max_var() == null_var;
|
||||
return p == nullptr || p->max_var() == null_var;
|
||||
}
|
||||
|
||||
bool is_zero(polynomial const * p) {
|
||||
return p == 0;
|
||||
return p == nullptr;
|
||||
}
|
||||
|
||||
static bool is_univariate(polynomial const * p) {
|
||||
|
@ -154,7 +154,7 @@ namespace rpolynomial {
|
|||
unsigned sz = p->size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
poly_or_num * pn = p->arg(i);
|
||||
if (pn == 0)
|
||||
if (pn == nullptr)
|
||||
continue;
|
||||
if (is_poly(pn))
|
||||
return false;
|
||||
|
@ -169,7 +169,7 @@ namespace rpolynomial {
|
|||
SASSERT(sz > 0);
|
||||
SASSERT(p->arg(sz - 1) != 0);
|
||||
for (unsigned i = 0; i < sz - 1; i++) {
|
||||
if (p->arg(i) != 0)
|
||||
if (p->arg(i) != nullptr)
|
||||
return false;
|
||||
}
|
||||
SASSERT(is_poly(p->arg(sz - 1)));
|
||||
|
@ -179,13 +179,13 @@ namespace rpolynomial {
|
|||
unsigned degree(polynomial const * p) {
|
||||
SASSERT(p != 0);
|
||||
SASSERT(p->size() > 0);
|
||||
return p == 0 ? 0 : p->size() - 1;
|
||||
return p == nullptr ? 0 : p->size() - 1;
|
||||
}
|
||||
|
||||
bool eq(polynomial const * p1, polynomial const * p2) {
|
||||
if (p1 == p2)
|
||||
return true;
|
||||
if (p1 == 0 || p2 == 0)
|
||||
if (p1 == nullptr || p2 == nullptr)
|
||||
return false;
|
||||
if (p1->size() != p2->size())
|
||||
return false;
|
||||
|
@ -195,9 +195,9 @@ namespace rpolynomial {
|
|||
for (unsigned i = 0; i < sz; i++) {
|
||||
poly_or_num * pn1 = p1->arg(i);
|
||||
poly_or_num * pn2 = p2->arg(i);
|
||||
if (pn1 == 0 && pn2 == 0)
|
||||
if (pn1 == nullptr && pn2 == nullptr)
|
||||
continue;
|
||||
if (pn1 == 0 || pn2 == 0)
|
||||
if (pn1 == nullptr || pn2 == nullptr)
|
||||
return false;
|
||||
if (is_num(pn1) && is_num(pn2)) {
|
||||
if (!m_manager.eq(to_num(pn1), to_num(pn2)))
|
||||
|
@ -217,7 +217,7 @@ namespace rpolynomial {
|
|||
void inc_ref_args(unsigned sz, poly_or_num * const * args) {
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
poly_or_num * pn = args[i];
|
||||
if (pn == 0 || is_num(pn))
|
||||
if (pn == nullptr || is_num(pn))
|
||||
continue;
|
||||
inc_ref(to_poly(pn));
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ namespace rpolynomial {
|
|||
void dec_ref_args(unsigned sz, poly_or_num * const * args) {
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
poly_or_num * pn = args[i];
|
||||
if (pn == 0 || is_num(pn))
|
||||
if (pn == nullptr || is_num(pn))
|
||||
continue;
|
||||
dec_ref(to_poly(pn));
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ namespace rpolynomial {
|
|||
|
||||
unsigned trim(unsigned sz, poly_or_num * const * args) {
|
||||
while (sz > 0) {
|
||||
if (args[sz - 1] != 0)
|
||||
if (args[sz - 1] != nullptr)
|
||||
return sz;
|
||||
sz--;
|
||||
}
|
||||
|
@ -281,8 +281,8 @@ namespace rpolynomial {
|
|||
|
||||
polynomial * mk_poly(unsigned sz, poly_or_num * const * args, var max_var) {
|
||||
poly_or_num * _p = mk_poly_core(sz, args, max_var);
|
||||
if (_p == 0)
|
||||
return 0;
|
||||
if (_p == nullptr)
|
||||
return nullptr;
|
||||
else if (is_num(_p))
|
||||
return allocate_poly(1, &_p, null_var);
|
||||
else
|
||||
|
@ -291,7 +291,7 @@ namespace rpolynomial {
|
|||
|
||||
polynomial * mk_const(numeral const & n) {
|
||||
if (m_manager.is_zero(n))
|
||||
return 0;
|
||||
return nullptr;
|
||||
numeral * a = mk_numeral();
|
||||
m_manager.set(*a, n);
|
||||
poly_or_num * _a = to_poly_or_num(a);
|
||||
|
@ -322,8 +322,8 @@ namespace rpolynomial {
|
|||
}
|
||||
|
||||
poly_or_num * unpack(polynomial const * p) {
|
||||
if (p == 0) {
|
||||
return 0;
|
||||
if (p == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
else if (is_const(p)) {
|
||||
SASSERT(p->size() == 1);
|
||||
|
@ -336,8 +336,8 @@ namespace rpolynomial {
|
|||
}
|
||||
|
||||
polynomial * pack(poly_or_num * p) {
|
||||
if (p == 0)
|
||||
return 0;
|
||||
if (p == nullptr)
|
||||
return nullptr;
|
||||
else if (is_num(p))
|
||||
return mk_poly(1, &p, null_var);
|
||||
else
|
||||
|
@ -345,8 +345,8 @@ namespace rpolynomial {
|
|||
}
|
||||
|
||||
poly_or_num * mul_core(numeral const & c, poly_or_num * p) {
|
||||
if (m_manager.is_zero(c) || p == 0) {
|
||||
return 0;
|
||||
if (m_manager.is_zero(c) || p == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
else if (is_num(p)) {
|
||||
numeral * r = mk_numeral();
|
||||
|
@ -379,7 +379,7 @@ namespace rpolynomial {
|
|||
if (m_manager.is_zero(c)) {
|
||||
return p;
|
||||
}
|
||||
else if (p == 0) {
|
||||
else if (p == nullptr) {
|
||||
numeral * r = mk_numeral();
|
||||
m_manager.set(*r, c);
|
||||
return to_poly_or_num(r);
|
||||
|
@ -388,7 +388,7 @@ namespace rpolynomial {
|
|||
numeral a;
|
||||
m_manager.add(c, to_num(p), a);
|
||||
if (m_manager.is_zero(a))
|
||||
return 0;
|
||||
return nullptr;
|
||||
numeral * new_arg = mk_numeral();
|
||||
m_manager.swap(*new_arg, a);
|
||||
return to_poly_or_num(new_arg);
|
||||
|
@ -662,7 +662,7 @@ namespace rpolynomial {
|
|||
while (i > 0) {
|
||||
--i;
|
||||
poly_or_num * pn = p->arg(i);
|
||||
if (pn == 0)
|
||||
if (pn == nullptr)
|
||||
continue;
|
||||
if (first)
|
||||
first = false;
|
||||
|
@ -730,7 +730,7 @@ namespace rpolynomial {
|
|||
}
|
||||
|
||||
bool manager::is_zero(polynomial const * p) {
|
||||
return p == 0;
|
||||
return p == nullptr;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace rpolynomial {
|
|||
private:
|
||||
imp * m_imp;
|
||||
public:
|
||||
manager(numeral_manager & m, small_object_allocator * a = 0);
|
||||
manager(numeral_manager & m, small_object_allocator * a = nullptr);
|
||||
~manager();
|
||||
|
||||
numeral_manager & m() const;
|
||||
|
|
|
@ -190,7 +190,7 @@ namespace upolynomial {
|
|||
|
||||
// Copy elements from p to buffer.
|
||||
void core_manager::set(unsigned sz, numeral const * p, numeral_vector & buffer) {
|
||||
if (p != 0 && buffer.c_ptr() == p) {
|
||||
if (p != nullptr && buffer.c_ptr() == p) {
|
||||
SASSERT(buffer.size() == sz);
|
||||
return;
|
||||
}
|
||||
|
@ -781,17 +781,15 @@ namespace upolynomial {
|
|||
set(q.size(), q.c_ptr(), C);
|
||||
m().set(bound, p);
|
||||
}
|
||||
else if (q.size() < C.size() || m().m().is_even(p) || m().m().is_even(bound)) {
|
||||
// discard accumulated image, it was affected by unlucky primes
|
||||
TRACE("mgcd", tout << "discarding image\n";);
|
||||
set(q.size(), q.c_ptr(), C);
|
||||
m().set(bound, p);
|
||||
}
|
||||
else {
|
||||
if (q.size() < C.size()) {
|
||||
// discard accumulated image, it was affected by unlucky primes
|
||||
TRACE("mgcd", tout << "discarding image\n";);
|
||||
set(q.size(), q.c_ptr(), C);
|
||||
m().set(bound, p);
|
||||
}
|
||||
else {
|
||||
CRA_combine_images(q, p, C, bound);
|
||||
TRACE("mgcd", tout << "new combined:\n"; display_star(tout, C); tout << "\n";);
|
||||
}
|
||||
CRA_combine_images(q, p, C, bound);
|
||||
TRACE("mgcd", tout << "new combined:\n"; display_star(tout, C); tout << "\n";);
|
||||
}
|
||||
numeral_vector & candidate = q;
|
||||
get_primitive(C, candidate);
|
||||
|
|
|
@ -117,7 +117,7 @@ namespace upolynomial {
|
|||
numeral_vector m_sqf_tmp2;
|
||||
numeral_vector m_pw_tmp;
|
||||
|
||||
static bool is_alias(numeral const * p, numeral_vector & buffer) { return buffer.c_ptr() != 0 && buffer.c_ptr() == p; }
|
||||
static bool is_alias(numeral const * p, numeral_vector & buffer) { return buffer.c_ptr() != nullptr && buffer.c_ptr() == p; }
|
||||
void neg_core(unsigned sz1, numeral const * p1, numeral_vector & buffer);
|
||||
void add_core(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & buffer);
|
||||
void sub_core(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & buffer);
|
||||
|
|
|
@ -152,7 +152,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
\brief 'Disagonalizes' the matrix using only column operations. The reusling matrix will have -1 at pivot
|
||||
\brief 'Diagonalizes' the matrix using only column operations. The resulting matrix will have -1 at pivot
|
||||
elements. Returns the rank of the null space.
|
||||
*/
|
||||
unsigned diagonalize() {
|
||||
|
@ -170,7 +170,7 @@ public:
|
|||
m_column_pivot[j] = i;
|
||||
m_row_pivot[i] = j;
|
||||
|
||||
// found a pivot, to make it -1 we compute the multuplier -p^-1
|
||||
// found a pivot, to make it -1 we compute the multiplier -p^-1
|
||||
m_zpm.set(multiplier, get(i, j));
|
||||
m_zpm.inv(multiplier);
|
||||
m_zpm.neg(multiplier);
|
||||
|
@ -201,7 +201,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
If rank of the matrix is n - r, we are interested in linearly indeprendent vectors v_1, ..., v_r (the basis of
|
||||
If rank of the matrix is n - r, we are interested in linearly independent vectors v_1, ..., v_r (the basis of
|
||||
the null space), such that v_k A = 0. This method will give one at a time. The method returns true if vector has
|
||||
been computed properly. The first vector [1, 0, ..., 0] is ignored (m_null_row starts from 1).
|
||||
*/
|
||||
|
@ -417,7 +417,7 @@ bool zp_factor_square_free_berlekamp(zp_manager & upm, numeral_vector const & f,
|
|||
// construct the berlekamp Q matrix to get the null space
|
||||
berlekamp_matrix Q_I(upm, f);
|
||||
|
||||
// copy the inital polynomial to factors
|
||||
// copy the initial polynomial to factors
|
||||
unsigned first_factor = factors.distinct_factors();
|
||||
factors.push_back(f, 1);
|
||||
|
||||
|
@ -473,7 +473,7 @@ bool zp_factor_square_free_berlekamp(zp_manager & upm, numeral_vector const & f,
|
|||
// get the gcd
|
||||
upm.gcd(v_k.size(), v_k.c_ptr(), current_factor.size(), current_factor.c_ptr(), gcd);
|
||||
|
||||
// if the gcd is 1, or the the gcd is f, we just ignroe it
|
||||
// if the gcd is 1, or the gcd is f, we just ignore it
|
||||
if (gcd.size() != 1 && gcd.size() != current_factor.size()) {
|
||||
|
||||
// get the divisor also (no need to normalize the div, both are monic)
|
||||
|
@ -568,13 +568,13 @@ bool check_hansel_lift(z_manager & upm, numeral_vector const & C,
|
|||
}
|
||||
|
||||
/**
|
||||
Performs a Hensel lift of A and B in Z_a to Z_b, where p is prime and and a = p^{a_k}, b = p^{b_k},
|
||||
Performs a Hensel lift of A and B in Z_a to Z_b, where p is prime and a = p^{a_k}, b = p^{b_k},
|
||||
r = (a, b), with the following assumptions:
|
||||
|
||||
(1) UA + VB = 1 (mod a)
|
||||
(1) UA + VB = 1 (mod a)
|
||||
(2) C = A*B (mod b)
|
||||
(3) (l(A), r) = 1 (importand in order to divide by A, i.e. to invert l(A))
|
||||
(4) deg(A) + deg(B) = deg(C)
|
||||
(3) (l(A), r) = 1 (important in order to divide by A, i.e. to invert l(A))
|
||||
(4) deg(A) + deg(B) = deg(C)
|
||||
|
||||
The output of is two polynomials A1, B1 such that A1 = A (mod b), B1 = B (mod b),
|
||||
l(A1) = l(A), deg(A1) = deg(A), deg(B1) = deg(B) and C = A1 B1 (mod b*r). Such A1, B1 are unique if
|
||||
|
@ -625,7 +625,7 @@ void hensel_lift(z_manager & upm, numeral const & a, numeral const & b, numeral
|
|||
// having (1) AU + BV = 1 (mod r) and (5) AT + BS = f (mod r), we know that
|
||||
// A*(fU) + B*(fV) = f (mod r), i.e. T = fU, S = fV is a solution
|
||||
// but we also know that we need an S with deg(S) <= deg(A) so we can do the following
|
||||
// we know that l(A) is invertible so we can find the exact remainder of fV with A, i.e. find the qotient
|
||||
// we know that l(A) is invertible so we can find the exact remainder of fV with A, i.e. find the quotient
|
||||
// t in the division and set
|
||||
// A*(fU + tB) + B*(fV - tA) = f
|
||||
// T = fU + tB, S = fU - tA
|
||||
|
@ -1093,7 +1093,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
continue;
|
||||
}
|
||||
|
||||
// if it's not square free, we also try somehting else
|
||||
// if it's not square free, we also try something else
|
||||
scoped_numeral_vector f_pp_zp(nm);
|
||||
to_zp_manager(zp_upm, f_pp, f_pp_zp);
|
||||
|
||||
|
@ -1170,7 +1170,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
zp_numeral_manager & zpe_nm = zpe_upm.m();
|
||||
|
||||
zp_factors zpe_fs(zpe_upm);
|
||||
// this might give something bigger than p^e, but the lifting proocedure will update the zpe_nm
|
||||
// this might give something bigger than p^e, but the lifting procedure will update the zpe_nm
|
||||
// zp factors are monic, so will be the zpe factors, i.e. f_pp = zpe_fs * lc(f_pp) (mod p^e)
|
||||
hensel_lift(upm, f_pp, zp_fs, e, zpe_fs);
|
||||
|
||||
|
@ -1182,7 +1182,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
scoped_numeral f_pp_lc(nm);
|
||||
zpe_nm.set(f_pp_lc, f_pp.back());
|
||||
|
||||
// we always keep in f_pp the the actual primitive part f_pp*lc(f_pp)
|
||||
// we always keep in f_pp the actual primitive part f_pp*lc(f_pp)
|
||||
upm.mul(f_pp, f_pp_lc);
|
||||
|
||||
// now we go through the combinations of factors to check construct the factorization
|
||||
|
@ -1287,7 +1287,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
fs.push_back(f_pp, k);
|
||||
}
|
||||
else {
|
||||
// if a constant it must be 1 (it was primitve)
|
||||
// if a constant it must be 1 (it was primitive)
|
||||
SASSERT(f_pp.size() == 1 && nm.is_one(f_pp.back()));
|
||||
}
|
||||
|
||||
|
|
|
@ -34,12 +34,12 @@ namespace upolynomial {
|
|||
typedef manager::scoped_numeral scoped_numeral;
|
||||
|
||||
/**
|
||||
\breif Factor f into f = f_1^k_1 * ... * p_n^k_n, such that p_i are square-free and coprime.
|
||||
\brief Factor f into f = f_1^k_1 * ... * p_n^k_n, such that p_i are square-free and coprime.
|
||||
*/
|
||||
void zp_square_free_factor(zp_manager & zp_upm, numeral_vector const & f, zp_factors & sq_free_factors);
|
||||
|
||||
/**
|
||||
\brief Factor the monic square-free polynomial f from Z_p[x]. Returns true if factorization was sucesseful, or false
|
||||
\brief Factor the monic square-free polynomial f from Z_p[x]. Returns true if factorization was successful, or false
|
||||
if f is an irreducible square-free polynomial in Z_p[x].
|
||||
*/
|
||||
bool zp_factor_square_free(zp_manager & zp_upm, numeral_vector const & f, zp_factors & factors);
|
||||
|
@ -55,17 +55,17 @@ namespace upolynomial {
|
|||
bool zp_factor_square_free_berlekamp(zp_manager & zp_upm, numeral_vector const & f, zp_factors & factors, bool randomized = true);
|
||||
|
||||
/**
|
||||
\brief Factor the polynomial f from Z_p[x]. Returns true if factorization was sucesseful, or false if f is
|
||||
\brief Factor the polynomial f from Z_p[x]. Returns true if factorization was successful, or false if f is
|
||||
an irreducible polynomial in Z_p[x]
|
||||
*/
|
||||
bool zp_factor(zp_manager & zp_upm, numeral_vector const & f, zp_factors & factors);
|
||||
|
||||
/**
|
||||
\brief Performs a Hensel lift of A and B in Z_a to Z_b, where p is prime and and a = p^{a_k}, b = p^{b_k},
|
||||
\brief Performs a Hensel lift of A and B in Z_a to Z_b, where p is prime and a = p^{a_k}, b = p^{b_k},
|
||||
r = (a, b), with the following assumptions:
|
||||
* UA + VB = 1 (mod a)
|
||||
* C = AB (mod b)
|
||||
* (l(A), r) = 1 (importand in order to divide by A, i.e. to invert l(A))
|
||||
* (l(A), r) = 1 (important in order to divide by A, i.e. to invert l(A))
|
||||
the output of is two polynomials A1, B1 (replacing A and B) such that A1 = A (mod b), B1 = B (mod b),
|
||||
l(A1) = l(A), deg(A1) = deg(A), deg(B1) = deg(B) and C = A1 B1 (mod b*r). Such A1, B1 are unique if
|
||||
r is prime. See [3] p. 138.
|
||||
|
@ -82,7 +82,7 @@ namespace upolynomial {
|
|||
void hensel_lift(z_manager & upm, numeral_vector const & f, zp_factors const & factors_p, unsigned e, zp_factors & factors_pe);
|
||||
|
||||
/**
|
||||
\brief Factor the square-free polynomial f from Z[x]. Returns true if factorization was sucesseful, or false if
|
||||
\brief Factor the square-free polynomial f from Z[x]. Returns true if factorization was successful, or false if
|
||||
f is an irreducible polynomial in Z[x]. The vector of factors is cleared.
|
||||
*/
|
||||
bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs, factor_params const & ps = factor_params());
|
||||
|
|
|
@ -322,7 +322,7 @@ namespace upolynomial {
|
|||
/**
|
||||
\brief Filter the ones not in the degree set.
|
||||
*/
|
||||
bool filter_current() const {
|
||||
bool filter_current() const override {
|
||||
|
||||
// select only the ones that have degrees in the degree set
|
||||
if (!m_degree_set.in_set(current_degree())) {
|
||||
|
|
|
@ -49,7 +49,7 @@ void mpz_matrix_manager::mk(unsigned m, unsigned n, mpz_matrix & A) {
|
|||
}
|
||||
|
||||
void mpz_matrix_manager::del(mpz_matrix & A) {
|
||||
if (A.a_ij != 0) {
|
||||
if (A.a_ij != nullptr) {
|
||||
for (unsigned i = 0; i < A.m; i++)
|
||||
for (unsigned j = 0; j < A.n; j++)
|
||||
nm().del(A(i,j));
|
||||
|
@ -57,7 +57,7 @@ void mpz_matrix_manager::del(mpz_matrix & A) {
|
|||
m_allocator.deallocate(sz, A.a_ij);
|
||||
A.m = 0;
|
||||
A.n = 0;
|
||||
A.a_ij = 0;
|
||||
A.a_ij = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ bool mpz_matrix_manager::eliminate(mpz_matrix & A, mpz * b, unsigned k1, unsigne
|
|||
// a_ik <- 0
|
||||
nm().set(A(i, k2), 0);
|
||||
// normalize row i
|
||||
if (!normalize_row(A.row(i), A.n, b ? &(b[i]) : 0, int_solver))
|
||||
if (!normalize_row(A.row(i), A.n, b ? &(b[i]) : nullptr, int_solver))
|
||||
return false;
|
||||
}
|
||||
SASSERT(nm().is_zero(A(i, k2)));
|
||||
|
@ -386,7 +386,7 @@ unsigned mpz_matrix_manager::linear_independent_rows(mpz_matrix const & _A, unsi
|
|||
r_sz++;
|
||||
if (r_sz >= A.n())
|
||||
break;
|
||||
eliminate(A, 0, k1, k2, false);
|
||||
eliminate(A, nullptr, k1, k2, false);
|
||||
k2++;
|
||||
}
|
||||
std::sort(r, r + r_sz);
|
||||
|
|
|
@ -45,7 +45,7 @@ class mpz_matrix {
|
|||
unsigned n;
|
||||
mpz * a_ij;
|
||||
public:
|
||||
mpz_matrix():m(0), n(0), a_ij(0) {}
|
||||
mpz_matrix():m(0), n(0), a_ij(nullptr) {}
|
||||
mpz const & operator()(unsigned i, unsigned j) const {
|
||||
SASSERT(i < m);
|
||||
SASSERT(j < n);
|
||||
|
|
|
@ -162,7 +162,7 @@ namespace realclosure {
|
|||
// To cope with this issue, we cache the value m_interval in m_old_interval whenever the width of m_interval is below
|
||||
// a give threshold. Then, after finishing OP, we restore the old_interval.
|
||||
mpbqi * m_old_interval;
|
||||
value(bool rat):m_ref_count(0), m_rational(rat), m_old_interval(0) {}
|
||||
value(bool rat):m_ref_count(0), m_rational(rat), m_old_interval(nullptr) {}
|
||||
bool is_rational() const { return m_rational; }
|
||||
mpbqi const & interval() const { return m_interval; }
|
||||
mpbqi & interval() { return m_interval; }
|
||||
|
@ -220,7 +220,7 @@ namespace realclosure {
|
|||
mpbqi m_interval;
|
||||
mpbqi * m_old_interval;
|
||||
|
||||
extension(kind k, unsigned idx):m_ref_count(0), m_kind(k), m_idx(idx), m_old_interval(0) {}
|
||||
extension(kind k, unsigned idx):m_ref_count(0), m_kind(k), m_idx(idx), m_old_interval(nullptr) {}
|
||||
|
||||
unsigned idx() const { return m_idx; }
|
||||
kind knd() const { return static_cast<kind>(m_kind); }
|
||||
|
@ -256,7 +256,7 @@ namespace realclosure {
|
|||
unsigned m_mark:1; // auxiliary mark used during deletion
|
||||
int m_sign; // Sign of the polynomial associated with m_q_idx
|
||||
sign_condition * m_prev; // Antecedent
|
||||
sign_condition():m_q_idx(0), m_mark(false), m_sign(0), m_prev(0) {}
|
||||
sign_condition():m_q_idx(0), m_mark(false), m_sign(0), m_prev(nullptr) {}
|
||||
sign_condition(unsigned qidx, int sign, sign_condition * prev):m_q_idx(qidx), m_mark(false), m_sign(sign), m_prev(prev) {}
|
||||
|
||||
sign_condition * prev() const { return m_prev; }
|
||||
|
@ -287,13 +287,13 @@ namespace realclosure {
|
|||
unsigned m_sc_idx; //!< != UINT_MAX if m_sign_det != 0, in this case m_sc_idx < m_sign_det->m_sign_conditions.size()
|
||||
bool m_depends_on_infinitesimals; //!< True if the polynomial p depends on infinitesimal extensions.
|
||||
|
||||
algebraic(unsigned idx):extension(ALGEBRAIC, idx), m_sign_det(0), m_sc_idx(0), m_depends_on_infinitesimals(false) {}
|
||||
algebraic(unsigned idx):extension(ALGEBRAIC, idx), m_sign_det(nullptr), m_sc_idx(0), m_depends_on_infinitesimals(false) {}
|
||||
|
||||
polynomial const & p() const { return m_p; }
|
||||
bool depends_on_infinitesimals() const { return m_depends_on_infinitesimals; }
|
||||
sign_det * sdt() const { return m_sign_det; }
|
||||
unsigned sc_idx() const { return m_sc_idx; }
|
||||
unsigned num_roots_inside_interval() const { return m_sign_det == 0 ? 1 : m_sign_det->num_roots(); }
|
||||
unsigned num_roots_inside_interval() const { return m_sign_det == nullptr ? 1 : m_sign_det->num_roots(); }
|
||||
mpbqi & iso_interval() { return m_iso_interval; }
|
||||
};
|
||||
|
||||
|
@ -344,13 +344,13 @@ namespace realclosure {
|
|||
// ---------------------------------
|
||||
|
||||
struct mk_pi_interval : public mk_interval {
|
||||
virtual void operator()(unsigned k, mpqi_manager & im, mpqi_manager::interval & r) {
|
||||
void operator()(unsigned k, mpqi_manager & im, mpqi_manager::interval & r) override {
|
||||
im.pi(k, r);
|
||||
}
|
||||
};
|
||||
|
||||
struct mk_e_interval : public mk_interval {
|
||||
virtual void operator()(unsigned k, mpqi_manager & im, mpqi_manager::interval & r) {
|
||||
void operator()(unsigned k, mpqi_manager & im, mpqi_manager::interval & r) override {
|
||||
im.e(k, r);
|
||||
}
|
||||
};
|
||||
|
@ -497,8 +497,8 @@ namespace realclosure {
|
|||
|
||||
imp(reslimit& lim, unsynch_mpq_manager & qm, params_ref const & p, small_object_allocator * a):
|
||||
m_limit(lim),
|
||||
m_allocator(a == 0 ? alloc(small_object_allocator, "realclosure") : a),
|
||||
m_own_allocator(a == 0),
|
||||
m_allocator(a == nullptr ? alloc(small_object_allocator, "realclosure") : a),
|
||||
m_own_allocator(a == nullptr),
|
||||
m_qm(qm),
|
||||
m_mm(m_qm, *m_allocator),
|
||||
m_bqm(m_qm),
|
||||
|
@ -509,8 +509,8 @@ namespace realclosure {
|
|||
mpq one(1);
|
||||
m_one = mk_rational(one);
|
||||
inc_ref(m_one);
|
||||
m_pi = 0;
|
||||
m_e = 0;
|
||||
m_pi = nullptr;
|
||||
m_e = nullptr;
|
||||
|
||||
m_exec_depth = 0;
|
||||
|
||||
|
@ -657,7 +657,7 @@ namespace realclosure {
|
|||
*/
|
||||
template<typename T>
|
||||
void save_interval(T * v, ptr_vector<T> & to_restore) {
|
||||
if (v->m_old_interval != 0)
|
||||
if (v->m_old_interval != nullptr)
|
||||
return; // interval was already saved.
|
||||
to_restore.push_back(v);
|
||||
inc_ref(v);
|
||||
|
@ -698,7 +698,7 @@ namespace realclosure {
|
|||
set_interval(v->m_interval, *(v->m_old_interval));
|
||||
bqim().del(*(v->m_old_interval));
|
||||
allocator().deallocate(sizeof(mpbqi), v->m_old_interval);
|
||||
v->m_old_interval = 0;
|
||||
v->m_old_interval = nullptr;
|
||||
dec_ref(v);
|
||||
}
|
||||
to_restore.reset();
|
||||
|
@ -811,12 +811,12 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void inc_ref_sign_det(sign_det * sd) {
|
||||
if (sd != 0)
|
||||
if (sd != nullptr)
|
||||
sd->m_ref_count++;
|
||||
}
|
||||
|
||||
void dec_ref_sign_det(sign_det * sd) {
|
||||
if (sd != 0) {
|
||||
if (sd != nullptr) {
|
||||
sd->m_ref_count--;
|
||||
if (sd->m_ref_count == 0) {
|
||||
del_sign_det(sd);
|
||||
|
@ -887,7 +887,7 @@ namespace realclosure {
|
|||
|
||||
void del(numeral & a) {
|
||||
dec_ref(a.m_value);
|
||||
a.m_value = 0;
|
||||
a.m_value = nullptr;
|
||||
}
|
||||
|
||||
void del(numeral_vector & v) {
|
||||
|
@ -910,7 +910,7 @@ namespace realclosure {
|
|||
\brief Return true if v is zero.
|
||||
*/
|
||||
static bool is_zero(value * v) {
|
||||
return v == 0;
|
||||
return v == nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1260,14 +1260,14 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
rational_function_value * mk_rational_function_value_core(algebraic * ext, unsigned num_sz, value * const * num) {
|
||||
return mk_rational_function_value_core(ext, num_sz, num, 0, 0);
|
||||
return mk_rational_function_value_core(ext, num_sz, num, 0, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Create a value using the given extension.
|
||||
*/
|
||||
rational_function_value * mk_rational_function_value(extension * ext) {
|
||||
value * num[2] = { 0, one() };
|
||||
value * num[2] = { nullptr, one() };
|
||||
value * den[1] = { one() };
|
||||
rational_function_value * v = mk_rational_function_value_core(ext, 2, num, 1, den);
|
||||
set_interval(v->interval(), ext->interval());
|
||||
|
@ -1838,7 +1838,7 @@ namespace realclosure {
|
|||
interval contains only one root of p.
|
||||
*/
|
||||
void add_root(unsigned p_sz, value * const * p, mpbqi const & interval, mpbqi const & iso_interval, numeral_vector & roots) {
|
||||
add_root(p_sz, p, interval, iso_interval, 0, UINT_MAX, roots);
|
||||
add_root(p_sz, p, interval, iso_interval, nullptr, UINT_MAX, roots);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1965,7 +1965,7 @@ namespace realclosure {
|
|||
// Sequence of sign conditions associated with the columns of M_s
|
||||
// These are sign conditions on the polynomials in qs.
|
||||
scoped_sign_conditions scs(*this);
|
||||
scs.push_back(0);
|
||||
scs.push_back(nullptr);
|
||||
|
||||
// Starting configuration
|
||||
//
|
||||
|
@ -2322,7 +2322,7 @@ namespace realclosure {
|
|||
|
||||
if (num_neg_roots > 0) {
|
||||
if (num_neg_roots == 1) {
|
||||
add_root(n, p, neg_interval, minf_zero, 0, UINT_MAX, roots);
|
||||
add_root(n, p, neg_interval, minf_zero, nullptr, UINT_MAX, roots);
|
||||
}
|
||||
else {
|
||||
if (has_neg_lower) {
|
||||
|
@ -2336,7 +2336,7 @@ namespace realclosure {
|
|||
|
||||
if (num_pos_roots > 0) {
|
||||
if (num_pos_roots == 1) {
|
||||
add_root(n, p, pos_interval, zero_inf, 0, UINT_MAX, roots);
|
||||
add_root(n, p, pos_interval, zero_inf, nullptr, UINT_MAX, roots);
|
||||
}
|
||||
else {
|
||||
if (has_pos_upper) {
|
||||
|
@ -2668,7 +2668,7 @@ namespace realclosure {
|
|||
\brief Remove 0s
|
||||
*/
|
||||
void adjust_size(value_ref_buffer & r) {
|
||||
while (!r.empty() && r.back() == 0) {
|
||||
while (!r.empty() && r.back() == nullptr) {
|
||||
r.pop_back();
|
||||
}
|
||||
}
|
||||
|
@ -2753,7 +2753,7 @@ namespace realclosure {
|
|||
void mul(value * a, unsigned sz, value * const * p, value_ref_buffer & r) {
|
||||
SASSERT(p != r.c_ptr());
|
||||
r.reset();
|
||||
if (a == 0)
|
||||
if (a == nullptr)
|
||||
return;
|
||||
value_ref a_i(*this);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
|
@ -2778,7 +2778,7 @@ namespace realclosure {
|
|||
value_ref tmp(*this);
|
||||
for (unsigned i = 0; i < sz1; i++) {
|
||||
checkpoint();
|
||||
if (p1[i] == 0)
|
||||
if (p1[i] == nullptr)
|
||||
continue;
|
||||
for (unsigned j = 0; j < sz2; j++) {
|
||||
// r[i+j] <- r[i+j] + p1[i]*p2[j]
|
||||
|
@ -3060,7 +3060,7 @@ namespace realclosure {
|
|||
bool struct_eq(value * a, value * b) const {
|
||||
if (a == b)
|
||||
return true;
|
||||
else if (a == 0 || b == 0)
|
||||
else if (a == nullptr || b == nullptr)
|
||||
return false;
|
||||
else if (is_nz_rational(a) && is_nz_rational(b))
|
||||
return qm().eq(to_mpq(a), to_mpq(b));
|
||||
|
@ -3112,7 +3112,7 @@ namespace realclosure {
|
|||
- a is a rational_function_value of the form p_a(x)/1 where the coefficients of p_a also have clean denominators.
|
||||
*/
|
||||
bool has_clean_denominators(value * a) const {
|
||||
if (a == 0)
|
||||
if (a == nullptr)
|
||||
return true;
|
||||
else if (is_nz_rational(a))
|
||||
return qm().is_int(to_mpq(a));
|
||||
|
@ -3150,7 +3150,7 @@ namespace realclosure {
|
|||
INC_DEPTH();
|
||||
TRACE("rcf_clean", tout << "clean_denominators_core [" << m_exec_depth << "]\na: "; display(tout, a, false); tout << "\n";);
|
||||
p.reset(); q.reset();
|
||||
if (a == 0) {
|
||||
if (a == nullptr) {
|
||||
p = a;
|
||||
q = one();
|
||||
}
|
||||
|
@ -3205,8 +3205,8 @@ namespace realclosure {
|
|||
dens.push_back(a_d);
|
||||
}
|
||||
else {
|
||||
nums.push_back(0);
|
||||
dens.push_back(0);
|
||||
nums.push_back(nullptr);
|
||||
dens.push_back(nullptr);
|
||||
}
|
||||
}
|
||||
if (all_one) {
|
||||
|
@ -3258,7 +3258,7 @@ namespace realclosure {
|
|||
value_ref m(*this);
|
||||
for (unsigned i = 0; i < p_sz; i++) {
|
||||
if (!nums[i]) {
|
||||
norm_p.push_back(0);
|
||||
norm_p.push_back(nullptr);
|
||||
}
|
||||
else {
|
||||
SASSERT(dens[i]);
|
||||
|
@ -3348,7 +3348,7 @@ namespace realclosure {
|
|||
If g != 0, then it will compute the gcd of g and the coefficients in a.
|
||||
*/
|
||||
bool gcd_int_coeffs(value * a, mpz & g) {
|
||||
if (a == 0) {
|
||||
if (a == nullptr) {
|
||||
return false;
|
||||
}
|
||||
else if (is_nz_rational(a)) {
|
||||
|
@ -3410,7 +3410,7 @@ namespace realclosure {
|
|||
for (unsigned i = 0; i < p.size(); i++) {
|
||||
if (p[i]) {
|
||||
a = p[i];
|
||||
p.set(i, 0);
|
||||
p.set(i, nullptr);
|
||||
exact_div_z(a, g);
|
||||
p.set(i, a);
|
||||
}
|
||||
|
@ -3448,7 +3448,7 @@ namespace realclosure {
|
|||
new_ais.push_back(ai);
|
||||
}
|
||||
else {
|
||||
new_ais.push_back(0);
|
||||
new_ais.push_back(nullptr);
|
||||
}
|
||||
}
|
||||
rational_function_value * r = mk_rational_function_value_core(rf->ext(), new_ais.size(), new_ais.c_ptr(), 1, &m_one);
|
||||
|
@ -3759,7 +3759,7 @@ namespace realclosure {
|
|||
while (i > 0) {
|
||||
checkpoint();
|
||||
--i;
|
||||
if (p[i] != 0)
|
||||
if (p[i] != nullptr)
|
||||
bqim().add(r, interval(p[i]), r);
|
||||
if (i > 0)
|
||||
bqim().mul(r, bi, r);
|
||||
|
@ -3772,7 +3772,7 @@ namespace realclosure {
|
|||
*/
|
||||
bool has_refineable_approx_coeffs(unsigned n, value * const * p) {
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
if (p[i] != 0) {
|
||||
if (p[i] != nullptr) {
|
||||
mpbqi & a_i = interval(p[i]);
|
||||
if (a_i.lower_is_inf() || a_i.upper_is_inf())
|
||||
return false;
|
||||
|
@ -3786,7 +3786,7 @@ namespace realclosure {
|
|||
*/
|
||||
void mk_polynomial_value(unsigned n, value * const * p, value * b, value_ref & r) {
|
||||
SASSERT(n > 0);
|
||||
if (n == 1 || b == 0) {
|
||||
if (n == 1 || b == nullptr) {
|
||||
r = p[0];
|
||||
}
|
||||
else {
|
||||
|
@ -3798,7 +3798,7 @@ namespace realclosure {
|
|||
unsigned i = n - 1;
|
||||
while (i > 0) {
|
||||
--i;
|
||||
if (p[i] != 0)
|
||||
if (p[i] != nullptr)
|
||||
add(r, p[i], r); // r <- r + a_i
|
||||
if (i > 0)
|
||||
mul(r, b, r); // r <- r * b
|
||||
|
@ -3856,7 +3856,7 @@ namespace realclosure {
|
|||
int find_biggest_interval_magnitude(unsigned n, value * const * p) {
|
||||
int r = INT_MIN;
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
if (p[i] != 0) {
|
||||
if (p[i] != nullptr) {
|
||||
mpbqi & a_i = interval(p[i]);
|
||||
SASSERT(!a_i.lower_is_inf() && !a_i.upper_is_inf());
|
||||
int m = magnitude(a_i);
|
||||
|
@ -4089,7 +4089,7 @@ namespace realclosure {
|
|||
*/
|
||||
bool refine_coeffs_interval(unsigned n, value * const * p, unsigned prec) {
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
if (p[i] != 0 && !refine_interval(p[i], prec))
|
||||
if (p[i] != nullptr && !refine_interval(p[i], prec))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -4243,7 +4243,7 @@ namespace realclosure {
|
|||
|
||||
bool refine_algebraic_interval(algebraic * a, unsigned prec) {
|
||||
save_interval_if_too_small(a, prec);
|
||||
if (a->sdt() != 0) {
|
||||
if (a->sdt() != nullptr) {
|
||||
// We don't bisect the interval, since it contains more than one root.
|
||||
// To bisect this kind of interval we would have to use Tarski queries.
|
||||
return false;
|
||||
|
@ -4941,7 +4941,7 @@ namespace realclosure {
|
|||
}
|
||||
else {
|
||||
// The new value is 0
|
||||
r = 0;
|
||||
r = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4979,7 +4979,7 @@ namespace realclosure {
|
|||
// num <- a + b * ad
|
||||
add(an.size(), an.c_ptr(), b_ad.size(), b_ad.c_ptr(), num);
|
||||
if (num.empty())
|
||||
r = 0;
|
||||
r = nullptr;
|
||||
else {
|
||||
value_ref_buffer new_num(*this);
|
||||
value_ref_buffer new_den(*this);
|
||||
|
@ -5003,7 +5003,7 @@ namespace realclosure {
|
|||
value_ref_buffer new_num(*this);
|
||||
add(an.size(), an.c_ptr(), bn.size(), bn.c_ptr(), new_num);
|
||||
if (new_num.empty())
|
||||
r = 0;
|
||||
r = nullptr;
|
||||
else {
|
||||
// We don't need to invoke normalize_algebraic even if x (== a->ext()) is algebraic.
|
||||
// Reason: by construction the polynomials a->num() and b->num() are "normalized".
|
||||
|
@ -5035,7 +5035,7 @@ namespace realclosure {
|
|||
value_ref_buffer num(*this);
|
||||
add(an_bd.size(), an_bd.c_ptr(), bn_ad.size(), bn_ad.c_ptr(), num);
|
||||
if (num.empty()) {
|
||||
r = 0;
|
||||
r = nullptr;
|
||||
}
|
||||
else {
|
||||
value_ref_buffer den(*this);
|
||||
|
@ -5050,17 +5050,17 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void add(value * a, value * b, value_ref & r) {
|
||||
if (a == 0) {
|
||||
if (a == nullptr) {
|
||||
r = b;
|
||||
}
|
||||
else if (b == 0) {
|
||||
else if (b == nullptr) {
|
||||
r = a;
|
||||
}
|
||||
else if (is_nz_rational(a) && is_nz_rational(b)) {
|
||||
scoped_mpq v(qm());
|
||||
qm().add(to_mpq(a), to_mpq(b), v);
|
||||
if (qm().is_zero(v))
|
||||
r = 0;
|
||||
r = nullptr;
|
||||
else
|
||||
r = mk_rational_and_swap(v);
|
||||
}
|
||||
|
@ -5079,17 +5079,17 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void sub(value * a, value * b, value_ref & r) {
|
||||
if (a == 0) {
|
||||
if (a == nullptr) {
|
||||
neg(b, r);
|
||||
}
|
||||
else if (b == 0) {
|
||||
else if (b == nullptr) {
|
||||
r = a;
|
||||
}
|
||||
else if (is_nz_rational(a) && is_nz_rational(b)) {
|
||||
scoped_mpq v(qm());
|
||||
qm().sub(to_mpq(a), to_mpq(b), v);
|
||||
if (qm().is_zero(v))
|
||||
r = 0;
|
||||
r = nullptr;
|
||||
else
|
||||
r = mk_rational_and_swap(v);
|
||||
}
|
||||
|
@ -5118,8 +5118,8 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void neg(value * a, value_ref & r) {
|
||||
if (a == 0) {
|
||||
r = 0;
|
||||
if (a == nullptr) {
|
||||
r = nullptr;
|
||||
}
|
||||
else if (is_nz_rational(a)) {
|
||||
scoped_mpq v(qm());
|
||||
|
@ -5155,7 +5155,7 @@ namespace realclosure {
|
|||
}
|
||||
else {
|
||||
// The new value is 0
|
||||
r = 0;
|
||||
r = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5252,8 +5252,8 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void mul(value * a, value * b, value_ref & r) {
|
||||
if (a == 0 || b == 0) {
|
||||
r = 0;
|
||||
if (a == nullptr || b == nullptr) {
|
||||
r = nullptr;
|
||||
}
|
||||
else if (is_rational_one(a)) {
|
||||
r = b;
|
||||
|
@ -5287,10 +5287,10 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void div(value * a, value * b, value_ref & r) {
|
||||
if (a == 0) {
|
||||
r = 0;
|
||||
if (a == nullptr) {
|
||||
r = nullptr;
|
||||
}
|
||||
else if (b == 0) {
|
||||
else if (b == nullptr) {
|
||||
throw exception("division by zero");
|
||||
}
|
||||
else if (is_rational_one(b)) {
|
||||
|
@ -5461,7 +5461,7 @@ namespace realclosure {
|
|||
// r == 1/inv(new_a)
|
||||
inv(new_a, r);
|
||||
}
|
||||
else if (alpha->sdt() == 0) {
|
||||
else if (alpha->sdt() == nullptr) {
|
||||
// Another easy case: we just have to replace
|
||||
// alpha->p() with new_p.
|
||||
// The m_iso_interval for p() is also an isolating interval for new_p,
|
||||
|
@ -5552,7 +5552,7 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void inv(value * a, value_ref & r) {
|
||||
if (a == 0) {
|
||||
if (a == nullptr) {
|
||||
throw exception("division by zero");
|
||||
}
|
||||
if (is_nz_rational(a)) {
|
||||
|
@ -5644,7 +5644,7 @@ namespace realclosure {
|
|||
neg(a.m_value, neg_a);
|
||||
p.push_back(neg_a);
|
||||
for (unsigned i = 0; i < k - 1; i++)
|
||||
p.push_back(0);
|
||||
p.push_back(nullptr);
|
||||
p.push_back(one());
|
||||
|
||||
numeral_vector roots;
|
||||
|
@ -5687,9 +5687,9 @@ namespace realclosure {
|
|||
// ---------------------------------
|
||||
|
||||
int compare(value * a, value * b) {
|
||||
if (a == 0)
|
||||
if (a == nullptr)
|
||||
return -sign(b);
|
||||
else if (b == 0)
|
||||
else if (b == nullptr)
|
||||
return sign(a);
|
||||
else if (is_nz_rational(a) && is_nz_rational(b)) {
|
||||
if (qm().eq(to_mpq(a), to_mpq(b)))
|
||||
|
@ -5744,7 +5744,7 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void mark(value * v) {
|
||||
if (v == 0 || is_nz_rational(v))
|
||||
if (v == nullptr || is_nz_rational(v))
|
||||
return;
|
||||
rational_function_value * rf = to_rational_function(v);
|
||||
mark(rf->ext());
|
||||
|
@ -5779,7 +5779,7 @@ namespace realclosure {
|
|||
bool first = true;
|
||||
while (i > 0) {
|
||||
--i;
|
||||
if (p[i] == 0)
|
||||
if (p[i] == nullptr)
|
||||
continue;
|
||||
if (first)
|
||||
first = false;
|
||||
|
@ -5893,7 +5893,7 @@ namespace realclosure {
|
|||
out << ", ";
|
||||
display_interval(out, a->iso_interval(), pp);
|
||||
out << ", ";
|
||||
if (a->sdt() != 0)
|
||||
if (a->sdt() != nullptr)
|
||||
display_sign_conditions(out, a->sdt()->sc(a->sc_idx()), a->sdt()->qs(), compact, pp);
|
||||
else
|
||||
out << "{}";
|
||||
|
@ -5931,7 +5931,7 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void display(std::ostream & out, value * v, bool compact, bool pp=false) const {
|
||||
if (v == 0)
|
||||
if (v == nullptr)
|
||||
out << "0";
|
||||
else if (is_nz_rational(v))
|
||||
qm().display(out, to_mpq(v));
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace realclosure {
|
|||
friend class save_interval_ctx;
|
||||
imp * m_imp;
|
||||
public:
|
||||
manager(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0);
|
||||
manager(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = nullptr);
|
||||
~manager();
|
||||
typedef num numeral;
|
||||
typedef svector<numeral> numeral_vector;
|
||||
|
@ -271,7 +271,7 @@ namespace realclosure {
|
|||
friend struct manager::imp;
|
||||
value * m_value;
|
||||
public:
|
||||
num():m_value(0) {}
|
||||
num():m_value(nullptr) {}
|
||||
|
||||
// Low level functions for implementing the C API
|
||||
void * c_ptr() { return m_value; }
|
||||
|
|
|
@ -634,7 +634,7 @@ namespace simplex {
|
|||
//
|
||||
// max { c*x | A*x = 0 and l <= x <= u }
|
||||
//
|
||||
// start with feasible assigment
|
||||
// start with feasible assignment
|
||||
// A*x0 = 0 and l <= x0 <= u
|
||||
//
|
||||
// Identify pivot: i, j: such that x_i is base,
|
||||
|
@ -745,7 +745,7 @@ namespace simplex {
|
|||
numeral const& base_coeff = vs.m_base_coeff;
|
||||
SASSERT(!m.is_zero(coeff));
|
||||
bool base_to_lower = (m.is_pos(coeff) != m.is_pos(base_coeff)) == to_lower;
|
||||
eps_numeral const* bound = 0;
|
||||
eps_numeral const* bound = nullptr;
|
||||
if (!base_to_lower && vs.m_upper_valid) {
|
||||
bound = &vs.m_upper;
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ namespace simplex {
|
|||
return it;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename Ext>
|
||||
|
|
|
@ -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