3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-07 15:55:46 +00:00

add simplifiation pass

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-02-22 11:21:53 -08:00
parent ab9bcfdcce
commit d1e95a133b
10 changed files with 115 additions and 36 deletions

View file

@ -89,6 +89,15 @@ namespace sat {
m_cuts[m_size++] = c;
}
void cut_set::evict(on_update_t& on_del, cut const& c) {
for (unsigned i = 0; i < m_size; ++i) {
if (m_cuts[i] == c) {
evict(on_del, i);
break;
}
}
}
void cut_set::evict(on_update_t& on_del, unsigned idx) {
if (m_var != UINT_MAX && on_del) on_del(m_var, m_cuts[idx]);
m_cuts[idx] = m_cuts[--m_size];
@ -166,6 +175,56 @@ namespace sat {
return true;
}
/**
* \brief create the masks
* i = 0: 101010101010101
* i = 1: 1100110011001100
* i = 2: 1111000011110000
* i = 3: 111111110000000011111111
*/
uint64_t cut::effect_mask(unsigned i) {
SASSERT(i <= 6);
uint64_t m = 0;
if (i == 6) {
m = ~((uint64_t)0);
}
else {
m = (1ull << (1u << i)) - 1; // i = 0: m = 1
unsigned w = 1u << (i + 1); // i = 0: w = 2
while (w < 64) {
m |= (m << w); // i = 0: m = 1 + 4
w *= 2;
}
}
return m;
}
/**
remove element from cut as it is deemed a don't care
*/
void cut::remove_elem(unsigned i) {
for (unsigned j = i + 1; j < m_size; ++j) {
m_elems[j-1] = m_elems[j];
}
--m_size;
uint64_t m = effect_mask(i);
uint64_t t = 0;
for (unsigned j = 0, offset = 0; j < 64; ++j) {
if (0 != (m & (1ull << j))) {
t |= ((m_table >> j) & 1u) << offset;
++offset;
}
}
m_table = t;
m_dont_care = 0;
unsigned f = 0;
for (unsigned e : *this) {
f |= (1u << (e & 0x1F));
}
m_filter = f;
}
/**
sat-sweep evaluation. Given 64 bits worth of possible values per variable,
find possible values for function table encoded by cut.