Z3
 
Loading...
Searching...
No Matches
Expr.java
Go to the documentation of this file.
1
18package com.microsoft.z3;
19
20import java.lang.reflect.Type;
21import java.lang.reflect.ParameterizedType;
22
23import com.microsoft.z3.enumerations.Z3_ast_kind;
24import com.microsoft.z3.enumerations.Z3_decl_kind;
25import com.microsoft.z3.enumerations.Z3_lbool;
26import com.microsoft.z3.enumerations.Z3_sort_kind;
27
28/* using System; */
29
33@SuppressWarnings("unchecked")
34public class Expr<R extends Sort> extends AST
35{
42 {
43 return simplify(null);
44 }
45
56 {
57
58 if (p == null) {
59 return (Expr<R>) Expr.create(getContext(),
60 Native.simplify(getContext().nCtx(), getNativeObject()));
61 }
62 else {
63 return (Expr<R>) Expr.create(
64 getContext(),
65 Native.simplifyEx(getContext().nCtx(), getNativeObject(),
66 p.getNativeObject()));
67 }
68 }
69
77 {
78 return new FuncDecl<>(getContext(), Native.getAppDecl(getContext().nCtx(),
79 getNativeObject()));
80 }
81
89 {
90 return Z3_lbool.fromInt(Native.getBoolValue(getContext().nCtx(),
91 getNativeObject()));
92 }
93
99 public int getNumArgs()
100 {
101 return Native.getAppNumArgs(getContext().nCtx(), getNativeObject());
102 }
103
109 public Expr<?>[] getArgs()
110 {
111 int n = getNumArgs();
112 Expr<?>[] res = new Expr[n];
113 for (int i = 0; i < n; i++) {
114 res[i] = Expr.create(getContext(),
115 Native.getAppArg(getContext().nCtx(), getNativeObject(), i));
116 }
117 return res;
118 }
119
127 public Expr<R> update(Expr<?>[] args)
128 {
129 getContext().checkContextMatch(args);
130 if (isApp() && args.length != getNumArgs()) {
131 throw new Z3Exception("Number of arguments does not match");
132 }
133 return (Expr<R>) Expr.create(getContext(), Native.updateTerm(getContext().nCtx(), getNativeObject(),
134 args.length, Expr.arrayToNative(args)));
135 }
136
149 public Expr<R> substitute(Expr<?>[] from, Expr<?>[] to)
150 {
151 getContext().checkContextMatch(from);
152 getContext().checkContextMatch(to);
153 if (from.length != to.length) {
154 throw new Z3Exception("Argument sizes do not match");
155 }
156 return (Expr<R>) Expr.create(getContext(), Native.substitute(getContext().nCtx(),
157 getNativeObject(), from.length, Expr.arrayToNative(from),
158 Expr.arrayToNative(to)));
159 }
160
169 {
170 return substitute(new Expr[] { from }, new Expr[] { to });
171 }
172
184 {
185
186 getContext().checkContextMatch(to);
187 return (Expr<R>) Expr.create(getContext(), Native.substituteVars(getContext().nCtx(),
188 getNativeObject(), to.length, Expr.arrayToNative(to)));
189 }
190
204 {
205 getContext().checkContextMatch(from);
206 getContext().checkContextMatch(to);
207 if (from.length != to.length) {
208 throw new Z3Exception("Arrays 'from' and 'to' must have the same length");
209 }
210 return (Expr<R>) Expr.create(getContext(), Native.substituteFuns(getContext().nCtx(),
211 getNativeObject(), from.length, AST.arrayToNative(from),
212 Expr.arrayToNative(to)));
213 }
214
224 {
225 return (Expr<R>) super.translate(ctx);
226 }
227
231 @Override
232 public String toString()
233 {
234 return super.toString();
235 }
236
242 public boolean isNumeral()
243 {
244 return Native.isNumeralAst(getContext().nCtx(), getNativeObject());
245 }
246
251 public double getNumeralDouble()
252 {
253 return Native.getNumeralDouble(getContext().nCtx(), getNativeObject());
254 }
255
262 public boolean isWellSorted()
263 {
264 return Native.isWellSorted(getContext().nCtx(), getNativeObject());
265 }
266
272 public R getSort()
273 {
274 return (R) Sort.create(getContext(),
275 Native.getSort(getContext().nCtx(), getNativeObject()));
276 }
277
283 public boolean isConst()
284 {
285 return isApp() && getNumArgs() == 0 && getFuncDecl().getDomainSize() == 0;
286 }
287
293 public boolean isIntNum()
294 {
295 return isNumeral() && isInt();
296 }
297
303 public boolean isRatNum()
304 {
305 return isNumeral() && isReal();
306 }
307
313 public boolean isAlgebraicNumber()
314 {
315 return Native.isAlgebraicNumber(getContext().nCtx(), getNativeObject());
316 }
317
323 public boolean isGround()
324 {
325 return Native.isGround(getContext().nCtx(), getNativeObject());
326 }
327
333 public boolean isLambda()
334 {
335 return Native.isLambda(getContext().nCtx(), getNativeObject());
336 }
337
343 public boolean isBool()
344 {
345 return (isExpr() && Native.isEqSort(getContext().nCtx(),
346 Native.mkBoolSort(getContext().nCtx()),
347 Native.getSort(getContext().nCtx(), getNativeObject())));
348 }
349
355 public boolean isTrue()
356 {
357 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_TRUE;
358 }
359
365 public boolean isFalse()
366 {
367 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FALSE;
368 }
369
375 public boolean isEq()
376 {
377 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_EQ;
378 }
379
386 public boolean isDistinct()
387 {
388 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_DISTINCT;
389 }
390
396 public boolean isITE()
397 {
398 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ITE;
399 }
400
406 public boolean isAnd()
407 {
408 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_AND;
409 }
410
416 public boolean isOr()
417 {
418 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_OR;
419 }
420
427 public boolean isIff()
428 {
429 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_IFF;
430 }
431
437 public boolean isXor()
438 {
439 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_XOR;
440 }
441
447 public boolean isNot()
448 {
449 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_NOT;
450 }
451
457 public boolean isImplies()
458 {
459 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_IMPLIES;
460 }
461
467 public boolean isInt()
468 {
469 return Native.getSortKind(getContext().nCtx(), Native.getSort(getContext().nCtx(), getNativeObject())) == Z3_sort_kind.Z3_INT_SORT.toInt();
470 }
471
477 public boolean isReal()
478 {
479 return Native.getSortKind(getContext().nCtx(), Native.getSort(getContext().nCtx(), getNativeObject())) == Z3_sort_kind.Z3_REAL_SORT.toInt();
480 }
481
487 public boolean isArithmeticNumeral()
488 {
489 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ANUM;
490 }
491
497 public boolean isLE()
498 {
499 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_LE;
500 }
501
507 public boolean isGE()
508 {
509 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_GE;
510 }
511
517 public boolean isLT()
518 {
519 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_LT;
520 }
521
527 public boolean isGT()
528 {
529 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_GT;
530 }
531
537 public boolean isAdd()
538 {
539 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ADD;
540 }
541
547 public boolean isSub()
548 {
549 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SUB;
550 }
551
557 public boolean isUMinus()
558 {
559 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_UMINUS;
560 }
561
567 public boolean isMul()
568 {
569 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_MUL;
570 }
571
577 public boolean isDiv()
578 {
579 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_DIV;
580 }
581
587 public boolean isIDiv()
588 {
589 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_IDIV;
590 }
591
597 public boolean isRemainder()
598 {
599 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_REM;
600 }
601
607 public boolean isModulus()
608 {
609 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_MOD;
610 }
611
617 public boolean isIntToReal()
618 {
619 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_TO_REAL;
620 }
621
627 public boolean isRealToInt()
628 {
629 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_TO_INT;
630 }
631
638 public boolean isRealIsInt()
639 {
640 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_IS_INT;
641 }
642
648 public boolean isArray()
649 {
650 return (Native.isApp(getContext().nCtx(), getNativeObject()) && Z3_sort_kind
651 .fromInt(Native.getSortKind(getContext().nCtx(),
652 Native.getSort(getContext().nCtx(), getNativeObject()))) == Z3_sort_kind.Z3_ARRAY_SORT);
653 }
654
661 public boolean isStore()
662 {
663 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_STORE;
664 }
665
671 public boolean isSelect()
672 {
673 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SELECT;
674 }
675
682 public boolean isConstantArray()
683 {
684 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_CONST_ARRAY;
685 }
686
693 public boolean isDefaultArray()
694 {
695 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ARRAY_DEFAULT;
696 }
697
705 public boolean isArrayMap()
706 {
707 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ARRAY_MAP;
708 }
709
716 public boolean isAsArray()
717 {
718 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_AS_ARRAY;
719 }
720
726 public boolean isSetUnion()
727 {
728 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SET_UNION;
729 }
730
736 public boolean isSetIntersect()
737 {
738 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SET_INTERSECT;
739 }
740
746 public boolean isSetDifference()
747 {
748 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SET_DIFFERENCE;
749 }
750
756 public boolean isSetComplement()
757 {
758 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SET_COMPLEMENT;
759 }
760
766 public boolean isSetSubset()
767 {
768 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SET_SUBSET;
769 }
770
776 public boolean isBV()
777 {
778 return Native.getSortKind(getContext().nCtx(),
779 Native.getSort(getContext().nCtx(), getNativeObject())) == Z3_sort_kind.Z3_BV_SORT
780 .toInt();
781 }
782
788 public boolean isBVNumeral()
789 {
790 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BNUM;
791 }
792
798 public boolean isBVBitOne()
799 {
800 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BIT1;
801 }
802
808 public boolean isBVBitZero()
809 {
810 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BIT0;
811 }
812
818 public boolean isBVUMinus()
819 {
820 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BNEG;
821 }
822
828 public boolean isBVAdd()
829 {
830 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BADD;
831 }
832
838 public boolean isBVSub()
839 {
840 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSUB;
841 }
842
848 public boolean isBVMul()
849 {
850 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BMUL;
851 }
852
858 public boolean isBVSDiv()
859 {
860 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSDIV;
861 }
862
868 public boolean isBVUDiv()
869 {
870 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BUDIV;
871 }
872
878 public boolean isBVSRem()
879 {
880 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSREM;
881 }
882
888 public boolean isBVURem()
889 {
890 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BUREM;
891 }
892
898 public boolean isBVSMod()
899 {
900 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSMOD;
901 }
902
908 boolean isBVSDiv0()
909 {
910 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSDIV0;
911 }
912
918 boolean isBVUDiv0()
919 {
920 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BUDIV0;
921 }
922
928 boolean isBVSRem0()
929 {
930 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSREM0;
931 }
932
938 boolean isBVURem0()
939 {
940 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BUREM0;
941 }
942
948 boolean isBVSMod0()
949 {
950 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSMOD0;
951 }
952
958 public boolean isBVULE()
959 {
960 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ULEQ;
961 }
962
968 public boolean isBVSLE()
969 {
970 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SLEQ;
971 }
972
979 public boolean isBVUGE()
980 {
981 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_UGEQ;
982 }
983
989 public boolean isBVSGE()
990 {
991 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SGEQ;
992 }
993
999 public boolean isBVULT()
1000 {
1001 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ULT;
1002 }
1003
1009 public boolean isBVSLT()
1010 {
1011 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SLT;
1012 }
1013
1019 public boolean isBVUGT()
1020 {
1021 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_UGT;
1022 }
1023
1029 public boolean isBVSGT()
1030 {
1031 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SGT;
1032 }
1033
1039 public boolean isBVAND()
1040 {
1041 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BAND;
1042 }
1043
1049 public boolean isBVOR()
1050 {
1051 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BOR;
1052 }
1053
1059 public boolean isBVNOT()
1060 {
1061 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BNOT;
1062 }
1063
1069 public boolean isBVXOR()
1070 {
1071 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BXOR;
1072 }
1073
1079 public boolean isBVNAND()
1080 {
1081 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BNAND;
1082 }
1083
1089 public boolean isBVNOR()
1090 {
1091 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BNOR;
1092 }
1093
1099 public boolean isBVXNOR()
1100 {
1101 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BXNOR;
1102 }
1103
1109 public boolean isBVConcat()
1110 {
1111 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_CONCAT;
1112 }
1113
1119 public boolean isBVSignExtension()
1120 {
1121 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SIGN_EXT;
1122 }
1123
1129 public boolean isBVZeroExtension()
1130 {
1131 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ZERO_EXT;
1132 }
1133
1139 public boolean isBVExtract()
1140 {
1141 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_EXTRACT;
1142 }
1143
1149 public boolean isBVRepeat()
1150 {
1151 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_REPEAT;
1152 }
1153
1159 public boolean isBVReduceOR()
1160 {
1161 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BREDOR;
1162 }
1163
1169 public boolean isBVReduceAND()
1170 {
1171 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BREDAND;
1172 }
1173
1179 public boolean isBVComp()
1180 {
1181 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BCOMP;
1182 }
1183
1189 public boolean isBVShiftLeft()
1190 {
1191 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BSHL;
1192 }
1193
1199 public boolean isBVShiftRightLogical()
1200 {
1201 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BLSHR;
1202 }
1203
1210 {
1211 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BASHR;
1212 }
1213
1219 public boolean isBVRotateLeft()
1220 {
1221 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ROTATE_LEFT;
1222 }
1223
1229 public boolean isBVRotateRight()
1230 {
1231 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_ROTATE_RIGHT;
1232 }
1233
1241 public boolean isBVRotateLeftExtended()
1242 {
1243 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_EXT_ROTATE_LEFT;
1244 }
1245
1254 {
1255 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_EXT_ROTATE_RIGHT;
1256 }
1257
1265 public boolean isIntToBV()
1266 {
1267 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_INT2BV;
1268 }
1269
1277 public boolean isBVToInt()
1278 {
1279 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_BV2INT;
1280 }
1281
1288 public boolean isBVCarry()
1289 {
1290 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_CARRY;
1291 }
1292
1299 public boolean isBVXOR3()
1300 {
1301 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_XOR3;
1302 }
1303
1312 public boolean isLabel()
1313 {
1314 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_LABEL;
1315 }
1316
1325 public boolean isLabelLit()
1326 {
1327 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_LABEL_LIT;
1328 }
1329
1334 public boolean isString()
1335 {
1336 return isApp() && Native.isString(getContext().nCtx(), getNativeObject());
1337 }
1338
1345 public String getString()
1346 {
1347 return Native.getString(getContext().nCtx(), getNativeObject());
1348 }
1349
1370 public boolean isConcat()
1371 {
1372 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_SEQ_CONCAT;
1373 }
1374
1382 public boolean isOEQ()
1383 {
1384 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_OEQ;
1385 }
1386
1392 public boolean isProofTrue()
1393 {
1394 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_TRUE;
1395 }
1396
1402 public boolean isProofAsserted()
1403 {
1404 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_ASSERTED;
1405 }
1406
1413 public boolean isProofGoal()
1414 {
1415 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_GOAL;
1416 }
1417
1427 public boolean isProofModusPonens()
1428 {
1429 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS;
1430 }
1431
1442 public boolean isProofReflexivity()
1443 {
1444 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_REFLEXIVITY;
1445 }
1446
1454 public boolean isProofSymmetry()
1455 {
1456 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_SYMMETRY;
1457 }
1458
1466 public boolean isProofTransitivity()
1467 {
1468 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY;
1469 }
1470
1487 {
1488 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY_STAR;
1489 }
1490
1501 public boolean isProofMonotonicity()
1502 {
1503 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_MONOTONICITY;
1504 }
1505
1512 public boolean isProofQuantIntro()
1513 {
1514 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_QUANT_INTRO;
1515 }
1516
1531 public boolean isProofDistributivity()
1532 {
1533 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_DISTRIBUTIVITY;
1534 }
1535
1542 public boolean isProofAndElimination()
1543 {
1544 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_AND_ELIM;
1545 }
1546
1553 public boolean isProofOrElimination()
1554 {
1555 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_NOT_OR_ELIM;
1556 }
1557
1573 public boolean isProofRewrite()
1574 {
1575 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_REWRITE;
1576 }
1577
1589 public boolean isProofRewriteStar()
1590 {
1591 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_REWRITE_STAR;
1592 }
1593
1601 public boolean isProofPullQuant()
1602 {
1603 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_PULL_QUANT;
1604 }
1605
1606
1616 public boolean isProofPushQuant()
1617 {
1618 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_PUSH_QUANT;
1619 }
1620
1632 public boolean isProofElimUnusedVars()
1633 {
1634 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_ELIM_UNUSED_VARS;
1635 }
1636
1648 public boolean isProofDER()
1649 {
1650 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_DER;
1651 }
1652
1660 public boolean isProofQuantInst()
1661 {
1662 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_QUANT_INST;
1663 }
1664
1672 public boolean isProofHypothesis()
1673 {
1674 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_HYPOTHESIS;
1675 }
1676
1688 public boolean isProofLemma()
1689 {
1690 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_LEMMA;
1691 }
1692
1699 public boolean isProofUnitResolution()
1700 {
1701 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_UNIT_RESOLUTION;
1702 }
1703
1711 public boolean isProofIFFTrue()
1712 {
1713 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_IFF_TRUE;
1714 }
1715
1723 public boolean isProofIFFFalse()
1724 {
1725 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_IFF_FALSE;
1726 }
1727
1740 public boolean isProofCommutativity()
1741 {
1742 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_COMMUTATIVITY;
1743 }
1744
1766 public boolean isProofDefAxiom()
1767 {
1768 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_DEF_AXIOM;
1769 }
1770
1789 public boolean isProofDefIntro()
1790 {
1791 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_DEF_INTRO;
1792 }
1793
1801 public boolean isProofApplyDef()
1802 {
1803 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_APPLY_DEF;
1804 }
1805
1813 public boolean isProofIFFOEQ()
1814 {
1815 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_IFF_OEQ;
1816 }
1817
1841 public boolean isProofNNFPos()
1842 {
1843 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_NNF_POS;
1844 }
1845
1860 public boolean isProofNNFNeg()
1861 {
1862 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_NNF_NEG;
1863 }
1864
1865
1878 public boolean isProofSkolemize()
1879 {
1880 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_SKOLEMIZE;
1881 }
1882
1891 public boolean isProofModusPonensOEQ()
1892 {
1893 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS_OEQ;
1894 }
1895
1913 public boolean isProofTheoryLemma()
1914 {
1915 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_TH_LEMMA;
1916 }
1917
1923 public boolean isRelation()
1924 {
1925 return (Native.isApp(getContext().nCtx(), getNativeObject()) && Native
1926 .getSortKind(getContext().nCtx(),
1927 Native.getSort(getContext().nCtx(), getNativeObject())) == Z3_sort_kind.Z3_RELATION_SORT
1928 .toInt());
1929 }
1930
1940 public boolean isRelationStore()
1941 {
1942 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_STORE;
1943 }
1944
1950 public boolean isEmptyRelation()
1951 {
1952 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_EMPTY;
1953 }
1954
1960 public boolean isIsEmptyRelation()
1961 {
1962 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_IS_EMPTY;
1963 }
1964
1970 public boolean isRelationalJoin()
1971 {
1972 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_JOIN;
1973 }
1974
1982 public boolean isRelationUnion()
1983 {
1984 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_UNION;
1985 }
1986
1994 public boolean isRelationWiden()
1995 {
1996 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_WIDEN;
1997 }
1998
2007 public boolean isRelationProject()
2008 {
2009 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_PROJECT;
2010 }
2011
2022 public boolean isRelationFilter()
2023 {
2024 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_FILTER;
2025 }
2026
2043 {
2044 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_NEGATION_FILTER;
2045 }
2046
2054 public boolean isRelationRename()
2055 {
2056 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_RENAME;
2057 }
2058
2064 public boolean isRelationComplement()
2065 {
2066 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_COMPLEMENT;
2067 }
2068
2078 public boolean isRelationSelect()
2079 {
2080 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_SELECT;
2081 }
2082
2094 public boolean isRelationClone()
2095 {
2096 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_RA_CLONE;
2097 }
2098
2104 public boolean isFiniteDomain()
2105 {
2106 return (Native.isApp(getContext().nCtx(), getNativeObject()) && Native
2107 .getSortKind(getContext().nCtx(),
2108 Native.getSort(getContext().nCtx(), getNativeObject())) == Z3_sort_kind.Z3_FINITE_DOMAIN_SORT
2109 .toInt());
2110 }
2111
2117 public boolean isFiniteDomainLT()
2118 {
2119 return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FD_LT;
2120 }
2121
2140 public int getIndex()
2141 {
2142 if (!isVar()) {
2143 throw new Z3Exception("Term is not a bound variable.");
2144 }
2145
2146 return Native.getIndexValue(getContext().nCtx(), getNativeObject());
2147 }
2148
2149 private Class sort = null;
2150
2159 public <S extends R> Expr<S> distillSort(Class<S> newSort) {
2160 if (sort != null && !newSort.isAssignableFrom(sort)) {
2161 throw new Z3Exception(
2162 String.format("Cannot distill expression of sort %s to %s.", sort.getName(), newSort.getName()));
2163 }
2164
2165 return (Expr<S>) ((Expr<?>) this);
2166 }
2167
2172 protected Expr(Context ctx, long obj) {
2173 super(ctx, obj);
2174 Type superclass = getClass().getGenericSuperclass();
2175 if (superclass instanceof ParameterizedType) {
2176 Type argType = ((ParameterizedType) superclass).getActualTypeArguments()[0];
2177 if (argType instanceof Class) {
2178 this.sort = (Class) argType;
2179 }
2180 }
2181 }
2182
2183 @Override
2184 void checkNativeObject(long obj) {
2185 if (!Native.isApp(getContext().nCtx(), obj) &&
2186 Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_VAR_AST.toInt() &&
2187 Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST.toInt()) {
2188 throw new Z3Exception("Underlying object is not a term");
2189 }
2190 super.checkNativeObject(obj);
2191 }
2192
2193 static <U extends Sort> Expr<U> create(Context ctx, FuncDecl<U> f, Expr<?> ... arguments)
2194 {
2195 long obj = Native.mkApp(ctx.nCtx(), f.getNativeObject(),
2196 AST.arrayLength(arguments), AST.arrayToNative(arguments));
2197 return (Expr<U>) create(ctx, obj);
2198 }
2199
2200 // TODO generify, but it conflicts with AST.create
2201 static Expr<?> create(Context ctx, long obj)
2202 {
2203 Z3_ast_kind k = Z3_ast_kind.fromInt(Native.getAstKind(ctx.nCtx(), obj));
2204 if (k == Z3_ast_kind.Z3_QUANTIFIER_AST) {
2205 // a quantifier AST is a lambda iff it is neither a forall nor an exists.
2206 boolean isLambda = !Native.isQuantifierExists(ctx.nCtx(), obj) && !Native.isQuantifierForall(ctx.nCtx(), obj);
2207 if (isLambda) {
2208 return new Lambda(ctx, obj);
2209 } else {
2210 return new Quantifier(ctx, obj);
2211 }
2212 }
2213 long s = Native.getSort(ctx.nCtx(), obj);
2215 .fromInt(Native.getSortKind(ctx.nCtx(), s));
2216
2217 if (Native.isAlgebraicNumber(ctx.nCtx(), obj)) // is this a numeral ast?
2218 return new AlgebraicNum(ctx, obj);
2219
2220 if (Native.isNumeralAst(ctx.nCtx(), obj))
2221 {
2222 switch (sk)
2223 {
2224 case Z3_INT_SORT:
2225 return new IntNum(ctx, obj);
2226 case Z3_REAL_SORT:
2227 return new RatNum(ctx, obj);
2228 case Z3_BV_SORT:
2229 return new BitVecNum(ctx, obj);
2231 return new FPNum(ctx, obj);
2233 return new FPRMNum(ctx, obj);
2235 return new FiniteDomainNum(ctx, obj);
2236 default:
2237 }
2238 }
2239
2240 switch (sk)
2241 {
2242 case Z3_BOOL_SORT:
2243 return new BoolExpr(ctx, obj);
2244 case Z3_INT_SORT:
2245 return new IntExpr(ctx, obj);
2246 case Z3_REAL_SORT:
2247 return new RealExpr(ctx, obj);
2248 case Z3_BV_SORT:
2249 return new BitVecExpr(ctx, obj);
2250 case Z3_ARRAY_SORT:
2251 return new ArrayExpr<>(ctx, obj);
2252 case Z3_DATATYPE_SORT:
2253 return new DatatypeExpr<>(ctx, obj);
2255 return new FPExpr(ctx, obj);
2257 return new FPRMExpr(ctx, obj);
2259 return new FiniteDomainExpr(ctx, obj);
2260 case Z3_SEQ_SORT:
2261 return new SeqExpr<>(ctx, obj);
2262 case Z3_RE_SORT:
2263 return new ReExpr<>(ctx, obj);
2264 default:
2265 }
2266
2267 return new Expr<>(ctx, obj);
2268 }
2269}
boolean isProofLemma()
Definition Expr.java:1688
boolean isSetUnion()
Definition Expr.java:726
boolean isRelation()
Definition Expr.java:1923
boolean isSelect()
Definition Expr.java:671
boolean isBVRepeat()
Definition Expr.java:1149
boolean isConstantArray()
Definition Expr.java:682
Expr(Context ctx, long obj)
Definition Expr.java:2172
boolean isProofHypothesis()
Definition Expr.java:1672
boolean isProofDER()
Definition Expr.java:1648
boolean isBVSRem()
Definition Expr.java:878
boolean isImplies()
Definition Expr.java:457
boolean isArrayMap()
Definition Expr.java:705
boolean isProofTransitivityStar()
Definition Expr.java:1486
boolean isProofAsserted()
Definition Expr.java:1402
boolean isBVRotateRightExtended()
Definition Expr.java:1253
Expr< R > substitute(Expr<?>[] from, Expr<?>[] to)
Definition Expr.java:149
boolean isRelationFilter()
Definition Expr.java:2022
boolean isEmptyRelation()
Definition Expr.java:1950
Z3_lbool getBoolValue()
Definition Expr.java:88
Expr< R > substituteVars(Expr<?>[] to)
Definition Expr.java:183
boolean isProofIFFTrue()
Definition Expr.java:1711
boolean isIntToBV()
Definition Expr.java:1265
boolean isUMinus()
Definition Expr.java:557
boolean isRelationalJoin()
Definition Expr.java:1970
boolean isBVUGE()
Definition Expr.java:979
boolean isFalse()
Definition Expr.java:365
boolean isProofApplyDef()
Definition Expr.java:1801
Expr< R > simplify(Params p)
Definition Expr.java:55
boolean isProofNNFNeg()
Definition Expr.java:1860
boolean isBVToInt()
Definition Expr.java:1277
Expr< R > simplify()
Definition Expr.java:41
boolean isBVSLE()
Definition Expr.java:968
boolean isProofTrue()
Definition Expr.java:1392
boolean isProofQuantIntro()
Definition Expr.java:1512
boolean isProofReflexivity()
Definition Expr.java:1442
boolean isProofModusPonensOEQ()
Definition Expr.java:1891
boolean isProofTransitivity()
Definition Expr.java:1466
boolean isWellSorted()
Definition Expr.java:262
boolean isProofPullQuant()
Definition Expr.java:1601
boolean isProofOrElimination()
Definition Expr.java:1553
Expr< R > substituteFuns(FuncDecl<?>[] from, Expr<?>[] to)
Definition Expr.java:203
boolean isProofIFFFalse()
Definition Expr.java:1723
boolean isProofQuantInst()
Definition Expr.java:1660
boolean isBVExtract()
Definition Expr.java:1139
boolean isProofPushQuant()
Definition Expr.java:1616
boolean isRelationUnion()
Definition Expr.java:1982
boolean isProofTheoryLemma()
Definition Expr.java:1913
boolean isRealToInt()
Definition Expr.java:627
boolean isBVRotateLeftExtended()
Definition Expr.java:1241
Expr<?>[] getArgs()
Definition Expr.java:109
boolean isProofSkolemize()
Definition Expr.java:1878
boolean isRelationClone()
Definition Expr.java:2094
boolean isBVBitZero()
Definition Expr.java:808
boolean isBVSub()
Definition Expr.java:838
boolean isProofElimUnusedVars()
Definition Expr.java:1632
boolean isProofSymmetry()
Definition Expr.java:1454
boolean isGround()
Definition Expr.java:323
boolean isProofMonotonicity()
Definition Expr.java:1501
boolean isBVZeroExtension()
Definition Expr.java:1129
Expr< R > translate(Context ctx)
Definition Expr.java:223
boolean isAlgebraicNumber()
Definition Expr.java:313
boolean isSetDifference()
Definition Expr.java:746
boolean isProofAndElimination()
Definition Expr.java:1542
boolean isProofDefIntro()
Definition Expr.java:1789
boolean isBVRotateRight()
Definition Expr.java:1229
boolean isArray()
Definition Expr.java:648
boolean isSetComplement()
Definition Expr.java:756
boolean isProofGoal()
Definition Expr.java:1413
boolean isStore()
Definition Expr.java:661
boolean isIntToReal()
Definition Expr.java:617
boolean isArithmeticNumeral()
Definition Expr.java:487
boolean isBVShiftRightArithmetic()
Definition Expr.java:1209
boolean isBVCarry()
Definition Expr.java:1288
boolean isRatNum()
Definition Expr.java:303
boolean isFiniteDomainLT()
Definition Expr.java:2117
FuncDecl< R > getFuncDecl()
Definition Expr.java:76
boolean isIsEmptyRelation()
Definition Expr.java:1960
boolean isBVSGE()
Definition Expr.java:989
boolean isBVRotateLeft()
Definition Expr.java:1219
boolean isBVSDiv()
Definition Expr.java:858
Expr< R > update(Expr<?>[] args)
Definition Expr.java:127
boolean isRealIsInt()
Definition Expr.java:638
boolean isProofUnitResolution()
Definition Expr.java:1699
boolean isBVShiftLeft()
Definition Expr.java:1189
boolean isBVShiftRightLogical()
Definition Expr.java:1199
boolean isFiniteDomain()
Definition Expr.java:2104
boolean isRelationProject()
Definition Expr.java:2007
boolean isSetIntersect()
Definition Expr.java:736
boolean isAsArray()
Definition Expr.java:716
boolean isLabelLit()
Definition Expr.java:1325
boolean isSetSubset()
Definition Expr.java:766
boolean isRelationNegationFilter()
Definition Expr.java:2042
boolean isDistinct()
Definition Expr.java:386
boolean isBVSMod()
Definition Expr.java:898
boolean isLambda()
Definition Expr.java:333
boolean isRelationWiden()
Definition Expr.java:1994
boolean isRelationSelect()
Definition Expr.java:2078
boolean isBVConcat()
Definition Expr.java:1109
boolean isIntNum()
Definition Expr.java:293
boolean isProofDefAxiom()
Definition Expr.java:1766
boolean isBVUDiv()
Definition Expr.java:868
boolean isBVReduceAND()
Definition Expr.java:1169
boolean isBVULE()
Definition Expr.java:958
boolean isDefaultArray()
Definition Expr.java:693
boolean isBVURem()
Definition Expr.java:888
boolean isBVUMinus()
Definition Expr.java:818
boolean isBVReduceOR()
Definition Expr.java:1159
boolean isProofModusPonens()
Definition Expr.java:1427
boolean isRelationStore()
Definition Expr.java:1940
boolean isProofRewriteStar()
Definition Expr.java:1589
boolean isBVMul()
Definition Expr.java:848
boolean isProofDistributivity()
Definition Expr.java:1531
boolean isModulus()
Definition Expr.java:607
boolean isRelationRename()
Definition Expr.java:2054
boolean isNumeral()
Definition Expr.java:242
boolean isBVBitOne()
Definition Expr.java:798
boolean isProofNNFPos()
Definition Expr.java:1841
boolean isProofIFFOEQ()
Definition Expr.java:1813
boolean isBVULT()
Definition Expr.java:999
boolean isBVSignExtension()
Definition Expr.java:1119
boolean isBVAdd()
Definition Expr.java:828
boolean isRemainder()
Definition Expr.java:597
boolean isProofCommutativity()
Definition Expr.java:1740
double getNumeralDouble()
Definition Expr.java:251
boolean isConst()
Definition Expr.java:283
Expr< R > substitute(Expr<?> from, Expr<?> to)
Definition Expr.java:168
boolean isBVNumeral()
Definition Expr.java:788
boolean isRelationComplement()
Definition Expr.java:2064
boolean isProofRewrite()
Definition Expr.java:1573
static long[] arrayToNative(Z3Object[] a)
Definition Z3Object.java:73
Z3_ast_kind
The different kinds of Z3 AST (abstract syntax trees). That is, terms, formulas and types.
Definition z3_api.h:142
Z3_decl_kind
The different kinds of interpreted function kinds.
Definition z3_api.h:988
Z3_sort_kind
The different kinds of Z3 types (See Z3_get_sort_kind).
Definition z3_api.h:110
Z3_lbool
Lifted Boolean type: false, undefined, true.
Definition z3_api.h:58
@ Z3_BOOL_SORT
Definition z3_api.h:112
@ Z3_ROUNDING_MODE_SORT
Definition z3_api.h:121
@ Z3_BV_SORT
Definition z3_api.h:115
@ Z3_DATATYPE_SORT
Definition z3_api.h:117
@ Z3_INT_SORT
Definition z3_api.h:113
@ Z3_FINITE_DOMAIN_SORT
Definition z3_api.h:119
@ Z3_RE_SORT
Definition z3_api.h:123
@ Z3_FLOATING_POINT_SORT
Definition z3_api.h:120
@ Z3_ARRAY_SORT
Definition z3_api.h:116
@ Z3_REAL_SORT
Definition z3_api.h:114
@ Z3_SEQ_SORT
Definition z3_api.h:122