21using System.Collections.Generic;
22using System.Diagnostics;
24using System.Runtime.InteropServices;
44 m_ctx = Native.Z3_mk_context_rc(IntPtr.Zero);
45 Native.Z3_enable_concurrent_dec_ref(m_ctx);
68 public Context(Dictionary<string, string> settings)
71 Debug.Assert(settings !=
null);
75 IntPtr cfg = Native.Z3_mk_config();
76 foreach (KeyValuePair<string, string> kv
in settings)
77 Native.Z3_set_param_value(cfg, kv.Key, kv.Value);
78 m_ctx = Native.Z3_mk_context_rc(cfg);
79 Native.Z3_enable_concurrent_dec_ref(m_ctx);
80 Native.Z3_del_config(cfg);
99 bool is_external =
false;
127 internal Symbol[] MkSymbols(
string[] names)
129 if (names ==
null)
return new Symbol[0];
131 for (
int i = 0; i < names.Length; ++i) result[i] =
MkSymbol(names[i]);
138 private IntSort m_intSort =
null;
140 private SeqSort m_stringSort =
null;
150 if (m_boolSort ==
null) m_boolSort =
new BoolSort(
this);
return m_boolSort;
161 if (m_intSort ==
null) m_intSort =
new IntSort(
this);
return m_intSort;
173 if (m_realSort ==
null) m_realSort =
new RealSort(
this);
return m_realSort;
184 if (m_charSort ==
null) m_charSort =
new CharSort(
this);
return m_charSort;
196 if (m_stringSort ==
null) m_stringSort =
new SeqSort(
this, Native.Z3_mk_string_sort(nCtx));
215 Debug.Assert(s !=
null);
217 CheckContextMatch(s);
252 return new BitVecSort(
this, Native.Z3_mk_bv_sort(nCtx, size));
260 Debug.Assert(s !=
null);
261 return new SeqSort(
this, Native.Z3_mk_seq_sort(nCtx, s.NativeObject));
269 Debug.Assert(s !=
null);
270 return new ReSort(
this, Native.Z3_mk_re_sort(nCtx, s.NativeObject));
278 Debug.Assert(domain !=
null);
279 Debug.Assert(range !=
null);
281 CheckContextMatch(domain);
282 CheckContextMatch(range);
283 return new ArraySort(
this, domain, range);
291 Debug.Assert(domain !=
null);
292 Debug.Assert(range !=
null);
294 CheckContextMatch<Sort>(domain);
295 CheckContextMatch(range);
296 return new ArraySort(
this, domain, range);
304 Debug.Assert(name !=
null);
305 Debug.Assert(fieldNames !=
null);
306 Debug.Assert(fieldNames.All(fn => fn !=
null));
307 Debug.Assert(fieldSorts ==
null || fieldSorts.All(fs => fs !=
null));
309 CheckContextMatch(name);
310 CheckContextMatch<Symbol>(fieldNames);
311 CheckContextMatch<Sort>(fieldSorts);
312 return new TupleSort(
this, name, (uint)fieldNames.Length, fieldNames, fieldSorts);
320 Debug.Assert(name !=
null);
321 Debug.Assert(enumNames !=
null);
322 Debug.Assert(enumNames.All(f => f !=
null));
325 CheckContextMatch(name);
326 CheckContextMatch<Symbol>(enumNames);
327 return new EnumSort(
this, name, enumNames);
335 Debug.Assert(enumNames !=
null);
337 var enumSymbols = MkSymbols(enumNames);
341 return new EnumSort(
this, symbol, enumSymbols);
345 foreach (var enumSymbol
in enumSymbols)
346 enumSymbol.Dispose();
355 Debug.Assert(name !=
null);
356 Debug.Assert(elemSort !=
null);
358 CheckContextMatch(name);
359 CheckContextMatch(elemSort);
360 return new ListSort(
this, name, elemSort);
368 Debug.Assert(elemSort !=
null);
370 CheckContextMatch(elemSort);
372 return new ListSort(
this, symbol, elemSort);
383 Debug.Assert(name !=
null);
385 CheckContextMatch(name);
417 Debug.Assert(name !=
null);
418 Debug.Assert(recognizer !=
null);
420 return new Constructor(
this, name, recognizer, fieldNames, sorts, sortRefs);
435 using var nameSymbol =
MkSymbol(name);
436 using var recognizerSymbol =
MkSymbol(recognizer);
437 var fieldSymbols = MkSymbols(fieldNames);
440 return new Constructor(
this, nameSymbol, recognizerSymbol, fieldSymbols, sorts, sortRefs);
444 foreach (var fieldSymbol
in fieldSymbols)
445 fieldSymbol.Dispose();
454 Debug.Assert(name !=
null);
455 Debug.Assert(constructors !=
null);
456 Debug.Assert(constructors.All(c => c !=
null));
459 CheckContextMatch(name);
460 CheckContextMatch<Constructor>(constructors);
469 Debug.Assert(constructors !=
null);
470 Debug.Assert(constructors.All(c => c !=
null));
472 CheckContextMatch<Constructor>(constructors);
485 Debug.Assert(name !=
null);
486 CheckContextMatch(name);
487 if (parameters !=
null)
488 CheckContextMatch<Sort>(parameters);
490 var numParams = (parameters ==
null) ? 0 : (uint)parameters.Length;
491 var paramsNative = (parameters ==
null) ?
null :
AST.ArrayToNative(parameters);
492 return new DatatypeSort(
this, Native.Z3_mk_datatype_sort(nCtx, name.NativeObject, numParams, paramsNative));
514 Debug.Assert(names !=
null);
515 Debug.Assert(c !=
null);
516 Debug.Assert(names.Length == c.Length);
518 Debug.Assert(names.All(name => name !=
null));
520 CheckContextMatch<Symbol>(names);
521 uint n = (uint)names.Length;
523 IntPtr[] n_constr =
new IntPtr[n];
524 for (uint i = 0; i < n; i++)
527 CheckContextMatch<Constructor>(constructor);
529 n_constr[i] = cla[i].NativeObject;
531 IntPtr[] n_res =
new IntPtr[n];
532 Native.Z3_mk_datatypes(nCtx, n,
Symbol.ArrayToNative(names), n_res, n_constr);
534 for (uint i = 0; i < n; i++)
547 Debug.Assert(names !=
null);
548 Debug.Assert(c !=
null);
549 Debug.Assert(names.Length == c.Length);
553 var symbols = MkSymbols(names);
560 foreach (var symbol
in symbols)
573 return Expr.Create(
this, Native.Z3_datatype_update_field(
574 nCtx, field.NativeObject,
575 t.NativeObject, v.NativeObject));
581 #region Function Declarations
587 Debug.Assert(name !=
null);
588 Debug.Assert(range !=
null);
589 Debug.Assert(domain.All(d => d !=
null));
591 CheckContextMatch(name);
592 CheckContextMatch<Sort>(domain);
593 CheckContextMatch(range);
594 return new FuncDecl(
this, name, domain, range);
602 Debug.Assert(name !=
null);
603 Debug.Assert(domain !=
null);
604 Debug.Assert(range !=
null);
606 CheckContextMatch(name);
607 CheckContextMatch(domain);
608 CheckContextMatch(range);
610 return new FuncDecl(
this, name, q, range);
618 Debug.Assert(range !=
null);
619 Debug.Assert(domain.All(d => d !=
null));
621 CheckContextMatch<Sort>(domain);
622 CheckContextMatch(range);
624 return new FuncDecl(
this, symbol, domain, range);
632 Debug.Assert(range !=
null);
633 Debug.Assert(domain.All(d => d !=
null));
635 CheckContextMatch<Sort>(domain);
636 CheckContextMatch(range);
638 return new FuncDecl(
this, symbol, domain, range,
true);
649 CheckContextMatch(f);
650 CheckContextMatch<Expr>(args);
651 CheckContextMatch(body);
652 IntPtr[] argsNative =
AST.ArrayToNative(args);
653 Native.Z3_add_rec_def(nCtx, f.NativeObject, (uint)args.Length, argsNative, body.NativeObject);
661 Debug.Assert(range !=
null);
662 Debug.Assert(domain !=
null);
664 CheckContextMatch(domain);
665 CheckContextMatch(range);
668 return new FuncDecl(
this, symbol, q, range);
678 Debug.Assert(range !=
null);
679 Debug.Assert(domain.All(d => d !=
null));
681 CheckContextMatch<Sort>(domain);
682 CheckContextMatch(range);
683 return new FuncDecl(
this, prefix, domain, range);
691 Debug.Assert(name !=
null);
692 Debug.Assert(range !=
null);
694 CheckContextMatch(name);
695 CheckContextMatch(range);
696 return new FuncDecl(
this, name,
null, range);
704 Debug.Assert(range !=
null);
706 CheckContextMatch(range);
708 return new FuncDecl(
this, symbol,
null, range);
718 Debug.Assert(range !=
null);
720 CheckContextMatch(range);
721 return new FuncDecl(
this, prefix,
null, range);
730 var fn = Native.Z3_solver_propagate_declare(nCtx, _name.NativeObject,
AST.ArrayLength(domain),
AST.ArrayToNative(domain), range.NativeObject);
735 #region Bound Variables
743 Debug.Assert(ty !=
null);
745 return Expr.Create(
this, Native.Z3_mk_bound(nCtx, index, ty.NativeObject));
749 #region Quantifier Patterns
755 Debug.Assert(terms !=
null);
756 if (terms.Length == 0)
757 throw new Z3Exception(
"Cannot create a pattern from zero terms");
759 IntPtr[] termsNative =
AST.ArrayToNative(terms);
760 return new Pattern(
this, Native.Z3_mk_pattern(nCtx, (uint)terms.Length, termsNative));
770 Debug.Assert(name !=
null);
771 Debug.Assert(range !=
null);
773 CheckContextMatch(name);
774 CheckContextMatch(range);
776 return Expr.Create(
this, Native.Z3_mk_const(nCtx, name.NativeObject, range.NativeObject));
784 Debug.Assert(range !=
null);
796 Debug.Assert(range !=
null);
798 CheckContextMatch(range);
799 return Expr.Create(
this, Native.Z3_mk_fresh_const(nCtx, prefix, range.NativeObject));
808 Debug.Assert(f !=
null);
818 Debug.Assert(name !=
null);
837 Debug.Assert(name !=
null);
847 Debug.Assert(name !=
null);
857 Debug.Assert(name !=
null);
876 Debug.Assert(name !=
null);
898 Debug.Assert(f !=
null);
899 Debug.Assert(args ==
null || args.All(a => a !=
null));
900 CheckContextMatch(f);
901 CheckContextMatch<Expr>(args);
902 return Expr.Create(
this, f, args);
910 Debug.Assert(f !=
null);
911 return MkApp(f, args?.ToArray());
914 #region Propositional
920 return new BoolExpr(
this, Native.Z3_mk_true(nCtx));
928 return new BoolExpr(
this, Native.Z3_mk_false(nCtx));
944 Debug.Assert(x !=
null);
945 Debug.Assert(y !=
null);
947 CheckContextMatch(x);
948 CheckContextMatch(y);
949 return new BoolExpr(
this, Native.Z3_mk_eq(nCtx, x.NativeObject, y.NativeObject));
957 Debug.Assert(args !=
null);
958 Debug.Assert(args.All(a => a !=
null));
960 CheckContextMatch<Expr>(args);
961 return new BoolExpr(
this, Native.Z3_mk_distinct(nCtx, (uint)args.Length,
AST.ArrayToNative(args)));
969 Debug.Assert(args !=
null);
978 Debug.Assert(a !=
null);
979 CheckContextMatch(a);
980 return new BoolExpr(
this, Native.Z3_mk_not(nCtx, a.NativeObject));
991 Debug.Assert(t1 !=
null);
992 Debug.Assert(t2 !=
null);
993 Debug.Assert(t3 !=
null);
995 CheckContextMatch(t1);
996 CheckContextMatch(t2);
997 CheckContextMatch(t3);
998 return Expr.Create(
this, Native.Z3_mk_ite(nCtx, t1.NativeObject, t2.NativeObject, t3.NativeObject));
1006 Debug.Assert(t1 !=
null);
1007 Debug.Assert(t2 !=
null);
1009 CheckContextMatch(t1);
1010 CheckContextMatch(t2);
1011 return new BoolExpr(
this, Native.Z3_mk_iff(nCtx, t1.NativeObject, t2.NativeObject));
1019 Debug.Assert(t1 !=
null);
1020 Debug.Assert(t2 !=
null);
1022 CheckContextMatch(t1);
1023 CheckContextMatch(t2);
1024 return new BoolExpr(
this, Native.Z3_mk_implies(nCtx, t1.NativeObject, t2.NativeObject));
1032 Debug.Assert(t1 !=
null);
1033 Debug.Assert(t2 !=
null);
1035 CheckContextMatch(t1);
1036 CheckContextMatch(t2);
1037 return new BoolExpr(
this, Native.Z3_mk_xor(nCtx, t1.NativeObject, t2.NativeObject));
1045 Debug.Assert(args !=
null);
1046 var ts = args.ToArray();
1047 Debug.Assert(ts.All(a => a !=
null));
1048 CheckContextMatch<BoolExpr>(ts);
1050 return ts.Aggregate(
MkFalse(), (r, t) =>
1062 Debug.Assert(ts !=
null);
1063 Debug.Assert(ts.All(a => a !=
null));
1065 CheckContextMatch<BoolExpr>(ts);
1066 return new BoolExpr(
this, Native.Z3_mk_and(nCtx, (uint)ts.Length,
AST.ArrayToNative(ts)));
1074 Debug.Assert(t !=
null);
1075 return MkAnd(t.ToArray());
1083 Debug.Assert(ts !=
null);
1084 Debug.Assert(ts.All(a => a !=
null));
1086 CheckContextMatch<BoolExpr>(ts);
1087 return new BoolExpr(
this, Native.Z3_mk_or(nCtx, (uint)ts.Length,
AST.ArrayToNative(ts)));
1096 Debug.Assert(ts !=
null);
1097 return MkOr(ts.ToArray());
1108 Debug.Assert(ts !=
null);
1109 Debug.Assert(ts.All(a => a !=
null));
1111 CheckContextMatch<ArithExpr>(ts);
1112 return (
ArithExpr)
Expr.Create(
this, Native.Z3_mk_add(nCtx, (uint)ts.Length,
AST.ArrayToNative(ts)));
1120 Debug.Assert(ts !=
null);
1121 return MkAdd(ts.ToArray());
1129 Debug.Assert(ts !=
null);
1130 Debug.Assert(ts.All(a => a !=
null));
1132 CheckContextMatch<ArithExpr>(ts);
1133 return (
ArithExpr)
Expr.Create(
this, Native.Z3_mk_mul(nCtx, (uint)ts.Length,
AST.ArrayToNative(ts)));
1141 Debug.Assert(ts !=
null);
1142 return MkMul(ts.ToArray());
1150 Debug.Assert(ts !=
null);
1151 Debug.Assert(ts.All(a => a !=
null));
1153 CheckContextMatch<ArithExpr>(ts);
1154 return (
ArithExpr)
Expr.Create(
this, Native.Z3_mk_sub(nCtx, (uint)ts.Length,
AST.ArrayToNative(ts)));
1162 Debug.Assert(t !=
null);
1164 CheckContextMatch(t);
1165 return (
ArithExpr)
Expr.Create(
this, Native.Z3_mk_unary_minus(nCtx, t.NativeObject));
1173 Debug.Assert(t1 !=
null);
1174 Debug.Assert(t2 !=
null);
1176 CheckContextMatch(t1);
1177 CheckContextMatch(t2);
1178 return (
ArithExpr)
Expr.Create(
this, Native.Z3_mk_div(nCtx, t1.NativeObject, t2.NativeObject));
1187 Debug.Assert(t1 !=
null);
1188 Debug.Assert(t2 !=
null);
1190 CheckContextMatch(t1);
1191 CheckContextMatch(t2);
1192 return new IntExpr(
this, Native.Z3_mk_mod(nCtx, t1.NativeObject, t2.NativeObject));
1201 Debug.Assert(t1 !=
null);
1202 Debug.Assert(t2 !=
null);
1204 CheckContextMatch(t1);
1205 CheckContextMatch(t2);
1206 return new IntExpr(
this, Native.Z3_mk_rem(nCtx, t1.NativeObject, t2.NativeObject));
1214 Debug.Assert(t1 !=
null);
1215 Debug.Assert(t2 !=
null);
1217 CheckContextMatch(t1);
1218 CheckContextMatch(t2);
1219 return (
ArithExpr)
Expr.Create(
this, Native.Z3_mk_power(nCtx, t1.NativeObject, t2.NativeObject));
1227 Debug.Assert(t1 !=
null);
1228 Debug.Assert(t2 !=
null);
1230 CheckContextMatch(t1);
1231 CheckContextMatch(t2);
1232 return new BoolExpr(
this, Native.Z3_mk_lt(nCtx, t1.NativeObject, t2.NativeObject));
1240 Debug.Assert(t1 !=
null);
1241 Debug.Assert(t2 !=
null);
1243 CheckContextMatch(t1);
1244 CheckContextMatch(t2);
1245 return new BoolExpr(
this, Native.Z3_mk_le(nCtx, t1.NativeObject, t2.NativeObject));
1253 Debug.Assert(t1 !=
null);
1254 Debug.Assert(t2 !=
null);
1256 CheckContextMatch(t1);
1257 CheckContextMatch(t2);
1258 return new BoolExpr(
this, Native.Z3_mk_gt(nCtx, t1.NativeObject, t2.NativeObject));
1266 Debug.Assert(t1 !=
null);
1267 Debug.Assert(t2 !=
null);
1269 CheckContextMatch(t1);
1270 CheckContextMatch(t2);
1271 return new BoolExpr(
this, Native.Z3_mk_ge(nCtx, t1.NativeObject, t2.NativeObject));
1286 Debug.Assert(t !=
null);
1288 CheckContextMatch(t);
1289 return new RealExpr(
this, Native.Z3_mk_int2real(nCtx, t.NativeObject));
1301 Debug.Assert(t !=
null);
1303 CheckContextMatch(t);
1304 return new IntExpr(
this, Native.Z3_mk_real2int(nCtx, t.NativeObject));
1312 Debug.Assert(t !=
null);
1314 CheckContextMatch(t);
1315 return new BoolExpr(
this, Native.Z3_mk_is_int(nCtx, t.NativeObject));
1326 Debug.Assert(t !=
null);
1328 CheckContextMatch(t);
1329 return new BitVecExpr(
this, Native.Z3_mk_bvnot(nCtx, t.NativeObject));
1338 Debug.Assert(t !=
null);
1340 CheckContextMatch(t);
1341 return new BitVecExpr(
this, Native.Z3_mk_bvredand(nCtx, t.NativeObject));
1350 Debug.Assert(t !=
null);
1352 CheckContextMatch(t);
1353 return new BitVecExpr(
this, Native.Z3_mk_bvredor(nCtx, t.NativeObject));
1362 Debug.Assert(t1 !=
null);
1363 Debug.Assert(t2 !=
null);
1365 CheckContextMatch(t1);
1366 CheckContextMatch(t2);
1367 return new BitVecExpr(
this, Native.Z3_mk_bvand(nCtx, t1.NativeObject, t2.NativeObject));
1376 Debug.Assert(t1 !=
null);
1377 Debug.Assert(t2 !=
null);
1379 CheckContextMatch(t1);
1380 CheckContextMatch(t2);
1381 return new BitVecExpr(
this, Native.Z3_mk_bvor(nCtx, t1.NativeObject, t2.NativeObject));
1390 Debug.Assert(t1 !=
null);
1391 Debug.Assert(t2 !=
null);
1393 CheckContextMatch(t1);
1394 CheckContextMatch(t2);
1395 return new BitVecExpr(
this, Native.Z3_mk_bvxor(nCtx, t1.NativeObject, t2.NativeObject));
1404 Debug.Assert(t1 !=
null);
1405 Debug.Assert(t2 !=
null);
1407 CheckContextMatch(t1);
1408 CheckContextMatch(t2);
1409 return new BitVecExpr(
this, Native.Z3_mk_bvnand(nCtx, t1.NativeObject, t2.NativeObject));
1418 Debug.Assert(t1 !=
null);
1419 Debug.Assert(t2 !=
null);
1421 CheckContextMatch(t1);
1422 CheckContextMatch(t2);
1423 return new BitVecExpr(
this, Native.Z3_mk_bvnor(nCtx, t1.NativeObject, t2.NativeObject));
1432 Debug.Assert(t1 !=
null);
1433 Debug.Assert(t2 !=
null);
1435 CheckContextMatch(t1);
1436 CheckContextMatch(t2);
1437 return new BitVecExpr(
this, Native.Z3_mk_bvxnor(nCtx, t1.NativeObject, t2.NativeObject));
1446 Debug.Assert(t !=
null);
1448 CheckContextMatch(t);
1449 return new BitVecExpr(
this, Native.Z3_mk_bvneg(nCtx, t.NativeObject));
1458 Debug.Assert(t1 !=
null);
1459 Debug.Assert(t2 !=
null);
1461 CheckContextMatch(t1);
1462 CheckContextMatch(t2);
1463 return new BitVecExpr(
this, Native.Z3_mk_bvadd(nCtx, t1.NativeObject, t2.NativeObject));
1472 Debug.Assert(t1 !=
null);
1473 Debug.Assert(t2 !=
null);
1475 CheckContextMatch(t1);
1476 CheckContextMatch(t2);
1477 return new BitVecExpr(
this, Native.Z3_mk_bvsub(nCtx, t1.NativeObject, t2.NativeObject));
1486 Debug.Assert(t1 !=
null);
1487 Debug.Assert(t2 !=
null);
1489 CheckContextMatch(t1);
1490 CheckContextMatch(t2);
1491 return new BitVecExpr(
this, Native.Z3_mk_bvmul(nCtx, t1.NativeObject, t2.NativeObject));
1505 Debug.Assert(t1 !=
null);
1506 Debug.Assert(t2 !=
null);
1508 CheckContextMatch(t1);
1509 CheckContextMatch(t2);
1510 return new BitVecExpr(
this, Native.Z3_mk_bvudiv(nCtx, t1.NativeObject, t2.NativeObject));
1528 Debug.Assert(t1 !=
null);
1529 Debug.Assert(t2 !=
null);
1531 CheckContextMatch(t1);
1532 CheckContextMatch(t2);
1533 return new BitVecExpr(
this, Native.Z3_mk_bvsdiv(nCtx, t1.NativeObject, t2.NativeObject));
1546 Debug.Assert(t1 !=
null);
1547 Debug.Assert(t2 !=
null);
1549 CheckContextMatch(t1);
1550 CheckContextMatch(t2);
1551 return new BitVecExpr(
this, Native.Z3_mk_bvurem(nCtx, t1.NativeObject, t2.NativeObject));
1566 Debug.Assert(t1 !=
null);
1567 Debug.Assert(t2 !=
null);
1569 CheckContextMatch(t1);
1570 CheckContextMatch(t2);
1571 return new BitVecExpr(
this, Native.Z3_mk_bvsrem(nCtx, t1.NativeObject, t2.NativeObject));
1583 Debug.Assert(t1 !=
null);
1584 Debug.Assert(t2 !=
null);
1586 CheckContextMatch(t1);
1587 CheckContextMatch(t2);
1588 return new BitVecExpr(
this, Native.Z3_mk_bvsmod(nCtx, t1.NativeObject, t2.NativeObject));
1599 Debug.Assert(t1 !=
null);
1600 Debug.Assert(t2 !=
null);
1602 CheckContextMatch(t1);
1603 CheckContextMatch(t2);
1604 return new BoolExpr(
this, Native.Z3_mk_bvult(nCtx, t1.NativeObject, t2.NativeObject));
1615 Debug.Assert(t1 !=
null);
1616 Debug.Assert(t2 !=
null);
1618 CheckContextMatch(t1);
1619 CheckContextMatch(t2);
1620 return new BoolExpr(
this, Native.Z3_mk_bvslt(nCtx, t1.NativeObject, t2.NativeObject));
1631 Debug.Assert(t1 !=
null);
1632 Debug.Assert(t2 !=
null);
1634 CheckContextMatch(t1);
1635 CheckContextMatch(t2);
1636 return new BoolExpr(
this, Native.Z3_mk_bvule(nCtx, t1.NativeObject, t2.NativeObject));
1647 Debug.Assert(t1 !=
null);
1648 Debug.Assert(t2 !=
null);
1650 CheckContextMatch(t1);
1651 CheckContextMatch(t2);
1652 return new BoolExpr(
this, Native.Z3_mk_bvsle(nCtx, t1.NativeObject, t2.NativeObject));
1663 Debug.Assert(t1 !=
null);
1664 Debug.Assert(t2 !=
null);
1666 CheckContextMatch(t1);
1667 CheckContextMatch(t2);
1668 return new BoolExpr(
this, Native.Z3_mk_bvuge(nCtx, t1.NativeObject, t2.NativeObject));
1679 Debug.Assert(t1 !=
null);
1680 Debug.Assert(t2 !=
null);
1682 CheckContextMatch(t1);
1683 CheckContextMatch(t2);
1684 return new BoolExpr(
this, Native.Z3_mk_bvsge(nCtx, t1.NativeObject, t2.NativeObject));
1695 Debug.Assert(t1 !=
null);
1696 Debug.Assert(t2 !=
null);
1698 CheckContextMatch(t1);
1699 CheckContextMatch(t2);
1700 return new BoolExpr(
this, Native.Z3_mk_bvugt(nCtx, t1.NativeObject, t2.NativeObject));
1711 Debug.Assert(t1 !=
null);
1712 Debug.Assert(t2 !=
null);
1714 CheckContextMatch(t1);
1715 CheckContextMatch(t2);
1716 return new BoolExpr(
this, Native.Z3_mk_bvsgt(nCtx, t1.NativeObject, t2.NativeObject));
1731 Debug.Assert(t1 !=
null);
1732 Debug.Assert(t2 !=
null);
1734 CheckContextMatch(t1);
1735 CheckContextMatch(t2);
1736 return new BitVecExpr(
this, Native.Z3_mk_concat(nCtx, t1.NativeObject, t2.NativeObject));
1750 Debug.Assert(t !=
null);
1752 CheckContextMatch(t);
1753 return new BitVecExpr(
this, Native.Z3_mk_extract(nCtx, high, low, t.NativeObject));
1766 Debug.Assert(t !=
null);
1768 CheckContextMatch(t);
1769 return new BitVecExpr(
this, Native.Z3_mk_sign_ext(nCtx, i, t.NativeObject));
1783 Debug.Assert(t !=
null);
1785 CheckContextMatch(t);
1786 return new BitVecExpr(
this, Native.Z3_mk_zero_ext(nCtx, i, t.NativeObject));
1797 Debug.Assert(t !=
null);
1799 CheckContextMatch(t);
1800 return new BitVecExpr(
this, Native.Z3_mk_repeat(nCtx, i, t.NativeObject));
1817 Debug.Assert(t1 !=
null);
1818 Debug.Assert(t2 !=
null);
1820 CheckContextMatch(t1);
1821 CheckContextMatch(t2);
1822 return new BitVecExpr(
this, Native.Z3_mk_bvshl(nCtx, t1.NativeObject, t2.NativeObject));
1839 Debug.Assert(t1 !=
null);
1840 Debug.Assert(t2 !=
null);
1842 CheckContextMatch(t1);
1843 CheckContextMatch(t2);
1844 return new BitVecExpr(
this, Native.Z3_mk_bvlshr(nCtx, t1.NativeObject, t2.NativeObject));
1863 Debug.Assert(t1 !=
null);
1864 Debug.Assert(t2 !=
null);
1866 CheckContextMatch(t1);
1867 CheckContextMatch(t2);
1868 return new BitVecExpr(
this, Native.Z3_mk_bvashr(nCtx, t1.NativeObject, t2.NativeObject));
1880 Debug.Assert(t !=
null);
1882 CheckContextMatch(t);
1883 return new BitVecExpr(
this, Native.Z3_mk_rotate_left(nCtx, i, t.NativeObject));
1895 Debug.Assert(t !=
null);
1897 CheckContextMatch(t);
1898 return new BitVecExpr(
this, Native.Z3_mk_rotate_right(nCtx, i, t.NativeObject));
1910 Debug.Assert(t1 !=
null);
1911 Debug.Assert(t2 !=
null);
1913 CheckContextMatch(t1);
1914 CheckContextMatch(t2);
1915 return new BitVecExpr(
this, Native.Z3_mk_ext_rotate_left(nCtx, t1.NativeObject, t2.NativeObject));
1927 Debug.Assert(t1 !=
null);
1928 Debug.Assert(t2 !=
null);
1930 CheckContextMatch(t1);
1931 CheckContextMatch(t2);
1932 return new BitVecExpr(
this, Native.Z3_mk_ext_rotate_right(nCtx, t1.NativeObject, t2.NativeObject));
1947 Debug.Assert(t !=
null);
1949 CheckContextMatch(t);
1950 return new BitVecExpr(
this, Native.Z3_mk_int2bv(nCtx, n, t.NativeObject));
1970 Debug.Assert(t !=
null);
1972 CheckContextMatch(t);
1973 return new IntExpr(
this, Native.Z3_mk_bv2int(nCtx, t.NativeObject, (
byte)(
signed ? 1 : 0)));
1984 Debug.Assert(t1 !=
null);
1985 Debug.Assert(t2 !=
null);
1987 CheckContextMatch(t1);
1988 CheckContextMatch(t2);
1989 return new BoolExpr(
this, Native.Z3_mk_bvadd_no_overflow(nCtx, t1.NativeObject, t2.NativeObject, (
byte)(isSigned ? 1 : 0)));
2000 Debug.Assert(t1 !=
null);
2001 Debug.Assert(t2 !=
null);
2003 CheckContextMatch(t1);
2004 CheckContextMatch(t2);
2005 return new BoolExpr(
this, Native.Z3_mk_bvadd_no_underflow(nCtx, t1.NativeObject, t2.NativeObject));
2016 Debug.Assert(t1 !=
null);
2017 Debug.Assert(t2 !=
null);
2019 CheckContextMatch(t1);
2020 CheckContextMatch(t2);
2021 return new BoolExpr(
this, Native.Z3_mk_bvsub_no_overflow(nCtx, t1.NativeObject, t2.NativeObject));
2032 Debug.Assert(t1 !=
null);
2033 Debug.Assert(t2 !=
null);
2035 CheckContextMatch(t1);
2036 CheckContextMatch(t2);
2037 return new BoolExpr(
this, Native.Z3_mk_bvsub_no_underflow(nCtx, t1.NativeObject, t2.NativeObject, (
byte)(isSigned ? 1 : 0)));
2048 Debug.Assert(t1 !=
null);
2049 Debug.Assert(t2 !=
null);
2051 CheckContextMatch(t1);
2052 CheckContextMatch(t2);
2053 return new BoolExpr(
this, Native.Z3_mk_bvsdiv_no_overflow(nCtx, t1.NativeObject, t2.NativeObject));
2064 Debug.Assert(t !=
null);
2066 CheckContextMatch(t);
2067 return new BoolExpr(
this, Native.Z3_mk_bvneg_no_overflow(nCtx, t.NativeObject));
2078 Debug.Assert(t1 !=
null);
2079 Debug.Assert(t2 !=
null);
2081 CheckContextMatch(t1);
2082 CheckContextMatch(t2);
2083 return new BoolExpr(
this, Native.Z3_mk_bvmul_no_overflow(nCtx, t1.NativeObject, t2.NativeObject, (
byte)(isSigned ? 1 : 0)));
2094 Debug.Assert(t1 !=
null);
2095 Debug.Assert(t2 !=
null);
2097 CheckContextMatch(t1);
2098 CheckContextMatch(t2);
2099 return new BoolExpr(
this, Native.Z3_mk_bvmul_no_underflow(nCtx, t1.NativeObject, t2.NativeObject));
2109 Debug.Assert(name !=
null);
2110 Debug.Assert(domain !=
null);
2111 Debug.Assert(range !=
null);
2122 Debug.Assert(domain !=
null);
2123 Debug.Assert(range !=
null);
2146 Debug.Assert(a !=
null);
2147 Debug.Assert(i !=
null);
2149 CheckContextMatch(a);
2150 CheckContextMatch(i);
2151 return Expr.Create(
this, Native.Z3_mk_select(nCtx, a.NativeObject, i.NativeObject));
2169 Debug.Assert(a !=
null);
2170 Debug.Assert(args !=
null && args.All(n => n !=
null));
2172 CheckContextMatch(a);
2173 CheckContextMatch<Expr>(args);
2174 return Expr.Create(
this, Native.Z3_mk_select_n(nCtx, a.NativeObject,
AST.ArrayLength(args),
AST.ArrayToNative(args)));
2198 Debug.Assert(a !=
null);
2199 Debug.Assert(i !=
null);
2200 Debug.Assert(v !=
null);
2202 CheckContextMatch(a);
2203 CheckContextMatch(i);
2204 CheckContextMatch(v);
2205 return new ArrayExpr(
this, Native.Z3_mk_store(nCtx, a.NativeObject, i.NativeObject, v.NativeObject));
2228 Debug.Assert(a !=
null);
2229 Debug.Assert(args !=
null);
2230 Debug.Assert(v !=
null);
2232 CheckContextMatch<Expr>(args);
2233 CheckContextMatch(a);
2234 CheckContextMatch(v);
2235 return new ArrayExpr(
this, Native.Z3_mk_store_n(nCtx, a.NativeObject,
AST.ArrayLength(args),
AST.ArrayToNative(args), v.NativeObject));
2249 Debug.Assert(domain !=
null);
2250 Debug.Assert(v !=
null);
2252 CheckContextMatch(domain);
2253 CheckContextMatch(v);
2254 return new ArrayExpr(
this, Native.Z3_mk_const_array(nCtx, domain.NativeObject, v.NativeObject));
2270 Debug.Assert(f !=
null);
2271 Debug.Assert(args ==
null || args.All(a => a !=
null));
2273 CheckContextMatch(f);
2274 CheckContextMatch<ArrayExpr>(args);
2275 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_map(nCtx, f.NativeObject,
AST.ArrayLength(args),
AST.ArrayToNative(args)));
2287 Debug.Assert(array !=
null);
2289 CheckContextMatch(array);
2290 return Expr.Create(
this, Native.Z3_mk_array_default(nCtx, array.NativeObject));
2298 Debug.Assert(arg1 !=
null);
2299 Debug.Assert(arg2 !=
null);
2301 CheckContextMatch(arg1);
2302 CheckContextMatch(arg2);
2303 return Expr.Create(
this, Native.Z3_mk_array_ext(nCtx, arg1.NativeObject, arg2.NativeObject));
2314 Debug.Assert(ty !=
null);
2316 CheckContextMatch(ty);
2325 Debug.Assert(domain !=
null);
2327 CheckContextMatch(domain);
2328 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_empty_set(nCtx, domain.NativeObject));
2336 Debug.Assert(domain !=
null);
2338 CheckContextMatch(domain);
2339 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_full_set(nCtx, domain.NativeObject));
2347 Debug.Assert(
set !=
null);
2348 Debug.Assert(element !=
null);
2350 CheckContextMatch(
set);
2351 CheckContextMatch(element);
2352 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_set_add(nCtx,
set.NativeObject, element.NativeObject));
2361 Debug.Assert(
set !=
null);
2362 Debug.Assert(element !=
null);
2364 CheckContextMatch(
set);
2365 CheckContextMatch(element);
2366 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_set_del(nCtx,
set.NativeObject, element.NativeObject));
2374 Debug.Assert(args !=
null);
2375 Debug.Assert(args.All(a => a !=
null));
2377 CheckContextMatch<ArrayExpr>(args);
2378 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_set_union(nCtx, (uint)args.Length,
AST.ArrayToNative(args)));
2386 Debug.Assert(args !=
null);
2387 Debug.Assert(args.All(a => a !=
null));
2389 CheckContextMatch<ArrayExpr>(args);
2390 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_set_intersect(nCtx, (uint)args.Length,
AST.ArrayToNative(args)));
2398 Debug.Assert(arg1 !=
null);
2399 Debug.Assert(arg2 !=
null);
2401 CheckContextMatch(arg1);
2402 CheckContextMatch(arg2);
2403 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_set_difference(nCtx, arg1.NativeObject, arg2.NativeObject));
2411 Debug.Assert(arg !=
null);
2413 CheckContextMatch(arg);
2414 return (
ArrayExpr)
Expr.Create(
this, Native.Z3_mk_set_complement(nCtx, arg.NativeObject));
2422 Debug.Assert(elem !=
null);
2423 Debug.Assert(
set !=
null);
2425 CheckContextMatch(elem);
2426 CheckContextMatch(
set);
2427 return (
BoolExpr)
Expr.Create(
this, Native.Z3_mk_set_member(nCtx, elem.NativeObject,
set.NativeObject));
2435 Debug.Assert(arg1 !=
null);
2436 Debug.Assert(arg2 !=
null);
2438 CheckContextMatch(arg1);
2439 CheckContextMatch(arg2);
2440 return (
BoolExpr)
Expr.Create(
this, Native.Z3_mk_set_subset(nCtx, arg1.NativeObject, arg2.NativeObject));
2445 #region Sequence, string and regular expressions
2452 Debug.Assert(s !=
null);
2453 return new SeqExpr(
this, Native.Z3_mk_seq_empty(nCtx, s.NativeObject));
2461 Debug.Assert(elem !=
null);
2462 return new SeqExpr(
this, Native.Z3_mk_seq_unit(nCtx, elem.NativeObject));
2470 Debug.Assert(s !=
null);
2471 return new SeqExpr(
this, Native.Z3_mk_string(nCtx, s));
2479 Debug.Assert(e !=
null);
2481 return new SeqExpr(
this, Native.Z3_mk_int_to_str(nCtx, e.NativeObject));
2489 Debug.Assert(e !=
null);
2491 return new SeqExpr(
this, Native.Z3_mk_ubv_to_str(nCtx, e.NativeObject));
2499 Debug.Assert(e !=
null);
2501 return new SeqExpr(
this, Native.Z3_mk_sbv_to_str(nCtx, e.NativeObject));
2509 Debug.Assert(e !=
null);
2511 return new IntExpr(
this, Native.Z3_mk_str_to_int(nCtx, e.NativeObject));
2520 Debug.Assert(t !=
null);
2521 Debug.Assert(t.All(a => a !=
null));
2523 CheckContextMatch<SeqExpr>(t);
2524 return new SeqExpr(
this, Native.Z3_mk_seq_concat(nCtx, (uint)t.Length,
AST.ArrayToNative(t)));
2533 Debug.Assert(s !=
null);
2534 return (
IntExpr)
Expr.Create(
this, Native.Z3_mk_seq_length(nCtx, s.NativeObject));
2542 Debug.Assert(s1 !=
null);
2543 Debug.Assert(s2 !=
null);
2544 CheckContextMatch(s1, s2);
2545 return new BoolExpr(
this, Native.Z3_mk_seq_prefix(nCtx, s1.NativeObject, s2.NativeObject));
2553 Debug.Assert(s1 !=
null);
2554 Debug.Assert(s2 !=
null);
2555 CheckContextMatch(s1, s2);
2556 return new BoolExpr(
this, Native.Z3_mk_seq_suffix(nCtx, s1.NativeObject, s2.NativeObject));
2564 Debug.Assert(s1 !=
null);
2565 Debug.Assert(s2 !=
null);
2566 CheckContextMatch(s1, s2);
2567 return new BoolExpr(
this, Native.Z3_mk_seq_contains(nCtx, s1.NativeObject, s2.NativeObject));
2575 Debug.Assert(s1 !=
null);
2576 Debug.Assert(s2 !=
null);
2577 CheckContextMatch(s1, s2);
2578 return new BoolExpr(
this, Native.Z3_mk_str_lt(nCtx, s1.NativeObject, s2.NativeObject));
2586 Debug.Assert(s1 !=
null);
2587 Debug.Assert(s2 !=
null);
2588 CheckContextMatch(s1, s2);
2589 return new BoolExpr(
this, Native.Z3_mk_str_le(nCtx, s1.NativeObject, s2.NativeObject));
2597 Debug.Assert(s !=
null);
2598 Debug.Assert(index !=
null);
2599 CheckContextMatch(s, index);
2600 return new SeqExpr(
this, Native.Z3_mk_seq_at(nCtx, s.NativeObject, index.NativeObject));
2608 Debug.Assert(s !=
null);
2609 Debug.Assert(index !=
null);
2610 CheckContextMatch(s, index);
2611 return Expr.Create(
this, Native.Z3_mk_seq_nth(nCtx, s.NativeObject, index.NativeObject));
2619 Debug.Assert(s !=
null);
2620 Debug.Assert(offset !=
null);
2621 Debug.Assert(length !=
null);
2622 CheckContextMatch(s, offset, length);
2623 return new SeqExpr(
this, Native.Z3_mk_seq_extract(nCtx, s.NativeObject, offset.NativeObject, length.NativeObject));
2631 Debug.Assert(s !=
null);
2632 Debug.Assert(offset !=
null);
2633 Debug.Assert(substr !=
null);
2634 CheckContextMatch(s, substr, offset);
2635 return new IntExpr(
this, Native.Z3_mk_seq_index(nCtx, s.NativeObject, substr.NativeObject, offset.NativeObject));
2643 Debug.Assert(s !=
null);
2644 Debug.Assert(src !=
null);
2645 Debug.Assert(dst !=
null);
2646 CheckContextMatch(s, src, dst);
2647 return new SeqExpr(
this, Native.Z3_mk_seq_replace(nCtx, s.NativeObject, src.NativeObject, dst.NativeObject));
2655 Debug.Assert(f !=
null);
2656 Debug.Assert(s !=
null);
2657 CheckContextMatch(f, s);
2658 return Expr.Create(
this, Native.Z3_mk_seq_map(nCtx, f.NativeObject, s.NativeObject));
2666 Debug.Assert(f !=
null);
2667 Debug.Assert(i !=
null);
2668 Debug.Assert(s !=
null);
2669 CheckContextMatch(f, i, s);
2670 return Expr.Create(
this, Native.Z3_mk_seq_mapi(nCtx, f.NativeObject, i.NativeObject, s.NativeObject));
2678 Debug.Assert(f !=
null);
2679 Debug.Assert(a !=
null);
2680 Debug.Assert(s !=
null);
2681 CheckContextMatch(f, a, s);
2682 return Expr.Create(
this, Native.Z3_mk_seq_foldl(nCtx, f.NativeObject, a.NativeObject, s.NativeObject));
2690 Debug.Assert(f !=
null);
2691 Debug.Assert(i !=
null);
2692 Debug.Assert(a !=
null);
2693 Debug.Assert(s !=
null);
2694 CheckContextMatch(f, i, a);
2695 CheckContextMatch(s, a);
2696 return Expr.Create(
this, Native.Z3_mk_seq_foldli(nCtx, f.NativeObject, i.NativeObject, a.NativeObject, s.NativeObject));
2704 Debug.Assert(s !=
null);
2705 return new ReExpr(
this, Native.Z3_mk_seq_to_re(nCtx, s.NativeObject));
2714 Debug.Assert(s !=
null);
2715 Debug.Assert(re !=
null);
2716 CheckContextMatch(s, re);
2717 return new BoolExpr(
this, Native.Z3_mk_seq_in_re(nCtx, s.NativeObject, re.NativeObject));
2725 Debug.Assert(re !=
null);
2726 return new ReExpr(
this, Native.Z3_mk_re_star(nCtx, re.NativeObject));
2734 Debug.Assert(re !=
null);
2735 return new ReExpr(
this, Native.Z3_mk_re_loop(nCtx, re.NativeObject, lo, hi));
2743 Debug.Assert(re !=
null);
2744 return new ReExpr(
this, Native.Z3_mk_re_plus(nCtx, re.NativeObject));
2752 Debug.Assert(re !=
null);
2753 return new ReExpr(
this, Native.Z3_mk_re_option(nCtx, re.NativeObject));
2761 Debug.Assert(re !=
null);
2762 return new ReExpr(
this, Native.Z3_mk_re_complement(nCtx, re.NativeObject));
2770 Debug.Assert(t !=
null);
2771 Debug.Assert(t.All(a => a !=
null));
2773 CheckContextMatch<ReExpr>(t);
2774 return new ReExpr(
this, Native.Z3_mk_re_concat(nCtx, (uint)t.Length,
AST.ArrayToNative(t)));
2782 Debug.Assert(t !=
null);
2783 Debug.Assert(t.All(a => a !=
null));
2785 CheckContextMatch<ReExpr>(t);
2786 return new ReExpr(
this, Native.Z3_mk_re_union(nCtx, (uint)t.Length,
AST.ArrayToNative(t)));
2794 Debug.Assert(t !=
null);
2795 Debug.Assert(t.All(a => a !=
null));
2797 CheckContextMatch<ReExpr>(t);
2798 return new ReExpr(
this, Native.Z3_mk_re_intersect(nCtx, (uint)t.Length,
AST.ArrayToNative(t)));
2806 Debug.Assert(a !=
null);
2807 Debug.Assert(b !=
null);
2808 CheckContextMatch(a, b);
2809 return new ReExpr(
this, Native.Z3_mk_re_diff(nCtx, a.NativeObject, b.NativeObject));
2818 Debug.Assert(s !=
null);
2819 return new ReExpr(
this, Native.Z3_mk_re_empty(nCtx, s.NativeObject));
2828 Debug.Assert(s !=
null);
2829 return new ReExpr(
this, Native.Z3_mk_re_full(nCtx, s.NativeObject));
2838 Debug.Assert(lo !=
null);
2839 Debug.Assert(hi !=
null);
2840 CheckContextMatch(lo, hi);
2841 return new ReExpr(
this, Native.Z3_mk_re_range(nCtx, lo.NativeObject, hi.NativeObject));
2849 Debug.Assert(ch1 !=
null);
2850 Debug.Assert(ch2 !=
null);
2851 return new BoolExpr(
this, Native.Z3_mk_char_le(nCtx, ch1.NativeObject, ch2.NativeObject));
2859 Debug.Assert(ch !=
null);
2860 return new IntExpr(
this, Native.Z3_mk_char_to_int(nCtx, ch.NativeObject));
2868 Debug.Assert(ch !=
null);
2869 return new BitVecExpr(
this, Native.Z3_mk_char_to_bv(nCtx, ch.NativeObject));
2877 Debug.Assert(bv !=
null);
2878 return new Expr(
this, Native.Z3_mk_char_from_bv(nCtx, bv.NativeObject));
2886 Debug.Assert(ch !=
null);
2887 return new BoolExpr(
this, Native.Z3_mk_char_is_digit(nCtx, ch.NativeObject));
2892 #region Pseudo-Boolean constraints
2899 Debug.Assert(args !=
null);
2900 var ts = args.ToArray();
2901 CheckContextMatch<BoolExpr>(ts);
2902 return new BoolExpr(
this, Native.Z3_mk_atmost(nCtx, (uint)ts.Length,
2903 AST.ArrayToNative(ts), k));
2911 Debug.Assert(args !=
null);
2912 var ts = args.ToArray();
2913 CheckContextMatch<BoolExpr>(ts);
2914 return new BoolExpr(
this, Native.Z3_mk_atleast(nCtx, (uint)ts.Length,
2915 AST.ArrayToNative(ts), k));
2923 Debug.Assert(args !=
null);
2924 Debug.Assert(coeffs !=
null);
2925 Debug.Assert(args.Length == coeffs.Length);
2926 CheckContextMatch<BoolExpr>(args);
2927 return new BoolExpr(
this, Native.Z3_mk_pble(nCtx, (uint)args.Length,
2928 AST.ArrayToNative(args),
2937 Debug.Assert(args !=
null);
2938 Debug.Assert(coeffs !=
null);
2939 Debug.Assert(args.Length == coeffs.Length);
2940 CheckContextMatch<BoolExpr>(args);
2941 return new BoolExpr(
this, Native.Z3_mk_pbge(nCtx, (uint)args.Length,
2942 AST.ArrayToNative(args),
2950 Debug.Assert(args !=
null);
2951 Debug.Assert(coeffs !=
null);
2952 Debug.Assert(args.Length == coeffs.Length);
2953 CheckContextMatch<BoolExpr>(args);
2954 return new BoolExpr(
this, Native.Z3_mk_pbeq(nCtx, (uint)args.Length,
2955 AST.ArrayToNative(args),
2962 #region General Numerals
2971 Debug.Assert(ty !=
null);
2973 CheckContextMatch(ty);
2974 return Expr.Create(
this, Native.Z3_mk_numeral(nCtx, v, ty.NativeObject));
2986 Debug.Assert(ty !=
null);
2988 CheckContextMatch(ty);
2989 return Expr.Create(
this, Native.Z3_mk_int(nCtx, v, ty.NativeObject));
3001 Debug.Assert(ty !=
null);
3003 CheckContextMatch(ty);
3004 return Expr.Create(
this, Native.Z3_mk_unsigned_int(nCtx, v, ty.NativeObject));
3016 Debug.Assert(ty !=
null);
3018 CheckContextMatch(ty);
3019 return Expr.Create(
this, Native.Z3_mk_int64(nCtx, v, ty.NativeObject));
3031 Debug.Assert(ty !=
null);
3033 CheckContextMatch(ty);
3034 return Expr.Create(
this, Native.Z3_mk_unsigned_int64(nCtx, v, ty.NativeObject));
3051 return new RatNum(
this, Native.Z3_mk_real(nCtx, num, den));
3062 return new RatNum(
this, Native.Z3_mk_numeral(nCtx, v,
RealSort.NativeObject));
3073 return new RatNum(
this, Native.Z3_mk_int(nCtx, v,
RealSort.NativeObject));
3084 return new RatNum(
this, Native.Z3_mk_unsigned_int(nCtx, v,
RealSort.NativeObject));
3095 return new RatNum(
this, Native.Z3_mk_int64(nCtx, v,
RealSort.NativeObject));
3106 return new RatNum(
this, Native.Z3_mk_unsigned_int64(nCtx, v,
RealSort.NativeObject));
3118 return new IntNum(
this, Native.Z3_mk_numeral(nCtx, v,
IntSort.NativeObject));
3129 return new IntNum(
this, Native.Z3_mk_int(nCtx, v,
IntSort.NativeObject));
3140 return new IntNum(
this, Native.Z3_mk_unsigned_int(nCtx, v,
IntSort.NativeObject));
3151 return new IntNum(
this, Native.Z3_mk_int64(nCtx, v,
IntSort.NativeObject));
3162 return new IntNum(
this, Native.Z3_mk_unsigned_int64(nCtx, v,
IntSort.NativeObject));
3228 byte[] _bits =
new byte[bits.Length];
3229 for (
int i = 0; i < bits.Length; ++i) _bits[i] = (
byte)(bits[i] ? 1 : 0);
3230 return (
BitVecNum)
Expr.Create(
this, Native.Z3_mk_bv_numeral(nCtx, (uint)bits.Length, _bits));
3265 Debug.Assert(sorts !=
null);
3266 Debug.Assert(names !=
null);
3267 Debug.Assert(body !=
null);
3268 Debug.Assert(sorts.Length == names.Length);
3269 Debug.Assert(sorts.All(s => s !=
null));
3270 Debug.Assert(names.All(n => n !=
null));
3271 Debug.Assert(patterns ==
null || patterns.All(p => p !=
null));
3272 Debug.Assert(noPatterns ==
null || noPatterns.All(np => np !=
null));
3275 return new Quantifier(
this,
true, sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID);
3289 Debug.Assert(body !=
null);
3290 Debug.Assert(boundConstants ==
null || boundConstants.All(b => b !=
null));
3291 Debug.Assert(patterns ==
null || patterns.All(p => p !=
null));
3292 Debug.Assert(noPatterns ==
null || noPatterns.All(np => np !=
null));
3295 return new Quantifier(
this,
true, boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID);
3307 Debug.Assert(sorts !=
null);
3308 Debug.Assert(names !=
null);
3309 Debug.Assert(body !=
null);
3310 Debug.Assert(sorts.Length == names.Length);
3311 Debug.Assert(sorts.All(s => s !=
null));
3312 Debug.Assert(names.All(n => n !=
null));
3313 Debug.Assert(patterns ==
null || patterns.All(p => p !=
null));
3314 Debug.Assert(noPatterns ==
null || noPatterns.All(np => np !=
null));
3316 return new Quantifier(
this,
false, sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID);
3329 Debug.Assert(body !=
null);
3330 Debug.Assert(boundConstants ==
null || boundConstants.All(n => n !=
null));
3331 Debug.Assert(patterns ==
null || patterns.All(p => p !=
null));
3332 Debug.Assert(noPatterns ==
null || noPatterns.All(np => np !=
null));
3334 return new Quantifier(
this,
false, boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID);
3344 Debug.Assert(body !=
null);
3345 Debug.Assert(names !=
null);
3346 Debug.Assert(sorts !=
null);
3347 Debug.Assert(sorts.Length == names.Length);
3348 Debug.Assert(sorts.All(s => s !=
null));
3349 Debug.Assert(names.All(n => n !=
null));
3350 Debug.Assert(patterns ==
null || patterns.All(p => p !=
null));
3351 Debug.Assert(noPatterns ==
null || noPatterns.All(np => np !=
null));
3355 return MkForall(sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID);
3357 return MkExists(sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID);
3367 Debug.Assert(body !=
null);
3368 Debug.Assert(boundConstants ==
null || boundConstants.All(n => n !=
null));
3369 Debug.Assert(patterns ==
null || patterns.All(p => p !=
null));
3370 Debug.Assert(noPatterns ==
null || noPatterns.All(np => np !=
null));
3374 return MkForall(boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID);
3376 return MkExists(boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID);
3399 Debug.Assert(sorts !=
null);
3400 Debug.Assert(names !=
null);
3401 Debug.Assert(body !=
null);
3402 Debug.Assert(sorts.Length == names.Length);
3403 Debug.Assert(sorts.All(s => s !=
null));
3404 Debug.Assert(names.All(n => n !=
null));
3405 return new Lambda(
this, sorts, names, body);
3418 Debug.Assert(body !=
null);
3419 Debug.Assert(boundConstants !=
null && boundConstants.All(b => b !=
null));
3420 return new Lambda(
this, boundConstants, body);
3447 get {
return m_print_mode; }
3450 Native.Z3_set_ast_print_mode(nCtx, (uint)value);
3451 m_print_mode = value;
3456 #region SMT Files & Strings
3465 uint csn =
Symbol.ArrayLength(sortNames);
3466 uint cs =
Sort.ArrayLength(sorts);
3467 uint cdn =
Symbol.ArrayLength(declNames);
3468 uint cd =
AST.ArrayLength(decls);
3469 if (csn != cs || cdn != cd)
3471 using ASTVector assertions =
new ASTVector(
this, Native.Z3_parse_smtlib2_string(nCtx, str,
3472 AST.ArrayLength(sorts),
Symbol.ArrayToNative(sortNames),
AST.ArrayToNative(sorts),
3473 AST.ArrayLength(decls),
Symbol.ArrayToNative(declNames),
AST.ArrayToNative(decls)));
3474 return assertions.ToBoolExprArray();
3484 uint csn =
Symbol.ArrayLength(sortNames);
3485 uint cs =
Sort.ArrayLength(sorts);
3486 uint cdn =
Symbol.ArrayLength(declNames);
3487 uint cd =
AST.ArrayLength(decls);
3488 if (csn != cs || cdn != cd)
3490 using ASTVector assertions =
new ASTVector(
this, Native.Z3_parse_smtlib2_file(nCtx, fileName,
3491 AST.ArrayLength(sorts),
Symbol.ArrayToNative(sortNames),
AST.ArrayToNative(sorts),
3492 AST.ArrayLength(decls),
Symbol.ArrayToNative(declNames),
AST.ArrayToNative(decls)));
3493 return assertions.ToBoolExprArray();
3508 Debug.Assert(assumptions !=
null);
3509 Debug.Assert(formula !=
null);
3511 return Native.Z3_benchmark_to_smtlib_string(
3517 (uint)(assumptions?.Length ?? 0),
3518 AST.ArrayToNative(assumptions),
3519 formula.NativeObject);
3534 public Goal MkGoal(
bool models =
true,
bool unsatCores =
false,
bool proofs =
false)
3537 return new Goal(
this, models, unsatCores, proofs);
3541 #region ParameterSets
3558 get {
return Native.Z3_get_num_tactics(nCtx); }
3570 string[] res =
new string[n];
3571 for (uint i = 0; i < n; i++)
3572 res[i] = Native.Z3_get_tactic_name(nCtx, i);
3583 return Native.Z3_tactic_get_descr(nCtx, name);
3592 return new Tactic(
this, name);
3601 Debug.Assert(t1 !=
null);
3602 Debug.Assert(t2 !=
null);
3606 CheckContextMatch(t1);
3607 CheckContextMatch(t2);
3608 CheckContextMatch<Tactic>(ts);
3610 IntPtr last = IntPtr.Zero;
3611 if (ts !=
null && ts.Length > 0)
3613 last = ts[ts.Length - 1].NativeObject;
3614 for (
int i = ts.Length - 2; i >= 0; i--)
3615 last = Native.Z3_tactic_and_then(nCtx, ts[i].NativeObject, last);
3617 if (last != IntPtr.Zero)
3619 last = Native.Z3_tactic_and_then(nCtx, t2.NativeObject, last);
3620 return new Tactic(
this, Native.Z3_tactic_and_then(nCtx, t1.NativeObject, last));
3623 return new Tactic(
this, Native.Z3_tactic_and_then(nCtx, t1.NativeObject, t2.NativeObject));
3635 Debug.Assert(t1 !=
null);
3636 Debug.Assert(t2 !=
null);
3648 Debug.Assert(t1 !=
null);
3649 Debug.Assert(t2 !=
null);
3651 CheckContextMatch(t1);
3652 CheckContextMatch(t2);
3653 return new Tactic(
this, Native.Z3_tactic_or_else(nCtx, t1.NativeObject, t2.NativeObject));
3664 Debug.Assert(t !=
null);
3666 CheckContextMatch(t);
3667 return new Tactic(
this, Native.Z3_tactic_try_for(nCtx, t.NativeObject, ms));
3679 Debug.Assert(p !=
null);
3680 Debug.Assert(t !=
null);
3682 CheckContextMatch(t);
3683 CheckContextMatch(p);
3684 return new Tactic(
this, Native.Z3_tactic_when(nCtx, p.NativeObject, t.NativeObject));
3693 Debug.Assert(p !=
null);
3694 Debug.Assert(t1 !=
null);
3695 Debug.Assert(t2 !=
null);
3697 CheckContextMatch(p);
3698 CheckContextMatch(t1);
3699 CheckContextMatch(t2);
3700 return new Tactic(
this, Native.Z3_tactic_cond(nCtx, p.NativeObject, t1.NativeObject, t2.NativeObject));
3709 Debug.Assert(t !=
null);
3711 CheckContextMatch(t);
3712 return new Tactic(
this, Native.Z3_tactic_repeat(nCtx, t.NativeObject, max));
3721 return new Tactic(
this, Native.Z3_tactic_skip(nCtx));
3730 return new Tactic(
this, Native.Z3_tactic_fail(nCtx));
3738 Debug.Assert(p !=
null);
3740 CheckContextMatch(p);
3741 return new Tactic(
this, Native.Z3_tactic_fail_if(nCtx, p.NativeObject));
3751 return new Tactic(
this, Native.Z3_tactic_fail_if_not_decided(nCtx));
3759 Debug.Assert(t !=
null);
3760 Debug.Assert(p !=
null);
3762 CheckContextMatch(t);
3763 CheckContextMatch(p);
3764 return new Tactic(
this, Native.Z3_tactic_using_params(nCtx, t.NativeObject, p.NativeObject));
3773 Debug.Assert(t !=
null);
3774 Debug.Assert(p !=
null);
3784 Debug.Assert(t ==
null || t.All(tactic => tactic !=
null));
3786 CheckContextMatch<Tactic>(t);
3787 return new Tactic(
this, Native.Z3_tactic_par_or(nCtx,
Tactic.ArrayLength(t),
Tactic.ArrayToNative(t)));
3796 Debug.Assert(t1 !=
null);
3797 Debug.Assert(t2 !=
null);
3799 CheckContextMatch(t1);
3800 CheckContextMatch(t2);
3801 return new Tactic(
this, Native.Z3_tactic_par_and_then(nCtx, t1.NativeObject, t2.NativeObject));
3810 Native.Z3_interrupt(nCtx);
3820 get {
return Native.Z3_get_num_simplifiers(nCtx); }
3832 string[] res =
new string[n];
3833 for (uint i = 0; i < n; i++)
3834 res[i] = Native.Z3_get_simplifier_name(nCtx, i);
3845 return Native.Z3_simplifier_get_descr(nCtx, name);
3863 Debug.Assert(t1 !=
null);
3864 Debug.Assert(t2 !=
null);
3868 CheckContextMatch(t1);
3869 CheckContextMatch(t2);
3870 CheckContextMatch<Simplifier>(ts);
3872 IntPtr last = IntPtr.Zero;
3873 if (ts !=
null && ts.Length > 0)
3875 last = ts[ts.Length - 1].NativeObject;
3876 for (
int i = ts.Length - 2; i >= 0; i--)
3877 last = Native.Z3_simplifier_and_then(nCtx, ts[i].NativeObject, last);
3879 if (last != IntPtr.Zero)
3881 last = Native.Z3_simplifier_and_then(nCtx, t2.NativeObject, last);
3882 return new Simplifier(
this, Native.Z3_simplifier_and_then(nCtx, t1.NativeObject, last));
3885 return new Simplifier(
this, Native.Z3_simplifier_and_then(nCtx, t1.NativeObject, t2.NativeObject));
3897 Debug.Assert(t1 !=
null);
3898 Debug.Assert(t2 !=
null);
3909 Debug.Assert(t !=
null);
3910 Debug.Assert(p !=
null);
3912 CheckContextMatch(t);
3913 CheckContextMatch(p);
3914 return new Simplifier(
this, Native.Z3_simplifier_using_params(nCtx, t.NativeObject, p.NativeObject));
3924 get {
return Native.Z3_get_num_probes(nCtx); }
3936 string[] res =
new string[n];
3937 for (uint i = 0; i < n; i++)
3938 res[i] = Native.Z3_get_probe_name(nCtx, i);
3949 return Native.Z3_probe_get_descr(nCtx, name);
3958 return new Probe(
this, name);
3967 return new Probe(
this, Native.Z3_probe_const(nCtx, val));
3976 Debug.Assert(p1 !=
null);
3977 Debug.Assert(p2 !=
null);
3979 CheckContextMatch(p1);
3980 CheckContextMatch(p2);
3981 return new Probe(
this, Native.Z3_probe_lt(nCtx, p1.NativeObject, p2.NativeObject));
3990 Debug.Assert(p1 !=
null);
3991 Debug.Assert(p2 !=
null);
3993 CheckContextMatch(p1);
3994 CheckContextMatch(p2);
3995 return new Probe(
this, Native.Z3_probe_gt(nCtx, p1.NativeObject, p2.NativeObject));
4004 Debug.Assert(p1 !=
null);
4005 Debug.Assert(p2 !=
null);
4007 CheckContextMatch(p1);
4008 CheckContextMatch(p2);
4009 return new Probe(
this, Native.Z3_probe_le(nCtx, p1.NativeObject, p2.NativeObject));
4018 Debug.Assert(p1 !=
null);
4019 Debug.Assert(p2 !=
null);
4021 CheckContextMatch(p1);
4022 CheckContextMatch(p2);
4023 return new Probe(
this, Native.Z3_probe_ge(nCtx, p1.NativeObject, p2.NativeObject));
4032 Debug.Assert(p1 !=
null);
4033 Debug.Assert(p2 !=
null);
4035 CheckContextMatch(p1);
4036 CheckContextMatch(p2);
4037 return new Probe(
this, Native.Z3_probe_eq(nCtx, p1.NativeObject, p2.NativeObject));
4046 Debug.Assert(p1 !=
null);
4047 Debug.Assert(p2 !=
null);
4049 CheckContextMatch(p1);
4050 CheckContextMatch(p2);
4051 return new Probe(
this, Native.Z3_probe_and(nCtx, p1.NativeObject, p2.NativeObject));
4060 Debug.Assert(p1 !=
null);
4061 Debug.Assert(p2 !=
null);
4063 CheckContextMatch(p1);
4064 CheckContextMatch(p2);
4065 return new Probe(
this, Native.Z3_probe_or(nCtx, p1.NativeObject, p2.NativeObject));
4074 Debug.Assert(p !=
null);
4076 CheckContextMatch(p);
4077 return new Probe(
this, Native.Z3_probe_not(nCtx, p.NativeObject));
4094 return new Solver(
this, Native.Z3_mk_solver(nCtx));
4096 return new Solver(
this, Native.Z3_mk_solver_for_logic(nCtx, logic.NativeObject));
4105 using var symbol =
MkSymbol(logic);
4115 return new Solver(
this, Native.Z3_mk_simple_solver(nCtx));
4124 Debug.Assert(s !=
null);
4125 return new Solver(
this, Native.Z3_solver_add_simplifier(nCtx, s.NativeObject, t.NativeObject));
4139 return new Solver(
this, Native.Z3_mk_solver_from_tactic(nCtx, t.NativeObject));
4156 #region Optimization
4167 #region Floating-Point Arithmetic
4169 #region Rounding Modes
4170 #region RoundingMode Sort
4186 return new FPRMExpr(
this, Native.Z3_mk_fpa_round_nearest_ties_to_even(nCtx));
4194 return new FPRMNum(
this, Native.Z3_mk_fpa_rne(nCtx));
4202 return new FPRMNum(
this, Native.Z3_mk_fpa_round_nearest_ties_to_away(nCtx));
4210 return new FPRMNum(
this, Native.Z3_mk_fpa_rna(nCtx));
4218 return new FPRMNum(
this, Native.Z3_mk_fpa_round_toward_positive(nCtx));
4226 return new FPRMNum(
this, Native.Z3_mk_fpa_rtp(nCtx));
4234 return new FPRMNum(
this, Native.Z3_mk_fpa_round_toward_negative(nCtx));
4242 return new FPRMNum(
this, Native.Z3_mk_fpa_rtn(nCtx));
4250 return new FPRMNum(
this, Native.Z3_mk_fpa_round_toward_zero(nCtx));
4258 return new FPRMNum(
this, Native.Z3_mk_fpa_rtz(nCtx));
4263 #region FloatingPoint Sorts
4271 return new FPSort(
this, ebits, sbits);
4279 return new FPSort(
this, Native.Z3_mk_fpa_sort_half(nCtx));
4287 return new FPSort(
this, Native.Z3_mk_fpa_sort_16(nCtx));
4295 return new FPSort(
this, Native.Z3_mk_fpa_sort_single(nCtx));
4303 return new FPSort(
this, Native.Z3_mk_fpa_sort_32(nCtx));
4311 return new FPSort(
this, Native.Z3_mk_fpa_sort_double(nCtx));
4319 return new FPSort(
this, Native.Z3_mk_fpa_sort_64(nCtx));
4327 return new FPSort(
this, Native.Z3_mk_fpa_sort_quadruple(nCtx));
4335 return new FPSort(
this, Native.Z3_mk_fpa_sort_128(nCtx));
4346 return new FPNum(
this, Native.Z3_mk_fpa_nan(nCtx, s.NativeObject));
4356 return new FPNum(
this, Native.Z3_mk_fpa_inf(nCtx, s.NativeObject, (
byte)(negative ? 1 : 0)));
4366 return new FPNum(
this, Native.Z3_mk_fpa_zero(nCtx, s.NativeObject, (
byte)(negative ? 1 : 0)));
4376 return new FPNum(
this, Native.Z3_mk_fpa_numeral_float(nCtx, v, s.NativeObject));
4386 return new FPNum(
this, Native.Z3_mk_fpa_numeral_double(nCtx, v, s.NativeObject));
4396 return new FPNum(
this, Native.Z3_mk_fpa_numeral_int(nCtx, v, s.NativeObject));
4408 return new FPNum(
this, Native.Z3_mk_fpa_numeral_int_uint(nCtx, (
byte)(sgn ? 1 : 0), exp, sig, s.NativeObject));
4420 return new FPNum(
this, Native.Z3_mk_fpa_numeral_int64_uint64(nCtx, (
byte)(sgn ? 1 : 0), exp, sig, s.NativeObject));
4486 return new FPExpr(
this, Native.Z3_mk_fpa_abs(
this.nCtx, t.NativeObject));
4495 return new FPExpr(
this, Native.Z3_mk_fpa_neg(
this.nCtx, t.NativeObject));
4506 return new FPExpr(
this, Native.Z3_mk_fpa_add(
this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
4517 return new FPExpr(
this, Native.Z3_mk_fpa_sub(
this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
4528 return new FPExpr(
this, Native.Z3_mk_fpa_mul(
this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
4539 return new FPExpr(
this, Native.Z3_mk_fpa_div(
this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
4554 return new FPExpr(
this, Native.Z3_mk_fpa_fma(
this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject, t3.NativeObject));
4564 return new FPExpr(
this, Native.Z3_mk_fpa_sqrt(
this.nCtx, rm.NativeObject, t.NativeObject));
4574 return new FPExpr(
this, Native.Z3_mk_fpa_rem(
this.nCtx, t1.NativeObject, t2.NativeObject));
4585 return new FPExpr(
this, Native.Z3_mk_fpa_round_to_integral(
this.nCtx, rm.NativeObject, t.NativeObject));
4595 return new FPExpr(
this, Native.Z3_mk_fpa_min(
this.nCtx, t1.NativeObject, t2.NativeObject));
4605 return new FPExpr(
this, Native.Z3_mk_fpa_max(
this.nCtx, t1.NativeObject, t2.NativeObject));
4615 return new BoolExpr(
this, Native.Z3_mk_fpa_leq(
this.nCtx, t1.NativeObject, t2.NativeObject));
4625 return new BoolExpr(
this, Native.Z3_mk_fpa_lt(
this.nCtx, t1.NativeObject, t2.NativeObject));
4635 return new BoolExpr(
this, Native.Z3_mk_fpa_geq(
this.nCtx, t1.NativeObject, t2.NativeObject));
4645 return new BoolExpr(
this, Native.Z3_mk_fpa_gt(
this.nCtx, t1.NativeObject, t2.NativeObject));
4658 return new BoolExpr(
this, Native.Z3_mk_fpa_eq(
this.nCtx, t1.NativeObject, t2.NativeObject));
4667 return new BoolExpr(
this, Native.Z3_mk_fpa_is_normal(
this.nCtx, t.NativeObject));
4676 return new BoolExpr(
this, Native.Z3_mk_fpa_is_subnormal(
this.nCtx, t.NativeObject));
4685 return new BoolExpr(
this, Native.Z3_mk_fpa_is_zero(
this.nCtx, t.NativeObject));
4694 return new BoolExpr(
this, Native.Z3_mk_fpa_is_infinite(
this.nCtx, t.NativeObject));
4703 return new BoolExpr(
this, Native.Z3_mk_fpa_is_nan(
this.nCtx, t.NativeObject));
4712 return new BoolExpr(
this, Native.Z3_mk_fpa_is_negative(
this.nCtx, t.NativeObject));
4721 return new BoolExpr(
this, Native.Z3_mk_fpa_is_positive(
this.nCtx, t.NativeObject));
4725 #region Conversions to FloatingPoint terms
4741 return new FPExpr(
this, Native.Z3_mk_fpa_fp(
this.nCtx, sgn.NativeObject, sig.NativeObject, exp.NativeObject));
4757 return new FPExpr(
this, Native.Z3_mk_fpa_to_fp_bv(
this.nCtx, bv.NativeObject, s.NativeObject));
4773 return new FPExpr(
this, Native.Z3_mk_fpa_to_fp_float(
this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
4789 return new FPExpr(
this, Native.Z3_mk_fpa_to_fp_real(
this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
4808 return new FPExpr(
this, Native.Z3_mk_fpa_to_fp_signed(
this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
4810 return new FPExpr(
this, Native.Z3_mk_fpa_to_fp_unsigned(
this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
4825 return new FPExpr(
this, Native.Z3_mk_fpa_to_fp_float(
this.nCtx, s.NativeObject, rm.NativeObject, t.NativeObject));
4829 #region Conversions from FloatingPoint terms
4845 return new BitVecExpr(
this, Native.Z3_mk_fpa_to_sbv(
this.nCtx, rm.NativeObject, t.NativeObject, sz));
4847 return new BitVecExpr(
this, Native.Z3_mk_fpa_to_ubv(
this.nCtx, rm.NativeObject, t.NativeObject, sz));
4861 return new RealExpr(
this, Native.Z3_mk_fpa_to_real(
this.nCtx, t.NativeObject));
4865 #region Z3-specific extensions
4878 return new BitVecExpr(
this, Native.Z3_mk_fpa_to_ieee_bv(
this.nCtx, t.NativeObject));
4895 return new BitVecExpr(
this, Native.Z3_mk_fpa_to_fp_int_real(
this.nCtx, rm.NativeObject, exp.NativeObject, sig.NativeObject, s.NativeObject));
4900 #region Miscellaneous
4913 return AST.Create(
this, nativeObject);
4929 return a.NativeObject;
4939 return new FuncDecl(
this, Native.Z3_mk_partial_order(
this.nCtx, a.NativeObject, index));
4949 return new FuncDecl(
this, Native.Z3_mk_transitive_closure(
this.nCtx, f.NativeObject));
4964 CheckContextMatch(p);
4965 CheckContextMatch(q);
4966 CheckContextMatch(x);
4967 return new ASTVector(
this, Native.Z3_polynomial_subresultants(
this.nCtx, p.NativeObject, q.NativeObject, x.NativeObject));
4976 return Native.Z3_simplify_get_help(nCtx);
4984 get {
return new ParamDescrs(
this, Native.Z3_simplify_get_param_descrs(nCtx)); }
4988 #region Error Handling
5016 Native.Z3_update_param_value(nCtx,
id, value);
5022 internal IntPtr m_ctx = IntPtr.Zero;
5023 internal Native.Z3_error_handler m_n_err_handler =
null;
5024 internal static Object creation_lock =
new Object();
5025 internal IntPtr nCtx {
get {
return m_ctx; } }
5028 internal void NativeErrorHandler(IntPtr ctx,
Z3_error_code errorCode)
5033 internal void InitContext()
5036 m_n_err_handler =
new Native.Z3_error_handler(NativeErrorHandler);
5037 Native.Z3_set_error_handler(m_ctx, m_n_err_handler);
5040 internal void CheckContextMatch(Z3Object other)
5042 Debug.Assert(other !=
null);
5044 if (!ReferenceEquals(
this, other.Context))
5045 throw new Z3Exception(
"Context mismatch");
5048 internal void CheckContextMatch(Z3Object other1, Z3Object other2)
5050 Debug.Assert(other1 !=
null);
5051 Debug.Assert(other2 !=
null);
5052 CheckContextMatch(other1);
5053 CheckContextMatch(other2);
5056 internal void CheckContextMatch(Z3Object other1, Z3Object other2, Z3Object other3)
5058 Debug.Assert(other1 !=
null);
5059 Debug.Assert(other2 !=
null);
5060 Debug.Assert(other3 !=
null);
5061 CheckContextMatch(other1);
5062 CheckContextMatch(other2);
5063 CheckContextMatch(other3);
5066 internal void CheckContextMatch(Z3Object[] arr)
5068 Debug.Assert(arr ==
null || arr.All(a => a !=
null));
5072 foreach (Z3Object a
in arr)
5074 Debug.Assert(a !=
null);
5075 CheckContextMatch(a);
5080 internal void CheckContextMatch<T>(IEnumerable<T> arr) where T : Z3Object
5082 Debug.Assert(arr ==
null || arr.All(a => a !=
null));
5086 foreach (Z3Object a
in arr)
5088 Debug.Assert(a !=
null);
5089 CheckContextMatch(a);
5094 private void ObjectInvariant()
5115 if (m_boolSort !=
null) m_boolSort.Dispose();
5116 if (m_intSort !=
null) m_intSort.Dispose();
5117 if (m_realSort !=
null) m_realSort.Dispose();
5118 if (m_stringSort !=
null) m_stringSort.Dispose();
5119 if (m_charSort !=
null) m_charSort.Dispose();
5123 m_stringSort =
null;
5125 if (m_ctx != IntPtr.Zero)
5130 m_n_err_handler =
null;
5131 m_ctx = IntPtr.Zero;
5134 Native.Z3_del_context(ctx);
5137 GC.SuppressFinalize(
this);
The abstract syntax tree (AST) class.
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.
ArithExpr MkAdd(IEnumerable< ArithExpr > ts)
Create an expression representing t[0] + t[1] + ....
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.
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.
Simplifier Then(Simplifier t1, Simplifier t2, params Simplifier[] ts)
Create a simplifier that applies t1 and then then t2 .
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.
ArithExpr MkAdd(params ArithExpr[] ts)
Create an expression representing t[0] + t[1] + ....
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.
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 .
BoolExpr MkOr(params BoolExpr[] ts)
Create an expression representing t[0] or t[1] or ....
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.
FuncDecl MkPartialOrder(Sort a, uint index)
Create a partial order relation over a sort.
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.
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.
Simplifier UsingParams(Simplifier t, Params p)
Create a tactic that applies t using the given set of parameters p .
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.
string BenchmarkToSmtlibString(string name, string logic, string status, string attributes, BoolExpr[] assumptions, BoolExpr formula)
Convert a benchmark into SMT-LIB2 formatted string.
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 .
string[] SimplifierNames
The names of all supported tactics.
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.
BoolExpr MkXor(IEnumerable< BoolExpr > args)
Create an expression representing t1 xor t2 xor t3 ... .
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.
ReExpr MkEmptyRe(Sort s)
Create the empty regular expression. The sort s should be a regular expression.
FuncDecl MkTransitiveClosure(FuncDecl f)
Create the transitive closure of a binary relation.
Expr MkNth(SeqExpr s, Expr index)
Retrieve element at index.
Expr MkSeqMap(Expr f, SeqExpr s)
Map function f over the sequence s.
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.
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.
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).
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.
Expr MkSeqMapi(Expr f, Expr i, SeqExpr s)
Map function f over the sequence s at index i.
void UpdateParamValue(string id, string value)
Update a mutable configuration parameter.
DatatypeSort MkDatatypeSort(Symbol name, Constructor[] constructors)
Create a new datatype sort.
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.
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.
ArithExpr MkMul(IEnumerable< ArithExpr > ts)
Create an expression representing t[0] * t[1] * ....
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.
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.
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.
uint NumSimplifiers
The number of supported simplifiers.
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 .
BoolExpr MkAnd(params BoolExpr[] ts)
Create an expression representing t[0] and t[1] and ....
RealSort RealSort
Retrieves the Real sort of the context.
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
ASTVector PolynomialSubresultants(Expr p, Expr q, Expr x)
Return the nonzero subresultants of p and q with respect to the "variable" x.
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.
Expr MkSeqFoldLeft(Expr f, Expr a, SeqExpr s)
Fold left the function f over the sequence s with initial value a.
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.
string SimplifierDescription(string name)
Returns a string containing a description of the simplifier with the given name.
FPRMNum MkFPRoundTowardZero()
Create a numeral of RoundingMode sort which represents the RoundTowardZero rounding mode.
ArithExpr MkSub(params ArithExpr[] ts)
Create an expression representing t[0] - t[1] - ....
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 .
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...
DatatypeSort MkDatatypeSortRef(string name, Sort[] parameters=null)
Create a forward reference to a datatype sort. This is useful for creating recursive datatypes or par...
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.
Simplifier MkSimplifier(string name)
Creates a new Tactic.
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 ....
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.
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.
DatatypeSort MkDatatypeSortRef(Symbol name, Sort[] parameters=null)
Create a forward reference to a datatype sort. This is useful for creating recursive datatypes or par...
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.
SetSort MkSetSort(Sort ty)
Create a set type.
EnumSort MkEnumSort(string name, params string[] enumNames)
Create a new enumeration sort.
Simplifier AndThen(Simplifier t1, Simplifier t2, params Simplifier[] ts)
Create a simplifier that applies t1 and then t2 .
BitVecNum MkBV(int v, uint size)
Create a bit-vector numeral.
RatNum MkReal(int num, int den)
Create a real from a fraction.
EnumSort MkEnumSort(Symbol name, params Symbol[] enumNames)
Create a new enumeration sort.
Solver MkSolver(Solver s, Simplifier t)
Creates a solver that uses an incremental simplifier.
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.
BoolExpr MkOr(IEnumerable< BoolExpr > ts)
Create an expression representing t[0] or t[1] or ....
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.
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.
ReExpr MkComplement(ReExpr re)
Create the complement regular expression.
BitVecExpr MkExtract(uint high, uint low, BitVecExpr t)
Bit-vector extraction.
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.
Expr MkSeqFoldLeftI(Expr f, Expr i, Expr a, SeqExpr s)
Fold left with index the function f over the sequence s with initial value a starting at index i.
ArithExpr MkMul(params ArithExpr[] ts)
Create an expression representing t[0] * t[1] * ....
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.
Simplifiers are the basic building block for creating custom solvers with incremental pre-processing....
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).