Example #1
0
        public void EndsWith()
        {
            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 PDLEndsWith("abc");

            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$");

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

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

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
        }
Example #2
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 EndsWith()
        {
            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 PDLEndsWith("abc");

            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$");

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

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

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

        }
        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>()));


        }