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


C# Context.MkSub方法代码示例

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


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

示例1: Run

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

        using (Context ctx = new Context(cfg))
        {
            RealExpr x = ctx.MkRealConst("x");
            RealExpr y = ctx.MkRealConst("y");
            RealExpr z = ctx.MkRealConst("z");
            RatNum zero = ctx.MkReal(0);
            RatNum two = ctx.MkReal(2);

            Goal g = ctx.MkGoal();

            g.Assert(ctx.MkGe(ctx.MkSub(ctx.MkPower(x, two), ctx.MkPower(y, two)), zero));

            Probe p = ctx.MkProbe("num-consts");
            Probe p2 = ctx.Gt(p, ctx.Const(2));
            Tactic t = ctx.Cond(p2, ctx.MkTactic("simplify"), ctx.MkTactic("factor"));

            Console.WriteLine(t[g]);

            g = ctx.MkGoal();
            g.Assert(ctx.MkGe(ctx.MkAdd(x, x, y, z), zero));
            g.Assert(ctx.MkGe(ctx.MkSub(ctx.MkPower(x, two), ctx.MkPower(y, two)), zero));

            Console.WriteLine(t[g]);
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:30,代码来源:probe.3.cs

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

示例3: Run

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

        using (Context ctx = new Context(cfg))
        {
                        RealExpr x = ctx.MkRealConst("x");
            RealExpr y = ctx.MkRealConst("y");

            Solver s = ctx.MkSolver();

            s.Assert(ctx.MkGt(x, ctx.MkReal(1)),
                     ctx.MkGt(y, ctx.MkReal(1)),
                     ctx.MkOr(ctx.MkGt(ctx.MkAdd(x, y), ctx.MkReal(1)),
                              ctx.MkLt(ctx.MkSub(x, y), ctx.MkReal(2))));

            Console.WriteLine("asserted constraints: ");
            foreach (var c in s.Assertions)
                Console.WriteLine(c);

            Console.WriteLine(s.Check());
            Console.WriteLine(s.Statistics);

            Console.WriteLine("stats for last check: ");
            foreach (Statistics.Entry e in s.Statistics.Entries)
                Console.WriteLine(e);
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:29,代码来源:z3py.12.cs

示例4: Run

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

        Context ctx = new Context(cfg);

        RealExpr x = ctx.MkRealConst("x");
        RealExpr y = ctx.MkRealConst("y");
        RealExpr z = ctx.MkRealConst("z");

        RatNum two = ctx.MkReal(2);

        Console.WriteLine(ctx.MkAdd(ctx.MkSub(ctx.MkMul(x, y), ctx.MkPower(y, two)), ctx.MkPower(z, two)));

        Console.WriteLine(ctx.MkSub(ctx.MkAdd(ctx.MkMul(x, y), ctx.MkPower(y, two)), ctx.MkPower(z, two)));

        Console.WriteLine(ctx.MkMul(ctx.MkAdd(x, y), z));
    }
开发者ID:ahorn,项目名称:z3test,代码行数:19,代码来源:bug5.cs

示例5: Run

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

        using (Context ctx = new Context(cfg))
        {
            ArithExpr[] Q = new ArithExpr[8];
            for (uint i = 0; i < 8; i++)
                Q[i] = ctx.MkIntConst(string.Format("Q_{0}", i + 1));

            BoolExpr[] val_c = new BoolExpr[8];
            for (uint i = 0; i < 8; i++)
                val_c[i] = ctx.MkAnd(ctx.MkLe(ctx.MkInt(1), Q[i]),
                                     ctx.MkLe(Q[i], ctx.MkInt(8)));

            BoolExpr col_c = ctx.MkDistinct(Q);

            BoolExpr[][] diag_c = new BoolExpr[8][];
            for (uint i = 0; i < 8; i++)
            {
                diag_c[i] = new BoolExpr[i];
                for (uint j = 0; j < i; j++)
                    diag_c[i][j] = (BoolExpr)ctx.MkITE(ctx.MkEq(ctx.MkInt(i), ctx.MkInt(j)),
                                             ctx.MkTrue(),
                                             ctx.MkAnd(ctx.MkNot(ctx.MkEq(ctx.MkSub(Q[i], Q[j]),
                                                                          ctx.MkSub(ctx.MkInt(i), ctx.MkInt(j)))),
                                                       ctx.MkNot(ctx.MkEq(ctx.MkSub(Q[i], Q[j]),
                                                                          ctx.MkSub(ctx.MkInt(j), ctx.MkInt(i))))));
            }

            Solver s = ctx.MkSolver();
            s.Assert(val_c);
            s.Assert(col_c);
            foreach (var c in diag_c)
                s.Assert(c);

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

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

示例7: SimplifierExample

        /// <summary>
        /// Simplifier example.
        /// </summary>
        public static void SimplifierExample(Context ctx)
        {
            Console.WriteLine("SimplifierExample");

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

            Expr t1 = ctx.MkAdd(x, ctx.MkSub(y, ctx.MkAdd(x, z)));
            Expr t2 = t1.Simplify();
            Console.WriteLine("{0} -> {1}", (t1), (t2));
        }
开发者ID:perillaseed,项目名称:z3,代码行数:16,代码来源:Program.cs

示例8: Run

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

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

            ctx.UpdateParamValue(":pp-flat-assoc", "false");

            Console.WriteLine(ctx.MkAdd(x, y, ctx.MkInt2Real(a)));
            Console.WriteLine(ctx.MkAdd(x, ctx.MkReal(1)));
            Console.WriteLine(ctx.MkAdd(ctx.MkReal(2), y));
            Console.WriteLine(ctx.MkMul(x, y));
            Console.WriteLine(ctx.MkAdd(ctx.MkInt(2), ctx.MkInt(3)));
            Console.WriteLine(ctx.MkMul(ctx.MkReal(2), x));
            Console.WriteLine(ctx.MkAdd(ctx.MkInt2Real((IntExpr)ctx.MkAdd(ctx.MkInt(2), ctx.MkInt(3))), x));
            Console.WriteLine(ctx.MkAdd((RealExpr)ctx.MkInt2Real((IntExpr)ctx.MkAdd(ctx.MkInt(2), ctx.MkInt(3))).Simplify(), x));
            Console.WriteLine(ctx.MkAdd(a, b, ctx.MkInt(1)));
            Console.WriteLine(ctx.MkDiv(x, y));
            Console.WriteLine(ctx.MkDiv(x, ctx.MkReal(2)));
            Console.WriteLine(ctx.MkDiv(ctx.MkReal(2), y));
            Console.WriteLine(ctx.MkDiv(a, ctx.MkInt(2)));
            Console.WriteLine(ctx.MkDiv(ctx.MkAdd(a, b), ctx.MkInt(2)));
            Console.WriteLine(ctx.MkDiv(ctx.MkInt(3), a));
            Console.WriteLine(ctx.MkMod(a, b));
            Console.WriteLine(ctx.MkMod(a, ctx.MkInt(2)));
            Console.WriteLine(ctx.MkMod(ctx.MkInt(3), a));
            Console.WriteLine(ctx.MkSub(a, ctx.MkInt(2)));
            Console.WriteLine(ctx.MkUnaryMinus(a));
            Console.WriteLine(ctx.MkUnaryMinus(x));
            Console.WriteLine(ctx.MkSub(a, b));

            Console.WriteLine(a.IsAdd);
            Console.WriteLine(ctx.MkAdd(a, b).IsAdd);
            Console.WriteLine(ctx.MkSub(a, b).IsAdd);
            Console.WriteLine(ctx.MkInt(10).IsAdd);
            Console.WriteLine(ctx.MkMul(a, b).IsMul);
            Console.WriteLine(ctx.MkMul(x, ctx.MkInt2Real(b)).IsMul);
            Console.WriteLine(ctx.MkAdd(a, b).IsMul);
            Console.WriteLine(ctx.MkDiv(a, ctx.MkInt(2)).IsDiv);
            Console.WriteLine(ctx.MkDiv(ctx.MkReal(3), x).IsDiv);
            Console.WriteLine(ctx.MkDiv(x,y).IsDiv);
            Console.WriteLine(ctx.MkDiv(a, ctx.MkInt(2)).IsIDiv);
            Console.WriteLine(ctx.MkAdd(ctx.MkInt(2), ctx.MkInt(3)).Simplify().IsAdd);

            Console.WriteLine();
            Console.WriteLine(a is ArithExpr);
            Console.WriteLine(ctx.MkInt(2) is ArithExpr);
            Console.WriteLine(ctx.MkAdd(a, b) is ArithExpr);
            Console.WriteLine(ctx.MkBoolConst("p") is ArithExpr);
            Console.WriteLine(ctx.MkInt(2) is IntNum);
            Console.WriteLine(ctx.MkInt(2) is RatNum);
            Console.WriteLine(ctx.MkReal(2, 3));
            Console.WriteLine(ctx.MkReal(2, 3).IsReal);
            Console.WriteLine(ctx.MkReal(2, 3) is ArithExpr);
            Console.WriteLine(ctx.MkReal(2, 3).IsConst);
            Console.WriteLine(ctx.MkReal(2, 3).Simplify() is RatNum);
            Console.WriteLine(ctx.MkReal(2, 3).Simplify().IsRatNum);
            Console.WriteLine(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 2)).Simplify().IsAlgebraicNumber);
            Console.WriteLine(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 2)).Simplify() is AlgebraicNum);
            Console.WriteLine(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 2)).IsAlgebraicNumber);
            Console.WriteLine(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 2)) is AlgebraicNum);
            Console.WriteLine(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 2)));
            Console.WriteLine(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 3)));
        }
    }
开发者ID:ahorn,项目名称:z3test,代码行数:71,代码来源:tst10.cs

示例9: MyQuantifierExample

        /// <summary>
        /// A basic example of how to use quantifiers.
        /// </summary>
        static void MyQuantifierExample(Context ctx)
        {
            Console.WriteLine("MyQuantifierExample");

            RealExpr x1 = ctx.MkRealConst("x1");
            RealExpr x2 = ctx.MkRealConst("x2");

            BoolExpr body_vars = ctx.MkEq(ctx.MkAdd(x1, x2), ctx.MkReal(15));

            BoolExpr body_const = ctx.MkEq(ctx.MkSub(x1, x2), ctx.MkReal(4));

            Solver s = ctx.MkSolver();

            s.Assert(body_vars);
            s.Assert(body_const);

            Status q = s.Check();

            Model m = s.Model;

            Console.WriteLine(m.ToString());

            Console.WriteLine("Quantifier x1: " + m.Evaluate(x1, true));

            Console.WriteLine("Quantifier x2: " + m.Evaluate(x2, true));
        }
开发者ID:kai-liki,项目名称:Study,代码行数:29,代码来源:Program.cs


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