mirror of
https://github.com/Z3Prover/z3
synced 2025-08-15 07:15:26 +00:00
use intervals for tracking bounds on arithmetic variables
leverage interval propagation for bounds. merge functionality with propagate-ineqs tactic remove the new propagate-bounds tactic and instead use propagate-ineqs
This commit is contained in:
parent
eb751bec4c
commit
d9f9cceea4
7 changed files with 444 additions and 764 deletions
|
@ -23,25 +23,26 @@ Description:
|
|||
#include "ast/rewriter/th_rewriter.h"
|
||||
#include "ast/simplifiers/dependent_expr_state.h"
|
||||
#include "ast/simplifiers/bound_propagator.h"
|
||||
#include "math/interval/interval.h"
|
||||
#include "math/interval/dep_intervals.h"
|
||||
|
||||
|
||||
class bound_simplifier : public dependent_expr_simplifier {
|
||||
typedef interval_manager<im_default_config> _interval_manager;
|
||||
typedef _interval_manager::interval interval;
|
||||
typedef _scoped_interval<_interval_manager> scoped_interval;
|
||||
typedef bound_propagator::var a_var;
|
||||
typedef numeral_buffer<mpq, unsynch_mpq_manager> mpq_buffer;
|
||||
typedef svector<a_var> var_buffer;
|
||||
|
||||
arith_util a;
|
||||
params_ref m_params;
|
||||
th_rewriter m_rewriter;
|
||||
unsynch_mpq_manager nm;
|
||||
small_object_allocator m_alloc;
|
||||
bound_propagator bp;
|
||||
im_default_config i_cfg;
|
||||
_interval_manager i_manager;
|
||||
unsigned m_num_vars = 0;
|
||||
dep_intervals m_interval;
|
||||
ptr_vector<expr> m_var2expr;
|
||||
unsigned_vector m_expr2var;
|
||||
bool m_updated = false;
|
||||
mpq_buffer m_num_buffer;
|
||||
var_buffer m_var_buffer;
|
||||
unsigned m_num_reduced = 0;
|
||||
|
||||
struct rw_cfg;
|
||||
struct rw;
|
||||
|
@ -62,20 +63,27 @@ class bound_simplifier : public dependent_expr_simplifier {
|
|||
unsigned to_var(expr* e) {
|
||||
unsigned v = m_expr2var.get(e->get_id(), UINT_MAX);
|
||||
if (v == UINT_MAX) {
|
||||
v = m_num_vars++;
|
||||
v = m_var2expr.size();
|
||||
bp.mk_var(v, a.is_int(e));
|
||||
m_expr2var.setx(e->get_id(), v, UINT_MAX);
|
||||
m_var2expr.setx(v, e, nullptr);
|
||||
m_var2expr.push_back(e);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
br_status reduce_app(func_decl* f, unsigned num_args, expr* const* args, expr_ref& result, proof_ref& pr);
|
||||
|
||||
void assert_lower(expr* x, rational const& n, bool strict);
|
||||
void assert_upper(expr* x, rational const& n, bool strict);
|
||||
|
||||
bool has_upper(expr* x, rational& n, bool& strict);
|
||||
bool has_lower(expr* x, rational& n, bool& strict);
|
||||
void get_bounds(expr* x, scoped_interval&);
|
||||
void get_bounds(expr* x, scoped_dep_interval&);
|
||||
|
||||
void expr2linear_pol(expr* t, mpq_buffer& as, var_buffer& xs);
|
||||
bool lower_subsumed(expr* p, mpq const& k, bool strict);
|
||||
bool upper_subsumed(expr* p, mpq const& k, bool strict);
|
||||
void restore_bounds();
|
||||
|
||||
// e = x + offset
|
||||
bool is_offset(expr* e, expr* x, rational& offset);
|
||||
|
@ -87,14 +95,35 @@ public:
|
|||
a(m),
|
||||
m_rewriter(m),
|
||||
bp(nm, m_alloc, p),
|
||||
i_cfg(nm),
|
||||
i_manager(m.limit(), im_default_config(nm)) {
|
||||
m_interval(m.limit()),
|
||||
m_num_buffer(nm) {
|
||||
updt_params(p);
|
||||
}
|
||||
|
||||
char const* name() const override { return "bounds-simplifier"; }
|
||||
char const* name() const override { return "propagate-ineqs"; }
|
||||
|
||||
bool supports_proofs() const override { return false; }
|
||||
|
||||
void reduce() override;
|
||||
|
||||
void updt_params(params_ref const& p) override {
|
||||
m_params.append(p);
|
||||
bp.updt_params(m_params);
|
||||
}
|
||||
|
||||
void collect_param_descrs(param_descrs & r) override {
|
||||
bound_propagator::get_param_descrs(r);
|
||||
}
|
||||
|
||||
void collect_statistics(statistics& st) const override {
|
||||
st.update("bound-propagations", bp.get_num_propagations());
|
||||
st.update("bound-false-alarms", bp.get_num_false_alarms());
|
||||
st.update("bound-simplifications", m_num_reduced);
|
||||
}
|
||||
|
||||
void reset_statistics() override {
|
||||
m_num_reduced = 0;
|
||||
bp.reset_statistics();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue