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


C# Z3Provider.MkEq方法代码示例

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


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

示例1: RunTestForGivenSize

        private static void RunTestForGivenSize(int K)
        {
            Console.WriteLine(K);
            Z3Provider Z = new Z3Provider();
            var A = (Z.TT.MkRankedAlphabet("A", Z.IntSort, new string[] { "zero", "two" }, new int[] { 0, 2 }));

            Func<int, Expr> beta = (i => Z.MkEq(Z.MkInt(1), Z.MkMod(Z.MkDiv(A.AttrVar, Z.MkInt(1 << (i%32))), Z.MkInt(2))));

            Expr e1 = Z.MkEq(Z.MkInt(1), A.AttrVar);
            Expr e2 = Z.MkEq(Z.MkInt(2), A.AttrVar);
            Expr e3 = Z.MkEq(Z.MkInt(3), A.AttrVar);

            var r1 = Z.TT.MkTreeAcceptorRule(A, 0, "zero", e1);
            var r2 = Z.TT.MkTreeAcceptorRule(A, 1, "zero", e2);
            var r3 = Z.TT.MkTreeAcceptorRule(A, 2, "zero", e3);
            var rules = new List<TreeRule>();

            rules.Add(r1);
            rules.Add(r2);
            rules.Add(r3);

            for (int i = 0; i < K; i++)
            {
                rules.Add(Z.TT.MkTreeAcceptorRule(A, 3 * i + 3, "two", beta(i), 3 * i, 3 * i + 2));
                rules.Add(Z.TT.MkTreeAcceptorRule(A, 3 * i + 4, "two", beta(i), 3 * i + 1, 3 * i + 2));
                rules.Add(Z.TT.MkTreeAcceptorRule(A, 3 * i + 5, "two", beta(i), 3 * i + 2, 3 * i + 2));
            }

            var T = Z.TT.MkTreeAutomaton(new int[] { 3 * K , 3 * K +1 }, A, A, rules);
            var comp = T.Complete();

            Util.RunAllAlgorithms(T, comp, K.ToString(), Program.largeAlphabetFile);
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:33,代码来源:LargeAlphabetExperiment.cs

示例2: EmptyTupleTest

 public void EmptyTupleTest()
 {
     Z3Provider Z = new Z3Provider();
     Sort sort = Z.MkTupleSort();
     Expr unit = Z.MkTuple();
     Expr t = Z.MkVar(0, sort);
     Expr t_eq_unit = Z.MkEq(t, unit);
     var v = new List<IValue<Expr>>(Z.MainSolver.FindAllMembers(t_eq_unit));
     Assert.IsTrue(v.Count == 1);
     Assert.AreEqual(unit, v[0].Value);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:11,代码来源:UnitTest1.cs

示例3: MintermBlowupTestHelperMoore

        private static int MintermBlowupTestHelperMoore(int K)
        {
            var z3p = new Z3Provider(BitWidth.BV32);
            var x = z3p.CharVar;
            var zero = z3p.MkNumeral(0, z3p.CharSort);
            Func<int, Expr> gamma = k =>
            {
                int kth = 1 << k;
                Expr mask = z3p.MkNumeral(kth, z3p.CharSort);
                Expr cond = z3p.MkNot(z3p.MkEq(z3p.MkBvAnd(x, mask), zero));
                return cond;
            };
            var moves = new List<Move<Expr>>();
            for (int i = 0; i < K; i++)
                moves.Add(Move<Expr>.Create(i, i + 1, gamma(i)));
            for (int i = 0; i < K; i++)
                moves.Add(Move<Expr>.Create(i == 0 ? 0 : K + i, K + i + 1, i ==0 ? z3p.MkNot(gamma(i)) : gamma(i)));
            var aut = Automaton<Expr>.Create(z3p, 0, new int[] { K, 2 * K }, moves);

            var sfa = new SFA<FuncDecl, Expr, Sort>(z3p, z3p.CharSort, aut);
            sfa.Automaton.CheckDeterminism(true);

            int t = System.Environment.TickCount;
            var autmin = sfa.Automaton.MinimizeMoore();
            t = System.Environment.TickCount - t;

            return t;
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:28,代码来源:FiniteAutomataTests.cs

示例4: MkEqTrans

 public Move<Expr> MkEqTrans(Z3Provider z3p, int sourceState, int targetState, char c)
 {
     Expr x = z3p.CharVar;
     Expr cond = z3p.MkEq(x, z3p.MkCharExpr(c));
     Move<Expr> t = Move<Expr>.Create(sourceState, targetState, cond);
     return t;
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:7,代码来源:FiniteAutomataTests.cs

示例5: TestMinimization

        private static void TestMinimization(int K)
        {
            Z3Provider Z = new Z3Provider();
            var A = (Z.TT.MkRankedAlphabet("A", Z.IntSort, new string[] { "zero", "two" }, new int[] { 0, 2 }));

            Func<int, Expr> beta = (i => Z.MkEq(Z.MkInt(1), Z.MkMod(Z.MkDiv(A.AttrVar, Z.MkInt(1 << i)), Z.MkInt(2))));

            var r0 = Z.TT.MkTreeAcceptorRule(A, 0, "zero", beta(0));
            var r1 = Z.TT.MkTreeAcceptorRule(A, 1, "zero", beta(1));
            var rules = new List<TreeRule>();
            rules.Add(r0);
            rules.Add(r1);
            for (int i = 0; i < K; i++)
                rules.Add(Z.TT.MkTreeAcceptorRule(A, i + 1, "two", beta(i + 1), i, i));

            var T = Z.TT.MkTreeAutomaton(K, A, A, rules);

            var T1 = T.Determinize();
            var T2 = T1.RemoveUselessStates();

            var Tmin = T2.Minimize();

            Assert.AreNotEqual(T1.StateCount, Tmin.StateCount);

            Console.WriteLine("k = {0}, |Q| = {1}, |Delta| = {2}, |Q_d| = {3}, |Delta_d| = {4}, |Q_u| = {5}, |Delta_u| = {6},|Q_m| = {7}, |Delta_m| = {8},",
                K, T.StateCount, T.RuleCount, T1.StateCount, T1.RuleCount, T2.StateCount, T2.RuleCount, Tmin.StateCount, Tmin.RuleCount);
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:27,代码来源:TreeTransducerTests.cs

示例6: TestTreeAutomataMinimization

        public void TestTreeAutomataMinimization()
        {
            Z3Provider Z = new Z3Provider();
            var A = (Z.TT.MkRankedAlphabet("A", Z.IntSort, new string[] { "zero", "two" }, new int[] { 0, 2 }));

            Func<int,Expr> beta = (i => Z.MkEq(Z.MkInt(1), Z.MkMod(Z.MkDiv(A.AttrVar,Z.MkInt(1<<i)), Z.MkInt(2))));

            var r0 = Z.TT.MkTreeAcceptorRule(A, 0, "zero", beta(0));
            var r1 = Z.TT.MkTreeAcceptorRule(A, 1, "two", beta(1), 0 ,0 );
            var r2 = Z.TT.MkTreeAcceptorRule(A, 2, "two", beta(2), 1, 1);

            var T = Z.TT.MkTreeAutomaton(2, A, A, new TreeRule[] { r0, r1, r2 });

            var Tmin = T.Minimize();

            Assert.AreEqual(T.StateCount, Tmin.StateCount);
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:17,代码来源:TreeTransducerTests.cs

示例7: TestRegularLookaheadComposition3

        public void TestRegularLookaheadComposition3()
        {
            Z3Provider Z = new Z3Provider();
            var A = (Z.TT.MkRankedAlphabet("A", Z.IntSort, new string[] { "z", "u", "b" }, new int[] { 0, 1, 2 }));
            var B = (Z.TT.MkRankedAlphabet("B", Z.IntSort, new string[] { "z", "u", "b" }, new int[] { 0, 1, 2 }));
            var C = (Z.TT.MkRankedAlphabet("C", Z.IntSort, new string[] { "z", "u", "b" }, new int[] { 0, 1, 2 }));

            var _0 = Z.MkInt(0);
            var _1 = Z.MkInt(1);
            var _2 = Z.MkInt(2);
            var _7 = Z.MkInt(7);

            var AB_r0 = Z.TT.MkTreeRule(A, B, 0, "u", Z.MkLe(_0, A.AttrVar), B.MkTree("u", Z.MkAdd(_1, A.AttrVar), A.MkTrans(B, 1, 1)), new int[][] { new int[] { 3, 1 } });
            var AB_r1 = Z.TT.MkTreeRule(A, B, 1, "u", Z.MkLe(_1, A.AttrVar), B.MkTree("u", Z.MkAdd(_1, A.AttrVar), A.MkTrans(B, 0, 1)), new int[][] { new int[] { 2, 0 } });
            var AB_r2 = Z.TT.MkTreeRule(A, B, 1, "u", Z.MkEq(_2, A.AttrVar), B.MkTree("z", Z.MkAdd(_1, A.AttrVar)));

            var AB_q2 = Z.TT.MkTreeRule(A, B, 2, "u", Z.MkGe(_0, A.AttrVar), null, new int[][] { new int[] { 3 } });
            var AB_q3a = Z.TT.MkTreeRule(A, B, 3, "u", Z.MkGe(_1, A.AttrVar), null, new int[][] { new int[] { 2 } });
            var AB_q3b = Z.TT.MkTreeRule(A, B, 3, "u", Z.MkEq(_2, A.AttrVar), null);

            //just accept the input if the attribute is 1, delete the child subtree and return zeroC(1)
            var BC_r0 = Z.TT.MkTreeRule(B, C, 0, "u", Z.MkEq(_1, B.AttrVar), C.MkTree("z", Z.MkAdd(_7, B.AttrVar)));

            var AB = Z.TT.MkTreeAutomaton(0, A, B, new TreeRule[] { AB_r0, AB_r1, AB_r2, AB_q2, AB_q3a, AB_q3b });
            var BC = Z.TT.MkTreeAutomaton(0, B, C, new TreeRule[] { BC_r0 });

            var AC = TreeTransducer.ComposeR(AB, BC);

            Assert.AreEqual<int>(5, AC.RuleCount);
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:30,代码来源:TreeTransducerTests.cs

示例8: TestRegularLookaheadComposition2

        public void TestRegularLookaheadComposition2()
        {
            Z3Provider Z = new Z3Provider();
            var A = (Z.TT.MkRankedAlphabet("A", Z.IntSort, new string[] { "zeroA", "oneA", "twoA" }, new int[] { 0, 1, 2 }));
            var B = (Z.TT.MkRankedAlphabet("B", Z.IntSort, new string[] { "zeroB", "oneB", "twoB" }, new int[] { 0, 1, 2 }));
            var C = (Z.TT.MkRankedAlphabet("C", Z.IntSort, new string[] { "zeroC", "oneC", "twoC" }, new int[] { 0, 1, 2 }));

            var _0 = Z.MkInt(0);
            var _1 = Z.MkInt(1);
            var _2 = Z.MkInt(2);

            var AB_r0 = Z.TT.MkTreeRule(A, B, 0, "oneA", Z.MkEq(_0, A.AttrVar), B.MkTree("oneB", Z.MkAdd(_1, A.AttrVar), A.MkTrans(B, 1, 1)), new int[][] { new int[] { 1 } });
            var AB_r1 = Z.TT.MkTreeRule(A, B, 1, "oneA", Z.MkEq(_1, A.AttrVar), B.MkTree("oneB", Z.MkAdd(_1, A.AttrVar), A.MkTrans(B, 0, 1)), new int[][] { new int[] { 0 } });
            var AB_r2 = Z.TT.MkTreeRule(A, B, 1, "oneA", Z.MkEq(_2, A.AttrVar), B.MkTree("zeroB", Z.MkAdd(_1, A.AttrVar)));

            //just accept the input if the attribute is 1 and delete the child subtree
            var BC_r0 = Z.TT.MkTreeRule(B, C, 0, "oneB", Z.MkEq(_1, B.AttrVar), C.MkTree("zeroC", B.AttrVar));

            var AB = Z.TT.MkTreeAutomaton(0, A, B, new TreeRule[] { AB_r0, AB_r1, AB_r2});
            var BC = Z.TT.MkTreeAutomaton(0, B, C, new TreeRule[] { BC_r0 });

            var AC = TreeTransducer.ComposeR(AB, BC);

            Assert.AreEqual<int>(4, AC.RuleCount);
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:25,代码来源:TreeTransducerTests.cs

示例9: TestSTbSimplify

        public void TestSTbSimplify()
        {
            string utf8decode_bek = @"
            function fuse(r,c) = ((r << 6) | (c & 0x3F));
            function one(c) = ((0 <= c) && (c <= 0x7F));
            function C2_DF(c) = ((0xC2 <= c) && (c <= 0xDF));
            function E1_EF(c) = ((0xE1 <= c) && (c <= 0xEF));
            function A0_BF(c) = ((0xA0 <= c) && (c <= 0xBF));
            function x80_BF(c) = ((0x80 <= c) && (c <= 0xBF));
            function x80_9F(c) = ((0x80 <= c) && (c <= 0x9F));
            program utf8decode(input){
              return iter(c in input)[q := 0; r := 0;]
              {
            case (q == 0):
              if (one(c))                  {yield (c);}
              else if (C2_DF(c))           {q := 2; r := (c & 0x1F);}    // ------ 2 bytes --------
              else if (c == 0xE0)          {q := 4; r := (c & 0x0F);}    // ------ 3 bytes --------
              else if (c == 0xED)          {q := 5; r := (c & 0x0F);}    // ------ 3 bytes --------
              else if (E1_EF(c))           {q := 3; r := (c & 0x0F);}    // ------ 3 bytes --------
              else {raise InvalidInput;}

            case (q == 2):
              if (x80_BF(c))                 {q := 0; yield(fuse(r,c)); r := 0;}
              else {raise InvalidInput;}

            case (q == 3):
              if (x80_BF(c))                 {q := 2; r := fuse(r,c);}
              else {raise InvalidInput;}

            case (q == 4):
              if (A0_BF(c))                  {q := 2; r := fuse(r,c);}
              else {raise InvalidInput;}

            case (q == 5):
              if (x80_9F(c))                 {q := 2; r := fuse(r,c);}
              else {raise InvalidInput;}

            end case (!(q == 0)):
              raise InvalidInput;
              };
            }
            ";

            Z3Provider solver = new Z3Provider(BitWidth.BV16);
            var dec = BekConverter.BekToSTb(solver, utf8decode_bek);
            var utf8decode = dec.ExploreBools();

            Sort bv32 = solver.MkBitVecSort(32);
            Sort outSort = solver.MkTupleSort(solver.StringSort, bv32);
            var initReg = solver.MkTuple(solver.GetNil(solver.StringSort), solver.MkNumeral(0,bv32));
            var regVar = solver.MkVar(1,outSort);
            var reg1 = solver.MkProj(1, regVar);
            var reg0 = solver.MkProj(0, regVar);
            STb<FuncDecl, Expr, Sort> parse = new STbModel(solver, "Parse", solver.CharacterSort, outSort, outSort, initReg, 0);

            var letter = solver.MkOr(//solver.MkAnd(solver.MkCharLe(solver.MkCharExpr('\xC0'), solver.CharVar),
                                     //                    solver.MkCharLe(solver.CharVar, solver.MkCharExpr('\xFF'))),
                                     solver.MkAnd(solver.MkCharLe(solver.MkCharExpr('a'), solver.CharVar),
                                                         solver.MkCharLe(solver.CharVar, solver.MkCharExpr('z'))),
                                     solver.MkAnd(solver.MkCharLe(solver.MkCharExpr('A'), solver.CharVar),
                                                         solver.MkCharLe(solver.CharVar, solver.MkCharExpr('Z'))));

            //var not_letter = solver.MkNot(letter);

            var digit = solver.MkAnd(solver.MkCharLe(solver.MkCharExpr('0'), solver.CharVar),
                                                         solver.MkCharLe(solver.CharVar, solver.MkCharExpr('9')));

            var nl = solver.MkEq(solver.CharVar, solver.MkCharExpr('\n'));

            var space = solver.MkEq(solver.CharVar, solver.MkCharExpr(' '));

            //var not_nl = solver.MkNot(nl);

            var _0 = solver.MkNumeral((int)'0', bv32);

            //var z = solver.Z3.MkFreshConst("z", solver.CharacterSort);

            //var constr = solver.MkNot(solver.Z3.MkExists(new Expr[] { z }, nl.Substitute(solver.CharVar, z)));
            ////var constr = nl.Substitute(solver.CharVar, z);

            //solver.Z3S.Push();
            //solver.Z3S.Assert((BoolExpr)solver.MkNot(constr));
            //var status = solver.Check();
            //var m = solver.Z3S.Model;
            //var zval = m.Evaluate(z, true);
            //solver.Z3S.Pop();

            var loop_0 = new BaseRule<Expr>(Sequence<Expr>.Empty, regVar, 0);
            var brule0_1 = new BaseRule<Expr>(Sequence<Expr>.Empty, solver.MkTuple(solver.MkListCons(solver.CharVar, reg0), reg1), 1);
            var rule0 = new IteRule<Expr>(letter, brule0_1, new IteRule<Expr>(space, loop_0, UndefRule<Expr>.Default));
            parse.AssignRule(0, rule0);

            var brule1_2 = new BaseRule<Expr>(Sequence<Expr>.Empty, solver.MkTuple(solver.MkListCons(solver.CharVar, reg0), reg1), 2);
            var brule_4 = new BaseRule<Expr>(Sequence<Expr>.Empty, regVar, 4);
            var rule1 = new IteRule<Expr>(letter, brule1_2, new IteRule<Expr>(space, brule_4, UndefRule<Expr>.Default));
            parse.AssignRule(1, rule1);

            var brule2_3 = new BaseRule<Expr>(Sequence<Expr>.Empty, solver.MkTuple(solver.MkListCons(solver.CharVar, reg0), reg1), 4);
            var rule2 = new IteRule<Expr>(letter, brule2_3, new IteRule<Expr>(space, brule_4, UndefRule<Expr>.Default));
            parse.AssignRule(2, rule2);
//.........这里部分代码省略.........
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:101,代码来源:STbTests.cs

示例10: TupleTest

 public void TupleTest()
 {
     Z3Provider z3p = new Z3Provider();
     //create the tuple sort for mouth
     FuncDecl mouth;
     FuncDecl[] mouth_accessors;
     var MOUTH = z3p.MkTupleSort("MOUTH", new string[] { "open", "teeth" }, new Sort[] { z3p.BoolSort, z3p.IntSort }, out mouth, out mouth_accessors);
     Func<Expr,Expr,Expr> mk_mouth = ((o,t) => z3p.MkApp(mouth, o, t));
     Func<Expr,Expr> get_open = (m => z3p.MkApp(mouth_accessors[0], m));
     Func<Expr,Expr> get_teeth = (m => z3p.MkApp(mouth_accessors[1], m));
     //create the tuple sort for nose
     FuncDecl nose;
     FuncDecl[] nose_accessors;
     var NOSE = z3p.MkTupleSort("NOSE", new string[] { "size" }, new Sort[] { z3p.IntSort }, out nose, out nose_accessors);
     Func<Expr,Expr> mk_nose = (s => z3p.MkApp(nose, s));
     Func<Expr,Expr> get_size = (n => z3p.MkApp(nose_accessors[0], n));
     //create the tuple sort for head
     FuncDecl head;
     FuncDecl[] head_accessors;
     var HEAD = z3p.MkTupleSort("HEAD", new string[] { "bald", "nose", "mouth" }, new Sort[] { z3p.BoolSort, NOSE, MOUTH }, out head, out head_accessors);
     Func<Expr,Expr,Expr,Expr> mk_head = ((b,n,m) => z3p.MkApp(head, b,n,m));
     Func<Expr,Expr> get_bald = (h => z3p.MkApp(head_accessors[0], h));
     Func<Expr,Expr> get_nose = (h => z3p.MkApp(head_accessors[1], h));
     Func<Expr,Expr> get_mouth = (h => z3p.MkApp(head_accessors[2], h));
     //------------------------
     // create a transformation "punch" from HEAD tp HEAD that removes k teeth, k is  the second parameter of the transformation
     var punch = z3p.MkFuncDecl("punch", new Sort[]{HEAD, z3p.IntSort}, HEAD);
     var x = z3p.MkVar(0, HEAD);        // <-- this is the input HEAD
     var y = z3p.MkVar(1, z3p.IntSort); // <-- this is the n parameter
     //this is the actual transformation of x that removes one tooth
     var new_mouth = mk_mouth(get_open(get_mouth(x)), z3p.MkSub(get_teeth(get_mouth(x)), y));
     var old_nose = get_nose(x);
     var old_bald = get_bald(x);
     var punch_def = mk_head(old_bald, old_nose,new_mouth);
     var punch_axiom = z3p.MkEqForall(z3p.MkApp(punch, x , y), punch_def, x, y);
     Func<Expr,Expr,Expr> punch_app = ((h,k) => z3p.MkApp(punch, h,k));
     z3p.MainSolver.Assert(punch_axiom);
     //------------------------
     // create a transformation "hit" from HEAD tp HEAD that doubles the size of the nose
     var hit = z3p.MkFuncDecl("hit", HEAD, HEAD);
     var hit_def = mk_head(get_bald(x), mk_nose(z3p.MkMul(z3p.MkInt(2),get_size(get_nose(x)))), get_mouth(x));
     var hit_axiom = z3p.MkEqForall(z3p.MkApp(hit, x), hit_def, x);
     Func<Expr,Expr> hit_app = (h => z3p.MkApp(hit, h));
     z3p.MainSolver.Assert(hit_axiom);
     //-------------------------------
     // Analysis
     var H = z3p.MkConst("H", HEAD);
     var N = z3p.MkConst("N", z3p.IntSort);
     // check that hit and punch commute
     z3p.MainSolver.Push();
     z3p.MainSolver.Assert(z3p.MkNeq(punch_app(hit_app(H), N), hit_app(punch_app(H, N))));
     Status status = z3p.Check(); //here status must be UNSATISFIABLE
     z3p.MainSolver.Pop(); //remove the temporary context
     //check that hit is not idempotent
     z3p.MainSolver.Push();
     z3p.MainSolver.Assert(z3p.MkNeq(hit_app(hit_app(H)), hit_app(H)));
     status = z3p.Check(); //here status must not be UNSATISFIABLE (it is UNKNOWN due to use of axioms)
     var model1 = z3p.Z3S.Model;
     var witness1 = model1.Evaluate(H, true);   //a concrete instance of HEAD that shows when hitting twice is not the same as hitting once
     z3p.MainSolver.Pop();
     //but it is possible that hitting twice does no harm (when nose has size 0)
     z3p.MainSolver.Push();
     z3p.MainSolver.Assert(z3p.MkEq(hit_app(hit_app(H)), hit_app(H)));
     status = z3p.Check();
     var model2 = z3p.Z3S.Model;
     var witness2 = model2.Evaluate(H, true);
     z3p.MainSolver.Pop();
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:68,代码来源:UnitTest1.cs

示例11: TestCssCombinedCodepoint

        public void TestCssCombinedCodepoint()
        {
            var kkkk = 0x7FFF - 65532;
            Z3Provider solver = new Z3Provider();
            Sort bv64 = solver.MkBitVecSort(64);
            Sort bv16 = solver.CharacterSort;

            Expr hs = solver.MkConst("hs", bv16);
            Expr ls = solver.MkConst("ls", bv16);

            Expr res = solver.MkConst("res", bv64);

            Expr maxVal = solver.MkNumeral(0x10FFFF, bv64); //max 16 bit nr

            Expr x = solver.ConvertBitVector(hs, bv64);
            Expr y = solver.ConvertBitVector(ls, bv64);
            Expr _0x10000 = solver.MkNumeral(0x10000, bv64);
            Expr _0xD800 = solver.MkNumeral(0xD800, bv64);
            Expr _0x400 = solver.MkNumeral(0x400, bv64);
            Expr _0xDC00 = solver.MkNumeral(0xDC00, bv64);

            ushort tmpLS = ((ushort)0xdfff) - ((ushort)0xdc00);

            for (int i = 0xdc00; i <= 0xdfff; i++ )
            {
                int j = (i - 0xdc00) >> 8;
                int k = (i >> 8) & 3;
                Assert.AreEqual<int>(j, k);
            }

            int tmpHS = (((int)0xdbff) - ((int)0xd800)) * ((int)0x400);
            //int tmpHS = (((int)0xdbff) - ((int)0xd800)) << 10;

            int tmpHSLS = tmpLS + tmpHS;

            int maxcodepoint = tmpHSLS + 0x10000;

            Expr cp = solver.MkCharAdd(_0x10000,
                       solver.MkCharAdd(solver.MkCharMul(solver.MkCharSub(x, _0xD800), _0x400),
                                        solver.MkCharSub(y, _0xDC00)));

            Expr ls_is_lowSurrogate =
                solver.MkAnd(solver.MkCharGe(ls, solver.MkNumeral(0xdc00, bv16)),
                                solver.MkCharLe(ls, solver.MkNumeral(0xdfff, bv16)));

            Expr hs_is_highSurrogate =
                solver.MkAnd(solver.MkCharGe(hs, solver.MkNumeral(0xd800, bv16)),
                                solver.MkCharLe(hs, solver.MkNumeral(0xdbff, bv16)));

            Expr assert = solver.Simplify(solver.MkAnd(
                ls_is_lowSurrogate,
                hs_is_highSurrogate,
                solver.MkEq(res, cp)));

            //string s = solver.PrettyPrint(assert);

            solver.MainSolver.Assert(assert);

            var model = solver.MainSolver.GetModel(solver.MkCharLt(maxVal, res), hs, ls, res);

            Assert.IsNull(model);

            //if (model != null)
            //{
            //    int hsVal = solver.GetNumeralInt(model[hs].Value);
            //    int lsVal = solver.GetNumeralInt(model[ls].Value);
            //    long resval = solver.GetNumeralUInt(model[res].Value);
            //    Assert.AreEqual<long>(CssCombinedCodepoint(hsVal, lsVal), resval);
            //}
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:70,代码来源:UnitTest1.cs

示例12: SolverTest

 public void SolverTest()
 {
     var z3c = new Z3Provider();
     var z3s = z3c.MkSolver();
     var phi = z3c.MkLe(z3c.MkVar(0, z3c.IntSort), z3c.MkVar(1, z3c.IntSort));
     var psi = z3c.MkGt(z3c.MkVar(0, z3c.IntSort), z3c.MkVar(2, z3c.IntSort));
     var eq = z3c.MkEq(z3c.MkVar(1, z3c.IntSort), z3c.MkVar(2, z3c.IntSort));
     z3s.Push();
     z3s.Assert(phi);
     z3s.Assert(psi);
     z3s.Push();
     z3s.Assert(eq);
     var isSat1 = z3s.Check();
     z3s.Pop();
     var isSat2 = z3s.Check();
     z3s.Pop();
     Assert.IsFalse(isSat1);
     Assert.IsTrue(isSat2);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:19,代码来源:UnitTest1.cs


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