3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

debugging

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2017-06-27 13:18:20 -07:00
parent 94416bea52
commit 6f4c873b29
9 changed files with 139 additions and 102 deletions

View file

@ -281,106 +281,109 @@ namespace sat {
for (unsigned i = 0; i < num_watch; ++i) {
watch_literal(p, p[i]);
}
p.set_slack(slack);
p.set_num_watch(num_watch);
}
TRACE("sat", display(tout << "init watch: ", p, true););
}
p.set_slack(slack);
p.set_num_watch(num_watch);
}
TRACE("sat", display(tout << "init watch: ", p, true););
}
/*
Chai Kuhlmann:
Lw - set of watched literals
Lu - set of unwatched literals that are not false
Lw = Lw \ { alit }
Sw -= value
a_max = max { a | l in Lw u Lu, l = undef }
while (Sw < k + a_max & Lu != 0) {
a_s = max { a | l in Lu }
Sw += a_s
Lw = Lw u {l_s}
Lu = Lu \ {l_s}
}
if (Sw < k) conflict
while (Sw < k + a_max) {
assign (l_max)
a_max = max { ai | li in Lw, li = undef }
}
ASSERT(Sw >= bound)
return no-conflict
/*
Chai Kuhlmann:
Lw - set of watched literals
Lu - set of unwatched literals that are not false
a_max index: index of non-false literal with maximal weight.
*/
void card_extension::add_index(pb& p, unsigned index, literal lit) {
if (value(lit) == l_undef) {
m_pb_undef.push_back(index);
if (p[index].first > m_a_max) {
m_a_max = p[index].first;
}
}
}
Lw = Lw \ { alit }
Sw -= value
a_max = max { a | l in Lw u Lu, l = undef }
while (Sw < k + a_max & Lu != 0) {
a_s = max { a | l in Lu }
Sw += a_s
Lw = Lw u {l_s}
Lu = Lu \ {l_s}
}
if (Sw < k) conflict
while (Sw < k + a_max) {
assign (l_max)
a_max = max { ai | li in Lw, li = undef }
}
ASSERT(Sw >= bound)
return no-conflict
lbool card_extension::add_assign(pb& p, literal alit) {
a_max index: index of non-false literal with maximal weight.
TRACE("sat", display(tout << "assign: " << alit << "\n", p, true););
SASSERT(!inconsistent());
unsigned sz = p.size();
unsigned bound = p.k();
unsigned num_watch = p.num_watch();
unsigned slack = p.slack();
SASSERT(value(alit) == l_false);
SASSERT(p.lit() == null_literal || value(p.lit()) == l_true);
SASSERT(num_watch <= sz);
SASSERT(num_watch > 0);
unsigned index = 0;
m_a_max = 0;
m_pb_undef.reset();
for (; index < num_watch; ++index) {
literal lit = p[index].second;
if (lit == alit) {
break;
}
add_index(p, index, lit);
}
SASSERT(index < num_watch);
unsigned index1 = index + 1;
for (; m_a_max == 0 && index1 < num_watch; ++index1) {
add_index(p, index1, p[index1].second);
}
*/
void card_extension::add_index(pb& p, unsigned index, literal lit) {
if (value(lit) == l_undef) {
m_pb_undef.push_back(index);
if (p[index].first > m_a_max) {
m_a_max = p[index].first;
}
}
}
unsigned val = p[index].first;
SASSERT(value(p[index].second) == l_false);
SASSERT(val <= slack);
slack -= val;
// find literals to swap with:
for (unsigned j = num_watch; j < sz && slack < bound + m_a_max; ++j) {
literal lit = p[j].second;
if (value(lit) != l_false) {
slack += p[j].first;
watch_literal(p, p[j]);
p.swap(num_watch, j);
add_index(p, num_watch, lit);
++num_watch;
}
}
lbool card_extension::add_assign(pb& p, literal alit) {
SASSERT(!inconsistent());
DEBUG_CODE(for (auto idx : m_pb_undef) { SASSERT(value(p[idx].second) == l_undef); });
TRACE("sat", display(tout << "assign: " << alit << "\n", p, true););
SASSERT(!inconsistent());
unsigned sz = p.size();
unsigned bound = p.k();
unsigned num_watch = p.num_watch();
unsigned slack = p.slack();
SASSERT(value(alit) == l_false);
SASSERT(p.lit() == null_literal || value(p.lit()) == l_true);
SASSERT(num_watch <= sz);
SASSERT(num_watch > 0);
unsigned index = 0;
m_a_max = 0;
m_pb_undef.reset();
for (; index < num_watch; ++index) {
literal lit = p[index].second;
if (lit == alit) {
break;
}
add_index(p, index, lit);
}
SASSERT(index < num_watch);
if (slack < bound) {
// maintain watching the literal
slack += val;
p.set_slack(slack);
p.set_num_watch(num_watch);
SASSERT(bound <= slack);
TRACE("sat", tout << "conflict " << alit << "\n";);
set_conflict(p, alit);
return l_false;
}
unsigned index1 = index + 1;
for (; m_a_max == 0 && index1 < num_watch; ++index1) {
add_index(p, index1, p[index1].second);
}
unsigned val = p[index].first;
SASSERT(value(p[index].second) == l_false);
SASSERT(val <= slack);
slack -= val;
// find literals to swap with:
for (unsigned j = num_watch; j < sz && slack < bound + m_a_max; ++j) {
literal lit = p[j].second;
if (value(lit) != l_false) {
slack += p[j].first;
watch_literal(p, p[j]);
p.swap(num_watch, j);
add_index(p, num_watch, lit);
++num_watch;
}
}
SASSERT(!inconsistent());
DEBUG_CODE(for (auto idx : m_pb_undef) { SASSERT(value(p[idx].second) == l_undef); });
if (slack < bound) {
// maintain watching the literal
slack += val;
p.set_slack(slack);
p.set_num_watch(num_watch);
SASSERT(bound <= slack);
TRACE("sat", tout << "conflict " << alit << "\n";);
set_conflict(p, alit);
return l_false;
}
if (index > p.size() || num_watch > p.size()) {
std::cout << "size: " << p.size() << "index: " << index << " num watch: " << num_watch << "\n";
}
// swap out the watched literal.
--num_watch;
SASSERT(num_watch > 0);
@ -1711,6 +1714,7 @@ namespace sat {
}
void card_extension::simplify() {
return;
s().pop_to_base_level();
unsigned trail_sz;
do {

View file

@ -1734,11 +1734,14 @@ namespace sat {
}
IF_VERBOSE(1, verbose_stream() << "(sat-lookahead :units " << num_units << ")\n";);
if (num_units > 0 && !m_s.inconsistent()) {
if (m_s.inconsistent()) return;
if (num_units > 0) {
m_s.propagate_core(false);
m_s.m_simplifier(false);
}
m_lookahead.reset();
}
//

View file

@ -162,7 +162,7 @@ namespace sat {
for (unsigned i = 0; i < sz; ++i)
e.m_clauses.push_back(c[i]);
e.m_clauses.push_back(null_literal);
TRACE("sat_mc_bug", tout << "adding (wrapper): "; for (literal l : c) tout << l << " "; tout << "\n";);
// TRACE("sat_mc_bug", tout << "adding (wrapper): "; for (literal l : c) tout << l << " "; tout << "\n";);
}
bool model_converter::check_invariant(unsigned num_vars) const {

View file

@ -1415,10 +1415,16 @@ namespace sat {
}
if (m_config.m_lookahead_simplify) {
lookahead lh(*this);
lh.simplify();
lh.scc();
lh.collect_statistics(m_aux_stats);
{
lookahead lh(*this);
lh.simplify();
lh.collect_statistics(m_aux_stats);
}
{
lookahead lh(*this);
lh.scc();
lh.collect_statistics(m_aux_stats);
}
}
sort_watch_lits();
@ -1450,7 +1456,7 @@ namespace sat {
m_next_simplify = m_conflicts_since_init + m_config.m_simplify_max;
}
#if 1
#if 0
static unsigned file_no = 0;
#pragma omp critical (print_sat)
{