Exemple #1
0
        /// <summary>
        /// x_j = x_i + n, with min(nonempty-set)-semantics
        /// </summary>
        public static Automaton <IMonadicPredicate <BDD, T> > MkSuccN2 <T>(int i, int j, int n, ICartesianAlgebraBDD <T> alg)
        {
            var ieq0      = alg.BDDAlgebra.MkBitFalse(i);
            var ieq1      = alg.BDDAlgebra.MkBitTrue(i);
            var jeq0      = alg.BDDAlgebra.MkBitFalse(j);
            var jeq1      = alg.BDDAlgebra.MkBitTrue(j);
            var both0     = alg.BDDAlgebra.MkAnd(ieq0, jeq0);
            var ieq1_jeq0 = alg.BDDAlgebra.MkAnd(ieq1, jeq0);

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

            moves.Add(new Move <IMonadicPredicate <BDD, T> >(0, 0, alg.MkCartesianProduct(both0, alg.Second.True)));
            moves.Add(new Move <IMonadicPredicate <BDD, T> >(0, 1, alg.MkCartesianProduct(ieq1_jeq0, alg.Second.True)));

            for (int k = 1; k < n; k++)
            {
                moves.Add(new Move <IMonadicPredicate <BDD, T> >(k, k + 1, alg.MkCartesianProduct(jeq0, alg.Second.True)));
            }

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

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

            return(aut);
        }
Exemple #2
0
        /// <summary>
        /// x_j = x_i + n, with singleton-set-semantics
        /// </summary>
        public static Automaton <IMonadicPredicate <BDD, T> > MkSuccN1 <T>(int i1, int i2, int n, ICartesianAlgebraBDD <T> ca)
        {
            var bddAlg     = ca.BDDAlgebra;
            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);

            var both0t      = ca.MkCartesianProduct(both0, ca.Second.True);
            var ind11ind20t = ca.MkCartesianProduct(ind11ind20, ca.Second.True);
            var ind10ind21t = ca.MkCartesianProduct(ind10ind21, ca.Second.True);

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

            moves.Add(new Move <IMonadicPredicate <BDD, T> >(0, 0, both0t));
            moves.Add(new Move <IMonadicPredicate <BDD, T> >(0, 1, ind11ind20t));
            moves.Add(new Move <IMonadicPredicate <BDD, T> >(n, n + 1, ind10ind21t));
            moves.Add(new Move <IMonadicPredicate <BDD, T> >(n + 1, n + 1, both0t));

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

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

            return(aut);
        }
Exemple #3
0
        /// <summary>
        /// all1 x: x in X_i => [psi](x)
        /// </summary>
        public static Automaton <IMonadicPredicate <BDD, T> > MkLabelOfSet <T>(int i, T psi, ICartesianAlgebraBDD <T> ca)
        {
            Func <BDD, IMonadicPredicate <BDD, T> > lift1 = bdd => ca.MkCartesianProduct(bdd, ca.Second.True);
            Func <T, IMonadicPredicate <BDD, T> >   lift2 = p => ca.MkCartesianProduct(ca.BDDAlgebra.True, p);
            var bit_i_is0 = ca.BDDAlgebra.MkBitFalse(i);
            var cond      = ca.MkOr(lift2(psi), lift1(bit_i_is0));
            var moves     = new Move <IMonadicPredicate <BDD, T> >[] { new Move <IMonadicPredicate <BDD, T> >(0, 0, cond) };
            var aut       = Automaton <IMonadicPredicate <BDD, T> > .Create(ca, 0, new int[] { 0 }, moves, false, false, true);

            return(aut);
        }
Exemple #4
0
        /// <summary>
        /// [psi](x_i) with min(nonempty-set)-semantics
        /// </summary>
        /// <returns></returns>
        public static Automaton <IMonadicPredicate <BDD, T> > MkLabelOfPosition2 <T>(int i, T pred, ICartesianAlgebraBDD <T> alg)
        {
            var bit_i_is0 = alg.BDDAlgebra.MkBitFalse(i);
            var bit_i_is1 = alg.BDDAlgebra.MkBitTrue(i);
            var cond      = alg.MkCartesianProduct(bit_i_is1, pred);
            var moves     = new Move <IMonadicPredicate <BDD, T> >[] {
                new Move <IMonadicPredicate <BDD, T> >(0, 0, alg.MkCartesianProduct(bit_i_is0, alg.Second.True)),
                new Move <IMonadicPredicate <BDD, T> >(0, 1, cond),
                new Move <IMonadicPredicate <BDD, T> >(1, 1, alg.True)
            };
            var aut = Automaton <IMonadicPredicate <BDD, T> > .Create(alg, 0, new int[] { 1 }, moves, false, false, true);

            return(aut);
        }
Exemple #5
0
        /// <summary>
        /// x_i in X_j with min(nonempty-set)-semantics for x_i
        /// </summary>
        public static Automaton <IMonadicPredicate <BDD, T> > MkIn2 <T>(int i, int j, ICartesianAlgebraBDD <T> alg)
        {
            var ieq0      = alg.BDDAlgebra.MkBitFalse(i);
            var ieq1      = alg.BDDAlgebra.MkBitTrue(i);
            var jeq1      = alg.BDDAlgebra.MkBitTrue(j);
            var ieq1_jeq1 = alg.BDDAlgebra.MkAnd(jeq1, ieq1);
            var moves     = new Move <IMonadicPredicate <BDD, T> >[] {
                new Move <IMonadicPredicate <BDD, T> >(0, 0, alg.MkCartesianProduct(ieq0, alg.Second.True)),
                new Move <IMonadicPredicate <BDD, T> >(0, 1, alg.MkCartesianProduct(ieq1_jeq1, alg.Second.True)),
                new Move <IMonadicPredicate <BDD, T> >(1, 1, alg.True)
            };
            var aut = Automaton <IMonadicPredicate <BDD, T> > .Create(alg, 0, new int[] { 1 }, moves, false, false, true);

            return(aut);
        }
        public static Automaton <IMonadicPredicate <BDD, T> > MkSingleton <T>(int i, ICartesianAlgebraBDD <T> ca)
        {
            Func <BDD, IMonadicPredicate <BDD, T> > lift1 = bdd => ca.MkCartesianProduct(bdd, ca.Second.True);
            Func <T, IMonadicPredicate <BDD, T> >   lift2 = psi => ca.MkCartesianProduct(ca.BDDAlgebra.True, psi);
            var alg       = ca.BDDAlgebra;
            var bit_i_is0 = alg.MkBitFalse(i);
            var bit_i_is1 = alg.MkBitTrue(i);
            var moves     = new Move <IMonadicPredicate <BDD, T> >[] {
                new Move <IMonadicPredicate <BDD, T> >(0, 0, lift1(bit_i_is0)),
                new Move <IMonadicPredicate <BDD, T> >(0, 1, lift1(bit_i_is1)),
                new Move <IMonadicPredicate <BDD, T> >(1, 1, lift1(bit_i_is0))
            };
            var aut = Automaton <IMonadicPredicate <BDD, T> > .Create(ca, 0, new int[] { 1 }, moves, false, false, true);

            return(aut);
        }
Exemple #7
0
        /// <summary>
        /// x_i = x_j, with min(nonempty-set)-semantics for f-o vars
        /// </summary>
        public static Automaton <IMonadicPredicate <BDD, T> > MkEqualPositions2 <T>(int i, int j, ICartesianAlgebraBDD <T> alg)
        {
            var bit_j_is1 = alg.BDDAlgebra.MkBitTrue(j);
            var bit_i_is1 = alg.BDDAlgebra.MkBitTrue(i);
            var bit_i_is0 = alg.BDDAlgebra.MkBitFalse(i);
            var bit_j_is0 = alg.BDDAlgebra.MkBitFalse(j);
            var both0     = alg.BDDAlgebra.MkAnd(bit_i_is0, bit_j_is0);
            var both1     = alg.BDDAlgebra.MkAnd(bit_i_is1, bit_j_is1);
            var moves     = new Move <IMonadicPredicate <BDD, T> >[] {
                new Move <IMonadicPredicate <BDD, T> >(0, 0, alg.MkCartesianProduct(both0, alg.Second.True)),
                new Move <IMonadicPredicate <BDD, T> >(0, 1, alg.MkCartesianProduct(both1, alg.Second.True)),
                new Move <IMonadicPredicate <BDD, T> >(1, 1, alg.True)
            };
            var aut = Automaton <IMonadicPredicate <BDD, T> > .Create(alg, 0, new int[] { 1 }, moves, false, false, true);

            return(aut);
        }
Exemple #8
0
        /// <summary>
        /// x_i = n, with min(nonempty-set)-semantics
        /// </summary>
        internal static Automaton <IMonadicPredicate <BDD, T> > MkEqN2 <T>(int i, int n, ICartesianAlgebraBDD <T> alg)
        {
            var ieq0  = alg.BDDAlgebra.MkBitFalse(i);
            var ieq1  = alg.BDDAlgebra.MkBitTrue(i);
            var moves = new List <Move <IMonadicPredicate <BDD, T> > >();

            for (int k = 0; k < n; k++)
            {
                moves.Add(new Move <IMonadicPredicate <BDD, T> >(k, k + 1, alg.MkCartesianProduct(ieq0, alg.Second.True)));
            }

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

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

            return(aut);
        }
Exemple #9
0
        /// <summary>
        /// X_i = {}
        /// </summary>
        internal static Automaton <IMonadicPredicate <BDD, T> > MkIsEmpty <T>(int i, ICartesianAlgebraBDD <T> alg)
        {
            var ieq0  = alg.BDDAlgebra.MkBitFalse(i);
            var moves = new Move <IMonadicPredicate <BDD, T> >[] {
                new Move <IMonadicPredicate <BDD, T> >(0, 0, alg.MkCartesianProduct(ieq0, alg.Second.True)),
            };
            var aut = Automaton <IMonadicPredicate <BDD, T> > .Create(alg, 0, new int[] { 0 }, moves, false, false, true);

            return(aut);
        }
Exemple #10
0
        /// <summary>
        /// X_i = X_j
        /// </summary>
        public static Automaton <IMonadicPredicate <BDD, T> > MkEqualSets <T>(int i, int j, ICartesianAlgebraBDD <T> alg)
        {
            var bit_j_is1 = alg.BDDAlgebra.MkBitTrue(j);
            var bit_i_is1 = alg.BDDAlgebra.MkBitTrue(i);
            var bit_i_is0 = alg.BDDAlgebra.MkBitFalse(i);
            var bit_j_is0 = alg.BDDAlgebra.MkBitFalse(j);
            var cond      = alg.MkCartesianProduct(alg.BDDAlgebra.MkOr(alg.BDDAlgebra.MkAnd(bit_i_is1, bit_j_is1), alg.BDDAlgebra.MkAnd(bit_i_is0, bit_j_is0)), alg.Second.True);
            var moves     = new Move <IMonadicPredicate <BDD, T> >[] { new Move <IMonadicPredicate <BDD, T> >(0, 0, cond) };
            var aut       = Automaton <IMonadicPredicate <BDD, T> > .Create(alg, 0, new int[] { 0 }, moves, false, false, true);

            return(aut);
        }
Exemple #11
0
        /// <summary>
        /// x_i is the last position
        /// </summary>
        internal static Automaton <IMonadicPredicate <BDD, T> > MkLast <T>(int i, ICartesianAlgebraBDD <T> alg)
        {
            Func <BDD, IMonadicPredicate <BDD, T> > f = bdd => alg.MkCartesianProduct(bdd, alg.Second.True);
            var ieq0  = alg.BDDAlgebra.MkBitFalse(i);
            var ieq1  = alg.BDDAlgebra.MkBitTrue(i);
            var moves = new Move <IMonadicPredicate <BDD, T> >[] {
                new Move <IMonadicPredicate <BDD, T> >(0, 0, f(ieq0)),
                new Move <IMonadicPredicate <BDD, T> >(0, 1, f(ieq1)),
            };
            var aut = Automaton <IMonadicPredicate <BDD, T> > .Create(alg, 0, new int[] { 1 }, moves, false, false, true);

            return(aut);
        }
Exemple #12
0
        /// <summary>
        /// x_i in X_j with singleton-set-semantics for x_i
        /// </summary>
        internal static Automaton <IMonadicPredicate <BDD, T> > MkIn1 <T>(int i, int j, ICartesianAlgebraBDD <T> ca)
        {
            Func <BDD, IMonadicPredicate <BDD, T> > lift = bdd => ca.MkCartesianProduct(bdd, ca.Second.True);
            var alg       = ca.BDDAlgebra;
            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 <IMonadicPredicate <BDD, T> >[] {
                new Move <IMonadicPredicate <BDD, T> >(0, 0, lift(bit_i_is0)),
                new Move <IMonadicPredicate <BDD, T> >(0, 1, lift(both1)),
                new Move <IMonadicPredicate <BDD, T> >(1, 1, lift(bit_i_is0))
            };
            var aut = Automaton <IMonadicPredicate <BDD, T> > .Create(ca, 0, new int[] { 1 }, moves, false, false, true);

            return(aut);
        }
Exemple #13
0
        /// <summary>
        /// x_i &lt;= x_j, with min(nonempty-set)-semantics for f-o vars
        /// </summary>
        public static Automaton <IMonadicPredicate <BDD, T> > MkLe2 <T>(int i, int j, ICartesianAlgebraBDD <T> alg)
        {
            Func <BDD, IMonadicPredicate <BDD, T> > f = bdd => alg.MkCartesianProduct(bdd, alg.Second.True);
            var bit_i_is0           = alg.BDDAlgebra.MkBitFalse(i);
            var bit_i_is1           = alg.BDDAlgebra.MkBitTrue(i);
            var bit_j_is0           = alg.BDDAlgebra.MkBitFalse(j);
            var bit_j_is1           = alg.BDDAlgebra.MkBitTrue(j);
            var both0               = alg.BDDAlgebra.MkAnd(bit_i_is0, bit_j_is0);
            var both1               = alg.BDDAlgebra.MkAnd(bit_i_is1, bit_j_is1);
            var bit_i_is1_bit_j_is0 = alg.BDDAlgebra.MkAnd(bit_i_is1, bit_j_is0);
            var moves               = new Move <IMonadicPredicate <BDD, T> >[] {
                new Move <IMonadicPredicate <BDD, T> >(0, 0, f(both0)),
                new Move <IMonadicPredicate <BDD, T> >(0, 1, f(bit_i_is1_bit_j_is0)),
                new Move <IMonadicPredicate <BDD, T> >(1, 1, f(bit_j_is0)),
                new Move <IMonadicPredicate <BDD, T> >(1, 2, f(bit_j_is1)),
                new Move <IMonadicPredicate <BDD, T> >(2, 2, alg.True),
                new Move <IMonadicPredicate <BDD, T> >(0, 2, f(both1))
            };
            var aut = Automaton <IMonadicPredicate <BDD, T> > .Create(alg, 0, new int[] { 2 }, moves, false, false, true);

            return(aut);
        }