Пример #1
0
 internal BDD(IBDDAlgebra algebra, int ordinal)
 {
     this.One = null;
     this.Zero = null;
     this.Ordinal = ordinal;
     this.algebra = algebra;
 }
Пример #2
0
 internal BDD(IBDDAlgebra algebra, int ordinal, BDD one, BDD zero)
 {
     this.One = one;
     this.Zero = zero;
     this.Ordinal = ordinal;
     this.algebra = algebra;
 }
Пример #3
0
 internal BDD(IBDDAlgebra algebra, int ordinal, BDD one, BDD zero)
 {
     this.One     = one;
     this.Zero    = zero;
     this.Ordinal = ordinal;
     this.algebra = algebra;
 }
Пример #4
0
        public static Automaton <BDD> MkSuccN(int i1, int i2, int n, IBDDAlgebra bddAlg)
        {
            var alg        = bddAlg;
            var ind10      = bddAlg.MkBitFalse(i1);
            var ind11      = bddAlg.MkBitTrue(i1);
            var ind20      = bddAlg.MkBitFalse(i2);
            var ind21      = bddAlg.MkBitTrue(i2);
            var both0      = bddAlg.MkAnd(ind10, ind20);
            var ind11ind20 = bddAlg.MkAnd(ind11, ind20);
            var ind10ind21 = bddAlg.MkAnd(ind10, ind21);

            //Create moves
            var moves = new List <Move <BDD> >();

            moves.Add(new Move <BDD>(0, 0, both0));
            moves.Add(new Move <BDD>(0, 1, ind11ind20));
            moves.Add(new Move <BDD>(n, n + 1, ind10ind21));
            moves.Add(new Move <BDD>(n + 1, n + 1, both0));

            for (int i = 1; i < n; i++)
            {
                moves.Add(new Move <BDD>(i, i + 1, both0));
            }

            var aut = Automaton <BDD> .Create(bddAlg, 0, new int[] { n + 1 }, moves, false, false, true);

            return(aut);
        }
Пример #5
0
 internal BDD(IBDDAlgebra algebra, int ordinal)
 {
     this.One     = null;
     this.Zero    = null;
     this.Ordinal = ordinal;
     this.algebra = algebra;
 }
Пример #6
0
        /// <summary>
        /// x_j = x_i + n, with min(nonempty-set)-semantics
        /// </summary>
        public static Automaton <BDD> MkSuccN2(int i, int j, int n, IBDDAlgebra alg)
        {
            var ieq0      = alg.MkBitFalse(i);
            var ieq1      = alg.MkBitTrue(i);
            var jeq0      = alg.MkBitFalse(j);
            var jeq1      = alg.MkBitTrue(j);
            var both0     = alg.MkAnd(ieq0, jeq0);
            var ieq1_jeq0 = alg.MkAnd(ieq1, jeq0);

            //Create moves
            var moves = new List <Move <BDD> >();

            moves.Add(new Move <BDD>(0, 0, both0));
            moves.Add(new Move <BDD>(0, 1, ieq1_jeq0));

            for (int k = 1; k < n; k++)
            {
                moves.Add(new Move <BDD>(k, k + 1, jeq0));
            }

            moves.Add(new Move <BDD>(n, n + 1, jeq1));
            moves.Add(new Move <BDD>(n + 1, n + 1, alg.True));

            var aut = Automaton <BDD> .Create(alg, 0, new int[] { n + 1 }, moves, false, false, true);

            return(aut);
        }
Пример #7
0
        public static Automaton <BDD> MkTrue(IBDDAlgebra alg)
        {
            var moves = new Move <BDD>[] {
                new Move <BDD>(0, 0, alg.True)
            };

            return(Automaton <BDD> .Create(alg, 0, new int[] { 0 }, moves, false, false, true));
        }
Пример #8
0
        /// <summary>
        /// all1 x: x in X_i => [psi](x)
        /// </summary>
        public static Automaton <BDD> MkLabelOfSet(int i, BDD psi, IBDDAlgebra alg)
        {
            var bit_i_is0 = alg.MkBitFalse(i);
            var cond      = alg.MkOr(psi, bit_i_is0);
            var moves     = new Move <BDD>[] { new Move <BDD>(0, 0, cond) };
            var aut       = Automaton <BDD> .Create(alg, 0, new int[] { 0 }, moves, false, false, true);

            return(aut);
        }
Пример #9
0
        public Automaton <BDD> GetAutomatonBDD(IBDDAlgebra alg, int nrOfLabelBits, params Variable[] fv)
        {
            if (!(typeof(T).Equals(typeof(BDD))))
            {
                throw new ArgumentException("Method is not supported because T is not BDD");
            }

            return(getAutomatonBDD(SimpleList <Variable> .Empty.Append(fv), alg, nrOfLabelBits));
        }
Пример #10
0
        public static Automaton <BDD> MkSingleton(int i, IBDDAlgebra alg)
        {
            var bit_i_is0 = alg.MkBitFalse(i);
            var bit_i_is1 = alg.MkBitTrue(i);
            var moves     = new Move <BDD>[] { new Move <BDD>(0, 0, bit_i_is0),
                                               new Move <BDD>(0, 1, bit_i_is1), new Move <BDD>(1, 1, bit_i_is0) };
            var aut = Automaton <BDD> .Create(alg, 0, new int[] { 1 }, moves, false, false, true);

            return(aut);
        }
Пример #11
0
        public BDD AsBDD(IBDDAlgebra alg)
        {
            var res = alg.False;

            for (int i = 0; i < intervals.Length; i++)
            {
                res = res | alg.MkSetFromRange(intervals[i].Item1, intervals[i].Item2, 15);
            }
            return(res);
        }
Пример #12
0
        /// <summary>
        /// X_i sub X_j
        /// </summary>
        public static Automaton <BDD> MkSubset(int i, int j, IBDDAlgebra alg)
        {
            var bit_j_is1  = alg.MkBitTrue(j);
            var bit_i_is0  = alg.MkBitFalse(i);
            var subsetCond = alg.MkOr(bit_j_is1, bit_i_is0);
            var moves      = new Move <BDD>[] { new Move <BDD>(0, 0, subsetCond) };
            var aut        = Automaton <BDD> .Create(alg, 0, new int[] { 0 }, moves, false, false, true);

            return(aut);
        }
Пример #13
0
        /// <summary>
        /// X_i = {}
        /// </summary>
        internal static Automaton <BDD> MkIsEmpty(int i, IBDDAlgebra alg)
        {
            var ieq0  = alg.MkBitFalse(i);
            var moves = new Move <BDD>[] {
                new Move <BDD>(0, 0, ieq0),
            };
            var aut = Automaton <BDD> .Create(alg, 0, new int[] { 0 }, moves, false, false, true);

            return(aut);
        }
Пример #14
0
        /// <summary>
        /// X_i = X_j
        /// </summary>
        public static Automaton <BDD> MkEqualSets(int i, int j, IBDDAlgebra alg)
        {
            var bit_j_is1 = alg.MkBitTrue(j);
            var bit_i_is1 = alg.MkBitTrue(i);
            var bit_i_is0 = alg.MkBitFalse(i);
            var bit_j_is0 = alg.MkBitFalse(j);
            var cond      = alg.MkOr(alg.MkAnd(bit_i_is1, bit_j_is1), alg.MkAnd(bit_i_is0, bit_j_is0));
            var moves     = new Move <BDD>[] { new Move <BDD>(0, 0, cond) };
            var aut       = Automaton <BDD> .Create(alg, 0, new int[] { 0 }, moves, false, false, true);

            return(aut);
        }
Пример #15
0
        /// <summary>
        /// x_i in X_j with singleton-set-semantics for x_i
        /// </summary>
        internal static Automaton <BDD> MkIn1(int i, int j, IBDDAlgebra alg)
        {
            var bit_j_is1 = alg.MkBitTrue(j);
            var bit_i_is1 = alg.MkBitTrue(i);
            var bit_i_is0 = alg.MkBitFalse(i);
            var both1     = alg.MkAnd(bit_i_is1, bit_j_is1);
            var moves     = new Move <BDD>[] { new Move <BDD>(0, 0, bit_i_is0),
                                               new Move <BDD>(0, 1, both1), new Move <BDD>(1, 1, bit_i_is0) };
            var aut = Automaton <BDD> .Create(alg, 0, new int[] { 1 }, moves, false, false, true);

            return(aut);
        }
Пример #16
0
        /// <summary>
        /// [psi](x_i) with min(nonempty-set)-semantics
        /// </summary>
        /// <returns></returns>
        public static Automaton <BDD> MkLabelOfPosition2(int i, BDD psi, IBDDAlgebra alg)
        {
            var bit_i_is0 = alg.MkBitFalse(i);
            var bit_i_is1 = alg.MkBitTrue(i);
            var cond      = alg.MkAnd(bit_i_is1, psi);
            var moves     = new Move <BDD>[] {
                new Move <BDD>(0, 0, bit_i_is0),
                new Move <BDD>(0, 1, cond),
                new Move <BDD>(1, 1, alg.True)
            };
            var aut = Automaton <BDD> .Create(alg, 0, new int[] { 1 }, moves, false, false, true);

            return(aut);
        }
Пример #17
0
        /// <summary>
        /// x_i in X_j with min(nonempty-set)-semantics for x_i
        /// </summary>
        public static Automaton <BDD> MkIn2(int i, int j, IBDDAlgebra alg)
        {
            var ieq0      = alg.MkBitFalse(i);
            var ieq1      = alg.MkBitTrue(i);
            var jeq1      = alg.MkBitTrue(j);
            var ieq1_jeq1 = alg.MkAnd(jeq1, ieq1);
            var moves     = new Move <BDD>[] {
                new Move <BDD>(0, 0, ieq0),
                new Move <BDD>(0, 1, ieq1_jeq1),
                new Move <BDD>(1, 1, alg.True)
            };
            var aut = Automaton <BDD> .Create(alg, 0, new int[] { 1 }, moves, false, false, true);

            return(aut);
        }
Пример #18
0
        /// <summary>
        /// x_i &lt; x_j, with singleton-set semantics for f-o vars
        /// </summary>
        public static Automaton <BDD> MkLt1(int i, int j, IBDDAlgebra alg)
        {
            var bit_i_is0 = alg.MkBitFalse(i);
            var bit_i_is1 = alg.MkBitTrue(i);
            var bit_j_is0 = alg.MkBitFalse(j);
            var bit_j_is1 = alg.MkBitTrue(j);
            var both0     = alg.MkAnd(bit_i_is0, bit_j_is0);
            var cond1     = alg.MkAnd(bit_i_is1, bit_j_is0);
            var cond2     = alg.MkAnd(bit_j_is1, bit_i_is0);
            var moves     = new Move <BDD>[] { new Move <BDD>(0, 0, both0),
                                               new Move <BDD>(0, 1, cond1), new Move <BDD>(1, 1, both0),
                                               new Move <BDD>(1, 2, cond2), new Move <BDD>(2, 2, both0) };
            var aut = Automaton <BDD> .Create(alg, 0, new int[] { 2 }, moves, false, false, true);

            return(aut);
        }
Пример #19
0
        public BDD ConvertToCharSet(IBDDAlgebra solver, ulong pred)
        {
            BDD res = solver.False;

            if (!pred.Equals(this.zero))
            {
                for (int i = 0; i < atoms.Length; i++)
                {
                    //construct the union of the corresponding atoms
                    if (!(pred & atoms[i]).Equals(this.zero))
                    {
                        BDD bdd_i = partition[i].AsBDD(solver);
                        res = solver.MkOr(res, bdd_i);
                    }
                }
            }
            return(res);
        }
Пример #20
0
        /// <summary>
        /// x_i = n, with min(nonempty-set)-semantics
        /// </summary>
        internal static Automaton <BDD> MkEqN2(int i, int n, IBDDAlgebra alg)
        {
            var ieq0  = alg.MkBitFalse(i);
            var ieq1  = alg.MkBitTrue(i);
            var moves = new List <Move <BDD> >();

            for (int k = 0; k < n; k++)
            {
                moves.Add(new Move <BDD>(k, k + 1, ieq0));
            }

            moves.Add(new Move <BDD>(n, n + 1, ieq1));
            moves.Add(new Move <BDD>(n + 1, n + 1, alg.True));

            var aut = Automaton <BDD> .Create(alg, 0, new int[] { n + 1 }, moves, false, false, true);

            return(aut);
        }
Пример #21
0
        public bool TryConvertToCharSet(IBDDAlgebra solver, BV pred, out BDD set)
        {
            BDD res = solver.False;

            if (!pred.Equals(this.zero))
            {
                for (int i = 0; i < atoms.Length; i++)
                {
                    //construct the union of the corresponding atoms
                    if (!(pred & atoms[i]).Equals(this.zero))
                    {
                        BDD bdd_i = partition[i].AsBDD(solver);
                        res = solver.MkOr(res, bdd_i);
                    }
                }
            }
            set = res;
            return(true);
        }
Пример #22
0
        Automaton <BDD> GetAutomatonBDD1(Variable[] variables, IBDDAlgebra alg, int nrOfFreeBits, bool singletonSetSemantics)
        {
            var res = GetAutomatonBDD(SimpleList <Variable> .Empty.Append(variables), alg, nrOfFreeBits, singletonSetSemantics);

            for (int i = 0; i < variables.Length; i++)
            {
                if (variables[i].IsFirstOrder)
                {
                    if (singletonSetSemantics)
                    {
                        res = res.Intersect(BasicAutomata.MkSingleton(i, alg)).Determinize().Minimize();
                    }
                    else
                    {
                        res = res.Intersect(BasicAutomata.MkIsNonempty(i, alg)).Determinize().Minimize();
                    }
                }
            }
            return(res);
        }
Пример #23
0
        internal override Automaton <BDD> GetAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfLabelBits)
        {
            var pos1 = variables.IndexOf(var1);
            var pos2 = variables.IndexOf(var2);

            if (pos1 < 0)
            {
                throw new InvalidOperationException(string.Format("unkown variable {0}", var1));
            }
            if (pos2 < 0)
            {
                throw new InvalidOperationException(string.Format("unkown variable {0}", var2));
            }

            pos1 = pos1 + nrOfLabelBits;
            pos2 = pos2 + nrOfLabelBits;

            return(BasicAutomata.MkLt2(pos1, pos2, alg));
        }
Пример #24
0
 internal abstract Automaton <BDD> GetAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfFreeBits);
Пример #25
0
        internal override Automaton <BDD> GetAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfLabelBits)
        {
            var k = variables.IndexOf(var);

            if (k < 0)
            {
                throw new ArgumentOutOfRangeException("variables", string.Format("does not contain variable: {0}", var));
            }

            k = k + nrOfLabelBits;

            return(BasicAutomata.MkEqN2(k, n, alg));
        }
Пример #26
0
        internal override Automaton <BDD> GetAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfLabelBits)
        {
            var pos = variables.IndexOf(var);

            if (pos < 0)
            {
                throw new ArgumentOutOfRangeException("variables", string.Format("does not contain {0}", var));
            }

            Automaton <BDD> aut = BasicAutomata.MkLast(pos + nrOfLabelBits, alg);

            return(aut);
        }
Пример #27
0
        internal override Automaton <BDD> GetAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfLabelBits)
        {
            var pos1 = variables.IndexOf(var1);
            var pos2 = variables.IndexOf(var2);

            if (pos1 < 0)
            {
                throw new ArgumentException("variables", string.Format("does not contain {0}", var1));
            }
            if (pos2 < 0)
            {
                throw new ArgumentException("variables", string.Format("does not contain {0}", var2));
            }

            pos1 = pos1 + nrOfLabelBits;
            pos2 = pos2 + nrOfLabelBits;

            return(BasicAutomata.MkSuccN2(pos1, pos2, n, alg));
        }
Пример #28
0
        internal override Automaton <BDD> GetAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfLabelBits)
        {
            var k = variables.IndexOf(var);

            if (k < 0)
            {
                throw new ArgumentOutOfRangeException("variables", string.Format("does not contain variable: {0}", var));
            }

            k = k + nrOfLabelBits;

            if (var.IsFirstOrder)
            {
                return(BasicAutomata.MkLabelOfPosition2(k, pred as BDD, alg));
            }
            else
            {
                return(BasicAutomata.MkLabelOfSet(k, pred as BDD, alg));
            }
        }
Пример #29
0
        internal override Automaton <BDD> GetAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfLabelBits)
        {
            var aut = phi.GetAutomatonBDD(variables, alg, nrOfLabelBits);
            var res = aut.Determinize(alg).Complement(alg).Minimize(alg);

            return(res);
        }
Пример #30
0
        internal override Automaton <BDD> GetAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfLabelBits)
        {
            var aut1 = phi1.GetAutomatonBDD(variables, alg, nrOfLabelBits);
            var aut2 = phi2.GetAutomatonBDD(variables, alg, nrOfLabelBits);
            var aut  = aut1.Intersect(aut2, alg);

            aut = aut.Minimize(alg);
            return(aut);
        }
Пример #31
0
        internal override Automaton <BDD> GetAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfLabelBits)
        {
            var pos1 = variables.IndexOf(var1);
            var pos2 = variables.IndexOf(var2);

            if (pos1 < 0)
            {
                throw new ArgumentOutOfRangeException("variables", string.Format("does not contain {0}", var1));
            }
            if (pos2 < 0)
            {
                throw new ArgumentOutOfRangeException("variables", string.Format("does not contain {0}", var2));
            }

            var aut = BasicAutomata.MkMax2(pos1 + nrOfLabelBits, pos2 + nrOfLabelBits, alg);

            return(aut);
        }
Пример #32
0
        internal override Automaton <BDD> GetAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfLabelBits)
        {
            var pos1 = variables.IndexOf(var1);
            var pos2 = variables.IndexOf(var2);

            if (pos1 < 0)
            {
                throw new ArgumentOutOfRangeException("variables", string.Format("does not contain {0}", var1));
            }
            if (pos2 < 0)
            {
                throw new ArgumentOutOfRangeException("variables", string.Format("does not contain {0}", var2));
            }

            pos1 = pos1 + nrOfLabelBits;
            pos2 = pos2 + nrOfLabelBits;

            if (var1.IsFirstOrder)
            {
                return(BasicAutomata.MkEqualPositions2(pos1, pos2, alg));
            }
            else
            {
                return(BasicAutomata.MkEqualSets(pos1, pos2, alg));
            }
        }