3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-19 23:14:40 +00:00

improve logging

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
Lev Nachmanson 2025-11-20 10:51:39 -10:00 committed by Nikolaj Bjorner
parent 82958565ed
commit 8f97785498
6 changed files with 99 additions and 40 deletions

View file

@ -2772,9 +2772,12 @@ namespace algebraic_numbers {
return out;
}
std::ostream& display_root_smt2(std::ostream & out, numeral const & a) {
template<typename Printer>
std::ostream& display_root_common(std::ostream & out, numeral const & a, char const* var_name, bool no_power, Printer&& printer) {
SASSERT(var_name != nullptr);
if (is_zero(a)) {
out << "(root-obj x 1)";
auto poly_printer = [&](std::ostream& dst) { dst << var_name; };
return printer(out, poly_printer, 1u);
}
else if (a.is_basic()) {
mpq const & v = basic_value(a);
@ -2782,25 +2785,53 @@ namespace algebraic_numbers {
qm().set(neg_n, v.numerator());
qm().neg(neg_n);
mpz coeffs[2] = { std::move(neg_n), qm().dup(v.denominator()) };
out << "(root-obj ";
upm().display_smt2(out, 2, coeffs, "x");
out << " 1)"; // first root of the polynomial d*# - n
auto poly_printer = [&](std::ostream& dst) {
if (no_power)
upm().display_smt2_no_power(dst, 2, coeffs, var_name);
else
upm().display_smt2(dst, 2, coeffs, var_name);
};
std::ostream& r = printer(out, poly_printer, 1u); // first root of d*x - n
qm().del(coeffs[0]);
qm().del(coeffs[1]);
return r;
}
else {
algebraic_cell * c = a.to_algebraic();
out << "(root-obj ";
upm().display_smt2(out, c->m_p_sz, c->m_p, "x");
auto poly_printer = [&](std::ostream& dst) {
if (no_power)
upm().display_smt2_no_power(dst, c->m_p_sz, c->m_p, var_name);
else
upm().display_smt2(dst, c->m_p_sz, c->m_p, var_name);
};
if (c->m_i == 0) {
// undefined
c->m_i = upm().get_root_id(c->m_p_sz, c->m_p, lower(c)) + 1;
}
SASSERT(c->m_i > 0);
out << " " << c->m_i;
out << ")";
return printer(out, poly_printer, c->m_i);
}
return out;
}
std::ostream& display_root_smt2(std::ostream & out, numeral const & a) {
auto printer = [&](std::ostream& dst, auto const& poly_printer, unsigned idx) -> std::ostream& {
dst << "(root-obj ";
poly_printer(dst);
dst << " " << idx << ")";
return dst;
};
return display_root_common(out, a, "x", false, printer);
}
std::ostream& display_root_smtrat(std::ostream & out, numeral const & a, char const* var_name) {
SASSERT(var_name != nullptr);
auto printer = [&](std::ostream& dst, auto const& poly_printer, unsigned idx) -> std::ostream& {
dst << "(root ";
poly_printer(dst);
dst << " " << idx << " " << var_name << ")";
return dst;
};
return display_root_common(out, a, var_name, true, printer);
}
std::ostream& display_interval(std::ostream & out, numeral const & a) {
@ -3167,6 +3198,10 @@ namespace algebraic_numbers {
return m_imp->display_root_smt2(out, a);
}
std::ostream& manager::display_root_smtrat(std::ostream & out, numeral const & a, char const* var_name) const {
return m_imp->display_root_smtrat(out, a, var_name);
}
void manager::reset_statistics() {
m_imp->reset_statistics();
}