當前位置: 首頁>>代碼示例>>C#>>正文


C# Context.MkBVAdd方法代碼示例

本文整理匯總了C#中Microsoft.Z3.Context.MkBVAdd方法的典型用法代碼示例。如果您正苦於以下問題:C# Context.MkBVAdd方法的具體用法?C# Context.MkBVAdd怎麽用?C# Context.MkBVAdd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.Z3.Context的用法示例。


在下文中一共展示了Context.MkBVAdd方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Run

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

        using (Context ctx = new Context(cfg))
        {
            BitVecExpr x = ctx.MkBVConst("x", 16);
            BitVecExpr y = ctx.MkBVConst("y", 16);

            Params p = ctx.MkParams();
            p.Add(":mul2concat", true);

            Tactic t = ctx.Then(ctx.UsingParams(ctx.MkTactic("simplify"), p),
                                ctx.MkTactic("solve-eqs"),
                                ctx.MkTactic("bit-blast"),
                                ctx.MkTactic("aig"),
                                ctx.MkTactic("sat"));
            Solver s = ctx.MkSolver(t);

            s.Assert(ctx.MkEq(ctx.MkBVAdd(ctx.MkBVMul(x, ctx.MkBV(32, 16)), y), ctx.MkBV(13, 16)));
            s.Assert(ctx.MkBVSLT(ctx.MkBVAND(x, y), ctx.MkBV(10, 16)));
            s.Assert(ctx.MkBVSGT(y, ctx.MkBV(-100, 16)));

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

            Console.WriteLine(ctx.MkBVAdd(ctx.MkBVMul(x, ctx.MkBV(32, 16)), y) + " == " + m.Evaluate(ctx.MkBVAdd(ctx.MkBVMul(x, ctx.MkBV(32, 16)), y)));
            Console.WriteLine(ctx.MkBVAND(x, y) + " == " + m.Evaluate(ctx.MkBVAND(x, y)) );
        }
    }
開發者ID:ahorn,項目名稱:z3test,代碼行數:32,代碼來源:tactic.7.cs

示例2: Run

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

        using (Context ctx = new Context(cfg))
        {
            BitVecExpr x = ctx.MkBVConst("x", 16);
            BitVecExpr y = ctx.MkBVConst("y", 16);

            Console.WriteLine(ctx.MkBVAdd(x, ctx.MkBV(2, 16)));

            Console.WriteLine(ctx.MkBVSub(ctx.MkBVAdd(x, y), ctx.MkBV(1, 16)).Simplify());

            BitVecExpr a = ctx.MkBV(-1, 16);
            BitVecExpr b = ctx.MkBV(65535, 16);
            Console.WriteLine(ctx.MkEq(a, b).Simplify());

            a = ctx.MkBV(-1, 32);
            b = ctx.MkBV(65535, 32);
            Console.WriteLine(ctx.MkEq(a, b).Simplify());
        }
    }
開發者ID:ahorn,項目名稱:z3test,代碼行數:23,代碼來源:bitvec.1.cs

示例3: Run

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

        using (Context ctx = new Context(cfg))
        {
            BitVecExpr x = ctx.MkBVConst("x", 32);
            BitVecExpr y = ctx.MkBVConst("y", 32);

            BoolExpr q = ctx.MkAnd(ctx.MkEq(ctx.MkBVAdd(x, y), ctx.MkBV(2, 32)),
                                   ctx.MkBVSGT(x, ctx.MkBV(0, 32)),
                                   ctx.MkBVSGT(y, ctx.MkBV(0, 32)));

            Console.WriteLine(q);

            Solver s = ctx.MkSolver();
            s.Assert(q);
            Console.WriteLine(s.Check());
            Console.WriteLine(s.Model);

            q = ctx.MkEq(ctx.MkBVAND(x, y), ctx.MkBVNeg(y));
            Console.WriteLine(q);

            s = ctx.MkSolver();
            s.Assert(q);
            Console.WriteLine(s.Check());
            Console.WriteLine(s.Model);

            q = ctx.MkBVSLT(x, ctx.MkBV(0, 32));
            Console.WriteLine(q);

            s = ctx.MkSolver();
            s.Assert(q);
            Console.WriteLine(s.Check());
            Console.WriteLine(s.Model);

            q = ctx.MkBVULT(x, ctx.MkBV(0, 32));
            Console.WriteLine(q);

            s = ctx.MkSolver();
            s.Assert(q);
            Console.WriteLine(s.Check());
        }
    }
開發者ID:ahorn,項目名稱:z3test,代碼行數:45,代碼來源:bitvec.2.cs

示例4: FindSmallModelExample

        /// <summary>
        /// Reduced-size model generation example.
        /// </summary>
        public static void FindSmallModelExample(Context ctx)
        {
            Console.WriteLine("FindSmallModelExample");

            BitVecExpr x = ctx.MkBVConst("x", 32);
            BitVecExpr y = ctx.MkBVConst("y", 32);
            BitVecExpr z = ctx.MkBVConst("z", 32);

            Solver solver = ctx.MkSolver();

            solver.Assert(ctx.MkBVULE(x, ctx.MkBVAdd(y, z)));
            CheckSmall(ctx, solver, new BitVecExpr[] { x, y, z });
        }
開發者ID:perillaseed,項目名稱:z3,代碼行數:16,代碼來源:Program.cs

示例5: TestBitVectorOps

 public void TestBitVectorOps()
 {
     Context z3 = new Context();
     var bv16 = z3.MkBitVecSort(16);
     var c = (BitVecExpr)z3.MkConst("c",bv16);
     var _3 = (BitVecExpr)z3.MkNumeral(3, bv16);
     var _7 = (BitVecExpr)z3.MkNumeral(7, bv16);
     var _1 = (BitVecExpr)z3.MkNumeral(1, bv16);
     var c_and_7 = z3.MkBVAND(c, _7);
     //((1 + (c & 7)) & 3)
     var t = z3.MkBVAND(z3.MkBVAdd(_1, c_and_7), _3);
     var s = t.Simplify(); //comes out as: (1 + (c & 3))
     var t_neq_s = z3.MkNot(z3.MkEq(t, s));
     var solv =z3.MkSolver();
     solv.Assert(t_neq_s);
     Assert.AreEqual(Status.UNSATISFIABLE, solv.Check());
 }
開發者ID:AutomataDotNet,項目名稱:Automata,代碼行數:17,代碼來源:UnitTest1.cs


注:本文中的Microsoft.Z3.Context.MkBVAdd方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。