mirror of
https://github.com/Z3Prover/z3
synced 2025-06-28 08:58:44 +00:00
Merge branch 'master' into nl_branches
This commit is contained in:
commit
9aeaed8f53
52 changed files with 735 additions and 590 deletions
|
@ -67,6 +67,8 @@ namespace smt {
|
|||
m_ge(ge) {
|
||||
}
|
||||
|
||||
~arith_eq_relevancy_eh() override {}
|
||||
|
||||
void operator()(relevancy_propagator & rp) override {
|
||||
if (!rp.is_relevant(m_n1))
|
||||
return;
|
||||
|
|
|
@ -3565,7 +3565,6 @@ namespace smt {
|
|||
try {
|
||||
internalize_assertions();
|
||||
} catch (cancel_exception&) {
|
||||
VERIFY(resource_limits_exceeded());
|
||||
return l_undef;
|
||||
}
|
||||
expr_ref_vector theory_assumptions(m);
|
||||
|
@ -3637,7 +3636,6 @@ namespace smt {
|
|||
TRACE("unsat_core_bug", tout << asms << '\n';);
|
||||
init_assumptions(asms);
|
||||
} catch (cancel_exception&) {
|
||||
VERIFY(resource_limits_exceeded());
|
||||
return l_undef;
|
||||
}
|
||||
TRACE("before_search", display(tout););
|
||||
|
@ -3664,7 +3662,6 @@ namespace smt {
|
|||
for (auto const& clause : clauses) if (!validate_assumptions(clause)) return l_undef;
|
||||
init_assumptions(asms);
|
||||
} catch (cancel_exception&) {
|
||||
VERIFY(resource_limits_exceeded());
|
||||
return l_undef;
|
||||
}
|
||||
for (auto const& clause : clauses) init_clause(clause);
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace smt {
|
|||
}
|
||||
|
||||
struct relevancy_propagator_imp : public relevancy_propagator {
|
||||
unsigned m_qhead;
|
||||
unsigned m_qhead = 0;
|
||||
expr_ref_vector m_relevant_exprs;
|
||||
uint_set m_is_relevant;
|
||||
typedef list<relevancy_eh *> relevancy_ehs;
|
||||
|
@ -144,14 +144,18 @@ namespace smt {
|
|||
unsigned m_trail_lim;
|
||||
};
|
||||
svector<scope> m_scopes;
|
||||
bool m_propagating;
|
||||
bool m_propagating = false;
|
||||
|
||||
relevancy_propagator_imp(context & ctx):
|
||||
relevancy_propagator(ctx), m_qhead(0), m_relevant_exprs(ctx.get_manager()),
|
||||
m_propagating(false) {}
|
||||
relevancy_propagator(ctx), m_relevant_exprs(ctx.get_manager()) {}
|
||||
|
||||
~relevancy_propagator_imp() override {
|
||||
undo_trail(0);
|
||||
ast_manager & m = get_manager();
|
||||
unsigned i = m_trail.size();
|
||||
while (i != 0) {
|
||||
--i;
|
||||
m.dec_ref(m_trail[i].get_node());
|
||||
}
|
||||
}
|
||||
|
||||
relevancy_ehs * get_handlers(expr * n) {
|
||||
|
|
|
@ -41,13 +41,14 @@ namespace smt {
|
|||
/**
|
||||
\brief Fallback for the two previous methods.
|
||||
*/
|
||||
virtual void operator()(relevancy_propagator & rp) {}
|
||||
virtual void operator()(relevancy_propagator & rp) = 0;
|
||||
};
|
||||
|
||||
class simple_relevancy_eh : public relevancy_eh {
|
||||
expr * m_target;
|
||||
public:
|
||||
simple_relevancy_eh(expr * t):m_target(t) {}
|
||||
~simple_relevancy_eh() override {}
|
||||
void operator()(relevancy_propagator & rp) override;
|
||||
};
|
||||
|
||||
|
@ -60,6 +61,7 @@ namespace smt {
|
|||
expr * m_target;
|
||||
public:
|
||||
pair_relevancy_eh(expr * s1, expr * s2, expr * t):m_source1(s1), m_source2(s2), m_target(t) {}
|
||||
~pair_relevancy_eh() override {}
|
||||
void operator()(relevancy_propagator & rp) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -546,7 +546,7 @@ namespace smt {
|
|||
|
||||
expr_ref def2(m.mk_app(f, args2.size(), args2.data()), m);
|
||||
ctx.get_rewriter()(def2);
|
||||
expr* def1 = mk_default(map);
|
||||
expr_ref def1(mk_default(map), m);
|
||||
ctx.internalize(def1, false);
|
||||
ctx.internalize(def2, false);
|
||||
return try_assign_eq(def1, def2);
|
||||
|
@ -561,7 +561,7 @@ namespace smt {
|
|||
SASSERT(is_const(cnst));
|
||||
TRACE("array", tout << mk_bounded_pp(cnst->get_expr(), m) << "\n";);
|
||||
expr* val = cnst->get_arg(0)->get_expr();
|
||||
expr* def = mk_default(cnst->get_expr());
|
||||
expr_ref def(mk_default(cnst->get_expr()), m);
|
||||
ctx.internalize(def, false);
|
||||
return try_assign_eq(val, def);
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ namespace smt {
|
|||
return false;
|
||||
m_stats.m_num_default_lambda_axiom++;
|
||||
expr* e = arr->get_expr();
|
||||
expr* def = mk_default(e);
|
||||
expr_ref def(mk_default(e), m);
|
||||
quantifier* lam = m.is_lambda_def(arr->get_decl());
|
||||
TRACE("array", tout << mk_pp(lam, m) << "\n" << mk_pp(e, m) << "\n");
|
||||
expr_ref_vector args(m);
|
||||
|
|
|
@ -2874,7 +2874,7 @@ public:
|
|||
lp::lar_term const& term = lp().get_term(ti);
|
||||
for (auto const mono : term) {
|
||||
auto wi = lp().column2tv(mono.column());
|
||||
lp::constraint_index ci;
|
||||
u_dependency* ci = nullptr;
|
||||
rational value;
|
||||
bool is_strict;
|
||||
if (wi.is_term()) {
|
||||
|
@ -2977,12 +2977,13 @@ public:
|
|||
vector<constraint_bound> m_upper_terms;
|
||||
|
||||
void propagate_eqs(lp::tv t, lp::constraint_index ci1, lp::lconstraint_kind k, api_bound& b, rational const& value) {
|
||||
lp::constraint_index ci2;
|
||||
u_dependency* ci2 = nullptr;
|
||||
auto pair = [&]() { return lp().dep_manager().mk_join(lp().dep_manager().mk_leaf(ci1), ci2); };
|
||||
if (k == lp::GE && set_lower_bound(t, ci1, value) && has_upper_bound(t.index(), ci2, value)) {
|
||||
fixed_var_eh(b.get_var(), t, ci1, ci2, value);
|
||||
fixed_var_eh(b.get_var(), t, pair(), value);
|
||||
}
|
||||
else if (k == lp::LE && set_upper_bound(t, ci1, value) && has_lower_bound(t.index(), ci2, value)) {
|
||||
fixed_var_eh(b.get_var(), t, ci1, ci2, value);
|
||||
fixed_var_eh(b.get_var(), t, pair(), value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3023,11 +3024,12 @@ public:
|
|||
// m_solver already tracks bounds on proper variables, but not on terms.
|
||||
bool is_strict = false;
|
||||
rational b;
|
||||
u_dependency* dep = nullptr;
|
||||
if (is_lower) {
|
||||
return lp().has_lower_bound(tv.id(), ci, b, is_strict) && !is_strict && b == v;
|
||||
return lp().has_lower_bound(tv.id(), dep, b, is_strict) && !is_strict && b == v;
|
||||
}
|
||||
else {
|
||||
return lp().has_upper_bound(tv.id(), ci, b, is_strict) && !is_strict && b == v;
|
||||
return lp().has_upper_bound(tv.id(), dep, b, is_strict) && !is_strict && b == v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3035,35 +3037,37 @@ public:
|
|||
bool var_has_bound(lpvar vi, bool is_lower) {
|
||||
bool is_strict = false;
|
||||
rational b;
|
||||
lp::constraint_index ci;
|
||||
u_dependency* dep;
|
||||
if (is_lower) {
|
||||
return lp().has_lower_bound(vi, ci, b, is_strict);
|
||||
return lp().has_lower_bound(vi, dep, b, is_strict);
|
||||
}
|
||||
else {
|
||||
return lp().has_upper_bound(vi, ci, b, is_strict);
|
||||
return lp().has_upper_bound(vi, dep, b, is_strict);
|
||||
}
|
||||
}
|
||||
|
||||
bool has_upper_bound(lpvar vi, lp::constraint_index& ci, rational const& bound) { return has_bound(vi, ci, bound, false); }
|
||||
bool has_upper_bound(lpvar vi, u_dependency*& ci, rational const& bound) { return has_bound(vi, ci, bound, false); }
|
||||
|
||||
bool has_lower_bound(lpvar vi, lp::constraint_index& ci, rational const& bound) { return has_bound(vi, ci, bound, true); }
|
||||
bool has_lower_bound(lpvar vi, u_dependency*& ci, rational const& bound) { return has_bound(vi, ci, bound, true); }
|
||||
|
||||
bool has_bound(lpvar vi, lp::constraint_index& ci, rational const& bound, bool is_lower) {
|
||||
bool has_bound(lpvar vi, u_dependency*& dep, rational const& bound, bool is_lower) {
|
||||
if (lp::tv::is_term(vi)) {
|
||||
theory_var v = lp().local_to_external(vi);
|
||||
rational val;
|
||||
TRACE("arith", tout << lp().get_variable_name(vi) << " " << v << "\n";);
|
||||
if (v != null_theory_var && a.is_numeral(get_owner(v), val) && bound == val) {
|
||||
ci = UINT_MAX;
|
||||
dep = nullptr;
|
||||
return bound == val;
|
||||
}
|
||||
|
||||
auto& vec = is_lower ? m_lower_terms : m_upper_terms;
|
||||
lpvar ti = lp::tv::unmask_term(vi);
|
||||
if (vec.size() > ti) {
|
||||
constraint_bound& b = vec[ti];
|
||||
ci = b.first;
|
||||
return ci != UINT_MAX && bound == b.second;
|
||||
auto const& [ci, coeff] = vec[ti];
|
||||
if (ci == UINT_MAX)
|
||||
return false;
|
||||
dep = lp().dep_manager().mk_leaf(ci);
|
||||
return bound == coeff;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
@ -3073,10 +3077,10 @@ public:
|
|||
bool is_strict = false;
|
||||
rational b;
|
||||
if (is_lower) {
|
||||
return lp().has_lower_bound(vi, ci, b, is_strict) && b == bound && !is_strict;
|
||||
return lp().has_lower_bound(vi, dep, b, is_strict) && b == bound && !is_strict;
|
||||
}
|
||||
else {
|
||||
return lp().has_upper_bound(vi, ci, b, is_strict) && b == bound && !is_strict;
|
||||
return lp().has_upper_bound(vi, dep, b, is_strict) && b == bound && !is_strict;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3089,7 +3093,7 @@ public:
|
|||
|
||||
void report_equality_of_fixed_vars(unsigned vi1, unsigned vi2) {
|
||||
rational bound(0);
|
||||
lp::constraint_index ci1, ci2, ci3, ci4;
|
||||
u_dependency* ci1 = nullptr, *ci2 = nullptr, *ci3 = nullptr, *ci4 = nullptr;
|
||||
theory_var v1 = lp().local_to_external(vi1);
|
||||
theory_var v2 = lp().local_to_external(vi2);
|
||||
TRACE("arith", tout << "fixed: " << mk_pp(get_owner(v1), m) << " " << mk_pp(get_owner(v2), m) << "\n";);
|
||||
|
@ -3141,7 +3145,7 @@ public:
|
|||
ctx().assign_eq(x, y, eq_justification(js));
|
||||
}
|
||||
|
||||
void fixed_var_eh(theory_var v, lp::tv t, lp::constraint_index ci1, lp::constraint_index ci2, rational const& bound) {
|
||||
void fixed_var_eh(theory_var v, lp::tv t, u_dependency* dep, rational const& bound) {
|
||||
theory_var w = null_theory_var;
|
||||
enode* x = get_enode(v);
|
||||
if (m_value2var.find(bound, w))
|
||||
|
@ -3158,8 +3162,7 @@ public:
|
|||
if (x->get_root() == y->get_root())
|
||||
return;
|
||||
reset_evidence();
|
||||
set_evidence(ci1, m_core, m_eqs);
|
||||
set_evidence(ci2, m_core, m_eqs);
|
||||
set_evidence(dep, m_core, m_eqs);
|
||||
++m_stats.m_fixed_eqs;
|
||||
assign_eq(v, w);
|
||||
}
|
||||
|
@ -3194,6 +3197,11 @@ public:
|
|||
|
||||
// lp::constraint_index const null_constraint_index = UINT_MAX; // not sure what a correct fix is
|
||||
|
||||
void set_evidence(u_dependency* dep, literal_vector& core, svector<enode_pair>& eqs) {
|
||||
for (auto ci : lp().flatten(dep))
|
||||
set_evidence(ci, core, eqs);
|
||||
}
|
||||
|
||||
void set_evidence(lp::constraint_index idx, literal_vector& core, svector<enode_pair>& eqs) {
|
||||
if (idx == UINT_MAX) {
|
||||
return;
|
||||
|
@ -3414,7 +3422,7 @@ public:
|
|||
if (!is_registered_var(v))
|
||||
return false;
|
||||
lpvar vi = get_lpvar(v);
|
||||
lp::constraint_index ci;
|
||||
u_dependency* ci;
|
||||
return lp().has_lower_bound(vi, ci, val, is_strict);
|
||||
}
|
||||
|
||||
|
@ -3433,8 +3441,8 @@ public:
|
|||
if (!is_registered_var(v))
|
||||
return false;
|
||||
lpvar vi = get_lpvar(v);
|
||||
lp::constraint_index ci;
|
||||
return lp().has_upper_bound(vi, ci, val, is_strict);
|
||||
u_dependency* dep = nullptr;
|
||||
return lp().has_upper_bound(vi, dep, val, is_strict);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue