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


C# Context.MkMul方法代码示例

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


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

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

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

示例3: Run

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

        using (Context ctx = new Context(cfg))
        {
            RealExpr d = ctx.MkRealConst("d");
            RealExpr a = ctx.MkRealConst("a");
            RealExpr t = ctx.MkRealConst("t");
            RealExpr v_i = ctx.MkRealConst("v_i");
            RealExpr v_f = ctx.MkRealConst("v_f");

            BoolExpr[] equations = new BoolExpr[] {
                ctx.MkEq(d, ctx.MkAdd(ctx.MkMul(v_i, t),
                                      ctx.MkDiv(ctx.MkMul(a, ctx.MkPower(t, ctx.MkReal(2))),
                                                ctx.MkReal(2)))),
                ctx.MkEq(v_f, ctx.MkAdd(v_i, ctx.MkMul(a, t)))
            };

            Console.WriteLine("Kinematic equations: ");
            foreach (BoolExpr e in equations)
                Console.WriteLine(e);

            BoolExpr[] problem = new BoolExpr[] {
                ctx.MkEq(v_i, ctx.MkReal(0)),
                ctx.MkEq(t, ctx.MkReal("4.10")),
                ctx.MkEq(a, ctx.MkReal(6))
            };

            Console.WriteLine("Problem: ");
            foreach (BoolExpr p in problem)
                Console.WriteLine(p);

            Solver s = ctx.MkSolver();
            s.Assert(equations);
            s.Assert(problem);

            if (s.Check() != Status.SATISFIABLE)
                throw new Exception("BUG");

            Console.WriteLine("Solution: ");
            Console.WriteLine(s.Model);

            Console.WriteLine("Decimal Solution: ");
            foreach (FuncDecl f in s.Model.ConstDecls)
                Console.WriteLine(f.Name + " = " + ((RatNum)s.Model.ConstInterp(f)).ToDecimalString(10));
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:49,代码来源:k.2.cs

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

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

示例6: Run

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

        using (Context ctx = new Context(cfg))
        {
            Params p = ctx.MkParams();
            p.Add(":arith-lhs", true);
            p.Add(":som", true);

            Solver s = ctx.Then(ctx.With(ctx.MkTactic("simplify"), p),
                                ctx.MkTactic("normalize-bounds"),
                                ctx.MkTactic("lia2pb"),
                                ctx.MkTactic("pb2bv"),
                                ctx.MkTactic("bit-blast"),
                                ctx.MkTactic("sat")).Solver;

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

            s.Assert(new BoolExpr[] { ctx.MkGt(x, ctx.MkInt(0)),
                                      ctx.MkLt(x, ctx.MkInt(10)),
                                      ctx.MkGt(y, ctx.MkInt(0)),
                                      ctx.MkLt(y, ctx.MkInt(10)),
                                      ctx.MkGt(z, ctx.MkInt(0)),
                                      ctx.MkLt(z, ctx.MkInt(10)),
                                      ctx.MkEq(ctx.MkAdd(ctx.MkMul(ctx.MkInt(3), y),
                                                         ctx.MkMul(ctx.MkInt(2), x)), z) });

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

            s.Reset();

            s.Assert(ctx.MkEq(ctx.MkAdd(ctx.MkMul(ctx.MkInt(3), y),
                                        ctx.MkMul(ctx.MkInt(2), x)), z));

            Console.WriteLine(s.Check());
        }
    }
开发者ID:ahorn,项目名称:z3test,代码行数:42,代码来源:tactic.9.cs

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

示例8: toZ3Int

 public ArithExpr toZ3Int(Context ctx)
 {
     var terms = this.coefficients.Select(kv => ctx.MkMul(new ArithExpr[] { kv.Key.toZ3Int(ctx), ctx.MkInt(kv.Value) })).ToList();
     terms.Add(ctx.MkInt(this.constant));
     return ctx.MkAdd(terms.ToArray());
 }
开发者ID:AutomataTutor,项目名称:automatatutor-backend,代码行数:6,代码来源:Expression.cs


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