Z3
src/api/java/Expr.java
Go to the documentation of this file.
00001 
00018 package com.microsoft.z3;
00019 
00020 import com.microsoft.z3.enumerations.Z3_ast_kind;
00021 import com.microsoft.z3.enumerations.Z3_decl_kind;
00022 import com.microsoft.z3.enumerations.Z3_lbool;
00023 import com.microsoft.z3.enumerations.Z3_sort_kind;
00024 
00025 /* using System; */
00026 
00030 public class Expr extends AST
00031 {
00038     public Expr simplify()
00039     {
00040         return simplify(null);
00041     }
00042 
00053     public Expr simplify(Params p)
00054     {
00055 
00056         if (p == null)
00057             return Expr.create(getContext(),
00058                     Native.simplify(getContext().nCtx(), getNativeObject()));
00059         else
00060             return Expr.create(
00061                     getContext(),
00062                     Native.simplifyEx(getContext().nCtx(), getNativeObject(),
00063                             p.getNativeObject()));
00064     }
00065 
00072     public FuncDecl getFuncDecl()
00073     {
00074         return new FuncDecl(getContext(), Native.getAppDecl(getContext().nCtx(),
00075                 getNativeObject()));
00076     }
00077 
00084     public Z3_lbool getBoolValue()
00085     {
00086         return Z3_lbool.fromInt(Native.getBoolValue(getContext().nCtx(),
00087                 getNativeObject()));
00088     }
00089 
00095     public int getNumArgs()
00096     {
00097         return Native.getAppNumArgs(getContext().nCtx(), getNativeObject());
00098     }
00099 
00105     public Expr[] getArgs()
00106     {
00107         int n = getNumArgs();
00108         Expr[] res = new Expr[n];
00109         for (int i = 0; i < n; i++)
00110             res[i] = Expr.create(getContext(),
00111                     Native.getAppArg(getContext().nCtx(), getNativeObject(), i));
00112         return res;
00113     }
00114 
00122     public void update(Expr[] args)
00123     {
00124         getContext().checkContextMatch(args);
00125         if (isApp() && args.length != getNumArgs())
00126             throw new Z3Exception("Number of arguments does not match");
00127         setNativeObject(Native.updateTerm(getContext().nCtx(), getNativeObject(),
00128                 (int) args.length, Expr.arrayToNative(args)));
00129     }
00130 
00143     public Expr substitute(Expr[] from, Expr[] to)
00144     {
00145         getContext().checkContextMatch(from);
00146         getContext().checkContextMatch(to);
00147         if (from.length != to.length)
00148             throw new Z3Exception("Argument sizes do not match");
00149         return Expr.create(getContext(), Native.substitute(getContext().nCtx(),
00150                 getNativeObject(), (int) from.length, Expr.arrayToNative(from),
00151                 Expr.arrayToNative(to)));
00152     }
00153 
00161     public Expr substitute(Expr from, Expr to)
00162     {
00163 
00164         return substitute(new Expr[] { from }, new Expr[] { to });
00165     }
00166 
00177     public Expr substituteVars(Expr[] to)
00178     {
00179 
00180         getContext().checkContextMatch(to);
00181         return Expr.create(getContext(), Native.substituteVars(getContext().nCtx(),
00182                 getNativeObject(), (int) to.length, Expr.arrayToNative(to)));
00183     }
00184 
00194     public Expr translate(Context ctx)
00195     {
00196 
00197         if (getContext() == ctx)
00198             return this;
00199         else
00200             return Expr.create(
00201                     ctx,
00202                     Native.translate(getContext().nCtx(), getNativeObject(),
00203                             ctx.nCtx()));
00204     }
00205 
00209     public String toString()
00210     {
00211         return super.toString();
00212     }
00213 
00219     public boolean isNumeral()
00220     {
00221         return Native.isNumeralAst(getContext().nCtx(), getNativeObject());
00222     }
00223 
00231     public boolean isWellSorted()
00232     {
00233         return Native.isWellSorted(getContext().nCtx(), getNativeObject());
00234     }
00235 
00241     public Sort getSort()
00242     {
00243         return Sort.create(getContext(),
00244                 Native.getSort(getContext().nCtx(), getNativeObject()));
00245     }
00246 
00252     public boolean isConst()
00253     {
00254         return isApp() && getNumArgs() == 0 && getFuncDecl().getDomainSize() == 0;
00255     }
00256 
00262     public boolean isIntNum()
00263     {
00264         return isNumeral() && isInt();
00265     }
00266 
00272     public boolean isRatNum()
00273     {
00274         return isNumeral() && isReal();
00275     }
00276 
00282     public boolean isAlgebraicNumber()
00283     {
00284         return Native.isAlgebraicNumber(getContext().nCtx(), getNativeObject());
00285     }
00286 
00292     public boolean isBool()
00293     {
00294         return (isExpr() && Native.isEqSort(getContext().nCtx(),
00295                 Native.mkBoolSort(getContext().nCtx()),
00296                 Native.getSort(getContext().nCtx(), getNativeObject())));
00297     }
00298 
00304     public boolean isTrue()
00305     {
00306             return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_TRUE;
00307     }
00308 
00314     public boolean isFalse()
00315     {
00316         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FALSE;
00317     }
00318 
00324     public boolean isEq()
00325     {
00326         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_EQ;
00327     }
00328 
00335     public boolean isDistinct()
00336     {
00337         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_DISTINCT;
00338     }
00339 
00345     public boolean isITE()
00346     {
00347         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ITE;
00348     }
00349 
00355     public boolean isAnd()
00356     {
00357         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_AND;
00358     }
00359 
00365     public boolean isOr()
00366     {
00367         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_OR;
00368     }
00369 
00376     public boolean isIff()
00377     {
00378         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_IFF;
00379     }
00380 
00386     public boolean isXor()
00387     {
00388         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_XOR;
00389     }
00390 
00396     public boolean isNot()
00397     {
00398         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_NOT;
00399     }
00400 
00406     public boolean isImplies()
00407     {
00408         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_IMPLIES;
00409     }
00410 
00416     public boolean isInt()
00417     {
00418         return (Native.isNumeralAst(getContext().nCtx(), getNativeObject()) && Native
00419                 .getSortKind(getContext().nCtx(),
00420                         Native.getSort(getContext().nCtx(), getNativeObject())) == Z3_sort_kind.Z3_INT_SORT
00421                 .toInt());
00422     }
00423 
00429     public boolean isReal()
00430     {
00431         return Native.getSortKind(getContext().nCtx(),
00432                 Native.getSort(getContext().nCtx(), getNativeObject())) == Z3_sort_kind.Z3_REAL_SORT
00433                 .toInt();
00434     }
00435 
00441     public boolean isArithmeticNumeral()
00442     {
00443         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ANUM;
00444     }
00445 
00451     public boolean isLE()
00452     {
00453         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_LE;
00454     }
00455 
00461     public boolean isGE()
00462     {
00463         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_GE;
00464     }
00465 
00471     public boolean isLT()
00472     {
00473         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_LT;
00474     }
00475 
00481     public boolean isGT()
00482     {
00483         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_GT;
00484     }
00485 
00491     public boolean isAdd()
00492     {
00493         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ADD;
00494     }
00495 
00501     public boolean isSub()
00502     {
00503         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SUB;
00504     }
00505 
00511     public boolean isUMinus()
00512     {
00513         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_UMINUS;
00514     }
00515 
00521     public boolean isMul()
00522     {
00523         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_MUL;
00524     }
00525 
00531     public boolean isDiv()
00532     {
00533         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_DIV;
00534     }
00535 
00541     public boolean isIDiv()
00542     {
00543         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_IDIV;
00544     }
00545 
00551     public boolean isRemainder()
00552     {
00553         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_REM;
00554     }
00555 
00561     public boolean isModulus()
00562     {
00563         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_MOD;
00564     }
00565 
00571     public boolean isIntToReal()
00572     {
00573         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_TO_REAL;
00574     }
00575 
00581     public boolean isRealToInt()
00582     {
00583         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_TO_INT;
00584     }
00585 
00592     public boolean isRealIsInt()
00593     {
00594         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_IS_INT;
00595     }
00596 
00602     public boolean isArray()
00603     {
00604         return (Native.isApp(getContext().nCtx(), getNativeObject()) && Z3_sort_kind
00605                 .fromInt(Native.getSortKind(getContext().nCtx(),
00606                         Native.getSort(getContext().nCtx(), getNativeObject()))) == Z3_sort_kind.Z3_ARRAY_SORT);
00607     }
00608 
00615     public boolean isStore()
00616     {
00617         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_STORE;
00618     }
00619 
00625     public boolean isSelect()
00626     {
00627         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SELECT;
00628     }
00629 
00636     public boolean isConstantArray()
00637     {
00638         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_CONST_ARRAY;
00639     }
00640 
00647     public boolean isDefaultArray()
00648     {
00649         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ARRAY_DEFAULT;
00650     }
00651 
00659     public boolean isArrayMap()
00660     {
00661         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ARRAY_MAP;
00662     }
00663 
00670     public boolean isAsArray()
00671     {
00672         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_AS_ARRAY;
00673     }
00674 
00680     public boolean isSetUnion()
00681     {
00682         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SET_UNION;
00683     }
00684 
00690     public boolean isSetIntersect()
00691     {
00692         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SET_INTERSECT;
00693     }
00694 
00700     public boolean isSetDifference()
00701     {
00702         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SET_DIFFERENCE;
00703     }
00704 
00710     public boolean isSetComplement()
00711     {
00712         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SET_COMPLEMENT;
00713     }
00714 
00720     public boolean isSetSubset()
00721     {
00722         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SET_SUBSET;
00723     }
00724 
00730     public boolean isBV()
00731     {
00732         return Native.getSortKind(getContext().nCtx(),
00733                 Native.getSort(getContext().nCtx(), getNativeObject())) == Z3_sort_kind.Z3_BV_SORT
00734                 .toInt();
00735     }
00736 
00742     public boolean isBVNumeral()
00743     {
00744         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BNUM;
00745     }
00746 
00752     public boolean isBVBitOne()
00753     {
00754         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BIT1;
00755     }
00756 
00762     public boolean isBVBitZero()
00763     {
00764         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BIT0;
00765     }
00766 
00772     public boolean isBVUMinus()
00773     {
00774         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BNEG;
00775     }
00776 
00782     public boolean isBVAdd()
00783     {
00784         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BADD;
00785     }
00786 
00792     public boolean isBVSub()
00793     {
00794         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSUB;
00795     }
00796 
00802     public boolean isBVMul()
00803     {
00804         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BMUL;
00805     }
00806 
00812     public boolean isBVSDiv()
00813     {
00814         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSDIV;
00815     }
00816 
00822     public boolean isBVUDiv()
00823     {
00824         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BUDIV;
00825     }
00826 
00832     public boolean isBVSRem()
00833     {
00834         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSREM;
00835     }
00836 
00842     public boolean isBVURem()
00843     {
00844         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BUREM;
00845     }
00846 
00852     public boolean isBVSMod()
00853     {
00854         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSMOD;
00855     }
00856 
00862     boolean isBVSDiv0()
00863     {
00864         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSDIV0;
00865     }
00866 
00872     boolean isBVUDiv0()
00873     {
00874         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BUDIV0;
00875     }
00876 
00882     boolean isBVSRem0()
00883     {
00884         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSREM0;
00885     }
00886 
00892     boolean isBVURem0()
00893     {
00894         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BUREM0;
00895     }
00896 
00902     boolean isBVSMod0()
00903     {
00904         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSMOD0;
00905     }
00906 
00912     public boolean isBVULE()
00913     {
00914         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ULEQ;
00915     }
00916 
00922     public boolean isBVSLE()
00923     {
00924         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SLEQ;
00925     }
00926 
00933     public boolean isBVUGE()
00934     {
00935         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_UGEQ;
00936     }
00937 
00943     public boolean isBVSGE()
00944     {
00945         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SGEQ;
00946     }
00947 
00953     public boolean isBVULT()
00954     {
00955         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ULT;
00956     }
00957 
00963     public boolean isBVSLT()
00964     {
00965         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SLT;
00966     }
00967 
00973     public boolean isBVUGT()
00974     {
00975         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_UGT;
00976     }
00977 
00983     public boolean isBVSGT()
00984     {
00985         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SGT;
00986     }
00987 
00993     public boolean isBVAND()
00994     {
00995         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BAND;
00996     }
00997 
01003     public boolean isBVOR()
01004     {
01005         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BOR;
01006     }
01007 
01013     public boolean isBVNOT()
01014     {
01015         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BNOT;
01016     }
01017 
01023     public boolean isBVXOR()
01024     {
01025         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BXOR;
01026     }
01027 
01033     public boolean isBVNAND()
01034     {
01035         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BNAND;
01036     }
01037 
01043     public boolean isBVNOR()
01044     {
01045         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BNOR;
01046     }
01047 
01053     public boolean isBVXNOR()
01054     {
01055         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BXNOR;
01056     }
01057 
01063     public boolean isBVConcat()
01064     {
01065         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_CONCAT;
01066     }
01067 
01073     public boolean isBVSignExtension()
01074     {
01075         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SIGN_EXT;
01076     }
01077 
01083     public boolean isBVZeroExtension()
01084     {
01085         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ZERO_EXT;
01086     }
01087 
01093     public boolean isBVExtract()
01094     {
01095         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_EXTRACT;
01096     }
01097 
01103     public boolean isBVRepeat()
01104     {
01105         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_REPEAT;
01106     }
01107 
01113     public boolean isBVReduceOR()
01114     {
01115         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BREDOR;
01116     }
01117 
01123     public boolean isBVReduceAND()
01124     {
01125         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BREDAND;
01126     }
01127 
01133     public boolean isBVComp()
01134     {
01135         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BCOMP;
01136     }
01137 
01143     public boolean isBVShiftLeft()
01144     {
01145         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSHL;
01146     }
01147 
01153     public boolean isBVShiftRightLogical()
01154     {
01155         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BLSHR;
01156     }
01157 
01163     public boolean isBVShiftRightArithmetic()
01164     {
01165         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BASHR;
01166     }
01167 
01173     public boolean isBVRotateLeft()
01174     {
01175         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ROTATE_LEFT;
01176     }
01177 
01183     public boolean isBVRotateRight()
01184     {
01185         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ROTATE_RIGHT;
01186     }
01187 
01195     public boolean isBVRotateLeftExtended()
01196     {
01197         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_EXT_ROTATE_LEFT;
01198     }
01199 
01207     public boolean isBVRotateRightExtended()
01208     {
01209         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_EXT_ROTATE_RIGHT;
01210     }
01211 
01219     public boolean isIntToBV()
01220     {
01221         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_INT2BV;
01222     }
01223 
01231     public boolean isBVToInt()
01232     {
01233         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BV2INT;
01234     }
01235 
01242     public boolean isBVCarry()
01243     {
01244         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_CARRY;
01245     }
01246 
01253     public boolean isBVXOR3()
01254     {
01255         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_XOR3;
01256     }
01257 
01266     public boolean isLabel()
01267     {
01268         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_LABEL;
01269     }
01270 
01279     public boolean isLabelLit()
01280     {
01281         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_LABEL_LIT;
01282     }
01283 
01291     public boolean isOEQ()
01292     {
01293         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_OEQ;
01294     }
01295 
01301     public boolean isProofTrue()
01302     {
01303         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_TRUE;
01304     }
01305 
01311     public boolean isProofAsserted()
01312     {
01313         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_ASSERTED;
01314     }
01315 
01322     public boolean isProofGoal()
01323     {
01324         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_GOAL;
01325     }
01326 
01336     public boolean isProofModusPonens()
01337     {
01338         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS;
01339     }
01340 
01351     public boolean isProofReflexivity()
01352     {
01353         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_REFLEXIVITY;
01354     }
01355 
01363     public boolean isProofSymmetry()
01364     {
01365         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_SYMMETRY;
01366     }
01367 
01375     public boolean isProofTransitivity()
01376     {
01377         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY;
01378     }
01379 
01396     public boolean isProofTransitivityStar()
01397     {
01398         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY_STAR;
01399     }
01400 
01411     public boolean isProofMonotonicity()
01412     {
01413         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_MONOTONICITY;
01414     }
01415 
01422     public boolean isProofQuantIntro()
01423     {
01424         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_QUANT_INTRO;
01425     }
01426 
01441     public boolean isProofDistributivity()
01442     {
01443         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_DISTRIBUTIVITY;
01444     }
01445 
01452     public boolean isProofAndElimination()
01453     {
01454         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_AND_ELIM;
01455     }
01456 
01463     public boolean isProofOrElimination()
01464     {
01465         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_NOT_OR_ELIM;
01466     }
01467 
01483     public boolean isProofRewrite()
01484     {
01485         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_REWRITE;
01486     }
01487 
01502     public boolean isProofRewriteStar()
01503     {
01504         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_REWRITE_STAR;
01505     }
01506 
01514     public boolean isProofPullQuant()
01515     {
01516         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_PULL_QUANT;
01517     }
01518 
01526     public boolean isProofPullQuantStar()
01527     {
01528         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_PULL_QUANT_STAR;
01529     }
01530 
01540     public boolean isProofPushQuant()
01541     {
01542         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_PUSH_QUANT;
01543     }
01544 
01556     public boolean isProofElimUnusedVars()
01557     {
01558         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_ELIM_UNUSED_VARS;
01559     }
01560 
01572     public boolean isProofDER()
01573     {
01574         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_DER;
01575     }
01576 
01584     public boolean isProofQuantInst()
01585     {
01586         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_QUANT_INST;
01587     }
01588 
01596     public boolean isProofHypothesis()
01597     {
01598         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_HYPOTHESIS;
01599     }
01600 
01612     public boolean isProofLemma()
01613     {
01614         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_LEMMA;
01615     }
01616 
01623     public boolean isProofUnitResolution()
01624     {
01625         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_UNIT_RESOLUTION;
01626     }
01627 
01635     public boolean isProofIFFTrue()
01636     {
01637         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_IFF_TRUE;
01638     }
01639 
01647     public boolean isProofIFFFalse()
01648     {
01649         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_IFF_FALSE;
01650     }
01651 
01664     public boolean isProofCommutativity()
01665     {
01666         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_COMMUTATIVITY;
01667     }
01668 
01690     public boolean isProofDefAxiom()
01691     {
01692         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_DEF_AXIOM;
01693     }
01694 
01713     public boolean isProofDefIntro()
01714     {
01715         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_DEF_INTRO;
01716     }
01717 
01725     public boolean isProofApplyDef()
01726     {
01727         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_APPLY_DEF;
01728     }
01729 
01737     public boolean isProofIFFOEQ()
01738     {
01739         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_IFF_OEQ;
01740     }
01741 
01765     public boolean isProofNNFPos()
01766     {
01767         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_NNF_POS;
01768     }
01769 
01784     public boolean isProofNNFNeg()
01785     {
01786         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_NNF_NEG;
01787     }
01788 
01802     public boolean isProofNNFStar()
01803     {
01804         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_NNF_STAR;
01805     }
01806 
01817     public boolean isProofCNFStar()
01818     {
01819         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_CNF_STAR;
01820     }
01821 
01834     public boolean isProofSkolemize()
01835     {
01836         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_SKOLEMIZE;
01837     }
01838 
01847     public boolean isProofModusPonensOEQ()
01848     {
01849         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS_OEQ;
01850     }
01851 
01869     public boolean isProofTheoryLemma()
01870     {
01871         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_TH_LEMMA;
01872     }
01873 
01879     public boolean isRelation()
01880     {
01881         return (Native.isApp(getContext().nCtx(), getNativeObject()) && Native
01882                 .getSortKind(getContext().nCtx(),
01883                         Native.getSort(getContext().nCtx(), getNativeObject())) == Z3_sort_kind.Z3_RELATION_SORT
01884                 .toInt());
01885     }
01886 
01896     public boolean isRelationStore()
01897     {
01898         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_STORE;
01899     }
01900 
01906     public boolean isEmptyRelation()
01907     {
01908         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_EMPTY;
01909     }
01910 
01916     public boolean isIsEmptyRelation()
01917     {
01918         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_IS_EMPTY;
01919     }
01920 
01926     public boolean isRelationalJoin()
01927     {
01928         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_JOIN;
01929     }
01930 
01938     public boolean isRelationUnion()
01939     {
01940         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_UNION;
01941     }
01942 
01950     public boolean isRelationWiden()
01951     {
01952         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_WIDEN;
01953     }
01954 
01963     public boolean isRelationProject()
01964     {
01965         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_PROJECT;
01966     }
01967 
01978     public boolean isRelationFilter()
01979     {
01980         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_FILTER;
01981     }
01982 
01998     public boolean isRelationNegationFilter()
01999     {
02000         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_NEGATION_FILTER;
02001     }
02002 
02010     public boolean isRelationRename()
02011     {
02012         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_RENAME;
02013     }
02014 
02020     public boolean isRelationComplement()
02021     {
02022         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_COMPLEMENT;
02023     }
02024 
02034     public boolean isRelationSelect()
02035     {
02036         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_SELECT;
02037     }
02038 
02050     public boolean isRelationClone()
02051     {
02052         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_CLONE;
02053     }
02054 
02060     public boolean isFiniteDomain()
02061     {
02062         return (Native.isApp(getContext().nCtx(), getNativeObject()) && Native
02063                 .getSortKind(getContext().nCtx(),
02064                         Native.getSort(getContext().nCtx(), getNativeObject())) == Z3_sort_kind.Z3_FINITE_DOMAIN_SORT
02065                 .toInt());
02066     }
02067 
02073     public boolean isFiniteDomainLT()
02074     {
02075         return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FD_LT;
02076     }
02077 
02096     public int getIndex()
02097     {
02098         if (!isVar())
02099             throw new Z3Exception("Term is not a bound variable.");
02100 
02101         return Native.getIndexValue(getContext().nCtx(), getNativeObject());
02102     }
02103 
02107     protected Expr(Context ctx)
02108     {
02109         super(ctx);
02110         {
02111         }
02112     }
02113 
02118     protected Expr(Context ctx, long obj)
02119     {
02120         super(ctx, obj);
02121         {
02122         }
02123     }
02124 
02125     void checkNativeObject(long obj)
02126     {
02127         if (!Native.isApp(getContext().nCtx(), obj) && 
02128             Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_VAR_AST.toInt() &&
02129             Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST.toInt())
02130             throw new Z3Exception("Underlying object is not a term");
02131         super.checkNativeObject(obj);
02132     }
02133 
02134     static Expr create(Context ctx, FuncDecl f, Expr ... arguments)
02135            
02136     {
02137         long obj = Native.mkApp(ctx.nCtx(), f.getNativeObject(),
02138                 AST.arrayLength(arguments), AST.arrayToNative(arguments));
02139         return create(ctx, obj);
02140     }
02141 
02142     static Expr create(Context ctx, long obj)
02143     {
02144         Z3_ast_kind k = Z3_ast_kind.fromInt(Native.getAstKind(ctx.nCtx(), obj));
02145         if (k == Z3_ast_kind.Z3_QUANTIFIER_AST)
02146             return new Quantifier(ctx, obj);
02147         long s = Native.getSort(ctx.nCtx(), obj);
02148         Z3_sort_kind sk = Z3_sort_kind
02149                 .fromInt(Native.getSortKind(ctx.nCtx(), s));
02150 
02151         if (Native.isAlgebraicNumber(ctx.nCtx(), obj)) // is this a numeral ast?
02152             return new AlgebraicNum(ctx, obj);
02153 
02154         if (Native.isNumeralAst(ctx.nCtx(), obj))
02155         {
02156             switch (sk)
02157             {
02158             case Z3_INT_SORT:
02159                 return new IntNum(ctx, obj);
02160             case Z3_REAL_SORT:
02161                 return new RatNum(ctx, obj);
02162             case Z3_BV_SORT:
02163                 return new BitVecNum(ctx, obj);
02164             case Z3_FLOATING_POINT_SORT:
02165                 return new FPNum(ctx, obj);
02166             case Z3_ROUNDING_MODE_SORT:
02167                 return new FPRMNum(ctx, obj);
02168             default: ;
02169             }
02170         }
02171 
02172         switch (sk)
02173         {
02174         case Z3_BOOL_SORT:
02175             return new BoolExpr(ctx, obj);
02176         case Z3_INT_SORT:
02177             return new IntExpr(ctx, obj);
02178         case Z3_REAL_SORT:
02179             return new RealExpr(ctx, obj);
02180         case Z3_BV_SORT:
02181             return new BitVecExpr(ctx, obj);
02182         case Z3_ARRAY_SORT:
02183             return new ArrayExpr(ctx, obj);
02184         case Z3_DATATYPE_SORT:
02185             return new DatatypeExpr(ctx, obj);
02186         case Z3_FLOATING_POINT_SORT:
02187             return new FPExpr(ctx, obj);
02188         case Z3_ROUNDING_MODE_SORT:
02189             return new FPRMExpr(ctx, obj);
02190         default: ;
02191         }
02192 
02193         return new Expr(ctx, obj);
02194     }
02195 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines