Z3
src/api/java/Fixedpoint.java
Go to the documentation of this file.
00001 
00018 package com.microsoft.z3;
00019 
00020 import com.microsoft.z3.enumerations.Z3_lbool;
00021 
00025 public class Fixedpoint extends Z3Object
00026 {
00027 
00031     public String getHelp()
00032     {
00033         return Native.fixedpointGetHelp(getContext().nCtx(), getNativeObject());
00034     }
00035 
00041     public void setParameters(Params value)
00042     {
00043 
00044         getContext().checkContextMatch(value);
00045         Native.fixedpointSetParams(getContext().nCtx(), getNativeObject(),
00046                 value.getNativeObject());
00047     }
00048 
00054     public ParamDescrs getParameterDescriptions()
00055     {
00056         return new ParamDescrs(getContext(), Native.fixedpointGetParamDescrs(
00057                 getContext().nCtx(), getNativeObject()));
00058     }
00059 
00065     public void add(BoolExpr ... constraints)
00066     {
00067         getContext().checkContextMatch(constraints);
00068         for (BoolExpr a : constraints)
00069         {
00070             Native.fixedpointAssert(getContext().nCtx(), getNativeObject(),
00071                     a.getNativeObject());
00072         }
00073     }
00074 
00080     public void registerRelation(FuncDecl f)
00081     {
00082 
00083         getContext().checkContextMatch(f);
00084         Native.fixedpointRegisterRelation(getContext().nCtx(), getNativeObject(),
00085                 f.getNativeObject());
00086     }
00087 
00093     public void addRule(BoolExpr rule, Symbol name)
00094     {
00095 
00096         getContext().checkContextMatch(rule);
00097         Native.fixedpointAddRule(getContext().nCtx(), getNativeObject(),
00098                 rule.getNativeObject(), AST.getNativeObject(name));
00099     }
00100 
00106     public void addFact(FuncDecl pred, int ... args)
00107     {
00108         getContext().checkContextMatch(pred);
00109         Native.fixedpointAddFact(getContext().nCtx(), getNativeObject(),
00110                 pred.getNativeObject(), (int) args.length, args);
00111     }
00112 
00122     public Status query(BoolExpr query)
00123     {
00124 
00125         getContext().checkContextMatch(query);
00126         Z3_lbool r = Z3_lbool.fromInt(Native.fixedpointQuery(getContext().nCtx(),
00127                 getNativeObject(), query.getNativeObject()));
00128         switch (r)
00129         {
00130         case Z3_L_TRUE:
00131             return Status.SATISFIABLE;
00132         case Z3_L_FALSE:
00133             return Status.UNSATISFIABLE;
00134         default:
00135             return Status.UNKNOWN;
00136         }
00137     }
00138 
00147     public Status query(FuncDecl[] relations)
00148     {
00149 
00150         getContext().checkContextMatch(relations);
00151         Z3_lbool r = Z3_lbool.fromInt(Native.fixedpointQueryRelations(getContext()
00152                 .nCtx(), getNativeObject(), AST.arrayLength(relations), AST
00153                 .arrayToNative(relations)));
00154         switch (r)
00155         {
00156         case Z3_L_TRUE:
00157             return Status.SATISFIABLE;
00158         case Z3_L_FALSE:
00159             return Status.UNSATISFIABLE;
00160         default:
00161             return Status.UNKNOWN;
00162         }
00163     }
00164 
00169     public void push()
00170     {
00171         Native.fixedpointPush(getContext().nCtx(), getNativeObject());
00172     }
00173 
00181     public void pop()
00182     {
00183         Native.fixedpointPop(getContext().nCtx(), getNativeObject());
00184     }
00185 
00191     public void updateRule(BoolExpr rule, Symbol name)
00192     {
00193 
00194         getContext().checkContextMatch(rule);
00195         Native.fixedpointUpdateRule(getContext().nCtx(), getNativeObject(),
00196                 rule.getNativeObject(), AST.getNativeObject(name));
00197     }
00198 
00205     public Expr getAnswer()
00206     {
00207         long ans = Native.fixedpointGetAnswer(getContext().nCtx(), getNativeObject());
00208         return (ans == 0) ? null : Expr.create(getContext(), ans);
00209     }
00210 
00214     public String getReasonUnknown()
00215     {
00216         return Native.fixedpointGetReasonUnknown(getContext().nCtx(),
00217                 getNativeObject());
00218     }
00219 
00223     public int getNumLevels(FuncDecl predicate)
00224     {
00225         return Native.fixedpointGetNumLevels(getContext().nCtx(), getNativeObject(),
00226                 predicate.getNativeObject());
00227     }
00228 
00234     public Expr getCoverDelta(int level, FuncDecl predicate)
00235     {
00236         long res = Native.fixedpointGetCoverDelta(getContext().nCtx(),
00237                 getNativeObject(), level, predicate.getNativeObject());
00238         return (res == 0) ? null : Expr.create(getContext(), res);
00239     }
00240 
00245     public void addCover(int level, FuncDecl predicate, Expr property)
00246            
00247     {
00248         Native.fixedpointAddCover(getContext().nCtx(), getNativeObject(), level,
00249                 predicate.getNativeObject(), property.getNativeObject());
00250     }
00251 
00255     public String toString()
00256     {
00257         try
00258         {
00259             return Native.fixedpointToString(getContext().nCtx(), getNativeObject(),
00260                     0, null);
00261         } catch (Z3Exception e)
00262         {
00263             return "Z3Exception: " + e.getMessage();
00264         }
00265     }
00266 
00271     public void setPredicateRepresentation(FuncDecl f, Symbol[] kinds)
00272     {
00273 
00274         Native.fixedpointSetPredicateRepresentation(getContext().nCtx(),
00275                 getNativeObject(), f.getNativeObject(), AST.arrayLength(kinds),
00276                 Symbol.arrayToNative(kinds));
00277 
00278     }
00279 
00283     public String toString(BoolExpr[] queries)
00284     {
00285 
00286         return Native.fixedpointToString(getContext().nCtx(), getNativeObject(),
00287                 AST.arrayLength(queries), AST.arrayToNative(queries));
00288     }
00289 
00295     public BoolExpr[] getRules()
00296     {
00297         ASTVector v = new ASTVector(getContext(), Native.fixedpointGetRules(getContext().nCtx(), getNativeObject()));
00298         return v.ToBoolExprArray();
00299     }
00300 
00306     public BoolExpr[] getAssertions()
00307     {
00308         ASTVector v = new ASTVector(getContext(), Native.fixedpointGetAssertions(getContext().nCtx(), getNativeObject()));
00309         return v.ToBoolExprArray();
00310     }
00311 
00317     public Statistics getStatistics()
00318     {
00319         return new Statistics(getContext(), Native.fixedpointGetStatistics(
00320                 getContext().nCtx(), getNativeObject()));
00321     }
00322 
00328     public BoolExpr[] ParseFile(String file)
00329     {
00330         ASTVector av = new ASTVector(getContext(), Native.fixedpointFromFile(getContext().nCtx(), getNativeObject(), file));
00331         return av.ToBoolExprArray();
00332     }
00333 
00339     public BoolExpr[] ParseString(String s)
00340     {
00341         ASTVector av = new ASTVector(getContext(), Native.fixedpointFromString(getContext().nCtx(), getNativeObject(), s));
00342         return av.ToBoolExprArray();
00343     }
00344     
00345 
00346     Fixedpoint(Context ctx, long obj) throws Z3Exception
00347     {
00348         super(ctx, obj);
00349     }
00350 
00351     Fixedpoint(Context ctx)
00352     {
00353         super(ctx, Native.mkFixedpoint(ctx.nCtx()));
00354     }
00355 
00356     void incRef(long o)
00357     {
00358         getContext().getFixedpointDRQ().incAndClear(getContext(), o);
00359         super.incRef(o);
00360     }
00361 
00362     void decRef(long o)
00363     {
00364         getContext().getFixedpointDRQ().add(o);
00365         super.decRef(o);
00366     }
00367 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines