Ejemplo n.º 1
0
        public void evenSpacingA() //any two a's are separated by even number of symbols
        {
            var         solver = new CharSetSolver(BitWidth.BV64);
            List <char> alph   = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);

            PDLPos px = new PDLPosVar("x");
            PDLPos py = new PDLPosVar("y");

            //TODO - is it possible to consider string as type PDLvar?
            PDLPred phi = new PDLForallFO("x", new PDLForallFO("y", new PDLIf(
                                                                   new PDLAnd(new PDLAnd(new PDLPosLe(px, py), new PDLAtPos('a', px)), new PDLAtPos('a', py)),
                                                                   new PDLModSetEq(new PDLIntersect(new PDLAllPosAfter(px), new PDLAllPosBefore(py)), 2, 0))));

            StringBuilder sb = new StringBuilder();

            phi.ToString(sb);

            System.Console.WriteLine(sb);

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

            var test = solver.Convert(@"^(b*|b*ab*|b*a(bb)*ab*)$").Determinize(solver).Minimize(solver);

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

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

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
        }
Ejemplo n.º 2
0
        public void OddA()
        {
            var         solver = new CharSetSolver(BitWidth.BV64);
            List <char> alph   = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);

            PDLPred phi = new PDLForallFO("p", new PDLIf(new PDLModSetEq(
                                                             new PDLAllPosUpto(new PDLPosVar("p")), 2, 1), new PDLAtPos('a', new PDLPosVar("p"))));

            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(a|b))*a?$");

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

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

            //solver.SaveAsDot(dfa, "aut", file);
        }
        public void TestMethod2()
        {
            var solver = new CharSetSolver(BitWidth.BV64);
            List<char> alph = new List<char> { 'a', 'b' };
            HashSet<char> al = new HashSet<char>(alph);

            PDLPred phi1 = new PDLForallFO("p", new PDLIf(new PDLModSetEq(
                new PDLAllPosBefore(new PDLPosVar("p")), 2, 1), new PDLAtPos('a', new PDLPosVar("p"))));
            var dfa1 = phi1.GetDFA(al, solver);

            PDLPred phi2 = new PDLForallFO("p", new PDLIf(new PDLModSetEq(
                new PDLAllPosBefore(new PDLPosVar("p")), 2, 1), new PDLAtPos('b', new PDLPosVar("p"))));
            var dfa2 = phi2.GetDFA(al, solver);

            StringBuilder sb = new StringBuilder();
            DFAEditDistance.GetDFAOptimalEdit(dfa1, dfa2, al, solver, 3000, sb);
            Console.WriteLine(sb);
        }
Ejemplo n.º 4
0
        public void TestMethod2()
        {
            var         solver = new CharSetSolver(BitWidth.BV64);
            List <char> alph   = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);

            PDLPred phi1 = new PDLForallFO("p", new PDLIf(new PDLModSetEq(
                                                              new PDLAllPosBefore(new PDLPosVar("p")), 2, 1), new PDLAtPos('a', new PDLPosVar("p"))));
            var dfa1 = phi1.GetDFA(al, solver);

            PDLPred phi2 = new PDLForallFO("p", new PDLIf(new PDLModSetEq(
                                                              new PDLAllPosBefore(new PDLPosVar("p")), 2, 1), new PDLAtPos('b', new PDLPosVar("p"))));
            var dfa2 = phi2.GetDFA(al, solver);

            StringBuilder sb = new StringBuilder();

            DFAEditDistance.GetDFAOptimalEdit(dfa1, dfa2, al, solver, 3000, sb);
            Console.WriteLine(sb);
        }
Ejemplo n.º 5
0
        public void evenSpacingA() //any two a's are separated by even number of symbols
        {
            var solver = new CharSetSolver(BitWidth.BV64);
            List<char> alph = new List<char> { 'a', 'b' };
            HashSet<char> al = new HashSet<char>(alph);

            PDLPos px = new PDLPosVar("x");
            PDLPos py = new PDLPosVar("y");

            //TODO - is it possible to consider string as type PDLvar?
            PDLPred phi = new PDLForallFO("x", new PDLForallFO("y", new PDLIf(
                new PDLAnd(new PDLAnd(new PDLPosLe(px, py), new PDLAtPos('a', px)), new PDLAtPos('a', py)),
                    new PDLModSetEq(new PDLIntersect(new PDLAllPosAfter(px), new PDLAllPosBefore(py)), 2, 0))));

            StringBuilder sb = new StringBuilder();

            phi.ToString(sb);

            System.Console.WriteLine(sb);

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

            var test = solver.Convert(@"^(b*|b*ab*|b*a(bb)*ab*)$").Determinize(solver).Minimize(solver);

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

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

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
        }
Ejemplo n.º 6
0
        public void OddA()
        {
            var solver = new CharSetSolver(BitWidth.BV64);
            List<char> alph = new List<char> { 'a', 'b' };
            HashSet<char> al = new HashSet<char>(alph);

            PDLPred phi = new PDLForallFO("p", new PDLIf(new PDLModSetEq(
                new PDLAllPosUpto(new PDLPosVar("p")), 2, 1), new PDLAtPos('a', new PDLPosVar("p"))));

            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(a|b))*a?$");

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

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

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