3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

add backtrack level to cuber interface

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2017-11-08 21:44:21 -08:00
parent 0a9946578b
commit 75b8d10f48
22 changed files with 53 additions and 40 deletions

View file

@ -529,9 +529,9 @@ extern "C" {
Z3_CATCH_RETURN(Z3_L_UNDEF);
}
Z3_ast Z3_API Z3_solver_cube(Z3_context c, Z3_solver s) {
Z3_ast Z3_API Z3_solver_cube(Z3_context c, Z3_solver s, unsigned cutoff) {
Z3_TRY;
LOG_Z3_solver_cube(c, s);
LOG_Z3_solver_cube(c, s, cutoff);
ast_manager& m = mk_c(c)->m();
expr_ref result(m);
unsigned timeout = to_solver(s)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
@ -544,7 +544,7 @@ extern "C" {
scoped_timer timer(timeout, &eh);
scoped_rlimit _rlimit(mk_c(c)->m().limit(), rlimit);
try {
result = to_solver_ref(s)->cube();
result = to_solver_ref(s)->cube(cutoff);
}
catch (z3_exception & ex) {
mk_c(c)->handle_exception(ex);

View file

@ -353,6 +353,12 @@ namespace Microsoft.Z3
}
}
/// <summary>
/// Backtrack level that can be adjusted by conquer process
/// </summary>
public uint BacktrackLevel { get; set; }
/// <summary>
/// Return a set of cubes.
/// </summary>
@ -360,10 +366,8 @@ namespace Microsoft.Z3
{
int rounds = 0;
while (true) {
BoolExpr r = (BoolExpr)Expr.Create(Context, Native.Z3_solver_cube(Context.nCtx, NativeObject));
BoolExpr r = (BoolExpr)Expr.Create(Context, Native.Z3_solver_cube(Context.nCtx, NativeObject, BacktrackLevel));
if (r.IsFalse) {
if (rounds == 0)
yield return r;
break;
}
if (r.IsTrue) {
@ -412,6 +416,7 @@ namespace Microsoft.Z3
: base(ctx, obj)
{
Contract.Requires(ctx != null);
this.BacktrackLevel = uint.MaxValue;
}
internal class DecRefQueue : IDecRefQueue

View file

@ -6283,19 +6283,16 @@ class Solver(Z3PPObject):
consequences = [ consequences[i] for i in range(sz) ]
return CheckSatResult(r), consequences
def cube(self):
def cube(self, level_ref):
"""Get set of cubes"""
rounds = 0
while True:
r = _to_expr_ref(Z3_solver_cube(self.ctx.ref(), self.solver), self.ctx)
backtrack_level = level_ref.backtrack_level
r = _to_expr_ref(Z3_solver_cube(self.ctx.ref(), self.solver, backtrack_level), self.ctx)
if (is_false(r)):
if (rounds == 0):
yield r
return
if (is_true(r)):
yield r
return
rounds += 1
yield r
def proof(self):

View file

@ -6232,10 +6232,13 @@ extern "C" {
The number of (non-constant) cubes is by default 1. For the sat solver cubing is controlled
using parameters sat.lookahead.cube.cutoff and sat.lookahead.cube.fraction.
def_API('Z3_solver_cube', AST, (_in(CONTEXT), _in(SOLVER)))
The last argument is a backtracking level. It instructs the cube process to backtrack below
the indicated level for the next cube.
def_API('Z3_solver_cube', AST, (_in(CONTEXT), _in(SOLVER), _in(UINT)))
*/
Z3_ast Z3_API Z3_solver_cube(Z3_context c, Z3_solver s);
Z3_ast Z3_API Z3_solver_cube(Z3_context c, Z3_solver s, unsigned backtrack_level);
/**
\brief Retrieve the model for the last #Z3_solver_check or #Z3_solver_check_assumptions