28#ifndef MCRL2_LTS_LIBLTS_MERGE_H
29#define MCRL2_LTS_LIBLTS_MERGE_H
42template <
class LTS_TYPE>
43void merge(LTS_TYPE& l1,
const LTS_TYPE& l2)
45 const std::size_t old_nstates=l1.num_states();
46 l1.set_num_states(l1.num_states() + l2.num_states());
50 if (l1.has_state_info() && l2.has_state_info())
52 for (std::size_t i=0; i<l2.num_states(); ++i)
54 l1.add_state(l2.state_label(i));
60 l1.clear_state_labels();
67 typedef typename LTS_TYPE::action_label_t action_label_type;
68 typedef typename LTS_TYPE::labels_size_type
label_index;
69 typedef typename std::pair< typename std::map < action_label_type,label_index >::const_iterator,
bool > insert_type;
70 std::map < action_label_type,label_index > labs;
73 for (std::size_t i = 0; i < l1.num_action_labels(); ++i)
75 labs.insert(std::pair <typename LTS_TYPE::action_label_t,typename LTS_TYPE::labels_size_type>
76 (l1.action_label(i),i));
85 for (std::size_t i=0; i<l2.num_action_labels(); ++i)
87 typename LTS_TYPE::labels_size_type new_index;
88 const insert_type it=labs.insert(std::pair < action_label_type,label_index >
89 (l2.action_label(i),l1.num_action_labels()));
93 new_index=l1.add_action(l2.action_label(i));
94 if (l2.is_tau(l2.apply_hidden_label_map(i)))
96 l1.hidden_label_set().insert(new_index);
102 new_index=it.first->second;
105 if (l1.is_tau(l1.apply_hidden_label_map(new_index)) != l2.is_tau(l2.apply_hidden_label_map(i)))
108 pp(l1.action_label(l1.apply_hidden_label_map(new_index))) +
" and " +
109 pp(l2.action_label(l2.apply_hidden_label_map(i))) +
".");
112 assert(new_index==it.first->second);
117 std::vector<transition>& trans1=l1.get_transitions();
118 for (std::vector<transition>::iterator r=trans1.begin(); r!=trans1.end(); ++r)
120 r->set_label(labs[l1.action_label(r->label())]);
127 const std::vector<transition>& trans2=l2.get_transitions();
128 for (std::vector<transition>::const_iterator r=trans2.begin(); r!=trans2.end(); ++r)
131 l1.add_transition(
transition(transition_to_add.
from()+old_nstates,
132 labs[l2.action_label(transition_to_add.
label())],
133 transition_to_add.
to()+old_nstates));
A class containing triples, source label and target representing transitions.
size_type from() const
The source of the transition.
size_type label() const
The label of the transition.
size_type to() const
The target of the transition.
Standard exception class for reporting runtime errors.
Exception classes for use in libraries and tools.
The file containing the core class for transition systems.
std::string pp(const detail::lhs_t &lhs)
void merge(LTS_TYPE &l1, const LTS_TYPE &l2)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...