diff --git a/alib2elgo/src/automaton/properties/efficient/ReachableStates.h b/alib2elgo/src/automaton/properties/efficient/ReachableStates.h index 82b66de988b832c73180876f254853b958f53d08..941f33fb18f954c0c2ad2054949c32046f427b32 100644 --- a/alib2elgo/src/automaton/properties/efficient/ReachableStates.h +++ b/alib2elgo/src/automaton/properties/efficient/ReachableStates.h @@ -31,16 +31,18 @@ public: /** * Removes dead states from FSM. Melichar 2.29 */ - template < class T, class SymbolType = typename automaton::SymbolTypeOfAutomaton < T >, class StateType = typename automaton::StateTypeOfAutomaton < T > > - static ext::set<StateType> reachableStates( const T & fsm ); + template < class T > + static ext::set < typename automaton::StateTypeOfAutomaton < T > > reachableStates( const T & fsm ); template < class SymbolType, class StateType > static ext::set<StateType> reachableStates( const automaton::MultiInitialStateNFA < SymbolType, StateType > & fsm ); template < class SymbolType, class StateType > static ext::set<StateType> reachableStates( const automaton::DFA < SymbolType, StateType > & fsm ); }; -template < class T, class SymbolType, class StateType > -ext::set<StateType> ReachableStates::reachableStates( const T & fsm ) { +template < class T > +ext::set < typename automaton::StateTypeOfAutomaton < T > > ReachableStates::reachableStates( const T & fsm ) { + using StateType = typename automaton::StateTypeOfAutomaton < T >; + ext::map<StateType, ext::set<StateType>> transitions; for(const auto& transition : fsm.getTransitions()) transitions[transition.first.first].insert(transition.second.begin(), transition.second.end()); diff --git a/alib2elgo/src/automaton/properties/efficient/UsefullStates.h b/alib2elgo/src/automaton/properties/efficient/UsefullStates.h index c8be7796451db20564eaa6656a1148194a205e00..66dce4db94e31e4fc840927266fdd4f5692cb7d7 100644 --- a/alib2elgo/src/automaton/properties/efficient/UsefullStates.h +++ b/alib2elgo/src/automaton/properties/efficient/UsefullStates.h @@ -31,14 +31,16 @@ public: /** * Removes dead states from FSM. Melichar 2.32 */ - template < class T, class SymbolType = typename automaton::SymbolTypeOfAutomaton < T >, class StateType = typename automaton::StateTypeOfAutomaton < T > > - static ext::set<StateType> usefullStates( const T & fsm ); + template < class T > + static ext::set < typename automaton::StateTypeOfAutomaton < T > > usefullStates( const T & fsm ); template < class SymbolType, class StateType > static ext::set<StateType> usefullStates( const automaton::DFA < SymbolType, StateType > & fsm ); }; -template < class T, class SymbolType, class StateType > -ext::set<StateType> UsefullStates::usefullStates( const T & fsm ) { +template < class T > +ext::set < typename automaton::StateTypeOfAutomaton < T > > UsefullStates::usefullStates( const T & fsm ) { + using StateType = typename automaton::StateTypeOfAutomaton < T >; + ext::map<StateType, ext::set<StateType>> reversedTransitions; for(const auto& transition : fsm.getTransitions()) for(const StateType& to : transition.second) diff --git a/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.h b/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.h index c5f1f1749d172e68d5ea1c15c04a39ee6963a1f1..4a93bd1dd9212e257c8a5198ffa884cc525a359d 100644 --- a/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.h +++ b/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.h @@ -32,7 +32,7 @@ public: /** * Removes dead states from FSM. Melichar 2.29 */ - template<class T, class SymbolType = typename automaton::SymbolTypeOfAutomaton < T >, class StateType = typename automaton::StateTypeOfAutomaton < T > > + template < class T > static T remove( const T & automaton ); template < class SymbolType, class StateType > static automaton::DFA < SymbolType, StateType > remove( const automaton::DFA < SymbolType, StateType > & fsm ); @@ -40,8 +40,10 @@ public: static automaton::MultiInitialStateNFA < SymbolType, StateType > remove( const automaton::MultiInitialStateNFA < SymbolType, StateType > & fsm ); }; -template < class T, class SymbolType, class StateType > -T UnreachableStatesRemover::remove( const T & fsm ) { +template < class T > +T UnreachableStatesRemover::remove ( const T & fsm ) { + using StateType = typename automaton::StateTypeOfAutomaton < T >; + // 1a ext::set<StateType> Qa = automaton::properties::efficient::ReachableStates::reachableStates( fsm ); diff --git a/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.h b/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.h index e8eb8b1aa0d4ae41ae010573c1b46b74ee212d31..cb32c308598a0d9641f1dd956b4309b029e3917b 100644 --- a/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.h +++ b/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.h @@ -32,7 +32,7 @@ public: /** * Removes dead states from FSM. Melichar 2.29 */ - template<class T, class SymbolType = typename automaton::SymbolTypeOfAutomaton < T >, class StateType = typename automaton::StateTypeOfAutomaton < T > > + template < class T > static T remove( const T & automaton ); template < class SymbolType, class StateType > static automaton::DFA < SymbolType, StateType > remove( const automaton::DFA < SymbolType, StateType > & fsm ); @@ -40,8 +40,10 @@ public: static automaton::MultiInitialStateNFA < SymbolType, StateType > remove( const automaton::MultiInitialStateNFA < SymbolType, StateType > & fsm ); }; -template<class T, class SymbolType, class StateType > +template < class T > T UselessStatesRemover::remove( const T & fsm ) { + using StateType = typename automaton::StateTypeOfAutomaton < T >; + // 1. ext::set<StateType> Qu = automaton::properties::efficient::UsefullStates::usefullStates( fsm );