3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-11-25 23:19:32 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2025-11-20 10:32:51 -08:00
parent 823800541e
commit fc96f827a1
3 changed files with 60 additions and 18 deletions

View file

@ -709,12 +709,9 @@ namespace nla {
while (m_constraints.size() > max_ci) {
auto const& [_p, _k, _j] = m_constraints.back();
m_constraint_index.erase({_p.index(), _k});
auto ci = m_constraints.size() - 1;
remove_occurs(ci);
m_constraints.pop_back();
auto ci = m_constraints.size();
if (!m_occurs_trail.empty() && m_occurs_trail.back() == ci) {
remove_occurs(ci);
m_occurs_trail.pop_back();
}
}
for (auto const &[_p, _k, _j] : replay) {
auto ci = add_constraint(_p, _k, _j);
@ -937,13 +934,18 @@ namespace nla {
return;
m_occurs_trail.push_back(ci);
auto const &con = m_constraints[ci];
verbose_stream() << "init-occurs " << ci << " vars: " << con.p.free_vars() << "\n";
for (auto v : con.p.free_vars())
m_occurs[v].push_back(ci);
}
void stellensatz::remove_occurs(lp::constraint_index ci) {
if (m_occurs_trail.empty() || m_occurs_trail.back() != ci)
return;
m_occurs_trail.pop_back();
auto const &con = m_constraints[ci];
verbose_stream() << "remove-occurs " << ci << " vars: " << con.p.free_vars() << "\n";
for (auto v : con.p.free_vars())
m_occurs[v].pop_back();
}

View file

@ -161,6 +161,35 @@ struct solver::imp {
}
}
void add_tangent_lemmas() {
for (auto const mi : m_nla_core.to_refine()) {
auto const& m = m_nla_core.emon(mi);
if (m.size() != 2)
continue;
auto x = m.vars()[0];
auto y = m.vars()[1];
rational xv = m_nla_core.val(x);
rational yv = m_nla_core.val(y);
rational mv = m_nla_core.val(m.var());
SASSERT(xv * yv != mv);
// a := xv - 1, b := yv - 1
// mv < xv * yv
// (x - a)(y - b) = 1
// (x - a)(y - b) = xy - bx - ay + ab = 1
// mv - bx - ay + ab < 1
// lemma: x > a, y > b => xy - bx - ay + ab >= 1
//
// mv > xv * yv
// a := xv - 1, b := yv + 1
// x > a, y < b => xy - by - ax + ab <= -1
//
// other lemmas around a < x, b < y and a < x, b > y
//
}
}
/**
\brief one-shot nlsat check.
A one shot checker is the least functionality that can