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


C# Context.MkFalse方法代码示例

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


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

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

示例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", 32);
            BitVecExpr[] powers = new BitVecExpr[32];
            for (uint i = 0; i < 32; i++)
                powers[i] = ctx.MkBVSHL(ctx.MkBV(1, 32), ctx.MkBV(i, 32));

            BoolExpr step_zero = ctx.MkEq(ctx.MkBVAND(x, ctx.MkBVSub(x, ctx.MkBV(1, 32))), ctx.MkBV(0, 32));

            BoolExpr fast = ctx.MkAnd(ctx.MkNot(ctx.MkEq(x, ctx.MkBV(0, 32))),
                                      step_zero);

            BoolExpr slow = ctx.MkFalse();
            foreach (BitVecExpr p in powers)
                slow = ctx.MkOr(slow, ctx.MkEq(x, p));

        TestDriver.CheckString(fast, "(and (not (= x #x00000000)) (= (bvand x (bvsub x #x00000001)) #x00000000))");

            Solver s = ctx.MkSolver();
            s.Assert(ctx.MkNot(ctx.MkEq(fast, slow)));
            TestDriver.CheckUNSAT(s.Check());

            s = ctx.MkSolver();
            s.Assert(ctx.MkNot(step_zero));
            TestDriver.CheckSAT(s.Check());
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:32,代码来源:bit.1.cs

示例3: Conflict

 public BoolExpr Conflict(Context ctx, params BoolExpr[] packs)
 {
     BoolExpr q = ctx.MkFalse();
     foreach (BoolExpr p in packs)
         q = ctx.MkOr(q, ctx.MkNot(p));
     return q;
 }
开发者ID:ExiaHan,项目名称:z3test,代码行数:7,代码来源:install.2.cs

示例4: Run

 public void Run()
 {
     using (Context ctx = new Context())
     {
         BoolExpr e = ctx.MkFalse();
         Solver s = ctx.MkSolver();
         s.Assert(e);
         Console.WriteLine(s.Check());
     }
 }
开发者ID:ahorn,项目名称:z3test,代码行数:10,代码来源:basic2.cs

示例5: CastingTest


//.........这里部分代码省略.........
            {
                Expr uc = (Expr)upcast;
                throw new TestFailedException(); // should not be reachable!
            }
            catch (InvalidCastException)
            {
            }

            Symbol s = ctx.MkSymbol(42);
            IntSymbol si = s as IntSymbol;
            if (si == null) throw new TestFailedException();
            try
            {
                IntSymbol si2 = (IntSymbol)s;
            }
            catch (InvalidCastException)
            {
                throw new TestFailedException();
            }

            s = ctx.MkSymbol("abc");
            StringSymbol ss = s as StringSymbol;
            if (ss == null) throw new TestFailedException();
            try
            {
                StringSymbol ss2 = (StringSymbol)s;
            }
            catch (InvalidCastException)
            {
                throw new TestFailedException();
            }
            try
            {
                IntSymbol si2 = (IntSymbol)s;
                throw new TestFailedException(); // unreachable
            }
            catch
            {
            }

            Sort srt = ctx.MkBitVecSort(32);
            BitVecSort bvs = null;
            try
            {
                bvs = (BitVecSort)srt;
            }
            catch (InvalidCastException)
            {
                throw new TestFailedException();
            }

            if (bvs.Size != 32)
                throw new TestFailedException();

            Expr q = ctx.MkAdd(ctx.MkInt(1), ctx.MkInt(2));
            Expr q2 = q.Args[1];
            Sort qs = q2.Sort;
            if (qs as IntSort == null)
                throw new TestFailedException();
            try
            {
                IntSort isrt = (IntSort)qs;
            }
            catch (InvalidCastException)
            {
                throw new TestFailedException();
            }

            AST a = ctx.MkInt(42);
            Expr ae = a as Expr;
            if (ae == null) throw new TestFailedException();
            ArithExpr aae = a as ArithExpr;
            if (aae == null) throw new TestFailedException();
            IntExpr aie = a as IntExpr;
            if (aie == null) throw new TestFailedException();
            IntNum ain = a as IntNum;
            if (ain == null) throw new TestFailedException();


            Expr[][] earr = new Expr[2][];
            earr[0] = new Expr[2];
            earr[1] = new Expr[2];
            earr[0][0] = ctx.MkTrue();
            earr[0][1] = ctx.MkTrue();
            earr[1][0] = ctx.MkFalse();
            earr[1][1] = ctx.MkFalse();
            foreach (Expr[] ea in earr)
                foreach (Expr e in ea)
                {
                    try
                    {
                        Expr ns = ctx.MkNot((BoolExpr)e);
                        BoolExpr ens = (BoolExpr)ns;
                    }
                    catch (InvalidCastException)
                    {
                        throw new TestFailedException();
                    }
                }
        }
开发者ID:perillaseed,项目名称:z3,代码行数:101,代码来源:Program.cs

示例6: BasicTests

        /// <summary>
        /// Some basic tests.
        /// </summary>
        static void BasicTests(Context ctx)
        {
            Console.WriteLine("BasicTests");

            Symbol qi = ctx.MkSymbol(1);
            Symbol fname = ctx.MkSymbol("f");
            Symbol x = ctx.MkSymbol("x");
            Symbol y = ctx.MkSymbol("y");

            Sort bs = ctx.MkBoolSort();

            Sort[] domain = { bs, bs };
            FuncDecl f = ctx.MkFuncDecl(fname, domain, bs);
            Expr fapp = ctx.MkApp(f, ctx.MkConst(x, bs), ctx.MkConst(y, bs));

            Expr[] fargs2 = { ctx.MkFreshConst("cp", bs) };
            Sort[] domain2 = { bs };
            Expr fapp2 = ctx.MkApp(ctx.MkFreshFuncDecl("fp", domain2, bs), fargs2);

            BoolExpr trivial_eq = ctx.MkEq(fapp, fapp);
            BoolExpr nontrivial_eq = ctx.MkEq(fapp, fapp2);

            Goal g = ctx.MkGoal(true);
            g.Assert(trivial_eq);
            g.Assert(nontrivial_eq);
            Console.WriteLine("Goal: " + g);

            Solver solver = ctx.MkSolver();

            foreach (BoolExpr a in g.Formulas)
                solver.Assert(a);

            if (solver.Check() != Status.SATISFIABLE)
                throw new TestFailedException();

            ApplyResult ar = ApplyTactic(ctx, ctx.MkTactic("simplify"), g);
            if (ar.NumSubgoals == 1 && (ar.Subgoals[0].IsDecidedSat || ar.Subgoals[0].IsDecidedUnsat))
                throw new TestFailedException();

            ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g);
            if (ar.NumSubgoals != 1 || !ar.Subgoals[0].IsDecidedSat)
                throw new TestFailedException();

            g.Assert(ctx.MkEq(ctx.MkNumeral(1, ctx.MkBitVecSort(32)),
                                      ctx.MkNumeral(2, ctx.MkBitVecSort(32))));
            ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g);
            if (ar.NumSubgoals != 1 || !ar.Subgoals[0].IsDecidedUnsat)
                throw new TestFailedException();


            Goal g2 = ctx.MkGoal(true, true);
            ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g2);
            if (ar.NumSubgoals != 1 || !ar.Subgoals[0].IsDecidedSat)
                throw new TestFailedException();

            g2 = ctx.MkGoal(true, true);
            g2.Assert(ctx.MkFalse());
            ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g2);
            if (ar.NumSubgoals != 1 || !ar.Subgoals[0].IsDecidedUnsat)
                throw new TestFailedException();

            Goal g3 = ctx.MkGoal(true, true);
            Expr xc = ctx.MkConst(ctx.MkSymbol("x"), ctx.IntSort);
            Expr yc = ctx.MkConst(ctx.MkSymbol("y"), ctx.IntSort);
            g3.Assert(ctx.MkEq(xc, ctx.MkNumeral(1, ctx.IntSort)));
            g3.Assert(ctx.MkEq(yc, ctx.MkNumeral(2, ctx.IntSort)));
            BoolExpr constr = ctx.MkEq(xc, yc);
            g3.Assert(constr);
            ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g3);
            if (ar.NumSubgoals != 1 || !ar.Subgoals[0].IsDecidedUnsat)
                throw new TestFailedException();

            ModelConverterTest(ctx);

            // Real num/den test.
            RatNum rn = ctx.MkReal(42, 43);
            Expr inum = rn.Numerator;
            Expr iden = rn.Denominator;
            Console.WriteLine("Numerator: " + inum + " Denominator: " + iden);
            if (inum.ToString() != "42" || iden.ToString() != "43")
                throw new TestFailedException();

            if (rn.ToDecimalString(3) != "0.976?")
                throw new TestFailedException();

            BigIntCheck(ctx, ctx.MkReal("-1231231232/234234333"));
            BigIntCheck(ctx, ctx.MkReal("-123123234234234234231232/234234333"));
            BigIntCheck(ctx, ctx.MkReal("-234234333"));
            BigIntCheck(ctx, ctx.MkReal("234234333/2"));


            string bn = "1234567890987654321";

            if (ctx.MkInt(bn).BigInteger.ToString() != bn)
                throw new TestFailedException();

            if (ctx.MkBV(bn, 128).BigInteger.ToString() != bn)
//.........这里部分代码省略.........
开发者ID:perillaseed,项目名称:z3,代码行数:101,代码来源:Program.cs

示例7: ITEExample

        /// <summary>
        /// Create an ite-Expr (if-then-else Exprs).
        /// </summary>
        public static void ITEExample(Context ctx)
        {
            Console.WriteLine("ITEExample");

            BoolExpr f = ctx.MkFalse();
            Expr one = ctx.MkInt(1);
            Expr zero = ctx.MkInt(0);
            Expr ite = ctx.MkITE(f, one, zero);

            Console.WriteLine("Expr: {0}", ite);
        }
开发者ID:perillaseed,项目名称:z3,代码行数:14,代码来源:Program.cs

示例8: toZ3Bool

 public override BoolExpr toZ3Bool(Context ctx)
 {
     switch (this.logical_operator)
     {
         case LogicalOperator.True:
             return ctx.MkTrue();
         case LogicalOperator.False:
             return ctx.MkFalse();
         case LogicalOperator.And:
             return ctx.MkAnd(new BoolExpr[] { boolean_operand1.toZ3Bool(ctx), boolean_operand2.toZ3Bool(ctx) });
         case LogicalOperator.Or:
             return ctx.MkOr(new BoolExpr[] { boolean_operand1.toZ3Bool(ctx), boolean_operand2.toZ3Bool(ctx) });
         case LogicalOperator.Not:
             return ctx.MkNot(boolean_operand1.toZ3Bool(ctx));
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
开发者ID:AutomataTutor,项目名称:automatatutor-backend,代码行数:18,代码来源:Expression.cs


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