3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-03-01 19:26:53 +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

@ -57,7 +57,7 @@ struct gomory_test {
}
void real_case_in_gomory_cut(const mpq & a, unsigned x_j, mpq & k, lar_term& pol, explanation & expl, const mpq& f_0, const mpq& one_minus_f_0) {
TRACE("gomory_cut_detail_real", tout << "real\n";);
TRACE(gomory_cut_detail_real, tout << "real\n";);
mpq new_a;
if (at_low(x_j)) {
if (a.is_pos()) {
@ -83,7 +83,7 @@ struct gomory_test {
k.addmul(new_a, upper_bound(x_j).x); // k += upper_bound(x_j).x * new_a;
expl.add_pair(column_upper_bound_constraint(x_j), new_a);
}
TRACE("gomory_cut_detail_real", tout << a << "*v" << x_j << " k: " << k << "\n";);
TRACE(gomory_cut_detail_real, tout << a << "*v" << x_j << " k: " << k << "\n";);
pol.add_monomial(new_a, x_j);
}
@ -92,7 +92,7 @@ struct gomory_test {
SASSERT(!a.is_int());
SASSERT(f_0 > zero_of_type<mpq>() && f_0 < one_of_type<mpq>());
mpq f_j = fractional_part(a);
TRACE("gomory_cut_detail",
TRACE(gomory_cut_detail,
tout << a << " x_j = " << x_j << ", k = " << k << "\n";
tout << "f_j: " << f_j << "\n";
tout << "f_0: " << f_0 << "\n";
@ -123,7 +123,7 @@ struct gomory_test {
k.addmul(new_a, upper_bound(x_j).x);
expl.add_pair(column_upper_bound_constraint(x_j), new_a);
}
TRACE("gomory_cut_detail", tout << "new_a: " << new_a << " k: " << k << "\n";);
TRACE(gomory_cut_detail, tout << "new_a: " << new_a << " k: " << k << "\n";);
t.add_monomial(new_a, x_j);
lcm_den = lcm(lcm_den, denominator(new_a));
}
@ -138,7 +138,7 @@ struct gomory_test {
auto pol = t.coeffs_as_vector();
t.clear();
if (pol.size() == 1) {
TRACE("gomory_cut_detail", tout << "pol.size() is 1" << std::endl;);
TRACE(gomory_cut_detail, tout << "pol.size() is 1" << std::endl;);
unsigned v = pol[0].second;
SASSERT(is_integer(v));
const mpq& a = pol[0].first;
@ -155,9 +155,9 @@ struct gomory_test {
t.add_monomial(mpq(1), v);
}
} else {
TRACE("gomory_cut_detail", tout << "pol.size() > 1" << std::endl;);
TRACE(gomory_cut_detail, tout << "pol.size() > 1" << std::endl;);
lcm_den = lcm(lcm_den, denominator(k));
TRACE("gomory_cut_detail", tout << "k: " << k << " lcm_den: " << lcm_den << "\n";
TRACE(gomory_cut_detail, tout << "k: " << k << " lcm_den: " << lcm_den << "\n";
for (unsigned i = 0; i < pol.size(); i++) {
tout << pol[i].first << " " << pol[i].second << "\n";
}
@ -171,7 +171,7 @@ struct gomory_test {
}
k *= lcm_den;
}
TRACE("gomory_cut_detail", tout << "after *lcm\n";
TRACE(gomory_cut_detail, tout << "after *lcm\n";
for (unsigned i = 0; i < pol.size(); i++) {
tout << pol[i].first << " * v" << pol[i].second << "\n";
}
@ -182,7 +182,7 @@ struct gomory_test {
t.add_monomial(-pi.first, pi.second);
k.neg();
}
TRACE("gomory_cut_detail", tout << "k = " << k << std::endl;);
TRACE(gomory_cut_detail, tout << "k = " << k << std::endl;);
SASSERT(k.is_int());
}
@ -197,7 +197,7 @@ struct gomory_test {
enable_trace("gomory_cut");
enable_trace("gomory_cut_detail");
TRACE("gomory_cut",
TRACE(gomory_cut,
tout << "applying cut at:\n"; print_row(tout, row);
tout << std::endl << "inf_col = " << inf_col << std::endl;
);
@ -231,7 +231,7 @@ struct gomory_test {
if (some_int_columns)
adjust_term_and_k_for_some_ints_case_gomory(t, k, lcm_den);
TRACE("gomory_cut", tout<<"new cut :"; print_term(t, tout); tout << " >= " << k << std::endl;);
TRACE(gomory_cut, tout<<"new cut :"; print_term(t, tout); tout << " >= " << k << std::endl;);
}
};

View file

@ -132,7 +132,7 @@ void test_basic_lemma_for_mon_neutral_from_factors_to_monomial();
void test_cn_on_expr(nex_sum *t, cross_nested &cn) {
t = to_sum(cn.get_nex_creator().simplify(t));
TRACE("nla_test", tout << "t=" << *t << '\n';);
TRACE(nla_test, tout << "t=" << *t << '\n';);
cn.run(t);
}
@ -183,7 +183,7 @@ void test_simplify() {
nex_creator r;
cross_nested cn(
[](const nex *n) {
TRACE("nla_cn_test", tout << *n << "\n";);
TRACE(nla_cn_test, tout << *n << "\n";);
return false;
},
[](unsigned) { return false; }, []() { return 1; }, // for random
@ -203,7 +203,7 @@ void test_simplify() {
auto a_plus_bc = r.mk_sum(a, bc);
auto two_a_plus_bc = r.mk_mul(r.mk_scalar(rational(2)), a_plus_bc);
auto simp_two_a_plus_bc = r.simplify(two_a_plus_bc);
TRACE("nla_test", tout << *simp_two_a_plus_bc << "\n";);
TRACE(nla_test, tout << *simp_two_a_plus_bc << "\n";);
ENSURE(nex_creator::equal(simp_two_a_plus_bc, two_a_plus_bc));
auto simp_a_plus_bc = r.simplify(a_plus_bc);
ENSURE(to_sum(simp_a_plus_bc)->size() > 1);
@ -211,46 +211,46 @@ void test_simplify() {
auto three_ab = r.mk_mul(r.mk_scalar(rational(3)), a, b);
auto three_ab_square = r.mk_mul(three_ab, three_ab, three_ab);
TRACE("nla_test", tout << "before simplify " << *three_ab_square << "\n";);
TRACE(nla_test, tout << "before simplify " << *three_ab_square << "\n";);
three_ab_square = to_mul(r.simplify(three_ab_square));
TRACE("nla_test", tout << *three_ab_square << "\n";);
TRACE(nla_test, tout << *three_ab_square << "\n";);
const rational &s = three_ab_square->coeff();
ENSURE(s == rational(27));
auto m = r.mk_mul(a, a);
TRACE("nla_test_", tout << "m = " << *m << "\n";);
TRACE(nla_test_, tout << "m = " << *m << "\n";);
/*
auto n = r.mk_mul(b, b, b, b, b, b, b);
n->add_child_in_power(b, 7);
n->add_child(r.mk_scalar(rational(3)));
n->add_child_in_power(r.mk_scalar(rational(2)), 2);
n->add_child(r.mk_scalar(rational(1)));
TRACE("nla_test_", tout << "n = " << *n << "\n";);
TRACE(nla_test_, tout << "n = " << *n << "\n";);
m->add_child_in_power(n, 3);
n->add_child_in_power(r.mk_scalar(rational(1, 3)), 2);
TRACE("nla_test_", tout << "m = " << *m << "\n";);
TRACE(nla_test_, tout << "m = " << *m << "\n";);
nex_sum * e = r.mk_sum(a, r.mk_sum(b, m));
TRACE("nla_test", tout << "before simplify e = " << *e << "\n";);
TRACE(nla_test, tout << "before simplify e = " << *e << "\n";);
e = to_sum(r.simplify(e));
TRACE("nla_test", tout << "simplified e = " << *e << "\n";);
TRACE(nla_test, tout << "simplified e = " << *e << "\n";);
ENSURE(e->children().size() > 2);
nex_sum * e_m = r.mk_sum();
for (const nex* ex: to_sum(e)->children()) {
nex* ce = r.mk_mul(r.clone(ex), r.mk_scalar(rational(3)));
TRACE("nla_test", tout << "before simpl ce = " << *ce << "\n";);
TRACE(nla_test, tout << "before simpl ce = " << *ce << "\n";);
ce = r.simplify(ce);
TRACE("nla_test", tout << "simplified ce = " << *ce << "\n";);
TRACE(nla_test, tout << "simplified ce = " << *ce << "\n";);
e_m->add_child(ce);
}
e->add_child(e_m);
TRACE("nla_test", tout << "before simplify sum e = " << *e << "\n";);
TRACE(nla_test, tout << "before simplify sum e = " << *e << "\n";);
e = to_sum(r.simplify(e));
TRACE("nla_test", tout << "simplified sum e = " << *e << "\n";);
TRACE(nla_test, tout << "simplified sum e = " << *e << "\n";);
nex * pr = r.mk_mul(a, b, b);
TRACE("nla_test", tout << "before simplify pr = " << *pr << "\n";);
TRACE(nla_test, tout << "before simplify pr = " << *pr << "\n";);
r.simplify(pr);
TRACE("nla_test", tout << "simplified sum e = " << *pr << "\n";);
TRACE(nla_test, tout << "simplified sum e = " << *pr << "\n";);
*/
#endif
}
@ -260,7 +260,7 @@ void test_cn_shorter() {
// nex_creator cr;
// cross_nested cn(
// [](const nex* n) {
// TRACE("nla_test", tout <<"cn form = " << *n << "\n";
// TRACE(nla_test, tout <<"cn form = " << *n << "\n";
// );
// return false;
@ -295,7 +295,7 @@ void test_cn_shorter() {
// rational(3); nex* _6aad = cr.mk_mul(cr.mk_scalar(rational(6)), a, a,
// d); clone = to_sum(cr.clone(cr.mk_sum(_6aad, abcd, eae, three_eac)));
// clone = to_sum(cr.simplify(clone));
// TRACE("nla_test", tout << "clone = " << *clone << "\n";);
// TRACE(nla_test, tout << "clone = " << *clone << "\n";);
// // test_cn_on_expr(cr.mk_sum(aad, abcd, aaccd, add, eae, eac, ed),
// cn); test_cn_on_expr(clone, cn);
// */
@ -307,7 +307,7 @@ void test_cn() {
// nex_creator cr;
// cross_nested cn(
// [](const nex* n) {
// TRACE("nla_test", tout <<"cn form = " << *n << "\n";);
// TRACE(nla_test, tout <<"cn form = " << *n << "\n";);
// return false;
// } ,
// [](unsigned) { return false; },
@ -352,14 +352,14 @@ void test_cn() {
// nex* _6aad = cr.mk_mul(cr.mk_scalar(rational(6)), a, a, d);
// nex * clone = cr.clone(cr.mk_sum(_6aad, abcd, aaccd, add, eae, eac,
// ed)); clone = cr.simplify(clone); ENSURE(cr.is_simplified(clone));
// TRACE("nla_test", tout << "clone = " << *clone << "\n";);
// TRACE(nla_test, tout << "clone = " << *clone << "\n";);
// // test_cn_on_expr(cr.mk_sum(aad, abcd, aaccd, add, eae, eac, ed),
// cn); test_cn_on_expr(to_sum(clone), cn); TRACE("nla_test", tout <<
// cn); test_cn_on_expr(to_sum(clone), cn); TRACE(nla_test, tout <<
// "done\n";); test_cn_on_expr(cr.mk_sum(abd, abc, cbd, acd), cn);
// TRACE("nla_test", tout << "done\n";);*/
// TRACE(nla_test, tout << "done\n";);*/
// #endif
// // test_cn_on_expr(a*b*b*d*d + a*b*b*c*d + c*b*b*d);
// // TRACE("nla_test", tout << "done\n";);
// // TRACE(nla_test, tout << "done\n";);
// // test_cn_on_expr(a*b*d + a*b*c + c*b*d);
}

View file

@ -154,7 +154,7 @@ void create_abcde(solver & nla,
void test_basic_lemma_for_mon_neutral_from_factors_to_monomial_0() {
std::cout << "test_basic_lemma_for_mon_neutral_from_factors_to_monomial_0\n";
enable_trace("nla_solver");
TRACE("nla_solver",);
TRACE(nla_solver,);
lp::lar_solver s;
unsigned a = 0, b = 1, c = 2, d = 3, e = 4,
abcde = 5, ac = 6, bde = 7;
@ -233,7 +233,7 @@ void s_set_column_value_test(lp::lar_solver&s, lpvar j, const lp::impq & v) {
void test_basic_lemma_for_mon_neutral_from_factors_to_monomial_1() {
std::cout << "test_basic_lemma_for_mon_neutral_from_factors_to_monomial_1\n";
TRACE("nla_solver",);
TRACE(nla_solver,);
lp::lar_solver s;
unsigned a = 0, b = 1, c = 2, d = 3, e = 4,
bde = 7;