21using System.Collections.Generic;
22using System.Diagnostics;
24using System.Runtime.InteropServices;
44 m_ctx = Native.Z3_mk_context_rc(IntPtr.Zero);
67 public Context(Dictionary<string, string> settings)
70 Debug.Assert(settings !=
null);
74 IntPtr cfg = Native.Z3_mk_config();
75 foreach (KeyValuePair<string, string> kv
in settings)
76 Native.Z3_set_param_value(cfg, kv.Key, kv.Value);
77 m_ctx = Native.Z3_mk_context_rc(cfg);
78 Native.Z3_del_config(cfg);
97 bool is_external =
false;
125 internal Symbol[] MkSymbols(
string[] names)
127 if (names ==
null)
return new Symbol[0];
129 for (
int i = 0; i < names.Length; ++i) result[i] =
MkSymbol(names[i]);
136 private IntSort m_intSort =
null;
138 private SeqSort m_stringSort =
null;
148 if (m_boolSort ==
null) m_boolSort =
new BoolSort(
this);
return m_boolSort;
159 if (m_intSort ==
null) m_intSort =
new IntSort(
this);
return m_intSort;
171 if (m_realSort ==
null) m_realSort =
new RealSort(
this);
return m_realSort;
182 if (m_charSort ==
null) m_charSort =
new CharSort(
this);
return m_charSort;
194 if (m_stringSort ==
null) m_stringSort =
new SeqSort(
this, Native.Z3_mk_string_sort(nCtx));
213 Debug.Assert(s !=
null);
215 CheckContextMatch(s);
250 return new BitVecSort(
this, Native.Z3_mk_bv_sort(nCtx, size));
258 Debug.Assert(s !=
null);
259 return new SeqSort(
this, Native.Z3_mk_seq_sort(nCtx, s.NativeObject));
267 Debug.Assert(s !=
null);
268 return new ReSort(
this, Native.Z3_mk_re_sort(nCtx, s.NativeObject));
276 Debug.Assert(domain !=
null);
277 Debug.Assert(
range !=
null);
279 CheckContextMatch(domain);
280 CheckContextMatch(
range);
289 Debug.Assert(domain !=
null);
290 Debug.Assert(
range !=
null);
292 CheckContextMatch<Sort>(domain);
293 CheckContextMatch(
range);
302 Debug.Assert(name !=
null);
303 Debug.Assert(fieldNames !=
null);
304 Debug.Assert(fieldNames.All(fn => fn !=
null));
305 Debug.Assert(fieldSorts ==
null || fieldSorts.All(fs => fs !=
null));
307 CheckContextMatch(name);
308 CheckContextMatch<Symbol>(fieldNames);
309 CheckContextMatch<Sort>(fieldSorts);
310 return new TupleSort(
this, name, (uint)fieldNames.Length, fieldNames, fieldSorts);
318 Debug.Assert(name !=
null);
319 Debug.Assert(enumNames !=
null);
320 Debug.Assert(enumNames.All(f => f !=
null));
323 CheckContextMatch(name);
324 CheckContextMatch<Symbol>(enumNames);
325 return new EnumSort(
this, name, enumNames);
333 Debug.Assert(enumNames !=
null);
335 var enumSymbols = MkSymbols(enumNames);
339 return new EnumSort(
this, symbol, enumSymbols);
343 foreach (var enumSymbol
in enumSymbols)
344 enumSymbol.Dispose();
353 Debug.Assert(name !=
null);
354 Debug.Assert(elemSort !=
null);
356 CheckContextMatch(name);
357 CheckContextMatch(elemSort);
358 return new ListSort(
this, name, elemSort);
366 Debug.Assert(elemSort !=
null);
368 CheckContextMatch(elemSort);
370 return new ListSort(
this, symbol, elemSort);
381 Debug.Assert(name !=
null);
383 CheckContextMatch(name);
415 Debug.Assert(name !=
null);
416 Debug.Assert(recognizer !=
null);
418 return new Constructor(
this, name, recognizer, fieldNames, sorts, sortRefs);
433 using var nameSymbol =
MkSymbol(name);
434 using var recognizerSymbol =
MkSymbol(recognizer);
435 var fieldSymbols = MkSymbols(fieldNames);
438 return new Constructor(
this, nameSymbol, recognizerSymbol, fieldSymbols, sorts, sortRefs);
442 foreach (var fieldSymbol
in fieldSymbols)
443 fieldSymbol.Dispose();
452 Debug.Assert(name !=
null);
453 Debug.Assert(constructors !=
null);
454 Debug.Assert(constructors.All(c => c !=
null));
457 CheckContextMatch(name);
458 CheckContextMatch<Constructor>(constructors);
467 Debug.Assert(constructors !=
null);
468 Debug.Assert(constructors.All(c => c !=
null));
470 CheckContextMatch<Constructor>(constructors);
482 Debug.Assert(names !=
null);
483 Debug.Assert(c !=
null);
484 Debug.Assert(names.Length == c.Length);
486 Debug.Assert(names.All(name => name !=
null));
488 CheckContextMatch<Symbol>(names);
489 uint n = (uint)names.Length;
491 IntPtr[] n_constr =
new IntPtr[n];
492 for (uint i = 0; i < n; i++)
495 CheckContextMatch<Constructor>(constructor);
497 n_constr[i] = cla[i].NativeObject;
499 IntPtr[] n_res =
new IntPtr[n];
500 Native.Z3_mk_datatypes(nCtx, n,
Symbol.ArrayToNative(names), n_res, n_constr);
502 for (uint i = 0; i < n; i++)
515 Debug.Assert(names !=
null);
516 Debug.Assert(c !=
null);
517 Debug.Assert(names.Length == c.Length);
521 var symbols = MkSymbols(names);
528 foreach (var symbol
in symbols)
541 return Expr.Create(
this, Native.Z3_datatype_update_field(
542 nCtx, field.NativeObject,
543 t.NativeObject, v.NativeObject));
549 #region Function Declarations
555 Debug.Assert(name !=
null);
556 Debug.Assert(
range !=
null);
557 Debug.Assert(domain.All(d => d !=
null));
559 CheckContextMatch(name);
560 CheckContextMatch<Sort>(domain);
561 CheckContextMatch(
range);
570 Debug.Assert(name !=
null);
571 Debug.Assert(domain !=
null);
572 Debug.Assert(
range !=
null);
574 CheckContextMatch(name);
575 CheckContextMatch(domain);
576 CheckContextMatch(
range);
586 Debug.Assert(
range !=
null);
587 Debug.Assert(domain.All(d => d !=
null));
589 CheckContextMatch<Sort>(domain);
590 CheckContextMatch(
range);
600 Debug.Assert(
range !=
null);
601 Debug.Assert(domain.All(d => d !=
null));
603 CheckContextMatch<Sort>(domain);
604 CheckContextMatch(
range);
617 CheckContextMatch(f);
618 CheckContextMatch<Expr>(args);
619 CheckContextMatch(body);
620 IntPtr[] argsNative =
AST.ArrayToNative(args);
621 Native.Z3_add_rec_def(nCtx, f.NativeObject, (uint)args.Length, argsNative, body.NativeObject);
629 Debug.Assert(
range !=
null);
630 Debug.Assert(domain !=
null);
632 CheckContextMatch(domain);
633 CheckContextMatch(
range);
646 Debug.Assert(
range !=
null);
647 Debug.Assert(domain.All(d => d !=
null));
649 CheckContextMatch<Sort>(domain);
650 CheckContextMatch(
range);
659 Debug.Assert(name !=
null);
660 Debug.Assert(
range !=
null);
662 CheckContextMatch(name);
663 CheckContextMatch(
range);
672 Debug.Assert(
range !=
null);
674 CheckContextMatch(
range);
686 Debug.Assert(
range !=
null);
688 CheckContextMatch(
range);
698 var fn = Native.Z3_solver_propagate_declare(nCtx, _name.NativeObject,
AST.ArrayLength(domain),
AST.ArrayToNative(domain),
range.NativeObject);
703 #region Bound Variables
711 Debug.Assert(ty !=
null);
713 return Expr.Create(
this, Native.Z3_mk_bound(nCtx, index, ty.NativeObject));
717 #region Quantifier Patterns
723 Debug.Assert(terms !=
null);
724 if (terms.Length == 0)
725 throw new Z3Exception(
"Cannot create a pattern from zero terms");
727 IntPtr[] termsNative =
AST.ArrayToNative(terms);
728 return new Pattern(
this, Native.Z3_mk_pattern(nCtx, (uint)terms.Length, termsNative));
738 Debug.Assert(name !=
null);
739 Debug.Assert(
range !=
null);
741 CheckContextMatch(name);
742 CheckContextMatch(
range);
744 return Expr.Create(
this, Native.Z3_mk_const(nCtx, name.NativeObject,
range.NativeObject));
752 Debug.Assert(
range !=
null);
764 Debug.Assert(
range !=
null);
766 CheckContextMatch(
range);
767 return Expr.Create(
this, Native.Z3_mk_fresh_const(nCtx, prefix,
range.NativeObject));
776 Debug.Assert(f !=
null);
786 Debug.Assert(name !=
null);
805 Debug.Assert(name !=
null);
815 Debug.Assert(name !=
null);
825 Debug.Assert(name !=
null);
844 Debug.Assert(name !=
null);
866 Debug.Assert(f !=
null);
867 Debug.Assert(args ==
null || args.All(a => a !=
null));
869 CheckContextMatch(f);
870 CheckContextMatch<Expr>(args);
871 return Expr.Create(
this, f, args);
879 Debug.Assert(f !=
null);
880 Debug.Assert(args ==
null || args.All(a => a !=
null));
882 CheckContextMatch(f);
883 CheckContextMatch(args);
884 return Expr.Create(
this, f, args.ToArray());
887 #region Propositional
894 return new BoolExpr(
this, Native.Z3_mk_true(nCtx));
903 return new BoolExpr(
this, Native.Z3_mk_false(nCtx));
920 Debug.Assert(x !=
null);
921 Debug.Assert(y !=
null);
923 CheckContextMatch(x);
924 CheckContextMatch(y);
925 return new BoolExpr(
this, Native.Z3_mk_eq(nCtx, x.NativeObject, y.NativeObject));
933 Debug.Assert(args !=
null);
934 Debug.Assert(args.All(a => a !=
null));
937 CheckContextMatch<Expr>(args);
938 return new BoolExpr(
this, Native.Z3_mk_distinct(nCtx, (uint)args.Length,
AST.ArrayToNative(args)));
946 Debug.Assert(args !=
null);
955 Debug.Assert(a !=
null);
957 CheckContextMatch(a);
958 return new BoolExpr(
this, Native.Z3_mk_not(nCtx, a.NativeObject));
969 Debug.Assert(t1 !=
null);
970 Debug.Assert(t2 !=
null);
971 Debug.Assert(t3 !=
null);
973 CheckContextMatch(t1);
974 CheckContextMatch(t2);
975 CheckContextMatch(t3);
976 return Expr.Create(
this, Native.Z3_mk_ite(nCtx, t1.NativeObject, t2.NativeObject, t3.NativeObject));
984 Debug.Assert(t1 !=
null);
985 Debug.Assert(t2 !=
null);
987 CheckContextMatch(t1);
988 CheckContextMatch(t2);
989 return new BoolExpr(
this, Native.Z3_mk_iff(nCtx, t1.NativeObject, t2.NativeObject));
997 Debug.Assert(t1 !=
null);
998 Debug.Assert(t2 !=
null);
1000 CheckContextMatch(t1);
1001 CheckContextMatch(t2);
1002 return new BoolExpr(
this, Native.Z3_mk_implies(nCtx, t1.NativeObject, t2.NativeObject));
1010 Debug.Assert(t1 !=
null);
1011 Debug.Assert(t2 !=
null);
1013 CheckContextMatch(t1);
1014 CheckContextMatch(t2);
1015 return new BoolExpr(
this, Native.Z3_mk_xor(nCtx, t1.NativeObject, t2.NativeObject));
1023 Debug.Assert(ts !=
null);
1024 Debug.Assert(ts.All(a => a !=
null));
1025 CheckContextMatch<BoolExpr>(ts);
1027 return ts.Aggregate(
MkFalse(), (r, t) =>
1039 Debug.Assert(t !=
null);
1040 Debug.Assert(t.All(a => a !=
null));
1042 CheckContextMatch<BoolExpr>(t);
1043 return new BoolExpr(
this, Native.Z3_mk_and(nCtx, (uint)t.Length,
AST.ArrayToNative(t)));
1051 Debug.Assert(t !=
null);
1052 Debug.Assert(t.All(a => a !=
null));
1053 CheckContextMatch<BoolExpr>(t);
1054 var ands = t.ToArray();
1055 return new BoolExpr(
this, Native.Z3_mk_and(nCtx, (uint)t.Count(),
AST.ArrayToNative(ands)));
1063 Debug.Assert(t !=
null);
1064 Debug.Assert(t.All(a => a !=
null));
1066 CheckContextMatch<BoolExpr>(t);
1067 return new BoolExpr(
this, Native.Z3_mk_or(nCtx, (uint)t.Length,
AST.ArrayToNative(t)));
1076 Debug.Assert(t !=
null);
1077 Debug.Assert(t.All(a => a !=
null));
1079 CheckContextMatch(t);
1080 var ts = t.ToArray();
1081 return new BoolExpr(
this, Native.Z3_mk_or(nCtx, (uint)ts.Length,
AST.ArrayToNative(ts)));
1092 Debug.Assert(t !=
null);
1093 Debug.Assert(t.All(a => a !=
null));
1095 CheckContextMatch<ArithExpr>(t);
1096 return (
ArithExpr)
Expr.Create(
this, Native.Z3_mk_add(nCtx, (uint)t.Length,
AST.ArrayToNative(t)));
1104 Debug.Assert(t !=
null);
1105 Debug.Assert(t.All(a => a !=
null));
1107 CheckContextMatch(t);
1108 var ts = t.ToArray();
1109 return (
ArithExpr)
Expr.Create(
this, Native.Z3_mk_add(nCtx, (uint)ts.Length,
AST.ArrayToNative(ts)));
1117 Debug.Assert(t !=
null);
1118 Debug.Assert(t.All(a => a !=
null));
1120 CheckContextMatch<ArithExpr>(t);
1121 var ts = t.ToArray();
1122 return (
ArithExpr)
Expr.Create(
this, Native.Z3_mk_mul(nCtx, (uint)ts.Length,
AST.ArrayToNative(ts)));
1130 Debug.Assert(t !=
null);
1131 Debug.Assert(t.All(a => a !=
null));
1133 CheckContextMatch<ArithExpr>(t);
1134 var ts = t.ToArray();
1135 return (
ArithExpr)
Expr.Create(
this, Native.Z3_mk_mul(nCtx, (uint)ts.Length,
AST.ArrayToNative(ts)));
1143 Debug.Assert(t !=
null);
1144 Debug.Assert(t.All(a => a !=
null));
1146 CheckContextMatch<ArithExpr>(t);
1147 return (
ArithExpr)
Expr.Create(
this, Native.Z3_mk_sub(nCtx, (uint)t.Length,
AST.ArrayToNative(t)));
1155 Debug.Assert(t !=
null);
1157 CheckContextMatch(t);
1158 return (
ArithExpr)
Expr.Create(
this, Native.Z3_mk_unary_minus(nCtx, t.NativeObject));
1166 Debug.Assert(t1 !=
null);
1167 Debug.Assert(t2 !=
null);
1169 CheckContextMatch(t1);
1170 CheckContextMatch(t2);
1171 return (
ArithExpr)
Expr.Create(
this, Native.Z3_mk_div(nCtx, t1.NativeObject, t2.NativeObject));
1180 Debug.Assert(t1 !=
null);
1181 Debug.Assert(t2 !=
null);
1183 CheckContextMatch(t1);
1184 CheckContextMatch(t2);
1185 return new IntExpr(
this, Native.Z3_mk_mod(nCtx, t1.NativeObject, t2.NativeObject));
1194 Debug.Assert(t1 !=
null);
1195 Debug.Assert(t2 !=
null);
1197 CheckContextMatch(t1);
1198 CheckContextMatch(t2);
1199 return new IntExpr(
this, Native.Z3_mk_rem(nCtx, t1.NativeObject, t2.NativeObject));
1207 Debug.Assert(t1 !=
null);
1208 Debug.Assert(t2 !=
null);
1210 CheckContextMatch(t1);
1211 CheckContextMatch(t2);
1212 return (
ArithExpr)
Expr.Create(
this, Native.Z3_mk_power(nCtx, t1.NativeObject, t2.NativeObject));
1220 Debug.Assert(t1 !=
null);
1221 Debug.Assert(t2 !=
null);
1223 CheckContextMatch(t1);
1224 CheckContextMatch(t2);
1225 return new BoolExpr(
this, Native.Z3_mk_lt(nCtx, t1.NativeObject, t2.NativeObject));
1233 Debug.Assert(t1 !=
null);
1234 Debug.Assert(t2 !=
null);
1236 CheckContextMatch(t1);
1237 CheckContextMatch(t2);
1238 return new BoolExpr(
this, Native.Z3_mk_le(nCtx, t1.NativeObject, t2.NativeObject));
1246 Debug.Assert(t1 !=
null);
1247 Debug.Assert(t2 !=
null);
1249 CheckContextMatch(t1);
1250 CheckContextMatch(t2);
1251 return new BoolExpr(
this, Native.Z3_mk_gt(nCtx, t1.NativeObject, t2.NativeObject));
1259 Debug.Assert(t1 !=
null);
1260 Debug.Assert(t2 !=
null);
1262 CheckContextMatch(t1);
1263 CheckContextMatch(t2);
1264 return new BoolExpr(
this, Native.Z3_mk_ge(nCtx, t1.NativeObject, t2.NativeObject));
1279 Debug.Assert(t !=
null);
1281 CheckContextMatch(t);
1282 return new RealExpr(
this, Native.Z3_mk_int2real(nCtx, t.NativeObject));
1294 Debug.Assert(t !=
null);
1296 CheckContextMatch(t);
1297 return new IntExpr(
this, Native.Z3_mk_real2int(nCtx, t.NativeObject));
1305 Debug.Assert(t !=
null);
1307 CheckContextMatch(t);
1308 return new BoolExpr(
this, Native.Z3_mk_is_int(nCtx, t.NativeObject));
1319 Debug.Assert(t !=
null);
1321 CheckContextMatch(t);
1322 return new BitVecExpr(
this, Native.Z3_mk_bvnot(nCtx, t.NativeObject));
1331 Debug.Assert(t !=
null);
1333 CheckContextMatch(t);
1334 return new BitVecExpr(
this, Native.Z3_mk_bvredand(nCtx, t.NativeObject));
1343 Debug.Assert(t !=
null);
1345 CheckContextMatch(t);
1346 return new BitVecExpr(
this, Native.Z3_mk_bvredor(nCtx, t.NativeObject));
1355 Debug.Assert(t1 !=
null);
1356 Debug.Assert(t2 !=
null);
1358 CheckContextMatch(t1);
1359 CheckContextMatch(t2);
1360 return new BitVecExpr(
this, Native.Z3_mk_bvand(nCtx, t1.NativeObject, t2.NativeObject));
1369 Debug.Assert(t1 !=
null);
1370 Debug.Assert(t2 !=
null);
1372 CheckContextMatch(t1);
1373 CheckContextMatch(t2);
1374 return new BitVecExpr(
this, Native.Z3_mk_bvor(nCtx, t1.NativeObject, t2.NativeObject));
1383 Debug.Assert(t1 !=
null);
1384 Debug.Assert(t2 !=
null);
1386 CheckContextMatch(t1);
1387 CheckContextMatch(t2);
1388 return new BitVecExpr(
this, Native.Z3_mk_bvxor(nCtx, t1.NativeObject, t2.NativeObject));
1397 Debug.Assert(t1 !=
null);
1398 Debug.Assert(t2 !=
null);
1400 CheckContextMatch(t1);
1401 CheckContextMatch(t2);
1402 return new BitVecExpr(
this, Native.Z3_mk_bvnand(nCtx, t1.NativeObject, t2.NativeObject));
1411 Debug.Assert(t1 !=
null);
1412 Debug.Assert(t2 !=
null);
1414 CheckContextMatch(t1);
1415 CheckContextMatch(t2);
1416 return new BitVecExpr(
this, Native.Z3_mk_bvnor(nCtx, t1.NativeObject, t2.NativeObject));
1425 Debug.Assert(t1 !=
null);
1426 Debug.Assert(t2 !=
null);
1428 CheckContextMatch(t1);
1429 CheckContextMatch(t2);
1430 return new BitVecExpr(
this, Native.Z3_mk_bvxnor(nCtx, t1.NativeObject, t2.NativeObject));
1439 Debug.Assert(t !=
null);
1441 CheckContextMatch(t);
1442 return new BitVecExpr(
this, Native.Z3_mk_bvneg(nCtx, t.NativeObject));
1451 Debug.Assert(t1 !=
null);
1452 Debug.Assert(t2 !=
null);
1454 CheckContextMatch(t1);
1455 CheckContextMatch(t2);
1456 return new BitVecExpr(
this, Native.Z3_mk_bvadd(nCtx, t1.NativeObject, t2.NativeObject));
1465 Debug.Assert(t1 !=
null);
1466 Debug.Assert(t2 !=
null);
1468 CheckContextMatch(t1);
1469 CheckContextMatch(t2);
1470 return new BitVecExpr(
this, Native.Z3_mk_bvsub(nCtx, t1.NativeObject, t2.NativeObject));
1479 Debug.Assert(t1 !=
null);
1480 Debug.Assert(t2 !=
null);
1482 CheckContextMatch(t1);
1483 CheckContextMatch(t2);
1484 return new BitVecExpr(
this, Native.Z3_mk_bvmul(nCtx, t1.NativeObject, t2.NativeObject));
1498 Debug.Assert(t1 !=
null);
1499 Debug.Assert(t2 !=
null);
1501 CheckContextMatch(t1);
1502 CheckContextMatch(t2);
1503 return new BitVecExpr(
this, Native.Z3_mk_bvudiv(nCtx, t1.NativeObject, t2.NativeObject));
1521 Debug.Assert(t1 !=
null);
1522 Debug.Assert(t2 !=
null);
1524 CheckContextMatch(t1);
1525 CheckContextMatch(t2);
1526 return new BitVecExpr(
this, Native.Z3_mk_bvsdiv(nCtx, t1.NativeObject, t2.NativeObject));
1539 Debug.Assert(t1 !=
null);
1540 Debug.Assert(t2 !=
null);
1542 CheckContextMatch(t1);
1543 CheckContextMatch(t2);
1544 return new BitVecExpr(
this, Native.Z3_mk_bvurem(nCtx, t1.NativeObject, t2.NativeObject));
1559 Debug.Assert(t1 !=
null);
1560 Debug.Assert(t2 !=
null);
1562 CheckContextMatch(t1);
1563 CheckContextMatch(t2);
1564 return new BitVecExpr(
this, Native.Z3_mk_bvsrem(nCtx, t1.NativeObject, t2.NativeObject));
1576 Debug.Assert(t1 !=
null);
1577 Debug.Assert(t2 !=
null);
1579 CheckContextMatch(t1);
1580 CheckContextMatch(t2);
1581 return new BitVecExpr(
this, Native.Z3_mk_bvsmod(nCtx, t1.NativeObject, t2.NativeObject));
1592 Debug.Assert(t1 !=
null);
1593 Debug.Assert(t2 !=
null);
1595 CheckContextMatch(t1);
1596 CheckContextMatch(t2);
1597 return new BoolExpr(
this, Native.Z3_mk_bvult(nCtx, t1.NativeObject, t2.NativeObject));
1608 Debug.Assert(t1 !=
null);
1609 Debug.Assert(t2 !=
null);
1611 CheckContextMatch(t1);
1612 CheckContextMatch(t2);
1613 return new BoolExpr(
this, Native.Z3_mk_bvslt(nCtx, t1.NativeObject, t2.NativeObject));
1624 Debug.Assert(t1 !=
null);
1625 Debug.Assert(t2 !=
null);
1627 CheckContextMatch(t1);
1628 CheckContextMatch(t2);
1629 return new BoolExpr(
this, Native.Z3_mk_bvule(nCtx, t1.NativeObject, t2.NativeObject));
1640 Debug.Assert(t1 !=
null);
1641 Debug.Assert(t2 !=
null);
1643 CheckContextMatch(t1);
1644 CheckContextMatch(t2);
1645 return new BoolExpr(
this, Native.Z3_mk_bvsle(nCtx, t1.NativeObject, t2.NativeObject));
1656 Debug.Assert(t1 !=
null);
1657 Debug.Assert(t2 !=
null);
1659 CheckContextMatch(t1);
1660 CheckContextMatch(t2);
1661 return new BoolExpr(
this, Native.Z3_mk_bvuge(nCtx, t1.NativeObject, t2.NativeObject));
1672 Debug.Assert(t1 !=
null);
1673 Debug.Assert(t2 !=
null);
1675 CheckContextMatch(t1);
1676 CheckContextMatch(t2);
1677 return new BoolExpr(
this, Native.Z3_mk_bvsge(nCtx, t1.NativeObject, t2.NativeObject));
1688 Debug.Assert(t1 !=
null);
1689 Debug.Assert(t2 !=
null);
1691 CheckContextMatch(t1);
1692 CheckContextMatch(t2);
1693 return new BoolExpr(
this, Native.Z3_mk_bvugt(nCtx, t1.NativeObject, t2.NativeObject));
1704 Debug.Assert(t1 !=
null);
1705 Debug.Assert(t2 !=
null);
1707 CheckContextMatch(t1);
1708 CheckContextMatch(t2);
1709 return new BoolExpr(
this, Native.Z3_mk_bvsgt(nCtx, t1.NativeObject, t2.NativeObject));
1724 Debug.Assert(t1 !=
null);
1725 Debug.Assert(t2 !=
null);
1727 CheckContextMatch(t1);
1728 CheckContextMatch(t2);
1729 return new BitVecExpr(
this, Native.Z3_mk_concat(nCtx, t1.NativeObject, t2.NativeObject));
1743 Debug.Assert(t !=
null);
1745 CheckContextMatch(t);
1746 return new BitVecExpr(
this, Native.Z3_mk_extract(nCtx, high, low, t.NativeObject));
1759 Debug.Assert(t !=
null);
1761 CheckContextMatch(t);
1762 return new BitVecExpr(
this, Native.Z3_mk_sign_ext(nCtx, i, t.NativeObject));
1776 Debug.Assert(t !=
null);
1778 CheckContextMatch(t);
1779 return new BitVecExpr(
this, Native.Z3_mk_zero_ext(nCtx, i, t.NativeObject));
1790 Debug.Assert(t !=
null);
1792 CheckContextMatch(t);
1793 return new BitVecExpr(
this, Native.Z3_mk_repeat(nCtx, i, t.NativeObject));
1810 Debug.Assert(t1 !=
null);
1811 Debug.Assert(t2 !=
null);
1813 CheckContextMatch(t1);
1814 CheckContextMatch(t2);
1815 return new BitVecExpr(
this, Native.Z3_mk_bvshl(nCtx, t1.NativeObject, t2.NativeObject));
1832 Debug.Assert(t1 !=
null);
1833 Debug.Assert(t2 !=
null);
1835 CheckContextMatch(t1);
1836 CheckContextMatch(t2);
1837 return new BitVecExpr(
this, Native.Z3_mk_bvlshr(nCtx, t1.NativeObject, t2.NativeObject));
1856 Debug.Assert(t1 !=
null);
1857 Debug.Assert(t2 !=
null);
1859 CheckContextMatch(t1);
1860 CheckContextMatch(t2);
1861 return new BitVecExpr(
this, Native.Z3_mk_bvashr(nCtx, t1.NativeObject, t2.NativeObject));
1873 Debug.Assert(t !=
null);
1875 CheckContextMatch(t);
1876 return new BitVecExpr(
this, Native.Z3_mk_rotate_left(nCtx, i, t.NativeObject));
1888 Debug.Assert(t !=
null);
1890 CheckContextMatch(t);
1891 return new BitVecExpr(
this, Native.Z3_mk_rotate_right(nCtx, i, t.NativeObject));
1903 Debug.Assert(t1 !=
null);
1904 Debug.Assert(t2 !=
null);
1906 CheckContextMatch(t1);
1907 CheckContextMatch(t2);
1908 return new BitVecExpr(
this, Native.Z3_mk_ext_rotate_left(nCtx, t1.NativeObject, t2.NativeObject));
1920 Debug.Assert(t1 !=
null);
1921 Debug.Assert(t2 !=
null);
1923 CheckContextMatch(t1);
1924 CheckContextMatch(t2);
1925 return new BitVecExpr(
this, Native.Z3_mk_ext_rotate_right(nCtx, t1.NativeObject, t2.NativeObject));
1940 Debug.Assert(t !=
null);
1942 CheckContextMatch(t);
1943 return new BitVecExpr(
this, Native.Z3_mk_int2bv(nCtx, n, t.NativeObject));
1963 Debug.Assert(t !=
null);
1965 CheckContextMatch(t);
1966 return new IntExpr(
this, Native.Z3_mk_bv2int(nCtx, t.NativeObject, (
byte)(
signed ? 1 : 0)));
1977 Debug.Assert(t1 !=
null);
1978 Debug.Assert(t2 !=
null);
1980 CheckContextMatch(t1);
1981 CheckContextMatch(t2);
1982 return new BoolExpr(
this, Native.Z3_mk_bvadd_no_overflow(nCtx, t1.NativeObject, t2.NativeObject, (
byte)(isSigned ? 1 : 0)));
1993 Debug.Assert(t1 !=
null);
1994 Debug.Assert(t2 !=
null);
1996 CheckContextMatch(t1);
1997 CheckContextMatch(t2);
1998 return new BoolExpr(
this, Native.Z3_mk_bvadd_no_underflow(nCtx, t1.NativeObject, t2.NativeObject));
2009 Debug.Assert(t1 !=
null);
2010 Debug.Assert(t2 !=
null);
2012 CheckContextMatch(t1);
2013 CheckContextMatch(t2);
2014 return new BoolExpr(
this, Native.Z3_mk_bvsub_no_overflow(nCtx, t1.NativeObject, t2.NativeObject));
2025 Debug.Assert(t1 !=
null);
2026 Debug.Assert(t2 !=
null);
2028 CheckContextMatch(t1);
2029 CheckContextMatch(t2);
2030 return new BoolExpr(
this, Native.Z3_mk_bvsub_no_underflow(nCtx, t1.NativeObject, t2.NativeObject, (
byte)(isSigned ? 1 : 0)));
2041 Debug.Assert(t1 !=
null);
2042 Debug.Assert(t2 !=
null);
2044 CheckContextMatch(t1);
2045 CheckContextMatch(t2);
2046 return new BoolExpr(
this, Native.Z3_mk_bvsdiv_no_overflow(nCtx, t1.NativeObject, t2.NativeObject));
2057 Debug.Assert(t !=
null);
2059 CheckContextMatch(t);
2060 return new BoolExpr(
this, Native.Z3_mk_bvneg_no_overflow(nCtx, t.NativeObject));
2071 Debug.Assert(t1 !=
null);
2072 Debug.Assert(t2 !=
null);
2074 CheckContextMatch(t1);
2075 CheckContextMatch(t2);
2076 return new BoolExpr(
this, Native.Z3_mk_bvmul_no_overflow(nCtx, t1.NativeObject, t2.NativeObject, (
byte)(isSigned ? 1 : 0)));
2087 Debug.Assert(t1 !=
null);
2088 Debug.Assert(t2 !=
null);
2090 CheckContextMatch(t1);
2091 CheckContextMatch(t2);
2092 return new BoolExpr(
this, Native.Z3_mk_bvmul_no_underflow(nCtx, t1.NativeObject, t2.NativeObject));
2102 Debug.Assert(name !=
null);
2103 Debug.Assert(domain !=
null);
2104 Debug.Assert(
range !=
null);
2115 Debug.Assert(domain !=
null);
2116 Debug.Assert(
range !=
null);
2139 Debug.Assert(a !=
null);
2140 Debug.Assert(i !=
null);
2142 CheckContextMatch(a);
2143 CheckContextMatch(i);
2144 return Expr.Create(
this, Native.Z3_mk_select(nCtx, a.NativeObject, i.NativeObject));
2162 Debug.Assert(a !=
null);
2163 Debug.Assert(args !=
null && args.All(n => n !=
null));
2165 CheckContextMatch(a);
2166 CheckContextMatch<Expr>(args);
2167 return Expr.Create(
this, Native.Z3_mk_select_n(nCtx, a.NativeObject,
AST.ArrayLength(args),
AST.ArrayToNative(args)));
2191 Debug.Assert(a !=
null);
2192 Debug.Assert(i !=
null);
2193 Debug.Assert(v !=
null);
2195 CheckContextMatch(a);
2196 CheckContextMatch(i);
2197 CheckContextMatch(v);
2198 return new ArrayExpr(
this, Native.Z3_mk_store(nCtx, a.NativeObject, i.NativeObject, v.NativeObject));
2221 Debug.Assert(a !=
null);
2222 Debug.Assert(args !=
null);
2223 Debug.Assert(v !=
null);
2225 CheckContextMatch<Expr>(args);
2226 CheckContextMatch(a);
2227 CheckContextMatch(v);
2228 return new ArrayExpr(
this, Native.Z3_mk_store_n(nCtx, a.NativeObject,
AST.ArrayLength(args),
AST.ArrayToNative(args), v.NativeObject));
2242 Debug.Assert(domain !=
null);
2243 Debug.Assert(v !=
null);
2245 CheckContextMatch(domain);
2246 CheckContextMatch(v);
2247 return new ArrayExpr(
this, Native.Z3_mk_const_array(nCtx, domain.NativeObject, v.NativeObject));
2263 Debug.Assert(f !=
null);
2264 Debug.Assert(args ==
null || args.All(a => a !=
null));
2266 CheckContextMatch(f);
2267 CheckContextMatch<ArrayExpr>(args);
2268 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_map(nCtx, f.NativeObject,
AST.ArrayLength(args),
AST.ArrayToNative(args)));
2280 Debug.Assert(array !=
null);
2282 CheckContextMatch(array);
2283 return Expr.Create(
this, Native.Z3_mk_array_default(nCtx, array.NativeObject));
2291 Debug.Assert(arg1 !=
null);
2292 Debug.Assert(arg2 !=
null);
2294 CheckContextMatch(arg1);
2295 CheckContextMatch(arg2);
2296 return Expr.Create(
this, Native.Z3_mk_array_ext(nCtx, arg1.NativeObject, arg2.NativeObject));
2307 Debug.Assert(ty !=
null);
2309 CheckContextMatch(ty);
2318 Debug.Assert(domain !=
null);
2320 CheckContextMatch(domain);
2321 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_empty_set(nCtx, domain.NativeObject));
2329 Debug.Assert(domain !=
null);
2331 CheckContextMatch(domain);
2332 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_full_set(nCtx, domain.NativeObject));
2340 Debug.Assert(
set !=
null);
2341 Debug.Assert(element !=
null);
2343 CheckContextMatch(
set);
2344 CheckContextMatch(element);
2345 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_set_add(nCtx,
set.NativeObject, element.NativeObject));
2354 Debug.Assert(
set !=
null);
2355 Debug.Assert(element !=
null);
2357 CheckContextMatch(
set);
2358 CheckContextMatch(element);
2359 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_set_del(nCtx,
set.NativeObject, element.NativeObject));
2367 Debug.Assert(args !=
null);
2368 Debug.Assert(args.All(a => a !=
null));
2370 CheckContextMatch<ArrayExpr>(args);
2371 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_set_union(nCtx, (uint)args.Length,
AST.ArrayToNative(args)));
2379 Debug.Assert(args !=
null);
2380 Debug.Assert(args.All(a => a !=
null));
2382 CheckContextMatch<ArrayExpr>(args);
2383 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_set_intersect(nCtx, (uint)args.Length,
AST.ArrayToNative(args)));
2391 Debug.Assert(arg1 !=
null);
2392 Debug.Assert(arg2 !=
null);
2394 CheckContextMatch(arg1);
2395 CheckContextMatch(arg2);
2396 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_set_difference(nCtx, arg1.NativeObject, arg2.NativeObject));
2404 Debug.Assert(arg !=
null);
2406 CheckContextMatch(arg);
2407 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_set_complement(nCtx, arg.NativeObject));
2415 Debug.Assert(elem !=
null);
2416 Debug.Assert(
set !=
null);
2418 CheckContextMatch(elem);
2419 CheckContextMatch(
set);
2420 return (
BoolExpr)
Expr.Create(
this, Native.Z3_mk_set_member(nCtx, elem.NativeObject,
set.NativeObject));
2428 Debug.Assert(arg1 !=
null);
2429 Debug.Assert(arg2 !=
null);
2431 CheckContextMatch(arg1);
2432 CheckContextMatch(arg2);
2433 return (
BoolExpr)
Expr.Create(
this, Native.Z3_mk_set_subset(nCtx, arg1.NativeObject, arg2.NativeObject));
2438 #region Sequence, string and regular expressions
2445 Debug.Assert(s !=
null);
2446 return new SeqExpr(
this, Native.Z3_mk_seq_empty(nCtx, s.NativeObject));
2454 Debug.Assert(elem !=
null);
2455 return new SeqExpr(
this, Native.Z3_mk_seq_unit(nCtx, elem.NativeObject));
2463 Debug.Assert(s !=
null);
2464 return new SeqExpr(
this, Native.Z3_mk_string(nCtx, s));
2472 Debug.Assert(e !=
null);
2474 return new SeqExpr(
this, Native.Z3_mk_int_to_str(nCtx, e.NativeObject));
2482 Debug.Assert(e !=
null);
2484 return new SeqExpr(
this, Native.Z3_mk_ubv_to_str(nCtx, e.NativeObject));
2492 Debug.Assert(e !=
null);
2494 return new SeqExpr(
this, Native.Z3_mk_sbv_to_str(nCtx, e.NativeObject));
2502 Debug.Assert(e !=
null);
2504 return new IntExpr(
this, Native.Z3_mk_str_to_int(nCtx, e.NativeObject));
2513 Debug.Assert(t !=
null);
2514 Debug.Assert(t.All(a => a !=
null));
2516 CheckContextMatch<SeqExpr>(t);
2517 return new SeqExpr(
this, Native.Z3_mk_seq_concat(nCtx, (uint)t.Length,
AST.ArrayToNative(t)));
2526 Debug.Assert(s !=
null);
2527 return (
IntExpr)
Expr.Create(
this, Native.Z3_mk_seq_length(nCtx, s.NativeObject));
2535 Debug.Assert(s1 !=
null);
2536 Debug.Assert(s2 !=
null);
2537 CheckContextMatch(s1, s2);
2538 return new BoolExpr(
this, Native.Z3_mk_seq_prefix(nCtx, s1.NativeObject, s2.NativeObject));
2546 Debug.Assert(s1 !=
null);
2547 Debug.Assert(s2 !=
null);
2548 CheckContextMatch(s1, s2);
2549 return new BoolExpr(
this, Native.Z3_mk_seq_suffix(nCtx, s1.NativeObject, s2.NativeObject));
2557 Debug.Assert(s1 !=
null);
2558 Debug.Assert(s2 !=
null);
2559 CheckContextMatch(s1, s2);
2560 return new BoolExpr(
this, Native.Z3_mk_seq_contains(nCtx, s1.NativeObject, s2.NativeObject));
2568 Debug.Assert(s1 !=
null);
2569 Debug.Assert(s2 !=
null);
2570 CheckContextMatch(s1, s2);
2571 return new BoolExpr(
this, Native.Z3_mk_str_lt(nCtx, s1.NativeObject, s2.NativeObject));
2579 Debug.Assert(s1 !=
null);
2580 Debug.Assert(s2 !=
null);
2581 CheckContextMatch(s1, s2);
2582 return new BoolExpr(
this, Native.Z3_mk_str_le(nCtx, s1.NativeObject, s2.NativeObject));
2590 Debug.Assert(s !=
null);
2591 Debug.Assert(index !=
null);
2592 CheckContextMatch(s, index);
2593 return new SeqExpr(
this, Native.Z3_mk_seq_at(nCtx, s.NativeObject, index.NativeObject));
2601 Debug.Assert(s !=
null);
2602 Debug.Assert(index !=
null);
2603 CheckContextMatch(s, index);
2604 return Expr.Create(
this, Native.Z3_mk_seq_nth(nCtx, s.NativeObject, index.NativeObject));
2612 Debug.Assert(s !=
null);
2613 Debug.Assert(offset !=
null);
2614 Debug.Assert(length !=
null);
2615 CheckContextMatch(s, offset, length);
2616 return new SeqExpr(
this, Native.Z3_mk_seq_extract(nCtx, s.NativeObject, offset.NativeObject, length.NativeObject));
2624 Debug.Assert(s !=
null);
2625 Debug.Assert(offset !=
null);
2626 Debug.Assert(substr !=
null);
2627 CheckContextMatch(s, substr, offset);
2628 return new IntExpr(
this, Native.Z3_mk_seq_index(nCtx, s.NativeObject, substr.NativeObject, offset.NativeObject));
2636 Debug.Assert(s !=
null);
2637 Debug.Assert(src !=
null);
2638 Debug.Assert(dst !=
null);
2639 CheckContextMatch(s, src, dst);
2640 return new SeqExpr(
this, Native.Z3_mk_seq_replace(nCtx, s.NativeObject, src.NativeObject, dst.NativeObject));
2648 Debug.Assert(s !=
null);
2649 return new ReExpr(
this, Native.Z3_mk_seq_to_re(nCtx, s.NativeObject));
2658 Debug.Assert(s !=
null);
2659 Debug.Assert(re !=
null);
2660 CheckContextMatch(s, re);
2661 return new BoolExpr(
this, Native.Z3_mk_seq_in_re(nCtx, s.NativeObject, re.NativeObject));
2669 Debug.Assert(re !=
null);
2670 return new ReExpr(
this, Native.Z3_mk_re_star(nCtx, re.NativeObject));
2678 Debug.Assert(re !=
null);
2679 return new ReExpr(
this, Native.Z3_mk_re_loop(nCtx, re.NativeObject, lo, hi));
2687 Debug.Assert(re !=
null);
2688 return new ReExpr(
this, Native.Z3_mk_re_plus(nCtx, re.NativeObject));
2696 Debug.Assert(re !=
null);
2697 return new ReExpr(
this, Native.Z3_mk_re_option(nCtx, re.NativeObject));
2705 Debug.Assert(re !=
null);
2706 return new ReExpr(
this, Native.Z3_mk_re_complement(nCtx, re.NativeObject));
2714 Debug.Assert(t !=
null);
2715 Debug.Assert(t.All(a => a !=
null));
2717 CheckContextMatch<ReExpr>(t);
2718 return new ReExpr(
this, Native.Z3_mk_re_concat(nCtx, (uint)t.Length,
AST.ArrayToNative(t)));
2726 Debug.Assert(t !=
null);
2727 Debug.Assert(t.All(a => a !=
null));
2729 CheckContextMatch<ReExpr>(t);
2730 return new ReExpr(
this, Native.Z3_mk_re_union(nCtx, (uint)t.Length,
AST.ArrayToNative(t)));
2738 Debug.Assert(t !=
null);
2739 Debug.Assert(t.All(a => a !=
null));
2741 CheckContextMatch<ReExpr>(t);
2742 return new ReExpr(
this, Native.Z3_mk_re_intersect(nCtx, (uint)t.Length,
AST.ArrayToNative(t)));
2750 Debug.Assert(a !=
null);
2751 Debug.Assert(b !=
null);
2752 CheckContextMatch(a, b);
2753 return new ReExpr(
this, Native.Z3_mk_re_diff(nCtx, a.NativeObject, b.NativeObject));
2762 Debug.Assert(s !=
null);
2763 return new ReExpr(
this, Native.Z3_mk_re_empty(nCtx, s.NativeObject));
2772 Debug.Assert(s !=
null);
2773 return new ReExpr(
this, Native.Z3_mk_re_full(nCtx, s.NativeObject));
2782 Debug.Assert(lo !=
null);
2783 Debug.Assert(hi !=
null);
2784 CheckContextMatch(lo, hi);
2785 return new ReExpr(
this, Native.Z3_mk_re_range(nCtx, lo.NativeObject, hi.NativeObject));
2793 Debug.Assert(ch1 !=
null);
2794 Debug.Assert(ch2 !=
null);
2795 return new BoolExpr(
this, Native.Z3_mk_char_le(nCtx, ch1.NativeObject, ch2.NativeObject));
2803 Debug.Assert(ch !=
null);
2804 return new IntExpr(
this, Native.Z3_mk_char_to_int(nCtx, ch.NativeObject));
2812 Debug.Assert(ch !=
null);
2813 return new BitVecExpr(
this, Native.Z3_mk_char_to_bv(nCtx, ch.NativeObject));
2821 Debug.Assert(bv !=
null);
2822 return new Expr(
this, Native.Z3_mk_char_from_bv(nCtx, bv.NativeObject));
2830 Debug.Assert(ch !=
null);
2831 return new BoolExpr(
this, Native.Z3_mk_char_is_digit(nCtx, ch.NativeObject));
2836 #region Pseudo-Boolean constraints
2843 Debug.Assert(args !=
null);
2844 CheckContextMatch<BoolExpr>(args);
2845 var ts = args.ToArray();
2846 return new BoolExpr(
this, Native.Z3_mk_atmost(nCtx, (uint)ts.Length,
2847 AST.ArrayToNative(ts), k));
2855 Debug.Assert(args !=
null);
2856 CheckContextMatch<BoolExpr>(args);
2857 var ts = args.ToArray();
2858 return new BoolExpr(
this, Native.Z3_mk_atleast(nCtx, (uint)ts.Length,
2859 AST.ArrayToNative(ts), k));
2867 Debug.Assert(args !=
null);
2868 Debug.Assert(coeffs !=
null);
2869 Debug.Assert(args.Length == coeffs.Length);
2870 CheckContextMatch<BoolExpr>(args);
2871 return new BoolExpr(
this, Native.Z3_mk_pble(nCtx, (uint)args.Length,
2872 AST.ArrayToNative(args),
2881 Debug.Assert(args !=
null);
2882 Debug.Assert(coeffs !=
null);
2883 Debug.Assert(args.Length == coeffs.Length);
2884 CheckContextMatch<BoolExpr>(args);
2885 return new BoolExpr(
this, Native.Z3_mk_pbge(nCtx, (uint)args.Length,
2886 AST.ArrayToNative(args),
2894 Debug.Assert(args !=
null);
2895 Debug.Assert(coeffs !=
null);
2896 Debug.Assert(args.Length == coeffs.Length);
2897 CheckContextMatch<BoolExpr>(args);
2898 return new BoolExpr(
this, Native.Z3_mk_pbeq(nCtx, (uint)args.Length,
2899 AST.ArrayToNative(args),
2906 #region General Numerals
2915 Debug.Assert(ty !=
null);
2917 CheckContextMatch(ty);
2918 return Expr.Create(
this, Native.Z3_mk_numeral(nCtx, v, ty.NativeObject));
2930 Debug.Assert(ty !=
null);
2932 CheckContextMatch(ty);
2933 return Expr.Create(
this, Native.Z3_mk_int(nCtx, v, ty.NativeObject));
2945 Debug.Assert(ty !=
null);
2947 CheckContextMatch(ty);
2948 return Expr.Create(
this, Native.Z3_mk_unsigned_int(nCtx, v, ty.NativeObject));
2960 Debug.Assert(ty !=
null);
2962 CheckContextMatch(ty);
2963 return Expr.Create(
this, Native.Z3_mk_int64(nCtx, v, ty.NativeObject));
2975 Debug.Assert(ty !=
null);
2977 CheckContextMatch(ty);
2978 return Expr.Create(
this, Native.Z3_mk_unsigned_int64(nCtx, v, ty.NativeObject));
2995 return new RatNum(
this, Native.Z3_mk_real(nCtx, num, den));
3006 return new RatNum(
this, Native.Z3_mk_numeral(nCtx, v,
RealSort.NativeObject));
3017 return new RatNum(
this, Native.Z3_mk_int(nCtx, v,
RealSort.NativeObject));
3028 return new RatNum(
this, Native.Z3_mk_unsigned_int(nCtx, v,
RealSort.NativeObject));
3039 return new RatNum(
this, Native.Z3_mk_int64(nCtx, v,
RealSort.NativeObject));
3050 return new RatNum(
this, Native.Z3_mk_unsigned_int64(nCtx, v,
RealSort.NativeObject));
3062 return new IntNum(
this, Native.Z3_mk_numeral(nCtx, v,
IntSort.NativeObject));
3073 return new IntNum(
this, Native.Z3_mk_int(nCtx, v,
IntSort.NativeObject));
3084 return new IntNum(
this, Native.Z3_mk_unsigned_int(nCtx, v,
IntSort.NativeObject));
3095 return new IntNum(
this, Native.Z3_mk_int64(nCtx, v,
IntSort.NativeObject));
3106 return new IntNum(
this, Native.Z3_mk_unsigned_int64(nCtx, v,
IntSort.NativeObject));
3172 byte[] _bits =
new byte[bits.Length];
3173 for (
int i = 0; i < bits.Length; ++i) _bits[i] = (
byte)(bits[i] ? 1 : 0);
3174 return (
BitVecNum)
Expr.Create(
this, Native.Z3_mk_bv_numeral(nCtx, (uint)bits.Length, _bits));
3209 Debug.Assert(sorts !=
null);
3210 Debug.Assert(names !=
null);
3211 Debug.Assert(body !=
null);
3212 Debug.Assert(sorts.Length == names.Length);
3213 Debug.Assert(sorts.All(s => s !=
null));
3214 Debug.Assert(names.All(n => n !=
null));
3215 Debug.Assert(patterns ==
null || patterns.All(p => p !=
null));
3216 Debug.Assert(noPatterns ==
null || noPatterns.All(np => np !=
null));
3219 return new Quantifier(
this,
true, sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID);
3233 Debug.Assert(body !=
null);
3234 Debug.Assert(boundConstants ==
null || boundConstants.All(b => b !=
null));
3235 Debug.Assert(patterns ==
null || patterns.All(p => p !=
null));
3236 Debug.Assert(noPatterns ==
null || noPatterns.All(np => np !=
null));
3239 return new Quantifier(
this,
true, boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID);
3251 Debug.Assert(sorts !=
null);
3252 Debug.Assert(names !=
null);
3253 Debug.Assert(body !=
null);
3254 Debug.Assert(sorts.Length == names.Length);
3255 Debug.Assert(sorts.All(s => s !=
null));
3256 Debug.Assert(names.All(n => n !=
null));
3257 Debug.Assert(patterns ==
null || patterns.All(p => p !=
null));
3258 Debug.Assert(noPatterns ==
null || noPatterns.All(np => np !=
null));
3260 return new Quantifier(
this,
false, sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID);
3273 Debug.Assert(body !=
null);
3274 Debug.Assert(boundConstants ==
null || boundConstants.All(n => n !=
null));
3275 Debug.Assert(patterns ==
null || patterns.All(p => p !=
null));
3276 Debug.Assert(noPatterns ==
null || noPatterns.All(np => np !=
null));
3278 return new Quantifier(
this,
false, boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID);
3288 Debug.Assert(body !=
null);
3289 Debug.Assert(names !=
null);
3290 Debug.Assert(sorts !=
null);
3291 Debug.Assert(sorts.Length == names.Length);
3292 Debug.Assert(sorts.All(s => s !=
null));
3293 Debug.Assert(names.All(n => n !=
null));
3294 Debug.Assert(patterns ==
null || patterns.All(p => p !=
null));
3295 Debug.Assert(noPatterns ==
null || noPatterns.All(np => np !=
null));
3299 return MkForall(sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID);
3301 return MkExists(sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID);
3311 Debug.Assert(body !=
null);
3312 Debug.Assert(boundConstants ==
null || boundConstants.All(n => n !=
null));
3313 Debug.Assert(patterns ==
null || patterns.All(p => p !=
null));
3314 Debug.Assert(noPatterns ==
null || noPatterns.All(np => np !=
null));
3318 return MkForall(boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID);
3320 return MkExists(boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID);
3343 Debug.Assert(sorts !=
null);
3344 Debug.Assert(names !=
null);
3345 Debug.Assert(body !=
null);
3346 Debug.Assert(sorts.Length == names.Length);
3347 Debug.Assert(sorts.All(s => s !=
null));
3348 Debug.Assert(names.All(n => n !=
null));
3349 return new Lambda(
this, sorts, names, body);
3362 Debug.Assert(body !=
null);
3363 Debug.Assert(boundConstants !=
null && boundConstants.All(b => b !=
null));
3364 return new Lambda(
this, boundConstants, body);
3391 set { Native.Z3_set_ast_print_mode(nCtx, (uint)value); }
3395 #region SMT Files & Strings
3404 uint csn =
Symbol.ArrayLength(sortNames);
3405 uint cs =
Sort.ArrayLength(sorts);
3406 uint cdn =
Symbol.ArrayLength(declNames);
3407 uint cd =
AST.ArrayLength(decls);
3408 if (csn != cs || cdn != cd)
3410 using ASTVector assertions =
new ASTVector(
this, Native.Z3_parse_smtlib2_string(nCtx, str,
3411 AST.ArrayLength(sorts),
Symbol.ArrayToNative(sortNames),
AST.ArrayToNative(sorts),
3412 AST.ArrayLength(decls),
Symbol.ArrayToNative(declNames),
AST.ArrayToNative(decls)));
3423 uint csn =
Symbol.ArrayLength(sortNames);
3424 uint cs =
Sort.ArrayLength(sorts);
3425 uint cdn =
Symbol.ArrayLength(declNames);
3426 uint cd =
AST.ArrayLength(decls);
3427 if (csn != cs || cdn != cd)
3429 using ASTVector assertions =
new ASTVector(
this, Native.Z3_parse_smtlib2_file(nCtx, fileName,
3430 AST.ArrayLength(sorts),
Symbol.ArrayToNative(sortNames),
AST.ArrayToNative(sorts),
3431 AST.ArrayLength(decls),
Symbol.ArrayToNative(declNames),
AST.ArrayToNative(decls)));
3447 public Goal MkGoal(
bool models =
true,
bool unsatCores =
false,
bool proofs =
false)
3450 return new Goal(
this, models, unsatCores, proofs);
3454 #region ParameterSets
3471 get {
return Native.Z3_get_num_tactics(nCtx); }
3483 string[] res =
new string[n];
3484 for (uint i = 0; i < n; i++)
3485 res[i] = Native.Z3_get_tactic_name(nCtx, i);
3496 return Native.Z3_tactic_get_descr(nCtx, name);
3505 return new Tactic(
this, name);
3514 Debug.Assert(t1 !=
null);
3515 Debug.Assert(t2 !=
null);
3519 CheckContextMatch(t1);
3520 CheckContextMatch(t2);
3521 CheckContextMatch<Tactic>(ts);
3523 IntPtr last = IntPtr.Zero;
3524 if (ts !=
null && ts.Length > 0)
3526 last = ts[ts.Length - 1].NativeObject;
3527 for (
int i = ts.Length - 2; i >= 0; i--)
3528 last = Native.Z3_tactic_and_then(nCtx, ts[i].NativeObject, last);
3530 if (last != IntPtr.Zero)
3532 last = Native.Z3_tactic_and_then(nCtx, t2.NativeObject, last);
3533 return new Tactic(
this, Native.Z3_tactic_and_then(nCtx, t1.NativeObject, last));
3536 return new Tactic(
this, Native.Z3_tactic_and_then(nCtx, t1.NativeObject, t2.NativeObject));
3548 Debug.Assert(t1 !=
null);
3549 Debug.Assert(t2 !=
null);
3561 Debug.Assert(t1 !=
null);
3562 Debug.Assert(t2 !=
null);
3564 CheckContextMatch(t1);
3565 CheckContextMatch(t2);
3566 return new Tactic(
this, Native.Z3_tactic_or_else(nCtx, t1.NativeObject, t2.NativeObject));
3577 Debug.Assert(t !=
null);
3579 CheckContextMatch(t);
3580 return new Tactic(
this, Native.Z3_tactic_try_for(nCtx, t.NativeObject, ms));
3592 Debug.Assert(p !=
null);
3593 Debug.Assert(t !=
null);
3595 CheckContextMatch(t);
3596 CheckContextMatch(p);
3597 return new Tactic(
this, Native.Z3_tactic_when(nCtx, p.NativeObject, t.NativeObject));
3606 Debug.Assert(p !=
null);
3607 Debug.Assert(t1 !=
null);
3608 Debug.Assert(t2 !=
null);
3610 CheckContextMatch(p);
3611 CheckContextMatch(t1);
3612 CheckContextMatch(t2);
3613 return new Tactic(
this, Native.Z3_tactic_cond(nCtx, p.NativeObject, t1.NativeObject, t2.NativeObject));
3622 Debug.Assert(t !=
null);
3624 CheckContextMatch(t);
3625 return new Tactic(
this, Native.Z3_tactic_repeat(nCtx, t.NativeObject,
max));
3634 return new Tactic(
this, Native.Z3_tactic_skip(nCtx));
3643 return new Tactic(
this, Native.Z3_tactic_fail(nCtx));
3651 Debug.Assert(p !=
null);
3653 CheckContextMatch(p);
3654 return new Tactic(
this, Native.Z3_tactic_fail_if(nCtx, p.NativeObject));
3664 return new Tactic(
this, Native.Z3_tactic_fail_if_not_decided(nCtx));
3672 Debug.Assert(t !=
null);
3673 Debug.Assert(p !=
null);
3675 CheckContextMatch(t);
3676 CheckContextMatch(p);
3677 return new Tactic(
this, Native.Z3_tactic_using_params(nCtx, t.NativeObject, p.NativeObject));
3686 Debug.Assert(t !=
null);
3687 Debug.Assert(p !=
null);
3697 Debug.Assert(t ==
null || t.All(tactic => tactic !=
null));
3699 CheckContextMatch<Tactic>(t);
3700 return new Tactic(
this, Native.Z3_tactic_par_or(nCtx,
Tactic.ArrayLength(t),
Tactic.ArrayToNative(t)));
3709 Debug.Assert(t1 !=
null);
3710 Debug.Assert(t2 !=
null);
3712 CheckContextMatch(t1);
3713 CheckContextMatch(t2);
3714 return new Tactic(
this, Native.Z3_tactic_par_and_then(nCtx, t1.NativeObject, t2.NativeObject));
3723 Native.Z3_interrupt(nCtx);
3733 get {
return Native.Z3_get_num_probes(nCtx); }
3745 string[] res =
new string[n];
3746 for (uint i = 0; i < n; i++)
3747 res[i] = Native.Z3_get_probe_name(nCtx, i);
3758 return Native.Z3_probe_get_descr(nCtx, name);
3767 return new Probe(
this, name);
3776 return new Probe(
this, Native.Z3_probe_const(nCtx, val));
3785 Debug.Assert(p1 !=
null);
3786 Debug.Assert(p2 !=
null);
3788 CheckContextMatch(p1);
3789 CheckContextMatch(p2);
3790 return new Probe(
this, Native.Z3_probe_lt(nCtx, p1.NativeObject, p2.NativeObject));
3799 Debug.Assert(p1 !=
null);
3800 Debug.Assert(p2 !=
null);
3802 CheckContextMatch(p1);
3803 CheckContextMatch(p2);
3804 return new Probe(
this, Native.Z3_probe_gt(nCtx, p1.NativeObject, p2.NativeObject));
3813 Debug.Assert(p1 !=
null);
3814 Debug.Assert(p2 !=
null);
3816 CheckContextMatch(p1);
3817 CheckContextMatch(p2);
3818 return new Probe(
this, Native.Z3_probe_le(nCtx, p1.NativeObject, p2.NativeObject));
3827 Debug.Assert(p1 !=
null);
3828 Debug.Assert(p2 !=
null);
3830 CheckContextMatch(p1);
3831 CheckContextMatch(p2);
3832 return new Probe(
this, Native.Z3_probe_ge(nCtx, p1.NativeObject, p2.NativeObject));
3841 Debug.Assert(p1 !=
null);
3842 Debug.Assert(p2 !=
null);
3844 CheckContextMatch(p1);
3845 CheckContextMatch(p2);
3846 return new Probe(
this, Native.Z3_probe_eq(nCtx, p1.NativeObject, p2.NativeObject));
3855 Debug.Assert(p1 !=
null);
3856 Debug.Assert(p2 !=
null);
3858 CheckContextMatch(p1);
3859 CheckContextMatch(p2);
3860 return new Probe(
this, Native.Z3_probe_and(nCtx, p1.NativeObject, p2.NativeObject));
3869 Debug.Assert(p1 !=
null);
3870 Debug.Assert(p2 !=
null);
3872 CheckContextMatch(p1);
3873 CheckContextMatch(p2);
3874 return new Probe(
this, Native.Z3_probe_or(nCtx, p1.NativeObject, p2.NativeObject));
3883 Debug.Assert(p !=
null);
3885 CheckContextMatch(p);
3886 return new Probe(
this, Native.Z3_probe_not(nCtx, p.NativeObject));
3903 return new Solver(
this, Native.Z3_mk_solver(nCtx));
3905 return new Solver(
this, Native.Z3_mk_solver_for_logic(nCtx, logic.NativeObject));
3914 using var symbol =
MkSymbol(logic);
3924 return new Solver(
this, Native.Z3_mk_simple_solver(nCtx));
3938 return new Solver(
this, Native.Z3_mk_solver_from_tactic(nCtx, t.NativeObject));
3953 #region Optimization
3964 #region Floating-Point Arithmetic
3966 #region Rounding Modes
3967 #region RoundingMode Sort
3983 return new FPRMExpr(
this, Native.Z3_mk_fpa_round_nearest_ties_to_even(nCtx));
3991 return new FPRMNum(
this, Native.Z3_mk_fpa_rne(nCtx));
3999 return new FPRMNum(
this, Native.Z3_mk_fpa_round_nearest_ties_to_away(nCtx));
4007 return new FPRMNum(
this, Native.Z3_mk_fpa_rna(nCtx));
4015 return new FPRMNum(
this, Native.Z3_mk_fpa_round_toward_positive(nCtx));
4023 return new FPRMNum(
this, Native.Z3_mk_fpa_rtp(nCtx));
4031 return new FPRMNum(
this, Native.Z3_mk_fpa_round_toward_negative(nCtx));
4039 return new FPRMNum(
this, Native.Z3_mk_fpa_rtn(nCtx));
4047 return new FPRMNum(
this, Native.Z3_mk_fpa_round_toward_zero(nCtx));
4055 return new FPRMNum(
this, Native.Z3_mk_fpa_rtz(nCtx));
4060 #region FloatingPoint Sorts
4068 return new FPSort(
this, ebits, sbits);
4076 return new FPSort(
this, Native.Z3_mk_fpa_sort_half(nCtx));
4084 return new FPSort(
this, Native.Z3_mk_fpa_sort_16(nCtx));
4092 return new FPSort(
this, Native.Z3_mk_fpa_sort_single(nCtx));
4100 return new FPSort(
this, Native.Z3_mk_fpa_sort_32(nCtx));
4108 return new FPSort(
this, Native.Z3_mk_fpa_sort_double(nCtx));
4116 return new FPSort(
this, Native.Z3_mk_fpa_sort_64(nCtx));
4124 return new FPSort(
this, Native.Z3_mk_fpa_sort_quadruple(nCtx));
4132 return new FPSort(
this, Native.Z3_mk_fpa_sort_128(nCtx));
4143 return new FPNum(
this, Native.Z3_mk_fpa_nan(nCtx, s.NativeObject));
4153 return new FPNum(
this, Native.Z3_mk_fpa_inf(nCtx, s.NativeObject, (
byte)(negative ? 1 : 0)));
4163 return new FPNum(
this, Native.Z3_mk_fpa_zero(nCtx, s.NativeObject, (
byte)(negative ? 1 : 0)));
4173 return new FPNum(
this, Native.Z3_mk_fpa_numeral_float(nCtx, v, s.NativeObject));
4183 return new FPNum(
this, Native.Z3_mk_fpa_numeral_double(nCtx, v, s.NativeObject));
4193 return new FPNum(
this, Native.Z3_mk_fpa_numeral_int(nCtx, v, s.NativeObject));
4205 return new FPNum(
this, Native.Z3_mk_fpa_numeral_int_uint(nCtx, (
byte)(sgn ? 1 : 0), exp, sig, s.NativeObject));
4217 return new FPNum(
this, Native.Z3_mk_fpa_numeral_int64_uint64(nCtx, (
byte)(sgn ? 1 : 0), exp, sig, s.NativeObject));
4283 return new FPExpr(
this, Native.Z3_mk_fpa_abs(
this.nCtx, t.NativeObject));
4292 return new FPExpr(
this, Native.Z3_mk_fpa_neg(
this.nCtx, t.NativeObject));
4303 return new FPExpr(
this, Native.Z3_mk_fpa_add(
this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
4314 return new FPExpr(
this, Native.Z3_mk_fpa_sub(
this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
4325 return new FPExpr(
this, Native.Z3_mk_fpa_mul(
this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
4336 return new FPExpr(
this, Native.Z3_mk_fpa_div(
this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
4351 return new FPExpr(
this, Native.Z3_mk_fpa_fma(
this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject, t3.NativeObject));
4361 return new FPExpr(
this, Native.Z3_mk_fpa_sqrt(
this.nCtx, rm.NativeObject, t.NativeObject));
4371 return new FPExpr(
this, Native.Z3_mk_fpa_rem(
this.nCtx, t1.NativeObject, t2.NativeObject));
4382 return new FPExpr(
this, Native.Z3_mk_fpa_round_to_integral(
this.nCtx, rm.NativeObject, t.NativeObject));
4392 return new FPExpr(
this, Native.Z3_mk_fpa_min(
this.nCtx, t1.NativeObject, t2.NativeObject));
4402 return new FPExpr(
this, Native.Z3_mk_fpa_max(
this.nCtx, t1.NativeObject, t2.NativeObject));
4412 return new BoolExpr(
this, Native.Z3_mk_fpa_leq(
this.nCtx, t1.NativeObject, t2.NativeObject));
4422 return new BoolExpr(
this, Native.Z3_mk_fpa_lt(
this.nCtx, t1.NativeObject, t2.NativeObject));
4432 return new BoolExpr(
this, Native.Z3_mk_fpa_geq(
this.nCtx, t1.NativeObject, t2.NativeObject));
4442 return new BoolExpr(
this, Native.Z3_mk_fpa_gt(
this.nCtx, t1.NativeObject, t2.NativeObject));
4455 return new BoolExpr(
this, Native.Z3_mk_fpa_eq(
this.nCtx, t1.NativeObject, t2.NativeObject));
4464 return new BoolExpr(
this, Native.Z3_mk_fpa_is_normal(
this.nCtx, t.NativeObject));
4473 return new BoolExpr(
this, Native.Z3_mk_fpa_is_subnormal(
this.nCtx, t.NativeObject));
4482 return new BoolExpr(
this, Native.Z3_mk_fpa_is_zero(
this.nCtx, t.NativeObject));
4491 return new BoolExpr(
this, Native.Z3_mk_fpa_is_infinite(
this.nCtx, t.NativeObject));
4500 return new BoolExpr(
this, Native.Z3_mk_fpa_is_nan(
this.nCtx, t.NativeObject));
4509 return new BoolExpr(
this, Native.Z3_mk_fpa_is_negative(
this.nCtx, t.NativeObject));
4518 return new BoolExpr(
this, Native.Z3_mk_fpa_is_positive(
this.nCtx, t.NativeObject));
4522 #region Conversions to FloatingPoint terms
4538 return new FPExpr(
this, Native.Z3_mk_fpa_fp(
this.nCtx, sgn.NativeObject, sig.NativeObject, exp.NativeObject));
4554 return new FPExpr(
this, Native.Z3_mk_fpa_to_fp_bv(
this.nCtx, bv.NativeObject, s.NativeObject));
4570 return new FPExpr(
this, Native.Z3_mk_fpa_to_fp_float(
this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
4586 return new FPExpr(
this, Native.Z3_mk_fpa_to_fp_real(
this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
4605 return new FPExpr(
this, Native.Z3_mk_fpa_to_fp_signed(
this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
4607 return new FPExpr(
this, Native.Z3_mk_fpa_to_fp_unsigned(
this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
4622 return new FPExpr(
this, Native.Z3_mk_fpa_to_fp_float(
this.nCtx, s.NativeObject, rm.NativeObject, t.NativeObject));
4626 #region Conversions from FloatingPoint terms
4642 return new BitVecExpr(
this, Native.Z3_mk_fpa_to_sbv(
this.nCtx, rm.NativeObject, t.NativeObject, sz));
4644 return new BitVecExpr(
this, Native.Z3_mk_fpa_to_ubv(
this.nCtx, rm.NativeObject, t.NativeObject, sz));
4658 return new RealExpr(
this, Native.Z3_mk_fpa_to_real(
this.nCtx, t.NativeObject));
4662 #region Z3-specific extensions
4675 return new BitVecExpr(
this, Native.Z3_mk_fpa_to_ieee_bv(
this.nCtx, t.NativeObject));
4692 return new BitVecExpr(
this, Native.Z3_mk_fpa_to_fp_int_real(
this.nCtx, rm.NativeObject, exp.NativeObject, sig.NativeObject, s.NativeObject));
4697 #region Miscellaneous
4710 return AST.Create(
this, nativeObject);
4726 return a.NativeObject;
4735 return Native.Z3_simplify_get_help(nCtx);
4743 get {
return new ParamDescrs(
this, Native.Z3_simplify_get_param_descrs(nCtx)); }
4747 #region Error Handling
4775 Native.Z3_update_param_value(nCtx,
id, value);
4781 internal IntPtr m_ctx = IntPtr.Zero;
4782 internal Native.Z3_error_handler m_n_err_handler =
null;
4783 internal static Object creation_lock =
new Object();
4784 internal IntPtr nCtx {
get {
return m_ctx; } }
4786 internal void NativeErrorHandler(IntPtr ctx,
Z3_error_code errorCode)
4791 internal void InitContext()
4794 m_n_err_handler =
new Native.Z3_error_handler(NativeErrorHandler);
4795 Native.Z3_set_error_handler(m_ctx, m_n_err_handler);
4796 GC.SuppressFinalize(
this);
4799 internal void CheckContextMatch(Z3Object other)
4801 Debug.Assert(other !=
null);
4803 if (!ReferenceEquals(
this, other.Context))
4804 throw new Z3Exception(
"Context mismatch");
4807 internal void CheckContextMatch(Z3Object other1, Z3Object other2)
4809 Debug.Assert(other1 !=
null);
4810 Debug.Assert(other2 !=
null);
4811 CheckContextMatch(other1);
4812 CheckContextMatch(other2);
4815 internal void CheckContextMatch(Z3Object other1, Z3Object other2, Z3Object other3)
4817 Debug.Assert(other1 !=
null);
4818 Debug.Assert(other2 !=
null);
4819 Debug.Assert(other3 !=
null);
4820 CheckContextMatch(other1);
4821 CheckContextMatch(other2);
4822 CheckContextMatch(other3);
4825 internal void CheckContextMatch(Z3Object[] arr)
4827 Debug.Assert(arr ==
null || arr.All(a => a !=
null));
4831 foreach (Z3Object a
in arr)
4833 Debug.Assert(a !=
null);
4834 CheckContextMatch(a);
4839 internal void CheckContextMatch<T>(IEnumerable<T> arr) where T : Z3Object
4841 Debug.Assert(arr ==
null || arr.All(a => a !=
null));
4845 foreach (Z3Object a
in arr)
4847 Debug.Assert(a !=
null);
4848 CheckContextMatch(a);
4853 private void ObjectInvariant()
4855 Debug.Assert(m_AST_DRQ !=
null);
4856 Debug.Assert(m_ASTMap_DRQ !=
null);
4857 Debug.Assert(m_ASTVector_DRQ !=
null);
4858 Debug.Assert(m_ApplyResult_DRQ !=
null);
4859 Debug.Assert(m_FuncEntry_DRQ !=
null);
4860 Debug.Assert(m_FuncInterp_DRQ !=
null);
4861 Debug.Assert(m_Goal_DRQ !=
null);
4862 Debug.Assert(m_Model_DRQ !=
null);
4863 Debug.Assert(m_Params_DRQ !=
null);
4864 Debug.Assert(m_ParamDescrs_DRQ !=
null);
4865 Debug.Assert(m_Probe_DRQ !=
null);
4866 Debug.Assert(m_Solver_DRQ !=
null);
4867 Debug.Assert(m_Statistics_DRQ !=
null);
4868 Debug.Assert(m_Tactic_DRQ !=
null);
4869 Debug.Assert(m_Fixedpoint_DRQ !=
null);
4870 Debug.Assert(m_Optimize_DRQ !=
null);
4873 readonly
private AST.DecRefQueue m_AST_DRQ =
new AST.DecRefQueue();
4874 readonly
private ASTMap.DecRefQueue m_ASTMap_DRQ =
new ASTMap.DecRefQueue(10);
4875 readonly
private ASTVector.DecRefQueue m_ASTVector_DRQ =
new ASTVector.DecRefQueue(10);
4876 readonly
private ApplyResult.DecRefQueue m_ApplyResult_DRQ =
new ApplyResult.DecRefQueue(10);
4877 readonly
private FuncInterp.Entry.DecRefQueue m_FuncEntry_DRQ =
new FuncInterp.Entry.DecRefQueue(10);
4878 readonly
private FuncInterp.DecRefQueue m_FuncInterp_DRQ =
new FuncInterp.DecRefQueue(10);
4879 readonly
private Goal.DecRefQueue m_Goal_DRQ =
new Goal.DecRefQueue(10);
4880 readonly
private Model.DecRefQueue m_Model_DRQ =
new Model.DecRefQueue(10);
4881 readonly
private Params.DecRefQueue m_Params_DRQ =
new Params.DecRefQueue(10);
4882 readonly
private ParamDescrs.DecRefQueue m_ParamDescrs_DRQ =
new ParamDescrs.DecRefQueue(10);
4883 readonly
private Probe.DecRefQueue m_Probe_DRQ =
new Probe.DecRefQueue(10);
4884 readonly
private Solver.DecRefQueue m_Solver_DRQ =
new Solver.DecRefQueue(10);
4885 readonly
private Statistics.DecRefQueue m_Statistics_DRQ =
new Statistics.DecRefQueue(10);
4886 readonly
private Tactic.DecRefQueue m_Tactic_DRQ =
new Tactic.DecRefQueue(10);
4887 readonly
private Fixedpoint.DecRefQueue m_Fixedpoint_DRQ =
new Fixedpoint.DecRefQueue(10);
4888 readonly
private Optimize.DecRefQueue m_Optimize_DRQ =
new Optimize.DecRefQueue(10);
4970 internal long refCount = 0;
5004 if (m_boolSort !=
null) m_boolSort.Dispose();
5005 if (m_intSort !=
null) m_intSort.Dispose();
5006 if (m_realSort !=
null) m_realSort.Dispose();
5007 if (m_stringSort !=
null) m_stringSort.Dispose();
5008 if (m_charSort !=
null) m_charSort.Dispose();
5012 m_stringSort =
null;
5014 if (refCount == 0 && m_ctx != IntPtr.Zero)
5016 m_n_err_handler =
null;
5018 m_ctx = IntPtr.Zero;
5020 Native.Z3_del_context(ctx);
5023 GC.ReRegisterForFinalize(
this);
The abstract syntax tree (AST) class.
BoolExpr[] ToBoolExprArray()
Translates an ASTVector into a BoolExpr[]
Arithmetic expressions (int/real)
Constructors are used for datatype sorts.
The main interaction with Z3 happens via the Context.
FPExpr MkFPToFP(FPRMExpr rm, RealExpr t, FPSort s)
Conversion of a term of real sort into a term of FloatingPoint sort.
BitVecExpr MkBVNAND(BitVecExpr t1, BitVecExpr t2)
Bitwise NAND.
FPNum MkFP(float v, FPSort s)
Create a numeral of FloatingPoint sort from a float.
RealExpr MkInt2Real(IntExpr t)
Coerce an integer to a real.
FPSort MkFPSort16()
Create the half-precision (16-bit) FloatingPoint sort.
BoolExpr MkCharLe(Expr ch1, Expr ch2)
Create less than or equal to between two characters.
Expr MkNumeral(uint v, Sort ty)
Create a Term of a given sort. This function can be used to create numerals that fit in a machine int...
ArrayExpr MkArrayConst(string name, Sort domain, Sort range)
Create an array constant.
BoolExpr MkAtLeast(IEnumerable< BoolExpr > args, uint k)
Create an at-least-k constraint.
BitVecExpr MkBVSHL(BitVecExpr t1, BitVecExpr t2)
Shift left.
IDecRefQueue ParamDescrs_DRQ
ParamDescrs DRQ
Tactic Skip()
Create a tactic that just returns the given goal.
Constructor MkConstructor(string name, string recognizer, string[] fieldNames=null, Sort[] sorts=null, uint[] sortRefs=null)
Create a datatype constructor.
BoolSort BoolSort
Retrieves the Boolean sort of the context.
BitVecNum MkBV(bool[] bits)
Create a bit-vector numeral.
FiniteDomainSort MkFiniteDomainSort(Symbol name, ulong size)
Create a new finite domain sort. The result is a sort
BoolExpr MkStringLe(SeqExpr s1, SeqExpr s2)
Check if the string s1 is lexicographically less or equal to s2.
FPSort MkFPSort(uint ebits, uint sbits)
Create a FloatingPoint sort.
Tactic With(Tactic t, Params p)
Create a tactic that applies t using the given set of parameters p .
string[] TacticNames
The names of all supported tactics.
BoolExpr MkIsDigit(Expr ch)
Create a check if the character is a digit.
FPExpr MkFPAdd(FPRMExpr rm, FPExpr t1, FPExpr t2)
Floating-point addition
BitVecExpr MkBVRotateLeft(BitVecExpr t1, BitVecExpr t2)
Rotate Left.
RealExpr MkRealConst(string name)
Creates a real constant.
RatNum MkReal(uint v)
Create a real numeral.
Probe Gt(Probe p1, Probe p2)
Create a probe that evaluates to "true" when the value returned by p1 is greater than the value retu...
BitVecExpr MkBVLSHR(BitVecExpr t1, BitVecExpr t2)
Logical shift right
FPRMSort MkFPRoundingModeSort()
Create the floating-point RoundingMode sort.
RealExpr MkFPToReal(FPExpr t)
Conversion of a floating-point term into a real-numbered term.
TupleSort MkTupleSort(Symbol name, Symbol[] fieldNames, Sort[] fieldSorts)
Create a new tuple sort.
Lambda MkLambda(Expr[] boundConstants, Expr body)
Create a lambda expression.
IDecRefQueue Params_DRQ
Params DRQ
BitVecSort MkBitVecSort(uint size)
Create a new bit-vector sort.
BoolExpr MkBVMulNoUnderflow(BitVecExpr t1, BitVecExpr t2)
Create a predicate that checks that the bit-wise multiplication does not underflow.
ReExpr MkDiff(ReExpr a, ReExpr b)
Create a difference regular expression.
ArrayExpr MkFullSet(Sort domain)
Create the full set.
FPSort MkFPSortQuadruple()
Create the quadruple-precision (128-bit) FloatingPoint sort.
BoolExpr MkLe(ArithExpr t1, ArithExpr t2)
Create an expression representing t1 <= t2
Probe ConstProbe(double val)
Create a probe that always evaluates to val .
Expr MkFreshConst(string prefix, Sort range)
Creates a fresh Constant of sort range and a name prefixed with prefix .
IntExpr MkReal2Int(RealExpr t)
Coerce a real to an integer.
UninterpretedSort MkUninterpretedSort(Symbol s)
Create a new uninterpreted sort.
FPSort MkFPSortHalf()
Create the half-precision (16-bit) FloatingPoint sort.
Quantifier MkForall(Expr[] boundConstants, Expr body, uint weight=1, Pattern[] patterns=null, Expr[] noPatterns=null, Symbol quantifierID=null, Symbol skolemID=null)
Create a universal Quantifier.
ArrayExpr MkSetDifference(ArrayExpr arg1, ArrayExpr arg2)
Take the difference between two sets.
BoolExpr MkXor(BoolExpr t1, BoolExpr t2)
Create an expression representing t1 xor t2.
Expr MkNumeral(long v, Sort ty)
Create a Term of a given sort. This function can be used to create numerals that fit in a machine int...
Expr MkITE(BoolExpr t1, Expr t2, Expr t3)
Create an expression representing an if-then-else: ite(t1, t2, t3).
IntNum MkInt(uint v)
Create an integer numeral.
IntExpr MkIntConst(Symbol name)
Creates an integer constant.
AST WrapAST(IntPtr nativeObject)
Wraps an AST.
SeqExpr IntToString(Expr e)
Convert an integer expression to a string.
FPExpr MkFPMax(FPExpr t1, FPExpr t2)
Maximum of floating-point numbers.
ArithExpr MkUnaryMinus(ArithExpr t)
Create an expression representing -t.
BitVecExpr MkFPToIEEEBV(FPExpr t)
Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
ArithExpr MkSub(params ArithExpr[] t)
Create an expression representing t[0] - t[1] - ....
Constructor MkConstructor(Symbol name, Symbol recognizer, Symbol[] fieldNames=null, Sort[] sorts=null, uint[] sortRefs=null)
Create a datatype constructor.
IntSort IntSort
Retrieves the Integer sort of the context.
BoolExpr MkSuffixOf(SeqExpr s1, SeqExpr s2)
Check for sequence suffix.
SeqExpr MkConcat(params SeqExpr[] t)
Concatenate sequences.
FuncDecl MkFuncDecl(string name, Sort domain, Sort range)
Creates a new function declaration.
BoolExpr MkNot(BoolExpr a)
Mk an expression representing not(a).
FuncDecl MkFuncDecl(string name, Sort[] domain, Sort range)
Creates a new function declaration.
FuncDecl MkUserPropagatorFuncDecl(string name, Sort[] domain, Sort range)
Declare a function to be processed by the user propagator plugin.
Expr MkTermArray(ArrayExpr array)
Access the array default value.
BitVecExpr MkBVSRem(BitVecExpr t1, BitVecExpr t2)
Signed remainder.
BitVecExpr MkBVRedOR(BitVecExpr t)
Take disjunction of bits in a vector, return vector of length 1.
Tactic MkTactic(string name)
Creates a new Tactic.
BoolExpr MkFPLEq(FPExpr t1, FPExpr t2)
Floating-point less than or equal.
ReExpr MkOption(ReExpr re)
Create the optional regular expression.
BoolExpr MkFPEq(FPExpr t1, FPExpr t2)
Floating-point equality.
DatatypeSort[] MkDatatypeSorts(Symbol[] names, Constructor[][] c)
Create mutually recursive datatypes.
SeqExpr MkExtract(SeqExpr s, IntExpr offset, IntExpr length)
Extract subsequence.
RatNum MkReal(string v)
Create a real numeral.
FPExpr MkFPToFP(FPRMExpr rm, FPExpr t, FPSort s)
Conversion of a FloatingPoint term into another term of different FloatingPoint sort.
DatatypeSort MkDatatypeSort(string name, Constructor[] constructors)
Create a new datatype sort.
FPExpr MkFPToFP(FPRMExpr rm, BitVecExpr t, FPSort s, bool signed)
Conversion of a 2's complement signed bit-vector term into a term of FloatingPoint sort.
Tactic UsingParams(Tactic t, Params p)
Create a tactic that applies t using the given set of parameters p .
BoolExpr MkBVNegNoOverflow(BitVecExpr t)
Create a predicate that checks that the bit-wise negation does not overflow.
ListSort MkListSort(string name, Sort elemSort)
Create a new list sort.
uint NumTactics
The number of supported tactics.
SeqExpr UbvToString(Expr e)
Convert a bit-vector expression, represented as an unsigned number, to a string.
ReExpr MkConcat(params ReExpr[] t)
Create the concatenation of regular languages.
BoolExpr MkBVULT(BitVecExpr t1, BitVecExpr t2)
Unsigned less-than
BoolExpr MkBVMulNoOverflow(BitVecExpr t1, BitVecExpr t2, bool isSigned)
Create a predicate that checks that the bit-wise multiplication does not overflow.
FuncDecl MkConstDecl(Symbol name, Sort range)
Creates a new constant function declaration.
BitVecExpr MkBVSDiv(BitVecExpr t1, BitVecExpr t2)
Signed division.
ParamDescrs SimplifyParameterDescriptions
Retrieves parameter descriptions for simplifier.
BitVecNum MkBV(ulong v, uint size)
Create a bit-vector numeral.
FPExpr MkFPFMA(FPRMExpr rm, FPExpr t1, FPExpr t2, FPExpr t3)
Floating-point fused multiply-add
BoolExpr MkFPIsInfinite(FPExpr t)
Predicate indicating whether t is a floating-point number representing +oo or -oo.
BitVecExpr MkInt2BV(uint n, IntExpr t)
Create an n bit bit-vector from the integer argument t .
BoolExpr MkTrue()
The true Term.
FPExpr MkFPSub(FPRMExpr rm, FPExpr t1, FPExpr t2)
Floating-point subtraction
FPNum MkFPNumeral(double v, FPSort s)
Create a numeral of FloatingPoint sort from a float.
FPExpr MkFPToFP(BitVecExpr bv, FPSort s)
Conversion of a single IEEE 754-2008 bit-vector into a floating-point number.
ReExpr MkUnion(params ReExpr[] t)
Create the union of regular languages.
RatNum MkReal(ulong v)
Create a real numeral.
BoolExpr MkBoolConst(Symbol name)
Create a Boolean constant.
IDecRefQueue Model_DRQ
Model DRQ
ReExpr MkEmptyRe(Sort s)
Create the empty regular expression. The sort s should be a regular expression.
Expr MkNth(SeqExpr s, Expr index)
Retrieve element at index.
FPSort MkFPSortSingle()
Create the single-precision (32-bit) FloatingPoint sort.
IntPtr UnwrapAST(AST a)
Unwraps an AST.
IntExpr MkMod(IntExpr t1, IntExpr t2)
Create an expression representing t1 mod t2.
BoolExpr MkPBLe(int[] coeffs, BoolExpr[] args, int k)
Create a pseudo-Boolean less-or-equal constraint.
IntNum MkInt(string v)
Create an integer numeral.
Expr MkConst(FuncDecl f)
Creates a fresh constant from the FuncDecl f .
FPRMNum MkFPRTZ()
Create a numeral of RoundingMode sort which represents the RoundTowardZero rounding mode.
IDecRefQueue Optimize_DRQ
Optimize DRQ
Tactic TryFor(Tactic t, uint ms)
Create a tactic that applies t to a goal for ms milliseconds.
BoolExpr MkImplies(BoolExpr t1, BoolExpr t2)
Create an expression representing t1 -> t2.
BoolExpr MkBVSubNoUnderflow(BitVecExpr t1, BitVecExpr t2, bool isSigned)
Create a predicate that checks that the bit-wise subtraction does not underflow.
Expr MkSelect(ArrayExpr a, Expr i)
Array read.
ArrayExpr MkSetUnion(params ArrayExpr[] args)
Take the union of a list of sets.
IDecRefQueue ApplyResult_DRQ
ApplyResult DRQ
IDecRefQueue ASTVector_DRQ
ASTVector DRQ
IntExpr MkIndexOf(SeqExpr s, SeqExpr substr, ArithExpr offset)
Extract index of sub-string starting at offset.
BoolExpr MkBoolConst(string name)
Create a Boolean constant.
Expr MkApp(FuncDecl f, params Expr[] args)
Create a new function application.
BitVecExpr MkBVSMod(BitVecExpr t1, BitVecExpr t2)
Two's complement signed remainder (sign follows divisor).
IDecRefQueue Goal_DRQ
Goal DRQ
Probe Or(Probe p1, Probe p2)
Create a probe that evaluates to "true" when the value p1 or p2 evaluate to "true".
BitVecExpr MkRepeat(uint i, BitVecExpr t)
Bit-vector repetition.
BoolExpr MkDistinct(IEnumerable< Expr > args)
Creates a distinct term.
FuncDecl MkFuncDecl(Symbol name, Sort domain, Sort range)
Creates a new function declaration.
BoolExpr MkFPGt(FPExpr t1, FPExpr t2)
Floating-point greater than.
BoolExpr MkAtMost(IEnumerable< BoolExpr > args, uint k)
Create an at-most-k constraint.
Tactic ParAndThen(Tactic t1, Tactic t2)
Create a tactic that applies t1 to a given goal and then t2 to every subgoal produced by t1 ....
Solver MkSolver(string logic)
Creates a new (incremental) solver.
Quantifier MkQuantifier(bool universal, Expr[] boundConstants, Expr body, uint weight=1, Pattern[] patterns=null, Expr[] noPatterns=null, Symbol quantifierID=null, Symbol skolemID=null)
Create a Quantifier.
ArrayExpr MkSetDel(ArrayExpr set, Expr element)
Remove an element from a set.
Expr MkUpdateField(FuncDecl field, Expr t, Expr v)
Update a datatype field at expression t with value v. The function performs a record update at t....
Probe Lt(Probe p1, Probe p2)
Create a probe that evaluates to "true" when the value returned by p1 is less than the value returne...
ReExpr MkRange(SeqExpr lo, SeqExpr hi)
Create a range expression.
BitVecNum MkBV(long v, uint size)
Create a bit-vector numeral.
BoolExpr MkBVSGT(BitVecExpr t1, BitVecExpr t2)
Two's complement signed greater-than.
Params MkParams()
Creates a new ParameterSet.
ArrayExpr MkSetIntersection(params ArrayExpr[] args)
Take the intersection of a list of sets.
FPNum MkFPNaN(FPSort s)
Create a NaN of sort s.
FPNum MkFP(bool sgn, Int64 exp, UInt64 sig, FPSort s)
Create a numeral of FloatingPoint sort from a sign bit and two 64-bit integers.
BoolExpr[] ParseSMTLIB2String(string str, Symbol[] sortNames=null, Sort[] sorts=null, Symbol[] declNames=null, FuncDecl[] decls=null)
Parse the given string using the SMT-LIB2 parser.
BitVecExpr MkBVNOR(BitVecExpr t1, BitVecExpr t2)
Bitwise NOR.
IntExpr CharToInt(Expr ch)
Create an integer (code point) from character.
BoolExpr MkDistinct(params Expr[] args)
Creates a distinct term.
FPExpr MkFPRoundToIntegral(FPRMExpr rm, FPExpr t)
Floating-point roundToIntegral. Rounds a floating-point number to the closest integer,...
Fixedpoint MkFixedpoint()
Create a Fixedpoint context.
BoolExpr MkXor(IEnumerable< BoolExpr > ts)
Create an expression representing t1 xor t2 xor t3 ... .
void UpdateParamValue(string id, string value)
Update a mutable configuration parameter.
DatatypeSort MkDatatypeSort(Symbol name, Constructor[] constructors)
Create a new datatype sort.
IDecRefQueue Statistics_DRQ
Statistics DRQ
void AddRecDef(FuncDecl f, Expr[] args, Expr body)
Bind a definition to a recursive function declaration. The function must have previously been created...
FPNum MkFPNumeral(float v, FPSort s)
Create a numeral of FloatingPoint sort from a float.
ArrayExpr MkConstArray(Sort domain, Expr v)
Create a constant array.
ArrayExpr MkSetComplement(ArrayExpr arg)
Take the complement of a set.
BoolExpr MkSetSubset(ArrayExpr arg1, ArrayExpr arg2)
Check for subsetness of sets.
Probe Eq(Probe p1, Probe p2)
Create a probe that evaluates to "true" when the value returned by p1 is equal to the value returned...
FPRMNum MkFPRoundNearestTiesToAway()
Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
string[] ProbeNames
The names of all supported Probes.
Tactic AndThen(Tactic t1, Tactic t2, params Tactic[] ts)
Create a tactic that applies t1 to a Goal and then t2 to every subgoal produced by t1 .
BitVecExpr MkZeroExt(uint i, BitVecExpr t)
Bit-vector zero extension.
Z3_ast_print_mode PrintMode
Selects the format used for pretty-printing expressions.
IDecRefQueue FuncEntry_DRQ
FuncEntry DRQ
void Dispose()
Disposes of the context.
BitVecExpr CharToBV(Expr ch)
Create a bit-vector (code point) from character.
SeqExpr SbvToString(Expr e)
Convert a bit-vector expression, represented as an signed number, to a string.
IDecRefQueue Solver_DRQ
Solver DRQ
ArrayExpr MkEmptySet(Sort domain)
Create an empty set.
Quantifier MkExists(Sort[] sorts, Symbol[] names, Expr body, uint weight=1, Pattern[] patterns=null, Expr[] noPatterns=null, Symbol quantifierID=null, Symbol skolemID=null)
Create an existential Quantifier.
UninterpretedSort MkUninterpretedSort(string str)
Create a new uninterpreted sort.
IDecRefQueue FuncInterp_DRQ
FuncInterp DRQ
Expr MkNumeral(ulong v, Sort ty)
Create a Term of a given sort. This function can be used to create numerals that fit in a machine int...
ReExpr MkStar(ReExpr re)
Take the Kleene star of a regular expression.
BitVecExpr MkBVConst(string name, uint size)
Creates a bit-vector constant.
BitVecNum MkBV(uint v, uint size)
Create a bit-vector numeral.
Optimize MkOptimize()
Create an Optimization context.
IDecRefQueue AST_DRQ
AST DRQ
Quantifier MkQuantifier(bool universal, Sort[] sorts, Symbol[] names, Expr body, uint weight=1, Pattern[] patterns=null, Expr[] noPatterns=null, Symbol quantifierID=null, Symbol skolemID=null)
Create a Quantifier.
Expr CharFromBV(BitVecExpr bv)
Create a character from a bit-vector (code point).
Expr MkArrayExt(ArrayExpr arg1, ArrayExpr arg2)
Create Extentionality index. Two arrays are equal if and only if they are equal on the index returned...
CharSort CharSort
Retrieves the String sort of the context.
FPNum MkFPInf(FPSort s, bool negative)
Create a floating-point infinity of sort s.
FuncDecl MkConstDecl(string name, Sort range)
Creates a new constant function declaration.
ArrayExpr MkMap(FuncDecl f, params ArrayExpr[] args)
Maps f on the argument arrays.
ReExpr MkIntersect(params ReExpr[] t)
Create the intersection of regular languages.
Tactic Repeat(Tactic t, uint max=uint.MaxValue)
Create a tactic that keeps applying t until the goal is not modified anymore or the maximum number o...
BoolExpr MkBVSLE(BitVecExpr t1, BitVecExpr t2)
Two's complement signed less-than or equal to.
FPNum MkFP(int v, FPSort s)
Create a numeral of FloatingPoint sort from an int.
IDecRefQueue Fixedpoint_DRQ
FixedPoint DRQ
BoolExpr MkLt(ArithExpr t1, ArithExpr t2)
Create an expression representing t1 < t2
FPNum MkFP(bool sgn, int exp, uint sig, FPSort s)
Create a numeral of FloatingPoint sort from a sign bit and two integers.
ListSort MkListSort(Symbol name, Sort elemSort)
Create a new list sort.
SeqExpr MkAt(SeqExpr s, Expr index)
Retrieve sequence of length one at index.
FPExpr MkFPToFP(FPSort s, FPRMExpr rm, FPExpr t)
Conversion of a floating-point number to another FloatingPoint sort s.
BoolExpr MkSetMembership(Expr elem, ArrayExpr set)
Check for set membership.
BitVecExpr MkBVRotateRight(BitVecExpr t1, BitVecExpr t2)
Rotate Right.
SeqExpr MkReplace(SeqExpr s, SeqExpr src, SeqExpr dst)
Replace the first occurrence of src by dst in s.
FPRMExpr MkFPRoundNearestTiesToEven()
Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
string ProbeDescription(string name)
Returns a string containing a description of the probe with the given name.
Pattern MkPattern(params Expr[] terms)
Create a quantifier pattern.
Probe And(Probe p1, Probe p2)
Create a probe that evaluates to "true" when the value p1 and p2 evaluate to "true".
Probe Le(Probe p1, Probe p2)
Create a probe that evaluates to "true" when the value returned by p1 is less than or equal the valu...
FPExpr MkFPNeg(FPExpr t)
Floating-point negation
FPSort MkFPSort32()
Create the single-precision (32-bit) FloatingPoint sort.
Expr MkConst(Symbol name, Sort range)
Creates a new Constant of sort range and named name .
RealSort RealSort
Retrieves the Real sort of the context.
BoolExpr MkAnd(params BoolExpr[] t)
Create an expression representing t[0] and t[1] and ....
BoolExpr MkIsInteger(RealExpr t)
Creates an expression that checks whether a real number is an integer.
BitVecExpr MkBVXNOR(BitVecExpr t1, BitVecExpr t2)
Bitwise XNOR.
BoolExpr MkBVULE(BitVecExpr t1, BitVecExpr t2)
Unsigned less-than or equal to.
BoolExpr MkGe(ArithExpr t1, ArithExpr t2)
Create an expression representing t1 >= t2
FPNum MkFPNumeral(bool sgn, Int64 exp, UInt64 sig, FPSort s)
Create a numeral of FloatingPoint sort from a sign bit and two 64-bit integers.
BitVecExpr MkFPToBV(FPRMExpr rm, FPExpr t, uint sz, bool sign)
Conversion of a floating-point term into a bit-vector.
BoolExpr MkBVAddNoUnderflow(BitVecExpr t1, BitVecExpr t2)
Create a predicate that checks that the bit-wise addition does not underflow.
BitVecNum MkBV(string v, uint size)
Create a bit-vector numeral.
ReExpr MkFullRe(Sort s)
Create the full regular expression. The sort s should be a regular expression.
ArithExpr MkMul(params ArithExpr[] t)
Create an expression representing t[0] * t[1] * ....
BoolExpr MkFPIsSubnormal(FPExpr t)
Predicate indicating whether t is a subnormal floating-point number.
ArrayExpr MkArrayConst(Symbol name, Sort domain, Sort range)
Create an array constant.
BoolExpr MkFPIsZero(FPExpr t)
Predicate indicating whether t is a floating-point number with zero value, i.e., +0 or -0.
ReSort MkReSort(SeqSort s)
Create a new regular expression sort.
FPSort MkFPSortDouble()
Create the double-precision (64-bit) FloatingPoint sort.
FPRMNum MkFPRoundTowardZero()
Create a numeral of RoundingMode sort which represents the RoundTowardZero rounding mode.
Goal MkGoal(bool models=true, bool unsatCores=false, bool proofs=false)
Creates a new Goal.
IntExpr MkBV2Int(BitVecExpr t, bool signed)
Create an integer from the bit-vector argument t .
ArithExpr MkAdd(params ArithExpr[] t)
Create an expression representing t[0] + t[1] + ....
BoolExpr MkInRe(SeqExpr s, ReExpr re)
Check for regular expression membership.
ArrayExpr MkSetAdd(ArrayExpr set, Expr element)
Add an element to the set.
BitVecExpr MkBVRedAND(BitVecExpr t)
Take conjunction of bits in a vector, return vector of length 1.
Probe Ge(Probe p1, Probe p2)
Create a probe that evaluates to "true" when the value returned by p1 is greater than or equal the v...
ReExpr MkLoop(ReExpr re, uint lo, uint hi=0)
Take the bounded Kleene star of a regular expression.
FPRMNum MkFPRoundTowardNegative()
Create a numeral of RoundingMode sort which represents the RoundTowardNegative rounding mode.
Probe MkProbe(string name)
Creates a new Probe.
FPNum MkFPNumeral(bool sgn, uint sig, int exp, FPSort s)
Create a numeral of FloatingPoint sort from a sign bit and two integers.
SeqSort MkSeqSort(Sort s)
Create a new sequence sort.
DatatypeSort[] MkDatatypeSorts(string[] names, Constructor[][] c)
Create mutually recursive data-types.
Tactic FailIf(Probe p)
Create a tactic that fails if the probe p evaluates to false.
Expr MkBound(uint index, Sort ty)
Creates a new bound variable.
FPRMNum MkFPRTN()
Create a numeral of RoundingMode sort which represents the RoundTowardNegative rounding mode.
FPSort MkFPSort128()
Create the quadruple-precision (128-bit) FloatingPoint sort.
BoolExpr MkBVUGE(BitVecExpr t1, BitVecExpr t2)
Unsigned greater than or equal to.
Expr MkNumeral(int v, Sort ty)
Create a Term of a given sort. This function can be used to create numerals that fit in a machine int...
FPRMNum MkFPRTP()
Create a numeral of RoundingMode sort which represents the RoundTowardPositive rounding mode.
BoolSort MkBoolSort()
Create a new Boolean sort.
BitVecExpr MkConcat(BitVecExpr t1, BitVecExpr t2)
Bit-vector concatenation.
ArithExpr MkPower(ArithExpr t1, ArithExpr t2)
Create an expression representing t1 ^ t2.
SeqExpr MkEmptySeq(Sort s)
Create the empty sequence.
BitVecExpr MkBVNot(BitVecExpr t)
Bitwise negation.
FPExpr MkFPRem(FPExpr t1, FPExpr t2)
Floating-point remainder
RealSort MkRealSort()
Create a real sort.
BoolExpr MkBVAddNoOverflow(BitVecExpr t1, BitVecExpr t2, bool isSigned)
Create a predicate that checks that the bit-wise addition does not overflow.
ArithExpr MkDiv(ArithExpr t1, ArithExpr t2)
Create an expression representing t1 / t2.
Expr MkSelect(ArrayExpr a, params Expr[] args)
Array read.
FPNum MkFPNumeral(int v, FPSort s)
Create a numeral of FloatingPoint sort from an int.
BoolExpr[] ParseSMTLIB2File(string fileName, Symbol[] sortNames=null, Sort[] sorts=null, Symbol[] declNames=null, FuncDecl[] decls=null)
Parse the given file using the SMT-LIB2 parser.
BoolExpr MkFPLt(FPExpr t1, FPExpr t2)
Floating-point less than.
BoolExpr MkFPGEq(FPExpr t1, FPExpr t2)
Floating-point greater than or equal.
BitVecExpr MkSignExt(uint i, BitVecExpr t)
Bit-vector sign extension.
Tactic ParOr(params Tactic[] t)
Create a tactic that applies the given tactics in parallel until one of them succeeds (i....
IntSort MkIntSort()
Create a new integer sort.
BoolExpr MkAnd(IEnumerable< BoolExpr > t)
Create an expression representing t[0] and t[1] and ....
BoolExpr MkOr(params BoolExpr[] t)
Create an expression representing t[0] or t[1] or ....
BitVecExpr MkBVMul(BitVecExpr t1, BitVecExpr t2)
Two's complement multiplication.
IntExpr StringToInt(Expr e)
Convert an integer expression to a string.
BoolExpr MkBVSDivNoOverflow(BitVecExpr t1, BitVecExpr t2)
Create a predicate that checks that the bit-wise signed division does not overflow.
BoolExpr MkContains(SeqExpr s1, SeqExpr s2)
Check for sequence containment of s2 in s1.
Tactic OrElse(Tactic t1, Tactic t2)
Create a tactic that first applies t1 to a Goal and if it fails then returns the result of t2 appli...
SeqSort StringSort
Retrieves the String sort of the context.
BoolExpr MkEq(Expr x, Expr y)
Creates the equality x = y .
Tactic Cond(Probe p, Tactic t1, Tactic t2)
Create a tactic that applies t1 to a given goal if the probe p evaluates to true and t2 otherwise.
BitVecExpr MkBVSub(BitVecExpr t1, BitVecExpr t2)
Two's complement subtraction.
BitVecExpr MkBVUDiv(BitVecExpr t1, BitVecExpr t2)
Unsigned division.
void Interrupt()
Interrupt the execution of a Z3 procedure.
BoolExpr MkBVUGT(BitVecExpr t1, BitVecExpr t2)
Unsigned greater-than.
ArraySort MkArraySort(Sort domain, Sort range)
Create a new array sort.
BitVecExpr MkBVConst(Symbol name, uint size)
Creates a bit-vector constant.
BitVecExpr MkBVASHR(BitVecExpr t1, BitVecExpr t2)
Arithmetic shift right
Tactic Then(Tactic t1, Tactic t2, params Tactic[] ts)
Create a tactic that applies t1 to a Goal and then t2 to every subgoal produced by t1 .
FPNum MkFPZero(FPSort s, bool negative)
Create a floating-point zero of sort s.
BoolExpr MkPBGe(int[] coeffs, BoolExpr[] args, int k)
Create a pseudo-Boolean greater-or-equal constraint.
IntNum MkInt(long v)
Create an integer numeral.
RatNum MkReal(long v)
Create a real numeral.
ReExpr MkPlus(ReExpr re)
Take the Kleene plus of a regular expression.
FPExpr MkFPSqrt(FPRMExpr rm, FPExpr t)
Floating-point square root
BoolExpr MkIff(BoolExpr t1, BoolExpr t2)
Create an expression representing t1 iff t2.
FiniteDomainSort MkFiniteDomainSort(string name, ulong size)
Create a new finite domain sort. The result is a sortElements of the sort are created using MkNumeral...
Expr MkNumeral(string v, Sort ty)
Create a Term of a given sort.
ArithExpr MkAdd(IEnumerable< ArithExpr > t)
Create an expression representing t[0] + t[1] + ....
FuncDecl MkRecFuncDecl(string name, Sort[] domain, Sort range)
Creates a new recursive function declaration.
BitVecExpr MkBVAdd(BitVecExpr t1, BitVecExpr t2)
Two's complement addition.
BoolExpr MkGt(ArithExpr t1, ArithExpr t2)
Create an expression representing t1 > t2
Solver MkSimpleSolver()
Creates a new (incremental) solver.
ArraySort MkArraySort(Sort[] domain, Sort range)
Create a new n-ary array sort.
Probe Not(Probe p)
Create a probe that evaluates to "true" when the value p does not evaluate to "true".
BoolExpr MkBool(bool value)
Creates a Boolean value.
BitVecExpr MkBVAND(BitVecExpr t1, BitVecExpr t2)
Bitwise conjunction.
Solver MkSolver(Tactic t)
Creates a solver that is implemented using the given tactic.
RealExpr MkRealConst(Symbol name)
Creates a real constant.
IntNum MkInt(ulong v)
Create an integer numeral.
Expr MkApp(FuncDecl f, IEnumerable< Expr > args)
Create a new function application.
ReExpr MkToRe(SeqExpr s)
Convert a regular expression that accepts sequence s.
BoolExpr MkFPIsNaN(FPExpr t)
Predicate indicating whether t is a NaN.
BitVecExpr MkBVRotateRight(uint i, BitVecExpr t)
Rotate Right.
string SimplifyHelp()
Return a string describing all available parameters to Expr.Simplify.
Quantifier MkExists(Expr[] boundConstants, Expr body, uint weight=1, Pattern[] patterns=null, Expr[] noPatterns=null, Symbol quantifierID=null, Symbol skolemID=null)
Create an existential Quantifier.
Lambda MkLambda(Sort[] sorts, Symbol[] names, Expr body)
Create a lambda expression.
FuncDecl MkFuncDecl(Symbol name, Sort[] domain, Sort range)
Creates a new function declaration.
BoolExpr MkBVSLT(BitVecExpr t1, BitVecExpr t2)
Two's complement signed less-than
IDecRefQueue Tactic_DRQ
Tactic DRQ
SetSort MkSetSort(Sort ty)
Create a set type.
EnumSort MkEnumSort(string name, params string[] enumNames)
Create a new enumeration sort.
BitVecNum MkBV(int v, uint size)
Create a bit-vector numeral.
RatNum MkReal(int num, int den)
Create a real from a fraction.
IDecRefQueue Probe_DRQ
Probe DRQ
EnumSort MkEnumSort(Symbol name, params Symbol[] enumNames)
Create a new enumeration sort.
BoolExpr MkFPIsNegative(FPExpr t)
Predicate indicating whether t is a negative floating-point number.
FuncDecl MkFreshFuncDecl(string prefix, Sort[] domain, Sort range)
Creates a fresh function declaration with a name prefixed with prefix .
IntExpr MkIntConst(string name)
Creates an integer constant.
Tactic When(Probe p, Tactic t)
Create a tactic that applies t to a given goal if the probe p evaluates to true.
BitVecExpr MkBVNeg(BitVecExpr t)
Standard two's complement unary minus.
FuncDecl MkFreshConstDecl(string prefix, Sort range)
Creates a fresh constant function declaration with a name prefixed with prefix .
Tactic Fail()
Create a tactic always fails.
Tactic FailIfNotDecided()
Create a tactic that fails if the goal is not trivially satisfiable (i.e., empty) or trivially unsati...
FPRMNum MkFPRoundTowardPositive()
Create a numeral of RoundingMode sort which represents the RoundTowardPositive rounding mode.
BitVecExpr MkBVOR(BitVecExpr t1, BitVecExpr t2)
Bitwise disjunction.
Expr MkConst(string name, Sort range)
Creates a new Constant of sort range and named name .
IntExpr MkRem(IntExpr t1, IntExpr t2)
Create an expression representing t1 rem t2.
FPExpr MkFPMul(FPRMExpr rm, FPExpr t1, FPExpr t2)
Floating-point multiplication
BoolExpr MkStringLt(SeqExpr s1, SeqExpr s2)
Check if the string s1 is lexicographically strictly less than s2.
BoolExpr MkBVSubNoOverflow(BitVecExpr t1, BitVecExpr t2)
Create a predicate that checks that the bit-wise subtraction does not overflow.
BitVecExpr MkFPToFP(FPRMExpr rm, IntExpr exp, RealExpr sig, FPSort s)
Conversion of a real-sorted significand and an integer-sorted exponent into a term of FloatingPoint s...
FPSort MkFPSort64()
Create the double-precision (64-bit) FloatingPoint sort.
FPRMNum MkFPRNA()
Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
Context(Dictionary< string, string > settings)
Constructor.
BitVecExpr MkBVRotateLeft(uint i, BitVecExpr t)
Rotate Left.
string TacticDescription(string name)
Returns a string containing a description of the tactic with the given name.
FPRMNum MkFPRNE()
Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
IDecRefQueue ASTMap_DRQ
ASTMap DRQ
SeqExpr MkUnit(Expr elem)
Create the singleton sequence.
uint NumProbes
The number of supported Probes.
BoolExpr MkPBEq(int[] coeffs, BoolExpr[] args, int k)
Create a pseudo-Boolean equal constraint.
IntNum MkInt(int v)
Create an integer numeral.
BitVecExpr MkBVXOR(BitVecExpr t1, BitVecExpr t2)
Bitwise XOR.
ArrayExpr MkStore(ArrayExpr a, Expr[] args, Expr v)
Array update.
Solver MkSolver(Symbol logic=null)
Creates a new (incremental) solver.
FPExpr MkFPAbs(FPExpr t)
Floating-point absolute value
FPExpr MkFPMin(FPExpr t1, FPExpr t2)
Minimum of floating-point numbers.
FPExpr MkFPDiv(FPRMExpr rm, FPExpr t1, FPExpr t2)
Floating-point division
BoolExpr MkOr(IEnumerable< BoolExpr > t)
Create an expression representing t[0] or t[1] or ....
ReExpr MkComplement(ReExpr re)
Create the complement regular expression.
BitVecExpr MkExtract(uint high, uint low, BitVecExpr t)
Bit-vector extraction.
ArithExpr MkMul(IEnumerable< ArithExpr > t)
Create an expression representing t[0] * t[1] * ....
StringSymbol MkSymbol(string name)
Create a symbol using a string.
BitVecExpr MkBVURem(BitVecExpr t1, BitVecExpr t2)
Unsigned remainder.
BoolExpr MkFalse()
The false Term.
IntExpr MkLength(SeqExpr s)
Retrieve the length of a given sequence.
RatNum MkReal(int v)
Create a real numeral.
IntSymbol MkSymbol(int i)
Creates a new symbol using an integer.
SeqExpr MkString(string s)
Create a string constant.
ArrayExpr MkStore(ArrayExpr a, Expr i, Expr v)
Array update.
FPExpr MkFP(BitVecExpr sgn, BitVecExpr sig, BitVecExpr exp)
Create an expression of FloatingPoint sort from three bit-vector expressions.
BoolExpr MkBVSGE(BitVecExpr t1, BitVecExpr t2)
Two's complement signed greater than or equal to.
Quantifier MkForall(Sort[] sorts, Symbol[] names, Expr body, uint weight=1, Pattern[] patterns=null, Expr[] noPatterns=null, Symbol quantifierID=null, Symbol skolemID=null)
Create a universal Quantifier.
FPNum MkFP(double v, FPSort s)
Create a numeral of FloatingPoint sort from a float.
BoolExpr MkFPIsNormal(FPExpr t)
Predicate indicating whether t is a normal floating-point number.
BoolExpr MkPrefixOf(SeqExpr s1, SeqExpr s2)
Check for sequence prefix.
BoolExpr MkFPIsPositive(FPExpr t)
Predicate indicating whether t is a positive floating-point number.
FloatingPoint Expressions
FloatingPoint RoundingMode Expressions
Floating-point rounding mode numerals
The FloatingPoint RoundingMode sort
Object for managing fixedpoints
A goal (aka problem). A goal is essentially a set of formulas, that can be solved and/or transformed ...
Object for managing optimization context
A ParamDescrs describes a set of parameters.
A Params objects represents a configuration in the form of Symbol/value pairs.
Patterns comprise a list of terms. The list should be non-empty. If the list comprises of more than o...
Probes are used to inspect a goal (aka problem) and collect information that may be used to decide wh...
Regular expression expressions
A regular expression sort
void Assert(params BoolExpr[] constraints)
Assert a constraint (or multiple) into the solver.
The Sort class implements type information for ASTs.
Symbols are used to name several term and type constructors.
Tactics are the basic building block for creating custom solvers for specific problem domains....
The exception base class for error reporting from Z3
Z3_ast_print_mode
Z3 pretty printing modes (See Z3_set_ast_print_mode).
Z3_error_code
Z3 error codes (See Z3_get_error_code).
expr range(expr const &lo, expr const &hi)
expr max(expr const &a, expr const &b)
def DatatypeSort(name, ctx=None)
def EnumSort(name, values, ctx=None)
def FiniteDomainSort(name, sz, ctx=None)
def FPSort(ebits, sbits, ctx=None)
def TupleSort(name, sorts, ctx=None)
def BitVecSort(sz, ctx=None)