13#include <unordered_set>
32 template <
class LTS_TYPE>
48 for(
const transition& t: aut.get_transitions())
50 if (aut.is_tau(aut.apply_hidden_label_map(t.label())))
70 for(
const transition& t: aut.get_transitions())
72 if (aut.is_tau(aut.apply_hidden_label_map(t.label())))
126template <
class LTS_TYPE>
185 bool in_same_class(
const std::size_t s,
const std::size_t t)
const;
201 std::vector < bool >& visited);
204 std::vector < bool >& visited);
209template <
class LTS_TYPE>
212 block_index_of_a_state(aut.num_states(),0),
213 equivalence_class_index(0)
215 mCRL2log(
log::debug) <<
"Tau loop (SCC) partitioner created for " << l.num_states() <<
" states and " <<
216 l.num_transitions() <<
" transitions" << std::endl;
221 std::vector<bool> visited(
aut.num_states(),
false);
232 for (std::vector < state_type >::reverse_iterator i=
dfsn2state.rbegin();
247template <
class LTS_TYPE>
278 t.set_from(block_index_of_a_state[t.from()]);
279 t.set_label(aut.apply_hidden_label_map(t.label()));
280 t.set_to(block_index_of_a_state[t.to()]);
286 constexpr std::size_t non_existent=-1;
287 std::size_t old_index=non_existent;
288 for (
const transition& t: aut.get_transitions())
290 if (!aut.is_tau(t.label()) ||
291 preserve_divergence_loops ||
294 if (old_index==non_existent)
297 aut.get_transitions()[old_index]=t;
299 else if (t!=aut.get_transitions()[old_index])
302 aut.get_transitions()[old_index]=t;
306 aut.set_num_transitions(old_index+1);
310 if (aut.has_state_info())
313 std::vector<typename LTS_TYPE::state_label_t> new_labels(num_eq_classes());
315 for(std::size_t i=aut.num_states(); i>0; )
318 const std::size_t new_index=block_index_of_a_state[i];
319 new_labels[new_index]=new_labels[new_index]+aut.state_label(i);
322 for(std::size_t i=0; i<num_eq_classes(); ++i)
324 aut.set_state_label(i,new_labels[i]);
328 aut.set_num_states(num_eq_classes());
329 aut.set_initial_state(get_eq_class(aut.initial_state()));
332template <
class LTS_TYPE>
335 return equivalence_class_index;
338template <
class LTS_TYPE>
341 return block_index_of_a_state[s];
344template <
class LTS_TYPE>
347 return get_eq_class(s)==get_eq_class(t);
352template <
class LTS_TYPE>
357 std::vector < bool >& visited)
367 group_components(tgt_src.
get_transitions()[i],equivalence_class_index,tgt_src,visited);
369 block_index_of_a_state[s]=equivalence_class_index;
372template <
class LTS_TYPE>
376 std::vector < bool >& visited)
388 dfsn2state.push_back(s);
393template <
class LTS_TYPE>
394void scc_reduce(LTS_TYPE& l,
const bool preserve_divergence_loops =
false)
size_t upperbound(const state_type s) const
indexed_sorted_vector_for_tau_transitions(const LTS_TYPE &aut, bool outgoing)
std::vector< size_t > m_indices
size_t lowerbound(const state_type s) const
const std::vector< state_type > & get_transitions() const
std::vector< state_type > m_states_with_outgoing_or_incoming_tau_transition
This class contains an scc partitioner removing inert tau loops.
std::size_t get_eq_class(const std::size_t s) const
Gives the equivalence class number of a state. The equivalence class numbers range from 0 upto (and e...
void dfs_numbering(const state_type t, const indexed_sorted_vector_for_tau_transitions< LTS_TYPE > &src_tgt, std::vector< bool > &visited)
std::size_t num_eq_classes() const
Gives the number of bisimulation equivalence classes of the LTS.
state_type equivalence_class_index
void group_components(const state_type t, const state_type equivalence_class_index, const indexed_sorted_vector_for_tau_transitions< LTS_TYPE > &src_tgt_src, std::vector< bool > &visited)
void replace_transition_system(const bool preserve_divergence_loops)
The lts for which this partioner is created is replaced by the lts modulo the calculated partition.
~scc_partitioner()=default
Destroys this partitioner.
bool in_same_class(const std::size_t s, const std::size_t t) const
Returns whether two states are in the same bisimulation equivalence class.
std::vector< state_type > block_index_of_a_state
std::vector< state_type > dfsn2state
A class containing triples, source label and target representing transitions.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
The file containing the core class for transition systems.
void sort_transitions(std::vector< transition > &transitions, const std::set< transition::size_type > &hidden_label_set, transition_sort_style ts=src_lbl_tgt)
Sorts the transitions using a sort style.
void scc_reduce(LTS_TYPE &l, const bool preserve_divergence_loops=false)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...