mirror of
https://github.com/Z3Prover/z3
synced 2025-06-23 22:33:40 +00:00
fixes and expose new bugs
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
32c3a3e3cc
commit
cd76fd9edd
3 changed files with 35 additions and 13 deletions
|
@ -32,6 +32,17 @@ namespace polysat {
|
||||||
}
|
}
|
||||||
|
|
||||||
clause_ref clause_builder::build() {
|
clause_ref clause_builder::build() {
|
||||||
|
std::sort(m_literals.data(), m_literals.data() + m_literals.size());
|
||||||
|
sat::literal prev = sat::null_literal;
|
||||||
|
unsigned j = 0;
|
||||||
|
for (unsigned i = 0; i < m_literals.size(); ++i) {
|
||||||
|
sat::literal lit = m_literals[i];
|
||||||
|
if (prev == lit)
|
||||||
|
continue;
|
||||||
|
prev = lit;
|
||||||
|
m_literals[j++] = lit;
|
||||||
|
}
|
||||||
|
m_literals.shrink(j);
|
||||||
clause_ref cl = clause::from_literals(std::move(m_literals));
|
clause_ref cl = clause::from_literals(std::move(m_literals));
|
||||||
SASSERT(empty());
|
SASSERT(empty());
|
||||||
return cl;
|
return cl;
|
||||||
|
|
|
@ -115,23 +115,29 @@ namespace polysat {
|
||||||
if (is_conflict())
|
if (is_conflict())
|
||||||
return; // no need to do anything if we already have a conflict at base level
|
return; // no need to do anything if we already have a conflict at base level
|
||||||
m_constraints.ensure_bvar(c.get());
|
m_constraints.ensure_bvar(c.get());
|
||||||
|
sat::literal lit = c.blit();
|
||||||
|
LOG("New constraint: " << c);
|
||||||
|
if (m_bvars.is_false(lit) || c.is_currently_false(*this)) {
|
||||||
|
set_conflict(c /*, dep */);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
clause_ref unit = clause::from_unit(c);
|
clause_ref unit = clause::from_unit(c);
|
||||||
m_constraints.store(unit.get(), *this);
|
m_constraints.store(unit.get(), *this);
|
||||||
c->set_unit_clause(unit.get());
|
c->set_unit_clause(unit.get());
|
||||||
LOG("New constraint: " << c);
|
|
||||||
|
|
||||||
#if ENABLE_LINEAR_SOLVER
|
|
||||||
m_linear_solver.new_constraint(*c.get());
|
|
||||||
#endif
|
|
||||||
(void) dep; // dependencies go into justification
|
(void) dep; // dependencies go into justification
|
||||||
assign_bool(m_level, c.blit(), c->unit_clause(), nullptr);
|
assign_bool(m_level, lit, c->unit_clause(), nullptr);
|
||||||
#if 0
|
#else
|
||||||
// just add them as axioms, tracked by dependencies
|
// just add them as axioms, tracked by dependencies
|
||||||
literal lit = c.blit();
|
|
||||||
m_bvars.assign(lit, m_level, nullptr, nullptr, dep);
|
m_bvars.assign(lit, m_level, nullptr, nullptr, dep);
|
||||||
m_trail.push_back(trail_instr_t::assign_bool_i);
|
m_trail.push_back(trail_instr_t::assign_bool_i);
|
||||||
m_search.push_boolean(lit);
|
m_search.push_boolean(lit);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLE_LINEAR_SOLVER
|
||||||
|
m_linear_solver.new_constraint(*c.get());
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -537,6 +543,7 @@ namespace polysat {
|
||||||
case l_false:
|
case l_false:
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
|
|
||||||
if (lit2cnstr(lit).is_currently_false(*this)) {
|
if (lit2cnstr(lit).is_currently_false(*this)) {
|
||||||
num_choices++;
|
num_choices++;
|
||||||
continue;
|
continue;
|
||||||
|
@ -556,12 +563,14 @@ namespace polysat {
|
||||||
}
|
}
|
||||||
|
|
||||||
signed_constraint c = lit2cnstr(choice);
|
signed_constraint c = lit2cnstr(choice);
|
||||||
|
if (num_choices > 0)
|
||||||
|
push_level();
|
||||||
push_cjust(lemma.justified_var(), c);
|
push_cjust(lemma.justified_var(), c);
|
||||||
|
|
||||||
if (num_choices == 1)
|
if (num_choices == 1)
|
||||||
assign_bool(level(lemma), choice, &lemma, nullptr);
|
assign_bool(level(lemma), choice, &lemma, nullptr);
|
||||||
else
|
else
|
||||||
decide_bool(choice, &lemma);
|
assign_bool(m_level, choice, nullptr, &lemma);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -927,8 +927,11 @@ namespace polysat {
|
||||||
|
|
||||||
void tst_polysat() {
|
void tst_polysat() {
|
||||||
|
|
||||||
polysat::test_ineq_axiom1();
|
polysat::test_subst();
|
||||||
return;
|
|
||||||
|
|
||||||
|
// polysat::test_ineq_axiom1();
|
||||||
|
// return;
|
||||||
|
|
||||||
// not working
|
// not working
|
||||||
// polysat::test_fixed_point_arith_div_mul_inverse();
|
// polysat::test_fixed_point_arith_div_mul_inverse();
|
||||||
|
@ -961,7 +964,6 @@ void tst_polysat() {
|
||||||
polysat::test_ineq_basic6();
|
polysat::test_ineq_basic6();
|
||||||
polysat::test_monot_bounds(2);
|
polysat::test_monot_bounds(2);
|
||||||
polysat::test_cjust();
|
polysat::test_cjust();
|
||||||
polysat::test_subst();
|
|
||||||
|
|
||||||
// inefficient conflicts:
|
// inefficient conflicts:
|
||||||
// Takes time: polysat::test_monot_bounds_full();
|
// Takes time: polysat::test_monot_bounds_full();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue