Example #1
0
        internal EnumSort(Context ctx, Symbol name, Symbol[] enumNames)
            : base(ctx, IntPtr.Zero)
        {
            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);
        }
Example #2
0
        [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)
        {
            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);
            }
        }
Example #3
0
        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)
        {
            Debug.Assert(ctx != null);
            Debug.Assert(sorts != null);
            Debug.Assert(names != null);
            Debug.Assert(body != null);
            Debug.Assert(sorts.Length == names.Length);
            Debug.Assert(sorts.All(s => s != null));
            Debug.Assert(names.All(n => n != null));
            Debug.Assert(patterns == null || patterns.All(p => p != null));
            Debug.Assert(noPatterns == null || noPatterns.All(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, (byte)(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, (byte)(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);
            }
        }
Example #4
0
        internal Lambda(Context ctx, Sort[] sorts, Symbol[] names, Expr body)
            : base(ctx, IntPtr.Zero)
        {
            Debug.Assert(ctx != null);
            Debug.Assert(sorts != null);
            Debug.Assert(names != null);
            Debug.Assert(body != null);
            Debug.Assert(sorts.Length == names.Length);
            Debug.Assert(sorts.All(s => s != null));
            Debug.Assert(names.All(n => n != null));
            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");
            }

            NativeObject = Native.Z3_mk_lambda(ctx.nCtx,
                                               AST.ArrayLength(sorts), AST.ArrayToNative(sorts),
                                               Symbol.ArrayToNative(names),
                                               body.NativeObject);
        }
Example #5
0
        /// <summary>
        /// Instrument the Datalog engine on which table representation to use for recursive predicate.
        /// </summary>
        public void SetPredicateRepresentation(FuncDecl f, Symbol[] kinds)
        {
            Contract.Requires(f != null);

            Native.Z3_fixedpoint_set_predicate_representation(Context.nCtx, NativeObject,
                                                              f.NativeObject, AST.ArrayLength(kinds), Symbol.ArrayToNative(kinds));
        }