11
12
13
14
15
16
17
19#ifndef MCRL2_LTS_LTS_ALGORITHM_H
20#define MCRL2_LTS_LTS_ALGORITHM_H
22#include "mcrl2/lts/detail/liblts_bisim.h"
23#include "mcrl2/lts/detail/liblts_bisim_minimal_depth.h"
24#include "mcrl2/lts/detail/liblts_bisim_gjkw.h"
25#include "mcrl2/lts/detail/liblts_bisim_gj.h"
26#include "mcrl2/lts/detail/liblts_bisim_gj_lazy_BLC.h"
27#include "mcrl2/lts/detail/liblts_branching_bisim_minimal_depth.h"
28#include "mcrl2/lts/detail/liblts_weak_bisim.h"
29#include "mcrl2/lts/detail/liblts_add_an_action_loop.h"
30#include "mcrl2/lts/detail/liblts_ready_sim.h"
31#include "mcrl2/lts/detail/liblts_failures_refinement.h"
32#include "mcrl2/lts/detail/liblts_coupledsim.h"
33#include "mcrl2/lts/detail/liblts_impossible_futures.h"
34#include "mcrl2/lts/detail/tree_set.h"
35#include "mcrl2/lts/lts_equivalence.h"
36#include "mcrl2/lts/lts_preorder.h"
37#include "mcrl2/lts/sigref.h"
38#include "mcrl2/utilities/exception.h"
44
45
46
47
48template <
class LTS_TYPE>
49void reduce(LTS_TYPE& l, lts_equivalence eq);
52
53
54
55
56
57
58
59
60
61
62
63
64
65template <
class LTS_TYPE>
68 const lts_equivalence eq,
69 const bool generate_counter_examples =
false,
70 const std::string& counter_example_file =
std::
string(),
71 const bool structured_output =
false)
82 case lts_eq_bisim_jgkw:
84 return detail::destructive_bisimulation_compare_dnj(l1,l2,
false,
false,generate_counter_examples,counter_example_file,structured_output);
88 return detail::destructive_bisimulation_compare(l1,l2,
false,
false,generate_counter_examples,counter_example_file,structured_output);
90 case lts_eq_bisim_gjkw:
92 return detail::destructive_bisimulation_compare_gjkw(l1,l2,
false,
false,generate_counter_examples,counter_example_file,structured_output);
96 if (generate_counter_examples)
98 mCRL2log(mcrl2::log::warning) <<
"A slower partition refinement algorithm is used to generate minimal-depth counter examples.\n";
99 return detail::destructive_bisimulation_compare_minimal_depth(l1, l2, counter_example_file);
101 return detail::destructive_bisimulation_compare_gj(l1,l2,
false,
false,generate_counter_examples,counter_example_file,structured_output);
103 case lts_eq_bisim_gj:
105 return detail::destructive_bisimulation_compare_gj(l1,l2,
false,
false,generate_counter_examples,counter_example_file,structured_output);
107 case lts_eq_bisim_gj_lazy_BLC:
109 return detail::destructive_bisimulation_compare_gj_lazy_BLC(l1,l2,
false,
false,generate_counter_examples,counter_example_file,structured_output);
111 case lts_eq_branching_bisim_jgkw:
113 return detail::destructive_bisimulation_compare_dnj(l1,l2,
true,
false,generate_counter_examples,counter_example_file,structured_output);
115 case lts_eq_branching_bisim_gv:
117 return detail::destructive_bisimulation_compare(l1,l2,
true,
false,generate_counter_examples,counter_example_file,structured_output);
119 case lts_eq_branching_bisim_gjkw:
121 return detail::destructive_bisimulation_compare_gjkw(l1,l2,
true,
false,generate_counter_examples,counter_example_file,structured_output);
123 case lts_eq_branching_bisim:
125 if (generate_counter_examples)
127 mCRL2log(mcrl2::log::warning) <<
"The default branching bisimulation comparison algorithm cannot generate counter examples. A slower partition refinement algorithm (Martens/Groote 2024) is used instead.\n";
128 return detail::destructive_branching_bisimulation_compare_minimal_depth(l1, l2, counter_example_file);
130 return detail::destructive_bisimulation_compare_gj(l1,l2,
true,
false,generate_counter_examples,counter_example_file,structured_output);
132 case lts_eq_branching_bisim_gj:
134 return detail::destructive_bisimulation_compare_gj(l1,l2,
true,
false,generate_counter_examples,counter_example_file,structured_output);
136 case lts_eq_branching_bisim_gj_lazy_BLC:
138 return detail::destructive_bisimulation_compare_gj_lazy_BLC(l1,l2,
true,
false,generate_counter_examples,counter_example_file,structured_output);
140 case lts_eq_divergence_preserving_branching_bisim_jgkw:
142 return detail::destructive_bisimulation_compare_dnj(l1,l2,
true,
true,generate_counter_examples,counter_example_file,structured_output);
144 case lts_eq_divergence_preserving_branching_bisim_gv:
146 return detail::destructive_bisimulation_compare(l1,l2,
true,
true,generate_counter_examples,counter_example_file,structured_output);
148 case lts_eq_divergence_preserving_branching_bisim_gjkw:
150 return detail::destructive_bisimulation_compare_gjkw(l1,l2,
true,
true,generate_counter_examples,counter_example_file,structured_output);
152 case lts_eq_divergence_preserving_branching_bisim:
154 if (generate_counter_examples)
156 mCRL2log(mcrl2::log::warning) <<
"The default divergence-preserving branching bisimulation comparison algorithm cannot generate counter examples. Therefore the slower gv algorithm is used instead.\n";
157 return detail::destructive_bisimulation_compare(l1,l2,
true,
true,generate_counter_examples,counter_example_file,structured_output);
159 return detail::destructive_bisimulation_compare_gj(l1,l2,
true,
true,generate_counter_examples,counter_example_file,structured_output);
161 case lts_eq_divergence_preserving_branching_bisim_gj:
163 return detail::destructive_bisimulation_compare_gj(l1,l2,
true,
true,generate_counter_examples,counter_example_file,structured_output);
165 case lts_eq_divergence_preserving_branching_bisim_gj_lazy_BLC:
167 return detail::destructive_bisimulation_compare_gj_lazy_BLC(l1,l2,
true,
true,generate_counter_examples,counter_example_file,structured_output);
169 case lts_eq_weak_bisim:
171 if (generate_counter_examples)
173 mCRL2log(log::warning) <<
"Cannot generate counter examples for weak bisimulation\n";
175 return detail::destructive_weak_bisimulation_compare(l1,l2,
false);
177 case lts_eq_divergence_preserving_weak_bisim:
179 if (generate_counter_examples)
181 mCRL2log(log::warning) <<
"Cannot generate counter examples for divergence-preserving weak bisimulation\n";
183 return detail::destructive_weak_bisimulation_compare(l1,l2,
true);
187 if (generate_counter_examples)
189 mCRL2log(log::warning) <<
"Cannot generate counter examples for simulation equivalence\n";
192 std::size_t init_l2 = l2.initial_state() + l1.num_states();
196 sp.partitioning_algorithm();
198 return sp.in_same_class(l1.initial_state(),init_l2);
200 case lts_eq_ready_sim:
202 if (generate_counter_examples)
204 mCRL2log(log::warning) <<
"Cannot generate counter examples for ready-simulation equivalence\n";
207 std::size_t init_l2 = l2.initial_state() + l1.num_states();
211 rsp.partitioning_algorithm();
213 return rsp.in_same_class(l1.initial_state(),init_l2);
218 detail::bisimulation_reduce_gj(l1,
false);
222 detail::bisimulation_reduce_gj(l2,
false);
226 if (generate_counter_examples)
228 return detail::destructive_bisimulation_compare_minimal_depth(l1, l2, counter_example_file);
230 return detail::destructive_bisimulation_compare(l1, l2,
false,
false, generate_counter_examples, counter_example_file, structured_output);
232 case lts_eq_weak_trace:
234 if (generate_counter_examples)
236 detail::bisimulation_reduce_gj(l1,
true,
false);
237 detail::tau_star_reduce(l1);
238 detail::bisimulation_reduce_gj(l1,
false);
240 detail::bisimulation_reduce_gj(l2,
true,
false);
241 detail::tau_star_reduce(l2);
242 detail::bisimulation_reduce_gj(l2,
false);
244 return detail::destructive_branching_bisimulation_compare_minimal_depth(l1, l2, counter_example_file);
248 detail::bisimulation_reduce_gj(l1,
true,
false);
249 detail::tau_star_reduce(l1);
250 detail::bisimulation_reduce_gj(l1,
false);
254 detail::bisimulation_reduce_gj(l2,
true,
false);
255 detail::tau_star_reduce(l2);
256 detail::bisimulation_reduce_gj(l2,
false);
260 return detail::destructive_bisimulation_compare(l1,l2,
false,
false,
false,counter_example_file,structured_output);
262 case lts_eq_coupled_sim:
264 return detail::coupled_simulation_compare(l1,l2);
267 throw mcrl2::runtime_error(
"Comparison for this equivalence is not available");
273
274
275
276
277
278
279
280
281
282
283
284
285template<
class LTS_TYPE>
286bool compare(
const LTS_TYPE& l1,
289 bool generate_counter_examples =
false,
290 const std::string& counter_example_file =
"",
291 bool structured_output =
false);
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314template<
class LTS_TYPE>
318 bool generate_counter_example,
319 const std::string& counter_example_file =
"",
320 bool structured_output =
false,
321 lps::exploration_strategy strategy =
lps::es_breadth,
322 bool preprocess =
true);
325
326
327
328
329
330
331
332
333
334
335
336
337
338template<
class LTS_TYPE>
339bool compare(
const LTS_TYPE& l1,
342 bool generate_counter_example,
343 const std::string& counter_example_file =
"",
344 bool structured_output =
false,
345 lps::exploration_strategy strategy =
lps::es_breadth,
346 bool preprocess =
true);
349template <
class LTS_TYPE>
354
355
356
357
358
359
360
361
362
363template <
class SL,
class AL,
class BASE>
367 const outgoing_transitions_per_state_t out_trans(l.get_transitions(),l.num_states(),
true);
369 std::vector <
bool > visited(l.num_states(),
false);
370 std::stack<std::size_t> todo;
372 visited[l.initial_state()]=
true;
373 todo.push(l.initial_state());
375 while (!todo.empty())
377 std::size_t state_to_consider=todo.top();
379 for (detail::state_type i=out_trans.lowerbound(state_to_consider); i<out_trans.upperbound(state_to_consider); ++i)
381 const outgoing_pair_t& p=out_trans.get_transitions()[i];
382 assert(visited[state_to_consider] && state_to_consider<l.num_states() && to(p)<l.num_states());
395 bool all_reachable = find(visited.begin(),visited.end(),
false)==visited.end();
397 if (!all_reachable && remove_unreachable)
402 std::vector < detail::state_type > state_map(l.num_states());
403 std::vector < detail::state_type > label_map(l.num_action_labels());
405 lts < SL, AL, BASE> new_lts=l;
408 std::size_t new_nstates = 0;
409 for (std::size_t i=0; i<l.num_states(); i++)
413 state_map[i] = new_nstates;
414 if (l.has_state_info())
416 new_lts.add_state(l.state_label(i));
426 for (
const transition& t: l.get_transitions())
428 if (visited[t.from()])
430 label_map[t.label()] = 1;
435 std::size_t new_nlabels = 0;
436 for (std::size_t i=0; i<l.num_action_labels(); i++)
440 label_map[i] = new_nlabels;
441 new_lts.add_action(l.action_label(i));
446 for (
const transition& t: l.get_transitions())
448 if (visited[t.from()])
450 new_lts.add_transition(transition(state_map[t.from()],label_map[t.label()],state_map[t.to()]));
454 new_lts.set_initial_state(state_map.at(l.initial_state()));
458 return all_reachable;
462
463
464
465
466
467
468
469
470
471template <
class SL,
class AL,
class PROBABILISTIC_STATE,
class BASE>
475 const outgoing_transitions_per_state_t out_trans(l.get_transitions(),l.num_states(),
true);
477 std::vector <
bool > visited(l.num_states(),
false);
478 std::stack<std::size_t> todo;
480 if (l.initial_probabilistic_state().size()>1)
482 for(
const typename PROBABILISTIC_STATE::state_probability_pair& s: l.initial_probabilistic_state())
484 visited[s.state()]=
true;
485 todo.push(s.state());
490 const typename PROBABILISTIC_STATE::state_t sn=l.initial_probabilistic_state().get();
495 while (!todo.empty())
497 std::size_t state_to_consider=todo.top();
499 for (detail::state_type i=out_trans.lowerbound(state_to_consider); i<out_trans.upperbound(state_to_consider); ++i)
501 const outgoing_pair_t& p=out_trans.get_transitions()[i];
502 assert(visited[state_to_consider] && state_to_consider<l.num_states() && to(p)<l.num_probabilistic_states());
504 if (l.probabilistic_state(to(p)).size()>1)
506 for(
const typename PROBABILISTIC_STATE::state_probability_pair& pr: l.probabilistic_state(to(p)))
508 if (!visited[pr.state()])
510 visited[pr.state()]=
true;
511 todo.push(pr.state());
517 const typename PROBABILISTIC_STATE::state_t sn=l.probabilistic_state(to(p)).get();
531 bool all_reachable = find(visited.begin(),visited.end(),
false)==visited.end();
533 if (!all_reachable && remove_unreachable)
538 std::vector < detail::state_type > state_map(l.num_states());
539 std::vector < detail::state_type > label_map(l.num_action_labels());
544 std::size_t new_nstates = 0;
545 for (std::size_t i=0; i<l.num_states(); i++)
549 state_map[i] = new_nstates;
550 if (l.has_state_info())
552 new_lts.add_state(l.state_label(i));
562 for (
const transition& t: l.get_transitions())
564 if (visited[t.from()])
566 label_map[t.label()] = 1;
571 std::size_t new_nlabels = 0;
572 for (std::size_t i=0; i<l.num_action_labels(); i++)
576 label_map[i] = new_nlabels;
577 new_lts.add_action(l.action_label(i));
582 for (
const transition& t: l.get_transitions())
584 if (visited[t.from()])
586 new_lts.add_transition(transition(state_map[t.from()],label_map[t.label()],t.to()));
590 PROBABILISTIC_STATE new_initial_state;
591 for (std::size_t i=0; i<l.num_probabilistic_states(); ++i)
593 new_initial_state.clear();
594 if (l.probabilistic_state(i).size()==0)
596 new_initial_state.set(state_map[l.probabilistic_state(i).get()]);
600 for(
const typename PROBABILISTIC_STATE::state_probability_pair& s: l.probabilistic_state(i))
602 new_initial_state.add(state_map[s.state()], s.probability());
605 new_lts.add_probabilistic_state(new_initial_state);
608 new_initial_state.clear();
609 if (l.initial_probabilistic_state().size()==0)
611 new_initial_state.set(state_map[l.initial_probabilistic_state().get()]);
615 for(
const typename PROBABILISTIC_STATE::state_probability_pair& s: l.initial_probabilistic_state())
617 new_initial_state.add(state_map[s.state()], s.probability());
620 new_lts.set_initial_probabilistic_state(new_initial_state);
624 return all_reachable;
628
629
630template <
class LTS_TYPE>
634
635
636
637template <
class LTS_TYPE>
638void merge(LTS_TYPE& l1,
const LTS_TYPE& l2)
645
649template <
class LTS_TYPE>
650void reduce(LTS_TYPE& l,lts_equivalence eq)
659 detail::bisimulation_reduce_gj(l,
false,
false);
662 case lts_eq_bisim_gv:
664 detail::bisimulation_reduce(l,
false,
false);
667 case lts_eq_bisim_gjkw:
669 detail::bisimulation_reduce_gjkw(l,
false,
false);
672 case lts_eq_bisim_jgkw:
674 detail::bisimulation_reduce_dnj(l,
false,
false);
677 case lts_eq_bisim_gj:
679 detail::bisimulation_reduce_gj(l,
false,
false);
682 case lts_eq_bisim_gj_lazy_BLC:
684 detail::bisimulation_reduce_gj_lazy_BLC(l,
false,
false);
687 case lts_eq_bisim_sigref:
693 case lts_eq_branching_bisim:
695 detail::bisimulation_reduce_gj(l,
true,
false);
698 case lts_eq_branching_bisim_gv:
700 detail::bisimulation_reduce(l,
true,
false);
703 case lts_eq_branching_bisim_gjkw:
705 detail::bisimulation_reduce_gjkw(l,
true,
false);
708 case lts_eq_branching_bisim_jgkw:
710 detail::bisimulation_reduce_dnj(l,
true,
false);
713 case lts_eq_branching_bisim_gj:
715 detail::bisimulation_reduce_gj(l,
true,
false);
718 case lts_eq_branching_bisim_gj_lazy_BLC:
720 detail::bisimulation_reduce_gj_lazy_BLC(l,
true,
false);
723 case lts_eq_branching_bisim_sigref:
729 case lts_eq_divergence_preserving_branching_bisim:
731 detail::bisimulation_reduce_gj(l,
true,
true);
734 case lts_eq_divergence_preserving_branching_bisim_gv:
736 detail::bisimulation_reduce(l,
true,
true);
739 case lts_eq_divergence_preserving_branching_bisim_gjkw:
741 detail::bisimulation_reduce_gjkw(l,
true,
true);
744 case lts_eq_divergence_preserving_branching_bisim_jgkw:
746 detail::bisimulation_reduce_dnj(l,
true,
true);
749 case lts_eq_divergence_preserving_branching_bisim_gj:
751 detail::bisimulation_reduce_gj(l,
true,
true);
754 case lts_eq_divergence_preserving_branching_bisim_gj_lazy_BLC:
756 detail::bisimulation_reduce_gj_lazy_BLC(l,
true,
true);
759 case lts_eq_divergence_preserving_branching_bisim_sigref:
765 case lts_eq_weak_bisim:
767 detail::weak_bisimulation_reduce(l,
false);
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786 case lts_eq_divergence_preserving_weak_bisim:
788 detail::weak_bisimulation_reduce(l,
true);
795 sp.partitioning_algorithm();
799 l.clear_state_labels();
800 l.clear_transitions();
803 l.set_num_states(sp.num_eq_classes());
804 l.set_initial_state(sp.get_eq_class(l.initial_state()));
806 const std::vector <transition> trans=sp.get_transitions();
807 l.clear_transitions();
808 for (
const transition& t: trans)
814 reachability_check(l,
true);
818 case lts_eq_ready_sim:
822 rsp.partitioning_algorithm();
826 l.clear_state_labels();
827 l.clear_transitions();
830 l.set_num_states(rsp.num_eq_classes());
831 l.set_initial_state(rsp.get_eq_class(l.initial_state()));
833 const std::vector <transition> trans=rsp.get_transitions();
834 l.clear_transitions();
835 for (
const transition& t: trans)
841 reachability_check(l,
true);
846 detail::bisimulation_reduce_gj(l,
false);
848 detail::bisimulation_reduce_gj(l,
false);
850 case lts_eq_weak_trace:
852 detail::bisimulation_reduce_gj(l,
true,
false);
853 detail::tau_star_reduce(l);
854 detail::bisimulation_reduce_gj(l,
false);
856 detail::bisimulation_reduce_gj(l,
false);
859 case lts_red_tau_star:
861 detail::bisimulation_reduce_gj(l,
true,
false);
862 detail::tau_star_reduce(l);
863 detail::bisimulation_reduce_gj(l,
false);
866 case lts_red_determinisation:
871 case lts_red_tau_scc:
881template <
class LTS_TYPE>
882bool compare(
const LTS_TYPE& l1,
const LTS_TYPE& l2,
const lts_equivalence eq,
const bool generate_counter_examples,
const std::string& counter_example_file,
const bool structured_output)
889 LTS_TYPE l1_copy(l1);
890 LTS_TYPE l2_copy(l2);
891 return destructive_compare(l1_copy, l2_copy, eq ,generate_counter_examples, counter_example_file, structured_output);
896template <
class LTS_TYPE>
897bool compare(
const LTS_TYPE& l1,
const LTS_TYPE& l2,
const lts_preorder pre,
const bool generate_counter_example,
const std::string& counter_example_file,
const bool structured_output,
const lps::exploration_strategy strategy,
const bool preprocess)
899 LTS_TYPE l1_copy(l1);
900 LTS_TYPE l2_copy(l2);
901 return destructive_compare(l1_copy, l2_copy, pre, generate_counter_example, counter_example_file, structured_output, strategy, preprocess);
904template <
class LTS_TYPE>
905bool destructive_compare(LTS_TYPE& l1, LTS_TYPE& l2,
const lts_preorder pre,
const bool generate_counter_example,
const std::string& counter_example_file,
const bool structured_output,
const lps::exploration_strategy strategy,
const bool preprocess)
909 case lts_preorder::lts_pre_sim:
915 const std::size_t init_l2 = l2.initial_state() + l1.num_states();
923 sp.partitioning_algorithm();
925 return sp.in_preorder(l1.initial_state(),init_l2);
927 case lts_preorder::lts_pre_ready_sim:
933 const std::size_t init_l2 = l2.initial_state() + l1.num_states();
941 rsp.partitioning_algorithm();
943 return rsp.in_preorder(l1.initial_state(),init_l2);
945 case lts_preorder::lts_pre_trace:
950 detail::bisimulation_reduce_gj(l1,
false);
951 detail::bisimulation_reduce_gj(l2,
false);
958 detail::bisimulation_reduce_gj(l1,
false);
961 detail::bisimulation_reduce_gj(l2,
false);
964 return destructive_compare(l1, l2, lts_preorder::lts_pre_sim, generate_counter_example, counter_example_file, structured_output, strategy);
966 case lts_preorder::lts_pre_weak_trace:
969 detail::bisimulation_reduce_gj(l1,
true,
false);
970 detail::tau_star_reduce(l1);
973 detail::bisimulation_reduce_gj(l2,
true,
false);
974 detail::tau_star_reduce(l2);
977 return destructive_compare(l1, l2, lts_preorder::lts_pre_trace, generate_counter_example, counter_example_file, structured_output, strategy);
979 case lts_preorder::lts_pre_trace_anti_chain:
981 if (generate_counter_example)
988 case lts_preorder::lts_pre_weak_trace_anti_chain:
990 if (generate_counter_example)
997 case lts_preorder::lts_pre_failures_refinement:
999 if (generate_counter_example)
1006 case lts_preorder::lts_pre_weak_failures_refinement:
1008 if (generate_counter_example)
1015 case lts_preorder::lts_pre_failures_divergence_refinement:
1017 if (generate_counter_example)
1024 case lts_preorder::lts_pre_impossible_futures:
1026 if (generate_counter_example)
1028 return detail::destructive_impossible_futures(l1, l2, strategy, counter_example_file, generate_counter_example, structured_output);
1031 return detail::destructive_impossible_futures(l1, l2, strategy, counter_example_file,
false, structured_output);
1033 case lts_preorder::lts_pre_none:
1035 throw mcrl2::runtime_error(
"Expected a valid preorder");
1038 mCRL2log(log::error) <<
"Comparison for this preorder is not available\n";
1044template <
class LTS_TYPE>
1047 if (l.num_transitions() == 0)
1052 std::vector<transition> temporary_copy_of_transitions = l.get_transitions();
1053 sort_transitions(temporary_copy_of_transitions, l.hidden_label_set(), src_lbl_tgt);
1057 transition& previous_t=temporary_copy_of_transitions[0];
1058 bool previous_t_is_valid=
false;
1059 for(
const transition& t: temporary_copy_of_transitions)
1061 if (previous_t_is_valid)
1063 if (previous_t.from()==t.from() &&
1064 previous_t.label()==t.label() &&
1065 previous_t.to()!=t.to())
1071 previous_t_is_valid=
true;
1080template <
class LTS_TYPE>
1081void get_trans(
const outgoing_transitions_per_state_t& begin,
1082 tree_set_store& tss,
1084 std::vector<transition>& d_trans,
1087 if (!tss.is_set_empty(d))
1089 if (tss.is_set_empty(tss.get_set_child_right(d)))
1091 const state_type from=tss.get_set_child_left(d);
1092 for (detail::state_type i=begin.lowerbound(from); i<begin.upperbound(from); ++i)
1094 const outgoing_pair_t& p=begin.get_transitions()[i];
1095 d_trans.push_back(transition(from, aut.apply_hidden_label_map(label(p)), to(p)));
1100 get_trans(begin,tss,tss.get_set_child_left(d),d_trans,aut);
1101 get_trans(begin,tss,tss.get_set_child_right(d),d_trans,aut);
1108template <
class LTS_TYPE>
1113 std::vector<transition> d_transs;
1114 std::vector<std::ptrdiff_t> d_states;
1117 d_states.push_back(l.initial_state());
1118 std::ptrdiff_t d_id = tss.set_set_tag(tss.create_set(d_states));
1121 const outgoing_transitions_per_state_t begin(l.get_transitions(),l.num_states(),
true);
1123 l.clear_transitions();
1124 l.clear_state_labels();
1125 std::size_t d_ntransitions = 0;
1126 std::vector < transition > d_transitions;
1134 while (d_id < tss.get_next_tag())
1138 detail::get_trans(begin,tss,tss.get_set(d_id),d_transs,l);
1141 const detail::compare_transitions_lts compare(l.hidden_label_set());
1142 sort(d_transs.begin(),d_transs.end(),compare);
1144 n_t = d_transs.size();
1146 for (lbl = 0; lbl < l.num_action_labels(); ++lbl)
1149 while (i < n_t && l.apply_hidden_label_map(d_transs[i].label()) < lbl)
1153 while (i < n_t && l.apply_hidden_label_map(d_transs[i].label()) == lbl)
1155 to = d_transs[i].to();
1156 d_states.push_back(
static_cast<std::ptrdiff_t>(to));
1157 while (i < n_t && l.apply_hidden_label_map(d_transs[i].label()) == lbl &&
1158 d_transs[i].to() == to)
1163 s = tss.create_set(d_states);
1166 if (!tss.is_set_empty(s))
1168 d_transitions.emplace_back(d_id, lbl, tss.set_set_tag(s));
1170 if (d_ntransitions%10000 == 0)
1173 "generated " << tss.get_next_tag() <<
" states and " << d_ntransitions
1174 <<
" transitions; explored " << d_id <<
" states" << std::endl;
1184 l.set_num_states(d_id,
false);
1185 l.set_initial_state(0);
1187 for (
const transition& t: d_transitions)
1189 l.add_transition(t);
1191 assert(is_deterministic(l));
function object to compare two constln_t pointers based on their contents
A class that can be used to store counterexample trees and.
A class that contains a labelled transition system.
Class for computing the signature for strong bisimulation.
Class for computing the signature for branching bisimulation.
Class for computing the signature for divergence preserving branching bisimulation.
Signature based reductions for labelled transition systems.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
The main namespace for the LPS library.
lts_type guess_format(std::string const &s, const bool be_verbose)
Determines the LTS format from a filename by its extension.
static const std::array< std::string, 5 > extension_strings
std::string supported_lts_formats_text(lts_type default_format, const std::set< lts_type > &supported)
Gives a textual list describing supported LTS formats.
std::string supported_lts_formats_text(const std::set< lts_type > &supported)
Gives a textual list describing supported LTS formats.
std::string string_for_type(const lts_type type)
Gives a string representation of an LTS format.
std::string mime_type_for_type(const lts_type type)
Gives the MIME type associated with an LTS format.
void get_trans(const outgoing_transitions_per_state_t &begin, tree_set_store &tss, std::ptrdiff_t d, std::vector< transition > &d_trans, LTS_TYPE &aut)
lts_type parse_format(std::string const &s)
Determines the LTS format from a format specification string.
static const std::array< std::string, 5 > type_strings
std::string extension_for_type(const lts_type type)
Gives the filename extension associated with an LTS format.
const std::set< lts_type > & supported_lts_formats()
Gives the set of all supported LTS formats.
std::string lts_extensions_as_string(const std::set< lts_type > &supported)
Gives a list of extensions for supported LTS formats.
std::string lts_extensions_as_string(const std::string &sep, const std::set< lts_type > &supported)
Gives a list of extensions for supported LTS formats.
bool lts_named_cmp(const std::array< std::string, Size > &N, T a, T b)
static const std::array< std::string, 5 > type_desc_strings
static const std::array< std::string, 5 > mime_type_strings
static const std::set< lts_type > & initialise_supported_lts_formats()
bool is_deterministic(const LTS_TYPE &l)
Checks whether this LTS is deterministic.
void determinise(LTS_TYPE &l)
Determinises this LTS.
void reduce(LTS_TYPE &l, lts_equivalence eq)
Applies a reduction algorithm to this LTS.
bool compare(const LTS_TYPE &l1, const LTS_TYPE &l2, lts_equivalence eq, bool generate_counter_examples=false, const std::string &counter_example_file="", bool structured_output=false)
Checks whether this LTS is equivalent to another LTS.
bool destructive_compare(LTS_TYPE &l1, LTS_TYPE &l2, const lts_equivalence eq, const bool generate_counter_examples=false, const std::string &counter_example_file=std::string(), const bool structured_output=false)
Checks whether this LTS is equivalent to another LTS.
bool destructive_compare(LTS_TYPE &l1, LTS_TYPE &l2, lts_preorder pre, bool generate_counter_example, const std::string &counter_example_file="", bool structured_output=false, lps::exploration_strategy strategy=lps::es_breadth, bool preprocess=true)
Checks whether this LTS is smaller than another LTS according to a preorder.
void merge(LTS_TYPE &l1, const LTS_TYPE &l2)
Merge the second lts into the first lts.
bool reachability_check(lts< SL, AL, BASE > &l, bool remove_unreachable=false)
Checks whether all states in this LTS are reachable from the initial state and remove unreachable sta...
bool reachability_check(probabilistic_lts< SL, AL, PROBABILISTIC_STATE, BASE > &l, bool remove_unreachable=false)
Checks whether all states in a probabilistic LTS are reachable from the initial state and remove unre...
bool compare(const LTS_TYPE &l1, const LTS_TYPE &l2, lts_preorder pre, bool generate_counter_example, const std::string &counter_example_file="", bool structured_output=false, lps::exploration_strategy strategy=lps::es_breadth, bool preprocess=true)
Checks whether this LTS is smaller than another LTS according to a preorder.