mirror of
https://github.com/Z3Prover/z3
synced 2026-01-22 01:54:44 +00:00
* 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).
106 lines
2.8 KiB
C++
106 lines
2.8 KiB
C++
/**++
|
|
Copyright (c) 2020 Arie Gurfinkel
|
|
|
|
Module Name:
|
|
|
|
spacer_arith_kernel.cpp
|
|
|
|
Abstract:
|
|
|
|
Compute kernel of a matrix
|
|
|
|
Author:
|
|
|
|
Hari Govind
|
|
Arie Gurfinkel
|
|
|
|
Notes:
|
|
|
|
--*/
|
|
|
|
#include "muz/spacer/spacer_arith_kernel.h"
|
|
|
|
#include "math/simplex/sparse_matrix_def.h"
|
|
#include "math/simplex/sparse_matrix_ops.h"
|
|
|
|
using namespace spacer;
|
|
|
|
bool spacer_arith_kernel::compute_kernel() {
|
|
SASSERT(m_matrix.num_rows() > 1);
|
|
|
|
if (false && m_matrix.compute_linear_deps(m_kernel)) {
|
|
// the matrix cannot be reduced further
|
|
if (m_matrix.num_cols() - m_kernel.num_rows() <= 1) return true;
|
|
|
|
m_kernel.reset(m_kernel.num_cols());
|
|
SASSERT(m_matrix.num_cols() > 2);
|
|
}
|
|
if (m_matrix.num_cols() > 2) m_st.m_failed++;
|
|
if (m_plugin /* && m_matrix.num_cols() > 2 */) {
|
|
return m_plugin->compute_kernel(m_matrix, m_kernel, m_basic_vars);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
namespace {
|
|
class simplex_arith_kernel_plugin : public spacer_arith_kernel::plugin {
|
|
public:
|
|
bool compute_kernel(const spacer_matrix &in, spacer_matrix &out,
|
|
vector<unsigned> &basics) override {
|
|
using qmatrix = simplex::sparse_matrix<simplex::mpq_ext>;
|
|
unsynch_mpq_manager m;
|
|
qmatrix qmat(m);
|
|
|
|
// extra column for column of 1
|
|
qmat.ensure_var(in.num_cols());
|
|
|
|
for (unsigned i = 0, n_rows = in.num_rows(); i < n_rows; ++i) {
|
|
auto row_id = qmat.mk_row();
|
|
unsigned j, n_cols;
|
|
for (j = 0, n_cols = in.num_cols(); j < n_cols; ++j) {
|
|
qmat.add_var(row_id, in.get(i, j).to_mpq(), j);
|
|
}
|
|
qmat.add_var(row_id, rational::one().to_mpq(), n_cols);
|
|
}
|
|
TRACE(gg, qmat.display(tout););
|
|
|
|
qmatrix kern(m);
|
|
simplex::sparse_matrix_ops::kernel_ffe<simplex::mpq_ext>(qmat, kern,
|
|
basics);
|
|
|
|
out.reset(kern.num_vars());
|
|
vector<rational> vec;
|
|
for (auto row : kern.get_rows()) {
|
|
vec.reset();
|
|
vec.reserve(kern.num_vars(), rational(0));
|
|
for (auto &[coeff, v] : kern.get_row(row)) {
|
|
vec[v] = rational(coeff);
|
|
}
|
|
out.add_row(vec);
|
|
}
|
|
|
|
TRACE(gg, {
|
|
tout << "Computed kernel\n";
|
|
qmat.display(tout);
|
|
tout << "\n";
|
|
kern.display(tout);
|
|
tout << "\n";
|
|
tout << "basics: " << basics << "\n";
|
|
out.display(tout);
|
|
});
|
|
return out.num_rows() > 0;
|
|
}
|
|
|
|
void collect_statistics(statistics &st) const override {}
|
|
void reset_statistics() override {}
|
|
void reset() override {}
|
|
};
|
|
|
|
} // namespace
|
|
|
|
namespace spacer {
|
|
|
|
spacer_arith_kernel::plugin *mk_simplex_kernel_plugin() {
|
|
return alloc(simplex_arith_kernel_plugin);
|
|
}
|
|
} // namespace spacer
|