/// <summary> /// Adds a parameter setting. /// </summary> public void Add(Symbol name, Symbol value) { Contract.Requires(name != null); Contract.Requires(value != null); Native.Z3_params_set_symbol(Context.nCtx, NativeObject, name.NativeObject, value.NativeObject); }
internal Quantifier(Context ctx, bool isForall, Expr[] bound, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) : base(ctx) { Contract.Requires(ctx != null); Contract.Requires(body != null); Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null)); Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null)); Contract.Requires(bound == null || Contract.ForAll(bound, n => n != null)); Context.CheckContextMatch(noPatterns); Context.CheckContextMatch(patterns); //Context.CheckContextMatch(bound); Context.CheckContextMatch(body); if (noPatterns == null && quantifierID == null && skolemID == null) { NativeObject = Native.Z3_mk_quantifier_const(ctx.nCtx, (isForall) ? 1 : 0, weight, AST.ArrayLength(bound), AST.ArrayToNative(bound), AST.ArrayLength(patterns), AST.ArrayToNative(patterns), body.NativeObject); } else { NativeObject = Native.Z3_mk_quantifier_const_ex(ctx.nCtx, (isForall) ? 1 : 0, weight, AST.GetNativeObject(quantifierID), AST.GetNativeObject(skolemID), AST.ArrayLength(bound), AST.ArrayToNative(bound), AST.ArrayLength(patterns), AST.ArrayToNative(patterns), AST.ArrayLength(noPatterns), AST.ArrayToNative(noPatterns), body.NativeObject); } }
internal FiniteDomainSort(Context ctx, Symbol name, ulong size) : base(ctx, Native.Z3_mk_finite_domain_sort(ctx.nCtx, name.NativeObject, size)) { Contract.Requires(ctx != null); Contract.Requires(name != null); }
internal DatatypeSort(Context ctx, Symbol name, Constructor[] constructors) : base(ctx, Native.Z3_mk_datatype(ctx.nCtx, name.NativeObject, (uint)constructors.Length, ArrayToNative(constructors))) { Contract.Requires(ctx != null); Contract.Requires(name != null); Contract.Requires(constructors != null); }
internal TupleSort(Context ctx, Symbol name, uint numFields, Symbol[] fieldNames, Sort[] fieldSorts) : base(ctx) { Contract.Requires(ctx != null); Contract.Requires(name != null); IntPtr t = IntPtr.Zero; NativeObject = Native.Z3_mk_tuple_sort(ctx.nCtx, name.NativeObject, numFields, Symbol.ArrayToNative(fieldNames), AST.ArrayToNative(fieldSorts), ref t, new IntPtr[numFields]); }
/// <summary> /// Create axiom: function f is injective in the i-th argument. /// </summary> /// <remarks> /// The following axiom is produced: /// <c> /// forall (x_0, ..., x_n) finv(f(x_0, ..., x_i, ..., x_{n-1})) = x_i /// </c> /// Where, <code>finv</code>is a fresh function declaration. /// </summary> public static BoolExpr InjAxiom(Context ctx, FuncDecl f, int i) { Sort[] domain = f.Domain; uint sz = f.DomainSize; if (i >= sz) { Console.WriteLine("failed to create inj axiom"); return null; } /* declare the i-th inverse of f: finv */ Sort finv_domain = f.Range; Sort finv_range = domain[i]; FuncDecl finv = ctx.MkFuncDecl("f_fresh", finv_domain, finv_range); /* allocate temporary arrays */ Expr[] xs = new Expr[sz]; Symbol[] names = new Symbol[sz]; Sort[] types = new Sort[sz]; /* fill types, names and xs */ for (uint j = 0; j < sz; j++) { types[j] = domain[j]; names[j] = ctx.MkSymbol(String.Format("x_{0}", j)); xs[j] = ctx.MkBound(j, types[j]); } Expr x_i = xs[i]; /* create f(x_0, ..., x_i, ..., x_{n-1}) */ Expr fxs = f[xs]; /* create f_inv(f(x_0, ..., x_i, ..., x_{n-1})) */ Expr finv_fxs = finv[fxs]; /* create finv(f(x_0, ..., x_i, ..., x_{n-1})) = x_i */ Expr eq = ctx.MkEq(finv_fxs, x_i); /* use f(x_0, ..., x_i, ..., x_{n-1}) as the pattern for the quantifier */ Pattern p = ctx.MkPattern(new Expr[] { fxs }); /* create & assert quantifier */ BoolExpr q = ctx.MkForall( types, /* types of quantified variables */ names, /* names of quantified variables */ eq, 1, new Pattern[] { p } /* patterns */); return q; }
internal EnumSort(Context ctx, Symbol name, Symbol[] enumNames) : base(ctx) { Contract.Requires(ctx != null); Contract.Requires(name != null); Contract.Requires(enumNames != null); int n = enumNames.Length; IntPtr[] n_constdecls = new IntPtr[n]; IntPtr[] n_testers = new IntPtr[n]; NativeObject = Native.Z3_mk_enumeration_sort(ctx.nCtx, name.NativeObject, (uint)n, Symbol.ArrayToNative(enumNames), n_constdecls, n_testers); }
internal ListSort(Context ctx, Symbol name, Sort elemSort) : base(ctx) { Contract.Requires(ctx != null); Contract.Requires(name != null); Contract.Requires(elemSort != null); IntPtr inil = IntPtr.Zero, iisnil = IntPtr.Zero, icons = IntPtr.Zero, iiscons = IntPtr.Zero, ihead = IntPtr.Zero, itail = IntPtr.Zero; NativeObject = Native.Z3_mk_list_sort(ctx.nCtx, name.NativeObject, elemSort.NativeObject, ref inil, ref iisnil, ref icons, ref iiscons, ref ihead, ref itail); }
internal Quantifier(Context ctx, bool isForall, Sort[] sorts, Symbol[] names, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null ) : base(ctx) { Contract.Requires(ctx != null); Contract.Requires(sorts != null); Contract.Requires(names != null); Contract.Requires(body != null); Contract.Requires(sorts.Length == names.Length); Contract.Requires(Contract.ForAll(sorts, s => s != null)); Contract.Requires(Contract.ForAll(names, n => n != null)); Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null)); Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null)); Context.CheckContextMatch(patterns); Context.CheckContextMatch(noPatterns); Context.CheckContextMatch(sorts); Context.CheckContextMatch(names); Context.CheckContextMatch(body); if (sorts.Length != names.Length) throw new Z3Exception("Number of sorts does not match number of names"); IntPtr[] _patterns = AST.ArrayToNative(patterns); if (noPatterns == null && quantifierID == null && skolemID == null) { NativeObject = Native.Z3_mk_quantifier(ctx.nCtx, (isForall) ? 1 : 0, weight, AST.ArrayLength(patterns), AST.ArrayToNative(patterns), AST.ArrayLength(sorts), AST.ArrayToNative(sorts), Symbol.ArrayToNative(names), body.NativeObject); } else { NativeObject = Native.Z3_mk_quantifier_ex(ctx.nCtx, (isForall) ? 1 : 0, weight, AST.GetNativeObject(quantifierID), AST.GetNativeObject(skolemID), AST.ArrayLength(patterns), AST.ArrayToNative(patterns), AST.ArrayLength(noPatterns), AST.ArrayToNative(noPatterns), AST.ArrayLength(sorts), AST.ArrayToNative(sorts), Symbol.ArrayToNative(names), body.NativeObject); } }
internal Constructor(Context ctx, Symbol name, Symbol recognizer, Symbol[] fieldNames, Sort[] sorts, uint[] sortRefs) : base(ctx) { Contract.Requires(ctx != null); Contract.Requires(name != null); Contract.Requires(recognizer != null); n = AST.ArrayLength(fieldNames); if (n != AST.ArrayLength(sorts)) throw new Z3Exception("Number of field names does not match number of sorts"); if (sortRefs != null && sortRefs.Length != n) throw new Z3Exception("Number of field names does not match number of sort refs"); if (sortRefs == null) sortRefs = new uint[n]; NativeObject = Native.Z3_mk_constructor(ctx.nCtx, name.NativeObject, recognizer.NativeObject, n, Symbol.ArrayToNative(fieldNames), Sort.ArrayToNative(sorts), sortRefs); }
/// <summary> /// Creates a new function declaration. /// </summary> public FuncDecl MkFuncDecl(Symbol name, Sort[] domain, Sort range) { Contract.Requires(name != null); Contract.Requires(range != null); Contract.Requires(Contract.ForAll(domain, d => d != null)); Contract.Ensures(Contract.Result<FuncDecl>() != null); CheckContextMatch(name); CheckContextMatch(domain); CheckContextMatch(range); return new FuncDecl(this, name, domain, range); }
/// <summary> /// Create a universal Quantifier. /// </summary> public Quantifier MkForall(Expr[] boundConstants, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) { Contract.Requires(body != null); Contract.Requires(boundConstants == null || Contract.ForAll(boundConstants, b => b != null)); Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null)); Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null)); Contract.Ensures(Contract.Result<Quantifier>() != null); return new Quantifier(this, true, boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID); }
/// <summary> /// Create a universal Quantifier. /// </summary> /// <remarks> /// Creates a forall formula, where <paramref name="weight"/> is the weight, /// <paramref name="patterns"/> is an array of patterns, <paramref name="sorts"/> is an array /// with the sorts of the bound variables, <paramref name="names"/> is an array with the /// 'names' of the bound variables, and <paramref name="body"/> is the body of the /// quantifier. Quantifiers are associated with weights indicating /// the importance of using the quantifier during instantiation. /// </remarks> /// <param name="sorts">the sorts of the bound variables.</param> /// <param name="names">names of the bound variables</param> /// <param name="body">the body of the quantifier.</param> /// <param name="weight">quantifiers are associated with weights indicating the importance of using the quantifier during instantiation. By default, pass the weight 0.</param> /// <param name="patterns">array containing the patterns created using <c>MkPattern</c>.</param> /// <param name="noPatterns">array containing the anti-patterns created using <c>MkPattern</c>.</param> /// <param name="quantifierID">optional symbol to track quantifier.</param> /// <param name="skolemID">optional symbol to track skolem constants.</param> public Quantifier MkForall(Sort[] sorts, Symbol[] names, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) { Contract.Requires(sorts != null); Contract.Requires(names != null); Contract.Requires(body != null); Contract.Requires(sorts.Length == names.Length); Contract.Requires(Contract.ForAll(sorts, s => s != null)); Contract.Requires(Contract.ForAll(names, n => n != null)); Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null)); Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null)); Contract.Ensures(Contract.Result<Quantifier>() != null); return new Quantifier(this, true, sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID); }
/// <summary> /// Create a Boolean constant. /// </summary> public BoolExpr MkBoolConst(Symbol name) { Contract.Requires(name != null); Contract.Ensures(Contract.Result<BoolExpr>() != null); return (BoolExpr)MkConst(name, BoolSort); }
/// <summary> /// Create an array of symbols. /// </summary> internal Symbol[] MkSymbols(string[] names) { Contract.Ensures(names == null || Contract.Result<Symbol[]>() != null); Contract.Ensures(names != null || Contract.Result<Symbol[]>() == null); Contract.Ensures(Contract.Result<Symbol[]>() == null || Contract.Result<Symbol[]>().Length == names.Length); Contract.Ensures(Contract.Result<Symbol[]>() == null || Contract.ForAll(Contract.Result<Symbol[]>(), s => s != null)); if (names == null) return null; Symbol[] result = new Symbol[names.Length]; for (int i = 0; i < names.Length; ++i) result[i] = MkSymbol(names[i]); return result; }
[ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug internal Quantifier(Context ctx, bool isForall, Expr[] bound, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) : base(ctx, IntPtr.Zero) { Contract.Requires(ctx != null); Contract.Requires(body != null); Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null)); Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null)); Contract.Requires(bound == null || Contract.ForAll(bound, n => n != null)); Context.CheckContextMatch <Expr>(noPatterns); Context.CheckContextMatch <Pattern>(patterns); //Context.CheckContextMatch(bound); Context.CheckContextMatch(body); if (noPatterns == null && quantifierID == null && skolemID == null) { NativeObject = Native.Z3_mk_quantifier_const(ctx.nCtx, (isForall) ? 1 : 0, weight, AST.ArrayLength(bound), AST.ArrayToNative(bound), AST.ArrayLength(patterns), AST.ArrayToNative(patterns), body.NativeObject); } else { NativeObject = Native.Z3_mk_quantifier_const_ex(ctx.nCtx, (isForall) ? 1 : 0, weight, AST.GetNativeObject(quantifierID), AST.GetNativeObject(skolemID), AST.ArrayLength(bound), AST.ArrayToNative(bound), AST.ArrayLength(patterns), AST.ArrayToNative(patterns), AST.ArrayLength(noPatterns), AST.ArrayToNative(noPatterns), body.NativeObject); } }
/// <summary> /// Creates a real constant. /// </summary> public RealExpr MkRealConst(Symbol name) { Contract.Requires(name != null); Contract.Ensures(Contract.Result<RealExpr>() != null); return (RealExpr)MkConst(name, RealSort); }
/// <summary> /// Create a new list sort. /// </summary> public ListSort MkListSort(Symbol name, Sort elemSort) { Contract.Requires(name != null); Contract.Requires(elemSort != null); Contract.Ensures(Contract.Result<ListSort>() != null); CheckContextMatch(name); CheckContextMatch(elemSort); return new ListSort(this, name, elemSort); }
/// <summary> /// Creates a new function declaration. /// </summary> public FuncDecl MkFuncDecl(Symbol name, Sort domain, Sort range) { Contract.Requires(name != null); Contract.Requires(domain != null); Contract.Requires(range != null); Contract.Ensures(Contract.Result<FuncDecl>() != null); CheckContextMatch(name); CheckContextMatch(domain); CheckContextMatch(range); Sort[] q = new Sort[] { domain }; return new FuncDecl(this, name, q, range); }
/// <summary> /// Same as MkForAll but defaults to "forall" = false /// Create an existential Quantifier. /// </summary> /// <param name="sorts"></param> /// <param name="names"></param> /// <param name="body"></param> /// <param name="weight"></param> /// <param name="patterns"></param> /// <param name="noPatterns"></param> /// <param name="quantifierID"></param> /// <param name="skolemID"></param> /// <returns></returns> public Z3_ast MkExists(Z3_sort[] sorts, Z3_symbol[] names, Z3_ast body, uint weight = 1, Z3_ast[] patterns = null, Z3_ast[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) { return(MkQuantifier(false, sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID)); }
/// <summary> /// Create a quantified expression either forall or exists /// </summary> /// <param name="is_forall"></param> /// <param name="sorts"></param> /// <param name="names"></param> /// <param name="body"></param> /// <param name="weight"></param> /// <param name="patterns"></param> /// <param name="noPatterns"></param> /// <param name="quantifierID"></param> /// <param name="skolemID"></param> /// <returns></returns> private Z3_ast MkQuantifier(bool is_forall, Z3_sort[] sorts, Z3_symbol[] names, Z3_ast body, uint weight, Z3_ast[] patterns, Z3_ast[] noPatterns, Symbol quantifierID, Symbol skolemID) { Debug.Assert(sorts != null); Debug.Assert(names != null); Debug.Assert(body != null); Debug.Assert(sorts.Length == names.Length); Debug.Assert(sorts.All(s => s != IntPtr.Zero)); Debug.Assert(names.All(n => n != IntPtr.Zero)); Debug.Assert(patterns == null || patterns.All(p => p != IntPtr.Zero)); Debug.Assert(noPatterns == null || noPatterns.All(np => np != IntPtr.Zero)); if (noPatterns == null && quantifierID == null && skolemID == null) { return(Native.Z3_mk_quantifier(nCtx, (byte)(is_forall ? 1 : 0), weight, (uint)(patterns?.Length ?? 0), patterns, (uint)(sorts?.Length ?? 0), sorts, names, body)); } else { return(Native.Z3_mk_quantifier_ex(nCtx, (byte)(is_forall ? 1 : 0), weight, AST.GetNativeObject(quantifierID), AST.GetNativeObject(skolemID), (uint)(patterns?.Length ?? 0), patterns, (uint)(noPatterns?.Length ?? 0), noPatterns, (uint)(sorts?.Length ?? 0), sorts, names, body)); } }
/// <summary> /// Creates an integer constant. /// </summary> public IntExpr MkIntConst(Symbol name) { Contract.Requires(name != null); Contract.Ensures(Contract.Result<IntExpr>() != null); return (IntExpr)MkConst(name, IntSort); }
/// <summary> /// Create a new tuple sort. /// </summary> public TupleSort MkTupleSort(Symbol name, Symbol[] fieldNames, Sort[] fieldSorts) { Contract.Requires(name != null); Contract.Requires(fieldNames != null); Contract.Requires(Contract.ForAll(fieldNames, fn => fn != null)); Contract.Requires(fieldSorts == null || Contract.ForAll(fieldSorts, fs => fs != null)); Contract.Ensures(Contract.Result<TupleSort>() != null); CheckContextMatch(name); CheckContextMatch(fieldNames); CheckContextMatch(fieldSorts); return new TupleSort(this, name, (uint)fieldNames.Length, fieldNames, fieldSorts); }
/// <summary> /// Create a Quantifier. /// </summary> public Quantifier MkQuantifier(bool universal, Expr[] boundConstants, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) { Contract.Requires(body != null); Contract.Requires(boundConstants == null || Contract.ForAll(boundConstants, n => n != null)); Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null)); Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null)); Contract.Ensures(Contract.Result<Quantifier>() != null); if (universal) return MkForall(boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID); else return MkExists(boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID); }
/// <summary> /// Parse the given string using the SMT-LIB2 parser. /// </summary> /// <seealso cref="ParseSMTLIBString"/> /// <returns>A conjunction of assertions in the scope (up to push/pop) at the end of the string.</returns> public BoolExpr ParseSMTLIB2String(string str, Symbol[] sortNames = null, Sort[] sorts = null, Symbol[] declNames = null, FuncDecl[] decls = null) { Contract.Ensures(Contract.Result<BoolExpr>() != null); uint csn = Symbol.ArrayLength(sortNames); uint cs = Sort.ArrayLength(sorts); uint cdn = Symbol.ArrayLength(declNames); uint cd = AST.ArrayLength(decls); if (csn != cs || cdn != cd) throw new Z3Exception("Argument size mismatch"); return (BoolExpr)Expr.Create(this, Native.Z3_parse_smtlib2_string(nCtx, str, AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts), AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls))); }
/// <summary> /// Creates a new (incremental) solver. /// </summary> /// <remarks> /// This solver also uses a set of builtin tactics for handling the first /// check-sat command, and check-sat commands that take more than a given /// number of milliseconds to be solved. /// </remarks> public Solver MkSolver(Symbol logic = null) { Contract.Ensures(Contract.Result<Solver>() != null); if (logic == null) return new Solver(this, Native.Z3_mk_solver(nCtx)); else return new Solver(this, Native.Z3_mk_solver_for_logic(nCtx, logic.NativeObject)); }
[ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug internal Quantifier(Context ctx, bool isForall, Sort[] sorts, Symbol[] names, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) : base(ctx, IntPtr.Zero) { Contract.Requires(ctx != null); Contract.Requires(sorts != null); Contract.Requires(names != null); Contract.Requires(body != null); Contract.Requires(sorts.Length == names.Length); Contract.Requires(Contract.ForAll(sorts, s => s != null)); Contract.Requires(Contract.ForAll(names, n => n != null)); Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null)); Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null)); Context.CheckContextMatch <Pattern>(patterns); Context.CheckContextMatch <Expr>(noPatterns); Context.CheckContextMatch <Sort>(sorts); Context.CheckContextMatch <Symbol>(names); Context.CheckContextMatch(body); if (sorts.Length != names.Length) { throw new Z3Exception("Number of sorts does not match number of names"); } if (noPatterns == null && quantifierID == null && skolemID == null) { NativeObject = Native.Z3_mk_quantifier(ctx.nCtx, (isForall) ? 1 : 0, weight, AST.ArrayLength(patterns), AST.ArrayToNative(patterns), AST.ArrayLength(sorts), AST.ArrayToNative(sorts), Symbol.ArrayToNative(names), body.NativeObject); } else { NativeObject = Native.Z3_mk_quantifier_ex(ctx.nCtx, (isForall) ? 1 : 0, weight, AST.GetNativeObject(quantifierID), AST.GetNativeObject(skolemID), AST.ArrayLength(patterns), AST.ArrayToNative(patterns), AST.ArrayLength(noPatterns), AST.ArrayToNative(noPatterns), AST.ArrayLength(sorts), AST.ArrayToNative(sorts), Symbol.ArrayToNative(names), body.NativeObject); } }
/// <summary> /// Create a new uninterpreted sort. /// </summary> public UninterpretedSort MkUninterpretedSort(Symbol s) { Contract.Requires(s != null); Contract.Ensures(Contract.Result<UninterpretedSort>() != null); CheckContextMatch(s); return new UninterpretedSort(this, s); }
/// <summary> /// Create a new datatype sort. /// </summary> public DatatypeSort MkDatatypeSort(Symbol name, Constructor[] constructors) { Contract.Requires(name != null); Contract.Requires(constructors != null); Contract.Requires(Contract.ForAll(constructors, c => c != null)); Contract.Ensures(Contract.Result<DatatypeSort>() != null); CheckContextMatch(name); CheckContextMatch(constructors); return new DatatypeSort(this, name, constructors); }
/// <summary> /// Parse the given string using the SMT-LIB parser. /// </summary> /// <remarks> /// The symbol table of the parser can be initialized using the given sorts and declarations. /// The symbols in the arrays <paramref name="sortNames"/> and <paramref name="declNames"/> /// don't need to match the names of the sorts and declarations in the arrays <paramref name="sorts"/> /// and <paramref name="decls"/>. This is a useful feature since we can use arbitrary names to /// reference sorts and declarations. /// </remarks> public void ParseSMTLIBString(string str, Symbol[] sortNames = null, Sort[] sorts = null, Symbol[] declNames = null, FuncDecl[] decls = null) { uint csn = Symbol.ArrayLength(sortNames); uint cs = Sort.ArrayLength(sorts); uint cdn = Symbol.ArrayLength(declNames); uint cd = AST.ArrayLength(decls); if (csn != cs || cdn != cd) throw new Z3Exception("Argument size mismatch"); Native.Z3_parse_smtlib_string(nCtx, str, AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts), AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls)); }
/// <summary> /// Create mutually recursive datatypes. /// </summary> /// <param name="names">names of datatype sorts</param> /// <param name="c">list of constructors, one list per sort.</param> public DatatypeSort[] MkDatatypeSorts(Symbol[] names, Constructor[][] c) { Contract.Requires(names != null); Contract.Requires(c != null); Contract.Requires(names.Length == c.Length); Contract.Requires(Contract.ForAll(0, c.Length, j => c[j] != null)); Contract.Requires(Contract.ForAll(names, name => name != null)); Contract.Ensures(Contract.Result<DatatypeSort[]>() != null); CheckContextMatch(names); uint n = (uint)names.Length; ConstructorList[] cla = new ConstructorList[n]; IntPtr[] n_constr = new IntPtr[n]; for (uint i = 0; i < n; i++) { Constructor[] constructor = c[i]; Contract.Assume(Contract.ForAll(constructor, arr => arr != null), "Clousot does not support yet quantified formula on multidimensional arrays"); CheckContextMatch(constructor); cla[i] = new ConstructorList(this, constructor); n_constr[i] = cla[i].NativeObject; } IntPtr[] n_res = new IntPtr[n]; Native.Z3_mk_datatypes(nCtx, n, Symbol.ArrayToNative(names), n_res, n_constr); DatatypeSort[] res = new DatatypeSort[n]; for (uint i = 0; i < n; i++) res[i] = new DatatypeSort(this, n_res[i]); return res; }
/// <summary> /// Create an array constant. /// </summary> public ArrayExpr MkArrayConst(Symbol name, Sort domain, Sort range) { Contract.Requires(name != null); Contract.Requires(domain != null); Contract.Requires(range != null); Contract.Ensures(Contract.Result<ArrayExpr>() != null); return (ArrayExpr)MkConst(name, MkArraySort(domain, range)); }
/// <summary> /// Create a new enumeration sort. /// </summary> public EnumSort MkEnumSort(Symbol name, params Symbol[] enumNames) { Contract.Requires(name != null); Contract.Requires(enumNames != null); Contract.Requires(Contract.ForAll(enumNames, f => f != null)); Contract.Ensures(Contract.Result<EnumSort>() != null); CheckContextMatch(name); CheckContextMatch(enumNames); return new EnumSort(this, name, enumNames); }
/// <summary> /// Create a new finite domain sort. /// <returns>The result is a sort</returns> /// </summary> /// <param name="name">The name used to identify the sort</param> /// <param name="size">The size of the sort</param> public FiniteDomainSort MkFiniteDomainSort(Symbol name, ulong size) { Contract.Requires(name != null); Contract.Ensures(Contract.Result<FiniteDomainSort>() != null); CheckContextMatch(name); return new FiniteDomainSort(this, name, size); }
internal Parameter(Z3_parameter_kind k, Symbol s) { this.kind = k; this.sym = s; }