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

simplify distinguishable states computation for DFTA

parent a4a891a7
No related branches found
No related tags found
1 merge request!102Merge jt
......@@ -110,8 +110,9 @@ template < class SymbolType, class StateType >
ext::set < ext::pair < StateType, StateType > > DistinguishableStates::distinguishable ( const automaton::DFTA < SymbolType, StateType > & fta ) {
ext::set < ext::pair < StateType, StateType > > distinguishable = initial ( fta.getStates ( ), fta.getFinalStates ( ) );
 
bool changed;
do {
ext::set < ext::pair < StateType, StateType > > distinguishable2 = distinguishable;
changed = false;
 
for ( const StateType & a : fta.getStates ( ) ) {
for ( const StateType & b : fta.getStates ( ) ) {
......@@ -126,21 +127,19 @@ ext::set < ext::pair < StateType, StateType > > DistinguishableStates::distingui
 
const auto & transition2 = fta.getTransitions ( ).find ( std::make_pair ( transition.first.first, std::move ( copy ) ) );
 
if ( transition2 == fta.getTransitions ( ).end ( ) || distinguishable2.count ( ext::make_pair ( transition.second, transition2->second ) ) ) {
if ( transition2 == fta.getTransitions ( ).end ( ) || distinguishable.count ( ext::make_pair ( transition.second, transition2->second ) ) ) {
// end up in dead state - dead state is be distinguishable from every other state OR
// end up in distinguishable states
distinguishable.insert ( ext::make_pair ( a, b ) );
distinguishable.insert ( ext::make_pair ( b, a ) );
changed = true;
}
}
}
}
}
}
if ( distinguishable == distinguishable2 )
break;
} while ( true );
} while ( changed );
 
return distinguishable;
}
......
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