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

add tactic to eliminate enumeration sorts in favor of bit-vectors

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2016-07-23 14:11:21 -07:00
parent d9afcb4eaf
commit 083939ab0e
6 changed files with 362 additions and 3 deletions

View file

@ -933,6 +933,25 @@ bool datatype_util::is_recursive(sort * ty) {
return r;
}
bool datatype_util::is_enum_sort(sort* s) {
if (!is_datatype(s)) {
return false;
}
bool r = false;
if (m_is_enum.find(s, r))
return r;
ptr_vector<func_decl> const& cnstrs = *get_datatype_constructors(s);
r = true;
for (unsigned i = 0; r && i < cnstrs.size(); ++i) {
r = cnstrs[i]->get_arity() == 0;
}
m_is_enum.insert(s, r);
m_asts.push_back(s);
return r;
}
void datatype_util::reset() {
m_datatype2constructors.reset();
m_datatype2nonrec_constructor.reset();
@ -941,6 +960,7 @@ void datatype_util::reset() {
m_recognizer2constructor.reset();
m_accessor2constructor.reset();
m_is_recursive.reset();
m_is_enum.reset();
std::for_each(m_vectors.begin(), m_vectors.end(), delete_proc<ptr_vector<func_decl> >());
m_vectors.reset();
m_asts.reset();

View file

@ -173,6 +173,7 @@ class datatype_util {
obj_map<func_decl, func_decl *> m_recognizer2constructor;
obj_map<func_decl, func_decl *> m_accessor2constructor;
obj_map<sort, bool> m_is_recursive;
obj_map<sort, bool> m_is_enum;
ast_ref_vector m_asts;
ptr_vector<ptr_vector<func_decl> > m_vectors;
@ -184,6 +185,8 @@ public:
~datatype_util();
ast_manager & get_manager() const { return m_manager; }
bool is_datatype(sort * s) const { return is_sort_of(s, m_family_id, DATATYPE_SORT); }
bool is_enum_sort(sort* s);
bool is_recursive(sort * ty);
bool is_constructor(func_decl * f) const { return is_decl_of(f, m_family_id, OP_DT_CONSTRUCTOR); }
bool is_recognizer(func_decl * f) const { return is_decl_of(f, m_family_id, OP_DT_RECOGNISER); }