mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
wip - dependent expr simpliifer
- simplify iterator over current indices - add more simplifiers used by asserted_formulas - improve diagnostics printing
This commit is contained in:
parent
bec3acd146
commit
b084821a0c
25 changed files with 553 additions and 158 deletions
|
@ -22,9 +22,19 @@ Author:
|
|||
#include "ast/simplifiers/propagate_values.h"
|
||||
#include "ast/simplifiers/rewriter_simplifier.h"
|
||||
#include "ast/simplifiers/solve_eqs.h"
|
||||
#include "ast/simplifiers/bv_slice.h"
|
||||
#include "ast/simplifiers/eliminate_predicates.h"
|
||||
#include "ast/simplifiers/elim_unconstrained.h"
|
||||
#include "ast/simplifiers/pull_nested_quantifiers.h"
|
||||
#include "ast/simplifiers/distribute_forall.h"
|
||||
#include "ast/simplifiers/refine_inj_axiom.h"
|
||||
#include "ast/simplifiers/elim_bounds.h"
|
||||
#include "ast/simplifiers/bit2int.h"
|
||||
#include "ast/simplifiers/bv_elim.h"
|
||||
#include "sat/sat_params.hpp"
|
||||
#include "smt/params/smt_params.h"
|
||||
#include "sat/sat_solver/sat_smt_preprocess.h"
|
||||
#include "qe/lite/qe_lite.h"
|
||||
|
||||
void init_preprocess(ast_manager& m, params_ref const& p, seq_simplifier& s, dependent_expr_state& st) {
|
||||
params_ref simp1_p = p;
|
||||
|
@ -44,18 +54,38 @@ void init_preprocess(ast_manager& m, params_ref const& p, seq_simplifier& s, dep
|
|||
simp2_p.set_bool("flat_and_or", false);
|
||||
|
||||
sat_params sp(p);
|
||||
smt_params smtp(p);
|
||||
if (sp.euf() || sp.smt()) {
|
||||
s.add_simplifier(alloc(rewriter_simplifier, m, p, st));
|
||||
s.add_simplifier(alloc(propagate_values, m, p, st));
|
||||
s.add_simplifier(alloc(euf::solve_eqs, m, st));
|
||||
s.add_simplifier(alloc(elim_unconstrained, m, st));
|
||||
if (smtp.m_macro_finder || smtp.m_quasi_macros) s.add_simplifier(alloc(eliminate_predicates, m, st));
|
||||
if (smtp.m_qe_lite) s.add_simplifier(mk_qe_lite_simplifer(m, p, st));
|
||||
if (smtp.m_pull_nested_quantifiers) s.add_simplifier(alloc(pull_nested_quantifiers_simplifier, m, p, st));
|
||||
if (smtp.m_max_bv_sharing) s.add_simplifier(mk_max_bv_sharing(m, p, st));
|
||||
if (smtp.m_refine_inj_axiom) s.add_simplifier(alloc(refine_inj_axiom_simplifier, m, p, st));
|
||||
if (smtp.m_bv_size_reduce) s.add_simplifier(alloc(bv::slice, m, st));
|
||||
if (smtp.m_distribute_forall) s.add_simplifier(alloc(distribute_forall_simplifier, m, p, st));
|
||||
if (smtp.m_eliminate_bounds) s.add_simplifier(alloc(elim_bounds_simplifier, m, p, st));
|
||||
if (smtp.m_simplify_bit2int) s.add_simplifier(alloc(bit2int_simplifier, m, p, st));
|
||||
if (smtp.m_bb_quantifiers) s.add_simplifier(alloc(bv::elim_simplifier, m, p, st));
|
||||
//
|
||||
// add:
|
||||
// solve_eqs
|
||||
// elim_predicates
|
||||
// elim_uncnstr
|
||||
// euf_completion?
|
||||
//
|
||||
// add: make it externally configurable
|
||||
// add: make it externally programmable
|
||||
//
|
||||
#if 0
|
||||
?? if (!invoke(m_lift_ite)) return;
|
||||
m_lift_ite.m_functor.set_conservative(m_smt_params.m_lift_ite == lift_ite_kind::LI_CONSERVATIVE);
|
||||
m_ng_lift_ite.m_functor.set_conservative(m_smt_params.m_ng_lift_ite == lift_ite_kind::LI_CONSERVATIVE);
|
||||
?? if (!invoke(m_ng_lift_ite)) return;
|
||||
if (!invoke(m_elim_term_ite)) return;
|
||||
if (!invoke(m_apply_quasi_macros)) return;
|
||||
if (!invoke(m_flatten_clauses)) return;
|
||||
#endif
|
||||
|
||||
}
|
||||
else {
|
||||
s.add_simplifier(alloc(rewriter_simplifier, m, p, st));
|
||||
|
|
|
@ -60,6 +60,17 @@ class sat_smt_solver : public solver {
|
|||
void add(dependent_expr const& j) override { s.m_fmls.push_back(j); }
|
||||
bool inconsistent() override { return s.m_solver.inconsistent(); }
|
||||
model_reconstruction_trail& model_trail() override { return m_reconstruction_trail; }
|
||||
std::ostream& display(std::ostream& out) const override {
|
||||
unsigned i = 0;
|
||||
for (auto const& d : s.m_fmls) {
|
||||
if (i == qhead())
|
||||
out << "---- head ---\n";
|
||||
out << d << "\n";
|
||||
++i;
|
||||
}
|
||||
m_reconstruction_trail.display(out);
|
||||
return out;
|
||||
}
|
||||
void append(generic_model_converter& mc) { model_trail().append(mc); }
|
||||
void replay(unsigned qhead) { m_reconstruction_trail.replay(qhead, *this); }
|
||||
void flatten_suffix() override {
|
||||
|
@ -421,12 +432,10 @@ public:
|
|||
}
|
||||
|
||||
expr_ref_vector cube(expr_ref_vector& vs, unsigned backtrack_level) override {
|
||||
if (!is_internalized()) {
|
||||
lbool r = internalize_formulas();
|
||||
if (r != l_true) {
|
||||
IF_VERBOSE(0, verbose_stream() << "internalize produced " << r << "\n");
|
||||
return expr_ref_vector(m);
|
||||
}
|
||||
lbool r = internalize_formulas();
|
||||
if (r != l_true) {
|
||||
IF_VERBOSE(0, verbose_stream() << "internalize produced " << r << "\n");
|
||||
return expr_ref_vector(m);
|
||||
}
|
||||
convert_internalized();
|
||||
if (m_solver.inconsistent())
|
||||
|
@ -551,8 +560,7 @@ public:
|
|||
|
||||
void convert_internalized() {
|
||||
m_solver.pop_to_base_level();
|
||||
if (!is_internalized() && m_preprocess_state.qhead() > 0)
|
||||
internalize_formulas();
|
||||
internalize_formulas();
|
||||
if (!is_internalized() || m_internalized_converted)
|
||||
return;
|
||||
sat2goal s2g;
|
||||
|
@ -723,9 +731,8 @@ private:
|
|||
|
||||
for (unsigned v = 0; v < var2expr.size(); ++v) {
|
||||
expr * n = var2expr.get(v);
|
||||
if (!n || !is_uninterp_const(n)) {
|
||||
continue;
|
||||
}
|
||||
if (!n || !is_uninterp_const(n))
|
||||
continue;
|
||||
switch (sat::value_at(v, ll_m)) {
|
||||
case l_true:
|
||||
mdl->register_decl(to_app(n)->get_decl(), m.mk_true());
|
||||
|
@ -747,9 +754,8 @@ private:
|
|||
|
||||
TRACE("sat", model_smt2_pp(tout, m, *mdl, 0););
|
||||
|
||||
if (!gparams::get_ref().get_bool("model_validate", false)) {
|
||||
return;
|
||||
}
|
||||
if (!gparams::get_ref().get_bool("model_validate", false))
|
||||
return;
|
||||
IF_VERBOSE(1, verbose_stream() << "Verifying solution\n";);
|
||||
model_evaluator eval(*mdl);
|
||||
eval.set_model_completion(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue