mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25: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
|
@ -66,9 +66,9 @@ namespace nlsat {
|
|||
void reset() { m_assigned.reset(); }
|
||||
bool is_assigned(var x) const { return m_assigned.get(x, false); }
|
||||
anum const & value(var x) const { return m_values[x]; }
|
||||
virtual anum_manager & m() const { return am(); }
|
||||
virtual bool contains(var x) const { return is_assigned(x); }
|
||||
virtual anum const & operator()(var x) const { SASSERT(is_assigned(x)); return value(x); }
|
||||
anum_manager & m() const override { return am(); }
|
||||
bool contains(var x) const override { return is_assigned(x); }
|
||||
anum const & operator()(var x) const override { SASSERT(is_assigned(x)); return value(x); }
|
||||
void swap(var x, var y) {
|
||||
SASSERT(x < m_values.size() && y < m_values.size());
|
||||
std::swap(m_assigned[x], m_assigned[y]);
|
||||
|
@ -95,9 +95,9 @@ namespace nlsat {
|
|||
var m_y;
|
||||
public:
|
||||
undef_var_assignment(assignment const & a, var y):m_assignment(a), m_y(y) {}
|
||||
virtual anum_manager & m() const { return m_assignment.am(); }
|
||||
virtual bool contains(var x) const { return x != m_y && m_assignment.is_assigned(x); }
|
||||
virtual anum const & operator()(var x) const { return m_assignment.value(x); }
|
||||
anum_manager & m() const override { return m_assignment.am(); }
|
||||
bool contains(var x) const override { return x != m_y && m_assignment.is_assigned(x); }
|
||||
anum const & operator()(var x) const override { return m_assignment.value(x); }
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -44,6 +44,8 @@ namespace nlsat {
|
|||
bool is_learned() const { return m_learned; }
|
||||
literal * begin() { return m_lits; }
|
||||
literal * end() { return m_lits + m_size; }
|
||||
literal const * begin() const { return m_lits; }
|
||||
literal const * end() const { return m_lits + m_size; }
|
||||
literal const * c_ptr() const { return m_lits; }
|
||||
void inc_activity() { m_activity++; }
|
||||
void set_activity(unsigned v) { m_activity = v; }
|
||||
|
|
|
@ -146,7 +146,7 @@ namespace nlsat {
|
|||
m_todo(u),
|
||||
m_core1(s),
|
||||
m_core2(s),
|
||||
m_result(0),
|
||||
m_result(nullptr),
|
||||
m_evaluator(ev) {
|
||||
m_simplify_cores = false;
|
||||
m_full_dimensional = false;
|
||||
|
@ -242,7 +242,7 @@ namespace nlsat {
|
|||
}
|
||||
|
||||
/**
|
||||
\breif Store in ps the polynomials occurring in the given literals.
|
||||
\brief Store in ps the polynomials occurring in the given literals.
|
||||
*/
|
||||
void collect_polys(unsigned num, literal const * ls, polynomial_ref_vector & ps) {
|
||||
ps.reset();
|
||||
|
@ -332,7 +332,7 @@ namespace nlsat {
|
|||
if (!is_zero(lc)) {
|
||||
if (sign(lc) != 0)
|
||||
return;
|
||||
// lc is not the zero polynomial, but it vanished in the current interpretaion.
|
||||
// lc is not the zero polynomial, but it vanished in the current interpretation.
|
||||
// so we keep searching...
|
||||
add_zero_assumption(lc);
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ namespace nlsat {
|
|||
|
||||
polynomial::var max_var(literal l) {
|
||||
atom * a = m_atoms[l.var()];
|
||||
if (a != 0)
|
||||
if (a != nullptr)
|
||||
return a->max_var();
|
||||
else
|
||||
return null_var;
|
||||
|
@ -535,7 +535,7 @@ namespace nlsat {
|
|||
for (unsigned i = 0; i < sz; i++) {
|
||||
literal l = ls[i];
|
||||
atom * a = m_atoms[l.var()];
|
||||
if (a != 0) {
|
||||
if (a != nullptr) {
|
||||
var x = a->max_var();
|
||||
SASSERT(x != null_var);
|
||||
if (max == null_var || x > max)
|
||||
|
@ -705,7 +705,7 @@ namespace nlsat {
|
|||
m_result = &result;
|
||||
add_root_literal(k, y, i, p);
|
||||
reset_already_added();
|
||||
m_result = 0;
|
||||
m_result = nullptr;
|
||||
}
|
||||
|
||||
void add_root_literal(atom::kind k, var y, unsigned i, poly * p) {
|
||||
|
@ -1232,7 +1232,7 @@ namespace nlsat {
|
|||
This method selects the equation of minimal degree in max.
|
||||
*/
|
||||
poly * select_eq(scoped_literal_vector & C, var max) {
|
||||
poly * r = 0;
|
||||
poly * r = nullptr;
|
||||
unsigned min_d = UINT_MAX;
|
||||
unsigned sz = C.size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
|
@ -1289,7 +1289,7 @@ namespace nlsat {
|
|||
if (y >= max)
|
||||
continue;
|
||||
atom * eq = m_x2eq[y];
|
||||
if (eq == 0)
|
||||
if (eq == nullptr)
|
||||
continue;
|
||||
SASSERT(eq->is_ineq_atom());
|
||||
SASSERT(to_ineq_atom(eq)->size() == 1);
|
||||
|
@ -1305,7 +1305,7 @@ namespace nlsat {
|
|||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1315,7 +1315,7 @@ namespace nlsat {
|
|||
// Simplify using equations in the core
|
||||
while (!C.empty()) {
|
||||
poly * eq = select_eq(C, max);
|
||||
if (eq == 0)
|
||||
if (eq == nullptr)
|
||||
break;
|
||||
TRACE("nlsat_simplify_core", tout << "using equality for simplifying core\n";
|
||||
m_pm.display(tout, eq, m_solver.display_proc()); tout << "\n";);
|
||||
|
@ -1325,7 +1325,7 @@ namespace nlsat {
|
|||
// Simplify using equations using variables from lower stages.
|
||||
while (!C.empty()) {
|
||||
ineq_atom * eq = select_lower_stage_eq(C, max);
|
||||
if (eq == 0)
|
||||
if (eq == nullptr)
|
||||
break;
|
||||
SASSERT(eq->size() == 1);
|
||||
SASSERT(!eq->is_even(0));
|
||||
|
@ -1456,7 +1456,7 @@ namespace nlsat {
|
|||
m_result = &result;
|
||||
process(num, ls);
|
||||
reset_already_added();
|
||||
m_result = 0;
|
||||
m_result = nullptr;
|
||||
TRACE("nlsat_explain", tout << "[explain] result\n"; display(tout, result););
|
||||
CASSERT("nlsat", check_already_added());
|
||||
}
|
||||
|
@ -1495,14 +1495,14 @@ namespace nlsat {
|
|||
project(m_ps, mx_var);
|
||||
}
|
||||
reset_already_added();
|
||||
m_result = 0;
|
||||
m_result = nullptr;
|
||||
if (x != mx_var) {
|
||||
m_solver.restore_order();
|
||||
}
|
||||
}
|
||||
else {
|
||||
reset_already_added();
|
||||
m_result = 0;
|
||||
m_result = nullptr;
|
||||
}
|
||||
for (unsigned i = 0; i < result.size(); ++i) {
|
||||
result.set(i, ~result[i]);
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace nlsat {
|
|||
}
|
||||
|
||||
void interval_set_manager::del(interval_set * s) {
|
||||
if (s == 0)
|
||||
if (s == nullptr)
|
||||
return;
|
||||
unsigned num = s->m_num_intervals;
|
||||
unsigned obj_sz = interval_set::get_obj_size(num);
|
||||
|
@ -270,9 +270,9 @@ namespace nlsat {
|
|||
|
||||
interval_set * interval_set_manager::mk_union(interval_set const * s1, interval_set const * s2) {
|
||||
TRACE("nlsat_interval", tout << "mk_union\ns1: "; display(tout, s1); tout << "\ns2: "; display(tout, s2); tout << "\n";);
|
||||
if (s1 == 0 || s1 == s2)
|
||||
if (s1 == nullptr || s1 == s2)
|
||||
return const_cast<interval_set*>(s2);
|
||||
if (s2 == 0)
|
||||
if (s2 == nullptr)
|
||||
return const_cast<interval_set*>(s1);
|
||||
if (s1->m_full)
|
||||
return const_cast<interval_set*>(s1);
|
||||
|
@ -514,22 +514,22 @@ namespace nlsat {
|
|||
}
|
||||
|
||||
bool interval_set_manager::is_full(interval_set const * s) {
|
||||
if (s == 0)
|
||||
if (s == nullptr)
|
||||
return false;
|
||||
return s->m_full == 1;
|
||||
}
|
||||
|
||||
unsigned interval_set_manager::num_intervals(interval_set const * s) const {
|
||||
if (s == 0) return 0;
|
||||
if (s == nullptr) return 0;
|
||||
return s->m_num_intervals;
|
||||
}
|
||||
|
||||
bool interval_set_manager::subset(interval_set const * s1, interval_set const * s2) {
|
||||
if (s1 == s2)
|
||||
return true;
|
||||
if (s1 == 0)
|
||||
if (s1 == nullptr)
|
||||
return true;
|
||||
if (s2 == 0)
|
||||
if (s2 == nullptr)
|
||||
return false;
|
||||
if (s2->m_full)
|
||||
return true;
|
||||
|
@ -616,7 +616,7 @@ namespace nlsat {
|
|||
}
|
||||
|
||||
bool interval_set_manager::set_eq(interval_set const * s1, interval_set const * s2) {
|
||||
if (s1 == 0 || s2 == 0)
|
||||
if (s1 == nullptr || s2 == nullptr)
|
||||
return s1 == s2;
|
||||
if (s1->m_full || s2->m_full)
|
||||
return s1->m_full == s2->m_full;
|
||||
|
@ -625,7 +625,7 @@ namespace nlsat {
|
|||
}
|
||||
|
||||
bool interval_set_manager::eq(interval_set const * s1, interval_set const * s2) {
|
||||
if (s1 == 0 || s2 == 0)
|
||||
if (s1 == nullptr || s2 == nullptr)
|
||||
return s1 == s2;
|
||||
if (s1->m_num_intervals != s2->m_num_intervals)
|
||||
return false;
|
||||
|
@ -672,14 +672,14 @@ namespace nlsat {
|
|||
return new_set;
|
||||
}
|
||||
|
||||
void interval_set_manager::peek_in_complement(interval_set const * s, anum & w, bool randomize) {
|
||||
void interval_set_manager::peek_in_complement(interval_set const * s, bool is_int, anum & w, bool randomize) {
|
||||
SASSERT(!is_full(s));
|
||||
if (s == 0) {
|
||||
if (s == nullptr) {
|
||||
if (randomize) {
|
||||
int num = m_rand() % 2 == 0 ? 1 : -1;
|
||||
#define MAX_RANDOM_DEN_K 4
|
||||
int den_k = (m_rand() % MAX_RANDOM_DEN_K);
|
||||
int den = 1 << den_k;
|
||||
int den = is_int ? 1 : (1 << den_k);
|
||||
scoped_mpq _w(m_am.qm());
|
||||
m_am.qm().set(_w, num, den);
|
||||
m_am.set(w, _w);
|
||||
|
@ -744,7 +744,7 @@ namespace nlsat {
|
|||
}
|
||||
|
||||
void interval_set_manager::display(std::ostream & out, interval_set const * s) const {
|
||||
if (s == 0) {
|
||||
if (s == nullptr) {
|
||||
out << "{}";
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace nlsat {
|
|||
/**
|
||||
\brief Return the empty set.
|
||||
*/
|
||||
interval_set * mk_empty() { return 0; }
|
||||
interval_set * mk_empty() { return nullptr; }
|
||||
|
||||
/**
|
||||
\brief Return a set of composed of a single interval.
|
||||
|
@ -64,7 +64,7 @@ namespace nlsat {
|
|||
\brief Return true if s is the empty set.
|
||||
*/
|
||||
bool is_empty(interval_set const * s) {
|
||||
return s == 0;
|
||||
return s == nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,7 +108,7 @@ namespace nlsat {
|
|||
|
||||
\pre !is_full(s)
|
||||
*/
|
||||
void peek_in_complement(interval_set const * s, anum & w, bool randomize);
|
||||
void peek_in_complement(interval_set const * s, bool is_int, anum & w, bool randomize);
|
||||
};
|
||||
|
||||
typedef obj_ref<interval_set, interval_set_manager> interval_set_ref;
|
||||
|
|
|
@ -54,8 +54,8 @@ namespace nlsat {
|
|||
void * m_data;
|
||||
public:
|
||||
enum kind { NULL_JST = 0, DECISION, CLAUSE, LAZY };
|
||||
justification():m_data(TAG(void *, static_cast<void*>(0), NULL_JST)) { SASSERT(is_null()); }
|
||||
justification(bool):m_data(TAG(void *, static_cast<void*>(0), DECISION)) { SASSERT(is_decision()); }
|
||||
justification():m_data(TAG(void *, nullptr, NULL_JST)) { SASSERT(is_null()); }
|
||||
justification(bool):m_data(TAG(void *, nullptr, DECISION)) { SASSERT(is_decision()); }
|
||||
justification(clause * c):m_data(TAG(void *, c, CLAUSE)) { SASSERT(is_clause()); }
|
||||
justification(lazy_justification * j):m_data(TAG(void *, j, LAZY)) { SASSERT(is_lazy()); }
|
||||
kind get_kind() const { return static_cast<kind>(GET_TAG(m_data)); }
|
||||
|
|
|
@ -10,6 +10,7 @@ def_module_params('nlsat',
|
|||
('randomize', BOOL, True, "randomize selection of a witness in nlsat."),
|
||||
('max_conflicts', UINT, UINT_MAX, "maximum number of conflicts."),
|
||||
('shuffle_vars', BOOL, False, "use a random variable order."),
|
||||
('inline_vars', BOOL, False, "inline variables that can be isolated from equations"),
|
||||
('seed', UINT, 0, "random seed."),
|
||||
('factor', BOOL, True, "factor polynomials produced during conflict resolution.")
|
||||
))
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -35,7 +35,7 @@ namespace nlsat {
|
|||
struct imp;
|
||||
imp * m_imp;
|
||||
public:
|
||||
solver(reslimit& rlim, params_ref const & p);
|
||||
solver(reslimit& rlim, params_ref const & p, bool incremental);
|
||||
~solver();
|
||||
|
||||
/**
|
||||
|
@ -108,7 +108,7 @@ namespace nlsat {
|
|||
/**
|
||||
\brief Create a new clause.
|
||||
*/
|
||||
void mk_clause(unsigned num_lits, literal * lits, assumption a = 0);
|
||||
void mk_clause(unsigned num_lits, literal * lits, assumption a = nullptr);
|
||||
|
||||
// -----------------------
|
||||
//
|
||||
|
|
|
@ -47,6 +47,8 @@ namespace nlsat {
|
|||
typedef polynomial::var_vector var_vector;
|
||||
typedef polynomial::manager pmanager;
|
||||
typedef polynomial::polynomial poly;
|
||||
typedef polynomial::monomial monomial;
|
||||
typedef polynomial::numeral numeral;
|
||||
const var null_var = polynomial::null_var;
|
||||
|
||||
const var true_bool_var = 0;
|
||||
|
@ -148,10 +150,7 @@ namespace nlsat {
|
|||
typedef algebraic_numbers::anum anum;
|
||||
typedef algebraic_numbers::manager anum_manager;
|
||||
|
||||
class solver_exception : public default_exception {
|
||||
public:
|
||||
solver_exception(char const * msg):default_exception(msg) {}
|
||||
};
|
||||
typedef default_exception solver_exception;
|
||||
|
||||
class assignment;
|
||||
|
||||
|
|
|
@ -41,11 +41,11 @@ struct goal2nlsat::imp {
|
|||
m_solver(s) {
|
||||
}
|
||||
|
||||
virtual bool is_int(polynomial::var x) const {
|
||||
bool is_int(polynomial::var x) const override {
|
||||
return m_solver.is_int(x);
|
||||
}
|
||||
|
||||
virtual polynomial::var mk_var(bool is_int) {
|
||||
polynomial::var mk_var(bool is_int) override {
|
||||
return m_solver.mk_var(is_int);
|
||||
}
|
||||
};
|
||||
|
@ -269,12 +269,12 @@ struct goal2nlsat::scoped_set_imp {
|
|||
}
|
||||
|
||||
~scoped_set_imp() {
|
||||
m_owner.m_imp = 0;
|
||||
m_owner.m_imp = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
goal2nlsat::goal2nlsat() {
|
||||
m_imp = 0;
|
||||
m_imp = nullptr;
|
||||
}
|
||||
|
||||
goal2nlsat::~goal2nlsat() {
|
||||
|
|
|
@ -32,11 +32,11 @@ class nlsat_tactic : public tactic {
|
|||
ast_manager & m;
|
||||
expr_ref_vector m_var2expr;
|
||||
expr_display_var_proc(ast_manager & _m):m(_m), m_var2expr(_m) {}
|
||||
virtual void operator()(std::ostream & out, nlsat::var x) const {
|
||||
std::ostream& operator()(std::ostream & out, nlsat::var x) const override {
|
||||
if (x < m_var2expr.size())
|
||||
out << mk_ismt2_pp(m_var2expr.get(x), m);
|
||||
return out << mk_ismt2_pp(m_var2expr.get(x), m);
|
||||
else
|
||||
out << "x!" << x;
|
||||
return out << "x!" << x;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -51,7 +51,7 @@ class nlsat_tactic : public tactic {
|
|||
m(_m),
|
||||
m_params(p),
|
||||
m_display_var(_m),
|
||||
m_solver(m.limit(), p) {
|
||||
m_solver(m.limit(), p, false) {
|
||||
}
|
||||
|
||||
void updt_params(params_ref const & p) {
|
||||
|
@ -68,7 +68,7 @@ class nlsat_tactic : public tactic {
|
|||
}
|
||||
for (unsigned b = 0; b < b2a.size(); b++) {
|
||||
expr * a = b2a.get(b);
|
||||
if (a == 0)
|
||||
if (a == nullptr)
|
||||
continue;
|
||||
if (is_uninterp_const(a))
|
||||
continue;
|
||||
|
@ -116,7 +116,7 @@ class nlsat_tactic : public tactic {
|
|||
}
|
||||
for (unsigned b = 0; b < b2a.size(); b++) {
|
||||
expr * a = b2a.get(b);
|
||||
if (a == 0 || !is_uninterp_const(a))
|
||||
if (a == nullptr || !is_uninterp_const(a))
|
||||
continue;
|
||||
lbool val = m_solver.bvalue(b);
|
||||
if (val == l_undef)
|
||||
|
@ -171,7 +171,7 @@ class nlsat_tactic : public tactic {
|
|||
}
|
||||
}
|
||||
else {
|
||||
expr_dependency* lcore = 0;
|
||||
expr_dependency* lcore = nullptr;
|
||||
if (g->unsat_core_enabled()) {
|
||||
vector<nlsat::assumption, false> assumptions;
|
||||
m_solver.get_core(assumptions);
|
||||
|
@ -180,7 +180,7 @@ class nlsat_tactic : public tactic {
|
|||
lcore = m.mk_join(lcore, d);
|
||||
}
|
||||
}
|
||||
g->assert_expr(m.mk_false(), 0, lcore);
|
||||
g->assert_expr(m.mk_false(), nullptr, lcore);
|
||||
}
|
||||
|
||||
g->inc_depth();
|
||||
|
@ -202,36 +202,36 @@ class nlsat_tactic : public tactic {
|
|||
|
||||
~scoped_set_imp() {
|
||||
m_owner.m_imp->m_solver.collect_statistics(m_owner.m_stats);
|
||||
m_owner.m_imp = 0;
|
||||
m_owner.m_imp = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
nlsat_tactic(params_ref const & p):
|
||||
m_params(p) {
|
||||
m_imp = 0;
|
||||
m_imp = nullptr;
|
||||
}
|
||||
|
||||
virtual tactic * translate(ast_manager & m) {
|
||||
tactic * translate(ast_manager & m) override {
|
||||
return alloc(nlsat_tactic, m_params);
|
||||
}
|
||||
|
||||
virtual ~nlsat_tactic() {
|
||||
~nlsat_tactic() override {
|
||||
SASSERT(m_imp == 0);
|
||||
}
|
||||
|
||||
virtual void updt_params(params_ref const & p) {
|
||||
void updt_params(params_ref const & p) override {
|
||||
m_params = p;
|
||||
}
|
||||
|
||||
virtual void collect_param_descrs(param_descrs & r) {
|
||||
void collect_param_descrs(param_descrs & r) override {
|
||||
goal2nlsat::collect_param_descrs(r);
|
||||
nlsat::solver::collect_param_descrs(r);
|
||||
algebraic_numbers::manager::collect_param_descrs(r);
|
||||
}
|
||||
|
||||
virtual void operator()(goal_ref const & in,
|
||||
goal_ref_buffer & result) {
|
||||
void operator()(goal_ref const & in,
|
||||
goal_ref_buffer & result) override {
|
||||
try {
|
||||
imp local_imp(in->m(), m_params);
|
||||
scoped_set_imp setter(*this, local_imp);
|
||||
|
@ -246,13 +246,13 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void cleanup() {}
|
||||
void cleanup() override {}
|
||||
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -48,11 +48,15 @@ tactic * mk_qfnra_nlsat_tactic(ast_manager & m, params_ref const & p) {
|
|||
purify_p),
|
||||
mk_propagate_values_tactic(m, p),
|
||||
mk_solve_eqs_tactic(m, p),
|
||||
using_params(mk_purify_arith_tactic(m, p),
|
||||
purify_p),
|
||||
mk_elim_uncnstr_tactic(m, p),
|
||||
mk_elim_term_ite_tactic(m, p)),
|
||||
and_then(/* mk_degree_shift_tactic(m, p), */ // may affect full dimensionality detection
|
||||
factor,
|
||||
mk_solve_eqs_tactic(m, p),
|
||||
using_params(mk_purify_arith_tactic(m, p),
|
||||
purify_p),
|
||||
using_params(mk_simplify_tactic(m, p),
|
||||
main_p),
|
||||
mk_tseitin_cnf_core_tactic(m, p),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue