当前位置: 首页>>代码示例>>C#>>正文


C# Context.MkFuncDecl方法代码示例

本文整理汇总了C#中Microsoft.Z3.Context.MkFuncDecl方法的典型用法代码示例。如果您正苦于以下问题:C# Context.MkFuncDecl方法的具体用法?C# Context.MkFuncDecl怎么用?C# Context.MkFuncDecl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Z3.Context的用法示例。


在下文中一共展示了Context.MkFuncDecl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MkRandomExpr

 /// <summary>
 /// Generates a slightly randomized expression.
 /// </summary>
 static BoolExpr MkRandomExpr(Context ctx, System.Random rng)
 {
     int limit = 1073741823;
         Sort i = ctx.IntSort;
         Sort b = ctx.BoolSort;
         Symbol sr1 = ctx.MkSymbol(rng.Next(0, limit));
         Symbol sr2 = ctx.MkSymbol(rng.Next(0, limit));
         Symbol sr3 = ctx.MkSymbol(rng.Next(0, limit));
         FuncDecl r1 = ctx.MkFuncDecl(sr1, i, b);
         FuncDecl r2 = ctx.MkFuncDecl(sr2, i, b);
         FuncDecl r3 = ctx.MkFuncDecl(sr3, i, b);
         Symbol s = ctx.MkSymbol(rng.Next(0, limit));
         Expr x = ctx.MkConst(s, i);
         BoolExpr r1x = (BoolExpr)ctx.MkApp(r1, x);
         BoolExpr r2x = (BoolExpr)ctx.MkApp(r2, x);
         BoolExpr r3x = (BoolExpr)ctx.MkApp(r3, x);
         Expr[] vars = { x };
         BoolExpr rl1 = ctx.MkForall(vars, ctx.MkImplies(r1x, r2x));
         BoolExpr rl2 = ctx.MkForall(vars, ctx.MkImplies(r2x, r1x));
         BoolExpr rl3 = (BoolExpr)ctx.MkApp(r1, ctx.MkInt(3));
         BoolExpr q = (BoolExpr)ctx.MkApp(r3, ctx.MkInt(2));
         BoolExpr a1 = ctx.MkNot(q);
         BoolExpr q1 = ctx.MkExists(vars, ctx.MkAnd(r3x, r2x));
         BoolExpr q2 = ctx.MkExists(vars, ctx.MkAnd(r3x, r1x));
         BoolExpr[] all = { a1, q1, q2 };
         return ctx.MkAnd(all);
 }
开发者ID:ExiaHan,项目名称:z3test,代码行数:30,代码来源:memory.cs

示例2: Run

 public void Run()
 {
     using (Context ctx = new Context()) {
         var s = ctx.MkFixedpoint();
         BoolSort B = ctx.BoolSort;
         Sort BV8   = ctx.MkBitVecSort(8);
         FuncDecl edge = ctx.MkFuncDecl("edge", new Sort[]{BV8, BV8}, B);
         FuncDecl path = ctx.MkFuncDecl("path", new Sort[]{BV8, BV8}, B);
         BitVecExpr x = (BitVecExpr)ctx.MkBound(0,BV8);
         BitVecExpr y = (BitVecExpr)ctx.MkBound(1,BV8);
         BitVecExpr z = (BitVecExpr)ctx.MkBound(2,BV8);
         s.RegisterRelation(edge);
         s.RegisterRelation(path);
         s.AddRule(ctx.MkImplies((BoolExpr)edge[x,y],(BoolExpr)path[x,y]));
         s.AddRule(ctx.MkImplies(ctx.MkAnd((BoolExpr)path[x,y],(BoolExpr)path[y,z]),
                                 (BoolExpr)path[x,z]));
         for (uint i = 0; i < 128; ++i) {
            s.AddFact(edge, i, i+1);
         }
         Console.WriteLine(s.Query((BoolExpr)path[ctx.MkBV(0,8),ctx.MkBV(129,8)]));
         Console.WriteLine(s.GetAnswer());
         Console.WriteLine(s.Query((BoolExpr)path[ctx.MkBV(0,8),ctx.MkBV(128,8)]));
         Console.WriteLine(s.GetAnswer());
         Console.WriteLine(s.Query((BoolExpr)path[x,ctx.MkBV(20,8)]));
         Console.WriteLine(s.GetAnswer());
         Console.WriteLine(s.Query(ctx.MkAnd((BoolExpr)path[x,y],
                                             (BoolExpr)path[y,ctx.MkBV(20,8)])));
         Console.WriteLine(s.GetAnswer());
     }
 }
开发者ID:ahorn,项目名称:z3test,代码行数:30,代码来源:fixedpoint.7.cs

示例3: Run

    public void Run()
    {
        Dictionary<string, string> cfg = new Dictionary<string, string>() {
            { "AUTO_CONFIG", "true" } };

        using (Context ctx = new Context(cfg))
        {
            Sort A = ctx.MkUninterpretedSort("A");
            Sort B = ctx.MkUninterpretedSort("B");

            FuncDecl f = ctx.MkFuncDecl("f", A, B);
            FuncDecl finv = ctx.MkFuncDecl("finv", B, A);

            Expr a1 = ctx.MkConst("a1", A);
            Expr a2 = ctx.MkConst("a2", A);
            Expr b = ctx.MkConst("b", B);
            Expr x = ctx.MkConst("x", A);
            Expr y = ctx.MkConst("y", A);

            Solver s = ctx.MkSolver();

            s.Assert(ctx.MkNot(ctx.MkEq(a1, a2)));
            s.Assert(ctx.MkEq(f[a1], b));
            s.Assert(ctx.MkEq(f[a2], b));
            s.Assert(ctx.MkForall(new Expr[] { x }, ctx.MkEq(finv[f[x]], x)));

            Console.WriteLine(s);
            Console.WriteLine(s.Check());
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:30,代码来源:quant.8.cs

示例4: Run

    public void Run()
    {
        Dictionary<string, string> cfg = new Dictionary<string, string>() { };

        using (Context ctx = new Context(cfg))
        {
            FuncDecl f = ctx.MkFuncDecl("f", ctx.IntSort, ctx.IntSort);
            FuncDecl g = ctx.MkFuncDecl("g", ctx.IntSort, ctx.IntSort);

            IntExpr a = ctx.MkIntConst("a");
            IntExpr b = ctx.MkIntConst("b");
            IntExpr c = ctx.MkIntConst("c");

            IntExpr x = ctx.MkIntConst("x");

            Solver s = ctx.MkSolver();
            Params p = ctx.MkParams();
            p.Add("AUTO_CONFIG", false);
            p.Add("MBQI", false);
            s.Parameters = p;

            s.Assert(ctx.MkForall(new Expr[] { x }, ctx.MkEq(f[g[x]], x), 1, new Pattern[] { ctx.MkPattern(f[g[x]]) }));
            s.Assert(ctx.MkEq(a, g[b]));
            s.Assert(ctx.MkEq(b, c));
            s.Assert(ctx.MkDistinct(f[a], c));

            Console.WriteLine(s);
            Console.WriteLine(s.Check());
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:30,代码来源:quant.6.cs

示例5: Run

    public void Run()
    {
        Dictionary<string, string> cfg = new Dictionary<string, string>() {
            { "AUTO_CONFIG", "true" } };

        using (Context ctx = new Context(cfg))
        {
            Sort A = ctx.MkUninterpretedSort("A");
            Expr x = ctx.MkConst("x", A);
            Expr y = ctx.MkConst("y", A);
            FuncDecl f = ctx.MkFuncDecl("f", A, A);

            Solver s = ctx.MkSolver();
            s.Assert(ctx.MkEq(f[f[x]], x),
                     ctx.MkEq(f[x], y),
                     ctx.MkNot(ctx.MkEq(x, y)));

            Console.WriteLine(s.Check());
            Model m = s.Model;
            Console.WriteLine(m);
            Console.WriteLine("interpretation assigned to A: ");
            foreach (Expr a in m.SortUniverse(A))
                Console.WriteLine(a);
        }
    }
开发者ID:ahorn,项目名称:z3test,代码行数:25,代码来源:uninterp.cs

示例6: Run

    public void Run()
    {
        using (Context ctx = new Context())
        {
            Sort U = ctx.MkUninterpretedSort("U");
            Console.WriteLine(U);
            Expr a = ctx.MkConst("a", U);

            a = ctx.MkConst("a", U);
            Expr b = ctx.MkConst("b", U);
            Expr c = ctx.MkConst("c", U);

            IntExpr x = ctx.MkIntConst("x");
            IntExpr y = ctx.MkIntConst("y");

            Console.WriteLine(ctx.MkAnd(ctx.MkEq(a, b), ctx.MkEq(a, c)));
            Console.WriteLine(U == ctx.IntSort);

            Sort U2 = ctx.MkUninterpretedSort("U");
            Console.WriteLine(U == U2);

            U2 = ctx.MkUninterpretedSort("U2");
            Console.WriteLine(U == U2);
            Console.WriteLine(ctx.MkDistinct(a, b, c));

            FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { U, U }, U);
            Console.WriteLine(ctx.MkEq(f[a,b], b));
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:29,代码来源:tst8.cs

示例7: Run

    public void Run()
    {
        using (Context ctx = new Context()) {
            ctx.UpdateParamValue("DL_ENGINE","1");
            ctx.UpdateParamValue("DL_PDR_USE_FARKAS","true");
        //          ctx.UpdateParamValue("VERBOSE","2");
            var s = ctx.MkFixedpoint();
            BoolSort B = ctx.BoolSort;
            IntSort I = ctx.IntSort;
            FuncDecl mc = ctx.MkFuncDecl("mc", new Sort[]{I, I}, B);
            ArithExpr x = (ArithExpr)ctx.MkBound(0,I);
            ArithExpr y = (ArithExpr)ctx.MkBound(1,I);
            ArithExpr z = (ArithExpr)ctx.MkBound(2,I);
            s.RegisterRelation(mc);
            BoolExpr gt = ctx.MkGt(x, ctx.MkInt(100));
            s.AddRule(ctx.MkImplies(gt,(BoolExpr)mc[x,ctx.MkSub(x,ctx.MkInt(10))]));
            s.AddRule(ctx.MkImplies(ctx.MkAnd(ctx.MkNot(gt),
                                      (BoolExpr) mc[ctx.MkAdd(x,ctx.MkInt(11)),y],
                                      (BoolExpr) mc[y,z]),
                                      (BoolExpr) mc[x,z]));
            Console.WriteLine(s.Query(ctx.MkAnd((BoolExpr)mc[x,y], ctx.MkGt(y,ctx.MkInt(100)))));
            Console.WriteLine(s.GetAnswer());

            Console.WriteLine(s.Query(ctx.MkAnd((BoolExpr)mc[x,y], ctx.MkLt(y,ctx.MkInt(91)))));
            Console.WriteLine(s.GetAnswer());
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:27,代码来源:fixedpoint4.cs

示例8: Run

    public void Run()
    {
        using (Context ctx = new Context())
        {
            Sort U = ctx.MkUninterpretedSort("U");
            FuncDecl f = ctx.MkFuncDecl("f", U, U);
            Expr a = ctx.MkConst("a", U);
            Expr b = ctx.MkConst("b", U);
            Expr c = ctx.MkConst("c", U);

            Solver s = ctx.MkSolver();
            s.Assert(ctx.MkEq(f[f[a]], b),
                     ctx.MkNot(ctx.MkEq(f[b], c)),
                     ctx.MkEq(f[c], c));
            Console.WriteLine(s.Check());
            Model m = s.Model;
            foreach (FuncDecl d in m.Decls)
                if (d.DomainSize == 0)
                    Console.WriteLine(d.Name + " -> " + m.ConstInterp(d));
                else
                    Console.WriteLine(d.Name + " -> " + m.FuncInterp(d));

            Console.WriteLine(m.NumSorts);
            Console.WriteLine(m.Sorts[0]);

            foreach(Sort srt in m.Sorts)
                Console.WriteLine(srt);

            foreach (Expr v in m.SortUniverse(U))
                Console.WriteLine(v);
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:32,代码来源:tst16.cs

示例9: Run

    public void Run()
    {
        Dictionary<string, string> cfg = new Dictionary<string, string>() {
            { "AUTO_CONFIG", "true" } };

        using (Context ctx = new Context(cfg))
        {
            IntExpr x = ctx.MkIntConst("x");
            FuncDecl x_d = x.FuncDecl;

            Console.WriteLine("is_expr(x_d): " + x_d.IsExpr);
            Console.WriteLine("is_func_decl(x_d): " + x_d.IsFuncDecl);
            Console.WriteLine("x_d.Name: " + x_d.Name);
            Console.WriteLine("x_d.Range: " + x_d.Range);
            Console.WriteLine("x_d.Arity: " + x_d.Arity);
            Console.WriteLine("x_d() == x: " + (x_d.Apply() == x));

            FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { ctx.IntSort, ctx.RealSort }, ctx.BoolSort);

            Console.WriteLine("f.Name: " + f.Name);
            Console.WriteLine("f.Range: " + f.Range);
            Console.WriteLine("f.Arity: " + f.Arity);

            for (uint i = 0; i < f.Arity; i++)
                Console.WriteLine("domain(" + i + "): " + f.Domain[i]);

            Console.WriteLine(f[x, ctx.MkInt2Real(x)]);
            Console.WriteLine(f[x, ctx.MkInt2Real(x)].FuncDecl == f);
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:30,代码来源:expr.5.cs

示例10: Run

    public void Run()
    {
        using (Context ctx = new Context())
        {
            RealExpr x = ctx.MkRealConst("x");
            RealExpr y = ctx.MkRealConst("y");
            RealExpr z = ctx.MkRealConst("z");

            FuncDecl f = ctx.MkFuncDecl("f", ctx.RealSort, ctx.RealSort);
            Solver s = ctx.MkSolver();

            s.Assert(ctx.MkGt(x, ctx.MkReal(10)),
                     ctx.MkEq(y, ctx.MkAdd(x, ctx.MkReal(3))),
                     ctx.MkLt(y, ctx.MkReal(15)),
                     ctx.MkGt((RealExpr)f[x], ctx.MkReal(2)),
                     ctx.MkNot(ctx.MkEq(f[y], f[x])));

            Console.WriteLine(s.Check());

            Model m = s.Model;

            foreach (FuncDecl fd in m.Decls)
                Console.Write(" " + fd.Name);
            Console.WriteLine();

            foreach (FuncDecl fd in m.Decls)
            {
                if (fd.DomainSize == 0)
                    Console.WriteLine(fd.Name + " -> " + m.ConstInterp(fd));
                else
                    Console.WriteLine(fd.Name + " -> " + m.FuncInterp(fd));
            }

            Console.WriteLine(m.Evaluate(ctx.MkAdd(z, ctx.MkReal(1))));
            Console.WriteLine(m.Evaluate(ctx.MkAdd(z, ctx.MkReal(1)), true));
            Console.WriteLine(m.Evaluate(z));

            FuncInterp fi = m.FuncInterp(f);

            Console.WriteLine(fi.Else);
            Console.WriteLine(fi.NumEntries);
            Console.WriteLine(fi.Entries[0]);
            Console.WriteLine(fi.Entries[0].NumArgs);
            Console.WriteLine(fi.Entries[0].Args[0]);
            Console.WriteLine(fi.Entries[0].Value);

            ArrayExpr a = ctx.MkArrayConst("a", ctx.RealSort, ctx.RealSort);
            s.Assert(ctx.MkGt((RealExpr)ctx.MkSelect(a, x), ctx.MkReal(10)),
                     ctx.MkGt((RealExpr)ctx.MkSelect(a, y), ctx.MkReal(20)));

            Console.WriteLine(s);
            Console.WriteLine(s.Check());
            Console.WriteLine(s.Model);
            Console.WriteLine(s.Model.Evaluate(a));
            Console.WriteLine(s.Model.FuncInterp(a.FuncDecl));
        }
    }
开发者ID:ahorn,项目名称:z3test,代码行数:57,代码来源:tst14.cs

示例11: Run

 public void Run()
 {
     using (Context ctx = new Context()) {
         var s = ctx.MkFixedpoint();
         BoolSort B = ctx.BoolSort;
         Sort BV8     = ctx.MkBitVecSort(8);
         FuncDecl f = ctx.MkFuncDecl("f", BV8, B);
         FuncDecl g = ctx.MkFuncDecl("g", BV8, B);
         BitVecExpr b0 = (BitVecExpr)ctx.MkBound(0,BV8);
         s.RegisterRelation(f);
         s.RegisterRelation(g);
         s.AddRule((BoolExpr)f[b0]);
         BitVecExpr mask0 = ctx.MkBV(0xFE,8);
         BoolExpr even = ctx.MkEq(b0,ctx.MkBVAND(b0,mask0));
         s.AddRule(ctx.MkImplies(ctx.MkAnd((BoolExpr)f[b0],even), (BoolExpr)g[b0]));
         Console.WriteLine(s.Query((BoolExpr)g[b0]));
         Console.WriteLine(s.GetAnswer());
     }
 }
开发者ID:ExiaHan,项目名称:z3test,代码行数:19,代码来源:fixedpoint2.cs

示例12: GetOrAddMemberAccessFunction

        internal static FuncDecl GetOrAddMemberAccessFunction(Context context, Environment environment, MemberInfo memberInfo)
        {
            FuncDecl memberFunc;
            if (!environment.Members.TryGetValue(memberInfo, out memberFunc))
            {
                Sort memberTypeSort;
                if (!environment.Types.TryGetValue(memberInfo.DeclaringType, out memberTypeSort))
                {
                    throw new KeyNotFoundException(memberInfo.DeclaringType + " could not be found at environment.Types");
                }

                Sort memberReturnTypeEnumSort;
                var propertyType = ((PropertyInfo)memberInfo).PropertyType;
                if (propertyType == typeof(bool))
                    memberReturnTypeEnumSort = context.MkBoolSort();
                else if (propertyType == typeof(int))
                    memberReturnTypeEnumSort = context.MkIntSort();
                else if (propertyType == typeof(long))
                    memberReturnTypeEnumSort = context.MkRealSort();
                else if (propertyType == typeof(string))
                    memberReturnTypeEnumSort = environment.PossibleStringValues;
                else
                {
                    if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
                    {
                        var listItemType = propertyType.GenericTypeArguments[0];

                        var listSort = context.MkSetSort(environment.Types[listItemType]);

                        memberReturnTypeEnumSort = listSort;

                        // TODO: add TryGetValue
                        environment.Types.Add(propertyType, listSort);
                    }
                    else if (propertyType.IsEnum)
                    {
                        EnumSort enumSort = context.MkEnumSort(propertyType.Name, Enum.GetNames(propertyType));

                        memberReturnTypeEnumSort = enumSort;

                        // TODO: add TryGetValue
                        environment.Types.Add(propertyType, enumSort);
                    }
                    else
                    {
                        // TODO throw exception if type is not supported
                        memberReturnTypeEnumSort = environment.Types[propertyType];
                    }
                }

                memberFunc = context.MkFuncDecl(memberInfo.Name, memberTypeSort, memberReturnTypeEnumSort);
                environment.Members.Add(memberInfo, memberFunc);
            }
            return memberFunc;
        }
开发者ID:RicardoNiepel,项目名称:Z3.ObjectTheorem,代码行数:55,代码来源:LambdaExpressionToConstraintGenerator.cs

示例13: InjAxiom

        /// <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;
        }
开发者ID:perillaseed,项目名称:z3,代码行数:63,代码来源:Program.cs

示例14: Run

    public void Run()
    {
        using (Context ctx = new Context())
        {
            FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { ctx.IntSort, ctx.RealSort }, ctx.IntSort);

            try
            {
                Console.WriteLine(f.Domain[3]);
            }
            catch (IndexOutOfRangeException ex)
            {
                Console.WriteLine("failed: " + ex.Message);
            }

            IntExpr x = ctx.MkIntConst("x");

            Console.WriteLine(f[ctx.MkInt(1), ctx.MkReal(1)]);
            Console.WriteLine(f[ctx.MkInt(1), ctx.MkReal(1)].Sort);
            Console.WriteLine(f[ctx.MkInt(1), ctx.MkReal(1)].NumArgs);
            foreach (Expr e in f[ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkReal(1)].Args)
            Console.WriteLine(e);
            Console.WriteLine(f[ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkReal(1)].Args[0]);
            Console.WriteLine(f[ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkReal(1)].Args[0].Equals(ctx.MkAdd(x, ctx.MkInt(1))));
            Console.WriteLine(f[ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkReal(1)].FuncDecl[ctx.MkInt(2), ctx.MkInt2Real((IntExpr)ctx.MkAdd(x, ctx.MkInt(1)))]);

            Console.WriteLine(ctx.MkInt(1).IsExpr);
            Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1)).IsExpr);
            Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).IsExpr);
            Console.WriteLine(ctx.MkInt(1).IsConst);
            Console.WriteLine(x.IsConst);
            Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1)).IsConst);
            Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).IsConst);

            Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).Body.Args[0]);
            Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).Body.Args[0].IsExpr);
            Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).Body.Args[0].IsConst);
            Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).Body.Args[0].IsVar);
            Console.WriteLine(x.IsVar);
            Console.WriteLine(ctx.MkITE(ctx.MkTrue(), x, ctx.MkAdd(x, ctx.MkInt(1))));

            Context ctx1 = new Context();
            Console.WriteLine(ctx1.MkITE(ctx1.MkTrue(), x.Translate(ctx1), ctx.MkAdd(x, ctx.MkInt(1)).Translate(ctx1)));
            Console.WriteLine(ctx.MkITE(ctx.MkTrue(), ctx.MkInt(1), ctx.MkInt(1)));

            Console.WriteLine(ctx.MkDistinct(x, ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkAdd(x, ctx.MkInt(2))));

            Console.WriteLine(ctx1.MkAnd(ctx1.MkDistinct(x.Translate(ctx1), ctx1.MkInt(1)),
                                         ctx1.MkGt((IntExpr)x.Translate(ctx1), ctx1.MkInt(0))));

        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:52,代码来源:tst5.cs

示例15: Run

 public void Run()
 {
     using (Context ctx = new Context()) {
         Symbol s1 = ctx.MkSymbol(1);
         Symbol s2 = ctx.MkSymbol(1);
         Symbol s3 = ctx.MkSymbol(2);
         Sort[] domain = new Sort[0];
     Sort range = ctx.IntSort;
         TestDriver.CheckAssertion("a1", s1 == s2);
         TestDriver.CheckAssertion("a2", s1 != s3);
         TestDriver.CheckAssertion("a3", ctx.MkSymbol("x") != s1);
         TestDriver.CheckAssertion("a4", ctx.MkSymbol("x") == ctx.MkSymbol("x"));
         TestDriver.CheckAssertion("a5", ctx.MkFuncDecl("f", domain, range) == ctx.MkFuncDecl("f", domain, range));
         TestDriver.CheckAssertion("a6", ctx.MkFuncDecl("f", domain, range) != ctx.MkFuncDecl("g", domain, range));
         TestDriver.CheckAssertion("a7", ctx.MkUninterpretedSort("s") == ctx.MkUninterpretedSort("s"));
         TestDriver.CheckAssertion("a8", ctx.MkUninterpretedSort("s") != ctx.MkUninterpretedSort("t"));
         TestDriver.CheckAssertion("a9", ctx.MkUninterpretedSort("s") != ctx.IntSort);
         TestDriver.CheckAssertion("a10", ctx.MkConst("x", range) == ctx.MkConst("x", range));
         TestDriver.CheckAssertion("a11", ctx.MkConst("x", range) == ctx.MkConst(ctx.MkSymbol("x"), range));
         TestDriver.CheckAssertion("a12", ctx.MkConst("x", range) != ctx.MkConst("y", range));
     }
 }
开发者ID:ExiaHan,项目名称:z3test,代码行数:22,代码来源:compare.cs


注:本文中的Microsoft.Z3.Context.MkFuncDecl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。