mirror of
https://github.com/Z3Prover/z3
synced 2025-08-17 16:52:15 +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:
parent
d766292dab
commit
0a93ff515d
583 changed files with 8698 additions and 7299 deletions
|
@ -135,7 +135,7 @@ namespace sat {
|
|||
}
|
||||
m_sub_todo.erase(c);
|
||||
c.set_removed(true);
|
||||
TRACE("sat_simplifier", tout << "del_clause: " << c << "\n";);
|
||||
TRACE(sat_simplifier, tout << "del_clause: " << c << "\n";);
|
||||
m_need_cleanup = true;
|
||||
m_use_list.erase(c);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ namespace sat {
|
|||
m_sub_bin_todo.reset();
|
||||
m_elim_todo.reset();
|
||||
init_visited();
|
||||
TRACE("after_cleanup", s.display(tout););
|
||||
TRACE(after_cleanup, s.display(tout););
|
||||
CASSERT("sat_solver", s.check_invariant());
|
||||
}
|
||||
|
||||
|
@ -194,10 +194,10 @@ namespace sat {
|
|||
initialize();
|
||||
|
||||
CASSERT("sat_solver", s.check_invariant());
|
||||
TRACE("sat_simplifier", s.display(tout););
|
||||
TRACE(sat_simplifier, s.display(tout););
|
||||
|
||||
s.m_cleaner(true);
|
||||
TRACE("after_cleanup", s.display(tout););
|
||||
TRACE(after_cleanup, s.display(tout););
|
||||
CASSERT("sat_solver", s.check_invariant());
|
||||
m_need_cleanup = false;
|
||||
m_use_list.init(s.num_vars());
|
||||
|
@ -243,7 +243,7 @@ namespace sat {
|
|||
bool vars_eliminated = m_num_elim_vars > m_old_num_elim_vars;
|
||||
|
||||
if (m_need_cleanup || vars_eliminated) {
|
||||
TRACE("after_simplifier", tout << "cleanning watches...\n";);
|
||||
TRACE(after_simplifier, tout << "cleanning watches...\n";);
|
||||
cleanup_watches();
|
||||
move_clauses(s.m_learned, true);
|
||||
move_clauses(s.m_clauses, false);
|
||||
|
@ -252,7 +252,7 @@ namespace sat {
|
|||
}
|
||||
|
||||
CASSERT("sat_solver", s.check_invariant());
|
||||
TRACE("sat_simplifier", s.display(tout); tout << "model_converter:\n"; s.m_mc.display(tout););
|
||||
TRACE(sat_simplifier, s.display(tout); tout << "model_converter:\n"; s.m_mc.display(tout););
|
||||
|
||||
finalize();
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ namespace sat {
|
|||
}
|
||||
|
||||
void simplifier::cleanup_clauses(clause_vector & cs, bool learned, bool vars_eliminated) {
|
||||
TRACE("sat", tout << "cleanup_clauses\n";);
|
||||
TRACE(sat, tout << "cleanup_clauses\n";);
|
||||
clause_vector::iterator it = cs.begin();
|
||||
clause_vector::iterator it2 = it;
|
||||
clause_vector::iterator end = cs.end();
|
||||
|
@ -428,7 +428,7 @@ namespace sat {
|
|||
clause_use_list const & cs = m_use_list.get(target);
|
||||
for (auto it = cs.mk_iterator(); !it.at_end(); it.next()) {
|
||||
clause & c2 = it.curr();
|
||||
CTRACE("sat_simplifier", c2.was_removed(), tout << "clause has been removed:\n" << c2 << "\n";);
|
||||
CTRACE(sat_simplifier, c2.was_removed(), tout << "clause has been removed:\n" << c2 << "\n";);
|
||||
SASSERT(!c2.was_removed());
|
||||
if (&c2 != &c1 &&
|
||||
c1.size() <= c2.size() &&
|
||||
|
@ -470,16 +470,16 @@ namespace sat {
|
|||
if (c1.is_learned() && !c2.is_learned()) {
|
||||
s.set_learned(c1, false);
|
||||
}
|
||||
TRACE("subsumption", tout << c1 << " subsumed " << c2 << "\n";);
|
||||
TRACE(subsumption, tout << c1 << " subsumed " << c2 << "\n";);
|
||||
remove_clause(c2, false);
|
||||
m_num_subsumed++;
|
||||
}
|
||||
else if (!c2.was_removed()) {
|
||||
// subsumption resolution
|
||||
TRACE("subsumption_resolution", tout << c1 << " sub-ref(" << *l_it << ") " << c2 << "\n";);
|
||||
TRACE(subsumption_resolution, tout << c1 << " sub-ref(" << *l_it << ") " << c2 << "\n";);
|
||||
elim_lit(c2, *l_it);
|
||||
m_num_sub_res++;
|
||||
TRACE("subsumption_resolution", tout << "result: " << c2 << "\n";);
|
||||
TRACE(subsumption_resolution, tout << "result: " << c2 << "\n";);
|
||||
}
|
||||
if (s.inconsistent())
|
||||
break;
|
||||
|
@ -570,7 +570,7 @@ namespace sat {
|
|||
// c2 was subsumed
|
||||
if (c1.is_learned() && !c2.is_learned())
|
||||
s.set_learned(c1, false);
|
||||
TRACE("subsumption", tout << c1 << " subsumed " << c2 << "\n";);
|
||||
TRACE(subsumption, tout << c1 << " subsumed " << c2 << "\n";);
|
||||
remove_clause(c2, false);
|
||||
m_num_subsumed++;
|
||||
}
|
||||
|
@ -672,7 +672,7 @@ namespace sat {
|
|||
}
|
||||
|
||||
void simplifier::elim_lit(clause & c, literal l) {
|
||||
TRACE("elim_lit", tout << "processing: " << l << " @ " << c << "\n";);
|
||||
TRACE(elim_lit, tout << "processing: " << l << " @ " << c << "\n";);
|
||||
m_need_cleanup = true;
|
||||
m_num_elim_lits++;
|
||||
insert_elim_todo(l.var());
|
||||
|
@ -694,31 +694,31 @@ namespace sat {
|
|||
unsigned sz0 = c.size();
|
||||
if (cleanup_clause(c)) {
|
||||
// clause was satisfied
|
||||
TRACE("elim_lit", tout << "clause was satisfied\n";);
|
||||
TRACE(elim_lit, tout << "clause was satisfied\n";);
|
||||
remove_clause(c, true);
|
||||
return;
|
||||
}
|
||||
unsigned sz = c.size();
|
||||
switch (sz) {
|
||||
case 0:
|
||||
TRACE("elim_lit", tout << "clause is empty\n";);
|
||||
TRACE(elim_lit, tout << "clause is empty\n";);
|
||||
s.set_conflict();
|
||||
break;
|
||||
case 1:
|
||||
TRACE("elim_lit", tout << "clause became unit: " << c[0] << "\n";);
|
||||
TRACE(elim_lit, tout << "clause became unit: " << c[0] << "\n";);
|
||||
c.restore(sz0);
|
||||
propagate_unit(c[0]);
|
||||
// unit propagation removes c
|
||||
break;
|
||||
case 2:
|
||||
TRACE("elim_lit", tout << "clause became binary: " << c[0] << " " << c[1] << "\n";);
|
||||
TRACE(elim_lit, tout << "clause became binary: " << c[0] << " " << c[1] << "\n";);
|
||||
c.restore(sz0);
|
||||
s.mk_bin_clause(c[0], c[1], c.is_learned());
|
||||
m_sub_bin_todo.push_back(bin_clause(c[0], c[1], c.is_learned()));
|
||||
remove_clause(c, sz0 != sz);
|
||||
break;
|
||||
default:
|
||||
TRACE("elim_lit", tout << "result: " << c << "\n";);
|
||||
TRACE(elim_lit, tout << "result: " << c << "\n";);
|
||||
m_sub_todo.insert(c);
|
||||
break;
|
||||
}
|
||||
|
@ -742,7 +742,7 @@ namespace sat {
|
|||
back_subsumption1(c);
|
||||
if (w.is_learned() && !c.is_learned()) {
|
||||
SASSERT(wlist[j] == w);
|
||||
TRACE("set_not_learned_bug",
|
||||
TRACE(set_not_learned_bug,
|
||||
tout << "marking as not learned: " << l2 << " " << wlist[j].is_learned() << "\n";);
|
||||
wlist[j].set_learned(false);
|
||||
mark_as_not_learned_core(get_wlist(~l2), l);
|
||||
|
@ -806,7 +806,7 @@ namespace sat {
|
|||
continue;
|
||||
}
|
||||
if (it->get_literal() == last_lit) {
|
||||
TRACE("subsumption", tout << "eliminating: " << ~to_literal(l_idx)
|
||||
TRACE(subsumption, tout << "eliminating: " << ~to_literal(l_idx)
|
||||
<< " " << it->get_literal() << "\n";);
|
||||
elim++;
|
||||
}
|
||||
|
@ -850,9 +850,9 @@ namespace sat {
|
|||
subsumption_report rpt(*this);
|
||||
elim_dup_bins();
|
||||
subsume_with_binaries();
|
||||
TRACE("subsumption_bug", s.display(tout););
|
||||
TRACE(subsumption_bug, s.display(tout););
|
||||
while (true) {
|
||||
TRACE("subsumption", tout << "sub_todo size: " << m_sub_todo.size() << "\n";);
|
||||
TRACE(subsumption, tout << "sub_todo size: " << m_sub_todo.size() << "\n";);
|
||||
|
||||
m_sub_counter -= m_sub_bin_todo.size();
|
||||
while (!m_sub_bin_todo.empty()) {
|
||||
|
@ -869,7 +869,7 @@ namespace sat {
|
|||
|
||||
checkpoint();
|
||||
|
||||
TRACE("subsumption_bug", s.display(tout););
|
||||
TRACE(subsumption_bug, s.display(tout););
|
||||
|
||||
if (m_sub_todo.empty()) {
|
||||
m_last_sub_trail_sz = s.m_trail.size();
|
||||
|
@ -883,7 +883,7 @@ namespace sat {
|
|||
|
||||
c.unmark_strengthened();
|
||||
m_sub_counter--;
|
||||
TRACE("subsumption", tout << "next: " << c << "\n";);
|
||||
TRACE(subsumption, tout << "next: " << c << "\n";);
|
||||
if (s.m_trail.size() > m_last_sub_trail_sz) {
|
||||
unsigned sz0 = c.size();
|
||||
if (cleanup_clause(c)) {
|
||||
|
@ -901,7 +901,7 @@ namespace sat {
|
|||
// unit propagation removes c
|
||||
continue;
|
||||
case 2:
|
||||
TRACE("subsumption", tout << "clause became binary: " << c << "\n";);
|
||||
TRACE(subsumption, tout << "clause became binary: " << c << "\n";);
|
||||
s.mk_bin_clause(c[0], c[1], c.is_learned());
|
||||
m_sub_bin_todo.push_back(bin_clause(c[0], c[1], c.is_learned()));
|
||||
c.restore(sz0);
|
||||
|
@ -911,7 +911,7 @@ namespace sat {
|
|||
break;
|
||||
}
|
||||
}
|
||||
TRACE("subsumption", tout << "using: " << c << "\n";);
|
||||
TRACE(subsumption, tout << "using: " << c << "\n";);
|
||||
back_subsumption1(c);
|
||||
}
|
||||
}
|
||||
|
@ -1584,7 +1584,7 @@ namespace sat {
|
|||
}
|
||||
|
||||
void block_covered_clause(clause& c, literal l, model_converter::kind k) {
|
||||
TRACE("blocked_clause", tout << "new blocked clause: " << c << "\n";);
|
||||
TRACE(blocked_clause, tout << "new blocked clause: " << c << "\n";);
|
||||
SASSERT(!s.is_external(l));
|
||||
model_converter::entry& new_entry = m_mc.mk(k, l.var());
|
||||
for (literal lit : c) {
|
||||
|
@ -1599,7 +1599,7 @@ namespace sat {
|
|||
SASSERT(!s.is_external(blocked));
|
||||
model_converter::entry& new_entry = m_mc.mk(k, blocked.var());
|
||||
literal l2 = w.get_literal();
|
||||
TRACE("blocked_clause", tout << "new blocked clause: " << l2 << " " << l1 << "\n";);
|
||||
TRACE(blocked_clause, tout << "new blocked clause: " << l2 << " " << l1 << "\n";);
|
||||
s.set_learned(l1, l2);
|
||||
m_mc.insert(new_entry, m_covered_clause);
|
||||
m_mc.set_clause(new_entry, l1, l2);
|
||||
|
@ -1716,7 +1716,7 @@ namespace sat {
|
|||
};
|
||||
|
||||
void simplifier::elim_blocked_clauses() {
|
||||
TRACE("blocked_clause_bug", tout << "trail: " << s.m_trail.size() << "\n"; s.display_watches(tout); s.display(tout););
|
||||
TRACE(blocked_clause_bug, tout << "trail: " << s.m_trail.size() << "\n"; s.display_watches(tout); s.display(tout););
|
||||
blocked_cls_report rpt(*this);
|
||||
blocked_clause_elim elim(*this, m_blocked_clause_limit, s.m_mc, m_use_list, s.m_watches);
|
||||
elim();
|
||||
|
@ -1740,7 +1740,7 @@ namespace sat {
|
|||
unsigned num_bin_pos = num_nonlearned_bin(pos_l);
|
||||
unsigned num_bin_neg = num_nonlearned_bin(neg_l);
|
||||
unsigned cost = 2 * num_pos * num_neg + num_pos * num_bin_neg + num_neg * num_bin_pos;
|
||||
CTRACE("sat_simplifier", cost == 0, tout << v << " num_pos: " << num_pos << " num_neg: " << num_neg << " num_bin_pos: " << num_bin_pos
|
||||
CTRACE(sat_simplifier, cost == 0, tout << v << " num_pos: " << num_pos << " num_neg: " << num_neg << " num_bin_pos: " << num_bin_pos
|
||||
<< " num_bin_neg: " << num_bin_neg << " cost: " << cost << "\n";);
|
||||
return cost;
|
||||
}
|
||||
|
@ -1765,7 +1765,7 @@ namespace sat {
|
|||
}
|
||||
m_elim_todo.reset();
|
||||
std::stable_sort(tmp.begin(), tmp.end(), bool_var_and_cost_lt());
|
||||
TRACE("sat_simplifier",
|
||||
TRACE(sat_simplifier,
|
||||
for (auto& p : tmp) tout << "(" << p.first << ", " << p.second << ") ";
|
||||
tout << "\n";);
|
||||
for (auto& p : tmp)
|
||||
|
@ -1803,7 +1803,7 @@ namespace sat {
|
|||
Return false if the result is a tautology
|
||||
*/
|
||||
bool simplifier::resolve(clause_wrapper const & c1, clause_wrapper const & c2, literal l, literal_vector & r) {
|
||||
CTRACE("resolve_bug", !c1.contains(l) || !c2.contains(~l), tout << c1 << "\n" << c2 << "\nl: " << l << "\n";);
|
||||
CTRACE(resolve_bug, !c1.contains(l) || !c2.contains(~l), tout << c1 << "\n" << c2 << "\nl: " << l << "\n";);
|
||||
if (m_visited.size() <= 2*s.num_vars())
|
||||
m_visited.resize(2*s.num_vars(), false);
|
||||
if (c1.was_removed() && !c1.contains(l))
|
||||
|
@ -1873,7 +1873,7 @@ namespace sat {
|
|||
watch_list::iterator end2 = wlist2.end();
|
||||
for (; it2 != end2; ++it2) {
|
||||
if (it2->is_binary_clause() && it2->get_literal() == l) {
|
||||
TRACE("bin_clause_bug", tout << "removing: " << l << " " << it2->get_literal() << "\n";);
|
||||
TRACE(bin_clause_bug, tout << "removing: " << l << " " << it2->get_literal() << "\n";);
|
||||
m_sub_bin_todo.erase(bin_clause(l2, l, it2->is_learned()));
|
||||
continue;
|
||||
}
|
||||
|
@ -1884,7 +1884,7 @@ namespace sat {
|
|||
m_sub_bin_todo.erase(bin_clause(l, l2, w.is_learned()));
|
||||
}
|
||||
}
|
||||
TRACE("bin_clause_bug", tout << "collapsing watch_list of: " << l << "\n";);
|
||||
TRACE(bin_clause_bug, tout << "collapsing watch_list of: " << l << "\n";);
|
||||
wlist.finalize();
|
||||
}
|
||||
|
||||
|
@ -1903,7 +1903,7 @@ namespace sat {
|
|||
c.set_removed(true);
|
||||
m_use_list.erase(c, l);
|
||||
m_sub_todo.erase(c);
|
||||
TRACE("sat_simplifier", tout << "del_clause (elim_var): " << c << "\n";);
|
||||
TRACE(sat_simplifier, tout << "del_clause (elim_var): " << c << "\n";);
|
||||
m_need_cleanup = true;
|
||||
}
|
||||
}
|
||||
|
@ -1922,7 +1922,7 @@ namespace sat {
|
|||
unsigned num_pos = pos_occs.num_irredundant() + num_bin_pos;
|
||||
unsigned num_neg = neg_occs.num_irredundant() + num_bin_neg;
|
||||
|
||||
TRACE("sat_simplifier", tout << v << " num_pos: " << num_pos << " neg_pos: " << num_neg << "\n";);
|
||||
TRACE(sat_simplifier, tout << v << " num_pos: " << num_pos << " neg_pos: " << num_neg << "\n";);
|
||||
|
||||
if (num_pos >= m_res_occ_cutoff && num_neg >= m_res_occ_cutoff)
|
||||
return false;
|
||||
|
@ -1939,7 +1939,7 @@ namespace sat {
|
|||
before_lits += it.curr().size();
|
||||
}
|
||||
|
||||
TRACE("sat_simplifier", tout << v << " num_pos: " << num_pos << " neg_pos: " << num_neg << " before_lits: " << before_lits << "\n";);
|
||||
TRACE(sat_simplifier, tout << v << " num_pos: " << num_pos << " neg_pos: " << num_neg << " before_lits: " << before_lits << "\n";);
|
||||
|
||||
if (num_pos >= m_res_occ_cutoff3 && num_neg >= m_res_occ_cutoff3 && before_lits > m_res_lit_cutoff3 && s.m_clauses.size() > m_res_cls_cutoff2)
|
||||
return false;
|
||||
|
@ -1955,24 +1955,24 @@ namespace sat {
|
|||
collect_clauses(pos_l, m_pos_cls);
|
||||
collect_clauses(neg_l, m_neg_cls);
|
||||
|
||||
TRACE("sat_simplifier", tout << "collecting number of after_clauses\n";);
|
||||
TRACE(sat_simplifier, tout << "collecting number of after_clauses\n";);
|
||||
unsigned before_clauses = num_pos + num_neg;
|
||||
unsigned after_clauses = 0;
|
||||
for (clause_wrapper& c1 : m_pos_cls) {
|
||||
for (clause_wrapper& c2 : m_neg_cls) {
|
||||
m_new_cls.reset();
|
||||
if (resolve(c1, c2, pos_l, m_new_cls)) {
|
||||
TRACE("sat_simplifier", tout << c1 << "\n" << c2 << "\n-->\n";
|
||||
TRACE(sat_simplifier, tout << c1 << "\n" << c2 << "\n-->\n";
|
||||
for (literal l : m_new_cls) tout << l << " "; tout << "\n";);
|
||||
after_clauses++;
|
||||
if (after_clauses > before_clauses) {
|
||||
TRACE("sat_simplifier", tout << "too many after clauses: " << after_clauses << "\n";);
|
||||
TRACE(sat_simplifier, tout << "too many after clauses: " << after_clauses << "\n";);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TRACE("sat_simplifier", tout << "eliminate " << v << ", before: " << before_clauses << " after: " << after_clauses << "\n";
|
||||
TRACE(sat_simplifier, tout << "eliminate " << v << ", before: " << before_clauses << " after: " << after_clauses << "\n";
|
||||
tout << "pos\n";
|
||||
for (auto & c : m_pos_cls)
|
||||
tout << c << "\n";
|
||||
|
@ -2000,7 +2000,7 @@ namespace sat {
|
|||
m_new_cls.reset();
|
||||
if (!resolve(c1, c2, pos_l, m_new_cls))
|
||||
continue;
|
||||
TRACE("sat_simplifier", tout << c1 << "\n" << c2 << "\n-->\n" << m_new_cls << "\n";);
|
||||
TRACE(sat_simplifier, tout << c1 << "\n" << c2 << "\n-->\n" << m_new_cls << "\n";);
|
||||
if (cleanup_clause(m_new_cls)) {
|
||||
continue; // clause is already satisfied.
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue