public void Feedback2()
        {
            CharSetSolver solver = new CharSetSolver(BitWidth.BV64);
            var al = new HashSet<char>(new char[] { 'a', 'b' });

            var dfa1 = new PDLModSetEq(new PDLIndicesOf("a"), 2, 1).GetDFA(al, solver);


            var a = solver.MkCharConstraint(false, 'a');
            var b = solver.MkCharConstraint(false, 'b');
            var movescorrect = new List<Move<BDD>>();

            movescorrect.Add(new Move<BDD>(0, 0, b));
            movescorrect.Add(new Move<BDD>(0, 1, a));
            movescorrect.Add(new Move<BDD>(1, 0, a));
            movescorrect.Add(new Move<BDD>(1, 0, b));

            var dfa2 = Automaton<BDD>.Create(0, new int[] { 1 }, movescorrect);

            var v4 = DFAGrading.GetGrade(dfa1, dfa2, al, solver, timeout, 10, FeedbackLevel.Hint);
            Console.WriteLine("Grade: {0}", v4.First);
            foreach (var v in v4.Second)
                Console.WriteLine("Feedback: {0}", v);


        }
예제 #2
0
        public void Feedback2()
        {
            CharSetSolver solver = new CharSetSolver(BitWidth.BV64);
            var           al     = new HashSet <char>(new char[] { 'a', 'b' });

            var dfa1 = new PDLModSetEq(new PDLIndicesOf("a"), 2, 1).GetDFA(al, solver);


            var a            = solver.MkCharConstraint(false, 'a');
            var b            = solver.MkCharConstraint(false, 'b');
            var movescorrect = new List <Move <BDD> >();

            movescorrect.Add(new Move <BDD>(0, 0, b));
            movescorrect.Add(new Move <BDD>(0, 1, a));
            movescorrect.Add(new Move <BDD>(1, 0, a));
            movescorrect.Add(new Move <BDD>(1, 0, b));

            var dfa2 = Automaton <BDD> .Create(0, new int[] { 1 }, movescorrect);

            var v4 = DFAGrading.GetGrade(dfa1, dfa2, al, solver, timeout, 10, FeedbackLevel.Hint);

            Console.WriteLine("Grade: {0}", v4.First);
            foreach (var v in v4.Second)
            {
                Console.WriteLine("Feedback: {0}", v);
            }
        }
        public void DileepTest1()
        {
            PDLEnumerator pdlEnumerator = new PDLEnumerator();
            var solver = new CharSetSolver(BitWidth.BV64);
            List<char> alph = new List<char> { 'a', 'b' };
            HashSet<char> al = new HashSet<char>(alph);

            PDLPred phi = new PDLModSetEq(new PDLIndicesOf("a"), 2, 1);
            phi = new PDLAnd(new PDLStartsWith("a"), phi);
            var dfa1 = phi.GetDFA(al, solver);

            var a = solver.MkCharConstraint(false, 'a');
            var b = solver.MkCharConstraint(false, 'b');
            var moves = new List<Move<BDD>>();

            moves.Add(new Move<BDD>(0, 0, a));
            moves.Add(new Move<BDD>(0, 5, a));
            moves.Add(new Move<BDD>(5, 0, a));
            moves.Add(new Move<BDD>(5, 5, b));

            var dfa2 = Automaton<BDD>.Create(0, new int[] { 5 }, moves);
            var feedbackGrade = DFAGrading.GetGrade(dfa1, dfa2, al, solver, timeout, 10, FeedbackLevel.Solution, true, false, false);
            var feedString = "<ul>";
            foreach (var feed in feedbackGrade.Second)
                feedString += string.Format("<li>{0}</li>", feed);
            feedString += "</ul>";

            Console.Write( string.Format("<div>Grade: {0} <br /> Feedback: {1}</div>", feedbackGrade.First, feedString));
        }
예제 #4
0
        public void mod5()
        {
            var         solver = new CharSetSolver(BitWidth.BV64);
            List <char> alph   = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);


            PDLPred phi = new PDLModSetEq(new PDLIndicesOf("a"), 5, 3);

            StringBuilder sb = new StringBuilder();

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

            System.Console.WriteLine(sb);

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

            var test = solver.Convert(@"^((b*ab*){5})*(b*ab*){3}$").Determinize(solver).Minimize(solver);

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

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


            //solver.SaveAsDot(test, "aut", file+"t");

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
        }
        public void Test5() // all string of odd length
        {
            PDLPred phi = new PDLModSetEq(new PDLAllPos(), 2, 1);

            PrintDFA(phi, "Test5", new List <char> {
                'a', 'b'
            });
        }
        public void Test6() // all strings of length divisible by 3
        {
            PDLPred phi = new PDLModSetEq(new PDLAllPos(), 3, 0);

            PrintDFA(phi, "Test6", new List <char> {
                'a', 'b'
            });
        }
        public void Test7() // all strings of length % 4 = 3
        {
            PDLPred phi = new PDLModSetEq(new PDLAllPos(), 4, 3);

            PrintDFA(phi, "Test7", new List <char> {
                'a', 'b'
            });
        }
        public void Test8() // all string of length % 5 =3
        {
            PDLPred phi = new PDLModSetEq(new PDLAllPos(), 5, 3);

            PrintDFA(phi, "Test8", new List <char> {
                'a', 'b'
            });
        }
        public void Test9() // length % 6 = 3
        {
            PDLPred phi = new PDLModSetEq(new PDLAllPos(), 6, 3);

            PrintDFA(phi, "Test9", new List <char> {
                'a', 'b'
            });
        }
        public void Test29() // Contains a 'a', and # of 'b's appearing after the first a is odd
        {
            PDLPos  x   = new PDLPosVar("x");
            PDLPos  p   = new PDLPosVar("p");
            PDLPred phi = new PDLModSetEq(new PDLIntersect(new PDLIndicesOf("b"),
                                                           new PDLPredSet("p", new PDLExistsFO("x", new PDLAnd(new PDLAtPos('a', x),
                                                                                                               new PDLPosLe(x, p))))), 2, 0);

            PrintDFA(phi, "Test29", new List <char> {
                'a', 'b'
            });
        }
예제 #11
0
        public void OddAfterFirstA()
        {
            PDLPred phi = new PDLModSetEq(new PDLIntersect(new PDLIndicesOf("b"), new PDLAllPosAfter(new PDLFirstOcc("a"))), 2, 1);

            var solver = new CharSetSolver(BitWidth.BV64);
            var alph   = new List <char> {
                'a', 'b'
            };
            var al = new HashSet <char>(alph);

            var dfa = phi.GetDFA(al, solver);
            //string file = "../../../TestPDL/DotFiles/OddAfterFirstA";
            //solver.SaveAsDot(dfa, "aut", file);
        }
        public void Feedback1()
        {
            CharSetSolver solver = new CharSetSolver(BitWidth.BV64);
            var al = new HashSet<char>(new char[] { 'a', 'b' });

            var dfa1 = new PDLModSetEq(new PDLIndicesOf("a"), 2, 0).GetDFA(al,solver);
            var dfa2 = new PDLModSetEq(new PDLIndicesOf("a"), 2, 1).GetDFA(al, solver);

            var v4 = DFAGrading.GetGrade(dfa2, dfa1, al, solver, timeout, 10, FeedbackLevel.Hint);
            Console.WriteLine("Grade: {0}", v4.First);
            foreach(var v in v4.Second)
                Console.WriteLine("Feedback: {0}", v);


        }
        public void mod2()
        {
            List <char> alph = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);

            PDLPred phi = new PDLModSetEq(new PDLAllPos(), 2, 1);


            StringBuilder sb = new StringBuilder();

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

            Output(sb, "mod2");
        }
예제 #14
0
        public void Feedback1()
        {
            CharSetSolver solver = new CharSetSolver(BitWidth.BV64);
            var           al     = new HashSet <char>(new char[] { 'a', 'b' });

            var dfa1 = new PDLModSetEq(new PDLIndicesOf("a"), 2, 0).GetDFA(al, solver);
            var dfa2 = new PDLModSetEq(new PDLIndicesOf("a"), 2, 1).GetDFA(al, solver);

            var v4 = DFAGrading.GetGrade(dfa2, dfa1, al, solver, timeout, 10, FeedbackLevel.Hint);

            Console.WriteLine("Grade: {0}", v4.First);
            foreach (var v in v4.Second)
            {
                Console.WriteLine("Feedback: {0}", v);
            }
        }
        public void TestMethod1()
        {
            var solver = new CharSetSolver(BitWidth.BV64);
            List<char> alph = new List<char> { 'a', 'b' };
            HashSet<char> al = new HashSet<char>(alph);

            PDLPred phi1 = new PDLContains("b");
            var dfa1 = phi1.GetDFA(al, solver);

            PDLPred phi2 = new PDLModSetEq(new PDLPredSet("x", new PDLAtPos('b', new PDLPosVar("x"))), 2, 1);
            var dfa2 = phi2.GetDFA(al, solver);

            StringBuilder sb = new StringBuilder();
            DFAEditDistance.GetDFAOptimalEdit(dfa1, dfa2, al, solver, 3000, sb);
            Console.WriteLine(sb);
        }
예제 #16
0
        public void TestMethod1()
        {
            var         solver = new CharSetSolver(BitWidth.BV64);
            List <char> alph   = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);

            PDLPred phi1 = new PDLContains("b");
            var     dfa1 = phi1.GetDFA(al, solver);

            PDLPred phi2 = new PDLModSetEq(new PDLPredSet("x", new PDLAtPos('b', new PDLPosVar("x"))), 2, 1);
            var     dfa2 = phi2.GetDFA(al, solver);

            StringBuilder sb = new StringBuilder();

            DFAEditDistance.GetDFAOptimalEdit(dfa1, dfa2, al, solver, 3000, sb);
            Console.WriteLine(sb);
        }
예제 #17
0
        public void mod6()
        {
            var         solver = new CharSetSolver(BitWidth.BV64);
            List <char> alph   = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);


            PDLPred phi = new PDLModSetEq(new PDLAllPos(), 6, 3);

            StringBuilder sb = new StringBuilder();

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

            System.Console.WriteLine(sb);

            Stopwatch sw = new Stopwatch();

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

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

            //Stopwatch sw1 = new Stopwatch();
            //sw1.Start();
            //var dfa1 = phi.GetDFA(al, solver);
            //sw1.Stop();
            //Console.WriteLine(sw1.ElapsedMilliseconds);

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

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

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


            Console.Write(phi.ToMSO().ToString());
            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
        }
예제 #18
0
        public void DileepTest1()
        {
            PDLEnumerator pdlEnumerator = new PDLEnumerator();
            var           solver        = new CharSetSolver(BitWidth.BV64);
            List <char>   alph          = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);

            PDLPred phi = new PDLModSetEq(new PDLIndicesOf("a"), 2, 1);

            phi = new PDLAnd(new PDLStartsWith("a"), phi);
            var dfa1 = phi.GetDFA(al, solver);

            var a     = solver.MkCharConstraint(false, 'a');
            var b     = solver.MkCharConstraint(false, 'b');
            var moves = new List <Move <BDD> >();

            moves.Add(new Move <BDD>(0, 0, a));
            moves.Add(new Move <BDD>(0, 5, a));
            moves.Add(new Move <BDD>(5, 0, a));
            moves.Add(new Move <BDD>(5, 5, b));

            var dfa2 = Automaton <BDD> .Create(0, new int[] { 5 }, moves);

            var feedbackGrade = DFAGrading.GetGrade(dfa1, dfa2, al, solver, timeout, 10, FeedbackLevel.Solution, true, false, false);
            var feedString    = "<ul>";

            foreach (var feed in feedbackGrade.Second)
            {
                feedString += string.Format("<li>{0}</li>", feed);
            }
            feedString += "</ul>";

            Console.Write(string.Format("<div>Grade: {0} <br /> Feedback: {1}</div>", feedbackGrade.First, feedString));
        }
예제 #19
0
        public static Testcase createTestcase19()
        {
            PDLPred language = new PDLModSetEq(new PDLIndicesOf("0"), 5, 0);

            return(new Testcase(19, oneZeroAlphabet, language));
        }
        public void Test29() // Contains a 'a', and # of 'b's appearing after the first a is odd
        {
            PDLPos x = new PDLPosVar("x");
            PDLPos p = new PDLPosVar("p");
            PDLPred phi = new PDLModSetEq(new PDLIntersect(new PDLIndicesOf("b"),
                                            new PDLPredSet("p", new PDLExistsFO("x", new PDLAnd(new PDLAtPos('a', x),
                                                new PDLPosLe(x, p))))), 2, 0);

            PrintDFA(phi, "Test29", new List<char> { 'a', 'b' });
        }
 public void Test5() // all string of odd length
 {
     PDLPred phi = new PDLModSetEq(new PDLAllPos(), 2, 1);
     PrintDFA(phi, "Test5", new List<char> { 'a', 'b' });
 }
 public void Test6() // all strings of length divisible by 3
 {
     PDLPred phi = new PDLModSetEq(new PDLAllPos(), 3, 0);
     PrintDFA(phi, "Test6", new List<char> { 'a', 'b' });
 }
 public void Test7() // all strings of length % 4 = 3
 {
     PDLPred phi = new PDLModSetEq(new PDLAllPos(), 4, 3);
     PrintDFA(phi, "Test7", new List<char> { 'a', 'b' });
 }
예제 #24
0
        public static Testcase createTestFormula20()
        {
            PDLPred language = new PDLModSetEq(new PDLIndicesOf("0"), 5, 0);

            return(new Testcase(20, createAlphabet10(), language));
        }
 public void Test8() // all string of length % 5 =3
 {
     PDLPred phi = new PDLModSetEq(new PDLAllPos(), 5, 3);
     PrintDFA(phi, "Test8", new List<char> { 'a', 'b' });
 }
 public static Testcase createTestFormula20()
 {
     PDLPred language = new PDLModSetEq(new PDLIndicesOf("0"), 5, 0);
     return new Testcase(20,createAlphabet10(), language);
 }
 public static Testcase createTestcase19()
 {
     PDLPred language = new PDLModSetEq(new PDLIndicesOf("0"), 5, 0);
     return new Testcase(19,oneZeroAlphabet, language);
 }
 public void Test9() // length % 6 = 3
 {
     PDLPred phi = new PDLModSetEq(new PDLAllPos(), 6, 3);
     PrintDFA(phi, "Test9", new List<char> { 'a', 'b' });
 }
예제 #29
0
        public void mod5()
        {
            var solver = new CharSetSolver(BitWidth.BV64);
            List<char> alph = new List<char> { 'a', 'b' };
            HashSet<char> al = new HashSet<char>(alph);


            PDLPred phi = new PDLModSetEq(new PDLIndicesOf("a"), 5, 3);

            StringBuilder sb = new StringBuilder();

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

            System.Console.WriteLine(sb);

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

            var test = solver.Convert(@"^((b*ab*){5})*(b*ab*){3}$").Determinize(solver).Minimize(solver);

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

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


            //solver.SaveAsDot(test, "aut", file+"t");

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));            

            

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


            PDLPred phi = new PDLModSetEq(new PDLAllPos(), 6, 3);

            StringBuilder sb = new StringBuilder();

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

            System.Console.WriteLine(sb);

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

            //Stopwatch sw1 = new Stopwatch();
            //sw1.Start();
            //var dfa1 = phi.GetDFA(al, solver);
            //sw1.Stop();
            //Console.WriteLine(sw1.ElapsedMilliseconds);

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

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

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


            Console.Write(phi.ToMSO().ToString());
            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
        }
예제 #31
0
        public void OddAfterFirstA()
        {
            PDLPred phi = new PDLModSetEq(new PDLIntersect(new PDLIndicesOf("b"), new PDLAllPosAfter(new PDLFirstOcc("a"))), 2, 1);

            var solver = new CharSetSolver(BitWidth.BV64);
            var alph = new List<char> { 'a', 'b' };
            var al = new HashSet<char>(alph);

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


        }