diff --git a/alib2data/src/automaton/TM/OneTapeDTM.h b/alib2data/src/automaton/TM/OneTapeDTM.h index c97acb36b36147c6b1af140d3ab2f1ce4e4cc29b..2440ac075c25e5918738e73a81f2ac6b2358e17c 100644 --- a/alib2data/src/automaton/TM/OneTapeDTM.h +++ b/alib2data/src/automaton/TM/OneTapeDTM.h @@ -244,6 +244,9 @@ bool OneTapeDTM<SymbolType, StateType>::addTransition(StateType from, SymbolType 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)) { throw AutomatonException("Tape symbol \"" + ext::to_string ( input ) + "\" doesn't exist."); } @@ -495,8 +498,16 @@ public: 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."); } };