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());
157 getContext().checkContextMatch(constraints);
158 getContext().checkContextMatch(ps);
159 if (constraints.length != ps.length) {
163 for (
int i = 0; i < constraints.length; i++) {
164 Native.solverAssertAndTrack(getContext().nCtx(), getNativeObject(),
165 constraints[i].getNativeObject(), ps[i].getNativeObject());
186 getContext().checkContextMatch(constraint);
187 getContext().checkContextMatch(p);
189 Native.solverAssertAndTrack(getContext().nCtx(), getNativeObject(),
190 constraint.getNativeObject(), p.getNativeObject());
198 Native.solverFromFile(getContext().nCtx(), getNativeObject(), file);
206 Native.solverFromString(getContext().nCtx(), getNativeObject(), str);
217 ASTVector assrts =
new ASTVector(getContext(), Native.solverGetAssertions(getContext().nCtx(), getNativeObject()));
218 return assrts.
size();
228 ASTVector assrts =
new ASTVector(getContext(), Native.solverGetAssertions(getContext().nCtx(), getNativeObject()));
243 if (assumptions ==
null) {
248 .nCtx(), getNativeObject(), assumptions.length,
AST
251 return lboolToStatus(r);
261 @SuppressWarnings(
"rawtypes")
264 return check((
Expr[])
null);
285 int r = Native.solverGetConsequences(getContext().nCtx(), getNativeObject(), asms.getNativeObject(), vars.getNativeObject(), result.getNativeObject());
286 for (
int i = 0; i < result.
size(); ++i) consequences.add((
BoolExpr)
Expr.create(getContext(), result.
get(i).getNativeObject()));
287 return lboolToStatus(
Z3_lbool.fromInt(r));
302 long x = Native.solverGetModel(getContext().nCtx(), getNativeObject());
306 return new Model(getContext(), x);
321 long x = Native.solverGetProof(getContext().nCtx(), getNativeObject());
325 return Expr.create(getContext(), x);
341 ASTVector core =
new ASTVector(getContext(), Native.solverGetUnsatCore(getContext().nCtx(), getNativeObject()));
355 ASTVector units =
new ASTVector(getContext(), Native.solverGetUnits(getContext().nCtx(), getNativeObject()));
368 ASTVector nonUnits =
new ASTVector(getContext(), Native.solverGetNonUnits(getContext().nCtx(), getNativeObject()));
383 ASTVector trail =
new ASTVector(getContext(), Native.solverGetTrail(getContext().nCtx(), getNativeObject()));
393 return Native.solverGetReasonUnknown(getContext().nCtx(),
407 ASTVector trailVector =
new ASTVector(getContext(), Native.solverGetTrail(getContext().nCtx(), getNativeObject()));
408 int[] levels =
new int[trailVector.
size()];
409 Native.solverGetLevels(getContext().nCtx(), getNativeObject(), trailVector.getNativeObject(), trailVector.
size(), levels);
434 return new java.util.Iterator<
BoolExpr[]>() {
435 private BoolExpr[] nextCube = computeNext();
439 Native.solverCube(getContext().nCtx(), getNativeObject(),
440 cubeVars.getNativeObject(), cutoff));
444 if (cube.length == 1 && cube[0].
isFalse()) {
447 if (cube.length == 0) {
454 public boolean hasNext() {
455 return nextCube !=
null;
460 if (nextCube ==
null) {
461 throw new java.util.NoSuchElementException();
464 nextCube = computeNext();
480 getContext().checkContextMatch(t);
481 return Expr.create(getContext(),
482 Native.solverCongruenceRoot(getContext().nCtx(), getNativeObject(), t.getNativeObject()));
495 getContext().checkContextMatch(t);
496 return Expr.create(getContext(),
497 Native.solverCongruenceNext(getContext().nCtx(), getNativeObject(), t.getNativeObject()));
510 getContext().checkContextMatch(a);
511 getContext().checkContextMatch(b);
512 return Expr.create(getContext(),
513 Native.solverCongruenceExplain(getContext().nCtx(), getNativeObject(),
514 a.getNativeObject(), b.getNativeObject()));
534 Native.solverSolveFor(getContext().nCtx(), getNativeObject(),
535 vars.getNativeObject(), termVec.getNativeObject(), guardVec.getNativeObject());
548 getContext().checkContextMatch(var);
549 getContext().checkContextMatch(value);
550 Native.solverSetInitialValue(getContext().nCtx(), getNativeObject(),
551 var.getNativeObject(), value.getNativeObject());
561 Native.solverImportModelConverter(getContext().nCtx(), src.getNativeObject(), getNativeObject());
569 return new Solver(ctx, Native.solverTranslate(getContext().nCtx(), getNativeObject(), ctx.
nCtx()));
580 return new Solver(getContext(), Native.solverAddSimplifier(
581 getContext().nCtx(), getNativeObject(), simplifier.getNativeObject()));
592 return Native.solverToDimacsString(getContext().nCtx(), getNativeObject(), includeNames);
602 return new Statistics(getContext(), Native.solverGetStatistics(
603 getContext().nCtx(), getNativeObject()));
613 .solverToString(getContext().nCtx(), getNativeObject());
632 Solver(Context ctx,
long obj)
639 Native.solverIncRef(getContext().nCtx(), getNativeObject());
643 void addToReferenceQueue() {
644 getContext().getReferenceQueue().storeReference(
this, SolverRef::new);
647 private static class SolverRef
extends Z3ReferenceQueue.Reference<Solver> {
649 private SolverRef(Solver referent, ReferenceQueue<Z3Object> q) {
654 void decRef(Context ctx,
long z3Obj) {
655 Native.solverDecRef(ctx.nCtx(), z3Obj);
BoolExpr[] ToBoolExprArray()
void setInitialValue(Expr<?> var, Expr<?> value)
void solveFor(Expr<?>[] variables, Expr<?>[] terms, BoolExpr[] guards)
Solver translate(Context ctx)
Status getConsequences(Expr< BoolSort >[] assumptions, Expr<?>[] variables, List< Expr< BoolSort > > consequences)
ParamDescrs getParameterDescriptions()
String toDimacs(boolean includeNames)
final Status check(Expr< BoolSort >... assumptions)
void assertAndTrack(Expr< BoolSort > constraint, Expr< BoolSort > p)
Expr<?> congruenceExplain(Expr<?> a, Expr<?> b)
Expr<?> congruenceNext(Expr<?> t)
void setParameters(Params value)
BoolExpr[] getUnsatCore()
void importModelConverter(Solver src)
java.util.Iterator< BoolExpr[]> cube(Expr<?>[] vars, int cutoff)
Expr<?> congruenceRoot(Expr<?> t)
Solver addSimplifier(Simplifier simplifier)
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.