Z3
Context.cs
Go to the documentation of this file.
1/*++
2Copyright (c) 2012 Microsoft Corporation
3
4Module Name:
5
6 Context.cs
7
8Abstract:
9
10 Z3 Managed API: Context
11
12Author:
13
14 Christoph Wintersteiger (cwinter) 2012-03-15
15
16Notes:
17
18--*/
19
20using System;
21using System.Collections.Generic;
22using System.Diagnostics;
23using System.Linq;
24using System.Runtime.InteropServices;
25
26namespace Microsoft.Z3
27{
28
29 using Z3_context = System.IntPtr;
33 public class Context : IDisposable
34 {
35 #region Constructors
39 public Context()
40 : base()
41 {
42 lock (creation_lock)
43 {
44 m_ctx = Native.Z3_mk_context_rc(IntPtr.Zero);
45 InitContext();
46 }
47 }
48
67 public Context(Dictionary<string, string> settings)
68 : base()
69 {
70 Debug.Assert(settings != null);
71
72 lock (creation_lock)
73 {
74 IntPtr cfg = Native.Z3_mk_config();
75 foreach (KeyValuePair<string, string> kv in settings)
76 Native.Z3_set_param_value(cfg, kv.Key, kv.Value);
77 m_ctx = Native.Z3_mk_context_rc(cfg);
78 Native.Z3_del_config(cfg);
79 InitContext();
80 }
81 }
82
86 internal Context(Z3_context ctx)
87 : base()
88 {
89 lock (creation_lock)
90 {
91 is_external = true;
92 m_ctx = ctx;
93 InitContext();
94 }
95 }
96
97 bool is_external = false;
98
99 #endregion
100
101 #region Symbols
109 public IntSymbol MkSymbol(int i)
110 {
111 return new IntSymbol(this, i);
112 }
113
117 public StringSymbol MkSymbol(string name)
118 {
119 return new StringSymbol(this, name);
120 }
121
125 internal Symbol[] MkSymbols(string[] names)
126 {
127 if (names == null) return new Symbol[0];
128 Symbol[] result = new Symbol[names.Length];
129 for (int i = 0; i < names.Length; ++i) result[i] = MkSymbol(names[i]);
130 return result;
131 }
132 #endregion
133
134 #region Sorts
135 private BoolSort m_boolSort = null;
136 private IntSort m_intSort = null;
137 private RealSort m_realSort = null;
138 private SeqSort m_stringSort = null;
139 private CharSort m_charSort = null;
140
145 {
146 get
147 {
148 if (m_boolSort == null) m_boolSort = new BoolSort(this); return m_boolSort;
149 }
150 }
151
156 {
157 get
158 {
159 if (m_intSort == null) m_intSort = new IntSort(this); return m_intSort;
160 }
161 }
162
163
168 {
169 get
170 {
171 if (m_realSort == null) m_realSort = new RealSort(this); return m_realSort;
172 }
173 }
174
179 {
180 get
181 {
182 if (m_charSort == null) m_charSort = new CharSort(this); return m_charSort;
183 }
184 }
185
186
191 {
192 get
193 {
194 if (m_stringSort == null) m_stringSort = new SeqSort(this, Native.Z3_mk_string_sort(nCtx));
195 return m_stringSort;
196 }
197 }
198
199
204 {
205 return new BoolSort(this);
206 }
207
212 {
213 Debug.Assert(s != null);
214
215 CheckContextMatch(s);
216 return new UninterpretedSort(this, s);
217 }
218
223 {
224 using var sym = MkSymbol(str);
225 return MkUninterpretedSort(sym);
226 }
227
232 {
233
234 return new IntSort(this);
235 }
236
241 {
242 return new RealSort(this);
243 }
244
248 public BitVecSort MkBitVecSort(uint size)
249 {
250 return new BitVecSort(this, Native.Z3_mk_bv_sort(nCtx, size));
251 }
252
257 {
258 Debug.Assert(s != null);
259 return new SeqSort(this, Native.Z3_mk_seq_sort(nCtx, s.NativeObject));
260 }
261
266 {
267 Debug.Assert(s != null);
268 return new ReSort(this, Native.Z3_mk_re_sort(nCtx, s.NativeObject));
269 }
270
275 {
276 Debug.Assert(domain != null);
277 Debug.Assert(range != null);
278
279 CheckContextMatch(domain);
280 CheckContextMatch(range);
281 return new ArraySort(this, domain, range);
282 }
283
288 {
289 Debug.Assert(domain != null);
290 Debug.Assert(range != null);
291
292 CheckContextMatch<Sort>(domain);
293 CheckContextMatch(range);
294 return new ArraySort(this, domain, range);
295 }
296
300 public TupleSort MkTupleSort(Symbol name, Symbol[] fieldNames, Sort[] fieldSorts)
301 {
302 Debug.Assert(name != null);
303 Debug.Assert(fieldNames != null);
304 Debug.Assert(fieldNames.All(fn => fn != null));
305 Debug.Assert(fieldSorts == null || fieldSorts.All(fs => fs != null));
306
307 CheckContextMatch(name);
308 CheckContextMatch<Symbol>(fieldNames);
309 CheckContextMatch<Sort>(fieldSorts);
310 return new TupleSort(this, name, (uint)fieldNames.Length, fieldNames, fieldSorts);
311 }
312
316 public EnumSort MkEnumSort(Symbol name, params Symbol[] enumNames)
317 {
318 Debug.Assert(name != null);
319 Debug.Assert(enumNames != null);
320 Debug.Assert(enumNames.All(f => f != null));
321
322
323 CheckContextMatch(name);
324 CheckContextMatch<Symbol>(enumNames);
325 return new EnumSort(this, name, enumNames);
326 }
327
331 public EnumSort MkEnumSort(string name, params string[] enumNames)
332 {
333 Debug.Assert(enumNames != null);
334
335 var enumSymbols = MkSymbols(enumNames);
336 try
337 {
338 using var symbol = MkSymbol(name);
339 return new EnumSort(this, symbol, enumSymbols);
340 }
341 finally
342 {
343 foreach (var enumSymbol in enumSymbols)
344 enumSymbol.Dispose();
345 }
346 }
347
351 public ListSort MkListSort(Symbol name, Sort elemSort)
352 {
353 Debug.Assert(name != null);
354 Debug.Assert(elemSort != null);
355
356 CheckContextMatch(name);
357 CheckContextMatch(elemSort);
358 return new ListSort(this, name, elemSort);
359 }
360
364 public ListSort MkListSort(string name, Sort elemSort)
365 {
366 Debug.Assert(elemSort != null);
367
368 CheckContextMatch(elemSort);
369 using var symbol = MkSymbol(name);
370 return new ListSort(this, symbol, elemSort);
371 }
372
380 {
381 Debug.Assert(name != null);
382
383 CheckContextMatch(name);
384 return new FiniteDomainSort(this, name, size);
385 }
386
395 public FiniteDomainSort MkFiniteDomainSort(string name, ulong size)
396 {
397 using var symbol = MkSymbol(name);
398 return new FiniteDomainSort(this, symbol, size);
399 }
400
401
402 #region Datatypes
413 public Constructor MkConstructor(Symbol name, Symbol recognizer, Symbol[] fieldNames = null, Sort[] sorts = null, uint[] sortRefs = null)
414 {
415 Debug.Assert(name != null);
416 Debug.Assert(recognizer != null);
417
418 return new Constructor(this, name, recognizer, fieldNames, sorts, sortRefs);
419 }
420
430 public Constructor MkConstructor(string name, string recognizer, string[] fieldNames = null, Sort[] sorts = null, uint[] sortRefs = null)
431 {
432
433 using var nameSymbol = MkSymbol(name);
434 using var recognizerSymbol = MkSymbol(recognizer);
435 var fieldSymbols = MkSymbols(fieldNames);
436 try
437 {
438 return new Constructor(this, nameSymbol, recognizerSymbol, fieldSymbols, sorts, sortRefs);
439 }
440 finally
441 {
442 foreach (var fieldSymbol in fieldSymbols)
443 fieldSymbol.Dispose();
444 }
445 }
446
450 public DatatypeSort MkDatatypeSort(Symbol name, Constructor[] constructors)
451 {
452 Debug.Assert(name != null);
453 Debug.Assert(constructors != null);
454 Debug.Assert(constructors.All(c => c != null));
455
456
457 CheckContextMatch(name);
458 CheckContextMatch<Constructor>(constructors);
459 return new DatatypeSort(this, name, constructors);
460 }
461
465 public DatatypeSort MkDatatypeSort(string name, Constructor[] constructors)
466 {
467 Debug.Assert(constructors != null);
468 Debug.Assert(constructors.All(c => c != null));
469
470 CheckContextMatch<Constructor>(constructors);
471 using var symbol = MkSymbol(name);
472 return new DatatypeSort(this, symbol, constructors);
473 }
474
481 {
482 Debug.Assert(names != null);
483 Debug.Assert(c != null);
484 Debug.Assert(names.Length == c.Length);
485 //Debug.Assert(Contract.ForAll(0, c.Length, j => c[j] != null));
486 Debug.Assert(names.All(name => name != null));
487
488 CheckContextMatch<Symbol>(names);
489 uint n = (uint)names.Length;
490 ConstructorList[] cla = new ConstructorList[n];
491 IntPtr[] n_constr = new IntPtr[n];
492 for (uint i = 0; i < n; i++)
493 {
494 Constructor[] constructor = c[i];
495 CheckContextMatch<Constructor>(constructor);
496 cla[i] = new ConstructorList(this, constructor);
497 n_constr[i] = cla[i].NativeObject;
498 }
499 IntPtr[] n_res = new IntPtr[n];
500 Native.Z3_mk_datatypes(nCtx, n, Symbol.ArrayToNative(names), n_res, n_constr);
501 DatatypeSort[] res = new DatatypeSort[n];
502 for (uint i = 0; i < n; i++)
503 res[i] = new DatatypeSort(this, n_res[i]);
504 return res;
505 }
506
513 public DatatypeSort[] MkDatatypeSorts(string[] names, Constructor[][] c)
514 {
515 Debug.Assert(names != null);
516 Debug.Assert(c != null);
517 Debug.Assert(names.Length == c.Length);
518 //Debug.Assert(Contract.ForAll(0, c.Length, j => c[j] != null));
519 //Debug.Assert(names.All(name => name != null));
520
521 var symbols = MkSymbols(names);
522 try
523 {
524 return MkDatatypeSorts(symbols, c);
525 }
526 finally
527 {
528 foreach (var symbol in symbols)
529 symbol.Dispose();
530 }
531 }
532
539 public Expr MkUpdateField(FuncDecl field, Expr t, Expr v)
540 {
541 return Expr.Create(this, Native.Z3_datatype_update_field(
542 nCtx, field.NativeObject,
543 t.NativeObject, v.NativeObject));
544 }
545
546 #endregion
547 #endregion
548
549 #region Function Declarations
553 public FuncDecl MkFuncDecl(Symbol name, Sort[] domain, Sort range)
554 {
555 Debug.Assert(name != null);
556 Debug.Assert(range != null);
557 Debug.Assert(domain.All(d => d != null));
558
559 CheckContextMatch(name);
560 CheckContextMatch<Sort>(domain);
561 CheckContextMatch(range);
562 return new FuncDecl(this, name, domain, range);
563 }
564
568 public FuncDecl MkFuncDecl(Symbol name, Sort domain, Sort range)
569 {
570 Debug.Assert(name != null);
571 Debug.Assert(domain != null);
572 Debug.Assert(range != null);
573
574 CheckContextMatch(name);
575 CheckContextMatch(domain);
576 CheckContextMatch(range);
577 Sort[] q = new Sort[] { domain };
578 return new FuncDecl(this, name, q, range);
579 }
580
584 public FuncDecl MkFuncDecl(string name, Sort[] domain, Sort range)
585 {
586 Debug.Assert(range != null);
587 Debug.Assert(domain.All(d => d != null));
588
589 CheckContextMatch<Sort>(domain);
590 CheckContextMatch(range);
591 using var symbol = MkSymbol(name);
592 return new FuncDecl(this, symbol, domain, range);
593 }
594
598 public FuncDecl MkRecFuncDecl(string name, Sort[] domain, Sort range)
599 {
600 Debug.Assert(range != null);
601 Debug.Assert(domain.All(d => d != null));
602
603 CheckContextMatch<Sort>(domain);
604 CheckContextMatch(range);
605 using var symbol = MkSymbol(name);
606 return new FuncDecl(this, symbol, domain, range, true);
607 }
608
615 public void AddRecDef(FuncDecl f, Expr[] args, Expr body)
616 {
617 CheckContextMatch(f);
618 CheckContextMatch<Expr>(args);
619 CheckContextMatch(body);
620 IntPtr[] argsNative = AST.ArrayToNative(args);
621 Native.Z3_add_rec_def(nCtx, f.NativeObject, (uint)args.Length, argsNative, body.NativeObject);
622 }
623
627 public FuncDecl MkFuncDecl(string name, Sort domain, Sort range)
628 {
629 Debug.Assert(range != null);
630 Debug.Assert(domain != null);
631
632 CheckContextMatch(domain);
633 CheckContextMatch(range);
634 using var symbol = MkSymbol(name);
635 Sort[] q = new Sort[] { domain };
636 return new FuncDecl(this, symbol, q, range);
637 }
638
644 public FuncDecl MkFreshFuncDecl(string prefix, Sort[] domain, Sort range)
645 {
646 Debug.Assert(range != null);
647 Debug.Assert(domain.All(d => d != null));
648
649 CheckContextMatch<Sort>(domain);
650 CheckContextMatch(range);
651 return new FuncDecl(this, prefix, domain, range);
652 }
653
658 {
659 Debug.Assert(name != null);
660 Debug.Assert(range != null);
661
662 CheckContextMatch(name);
663 CheckContextMatch(range);
664 return new FuncDecl(this, name, null, range);
665 }
666
670 public FuncDecl MkConstDecl(string name, Sort range)
671 {
672 Debug.Assert(range != null);
673
674 CheckContextMatch(range);
675 using var symbol = MkSymbol(name);
676 return new FuncDecl(this, symbol, null, range);
677 }
678
684 public FuncDecl MkFreshConstDecl(string prefix, Sort range)
685 {
686 Debug.Assert(range != null);
687
688 CheckContextMatch(range);
689 return new FuncDecl(this, prefix, null, range);
690 }
691
695 public FuncDecl MkUserPropagatorFuncDecl(string name, Sort[] domain, Sort range)
696 {
697 using var _name = MkSymbol(name);
698 var fn = Native.Z3_solver_propagate_declare(nCtx, _name.NativeObject, AST.ArrayLength(domain), AST.ArrayToNative(domain), range.NativeObject);
699 return new FuncDecl(this, fn);
700 }
701 #endregion
702
703 #region Bound Variables
709 public Expr MkBound(uint index, Sort ty)
710 {
711 Debug.Assert(ty != null);
712
713 return Expr.Create(this, Native.Z3_mk_bound(nCtx, index, ty.NativeObject));
714 }
715 #endregion
716
717 #region Quantifier Patterns
721 public Pattern MkPattern(params Expr[] terms)
722 {
723 Debug.Assert(terms != null);
724 if (terms.Length == 0)
725 throw new Z3Exception("Cannot create a pattern from zero terms");
726
727 IntPtr[] termsNative = AST.ArrayToNative(terms);
728 return new Pattern(this, Native.Z3_mk_pattern(nCtx, (uint)terms.Length, termsNative));
729 }
730 #endregion
731
732 #region Constants
737 {
738 Debug.Assert(name != null);
739 Debug.Assert(range != null);
740
741 CheckContextMatch(name);
742 CheckContextMatch(range);
743
744 return Expr.Create(this, Native.Z3_mk_const(nCtx, name.NativeObject, range.NativeObject));
745 }
746
750 public Expr MkConst(string name, Sort range)
751 {
752 Debug.Assert(range != null);
753
754 using var symbol = MkSymbol(name);
755 return MkConst(symbol, range);
756 }
757
762 public Expr MkFreshConst(string prefix, Sort range)
763 {
764 Debug.Assert(range != null);
765
766 CheckContextMatch(range);
767 return Expr.Create(this, Native.Z3_mk_fresh_const(nCtx, prefix, range.NativeObject));
768 }
769
775 {
776 Debug.Assert(f != null);
777
778 return MkApp(f);
779 }
780
785 {
786 Debug.Assert(name != null);
787
788 return (BoolExpr)MkConst(name, BoolSort);
789 }
790
794 public BoolExpr MkBoolConst(string name)
795 {
796 using var symbol = MkSymbol(name);
797 return (BoolExpr)MkConst(symbol, BoolSort);
798 }
799
804 {
805 Debug.Assert(name != null);
806
807 return (IntExpr)MkConst(name, IntSort);
808 }
809
813 public IntExpr MkIntConst(string name)
814 {
815 Debug.Assert(name != null);
816
817 return (IntExpr)MkConst(name, IntSort);
818 }
819
824 {
825 Debug.Assert(name != null);
826
827 return (RealExpr)MkConst(name, RealSort);
828 }
829
833 public RealExpr MkRealConst(string name)
834 {
835
836 return (RealExpr)MkConst(name, RealSort);
837 }
838
842 public BitVecExpr MkBVConst(Symbol name, uint size)
843 {
844 Debug.Assert(name != null);
845
846 using var sort = MkBitVecSort(size);
847 return (BitVecExpr)MkConst(name, sort);
848 }
849
853 public BitVecExpr MkBVConst(string name, uint size)
854 {
855 using var sort = MkBitVecSort(size);
856 return (BitVecExpr)MkConst(name, sort);
857 }
858 #endregion
859
860 #region Terms
864 public Expr MkApp(FuncDecl f, params Expr[] args)
865 {
866 Debug.Assert(f != null);
867 Debug.Assert(args == null || args.All(a => a != null));
868
869 CheckContextMatch(f);
870 CheckContextMatch<Expr>(args);
871 return Expr.Create(this, f, args);
872 }
873
877 public Expr MkApp(FuncDecl f, IEnumerable<Expr> args)
878 {
879 Debug.Assert(f != null);
880 Debug.Assert(args == null || args.All(a => a != null));
881
882 CheckContextMatch(f);
883 CheckContextMatch(args);
884 return Expr.Create(this, f, args.ToArray());
885 }
886
887 #region Propositional
892 {
893
894 return new BoolExpr(this, Native.Z3_mk_true(nCtx));
895 }
896
901 {
902
903 return new BoolExpr(this, Native.Z3_mk_false(nCtx));
904 }
905
909 public BoolExpr MkBool(bool value)
910 {
911
912 return value ? MkTrue() : MkFalse();
913 }
914
918 public BoolExpr MkEq(Expr x, Expr y)
919 {
920 Debug.Assert(x != null);
921 Debug.Assert(y != null);
922
923 CheckContextMatch(x);
924 CheckContextMatch(y);
925 return new BoolExpr(this, Native.Z3_mk_eq(nCtx, x.NativeObject, y.NativeObject));
926 }
927
931 public BoolExpr MkDistinct(params Expr[] args)
932 {
933 Debug.Assert(args != null);
934 Debug.Assert(args.All(a => a != null));
935
936
937 CheckContextMatch<Expr>(args);
938 return new BoolExpr(this, Native.Z3_mk_distinct(nCtx, (uint)args.Length, AST.ArrayToNative(args)));
939 }
940
944 public BoolExpr MkDistinct(IEnumerable<Expr> args)
945 {
946 Debug.Assert(args != null);
947 return MkDistinct(args.ToArray());
948 }
949
954 {
955 Debug.Assert(a != null);
956
957 CheckContextMatch(a);
958 return new BoolExpr(this, Native.Z3_mk_not(nCtx, a.NativeObject));
959 }
960
967 public Expr MkITE(BoolExpr t1, Expr t2, Expr t3)
968 {
969 Debug.Assert(t1 != null);
970 Debug.Assert(t2 != null);
971 Debug.Assert(t3 != null);
972
973 CheckContextMatch(t1);
974 CheckContextMatch(t2);
975 CheckContextMatch(t3);
976 return Expr.Create(this, Native.Z3_mk_ite(nCtx, t1.NativeObject, t2.NativeObject, t3.NativeObject));
977 }
978
983 {
984 Debug.Assert(t1 != null);
985 Debug.Assert(t2 != null);
986
987 CheckContextMatch(t1);
988 CheckContextMatch(t2);
989 return new BoolExpr(this, Native.Z3_mk_iff(nCtx, t1.NativeObject, t2.NativeObject));
990 }
991
996 {
997 Debug.Assert(t1 != null);
998 Debug.Assert(t2 != null);
999
1000 CheckContextMatch(t1);
1001 CheckContextMatch(t2);
1002 return new BoolExpr(this, Native.Z3_mk_implies(nCtx, t1.NativeObject, t2.NativeObject));
1003 }
1004
1009 {
1010 Debug.Assert(t1 != null);
1011 Debug.Assert(t2 != null);
1012
1013 CheckContextMatch(t1);
1014 CheckContextMatch(t2);
1015 return new BoolExpr(this, Native.Z3_mk_xor(nCtx, t1.NativeObject, t2.NativeObject));
1016 }
1017
1021 public BoolExpr MkXor(IEnumerable<BoolExpr> ts)
1022 {
1023 Debug.Assert(ts != null);
1024 Debug.Assert(ts.All(a => a != null));
1025 CheckContextMatch<BoolExpr>(ts);
1026
1027 return ts.Aggregate(MkFalse(), (r, t) =>
1028 {
1029 using (r)
1030 return MkXor(r, t);
1031 });
1032 }
1033
1037 public BoolExpr MkAnd(params BoolExpr[] t)
1038 {
1039 Debug.Assert(t != null);
1040 Debug.Assert(t.All(a => a != null));
1041
1042 CheckContextMatch<BoolExpr>(t);
1043 return new BoolExpr(this, Native.Z3_mk_and(nCtx, (uint)t.Length, AST.ArrayToNative(t)));
1044 }
1045
1049 public BoolExpr MkAnd(IEnumerable<BoolExpr> t)
1050 {
1051 Debug.Assert(t != null);
1052 Debug.Assert(t.All(a => a != null));
1053 CheckContextMatch<BoolExpr>(t);
1054 var ands = t.ToArray();
1055 return new BoolExpr(this, Native.Z3_mk_and(nCtx, (uint)t.Count(), AST.ArrayToNative(ands)));
1056 }
1057
1061 public BoolExpr MkOr(params BoolExpr[] t)
1062 {
1063 Debug.Assert(t != null);
1064 Debug.Assert(t.All(a => a != null));
1065
1066 CheckContextMatch<BoolExpr>(t);
1067 return new BoolExpr(this, Native.Z3_mk_or(nCtx, (uint)t.Length, AST.ArrayToNative(t)));
1068 }
1069
1070
1074 public BoolExpr MkOr(IEnumerable<BoolExpr> t)
1075 {
1076 Debug.Assert(t != null);
1077 Debug.Assert(t.All(a => a != null));
1078
1079 CheckContextMatch(t);
1080 var ts = t.ToArray();
1081 return new BoolExpr(this, Native.Z3_mk_or(nCtx, (uint)ts.Length, AST.ArrayToNative(ts)));
1082 }
1083
1084 #endregion
1085
1086 #region Arithmetic
1090 public ArithExpr MkAdd(params ArithExpr[] t)
1091 {
1092 Debug.Assert(t != null);
1093 Debug.Assert(t.All(a => a != null));
1094
1095 CheckContextMatch<ArithExpr>(t);
1096 return (ArithExpr)Expr.Create(this, Native.Z3_mk_add(nCtx, (uint)t.Length, AST.ArrayToNative(t)));
1097 }
1098
1102 public ArithExpr MkAdd(IEnumerable<ArithExpr> t)
1103 {
1104 Debug.Assert(t != null);
1105 Debug.Assert(t.All(a => a != null));
1106
1107 CheckContextMatch(t);
1108 var ts = t.ToArray();
1109 return (ArithExpr)Expr.Create(this, Native.Z3_mk_add(nCtx, (uint)ts.Length, AST.ArrayToNative(ts)));
1110 }
1111
1115 public ArithExpr MkMul(params ArithExpr[] t)
1116 {
1117 Debug.Assert(t != null);
1118 Debug.Assert(t.All(a => a != null));
1119
1120 CheckContextMatch<ArithExpr>(t);
1121 var ts = t.ToArray();
1122 return (ArithExpr)Expr.Create(this, Native.Z3_mk_mul(nCtx, (uint)ts.Length, AST.ArrayToNative(ts)));
1123 }
1124
1128 public ArithExpr MkMul(IEnumerable<ArithExpr> t)
1129 {
1130 Debug.Assert(t != null);
1131 Debug.Assert(t.All(a => a != null));
1132
1133 CheckContextMatch<ArithExpr>(t);
1134 var ts = t.ToArray();
1135 return (ArithExpr)Expr.Create(this, Native.Z3_mk_mul(nCtx, (uint)ts.Length, AST.ArrayToNative(ts)));
1136 }
1137
1141 public ArithExpr MkSub(params ArithExpr[] t)
1142 {
1143 Debug.Assert(t != null);
1144 Debug.Assert(t.All(a => a != null));
1145
1146 CheckContextMatch<ArithExpr>(t);
1147 return (ArithExpr)Expr.Create(this, Native.Z3_mk_sub(nCtx, (uint)t.Length, AST.ArrayToNative(t)));
1148 }
1149
1154 {
1155 Debug.Assert(t != null);
1156
1157 CheckContextMatch(t);
1158 return (ArithExpr)Expr.Create(this, Native.Z3_mk_unary_minus(nCtx, t.NativeObject));
1159 }
1160
1165 {
1166 Debug.Assert(t1 != null);
1167 Debug.Assert(t2 != null);
1168
1169 CheckContextMatch(t1);
1170 CheckContextMatch(t2);
1171 return (ArithExpr)Expr.Create(this, Native.Z3_mk_div(nCtx, t1.NativeObject, t2.NativeObject));
1172 }
1173
1179 {
1180 Debug.Assert(t1 != null);
1181 Debug.Assert(t2 != null);
1182
1183 CheckContextMatch(t1);
1184 CheckContextMatch(t2);
1185 return new IntExpr(this, Native.Z3_mk_mod(nCtx, t1.NativeObject, t2.NativeObject));
1186 }
1187
1193 {
1194 Debug.Assert(t1 != null);
1195 Debug.Assert(t2 != null);
1196
1197 CheckContextMatch(t1);
1198 CheckContextMatch(t2);
1199 return new IntExpr(this, Native.Z3_mk_rem(nCtx, t1.NativeObject, t2.NativeObject));
1200 }
1201
1206 {
1207 Debug.Assert(t1 != null);
1208 Debug.Assert(t2 != null);
1209
1210 CheckContextMatch(t1);
1211 CheckContextMatch(t2);
1212 return (ArithExpr)Expr.Create(this, Native.Z3_mk_power(nCtx, t1.NativeObject, t2.NativeObject));
1213 }
1214
1219 {
1220 Debug.Assert(t1 != null);
1221 Debug.Assert(t2 != null);
1222
1223 CheckContextMatch(t1);
1224 CheckContextMatch(t2);
1225 return new BoolExpr(this, Native.Z3_mk_lt(nCtx, t1.NativeObject, t2.NativeObject));
1226 }
1227
1232 {
1233 Debug.Assert(t1 != null);
1234 Debug.Assert(t2 != null);
1235
1236 CheckContextMatch(t1);
1237 CheckContextMatch(t2);
1238 return new BoolExpr(this, Native.Z3_mk_le(nCtx, t1.NativeObject, t2.NativeObject));
1239 }
1240
1245 {
1246 Debug.Assert(t1 != null);
1247 Debug.Assert(t2 != null);
1248
1249 CheckContextMatch(t1);
1250 CheckContextMatch(t2);
1251 return new BoolExpr(this, Native.Z3_mk_gt(nCtx, t1.NativeObject, t2.NativeObject));
1252 }
1253
1258 {
1259 Debug.Assert(t1 != null);
1260 Debug.Assert(t2 != null);
1261
1262 CheckContextMatch(t1);
1263 CheckContextMatch(t2);
1264 return new BoolExpr(this, Native.Z3_mk_ge(nCtx, t1.NativeObject, t2.NativeObject));
1265 }
1266
1278 {
1279 Debug.Assert(t != null);
1280
1281 CheckContextMatch(t);
1282 return new RealExpr(this, Native.Z3_mk_int2real(nCtx, t.NativeObject));
1283 }
1284
1293 {
1294 Debug.Assert(t != null);
1295
1296 CheckContextMatch(t);
1297 return new IntExpr(this, Native.Z3_mk_real2int(nCtx, t.NativeObject));
1298 }
1299
1304 {
1305 Debug.Assert(t != null);
1306
1307 CheckContextMatch(t);
1308 return new BoolExpr(this, Native.Z3_mk_is_int(nCtx, t.NativeObject));
1309 }
1310 #endregion
1311
1312 #region Bit-vectors
1318 {
1319 Debug.Assert(t != null);
1320
1321 CheckContextMatch(t);
1322 return new BitVecExpr(this, Native.Z3_mk_bvnot(nCtx, t.NativeObject));
1323 }
1324
1330 {
1331 Debug.Assert(t != null);
1332
1333 CheckContextMatch(t);
1334 return new BitVecExpr(this, Native.Z3_mk_bvredand(nCtx, t.NativeObject));
1335 }
1336
1342 {
1343 Debug.Assert(t != null);
1344
1345 CheckContextMatch(t);
1346 return new BitVecExpr(this, Native.Z3_mk_bvredor(nCtx, t.NativeObject));
1347 }
1348
1354 {
1355 Debug.Assert(t1 != null);
1356 Debug.Assert(t2 != null);
1357
1358 CheckContextMatch(t1);
1359 CheckContextMatch(t2);
1360 return new BitVecExpr(this, Native.Z3_mk_bvand(nCtx, t1.NativeObject, t2.NativeObject));
1361 }
1362
1368 {
1369 Debug.Assert(t1 != null);
1370 Debug.Assert(t2 != null);
1371
1372 CheckContextMatch(t1);
1373 CheckContextMatch(t2);
1374 return new BitVecExpr(this, Native.Z3_mk_bvor(nCtx, t1.NativeObject, t2.NativeObject));
1375 }
1376
1382 {
1383 Debug.Assert(t1 != null);
1384 Debug.Assert(t2 != null);
1385
1386 CheckContextMatch(t1);
1387 CheckContextMatch(t2);
1388 return new BitVecExpr(this, Native.Z3_mk_bvxor(nCtx, t1.NativeObject, t2.NativeObject));
1389 }
1390
1396 {
1397 Debug.Assert(t1 != null);
1398 Debug.Assert(t2 != null);
1399
1400 CheckContextMatch(t1);
1401 CheckContextMatch(t2);
1402 return new BitVecExpr(this, Native.Z3_mk_bvnand(nCtx, t1.NativeObject, t2.NativeObject));
1403 }
1404
1410 {
1411 Debug.Assert(t1 != null);
1412 Debug.Assert(t2 != null);
1413
1414 CheckContextMatch(t1);
1415 CheckContextMatch(t2);
1416 return new BitVecExpr(this, Native.Z3_mk_bvnor(nCtx, t1.NativeObject, t2.NativeObject));
1417 }
1418
1424 {
1425 Debug.Assert(t1 != null);
1426 Debug.Assert(t2 != null);
1427
1428 CheckContextMatch(t1);
1429 CheckContextMatch(t2);
1430 return new BitVecExpr(this, Native.Z3_mk_bvxnor(nCtx, t1.NativeObject, t2.NativeObject));
1431 }
1432
1438 {
1439 Debug.Assert(t != null);
1440
1441 CheckContextMatch(t);
1442 return new BitVecExpr(this, Native.Z3_mk_bvneg(nCtx, t.NativeObject));
1443 }
1444
1450 {
1451 Debug.Assert(t1 != null);
1452 Debug.Assert(t2 != null);
1453
1454 CheckContextMatch(t1);
1455 CheckContextMatch(t2);
1456 return new BitVecExpr(this, Native.Z3_mk_bvadd(nCtx, t1.NativeObject, t2.NativeObject));
1457 }
1458
1464 {
1465 Debug.Assert(t1 != null);
1466 Debug.Assert(t2 != null);
1467
1468 CheckContextMatch(t1);
1469 CheckContextMatch(t2);
1470 return new BitVecExpr(this, Native.Z3_mk_bvsub(nCtx, t1.NativeObject, t2.NativeObject));
1471 }
1472
1478 {
1479 Debug.Assert(t1 != null);
1480 Debug.Assert(t2 != null);
1481
1482 CheckContextMatch(t1);
1483 CheckContextMatch(t2);
1484 return new BitVecExpr(this, Native.Z3_mk_bvmul(nCtx, t1.NativeObject, t2.NativeObject));
1485 }
1486
1497 {
1498 Debug.Assert(t1 != null);
1499 Debug.Assert(t2 != null);
1500
1501 CheckContextMatch(t1);
1502 CheckContextMatch(t2);
1503 return new BitVecExpr(this, Native.Z3_mk_bvudiv(nCtx, t1.NativeObject, t2.NativeObject));
1504 }
1505
1520 {
1521 Debug.Assert(t1 != null);
1522 Debug.Assert(t2 != null);
1523
1524 CheckContextMatch(t1);
1525 CheckContextMatch(t2);
1526 return new BitVecExpr(this, Native.Z3_mk_bvsdiv(nCtx, t1.NativeObject, t2.NativeObject));
1527 }
1528
1538 {
1539 Debug.Assert(t1 != null);
1540 Debug.Assert(t2 != null);
1541
1542 CheckContextMatch(t1);
1543 CheckContextMatch(t2);
1544 return new BitVecExpr(this, Native.Z3_mk_bvurem(nCtx, t1.NativeObject, t2.NativeObject));
1545 }
1546
1558 {
1559 Debug.Assert(t1 != null);
1560 Debug.Assert(t2 != null);
1561
1562 CheckContextMatch(t1);
1563 CheckContextMatch(t2);
1564 return new BitVecExpr(this, Native.Z3_mk_bvsrem(nCtx, t1.NativeObject, t2.NativeObject));
1565 }
1566
1575 {
1576 Debug.Assert(t1 != null);
1577 Debug.Assert(t2 != null);
1578
1579 CheckContextMatch(t1);
1580 CheckContextMatch(t2);
1581 return new BitVecExpr(this, Native.Z3_mk_bvsmod(nCtx, t1.NativeObject, t2.NativeObject));
1582 }
1583
1591 {
1592 Debug.Assert(t1 != null);
1593 Debug.Assert(t2 != null);
1594
1595 CheckContextMatch(t1);
1596 CheckContextMatch(t2);
1597 return new BoolExpr(this, Native.Z3_mk_bvult(nCtx, t1.NativeObject, t2.NativeObject));
1598 }
1599
1607 {
1608 Debug.Assert(t1 != null);
1609 Debug.Assert(t2 != null);
1610
1611 CheckContextMatch(t1);
1612 CheckContextMatch(t2);
1613 return new BoolExpr(this, Native.Z3_mk_bvslt(nCtx, t1.NativeObject, t2.NativeObject));
1614 }
1615
1623 {
1624 Debug.Assert(t1 != null);
1625 Debug.Assert(t2 != null);
1626
1627 CheckContextMatch(t1);
1628 CheckContextMatch(t2);
1629 return new BoolExpr(this, Native.Z3_mk_bvule(nCtx, t1.NativeObject, t2.NativeObject));
1630 }
1631
1639 {
1640 Debug.Assert(t1 != null);
1641 Debug.Assert(t2 != null);
1642
1643 CheckContextMatch(t1);
1644 CheckContextMatch(t2);
1645 return new BoolExpr(this, Native.Z3_mk_bvsle(nCtx, t1.NativeObject, t2.NativeObject));
1646 }
1647
1655 {
1656 Debug.Assert(t1 != null);
1657 Debug.Assert(t2 != null);
1658
1659 CheckContextMatch(t1);
1660 CheckContextMatch(t2);
1661 return new BoolExpr(this, Native.Z3_mk_bvuge(nCtx, t1.NativeObject, t2.NativeObject));
1662 }
1663
1671 {
1672 Debug.Assert(t1 != null);
1673 Debug.Assert(t2 != null);
1674
1675 CheckContextMatch(t1);
1676 CheckContextMatch(t2);
1677 return new BoolExpr(this, Native.Z3_mk_bvsge(nCtx, t1.NativeObject, t2.NativeObject));
1678 }
1679
1687 {
1688 Debug.Assert(t1 != null);
1689 Debug.Assert(t2 != null);
1690
1691 CheckContextMatch(t1);
1692 CheckContextMatch(t2);
1693 return new BoolExpr(this, Native.Z3_mk_bvugt(nCtx, t1.NativeObject, t2.NativeObject));
1694 }
1695
1703 {
1704 Debug.Assert(t1 != null);
1705 Debug.Assert(t2 != null);
1706
1707 CheckContextMatch(t1);
1708 CheckContextMatch(t2);
1709 return new BoolExpr(this, Native.Z3_mk_bvsgt(nCtx, t1.NativeObject, t2.NativeObject));
1710 }
1711
1723 {
1724 Debug.Assert(t1 != null);
1725 Debug.Assert(t2 != null);
1726
1727 CheckContextMatch(t1);
1728 CheckContextMatch(t2);
1729 return new BitVecExpr(this, Native.Z3_mk_concat(nCtx, t1.NativeObject, t2.NativeObject));
1730 }
1731
1741 public BitVecExpr MkExtract(uint high, uint low, BitVecExpr t)
1742 {
1743 Debug.Assert(t != null);
1744
1745 CheckContextMatch(t);
1746 return new BitVecExpr(this, Native.Z3_mk_extract(nCtx, high, low, t.NativeObject));
1747 }
1748
1758 {
1759 Debug.Assert(t != null);
1760
1761 CheckContextMatch(t);
1762 return new BitVecExpr(this, Native.Z3_mk_sign_ext(nCtx, i, t.NativeObject));
1763 }
1764
1775 {
1776 Debug.Assert(t != null);
1777
1778 CheckContextMatch(t);
1779 return new BitVecExpr(this, Native.Z3_mk_zero_ext(nCtx, i, t.NativeObject));
1780 }
1781
1789 {
1790 Debug.Assert(t != null);
1791
1792 CheckContextMatch(t);
1793 return new BitVecExpr(this, Native.Z3_mk_repeat(nCtx, i, t.NativeObject));
1794 }
1795
1809 {
1810 Debug.Assert(t1 != null);
1811 Debug.Assert(t2 != null);
1812
1813 CheckContextMatch(t1);
1814 CheckContextMatch(t2);
1815 return new BitVecExpr(this, Native.Z3_mk_bvshl(nCtx, t1.NativeObject, t2.NativeObject));
1816 }
1817
1831 {
1832 Debug.Assert(t1 != null);
1833 Debug.Assert(t2 != null);
1834
1835 CheckContextMatch(t1);
1836 CheckContextMatch(t2);
1837 return new BitVecExpr(this, Native.Z3_mk_bvlshr(nCtx, t1.NativeObject, t2.NativeObject));
1838 }
1839
1855 {
1856 Debug.Assert(t1 != null);
1857 Debug.Assert(t2 != null);
1858
1859 CheckContextMatch(t1);
1860 CheckContextMatch(t2);
1861 return new BitVecExpr(this, Native.Z3_mk_bvashr(nCtx, t1.NativeObject, t2.NativeObject));
1862 }
1863
1872 {
1873 Debug.Assert(t != null);
1874
1875 CheckContextMatch(t);
1876 return new BitVecExpr(this, Native.Z3_mk_rotate_left(nCtx, i, t.NativeObject));
1877 }
1878
1887 {
1888 Debug.Assert(t != null);
1889
1890 CheckContextMatch(t);
1891 return new BitVecExpr(this, Native.Z3_mk_rotate_right(nCtx, i, t.NativeObject));
1892 }
1893
1902 {
1903 Debug.Assert(t1 != null);
1904 Debug.Assert(t2 != null);
1905
1906 CheckContextMatch(t1);
1907 CheckContextMatch(t2);
1908 return new BitVecExpr(this, Native.Z3_mk_ext_rotate_left(nCtx, t1.NativeObject, t2.NativeObject));
1909 }
1910
1919 {
1920 Debug.Assert(t1 != null);
1921 Debug.Assert(t2 != null);
1922
1923 CheckContextMatch(t1);
1924 CheckContextMatch(t2);
1925 return new BitVecExpr(this, Native.Z3_mk_ext_rotate_right(nCtx, t1.NativeObject, t2.NativeObject));
1926 }
1927
1938 public BitVecExpr MkInt2BV(uint n, IntExpr t)
1939 {
1940 Debug.Assert(t != null);
1941
1942 CheckContextMatch(t);
1943 return new BitVecExpr(this, Native.Z3_mk_int2bv(nCtx, n, t.NativeObject));
1944 }
1945
1961 public IntExpr MkBV2Int(BitVecExpr t, bool signed)
1962 {
1963 Debug.Assert(t != null);
1964
1965 CheckContextMatch(t);
1966 return new IntExpr(this, Native.Z3_mk_bv2int(nCtx, t.NativeObject, (byte)(signed ? 1 : 0)));
1967 }
1968
1975 public BoolExpr MkBVAddNoOverflow(BitVecExpr t1, BitVecExpr t2, bool isSigned)
1976 {
1977 Debug.Assert(t1 != null);
1978 Debug.Assert(t2 != null);
1979
1980 CheckContextMatch(t1);
1981 CheckContextMatch(t2);
1982 return new BoolExpr(this, Native.Z3_mk_bvadd_no_overflow(nCtx, t1.NativeObject, t2.NativeObject, (byte)(isSigned ? 1 : 0)));
1983 }
1984
1992 {
1993 Debug.Assert(t1 != null);
1994 Debug.Assert(t2 != null);
1995
1996 CheckContextMatch(t1);
1997 CheckContextMatch(t2);
1998 return new BoolExpr(this, Native.Z3_mk_bvadd_no_underflow(nCtx, t1.NativeObject, t2.NativeObject));
1999 }
2000
2008 {
2009 Debug.Assert(t1 != null);
2010 Debug.Assert(t2 != null);
2011
2012 CheckContextMatch(t1);
2013 CheckContextMatch(t2);
2014 return new BoolExpr(this, Native.Z3_mk_bvsub_no_overflow(nCtx, t1.NativeObject, t2.NativeObject));
2015 }
2016
2023 public BoolExpr MkBVSubNoUnderflow(BitVecExpr t1, BitVecExpr t2, bool isSigned)
2024 {
2025 Debug.Assert(t1 != null);
2026 Debug.Assert(t2 != null);
2027
2028 CheckContextMatch(t1);
2029 CheckContextMatch(t2);
2030 return new BoolExpr(this, Native.Z3_mk_bvsub_no_underflow(nCtx, t1.NativeObject, t2.NativeObject, (byte)(isSigned ? 1 : 0)));
2031 }
2032
2040 {
2041 Debug.Assert(t1 != null);
2042 Debug.Assert(t2 != null);
2043
2044 CheckContextMatch(t1);
2045 CheckContextMatch(t2);
2046 return new BoolExpr(this, Native.Z3_mk_bvsdiv_no_overflow(nCtx, t1.NativeObject, t2.NativeObject));
2047 }
2048
2056 {
2057 Debug.Assert(t != null);
2058
2059 CheckContextMatch(t);
2060 return new BoolExpr(this, Native.Z3_mk_bvneg_no_overflow(nCtx, t.NativeObject));
2061 }
2062
2069 public BoolExpr MkBVMulNoOverflow(BitVecExpr t1, BitVecExpr t2, bool isSigned)
2070 {
2071 Debug.Assert(t1 != null);
2072 Debug.Assert(t2 != null);
2073
2074 CheckContextMatch(t1);
2075 CheckContextMatch(t2);
2076 return new BoolExpr(this, Native.Z3_mk_bvmul_no_overflow(nCtx, t1.NativeObject, t2.NativeObject, (byte)(isSigned ? 1 : 0)));
2077 }
2078
2086 {
2087 Debug.Assert(t1 != null);
2088 Debug.Assert(t2 != null);
2089
2090 CheckContextMatch(t1);
2091 CheckContextMatch(t2);
2092 return new BoolExpr(this, Native.Z3_mk_bvmul_no_underflow(nCtx, t1.NativeObject, t2.NativeObject));
2093 }
2094 #endregion
2095
2096 #region Arrays
2101 {
2102 Debug.Assert(name != null);
2103 Debug.Assert(domain != null);
2104 Debug.Assert(range != null);
2105
2106 using var sort = MkArraySort(domain, range);
2107 return (ArrayExpr)MkConst(name, sort);
2108 }
2109
2113 public ArrayExpr MkArrayConst(string name, Sort domain, Sort range)
2114 {
2115 Debug.Assert(domain != null);
2116 Debug.Assert(range != null);
2117
2118 using var symbol = MkSymbol(name);
2119 using var sort = MkArraySort(domain, range);
2120 return (ArrayExpr)MkConst(symbol, sort);
2121 }
2122
2123
2138 {
2139 Debug.Assert(a != null);
2140 Debug.Assert(i != null);
2141
2142 CheckContextMatch(a);
2143 CheckContextMatch(i);
2144 return Expr.Create(this, Native.Z3_mk_select(nCtx, a.NativeObject, i.NativeObject));
2145 }
2146
2160 public Expr MkSelect(ArrayExpr a, params Expr[] args)
2161 {
2162 Debug.Assert(a != null);
2163 Debug.Assert(args != null && args.All(n => n != null));
2164
2165 CheckContextMatch(a);
2166 CheckContextMatch<Expr>(args);
2167 return Expr.Create(this, Native.Z3_mk_select_n(nCtx, a.NativeObject, AST.ArrayLength(args), AST.ArrayToNative(args)));
2168 }
2169
2170
2190 {
2191 Debug.Assert(a != null);
2192 Debug.Assert(i != null);
2193 Debug.Assert(v != null);
2194
2195 CheckContextMatch(a);
2196 CheckContextMatch(i);
2197 CheckContextMatch(v);
2198 return new ArrayExpr(this, Native.Z3_mk_store(nCtx, a.NativeObject, i.NativeObject, v.NativeObject));
2199 }
2200
2219 public ArrayExpr MkStore(ArrayExpr a, Expr[] args, Expr v)
2220 {
2221 Debug.Assert(a != null);
2222 Debug.Assert(args != null);
2223 Debug.Assert(v != null);
2224
2225 CheckContextMatch<Expr>(args);
2226 CheckContextMatch(a);
2227 CheckContextMatch(v);
2228 return new ArrayExpr(this, Native.Z3_mk_store_n(nCtx, a.NativeObject, AST.ArrayLength(args), AST.ArrayToNative(args), v.NativeObject));
2229 }
2230
2241 {
2242 Debug.Assert(domain != null);
2243 Debug.Assert(v != null);
2244
2245 CheckContextMatch(domain);
2246 CheckContextMatch(v);
2247 return new ArrayExpr(this, Native.Z3_mk_const_array(nCtx, domain.NativeObject, v.NativeObject));
2248 }
2249
2261 public ArrayExpr MkMap(FuncDecl f, params ArrayExpr[] args)
2262 {
2263 Debug.Assert(f != null);
2264 Debug.Assert(args == null || args.All(a => a != null));
2265
2266 CheckContextMatch(f);
2267 CheckContextMatch<ArrayExpr>(args);
2268 return (ArrayExpr)Expr.Create(this, Native.Z3_mk_map(nCtx, f.NativeObject, AST.ArrayLength(args), AST.ArrayToNative(args)));
2269 }
2270
2279 {
2280 Debug.Assert(array != null);
2281
2282 CheckContextMatch(array);
2283 return Expr.Create(this, Native.Z3_mk_array_default(nCtx, array.NativeObject));
2284 }
2285
2290 {
2291 Debug.Assert(arg1 != null);
2292 Debug.Assert(arg2 != null);
2293
2294 CheckContextMatch(arg1);
2295 CheckContextMatch(arg2);
2296 return Expr.Create(this, Native.Z3_mk_array_ext(nCtx, arg1.NativeObject, arg2.NativeObject));
2297 }
2298
2299 #endregion
2300
2301 #region Sets
2306 {
2307 Debug.Assert(ty != null);
2308
2309 CheckContextMatch(ty);
2310 return new SetSort(this, ty);
2311 }
2312
2317 {
2318 Debug.Assert(domain != null);
2319
2320 CheckContextMatch(domain);
2321 return (ArrayExpr)Expr.Create(this, Native.Z3_mk_empty_set(nCtx, domain.NativeObject));
2322 }
2323
2327 public ArrayExpr MkFullSet(Sort domain)
2328 {
2329 Debug.Assert(domain != null);
2330
2331 CheckContextMatch(domain);
2332 return (ArrayExpr)Expr.Create(this, Native.Z3_mk_full_set(nCtx, domain.NativeObject));
2333 }
2334
2338 public ArrayExpr MkSetAdd(ArrayExpr set, Expr element)
2339 {
2340 Debug.Assert(set != null);
2341 Debug.Assert(element != null);
2342
2343 CheckContextMatch(set);
2344 CheckContextMatch(element);
2345 return (ArrayExpr)Expr.Create(this, Native.Z3_mk_set_add(nCtx, set.NativeObject, element.NativeObject));
2346 }
2347
2348
2352 public ArrayExpr MkSetDel(ArrayExpr set, Expr element)
2353 {
2354 Debug.Assert(set != null);
2355 Debug.Assert(element != null);
2356
2357 CheckContextMatch(set);
2358 CheckContextMatch(element);
2359 return (ArrayExpr)Expr.Create(this, Native.Z3_mk_set_del(nCtx, set.NativeObject, element.NativeObject));
2360 }
2361
2365 public ArrayExpr MkSetUnion(params ArrayExpr[] args)
2366 {
2367 Debug.Assert(args != null);
2368 Debug.Assert(args.All(a => a != null));
2369
2370 CheckContextMatch<ArrayExpr>(args);
2371 return (ArrayExpr)Expr.Create(this, Native.Z3_mk_set_union(nCtx, (uint)args.Length, AST.ArrayToNative(args)));
2372 }
2373
2378 {
2379 Debug.Assert(args != null);
2380 Debug.Assert(args.All(a => a != null));
2381
2382 CheckContextMatch<ArrayExpr>(args);
2383 return (ArrayExpr)Expr.Create(this, Native.Z3_mk_set_intersect(nCtx, (uint)args.Length, AST.ArrayToNative(args)));
2384 }
2385
2390 {
2391 Debug.Assert(arg1 != null);
2392 Debug.Assert(arg2 != null);
2393
2394 CheckContextMatch(arg1);
2395 CheckContextMatch(arg2);
2396 return (ArrayExpr)Expr.Create(this, Native.Z3_mk_set_difference(nCtx, arg1.NativeObject, arg2.NativeObject));
2397 }
2398
2403 {
2404 Debug.Assert(arg != null);
2405
2406 CheckContextMatch(arg);
2407 return (ArrayExpr)Expr.Create(this, Native.Z3_mk_set_complement(nCtx, arg.NativeObject));
2408 }
2409
2414 {
2415 Debug.Assert(elem != null);
2416 Debug.Assert(set != null);
2417
2418 CheckContextMatch(elem);
2419 CheckContextMatch(set);
2420 return (BoolExpr)Expr.Create(this, Native.Z3_mk_set_member(nCtx, elem.NativeObject, set.NativeObject));
2421 }
2422
2427 {
2428 Debug.Assert(arg1 != null);
2429 Debug.Assert(arg2 != null);
2430
2431 CheckContextMatch(arg1);
2432 CheckContextMatch(arg2);
2433 return (BoolExpr)Expr.Create(this, Native.Z3_mk_set_subset(nCtx, arg1.NativeObject, arg2.NativeObject));
2434 }
2435
2436 #endregion
2437
2438 #region Sequence, string and regular expressions
2439
2444 {
2445 Debug.Assert(s != null);
2446 return new SeqExpr(this, Native.Z3_mk_seq_empty(nCtx, s.NativeObject));
2447 }
2448
2452 public SeqExpr MkUnit(Expr elem)
2453 {
2454 Debug.Assert(elem != null);
2455 return new SeqExpr(this, Native.Z3_mk_seq_unit(nCtx, elem.NativeObject));
2456 }
2457
2461 public SeqExpr MkString(string s)
2462 {
2463 Debug.Assert(s != null);
2464 return new SeqExpr(this, Native.Z3_mk_string(nCtx, s));
2465 }
2466
2471 {
2472 Debug.Assert(e != null);
2473 Debug.Assert(e is ArithExpr);
2474 return new SeqExpr(this, Native.Z3_mk_int_to_str(nCtx, e.NativeObject));
2475 }
2476
2481 {
2482 Debug.Assert(e != null);
2483 Debug.Assert(e is ArithExpr);
2484 return new SeqExpr(this, Native.Z3_mk_ubv_to_str(nCtx, e.NativeObject));
2485 }
2486
2491 {
2492 Debug.Assert(e != null);
2493 Debug.Assert(e is ArithExpr);
2494 return new SeqExpr(this, Native.Z3_mk_sbv_to_str(nCtx, e.NativeObject));
2495 }
2496
2501 {
2502 Debug.Assert(e != null);
2503 Debug.Assert(e is SeqExpr);
2504 return new IntExpr(this, Native.Z3_mk_str_to_int(nCtx, e.NativeObject));
2505 }
2506
2507
2511 public SeqExpr MkConcat(params SeqExpr[] t)
2512 {
2513 Debug.Assert(t != null);
2514 Debug.Assert(t.All(a => a != null));
2515
2516 CheckContextMatch<SeqExpr>(t);
2517 return new SeqExpr(this, Native.Z3_mk_seq_concat(nCtx, (uint)t.Length, AST.ArrayToNative(t)));
2518 }
2519
2520
2525 {
2526 Debug.Assert(s != null);
2527 return (IntExpr)Expr.Create(this, Native.Z3_mk_seq_length(nCtx, s.NativeObject));
2528 }
2529
2534 {
2535 Debug.Assert(s1 != null);
2536 Debug.Assert(s2 != null);
2537 CheckContextMatch(s1, s2);
2538 return new BoolExpr(this, Native.Z3_mk_seq_prefix(nCtx, s1.NativeObject, s2.NativeObject));
2539 }
2540
2545 {
2546 Debug.Assert(s1 != null);
2547 Debug.Assert(s2 != null);
2548 CheckContextMatch(s1, s2);
2549 return new BoolExpr(this, Native.Z3_mk_seq_suffix(nCtx, s1.NativeObject, s2.NativeObject));
2550 }
2551
2556 {
2557 Debug.Assert(s1 != null);
2558 Debug.Assert(s2 != null);
2559 CheckContextMatch(s1, s2);
2560 return new BoolExpr(this, Native.Z3_mk_seq_contains(nCtx, s1.NativeObject, s2.NativeObject));
2561 }
2562
2567 {
2568 Debug.Assert(s1 != null);
2569 Debug.Assert(s2 != null);
2570 CheckContextMatch(s1, s2);
2571 return new BoolExpr(this, Native.Z3_mk_str_lt(nCtx, s1.NativeObject, s2.NativeObject));
2572 }
2573
2578 {
2579 Debug.Assert(s1 != null);
2580 Debug.Assert(s2 != null);
2581 CheckContextMatch(s1, s2);
2582 return new BoolExpr(this, Native.Z3_mk_str_le(nCtx, s1.NativeObject, s2.NativeObject));
2583 }
2584
2588 public SeqExpr MkAt(SeqExpr s, Expr index)
2589 {
2590 Debug.Assert(s != null);
2591 Debug.Assert(index != null);
2592 CheckContextMatch(s, index);
2593 return new SeqExpr(this, Native.Z3_mk_seq_at(nCtx, s.NativeObject, index.NativeObject));
2594 }
2595
2599 public Expr MkNth(SeqExpr s, Expr index)
2600 {
2601 Debug.Assert(s != null);
2602 Debug.Assert(index != null);
2603 CheckContextMatch(s, index);
2604 return Expr.Create(this, Native.Z3_mk_seq_nth(nCtx, s.NativeObject, index.NativeObject));
2605 }
2606
2610 public SeqExpr MkExtract(SeqExpr s, IntExpr offset, IntExpr length)
2611 {
2612 Debug.Assert(s != null);
2613 Debug.Assert(offset != null);
2614 Debug.Assert(length != null);
2615 CheckContextMatch(s, offset, length);
2616 return new SeqExpr(this, Native.Z3_mk_seq_extract(nCtx, s.NativeObject, offset.NativeObject, length.NativeObject));
2617 }
2618
2622 public IntExpr MkIndexOf(SeqExpr s, SeqExpr substr, ArithExpr offset)
2623 {
2624 Debug.Assert(s != null);
2625 Debug.Assert(offset != null);
2626 Debug.Assert(substr != null);
2627 CheckContextMatch(s, substr, offset);
2628 return new IntExpr(this, Native.Z3_mk_seq_index(nCtx, s.NativeObject, substr.NativeObject, offset.NativeObject));
2629 }
2630
2635 {
2636 Debug.Assert(s != null);
2637 Debug.Assert(src != null);
2638 Debug.Assert(dst != null);
2639 CheckContextMatch(s, src, dst);
2640 return new SeqExpr(this, Native.Z3_mk_seq_replace(nCtx, s.NativeObject, src.NativeObject, dst.NativeObject));
2641 }
2642
2647 {
2648 Debug.Assert(s != null);
2649 return new ReExpr(this, Native.Z3_mk_seq_to_re(nCtx, s.NativeObject));
2650 }
2651
2652
2657 {
2658 Debug.Assert(s != null);
2659 Debug.Assert(re != null);
2660 CheckContextMatch(s, re);
2661 return new BoolExpr(this, Native.Z3_mk_seq_in_re(nCtx, s.NativeObject, re.NativeObject));
2662 }
2663
2668 {
2669 Debug.Assert(re != null);
2670 return new ReExpr(this, Native.Z3_mk_re_star(nCtx, re.NativeObject));
2671 }
2672
2676 public ReExpr MkLoop(ReExpr re, uint lo, uint hi = 0)
2677 {
2678 Debug.Assert(re != null);
2679 return new ReExpr(this, Native.Z3_mk_re_loop(nCtx, re.NativeObject, lo, hi));
2680 }
2681
2686 {
2687 Debug.Assert(re != null);
2688 return new ReExpr(this, Native.Z3_mk_re_plus(nCtx, re.NativeObject));
2689 }
2690
2695 {
2696 Debug.Assert(re != null);
2697 return new ReExpr(this, Native.Z3_mk_re_option(nCtx, re.NativeObject));
2698 }
2699
2704 {
2705 Debug.Assert(re != null);
2706 return new ReExpr(this, Native.Z3_mk_re_complement(nCtx, re.NativeObject));
2707 }
2708
2712 public ReExpr MkConcat(params ReExpr[] t)
2713 {
2714 Debug.Assert(t != null);
2715 Debug.Assert(t.All(a => a != null));
2716
2717 CheckContextMatch<ReExpr>(t);
2718 return new ReExpr(this, Native.Z3_mk_re_concat(nCtx, (uint)t.Length, AST.ArrayToNative(t)));
2719 }
2720
2724 public ReExpr MkUnion(params ReExpr[] t)
2725 {
2726 Debug.Assert(t != null);
2727 Debug.Assert(t.All(a => a != null));
2728
2729 CheckContextMatch<ReExpr>(t);
2730 return new ReExpr(this, Native.Z3_mk_re_union(nCtx, (uint)t.Length, AST.ArrayToNative(t)));
2731 }
2732
2736 public ReExpr MkIntersect(params ReExpr[] t)
2737 {
2738 Debug.Assert(t != null);
2739 Debug.Assert(t.All(a => a != null));
2740
2741 CheckContextMatch<ReExpr>(t);
2742 return new ReExpr(this, Native.Z3_mk_re_intersect(nCtx, (uint)t.Length, AST.ArrayToNative(t)));
2743 }
2744
2749 {
2750 Debug.Assert(a != null);
2751 Debug.Assert(b != null);
2752 CheckContextMatch(a, b);
2753 return new ReExpr(this, Native.Z3_mk_re_diff(nCtx, a.NativeObject, b.NativeObject));
2754 }
2755
2761 {
2762 Debug.Assert(s != null);
2763 return new ReExpr(this, Native.Z3_mk_re_empty(nCtx, s.NativeObject));
2764 }
2765
2771 {
2772 Debug.Assert(s != null);
2773 return new ReExpr(this, Native.Z3_mk_re_full(nCtx, s.NativeObject));
2774 }
2775
2776
2781 {
2782 Debug.Assert(lo != null);
2783 Debug.Assert(hi != null);
2784 CheckContextMatch(lo, hi);
2785 return new ReExpr(this, Native.Z3_mk_re_range(nCtx, lo.NativeObject, hi.NativeObject));
2786 }
2787
2791 public BoolExpr MkCharLe(Expr ch1, Expr ch2)
2792 {
2793 Debug.Assert(ch1 != null);
2794 Debug.Assert(ch2 != null);
2795 return new BoolExpr(this, Native.Z3_mk_char_le(nCtx, ch1.NativeObject, ch2.NativeObject));
2796 }
2797
2802 {
2803 Debug.Assert(ch != null);
2804 return new IntExpr(this, Native.Z3_mk_char_to_int(nCtx, ch.NativeObject));
2805 }
2806
2811 {
2812 Debug.Assert(ch != null);
2813 return new BitVecExpr(this, Native.Z3_mk_char_to_bv(nCtx, ch.NativeObject));
2814 }
2815
2820 {
2821 Debug.Assert(bv != null);
2822 return new Expr(this, Native.Z3_mk_char_from_bv(nCtx, bv.NativeObject));
2823 }
2824
2829 {
2830 Debug.Assert(ch != null);
2831 return new BoolExpr(this, Native.Z3_mk_char_is_digit(nCtx, ch.NativeObject));
2832 }
2833
2834 #endregion
2835
2836 #region Pseudo-Boolean constraints
2837
2841 public BoolExpr MkAtMost(IEnumerable<BoolExpr> args, uint k)
2842 {
2843 Debug.Assert(args != null);
2844 CheckContextMatch<BoolExpr>(args);
2845 var ts = args.ToArray();
2846 return new BoolExpr(this, Native.Z3_mk_atmost(nCtx, (uint)ts.Length,
2847 AST.ArrayToNative(ts), k));
2848 }
2849
2853 public BoolExpr MkAtLeast(IEnumerable<BoolExpr> args, uint k)
2854 {
2855 Debug.Assert(args != null);
2856 CheckContextMatch<BoolExpr>(args);
2857 var ts = args.ToArray();
2858 return new BoolExpr(this, Native.Z3_mk_atleast(nCtx, (uint)ts.Length,
2859 AST.ArrayToNative(ts), k));
2860 }
2861
2865 public BoolExpr MkPBLe(int[] coeffs, BoolExpr[] args, int k)
2866 {
2867 Debug.Assert(args != null);
2868 Debug.Assert(coeffs != null);
2869 Debug.Assert(args.Length == coeffs.Length);
2870 CheckContextMatch<BoolExpr>(args);
2871 return new BoolExpr(this, Native.Z3_mk_pble(nCtx, (uint)args.Length,
2872 AST.ArrayToNative(args),
2873 coeffs, k));
2874 }
2875
2879 public BoolExpr MkPBGe(int[] coeffs, BoolExpr[] args, int k)
2880 {
2881 Debug.Assert(args != null);
2882 Debug.Assert(coeffs != null);
2883 Debug.Assert(args.Length == coeffs.Length);
2884 CheckContextMatch<BoolExpr>(args);
2885 return new BoolExpr(this, Native.Z3_mk_pbge(nCtx, (uint)args.Length,
2886 AST.ArrayToNative(args),
2887 coeffs, k));
2888 }
2892 public BoolExpr MkPBEq(int[] coeffs, BoolExpr[] args, int k)
2893 {
2894 Debug.Assert(args != null);
2895 Debug.Assert(coeffs != null);
2896 Debug.Assert(args.Length == coeffs.Length);
2897 CheckContextMatch<BoolExpr>(args);
2898 return new BoolExpr(this, Native.Z3_mk_pbeq(nCtx, (uint)args.Length,
2899 AST.ArrayToNative(args),
2900 coeffs, k));
2901 }
2902 #endregion
2903
2904 #region Numerals
2905
2906 #region General Numerals
2913 public Expr MkNumeral(string v, Sort ty)
2914 {
2915 Debug.Assert(ty != null);
2916
2917 CheckContextMatch(ty);
2918 return Expr.Create(this, Native.Z3_mk_numeral(nCtx, v, ty.NativeObject));
2919 }
2920
2928 public Expr MkNumeral(int v, Sort ty)
2929 {
2930 Debug.Assert(ty != null);
2931
2932 CheckContextMatch(ty);
2933 return Expr.Create(this, Native.Z3_mk_int(nCtx, v, ty.NativeObject));
2934 }
2935
2943 public Expr MkNumeral(uint v, Sort ty)
2944 {
2945 Debug.Assert(ty != null);
2946
2947 CheckContextMatch(ty);
2948 return Expr.Create(this, Native.Z3_mk_unsigned_int(nCtx, v, ty.NativeObject));
2949 }
2950
2958 public Expr MkNumeral(long v, Sort ty)
2959 {
2960 Debug.Assert(ty != null);
2961
2962 CheckContextMatch(ty);
2963 return Expr.Create(this, Native.Z3_mk_int64(nCtx, v, ty.NativeObject));
2964 }
2965
2973 public Expr MkNumeral(ulong v, Sort ty)
2974 {
2975 Debug.Assert(ty != null);
2976
2977 CheckContextMatch(ty);
2978 return Expr.Create(this, Native.Z3_mk_unsigned_int64(nCtx, v, ty.NativeObject));
2979 }
2980 #endregion
2981
2982 #region Reals
2990 public RatNum MkReal(int num, int den)
2991 {
2992 if (den == 0)
2993 throw new Z3Exception("Denominator is zero");
2994
2995 return new RatNum(this, Native.Z3_mk_real(nCtx, num, den));
2996 }
2997
3003 public RatNum MkReal(string v)
3004 {
3005
3006 return new RatNum(this, Native.Z3_mk_numeral(nCtx, v, RealSort.NativeObject));
3007 }
3008
3014 public RatNum MkReal(int v)
3015 {
3016
3017 return new RatNum(this, Native.Z3_mk_int(nCtx, v, RealSort.NativeObject));
3018 }
3019
3025 public RatNum MkReal(uint v)
3026 {
3027
3028 return new RatNum(this, Native.Z3_mk_unsigned_int(nCtx, v, RealSort.NativeObject));
3029 }
3030
3036 public RatNum MkReal(long v)
3037 {
3038
3039 return new RatNum(this, Native.Z3_mk_int64(nCtx, v, RealSort.NativeObject));
3040 }
3041
3047 public RatNum MkReal(ulong v)
3048 {
3049
3050 return new RatNum(this, Native.Z3_mk_unsigned_int64(nCtx, v, RealSort.NativeObject));
3051 }
3052 #endregion
3053
3054 #region Integers
3059 public IntNum MkInt(string v)
3060 {
3061
3062 return new IntNum(this, Native.Z3_mk_numeral(nCtx, v, IntSort.NativeObject));
3063 }
3064
3070 public IntNum MkInt(int v)
3071 {
3072
3073 return new IntNum(this, Native.Z3_mk_int(nCtx, v, IntSort.NativeObject));
3074 }
3075
3081 public IntNum MkInt(uint v)
3082 {
3083
3084 return new IntNum(this, Native.Z3_mk_unsigned_int(nCtx, v, IntSort.NativeObject));
3085 }
3086
3092 public IntNum MkInt(long v)
3093 {
3094
3095 return new IntNum(this, Native.Z3_mk_int64(nCtx, v, IntSort.NativeObject));
3096 }
3097
3103 public IntNum MkInt(ulong v)
3104 {
3105
3106 return new IntNum(this, Native.Z3_mk_unsigned_int64(nCtx, v, IntSort.NativeObject));
3107 }
3108 #endregion
3109
3110 #region Bit-vectors
3116 public BitVecNum MkBV(string v, uint size)
3117 {
3118 using var sort = MkBitVecSort(size);
3119 return (BitVecNum)MkNumeral(v, sort);
3120 }
3121
3127 public BitVecNum MkBV(int v, uint size)
3128 {
3129 using var sort = MkBitVecSort(size);
3130 return (BitVecNum)MkNumeral(v, sort);
3131 }
3132
3138 public BitVecNum MkBV(uint v, uint size)
3139 {
3140 using var sort = MkBitVecSort(size);
3141 return (BitVecNum)MkNumeral(v, sort);
3142 }
3143
3149 public BitVecNum MkBV(long v, uint size)
3150 {
3151 using var sort = MkBitVecSort(size);
3152 return (BitVecNum)MkNumeral(v, sort);
3153 }
3154
3160 public BitVecNum MkBV(ulong v, uint size)
3161 {
3162 using var sort = MkBitVecSort(size);
3163 return (BitVecNum)MkNumeral(v, sort);
3164 }
3165
3170 public BitVecNum MkBV(bool[] bits)
3171 {
3172 byte[] _bits = new byte[bits.Length];
3173 for (int i = 0; i < bits.Length; ++i) _bits[i] = (byte)(bits[i] ? 1 : 0);
3174 return (BitVecNum)Expr.Create(this, Native.Z3_mk_bv_numeral(nCtx, (uint)bits.Length, _bits));
3175 }
3176
3177
3178 #endregion
3179
3180 #endregion // Numerals
3181
3182 #region Quantifiers
3207 public Quantifier MkForall(Sort[] sorts, Symbol[] names, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null)
3208 {
3209 Debug.Assert(sorts != null);
3210 Debug.Assert(names != null);
3211 Debug.Assert(body != null);
3212 Debug.Assert(sorts.Length == names.Length);
3213 Debug.Assert(sorts.All(s => s != null));
3214 Debug.Assert(names.All(n => n != null));
3215 Debug.Assert(patterns == null || patterns.All(p => p != null));
3216 Debug.Assert(noPatterns == null || noPatterns.All(np => np != null));
3217
3218
3219 return new Quantifier(this, true, sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID);
3220 }
3221
3222
3231 public Quantifier MkForall(Expr[] boundConstants, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null)
3232 {
3233 Debug.Assert(body != null);
3234 Debug.Assert(boundConstants == null || boundConstants.All(b => b != null));
3235 Debug.Assert(patterns == null || patterns.All(p => p != null));
3236 Debug.Assert(noPatterns == null || noPatterns.All(np => np != null));
3237
3238
3239 return new Quantifier(this, true, boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID);
3240 }
3241
3249 public Quantifier MkExists(Sort[] sorts, Symbol[] names, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null)
3250 {
3251 Debug.Assert(sorts != null);
3252 Debug.Assert(names != null);
3253 Debug.Assert(body != null);
3254 Debug.Assert(sorts.Length == names.Length);
3255 Debug.Assert(sorts.All(s => s != null));
3256 Debug.Assert(names.All(n => n != null));
3257 Debug.Assert(patterns == null || patterns.All(p => p != null));
3258 Debug.Assert(noPatterns == null || noPatterns.All(np => np != null));
3259
3260 return new Quantifier(this, false, sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID);
3261 }
3262
3271 public Quantifier MkExists(Expr[] boundConstants, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null)
3272 {
3273 Debug.Assert(body != null);
3274 Debug.Assert(boundConstants == null || boundConstants.All(n => n != null));
3275 Debug.Assert(patterns == null || patterns.All(p => p != null));
3276 Debug.Assert(noPatterns == null || noPatterns.All(np => np != null));
3277
3278 return new Quantifier(this, false, boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID);
3279 }
3280
3281
3286 public 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)
3287 {
3288 Debug.Assert(body != null);
3289 Debug.Assert(names != null);
3290 Debug.Assert(sorts != null);
3291 Debug.Assert(sorts.Length == names.Length);
3292 Debug.Assert(sorts.All(s => s != null));
3293 Debug.Assert(names.All(n => n != null));
3294 Debug.Assert(patterns == null || patterns.All(p => p != null));
3295 Debug.Assert(noPatterns == null || noPatterns.All(np => np != null));
3296
3297
3298 if (universal)
3299 return MkForall(sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID);
3300 else
3301 return MkExists(sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID);
3302 }
3303
3304
3309 public Quantifier MkQuantifier(bool universal, Expr[] boundConstants, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null)
3310 {
3311 Debug.Assert(body != null);
3312 Debug.Assert(boundConstants == null || boundConstants.All(n => n != null));
3313 Debug.Assert(patterns == null || patterns.All(p => p != null));
3314 Debug.Assert(noPatterns == null || noPatterns.All(np => np != null));
3315
3316
3317 if (universal)
3318 return MkForall(boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID);
3319 else
3320 return MkExists(boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID);
3321 }
3322
3341 public Lambda MkLambda(Sort[] sorts, Symbol[] names, Expr body)
3342 {
3343 Debug.Assert(sorts != null);
3344 Debug.Assert(names != null);
3345 Debug.Assert(body != null);
3346 Debug.Assert(sorts.Length == names.Length);
3347 Debug.Assert(sorts.All(s => s != null));
3348 Debug.Assert(names.All(n => n != null));
3349 return new Lambda(this, sorts, names, body);
3350 }
3351
3360 public Lambda MkLambda(Expr[] boundConstants, Expr body)
3361 {
3362 Debug.Assert(body != null);
3363 Debug.Assert(boundConstants != null && boundConstants.All(b => b != null));
3364 return new Lambda(this, boundConstants, body);
3365 }
3366
3367
3368 #endregion
3369
3370 #endregion // Expr
3371
3372 #region Options
3390 {
3391 set { Native.Z3_set_ast_print_mode(nCtx, (uint)value); }
3392 }
3393 #endregion
3394
3395 #region SMT Files & Strings
3396
3401 public BoolExpr[] ParseSMTLIB2String(string str, Symbol[] sortNames = null, Sort[] sorts = null, Symbol[] declNames = null, FuncDecl[] decls = null)
3402 {
3403
3404 uint csn = Symbol.ArrayLength(sortNames);
3405 uint cs = Sort.ArrayLength(sorts);
3406 uint cdn = Symbol.ArrayLength(declNames);
3407 uint cd = AST.ArrayLength(decls);
3408 if (csn != cs || cdn != cd)
3409 throw new Z3Exception("Argument size mismatch");
3410 using ASTVector assertions = new ASTVector(this, Native.Z3_parse_smtlib2_string(nCtx, str,
3411 AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts),
3412 AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls)));
3413 return assertions.ToBoolExprArray();
3414 }
3415
3420 public BoolExpr[] ParseSMTLIB2File(string fileName, Symbol[] sortNames = null, Sort[] sorts = null, Symbol[] declNames = null, FuncDecl[] decls = null)
3421 {
3422
3423 uint csn = Symbol.ArrayLength(sortNames);
3424 uint cs = Sort.ArrayLength(sorts);
3425 uint cdn = Symbol.ArrayLength(declNames);
3426 uint cd = AST.ArrayLength(decls);
3427 if (csn != cs || cdn != cd)
3428 throw new Z3Exception("Argument size mismatch");
3429 using ASTVector assertions = new ASTVector(this, Native.Z3_parse_smtlib2_file(nCtx, fileName,
3430 AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts),
3431 AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls)));
3432 return assertions.ToBoolExprArray();
3433 }
3434 #endregion
3435
3436 #region Goals
3447 public Goal MkGoal(bool models = true, bool unsatCores = false, bool proofs = false)
3448 {
3449
3450 return new Goal(this, models, unsatCores, proofs);
3451 }
3452 #endregion
3453
3454 #region ParameterSets
3459 {
3460
3461 return new Params(this);
3462 }
3463 #endregion
3464
3465 #region Tactics
3469 public uint NumTactics
3470 {
3471 get { return Native.Z3_get_num_tactics(nCtx); }
3472 }
3473
3477 public string[] TacticNames
3478 {
3479 get
3480 {
3481
3482 uint n = NumTactics;
3483 string[] res = new string[n];
3484 for (uint i = 0; i < n; i++)
3485 res[i] = Native.Z3_get_tactic_name(nCtx, i);
3486 return res;
3487 }
3488 }
3489
3493 public string TacticDescription(string name)
3494 {
3495
3496 return Native.Z3_tactic_get_descr(nCtx, name);
3497 }
3498
3502 public Tactic MkTactic(string name)
3503 {
3504
3505 return new Tactic(this, name);
3506 }
3507
3512 public Tactic AndThen(Tactic t1, Tactic t2, params Tactic[] ts)
3513 {
3514 Debug.Assert(t1 != null);
3515 Debug.Assert(t2 != null);
3516 // Debug.Assert(ts == null || Contract.ForAll(0, ts.Length, j => ts[j] != null));
3517
3518
3519 CheckContextMatch(t1);
3520 CheckContextMatch(t2);
3521 CheckContextMatch<Tactic>(ts);
3522
3523 IntPtr last = IntPtr.Zero;
3524 if (ts != null && ts.Length > 0)
3525 {
3526 last = ts[ts.Length - 1].NativeObject;
3527 for (int i = ts.Length - 2; i >= 0; i--)
3528 last = Native.Z3_tactic_and_then(nCtx, ts[i].NativeObject, last);
3529 }
3530 if (last != IntPtr.Zero)
3531 {
3532 last = Native.Z3_tactic_and_then(nCtx, t2.NativeObject, last);
3533 return new Tactic(this, Native.Z3_tactic_and_then(nCtx, t1.NativeObject, last));
3534 }
3535 else
3536 return new Tactic(this, Native.Z3_tactic_and_then(nCtx, t1.NativeObject, t2.NativeObject));
3537 }
3538
3546 public Tactic Then(Tactic t1, Tactic t2, params Tactic[] ts)
3547 {
3548 Debug.Assert(t1 != null);
3549 Debug.Assert(t2 != null);
3550 // Debug.Assert(ts == null || Contract.ForAll(0, ts.Length, j => ts[j] != null));
3551
3552 return AndThen(t1, t2, ts);
3553 }
3554
3560 {
3561 Debug.Assert(t1 != null);
3562 Debug.Assert(t2 != null);
3563
3564 CheckContextMatch(t1);
3565 CheckContextMatch(t2);
3566 return new Tactic(this, Native.Z3_tactic_or_else(nCtx, t1.NativeObject, t2.NativeObject));
3567 }
3568
3575 public Tactic TryFor(Tactic t, uint ms)
3576 {
3577 Debug.Assert(t != null);
3578
3579 CheckContextMatch(t);
3580 return new Tactic(this, Native.Z3_tactic_try_for(nCtx, t.NativeObject, ms));
3581 }
3582
3591 {
3592 Debug.Assert(p != null);
3593 Debug.Assert(t != null);
3594
3595 CheckContextMatch(t);
3596 CheckContextMatch(p);
3597 return new Tactic(this, Native.Z3_tactic_when(nCtx, p.NativeObject, t.NativeObject));
3598 }
3599
3604 public Tactic Cond(Probe p, Tactic t1, Tactic t2)
3605 {
3606 Debug.Assert(p != null);
3607 Debug.Assert(t1 != null);
3608 Debug.Assert(t2 != null);
3609
3610 CheckContextMatch(p);
3611 CheckContextMatch(t1);
3612 CheckContextMatch(t2);
3613 return new Tactic(this, Native.Z3_tactic_cond(nCtx, p.NativeObject, t1.NativeObject, t2.NativeObject));
3614 }
3615
3620 public Tactic Repeat(Tactic t, uint max = uint.MaxValue)
3621 {
3622 Debug.Assert(t != null);
3623
3624 CheckContextMatch(t);
3625 return new Tactic(this, Native.Z3_tactic_repeat(nCtx, t.NativeObject, max));
3626 }
3627
3631 public Tactic Skip()
3632 {
3633
3634 return new Tactic(this, Native.Z3_tactic_skip(nCtx));
3635 }
3636
3640 public Tactic Fail()
3641 {
3642
3643 return new Tactic(this, Native.Z3_tactic_fail(nCtx));
3644 }
3645
3650 {
3651 Debug.Assert(p != null);
3652
3653 CheckContextMatch(p);
3654 return new Tactic(this, Native.Z3_tactic_fail_if(nCtx, p.NativeObject));
3655 }
3656
3662 {
3663
3664 return new Tactic(this, Native.Z3_tactic_fail_if_not_decided(nCtx));
3665 }
3666
3671 {
3672 Debug.Assert(t != null);
3673 Debug.Assert(p != null);
3674
3675 CheckContextMatch(t);
3676 CheckContextMatch(p);
3677 return new Tactic(this, Native.Z3_tactic_using_params(nCtx, t.NativeObject, p.NativeObject));
3678 }
3679
3685 {
3686 Debug.Assert(t != null);
3687 Debug.Assert(p != null);
3688
3689 return UsingParams(t, p);
3690 }
3691
3695 public Tactic ParOr(params Tactic[] t)
3696 {
3697 Debug.Assert(t == null || t.All(tactic => tactic != null));
3698
3699 CheckContextMatch<Tactic>(t);
3700 return new Tactic(this, Native.Z3_tactic_par_or(nCtx, Tactic.ArrayLength(t), Tactic.ArrayToNative(t)));
3701 }
3702
3708 {
3709 Debug.Assert(t1 != null);
3710 Debug.Assert(t2 != null);
3711
3712 CheckContextMatch(t1);
3713 CheckContextMatch(t2);
3714 return new Tactic(this, Native.Z3_tactic_par_and_then(nCtx, t1.NativeObject, t2.NativeObject));
3715 }
3716
3721 public void Interrupt()
3722 {
3723 Native.Z3_interrupt(nCtx);
3724 }
3725 #endregion
3726
3727 #region Probes
3731 public uint NumProbes
3732 {
3733 get { return Native.Z3_get_num_probes(nCtx); }
3734 }
3735
3739 public string[] ProbeNames
3740 {
3741 get
3742 {
3743
3744 uint n = NumProbes;
3745 string[] res = new string[n];
3746 for (uint i = 0; i < n; i++)
3747 res[i] = Native.Z3_get_probe_name(nCtx, i);
3748 return res;
3749 }
3750 }
3751
3755 public string ProbeDescription(string name)
3756 {
3757
3758 return Native.Z3_probe_get_descr(nCtx, name);
3759 }
3760
3764 public Probe MkProbe(string name)
3765 {
3766
3767 return new Probe(this, name);
3768 }
3769
3773 public Probe ConstProbe(double val)
3774 {
3775
3776 return new Probe(this, Native.Z3_probe_const(nCtx, val));
3777 }
3778
3783 public Probe Lt(Probe p1, Probe p2)
3784 {
3785 Debug.Assert(p1 != null);
3786 Debug.Assert(p2 != null);
3787
3788 CheckContextMatch(p1);
3789 CheckContextMatch(p2);
3790 return new Probe(this, Native.Z3_probe_lt(nCtx, p1.NativeObject, p2.NativeObject));
3791 }
3792
3797 public Probe Gt(Probe p1, Probe p2)
3798 {
3799 Debug.Assert(p1 != null);
3800 Debug.Assert(p2 != null);
3801
3802 CheckContextMatch(p1);
3803 CheckContextMatch(p2);
3804 return new Probe(this, Native.Z3_probe_gt(nCtx, p1.NativeObject, p2.NativeObject));
3805 }
3806
3811 public Probe Le(Probe p1, Probe p2)
3812 {
3813 Debug.Assert(p1 != null);
3814 Debug.Assert(p2 != null);
3815
3816 CheckContextMatch(p1);
3817 CheckContextMatch(p2);
3818 return new Probe(this, Native.Z3_probe_le(nCtx, p1.NativeObject, p2.NativeObject));
3819 }
3820
3825 public Probe Ge(Probe p1, Probe p2)
3826 {
3827 Debug.Assert(p1 != null);
3828 Debug.Assert(p2 != null);
3829
3830 CheckContextMatch(p1);
3831 CheckContextMatch(p2);
3832 return new Probe(this, Native.Z3_probe_ge(nCtx, p1.NativeObject, p2.NativeObject));
3833 }
3834
3839 public Probe Eq(Probe p1, Probe p2)
3840 {
3841 Debug.Assert(p1 != null);
3842 Debug.Assert(p2 != null);
3843
3844 CheckContextMatch(p1);
3845 CheckContextMatch(p2);
3846 return new Probe(this, Native.Z3_probe_eq(nCtx, p1.NativeObject, p2.NativeObject));
3847 }
3848
3853 public Probe And(Probe p1, Probe p2)
3854 {
3855 Debug.Assert(p1 != null);
3856 Debug.Assert(p2 != null);
3857
3858 CheckContextMatch(p1);
3859 CheckContextMatch(p2);
3860 return new Probe(this, Native.Z3_probe_and(nCtx, p1.NativeObject, p2.NativeObject));
3861 }
3862
3867 public Probe Or(Probe p1, Probe p2)
3868 {
3869 Debug.Assert(p1 != null);
3870 Debug.Assert(p2 != null);
3871
3872 CheckContextMatch(p1);
3873 CheckContextMatch(p2);
3874 return new Probe(this, Native.Z3_probe_or(nCtx, p1.NativeObject, p2.NativeObject));
3875 }
3876
3881 public Probe Not(Probe p)
3882 {
3883 Debug.Assert(p != null);
3884
3885 CheckContextMatch(p);
3886 return new Probe(this, Native.Z3_probe_not(nCtx, p.NativeObject));
3887 }
3888 #endregion
3889
3890 #region Solvers
3899 public Solver MkSolver(Symbol logic = null)
3900 {
3901
3902 if (logic == null)
3903 return new Solver(this, Native.Z3_mk_solver(nCtx));
3904 else
3905 return new Solver(this, Native.Z3_mk_solver_for_logic(nCtx, logic.NativeObject));
3906 }
3907
3912 public Solver MkSolver(string logic)
3913 {
3914 using var symbol = MkSymbol(logic);
3915 return MkSolver(symbol);
3916 }
3917
3922 {
3923
3924 return new Solver(this, Native.Z3_mk_simple_solver(nCtx));
3925 }
3926
3935 {
3936 Debug.Assert(t != null);
3937
3938 return new Solver(this, Native.Z3_mk_solver_from_tactic(nCtx, t.NativeObject));
3939 }
3940 #endregion
3941
3942 #region Fixedpoints
3947 {
3948
3949 return new Fixedpoint(this);
3950 }
3951 #endregion
3952
3953 #region Optimization
3958 {
3959
3960 return new Optimize(this);
3961 }
3962 #endregion
3963
3964 #region Floating-Point Arithmetic
3965
3966 #region Rounding Modes
3967 #region RoundingMode Sort
3972 {
3973 return new FPRMSort(this);
3974 }
3975 #endregion
3976
3977 #region Numerals
3982 {
3983 return new FPRMExpr(this, Native.Z3_mk_fpa_round_nearest_ties_to_even(nCtx));
3984 }
3985
3990 {
3991 return new FPRMNum(this, Native.Z3_mk_fpa_rne(nCtx));
3992 }
3993
3998 {
3999 return new FPRMNum(this, Native.Z3_mk_fpa_round_nearest_ties_to_away(nCtx));
4000 }
4001
4006 {
4007 return new FPRMNum(this, Native.Z3_mk_fpa_rna(nCtx));
4008 }
4009
4014 {
4015 return new FPRMNum(this, Native.Z3_mk_fpa_round_toward_positive(nCtx));
4016 }
4017
4022 {
4023 return new FPRMNum(this, Native.Z3_mk_fpa_rtp(nCtx));
4024 }
4025
4030 {
4031 return new FPRMNum(this, Native.Z3_mk_fpa_round_toward_negative(nCtx));
4032 }
4033
4038 {
4039 return new FPRMNum(this, Native.Z3_mk_fpa_rtn(nCtx));
4040 }
4041
4046 {
4047 return new FPRMNum(this, Native.Z3_mk_fpa_round_toward_zero(nCtx));
4048 }
4049
4054 {
4055 return new FPRMNum(this, Native.Z3_mk_fpa_rtz(nCtx));
4056 }
4057 #endregion
4058 #endregion
4059
4060 #region FloatingPoint Sorts
4066 public FPSort MkFPSort(uint ebits, uint sbits)
4067 {
4068 return new FPSort(this, ebits, sbits);
4069 }
4070
4075 {
4076 return new FPSort(this, Native.Z3_mk_fpa_sort_half(nCtx));
4077 }
4078
4083 {
4084 return new FPSort(this, Native.Z3_mk_fpa_sort_16(nCtx));
4085 }
4086
4091 {
4092 return new FPSort(this, Native.Z3_mk_fpa_sort_single(nCtx));
4093 }
4094
4099 {
4100 return new FPSort(this, Native.Z3_mk_fpa_sort_32(nCtx));
4101 }
4102
4107 {
4108 return new FPSort(this, Native.Z3_mk_fpa_sort_double(nCtx));
4109 }
4110
4115 {
4116 return new FPSort(this, Native.Z3_mk_fpa_sort_64(nCtx));
4117 }
4118
4123 {
4124 return new FPSort(this, Native.Z3_mk_fpa_sort_quadruple(nCtx));
4125 }
4126
4131 {
4132 return new FPSort(this, Native.Z3_mk_fpa_sort_128(nCtx));
4133 }
4134 #endregion
4135
4136 #region Numerals
4142 {
4143 return new FPNum(this, Native.Z3_mk_fpa_nan(nCtx, s.NativeObject));
4144 }
4145
4151 public FPNum MkFPInf(FPSort s, bool negative)
4152 {
4153 return new FPNum(this, Native.Z3_mk_fpa_inf(nCtx, s.NativeObject, (byte)(negative ? 1 : 0)));
4154 }
4155
4161 public FPNum MkFPZero(FPSort s, bool negative)
4162 {
4163 return new FPNum(this, Native.Z3_mk_fpa_zero(nCtx, s.NativeObject, (byte)(negative ? 1 : 0)));
4164 }
4165
4171 public FPNum MkFPNumeral(float v, FPSort s)
4172 {
4173 return new FPNum(this, Native.Z3_mk_fpa_numeral_float(nCtx, v, s.NativeObject));
4174 }
4175
4181 public FPNum MkFPNumeral(double v, FPSort s)
4182 {
4183 return new FPNum(this, Native.Z3_mk_fpa_numeral_double(nCtx, v, s.NativeObject));
4184 }
4185
4191 public FPNum MkFPNumeral(int v, FPSort s)
4192 {
4193 return new FPNum(this, Native.Z3_mk_fpa_numeral_int(nCtx, v, s.NativeObject));
4194 }
4195
4203 public FPNum MkFPNumeral(bool sgn, uint sig, int exp, FPSort s)
4204 {
4205 return new FPNum(this, Native.Z3_mk_fpa_numeral_int_uint(nCtx, (byte)(sgn ? 1 : 0), exp, sig, s.NativeObject));
4206 }
4207
4215 public FPNum MkFPNumeral(bool sgn, Int64 exp, UInt64 sig, FPSort s)
4216 {
4217 return new FPNum(this, Native.Z3_mk_fpa_numeral_int64_uint64(nCtx, (byte)(sgn ? 1 : 0), exp, sig, s.NativeObject));
4218 }
4219
4225 public FPNum MkFP(float v, FPSort s)
4226 {
4227 return MkFPNumeral(v, s);
4228 }
4229
4235 public FPNum MkFP(double v, FPSort s)
4236 {
4237 return MkFPNumeral(v, s);
4238 }
4239
4245 public FPNum MkFP(int v, FPSort s)
4246 {
4247 return MkFPNumeral(v, s);
4248 }
4249
4257 public FPNum MkFP(bool sgn, int exp, uint sig, FPSort s)
4258 {
4259 return MkFPNumeral(sgn, exp, sig, s);
4260 }
4261
4269 public FPNum MkFP(bool sgn, Int64 exp, UInt64 sig, FPSort s)
4270 {
4271 return MkFPNumeral(sgn, exp, sig, s);
4272 }
4273
4274 #endregion
4275
4276 #region Operators
4282 {
4283 return new FPExpr(this, Native.Z3_mk_fpa_abs(this.nCtx, t.NativeObject));
4284 }
4285
4291 {
4292 return new FPExpr(this, Native.Z3_mk_fpa_neg(this.nCtx, t.NativeObject));
4293 }
4294
4302 {
4303 return new FPExpr(this, Native.Z3_mk_fpa_add(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
4304 }
4305
4313 {
4314 return new FPExpr(this, Native.Z3_mk_fpa_sub(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
4315 }
4316
4324 {
4325 return new FPExpr(this, Native.Z3_mk_fpa_mul(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
4326 }
4327
4335 {
4336 return new FPExpr(this, Native.Z3_mk_fpa_div(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
4337 }
4338
4350 {
4351 return new FPExpr(this, Native.Z3_mk_fpa_fma(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject, t3.NativeObject));
4352 }
4353
4360 {
4361 return new FPExpr(this, Native.Z3_mk_fpa_sqrt(this.nCtx, rm.NativeObject, t.NativeObject));
4362 }
4363
4370 {
4371 return new FPExpr(this, Native.Z3_mk_fpa_rem(this.nCtx, t1.NativeObject, t2.NativeObject));
4372 }
4373
4381 {
4382 return new FPExpr(this, Native.Z3_mk_fpa_round_to_integral(this.nCtx, rm.NativeObject, t.NativeObject));
4383 }
4384
4391 {
4392 return new FPExpr(this, Native.Z3_mk_fpa_min(this.nCtx, t1.NativeObject, t2.NativeObject));
4393 }
4394
4401 {
4402 return new FPExpr(this, Native.Z3_mk_fpa_max(this.nCtx, t1.NativeObject, t2.NativeObject));
4403 }
4404
4411 {
4412 return new BoolExpr(this, Native.Z3_mk_fpa_leq(this.nCtx, t1.NativeObject, t2.NativeObject));
4413 }
4414
4421 {
4422 return new BoolExpr(this, Native.Z3_mk_fpa_lt(this.nCtx, t1.NativeObject, t2.NativeObject));
4423 }
4424
4431 {
4432 return new BoolExpr(this, Native.Z3_mk_fpa_geq(this.nCtx, t1.NativeObject, t2.NativeObject));
4433 }
4434
4441 {
4442 return new BoolExpr(this, Native.Z3_mk_fpa_gt(this.nCtx, t1.NativeObject, t2.NativeObject));
4443 }
4444
4454 {
4455 return new BoolExpr(this, Native.Z3_mk_fpa_eq(this.nCtx, t1.NativeObject, t2.NativeObject));
4456 }
4457
4463 {
4464 return new BoolExpr(this, Native.Z3_mk_fpa_is_normal(this.nCtx, t.NativeObject));
4465 }
4466
4472 {
4473 return new BoolExpr(this, Native.Z3_mk_fpa_is_subnormal(this.nCtx, t.NativeObject));
4474 }
4475
4481 {
4482 return new BoolExpr(this, Native.Z3_mk_fpa_is_zero(this.nCtx, t.NativeObject));
4483 }
4484
4490 {
4491 return new BoolExpr(this, Native.Z3_mk_fpa_is_infinite(this.nCtx, t.NativeObject));
4492 }
4493
4499 {
4500 return new BoolExpr(this, Native.Z3_mk_fpa_is_nan(this.nCtx, t.NativeObject));
4501 }
4502
4508 {
4509 return new BoolExpr(this, Native.Z3_mk_fpa_is_negative(this.nCtx, t.NativeObject));
4510 }
4511
4517 {
4518 return new BoolExpr(this, Native.Z3_mk_fpa_is_positive(this.nCtx, t.NativeObject));
4519 }
4520 #endregion
4521
4522 #region Conversions to FloatingPoint terms
4537 {
4538 return new FPExpr(this, Native.Z3_mk_fpa_fp(this.nCtx, sgn.NativeObject, sig.NativeObject, exp.NativeObject));
4539 }
4540
4553 {
4554 return new FPExpr(this, Native.Z3_mk_fpa_to_fp_bv(this.nCtx, bv.NativeObject, s.NativeObject));
4555 }
4556
4569 {
4570 return new FPExpr(this, Native.Z3_mk_fpa_to_fp_float(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
4571 }
4572
4585 {
4586 return new FPExpr(this, Native.Z3_mk_fpa_to_fp_real(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
4587 }
4588
4602 public FPExpr MkFPToFP(FPRMExpr rm, BitVecExpr t, FPSort s, bool signed)
4603 {
4604 if (signed)
4605 return new FPExpr(this, Native.Z3_mk_fpa_to_fp_signed(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
4606 else
4607 return new FPExpr(this, Native.Z3_mk_fpa_to_fp_unsigned(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
4608 }
4609
4621 {
4622 return new FPExpr(this, Native.Z3_mk_fpa_to_fp_float(this.nCtx, s.NativeObject, rm.NativeObject, t.NativeObject));
4623 }
4624 #endregion
4625
4626 #region Conversions from FloatingPoint terms
4639 public BitVecExpr MkFPToBV(FPRMExpr rm, FPExpr t, uint sz, bool sign)
4640 {
4641 if (sign)
4642 return new BitVecExpr(this, Native.Z3_mk_fpa_to_sbv(this.nCtx, rm.NativeObject, t.NativeObject, sz));
4643 else
4644 return new BitVecExpr(this, Native.Z3_mk_fpa_to_ubv(this.nCtx, rm.NativeObject, t.NativeObject, sz));
4645 }
4646
4657 {
4658 return new RealExpr(this, Native.Z3_mk_fpa_to_real(this.nCtx, t.NativeObject));
4659 }
4660 #endregion
4661
4662 #region Z3-specific extensions
4674 {
4675 return new BitVecExpr(this, Native.Z3_mk_fpa_to_ieee_bv(this.nCtx, t.NativeObject));
4676 }
4677
4691 {
4692 return new BitVecExpr(this, Native.Z3_mk_fpa_to_fp_int_real(this.nCtx, rm.NativeObject, exp.NativeObject, sig.NativeObject, s.NativeObject));
4693 }
4694 #endregion
4695 #endregion // Floating-point Arithmetic
4696
4697 #region Miscellaneous
4708 public AST WrapAST(IntPtr nativeObject)
4709 {
4710 return AST.Create(this, nativeObject);
4711 }
4712
4724 public IntPtr UnwrapAST(AST a)
4725 {
4726 return a.NativeObject;
4727 }
4728
4732 public string SimplifyHelp()
4733 {
4734
4735 return Native.Z3_simplify_get_help(nCtx);
4736 }
4737
4742 {
4743 get { return new ParamDescrs(this, Native.Z3_simplify_get_param_descrs(nCtx)); }
4744 }
4745 #endregion
4746
4747 #region Error Handling
4755 //public delegate void ErrorHandler(Context ctx, Z3_error_code errorCode, string errorString);
4756
4760 //public event ErrorHandler OnError = null;
4761 #endregion
4762
4763 #region Parameters
4773 public void UpdateParamValue(string id, string value)
4774 {
4775 Native.Z3_update_param_value(nCtx, id, value);
4776 }
4777
4778 #endregion
4779
4780 #region Internal
4781 internal IntPtr m_ctx = IntPtr.Zero;
4782 internal Native.Z3_error_handler m_n_err_handler = null;
4783 internal static Object creation_lock = new Object();
4784 internal IntPtr nCtx { get { return m_ctx; } }
4785
4786 internal void NativeErrorHandler(IntPtr ctx, Z3_error_code errorCode)
4787 {
4788 // Do-nothing error handler. The wrappers in Z3.Native will throw exceptions upon errors.
4789 }
4790
4791 internal void InitContext()
4792 {
4793 PrintMode = Z3_ast_print_mode.Z3_PRINT_SMTLIB2_COMPLIANT;
4794 m_n_err_handler = new Native.Z3_error_handler(NativeErrorHandler); // keep reference so it doesn't get collected.
4795 Native.Z3_set_error_handler(m_ctx, m_n_err_handler);
4796 GC.SuppressFinalize(this);
4797 }
4798
4799 internal void CheckContextMatch(Z3Object other)
4800 {
4801 Debug.Assert(other != null);
4802
4803 if (!ReferenceEquals(this, other.Context))
4804 throw new Z3Exception("Context mismatch");
4805 }
4806
4807 internal void CheckContextMatch(Z3Object other1, Z3Object other2)
4808 {
4809 Debug.Assert(other1 != null);
4810 Debug.Assert(other2 != null);
4811 CheckContextMatch(other1);
4812 CheckContextMatch(other2);
4813 }
4814
4815 internal void CheckContextMatch(Z3Object other1, Z3Object other2, Z3Object other3)
4816 {
4817 Debug.Assert(other1 != null);
4818 Debug.Assert(other2 != null);
4819 Debug.Assert(other3 != null);
4820 CheckContextMatch(other1);
4821 CheckContextMatch(other2);
4822 CheckContextMatch(other3);
4823 }
4824
4825 internal void CheckContextMatch(Z3Object[] arr)
4826 {
4827 Debug.Assert(arr == null || arr.All(a => a != null));
4828
4829 if (arr != null)
4830 {
4831 foreach (Z3Object a in arr)
4832 {
4833 Debug.Assert(a != null); // It was an assume, now we added the precondition, and we made it into an assert
4834 CheckContextMatch(a);
4835 }
4836 }
4837 }
4838
4839 internal void CheckContextMatch<T>(IEnumerable<T> arr) where T : Z3Object
4840 {
4841 Debug.Assert(arr == null || arr.All(a => a != null));
4842
4843 if (arr != null)
4844 {
4845 foreach (Z3Object a in arr)
4846 {
4847 Debug.Assert(a != null); // It was an assume, now we added the precondition, and we made it into an assert
4848 CheckContextMatch(a);
4849 }
4850 }
4851 }
4852
4853 private void ObjectInvariant()
4854 {
4855 Debug.Assert(m_AST_DRQ != null);
4856 Debug.Assert(m_ASTMap_DRQ != null);
4857 Debug.Assert(m_ASTVector_DRQ != null);
4858 Debug.Assert(m_ApplyResult_DRQ != null);
4859 Debug.Assert(m_FuncEntry_DRQ != null);
4860 Debug.Assert(m_FuncInterp_DRQ != null);
4861 Debug.Assert(m_Goal_DRQ != null);
4862 Debug.Assert(m_Model_DRQ != null);
4863 Debug.Assert(m_Params_DRQ != null);
4864 Debug.Assert(m_ParamDescrs_DRQ != null);
4865 Debug.Assert(m_Probe_DRQ != null);
4866 Debug.Assert(m_Solver_DRQ != null);
4867 Debug.Assert(m_Statistics_DRQ != null);
4868 Debug.Assert(m_Tactic_DRQ != null);
4869 Debug.Assert(m_Fixedpoint_DRQ != null);
4870 Debug.Assert(m_Optimize_DRQ != null);
4871 }
4872
4873 readonly private AST.DecRefQueue m_AST_DRQ = new AST.DecRefQueue();
4874 readonly private ASTMap.DecRefQueue m_ASTMap_DRQ = new ASTMap.DecRefQueue(10);
4875 readonly private ASTVector.DecRefQueue m_ASTVector_DRQ = new ASTVector.DecRefQueue(10);
4876 readonly private ApplyResult.DecRefQueue m_ApplyResult_DRQ = new ApplyResult.DecRefQueue(10);
4877 readonly private FuncInterp.Entry.DecRefQueue m_FuncEntry_DRQ = new FuncInterp.Entry.DecRefQueue(10);
4878 readonly private FuncInterp.DecRefQueue m_FuncInterp_DRQ = new FuncInterp.DecRefQueue(10);
4879 readonly private Goal.DecRefQueue m_Goal_DRQ = new Goal.DecRefQueue(10);
4880 readonly private Model.DecRefQueue m_Model_DRQ = new Model.DecRefQueue(10);
4881 readonly private Params.DecRefQueue m_Params_DRQ = new Params.DecRefQueue(10);
4882 readonly private ParamDescrs.DecRefQueue m_ParamDescrs_DRQ = new ParamDescrs.DecRefQueue(10);
4883 readonly private Probe.DecRefQueue m_Probe_DRQ = new Probe.DecRefQueue(10);
4884 readonly private Solver.DecRefQueue m_Solver_DRQ = new Solver.DecRefQueue(10);
4885 readonly private Statistics.DecRefQueue m_Statistics_DRQ = new Statistics.DecRefQueue(10);
4886 readonly private Tactic.DecRefQueue m_Tactic_DRQ = new Tactic.DecRefQueue(10);
4887 readonly private Fixedpoint.DecRefQueue m_Fixedpoint_DRQ = new Fixedpoint.DecRefQueue(10);
4888 readonly private Optimize.DecRefQueue m_Optimize_DRQ = new Optimize.DecRefQueue(10);
4889
4893 public IDecRefQueue AST_DRQ { get { return m_AST_DRQ; } }
4894
4898 public IDecRefQueue ASTMap_DRQ { get { return m_ASTMap_DRQ; } }
4899
4903 public IDecRefQueue ASTVector_DRQ { get { return m_ASTVector_DRQ; } }
4904
4908 public IDecRefQueue ApplyResult_DRQ { get { return m_ApplyResult_DRQ; } }
4909
4913 public IDecRefQueue FuncEntry_DRQ { get { return m_FuncEntry_DRQ; } }
4914
4918 public IDecRefQueue FuncInterp_DRQ { get { return m_FuncInterp_DRQ; } }
4919
4923 public IDecRefQueue Goal_DRQ { get { return m_Goal_DRQ; } }
4924
4928 public IDecRefQueue Model_DRQ { get { return m_Model_DRQ; } }
4929
4933 public IDecRefQueue Params_DRQ { get { return m_Params_DRQ; } }
4934
4938 public IDecRefQueue ParamDescrs_DRQ { get { return m_ParamDescrs_DRQ; } }
4939
4943 public IDecRefQueue Probe_DRQ { get { return m_Probe_DRQ; } }
4944
4948 public IDecRefQueue Solver_DRQ { get { return m_Solver_DRQ; } }
4949
4953 public IDecRefQueue Statistics_DRQ { get { return m_Statistics_DRQ; } }
4954
4958 public IDecRefQueue Tactic_DRQ { get { return m_Tactic_DRQ; } }
4959
4963 public IDecRefQueue Fixedpoint_DRQ { get { return m_Fixedpoint_DRQ; } }
4964
4968 public IDecRefQueue Optimize_DRQ { get { return m_Fixedpoint_DRQ; } }
4969
4970 internal long refCount = 0;
4971
4975 ~Context()
4976 {
4977 // Console.WriteLine("Context Finalizer from " + System.Threading.Thread.CurrentThread.ManagedThreadId);
4978 Dispose();
4979 }
4980
4984 public void Dispose()
4985 {
4986 // Console.WriteLine("Context Dispose from " + System.Threading.Thread.CurrentThread.ManagedThreadId);
4987 AST_DRQ.Clear(this);
4988 ASTMap_DRQ.Clear(this);
4989 ASTVector_DRQ.Clear(this);
4990 ApplyResult_DRQ.Clear(this);
4991 FuncEntry_DRQ.Clear(this);
4992 FuncInterp_DRQ.Clear(this);
4993 Goal_DRQ.Clear(this);
4994 Model_DRQ.Clear(this);
4995 Params_DRQ.Clear(this);
4996 ParamDescrs_DRQ.Clear(this);
4997 Probe_DRQ.Clear(this);
4998 Solver_DRQ.Clear(this);
4999 Statistics_DRQ.Clear(this);
5000 Tactic_DRQ.Clear(this);
5001 Fixedpoint_DRQ.Clear(this);
5002 Optimize_DRQ.Clear(this);
5003
5004 if (m_boolSort != null) m_boolSort.Dispose();
5005 if (m_intSort != null) m_intSort.Dispose();
5006 if (m_realSort != null) m_realSort.Dispose();
5007 if (m_stringSort != null) m_stringSort.Dispose();
5008 if (m_charSort != null) m_charSort.Dispose();
5009 m_boolSort = null;
5010 m_intSort = null;
5011 m_realSort = null;
5012 m_stringSort = null;
5013 m_charSort = null;
5014 if (refCount == 0 && m_ctx != IntPtr.Zero)
5015 {
5016 m_n_err_handler = null;
5017 IntPtr ctx = m_ctx;
5018 m_ctx = IntPtr.Zero;
5019 if (!is_external)
5020 Native.Z3_del_context(ctx);
5021 }
5022 else
5023 GC.ReRegisterForFinalize(this);
5024 }
5025
5026
5027 #endregion
5028 }
5029}
The abstract syntax tree (AST) class.
Definition: AST.cs:31
Vectors of ASTs.
Definition: ASTVector.cs:29
BoolExpr[] ToBoolExprArray()
Translates an ASTVector into a BoolExpr[]
Definition: ASTVector.cs:127
Arithmetic expressions (int/real)
Definition: ArithExpr.cs:31
Array expressions
Definition: ArrayExpr.cs:32
Bit-vector expressions
Definition: BitVecExpr.cs:32
Bit-vector numerals
Definition: BitVecNum.cs:32
Bit-vector sorts.
Definition: BitVecSort.cs:29
Boolean expressions
Definition: BoolExpr.cs:32
A Boolean sort.
Definition: BoolSort.cs:29
A Character sort
Definition: CharSort.cs:29
Constructors are used for datatype sorts.
Definition: Constructor.cs:29
Lists of constructors
The main interaction with Z3 happens via the Context.
Definition: Context.cs:34
FPExpr MkFPToFP(FPRMExpr rm, RealExpr t, FPSort s)
Conversion of a term of real sort into a term of FloatingPoint sort.
Definition: Context.cs:4584
BitVecExpr MkBVNAND(BitVecExpr t1, BitVecExpr t2)
Bitwise NAND.
Definition: Context.cs:1395
FPNum MkFP(float v, FPSort s)
Create a numeral of FloatingPoint sort from a float.
Definition: Context.cs:4225
RealExpr MkInt2Real(IntExpr t)
Coerce an integer to a real.
Definition: Context.cs:1277
FPSort MkFPSort16()
Create the half-precision (16-bit) FloatingPoint sort.
Definition: Context.cs:4082
BoolExpr MkCharLe(Expr ch1, Expr ch2)
Create less than or equal to between two characters.
Definition: Context.cs:2791
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...
Definition: Context.cs:2943
ArrayExpr MkArrayConst(string name, Sort domain, Sort range)
Create an array constant.
Definition: Context.cs:2113
BoolExpr MkAtLeast(IEnumerable< BoolExpr > args, uint k)
Create an at-least-k constraint.
Definition: Context.cs:2853
BitVecExpr MkBVSHL(BitVecExpr t1, BitVecExpr t2)
Shift left.
Definition: Context.cs:1808
IDecRefQueue ParamDescrs_DRQ
ParamDescrs DRQ
Definition: Context.cs:4938
Tactic Skip()
Create a tactic that just returns the given goal.
Definition: Context.cs:3631
Constructor MkConstructor(string name, string recognizer, string[] fieldNames=null, Sort[] sorts=null, uint[] sortRefs=null)
Create a datatype constructor.
Definition: Context.cs:430
BoolSort BoolSort
Retrieves the Boolean sort of the context.
Definition: Context.cs:145
BitVecNum MkBV(bool[] bits)
Create a bit-vector numeral.
Definition: Context.cs:3170
FiniteDomainSort MkFiniteDomainSort(Symbol name, ulong size)
Create a new finite domain sort. The result is a sort
Definition: Context.cs:379
BoolExpr MkStringLe(SeqExpr s1, SeqExpr s2)
Check if the string s1 is lexicographically less or equal to s2.
Definition: Context.cs:2577
FPSort MkFPSort(uint ebits, uint sbits)
Create a FloatingPoint sort.
Definition: Context.cs:4066
Tactic With(Tactic t, Params p)
Create a tactic that applies t using the given set of parameters p .
Definition: Context.cs:3684
string[] TacticNames
The names of all supported tactics.
Definition: Context.cs:3478
BoolExpr MkIsDigit(Expr ch)
Create a check if the character is a digit.
Definition: Context.cs:2828
FPExpr MkFPAdd(FPRMExpr rm, FPExpr t1, FPExpr t2)
Floating-point addition
Definition: Context.cs:4301
BitVecExpr MkBVRotateLeft(BitVecExpr t1, BitVecExpr t2)
Rotate Left.
Definition: Context.cs:1901
RealExpr MkRealConst(string name)
Creates a real constant.
Definition: Context.cs:833
RatNum MkReal(uint v)
Create a real numeral.
Definition: Context.cs:3025
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...
Definition: Context.cs:3797
BitVecExpr MkBVLSHR(BitVecExpr t1, BitVecExpr t2)
Logical shift right
Definition: Context.cs:1830
FPRMSort MkFPRoundingModeSort()
Create the floating-point RoundingMode sort.
Definition: Context.cs:3971
RealExpr MkFPToReal(FPExpr t)
Conversion of a floating-point term into a real-numbered term.
Definition: Context.cs:4656
TupleSort MkTupleSort(Symbol name, Symbol[] fieldNames, Sort[] fieldSorts)
Create a new tuple sort.
Definition: Context.cs:300
Lambda MkLambda(Expr[] boundConstants, Expr body)
Create a lambda expression.
Definition: Context.cs:3360
IDecRefQueue Params_DRQ
Params DRQ
Definition: Context.cs:4933
BitVecSort MkBitVecSort(uint size)
Create a new bit-vector sort.
Definition: Context.cs:248
BoolExpr MkBVMulNoUnderflow(BitVecExpr t1, BitVecExpr t2)
Create a predicate that checks that the bit-wise multiplication does not underflow.
Definition: Context.cs:2085
ReExpr MkDiff(ReExpr a, ReExpr b)
Create a difference regular expression.
Definition: Context.cs:2748
ArrayExpr MkFullSet(Sort domain)
Create the full set.
Definition: Context.cs:2327
FPSort MkFPSortQuadruple()
Create the quadruple-precision (128-bit) FloatingPoint sort.
Definition: Context.cs:4122
BoolExpr MkLe(ArithExpr t1, ArithExpr t2)
Create an expression representing t1 <= t2
Definition: Context.cs:1231
Probe ConstProbe(double val)
Create a probe that always evaluates to val .
Definition: Context.cs:3773
Expr MkFreshConst(string prefix, Sort range)
Creates a fresh Constant of sort range and a name prefixed with prefix .
Definition: Context.cs:762
IntExpr MkReal2Int(RealExpr t)
Coerce a real to an integer.
Definition: Context.cs:1292
UninterpretedSort MkUninterpretedSort(Symbol s)
Create a new uninterpreted sort.
Definition: Context.cs:211
FPSort MkFPSortHalf()
Create the half-precision (16-bit) FloatingPoint sort.
Definition: Context.cs:4074
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.
Definition: Context.cs:3231
ArrayExpr MkSetDifference(ArrayExpr arg1, ArrayExpr arg2)
Take the difference between two sets.
Definition: Context.cs:2389
BoolExpr MkXor(BoolExpr t1, BoolExpr t2)
Create an expression representing t1 xor t2.
Definition: Context.cs:1008
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...
Definition: Context.cs:2958
Expr MkITE(BoolExpr t1, Expr t2, Expr t3)
Create an expression representing an if-then-else: ite(t1, t2, t3).
Definition: Context.cs:967
IntNum MkInt(uint v)
Create an integer numeral.
Definition: Context.cs:3081
IntExpr MkIntConst(Symbol name)
Creates an integer constant.
Definition: Context.cs:803
AST WrapAST(IntPtr nativeObject)
Wraps an AST.
Definition: Context.cs:4708
SeqExpr IntToString(Expr e)
Convert an integer expression to a string.
Definition: Context.cs:2470
FPExpr MkFPMax(FPExpr t1, FPExpr t2)
Maximum of floating-point numbers.
Definition: Context.cs:4400
ArithExpr MkUnaryMinus(ArithExpr t)
Create an expression representing -t.
Definition: Context.cs:1153
BitVecExpr MkFPToIEEEBV(FPExpr t)
Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
Definition: Context.cs:4673
ArithExpr MkSub(params ArithExpr[] t)
Create an expression representing t[0] - t[1] - ....
Definition: Context.cs:1141
Constructor MkConstructor(Symbol name, Symbol recognizer, Symbol[] fieldNames=null, Sort[] sorts=null, uint[] sortRefs=null)
Create a datatype constructor.
Definition: Context.cs:413
IntSort IntSort
Retrieves the Integer sort of the context.
Definition: Context.cs:156
BoolExpr MkSuffixOf(SeqExpr s1, SeqExpr s2)
Check for sequence suffix.
Definition: Context.cs:2544
SeqExpr MkConcat(params SeqExpr[] t)
Concatenate sequences.
Definition: Context.cs:2511
FuncDecl MkFuncDecl(string name, Sort domain, Sort range)
Creates a new function declaration.
Definition: Context.cs:627
BoolExpr MkNot(BoolExpr a)
Mk an expression representing not(a).
Definition: Context.cs:953
FuncDecl MkFuncDecl(string name, Sort[] domain, Sort range)
Creates a new function declaration.
Definition: Context.cs:584
FuncDecl MkUserPropagatorFuncDecl(string name, Sort[] domain, Sort range)
Declare a function to be processed by the user propagator plugin.
Definition: Context.cs:695
Expr MkTermArray(ArrayExpr array)
Access the array default value.
Definition: Context.cs:2278
BitVecExpr MkBVSRem(BitVecExpr t1, BitVecExpr t2)
Signed remainder.
Definition: Context.cs:1557
BitVecExpr MkBVRedOR(BitVecExpr t)
Take disjunction of bits in a vector, return vector of length 1.
Definition: Context.cs:1341
Tactic MkTactic(string name)
Creates a new Tactic.
Definition: Context.cs:3502
BoolExpr MkFPLEq(FPExpr t1, FPExpr t2)
Floating-point less than or equal.
Definition: Context.cs:4410
ReExpr MkOption(ReExpr re)
Create the optional regular expression.
Definition: Context.cs:2694
BoolExpr MkFPEq(FPExpr t1, FPExpr t2)
Floating-point equality.
Definition: Context.cs:4453
DatatypeSort[] MkDatatypeSorts(Symbol[] names, Constructor[][] c)
Create mutually recursive datatypes.
Definition: Context.cs:480
SeqExpr MkExtract(SeqExpr s, IntExpr offset, IntExpr length)
Extract subsequence.
Definition: Context.cs:2610
RatNum MkReal(string v)
Create a real numeral.
Definition: Context.cs:3003
FPExpr MkFPToFP(FPRMExpr rm, FPExpr t, FPSort s)
Conversion of a FloatingPoint term into another term of different FloatingPoint sort.
Definition: Context.cs:4568
DatatypeSort MkDatatypeSort(string name, Constructor[] constructors)
Create a new datatype sort.
Definition: Context.cs:465
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.
Definition: Context.cs:4602
Tactic UsingParams(Tactic t, Params p)
Create a tactic that applies t using the given set of parameters p .
Definition: Context.cs:3670
BoolExpr MkBVNegNoOverflow(BitVecExpr t)
Create a predicate that checks that the bit-wise negation does not overflow.
Definition: Context.cs:2055
ListSort MkListSort(string name, Sort elemSort)
Create a new list sort.
Definition: Context.cs:364
uint NumTactics
The number of supported tactics.
Definition: Context.cs:3470
SeqExpr UbvToString(Expr e)
Convert a bit-vector expression, represented as an unsigned number, to a string.
Definition: Context.cs:2480
ReExpr MkConcat(params ReExpr[] t)
Create the concatenation of regular languages.
Definition: Context.cs:2712
BoolExpr MkBVULT(BitVecExpr t1, BitVecExpr t2)
Unsigned less-than
Definition: Context.cs:1590
BoolExpr MkBVMulNoOverflow(BitVecExpr t1, BitVecExpr t2, bool isSigned)
Create a predicate that checks that the bit-wise multiplication does not overflow.
Definition: Context.cs:2069
FuncDecl MkConstDecl(Symbol name, Sort range)
Creates a new constant function declaration.
Definition: Context.cs:657
BitVecExpr MkBVSDiv(BitVecExpr t1, BitVecExpr t2)
Signed division.
Definition: Context.cs:1519
ParamDescrs SimplifyParameterDescriptions
Retrieves parameter descriptions for simplifier.
Definition: Context.cs:4742
BitVecNum MkBV(ulong v, uint size)
Create a bit-vector numeral.
Definition: Context.cs:3160
FPExpr MkFPFMA(FPRMExpr rm, FPExpr t1, FPExpr t2, FPExpr t3)
Floating-point fused multiply-add
Definition: Context.cs:4349
BoolExpr MkFPIsInfinite(FPExpr t)
Predicate indicating whether t is a floating-point number representing +oo or -oo.
Definition: Context.cs:4489
BitVecExpr MkInt2BV(uint n, IntExpr t)
Create an n bit bit-vector from the integer argument t .
Definition: Context.cs:1938
BoolExpr MkTrue()
The true Term.
Definition: Context.cs:891
FPExpr MkFPSub(FPRMExpr rm, FPExpr t1, FPExpr t2)
Floating-point subtraction
Definition: Context.cs:4312
FPNum MkFPNumeral(double v, FPSort s)
Create a numeral of FloatingPoint sort from a float.
Definition: Context.cs:4181
FPExpr MkFPToFP(BitVecExpr bv, FPSort s)
Conversion of a single IEEE 754-2008 bit-vector into a floating-point number.
Definition: Context.cs:4552
ReExpr MkUnion(params ReExpr[] t)
Create the union of regular languages.
Definition: Context.cs:2724
RatNum MkReal(ulong v)
Create a real numeral.
Definition: Context.cs:3047
BoolExpr MkBoolConst(Symbol name)
Create a Boolean constant.
Definition: Context.cs:784
IDecRefQueue Model_DRQ
Model DRQ
Definition: Context.cs:4928
ReExpr MkEmptyRe(Sort s)
Create the empty regular expression. The sort s should be a regular expression.
Definition: Context.cs:2760
Expr MkNth(SeqExpr s, Expr index)
Retrieve element at index.
Definition: Context.cs:2599
FPSort MkFPSortSingle()
Create the single-precision (32-bit) FloatingPoint sort.
Definition: Context.cs:4090
IntPtr UnwrapAST(AST a)
Unwraps an AST.
Definition: Context.cs:4724
IntExpr MkMod(IntExpr t1, IntExpr t2)
Create an expression representing t1 mod t2.
Definition: Context.cs:1178
BoolExpr MkPBLe(int[] coeffs, BoolExpr[] args, int k)
Create a pseudo-Boolean less-or-equal constraint.
Definition: Context.cs:2865
IntNum MkInt(string v)
Create an integer numeral.
Definition: Context.cs:3059
Expr MkConst(FuncDecl f)
Creates a fresh constant from the FuncDecl f .
Definition: Context.cs:774
FPRMNum MkFPRTZ()
Create a numeral of RoundingMode sort which represents the RoundTowardZero rounding mode.
Definition: Context.cs:4053
IDecRefQueue Optimize_DRQ
Optimize DRQ
Definition: Context.cs:4968
Tactic TryFor(Tactic t, uint ms)
Create a tactic that applies t to a goal for ms milliseconds.
Definition: Context.cs:3575
BoolExpr MkImplies(BoolExpr t1, BoolExpr t2)
Create an expression representing t1 -> t2.
Definition: Context.cs:995
BoolExpr MkBVSubNoUnderflow(BitVecExpr t1, BitVecExpr t2, bool isSigned)
Create a predicate that checks that the bit-wise subtraction does not underflow.
Definition: Context.cs:2023
Expr MkSelect(ArrayExpr a, Expr i)
Array read.
Definition: Context.cs:2137
ArrayExpr MkSetUnion(params ArrayExpr[] args)
Take the union of a list of sets.
Definition: Context.cs:2365
IDecRefQueue ApplyResult_DRQ
ApplyResult DRQ
Definition: Context.cs:4908
IDecRefQueue ASTVector_DRQ
ASTVector DRQ
Definition: Context.cs:4903
IntExpr MkIndexOf(SeqExpr s, SeqExpr substr, ArithExpr offset)
Extract index of sub-string starting at offset.
Definition: Context.cs:2622
BoolExpr MkBoolConst(string name)
Create a Boolean constant.
Definition: Context.cs:794
Expr MkApp(FuncDecl f, params Expr[] args)
Create a new function application.
Definition: Context.cs:864
BitVecExpr MkBVSMod(BitVecExpr t1, BitVecExpr t2)
Two's complement signed remainder (sign follows divisor).
Definition: Context.cs:1574
IDecRefQueue Goal_DRQ
Goal DRQ
Definition: Context.cs:4923
Probe Or(Probe p1, Probe p2)
Create a probe that evaluates to "true" when the value p1 or p2 evaluate to "true".
Definition: Context.cs:3867
BitVecExpr MkRepeat(uint i, BitVecExpr t)
Bit-vector repetition.
Definition: Context.cs:1788
BoolExpr MkDistinct(IEnumerable< Expr > args)
Creates a distinct term.
Definition: Context.cs:944
FuncDecl MkFuncDecl(Symbol name, Sort domain, Sort range)
Creates a new function declaration.
Definition: Context.cs:568
BoolExpr MkFPGt(FPExpr t1, FPExpr t2)
Floating-point greater than.
Definition: Context.cs:4440
BoolExpr MkAtMost(IEnumerable< BoolExpr > args, uint k)
Create an at-most-k constraint.
Definition: Context.cs:2841
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 ....
Definition: Context.cs:3707
Solver MkSolver(string logic)
Creates a new (incremental) solver.
Definition: Context.cs:3912
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.
Definition: Context.cs:3309
ArrayExpr MkSetDel(ArrayExpr set, Expr element)
Remove an element from a set.
Definition: Context.cs:2352
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....
Definition: Context.cs:539
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...
Definition: Context.cs:3783
ReExpr MkRange(SeqExpr lo, SeqExpr hi)
Create a range expression.
Definition: Context.cs:2780
BitVecNum MkBV(long v, uint size)
Create a bit-vector numeral.
Definition: Context.cs:3149
BoolExpr MkBVSGT(BitVecExpr t1, BitVecExpr t2)
Two's complement signed greater-than.
Definition: Context.cs:1702
Params MkParams()
Creates a new ParameterSet.
Definition: Context.cs:3458
ArrayExpr MkSetIntersection(params ArrayExpr[] args)
Take the intersection of a list of sets.
Definition: Context.cs:2377
FPNum MkFPNaN(FPSort s)
Create a NaN of sort s.
Definition: Context.cs:4141
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.
Definition: Context.cs:4269
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.
Definition: Context.cs:3401
BitVecExpr MkBVNOR(BitVecExpr t1, BitVecExpr t2)
Bitwise NOR.
Definition: Context.cs:1409
IntExpr CharToInt(Expr ch)
Create an integer (code point) from character.
Definition: Context.cs:2801
BoolExpr MkDistinct(params Expr[] args)
Creates a distinct term.
Definition: Context.cs:931
FPExpr MkFPRoundToIntegral(FPRMExpr rm, FPExpr t)
Floating-point roundToIntegral. Rounds a floating-point number to the closest integer,...
Definition: Context.cs:4380
Fixedpoint MkFixedpoint()
Create a Fixedpoint context.
Definition: Context.cs:3946
BoolExpr MkXor(IEnumerable< BoolExpr > ts)
Create an expression representing t1 xor t2 xor t3 ... .
Definition: Context.cs:1021
void UpdateParamValue(string id, string value)
Update a mutable configuration parameter.
Definition: Context.cs:4773
DatatypeSort MkDatatypeSort(Symbol name, Constructor[] constructors)
Create a new datatype sort.
Definition: Context.cs:450
IDecRefQueue Statistics_DRQ
Statistics DRQ
Definition: Context.cs:4953
void AddRecDef(FuncDecl f, Expr[] args, Expr body)
Bind a definition to a recursive function declaration. The function must have previously been created...
Definition: Context.cs:615
FPNum MkFPNumeral(float v, FPSort s)
Create a numeral of FloatingPoint sort from a float.
Definition: Context.cs:4171
ArrayExpr MkConstArray(Sort domain, Expr v)
Create a constant array.
Definition: Context.cs:2240
ArrayExpr MkSetComplement(ArrayExpr arg)
Take the complement of a set.
Definition: Context.cs:2402
BoolExpr MkSetSubset(ArrayExpr arg1, ArrayExpr arg2)
Check for subsetness of sets.
Definition: Context.cs:2426
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...
Definition: Context.cs:3839
FPRMNum MkFPRoundNearestTiesToAway()
Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
Definition: Context.cs:3997
string[] ProbeNames
The names of all supported Probes.
Definition: Context.cs:3740
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 .
Definition: Context.cs:3512
BitVecExpr MkZeroExt(uint i, BitVecExpr t)
Bit-vector zero extension.
Definition: Context.cs:1774
Z3_ast_print_mode PrintMode
Selects the format used for pretty-printing expressions.
Definition: Context.cs:3390
IDecRefQueue FuncEntry_DRQ
FuncEntry DRQ
Definition: Context.cs:4913
void Dispose()
Disposes of the context.
Definition: Context.cs:4984
BitVecExpr CharToBV(Expr ch)
Create a bit-vector (code point) from character.
Definition: Context.cs:2810
SeqExpr SbvToString(Expr e)
Convert a bit-vector expression, represented as an signed number, to a string.
Definition: Context.cs:2490
IDecRefQueue Solver_DRQ
Solver DRQ
Definition: Context.cs:4948
ArrayExpr MkEmptySet(Sort domain)
Create an empty set.
Definition: Context.cs:2316
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.
Definition: Context.cs:3249
UninterpretedSort MkUninterpretedSort(string str)
Create a new uninterpreted sort.
Definition: Context.cs:222
IDecRefQueue FuncInterp_DRQ
FuncInterp DRQ
Definition: Context.cs:4918
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...
Definition: Context.cs:2973
ReExpr MkStar(ReExpr re)
Take the Kleene star of a regular expression.
Definition: Context.cs:2667
Context()
Constructor.
Definition: Context.cs:39
BitVecExpr MkBVConst(string name, uint size)
Creates a bit-vector constant.
Definition: Context.cs:853
BitVecNum MkBV(uint v, uint size)
Create a bit-vector numeral.
Definition: Context.cs:3138
Optimize MkOptimize()
Create an Optimization context.
Definition: Context.cs:3957
IDecRefQueue AST_DRQ
AST DRQ
Definition: Context.cs:4893
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.
Definition: Context.cs:3286
Expr CharFromBV(BitVecExpr bv)
Create a character from a bit-vector (code point).
Definition: Context.cs:2819
Expr MkArrayExt(ArrayExpr arg1, ArrayExpr arg2)
Create Extentionality index. Two arrays are equal if and only if they are equal on the index returned...
Definition: Context.cs:2289
CharSort CharSort
Retrieves the String sort of the context.
Definition: Context.cs:179
FPNum MkFPInf(FPSort s, bool negative)
Create a floating-point infinity of sort s.
Definition: Context.cs:4151
FuncDecl MkConstDecl(string name, Sort range)
Creates a new constant function declaration.
Definition: Context.cs:670
ArrayExpr MkMap(FuncDecl f, params ArrayExpr[] args)
Maps f on the argument arrays.
Definition: Context.cs:2261
ReExpr MkIntersect(params ReExpr[] t)
Create the intersection of regular languages.
Definition: Context.cs:2736
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...
Definition: Context.cs:3620
BoolExpr MkBVSLE(BitVecExpr t1, BitVecExpr t2)
Two's complement signed less-than or equal to.
Definition: Context.cs:1638
FPNum MkFP(int v, FPSort s)
Create a numeral of FloatingPoint sort from an int.
Definition: Context.cs:4245
IDecRefQueue Fixedpoint_DRQ
FixedPoint DRQ
Definition: Context.cs:4963
BoolExpr MkLt(ArithExpr t1, ArithExpr t2)
Create an expression representing t1 < t2
Definition: Context.cs:1218
FPNum MkFP(bool sgn, int exp, uint sig, FPSort s)
Create a numeral of FloatingPoint sort from a sign bit and two integers.
Definition: Context.cs:4257
ListSort MkListSort(Symbol name, Sort elemSort)
Create a new list sort.
Definition: Context.cs:351
SeqExpr MkAt(SeqExpr s, Expr index)
Retrieve sequence of length one at index.
Definition: Context.cs:2588
FPExpr MkFPToFP(FPSort s, FPRMExpr rm, FPExpr t)
Conversion of a floating-point number to another FloatingPoint sort s.
Definition: Context.cs:4620
BoolExpr MkSetMembership(Expr elem, ArrayExpr set)
Check for set membership.
Definition: Context.cs:2413
BitVecExpr MkBVRotateRight(BitVecExpr t1, BitVecExpr t2)
Rotate Right.
Definition: Context.cs:1918
SeqExpr MkReplace(SeqExpr s, SeqExpr src, SeqExpr dst)
Replace the first occurrence of src by dst in s.
Definition: Context.cs:2634
FPRMExpr MkFPRoundNearestTiesToEven()
Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
Definition: Context.cs:3981
string ProbeDescription(string name)
Returns a string containing a description of the probe with the given name.
Definition: Context.cs:3755
Pattern MkPattern(params Expr[] terms)
Create a quantifier pattern.
Definition: Context.cs:721
Probe And(Probe p1, Probe p2)
Create a probe that evaluates to "true" when the value p1 and p2 evaluate to "true".
Definition: Context.cs:3853
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...
Definition: Context.cs:3811
FPExpr MkFPNeg(FPExpr t)
Floating-point negation
Definition: Context.cs:4290
FPSort MkFPSort32()
Create the single-precision (32-bit) FloatingPoint sort.
Definition: Context.cs:4098
Expr MkConst(Symbol name, Sort range)
Creates a new Constant of sort range and named name .
Definition: Context.cs:736
RealSort RealSort
Retrieves the Real sort of the context.
Definition: Context.cs:168
BoolExpr MkAnd(params BoolExpr[] t)
Create an expression representing t[0] and t[1] and ....
Definition: Context.cs:1037
BoolExpr MkIsInteger(RealExpr t)
Creates an expression that checks whether a real number is an integer.
Definition: Context.cs:1303
BitVecExpr MkBVXNOR(BitVecExpr t1, BitVecExpr t2)
Bitwise XNOR.
Definition: Context.cs:1423
BoolExpr MkBVULE(BitVecExpr t1, BitVecExpr t2)
Unsigned less-than or equal to.
Definition: Context.cs:1622
BoolExpr MkGe(ArithExpr t1, ArithExpr t2)
Create an expression representing t1 >= t2
Definition: Context.cs:1257
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.
Definition: Context.cs:4215
BitVecExpr MkFPToBV(FPRMExpr rm, FPExpr t, uint sz, bool sign)
Conversion of a floating-point term into a bit-vector.
Definition: Context.cs:4639
BoolExpr MkBVAddNoUnderflow(BitVecExpr t1, BitVecExpr t2)
Create a predicate that checks that the bit-wise addition does not underflow.
Definition: Context.cs:1991
BitVecNum MkBV(string v, uint size)
Create a bit-vector numeral.
Definition: Context.cs:3116
ReExpr MkFullRe(Sort s)
Create the full regular expression. The sort s should be a regular expression.
Definition: Context.cs:2770
ArithExpr MkMul(params ArithExpr[] t)
Create an expression representing t[0] * t[1] * ....
Definition: Context.cs:1115
BoolExpr MkFPIsSubnormal(FPExpr t)
Predicate indicating whether t is a subnormal floating-point number.
Definition: Context.cs:4471
ArrayExpr MkArrayConst(Symbol name, Sort domain, Sort range)
Create an array constant.
Definition: Context.cs:2100
BoolExpr MkFPIsZero(FPExpr t)
Predicate indicating whether t is a floating-point number with zero value, i.e., +0 or -0.
Definition: Context.cs:4480
ReSort MkReSort(SeqSort s)
Create a new regular expression sort.
Definition: Context.cs:265
FPSort MkFPSortDouble()
Create the double-precision (64-bit) FloatingPoint sort.
Definition: Context.cs:4106
FPRMNum MkFPRoundTowardZero()
Create a numeral of RoundingMode sort which represents the RoundTowardZero rounding mode.
Definition: Context.cs:4045
Goal MkGoal(bool models=true, bool unsatCores=false, bool proofs=false)
Creates a new Goal.
Definition: Context.cs:3447
IntExpr MkBV2Int(BitVecExpr t, bool signed)
Create an integer from the bit-vector argument t .
Definition: Context.cs:1961
ArithExpr MkAdd(params ArithExpr[] t)
Create an expression representing t[0] + t[1] + ....
Definition: Context.cs:1090
BoolExpr MkInRe(SeqExpr s, ReExpr re)
Check for regular expression membership.
Definition: Context.cs:2656
ArrayExpr MkSetAdd(ArrayExpr set, Expr element)
Add an element to the set.
Definition: Context.cs:2338
BitVecExpr MkBVRedAND(BitVecExpr t)
Take conjunction of bits in a vector, return vector of length 1.
Definition: Context.cs:1329
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...
Definition: Context.cs:3825
ReExpr MkLoop(ReExpr re, uint lo, uint hi=0)
Take the bounded Kleene star of a regular expression.
Definition: Context.cs:2676
FPRMNum MkFPRoundTowardNegative()
Create a numeral of RoundingMode sort which represents the RoundTowardNegative rounding mode.
Definition: Context.cs:4029
Probe MkProbe(string name)
Creates a new Probe.
Definition: Context.cs:3764
FPNum MkFPNumeral(bool sgn, uint sig, int exp, FPSort s)
Create a numeral of FloatingPoint sort from a sign bit and two integers.
Definition: Context.cs:4203
SeqSort MkSeqSort(Sort s)
Create a new sequence sort.
Definition: Context.cs:256
DatatypeSort[] MkDatatypeSorts(string[] names, Constructor[][] c)
Create mutually recursive data-types.
Definition: Context.cs:513
Tactic FailIf(Probe p)
Create a tactic that fails if the probe p evaluates to false.
Definition: Context.cs:3649
Expr MkBound(uint index, Sort ty)
Creates a new bound variable.
Definition: Context.cs:709
FPRMNum MkFPRTN()
Create a numeral of RoundingMode sort which represents the RoundTowardNegative rounding mode.
Definition: Context.cs:4037
FPSort MkFPSort128()
Create the quadruple-precision (128-bit) FloatingPoint sort.
Definition: Context.cs:4130
BoolExpr MkBVUGE(BitVecExpr t1, BitVecExpr t2)
Unsigned greater than or equal to.
Definition: Context.cs:1654
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...
Definition: Context.cs:2928
FPRMNum MkFPRTP()
Create a numeral of RoundingMode sort which represents the RoundTowardPositive rounding mode.
Definition: Context.cs:4021
BoolSort MkBoolSort()
Create a new Boolean sort.
Definition: Context.cs:203
BitVecExpr MkConcat(BitVecExpr t1, BitVecExpr t2)
Bit-vector concatenation.
Definition: Context.cs:1722
ArithExpr MkPower(ArithExpr t1, ArithExpr t2)
Create an expression representing t1 ^ t2.
Definition: Context.cs:1205
SeqExpr MkEmptySeq(Sort s)
Create the empty sequence.
Definition: Context.cs:2443
BitVecExpr MkBVNot(BitVecExpr t)
Bitwise negation.
Definition: Context.cs:1317
FPExpr MkFPRem(FPExpr t1, FPExpr t2)
Floating-point remainder
Definition: Context.cs:4369
RealSort MkRealSort()
Create a real sort.
Definition: Context.cs:240
BoolExpr MkBVAddNoOverflow(BitVecExpr t1, BitVecExpr t2, bool isSigned)
Create a predicate that checks that the bit-wise addition does not overflow.
Definition: Context.cs:1975
ArithExpr MkDiv(ArithExpr t1, ArithExpr t2)
Create an expression representing t1 / t2.
Definition: Context.cs:1164
Expr MkSelect(ArrayExpr a, params Expr[] args)
Array read.
Definition: Context.cs:2160
FPNum MkFPNumeral(int v, FPSort s)
Create a numeral of FloatingPoint sort from an int.
Definition: Context.cs:4191
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.
Definition: Context.cs:3420
BoolExpr MkFPLt(FPExpr t1, FPExpr t2)
Floating-point less than.
Definition: Context.cs:4420
BoolExpr MkFPGEq(FPExpr t1, FPExpr t2)
Floating-point greater than or equal.
Definition: Context.cs:4430
BitVecExpr MkSignExt(uint i, BitVecExpr t)
Bit-vector sign extension.
Definition: Context.cs:1757
Tactic ParOr(params Tactic[] t)
Create a tactic that applies the given tactics in parallel until one of them succeeds (i....
Definition: Context.cs:3695
IntSort MkIntSort()
Create a new integer sort.
Definition: Context.cs:231
BoolExpr MkAnd(IEnumerable< BoolExpr > t)
Create an expression representing t[0] and t[1] and ....
Definition: Context.cs:1049
BoolExpr MkOr(params BoolExpr[] t)
Create an expression representing t[0] or t[1] or ....
Definition: Context.cs:1061
BitVecExpr MkBVMul(BitVecExpr t1, BitVecExpr t2)
Two's complement multiplication.
Definition: Context.cs:1477
IntExpr StringToInt(Expr e)
Convert an integer expression to a string.
Definition: Context.cs:2500
BoolExpr MkBVSDivNoOverflow(BitVecExpr t1, BitVecExpr t2)
Create a predicate that checks that the bit-wise signed division does not overflow.
Definition: Context.cs:2039
BoolExpr MkContains(SeqExpr s1, SeqExpr s2)
Check for sequence containment of s2 in s1.
Definition: Context.cs:2555
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...
Definition: Context.cs:3559
SeqSort StringSort
Retrieves the String sort of the context.
Definition: Context.cs:191
BoolExpr MkEq(Expr x, Expr y)
Creates the equality x = y .
Definition: Context.cs:918
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.
Definition: Context.cs:3604
BitVecExpr MkBVSub(BitVecExpr t1, BitVecExpr t2)
Two's complement subtraction.
Definition: Context.cs:1463
BitVecExpr MkBVUDiv(BitVecExpr t1, BitVecExpr t2)
Unsigned division.
Definition: Context.cs:1496
void Interrupt()
Interrupt the execution of a Z3 procedure.
Definition: Context.cs:3721
BoolExpr MkBVUGT(BitVecExpr t1, BitVecExpr t2)
Unsigned greater-than.
Definition: Context.cs:1686
ArraySort MkArraySort(Sort domain, Sort range)
Create a new array sort.
Definition: Context.cs:274
BitVecExpr MkBVConst(Symbol name, uint size)
Creates a bit-vector constant.
Definition: Context.cs:842
BitVecExpr MkBVASHR(BitVecExpr t1, BitVecExpr t2)
Arithmetic shift right
Definition: Context.cs:1854
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 .
Definition: Context.cs:3546
FPNum MkFPZero(FPSort s, bool negative)
Create a floating-point zero of sort s.
Definition: Context.cs:4161
BoolExpr MkPBGe(int[] coeffs, BoolExpr[] args, int k)
Create a pseudo-Boolean greater-or-equal constraint.
Definition: Context.cs:2879
IntNum MkInt(long v)
Create an integer numeral.
Definition: Context.cs:3092
RatNum MkReal(long v)
Create a real numeral.
Definition: Context.cs:3036
ReExpr MkPlus(ReExpr re)
Take the Kleene plus of a regular expression.
Definition: Context.cs:2685
FPExpr MkFPSqrt(FPRMExpr rm, FPExpr t)
Floating-point square root
Definition: Context.cs:4359
BoolExpr MkIff(BoolExpr t1, BoolExpr t2)
Create an expression representing t1 iff t2.
Definition: Context.cs:982
FiniteDomainSort MkFiniteDomainSort(string name, ulong size)
Create a new finite domain sort. The result is a sortElements of the sort are created using MkNumeral...
Definition: Context.cs:395
Expr MkNumeral(string v, Sort ty)
Create a Term of a given sort.
Definition: Context.cs:2913
ArithExpr MkAdd(IEnumerable< ArithExpr > t)
Create an expression representing t[0] + t[1] + ....
Definition: Context.cs:1102
FuncDecl MkRecFuncDecl(string name, Sort[] domain, Sort range)
Creates a new recursive function declaration.
Definition: Context.cs:598
BitVecExpr MkBVAdd(BitVecExpr t1, BitVecExpr t2)
Two's complement addition.
Definition: Context.cs:1449
BoolExpr MkGt(ArithExpr t1, ArithExpr t2)
Create an expression representing t1 > t2
Definition: Context.cs:1244
Solver MkSimpleSolver()
Creates a new (incremental) solver.
Definition: Context.cs:3921
ArraySort MkArraySort(Sort[] domain, Sort range)
Create a new n-ary array sort.
Definition: Context.cs:287
Probe Not(Probe p)
Create a probe that evaluates to "true" when the value p does not evaluate to "true".
Definition: Context.cs:3881
BoolExpr MkBool(bool value)
Creates a Boolean value.
Definition: Context.cs:909
BitVecExpr MkBVAND(BitVecExpr t1, BitVecExpr t2)
Bitwise conjunction.
Definition: Context.cs:1353
Solver MkSolver(Tactic t)
Creates a solver that is implemented using the given tactic.
Definition: Context.cs:3934
RealExpr MkRealConst(Symbol name)
Creates a real constant.
Definition: Context.cs:823
IntNum MkInt(ulong v)
Create an integer numeral.
Definition: Context.cs:3103
Expr MkApp(FuncDecl f, IEnumerable< Expr > args)
Create a new function application.
Definition: Context.cs:877
ReExpr MkToRe(SeqExpr s)
Convert a regular expression that accepts sequence s.
Definition: Context.cs:2646
BoolExpr MkFPIsNaN(FPExpr t)
Predicate indicating whether t is a NaN.
Definition: Context.cs:4498
BitVecExpr MkBVRotateRight(uint i, BitVecExpr t)
Rotate Right.
Definition: Context.cs:1886
string SimplifyHelp()
Return a string describing all available parameters to Expr.Simplify.
Definition: Context.cs:4732
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.
Definition: Context.cs:3271
Lambda MkLambda(Sort[] sorts, Symbol[] names, Expr body)
Create a lambda expression.
Definition: Context.cs:3341
FuncDecl MkFuncDecl(Symbol name, Sort[] domain, Sort range)
Creates a new function declaration.
Definition: Context.cs:553
BoolExpr MkBVSLT(BitVecExpr t1, BitVecExpr t2)
Two's complement signed less-than
Definition: Context.cs:1606
IDecRefQueue Tactic_DRQ
Tactic DRQ
Definition: Context.cs:4958
SetSort MkSetSort(Sort ty)
Create a set type.
Definition: Context.cs:2305
EnumSort MkEnumSort(string name, params string[] enumNames)
Create a new enumeration sort.
Definition: Context.cs:331
BitVecNum MkBV(int v, uint size)
Create a bit-vector numeral.
Definition: Context.cs:3127
RatNum MkReal(int num, int den)
Create a real from a fraction.
Definition: Context.cs:2990
IDecRefQueue Probe_DRQ
Probe DRQ
Definition: Context.cs:4943
EnumSort MkEnumSort(Symbol name, params Symbol[] enumNames)
Create a new enumeration sort.
Definition: Context.cs:316
BoolExpr MkFPIsNegative(FPExpr t)
Predicate indicating whether t is a negative floating-point number.
Definition: Context.cs:4507
FuncDecl MkFreshFuncDecl(string prefix, Sort[] domain, Sort range)
Creates a fresh function declaration with a name prefixed with prefix .
Definition: Context.cs:644
IntExpr MkIntConst(string name)
Creates an integer constant.
Definition: Context.cs:813
Tactic When(Probe p, Tactic t)
Create a tactic that applies t to a given goal if the probe p evaluates to true.
Definition: Context.cs:3590
BitVecExpr MkBVNeg(BitVecExpr t)
Standard two's complement unary minus.
Definition: Context.cs:1437
FuncDecl MkFreshConstDecl(string prefix, Sort range)
Creates a fresh constant function declaration with a name prefixed with prefix .
Definition: Context.cs:684
Tactic Fail()
Create a tactic always fails.
Definition: Context.cs:3640
Tactic FailIfNotDecided()
Create a tactic that fails if the goal is not trivially satisfiable (i.e., empty) or trivially unsati...
Definition: Context.cs:3661
FPRMNum MkFPRoundTowardPositive()
Create a numeral of RoundingMode sort which represents the RoundTowardPositive rounding mode.
Definition: Context.cs:4013
BitVecExpr MkBVOR(BitVecExpr t1, BitVecExpr t2)
Bitwise disjunction.
Definition: Context.cs:1367
Expr MkConst(string name, Sort range)
Creates a new Constant of sort range and named name .
Definition: Context.cs:750
IntExpr MkRem(IntExpr t1, IntExpr t2)
Create an expression representing t1 rem t2.
Definition: Context.cs:1192
FPExpr MkFPMul(FPRMExpr rm, FPExpr t1, FPExpr t2)
Floating-point multiplication
Definition: Context.cs:4323
BoolExpr MkStringLt(SeqExpr s1, SeqExpr s2)
Check if the string s1 is lexicographically strictly less than s2.
Definition: Context.cs:2566
BoolExpr MkBVSubNoOverflow(BitVecExpr t1, BitVecExpr t2)
Create a predicate that checks that the bit-wise subtraction does not overflow.
Definition: Context.cs:2007
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...
Definition: Context.cs:4690
FPSort MkFPSort64()
Create the double-precision (64-bit) FloatingPoint sort.
Definition: Context.cs:4114
FPRMNum MkFPRNA()
Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
Definition: Context.cs:4005
Context(Dictionary< string, string > settings)
Constructor.
Definition: Context.cs:67
BitVecExpr MkBVRotateLeft(uint i, BitVecExpr t)
Rotate Left.
Definition: Context.cs:1871
string TacticDescription(string name)
Returns a string containing a description of the tactic with the given name.
Definition: Context.cs:3493
FPRMNum MkFPRNE()
Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
Definition: Context.cs:3989
IDecRefQueue ASTMap_DRQ
ASTMap DRQ
Definition: Context.cs:4898
SeqExpr MkUnit(Expr elem)
Create the singleton sequence.
Definition: Context.cs:2452
uint NumProbes
The number of supported Probes.
Definition: Context.cs:3732
BoolExpr MkPBEq(int[] coeffs, BoolExpr[] args, int k)
Create a pseudo-Boolean equal constraint.
Definition: Context.cs:2892
IntNum MkInt(int v)
Create an integer numeral.
Definition: Context.cs:3070
BitVecExpr MkBVXOR(BitVecExpr t1, BitVecExpr t2)
Bitwise XOR.
Definition: Context.cs:1381
ArrayExpr MkStore(ArrayExpr a, Expr[] args, Expr v)
Array update.
Definition: Context.cs:2219
Solver MkSolver(Symbol logic=null)
Creates a new (incremental) solver.
Definition: Context.cs:3899
FPExpr MkFPAbs(FPExpr t)
Floating-point absolute value
Definition: Context.cs:4281
FPExpr MkFPMin(FPExpr t1, FPExpr t2)
Minimum of floating-point numbers.
Definition: Context.cs:4390
FPExpr MkFPDiv(FPRMExpr rm, FPExpr t1, FPExpr t2)
Floating-point division
Definition: Context.cs:4334
BoolExpr MkOr(IEnumerable< BoolExpr > t)
Create an expression representing t[0] or t[1] or ....
Definition: Context.cs:1074
ReExpr MkComplement(ReExpr re)
Create the complement regular expression.
Definition: Context.cs:2703
BitVecExpr MkExtract(uint high, uint low, BitVecExpr t)
Bit-vector extraction.
Definition: Context.cs:1741
ArithExpr MkMul(IEnumerable< ArithExpr > t)
Create an expression representing t[0] * t[1] * ....
Definition: Context.cs:1128
StringSymbol MkSymbol(string name)
Create a symbol using a string.
Definition: Context.cs:117
BitVecExpr MkBVURem(BitVecExpr t1, BitVecExpr t2)
Unsigned remainder.
Definition: Context.cs:1537
BoolExpr MkFalse()
The false Term.
Definition: Context.cs:900
IntExpr MkLength(SeqExpr s)
Retrieve the length of a given sequence.
Definition: Context.cs:2524
RatNum MkReal(int v)
Create a real numeral.
Definition: Context.cs:3014
IntSymbol MkSymbol(int i)
Creates a new symbol using an integer.
Definition: Context.cs:109
SeqExpr MkString(string s)
Create a string constant.
Definition: Context.cs:2461
ArrayExpr MkStore(ArrayExpr a, Expr i, Expr v)
Array update.
Definition: Context.cs:2189
FPExpr MkFP(BitVecExpr sgn, BitVecExpr sig, BitVecExpr exp)
Create an expression of FloatingPoint sort from three bit-vector expressions.
Definition: Context.cs:4536
BoolExpr MkBVSGE(BitVecExpr t1, BitVecExpr t2)
Two's complement signed greater than or equal to.
Definition: Context.cs:1670
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.
Definition: Context.cs:3207
FPNum MkFP(double v, FPSort s)
Create a numeral of FloatingPoint sort from a float.
Definition: Context.cs:4235
BoolExpr MkFPIsNormal(FPExpr t)
Predicate indicating whether t is a normal floating-point number.
Definition: Context.cs:4462
BoolExpr MkPrefixOf(SeqExpr s1, SeqExpr s2)
Check for sequence prefix.
Definition: Context.cs:2533
BoolExpr MkFPIsPositive(FPExpr t)
Predicate indicating whether t is a positive floating-point number.
Definition: Context.cs:4516
Enumeration sorts.
Definition: EnumSort.cs:29
Expressions are terms.
Definition: Expr.cs:31
FloatingPoint Expressions
Definition: FPExpr.cs:32
FloatiungPoint Numerals
Definition: FPNum.cs:28
FloatingPoint RoundingMode Expressions
Definition: FPRMExpr.cs:32
Floating-point rounding mode numerals
Definition: FPRMNum.cs:32
The FloatingPoint RoundingMode sort
Definition: FPRMSort.cs:29
FloatingPoint sort
Definition: FPSort.cs:28
Object for managing fixedpoints
Definition: Fixedpoint.cs:30
Function declarations.
Definition: FuncDecl.cs:31
A goal (aka problem). A goal is essentially a set of formulas, that can be solved and/or transformed ...
Definition: Goal.cs:32
DecRefQueue interface
Definition: IDecRefQueue.cs:32
Int expressions
Definition: IntExpr.cs:32
Integer Numerals
Definition: IntNum.cs:32
An Integer sort
Definition: IntSort.cs:29
Numbered symbols
Definition: IntSymbol.cs:30
Lambda expressions.
Definition: Lambda.cs:30
Object for managing optimization context
Definition: Optimize.cs:31
A ParamDescrs describes a set of parameters.
Definition: ParamDescrs.cs:29
A Params objects represents a configuration in the form of Symbol/value pairs.
Definition: Params.cs:29
Patterns comprise a list of terms. The list should be non-empty. If the list comprises of more than o...
Definition: Pattern.cs:32
Probes are used to inspect a goal (aka problem) and collect information that may be used to decide wh...
Definition: Probe.cs:34
Quantifier expressions.
Definition: Quantifier.cs:30
Rational Numerals
Definition: RatNum.cs:32
Regular expression expressions
Definition: ReExpr.cs:32
A regular expression sort
Definition: ReSort.cs:29
Real expressions
Definition: RealExpr.cs:32
Sequence expressions
Definition: SeqExpr.cs:32
A Sequence sort
Definition: SeqSort.cs:29
Set sorts.
Definition: SetSort.cs:29
void Assert(params BoolExpr[] constraints)
Assert a constraint (or multiple) into the solver.
Definition: Solver.cs:200
The Sort class implements type information for ASTs.
Definition: Sort.cs:29
Symbols are used to name several term and type constructors.
Definition: Symbol.cs:30
Tactics are the basic building block for creating custom solvers for specific problem domains....
Definition: Tactic.cs:32
The exception base class for error reporting from Z3
Definition: Z3Exception.cs:32
Z3_ast_print_mode
Z3 pretty printing modes (See Z3_set_ast_print_mode).
Definition: z3_api.h:1317
Z3_error_code
Z3 error codes (See Z3_get_error_code).
Definition: z3_api.h:1342
System.IntPtr Z3_context
Definition: Context.cs:29
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3946
expr max(expr const &a, expr const &b)
Definition: z3++.h:1935
def Lambda(vs, body)
Definition: z3py.py:2252
def SeqSort(s)
Definition: z3py.py:10740
def SetSort(s)
Sets.
Definition: z3py.py:4908
def ArraySort(*sig)
Definition: z3py.py:4691
def DatatypeSort(name, ctx=None)
Definition: z3py.py:5349
def EnumSort(name, values, ctx=None)
Definition: z3py.py:5378
def ReSort(s)
Definition: z3py.py:11127
def FiniteDomainSort(name, sz, ctx=None)
Definition: z3py.py:7691
def FPSort(ebits, sbits, ctx=None)
Definition: z3py.py:9876
def TupleSort(name, sorts, ctx=None)
Definition: z3py.py:5354
def BitVecSort(sz, ctx=None)
Definition: z3py.py:3996
def Model(ctx=None)
Definition: z3py.py:6680