Skip to content

Commit

Permalink
euf solver updates
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Jan 8, 2021
1 parent 7bf691e commit 60ef60d
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ast/euf/euf_enode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,13 @@ namespace euf {
return false;
return true;
}

unsigned enode::class_generation() {
unsigned gen = m_generation;

for (enode* n : enode_class(this))
gen = std::min(n->generation(), gen);
return gen;
}

}
1 change: 1 addition & 0 deletions src/ast/euf/euf_enode.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ namespace euf {
void set_table_id(unsigned t) { m_table_id = t; }

unsigned generation() const { return m_generation; }
unsigned class_generation();

void mark1() { m_mark1 = true; }
void unmark1() { m_mark1 = false; }
Expand Down
4 changes: 4 additions & 0 deletions src/sat/smt/euf_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ namespace euf {
return m_values2root;
}

expr* solver::node2value(enode* n) const {
return m_values.get(n->get_root_id(), nullptr);
}

void solver::validate_model(model& mdl) {
for (enode* n : m_egraph.nodes()) {
expr* e = n->get_expr();
Expand Down
2 changes: 2 additions & 0 deletions src/sat/smt/euf_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ namespace euf {
bool check_model(sat::model const& m) const override;
unsigned max_var(unsigned w) const override;

// proof
bool use_drat() { return s().get_config().m_drat && (init_drat(), true); }
sat::drat& get_drat() { return s().get_drat(); }
void drat_bool_def(sat::bool_var v, expr* n);
Expand Down Expand Up @@ -345,6 +346,7 @@ namespace euf {
// model construction
void update_model(model_ref& mdl);
obj_map<expr, enode*> const& values2root();
expr* node2value(enode* n) const;

// diagnostics
func_decl_ref_vector const& unhandled_functions() { return m_unhandled_functions; }
Expand Down
21 changes: 21 additions & 0 deletions src/sat/smt/q_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,25 @@ namespace q {
ctx.push(insert_ref2_map<euf::solver, ast_manager, sort, expr>(m, m_unit_table, s, val));
return val;
}

unsigned solver::get_max_generation(expr* e) const {
unsigned g = 0;
expr_fast_mark1 mark;
m_todo.push_back(e);
while (!m_todo.empty()) {
e = m_todo.back();
m_todo.pop_back();
if (mark.is_marked(e))
continue;
mark.mark(e);
euf::enode* n = ctx.get_egraph().find(e);
if (n)
g = std::max(g, n->generation());
else if (is_app(e))
for (expr* arg : *to_app(e))
m_todo.push_back(arg);
}
return g;
}

}
3 changes: 3 additions & 0 deletions src/sat/smt/q_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace q {
flat_table m_flat;
sat::literal_vector m_universal;
obj_map<sort, expr*> m_unit_table;
mutable ptr_vector<expr> m_todo;

sat::literal instantiate(quantifier* q, bool negate, std::function<expr* (quantifier*, unsigned)>& mk_var);
sat::literal skolemize(quantifier* q);
Expand Down Expand Up @@ -75,5 +76,7 @@ namespace q {
ast_manager& get_manager() { return m; }
sat::literal_vector const& universal() const { return m_universal; }
quantifier* flatten(quantifier* q);

unsigned get_max_generation(expr* e) const;
};
}
4 changes: 4 additions & 0 deletions src/sat/smt/sat_th.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ namespace euf {
return n;
}

unsigned th_euf_solver::random() {
return ctx.s().rand()();
}

size_t th_propagation::get_obj_size(unsigned num_lits, unsigned num_eqs) {
return sat::constraint_base::obj_size(sizeof(th_propagation) + sizeof(sat::literal) * num_lits + sizeof(enode_pair) * num_eqs);
}
Expand Down
2 changes: 2 additions & 0 deletions src/sat/smt/sat_th.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ namespace euf {
bool is_root(theory_var v) const { return var2enode(v)->is_root(); }
void push() override { m_num_scopes++; }
void pop(unsigned n) override;

unsigned random();
};


Expand Down

0 comments on commit 60ef60d

Please sign in to comment.