Z3
 
Loading...
Searching...
No Matches
Fixedpoint.java
Go to the documentation of this file.
1
18package com.microsoft.z3;
19
20import com.microsoft.z3.enumerations.Z3_lbool;
21
22import java.lang.ref.ReferenceQueue;
23
27public class Fixedpoint extends Z3Object
28{
29
33 public String getHelp()
34 {
35 return Native.fixedpointGetHelp(getContext().nCtx(), getNativeObject());
36 }
37
43 public void setParameters(Params value)
44 {
45
46 getContext().checkContextMatch(value);
47 Native.fixedpointSetParams(getContext().nCtx(), getNativeObject(),
48 value.getNativeObject());
49 }
50
57 {
58 return new ParamDescrs(getContext(), Native.fixedpointGetParamDescrs(
59 getContext().nCtx(), getNativeObject()));
60 }
61
67 @SafeVarargs
68 public final void add(Expr<BoolSort>... constraints)
69 {
70 getContext().checkContextMatch(constraints);
71 for (Expr<BoolSort> a : constraints)
72 {
73 Native.fixedpointAssert(getContext().nCtx(), getNativeObject(),
74 a.getNativeObject());
75 }
76 }
77
84 {
85 getContext().checkContextMatch(f);
86 Native.fixedpointRegisterRelation(getContext().nCtx(), getNativeObject(),
87 f.getNativeObject());
88 }
89
97 public void addRule(Expr<BoolSort> rule, Symbol name) {
98 getContext().checkContextMatch(rule);
99 Native.fixedpointAddRule(getContext().nCtx(), getNativeObject(),
100 rule.getNativeObject(), AST.getNativeObject(name));
101 }
102
108 public void addFact(FuncDecl<BoolSort> pred, int ... args) {
109 getContext().checkContextMatch(pred);
110 Native.fixedpointAddFact(getContext().nCtx(), getNativeObject(),
111 pred.getNativeObject(), args.length, args);
112 }
113
124 getContext().checkContextMatch(query);
125 Z3_lbool r = Z3_lbool.fromInt(Native.fixedpointQuery(getContext().nCtx(),
126 getNativeObject(), query.getNativeObject()));
127 switch (r)
128 {
129 case Z3_L_TRUE:
130 return Status.SATISFIABLE;
131 case Z3_L_FALSE:
132 return Status.UNSATISFIABLE;
133 default:
134 return Status.UNKNOWN;
135 }
136 }
137
146 public Status query(FuncDecl<BoolSort>[] relations) {
147 getContext().checkContextMatch(relations);
148 Z3_lbool r = Z3_lbool.fromInt(Native.fixedpointQueryRelations(getContext()
149 .nCtx(), getNativeObject(), AST.arrayLength(relations), AST
150 .arrayToNative(relations)));
151 switch (r)
152 {
153 case Z3_L_TRUE:
154 return Status.SATISFIABLE;
155 case Z3_L_FALSE:
156 return Status.UNSATISFIABLE;
157 default:
158 return Status.UNKNOWN;
159 }
160 }
161
169 public void updateRule(Expr<BoolSort> rule, Symbol name) {
170 getContext().checkContextMatch(rule);
171 Native.fixedpointUpdateRule(getContext().nCtx(), getNativeObject(),
172 rule.getNativeObject(), AST.getNativeObject(name));
173 }
174
182 {
183 long ans = Native.fixedpointGetAnswer(getContext().nCtx(), getNativeObject());
184 return (ans == 0) ? null : Expr.create(getContext(), ans);
185 }
186
190 public String getReasonUnknown()
191 {
192 return Native.fixedpointGetReasonUnknown(getContext().nCtx(),
193 getNativeObject());
194 }
195
199 public int getNumLevels(FuncDecl<BoolSort> predicate)
200 {
201 return Native.fixedpointGetNumLevels(getContext().nCtx(), getNativeObject(),
202 predicate.getNativeObject());
203 }
204
210 public Expr<?> getCoverDelta(int level, FuncDecl<BoolSort> predicate)
211 {
212 long res = Native.fixedpointGetCoverDelta(getContext().nCtx(),
213 getNativeObject(), level, predicate.getNativeObject());
214 return (res == 0) ? null : Expr.create(getContext(), res);
215 }
216
221 public void addCover(int level, FuncDecl<BoolSort> predicate, Expr<?> property)
222
223 {
224 Native.fixedpointAddCover(getContext().nCtx(), getNativeObject(), level,
225 predicate.getNativeObject(), property.getNativeObject());
226 }
227
231 @Override
232 public String toString()
233 {
234 return Native.fixedpointToString(getContext().nCtx(), getNativeObject(),
235 0, null);
236 }
237
243 {
244 Native.fixedpointSetPredicateRepresentation(getContext().nCtx(),
245 getNativeObject(), f.getNativeObject(), AST.arrayLength(kinds),
246 Symbol.arrayToNative(kinds));
247
248 }
249
253 public String toString(Expr<BoolSort>[] queries)
254 {
255 return Native.fixedpointToString(getContext().nCtx(), getNativeObject(),
256 AST.arrayLength(queries), AST.arrayToNative(queries));
257 }
258
265 {
266 ASTVector v = new ASTVector(getContext(), Native.fixedpointGetRules(getContext().nCtx(), getNativeObject()));
267 return v.ToBoolExprArray();
268 }
269
276 {
277 ASTVector v = new ASTVector(getContext(), Native.fixedpointGetAssertions(getContext().nCtx(), getNativeObject()));
278 return v.ToBoolExprArray();
279 }
280
287 {
288 return new Statistics(getContext(), Native.fixedpointGetStatistics(
289 getContext().nCtx(), getNativeObject()));
290 }
291
297 public BoolExpr[] ParseFile(String file)
298 {
299 ASTVector av = new ASTVector(getContext(), Native.fixedpointFromFile(getContext().nCtx(), getNativeObject(), file));
300 return av.ToBoolExprArray();
301 }
302
308 public BoolExpr[] ParseString(String s)
309 {
310 ASTVector av = new ASTVector(getContext(), Native.fixedpointFromString(getContext().nCtx(), getNativeObject(), s));
311 return av.ToBoolExprArray();
312 }
313
314
315 Fixedpoint(Context ctx, long obj) throws Z3Exception
316 {
317 super(ctx, obj);
318 }
319
320 Fixedpoint(Context ctx)
321 {
322 super(ctx, Native.mkFixedpoint(ctx.nCtx()));
323 }
324
325 @Override
326 void incRef() {
327 Native.fixedpointIncRef(getContext().nCtx(), getNativeObject());
328 }
329
330 @Override
331 void addToReferenceQueue() {
332 getContext().getReferenceQueue().storeReference(this, FixedpointRef::new);
333 }
334
335 private static class FixedpointRef extends Z3ReferenceQueue.Reference<Fixedpoint> {
336
337 private FixedpointRef(Fixedpoint referent, ReferenceQueue<Z3Object> q) {
338 super(referent, q);
339 }
340
341 @Override
342 void decRef(Context ctx, long z3Obj) {
343 Native.fixedpointDecRef(ctx.nCtx(), z3Obj);
344 }
345 }
346}
BoolExpr[] ParseString(String s)
void updateRule(Expr< BoolSort > rule, Symbol name)
Status query(Expr< BoolSort > query)
ParamDescrs getParameterDescriptions()
void registerRelation(FuncDecl< BoolSort > f)
void setParameters(Params value)
BoolExpr[] ParseFile(String file)
void setPredicateRepresentation(FuncDecl< BoolSort > f, Symbol[] kinds)
Status query(FuncDecl< BoolSort >[] relations)
int getNumLevels(FuncDecl< BoolSort > predicate)
void addCover(int level, FuncDecl< BoolSort > predicate, Expr<?> property)
String toString(Expr< BoolSort >[] queries)
final void add(Expr< BoolSort >... constraints)
void addFact(FuncDecl< BoolSort > pred, int ... args)
Expr<?> getCoverDelta(int level, FuncDecl< BoolSort > predicate)
void addRule(Expr< BoolSort > rule, Symbol name)
static long[] arrayToNative(Z3Object[] a)
Definition Z3Object.java:73
static int arrayLength(Z3Object[] a)
Definition Z3Object.java:83
Z3_lbool
Lifted Boolean type: false, undefined, true.
Definition z3_api.h:58
@ Z3_L_TRUE
Definition z3_api.h:61
@ Z3_L_FALSE
Definition z3_api.h:59