mirror of
https://github.com/Z3Prover/z3
synced 2025-06-27 16:38:45 +00:00
fix exception safety in pdd-solver
This commit is contained in:
parent
c9c5dbc347
commit
3fa67777e5
5 changed files with 147 additions and 152 deletions
|
@ -62,6 +62,10 @@ namespace dd {
|
||||||
init_nodes(level2var);
|
init_nodes(level2var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pdd_manager::set_max_num_nodes(unsigned n) {
|
||||||
|
m_max_num_nodes = n + m_level2var.size();
|
||||||
|
}
|
||||||
|
|
||||||
void pdd_manager::init_nodes(unsigned_vector const& l2v) {
|
void pdd_manager::init_nodes(unsigned_vector const& l2v) {
|
||||||
// add dummy nodes for operations, and 0, 1 pdds.
|
// add dummy nodes for operations, and 0, 1 pdds.
|
||||||
for (unsigned i = 0; i < pdd_no_op; ++i) {
|
for (unsigned i = 0; i < pdd_no_op; ++i) {
|
||||||
|
@ -1352,9 +1356,8 @@ namespace dd {
|
||||||
e->get_data().m_refcount = 0;
|
e->get_data().m_refcount = 0;
|
||||||
}
|
}
|
||||||
if (do_gc) {
|
if (do_gc) {
|
||||||
if (m_nodes.size() > m_max_num_nodes) {
|
if (m_nodes.size() > m_max_num_nodes)
|
||||||
throw mem_out();
|
throw mem_out();
|
||||||
}
|
|
||||||
alloc_free_nodes(m_nodes.size()/2);
|
alloc_free_nodes(m_nodes.size()/2);
|
||||||
}
|
}
|
||||||
SASSERT(e->get_data().m_lo == n.m_lo);
|
SASSERT(e->get_data().m_lo == n.m_lo);
|
||||||
|
@ -1600,7 +1603,8 @@ namespace dd {
|
||||||
for (unsigned i = m_nodes.size(); i-- > pdd_no_op; ) {
|
for (unsigned i = m_nodes.size(); i-- > pdd_no_op; ) {
|
||||||
if (!reachable[i]) {
|
if (!reachable[i]) {
|
||||||
if (is_val(i)) {
|
if (is_val(i)) {
|
||||||
if (m_freeze_value == val(i)) continue;
|
if (m_freeze_value == val(i))
|
||||||
|
continue;
|
||||||
m_free_values.push_back(m_mpq_table.find(val(i)).m_value_index);
|
m_free_values.push_back(m_mpq_table.find(val(i)).m_value_index);
|
||||||
m_mpq_table.remove(val(i));
|
m_mpq_table.remove(val(i));
|
||||||
}
|
}
|
||||||
|
@ -1615,20 +1619,17 @@ namespace dd {
|
||||||
|
|
||||||
ptr_vector<op_entry> to_delete, to_keep;
|
ptr_vector<op_entry> to_delete, to_keep;
|
||||||
for (auto* e : m_op_cache) {
|
for (auto* e : m_op_cache) {
|
||||||
if (e->m_result != null_pdd) {
|
if (e->m_result != null_pdd)
|
||||||
to_delete.push_back(e);
|
to_delete.push_back(e);
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
to_keep.push_back(e);
|
to_keep.push_back(e);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
m_op_cache.reset();
|
m_op_cache.reset();
|
||||||
for (op_entry* e : to_delete) {
|
for (op_entry* e : to_delete)
|
||||||
m_alloc.deallocate(sizeof(*e), e);
|
m_alloc.deallocate(sizeof(*e), e);
|
||||||
}
|
|
||||||
for (op_entry* e : to_keep) {
|
for (op_entry* e : to_keep)
|
||||||
m_op_cache.insert(e);
|
m_op_cache.insert(e);
|
||||||
}
|
|
||||||
|
|
||||||
m_factor_cache.reset();
|
m_factor_cache.reset();
|
||||||
|
|
||||||
|
|
|
@ -324,8 +324,9 @@ namespace dd {
|
||||||
semantics get_semantics() const { return m_semantics; }
|
semantics get_semantics() const { return m_semantics; }
|
||||||
|
|
||||||
void reset(unsigned_vector const& level2var);
|
void reset(unsigned_vector const& level2var);
|
||||||
void set_max_num_nodes(unsigned n) { m_max_num_nodes = n; }
|
void set_max_num_nodes(unsigned n);
|
||||||
unsigned_vector const& get_level2var() const { return m_level2var; }
|
unsigned_vector const& get_level2var() const { return m_level2var; }
|
||||||
|
unsigned num_nodes() const { return m_nodes.size() - m_free_nodes.size(); }
|
||||||
|
|
||||||
pdd mk_var(unsigned i);
|
pdd mk_var(unsigned i);
|
||||||
pdd mk_val(rational const& r);
|
pdd mk_val(rational const& r);
|
||||||
|
|
|
@ -75,7 +75,7 @@ namespace dd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (pdd_manager::mem_out) {
|
catch (pdd_manager::mem_out) {
|
||||||
IF_VERBOSE(2, verbose_stream() << "simplifier memout\n");
|
IF_VERBOSE(1, verbose_stream() << "simplifier memout\n");
|
||||||
// done reduce
|
// done reduce
|
||||||
DEBUG_CODE(s.invariant(););
|
DEBUG_CODE(s.invariant(););
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,8 @@ namespace dd {
|
||||||
for (equation* e : s.m_to_simplify) {
|
for (equation* e : s.m_to_simplify) {
|
||||||
pdd p = e->poly();
|
pdd p = e->poly();
|
||||||
if (binary) {
|
if (binary) {
|
||||||
if (p.is_binary()) linear.push_back(e);
|
if (p.is_binary())
|
||||||
|
linear.push_back(e);
|
||||||
}
|
}
|
||||||
else if (p.is_linear()) {
|
else if (p.is_linear()) {
|
||||||
linear.push_back(e);
|
linear.push_back(e);
|
||||||
|
@ -112,29 +113,33 @@ namespace dd {
|
||||||
use_list_t use_list = get_use_list();
|
use_list_t use_list = get_use_list();
|
||||||
compare_top_var ctv;
|
compare_top_var ctv;
|
||||||
std::stable_sort(linear.begin(), linear.end(), ctv);
|
std::stable_sort(linear.begin(), linear.end(), ctv);
|
||||||
equation_vector trivial;
|
struct trivial {
|
||||||
|
solver& s;
|
||||||
|
equation_vector elems;
|
||||||
|
trivial(solver& s) : s(s) {}
|
||||||
|
~trivial () {
|
||||||
|
for (auto* e : elems)
|
||||||
|
s.del_equation(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
trivial trivial(s);
|
||||||
unsigned j = 0;
|
unsigned j = 0;
|
||||||
bool has_conflict = false;
|
bool has_conflict = false;
|
||||||
for (equation* src : linear) {
|
for (equation* src : linear) {
|
||||||
if (has_conflict) {
|
if (has_conflict)
|
||||||
break;
|
break;
|
||||||
}
|
if (s.is_trivial(*src))
|
||||||
if (s.is_trivial(*src)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
unsigned v = src->poly().var();
|
unsigned v = src->poly().var();
|
||||||
equation_vector const& uses = use_list[v];
|
equation_vector const& uses = use_list[v];
|
||||||
TRACE("dd.solver",
|
TRACE("dd.solver",
|
||||||
s.display(tout << "uses of: ", *src) << "\n";
|
s.display(tout << "uses of: ", *src) << "\n";
|
||||||
for (equation* e : uses) {
|
for (equation* e : uses) s.display(tout, *e) << "\n";);
|
||||||
s.display(tout, *e) << "\n";
|
|
||||||
});
|
|
||||||
bool changed_leading_term;
|
bool changed_leading_term;
|
||||||
bool all_reduced = true;
|
bool all_reduced = true;
|
||||||
for (equation* dst : uses) {
|
for (equation* dst : uses) {
|
||||||
if (src == dst || s.is_trivial(*dst)) {
|
if (src == dst || s.is_trivial(*dst))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
pdd q = dst->poly();
|
pdd q = dst->poly();
|
||||||
if (!src->poly().is_binary() && !q.is_linear()) {
|
if (!src->poly().is_binary() && !q.is_linear()) {
|
||||||
all_reduced = false;
|
all_reduced = false;
|
||||||
|
@ -142,9 +147,8 @@ namespace dd {
|
||||||
}
|
}
|
||||||
remove_from_use(dst, use_list, v);
|
remove_from_use(dst, use_list, v);
|
||||||
s.simplify_using(*dst, *src, changed_leading_term);
|
s.simplify_using(*dst, *src, changed_leading_term);
|
||||||
if (s.is_trivial(*dst)) {
|
if (s.is_trivial(*dst))
|
||||||
trivial.push_back(dst);
|
trivial.elems.push_back(dst);
|
||||||
}
|
|
||||||
else if (s.is_conflict(dst)) {
|
else if (s.is_conflict(dst)) {
|
||||||
s.pop_equation(dst);
|
s.pop_equation(dst);
|
||||||
s.set_conflict(dst);
|
s.set_conflict(dst);
|
||||||
|
@ -158,10 +162,9 @@ namespace dd {
|
||||||
// SASSERT(!dst->poly().free_vars().contains(v));
|
// SASSERT(!dst->poly().free_vars().contains(v));
|
||||||
add_to_use(dst, use_list);
|
add_to_use(dst, use_list);
|
||||||
}
|
}
|
||||||
if (all_reduced) {
|
if (all_reduced)
|
||||||
linear[j++] = src;
|
linear[j++] = src;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!has_conflict) {
|
if (!has_conflict) {
|
||||||
linear.shrink(j);
|
linear.shrink(j);
|
||||||
for (equation* src : linear) {
|
for (equation* src : linear) {
|
||||||
|
@ -169,9 +172,7 @@ namespace dd {
|
||||||
s.push_equation(solver::solved, src);
|
s.push_equation(solver::solved, src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (equation* e : trivial) {
|
|
||||||
s.del_equation(e);
|
|
||||||
}
|
|
||||||
DEBUG_CODE(s.invariant(););
|
DEBUG_CODE(s.invariant(););
|
||||||
return j > 0 || has_conflict;
|
return j > 0 || has_conflict;
|
||||||
}
|
}
|
||||||
|
@ -187,8 +188,9 @@ namespace dd {
|
||||||
IF_VERBOSE(3, verbose_stream() << "cc\n");
|
IF_VERBOSE(3, verbose_stream() << "cc\n");
|
||||||
u_map<equation*> los;
|
u_map<equation*> los;
|
||||||
bool reduced = false;
|
bool reduced = false;
|
||||||
unsigned j = 0;
|
solver::scoped_update sc(s.m_to_simplify);
|
||||||
for (equation* eq1 : s.m_to_simplify) {
|
for (; sc.i < sc.sz; ++sc.i) {
|
||||||
|
auto* eq1 = sc.get();
|
||||||
SASSERT(eq1->state() == solver::to_simplify);
|
SASSERT(eq1->state() == solver::to_simplify);
|
||||||
pdd p = eq1->poly();
|
pdd p = eq1->poly();
|
||||||
equation* eq2 = los.insert_if_not_there(p.lo().index(), eq1);
|
equation* eq2 = los.insert_if_not_there(p.lo().index(), eq1);
|
||||||
|
@ -201,14 +203,11 @@ namespace dd {
|
||||||
s.retire(eq1);
|
s.retire(eq1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (s.check_conflict(*eq1)) {
|
else if (s.check_conflict(*eq1))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
sc.nextj();
|
||||||
}
|
}
|
||||||
s.m_to_simplify[j] = eq1;
|
|
||||||
eq1->set_index(j++);
|
|
||||||
}
|
|
||||||
s.m_to_simplify.shrink(j);
|
|
||||||
return reduced;
|
return reduced;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,15 +224,12 @@ namespace dd {
|
||||||
pdd p = e->poly();
|
pdd p = e->poly();
|
||||||
if (p.is_val())
|
if (p.is_val())
|
||||||
continue;
|
continue;
|
||||||
if (!p.hi().is_val()) {
|
if (!p.hi().is_val())
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
leaves.reset();
|
leaves.reset();
|
||||||
for (equation* e2 : use_list[p.var()]) {
|
for (equation* e2 : use_list[p.var()])
|
||||||
if (e != e2 && e2->poly().var_is_leaf(p.var())) {
|
if (e != e2 && e2->poly().var_is_leaf(p.var()))
|
||||||
leaves.push_back(e2);
|
leaves.push_back(e2);
|
||||||
}
|
|
||||||
}
|
|
||||||
for (equation* e2 : leaves) {
|
for (equation* e2 : leaves) {
|
||||||
bool changed_leading_term;
|
bool changed_leading_term;
|
||||||
remove_from_use(e2, use_list);
|
remove_from_use(e2, use_list);
|
||||||
|
@ -264,22 +260,19 @@ namespace dd {
|
||||||
TRACE("dd.solver", tout << "pure\n";);
|
TRACE("dd.solver", tout << "pure\n";);
|
||||||
IF_VERBOSE(3, verbose_stream() << "pure\n");
|
IF_VERBOSE(3, verbose_stream() << "pure\n");
|
||||||
use_list_t use_list = get_use_list();
|
use_list_t use_list = get_use_list();
|
||||||
unsigned j = 0;
|
solver::scoped_update sc(s.m_to_simplify);
|
||||||
for (equation* e : s.m_to_simplify) {
|
bool has_solved = false;
|
||||||
|
for (; sc.i < sc.sz; ++sc.i) {
|
||||||
|
equation* e = sc.get();
|
||||||
pdd p = e->poly();
|
pdd p = e->poly();
|
||||||
if (!p.is_val() && p.hi().is_val() && use_list[p.var()].size() == 1) {
|
if (!p.is_val() && p.hi().is_val() && use_list[p.var()].size() == 1) {
|
||||||
s.push_equation(solver::solved, e);
|
s.push_equation(solver::solved, e);
|
||||||
|
has_solved = true;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
s.m_to_simplify[j] = e;
|
sc.nextj();
|
||||||
e->set_index(j++);
|
|
||||||
}
|
}
|
||||||
}
|
return has_solved;
|
||||||
if (j != s.m_to_simplify.size()) {
|
|
||||||
s.m_to_simplify.shrink(j);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -288,10 +281,11 @@ namespace dd {
|
||||||
*/
|
*/
|
||||||
bool simplifier::simplify_elim_dual_step() {
|
bool simplifier::simplify_elim_dual_step() {
|
||||||
use_list_t use_list = get_use_list();
|
use_list_t use_list = get_use_list();
|
||||||
unsigned j = 0;
|
|
||||||
bool reduced = false;
|
bool reduced = false;
|
||||||
for (unsigned i = 0; i < s.m_to_simplify.size(); ++i) {
|
{
|
||||||
equation* e = s.m_to_simplify[i];
|
solver::scoped_update sc(s.m_to_simplify);
|
||||||
|
for (; sc.i < sc.sz; ++sc.i) {
|
||||||
|
equation* e = sc.get();
|
||||||
pdd p = e->poly();
|
pdd p = e->poly();
|
||||||
// check that e is linear in top variable.
|
// check that e is linear in top variable.
|
||||||
if (e->state() != solver::to_simplify) {
|
if (e->state() != solver::to_simplify) {
|
||||||
|
@ -299,7 +293,8 @@ namespace dd {
|
||||||
}
|
}
|
||||||
else if (!s.done() && !s.is_trivial(*e) && p.hi().is_val() && use_list[p.var()].size() == 2) {
|
else if (!s.done() && !s.is_trivial(*e) && p.hi().is_val() && use_list[p.var()].size() == 2) {
|
||||||
for (equation* e2 : use_list[p.var()]) {
|
for (equation* e2 : use_list[p.var()]) {
|
||||||
if (e2 == e) continue;
|
if (e2 == e)
|
||||||
|
continue;
|
||||||
bool changed_leading_term;
|
bool changed_leading_term;
|
||||||
|
|
||||||
remove_from_use(e2, use_list);
|
remove_from_use(e2, use_list);
|
||||||
|
@ -320,32 +315,26 @@ namespace dd {
|
||||||
reduced = true;
|
reduced = true;
|
||||||
s.push_equation(solver::solved, e);
|
s.push_equation(solver::solved, e);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
s.m_to_simplify[j] = e;
|
sc.nextj();
|
||||||
e->set_index(j++);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (reduced) {
|
if (reduced) {
|
||||||
// clean up elements in s.m_to_simplify
|
// clean up elements in s.m_to_simplify
|
||||||
// they may have moved.
|
// they may have moved.
|
||||||
s.m_to_simplify.shrink(j);
|
solver::scoped_update sc(s.m_to_simplify);
|
||||||
j = 0;
|
for (; sc.i < sc.sz; ++sc.i) {
|
||||||
for (equation* e : s.m_to_simplify) {
|
equation* e = sc.get();
|
||||||
if (s.is_trivial(*e)) {
|
if (s.is_trivial(*e))
|
||||||
s.retire(e);
|
s.retire(e);
|
||||||
|
else if (e->state() == solver::to_simplify)
|
||||||
|
sc.nextj();
|
||||||
}
|
}
|
||||||
else if (e->state() == solver::to_simplify) {
|
|
||||||
s.m_to_simplify[j] = e;
|
|
||||||
e->set_index(j++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.m_to_simplify.shrink(j);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void simplifier::add_to_use(equation* e, use_list_t& use_list) {
|
void simplifier::add_to_use(equation* e, use_list_t& use_list) {
|
||||||
unsigned_vector const& fv = e->poly().free_vars();
|
unsigned_vector const& fv = e->poly().free_vars();
|
||||||
|
|
|
@ -90,10 +90,8 @@ namespace dd {
|
||||||
|
|
||||||
}
|
}
|
||||||
void solver::saturate() {
|
void solver::saturate() {
|
||||||
simplify();
|
if (done())
|
||||||
if (done()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
init_saturate();
|
init_saturate();
|
||||||
TRACE("dd.solver", display(tout););
|
TRACE("dd.solver", display(tout););
|
||||||
try {
|
try {
|
||||||
|
@ -105,7 +103,7 @@ namespace dd {
|
||||||
DEBUG_CODE(invariant(););
|
DEBUG_CODE(invariant(););
|
||||||
}
|
}
|
||||||
catch (pdd_manager::mem_out) {
|
catch (pdd_manager::mem_out) {
|
||||||
IF_VERBOSE(2, verbose_stream() << "mem-out\n");
|
IF_VERBOSE(1, verbose_stream() << "mem-out saturate\n");
|
||||||
// don't reduce further
|
// don't reduce further
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +122,7 @@ namespace dd {
|
||||||
|
|
||||||
solver::scoped_process::~scoped_process() {
|
solver::scoped_process::~scoped_process() {
|
||||||
if (e) {
|
if (e) {
|
||||||
pdd p = e->poly();
|
pdd const& p = e->poly();
|
||||||
SASSERT(!p.is_val());
|
SASSERT(!p.is_val());
|
||||||
g.push_equation(processed, e);
|
g.push_equation(processed, e);
|
||||||
}
|
}
|
||||||
|
@ -137,10 +135,9 @@ namespace dd {
|
||||||
|
|
||||||
|
|
||||||
void solver::superpose(equation const & eq) {
|
void solver::superpose(equation const & eq) {
|
||||||
for (equation* target : m_processed) {
|
for (equation* target : m_processed)
|
||||||
superpose(eq, *target);
|
superpose(eq, *target);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Use a set of equations to simplify eq
|
Use a set of equations to simplify eq
|
||||||
|
@ -166,25 +163,22 @@ namespace dd {
|
||||||
TRACE("dd.solver", display(tout << "simplification result: ", eq););
|
TRACE("dd.solver", display(tout << "simplification result: ", eq););
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void solver::well_formed() {
|
||||||
|
auto& set = m_to_simplify;
|
||||||
|
for (unsigned k = 0; k < set.size(); ++k)
|
||||||
|
for (unsigned l = k + 1; l < set.size(); ++l) {
|
||||||
|
if (!set[l] || !set[k] || set[k] != set[l])
|
||||||
|
continue;
|
||||||
|
verbose_stream() << k << " " << l << " " << set[k] << "\n";
|
||||||
|
for (auto* s : set)
|
||||||
|
verbose_stream() << s->idx() << "\n";
|
||||||
|
VERIFY(set[k] != set[l]);
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
Use the given equation to simplify equations in set
|
Use the given equation to simplify equations in set
|
||||||
*/
|
*/
|
||||||
void solver::simplify_using(equation_vector& set, std::function<bool(equation&, bool&)>& simplifier) {
|
void solver::simplify_using(equation_vector& set, std::function<bool(equation&, bool&)>& simplifier) {
|
||||||
struct scoped_update {
|
|
||||||
equation_vector& set;
|
|
||||||
unsigned i, j, sz;
|
|
||||||
scoped_update(equation_vector& set): set(set), i(0), j(0), sz(set.size()) {}
|
|
||||||
void nextj() {
|
|
||||||
set[j] = set[i];
|
|
||||||
set[i]->set_index(j++);
|
|
||||||
}
|
|
||||||
~scoped_update() {
|
|
||||||
for (; i < sz; ++i)
|
|
||||||
nextj();
|
|
||||||
set.shrink(j);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
scoped_update sr(set);
|
scoped_update sr(set);
|
||||||
for (; sr.i < sr.sz; ++sr.i) {
|
for (; sr.i < sr.sz; ++sr.i) {
|
||||||
equation& target = *set[sr.i];
|
equation& target = *set[sr.i];
|
||||||
|
@ -192,7 +186,6 @@ namespace dd {
|
||||||
bool simplified = true;
|
bool simplified = true;
|
||||||
simplified = !done() && simplifier(target, changed_leading_term);
|
simplified = !done() && simplifier(target, changed_leading_term);
|
||||||
|
|
||||||
|
|
||||||
if (simplified && is_trivial(target))
|
if (simplified && is_trivial(target))
|
||||||
retire(&target);
|
retire(&target);
|
||||||
else if (simplified && check_conflict(target)) {
|
else if (simplified && check_conflict(target)) {
|
||||||
|
@ -286,21 +279,32 @@ namespace dd {
|
||||||
m_stats.m_compute_steps++;
|
m_stats.m_compute_steps++;
|
||||||
IF_VERBOSE(3, if (m_stats.m_compute_steps % 100 == 0) verbose_stream() << "compute steps = " << m_stats.m_compute_steps << "\n";);
|
IF_VERBOSE(3, if (m_stats.m_compute_steps % 100 == 0) verbose_stream() << "compute steps = " << m_stats.m_compute_steps << "\n";);
|
||||||
equation* e = pick_next();
|
equation* e = pick_next();
|
||||||
if (!e) return false;
|
if (!e)
|
||||||
|
return false;
|
||||||
scoped_process sd(*this, e);
|
scoped_process sd(*this, e);
|
||||||
equation& eq = *e;
|
equation& eq = *e;
|
||||||
SASSERT(eq.state() == to_simplify);
|
SASSERT(eq.state() == to_simplify);
|
||||||
simplify_using(eq, m_processed);
|
simplify_using(eq, m_processed);
|
||||||
if (is_trivial(eq)) { sd.e = nullptr; retire(e); return true; }
|
if (is_trivial(eq)) {
|
||||||
if (check_conflict(eq)) { sd.e = nullptr; return false; }
|
sd.e = nullptr;
|
||||||
|
retire(e);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (check_conflict(eq)) {
|
||||||
|
sd.e = nullptr;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
m_too_complex = false;
|
m_too_complex = false;
|
||||||
simplify_using(m_processed, eq);
|
simplify_using(m_processed, eq);
|
||||||
if (done()) return false;
|
if (done())
|
||||||
|
return false;
|
||||||
TRACE("dd.solver", display(tout << "eq = ", eq););
|
TRACE("dd.solver", display(tout << "eq = ", eq););
|
||||||
superpose(eq);
|
superpose(eq);
|
||||||
simplify_using(m_to_simplify, eq);
|
simplify_using(m_to_simplify, eq);
|
||||||
if (done()) return false;
|
if (done())
|
||||||
if (!m_too_complex) sd.done();
|
return false;
|
||||||
|
if (!m_too_complex)
|
||||||
|
sd.done();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +449,6 @@ namespace dd {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void solver::pop_equation(equation& eq) {
|
void solver::pop_equation(equation& eq) {
|
||||||
equation_vector& v = get_queue(eq);
|
equation_vector& v = get_queue(eq);
|
||||||
unsigned idx = eq.idx();
|
unsigned idx = eq.idx();
|
||||||
|
|
|
@ -108,6 +108,7 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef ptr_vector<equation> equation_vector;
|
typedef ptr_vector<equation> equation_vector;
|
||||||
|
for (; i < sz; ++i)
|
||||||
typedef std::function<void (u_dependency* d, std::ostream& out)> print_dep_t;
|
typedef std::function<void (u_dependency* d, std::ostream& out)> print_dep_t;
|
||||||
|
|
||||||
pdd_manager& m;
|
pdd_manager& m;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue