virtual void assert_expr(expr * t, expr * a) { if (a) { m_asmsf.push_back(a); assert_expr(m.mk_implies(a, t)); } else { assert_expr(t); } }
void solver_na2as::assert_expr(expr * t, expr * a) { if (a == nullptr) { assert_expr(t); } else { SASSERT(is_uninterp_const(a)); SASSERT(m.is_bool(a)); TRACE("solver_na2as", tout << "asserting\n" << mk_ismt2_pp(t, m) << "\n" << mk_ismt2_pp(a, m) << "\n";); m_assumptions.push_back(a); expr_ref new_t(m); new_t = m.mk_implies(a, t); assert_expr(new_t); }
lbool check_sat(unsigned sz, expr * const * assumptions) override { m_solver.pop_to_base_level(); m_core.reset(); if (m_solver.inconsistent()) return l_false; expr_ref_vector _assumptions(m); obj_map<expr, expr*> asm2fml; for (unsigned i = 0; i < sz; ++i) { if (!is_literal(assumptions[i])) { expr_ref a(m.mk_fresh_const("s", m.mk_bool_sort()), m); expr_ref fml(m.mk_eq(a, assumptions[i]), m); assert_expr(fml); _assumptions.push_back(a); asm2fml.insert(a, assumptions[i]); } else { _assumptions.push_back(assumptions[i]); asm2fml.insert(assumptions[i], assumptions[i]); } } TRACE("sat", tout << _assumptions << "\n";);
void display_weighted(std::ostream& out, unsigned sz, expr * const * assumptions, unsigned const* weights) { if (weights != nullptr) { for (unsigned i = 0; i < sz; ++i) m_weights.push_back(weights[i]); } init_preprocess(); m_solver.pop_to_base_level(); dep2asm_t dep2asm; expr_ref_vector asms(m); for (unsigned i = 0; i < sz; ++i) { expr_ref a(m.mk_fresh_const("s", m.mk_bool_sort()), m); expr_ref fml(m.mk_implies(a, assumptions[i]), m); assert_expr(fml); asms.push_back(a); } VERIFY(l_true == internalize_formulas()); VERIFY(l_true == internalize_assumptions(sz, asms.c_ptr(), dep2asm)); svector<unsigned> nweights; for (unsigned i = 0; i < m_asms.size(); ++i) { nweights.push_back((unsigned) m_weights[i]); } m_weights.reset(); m_solver.display_wcnf(out, m_asms.size(), m_asms.c_ptr(), nweights.c_ptr()); }
void goal::assert_expr(expr * f, expr_dependency * d) { assert_expr(f, proofs_enabled() ? m().mk_asserted(f) : 0, d); }
lbool solver::get_consequences_core(expr_ref_vector const& asms, expr_ref_vector const& vars, expr_ref_vector& consequences) { ast_manager& m = asms.get_manager(); lbool is_sat = check_sat(asms); if (is_sat != l_true) { return is_sat; } model_ref model; get_model(model); expr_ref tmp(m), nlit(m), lit(m), val(m); expr_ref_vector asms1(asms); model_evaluator eval(*model.get()); unsigned k = 0; for (unsigned i = 0; i < vars.size(); ++i) { expr_ref_vector core(m); tmp = vars[i]; val = eval(tmp); if (!m.is_value(val)) { continue; } if (m.is_bool(tmp) && is_uninterp_const(tmp)) { if (m.is_true(val)) { nlit = m.mk_not(tmp); lit = tmp; } else if (m.is_false(val)) { nlit = tmp; lit = m.mk_not(tmp); } else { continue; } scoped_assumption_push _scoped_push(asms1, nlit); is_sat = check_sat(asms1); switch (is_sat) { case l_undef: return is_sat; case l_true: break; case l_false: get_unsat_core(core); k = 0; for (unsigned j = 0; j < core.size(); ++j) { if (core[j].get() != nlit) { core[k] = core[j].get(); ++k; } } core.resize(k); consequences.push_back(m.mk_implies(mk_and(core), lit)); break; } } else { lit = m.mk_eq(tmp, val); nlit = m.mk_not(lit); scoped_push _scoped_push(*this); assert_expr(nlit); is_sat = check_sat(asms); switch (is_sat) { case l_undef: return is_sat; case l_true: break; case l_false: get_unsat_core(core); consequences.push_back(m.mk_implies(mk_and(core), lit)); break; } } } return l_true; }