3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-15 07:15:26 +00:00

Add new tactic bound-simplifier for integer-based bit-vector reasoning.

This commit is contained in:
Nikolaj Bjorner 2023-01-22 22:07:18 -08:00
parent 83662701b6
commit db79346ef7
14 changed files with 460 additions and 12 deletions

View file

@ -0,0 +1,90 @@
/*++
Copyright (c) 2022 Microsoft Corporation
Module Name:
bound_simplifier.h
Author:
Nikolaj Bjorner (nbjorner) 2023-01-22
Description:
Collects bounds of sub-expressions and uses them to simplify modulus
expressions.
propagate_ineqs_tactic handles other propagations with bounds.
--*/
#pragma once
#include "ast/arith_decl_plugin.h"
#include "ast/rewriter/th_rewriter.h"
#include "ast/simplifiers/dependent_expr_state.h"
#include "ast/simplifiers/bound_propagator.h"
class bound_simplifier : public dependent_expr_simplifier {
arith_util a;
th_rewriter m_rewriter;
unsynch_mpq_manager nm;
small_object_allocator m_alloc;
bound_propagator bp;
unsigned m_num_vars = 0;
ptr_vector<expr> m_var2expr;
unsigned_vector m_expr2var;
bool m_updated = false;
struct rw_cfg;
struct rw;
bool insert_bound(dependent_expr const& de);
void tighten_bound(dependent_expr const& de);
void reset();
expr* to_expr(unsigned v) const {
return m_var2expr.get(v, nullptr);
}
bool is_var(expr* e) const {
return UINT_MAX != m_expr2var.get(e->get_id(), UINT_MAX);
}
unsigned to_var(expr* e) {
unsigned v = m_expr2var.get(e->get_id(), UINT_MAX);
if (v == UINT_MAX) {
v = m_num_vars++;
bp.mk_var(v, a.is_int(e));
m_expr2var.setx(e->get_id(), v, UINT_MAX);
m_var2expr.setx(v, e, nullptr);
}
return v;
}
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);
// e = x + offset
bool is_offset(expr* e, expr* x, rational& offset);
public:
bound_simplifier(ast_manager& m, params_ref const& p, dependent_expr_state& fmls):
dependent_expr_simplifier(m, fmls),
a(m),
m_rewriter(m),
bp(nm, m_alloc, p) {
}
char const* name() const override { return "bounds-simplifier"; }
bool supports_proofs() const override { return false; }
void reduce() override;
};