Z3
 
Loading...
Searching...
No Matches
Data Structures | Public Member Functions
user_propagator_base Class Referenceabstract

#include <z3++.h>

Public Member Functions

 user_propagator_base (context &c)
 
 user_propagator_base (solver *s)
 
virtual void push ()=0
 
virtual void pop (unsigned num_scopes)=0
 
virtual ~user_propagator_base ()
 
contextctx ()
 
virtual user_propagator_basefresh (context &ctx)=0
 user_propagators created using fresh() are created during search and their lifetimes are restricted to search time. They should be garbage collected by the propagator used to invoke fresh(). The life-time of the Z3_context object can only be assumed valid during callbacks, such as fixed(), which contains expressions based on the context.
 
void register_fixed (fixed_eh_t &f)
 register callbacks. Callbacks can only be registered with user_propagators that were created using a solver.
 
void register_fixed ()
 
void register_eq (eq_eh_t &f)
 
void register_eq ()
 
void register_final (final_eh_t &f)
 register a callback on final-check. During the final check stage, all propagations have been processed. This is an opportunity for the user-propagator to delay some analysis that could be expensive to perform incrementally. It is also an opportunity for the propagator to implement branch and bound optimization.
 
void register_final ()
 
void register_created (created_eh_t &c)
 
void register_created ()
 
void register_decide (decide_eh_t &c)
 
void register_decide ()
 
void register_on_binding ()
 
virtual void fixed (expr const &, expr const &)
 
virtual void eq (expr const &, expr const &)
 
virtual void final ()
 
virtual void created (expr const &)
 
virtual void decide (expr const &, unsigned, bool)
 
virtual bool on_binding (expr const &, expr const &)
 
bool next_split (expr const &e, unsigned idx, Z3_lbool phase)
 
void add (expr const &e)
 tracks e by a unique identifier that is returned by the call.
 
void conflict (expr_vector const &fixed)
 
void conflict (expr_vector const &fixed, expr_vector const &lhs, expr_vector const &rhs)
 
bool propagate (expr_vector const &fixed, expr const &conseq)
 
bool propagate (expr_vector const &fixed, expr_vector const &lhs, expr_vector const &rhs, expr const &conseq)
 

Detailed Description

Definition at line 4340 of file z3++.h.

Constructor & Destructor Documentation

◆ user_propagator_base() [1/2]

user_propagator_base ( context c)
inline

Definition at line 4435 of file z3++.h.

4435: s(nullptr), c(&c) {}

◆ user_propagator_base() [2/2]

user_propagator_base ( solver s)
inline

Definition at line 4437 of file z3++.h.

4437 : s(s), c(nullptr) {
4438 Z3_solver_propagate_init(ctx(), *s, this, push_eh, pop_eh, fresh_eh);
4439 }
void Z3_API Z3_solver_propagate_init(Z3_context c, Z3_solver s, void *user_context, Z3_push_eh push_eh, Z3_pop_eh pop_eh, Z3_fresh_eh fresh_eh)
register a user-propagator with the solver.

◆ ~user_propagator_base()

virtual ~user_propagator_base ( )
inlinevirtual

Definition at line 4444 of file z3++.h.

4444 {
4445 for (auto& subcontext : subcontexts) {
4446 subcontext->detach(); // detach first; the subcontexts will be freed internally!
4447 delete subcontext;
4448 }
4449 }

Member Function Documentation

◆ add()

void add ( expr const e)
inline

tracks e by a unique identifier that is returned by the call.

If the fixed() callback is registered and if e is a Boolean or Bit-vector, the fixed() callback gets invoked when e is bound to a value. If the eq() callback is registered, then equalities between registered expressions are reported. A consumer can use the propagate or conflict functions to invoke propagations or conflicts as a consequence of these callbacks. These functions take a list of identifiers for registered expressions that have been fixed. The list of identifiers must correspond to already fixed values. Similarly, a list of propagated equalities can be supplied. These must correspond to equalities that have been registered during a callback.

Definition at line 4598 of file z3++.h.

4598 {
4599 if (cb)
4601 else if (s)
4603 else
4604 assert(false);
4605 }
void Z3_API Z3_solver_propagate_register_cb(Z3_context c, Z3_solver_callback cb, Z3_ast e)
register an expression to propagate on with the solver. Only expressions of type Bool and type Bit-Ve...
void Z3_API Z3_solver_propagate_register(Z3_context c, Z3_solver s, Z3_ast e)
register an expression to propagate on with the solver. Only expressions of type Bool and type Bit-Ve...

Referenced by Solver::__iadd__().

◆ conflict() [1/2]

void conflict ( expr_vector const fixed)
inline

Definition at line 4607 of file z3++.h.

4607 {
4608 assert(cb);
4609 expr conseq = ctx().bool_val(false);
4610 array<Z3_ast> _fixed(fixed);
4611 Z3_solver_propagate_consequence(ctx(), cb, fixed.size(), _fixed.ptr(), 0, nullptr, nullptr, conseq);
4612 }
expr bool_val(bool b)
Definition z3++.h:3840
virtual void fixed(expr const &, expr const &)
Definition z3++.h:4567
bool Z3_API Z3_solver_propagate_consequence(Z3_context c, Z3_solver_callback cb, unsigned num_fixed, Z3_ast const *fixed, unsigned num_eqs, Z3_ast const *eq_lhs, Z3_ast const *eq_rhs, Z3_ast conseq)
propagate a consequence based on fixed values and equalities. A client may invoke it during the pro...

◆ conflict() [2/2]

void conflict ( expr_vector const fixed,
expr_vector const lhs,
expr_vector const rhs 
)
inline

Definition at line 4614 of file z3++.h.

4614 {
4615 assert(cb);
4616 assert(lhs.size() == rhs.size());
4617 expr conseq = ctx().bool_val(false);
4618 array<Z3_ast> _fixed(fixed);
4619 array<Z3_ast> _lhs(lhs);
4620 array<Z3_ast> _rhs(rhs);
4621 Z3_solver_propagate_consequence(ctx(), cb, fixed.size(), _fixed.ptr(), lhs.size(), _lhs.ptr(), _rhs.ptr(), conseq);
4622 }

◆ created()

virtual void created ( expr const )
inlinevirtual

Definition at line 4573 of file z3++.h.

4573{}

Referenced by user_propagator_base::register_created().

◆ ctx()

context & ctx ( )
inline

Definition at line 4451 of file z3++.h.

4451 {
4452 return c ? *c : s->ctx();
4453 }
context & ctx() const
Definition z3++.h:491

Referenced by ArithRef::__add__(), BitVecRef::__add__(), BitVecRef::__and__(), FuncDeclRef::__call__(), AstMap::__contains__(), AstRef::__copy__(), Goal::__copy__(), AstVector::__copy__(), FuncInterp::__copy__(), ModelRef::__copy__(), AstRef::__deepcopy__(), Datatype::__deepcopy__(), ParamsRef::__deepcopy__(), ParamDescrsRef::__deepcopy__(), Goal::__deepcopy__(), AstVector::__deepcopy__(), AstMap::__deepcopy__(), FuncEntry::__deepcopy__(), FuncInterp::__deepcopy__(), ModelRef::__deepcopy__(), Statistics::__deepcopy__(), Context::__del__(), AstRef::__del__(), ScopedConstructor::__del__(), ScopedConstructorList::__del__(), ParamsRef::__del__(), ParamDescrsRef::__del__(), Goal::__del__(), AstVector::__del__(), AstMap::__del__(), FuncEntry::__del__(), FuncInterp::__del__(), ModelRef::__del__(), Statistics::__del__(), Solver::__del__(), ArithRef::__div__(), BitVecRef::__div__(), ExprRef::__eq__(), ArithRef::__ge__(), BitVecRef::__ge__(), AstVector::__getitem__(), ModelRef::__getitem__(), Statistics::__getitem__(), AstMap::__getitem__(), ArithRef::__gt__(), BitVecRef::__gt__(), BitVecRef::__invert__(), ArithRef::__le__(), BitVecRef::__le__(), AstVector::__len__(), AstMap::__len__(), ModelRef::__len__(), Statistics::__len__(), BitVecRef::__lshift__(), ArithRef::__lt__(), BitVecRef::__lt__(), ArithRef::__mod__(), BitVecRef::__mod__(), BoolRef::__mul__(), ArithRef::__mul__(), BitVecRef::__mul__(), ExprRef::__ne__(), ArithRef::__neg__(), BitVecRef::__neg__(), BitVecRef::__or__(), ArithRef::__pow__(), ArithRef::__radd__(), BitVecRef::__radd__(), BitVecRef::__rand__(), ArithRef::__rdiv__(), BitVecRef::__rdiv__(), ParamsRef::__repr__(), ParamDescrsRef::__repr__(), AstMap::__repr__(), Statistics::__repr__(), BitVecRef::__rlshift__(), ArithRef::__rmod__(), BitVecRef::__rmod__(), ArithRef::__rmul__(), BitVecRef::__rmul__(), BitVecRef::__ror__(), ArithRef::__rpow__(), BitVecRef::__rrshift__(), BitVecRef::__rshift__(), ArithRef::__rsub__(), BitVecRef::__rsub__(), BitVecRef::__rxor__(), AstVector::__setitem__(), AstMap::__setitem__(), ArithRef::__sub__(), BitVecRef::__sub__(), BitVecRef::__xor__(), DatatypeSortRef::accessor(), user_propagator_base::add(), ExprRef::arg(), FuncEntry::arg_value(), FuncInterp::arity(), Goal::as_expr(), Solver::assert_and_track(), Goal::assert_exprs(), Solver::assert_exprs(), QuantifierRef::body(), Solver::check(), user_propagator_base::conflict(), user_propagator_base::conflict(), Goal::convert_model(), AstRef::ctx_ref(), ExprRef::decl(), ModelRef::decls(), ArrayRef::default(), RatNumRef::denominator(), Goal::depth(), Goal::dimacs(), FuncDeclRef::domain(), ArraySortRef::domain_n(), FuncInterp::else_value(), FuncInterp::entry(), AstMap::erase(), ModelRef::eval(), Goal::get(), ParamDescrsRef::get_documentation(), ModelRef::get_interp(), Statistics::get_key_value(), ParamDescrsRef::get_kind(), ParamDescrsRef::get_name(), ModelRef::get_sort(), ModelRef::get_universe(), Goal::inconsistent(), AstMap::keys(), Statistics::keys(), Solver::model(), SortRef::name(), user_propagator_base::next_split(), QuantifierRef::no_pattern(), FuncEntry::num_args(), FuncInterp::num_entries(), Solver::num_scopes(), ModelRef::num_sorts(), FuncDeclRef::params(), QuantifierRef::pattern(), AlgebraicNumRef::poly(), Solver::pop(), Goal::prec(), ModelRef::project(), ModelRef::project_with_witness(), user_propagator_base::propagate(), user_propagator_base::propagate(), Solver::push(), AstVector::push(), QuantifierRef::qid(), FuncDeclRef::range(), ArraySortRef::range(), DatatypeSortRef::recognizer(), Context::ref(), user_propagator_base::register_created(), user_propagator_base::register_created(), user_propagator_base::register_decide(), user_propagator_base::register_decide(), user_propagator_base::register_eq(), user_propagator_base::register_eq(), user_propagator_base::register_final(), user_propagator_base::register_final(), user_propagator_base::register_fixed(), user_propagator_base::register_fixed(), user_propagator_base::register_on_binding(), AstMap::reset(), Solver::reset(), AstVector::resize(), Solver::set(), ParamsRef::set(), Goal::sexpr(), AstVector::sexpr(), ModelRef::sexpr(), ParamDescrsRef::size(), Goal::size(), QuantifierRef::skolem_id(), AstVector::translate(), AstRef::translate(), Goal::translate(), ModelRef::translate(), user_propagator_base::user_propagator_base(), ParamsRef::validate(), FuncEntry::value(), QuantifierRef::var_name(), and QuantifierRef::var_sort().

◆ decide()

virtual void decide ( expr const ,
unsigned  ,
bool   
)
inlinevirtual

Definition at line 4575 of file z3++.h.

4575{}

Referenced by user_propagator_base::register_decide().

◆ eq()

virtual void eq ( expr const ,
expr const  
)
inlinevirtual

Definition at line 4569 of file z3++.h.

4569{ }

Referenced by AstRef::__eq__(), SortRef::cast(), and user_propagator_base::register_eq().

◆ final()

virtual void final ( )
inlinevirtual

Definition at line 4571 of file z3++.h.

4571{ }

◆ fixed()

virtual void fixed ( expr const ,
expr const  
)
inlinevirtual

◆ fresh()

virtual user_propagator_base * fresh ( context ctx)
pure virtual

user_propagators created using fresh() are created during search and their lifetimes are restricted to search time. They should be garbage collected by the propagator used to invoke fresh(). The life-time of the Z3_context object can only be assumed valid during callbacks, such as fixed(), which contains expressions based on the context.

◆ next_split()

bool next_split ( expr const e,
unsigned  idx,
Z3_lbool  phase 
)
inline

Definition at line 4579 of file z3++.h.

4579 {
4580 assert(cb);
4581 return Z3_solver_next_split(ctx(), cb, e, idx, phase);
4582 }
bool Z3_API Z3_solver_next_split(Z3_context c, Z3_solver_callback cb, Z3_ast t, unsigned idx, Z3_lbool phase)

◆ on_binding()

virtual bool on_binding ( expr const ,
expr const  
)
inlinevirtual

Definition at line 4577 of file z3++.h.

4577{ return true; }

Referenced by user_propagator_base::register_on_binding().

◆ pop()

virtual void pop ( unsigned  num_scopes)
pure virtual

Referenced by Solver::__exit__().

◆ propagate() [1/2]

bool propagate ( expr_vector const fixed,
expr const conseq 
)
inline

Definition at line 4624 of file z3++.h.

4624 {
4625 assert(cb);
4626 assert((Z3_context)conseq.ctx() == (Z3_context)ctx());
4627 array<Z3_ast> _fixed(fixed);
4628 return Z3_solver_propagate_consequence(ctx(), cb, _fixed.size(), _fixed.ptr(), 0, nullptr, nullptr, conseq);
4629 }

◆ propagate() [2/2]

bool propagate ( expr_vector const fixed,
expr_vector const lhs,
expr_vector const rhs,
expr const conseq 
)
inline

Definition at line 4631 of file z3++.h.

4633 {
4634 assert(cb);
4635 assert((Z3_context)conseq.ctx() == (Z3_context)ctx());
4636 assert(lhs.size() == rhs.size());
4637 array<Z3_ast> _fixed(fixed);
4638 array<Z3_ast> _lhs(lhs);
4639 array<Z3_ast> _rhs(rhs);
4640
4641 return Z3_solver_propagate_consequence(ctx(), cb, _fixed.size(), _fixed.ptr(), lhs.size(), _lhs.ptr(), _rhs.ptr(), conseq);
4642 }

◆ push()

virtual void push ( )
pure virtual

Referenced by Solver::__enter__().

◆ register_created() [1/2]

void register_created ( )
inline

Definition at line 4534 of file z3++.h.

4534 {
4535 m_created_eh = [this](expr const& e) {
4536 created(e);
4537 };
4538 if (s) {
4539 Z3_solver_propagate_created(ctx(), *s, created_eh);
4540 }
4541 }
virtual void created(expr const &)
Definition z3++.h:4573
void Z3_API Z3_solver_propagate_created(Z3_context c, Z3_solver s, Z3_created_eh created_eh)
register a callback when a new expression with a registered function is used by the solver The regist...

◆ register_created() [2/2]

void register_created ( created_eh_t &  c)
inline

Definition at line 4527 of file z3++.h.

4527 {
4528 m_created_eh = c;
4529 if (s) {
4530 Z3_solver_propagate_created(ctx(), *s, created_eh);
4531 }
4532 }

◆ register_decide() [1/2]

void register_decide ( )
inline

Definition at line 4550 of file z3++.h.

4550 {
4551 m_decide_eh = [this](expr val, unsigned bit, bool is_pos) {
4552 decide(val, bit, is_pos);
4553 };
4554 if (s) {
4555 Z3_solver_propagate_decide(ctx(), *s, decide_eh);
4556 }
4557 }
virtual void decide(expr const &, unsigned, bool)
Definition z3++.h:4575
void Z3_API Z3_solver_propagate_decide(Z3_context c, Z3_solver s, Z3_decide_eh decide_eh)
register a callback when the solver decides to split on a registered expression. The callback may cha...

◆ register_decide() [2/2]

void register_decide ( decide_eh_t &  c)
inline

Definition at line 4543 of file z3++.h.

4543 {
4544 m_decide_eh = c;
4545 if (s) {
4546 Z3_solver_propagate_decide(ctx(), *s, decide_eh);
4547 }
4548 }

◆ register_eq() [1/2]

void register_eq ( )
inline

Definition at line 4494 of file z3++.h.

4494 {
4495 m_eq_eh = [this](expr const& x, expr const& y) {
4496 eq(x, y);
4497 };
4498 if (s) {
4499 Z3_solver_propagate_eq(ctx(), *s, eq_eh);
4500 }
4501 }
virtual void eq(expr const &, expr const &)
Definition z3++.h:4569
void Z3_API Z3_solver_propagate_eq(Z3_context c, Z3_solver s, Z3_eq_eh eq_eh)
register a callback on expression equalities.

◆ register_eq() [2/2]

void register_eq ( eq_eh_t &  f)
inline

Definition at line 4487 of file z3++.h.

4487 {
4488 m_eq_eh = f;
4489 if (s) {
4490 Z3_solver_propagate_eq(ctx(), *s, eq_eh);
4491 }
4492 }

◆ register_final() [1/2]

void register_final ( )
inline

Definition at line 4518 of file z3++.h.

4518 {
4519 m_final_eh = [this]() {
4520 final();
4521 };
4522 if (s) {
4523 Z3_solver_propagate_final(ctx(), *s, final_eh);
4524 }
4525 }
void Z3_API Z3_solver_propagate_final(Z3_context c, Z3_solver s, Z3_final_eh final_eh)
register a callback on final check. This provides freedom to the propagator to delay actions or imple...

◆ register_final() [2/2]

void register_final ( final_eh_t &  f)
inline

register a callback on final-check. During the final check stage, all propagations have been processed. This is an opportunity for the user-propagator to delay some analysis that could be expensive to perform incrementally. It is also an opportunity for the propagator to implement branch and bound optimization.

Definition at line 4511 of file z3++.h.

4511 {
4512 m_final_eh = f;
4513 if (s) {
4514 Z3_solver_propagate_final(ctx(), *s, final_eh);
4515 }
4516 }

◆ register_fixed() [1/2]

void register_fixed ( )
inline

Definition at line 4478 of file z3++.h.

4478 {
4479 m_fixed_eh = [this](expr const &id, expr const &e) {
4480 fixed(id, e);
4481 };
4482 if (s) {
4483 Z3_solver_propagate_fixed(ctx(), *s, fixed_eh);
4484 }
4485 }
void Z3_API Z3_solver_propagate_fixed(Z3_context c, Z3_solver s, Z3_fixed_eh fixed_eh)
register a callback for when an expression is bound to a fixed value. The supported expression types ...

◆ register_fixed() [2/2]

void register_fixed ( fixed_eh_t &  f)
inline

register callbacks. Callbacks can only be registered with user_propagators that were created using a solver.

Definition at line 4471 of file z3++.h.

4471 {
4472 m_fixed_eh = f;
4473 if (s) {
4474 Z3_solver_propagate_fixed(ctx(), *s, fixed_eh);
4475 }
4476 }

◆ register_on_binding()

void register_on_binding ( )
inline

Definition at line 4559 of file z3++.h.

4559 {
4560 m_on_binding_eh = [this](expr const& q, expr const& inst) {
4561 return on_binding(q, inst);
4562 };
4563 if (s)
4564 Z3_solver_propagate_on_binding(ctx(), *s, on_binding_eh);
4565 }
virtual bool on_binding(expr const &, expr const &)
Definition z3++.h:4577
void Z3_API Z3_solver_propagate_on_binding(Z3_context c, Z3_solver s, Z3_on_binding_eh on_binding_eh)
register a callback when the solver instantiates a quantifier. If the callback returns false,...