mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
running updates to bv_solver (#4674)
* na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * dbg Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * bv Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * drat and fresh Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * move ackerman functionality Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * debugability Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * towards debugability Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * missing file Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * remove csp Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
4d1a2a2784
commit
d02b0cde7a
63 changed files with 3060 additions and 3095 deletions
|
@ -18,6 +18,9 @@ Revision History:
|
|||
--*/
|
||||
#pragma once
|
||||
|
||||
#if 0
|
||||
-- unused
|
||||
|
||||
/**
|
||||
Add element \c elem to the list headed by \c head.
|
||||
NextProc and PrevProc must have the methods:
|
||||
|
@ -131,5 +134,52 @@ bool dlist_check_invariant(T * head, NextProc const & next = NextProc(), PrevPro
|
|||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
class dll_base {
|
||||
T* m_next { nullptr };
|
||||
T* m_prev { nullptr };
|
||||
public:
|
||||
|
||||
T* prev() { return m_prev; }
|
||||
T* next() { return m_next; }
|
||||
|
||||
void init(T* t) {
|
||||
m_next = t;
|
||||
m_prev = t;
|
||||
}
|
||||
|
||||
static void remove_from(T*& list, T* elem) {
|
||||
if (list->m_next == list) {
|
||||
SASSERT(elem == list);
|
||||
list = nullptr;
|
||||
return;
|
||||
}
|
||||
if (list == elem)
|
||||
list = elem->m_next;
|
||||
auto* next = elem->m_next;
|
||||
auto* prev = elem->m_prev;
|
||||
prev->m_next = next;
|
||||
next->m_prev = prev;
|
||||
}
|
||||
|
||||
static void push_to_front(T*& list, T* elem) {
|
||||
if (!list) {
|
||||
list = elem;
|
||||
elem->m_next = elem;
|
||||
elem->m_prev = elem;
|
||||
}
|
||||
else if (list != elem) {
|
||||
remove_from(list, elem);
|
||||
list->m_prev->m_next = elem;
|
||||
elem->m_prev = list->m_prev;
|
||||
elem->m_next = list;
|
||||
list->m_prev = elem;
|
||||
list = elem;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
36
src/util/scoped_limit_trail.h
Normal file
36
src/util/scoped_limit_trail.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
|
||||
#include "util/vector.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
class scoped_limit_trail {
|
||||
unsigned_vector m_lim;
|
||||
unsigned m_scopes{ 0 };
|
||||
unsigned m_last{ 0 };
|
||||
public:
|
||||
|
||||
void push(unsigned n) {
|
||||
if (m_last == n)
|
||||
m_scopes++;
|
||||
else {
|
||||
for (; m_scopes > 0; --m_scopes)
|
||||
m_lim.push_back(m_last);
|
||||
m_last = n;
|
||||
}
|
||||
}
|
||||
unsigned pop(unsigned n) {
|
||||
SASSERT(n > 0);
|
||||
SASSERT(m_scopes + m_lim.size() >= n);
|
||||
if (n <= m_scopes) {
|
||||
m_scopes -= n;
|
||||
return m_last;
|
||||
}
|
||||
else {
|
||||
n -= m_scopes;
|
||||
m_scopes = 0;
|
||||
m_last = m_lim[m_lim.size() - n];
|
||||
m_lim.shrink(m_lim.size() - n);
|
||||
return m_last;
|
||||
}
|
||||
}
|
||||
};
|
|
@ -99,7 +99,7 @@ unsigned get_max_len(ptr_buffer<char> & keys) {
|
|||
return max;
|
||||
}
|
||||
|
||||
void statistics::display_smt2(std::ostream & out) const {
|
||||
std::ostream& statistics::display_smt2(std::ostream & out) const {
|
||||
#define INIT_DISPLAY() \
|
||||
key2val m_u; \
|
||||
key2dval m_d; \
|
||||
|
@ -140,9 +140,10 @@ void statistics::display_smt2(std::ostream & out) const {
|
|||
}
|
||||
}
|
||||
out << ")\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
void statistics::display(std::ostream & out) const {
|
||||
std::ostream& statistics::display(std::ostream & out) const {
|
||||
INIT_DISPLAY();
|
||||
|
||||
#undef DISPLAY_KEY
|
||||
|
@ -169,6 +170,7 @@ void statistics::display(std::ostream & out) const {
|
|||
out << " " << std::fixed << std::setprecision(2) << d_val << "\n";
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
template<typename M>
|
||||
|
|
|
@ -32,8 +32,8 @@ public:
|
|||
void reset();
|
||||
void update(char const * key, unsigned inc);
|
||||
void update(char const * key, double inc);
|
||||
void display(std::ostream & out) const;
|
||||
void display_smt2(std::ostream & out) const;
|
||||
std::ostream& display(std::ostream & out) const;
|
||||
std::ostream& display_smt2(std::ostream & out) const;
|
||||
void display_internal(std::ostream & out) const;
|
||||
unsigned size() const;
|
||||
bool is_uint(unsigned idx) const;
|
||||
|
@ -42,6 +42,8 @@ public:
|
|||
double get_double_value(unsigned idx) const;
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, statistics const& st) { return st.display(out); }
|
||||
|
||||
void get_memory_statistics(statistics& st);
|
||||
void get_rlimit_statistics(reslimit& l, statistics& st);
|
||||
|
||||
|
|
|
@ -36,10 +36,10 @@ private:
|
|||
_trail_stack m_stack;
|
||||
};
|
||||
|
||||
template<typename Ctx = union_find_default_ctx>
|
||||
template<typename Ctx = union_find_default_ctx, typename StackCtx = Ctx>
|
||||
class union_find {
|
||||
Ctx & m_ctx;
|
||||
trail_stack<Ctx> & m_trail_stack;
|
||||
trail_stack<StackCtx> & m_trail_stack;
|
||||
svector<unsigned> m_find;
|
||||
svector<unsigned> m_size;
|
||||
svector<unsigned> m_next;
|
||||
|
@ -47,12 +47,12 @@ class union_find {
|
|||
class mk_var_trail;
|
||||
friend class mk_var_trail;
|
||||
|
||||
class mk_var_trail : public trail<Ctx> {
|
||||
class mk_var_trail : public trail<StackCtx> {
|
||||
union_find & m_owner;
|
||||
public:
|
||||
mk_var_trail(union_find & o):m_owner(o) {}
|
||||
~mk_var_trail() override {}
|
||||
void undo(Ctx & ctx) override {
|
||||
void undo(StackCtx& ctx) override {
|
||||
m_owner.m_find.pop_back();
|
||||
m_owner.m_size.pop_back();
|
||||
m_owner.m_next.pop_back();
|
||||
|
@ -64,13 +64,13 @@ class union_find {
|
|||
class merge_trail;
|
||||
friend class merge_trail;
|
||||
|
||||
class merge_trail : public trail<Ctx> {
|
||||
class merge_trail : public trail<StackCtx> {
|
||||
union_find & m_owner;
|
||||
unsigned m_r1;
|
||||
public:
|
||||
merge_trail(union_find & o, unsigned r1):m_owner(o), m_r1(r1) {}
|
||||
~merge_trail() override {}
|
||||
void undo(Ctx & ctx) override { m_owner.unmerge(m_r1); }
|
||||
void undo(StackCtx& ctx) override { m_owner.unmerge(m_r1); }
|
||||
};
|
||||
|
||||
void unmerge(unsigned r1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue