3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-23 16:57:51 +00:00

Centralize and document TRACE tags using X-macros (#7657)

* Introduce X-macro-based trace tag definition
- Created trace_tags.def to centralize TRACE tag definitions
- Each tag includes a symbolic name and description
- Set up enum class TraceTag for type-safe usage in TRACE macros

* Add script to generate Markdown documentation from trace_tags.def
- Python script parses trace_tags.def and outputs trace_tags.md

* Refactor TRACE_NEW to prepend TraceTag and pass enum to is_trace_enabled

* trace: improve trace tag handling system with hierarchical tagging

- Introduce hierarchical tag-class structure: enabling a tag class activates all child tags
- Unify TRACE, STRACE, SCTRACE, and CTRACE under enum TraceTag
- Implement initial version of trace_tag.def using X(tag, tag_class, description)
  (class names and descriptions to be refined in a future update)

* trace: replace all string-based TRACE tags with enum TraceTag
- Migrated all TRACE, STRACE, SCTRACE, and CTRACE macros to use enum TraceTag values instead of raw string literals

* trace : add cstring header

* trace : Add Markdown documentation generation from trace_tags.def via mk_api_doc.py

* trace : rename macro parameter 'class' to 'tag_class' and remove Unicode comment in trace_tags.h.

* trace : Add TODO comment for future implementation of tag_class activation

* trace : Disable code related to tag_class until implementation is ready (#7663).
This commit is contained in:
LeeYoungJoon 2025-05-28 22:31:25 +09:00 committed by GitHub
parent d766292dab
commit 0a93ff515d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
583 changed files with 8698 additions and 7299 deletions

View file

@ -90,9 +90,9 @@ namespace sat {
solver::~solver() {
m_ext = nullptr;
SASSERT(m_config.m_num_threads > 1 || m_trim || rlimit().is_canceled() || check_invariant());
CTRACE("sat", !m_clauses.empty(), tout << "Delete clauses\n";);
CTRACE(sat, !m_clauses.empty(), tout << "Delete clauses\n";);
del_clauses(m_clauses);
CTRACE("sat", !m_learned.empty(), tout << "Delete learned\n";);
CTRACE(sat, !m_learned.empty(), tout << "Delete learned\n";);
del_clauses(m_learned);
dealloc(m_cuber);
m_cuber = nullptr;
@ -346,7 +346,7 @@ namespace sat {
DEBUG_CODE({
for (unsigned i = 0; i < num_lits; i++) {
CTRACE("sat", was_eliminated(lits[i]), tout << lits[i] << " was eliminated\n";);
CTRACE(sat, was_eliminated(lits[i]), tout << lits[i] << " was eliminated\n";);
SASSERT(!was_eliminated(lits[i]));
}
});
@ -412,12 +412,12 @@ namespace sat {
clause * solver::mk_clause_core(unsigned num_lits, literal * lits, sat::status st) {
bool redundant = st.is_redundant();
TRACE("sat", tout << "mk_clause: " << mk_lits_pp(num_lits, lits) << (redundant?" learned":" aux") << "\n";);
TRACE(sat, tout << "mk_clause: " << mk_lits_pp(num_lits, lits) << (redundant?" learned":" aux") << "\n";);
bool logged = false;
if (!redundant || !st.is_sat()) {
unsigned old_sz = num_lits;
bool keep = m_trim || simplify_clause(num_lits, lits);
TRACE("sat_mk_clause", tout << "mk_clause (after simp), keep: " << keep << "\n" << mk_lits_pp(num_lits, lits) << "\n";);
TRACE(sat_mk_clause, tout << "mk_clause (after simp), keep: " << keep << "\n" << mk_lits_pp(num_lits, lits) << "\n";);
if (!keep) {
return nullptr; // clause is equivalent to true.
}
@ -472,7 +472,7 @@ namespace sat {
}
watched* w0 = redundant ? find_binary_watch(get_wlist(~l1), l2) : nullptr;
if (w0 && !m_trim) {
TRACE("sat", tout << "found binary " << l1 << " " << l2 << "\n";);
TRACE(sat, tout << "found binary " << l1 << " " << l2 << "\n";);
if (w0->is_learned() && !redundant) {
w0->set_learned(false);
w0 = find_binary_watch(get_wlist(~l2), l1);
@ -532,13 +532,13 @@ namespace sat {
void solver::push_reinit_stack(clause & c) {
SASSERT(!at_base_lvl());
TRACE("sat_reinit", tout << "adding to reinit stack: " << c << "\n";);
TRACE(sat_reinit, tout << "adding to reinit stack: " << c << "\n";);
m_clauses_to_reinit.push_back(clause_wrapper(c));
c.set_reinit_stack(true);
}
void solver::push_reinit_stack(literal l1, literal l2) {
TRACE("sat_reinit", tout << "adding to reinit stack: " << l1 << " " << l2 << "\n";);
TRACE(sat_reinit, tout << "adding to reinit stack: " << l1 << " " << l2 << "\n";);
m_clauses_to_reinit.push_back(clause_wrapper(l1, l2));
}
@ -802,7 +802,7 @@ namespace sat {
unsigned num_lits = cls.size();
for (unsigned i = 1; i < num_lits; i++) {
literal l = cls[i];
CTRACE("sat", value(l) != l_false, tout << l << ":=" << value(l););
CTRACE(sat, value(l) != l_false, tout << l << ":=" << value(l););
SASSERT(value(l) == l_false);
if (max_false_idx == UINT_MAX || lvl(l) > lvl(cls[max_false_idx]))
max_false_idx = i;
@ -877,13 +877,13 @@ namespace sat {
m_inconsistent = true;
m_conflict = c;
m_not_l = not_l;
TRACE("sat", display(display_justification(tout << "conflict " << not_l << " ", c) << "\n"));
TRACE(sat, display(display_justification(tout << "conflict " << not_l << " ", c) << "\n"));
}
void solver::assign_core(literal l, justification j) {
SASSERT(value(l) == l_undef);
SASSERT(!m_trail.contains(l) && !m_trail.contains(~l));
TRACE("sat_assign_core", tout << l << " " << j << "\n";);
TRACE(sat_assign_core, tout << l << " " << j << "\n";);
if (j.level() == 0) {
if (m_config.m_drat)
drat_log_unit(l, j);
@ -1015,7 +1015,7 @@ namespace sat {
bool keep;
unsigned curr_level = lvl(l);
TRACE("sat_propagate", tout << "propagating: " << l << "@" << curr_level << " " << m_justification[l.var()] << "\n"; );
TRACE(sat_propagate, tout << "propagating: " << l << "@" << curr_level << " " << m_justification[l.var()] << "\n"; );
literal not_l = ~l;
SASSERT(value(l) == l_true);
@ -1052,7 +1052,7 @@ namespace sat {
break;
case watched::CLAUSE: {
if (value(it->get_blocked_literal()) == l_true) {
TRACE("propagate_clause_bug", tout << "blocked literal " << it->get_blocked_literal() << "\n";
TRACE(propagate_clause_bug, tout << "blocked literal " << it->get_blocked_literal() << "\n";
tout << get_clause(it) << "\n";);
*it2 = *it;
it2++;
@ -1060,10 +1060,10 @@ namespace sat {
}
clause_offset cls_off = it->get_clause_offset();
clause& c = get_clause(cls_off);
TRACE("propagate_clause_bug", tout << "processing... " << c << "\nwas_removed: " << c.was_removed() << "\n";);
TRACE(propagate_clause_bug, tout << "processing... " << c << "\nwas_removed: " << c.was_removed() << "\n";);
if (c[0] == not_l)
std::swap(c[0], c[1]);
CTRACE("propagate_bug", c[1] != not_l, tout << "l: " << l << " " << c << "\n";);
CTRACE(propagate_bug, c[1] != not_l, tout << "l: " << l << " " << c << "\n";);
if (c.was_removed() || c.size() == 1 || c[1] != not_l) {
@ -1267,8 +1267,8 @@ namespace sat {
propagate(false);
if (check_inconsistent()) return l_false;
if (m_config.m_force_cleanup) do_cleanup(true);
TRACE("sat", display(tout););
TRACE("before_search", display(tout););
TRACE(sat, display(tout););
TRACE(before_search, display(tout););
if (m_config.m_gc_burst) {
// force gc
@ -1283,7 +1283,7 @@ namespace sat {
if (m_config.m_max_conflicts == 0) {
IF_VERBOSE(SAT_VB_LVL, verbose_stream() << "(sat \"abort: max-conflicts = 0\")\n";);
TRACE("sat", display(tout); m_mc.display(tout););
TRACE(sat, display(tout); m_mc.display(tout););
return l_undef;
}
@ -1662,7 +1662,7 @@ namespace sat {
if (num_vars() == 0)
return null_bool_var;
next = m_rand() % num_vars();
TRACE("random_split", tout << "next: " << next << " value(next): " << value(next) << "\n";);
TRACE(random_split, tout << "next: " << next << " value(next): " << value(next) << "\n";);
if (value(next) == l_undef && !was_eliminated(next))
return next;
}
@ -1730,7 +1730,7 @@ namespace sat {
push();
m_stats.m_decision++;
CTRACE("sat", m_best_phase[next] != guess(next), tout << "phase " << phase << " " << m_best_phase[next] << " " << guess(next) << "\n");
CTRACE(sat, m_best_phase[next] != guess(next), tout << "phase " << phase << " " << m_best_phase[next] << " " << guess(next) << "\n");
if (phase == l_undef)
phase = guess(next) ? l_true: l_false;
@ -1754,7 +1754,7 @@ namespace sat {
if (!is_pos)
next_lit.neg();
TRACE("sat_decide", tout << scope_lvl() << ": next-case-split: " << next_lit << "\n";);
TRACE(sat_decide, tout << scope_lvl() << ": next-case-split: " << next_lit << "\n";);
assign_scoped(next_lit);
return true;
}
@ -1845,7 +1845,7 @@ namespace sat {
if (inconsistent())
return;
TRACE("sat",
TRACE(sat,
tout << literal_vector(num_lits, lits) << "\n";
if (!m_user_scope_literals.empty())
tout << "user literals: " << m_user_scope_literals << "\n";
@ -1894,7 +1894,7 @@ namespace sat {
pop_to_base_level();
push();
reset_assumptions();
TRACE("sat", tout << "reassert: " << m_min_core << "\n";);
TRACE(sat, tout << "reassert: " << m_min_core << "\n";);
for (literal lit : m_min_core) {
SASSERT(is_external(lit.var()));
add_assumption(lit);
@ -1906,7 +1906,7 @@ namespace sat {
void solver::reinit_assumptions() {
if (tracking_assumptions() && at_base_lvl() && !inconsistent()) {
TRACE("sat", tout << "assumptions: " << m_assumptions << " user scopes: " << m_user_scope_literals << "\n";);
TRACE(sat, tout << "assumptions: " << m_assumptions << " user scopes: " << m_user_scope_literals << "\n";);
if (!propagate(false)) return;
push();
for (literal lit : m_user_scope_literals) {
@ -1921,7 +1921,7 @@ namespace sat {
if (!inconsistent())
propagate(false);
TRACE("sat",
TRACE(sat,
tout << "consistent: " << !inconsistent() << "\n";
for (literal a : m_assumptions) {
index_set s;
@ -2006,7 +2006,7 @@ namespace sat {
m_mc.init_search(*this);
if (m_ext)
m_ext->init_search();
TRACE("sat", display(tout););
TRACE(sat, display(tout););
}
bool solver::should_simplify() const {
@ -2022,7 +2022,7 @@ namespace sat {
log_stats();
m_simplifications++;
TRACE("sat", tout << "simplify\n";);
TRACE(sat, tout << "simplify\n";);
pop(scope_lvl());
struct report {
@ -2152,7 +2152,7 @@ namespace sat {
m_best_phase[v] = value(v) == l_true;
}
}
TRACE("sat_mc_bug", m_mc.display(tout););
TRACE(sat_mc_bug, m_mc.display(tout););
#if 0
IF_VERBOSE(2, for (bool_var v = 0; v < num; v++) verbose_stream() << v << ": " << m_model[v] << "\n";);
@ -2184,7 +2184,7 @@ namespace sat {
throw solver_exception("check model failed");
}
TRACE("sat", for (bool_var v = 0; v < num; v++) tout << v << ": " << m_model[v] << "\n";);
TRACE(sat, for (bool_var v = 0; v < num; v++) tout << v << ": " << m_model[v] << "\n";);
if (m_clone) {
IF_VERBOSE(1, verbose_stream() << "\"checking model (on original set of clauses)\"\n";);
@ -2202,7 +2202,7 @@ namespace sat {
clause const & c = *cp;
if (!c.satisfied_by(m)) {
IF_VERBOSE(1, verbose_stream() << "failed clause " << c.id() << ": " << c << "\n";);
TRACE("sat", tout << "failed: " << c << "\n";
TRACE(sat, tout << "failed: " << c << "\n";
tout << "assumptions: " << m_assumptions << "\n";
tout << "trail: " << m_trail << "\n";
tout << "model: " << m << "\n";
@ -2227,7 +2227,7 @@ namespace sat {
if (value_at(l2, m) != l_true) {
IF_VERBOSE(1, verbose_stream() << "failed binary: " << l << " := " << value_at(l, m) << " " << l2 << " := " << value_at(l2, m) << "\n");
IF_VERBOSE(1, verbose_stream() << "elim l1: " << was_eliminated(l.var()) << " elim l2: " << was_eliminated(l2) << "\n");
TRACE("sat", m_mc.display(tout << "failed binary: " << l << " " << l2 << "\n"););
TRACE(sat, m_mc.display(tout << "failed binary: " << l << " " << l2 << "\n"););
ok = false;
}
}
@ -2238,7 +2238,7 @@ namespace sat {
if (value_at(l, m) != l_true) {
VERIFY(is_external(l.var()));
IF_VERBOSE(1, verbose_stream() << "assumption: " << l << " does not model check " << value_at(l, m) << "\n";);
TRACE("sat",
TRACE(sat,
tout << l << " does not model check\n";
tout << "trail: " << m_trail << "\n";
tout << "model: " << m << "\n";
@ -2257,7 +2257,7 @@ namespace sat {
bool ok = check_clauses(m);
if (ok && !m_mc.check_model(m)) {
ok = false;
TRACE("sat", tout << "model: " << m << "\n"; m_mc.display(tout););
TRACE(sat, tout << "model: " << m << "\n"; m_mc.display(tout););
IF_VERBOSE(0, verbose_stream() << "model check failed\n");
}
return ok;
@ -2349,9 +2349,9 @@ namespace sat {
}
log_stats();
}
TRACE("sat", tout << "restart " << restart_level(to_base) << "\n";);
TRACE(sat, tout << "restart " << restart_level(to_base) << "\n";);
IF_VERBOSE(30, display_status(verbose_stream()););
TRACE("sat", tout << "restart " << restart_level(to_base) << "\n";);
TRACE(sat, tout << "restart " << restart_level(to_base) << "\n";);
pop_reinit(restart_level(to_base));
set_next_restart();
}
@ -2446,7 +2446,7 @@ namespace sat {
if (m_conflict_lvl <= 1 && (!m_assumptions.empty() ||
!m_ext_assumption_set.empty() ||
!m_user_scope_literals.empty())) {
TRACE("sat", tout << "unsat core\n";);
TRACE(sat, tout << "unsat core\n";);
resolve_conflict_for_unsat_core();
return l_false;
}
@ -2455,7 +2455,7 @@ namespace sat {
drat_explain_conflict();
if (m_config.m_drat)
drat_log_clause(0, nullptr, sat::status::redundant());
TRACE("sat", tout << "conflict level is 0\n";);
TRACE(sat, tout << "conflict level is 0\n";);
return l_false;
}
@ -2464,7 +2464,7 @@ namespace sat {
// that only get triggered after decisions.
if (allow_backtracking() && unique_max && !m_force_conflict_analysis) {
TRACE("sat", tout << "unique max " << js << " " << m_not_l << "\n";);
TRACE(sat, tout << "unique max " << js << " " << m_not_l << "\n";);
pop_reinit(m_scope_lvl - m_conflict_lvl + 1);
m_force_conflict_analysis = true;
++m_stats.m_backtracks;
@ -2494,7 +2494,7 @@ namespace sat {
// save space for first uip
m_lemma.push_back(null_literal);
TRACE("sat_conflict_detail",
TRACE(sat_conflict_detail,
tout << "resolve: " << m_not_l << " "
<< " js: " << js
<< " idx: " << idx
@ -2504,13 +2504,13 @@ namespace sat {
unsigned num_marks = 0;
literal consequent = null_literal;
if (m_not_l != null_literal) {
TRACE("sat_conflict_detail", tout << "not_l: " << m_not_l << "\n";);
TRACE(sat_conflict_detail, tout << "not_l: " << m_not_l << "\n";);
process_antecedent(m_not_l, num_marks);
consequent = ~m_not_l;
}
do {
TRACE("sat_conflict_detail", tout << "processing consequent: " << consequent << " @" << (consequent==null_literal?m_conflict_lvl:lvl(consequent)) << "\n";
TRACE(sat_conflict_detail, tout << "processing consequent: " << consequent << " @" << (consequent==null_literal?m_conflict_lvl:lvl(consequent)) << "\n";
tout << "num_marks: " << num_marks << "\n";
display_justification(tout, js) << "\n";);
@ -2540,7 +2540,7 @@ namespace sat {
}
case justification::EXT_JUSTIFICATION: {
fill_ext_antecedents(consequent, js, false);
TRACE("sat", tout << "ext antecedents: " << m_ext_antecedents << "\n";);
TRACE(sat, tout << "ext antecedents: " << m_ext_antecedents << "\n";);
for (literal l : m_ext_antecedents)
process_antecedent(l, num_marks);
break;
@ -2560,12 +2560,12 @@ namespace sat {
}
SASSERT(lvl(c_var) < m_conflict_lvl);
}
CTRACE("sat", idx == 0,
CTRACE(sat, idx == 0,
tout << "conflict level " << m_conflict_lvl << "\n";
for (literal lit : m_trail)
if (is_marked(lit.var()))
tout << "missed " << lit << "@" << lvl(lit) << "\n";);
CTRACE("sat", idx == 0, display(tout););
CTRACE(sat, idx == 0, display(tout););
if (idx == 0)
IF_VERBOSE(0, verbose_stream() << "num-conflicts: " << m_stats.m_conflict << "\n");
VERIFY(idx > 0);
@ -2577,7 +2577,7 @@ namespace sat {
num_marks--;
reset_mark(c_var);
TRACE("sat", display_justification(tout << consequent << " ", js) << "\n";);
TRACE(sat, display_justification(tout << consequent << " ", js) << "\n";);
}
while (num_marks > 0);
@ -2588,7 +2588,7 @@ namespace sat {
}
void solver::learn_lemma_and_backjump() {
TRACE("sat_lemma", tout << "new lemma size: " << m_lemma.size() << "\n" << m_lemma << "\n";);
TRACE(sat_lemma, tout << "new lemma size: " << m_lemma.size() << "\n" << m_lemma << "\n";);
if (m_lemma.empty()) {
pop_reinit(m_scope_lvl);
@ -2601,7 +2601,7 @@ namespace sat {
reset_lemma_var_marks();
if (m_config.m_dyn_sub_res)
dyn_sub_res();
TRACE("sat_lemma", tout << "new lemma (after minimization) size: " << m_lemma.size() << "\n" << m_lemma << "\n";);
TRACE(sat_lemma, tout << "new lemma (after minimization) size: " << m_lemma.size() << "\n" << m_lemma << "\n";);
}
else {
reset_lemma_var_marks();
@ -2619,7 +2619,7 @@ namespace sat {
backtrack_lvl = backjump_lvl;
for (unsigned i = m_lemma.size(); i-- > 1;) {
if (lvl(m_lemma[i]) == backjump_lvl) {
TRACE("sat", tout << "swap " << m_lemma[0] << "@" << lvl(m_lemma[0]) << m_lemma[1] << "@" << backjump_lvl << "\n";);
TRACE(sat, tout << "swap " << m_lemma[0] << "@" << lvl(m_lemma[0]) << m_lemma[1] << "@" << backjump_lvl << "\n";);
std::swap(m_lemma[i], m_lemma[0]);
break;
}
@ -2638,7 +2638,7 @@ namespace sat {
pop_reinit(num_scopes);
}
else {
TRACE("sat", tout << "backtrack " << (m_scope_lvl - backtrack_lvl + 1) << " scopes\n";);
TRACE(sat, tout << "backtrack " << (m_scope_lvl - backtrack_lvl + 1) << " scopes\n";);
++m_stats.m_backtracks;
pop_reinit(m_scope_lvl - backtrack_lvl + 1);
}
@ -2650,7 +2650,7 @@ namespace sat {
m_par->share_clause(*this, *lemma);
}
m_lemma.reset();
TRACE("sat_conflict_detail", tout << "consistent " << (!m_inconsistent) << " scopes: " << scope_lvl() << " backtrack: " << backtrack_lvl << " backjump: " << backjump_lvl << "\n";);
TRACE(sat_conflict_detail, tout << "consistent " << (!m_inconsistent) << " scopes: " << scope_lvl() << " backtrack: " << backtrack_lvl << " backjump: " << backjump_lvl << "\n";);
decay_activity();
updt_phase_counters();
}
@ -2668,7 +2668,7 @@ namespace sat {
void solver::process_antecedent_for_unsat_core(literal antecedent) {
bool_var var = antecedent.var();
SASSERT(var < num_vars());
TRACE("sat", tout << antecedent << " " << (is_marked(var)?"+":"-") << "\n";);
TRACE(sat, tout << antecedent << " " << (is_marked(var)?"+":"-") << "\n";);
if (!is_marked(var)) {
mark(var);
m_unmark.push_back(var);
@ -2679,7 +2679,7 @@ namespace sat {
}
void solver::process_consequent_for_unsat_core(literal consequent, justification const& js) {
TRACE("sat", tout << "processing consequent: ";
TRACE(sat, tout << "processing consequent: ";
if (consequent == null_literal) tout << "null\n";
else tout << consequent << "\n";
display_justification(tout << "js kind: ", js) << "\n";);
@ -2722,7 +2722,7 @@ namespace sat {
}
void solver::resolve_conflict_for_unsat_core() {
TRACE("sat_verbose", display(tout);
TRACE(sat_verbose, display(tout);
unsigned level = 0;
for (literal l : m_trail) {
if (level != lvl(l)) {
@ -2755,7 +2755,7 @@ namespace sat {
literal consequent = m_not_l;
if (m_not_l != null_literal) {
justification js = m_justification[m_not_l.var()];
TRACE("sat", tout << "not_l: " << m_not_l << "\n";
TRACE(sat, tout << "not_l: " << m_not_l << "\n";
display_justification(tout, js) << "\n";);
process_antecedent_for_unsat_core(m_not_l);
@ -2818,7 +2818,7 @@ namespace sat {
if (not_l != null_literal) {
level = lvl(not_l);
}
TRACE("sat", tout << "level " << not_l << " is " << level << " " << js << "\n");
TRACE(sat, tout << "level " << not_l << " is " << level << " " << js << "\n");
switch (js.get_kind()) {
case justification::NONE:
@ -2842,7 +2842,7 @@ namespace sat {
UNREACHABLE();
break;
}
TRACE("sat", tout << "max-level " << level << " " << unique_max << "\n");
TRACE(sat, tout << "max-level " << level << " " << unique_max << "\n");
return level;
}
@ -2869,7 +2869,7 @@ namespace sat {
bool_var var = antecedent.var();
unsigned var_lvl = lvl(var);
SASSERT(var < num_vars());
TRACE("sat_verbose", tout << "process " << var << "@" << var_lvl << " marked " << is_marked(var) << " conflict " << m_conflict_lvl << "\n";);
TRACE(sat_verbose, tout << "process " << var << "@" << var_lvl << " marked " << is_marked(var) << " conflict " << m_conflict_lvl << "\n";);
if (!is_marked(var) && var_lvl > 0) {
mark(var);
switch (m_config.m_branching_heuristic) {
@ -2917,7 +2917,7 @@ namespace sat {
unsigned sz = m_trail.size();
for (unsigned i = head; i < sz; i++) {
bool_var v = m_trail[i].var();
TRACE("forget_phase", tout << "forgetting phase of v" << v << "\n";);
TRACE(forget_phase, tout << "forgetting phase of v" << v << "\n";);
m_phase[v] = m_rand() % 2 == 0;
}
if (is_sat_phase() && head >= m_best_phase_size) {
@ -3229,7 +3229,7 @@ namespace sat {
UNREACHABLE();
break;
}
TRACE("sat_conflict",
TRACE(sat_conflict,
display_justification(tout << var << " ",js) << "\n";);
}
return true;
@ -3496,7 +3496,7 @@ namespace sat {
void solver::push() {
SASSERT(!m_ext || !m_ext->can_propagate());
SASSERT(!inconsistent());
TRACE("sat_verbose", tout << "q:" << m_qhead << " trail: " << m_trail.size() << "\n";);
TRACE(sat_verbose, tout << "q:" << m_qhead << " trail: " << m_trail.size() << "\n";);
SASSERT(m_qhead == m_trail.size());
m_scopes.push_back(scope());
scope & s = m_scopes.back();
@ -3568,7 +3568,7 @@ namespace sat {
cleanup_watch(literal(v, true));
}
TRACE("sat",
TRACE(sat,
tout << "clauses to reinit: " << (m_clauses_to_reinit.size() - old_sz) << "\n";
tout << "new level: " << new_lvl << "\n";
tout << "vars to reinit: " << m_vars_to_reinit << "\n";
@ -3654,7 +3654,7 @@ namespace sat {
DEBUG_CODE(for (literal l : m_trail) SASSERT(lvl(l.var()) <= new_lvl););
m_qhead = m_trail.size();
if (!m_replay_assign.empty()) IF_VERBOSE(20, verbose_stream() << "replay assign: " << m_replay_assign.size() << "\n");
CTRACE("sat", !m_replay_assign.empty(), tout << "replay-assign: " << m_replay_assign << "\n";);
CTRACE(sat, !m_replay_assign.empty(), tout << "replay-assign: " << m_replay_assign << "\n";);
for (unsigned i = m_replay_assign.size(); i-- > 0; ) {
literal lit = m_replay_assign[i];
SASSERT(value(lit) == l_true);
@ -3710,7 +3710,7 @@ namespace sat {
m_cut_simplifier = nullptr; // for simplicity, wipe it out
if (m_ext)
m_ext->user_push();
TRACE("sat", tout << "user_push: " << lit << "\n";);
TRACE(sat, tout << "user_push: " << lit << "\n";);
}
void solver::user_pop(unsigned num_scopes) {
@ -3725,7 +3725,7 @@ namespace sat {
m_ext->user_pop(num_scopes);
gc_vars(max_var);
TRACE("sat", display(tout););
TRACE(sat, display(tout););
m_qhead = 0;
unsigned j = 0;
@ -3859,7 +3859,7 @@ namespace sat {
literal l2 = w.get_literal();
if (l.index() > l2.index())
continue;
TRACE("cleanup_bug", tout << "collected: " << l << " " << l2 << "\n";);
TRACE(cleanup_bug, tout << "collected: " << l << " " << l2 << "\n";);
r.push_back(bin_clause(l, l2));
}
}
@ -4121,7 +4121,7 @@ namespace sat {
if (c.frozen())
continue;
if (is_empty(c) || is_unit(c)) {
TRACE("sat_missed_prop", tout << "missed_propagation: " << c << "\n";
TRACE(sat_missed_prop, tout << "missed_propagation: " << c << "\n";
for (literal l : c) tout << l << ": " << value(l) << "\n";);
UNREACHABLE();
}
@ -4355,16 +4355,16 @@ namespace sat {
void solver::fixup_consequence_core() {
index_set s;
TRACE("sat", tout << m_core << "\n";);
TRACE(sat, tout << m_core << "\n";);
for (unsigned i = 0; i < m_core.size(); ++i) {
TRACE("sat", tout << m_core[i] << ": "; display_index_set(tout, m_antecedents.find(m_core[i].var())) << "\n";);
TRACE(sat, tout << m_core[i] << ": "; display_index_set(tout, m_antecedents.find(m_core[i].var())) << "\n";);
s |= m_antecedents.find(m_core[i].var());
}
m_core.reset();
for (unsigned idx : s) {
m_core.push_back(to_literal(idx));
}
TRACE("sat", tout << m_core << "\n";);
TRACE(sat, tout << m_core << "\n";);
}
bool solver::reached_max_conflicts() {
@ -4385,7 +4385,7 @@ namespace sat {
for (bool_var v : vars) {
unfixed_vars.insert(v);
}
TRACE("sat", tout << asms << "\n";);
TRACE(sat, tout << asms << "\n";);
m_antecedents.reset();
pop_to_base_level();
if (inconsistent()) return l_false;
@ -4438,7 +4438,7 @@ namespace sat {
}
lbool solver::get_consequences(literal_vector const& asms, literal_vector const& lits, vector<literal_vector>& conseq) {
TRACE("sat", tout << asms << "\n";);
TRACE(sat, tout << asms << "\n";);
m_antecedents.reset();
literal_set unfixed_lits(lits), assumptions(asms);
bool_var_set unfixed_vars;
@ -4489,7 +4489,7 @@ namespace sat {
propagate(false);
while (inconsistent()) {
if (!resolve_conflict()) {
TRACE("sat", display(tout << "inconsistent\n"););
TRACE(sat, display(tout << "inconsistent\n"););
m_inconsistent = false;
is_sat = l_undef;
break;
@ -4516,7 +4516,7 @@ namespace sat {
}
}
if (is_sat == l_false) {
TRACE("sat", tout << "unsat\n";);
TRACE(sat, tout << "unsat\n";);
m_inconsistent = false;
}
if (is_sat == l_true) {
@ -4576,7 +4576,7 @@ namespace sat {
void solver::extract_fixed_consequences(literal_set const& unfixed_lits, literal_set const& assumptions, bool_var_set& unfixed_vars, vector<literal_vector>& conseq) {
for (literal lit: unfixed_lits) {
TRACE("sat", tout << "extract: " << lit << " " << value(lit) << " " << lvl(lit) << "\n";);
TRACE(sat, tout << "extract: " << lit << " " << value(lit) << " " << lvl(lit) << "\n";);
if (lvl(lit) <= 1 && value(lit) == l_true) {
extract_fixed_consequences(lit, assumptions, unfixed_vars, conseq);
}
@ -4597,7 +4597,7 @@ namespace sat {
bool solver::extract_assumptions(literal lit, index_set& s) {
justification js = m_justification[lit.var()];
TRACE("sat", tout << lit << " " << js << "\n";);
TRACE(sat, tout << lit << " " << js << "\n";);
bool all_found = true;
switch (js.get_kind()) {
case justification::NONE:
@ -4635,7 +4635,7 @@ namespace sat {
UNREACHABLE();
break;
}
TRACE("sat", display_index_set(tout << lit << ": " , s) << "\n";);
TRACE(sat, display_index_set(tout << lit << ": " , s) << "\n";);
return all_found;
}