3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-13 01:16:15 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2018-10-03 17:43:42 -07:00
parent 46cdefac4d
commit 3bc2213d54
12 changed files with 152 additions and 32 deletions

View file

@ -161,9 +161,23 @@ public class Optimize extends Z3Object {
* Produce a model that (when the objectives are bounded and
* don't use strict inequalities) meets the objectives.
**/
public Status Check()
public Status Check(Expr... assumptions)
{
Z3_lbool r = Z3_lbool.fromInt(Native.optimizeCheck(getContext().nCtx(), getNativeObject()));
Z3_lbool r;
if (assumptions == null) {
r = Z3_lbool.fromInt(
Native.optimizeCheck(
getContext().nCtx(),
getNativeObject(), 0, null);
}
else {
r = Z3_lbool.fromInt(
Native.optimizeCheck(
getContext().nCtx(),
getNativeObject(),
assumptions.length,
AST.arrayToNative(assumptions)));
}
switch (r) {
case Z3_L_TRUE:
return Status.SATISFIABLE;
@ -209,6 +223,21 @@ public class Optimize extends Z3Object {
}
}
/**
* The unsat core of the last {@code Check}.
* Remarks: The unsat core
* is a subset of {@code Assumptions} The result is empty if
* {@code Check} was not invoked before, if its results was not
* {@code UNSATISFIABLE}, or if core production is disabled.
*
* @throws Z3Exception
**/
public BoolExpr[] getUnsatCore()
{
ASTVector core = new ASTVector(getContext(), Native.optimizeGetUnsatCore(getContext().nCtx(), getNativeObject()));
return core.ToBoolExprArray();
}
/**
* Declare an arithmetical maximization objective.
* Return a handle to the objective. The handle is used as