3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-03 18:00:23 +00:00

user propagator over the API

This commit is contained in:
Nikolaj Bjorner 2020-08-18 21:52:52 -07:00
parent c50e869e5a
commit 4857d60c99
13 changed files with 141 additions and 63 deletions

View file

@ -16,6 +16,7 @@ Author:
--*/
#include "ast/ast_pp.h"
#include "smt/user_propagator.h"
#include "smt/smt_context.h"
@ -23,26 +24,47 @@ using namespace smt;
user_propagator::user_propagator(context& ctx):
theory(ctx, ctx.get_manager().mk_family_id("user_propagator")),
m_qhead(0)
m_qhead(0),
m_num_scopes(0)
{}
void user_propagator::force_push() {
for (; m_num_scopes > 0; --m_num_scopes) {
theory::push_scope_eh();
m_push_eh(m_user_context);
m_prop_lim.push_back(m_prop.size());
}
}
// TODO: check type of 'e', either Bool or Bit-vector.
//
unsigned user_propagator::add_expr(expr* e) {
// TODO: check type of 'e', either Bool or Bit-vector.
return mk_var(ensure_enode(e));
force_push();
enode* n = ensure_enode(e);
if (is_attached_to_var(n))
return n->get_th_var(get_id());
theory_var v = mk_var(n);
ctx.attach_th_var(n, this, v);
return v;
}
void user_propagator::new_fixed_eh(theory_var v, expr* value, unsigned num_lits, literal const* jlits) {
force_push();
m_id2justification.setx(v, literal_vector(num_lits, jlits), literal_vector());
m_fixed_eh(m_user_context, v, value);
}
void user_propagator::push_scope_eh() {
theory::push_scope_eh();
m_push_eh(m_user_context);
m_prop_lim.push_back(m_prop.size());
++m_num_scopes;
}
void user_propagator::pop_scope_eh(unsigned num_scopes) {
unsigned n = std::min(num_scopes, m_num_scopes);
m_num_scopes -= n;
num_scopes -= n;
if (num_scopes == 0)
return;
m_pop_eh(m_user_context, num_scopes);
theory::pop_scope_eh(num_scopes);
unsigned old_sz = m_prop_lim.size() - num_scopes;
@ -55,6 +77,7 @@ bool user_propagator::can_propagate() {
}
void user_propagator::propagate() {
force_push();
unsigned qhead = m_qhead;
literal_vector lits;
enode_pair_vector eqs;