mirror of
https://github.com/Z3Prover/z3
synced 2025-08-17 16:52:15 +00:00
fixed-size min-heap for tracking top-k literals (#7752)
* very basic setup * ensure solve_eqs is fully disabled when smt.solve_eqs=false, #7743 Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * respect smt configuration parameter in elim_unconstrained simplifier Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * indentation * add bash files for test runs * add option to selectively disable variable solving for only ground expressions Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * remove verbose output Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * fix #7745 axioms for len(substr(...)) escaped due to nested rewriting * ensure atomic constraints are processed by arithmetic solver * #7739 optimization add simplification rule for at(x, offset) = "" Introducing j just postpones some rewrites that prevent useful simplifications. Z3 already uses common sub-expressions. The example highlights some opportunities for simplification, noteworthy at(..) = "". The example is solved in both versions after adding this simplification. * fix unsound len(substr) axiom Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * FreshConst is_sort (#7748) * #7750 add pre-processing simplification * Add parameter validation for selected API functions * updates to ac-plugin fix incrementality bugs by allowing destructive updates during saturation at the cost of redoing saturation after a pop. * enable passive, add check for bloom up-to-date * add top-k fixed-sized min-heap priority queue for top scoring literals --------- Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> Co-authored-by: Nikolaj Bjorner <nbjorner@microsoft.com> Co-authored-by: humnrdble <83878671+humnrdble@users.noreply.github.com>
This commit is contained in:
parent
a9b4e35938
commit
435ea6ea99
24 changed files with 762 additions and 303 deletions
|
@ -225,13 +225,15 @@ extern "C" {
|
|||
Z3_TRY;
|
||||
LOG_Z3_mk_fresh_func_decl(c, prefix, domain_size, domain, range);
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_IS_SORT(range, nullptr);
|
||||
CHECK_SORTS(domain_size, domain, nullptr);
|
||||
if (prefix == nullptr) {
|
||||
prefix = "";
|
||||
}
|
||||
|
||||
func_decl* d = mk_c(c)->m().mk_fresh_func_decl(prefix,
|
||||
domain_size,
|
||||
reinterpret_cast<sort*const*>(domain),
|
||||
to_sorts(domain),
|
||||
to_sort(range), false);
|
||||
|
||||
mk_c(c)->save_ast_trail(d);
|
||||
|
@ -243,9 +245,11 @@ extern "C" {
|
|||
Z3_TRY;
|
||||
LOG_Z3_mk_fresh_const(c, prefix, ty);
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_IS_SORT(ty, nullptr);
|
||||
if (prefix == nullptr) {
|
||||
prefix = "";
|
||||
}
|
||||
|
||||
app* a = mk_c(c)->m().mk_fresh_const(prefix, to_sort(ty), false);
|
||||
mk_c(c)->save_ast_trail(a);
|
||||
RETURN_Z3(of_ast(a));
|
||||
|
@ -654,6 +658,7 @@ extern "C" {
|
|||
Z3_TRY;
|
||||
LOG_Z3_get_sort_name(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_IS_SORT(t, of_symbol(symbol::null));
|
||||
CHECK_VALID_AST(t, of_symbol(symbol::null));
|
||||
return of_symbol(to_sort(t)->get_name());
|
||||
Z3_CATCH_RETURN(of_symbol(symbol::null));
|
||||
|
|
|
@ -286,10 +286,13 @@ namespace api {
|
|||
inline api::context * mk_c(Z3_context c) { return reinterpret_cast<api::context*>(c); }
|
||||
#define RESET_ERROR_CODE() { mk_c(c)->reset_error_code(); }
|
||||
#define SET_ERROR_CODE(ERR, MSG) { mk_c(c)->set_error_code(ERR, MSG); }
|
||||
#define CHECK_NON_NULL(_p_,_ret_) { if (_p_ == 0) { SET_ERROR_CODE(Z3_INVALID_ARG, "ast is null"); return _ret_; } }
|
||||
#define CHECK_VALID_AST(_a_, _ret_) { if (_a_ == 0 || !CHECK_REF_COUNT(_a_)) { SET_ERROR_CODE(Z3_INVALID_ARG, "not a valid ast"); return _ret_; } }
|
||||
#define CHECK_NON_NULL(_p_,_ret_) { if (_p_ == nullptr) { SET_ERROR_CODE(Z3_INVALID_ARG, "ast is null"); return _ret_; } }
|
||||
#define CHECK_VALID_AST(_a_, _ret_) { if (_a_ == nullptr || !CHECK_REF_COUNT(_a_)) { SET_ERROR_CODE(Z3_INVALID_ARG, "not a valid ast"); return _ret_; } }
|
||||
inline bool is_expr(Z3_ast a) { return is_expr(to_ast(a)); }
|
||||
#define CHECK_IS_EXPR(_p_, _ret_) { if (_p_ == 0 || !is_expr(_p_)) { SET_ERROR_CODE(Z3_INVALID_ARG, "ast is not an expression"); return _ret_; } }
|
||||
#define CHECK_IS_EXPR(_p_, _ret_) { if (_p_ == nullptr || !is_expr(_p_)) { SET_ERROR_CODE(Z3_INVALID_ARG, "ast is not an expression"); return _ret_; } }
|
||||
#define CHECK_IS_SORT(_p_, _ret_) { if (_p_ == nullptr || !is_sort(_p_)) { SET_ERROR_CODE(Z3_INVALID_ARG, "ast is not a sort"); return _ret_; } }
|
||||
#define CHECK_SORTS(_n_, _ps_, _ret_) { for (unsigned i = 0; i < _n_; ++i) if (!is_sort(_ps_[i])) { SET_ERROR_CODE(Z3_INVALID_ARG, "ast is not a sort"); return _ret_; } }
|
||||
|
||||
inline bool is_bool_expr(Z3_context c, Z3_ast a) { return is_expr(a) && mk_c(c)->m().is_bool(to_expr(a)); }
|
||||
#define CHECK_FORMULA(_a_, _ret_) { if (_a_ == 0 || !CHECK_REF_COUNT(_a_) || !is_bool_expr(c, _a_)) { SET_ERROR_CODE(Z3_INVALID_ARG, nullptr); return _ret_; } }
|
||||
#define CHECK_FORMULA(_a_, _ret_) { if (_a_ == nullptr || !CHECK_REF_COUNT(_a_) || !is_bool_expr(c, _a_)) { SET_ERROR_CODE(Z3_INVALID_ARG, nullptr); return _ret_; } }
|
||||
inline void check_sorts(Z3_context c, ast * n) { mk_c(c)->check_sorts(n); }
|
||||
|
|
|
@ -67,6 +67,7 @@ inline ast * const * to_asts(Z3_ast const* a) { return reinterpret_cast<ast* con
|
|||
|
||||
inline sort * to_sort(Z3_sort a) { return reinterpret_cast<sort*>(a); }
|
||||
inline Z3_sort of_sort(sort* s) { return reinterpret_cast<Z3_sort>(s); }
|
||||
inline bool is_sort(Z3_sort a) { return is_sort(to_sort(a)); }
|
||||
|
||||
inline sort * const * to_sorts(Z3_sort const* a) { return reinterpret_cast<sort* const*>(a); }
|
||||
inline Z3_sort const * of_sorts(sort* const* s) { return reinterpret_cast<Z3_sort const*>(s); }
|
||||
|
|
|
@ -1506,6 +1506,8 @@ def Consts(names, sort):
|
|||
|
||||
def FreshConst(sort, prefix="c"):
|
||||
"""Create a fresh constant of a specified sort"""
|
||||
if z3_debug():
|
||||
_z3_assert(is_sort(sort), f"Z3 sort expected, got {type(sort)}")
|
||||
ctx = _get_ctx(sort.ctx)
|
||||
return _to_expr_ref(Z3_mk_fresh_const(ctx.ref(), prefix, sort.ast), ctx)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue