3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-10-31 11:42:28 +00:00

outline for adding monomials

This commit is contained in:
Nikolaj Bjorner 2025-09-26 12:03:26 +03:00
parent a6ea667776
commit 6adb234673
14 changed files with 242 additions and 140 deletions

View file

@ -70,8 +70,8 @@ namespace smt {
struct enode_pp {
context const& ctx;
enode* n;
enode_pp(enode* n, context const& ctx): ctx(ctx), n(n) {}
enode const* n;
enode_pp(enode const* n, context const& ctx): ctx(ctx), n(n) {}
};
struct replay_unit {
@ -1414,7 +1414,7 @@ namespace smt {
void display_asserted_formulas(std::ostream & out) const;
enode_pp pp(enode* n) { return enode_pp(n, *this); }
enode_pp pp(enode const* n) { return enode_pp(n, *this); }
std::ostream& display_literal(std::ostream & out, literal l) const;

View file

@ -692,7 +692,7 @@ namespace smt {
std::ostream& operator<<(std::ostream& out, enode_pp const& p) {
ast_manager& m = p.ctx.get_manager();
enode* n = p.n;
enode const* n = p.n;
return out << n->get_owner_id() << ": " << mk_bounded_pp(n->get_expr(), m);
}

View file

@ -59,6 +59,11 @@ namespace smt {
}
}
bool theory::is_attached_to_var(enode const *n) const {
theory_var v = n->get_th_var(get_id());
return v != null_theory_var && get_enode(v) == n;
}
void theory::display_var2enode(std::ostream & out) const {
unsigned sz = m_var2enode.size();
for (unsigned v = 0; v < sz; v++) {

View file

@ -97,10 +97,7 @@ namespace smt {
but it may be inherited from another enode n' during an
equivalence class merge. That is, get_enode(v) != n.
*/
bool is_attached_to_var(enode const * n) const {
theory_var v = n->get_th_var(get_id());
return v != null_theory_var && get_enode(v) == n;
}
bool is_attached_to_var(enode const *n) const;
struct scoped_trace_stream {
ast_manager& m;

View file

@ -890,7 +890,7 @@ public:
mk_is_int_axiom(n);
}
bool internalize_atom(app * atom, bool gate_ctx) {
void internalize_atom(app * atom) {
TRACE(arith_internalize, tout << bpp(atom) << "\n";);
SASSERT(!ctx().b_internalized(atom));
expr* n1, *n2;
@ -918,12 +918,12 @@ public:
}
else if (a.is_is_int(atom)) {
internalize_is_int(atom);
return true;
return;
}
else {
TRACE(arith, tout << "Could not internalize " << mk_pp(atom, m) << "\n";);
found_unsupported(atom);
return true;
return;
}
if (is_int(v) && !r.is_int())
@ -936,7 +936,6 @@ public:
m_bool_var2bound.insert(bv, b);
mk_bound_axioms(*b);
TRACE(arith_internalize, tout << "Internalized " << bv << ": " << bpp(atom) << "\n";);
return true;
}
bool internalize_term(app * term) {
@ -1712,7 +1711,7 @@ public:
return FC_GIVEUP;
}
// create an eq atom representing "term = offset"
// create an eq atom representing "term = offset"
app_ref mk_eq(lp::lar_term const& term, rational const& offset) {
u_map<rational> coeffs;
term2coeffs(term, coeffs);
@ -1730,15 +1729,10 @@ public:
return atom;
}
}
// create a bound atom representing term >= k is lower_bound is true, and term <= k if it is false
expr_ref mk_bound(lp::lar_term const& term, rational const& k, bool lower_bound) {
rational offset;
expr_ref t(m);
return mk_bound(term, k, lower_bound, offset, t);
}
expr_ref mk_bound(lp::lar_term const& term, rational const& k, bool lower_bound, rational& offset, expr_ref& t) {
offset = k;
expr_ref mk_bound(lp::lar_term const& term, rational const& k, bool lower_bound) {
rational offset = k;
expr_ref t(m);
u_map<rational> coeffs;
term2coeffs(term, coeffs);
bool is_int = true;
@ -1925,9 +1919,7 @@ public:
TRACE(arith, tout << "branch\n";);
bool u = m_lia->is_upper();
auto const & k = m_lia->offset();
rational offset;
expr_ref t(m);
expr_ref b = mk_bound(m_lia->get_term(), k, !u, offset, t);
expr_ref b = mk_bound(m_lia->get_term(), k, !u);
if (m.has_trace_stream()) {
app_ref body(m);
body = m.mk_or(b, m.mk_not(b));
@ -4192,16 +4184,13 @@ public:
unsigned init_range() const { return 5; }
unsigned max_range() const { return 20; }
void setup() {
m_bounded_range_lit = null_literal;
m_bound_terms.reset();
m_bound_predicate = nullptr;
}
void validate_model(proto_model& mdl) {
rational r1, r2;
expr_ref res(m);
if (!m_model_is_initialized)
@ -4240,7 +4229,8 @@ void theory_lra::init() {
m_imp->init();
}
bool theory_lra::internalize_atom(app * atom, bool gate_ctx) {
return m_imp->internalize_atom(atom, gate_ctx);
m_imp->internalize_atom(atom);
return true;
}
bool theory_lra::internalize_term(app * term) {
return m_imp->internalize_term(term);