mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 09:35:32 +00:00
add unit extraction
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
75ba65a18a
commit
718e5a9b6c
27 changed files with 207 additions and 76 deletions
|
@ -211,7 +211,35 @@ void solver::updt_params(params_ref const & p) {
|
|||
m_enforce_model_conversion = m_params.get_bool("solver.enforce_model_conversion", false);
|
||||
}
|
||||
|
||||
void solver::hoist_converter(model_converter_ref& mc) {
|
||||
|
||||
}
|
||||
|
||||
expr_ref_vector solver::get_units(ast_manager& m) {
|
||||
expr_ref_vector fmls(m), result(m), tmp(m);
|
||||
get_assertions(fmls);
|
||||
obj_map<expr, bool> units;
|
||||
for (expr* f : fmls) {
|
||||
if (m.is_not(f, f) && is_literal(m, f)) {
|
||||
m.inc_ref(f);
|
||||
units.insert(f, false);
|
||||
}
|
||||
else if (is_literal(m, f)) {
|
||||
m.inc_ref(f);
|
||||
units.insert(f, true);
|
||||
}
|
||||
}
|
||||
model_converter_ref mc = get_model_converter();
|
||||
if (mc) {
|
||||
mc->get_units(units);
|
||||
}
|
||||
for (auto const& kv : units) {
|
||||
tmp.push_back(kv.m_key);
|
||||
if (kv.m_value)
|
||||
result.push_back(kv.m_key);
|
||||
else
|
||||
result.push_back(m.mk_not(kv.m_key));
|
||||
}
|
||||
for (expr* e : tmp) {
|
||||
m.dec_ref(e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -203,6 +203,11 @@ public:
|
|||
|
||||
virtual model_converter_ref get_model_converter() const { return m_mc0; }
|
||||
|
||||
/**
|
||||
\brief extract units from solver.
|
||||
*/
|
||||
expr_ref_vector get_units(ast_manager& m);
|
||||
|
||||
class scoped_push {
|
||||
solver& s;
|
||||
bool m_nopop;
|
||||
|
@ -220,7 +225,6 @@ protected:
|
|||
|
||||
bool is_literal(ast_manager& m, expr* e);
|
||||
|
||||
void hoist_converter(model_converter_ref& mc);
|
||||
};
|
||||
|
||||
typedef ref<solver> solver_ref;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue