void formula_compiler::compile_formulas(assertion_set const & assertions) { ast_manager & m = assertions.m(); expr_fast_mark2 axioms; mark_axioms(assertions, axioms); unmark_nested_atoms(assertions, axioms); ptr_vector<expr> formulas; // send axioms to theories, and save formulas to compile unsigned sz = assertions.size(); for (unsigned i = 0; i < sz; i++) { expr * f = assertions.form(i); bool neg = false; while (m.is_not(f, f)) neg = !neg; if (axioms.is_marked(f)) { assert_axiom(f, neg); } else { formulas.push_back(f); } } // compile formulas into sat::solver m_to_sat(m, formulas.size(), formulas.c_ptr(), s.m_params, *(s.m_sat), s.m_atom2bvar); // register atoms nested in the boolean structure in the theories atom2bool_var::recent_iterator it = s.m_atom2bvar.begin_recent(); atom2bool_var::recent_iterator end = s.m_atom2bvar.end_recent(); for (; it != end; ++it) { expr * atom = *it; register_atom(atom, s.m_atom2bvar.to_bool_var(atom)); } s.m_atom2bvar.reset_recent(); }
/** \brief Assert an assertion set s (owned by the external manager) */ void solver_exp::assert_set(assertion_set const & s) { SASSERT(&(s.m()) == &m_ext_mng); ast_translation translator(m_ext_mng, m, false); unsigned sz = s.size(); for (unsigned i = 0; i < sz; i++) { assert_expr_core(s.form(i), translator); } }
/** \brief Store in r the current set of assertions. r is (owned) by the external assertion set */ void solver_exp::get_assertions(assertion_set & r) { SASSERT(&(r.m()) == &m_ext_mng); ast_translation translator(m, m_ext_mng, false); unsigned sz = m_assertions.size(); for (unsigned i = 0; i < sz; i++) { expr * f = m_assertions.form(i); r.assert_expr(translator(f)); } }
/** \brief Unmark atoms that occur in the boolean structure. */ void formula_compiler::unmark_nested_atoms(assertion_set const & s, expr_fast_mark2 & axioms) { ast_manager & m = s.m(); expr_fast_mark1 visited; unmark_axioms_proc proc(axioms); unsigned sz = s.size(); for (unsigned i = 0; i < sz; i++) { expr * f = s.form(i); while (m.is_not(f, f)); if (axioms.is_marked(f)) continue; quick_for_each_expr(proc, visited, f); } }
void operator()(assertion_set & s, model_converter_ref & mc) { mc = 0; if (s.inconsistent()) return; as_st_report report("add-bounds", s); bound_manager bm(m); expr_fast_mark1 visited; add_bound_proc proc(bm, s, m_lower, m_upper); unsigned sz = s.size(); for (unsigned i = 0; i < sz; i++) quick_for_each_expr(proc, visited, s.form(i)); visited.reset(); report_st_progress(":added-bounds", proc.m_num_bounds); TRACE("add_bounds", s.display(tout););
/** \brief Assert expressions from ctx into t. */ void assert_exprs_from(cmd_context const & ctx, assertion_set & t) { ptr_vector<expr>::const_iterator it = ctx.begin_assertions(); ptr_vector<expr>::const_iterator end = ctx.end_assertions(); for (; it != end; ++it) { t.assert_expr(*it); } }
bool is_unbounded(assertion_set const & s) { ast_manager & m = s.m(); bound_manager bm(m); bm(s); is_unbounded_proc proc(bm); return test(s, proc); }
void operator()(assertion_set & s, model_converter_ref & mc) { mc = 0; if (s.inconsistent()) return; { as_st_report report("elim-term-ite", s); m_rw.m_cfg.m_num_fresh = 0; m_rw.m_cfg.m_set = &s; expr_ref new_curr(m); proof_ref new_pr(m); unsigned size = s.size(); for (unsigned idx = 0; idx < size; idx++) { expr * curr = s.form(idx); m_rw(curr, new_curr, new_pr); if (m.proofs_enabled()) { proof * pr = s.pr(idx); new_pr = m.mk_modus_ponens(pr, new_pr); } s.update(idx, new_curr, new_pr); } mc = m_rw.m_cfg.m_mc.get(); } report_st_progress(":elim-term-ite-consts", m_rw.m_cfg.m_num_fresh); }
br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) { if (!m.is_term_ite(f)) return BR_FAILED; expr_ref new_ite(m); new_ite = m.mk_app(f, num, args); expr_ref new_def(m); proof_ref new_def_pr(m); app_ref _result(m); if (m_defined_names.mk_name(new_ite, new_def, new_def_pr, _result, result_pr)) { m_set->assert_expr(new_def, new_def_pr); m_num_fresh++; if (m_produce_models) { if (!m_mc) m_mc = alloc(filter_model_converter, m); m_mc->insert(_result->get_decl()); } } result = _result.get(); return BR_DONE; }