mirror of
https://github.com/Z3Prover/z3
synced 2025-07-31 08:23:17 +00:00
put reinit-stack code path under ENALBE_REINIT_STACK macro
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
8cefa02b0d
commit
bee3320ff6
4 changed files with 630 additions and 624 deletions
File diff suppressed because it is too large
Load diff
|
@ -131,8 +131,10 @@ namespace polysat {
|
||||||
if (first)
|
if (first)
|
||||||
activate(s);
|
activate(s);
|
||||||
|
|
||||||
if (clause_ref lemma = produce_lemma(s, s.get_assignment()))
|
if (clause_ref lemma = produce_lemma(s, s.get_assignment())) {
|
||||||
s.add_clause(*lemma);
|
s.add_clause(*lemma);
|
||||||
|
s.push_reinit_stack(*lemma);
|
||||||
|
}
|
||||||
|
|
||||||
if (!s.is_conflict() && is_currently_false(s, is_positive))
|
if (!s.is_conflict() && is_currently_false(s, is_positive))
|
||||||
s.set_conflict(signed_constraint(this, is_positive));
|
s.set_conflict(signed_constraint(this, is_positive));
|
||||||
|
|
|
@ -28,6 +28,8 @@ Author:
|
||||||
// Lemmas are written into the folder "dbg-lemmas", and only if that folder already exists.
|
// Lemmas are written into the folder "dbg-lemmas", and only if that folder already exists.
|
||||||
#define ENABLE_LEMMA_VALIDITY_CHECK 0
|
#define ENABLE_LEMMA_VALIDITY_CHECK 0
|
||||||
|
|
||||||
|
#define ENABLE_REINIT_STACK 0
|
||||||
|
|
||||||
namespace polysat {
|
namespace polysat {
|
||||||
|
|
||||||
solver::solver(reslimit& lim):
|
solver::solver(reslimit& lim):
|
||||||
|
@ -301,7 +303,7 @@ namespace polysat {
|
||||||
sat::literal lit = cl[0];
|
sat::literal lit = cl[0];
|
||||||
LOG("Repropagate unit: " << lit_pp(*this, lit));
|
LOG("Repropagate unit: " << lit_pp(*this, lit));
|
||||||
switch (m_bvars.value(lit)) {
|
switch (m_bvars.value(lit)) {
|
||||||
case l_undef:
|
case l_undef:
|
||||||
assign_propagate(lit, cl);
|
assign_propagate(lit, cl);
|
||||||
break;
|
break;
|
||||||
case l_false:
|
case l_false:
|
||||||
|
@ -323,6 +325,8 @@ namespace polysat {
|
||||||
}
|
}
|
||||||
|
|
||||||
void solver::push_reinit_stack(clause& c) {
|
void solver::push_reinit_stack(clause& c) {
|
||||||
|
if (!ENABLE_REINIT_STACK)
|
||||||
|
return;
|
||||||
if (c.on_reinit_stack())
|
if (c.on_reinit_stack())
|
||||||
return;
|
return;
|
||||||
c.set_on_reinit_stack(true);
|
c.set_on_reinit_stack(true);
|
||||||
|
@ -352,7 +356,7 @@ namespace polysat {
|
||||||
m_constraints.unwatch(c);
|
m_constraints.unwatch(c);
|
||||||
reinit = m_constraints.watch(c);
|
reinit = m_constraints.watch(c);
|
||||||
|
|
||||||
// reinit <- true if clause is used for propagation
|
// reinit <- true if clause is used for propagation, watch lists not updated.
|
||||||
|
|
||||||
// has_variables_to_reinit:
|
// has_variables_to_reinit:
|
||||||
// = clause contains literal that was created above base level.
|
// = clause contains literal that was created above base level.
|
||||||
|
@ -360,10 +364,6 @@ namespace polysat {
|
||||||
// Each Boolean has a "scope". The scope is initialized to the scope where
|
// Each Boolean has a "scope". The scope is initialized to the scope where
|
||||||
// the Boolean is created.
|
// the Boolean is created.
|
||||||
|
|
||||||
// TODO
|
|
||||||
// The scope is updated on pop to be the new level where the clause resides.
|
|
||||||
// the reinit-stack is also
|
|
||||||
|
|
||||||
if (reinit && !at_base_level())
|
if (reinit && !at_base_level())
|
||||||
// clause propagated literal, must keep it in the reinit stack.
|
// clause propagated literal, must keep it in the reinit stack.
|
||||||
m_clauses_to_reinit[j++] = &c;
|
m_clauses_to_reinit[j++] = &c;
|
||||||
|
@ -772,7 +772,7 @@ namespace polysat {
|
||||||
case trail_instr_t::assign_i: {
|
case trail_instr_t::assign_i: {
|
||||||
auto v = m_search.back().var();
|
auto v = m_search.back().var();
|
||||||
LOG_V(20, "Undo assign_i: v" << v);
|
LOG_V(20, "Undo assign_i: v" << v);
|
||||||
if (get_level(v) <= target_level)
|
if (get_level(v) <= target_level && !ENABLE_REINIT_STACK)
|
||||||
for (signed_constraint c : m_viable.get_constraints(v))
|
for (signed_constraint c : m_viable.get_constraints(v))
|
||||||
m_repropagate_lits.push_back(c.blit());
|
m_repropagate_lits.push_back(c.blit());
|
||||||
m_free_pvars.unassign_var_eh(v);
|
m_free_pvars.unassign_var_eh(v);
|
||||||
|
@ -790,9 +790,8 @@ namespace polysat {
|
||||||
// Unit clauses are not stored in watch lists and must be re-propagated separately.
|
// Unit clauses are not stored in watch lists and must be re-propagated separately.
|
||||||
m_repropagate_units.push_back(reason);
|
m_repropagate_units.push_back(reason);
|
||||||
}
|
}
|
||||||
else {
|
else if (!ENABLE_REINIT_STACK)
|
||||||
m_repropagate_lits.push_back(lit);
|
m_repropagate_lits.push_back(lit);
|
||||||
}
|
|
||||||
m_bvars.unassign(lit);
|
m_bvars.unassign(lit);
|
||||||
m_search.pop();
|
m_search.pop();
|
||||||
break;
|
break;
|
||||||
|
@ -804,8 +803,7 @@ namespace polysat {
|
||||||
}
|
}
|
||||||
m_constraints.release_level(m_level + 1);
|
m_constraints.release_level(m_level + 1);
|
||||||
|
|
||||||
// todo:
|
reinit_clauses(m_reinit_head);
|
||||||
// reinit_clauses(m_reinit_head);
|
|
||||||
|
|
||||||
SASSERT(m_level == target_level);
|
SASSERT(m_level == target_level);
|
||||||
}
|
}
|
||||||
|
@ -1187,6 +1185,7 @@ namespace polysat {
|
||||||
|
|
||||||
for (auto it = lemmas.begin(); it != lemmas.end(); ++it) {
|
for (auto it = lemmas.begin(); it != lemmas.end(); ++it) {
|
||||||
clause& lemma = **it;
|
clause& lemma = **it;
|
||||||
|
push_reinit_stack(lemma);
|
||||||
if (!lemma.is_active())
|
if (!lemma.is_active())
|
||||||
add_clause(lemma);
|
add_clause(lemma);
|
||||||
else
|
else
|
||||||
|
@ -1229,6 +1228,8 @@ namespace polysat {
|
||||||
|
|
||||||
// Explicit boolean propagation over the given clause, without relying on watch lists.
|
// Explicit boolean propagation over the given clause, without relying on watch lists.
|
||||||
void solver::propagate_clause(clause& cl) {
|
void solver::propagate_clause(clause& cl) {
|
||||||
|
if (ENABLE_REINIT_STACK)
|
||||||
|
return;
|
||||||
LOG("propagate_clause: " << cl);
|
LOG("propagate_clause: " << cl);
|
||||||
for (sat::literal lit : cl) {
|
for (sat::literal lit : cl) {
|
||||||
LOG(" " << lit_pp(*this, lit));
|
LOG(" " << lit_pp(*this, lit));
|
||||||
|
@ -1483,8 +1484,10 @@ namespace polysat {
|
||||||
// TODO: currently we forget all new lemmas at this point.
|
// TODO: currently we forget all new lemmas at this point.
|
||||||
// (but anything that uses popped assumptions cannot be used anymore.)
|
// (but anything that uses popped assumptions cannot be used anymore.)
|
||||||
for (clause* lemma : lemmas)
|
for (clause* lemma : lemmas)
|
||||||
if (lemma->is_active())
|
if (lemma->is_active()) {
|
||||||
|
push_reinit_stack(*lemma);
|
||||||
propagate_clause(*lemma);
|
propagate_clause(*lemma);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_base_levels.shrink(m_base_levels.size() - num_scopes);
|
m_base_levels.shrink(m_base_levels.size() - num_scopes);
|
||||||
|
|
|
@ -319,6 +319,8 @@ namespace polysat {
|
||||||
void report_unsat();
|
void report_unsat();
|
||||||
void backjump(unsigned new_level);
|
void backjump(unsigned new_level);
|
||||||
|
|
||||||
|
void push_reinit_stack(clause& c);
|
||||||
|
|
||||||
void add_clause(clause_ref clause);
|
void add_clause(clause_ref clause);
|
||||||
void add_clause(clause& clause);
|
void add_clause(clause& clause);
|
||||||
void add_clause(signed_constraint c1, bool is_redundant);
|
void add_clause(signed_constraint c1, bool is_redundant);
|
||||||
|
@ -352,7 +354,6 @@ namespace polysat {
|
||||||
ptr_vector<clause> m_clauses_to_reinit;
|
ptr_vector<clause> m_clauses_to_reinit;
|
||||||
unsigned_vector m_reinit_heads;
|
unsigned_vector m_reinit_heads;
|
||||||
unsigned m_reinit_head = 0;
|
unsigned m_reinit_head = 0;
|
||||||
void push_reinit_stack(clause& c);
|
|
||||||
void reinit_clauses(unsigned old_sz);
|
void reinit_clauses(unsigned old_sz);
|
||||||
bool has_variables_to_reinit(clause const& c) const;
|
bool has_variables_to_reinit(clause const& c) const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue