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


C# Context.MkIntConst方法代码示例

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


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

示例1: Run

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

        using (Context ctx = new Context(settings))
        {
            IntExpr a = ctx.MkIntConst("a");
            IntExpr b = ctx.MkIntConst("b");
            IntExpr c = ctx.MkIntConst("c");
            RealExpr d = ctx.MkRealConst("d");
            RealExpr e = ctx.MkRealConst("e");

            BoolExpr q = ctx.MkAnd(
                ctx.MkGt(a, ctx.MkAdd(b, ctx.MkInt(2))),
                ctx.MkEq(a, ctx.MkAdd(ctx.MkMul(ctx.MkInt(2), c), ctx.MkInt(10))),
                ctx.MkLe(ctx.MkAdd(c, b), ctx.MkInt(1000)),
                ctx.MkGe(d, e));

            Solver s = ctx.MkSolver();
            s.Assert(q);

            Console.WriteLine(s.Check());

            Console.WriteLine(s.Model);
        }
    }
开发者ID:ahorn,项目名称:z3test,代码行数:26,代码来源:arith.2.cs

示例2: Run

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

        using (Context ctx = new Context(cfg))
        {
            IntExpr dog = ctx.MkIntConst("dog");
            IntExpr cat = ctx.MkIntConst("cat");
            IntExpr mouse = ctx.MkIntConst("mouse");

            Solver s = ctx.MkSolver();

            s.Assert(ctx.MkGe(dog, ctx.MkInt(1)));
            s.Assert(ctx.MkGe(cat, ctx.MkInt(1)));
            s.Assert(ctx.MkGe(mouse, ctx.MkInt(1)));
            s.Assert(ctx.MkEq(ctx.MkAdd(dog, cat, mouse), ctx.MkInt(100)));
            s.Assert(ctx.MkEq(ctx.MkAdd(ctx.MkMul(ctx.MkInt(1500), dog),
                                        ctx.MkMul(ctx.MkInt(100), cat),
                                        ctx.MkMul(ctx.MkInt(25), mouse)),
                              ctx.MkInt(10000)));

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

示例3: Run

    public void Run()
    {
        using (Context ctx = new Context())
        {
            BoolExpr p = ctx.MkBoolConst("p");
            Console.WriteLine(ctx.MkNot(p));
            Console.WriteLine(ctx.MkNot(p));
            IntExpr x = ctx.MkIntConst("x");
            IntExpr y = ctx.MkIntConst("y");

            Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1)));
            Console.WriteLine(ctx.MkAdd(ctx.MkInt(1), x));
            Console.WriteLine(ctx.MkAdd(x, y));
            Console.WriteLine(ctx.MkMul(ctx.MkInt(2), x));
            Console.WriteLine(ctx.MkMul(x, ctx.MkInt(2)));
            Console.WriteLine(ctx.MkMul(x, y));
            Console.WriteLine(ctx.MkDiv(x, y));
            Console.WriteLine(ctx.MkMod(x, y));
            Console.WriteLine(ctx.MkEq(x, y));
            Console.WriteLine(ctx.MkDistinct(x, y, x));
            Console.WriteLine(ctx.MkNot(ctx.MkEq(x, y)));
            Console.WriteLine(ctx.MkEq(x, y));
            Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1)));
            Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1)));

            BoolExpr q = ctx.MkBoolConst("q");
            Console.WriteLine(ctx.MkNot(p));
            Console.WriteLine(ctx.MkNot(p));
            Console.WriteLine(ctx.MkAnd(p, q));
            Console.WriteLine(ctx.MkAnd(p, q));
            Console.WriteLine(ctx.MkEq(x, y));
        }
    }
开发者ID:ahorn,项目名称:z3test,代码行数:33,代码来源:tst2.cs

示例4: 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");
            IntExpr y = ctx.MkIntConst("y");

            Solver s = ctx.MkSolver();
            Console.WriteLine(s);

            s.Assert(ctx.MkGt(x, ctx.MkInt(10)), ctx.MkEq(y, ctx.MkAdd(x, ctx.MkInt(2))));
            Console.WriteLine(s);
            Console.WriteLine("solving s");
            Console.WriteLine(s.Check());

            Console.WriteLine("creating new scope");
            s.Push();
            s.Assert(ctx.MkLt(y, ctx.MkInt(11)));
            Console.WriteLine(s);
            Console.WriteLine("solving updated constraints");
            Console.WriteLine(s.Check());

            Console.WriteLine("restoring");
            s.Pop();
            Console.WriteLine(s);
            Console.WriteLine("solving restored constraints");
            Console.WriteLine(s.Check());
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:32,代码来源:z3py.10.cs

示例5: Run

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

        using (Context ctx = new Context(cfg))
        {
            BoolExpr p1 = ctx.MkBoolConst("p1");
            BoolExpr p2 = ctx.MkBoolConst("p2");
            BoolExpr p3 = ctx.MkBoolConst("p3");

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

            Solver s = ctx.MkSolver();

            s.Assert(ctx.MkImplies(p1, ctx.MkGt(x, ctx.MkInt(10))),
                     ctx.MkImplies(p1, ctx.MkGt(y, x)),
                     ctx.MkImplies(p2, ctx.MkLt(y, ctx.MkInt(5))),
                     ctx.MkImplies(p3, ctx.MkGt(y, ctx.MkInt(0))));

            Console.WriteLine(s);
            Console.WriteLine(s.Check(p1, p2, p3));
            Console.WriteLine("Core: ");
            foreach (Expr e in s.UnsatCore)
                Console.WriteLine(e);

            Console.WriteLine(s.Check(p1, p3));
            Console.WriteLine(s.Model);
        }
    }
开发者ID:ahorn,项目名称:z3test,代码行数:31,代码来源:unsatcore.cs

示例6: 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

示例7: Run

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

        using (Context ctx = new Context(cfg))
        {
            IntExpr[] x = new IntExpr[20];
            IntExpr[] y = new IntExpr[20];

            for (uint i = 0; i < 20; i++)
            {
                x[i] = ctx.MkIntConst(string.Format("x_{0}", i));
                y[i] = ctx.MkIntConst(string.Format("y_{0}", i));
            }

            BoolExpr f = ctx.MkAnd(ctx.MkGe(ctx.MkAdd(x), ctx.MkInt(0)),
                                   ctx.MkGe(ctx.MkAdd(y), ctx.MkInt(0)));

            Console.WriteLine("now: " + ctx.GetParamValue("PP_MAX_DEPTH"));

            ctx.UpdateParamValue("PP_MAX_DEPTH", "1");
            Console.WriteLine(f);

            ctx.UpdateParamValue("PP_MAX_DEPTH", "100");
            ctx.UpdateParamValue("PP_MAX_NUM_LINES", "10");
            Console.WriteLine(f);

            ctx.UpdateParamValue("PP_MAX_NUM_LINES", "20");
            ctx.UpdateParamValue("PP_MAX_WIDTH", "300");
            Console.WriteLine(f);

            Console.WriteLine("now: " + ctx.GetParamValue("PP_MAX_WIDTH"));
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:35,代码来源:format.cs

示例8: 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

示例9: Run

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

        using (Context ctx = new Context(cfg))
        {
            ArithExpr[] a = new ArithExpr[5];
            for (uint x = 0; x < 5; x++)
                a[x] = ctx.MkInt(x+1);

            foreach (Expr e in a)
                Console.WriteLine(e);

            ArithExpr[] X = new ArithExpr[5];
            for (uint i = 0; i < 5; i++)
                X[i] = ctx.MkIntConst(string.Format("x{0}", i));

            ArithExpr[] Y = new ArithExpr[5];
            for (uint i = 0; i < 5; i++)
                Y[i] = ctx.MkIntConst(string.Format("y{0}", i));

            foreach (Expr e in X)
                Console.WriteLine(e);

            ArithExpr[] X_plus_Y = new ArithExpr[5];
            for (uint i = 0; i < 5; i++)
                X_plus_Y[i] = ctx.MkAdd(X[i], Y[i]);

            foreach (Expr e in X_plus_Y)
                Console.WriteLine(e);

            BoolExpr[] X_gt_Y = new BoolExpr[5];
            for (uint i = 0; i < 5; i++)
                X_gt_Y[i] = ctx.MkGt(X[i], Y[i]);

            foreach (Expr e in X_gt_Y)
                Console.WriteLine(e);

            Console.WriteLine(ctx.MkAnd(X_gt_Y));

            Expr[][] matrix = new Expr[3][];
            for (uint i = 0; i < 3; i++) {
                matrix[i] = new Expr[3];
                for (uint j = 0; j < 3; j++)
                    matrix[i][j] = ctx.MkIntConst(string.Format("x_{0}_{1}", i + 1, j + 1));
            }

            foreach(Expr[] row in matrix) {
                foreach(Expr e in row)
                    Console.Write(" " + e);
                Console.WriteLine();
            }
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:55,代码来源:list.1.cs

示例10: 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");
            IntExpr y = ctx.MkIntConst("y");

            Console.WriteLine(ctx.MkAdd(x, y).FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ADD);
            Console.WriteLine(ctx.MkAdd(x, y).FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SUB);
        }
    }
开发者ID:ahorn,项目名称:z3test,代码行数:14,代码来源:expr.6.cs

示例11: Run

    public void Run()
    {
        using (Context ctx = new Context())
        {
            BoolExpr p = ctx.MkBoolConst("p");
            BoolExpr q = ctx.MkBoolConst("q");
            Console.WriteLine(ctx.MkAnd(p, q));
            Console.WriteLine(ctx.MkOr(p, q));
            Console.WriteLine(ctx.MkAnd(p, ctx.MkTrue()));
            Console.WriteLine(ctx.MkOr(p, ctx.MkFalse()));
            Console.WriteLine(ctx.MkNot(p));
            Console.WriteLine(ctx.MkImplies(p, q));
            Console.WriteLine(ctx.MkEq(p, q).Simplify());
            Console.WriteLine(ctx.MkEq(p, q));

            BoolExpr r = ctx.MkBoolConst("r");

            Console.WriteLine(ctx.MkNot(ctx.MkEq(p, ctx.MkNot(ctx.MkEq(q, r)))));
            Console.WriteLine(ctx.MkNot(ctx.MkEq(ctx.MkNot(ctx.MkEq(p, q)), r)));
            Console.WriteLine(ctx.MkEq(p, ctx.MkTrue()));
            Console.WriteLine(ctx.MkEq(p, ctx.MkFalse()));
            Console.WriteLine(ctx.MkEq(p, ctx.MkTrue()).Simplify());
            Console.WriteLine(ctx.MkEq(p, ctx.MkFalse()).Simplify());
            Console.WriteLine(ctx.MkEq(p, p).Simplify());
            Console.WriteLine(ctx.MkEq(p, q).Simplify());
            Console.WriteLine(ctx.MkAnd(p, q, r));
            Console.WriteLine(ctx.MkOr(p, q, r));

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

            Console.WriteLine(x is BoolExpr);
            Console.WriteLine(p is BoolExpr);
            Console.WriteLine(ctx.MkAnd(p, q) is BoolExpr);
            Console.WriteLine(p is BoolExpr);
            Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1)) is BoolExpr);
            Console.WriteLine(p.IsAnd);
            Console.WriteLine(ctx.MkOr(p, q).IsOr);
            Console.WriteLine(ctx.MkAnd(p, q).IsAnd);
            Console.WriteLine(x.IsNot);
            Console.WriteLine(p.IsNot);
            Console.WriteLine(ctx.MkNot(p));
            Console.WriteLine(ctx.MkNot(p).IsDistinct);
            Console.WriteLine(ctx.MkEq(p, q).IsDistinct);
            Console.WriteLine(ctx.MkDistinct(p, q).IsDistinct);
            Console.WriteLine(ctx.MkDistinct(x, ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkAdd(x, ctx.MkInt(2))).IsDistinct);

            Console.WriteLine();

            Console.WriteLine(ctx.MkBool(true));
            Console.WriteLine(ctx.MkBool(false));
            Console.WriteLine(ctx.BoolSort);

            Context ctx1 = new Context();
            Console.WriteLine(ctx1.MkBool(true));
            Console.WriteLine(ctx1.BoolSort);
            Console.WriteLine(ctx1.MkBool(true).Sort == ctx1.BoolSort);
            Console.WriteLine(ctx1.MkBool(true).Sort == ctx.BoolSort);
            Console.WriteLine(ctx1.MkBool(true).Sort != ctx.BoolSort);
        }
    }
开发者ID:ahorn,项目名称:z3test,代码行数:60,代码来源:tst7.cs

示例12: 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

示例13: Run

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

        using (Context ctx = new Context(cfg))
        {
            IntExpr[] X = new IntExpr[5];
            for (uint i = 0; i < 5; i++)
                X[i] = ctx.MkIntConst(string.Format("x_{0}", i));

            RealExpr[] Y = new RealExpr[5];
            for (uint i = 0; i < 5; i++)
                Y[i] = ctx.MkRealConst(string.Format("y_{0}", i));

            BoolExpr[] P = new BoolExpr[5];
            for (uint i = 0; i < 5; i++)
                P[i] = ctx.MkBoolConst(string.Format("p_{0}", i));

            foreach (Expr x in X)
                Console.WriteLine(x);
            foreach (Expr x in Y)
                Console.WriteLine(x);
            foreach (Expr x in P)
                Console.WriteLine(x);

            foreach (ArithExpr y in Y)
                Console.WriteLine(ctx.MkPower(y, ctx.MkReal(2)));

            ArithExpr[] Yp = new ArithExpr[Y.Length];
            for (uint i = 0; i < Y.Length; i++)
                Yp[i] = ctx.MkPower(Y[i], ctx.MkReal(2));
            Console.WriteLine(ctx.MkAdd(Yp));
        }
    }
开发者ID:ahorn,项目名称:z3test,代码行数:35,代码来源:list.2.cs

示例14: ProveExample2

        public static void ProveExample2(Context ctx)
        {
            Console.WriteLine("ProveExample2");

            /* declare function g */
            Sort I = ctx.IntSort;

            FuncDecl g = ctx.MkFuncDecl("g", I, I);

            /* create x, y, and z */
            IntExpr x = ctx.MkIntConst("x");
            IntExpr y = ctx.MkIntConst("y");
            IntExpr z = ctx.MkIntConst("z");

            /* create gx, gy, gz */
            Expr gx = ctx.MkApp(g, x);
            Expr gy = ctx.MkApp(g, y);
            Expr gz = ctx.MkApp(g, z);

            /* create zero */
            IntExpr zero = ctx.MkInt(0);

            /* assert not(g(g(x) - g(y)) = g(z)) */
            ArithExpr gx_gy = ctx.MkSub((IntExpr)gx, (IntExpr)gy);
            Expr ggx_gy = ctx.MkApp(g, gx_gy);
            BoolExpr eq = ctx.MkEq(ggx_gy, gz);
            BoolExpr c1 = ctx.MkNot(eq);

            /* assert x + z <= y */
            ArithExpr x_plus_z = ctx.MkAdd(x, z);
            BoolExpr c2 = ctx.MkLe(x_plus_z, y);

            /* assert y <= x */
            BoolExpr c3 = ctx.MkLe(y, x);

            /* prove z < 0 */
            BoolExpr f = ctx.MkLt(z, zero);
            Console.WriteLine("prove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < 0");
            Prove(ctx, f, c1, c2, c3);

            /* disprove z < -1 */
            IntExpr minus_one = ctx.MkInt(-1);
            f = ctx.MkLt(z, minus_one);
            Console.WriteLine("disprove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < -1");
            Disprove(ctx, f, c1, c2, c3);
        }
开发者ID:lsfcin,项目名称:prepose,代码行数:46,代码来源:Program.cs

示例15: 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");
            IntExpr y = ctx.MkIntConst("y");

            Solver s = ctx.MkTactic("smt").Solver;

            s.Assert(ctx.MkGt(x, ctx.MkAdd(y, ctx.MkInt(1))));
            Console.WriteLine(s.Check());
            Console.WriteLine(s.Model);
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:17,代码来源:tactic.8.cs


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