Skip to content
Snippets Groups Projects
Commit 963feec7 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

detect transitions from final state of turing machine

parent 45f032e5
No related branches found
No related tags found
No related merge requests found
...@@ -244,6 +244,9 @@ bool OneTapeDTM<SymbolType, StateType>::addTransition(StateType from, SymbolType ...@@ -244,6 +244,9 @@ bool OneTapeDTM<SymbolType, StateType>::addTransition(StateType from, SymbolType
throw AutomatonException("State \"" + ext::to_string ( from ) + "\" doesn't exist."); throw AutomatonException("State \"" + ext::to_string ( from ) + "\" doesn't exist.");
} }
   
if ( getFinalStates().count ( from ) )
throw AutomatonException("From state \"" + ext::to_string ( from ) + "\" is final..");
if (!getTapeAlphabet().count(input)) { if (!getTapeAlphabet().count(input)) {
throw AutomatonException("Tape symbol \"" + ext::to_string ( input ) + "\" doesn't exist."); throw AutomatonException("Tape symbol \"" + ext::to_string ( input ) + "\" doesn't exist.");
} }
...@@ -495,8 +498,16 @@ public: ...@@ -495,8 +498,16 @@ public:
return automaton.getStates ( ).count ( state ); return automaton.getStates ( ).count ( state );
} }
   
static void valid ( const automaton::OneTapeDTM<SymbolType, StateType> &, const StateType & ) { /**
//TODO final state and outgoing transitions * All states are valid as a final state of the automaton.
*
* \param automaton the tested automaton
* \param state the tested state
*/
static void valid ( const automaton::OneTapeDTM<SymbolType, StateType> & automaton, const StateType & state ) {
for ( const std::pair<const ext::pair<StateType, SymbolType>, ext::tuple<StateType, SymbolType, automaton::Shift> >& transition : automaton.getTransitions ( ) )
if ( state == transition.first.first )
throw automaton::AutomatonException("State \"" + ext::to_string ( state ) + "\" cannot be marked as final as it is source of a transition.");
} }
}; };
   
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment