Exemple #1
0
        public void mod3inBinary()
        {
            var         solver = new CharSetSolver(BitWidth.BV64);
            List <char> alph   = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);

            //(number of 1's in even postion mod 3) is same as (number of 1's in odd position mod 3)
            int       i;
            PDLPosVar p   = new PDLPosVar("p");
            PDLPred   phi = new PDLFalse();

            for (i = 0; i < 3; i++)
            {
                phi = new PDLOr(phi, new PDLAnd(
                                    new PDLModSetEq(new PDLIntersect
                                                        (new PDLPredSet("p", new PDLAtPos('b', p)),
                                                        (new PDLPredSet("p", new PDLModSetEq(new PDLAllPosUpto(p), 2, 0)))), 3, i),
                                    new PDLModSetEq(new PDLIntersect
                                                        (new PDLPredSet("p", new PDLAtPos('b', p)),
                                                        (new PDLPredSet("p", new PDLModSetEq(new PDLAllPosUpto(p), 2, 1)))), 3, i)));
            }

            StringBuilder sb = new StringBuilder();

            phi.ToString(sb);
            System.Console.WriteLine(sb);
            //System.Console.WriteLine(Convert.ToString(43, 2));
            //System.Console.WriteLine(phi.Eval(Convert.ToString(57, 2), new Dictionary<string, int>()));

            var dfa = phi.GetDFA(al, solver);
            ////string file = "../../../TestPDL/DotFiles/mod3inBinary";
            ////solver.SaveAsDot(dfa, "aut", file);
        }
        public void Test14() // all strings whose value when interpreted as numbers in binary is divisible by 3
        {
            //(number of 1's in even postion mod 3) is same as (number of 1's in odd position mod 3)
            int       i;
            PDLPosVar p   = new PDLPosVar("p");
            PDLPred   phi = new PDLFalse();

            for (i = 0; i < 3; i++)
            {
                phi = new PDLOr(phi, new PDLAnd(
                                    new PDLModSetEq(new PDLIntersect
                                                        (new PDLPredSet("p", new PDLAtPos('b', p)),
                                                        (new PDLPredSet("p", new PDLModSetEq(new PDLAllPosUpto(p), 2, 0)))), 3, i),
                                    new PDLModSetEq(new PDLIntersect
                                                        (new PDLPredSet("p", new PDLAtPos('b', p)),
                                                        (new PDLPredSet("p", new PDLModSetEq(new PDLAllPosUpto(p), 2, 1)))), 3, i)));
            }

            PrintDFA(phi, "Test14", new List <char> {
                'a', 'b'
            });
        }
        public void mod3inBinary()
        {
            var solver = new CharSetSolver(BitWidth.BV64);
            List<char> alph = new List<char> { 'a', 'b' };
            HashSet<char> al = new HashSet<char>(alph);

            //(number of 1's in even postion mod 3) is same as (number of 1's in odd position mod 3)
            int i;
            PDLPosVar p = new PDLPosVar("p");
            PDLPred phi = new PDLFalse();

            for(i=0;i<3;i++)
            {
                phi = new PDLOr(phi, new PDLAnd(
                    new PDLModSetEq(new PDLIntersect
                    (new PDLPredSet("p", new PDLAtPos('b', p)),
                    (new PDLPredSet("p", new PDLModSetEq(new PDLAllPosUpto(p), 2, 0)))), 3, i),
                    new PDLModSetEq(new PDLIntersect
                    (new PDLPredSet("p", new PDLAtPos('b', p)),
                    (new PDLPredSet("p", new PDLModSetEq(new PDLAllPosUpto(p), 2, 1)))), 3, i)));

            }

            StringBuilder sb = new StringBuilder();
            phi.ToString(sb);
            System.Console.WriteLine(sb);
            //System.Console.WriteLine(Convert.ToString(43, 2));
            //System.Console.WriteLine(phi.Eval(Convert.ToString(57, 2), new Dictionary<string, int>()));

            var dfa = phi.GetDFA(al, solver);
            ////string file = "../../../TestPDL/DotFiles/mod3inBinary";
            ////solver.SaveAsDot(dfa, "aut", file);

        }
        public void Test14() // all strings whose value when interpreted as numbers in binary is divisible by 3
        {
            //(number of 1's in even postion mod 3) is same as (number of 1's in odd position mod 3)
            int i;
            PDLPosVar p = new PDLPosVar("p");
            PDLPred phi = new PDLFalse();

            for (i = 0; i < 3; i++)
            {
                phi = new PDLOr(phi, new PDLAnd(
                    new PDLModSetEq(new PDLIntersect
                    (new PDLPredSet("p", new PDLAtPos('b', p)),
                    (new PDLPredSet("p", new PDLModSetEq(new PDLAllPosUpto(p), 2, 0)))), 3, i),
                    new PDLModSetEq(new PDLIntersect
                    (new PDLPredSet("p", new PDLAtPos('b', p)),
                    (new PDLPredSet("p", new PDLModSetEq(new PDLAllPosUpto(p), 2, 1)))), 3, i)));

            }

            PrintDFA(phi, "Test14", new List<char> { 'a', 'b' });

        }