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


C# Z3Provider.MkBvAdd方法代码示例

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


在下文中一共展示了Z3Provider.MkBvAdd方法的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: TestSTbSimplify


//.........这里部分代码省略.........
            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);

            var bv32var = solver.Z3.MkZeroExt(16, (BitVecExpr)solver.CharVar);

            var brule4_5 = new BaseRule<Expr>(Sequence<Expr>.Empty, solver.MkTuple(reg0, solver.MkBvAdd(
                solver.MkBvMul(solver.MkNumeral(10,bv32),reg1),
                solver.MkBvSub(bv32var,_0))),5);
            var rule4 = new IteRule<Expr>(digit, brule4_5, new IteRule<Expr>(space, brule_4, UndefRule<Expr>.Default));
            parse.AssignRule(4, rule4);

            var brule_0 = new BaseRule<Expr>(Sequence<Expr>.Empty.Append(regVar), initReg, 0);

            var brule_7 = new BaseRule<Expr>(Sequence<Expr>.Empty, regVar, 7);

            var brule5_6 = new BaseRule<Expr>(Sequence<Expr>.Empty, solver.MkTuple(reg0, solver.MkBvAdd(
                solver.MkBvMul(solver.MkNumeral(10, bv32), reg1),
                solver.MkBvSub(bv32var, _0))), 6);
            var rule5 = new IteRule<Expr>(digit, brule5_6, new IteRule<Expr>(nl, brule_0, new IteRule<Expr>(space, brule_7, UndefRule<Expr>.Default)));
            parse.AssignRule(5, rule5);

            var brule6_7 = new BaseRule<Expr>(Sequence<Expr>.Empty, solver.MkTuple(reg0, solver.MkBvAdd(
                solver.MkBvMul(solver.MkNumeral(10, bv32), reg1),
                solver.MkBvSub(bv32var, _0))), 7);
            var rule6 = new IteRule<Expr>(digit, brule6_7, new IteRule<Expr>(nl, brule_0, new IteRule<Expr>(space, brule_7, UndefRule<Expr>.Default)));
            parse.AssignRule(6, rule6);

            var rule7 = new IteRule<Expr>(nl, brule_0, new IteRule<Expr>(space, brule_7, UndefRule<Expr>.Default));
            parse.AssignRule(7, rule7);

            parse.AssignFinalRule(0, new BaseRule<Expr>(Sequence<Expr>.Empty, initReg, 0));

            var comp = utf8decode.Compose(parse);

            //utf8decode.ToST().ShowGraph();

            //parse.ToST().ShowGraph();

            //comp.ToST().ShowGraph();

            //var comp1 = new STbSimulator<FuncDecl,Expr,Sort>(comp);
            //comp1.Explore();
            //Console.WriteLine(comp1.exploredSteps);

            //var rules = Array.ConvertAll(comp1.UncoveredMoves.ToArray(), r => new Tuple<int, int>(r.Item3.SourceState, r.Item3.TargetState));

            var simpl = comp.Simplify();

            Assert.AreEqual<int>(35, comp.StateCount);
            Assert.AreEqual<int>(7, simpl.StateCount);

            //simpl.ShowGraph();
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:101,代码来源:STbTests.cs


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