3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-09 20:50:50 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-04-06 19:43:32 -07:00
parent bd0620f245
commit 9bb579c5c8
2 changed files with 12 additions and 6 deletions

View file

@ -366,7 +366,7 @@ namespace datalog {
*/ */
table_base * table_base::complement(func_decl* p, const table_element * func_columns) const { table_base * table_base::complement(func_decl* p, const table_element * func_columns) const {
const table_signature & sig = get_signature(); const table_signature & sig = get_signature();
SASSERT(sig.functional_columns()==0 || func_columns!=0); SASSERT(sig.functional_columns() == 0 || func_columns != 0);
SASSERT(sig.first_functional() <= 1); SASSERT(sig.first_functional() <= 1);
table_base * res = get_plugin().mk_empty(sig); table_base * res = get_plugin().mk_empty(sig);
@ -377,6 +377,8 @@ namespace datalog {
if (sig.first_functional() == 0) { if (sig.first_functional() == 0) {
if (empty()) { if (empty()) {
if (fact.empty())
throw default_exception("empty relations cannot be complemented");
res->add_fact(fact); res->add_fact(fact);
} }
return res; return res;

View file

@ -260,7 +260,7 @@ namespace datalog {
unsigned bitvector_table::fact2offset(const table_element* f) const { unsigned bitvector_table::fact2offset(const table_element* f) const {
unsigned result = 0; unsigned result = 0;
for (unsigned i = 0; i < m_num_cols; ++i) { for (unsigned i = 0; i < m_num_cols; ++i) {
SASSERT(f[i]<get_signature()[i]); SASSERT(f[i] < get_signature()[i]);
result += ((unsigned)f[i]) << m_shift[i]; result += ((unsigned)f[i]) << m_shift[i];
} }
return result; return result;
@ -274,15 +274,19 @@ namespace datalog {
} }
void bitvector_table::add_fact(const table_fact & f) { void bitvector_table::add_fact(const table_fact & f) {
m_bv.set(fact2offset(f.c_ptr())); if (m_num_cols > 0) {
m_bv.set(fact2offset(f.c_ptr()));
}
} }
void bitvector_table::remove_fact(const table_element* fact) { void bitvector_table::remove_fact(const table_element* fact) {
m_bv.unset(fact2offset(fact)); if (m_num_cols > 0) {
m_bv.unset(fact2offset(fact));
}
} }
bool bitvector_table::contains_fact(const table_fact & f) const { bool bitvector_table::contains_fact(const table_fact & f) const {
return m_bv.get(fact2offset(f.c_ptr())); return !f.empty() && m_bv.get(fact2offset(f.c_ptr()));
} }
table_base::iterator bitvector_table::begin() const { table_base::iterator bitvector_table::begin() const {