40 getContext().checkContextMatch(a);
55 getContext().checkContextMatch(f);
58 "Non-zero arity functions have FunctionInterpretations as a model. Use getFuncInterp.");
60 long n = Native.modelGetConstInterp(getContext().nCtx(), getNativeObject(),
78 getContext().checkContextMatch(f);
81 .nCtx(), Native.getRange(getContext().nCtx(), f.getNativeObject())));
85 long n = Native.modelGetConstInterp(getContext().nCtx(),
86 getNativeObject(), f.getNativeObject());
94 if (Native.isAsArray(getContext().nCtx(), n)) {
95 long fd = Native.getAsArrayFuncDecl(getContext().nCtx(), n);
96 return getFuncInterp(
new FuncDecl<>(getContext(), fd));
103 "Constant functions do not have a function interpretation; use getConstInterp");
107 long n = Native.modelGetFuncInterp(getContext().nCtx(),
108 getNativeObject(), f.getNativeObject());
121 return Native.modelGetNumConsts(getContext().nCtx(), getNativeObject());
131 int n = getNumConsts();
133 for (
int i = 0; i < n; i++)
134 res[i] =
new FuncDecl<>(getContext(), Native.modelGetConstDecl(getContext()
135 .nCtx(), getNativeObject(), i));
144 return Native.modelGetNumFuncs(getContext().nCtx(), getNativeObject());
154 int n = getNumFuncs();
156 for (
int i = 0; i < n; i++)
157 res[i] =
new FuncDecl<>(getContext(), Native.modelGetFuncDecl(getContext()
158 .nCtx(), getNativeObject(), i));
169 int nFuncs = getNumFuncs();
170 int nConsts = getNumConsts();
171 int n = nFuncs + nConsts;
173 for (
int i = 0; i < nConsts; i++)
174 res[i] =
new FuncDecl<>(getContext(), Native.modelGetConstDecl(getContext()
175 .nCtx(), getNativeObject(), i));
176 for (
int i = 0; i < nFuncs; i++)
177 res[nConsts + i] =
new FuncDecl<>(getContext(), Native.modelGetFuncDecl(
178 getContext().nCtx(), getNativeObject(), i));
186 @SuppressWarnings(
"serial")
211 public <R extends Sort>
Expr<R> eval(
Expr<R> t,
boolean completion)
213 Native.LongPtr v =
new Native.LongPtr();
214 if (!Native.modelEval(getContext().nCtx(), getNativeObject(),
215 t.getNativeObject(), (completion), v))
216 throw new ModelEvaluationFailedException();
218 return (
Expr<R>)
Expr.create(getContext(), v.value);
226 public <R extends Sort> Expr<R> evaluate(Expr<R> t,
boolean completion)
228 return eval(t, completion);
237 return Native.modelGetNumSorts(getContext().nCtx(), getNativeObject());
254 int n = getNumSorts();
256 for (
int i = 0; i < n; i++)
257 res[i] =
Sort.create(getContext(),
258 Native.modelGetSort(getContext().nCtx(), getNativeObject(), i));
271 public <R extends Sort>
Expr<R>[] getSortUniverse(R s)
275 getContext().nCtx(), getNativeObject(), s.getNativeObject()));
286 return Native.modelToString(getContext().nCtx(), getNativeObject());
296 Native.modelIncRef(getContext().nCtx(), getNativeObject());
300 void addToReferenceQueue() {
301 getContext().getReferenceQueue().storeReference(
this, ModelRef::new);
304 private static class ModelRef
extends Z3ReferenceQueue.Reference<Model> {
306 private ModelRef(Model referent, ReferenceQueue<Z3Object> q) {
311 void decRef(Context ctx,
long z3Obj) {
312 Native.modelDecRef(ctx.nCtx(), z3Obj);