19package com.microsoft.z3;
21import com.microsoft.z3.enumerations.Z3_lbool;
23import java.lang.ref.ReferenceQueue;
29@SuppressWarnings(
"unchecked")
36 return Native.solverGetHelp(getContext().nCtx(), getNativeObject());
46 getContext().checkContextMatch(value);
47 Native.solverSetParams(getContext().nCtx(), getNativeObject(),
48 value.getNativeObject());
58 return new ParamDescrs(getContext(), Native.solverGetParamDescrs(
59 getContext().nCtx(), getNativeObject()));
70 .solverGetNumScopes(getContext().nCtx(), getNativeObject());
79 Native.solverPush(getContext().nCtx(), getNativeObject());
98 public void pop(
int n)
100 Native.solverPop(getContext().nCtx(), getNativeObject(), n);
110 Native.solverReset(getContext().nCtx(), getNativeObject());
120 Native.solverInterrupt(getContext().nCtx(), getNativeObject());
130 getContext().checkContextMatch(constraints);
133 Native.solverAssert(getContext().nCtx(), getNativeObject(),
134 a.getNativeObject());
155 getContext().checkContextMatch(constraints);
156 getContext().checkContextMatch(ps);
157 if (constraints.length != ps.length) {
161 for (
int i = 0; i < constraints.length; i++) {
162 Native.solverAssertAndTrack(getContext().nCtx(), getNativeObject(),
163 constraints[i].getNativeObject(), ps[i].getNativeObject());
182 getContext().checkContextMatch(constraint);
183 getContext().checkContextMatch(p);
185 Native.solverAssertAndTrack(getContext().nCtx(), getNativeObject(),
186 constraint.getNativeObject(), p.getNativeObject());
194 Native.solverFromFile(getContext().nCtx(), getNativeObject(), file);
202 Native.solverFromString(getContext().nCtx(), getNativeObject(), str);
213 ASTVector assrts =
new ASTVector(getContext(), Native.solverGetAssertions(getContext().nCtx(), getNativeObject()));
214 return assrts.
size();
224 ASTVector assrts =
new ASTVector(getContext(), Native.solverGetAssertions(getContext().nCtx(), getNativeObject()));
239 if (assumptions ==
null) {
244 .nCtx(), getNativeObject(), assumptions.length,
AST
247 return lboolToStatus(r);
257 @SuppressWarnings(
"rawtypes")
260 return check((
Expr[])
null);
281 int r = Native.solverGetConsequences(getContext().nCtx(), getNativeObject(), asms.getNativeObject(), vars.getNativeObject(), result.getNativeObject());
282 for (
int i = 0; i < result.
size(); ++i) consequences.add((
BoolExpr)
Expr.create(getContext(), result.
get(i).getNativeObject()));
283 return lboolToStatus(
Z3_lbool.fromInt(r));
298 long x = Native.solverGetModel(getContext().nCtx(), getNativeObject());
302 return new Model(getContext(), x);
317 long x = Native.solverGetProof(getContext().nCtx(), getNativeObject());
321 return Expr.create(getContext(), x);
337 ASTVector core =
new ASTVector(getContext(), Native.solverGetUnsatCore(getContext().nCtx(), getNativeObject()));
347 return Native.solverGetReasonUnknown(getContext().nCtx(),
356 return new Solver(ctx, Native.solverTranslate(getContext().nCtx(), getNativeObject(), ctx.
nCtx()));
366 return new Statistics(getContext(), Native.solverGetStatistics(
367 getContext().nCtx(), getNativeObject()));
377 .solverToString(getContext().nCtx(), getNativeObject());
396 Solver(Context ctx,
long obj)
403 Native.solverIncRef(getContext().nCtx(), getNativeObject());
407 void addToReferenceQueue() {
408 getContext().getReferenceQueue().storeReference(
this, SolverRef::new);
411 private static class SolverRef
extends Z3ReferenceQueue.Reference<Solver> {
413 private SolverRef(Solver referent, ReferenceQueue<Z3Object> q) {
418 void decRef(Context ctx,
long z3Obj) {
419 Native.solverDecRef(ctx.nCtx(), z3Obj);
BoolExpr[] ToBoolExprArray()
Solver translate(Context ctx)
Status getConsequences(Expr< BoolSort >[] assumptions, Expr<?>[] variables, List< Expr< BoolSort > > consequences)
ParamDescrs getParameterDescriptions()
final Status check(Expr< BoolSort >... assumptions)
void assertAndTrack(Expr< BoolSort > constraint, Expr< BoolSort > p)
void setParameters(Params value)
BoolExpr[] getUnsatCore()
BoolExpr[] getAssertions()
void fromString(String str)
Load solver assertions from a string.
void add(Expr< BoolSort >... constraints)
void fromFile(String file)
Load solver assertions from a file.
String getReasonUnknown()
void assertAndTrack(Expr< BoolSort >[] constraints, Expr< BoolSort >[] ps)
Statistics getStatistics()
static long[] arrayToNative(Z3Object[] a)
static Status fromInt(int v)
Z3_lbool
Lifted Boolean type: false, undefined, true.