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


C# Z3Provider.Simplify方法代码示例

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


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

示例1: getAutomata

        internal override Automaton<Expr> getAutomata(Z3Provider z3p, List<string> variables, Expr universe, Expr var, Sort sort)
        {            
            //var bit1 = z3p.Z3.MkInt2Bv(1,
            //        z3p.MkInt(1));
            var bit1 = z3p.Z3.MkInt2BV(BVConst.BVSIZE, (IntExpr)z3p.MkInt(1));

            //Sort for pairs (input theory, BV)
            var bv = z3p.Z3.MkBitVecSort(BVConst.BVSIZE);
            var pairSort = z3p.MkTupleSort(sort, bv);

            //Add the representation of the existential variable to the list of variables
            var newVariables = variables.ToArray().ToList();
            newVariables.Insert(0, variable);

            //Compute the DFA for the formula phi
            var phiDfa = phi.getAutomata(z3p, newVariables, universe, var, sort);

            //Compute the new moves by dropping the last bit of every element in the phiMoves
            var newMoves = Automaton<Expr>.Empty.GetMoves().ToList();
            foreach (var oldMove in phiDfa.GetMoves())
            {
                var oldCond = oldMove.Label;                               

                var t = z3p.MkProj(1,var);
                //Compute the new conditions
                var newCond0 = z3p.ApplySubstitution(oldCond, t,
                        z3p.Z3.MkBVSHL((BitVecExpr)t, (BitVecExpr)bit1));
                var newCond1 = z3p.ApplySubstitution(oldCond, t, 
                    z3p.MkBvAdd(
                        z3p.Z3.MkBVSHL((BitVecExpr)t, (BitVecExpr)bit1),
                        bit1));
                
                //Update the new set of moves
                newMoves.Add(new Move<Expr>(oldMove.SourceState, oldMove.TargetState, z3p.MkOr(z3p.Simplify(newCond0),z3p.Simplify(newCond1))));
            }

            //Build the new dfa with the new moves
            return Automaton<Expr>.Create(phiDfa.InitialState, phiDfa.GetFinalStates(), newMoves);
                //.Determinize(z3p).MinimizeClassical(z3p, int.MaxValue,false);            
        }
开发者ID:AutomataTutor,项目名称:automatatutor-backend,代码行数:40,代码来源:WS1SZ3.cs

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


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