3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-29 20:05:51 +00:00

prepare for theory plugins

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-09-02 10:42:07 -07:00
parent 141edef0d6
commit 116390833b
27 changed files with 492 additions and 336 deletions

View file

@ -20,13 +20,15 @@ Author:
#include "sat/smt/sat_smt.h"
#include "ast/euf/euf_egraph.h"
namespace sat {
namespace euf {
class solver;
class th_internalizer {
public:
virtual ~th_internalizer() {}
virtual literal internalize(expr* e, bool sign, bool root, bool redundant) = 0;
virtual sat::literal internalize(expr* e, bool sign, bool root, bool redundant) = 0;
};
class th_decompile {
@ -58,14 +60,49 @@ namespace sat {
virtual bool include_func_interp(func_decl* f) const { return false; }
};
class th_solver : public extension, public th_model_builder, public th_decompile, public th_internalizer {
class th_solver : public sat::extension, public th_model_builder, public th_decompile, public th_internalizer {
protected:
ast_manager & m;
euf::theory_id m_id;
public:
virtual ~th_solver() {}
th_solver(ast_manager& m, euf::theory_id id): m(m), m_id(id) {}
virtual th_solver* fresh(solver* s, ast_manager& m, sat_internalizer& si) = 0;
virtual th_solver* fresh(sat::solver* s, euf::solver& ctx) = 0;
virtual void new_eq_eh(euf::th_eq const& eq) {}
};
class th_euf_solver : public th_solver {
protected:
solver & ctx;
euf::enode_vector m_var2enode;
unsigned_vector m_var2enode_lim;
public:
virtual ~th_euf_solver() {}
th_euf_solver(euf::solver& ctx, euf::theory_id id);
virtual euf::theory_var mk_var(enode * n) {
SASSERT(!is_attached_to_var(n));
euf::theory_var v = m_var2enode.size();
m_var2enode.push_back(n);
return v;
}
enode* get_enode(theory_var v) const { return m_var2enode[v]; }
euf::theory_var get_th_var(expr* e) const;
euf::theory_var get_th_var(euf::enode* n) const {
return n->get_th_var(get_id());
}
bool is_attached_to_var(enode* n) const {
theory_var v = n->get_th_var(get_id());
return v != null_theory_var && get_enode(v) == n;
}
};
}