Beispiel #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);
        }
Beispiel #2
0
        public void div2or3()
        {
            var         solver = new CharSetSolver(BitWidth.BV64);
            List <char> alph   = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);

            PDLPred phi = new PDLOr(new PDLModSetEq(new PDLAllPos(), 2, 0), new PDLModSetEq(new PDLAllPos(), 3, 0));

            StringBuilder sb = new StringBuilder();

            phi.ToMSO(new FreshGen()).ToString(sb);

            System.Console.WriteLine(sb);

            var dfa = phi.GetDFA(al, solver);

            var test = solver.Convert(@"^(((a|b){2})*|((a|b){3})*)$");

            //string file = "../../../TestPDL/DotFiles/div2or3";

            //solver.SaveAsDot(dfa, "aut", file);

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
        }
Beispiel #3
0
        public void DileepTest2()
        {
            PDLPred phi = new PDLOr(new PDLIntGeq(new PDLIndicesOf("a"), 3), new PDLIntGeq(new PDLIndicesOf("b"), 3));

            var solver = new CharSetSolver(BitWidth.BV64);

            Console.WriteLine(phi.ToMSO());

            var al = new HashSet <char>(new char[] { 'a', 'b' });

            Stopwatch sw = new Stopwatch();

            sw.Start();
            var dfa = phi.GetDFA(al, solver);

            sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);


            //PDLPred synthPhi = null;
            //StringBuilder sb = new StringBuilder();

            //var count = 0;
            //foreach (var phi1 in Enumeration.SynthesizePDL(al, dfa, solver, sb, 1000))
            //{
            //    synthPhi = phi1;
            //    count++;
            //    if (count > 30)
            //        break;
            //}

            //Console.WriteLine(sb);
        }
        public void Test15() // length is either divisible by 2 or 3
        {
            PDLPred phi = new PDLOr(new PDLModSetEq(new PDLAllPos(), 2, 0), new PDLModSetEq(new PDLAllPos(), 3, 0));

            PrintDFA(phi, "Test15", new List <char> {
                'a', 'b'
            });
        }
        public void Test32() // Even # of a's or exactly 2 b's
        {
            PDLPred phi = new PDLOr(new PDLModSetEq(new PDLIndicesOf("a"), 2, 0), new PDLIntEq(new PDLIndicesOf("b"), 2));

            PrintDFA(phi, "Test32", new List <char> {
                'a', 'b'
            });
        }
        public void Test40() // starts with a ends with b, or b
        {
            PDLPred phi = new PDLOr(new PDLAnd(new PDLStartsWith("a"), new PDLEndsWith("b")), new PDLIsString("b"));

            PrintDFA(phi, "Test40", new List <char> {
                'a', 'b'
            });
        }
        public void Test31() // Starts with a and odd length, or starts with b and even length
        {
            PDLPred phi = new PDLOr(new PDLAnd(new PDLStartsWith("a"), new PDLModSetEq(new PDLAllPos(), 2, 1)),
                                    new PDLAnd(new PDLStartsWith("b"), new PDLModSetEq(new PDLAllPos(), 2, 0)));

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

            PDLPred phi = new PDLOr(new PDLModSetEq(new PDLAllPos(), 2, 0), new PDLModSetEq(new PDLAllPos(), 3, 0));


            StringBuilder sb = new StringBuilder();

            List <Pair <int, Pair <PDLPred, long> > > pairs = SynthTimer(phi, al, sb);

            Output(sb, "div2or3");
        }
        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 static Testcase createTestFormula7()
 {
     PDLPred language = new PDLOr(new PDLStartsWith("01"), new PDLEndsWith("01"));
     return new Testcase(7,createAlphabet10(), language);
 }
 public static Testcase createTestcase6()
 {
     PDLPred language = new PDLOr(new PDLStartsWith("01"), new PDLEndsWith("01"));
     return new Testcase(6,oneZeroAlphabet, language);
 }
        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 Test15() // length is either divisible by 2 or 3
 {
     PDLPred phi = new PDLOr(new PDLModSetEq(new PDLAllPos(), 2, 0), new PDLModSetEq(new PDLAllPos(), 3, 0));
     PrintDFA(phi, "Test15", new List<char> { 'a', 'b' });
 }
        public void Test31() // Starts with a and odd length, or starts with b and even length
        {
            PDLPred phi = new PDLOr(new PDLAnd(new PDLStartsWith("a"), new PDLModSetEq(new PDLAllPos(), 2, 1)),
                new PDLAnd(new PDLStartsWith("b"), new PDLModSetEq(new PDLAllPos(), 2, 0)));

            PrintDFA(phi, "Test31", new List<char> { 'a', 'b' });
        }
 public void Test32() // Even # of a's or exactly 2 b's
 {
     PDLPred phi = new PDLOr(new PDLModSetEq(new PDLIndicesOf("a"), 2, 0), new PDLIntEq(new PDLIndicesOf("b"), 2));
     PrintDFA(phi, "Test32", new List<char> { 'a', 'b' });
 }
 public void Test40() // starts with a ends with b, or b
 {
     PDLPred phi = new PDLOr(new PDLAnd(new PDLStartsWith("a"), new PDLEndsWith("b")), new PDLIsString("b"));
     PrintDFA(phi, "Test40", new List<char> { 'a', 'b' });
 }
Beispiel #18
0
        public static Testcase createTestFormula7()
        {
            PDLPred language = new PDLOr(new PDLStartsWith("01"), new PDLEndsWith("01"));

            return(new Testcase(7, createAlphabet10(), language));
        }
        public void div2or3()
        {
            var solver = new CharSetSolver(BitWidth.BV64);
            List<char> alph = new List<char> { 'a', 'b' };
            HashSet<char> al = new HashSet<char>(alph);

            PDLPred phi = new PDLOr(new PDLModSetEq(new PDLAllPos(), 2, 0), new PDLModSetEq(new PDLAllPos(), 3, 0));

            StringBuilder sb = new StringBuilder();

            phi.ToMSO(new FreshGen()).ToString(sb);

            System.Console.WriteLine(sb);

            var dfa = phi.GetDFA(al, solver);

            var test = solver.Convert(@"^(((a|b){2})*|((a|b){3})*)$");

            //string file = "../../../TestPDL/DotFiles/div2or3";

            //solver.SaveAsDot(dfa, "aut", file);

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
        }
Beispiel #20
0
        public static Testcase createTestcase6()
        {
            PDLPred language = new PDLOr(new PDLStartsWith("01"), new PDLEndsWith("01"));

            return(new Testcase(6, oneZeroAlphabet, language));
        }
        public void DileepTest2()
        {
            PDLPred phi = new PDLOr(new PDLIntGeq(new PDLIndicesOf("a"), 3), new PDLIntGeq(new PDLIndicesOf("b"), 3));

            var solver = new CharSetSolver(BitWidth.BV64);

            Console.WriteLine(phi.ToMSO());

            var al = new HashSet<char>(new char[]{'a','b'});

            Stopwatch sw = new Stopwatch();
            sw.Start();
            var dfa = phi.GetDFA(al, solver);
            sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);


            //PDLPred synthPhi = null;
            //StringBuilder sb = new StringBuilder();

            //var count = 0;
            //foreach (var phi1 in Enumeration.SynthesizePDL(al, dfa, solver, sb, 1000))
            //{
            //    synthPhi = phi1;
            //    count++;
            //    if (count > 30)
            //        break;
            //}

            //Console.WriteLine(sb);

        }