Пример #1
0
        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);
        }
Пример #2
0
        internal override Automaton <Expr> getAutomata(Z3Provider z3p, List <string> variables, Expr universe, Expr var, Sort sort)
        {
            //Sort for pairs (input theory, BV)
            var bv       = z3p.Z3.MkBitVecSort(BVConst.BVSIZE);
            var pairSort = z3p.MkTupleSort(sort, bv);

            //Create the predicate for the universe automaton
            var pred = z3p.MkBvUlt(z3p.MkProj(1, var),
                                   z3p.Z3.MkInt2BV(BVConst.BVSIZE,
                                                   (IntExpr)z3p.MkInt((int)(Math.Pow(2.0, variables.Count)))
                                                   ));

            pred = z3p.MkAnd(pred, universe);

            //Create the automaton with one state and one transition
            var univ = Automaton <Expr> .Create(0, new int[] { 0 }, new Move <Expr>[] { new Move <Expr>(0, 0, pred) });

            //Compute the set difference
            return(univ.Minus(phi.getAutomata(z3p, variables, universe, var, sort), z3p).Determinize(z3p).Minimize(z3p));
        }
Пример #3
0
 internal override Automaton <Expr> getAutomata(Z3Provider z3p, List <string> variables, Expr universe, Expr var, Sort sort)
 {
     return(left.getAutomata(z3p, variables, universe, var, sort).Intersect(right.getAutomata(z3p, variables, universe, var, sort), z3p).Determinize(z3p).Minimize(z3p));
 }