mirror of
https://github.com/Z3Prover/z3
synced 2025-08-09 20:50:50 +00:00
move flatten functionality to asserted_formulas, sort variables in lut_finder
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
38d690650b
commit
8b23a1701a
9 changed files with 88 additions and 57 deletions
|
@ -57,7 +57,8 @@ asserted_formulas::asserted_formulas(ast_manager & m, smt_params & sp, params_re
|
|||
m_find_macros(*this),
|
||||
m_propagate_values(*this),
|
||||
m_nnf_cnf(*this),
|
||||
m_apply_quasi_macros(*this) {
|
||||
m_apply_quasi_macros(*this),
|
||||
m_flatten_clauses(*this) {
|
||||
|
||||
m_macro_finder = alloc(macro_finder, m, m_macro_manager);
|
||||
|
||||
|
@ -267,6 +268,7 @@ void asserted_formulas::reduce() {
|
|||
if (!invoke(m_max_bv_sharing_fn)) return;
|
||||
if (!invoke(m_elim_bvs_from_quantifiers)) return;
|
||||
if (!invoke(m_reduce_asserted_formulas)) return;
|
||||
if (!invoke(m_flatten_clauses)) return;
|
||||
// if (!invoke(m_propagate_values)) return;
|
||||
|
||||
IF_VERBOSE(10, verbose_stream() << "(smt.simplifier-done)\n";);
|
||||
|
@ -344,6 +346,41 @@ void asserted_formulas::find_macros_core() {
|
|||
reduce_and_solve();
|
||||
}
|
||||
|
||||
/**
|
||||
\brief rewrite (a or (b & c)) to (a or b), (a or c) if the reference count of (b & c) is 1.
|
||||
This avoids the literal for (b & c)
|
||||
*/
|
||||
void asserted_formulas::flatten_clauses() {
|
||||
if (m.proofs_enabled()) return;
|
||||
bool change = true;
|
||||
vector<justified_expr> new_fmls;
|
||||
while (change) {
|
||||
change = false;
|
||||
new_fmls.reset();
|
||||
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(), *a = nullptr, *b = nullptr;
|
||||
bool decomposed = false;
|
||||
if (m.is_or(f, a, b) && m.is_not(b, b) && m.is_or(b) && b->get_ref_count() == 1) {
|
||||
decomposed = true;
|
||||
}
|
||||
else if (m.is_or(f, b, a) && m.is_not(b, b) && m.is_or(b) && b->get_ref_count() == 1) {
|
||||
decomposed = true;
|
||||
}
|
||||
if (decomposed) {
|
||||
for (expr* arg : *to_app(b)) {
|
||||
justified_expr j1(m, m.mk_or(a, m.is_not(arg, arg) ? arg : m.mk_not(arg)), nullptr);
|
||||
new_fmls.push_back(j1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
new_fmls.push_back(j);
|
||||
}
|
||||
swap_asserted_formulas(new_fmls);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void asserted_formulas::apply_quasi_macros() {
|
||||
TRACE("before_quasi_macros", display(tout););
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue