Beispiel #1
0
        public void a2b1() //atleast 2 a's and atmost one b
        {
            var         solver = new CharSetSolver(BitWidth.BV64);
            List <char> alph   = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);

            PDLPred phi = new PDLAnd(new PDLNot(new PDLIntLeq(new PDLIndicesOf("a"), 1)), new PDLIntLeq(new PDLIndicesOf("b"), 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(@"^(aa+|baa+|aba+|aa+ba*)$");

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

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

            Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
        }
Beispiel #2
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));
        }
Beispiel #3
0
        public void SameFirstLast()
        {
            var         solver = new CharSetSolver(BitWidth.BV64);
            List <char> alph   = new List <char> {
                'a', 'b'
            };
            HashSet <char> al = new HashSet <char>(alph);

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

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

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

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

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

            PDLPred phi = new PDLAnd(new PDLNot(new PDLIntLeq(new PDLIndicesOf("a"), 1)), new PDLIntLeq(new PDLIndicesOf("b"), 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(@"^(aa+|baa+|aba+|aa+ba*)$");

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

            //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));
        }
        public void SameFirstLast()
        {
            var solver = new CharSetSolver(BitWidth.BV64);
            List<char> alph = new List<char> { 'a', 'b' };
            HashSet<char> al = new HashSet<char>(alph);

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

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

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

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

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