コード例 #1
0
        public void intEq2()
        {
            var solver = new CharSetSolver(BitWidth.BV64);

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

            PDLPred phi = new PDLIntEq(new PDLAllPos(), 2);

            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|c){2}$");

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

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

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

        }
コード例 #2
0
        public void once_aaa()
        {
            var         solver = new CharSetSolver(BitWidth.BV64);
            List <char> alph   = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);

            PDLPred phi = new PDLIntEq(new PDLIndicesOf("aaa"), 1);

            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+|aab+)*aaa(b+a|b+aa)*b*$");

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

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

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
        }
コード例 #3
0
        public void intEq2()
        {
            var solver = new CharSetSolver(BitWidth.BV64);

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

            PDLPred phi = new PDLIntEq(new PDLAllPos(), 2);

            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|c){2}$");

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

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

            //solver.SaveAsDot(dfa, "aut", file);
        }
コード例 #4
0
        public void Test12() // ab appears twice
        {
            PDLPred phi = new PDLIntEq(new PDLIndicesOf("ab"), 2);

            PrintDFA(phi, "Test12", new List <char> {
                'a', 'b'
            });
        }
コード例 #5
0
        public void Test36() // does not contain bba
        {
            PDLPred phi = new PDLIntEq(new PDLIndicesOf("bba"), 0);

            PrintDFA(phi, "Test36", new List <char> {
                'a', 'b'
            });
        }
コード例 #6
0
        public void Test18() // aaa appears exactly once
        {
            PDLPred phi = new PDLIntEq(new PDLIndicesOf("aaa"), 1);

            PrintDFA(phi, "Test18", new List <char> {
                'a', 'b'
            });
        }
コード例 #7
0
        public void Test2() // length 2
        {
            PDLPred phi = new PDLIntEq(new PDLAllPos(), 2);

            PrintDFA(phi, "Test2", new List <Char> {
                'a', 'b', 'c'
            });
        }
コード例 #8
0
        public void intEq2()
        {
            List <char> alph = new List <char> {
                'a', 'b', 'c'
            };
            HashSet <char> al = new HashSet <char>(alph);

            PDLPred phi = new PDLIntEq(new PDLAllPos(), 2);

            StringBuilder sb = new StringBuilder();

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

            Output(sb, "intEq2");
        }
コード例 #9
0
        public void once_aaa()
        {
            var         solver = new CharSetSolver(BitWidth.BV64);
            List <char> alph   = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);

            PDLPred phi = new PDLIntEq(new PDLIndicesOf("aaa"), 1);


            StringBuilder sb = new StringBuilder();

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

            Output(sb, "once_aaa");
        }
コード例 #10
0
        public void abTwice()
        {
            var         solver = new CharSetSolver(BitWidth.BV64);
            List <char> alph   = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);

            PDLPred phi = new PDLIntEq(new PDLIndicesOf("ab"), 2);
            var     dfa = phi.GetDFA(al, solver);


            StringBuilder sb = new StringBuilder();

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

            Output(sb, "abTwice");
        }
コード例 #11
0
        public void checkEval()
        {
            PDLPred phi = new PDLIntEq(new PDLIndicesOf("aaa"), 1);

            System.Console.WriteLine("Exactly once aaa:");
            System.Console.WriteLine(phi.Eval("baaaabbb", new Dictionary <string, int>()));

            PDLPred phi1 = new PDLNot(new PDLIntLeq(new PDLIndicesOf("aa"), 0));
            PDLPred phi2 = (new PDLBelongs(new PDLPredecessor(new PDLLast()), new PDLIndicesOf("ab")));

            //System.Console.WriteLine("prevLast " + (new PDLprev(new PDLlast())).Eval("aaabbccab", new Dictionary<string, int>()));
            //System.Console.WriteLine("indab " + (new PDLindicesOf("ab")).Eval("aaabbccab", new Dictionary<string, int>()));


            //System.Console.WriteLine("phi2 " + phi2.Eval("aaabbccab", new Dictionary<string, int>()));

            phi = new PDLAnd(phi1, new PDLNot(phi2));
            System.Console.WriteLine("Contains aa and not end ab:");
            System.Console.WriteLine(phi.Eval("aaabbccabc", new Dictionary <string, int>()));

            phi = new PDLAnd(new PDLIf(new PDLAtPos('a', new PDLFirst()), new PDLAtPos('a', new PDLLast())),
                             new PDLIf(new PDLAtPos('b', new PDLFirst()), new PDLAtPos('b', new PDLLast())));
            System.Console.WriteLine("Same First Last:");
            System.Console.WriteLine(phi.Eval("abbba", new Dictionary <string, int>()));

            phi = new PDLExistsFO("x0", new PDLAtPos('a', new PDLPosVar("x0")));
            System.Console.WriteLine("exists a:");
            System.Console.WriteLine(phi.Eval("ab", new Dictionary <string, int>()));

            phi = new PDLEndsWith("abc");
            System.Console.WriteLine("ends with abc:");
            System.Console.WriteLine(phi.Eval("bc", new Dictionary <string, int>()));

            phi = new PDLStartsWith("abc");
            System.Console.WriteLine("starts with abc:");
            System.Console.WriteLine(phi.Eval("abcababcccabc", new Dictionary <string, int>()));
        }
コード例 #12
0
 public static Testcase createTestFormula21()
 {
     PDLPred language = new PDLIntEq(new PDLIndicesOf("101"), 0);
     return new Testcase(21, createAlphabet10(), language);
 }
コード例 #13
0
 public static Testcase createTestcase20()
 {
     PDLPred language = new PDLIntEq(new PDLIndicesOf("101"), 0);
     return new Testcase(20, oneZeroAlphabet, language);
 }
コード例 #14
0
 public void Test36() // does not contain bba
 {
     PDLPred phi = new PDLIntEq(new PDLIndicesOf("bba"), 0);
     PrintDFA(phi, "Test36", new List<char> { 'a', 'b' });
 }
コード例 #15
0
        public void checkEval()
        {
            PDLPred phi = new PDLIntEq(new PDLIndicesOf("aaa"), 1);
            System.Console.WriteLine("Exactly once aaa:");
            System.Console.WriteLine(phi.Eval("baaaabbb", new Dictionary<string, int>()));

            PDLPred phi1 = new PDLNot(new PDLIntLeq(new PDLIndicesOf("aa"), 0));
            PDLPred phi2 = (new PDLBelongs(new PDLPredecessor(new PDLLast()), new PDLIndicesOf("ab")));
            //System.Console.WriteLine("prevLast " + (new PDLprev(new PDLlast())).Eval("aaabbccab", new Dictionary<string, int>()));
            //System.Console.WriteLine("indab " + (new PDLindicesOf("ab")).Eval("aaabbccab", new Dictionary<string, int>()));


            //System.Console.WriteLine("phi2 " + phi2.Eval("aaabbccab", new Dictionary<string, int>()));

            phi = new PDLAnd(phi1, new PDLNot(phi2));
            System.Console.WriteLine("Contains aa and not end ab:");
            System.Console.WriteLine(phi.Eval("aaabbccabc", new Dictionary<string, int>()));

            phi = new PDLAnd(new PDLIf(new PDLAtPos('a', new PDLFirst()), new PDLAtPos('a', new PDLLast())),
                new PDLIf(new PDLAtPos('b', new PDLFirst()), new PDLAtPos('b', new PDLLast())));
            System.Console.WriteLine("Same First Last:");
            System.Console.WriteLine(phi.Eval("abbba", new Dictionary<string, int>()));

            phi = new PDLExistsFO("x0", new PDLAtPos('a', new PDLPosVar("x0")));
            System.Console.WriteLine("exists a:");
            System.Console.WriteLine(phi.Eval("ab", new Dictionary<string, int>()));

            phi = new PDLEndsWith("abc");
            System.Console.WriteLine("ends with abc:");
            System.Console.WriteLine(phi.Eval("bc", new Dictionary<string, int>()));

            phi = new PDLStartsWith("abc");
            System.Console.WriteLine("starts with abc:");
            System.Console.WriteLine(phi.Eval("abcababcccabc", new Dictionary<string, int>()));


        }
コード例 #16
0
        public void once_aaa()
        {
            var solver = new CharSetSolver(BitWidth.BV64);
            List<char> alph = new List<char> { 'a', 'b' };
            HashSet<char> al = new HashSet<char>(alph);

            PDLPred phi = new PDLIntEq(new PDLIndicesOf("aaa"), 1);

            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+|aab+)*aaa(b+a|b+aa)*b*$");

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

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

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
        }
コード例 #17
0
 public void Test18() // aaa appears exactly once
 {
     PDLPred phi = new PDLIntEq(new PDLIndicesOf("aaa"), 1);
     PrintDFA(phi, "Test18", new List<char> { 'a', 'b' });
 }
コード例 #18
0
 public void Test12() // ab appears twice
 {
     PDLPred phi = new PDLIntEq(new PDLIndicesOf("ab"), 2);
     PrintDFA(phi, "Test12", new List<char> { 'a', 'b' });
 }
コード例 #19
0
        public static Testcase createTestFormula21()
        {
            PDLPred language = new PDLIntEq(new PDLIndicesOf("101"), 0);

            return(new Testcase(21, createAlphabet10(), language));
        }
コード例 #20
0
        public static Testcase createTestcase20()
        {
            PDLPred language = new PDLIntEq(new PDLIndicesOf("101"), 0);

            return(new Testcase(20, oneZeroAlphabet, language));
        }
コード例 #21
0
 public void Test2() // length 2
 {
     PDLPred phi = new PDLIntEq(new PDLAllPos(), 2);
     PrintDFA(phi, "Test2", new List<Char> { 'a', 'b', 'c' });
 }