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

            //new PDL

            PDLPred phi1 = new PDLNot(new PDLIntLeq(new PDLIndicesOf("aa"), 0));
            PDLPred phi2 = (new PDLBelongs(new PDLPredecessor(new PDLLast()), new PDLIndicesOf("ab")));
            //PDLpred phi2 = new PDLAnd(new PDLatPos('a', new PDLprev(new PDLlast())), new PDLatPos('b', new PDLlast()));
            PDLPred phi = new PDLAnd(phi1, new PDLNot(phi2));
            //new PDLAnd(new PDLatPos('a', new PDLprev(new PDLlast())), new PDLatPos('b', new PDLlast())));

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

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

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

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
        }
Exemple #2
0
        public void abcSubStr()
        {
            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 PDLNot(new PDLIntEq(new PDLIndicesOf("abc"), 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-c]*abc[a-c]*$");

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

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

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
        }
        public void Test13() // abc appears as a substring
        {
            PDLPred phi = new PDLNot(new PDLIntLeq(new PDLIndicesOf("abc"), 0));

            PrintDFA(phi, "Test13", new List <char> {
                'a', 'b', 'c'
            });
        }
        public void Test16() // string containing aa and ending with ab
        {
            PDLPred phi1 = new PDLNot(new PDLIntLeq(new PDLIndicesOf("aa"), 0));
            PDLPred phi2 = new PDLAnd(new PDLAtPos('a', new PDLPredecessor(new PDLLast())), new PDLAtPos('b', new PDLLast()));
            PDLPred phi  = new PDLAnd(phi1, phi2);

            PrintDFA(phi, "Test16", new List <char> {
                'a', 'b'
            });
        }
        public void Test17() // string not containing aa but ends with ab
        {
            PDLPred phi1 = new PDLNot(new PDLIntLeq(new PDLIndicesOf("aa"), 0));
            PDLPred phi2 = (new PDLBelongs(new PDLPredecessor(new PDLLast()), new PDLIndicesOf("ab")));
            PDLPred phi  = new PDLAnd(phi1, new PDLNot(phi2));

            PrintDFA(phi, "Test17", new List <char> {
                'a', 'b'
            });
        }
        public void abcSubStr()
        {
            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 PDLNot(new PDLIntLeq(new PDLIndicesOf("abc"), 0));


            StringBuilder sb = new StringBuilder();

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

            Output(sb, "abcSubStr");
        }
        public void notLength1()
        {
            var         solver = new CharSetSolver(BitWidth.BV64);
            List <char> alph   = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);

            PDLPred phi = new PDLNot(new PDLIntEq(new PDLAllPos(), 1));


            StringBuilder sb = new StringBuilder();

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

            Output(sb, "notLength1");
        }
Exemple #8
0
        public static Testcase createTestcase4()
        {
            PDLPos  lastMinusFour     = posMinusN(new PDLLast(), 4);
            PDLPred xLeqLastMinusFour = new PDLPosLeq(new PDLPosVar("x"), lastMinusFour);

            PDLPred xLeqY            = new PDLPosLeq(new PDLPosVar("x"), new PDLPosVar("y"));
            PDLPred xLeqZ            = new PDLPosLeq(new PDLPosVar("x"), new PDLPosVar("z"));
            PDLPred yLeqXPlusFour    = new PDLPosLeq(new PDLPosVar("y"), posPlusN(new PDLPosVar("x"), 4));
            PDLPred zLeqXPlusFour    = new PDLPosLeq(new PDLPosVar("z"), posPlusN(new PDLPosVar("x"), 4));
            PDLPred yNeqZ            = new PDLNot(new PDLPosEq(new PDLPosVar("y"), new PDLPosVar("z")));
            PDLPred zeroAtY          = new PDLAtPos('0', new PDLPosVar("y"));
            PDLPred zeroAtZ          = new PDLAtPos('0', new PDLPosVar("z"));
            PDLPred consequence      = new PDLAnd(xLeqY, new PDLAnd(xLeqZ, new PDLAnd(yLeqXPlusFour, new PDLAnd(zLeqXPlusFour, new PDLAnd(yNeqZ, new PDLAnd(zeroAtY, zeroAtZ))))));
            PDLPred quantConsequence = new PDLExistsFO("y", new PDLExistsFO("z", consequence));

            PDLPred language = new PDLForallFO("x", new PDLIf(xLeqLastMinusFour, quantConsequence));

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

            //new PDL

            PDLPred phi1 = new PDLNot(new PDLIntLeq(new PDLIndicesOf("aa"), 0));
            PDLPred phi2 = new PDLAnd(new PDLAtPos('a', new PDLPredecessor(new PDLLast())), new PDLAtPos('b', new PDLLast()));
            PDLPred phi  = new PDLAnd(phi1, phi2);


            StringBuilder sb = new StringBuilder();

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

            Output(sb, "contains_aa_end_ab");
        }
Exemple #10
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>()));
        }
        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>()));


        }
 public void Test13() // abc appears as a substring
 {
     PDLPred phi = new PDLNot(new PDLIntLeq(new PDLIndicesOf("abc"), 0));
     PrintDFA(phi, "Test13", new List<char> { 'a', 'b', 'c' });
 }
        public static Testcase createTestFormula5()
        {
            PDLPos lastMinusFour = posMinusN(new PDLLast(), 4);
            PDLPred xLeqLastMinusFour = new PDLPosLeq(new PDLPosVar("x"), lastMinusFour);

            PDLPred xLeqY = new PDLPosLeq(new PDLPosVar("x"), new PDLPosVar("y"));
            PDLPred xLeqZ = new PDLPosLeq(new PDLPosVar("x"), new PDLPosVar("z"));
            PDLPred yLeqXPlusFour = new PDLPosLeq(new PDLPosVar("y"), posPlusN(new PDLPosVar("x"), 4));
            PDLPred zLeqXPlusFour = new PDLPosLeq(new PDLPosVar("z"), posPlusN(new PDLPosVar("x"), 4));
            PDLPred yNeqZ = new PDLNot(new PDLPosEq(new PDLPosVar("y"), new PDLPosVar("z")));
            PDLPred zeroAtY = new PDLAtPos('0', new PDLPosVar("y"));
            PDLPred zeroAtZ = new PDLAtPos('0', new PDLPosVar("z"));
            PDLPred consequence = new PDLAnd(xLeqY, new PDLAnd(xLeqZ, new PDLAnd(yLeqXPlusFour, new PDLAnd(zLeqXPlusFour, new PDLAnd(yNeqZ, new PDLAnd(zeroAtY, zeroAtZ))))));
            PDLPred quantConsequence = new PDLExistsFO("y", new PDLExistsFO("z", consequence));

            PDLPred language = new PDLForallFO("x", new PDLIf(xLeqLastMinusFour, quantConsequence));
            return new Testcase(5,createAlphabet10(), language);
        }
        public void Test16() // string containing aa and ending with ab
        {
            PDLPred phi1 = new PDLNot(new PDLIntLeq(new PDLIndicesOf("aa"), 0));
            PDLPred phi2 = new PDLAnd(new PDLAtPos('a', new PDLPredecessor(new PDLLast())), new PDLAtPos('b', new PDLLast()));
            PDLPred phi = new PDLAnd(phi1, phi2);

            PrintDFA(phi, "Test16", new List<char> { 'a', 'b' });
        }
        public void Test17() // string not containing aa but ends with ab
        {
            PDLPred phi1 = new PDLNot(new PDLIntLeq(new PDLIndicesOf("aa"), 0));
            PDLPred phi2 = (new PDLBelongs(new PDLPredecessor(new PDLLast()), new PDLIndicesOf("ab")));
            PDLPred phi = new PDLAnd(phi1, new PDLNot(phi2));

            PrintDFA(phi, "Test17", new List<char> { 'a', 'b' });
        }
        public void abcSubStr()
        {
            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 PDLNot(new PDLIntEq(new PDLIndicesOf("abc"), 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-c]*abc[a-c]*$");

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

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

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

            //new PDL

            PDLPred phi1 = new PDLNot(new PDLIntLeq(new PDLIndicesOf("aa"), 0));
            PDLPred phi2 = (new PDLBelongs(new PDLPredecessor(new PDLLast()), new PDLIndicesOf("ab")));
            //PDLpred phi2 = new PDLAnd(new PDLatPos('a', new PDLprev(new PDLlast())), new PDLatPos('b', new PDLlast()));
            PDLPred phi = new PDLAnd(phi1, new PDLNot(phi2));
            //new PDLAnd(new PDLatPos('a', new PDLprev(new PDLlast())), new PDLatPos('b', new PDLlast())));

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

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

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

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