3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-20 04:43:39 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-04-07 11:15:34 -07:00
parent 8dac9b7b94
commit b66360d0b5
5 changed files with 84 additions and 107 deletions

View file

@ -1088,6 +1088,7 @@ namespace opt {
if (D.is_zero()) { if (D.is_zero()) {
throw default_exception("modulo 0 is not defined"); throw default_exception("modulo 0 is not defined");
} }
if (D.is_neg()) D = abs(D);
TRACE("opt1", display(tout << "lcm: " << D << " x: v" << x << " tableau\n");); TRACE("opt1", display(tout << "lcm: " << D << " x: v" << x << " tableau\n"););
rational val_x = m_var2value[x]; rational val_x = m_var2value[x];
rational u = mod(val_x, D); rational u = mod(val_x, D);

View file

@ -39,10 +39,8 @@ namespace datalog {
} }
void dealloc_ptr_vector_content(ptr_vector<relation_base> & v) { void dealloc_ptr_vector_content(ptr_vector<relation_base> & v) {
ptr_vector<relation_base>::iterator it = v.begin(); for (auto& r : v) {
ptr_vector<relation_base>::iterator end = v.end(); r->deallocate();
for(; it!=end; ++it) {
(*it)->deallocate();
} }
} }
@ -77,7 +75,7 @@ namespace datalog {
unsigned sz = size(); unsigned sz = size();
out << "("; out << "(";
for (unsigned i = 0; i < sz; i++) { for (unsigned i = 0; i < sz; i++) {
if(i) { out<<","; } if (i != 0) out << ",";
out << mk_pp((*this)[i], m); out << mk_pp((*this)[i], m);
} }
out << ")"; out << ")";
@ -91,7 +89,7 @@ namespace datalog {
app_ref bottom_ref(m.mk_false(), m); app_ref bottom_ref(m.mk_false(), m);
scoped_ptr<relation_mutator_fn> reset_fn = get_manager().mk_filter_interpreted_fn(*this, bottom_ref); scoped_ptr<relation_mutator_fn> reset_fn = get_manager().mk_filter_interpreted_fn(*this, bottom_ref);
if (!reset_fn) { if (!reset_fn) {
NOT_IMPLEMENTED_YET(); throw default_exception("filter function does not exist");
} }
(*reset_fn)(*this); (*reset_fn)(*this);
} }
@ -227,9 +225,6 @@ namespace datalog {
} }
} }
// ----------------------------------- // -----------------------------------
// //
// table_base // table_base
@ -257,24 +252,18 @@ namespace datalog {
void table_base::reset() { void table_base::reset() {
vector<table_fact> to_remove; vector<table_fact> to_remove;
table_base::iterator it = begin();
table_base::iterator iend = end();
table_fact row; table_fact row;
for(; it!=iend; ++it) { for (auto& k : *this) {
it->get_fact(row); k.get_fact(row);
to_remove.push_back(row); to_remove.push_back(row);
} }
remove_facts(to_remove.size(), to_remove.c_ptr()); remove_facts(to_remove.size(), to_remove.c_ptr());
} }
bool table_base::contains_fact(const table_fact & f) const { bool table_base::contains_fact(const table_fact & f) const {
iterator it = begin();
iterator iend = end();
table_fact row; table_fact row;
for (auto const& k : *this) {
for(; it!=iend; ++it) { k.get_fact(row);
it->get_fact(row);
if (vectors_equal(row, f)) { if (vectors_equal(row, f)) {
return true; return true;
} }
@ -289,11 +278,9 @@ namespace datalog {
else { else {
unsigned sig_sz = get_signature().size(); unsigned sig_sz = get_signature().size();
unsigned non_func_cnt = sig_sz-get_signature().functional_columns(); unsigned non_func_cnt = sig_sz-get_signature().functional_columns();
table_base::iterator it = begin();
table_base::iterator iend = end();
table_fact row; table_fact row;
for(; it!=iend; ++it) { for (auto& k : *this) {
it->get_fact(row); k.get_fact(row);
bool differs = false; bool differs = false;
for (unsigned i=0; i<non_func_cnt; i++) { for (unsigned i=0; i<non_func_cnt; i++) {
if (row[i]!=f[i]) { if (row[i]!=f[i]) {
@ -341,14 +328,9 @@ namespace datalog {
table_base * table_base::clone() const { table_base * table_base::clone() const {
table_base * res = get_plugin().mk_empty(get_signature()); table_base * res = get_plugin().mk_empty(get_signature());
iterator it = begin();
iterator iend = end();
table_fact row; table_fact row;
for (auto& k : *this) {
for(; it!=iend; ++it) { k.get_fact(row);
it->get_fact(row);
res->add_new_fact(row); res->add_new_fact(row);
} }
return res; return res;
@ -408,11 +390,8 @@ namespace datalog {
print_container(get_signature(), out); print_container(get_signature(), out);
out << ":\n"; out << ":\n";
iterator it = begin(); for (auto& k : *this) {
iterator iend = end(); k.display(out);
for(; it!=iend; ++it) {
const row_interface & r = *it;
r.display(out);
} }
out << "\n"; out << "\n";
@ -470,10 +449,7 @@ namespace datalog {
dl_decl_util util(m); dl_decl_util util(m);
bool_rewriter brw(m); bool_rewriter brw(m);
table_fact fact; table_fact fact;
iterator it = begin(); for (row_interface const& r : *this) {
iterator iend = end();
for(; it != iend; ++it) {
const row_interface & r = *it;
r.get_fact(fact); r.get_fact(fact);
conjs.reset(); conjs.reset();
for (unsigned i = 0; i < fact.size(); ++i) { for (unsigned i = 0; i < fact.size(); ++i) {