3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 09:35:32 +00:00

Merge branch 'master' into polysat

This commit is contained in:
Jakob Rath 2022-08-01 11:27:49 +02:00
commit 220a63e8bd
223 changed files with 508 additions and 505 deletions

View file

@ -51,7 +51,6 @@ public:
result operator()(goal const & g) override {
return is_unbounded(g);
}
~is_unbounded_probe() override {}
};
probe * mk_is_unbounded_probe() {

View file

@ -39,9 +39,6 @@ public:
return alloc(card2bv_tactic, m, m_params);
}
~card2bv_tactic() override {
}
char const* name() const override { return "card2bv"; }
void updt_params(params_ref const & p) override {

View file

@ -165,10 +165,6 @@ public:
m_bounds(m) {
}
~eq2bv_tactic() override {
}
void updt_params(params_ref const & p) override {
}

View file

@ -61,7 +61,8 @@ class fm_tactic : public tactic {
return m.is_false(val);
}
r_kind process(func_decl * x, expr * cls, arith_util & u, model& ev, rational & r) {
r_kind process(func_decl * x, expr * cls, arith_util & u, model& ev, rational & r, expr_ref& r_e) {
r_e = nullptr;
unsigned num_lits;
expr * const * lits;
if (m.is_or(cls)) {
@ -93,6 +94,7 @@ class fm_tactic : public tactic {
expr * lhs = to_app(l)->get_arg(0);
expr * rhs = to_app(l)->get_arg(1);
rational c;
expr_ref c_e(m);
if (!u.is_numeral(rhs, c))
return NONE;
if (neg)
@ -133,27 +135,41 @@ class fm_tactic : public tactic {
expr_ref val(m);
val = ev(monomial);
rational tmp;
if (!u.is_numeral(val, tmp))
return NONE;
if (neg)
tmp.neg();
c -= tmp;
if (u.is_numeral(val, tmp)) {
if (neg)
tmp.neg();
c -= tmp;
}
else {
// this happens for algebraic numerals
if (neg)
val = u.mk_uminus(val);
if (!c_e)
c_e = u.mk_uminus(val);
else
c_e = u.mk_sub(c_e, val);
}
}
}
if (u.is_int(x->get_range()) && strict) {
// a*x < c --> a*x <= c-1
SASSERT(c.is_int());
c--;
SASSERT(!c_e);
}
is_lower = a_val.is_neg();
c /= a_val;
if (c_e)
c_e = u.mk_div(c_e, u.mk_numeral(a_val, false));
if (u.is_int(x->get_range())) {
SASSERT(!c_e);
if (is_lower)
c = ceil(c);
else
c = floor(c);
}
r = c;
r_e = c_e;
}
}
(void)found;
@ -187,6 +203,12 @@ class fm_tactic : public tactic {
//model_evaluator ev(*(md.get()));
//ev.set_model_completion(true);
arith_util u(m);
auto mk_max = [&](expr* a, expr* b) {
return expr_ref(m.mk_ite(u.mk_ge(a, b), a, b), m);
};
auto mk_min = [&](expr* a, expr* b) {
return expr_ref(m.mk_ite(u.mk_ge(a, b), b, a), m);
};
unsigned i = m_xs.size();
while (i > 0) {
--i;
@ -194,44 +216,67 @@ class fm_tactic : public tactic {
rational lower;
rational upper;
rational val;
bool has_lower = false;
bool has_upper = false;
expr_ref val_e(m), val_upper_e(m), val_lower_e(m);
bool has_lower = false, has_upper = false;
TRACE("fm_mc", tout << "processing " << x->get_name() << "\n";);
clauses::iterator it = m_clauses[i].begin();
clauses::iterator end = m_clauses[i].end();
for (; it != end; ++it) {
for (expr* cl : m_clauses[i]) {
if (!m.inc())
throw tactic_exception(m.limit().get_cancel_msg());
switch (process(x, *it, u, *md, val)) {
switch (process(x, cl, u, *md, val, val_e)) {
case NONE:
TRACE("fm_mc", tout << "no bound for:\n" << mk_ismt2_pp(*it, m) << "\n";);
TRACE("fm_mc", tout << "no bound for:\n" << mk_ismt2_pp(cl, m) << "\n";);
break;
case LOWER:
TRACE("fm_mc", tout << "lower bound: " << val << " for:\n" << mk_ismt2_pp(*it, m) << "\n";);
if (!has_lower || val > lower)
lower = val;
has_lower = true;
TRACE("fm_mc", tout << "lower bound: " << val << " for:\n" << mk_ismt2_pp(cl, m) << "\n";);
if (val_e)
val_lower_e = val_lower_e != nullptr ? mk_max(val_lower_e, val_e) : val_e;
else if (!has_lower || val > lower)
lower = val, has_lower = true;
break;
case UPPER:
TRACE("fm_mc", tout << "upper bound: " << val << " for:\n" << mk_ismt2_pp(*it, m) << "\n";);
if (!has_upper || val < upper)
upper = val;
has_upper = true;
TRACE("fm_mc", tout << "upper bound: " << val << " for:\n" << mk_ismt2_pp(cl, m) << "\n";);
if (val_e)
val_upper_e = val_upper_e != nullptr ? mk_min(val_upper_e, val_e) : val_e;
else if (!has_upper || val < upper)
upper = val, has_upper = true;
break;
}
}
expr * x_val;
if (u.is_int(x->get_range())) {
if (has_lower)
if (val_lower_e) {
x_val = val_lower_e;
if (has_lower)
x_val = mk_max(x_val, u.mk_numeral(lower, true));
}
else if (val_upper_e) {
x_val = val_upper_e;
if (has_upper)
x_val = mk_min(x_val, u.mk_numeral(upper, true));
}
else if (has_lower)
x_val = u.mk_numeral(lower, true);
else if (has_upper)
x_val = u.mk_numeral(upper, true);
else
x_val = u.mk_numeral(rational(0), true);
}
else {
if (has_lower && has_upper)
if (val_lower_e && has_lower)
val_lower_e = mk_max(val_lower_e, u.mk_numeral(lower, false));
if (val_upper_e && has_upper)
val_upper_e = mk_min(val_upper_e, u.mk_numeral(upper, false));
if (val_lower_e && val_upper_e)
x_val = u.mk_div(u.mk_add(val_lower_e, val_upper_e), u.mk_real(2));
else if (val_lower_e)
x_val = u.mk_add(val_lower_e, u.mk_real(1));
else if (val_upper_e)
x_val = u.mk_sub(val_upper_e, u.mk_real(1));
else if (has_lower && has_upper)
x_val = u.mk_numeral((upper + lower)/rational(2), false);
else if (has_lower)
x_val = u.mk_numeral(lower + rational(1), false);
@ -1168,18 +1213,12 @@ class fm_tactic : public tactic {
}
// x_cost_lt is not a total order on variables
std::stable_sort(x_cost_vector.begin(), x_cost_vector.end(), x_cost_lt(m_is_int));
TRACE("fm",
svector<x_cost>::iterator it2 = x_cost_vector.begin();
svector<x_cost>::iterator end2 = x_cost_vector.end();
for (; it2 != end2; ++it2) {
tout << "(" << mk_ismt2_pp(m_var2expr.get(it2->first), m) << " " << it2->second << ") ";
}
TRACE("fm",
for (auto const& [v,c] : x_cost_vector)
tout << "(" << mk_ismt2_pp(m_var2expr.get(v), m) << " " << c << ") ";
tout << "\n";);
svector<x_cost>::iterator it2 = x_cost_vector.begin();
svector<x_cost>::iterator end2 = x_cost_vector.end();
for (; it2 != end2; ++it2) {
xs.push_back(it2->first);
}
for (auto const& [v, c] : x_cost_vector)
xs.push_back(v);
}
void cleanup_constraints(constraints & cs) {
@ -1215,11 +1254,9 @@ class fm_tactic : public tactic {
void analyze(constraints const & cs, var x, bool & all_int, bool & unit_coeff) const {
all_int = true;
unit_coeff = true;
constraints::const_iterator it = cs.begin();
constraints::const_iterator end = cs.end();
for (; it != end; ++it) {
for (auto const * c : cs) {
bool curr_unit_coeff;
analyze(*(*it), x, all_int, curr_unit_coeff);
analyze(*c, x, all_int, curr_unit_coeff);
if (!all_int)
return;
if (!curr_unit_coeff)
@ -1243,12 +1280,8 @@ class fm_tactic : public tactic {
}
void copy_constraints(constraints const & s, clauses & t) {
constraints::const_iterator it = s.begin();
constraints::const_iterator end = s.end();
for (; it != end; ++it) {
app * c = to_expr(*(*it));
t.push_back(c);
}
for (auto const* cp : s)
t.push_back(to_expr(*cp));
}
clauses tmp_clauses;
@ -1262,10 +1295,8 @@ class fm_tactic : public tactic {
}
void mark_constraints_dead(constraints const & cs) {
constraints::const_iterator it = cs.begin();
constraints::const_iterator end = cs.end();
for (; it != end; ++it)
(*it)->m_dead = true;
for (auto* cp : cs)
cp->m_dead = true;
}
void mark_constraints_dead(var x) {
@ -1514,14 +1545,8 @@ class fm_tactic : public tactic {
}
void copy_remaining(vector<constraints> & v2cs) {
vector<constraints>::iterator it = v2cs.begin();
vector<constraints>::iterator end = v2cs.end();
for (; it != end; ++it) {
constraints & cs = *it;
constraints::iterator it2 = cs.begin();
constraints::iterator end2 = cs.end();
for (; it2 != end2; ++it2) {
constraint * c = *it2;
for (constraints& cs : v2cs) {
for (constraint* c : cs) {
if (!c->m_dead) {
c->m_dead = true;
expr * new_f = to_expr(*c);
@ -1604,11 +1629,9 @@ class fm_tactic : public tactic {
}
void display_constraints(std::ostream & out, constraints const & cs) const {
constraints::const_iterator it = cs.begin();
constraints::const_iterator end = cs.end();
for (; it != end; ++it) {
for (auto const* cp : cs) {
out << " ";
display(out, *(*it));
display(out, *cp);
out << "\n";
}
}

View file

@ -434,9 +434,6 @@ public:
return alloc(nla2bv_tactic, m_params);
}
~nla2bv_tactic() override {
}
char const* name() const override { return "nla2bv"; }
void updt_params(params_ref const & p) override {

View file

@ -902,9 +902,6 @@ public:
tactic * translate(ast_manager & m) override {
return alloc(purify_arith_tactic, m, m_params);
}
~purify_arith_tactic() override {
}
char const* name() const override { return "purify_arith"; }

View file

@ -50,10 +50,7 @@ struct bit_blaster_model_converter : public model_converter {
for (func_decl* f : newbits)
m_newbits.push_back(f);
}
~bit_blaster_model_converter() override {
}
void collect_bits(obj_hashtable<func_decl> & bits) {
unsigned sz = m_bits.size();
for (unsigned i = 0; i < sz; i++) {

View file

@ -109,8 +109,6 @@ struct bv_bound_chk_rewriter : public rewriter_tpl<bv_bound_chk_rewriter_cfg> {
updt_params(p);
}
~bv_bound_chk_rewriter() override {}
void updt_params(params_ref const & _p) {
m_cfg.updt_params(_p);
}

View file

@ -93,7 +93,6 @@ class dt2bv_tactic : public tactic {
struct sort_pred : public i_sort_pred {
dt2bv_tactic& m_t;
sort_pred(dt2bv_tactic& t): m_t(t) {}
~sort_pred() override {}
bool operator()(sort* s) override {
return m_t.m_fd_sorts.contains(s);
}

View file

@ -57,8 +57,6 @@ protected:
public:
concat_converter(T * c1, T * c2):m_c1(c1), m_c2(c2) {}
~concat_converter() override {}
void cancel() override {
m_c2->cancel();

View file

@ -50,7 +50,6 @@ public:
return alloc(cofactor_term_ite_tactic, m, m_params);
}
~cofactor_term_ite_tactic() override {}
char const* name() const override { return "cofactor"; }
void updt_params(params_ref const & p) override { m_params.append(p); m_elim_ite.updt_params(m_params); }
void collect_param_descrs(param_descrs & r) override { m_elim_ite.collect_param_descrs(r); }

View file

@ -52,8 +52,6 @@ public:
m_params(p) {
}
~collect_statistics_tactic() override {}
char const* name() const override { return "collect_statistics"; }
tactic * translate(ast_manager & m_) override {

View file

@ -32,7 +32,6 @@ class ctx_propagate_assertions : public ctx_simplify_tactic::simplifier {
void assert_eq_core(expr * t, app * val);
public:
ctx_propagate_assertions(ast_manager& m);
~ctx_propagate_assertions() override {}
bool assert_expr(expr * t, bool sign) override;
bool simplify(expr* t, expr_ref& result) override;
void push();

View file

@ -541,7 +541,6 @@ class expr_substitution_simplifier : public dom_simplifier {
public:
expr_substitution_simplifier(ast_manager& m): m(m), m_subst(m), m_scoped_substitution(m_subst), m_trail(m) {}
~expr_substitution_simplifier() override {}
bool assert_expr(expr * t, bool sign) override {
expr* tt;

View file

@ -47,8 +47,6 @@ public:
return alloc(nnf_tactic, m_params);
}
~nnf_tactic() override {}
char const* name() const override { return "nnf"; }
void updt_params(params_ref const & p) override { m_params.append(p); }

View file

@ -102,8 +102,6 @@ public:
pb_preprocess_tactic(ast_manager& m, params_ref const& p = params_ref()):
m(m), m_trail(m), pb(m), m_r(m) {}
~pb_preprocess_tactic() override {}
tactic * translate(ast_manager & m) override {
return alloc(pb_preprocess_tactic, m);
}

View file

@ -45,8 +45,6 @@ public:
m_arith(m)
{}
~reduce_invertible_tactic() override { }
char const* name() const override { return "reduce_invertible"; }
tactic * translate(ast_manager & m) override {

View file

@ -47,8 +47,6 @@ public:
special_relations_tactic(ast_manager & m, params_ref const & ref = params_ref()):
m(m), m_params(ref), m_pm(m) {}
~special_relations_tactic() override {}
void updt_params(params_ref const & p) override { m_params.append(p); }
void collect_param_descrs(param_descrs & r) override { }

View file

@ -52,8 +52,6 @@ class split_clause_tactic : public tactic {
split_pc(ast_manager & m, app * cls, proof * pr):m_clause(cls, m), m_clause_pr(pr, m) {
}
~split_pc() override { }
proof_ref operator()(ast_manager & m, unsigned num_source, proof * const * source) override {
// Let m_clause be of the form (l_0 or ... or l_{num_source - 1})
// Each source[i] proof is a proof for "false" using l_i as a hypothesis
@ -87,9 +85,6 @@ public:
t->m_largest_clause = m_largest_clause;
return t;
}
~split_clause_tactic() override {
}
char const* name() const override { return "split_clause"; }

View file

@ -32,8 +32,6 @@ public:
equiv_proof_converter(ast_manager& m): m(m), m_replace(m) {}
~equiv_proof_converter() override {}
proof_ref operator()(ast_manager & m, unsigned num_source, proof * const * source) override {
return m_replace(m, num_source, source);
}

View file

@ -46,8 +46,6 @@ public:
solver::updt_params(p);
}
~enum2bv_solver() override {}
solver* translate(ast_manager& dst_m, params_ref const& p) override {
solver* result = alloc(enum2bv_solver, dst_m, p, m_solver->translate(dst_m, p));
model_converter_ref mc = external_model_converter();

View file

@ -46,8 +46,6 @@ public:
solver::updt_params(p);
}
~pb2bv_solver() override {}
solver* translate(ast_manager& dst_m, params_ref const& p) override {
flush_assertions();
solver* result = alloc(pb2bv_solver, dst_m, p, m_solver->translate(dst_m, p));

View file

@ -1867,9 +1867,7 @@ namespace smtfd {
updt_params(p);
add_toggle(m.mk_true());
}
~solver() override {}
::solver* translate(ast_manager& dst_m, params_ref const& p) override {
solver* result = alloc(solver, m_indent, dst_m, p);
if (m_fd_sat_solver) result->m_fd_sat_solver = m_fd_sat_solver->translate(dst_m, p);

View file

@ -70,7 +70,6 @@ public:
result operator()(goal const & g) override {
return !test<is_non_fp_qfnra_predicate>(g);
}
~is_fp_qfnra_probe() override {}
};
probe * mk_is_fp_qfnra_probe() {
@ -145,8 +144,6 @@ public:
result operator()(goal const & g) override {
return !test<is_non_qffp_predicate>(g);
}
~is_qffp_probe() override {}
};
probe * mk_is_qffp_probe() {

View file

@ -82,8 +82,6 @@ public:
test<is_fpa_function>(g) &&
!test<is_non_qffplra_predicate>(g);
}
~is_qffplra_probe() override {}
};
probe * mk_is_qffplra_probe() {

View file

@ -136,8 +136,6 @@ public:
model2mc(model * m, labels_vec const & r):m_model(m), m_labels(r) {}
~model2mc() override {}
void operator()(model_ref & m) override {
if (!m || !m_model) {
m = m_model;

View file

@ -130,8 +130,7 @@ class smt_strategic_solver_factory : public solver_factory {
symbol m_logic;
public:
smt_strategic_solver_factory(symbol const & logic):m_logic(logic) {}
~smt_strategic_solver_factory() override {}
solver * operator()(ast_manager & m, params_ref const & p, bool proofs_enabled, bool models_enabled, bool unsat_core_enabled, symbol const & logic) override {
symbol l;
if (m_logic != symbol::null)

View file

@ -131,8 +131,6 @@ public:
return alloc(solver_subsumption_tactic, other_m, m_params);
}
~solver_subsumption_tactic() override {}
char const* name() const override { return "solver_subsumption"; }
void updt_params(params_ref const& p) override {

View file

@ -86,7 +86,6 @@ class proof2pc : public proof_converter {
proof_ref m_pr;
public:
proof2pc(ast_manager & m, proof * pr):m_pr(pr, m) {}
~proof2pc() override {}
proof_ref operator()(ast_manager & m, unsigned num_source, proof * const * source) override {
SASSERT(num_source == 0);

View file

@ -25,7 +25,6 @@ class goal;
class proof_converter : public converter {
public:
~proof_converter() override { }
virtual proof_ref operator()(ast_manager & m, unsigned num_source, proof * const * source) = 0;
virtual proof_converter * translate(ast_translation & translator) = 0;
};

View file

@ -31,8 +31,6 @@ public:
replace_proof_converter(ast_manager& _m): m(_m), m_proofs(m) {}
~replace_proof_converter() override {}
proof_ref operator()(ast_manager & _m, unsigned num_source, proof * const * source) override;
proof_converter * translate(ast_translation & translator) override;

View file

@ -51,8 +51,6 @@ public:
, m_inc_use_sat(false)
{}
~qfufbv_ackr_tactic() override { }
char const* name() const override { return "qfufbv_ackr"; }
void operator()(goal_ref const & g, goal_ref_buffer & result) override {

View file

@ -35,7 +35,6 @@ class tactic : public user_propagator::core {
unsigned m_ref_count;
public:
tactic():m_ref_count(0) {}
virtual ~tactic() {}
void inc_ref() { m_ref_count++; }
void dec_ref() { SASSERT(m_ref_count > 0); m_ref_count--; if (m_ref_count == 0) dealloc(this); }

View file

@ -26,7 +26,6 @@ protected:
std::string m_msg;
public:
tactic_exception(std::string && msg) : m_msg(std::move(msg)) {}
~tactic_exception() override {}
char const * msg() const override { return m_msg.c_str(); }
};