3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 09:05:31 +00:00

working on separating horn simplificaiton

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2013-03-18 21:46:42 -07:00
parent 39b9da7118
commit 7e9f4e264d
14 changed files with 160 additions and 295 deletions

View file

@ -25,7 +25,7 @@ Revision History:
#include "bool_rewriter.h"
#include "var_subst.h"
#include "ast_pp.h"
#include "ast_counter.h"
//
// Bring quantifiers of common type into prenex form.
@ -215,6 +215,37 @@ private:
break;
}
}
unsigned pull_quantifier(bool is_forall, expr_ref& fml, svector<symbol>* names) {
unsigned index = var_counter().get_next_var(fml);
while (is_quantifier(fml) && (is_forall == to_quantifier(fml)->is_forall())) {
quantifier* q = to_quantifier(fml);
index += q->get_num_decls();
if (names) {
names->append(q->get_num_decls(), q->get_decl_names());
}
fml = q->get_expr();
}
if (!has_quantifiers(fml)) {
return index;
}
app_ref_vector vars(m);
pull_quantifier(is_forall, fml, vars);
if (vars.empty()) {
return index;
}
// replace vars by de-bruijn indices
expr_safe_replace rep(m);
for (unsigned i = 0; i < vars.size(); ++i) {
app* v = vars[i].get();
if (names) {
names->push_back(v->get_decl()->get_name());
}
rep.insert(v, m.mk_var(index++,m.get_sort(v)));
}
rep(fml);
return index;
}
};
quantifier_hoister::quantifier_hoister(ast_manager& m) {
@ -237,3 +268,7 @@ void quantifier_hoister::pull_quantifier(bool is_forall, expr_ref& fml, app_ref_
m_impl->pull_quantifier(is_forall, fml, vars);
}
unsigned quantifier_hoister::pull_quantifier(bool is_forall, expr_ref& fml, svector<symbol>* names) {
return m_impl->pull_quantifier(is_forall, fml, names);
}

View file

@ -59,6 +59,14 @@ public:
The list of variables is empty if there are no top-level universal/existential quantifier.
*/
void pull_quantifier(bool is_forall, expr_ref& fml, app_ref_vector& vars);
/**
\brief Pull top-most universal (is_forall true) or existential (is_forall=false) quantifier up.
Return an expression with de-Bruijn indices and the list of names that were used.
Return index of maximal variable.
*/
unsigned pull_quantifier(bool is_forall, expr_ref& fml, svector<symbol>* names);
};
#endif