3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-09-21 00:44:50 +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

@ -216,7 +216,7 @@ namespace datalog {
for (; it2 != end; ++it2) {
app* a2 = it2->m_key;
var* v2 = it2->m_value;
TRACE("dl", tout << mk_pp(a1, m) << " " << mk_pp(a2, m) << "\n";);
TRACE(dl, tout << mk_pp(a1, m) << " " << mk_pp(a2, m) << "\n";);
if (get_select(a1) != get_select(a2)) {
continue;
}
@ -260,7 +260,7 @@ namespace datalog {
uint_set rhs_vars = rm.collect_vars(y);
lhs &= rhs_vars;
if (!lhs.empty()) {
TRACE("dl", tout << "unusable equality " << mk_pp(e, m) << "\n";);
TRACE(dl, tout << "unusable equality " << mk_pp(e, m) << "\n";);
new_conjs.push_back(e);
}
else {
@ -284,7 +284,7 @@ namespace datalog {
m_rewriter(body);
sub(head);
m_rewriter(head);
TRACE("dl", tout << body << " => " << head << "\n";);
TRACE(dl, tout << body << " => " << head << "\n";);
change = ackermanize(r, body, head);
if (!change) {
rules.add_rule(&r);
@ -294,7 +294,7 @@ namespace datalog {
fml2 = m.mk_implies(body, head);
proof_ref p(m);
rule_set new_rules(m_ctx);
TRACE("dl", tout << fml2 << "\n";);
TRACE(dl, tout << fml2 << "\n";);
rm.mk_rule(fml2, p, new_rules, r.name());
@ -309,7 +309,7 @@ namespace datalog {
}
rules.add_rule(new_rule.get());
rm.mk_rule_rewrite_proof(r, *new_rule.get());
TRACE("dl", new_rule->display(m_ctx, tout << "new rule\n"););
TRACE(dl, new_rule->display(m_ctx, tout << "new rule\n"););
}
return true;
}

View file

@ -69,7 +69,7 @@ namespace datalog {
result->add_rule(new_rule);
}
}
TRACE("dl", result->display(tout););
TRACE(dl, result->display(tout););
return result.detach();
}

View file

@ -75,7 +75,7 @@ namespace datalog {
if (!f) continue;
expr_ref body(m);
unsigned arity_q = q->get_arity();
TRACE("dl",
TRACE(dl,
model_v2_pp(tout, *model);
tout << mk_pp(p, m) << "\n";
tout << mk_pp(q, m) << "\n";);
@ -242,7 +242,7 @@ namespace datalog {
m_context.get_rule_manager().to_formula(*r2.get(), fml1);
m_blaster(fml1, fml2, pr);
m_rewriter(fml2, fml3);
TRACE("dl", tout << fml << "\n-> " << fml1 << "\n-> " << fml2 << "\n-> " << fml3 << "\n";);
TRACE(dl, tout << fml << "\n-> " << fml1 << "\n-> " << fml2 << "\n-> " << fml3 << "\n";);
if (fml3 != fml) {
fml = fml3;
return true;
@ -281,9 +281,9 @@ namespace datalog {
for (unsigned i = 0; !m_context.canceled() && i < sz; ++i) {
rule * r = source.get_rule(i);
rm.to_formula(*r, fml);
TRACE("dl", tout << fml << "\n";);
TRACE(dl, tout << fml << "\n";);
if (blast(r, fml)) {
TRACE("dl", tout << "blasted: " << fml << "\n";);
TRACE(dl, tout << "blasted: " << fml << "\n";);
proof_ref pr(m);
if (r->get_proof()) {
scoped_proof _sc(m);
@ -317,7 +317,7 @@ namespace datalog {
}
m_context.add_model_converter(concat(bvmc, fmc));
}
CTRACE("dl", result, result->display(tout););
CTRACE(dl, result, result->display(tout););
return result.detach();
}
};

View file

@ -92,7 +92,7 @@ namespace datalog {
}
}
if (res->get_num_rules() == source.get_num_rules()) {
TRACE("dl", tout << "No transformation\n";);
TRACE(dl, tout << "No transformation\n";);
res = nullptr;
}
else {
@ -108,9 +108,9 @@ namespace datalog {
for (func_decl* f : unreachable)
mc0->add(f, m.mk_false());
m_context.add_model_converter(mc0);
TRACE("dl", m_context.get_model_converter()->display(tout););
TRACE(dl, m_context.get_model_converter()->display(tout););
}
CTRACE("dl", res, res->display(tout););
CTRACE(dl, res, res->display(tout););
return res.detach();
}
@ -147,7 +147,7 @@ namespace datalog {
}
if (res->get_num_rules() == source.get_num_rules()) {
TRACE("dl", tout << "No transformation\n";);
TRACE(dl, tout << "No transformation\n";);
res = nullptr;
}
if (res && m_context.get_model_converter() && !pruned_preds.empty()) {
@ -171,7 +171,7 @@ namespace datalog {
}
m_context.add_model_converter(mc0);
}
CTRACE("dl", 0 != res, res->display(tout););
CTRACE(dl, 0 != res, res->display(tout););
return res.detach();
}
}

View file

@ -136,11 +136,11 @@ namespace datalog {
rule_ref new_rule(rm.mk(r.get_head(), tail.size(), tail.data(), nullptr, r.name(), false), rm);
rm.mk_rule_rewrite_proof(r, *new_rule.get());
new_rules.add_rule(new_rule);
TRACE("dl", tout << "No term-ite after blast_term_ite\n";);
TRACE(dl, tout << "No term-ite after blast_term_ite\n";);
return true;
}
TRACE("dl", tout << "Rule has term-ite after blasting, starting elimination\n";);
TRACE(dl, tout << "Rule has term-ite after blasting, starting elimination\n";);
body = ground(body);
// elim ite
tactic_ref elim_term_ite = mk_elim_term_ite_tactic(m);
@ -170,7 +170,7 @@ namespace datalog {
rw(body);
fml2 = m.mk_implies(body, ground(r.get_head()));
CTRACE("dl", has_term_ite(fml2), tout << "Rule has term-ite after elimination. Giving up\n";);
CTRACE(dl, has_term_ite(fml2), tout << "Rule has term-ite after elimination. Giving up\n";);
if (has_term_ite(fml2))
return false;
app_ref_vector consts(m);
@ -183,7 +183,7 @@ namespace datalog {
// NSB code review: breaks abstraction barrier: mk_rule could convert a single formula
// into multiple rules
rm.mk_rule_rewrite_proof(r, *new_rules.last());
TRACE("dl", tout << "New rule: " << fml2 << "\n";);
TRACE(dl, tout << "New rule: " << fml2 << "\n";);
return true;
}

View file

@ -53,7 +53,7 @@ namespace datalog {
*/
bool mk_filter_rules::is_candidate(app * pred) {
if (!m_context.is_predicate(pred)) {
TRACE("mk_filter_rules", tout << mk_pp(pred, m) << "\nis not a candidate because it is interpreted.\n";);
TRACE(mk_filter_rules, tout << mk_pp(pred, m) << "\nis not a candidate because it is interpreted.\n";);
return false;
}
var_idx_set used_vars;
@ -111,7 +111,7 @@ namespace datalog {
for (unsigned i = 0; i < sz; i++) {
app * tail = r->get_tail(i);
if (is_candidate(tail) && !r->is_neg_tail(i)) {
TRACE("mk_filter_rules", tout << "is_candidate: " << mk_pp(tail, m) << "\n";);
TRACE(mk_filter_rules, tout << "is_candidate: " << mk_pp(tail, m) << "\n";);
var_idx_set non_local_vars = rm.collect_rule_vars_ex(r, tail);
func_decl * filter_decl = mk_filter_decl(tail, non_local_vars);
ptr_buffer<expr> new_args;

View file

@ -474,12 +474,12 @@ namespace datalog {
if (!found_something) {
return false;
}
TRACE("dl_interp_tail_simplifier_propagation_pre",
TRACE(dl_interp_tail_simplifier_propagation_pre,
tout << "will propagate rule:\n";
r->display(m_context, tout);
);
m_rule_subst.get_result(res);
TRACE("dl_interp_tail_simplifier_propagation",
TRACE(dl_interp_tail_simplifier_propagation,
tout << "propagated equivalences of:\n";
r->display(m_context, tout);
tout << "into:\n";
@ -539,7 +539,7 @@ namespace datalog {
modified |= itail.get() != simp_res.get();
if (m.is_false(simp_res)) {
TRACE("dl", r->display(m_context, tout << "rule is infeasible\n"););
TRACE(dl, r->display(m_context, tout << "rule is infeasible\n"););
return false;
}
SASSERT(m.is_bool(simp_res));
@ -574,7 +574,7 @@ namespace datalog {
goto start;
}
CTRACE("dl", (res != r0), r0->display(m_context, tout << "old:\n"); res->display(m_context, tout << "new:\n"););
CTRACE(dl, (res != r0), r0->display(m_context, tout << "old:\n"); res->display(m_context, tout << "new:\n"););
return true;
}
@ -605,7 +605,7 @@ namespace datalog {
scoped_ptr<rule_set> res = alloc(rule_set, m_context);
if (transform_rules(source, *res)) {
res->inherit_predicates(source);
TRACE("dl",
TRACE(dl,
source.display(tout);
res->display(tout););
}

View file

@ -200,7 +200,7 @@ namespace datalog {
mk_backwards bwd(m_ctx);
scoped_ptr<rule_set> src_loop = lc(source);
TRACE("dl", src_loop->display(tout << "source loop\n"););
TRACE(dl, src_loop->display(tout << "source loop\n"););
get_invariants(*src_loop);
@ -214,7 +214,7 @@ namespace datalog {
scoped_ptr<rule_set> src_annot = update_rules(*src_loop);
rule_set* rules = lc.revert(*src_annot);
rules->inherit_predicates(source);
TRACE("dl", rules->display(tout););
TRACE(dl, rules->display(tout););
m_pinned.reset();
m_fun2inv.reset();
return rules;

View file

@ -195,7 +195,7 @@ namespace datalog {
}
app * mag_head = create_magic_literal(tail[i]);
rule * r = m_context.get_rule_manager().mk(mag_head, i+1, new_tail.data(), negations.data());
TRACE("dl", r->display(m_context,tout); );
TRACE(dl, r->display(m_context,tout); );
result.add_rule(r);
}
}

View file

@ -106,7 +106,7 @@ namespace datalog {
}
}
TRACE("dl", result->display(tout););
TRACE(dl, result->display(tout););
return result.detach();
}

View file

@ -88,7 +88,7 @@ namespace datalog {
}
// Create quantifier wrapper around body.
TRACE("dl", tout << body << "\n";);
TRACE(dl, tout << body << "\n";);
// 1. replace variables by the compound terms from
// the original predicate.
expr_safe_replace rep(m);
@ -98,7 +98,7 @@ namespace datalog {
rep(body);
rep.reset();
TRACE("dl", tout << body << "\n";);
TRACE(dl, tout << body << "\n";);
// 2. replace bound variables by constants.
expr_ref_vector consts(m), bound(m), _free(m);
svector<symbol> names;
@ -119,12 +119,12 @@ namespace datalog {
rep(body);
rep.reset();
TRACE("dl", tout << body << "\n";);
TRACE(dl, tout << body << "\n";);
// 3. abstract and quantify those variables that should be bound.
body = expr_abstract(bound, body);
body = m.mk_forall(names.size(), bound_sorts.data(), names.data(), body);
TRACE("dl", tout << body << "\n";);
TRACE(dl, tout << body << "\n";);
// 4. replace remaining constants by variables.
unsigned j = 0;
for (expr* f : _free) {
@ -133,7 +133,7 @@ namespace datalog {
rep(body);
new_model->register_decl(q, body);
TRACE("dl", tout << body << "\n";);
TRACE(dl, tout << body << "\n";);
}
old_model = new_model;
}
@ -234,7 +234,7 @@ namespace datalog {
}
args.push_back(arg);
}
TRACE("dl",
TRACE(dl,
tout << mk_pp(new_p, m) << "\n";
for (unsigned i = 0; i < args.size(); ++i) {
tout << mk_pp(args[i].get(), m) << "\n";
@ -329,7 +329,7 @@ namespace datalog {
for (unsigned i = 0; i < sz; ++i) {
tail.reset();
rule & r = *source.get_rule(i);
TRACE("dl", r.display(m_ctx, tout); );
TRACE(dl, r.display(m_ctx, tout); );
unsigned cnt = vc.get_max_rule_var(r)+1;
unsigned utsz = r.get_uninterpreted_tail_size();
unsigned tsz = r.get_tail_size();
@ -343,7 +343,7 @@ namespace datalog {
fml = m.mk_implies(m.mk_and(tail.size(), tail.data()), head);
proof_ref pr(m);
rm.mk_rule(fml, pr, *result, r.name());
TRACE("dl", result->last()->display(m_ctx, tout););
TRACE(dl, result->last()->display(m_ctx, tout););
}
// proof converter: proofs are not necessarily preserved using this transformation.

View file

@ -90,7 +90,7 @@ namespace datalog {
}
void mk_quantifier_instantiation::match(unsigned i, app* pat, unsigned j, term_pairs& todo, quantifier* q, expr_ref_vector& conjs) {
TRACE("dl", tout << "match" << mk_pp(pat, m) << "\n";);
TRACE(dl, tout << "match" << mk_pp(pat, m) << "\n";);
while (j < todo.size()) {
expr* p = todo[j].first;
expr* t = todo[j].second;
@ -157,7 +157,7 @@ namespace datalog {
m_binding.reverse();
m_cnst2var(res);
conjs.push_back(res);
TRACE("dl", tout << mk_pp(q, m) << "\n==>\n" << mk_pp(res, m) << "\n";);
TRACE(dl, tout << mk_pp(q, m) << "\n==>\n" << mk_pp(res, m) << "\n";);
}
void mk_quantifier_instantiation::collect_egraph(expr* e) {
@ -223,7 +223,7 @@ namespace datalog {
fml = m.mk_and(conjs.size(), conjs.data());
fml = m.mk_implies(fml, r.get_head());
TRACE("dl", r.display(m_ctx, tout); tout << mk_pp(fml, m) << "\n";);
TRACE(dl, r.display(m_ctx, tout); tout << mk_pp(fml, m) << "\n";);
rule_set added_rules(m_ctx);
proof_ref pr(m);

View file

@ -78,7 +78,7 @@ namespace datalog {
if (m_ready) {
m_deltas[0] = 0;
m_deltas[1] = var_cnt;
TRACE("dl",
TRACE(dl,
output_predicate(m_context, src.get_head(), tout << "unify rules ");
output_predicate(m_context, tgt.get_head(), tout << "\n");
tout << "\n";);
@ -88,7 +88,7 @@ namespace datalog {
void rule_unifier::apply(app * a, bool is_tgt, app_ref& res) {
expr_ref res_e(m);
TRACE("dl", output_predicate(m_context, a, tout); tout << "\n";);
TRACE(dl, output_predicate(m_context, a, tout); tout << "\n";);
m_subst.apply(2, m_deltas, expr_offset(a, is_tgt ? 0 : 1), res_e);
SASSERT(is_app(res_e.get()));
res = to_app(res_e.get());
@ -124,7 +124,7 @@ namespace datalog {
symbol combined_rule_name(comb_name.str());
res = m_rm.mk(new_head, tail.size(), tail.data(), tail_neg.data(), combined_rule_name, m_normalize);
res->set_accounting_parent_object(m_context, const_cast<rule*>(&tgt));
TRACE("dl",
TRACE(dl,
tgt.display(m_context, tout << "tgt (" << tail_index << "): \n");
src.display(m_context, tout << "src:\n");
res->display(m_context, tout << "res\n");
@ -193,7 +193,7 @@ namespace datalog {
return true;
}
else {
TRACE("dl", res->display(m_context, tout << "interpreted tail is unsat\n"););
TRACE(dl, res->display(m_context, tout << "interpreted tail is unsat\n"););
//the interpreted part is unsatisfiable
return false;
}
@ -392,7 +392,7 @@ namespace datalog {
if (forbid_multiple_multipliers(orig, *candidate_inlined_set))
candidate_inlined_set = create_allowed_rule_set(orig);
TRACE("dl", tout<<"rules to be inlined:\n" << (*candidate_inlined_set); );
TRACE(dl, tout<<"rules to be inlined:\n" << (*candidate_inlined_set); );
// now we start filling in the set of the inlined rules in a topological order,
// so that we inline rules into other rules
@ -407,7 +407,7 @@ namespace datalog {
for (rule * r : candidate_inlined_set->get_predicate_rules(pred))
transform_rule(orig, r, m_inlined_rules);
}
TRACE("dl", tout << "inlined rules after mutual inlining:\n" << m_inlined_rules; );
TRACE(dl, tout << "inlined rules after mutual inlining:\n" << m_inlined_rules; );
for (rule * r : m_inlined_rules)
datalog::del_rule(m_mc, *r, l_undef);
@ -425,7 +425,7 @@ namespace datalog {
unsigned i = 0;
for (; i < pt_len && !inlining_allowed(orig, r->get_decl(i)); ++i) {};
CTRACE("dl", has_quantifier(*r.get()), r->display(m_context, tout););
CTRACE(dl, has_quantifier(*r.get()), r->display(m_context, tout););
if (has_quantifier(*r.get())) {
tgt.add_rule(r);
continue;
@ -618,7 +618,7 @@ namespace datalog {
*/
bool mk_rule_inliner::visitor::operator()(expr* e) {
m_unifiers.append(m_positions.find(e));
TRACE("dl",
TRACE(dl,
tout << "unifier: " << (m_unifiers.empty()?0:m_unifiers.back());
tout << " num unifiers: " << m_unifiers.size();
tout << " num positions: " << m_positions.find(e).size() << "\n";
@ -661,7 +661,7 @@ namespace datalog {
if (source.is_output_predicate(headd) ||
m_preds_with_facts.contains(headd)) {
can_remove.set(i, false);
TRACE("dl", output_predicate(m_context, head, tout << "cannot remove: " << i << " "); tout << "\n";);
TRACE(dl, output_predicate(m_context, head, tout << "cannot remove: " << i << " "); tout << "\n";);
}
unsigned tl_sz = r->get_uninterpreted_tail_size();
@ -700,7 +700,7 @@ namespace datalog {
m_head_index.reset();
m_tail_index.reset();
TRACE("dl", rules->display(tout););
TRACE(dl, rules->display(tout););
rule_ref_vector acc(m_rm);
for (unsigned i = 0; i < sz; ++i) {
@ -742,14 +742,14 @@ namespace datalog {
rule_ref r(acc[i].get(), m_rm);
TRACE("dl", r->display(m_context, tout << "processing: " << i << "\n"););
TRACE(dl, r->display(m_context, tout << "processing: " << i << "\n"););
if (!valid.get(i)) {
TRACE("dl", tout << "invalid: " << i << "\n";);
TRACE(dl, tout << "invalid: " << i << "\n";);
break;
}
if (!can_expand.get(i)) {
TRACE("dl", tout << "cannot expand: " << i << "\n";);
TRACE(dl, tout << "cannot expand: " << i << "\n";);
break;
}
@ -757,36 +757,36 @@ namespace datalog {
m_head_index.unify(r->get_tail(0), m_head_visitor);
unsigned num_head_unifiers = m_head_visitor.get_unifiers().size();
if (num_head_unifiers != 1) {
TRACE("dl", tout << "no unique unifier " << num_head_unifiers << "\n";);
TRACE(dl, tout << "no unique unifier " << num_head_unifiers << "\n";);
break;
}
unsigned j = m_head_visitor.get_unifiers()[0];
if (!can_remove.get(j) || !valid.get(j) || i == j) {
TRACE("dl", tout << PRT(can_remove.get(j)) << " " << PRT(valid.get(j)) << " " << PRT(i != j) << "\n";);
TRACE(dl, tout << PRT(can_remove.get(j)) << " " << PRT(valid.get(j)) << " " << PRT(i != j) << "\n";);
break;
}
rule* r2 = acc.get(j);
// check that the head of r2 only unifies with this single body position.
TRACE("dl", output_predicate(m_context, r2->get_head(), tout << "unify head: "); tout << "\n";);
TRACE(dl, output_predicate(m_context, r2->get_head(), tout << "unify head: "); tout << "\n";);
m_tail_visitor.reset();
m_tail_index.unify(r2->get_head(), m_tail_visitor);
unsigned_vector const& tail_unifiers = m_tail_visitor.get_unifiers();
unsigned num_tail_unifiers = tail_unifiers.size();
SASSERT(!tail_unifiers.empty());
if (!allow_branching && num_tail_unifiers != 1) {
TRACE("dl", tout << "too many tails " << num_tail_unifiers << "\n";);
TRACE(dl, tout << "too many tails " << num_tail_unifiers << "\n";);
break;
}
rule_ref rl_res(m_rm);
if (!try_to_inline_rule(*r.get(), *r2, 0, rl_res)) {
TRACE("dl", r->display(m_context, tout << "inlining failed\n"); r2->display(m_context, tout); );
TRACE(dl, r->display(m_context, tout << "inlining failed\n"); r2->display(m_context, tout); );
break;
}
done_something = true;
TRACE("dl", r->display(m_context, tout); r2->display(m_context, tout); rl_res->display(m_context, tout); );
TRACE(dl, r->display(m_context, tout); r2->display(m_context, tout); rl_res->display(m_context, tout); );
del_rule(r, i);
add_rule(*rules, rl_res.get(), i);
@ -797,7 +797,7 @@ namespace datalog {
can_expand.set(i, can_expand.get(j));
if (num_tail_unifiers == 1) {
TRACE("dl", tout << "setting invalid: " << j << "\n";);
TRACE(dl, tout << "setting invalid: " << j << "\n";);
valid.set(j, false);
datalog::del_rule(m_mc, *r2, l_undef);
del_rule(r2, j);
@ -816,7 +816,7 @@ namespace datalog {
}
}
res->inherit_predicates(*rules);
TRACE("dl", res->display(tout););
TRACE(dl, res->display(tout););
rules = res.detach();
}
return done_something;
@ -843,7 +843,7 @@ namespace datalog {
scoped_ptr<rule_set> res = alloc(rule_set, m_context);
if (m_context.get_params().xform_inline_eager()) {
TRACE("dl", source.display(tout << "before eager inlining\n"););
TRACE(dl, source.display(tout << "before eager inlining\n"););
plan_inlining(source);
try {
something_done = transform_rules(source, *res);
@ -856,7 +856,7 @@ namespace datalog {
if (do_eager_inlining(res)) {
something_done = true;
}
TRACE("dl", res->display(tout << "after eager inlining\n"););
TRACE(dl, res->display(tout << "after eager inlining\n"););
}
if (something_done) {
res->inherit_predicates(source);

View file

@ -49,7 +49,7 @@ namespace datalog {
expr_ref tmp(m);
if (!new_fi) {
TRACE("dl", tout << new_p->get_name() << " has no value in the current model\n";);
TRACE(dl, tout << new_p->get_name() << " has no value in the current model\n";);
continue;
}
for (unsigned i = 0; i < old_p->get_arity(); ++i) {
@ -88,7 +88,7 @@ namespace datalog {
}
}
md = old_model;
//TRACE("dl", model_smt2_pp(tout, m, *md, 0); );
//TRACE(dl, model_smt2_pp(tout, m, *md, 0); );
}
model_converter * translate(ast_translation & translator) override {
@ -155,7 +155,7 @@ namespace datalog {
result->set_output_predicate(new_rule->get_decl());
}
}
TRACE("dl", result->display(tout););
TRACE(dl, result->display(tout););
if (m_mc) {
m_ctx.add_model_converter(m_mc);
}

View file

@ -121,7 +121,7 @@ namespace datalog {
for (; it != end; ++it) {
rm.to_formula(*it->m_value, fml);
m_pinned_exprs.push_back(fml);
TRACE("dl",
TRACE(dl,
tout << "orig: " << mk_pp(fml, m) << "\n";
it->m_value->display(m_ctx, tout << "new:\n"););
m_sliceform2rule.insert(fml, it->m_key);
@ -146,7 +146,7 @@ namespace datalog {
else {
m_new_proof.insert(p, p);
m_todo.pop_back();
TRACE("dl", tout << "unhandled proof term\n" << mk_pp(p, m) << "\n";);
TRACE(dl, tout << "unhandled proof term\n" << mk_pp(p, m) << "\n";);
}
}
pr = m_new_proof.find(pr);
@ -159,7 +159,7 @@ namespace datalog {
return false;
}
if (!m_sliceform2rule.find(fact, r)) {
TRACE("dl", tout << "does not have fact\n" << mk_pp(fact, m) << "\n";);
TRACE(dl, tout << "does not have fact\n" << mk_pp(fact, m) << "\n";);
return false;
}
proof_ref new_p(m);
@ -199,7 +199,7 @@ namespace datalog {
proof* p0 = to_app(p->get_arg(0));
proof* p0_new = m_new_proof.find(p0);
expr* fact0 = m.get_fact(p0);
TRACE("dl", tout << "fact0: " << mk_pp(fact0, m) << "\n";);
TRACE(dl, tout << "fact0: " << mk_pp(fact0, m) << "\n";);
rule* orig0;
if (!m_sliceform2rule.find(fact0, orig0)) {
return false;
@ -212,7 +212,7 @@ namespace datalog {
proof* p1 = to_app(p->get_arg(i));
proof* p1_new = m_new_proof.find(p1);
expr* fact1 = m.get_fact(p1);
TRACE("dl", tout << "fact1: " << mk_pp(fact1, m) << "\n";);
TRACE(dl, tout << "fact1: " << mk_pp(fact1, m) << "\n";);
rule* orig1 = nullptr;
if (!m_sliceform2rule.find(fact1, orig1)) {
return false;
@ -231,7 +231,7 @@ namespace datalog {
// size of substitutions may have grown...substs[j].resize(num_args[j]);
}
substs.push_back(m_unifier.get_rule_subst(*r2.get(), false));
TRACE("dl",
TRACE(dl,
r1->display(m_ctx, tout << "rule1:");
r2->display(m_ctx, tout << "rule2:");
r3->display(m_ctx, tout << "res:"););
@ -241,7 +241,7 @@ namespace datalog {
proof* new_p = m.mk_hyper_resolve(premises.size(), premises.data(), concl, positions, substs);
m_pinned_exprs.push_back(new_p);
m_pinned_rules.push_back(r1.get());
TRACE("dl",
TRACE(dl,
tout << "orig: " << mk_pp(slice_concl, m) << "\n";
r1->display(m_ctx, tout << "new:"););
m_sliceform2rule.insert(slice_concl, r1.get());
@ -249,7 +249,7 @@ namespace datalog {
m_renaming.insert(r1.get(), unsigned_vector());
m_new_proof.insert(p, new_p);
m_todo.pop_back();
TRACE("dl", tout << "translated:\n" << mk_pp(p, m) << "\nto\n" << mk_pp(new_p, m) << "\n";);
TRACE(dl, tout << "translated:\n" << mk_pp(p, m) << "\nto\n" << mk_pp(new_p, m) << "\n";);
return true;
}
@ -316,7 +316,7 @@ namespace datalog {
if (m_slice2old.empty()) {
return;
}
TRACE("dl", model_smt2_pp(tout, m, *md, 0); );
TRACE(dl, model_smt2_pp(tout, m, *md, 0); );
model_ref old_model = alloc(model, m);
for (auto [new_p, old_p] : m_slice2old) {
bit_vector const& is_sliced = m_sliceable.find(old_p);
@ -324,7 +324,7 @@ namespace datalog {
SASSERT(is_sliced.size() > new_p->get_arity());
func_interp* old_fi = alloc(func_interp, m, is_sliced.size());
TRACE("dl", tout << mk_pp(old_p, m) << " " << mk_pp(new_p, m) << "\n";
TRACE(dl, tout << mk_pp(old_p, m) << " " << mk_pp(new_p, m) << "\n";
for (unsigned j = 0; j < is_sliced.size(); ++j) {
tout << (is_sliced.get(j)?"1":"0");
}
@ -344,12 +344,12 @@ namespace datalog {
}
func_interp* new_fi = md->get_func_interp(new_p);
if (!new_fi) {
TRACE("dl", tout << new_p->get_name() << " has no value in the current model\n";);
TRACE(dl, tout << new_p->get_name() << " has no value in the current model\n";);
dealloc(old_fi);
continue;
}
if (!new_fi->is_partial()) {
TRACE("dl", tout << mk_pp(new_fi->get_else(), m) << "\n";);
TRACE(dl, tout << mk_pp(new_fi->get_else(), m) << "\n";);
tmp = vs(new_fi->get_else(), subst.size(), subst.data());
old_fi->set_else(tmp);
}
@ -391,7 +391,7 @@ namespace datalog {
}
}
md = old_model;
TRACE("dl", model_smt2_pp(tout, m, *md, 0); );
TRACE(dl, model_smt2_pp(tout, m, *md, 0); );
}
model_converter * translate(ast_translation & translator) override {
@ -466,15 +466,15 @@ namespace datalog {
expr_ref rhs(m);
unsigned v = 0;
if (is_eq(e, v, rhs) && is_output(v) && m_var_is_sliceable[v]) {
TRACE("dl", tout << "is_eq: " << mk_pp(e, m) << " " << (m_solved_vars[v].get()?"solved":"new") << "\n";);
TRACE(dl, tout << "is_eq: " << mk_pp(e, m) << " " << (m_solved_vars[v].get()?"solved":"new") << "\n";);
add_var(v);
if (!m_solved_vars[v].get()) {
TRACE("dl", tout << "#" << v << " is solved\n";);
TRACE(dl, tout << "#" << v << " is solved\n";);
add_free_vars(parameter_vars, rhs);
m_solved_vars[v] = rhs;
}
else {
TRACE("dl", tout << "#" << v << " is used\n";);
TRACE(dl, tout << "#" << v << " is used\n";);
// variables can only be solved once.
add_free_vars(used_vars, e);
add_free_vars(used_vars, m_solved_vars[v].get());
@ -489,7 +489,7 @@ namespace datalog {
bool mk_slice::prune_rule(rule& r) {
TRACE("dl", r.display(m_ctx, tout << "prune:\n"); );
TRACE(dl, r.display(m_ctx, tout << "prune:\n"); );
bool change = false;
init_vars(r);
//
@ -503,7 +503,7 @@ namespace datalog {
if (!is_var(p->get_arg(i)) && bv.get(i)) {
bv.unset(i);
change = true;
TRACE("dl", tout << "argument " << i << " is not a variable " << p->get_decl()->get_name() << "\n";);
TRACE(dl, tout << "argument " << i << " is not a variable " << p->get_decl()->get_name() << "\n";);
}
}
}
@ -524,7 +524,7 @@ namespace datalog {
// or are used to solve output sliceable variables, or
// don't occur in interpreted tail.
//
TRACE("dl", tout << "num vars " << num_vars() << "\n");
TRACE(dl, tout << "num vars " << num_vars() << "\n");
for (unsigned i = 0; i < num_vars(); ++i) {
if (!m_var_is_sliceable[i]) {
continue;
@ -535,7 +535,7 @@ namespace datalog {
}
bool is_input = m_input[i];
bool is_output = m_output[i];
TRACE("dl", tout << "#"<< i << " " << is_input << " " << is_output << " solved: " << mk_pp(m_solved_vars.get(i), m) << "\n");
TRACE(dl, tout << "#"<< i << " " << is_input << " " << is_output << " solved: " << mk_pp(m_solved_vars.get(i), m) << "\n");
if (is_input && is_output) {
if (m_solved_vars.get(i))
m_var_is_sliceable[i] = false;
@ -646,7 +646,7 @@ namespace datalog {
bit_vector& bv = get_predicate_slice(p);
for (unsigned i = 0; i < p->get_num_args(); ++i) {
if (is_neg_tail) {
TRACE("dl", tout << "negated " << i << " in " << p->get_decl()->get_name() << "\n";);
TRACE(dl, tout << "negated " << i << " in " << p->get_decl()->get_name() << "\n";);
bv.unset(i);
}
expr* arg = p->get_arg(i);
@ -663,7 +663,7 @@ namespace datalog {
}
else {
SASSERT(m.is_value(arg));
TRACE("dl", tout << i << " in " << p->get_decl()->get_name() << " is a value, unable to slice\n";);
TRACE(dl, tout << i << " in " << p->get_decl()->get_name() << " is a value, unable to slice\n";);
bv.unset(i);
}
}
@ -677,7 +677,7 @@ namespace datalog {
if (is_var(arg) && !m_var_is_sliceable[to_var(arg)->get_idx()] && bv.get(i)) {
bv.unset(i);
change = true;
TRACE("dl", tout << "variable is unslicable " << mk_pp(arg, m) << " for index " << i << " in " << p->get_decl()->get_name() << "\n";);
TRACE(dl, tout << "variable is unslicable " << mk_pp(arg, m) << " for index " << i << " in " << p->get_decl()->get_name() << "\n";);
}
}
return change;
@ -798,7 +798,7 @@ namespace datalog {
rm.fix_unbound_vars(new_rule, false);
TRACE("dl", r.display(m_ctx, tout << "replacing:\n"); new_rule->display(m_ctx, tout << "by:\n"););
TRACE(dl, r.display(m_ctx, tout << "replacing:\n"); new_rule->display(m_ctx, tout << "by:\n"););
if (m_ctx.generate_proof_trace()) {
rm.mk_rule_asserted_proof(*new_rule.get());
}
@ -844,9 +844,9 @@ namespace datalog {
// nothing could be sliced.
return nullptr;
}
TRACE("dl", display(tout););
TRACE(dl, display(tout););
update_rules(src, *result);
TRACE("dl", result->display(tout););
TRACE(dl, result->display(tout););
if (m_mc) {
obj_map<func_decl, bit_vector>::iterator it = m_sliceable.begin(), end = m_sliceable.end();
for (; it != end; ++it) {

View file

@ -247,7 +247,7 @@ namespace datalog {
}
m_context.add_model_converter(mc0);
}
TRACE("dl",
TRACE(dl,
tout << "original set size: "<<orig.get_num_rules()<<"\n"
<< "reduced set size: "<<tgt.get_num_rules()<<"\n"; );
return modified;

View file

@ -78,7 +78,7 @@ namespace datalog {
m_todo.push_back(ci);
m_map.insert(ci, cpred);
TRACE("dl", tout << "inserting: " << pred->get_name() << " " << arg_index << " for " << cpred->get_name() << "\n";);
TRACE(dl, tout << "inserting: " << pred->get_name() << " " << arg_index << " for " << cpred->get_name() << "\n";);
}
void mk_unbound_compressor::detect_tasks(rule_set const& source, unsigned rule_index) {
@ -103,7 +103,7 @@ namespace datalog {
if (is_var(arg, var_idx) &&
!tail_vars.contains(var_idx) &&
(1 == rm.get_counter().get(var_idx))) {
TRACE("dl", r->display(m_context, tout << "Compress: "););
TRACE(dl, r->display(m_context, tout << "Compress: "););
add_task(head_pred, i);
break;
//we compress out the unbound arguments one by one
@ -164,7 +164,7 @@ namespace datalog {
m_head_occurrence_ctr.dec(m_rules.get(rule_index)->get_decl());
unsigned new_size = m_rules.size() - 1;
rule* last_rule = m_rules.get(new_size);
TRACE("dl", tout << "remove\n"; r->display(m_context, tout);
TRACE(dl, tout << "remove\n"; r->display(m_context, tout);
tout << "shift\n"; last_rule->display(m_context, tout););
if (rule_index < new_size) {
m_rules.set(rule_index, last_rule);
@ -177,7 +177,7 @@ namespace datalog {
new_rule->set_accounting_parent_object(m_context, r);
m_head_occurrence_ctr.dec(m_rules.get(rule_index)->get_decl());
TRACE("dl", tout << "remove\n"; r->display(m_context, tout);
TRACE(dl, tout << "remove\n"; r->display(m_context, tout);
tout << "set\n"; new_rule->display(m_context, tout););
m_rules.set(rule_index, new_rule);
m_head_occurrence_ctr.inc(m_rules.get(rule_index)->get_decl());
@ -192,7 +192,7 @@ namespace datalog {
app * orig_dtail = r->get_tail(tail_index); //dtail ~ decompressed tail
c_info ci(orig_dtail->get_decl(), arg_index);
TRACE("dl", tout << "retrieving: " << ci.first->get_name() << " " << ci.second << "\n";);
TRACE(dl, tout << "retrieving: " << ci.first->get_name() << " " << ci.second << "\n";);
func_decl * dtail_pred = m_map.find(ci);
ptr_vector<expr> dtail_args;
@ -247,7 +247,7 @@ namespace datalog {
rule_ref new_rule = mk_decompression_rule(r, tail_index, arg_index);
unsigned new_rule_index = m_rules.size();
m_rules.push_back(new_rule);
TRACE("dl", r->display(m_context, tout); new_rule->display(m_context, tout); );
TRACE(dl, r->display(m_context, tout); new_rule->display(m_context, tout); );
m_context.get_rule_manager().mk_rule_rewrite_proof(*r, *new_rule.get());
m_head_occurrence_ctr.inc(new_rule->get_decl());
detect_tasks(source, new_rule_index);
@ -257,7 +257,7 @@ namespace datalog {
void mk_unbound_compressor::replace_by_decompression_rule(rule_set const& source, unsigned rule_index, unsigned tail_index, unsigned arg_index) {
rule * r = m_rules.get(rule_index);
rule_ref new_rule = mk_decompression_rule(r, tail_index, arg_index);
TRACE("dl", tout << "remove\n"; r->display(m_context, tout); tout << "set\n"; new_rule->display(m_context, tout););
TRACE(dl, tout << "remove\n"; r->display(m_context, tout); tout << "set\n"; new_rule->display(m_context, tout););
m_rules.set(rule_index, new_rule);
// we don't update the m_head_occurrence_ctr because the head predicate doesn't change
detect_tasks(source, rule_index);