mirror of
https://github.com/Z3Prover/z3
synced 2025-06-06 22:23:22 +00:00
Merge branch 'opt' of https://git01.codeplex.com/z3 into opt
This commit is contained in:
commit
928fc550a5
4 changed files with 56 additions and 12 deletions
|
@ -661,7 +661,7 @@ namespace datalog {
|
||||||
expr_ref_vector eqs(m);
|
expr_ref_vector eqs(m);
|
||||||
dst.to_formula(dstf);
|
dst.to_formula(dstf);
|
||||||
std::cout << mk_pp(dstf, m) << "\n";
|
std::cout << mk_pp(dstf, m) << "\n";
|
||||||
dst.to_formula(negf);
|
neg.to_formula(negf);
|
||||||
std::cout << mk_pp(negf, m) << "\n";
|
std::cout << mk_pp(negf, m) << "\n";
|
||||||
eqs.push_back(negf);
|
eqs.push_back(negf);
|
||||||
for (unsigned i = 0; i < cols1.size(); ++i) {
|
for (unsigned i = 0; i < cols1.size(); ++i) {
|
||||||
|
|
|
@ -174,19 +174,18 @@ public:
|
||||||
for ( ; i < sz; ++i, ++j) {
|
for ( ; i < sz; ++i, ++j) {
|
||||||
if (m.contains(*m_elems[i], *t)) {
|
if (m.contains(*m_elems[i], *t)) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (m.contains(*t, *m_elems[i])) {
|
else if (m.contains(*t, *m_elems[i])) {
|
||||||
m.deallocate(m_elems[i]);
|
m.deallocate(m_elems[i]);
|
||||||
--j;
|
--j;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (i != j) {
|
if (i != j) {
|
||||||
m_elems[j] = m_elems[i];
|
m_elems[j] = m_elems[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (j != sz) m_elems.resize(j);
|
if (j != sz) m_elems.resize(j);
|
||||||
if (found) {
|
if (found) {
|
||||||
SASSERT(j == i);
|
|
||||||
m.deallocate(t);
|
m.deallocate(t);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -1110,11 +1110,16 @@ namespace datalog {
|
||||||
for (unsigned i = 0; i < neg.size(); ++i) {
|
for (unsigned i = 0; i < neg.size(); ++i) {
|
||||||
doc& neg_i = neg[i];
|
doc& neg_i = neg[i];
|
||||||
doc_ref newD(dmt, dmt.allocateX());
|
doc_ref newD(dmt, dmt.allocateX());
|
||||||
copy_columns(newD->pos(), neg_i.pos(), t, n);
|
if (!copy_columns(newD->pos(), neg_i.pos(), t, n))
|
||||||
|
continue;
|
||||||
|
|
||||||
bool is_empty = false;
|
bool is_empty = false;
|
||||||
for (unsigned j = 0; !is_empty && j < neg_i.neg().size(); ++j) {
|
for (unsigned j = 0; !is_empty && j < neg_i.neg().size(); ++j) {
|
||||||
tbv_ref newT(dmt.tbvm(), dmt.tbvm().allocateX());
|
tbv_ref newT(dmt.tbvm(), dmt.tbvm().allocateX());
|
||||||
copy_columns(*newT, neg_i.neg()[j], t, n);
|
if (!copy_columns(*newT, neg_i.neg()[j], t, n) ||
|
||||||
|
!dmt.tbvm().set_and(*newT, newD->pos())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (dmt.tbvm().equals(newD->pos(), *newT)) {
|
if (dmt.tbvm().equals(newD->pos(), *newT)) {
|
||||||
is_empty = true;
|
is_empty = true;
|
||||||
}
|
}
|
||||||
|
@ -1139,17 +1144,19 @@ namespace datalog {
|
||||||
renamed_neg.reset(dmt);
|
renamed_neg.reset(dmt);
|
||||||
IF_VERBOSE(3, tb.display(verbose_stream() << "slow case:"););
|
IF_VERBOSE(3, tb.display(verbose_stream() << "slow case:"););
|
||||||
}
|
}
|
||||||
void copy_columns(
|
bool copy_columns(
|
||||||
tbv& dst, tbv const& src,
|
tbv& dst, tbv const& src,
|
||||||
udoc_relation const& dstt,
|
udoc_relation const& dstt,
|
||||||
udoc_relation const& srct)
|
udoc_relation const& srct)
|
||||||
{
|
{
|
||||||
unsigned num_cols = m_t_cols.size();
|
unsigned num_cols = m_t_cols.size();
|
||||||
for (unsigned i = 0; i < num_cols; ++i) {
|
for (unsigned i = 0; i < num_cols; ++i) {
|
||||||
copy_column(dst, src, m_t_cols[i], m_neg_cols[i], dstt, srct);
|
if (!copy_column(dst, src, m_t_cols[i], m_neg_cols[i], dstt, srct))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
void copy_column(
|
bool copy_column(
|
||||||
tbv& dst, tbv const& src,
|
tbv& dst, tbv const& src,
|
||||||
unsigned col_dst, unsigned col_src,
|
unsigned col_dst, unsigned col_src,
|
||||||
udoc_relation const& dstt,
|
udoc_relation const& dstt,
|
||||||
|
@ -1162,8 +1169,12 @@ namespace datalog {
|
||||||
IF_VERBOSE(3, verbose_stream() << "copy column " << idx_src
|
IF_VERBOSE(3, verbose_stream() << "copy column " << idx_src
|
||||||
<< " to " << idx_dst << " " << num_tbits << "\n";);
|
<< " to " << idx_dst << " " << num_tbits << "\n";);
|
||||||
for (unsigned i = 0; i < num_tbits; ++i) {
|
for (unsigned i = 0; i < num_tbits; ++i) {
|
||||||
dm.set(dst, idx_dst + i, src[idx_src + i]);
|
tbit bit = (tbit)(dst[idx_dst + i] & src[idx_src + i]);
|
||||||
|
if (bit == BIT_z)
|
||||||
|
return false;
|
||||||
|
dm.set(dst, idx_dst + i, bit);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -149,6 +149,7 @@ public:
|
||||||
test_rename();
|
test_rename();
|
||||||
test_filter_neg();
|
test_filter_neg();
|
||||||
test_filter_neg2();
|
test_filter_neg2();
|
||||||
|
test_filter_neg3();
|
||||||
|
|
||||||
|
|
||||||
// empty
|
// empty
|
||||||
|
@ -601,6 +602,39 @@ public:
|
||||||
t2->deallocate();
|
t2->deallocate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_filter_neg3() {
|
||||||
|
// filter_by_negation
|
||||||
|
relation_signature sig;
|
||||||
|
sig.push_back(bv.mk_sort(1));
|
||||||
|
sig.push_back(bv.mk_sort(1));
|
||||||
|
sig.push_back(bv.mk_sort(1));
|
||||||
|
unsigned_vector cols1, cols2;
|
||||||
|
|
||||||
|
cols1.push_back(0);
|
||||||
|
cols1.push_back(0);
|
||||||
|
cols2.push_back(0);
|
||||||
|
cols2.push_back(1);
|
||||||
|
|
||||||
|
/// 1xx
|
||||||
|
udoc_relation* t1 = mk_full(sig);
|
||||||
|
{
|
||||||
|
doc& d = t1->get_udoc()[0];
|
||||||
|
t1->get_dm().set(d, 0, BIT_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 10x
|
||||||
|
udoc_relation* t2 = mk_full(sig);
|
||||||
|
{
|
||||||
|
doc& d = t2->get_udoc()[0];
|
||||||
|
t1->get_dm().set(d, 0, BIT_1);
|
||||||
|
t1->get_dm().set(d, 1, BIT_0);
|
||||||
|
}
|
||||||
|
|
||||||
|
apply_filter_neg(*t1, *t2, cols1, cols2);
|
||||||
|
t1->deallocate();
|
||||||
|
t2->deallocate();
|
||||||
|
}
|
||||||
|
|
||||||
void set_random(udoc_relation& r, unsigned num_vals) {
|
void set_random(udoc_relation& r, unsigned num_vals) {
|
||||||
unsigned num_bits = r.get_dm().num_tbits();
|
unsigned num_bits = r.get_dm().num_tbits();
|
||||||
udoc_relation* full = mk_full(r.get_signature());
|
udoc_relation* full = mk_full(r.get_signature());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue