mirror of
https://github.com/Z3Prover/z3
synced 2025-04-26 10:35:33 +00:00
Propagator (#5845)
* user propagator without ids Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * user propagator without ids Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * fix signature Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * references #5818 Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * fix c++ build Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * switch to vs 2022 Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * switch 2022 Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * Update propagator example (I) (#5835) * fix #5829 * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * switch to vs 2022 Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * Adapted the example to the changes in the propagator Co-authored-by: Nikolaj Bjorner <nbjorner@microsoft.com> * context goes out of scope in stack allocation, so can't used scoped context when passing objects around * parameter check Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * add rewriter Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * Fixed bug in user-propagator "created" (#5843) Co-authored-by: Clemens Eisenhofer <56730610+CEisenhofer@users.noreply.github.com>
This commit is contained in:
parent
2e15e2aa4d
commit
2e00f2f32d
22 changed files with 261 additions and 328 deletions
|
@ -11261,7 +11261,7 @@ def user_prop_fresh(id, ctx):
|
|||
def user_prop_fixed(ctx, cb, id, value):
|
||||
prop = _prop_closures.get(ctx)
|
||||
prop.cb = cb
|
||||
prop.fixed(id, _to_expr_ref(ctypes.c_void_p(value), prop.ctx()))
|
||||
prop.fixed(_to_expr_ref(ctypes.c_void_p(id), prop.ctx()), _to_expr_ref(ctypes.c_void_p(value), prop.ctx()))
|
||||
prop.cb = None
|
||||
|
||||
|
||||
|
@ -11275,6 +11275,8 @@ def user_prop_final(ctx, cb):
|
|||
def user_prop_eq(ctx, cb, x, y):
|
||||
prop = _prop_closures.get(ctx)
|
||||
prop.cb = cb
|
||||
x = _to_expr_ref(ctypes.c_void_p(x), prop.ctx())
|
||||
y = _to_expr_ref(ctypes.c_void_p(y), prop.ctx())
|
||||
prop.eq(x, y)
|
||||
prop.cb = None
|
||||
|
||||
|
@ -11282,6 +11284,8 @@ def user_prop_eq(ctx, cb, x, y):
|
|||
def user_prop_diseq(ctx, cb, x, y):
|
||||
prop = _prop_closures.get(ctx)
|
||||
prop.cb = cb
|
||||
x = _to_expr_ref(ctypes.c_void_p(x), prop.ctx())
|
||||
y = _to_expr_ref(ctypes.c_void_p(y), prop.ctx())
|
||||
prop.diseq(x, y)
|
||||
prop.cb = None
|
||||
|
||||
|
@ -11385,18 +11389,12 @@ class UserPropagateBase:
|
|||
# Propagation can only be invoked as during a fixed or final callback.
|
||||
#
|
||||
def propagate(self, e, ids, eqs=[]):
|
||||
num_fixed = len(ids)
|
||||
_ids = (ctypes.c_uint * num_fixed)()
|
||||
for i in range(num_fixed):
|
||||
_ids[i] = ids[i]
|
||||
_ids, num_fixed = _to_ast_array(ids)
|
||||
num_eqs = len(eqs)
|
||||
_lhs = (ctypes.c_uint * num_eqs)()
|
||||
_rhs = (ctypes.c_uint * num_eqs)()
|
||||
for i in range(num_eqs):
|
||||
_lhs[i] = eqs[i][0]
|
||||
_rhs[i] = eqs[i][1]
|
||||
_lhs, _num_lhs = _to_ast_array([x for x, y in eqs])
|
||||
_rhs, _num_lhs = _to_ast_array([y for x, y in eqs])
|
||||
Z3_solver_propagate_consequence(e.ctx.ref(), ctypes.c_void_p(
|
||||
self.cb), num_fixed, _ids, num_eqs, _lhs, _rhs, e.ast)
|
||||
|
||||
def conflict(self, ids):
|
||||
self.propagate(BoolVal(False, self.ctx()), ids, eqs=[])
|
||||
def conflict(self, deps):
|
||||
self.propagate(BoolVal(False, self.ctx()), deps, eqs=[])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue