예제 #1
0
        public static NDFA <String> getTestNDFA52()
        {
            char[]        alphabet = { 'a', 'b' };
            NDFA <string> m        = new NDFA <string>(alphabet);

            m.addTransition(new Transition <String>("A", 'a', "C"));
            m.addTransition(new Transition <String>("A", 'b', "C"));
            m.addTransition(new Transition <String>("A", 'b', "B"));

            m.addTransition(new Transition <String>("B", '$', "C"));
            m.addTransition(new Transition <String>("B", 'b', "C"));

            m.addTransition(new Transition <String>("C", 'a', "D"));
            m.addTransition(new Transition <String>("C", 'b', "D"));

            m.addTransition(new Transition <String>("D", 'a', "C"));
            m.addTransition(new Transition <String>("D", 'a', "B"));

            m.addTransition(new Transition <String>("C", 'a', "E"));
            m.addTransition(new Transition <String>("E", '$', "D"));
            m.addTransition(new Transition <String>("E", 'b', "E"));

            m.addStartState("A");
            m.addFinalState("C");
            m.addFinalState("E");

            return(m);
        }
예제 #2
0
        public static NDFA <String> getExample1()
        {
            char[]        alphabet = { 'a', 'b' };
            NDFA <String> m        = new NDFA <String>(alphabet);

            m.addTransition(new Transition <String>("q0", '$', "q1"));
            m.addTransition(new Transition <String>("q0", '$', "q2"));

            m.addTransition(new Transition <String>("q1", 'b', "q3"));
            m.addTransition(new Transition <String>("q1", '$', "q5"));
            m.addTransition(new Transition <String>("q3", 'b', "q4"));

            m.addTransition(new Transition <String>("q2", 'a', "q5"));
            m.addTransition(new Transition <String>("q2", '$', "q6"));
            m.addTransition(new Transition <String>("q5", 'a', "q6"));

            m.addTransition(new Transition <String>("q4", '$', "q7"));
            m.addTransition(new Transition <String>("q6", '$', "q7"));

            // only on start state in a dfa:
            m.addStartState("q0");

            // two final states:
            m.addFinalState("q7");
            m.addFinalState("q3");

            return(m);
        }
예제 #3
0
        public static DFA <String> getTestNDFA00()
        {
            char[]        alphabet = { 'a', 'b' };
            NDFA <string> m        = new NDFA <string>(alphabet);

            m.addTransition(new Transition <string>("0", '$', "1"));
            m.addTransition(new Transition <string>("0", '$', "7"));

            m.addTransition(new Transition <string>("1", '$', "2"));
            m.addTransition(new Transition <string>("1", '$', "4"));

            m.addTransition(new Transition <string>("2", 'a', "3"));

            m.addTransition(new Transition <string>("3", '$', "6"));

            m.addTransition(new Transition <string>("4", 'b', "5"));

            m.addTransition(new Transition <string>("5", '$', "6"));

            m.addTransition(new Transition <string>("6", '$', "7"));
            m.addTransition(new Transition <string>("6", '$', "1"));

            m.addTransition(new Transition <string>("7", 'a', "8"));

            m.addTransition(new Transition <string>("8", 'b', "9"));

            m.addTransition(new Transition <string>("9", 'b', "10"));

            m.addStartState("0");
            m.addFinalState("10");

            DFA <string> epsilonDFA = NDFA <string> .toDFA(m);

            return(epsilonDFA);
        }
예제 #4
0
        public static NDFA <String> getMinimizeExample()
        {
            char[]        alphabet = { 'a', 'b' };
            NDFA <String> m        = new NDFA <String>(alphabet);

            m.addTransition(new Transition <String>("q0", 'a', "q1"));
            m.addTransition(new Transition <String>("q0", 'b', "q2"));

            m.addTransition(new Transition <String>("q1", 'a', "q0"));
            m.addTransition(new Transition <String>("q1", 'b'));

            m.addTransition(new Transition <String>("q2", 'a', "q0"));
            m.addTransition(new Transition <String>("q2", 'b'));

            // only one start state in a dfa:
            m.addStartState("q0");

            // two final states:
            m.addFinalState("q1");
            m.addFinalState("q2");

            return(m);
        }