public void ConvertToDFA()
        {
            AutomatonFromViewModel();

            ResetStates();

            automaton = automaton.ToDFA();
            ViewModelFromAutomaton();
        }
Beispiel #2
0
        private static void NFAToDFA()
        {
            var alphabet = new[] { '0', '1' };
            int statesCount = 4,
                initialIndex = 0;
            int[] acceptingIndexes = new[] { 2, 3 };
            var transitions = new[] { new Transition(0, 'ε', 2),
                                      new Transition(0, '0', 1),
                                      new Transition(1, '1', 1),
                                      new Transition(1, '1', 3),
                                      new Transition(2, 'ε', 1),
                                      new Transition(2, '0', 3),
                                      new Transition(3, '0', 2) };

            var nfa = new FiniteAutomaton(statesCount, alphabet, transitions, initialIndex, acceptingIndexes);
            var dfa = nfa.ToDFA();

            int dfaStatesCount = dfa.StatesCount;
            int dfaAcceptingsCount = dfa.AcceptingIndexes.Count();
            Debug.Assert(dfaStatesCount == 5);
            Debug.Assert(dfaAcceptingsCount == 4);
        }
Beispiel #3
0
        private static void NFAToDFA()
        {
            var alphabet     = new[] { '0', '1' };
            int statesCount  = 4,
                initialIndex = 0;

            int[] acceptingIndexes = new[] { 2, 3 };
            var   transitions      = new[] { new Transition(0, 'ε', 2),
                                             new Transition(0, '0', 1),
                                             new Transition(1, '1', 1),
                                             new Transition(1, '1', 3),
                                             new Transition(2, 'ε', 1),
                                             new Transition(2, '0', 3),
                                             new Transition(3, '0', 2) };

            var nfa = new FiniteAutomaton(statesCount, alphabet, transitions, initialIndex, acceptingIndexes);
            var dfa = nfa.ToDFA();

            int dfaStatesCount     = dfa.StatesCount;
            int dfaAcceptingsCount = dfa.AcceptingIndexes.Count();

            Debug.Assert(dfaStatesCount == 5);
            Debug.Assert(dfaAcceptingsCount == 4);
        }