mirror of
https://github.com/Z3Prover/z3
synced 2025-08-18 17:22:15 +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).
89 lines
2.8 KiB
C++
89 lines
2.8 KiB
C++
/*++
|
|
Copyright (c) 2006 Microsoft Corporation
|
|
|
|
Module Name:
|
|
|
|
well_sorted.cpp
|
|
|
|
Abstract:
|
|
|
|
<abstract>
|
|
|
|
Author:
|
|
|
|
Leonardo de Moura (leonardo) 2007-12-29.
|
|
|
|
Revision History:
|
|
|
|
--*/
|
|
|
|
#include<sstream>
|
|
#include "ast/for_each_expr.h"
|
|
#include "ast/well_sorted.h"
|
|
#include "ast/ast_ll_pp.h"
|
|
#include "ast/ast_pp.h"
|
|
#include "util/warning.h"
|
|
#include "ast/ast_smt2_pp.h"
|
|
|
|
namespace {
|
|
|
|
struct well_sorted_proc {
|
|
ast_manager & m_manager;
|
|
bool m_error;
|
|
|
|
well_sorted_proc(ast_manager & m):m_manager(m), m_error(false) {}
|
|
|
|
void operator()(var * v) {}
|
|
|
|
void operator()(quantifier * n) {
|
|
expr const * e = n->get_expr();
|
|
if (!is_lambda(n) && !m_manager.is_bool(e)) {
|
|
warning_msg("quantifier's body must be a boolean.");
|
|
m_error = true;
|
|
UNREACHABLE();
|
|
}
|
|
}
|
|
|
|
void operator()(app * n) {
|
|
unsigned num_args = n->get_num_args();
|
|
func_decl * decl = n->get_decl();
|
|
if (num_args != decl->get_arity() && !decl->is_associative() &&
|
|
!decl->is_right_associative() && !decl->is_left_associative()) {
|
|
TRACE(ws, tout << "unexpected number of arguments.\n" << mk_ismt2_pp(n, m_manager););
|
|
warning_msg("unexpected number of arguments.");
|
|
m_error = true;
|
|
return;
|
|
}
|
|
|
|
for (unsigned i = 0; i < num_args; i++) {
|
|
sort * actual_sort = n->get_arg(i)->get_sort();
|
|
sort * expected_sort = decl->is_associative() ? decl->get_domain(0) : decl->get_domain(i);
|
|
if (expected_sort != actual_sort) {
|
|
TRACE(tc, tout << "sort mismatch on argument #" << i << ".\n" << mk_ismt2_pp(n, m_manager);
|
|
tout << "Sort mismatch for argument " << i+1 << " of " << mk_ismt2_pp(n, m_manager, false) << "\n";
|
|
tout << "Expected sort: " << mk_pp(expected_sort, m_manager) << "\n";
|
|
tout << "Actual sort: " << mk_pp(actual_sort, m_manager) << "\n";
|
|
tout << "Function sort: " << mk_pp(decl, m_manager) << ".";
|
|
);
|
|
std::ostringstream strm;
|
|
strm << "Sort mismatch for argument " << i+1 << " of " << mk_ll_pp(n, m_manager, false) << "\n";
|
|
strm << "Expected sort: " << mk_pp(expected_sort, m_manager) << '\n';
|
|
strm << "Actual sort: " << mk_pp(actual_sort, m_manager) << '\n';
|
|
strm << "Function sort: " << mk_pp(decl, m_manager) << '.';
|
|
warning_msg("%s", std::move(strm).str().c_str());
|
|
m_error = true;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
bool is_well_sorted(ast_manager const & m, expr * n) {
|
|
well_sorted_proc p(const_cast<ast_manager&>(m));
|
|
for_each_expr(p, n);
|
|
return !p.m_error;
|
|
}
|
|
|
|
|