3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-11 09:44:43 +00:00

use lazy scopes to avoid push/pop overhead

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-08-17 08:07:06 -07:00
parent 558233dd8e
commit f0308436b5
6 changed files with 51 additions and 12 deletions

View file

@ -426,6 +426,8 @@ namespace smt {
quantifier_manager::quantifier_manager(context & ctx, smt_params & fp, params_ref const & p) {
m_imp = alloc(imp, *this, ctx, fp, mk_default_plugin());
m_imp->m_plugin->set_manager(*this);
m_lazy_scopes = 0;
m_lazy = true;
}
@ -438,6 +440,10 @@ namespace smt {
}
void quantifier_manager::add(quantifier * q, unsigned generation) {
if (m_lazy) {
while (m_lazy_scopes-- > 0) m_imp->push();
m_lazy = false;
}
m_imp->add(q, generation);
}
@ -529,12 +535,18 @@ namespace smt {
return m_imp->check_model(m, root2value);
}
void quantifier_manager::push() {
m_imp->push();
void quantifier_manager::push() {
if (m_lazy)
++m_lazy_scopes;
else
m_imp->push();
}
void quantifier_manager::pop(unsigned num_scopes) {
m_imp->pop(num_scopes);
if (m_lazy)
m_lazy_scopes -= num_scopes;
else
m_imp->pop(num_scopes);
}
void quantifier_manager::reset() {
@ -711,7 +723,7 @@ namespace smt {
}
bool can_propagate() const override {
return m_mam->has_work();
return m_active && m_mam->has_work();
}
void restart_eh() override {
@ -733,6 +745,8 @@ namespace smt {
}
void propagate() override {
if (!m_active)
return;
m_mam->match();
if (!m_context->relevancy() && use_ematching()) {
ptr_vector<enode>::const_iterator it = m_context->begin_enodes();