mirror of
https://github.com/Z3Prover/z3
synced 2025-06-28 08:58:44 +00:00
move from justified_expr to dependent_expr by aligning datatypes
This commit is contained in:
parent
fc9ff946b7
commit
decaee83f3
9 changed files with 52 additions and 51 deletions
|
@ -5,4 +5,5 @@ z3_add_component(solver_assertions
|
|||
smt2parser
|
||||
smt_params
|
||||
qe_lite
|
||||
solver
|
||||
)
|
||||
|
|
|
@ -184,7 +184,7 @@ void asserted_formulas::assert_expr(expr * e) {
|
|||
}
|
||||
|
||||
void asserted_formulas::get_assertions(ptr_vector<expr> & result) const {
|
||||
for (justified_expr const& je : m_formulas) result.push_back(je.get_fml());
|
||||
for (justified_expr const& je : m_formulas) result.push_back(je.fml());
|
||||
}
|
||||
|
||||
void asserted_formulas::push_scope() {
|
||||
|
@ -258,7 +258,7 @@ void asserted_formulas::finalize() {
|
|||
|
||||
bool asserted_formulas::check_well_sorted() const {
|
||||
for (justified_expr const& je : m_formulas) {
|
||||
if (!is_well_sorted(m, je.get_fml())) return false;
|
||||
if (!is_well_sorted(m, je.fml())) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ void asserted_formulas::display(std::ostream & out) const {
|
|||
for (unsigned i = 0; i < m_formulas.size(); i++) {
|
||||
if (i == m_qhead)
|
||||
out << "[HEAD] ==>\n";
|
||||
out << mk_pp(m_formulas[i].get_fml(), m) << "\n";
|
||||
out << mk_pp(m_formulas[i].fml(), m) << "\n";
|
||||
}
|
||||
out << "inconsistent: " << inconsistent() << "\n";
|
||||
}
|
||||
|
@ -356,10 +356,10 @@ void asserted_formulas::display(std::ostream & out) const {
|
|||
void asserted_formulas::display_ll(std::ostream & out, ast_mark & pp_visited) const {
|
||||
if (!m_formulas.empty()) {
|
||||
for (justified_expr const& f : m_formulas)
|
||||
ast_def_ll_pp(out, m, f.get_fml(), pp_visited, true, false);
|
||||
ast_def_ll_pp(out, m, f.fml(), pp_visited, true, false);
|
||||
out << "asserted formulas:\n";
|
||||
for (justified_expr const& f : m_formulas)
|
||||
out << "#" << f.get_fml()->get_id() << " ";
|
||||
out << "#" << f.fml()->get_id() << " ";
|
||||
out << "\n";
|
||||
}
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ void asserted_formulas::flatten_clauses() {
|
|||
unsigned sz = m_formulas.size();
|
||||
for (unsigned i = m_qhead; i < sz; ++i) {
|
||||
auto const& j = m_formulas.get(i);
|
||||
expr* f = j.get_fml();
|
||||
expr* f = j.fml();
|
||||
bool decomposed = false;
|
||||
if (m.is_or(f, a, b) && m.is_not(b, b) && m.is_or(b) && (b->get_ref_count() == 1 || is_literal(a))) {
|
||||
decomposed = true;
|
||||
|
@ -454,9 +454,9 @@ void asserted_formulas::nnf_cnf() {
|
|||
unsigned sz = m_formulas.size();
|
||||
TRACE("nnf_bug", tout << "i: " << i << " sz: " << sz << "\n";);
|
||||
for (; i < sz; i++) {
|
||||
expr * n = m_formulas[i].get_fml();
|
||||
expr * n = m_formulas[i].fml();
|
||||
TRACE("nnf_bug", tout << "processing:\n" << mk_pp(n, m) << "\n";);
|
||||
proof_ref pr(m_formulas[i].get_proof(), m);
|
||||
proof_ref pr(m_formulas[i].pr(), m);
|
||||
expr_ref r1(m);
|
||||
proof_ref pr1(m);
|
||||
push_todo.reset();
|
||||
|
@ -497,10 +497,10 @@ void asserted_formulas::simplify_fmls::operator()() {
|
|||
proof_ref result_pr(m);
|
||||
simplify(j, result, result_pr);
|
||||
if (m.proofs_enabled()) {
|
||||
if (!result_pr) result_pr = m.mk_rewrite(j.get_fml(), result);
|
||||
result_pr = m.mk_modus_ponens(j.get_proof(), result_pr);
|
||||
if (!result_pr) result_pr = m.mk_rewrite(j.fml(), result);
|
||||
result_pr = m.mk_modus_ponens(j.pr(), result_pr);
|
||||
}
|
||||
if (j.get_fml() == result) {
|
||||
if (j.fml() == result) {
|
||||
new_fmls.push_back(j);
|
||||
}
|
||||
else {
|
||||
|
@ -530,7 +530,7 @@ void asserted_formulas::commit(unsigned new_qhead) {
|
|||
m_macro_manager.mark_forbidden(new_qhead - m_qhead, m_formulas.data() + m_qhead);
|
||||
for (unsigned i = m_qhead; i < new_qhead; ++i) {
|
||||
justified_expr const& j = m_formulas[i];
|
||||
update_substitution(j.get_fml(), j.get_proof());
|
||||
update_substitution(j.fml(), j.pr());
|
||||
}
|
||||
m_qhead = new_qhead;
|
||||
}
|
||||
|
@ -575,17 +575,17 @@ void asserted_formulas::propagate_values() {
|
|||
}
|
||||
|
||||
unsigned asserted_formulas::propagate_values(unsigned i) {
|
||||
expr_ref n(m_formulas[i].get_fml(), m);
|
||||
expr_ref n(m_formulas[i].fml(), m);
|
||||
expr_ref new_n(m);
|
||||
proof_ref new_pr(m);
|
||||
m_rewriter(n, new_n, new_pr);
|
||||
if (m.proofs_enabled()) {
|
||||
proof * pr = m_formulas[i].get_proof();
|
||||
proof * pr = m_formulas[i].pr();
|
||||
new_pr = m.mk_modus_ponens(pr, new_pr);
|
||||
}
|
||||
justified_expr j(m, new_n, new_pr);
|
||||
m_formulas[i] = j;
|
||||
if (m.is_false(j.get_fml())) {
|
||||
if (m.is_false(j.fml())) {
|
||||
m_inconsistent = true;
|
||||
}
|
||||
update_substitution(new_n, new_pr);
|
||||
|
@ -670,26 +670,26 @@ proof * asserted_formulas::get_inconsistency_proof() const {
|
|||
if (!m.inc())
|
||||
return nullptr;
|
||||
for (justified_expr const& j : m_formulas) {
|
||||
if (m.is_false(j.get_fml()))
|
||||
return j.get_proof();
|
||||
if (m.is_false(j.fml()))
|
||||
return j.pr();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void asserted_formulas::refine_inj_axiom_fn::simplify(justified_expr const& j, expr_ref& n, proof_ref& p) {
|
||||
expr* f = j.get_fml();
|
||||
expr* f = j.fml();
|
||||
if (is_quantifier(f) && simplify_inj_axiom(m, to_quantifier(f), n)) {
|
||||
TRACE("inj_axiom", tout << "simplifying...\n" << mk_pp(f, m) << "\n" << n << "\n";);
|
||||
}
|
||||
else {
|
||||
n = j.get_fml();
|
||||
n = j.fml();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void asserted_formulas::bv_size_reduce_fn::simplify(justified_expr const& j, expr_ref& n, proof_ref& p) {
|
||||
bv_util bv(m);
|
||||
expr* f = j.get_fml();
|
||||
expr* f = j.fml();
|
||||
expr* a, *b, *x;
|
||||
unsigned lo, hi;
|
||||
rational r;
|
||||
|
@ -699,7 +699,7 @@ void asserted_formulas::bv_size_reduce_fn::simplify(justified_expr const& j, exp
|
|||
// insert x -> x[0,lo-1] ++ n into sub
|
||||
new_term = bv.mk_concat(b, bv.mk_extract(lo - 1, 0, x));
|
||||
m_sub.insert(x, new_term);
|
||||
n = j.get_fml();
|
||||
n = j.fml();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -708,7 +708,7 @@ void asserted_formulas::bv_size_reduce_fn::simplify(justified_expr const& j, exp
|
|||
// done
|
||||
}
|
||||
else {
|
||||
n = j.get_fml();
|
||||
n = j.fml();
|
||||
m_sub(n);
|
||||
}
|
||||
}
|
||||
|
@ -725,7 +725,7 @@ unsigned asserted_formulas::get_total_size() const {
|
|||
expr_mark visited;
|
||||
unsigned r = 0;
|
||||
for (justified_expr const& j : m_formulas)
|
||||
r += get_num_exprs(j.get_fml(), visited);
|
||||
r += get_num_exprs(j.fml(), visited);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ class asserted_formulas {
|
|||
class reduce_asserted_formulas_fn : public simplify_fmls {
|
||||
public:
|
||||
reduce_asserted_formulas_fn(asserted_formulas& af): simplify_fmls(af, "reduce-asserted") {}
|
||||
void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { af.m_rewriter(j.get_fml(), n, p); }
|
||||
void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { af.m_rewriter(j.fml(), n, p); }
|
||||
};
|
||||
|
||||
class find_macros_fn : public simplify_fmls {
|
||||
|
@ -122,7 +122,7 @@ class asserted_formulas {
|
|||
distribute_forall m_functor;
|
||||
public:
|
||||
distribute_forall_fn(asserted_formulas& af): simplify_fmls(af, "distribute-forall"), m_functor(af.m) {}
|
||||
void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { m_functor(j.get_fml(), n); }
|
||||
void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { m_functor(j.fml(), n); }
|
||||
bool should_apply() const override { return af.m_smt_params.m_distribute_forall && af.has_quantifiers(); }
|
||||
void post_op() override { af.reduce_and_solve(); TRACE("asserted_formulas", af.display(tout);); }
|
||||
};
|
||||
|
@ -131,7 +131,7 @@ class asserted_formulas {
|
|||
pattern_inference_rw m_infer;
|
||||
public:
|
||||
pattern_inference_fn(asserted_formulas& af): simplify_fmls(af, "pattern-inference"), m_infer(af.m, af.m_smt_params) {}
|
||||
void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { m_infer(j.get_fml(), n, p); }
|
||||
void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { m_infer(j.fml(), n, p); }
|
||||
bool should_apply() const override { return af.m_smt_params.m_ematching && af.has_quantifiers(); }
|
||||
};
|
||||
|
||||
|
@ -145,7 +145,7 @@ class asserted_formulas {
|
|||
class max_bv_sharing_fn : public simplify_fmls {
|
||||
public:
|
||||
max_bv_sharing_fn(asserted_formulas& af): simplify_fmls(af, "maximizing-bv-sharing") {}
|
||||
void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { af.m_bv_sharing(j.get_fml(), n, p); }
|
||||
void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { af.m_bv_sharing(j.fml(), n, p); }
|
||||
bool should_apply() const override { return af.m_smt_params.m_max_bv_sharing; }
|
||||
void post_op() override { af.m_reduce_asserted_formulas(); }
|
||||
};
|
||||
|
@ -164,7 +164,7 @@ class asserted_formulas {
|
|||
elim_term_ite_rw m_elim;
|
||||
public:
|
||||
elim_term_ite_fn(asserted_formulas& af): simplify_fmls(af, "elim-term-ite"), m_elim(af.m, af.m_defined_names) {}
|
||||
void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { m_elim(j.get_fml(), n, p); }
|
||||
void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { m_elim(j.fml(), n, p); }
|
||||
bool should_apply() const override { return af.m_smt_params.m_eliminate_term_ite && af.m_smt_params.m_lift_ite != lift_ite_kind::LI_FULL; }
|
||||
void post_op() override { af.m_formulas.append(m_elim.new_defs()); af.reduce_and_solve(); m_elim.reset(); }
|
||||
void push() { m_elim.push(); }
|
||||
|
@ -186,7 +186,7 @@ class asserted_formulas {
|
|||
FUNCTOR m_functor; \
|
||||
NAME(asserted_formulas& af):simplify_fmls(af, MSG), m_functor ARG {} \
|
||||
virtual void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) { \
|
||||
m_functor(j.get_fml(), n, p); \
|
||||
m_functor(j.fml(), n, p); \
|
||||
} \
|
||||
virtual void post_op() { if (REDUCE) af.reduce_and_solve(); } \
|
||||
virtual bool should_apply() const { return APP; } \
|
||||
|
@ -270,8 +270,8 @@ public:
|
|||
unsigned get_qhead() const { return m_qhead; }
|
||||
void commit();
|
||||
void commit(unsigned new_qhead);
|
||||
expr * get_formula(unsigned idx) const { return m_formulas[idx].get_fml(); }
|
||||
proof * get_formula_proof(unsigned idx) const { return m_formulas[idx].get_proof(); }
|
||||
expr * get_formula(unsigned idx) const { return m_formulas[idx].fml(); }
|
||||
proof * get_formula_proof(unsigned idx) const { return m_formulas[idx].pr(); }
|
||||
|
||||
params_ref const& get_params() const { return m_params; }
|
||||
void get_assertions(ptr_vector<expr> & result) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue