mirror of
https://github.com/Z3Prover/z3
synced 2025-04-15 13:28:47 +00:00
parent
983a552325
commit
dd5744a357
|
@ -19,6 +19,7 @@ Notes:
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
import com.microsoft.z3.enumerations.Z3_lbool;
|
import com.microsoft.z3.enumerations.Z3_lbool;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Solvers.
|
* Solvers.
|
||||||
|
@ -229,15 +230,7 @@ public class Solver extends Z3Object {
|
||||||
.nCtx(), getNativeObject(), assumptions.length, AST
|
.nCtx(), getNativeObject(), assumptions.length, AST
|
||||||
.arrayToNative(assumptions)));
|
.arrayToNative(assumptions)));
|
||||||
}
|
}
|
||||||
switch (r)
|
return lboolToStatus(r);
|
||||||
{
|
|
||||||
case Z3_L_TRUE:
|
|
||||||
return Status.SATISFIABLE;
|
|
||||||
case Z3_L_FALSE:
|
|
||||||
return Status.UNSATISFIABLE;
|
|
||||||
default:
|
|
||||||
return Status.UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -252,6 +245,30 @@ public class Solver extends Z3Object {
|
||||||
return check((Expr[]) null);
|
return check((Expr[]) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve fixed assignments to the set of variables in the form of consequences.
|
||||||
|
* Each consequence is an implication of the form
|
||||||
|
*
|
||||||
|
* relevant-assumptions Implies variable = value
|
||||||
|
*
|
||||||
|
* where the relevant assumptions is a subset of the assumptions that are passed in
|
||||||
|
* and the equality on the right side of the implication indicates how a variable
|
||||||
|
* is fixed.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public Status getConsequences(BoolExpr[] assumptions, Expr[] variables, List<BoolExpr> consequences)
|
||||||
|
{
|
||||||
|
ASTVector result = new ASTVector(getContext());
|
||||||
|
ASTVector asms = new ASTVector(getContext());
|
||||||
|
ASTVector vars = new ASTVector(getContext());
|
||||||
|
for (BoolExpr asm : assumptions) asms.push(asm);
|
||||||
|
for (Expr v : variables) vars.push(v);
|
||||||
|
int r = Native.solverGetConsequences(getContext().nCtx(), getNativeObject(), asms.getNativeObject(), vars.getNativeObject(), result.getNativeObject());
|
||||||
|
for (int i = 0; i < result.size(); ++i) consequences.add((BoolExpr)result.get(i));
|
||||||
|
return lboolToStatus(Z3_lbool.fromInt(r));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The model of the last {@code Check}.
|
* The model of the last {@code Check}.
|
||||||
* Remarks: The result is
|
* Remarks: The result is
|
||||||
|
@ -345,6 +362,22 @@ public class Solver extends Z3Object {
|
||||||
.solverToString(getContext().nCtx(), getNativeObject());
|
.solverToString(getContext().nCtx(), getNativeObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* convert lifted Boolean to status
|
||||||
|
*/
|
||||||
|
private Status lboolToStatus(Z3_lbool r)
|
||||||
|
{
|
||||||
|
switch (r)
|
||||||
|
{
|
||||||
|
case Z3_L_TRUE:
|
||||||
|
return Status.SATISFIABLE;
|
||||||
|
case Z3_L_FALSE:
|
||||||
|
return Status.UNSATISFIABLE;
|
||||||
|
default:
|
||||||
|
return Status.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Solver(Context ctx, long obj)
|
Solver(Context ctx, long obj)
|
||||||
{
|
{
|
||||||
super(ctx, obj);
|
super(ctx, obj);
|
||||||
|
|
Loading…
Reference in a new issue