mCRL2
Loading...
Searching...
No Matches
ltsmin.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
11
12#ifndef MCRL2_LPS_LTSMIN_H
13#define MCRL2_LPS_LTSMIN_H
14
15#define MCRL2_GUARDS 1
16
17#include "mcrl2/data/join.h"
18#include "mcrl2/lps/find.h"
19#include "mcrl2/lps/io.h"
20#include "mcrl2/lps/explorer.h"
21#include "mcrl2/lps/parse.h"
22
23// For backwards compatibility
26
27namespace mcrl2::log {
29}
30
31#ifdef MCRL2_ENABLE_JITTYC
32#define MCRL2_JITTYC_AVAILABLE
33#endif
34
35namespace mcrl2 {
36
37namespace lps {
38
40inline
41std::vector<std::string> generate_values(const data::data_specification& dataspec, const data::sort_expression& s, std::size_t max_size = 1000)
42{
44
45 std::vector<std::string> result;
46 std::size_t max_iterations = 10000;
47 data::rewriter rewr(dataspec);
49 bool accept_solutions_with_variables = false;
50 data::enumerator_algorithm<data::rewriter, data::rewriter> E(rewr, dataspec, rewr, id_generator, accept_solutions_with_variables, max_iterations);
52 data::variable x("x", s);
53 data::variable_list v_list{x};
54
55 E.enumerate(enumerator_element(v_list, data::sort_bool::true_()),
56 sigma,
57 [&](const enumerator_element& p)
58 {
59 p.add_assignments(v_list, sigma, rewr);
60 result.push_back(data::pp(sigma(x)));
61 return result.size() >= max_size;
62 }
63 );
64 return result;
65}
66
70{
71 protected:
76
77 public:
78
80 class index_iterator: public boost::iterator_facade<index_iterator, const std::size_t, boost::forward_traversal_tag>
81 {
82 public:
83 explicit index_iterator(std::size_t index = 0)
84 : m_index(index)
85 {}
86
87 private:
89
90 void increment()
91 {
92 m_index++;
93 }
94
95 bool equal(const index_iterator& other) const
96 {
97 return this->m_index == other.m_index;
98 }
99
100 const std::size_t& dereference() const
101 {
102 return m_index;
103 }
104
105 std::ptrdiff_t distance_to(const index_iterator& other) const
106 {
107 return other.m_index - this->m_index;
108 }
109
110 std::size_t m_index;
111 };
112
115 const process::action_label_list& action_labels,
116 bool is_bounded = false)
117 : // m_generator(generator),
118 m_data(data),
119 m_action_labels(action_labels),
121 {}
122
124 virtual ~pins_data_type() = default;
125
129 virtual std::string serialize(int i) const = 0;
130
135 virtual std::size_t deserialize(const std::string& s) = 0;
136
140 virtual std::string print(int i) const = 0;
141
146 virtual std::size_t parse(const std::string& s) = 0;
147
149 virtual const std::string& name() const = 0;
150
152 virtual std::vector<std::string> generate_values(std::size_t max_size) const = 0;
153
156 bool is_bounded() const
157 {
158 return m_is_bounded;
159 }
160
162 std::size_t size() const
163 {
164 return m_indexed_set.size();
165 }
166
169 {
170 return index_iterator(0);
171 }
172
175 {
176 return index_iterator(size());
177 }
178
180 std::size_t operator[](const atermpp::aterm& x)
181 {
182 return m_indexed_set.insert(x).first;
183 }
184
186 atermpp::aterm get(std::size_t i)
187 {
188 return m_indexed_set.at(i);
189 }
190
193 {
194 return m_indexed_set;
195 }
196
199 {
200 return m_indexed_set;
201 }
202};
203
206{
207 protected:
208 std::string m_name;
210
212 {
213 return m_indexed_set.insert(x).first;
214 }
215
217 {
218 return static_cast<data::data_expression>(m_indexed_set.at(i));
219 }
220
221 public:
223 const process::action_label_list& action_labels,
224 const data::sort_expression& sort,
225 bool sort_is_finite
226 )
227 : pins_data_type(data, action_labels, sort_is_finite),
228 m_sort(sort)
229 {
231 }
232
233 // prints the expression as an ATerm string
234 std::string serialize(int i) const override
235 {
238 return pp(t);
239 }
240
241 std::size_t deserialize(const std::string& s) override
242 {
244 return expression2index(atermpp::down_cast<data::data_expression>(t));
245 }
246
247 std::string print(int i) const override
248 {
249 return data::pp(index2expression(i));
250 }
251
252 std::size_t parse(const std::string& s) override
253 {
255 }
256
257 const std::string& name() const override
258 {
259 return m_name;
260 }
261
262 std::vector<std::string> generate_values(std::size_t max_size) const override
263 {
264 return lps::generate_values(m_data, m_sort, max_size);
265 }
266};
267
270{
271 protected:
272 std::string m_name;
273
274 public:
276 : pins_data_type(data, action_labels, false)
277 {
278 m_name = "action_labels";
279 }
280
281 std::string serialize(int i) const override
282 {
283 return pp(m_indexed_set.at(i));
284 }
285
286 std::size_t deserialize(const std::string& s) override
287 {
288 return m_indexed_set.insert(atermpp::read_term_from_string(s)).first;
289 }
290
291 std::string print(int i) const override
292 {
294 }
295
296 std::size_t parse(const std::string& s) override
297 {
299 return m_indexed_set.insert(m).first;
300 }
301
302 const std::string& name() const override
303 {
304 return m_name;
305 }
306
307 // TODO: get rid of this useless function
308 std::vector<std::string> generate_values(std::size_t) const override
309 {
310 return std::vector<std::string>();
311 }
312};
313
314class pins
315{
316 public:
317 typedef int* ltsmin_state_type;
322
324
325 protected:
326 std::size_t m_group_count;
327 std::size_t m_state_length;
328 std::vector<std::vector<std::size_t> > m_read_group;
329 std::vector<std::vector<std::size_t> > m_write_group;
330 std::vector<std::vector<std::size_t> > m_update_group;
334
335 std::vector<data::variable> m_parameters_list;
336 std::vector<std::string> m_process_parameter_names;
337
339 std::vector<std::vector<std::size_t> > guard_parameters_list;
340 std::vector<std::vector<std::size_t> > m_guard_info;
341 std::vector<std::string> m_guard_names;
342
343 // For guard-splitting we use a different generator with a different spec.
344 // This second spec has guards removed from the conditions.
347
348 // The type mappings
349 // m_data_types[0] ... m_data_types[N-1] contain the state parameter mappings
350 // m_data_types[N] contains the action label values
351 // where N is the number of process parameters
352 std::vector<pins_data_type*> m_data_types;
353
355 std::vector<pins_data_type*> m_unique_data_types;
356
357 // maps process parameter index to the corresponding index in m_unique_data_types
358 std::vector<std::size_t> m_unique_data_type_index;
359
362 {
363 return *m_data_types.back();
364 }
365
368 {
369 return *m_data_types.back();
370 }
371
374 {
375 return *m_data_types[i];
376 }
377
379 const pins_data_type& state_type_map(std::size_t i) const
380 {
381 return *m_data_types[i];
382 }
383
385 const linear_process& process() const
386 {
387 return m_specification.process();
388 }
389
393 {
395 }
396
399 {
400 return m_specification.data();
401 }
402
403 template <typename Iter>
404 std::string print_vector(Iter first, Iter last) const
405 {
406 std::ostringstream out;
407 out << "[";
408 for (Iter i = first; i != last; ++i)
409 {
410 if (i != first)
411 {
412 out << ", ";
413 }
414 out << *i;
415 }
416 out << "]";
417 return out.str();
418 }
419
420 template <typename Container>
421 std::string print_vector(const Container& c) const
422 {
423 return print_vector(c.begin(), c.end());
424 }
425
427 {
428 std::set<data::variable> parameters(process().process_parameters().begin(), process().process_parameters().end());
429
431
432 m_group_count = proc.action_summands().size();
433 m_state_length = proc.process_parameters().size();
434
437
438 // iterate over the list of summands
439 {
440 std::size_t i = 0;
441 for (const auto & summand : proc.action_summands())
442 {
443 std::set<data::variable> used_read_variables;
444 std::set<data::variable> used_write_variables;
445
446 data::find_free_variables(summand.condition(), std::inserter(used_read_variables, used_read_variables.end()));
447 lps::find_free_variables(summand.multi_action(), std::inserter(used_read_variables, used_read_variables.end()));
448
449 for (const auto & assignment : summand.assignments())
450 {
451 if (assignment.lhs() != assignment.rhs())
452 {
453 data::find_all_variables(assignment.lhs(), std::inserter(used_write_variables, used_write_variables.end()));
454 data::find_all_variables(assignment.rhs(), std::inserter(used_read_variables, used_read_variables.end()));
455 }
456 }
457
458 // process parameters used in condition, action or assignment of summand
459 std::set<data::variable> used_read_parameters;
460 std::set<data::variable> used_write_parameters;
461
462 std::set_intersection(used_read_variables.begin(),
464 parameters.begin(),
465 parameters.end(),
466 std::inserter(used_read_parameters,
467 used_read_parameters.begin()));
468 std::set_intersection(used_write_variables.begin(),
469 used_write_variables.end(),
470 parameters.begin(),
471 parameters.end(),
472 std::inserter(used_write_parameters,
473 used_write_parameters.begin()));
474
475 std::size_t j = 0;
476 for (auto & param : m_parameters_list)
477 {
478 if (used_read_parameters.find(param) != used_read_parameters.end())
479 {
480 m_read_group[i].push_back(j);
481 }
482 if (used_write_parameters.find(param) != used_write_parameters.end())
483 {
484 m_write_group[i].push_back(j);
485 }
486 j++;
487 }
488 i++;
489 }
490 }
491
493
494 // iterate over the list of reduced summands
495 {
496 std::size_t i = 0;
497 for (const auto & reduced_summand : process_reduced().action_summands())
498 {
499 std::set<data::variable> used_update_variables;
500
501 data::find_free_variables(reduced_summand.condition(), std::inserter(used_update_variables, used_update_variables.end()));
502 lps::find_free_variables(reduced_summand.multi_action(), std::inserter(used_update_variables, used_update_variables.end()));
503
504 for (const auto & assignment : reduced_summand.assignments())
505 {
506 if (assignment.lhs() != assignment.rhs())
507 {
508 data::find_all_variables(assignment.rhs(), std::inserter(used_update_variables, used_update_variables.end()));
509 }
510 }
511
512 // process parameters used in the action and assignment of summand
513 std::set<data::variable> used_update_parameters;
514
515 std::set_intersection(used_update_variables.begin(),
516 used_update_variables.end(),
517 parameters.begin(),
518 parameters.end(),
519 std::inserter(used_update_parameters,
520 used_update_parameters.begin()));
521
522 std::size_t j = 0;
523 for (auto & param : m_parameters_list)
524 {
525 if (used_update_parameters.find(param) != used_update_parameters.end())
526 {
527 m_update_group[i].push_back(j);
528 }
529 j++;
530 }
531 i++;
532 }
533 }
534 }
535
536 public:
537 typedef std::size_t datatype_index;
540 std::size_t process_parameter_count() const
541 {
543 }
544
546 std::size_t group_count() const
547 {
548 return m_specification.process().action_summands().size();
549 }
550
551 static lps::specification load_specification(const std::string& filename)
552 {
554 load_lps(specification, filename);
555 return specification;
556 }
557
561 // the list of summands
562 std::vector<lps::action_summand> reduced_summands;
563 for (const auto & summand : spec.process().action_summands())
564 {
565 // contains info about which guards this transition group has.
566 std::vector<std::size_t> guard_info;
567
568 // the initial new condition of a summand is always true.
569 // this maybe joined with conjuncts which have local variables.
570 data::data_expression reduced_condition = data::sort_bool::true_();
571
572 // process variables and guards in condition
573 std::set<data::data_expression> conjuncts = data::split_and(summand.condition());
574 std::set<data::variable> summation_variables(summand.summation_variables().begin(), summand.summation_variables().end());
575
576 for (const auto & conjunct : conjuncts)
577 {
578 // check if the conjunct is new
579 std::size_t at = m_guards.index(conjunct);
581 bool use_conjunct_as_guard = true;
582
583 if (is_new) { // we have not encountered the guard yet
584 std::set<data::variable> conjunct_variables;
585 data::find_free_variables(conjunct, std::inserter(conjunct_variables, conjunct_variables.end()));
586
587 if (!summand.summation_variables().empty())
588 {
589 // the conjunct may contain summation variables, in which case it can not be
590 // used as guard.
591 std::set<data::variable> summation_variables_in_conjunct;
592 std::set_intersection(conjunct_variables.begin(),
593 conjunct_variables.end(),
594 summation_variables.begin(),
595 summation_variables.end(),
596 std::inserter(summation_variables_in_conjunct, summation_variables_in_conjunct.begin()));
597
598 if (!summation_variables_in_conjunct.empty()) {
599 // this conjunct contains summation variables and will not be used as guard.
600 use_conjunct_as_guard = false;
601
602 std::string printed_guard(data::pp(conjunct).substr(0, 80));
604 << "Guard '" << printed_guard + (printed_guard.size() > 80?"...":"") << "' in summand "
605 << reduced_summands.size()
606 << " introduces local variables. To remove the guard from the condition, try instantiating the summand with 'lpssuminst'."
607 << std::endl;
608
609 // add conjunct to new summand condition
610 if (reduced_condition == data::sort_bool::true_()) {
611 reduced_condition = conjunct;
612 } else {
613 reduced_condition = data::sort_bool::and_(reduced_condition, conjunct);
614 }
615 }
616 }
617 if (use_conjunct_as_guard) {
618 // add conjunct to guards
619 std::vector<std::size_t> guard_parameters;
620 if (!conjunct_variables.empty())
621 {
622 // compute indexes of parameters used by the guard
623 std::size_t p = 0;
624 for (auto & param : m_parameters_list)
625 {
626 if (conjunct_variables.find(param) != conjunct_variables.end())
627 {
628 guard_parameters.push_back(p);
629 }
630 p++;
631 }
632 }
633 // add conjunct to the set of guards
634 at = m_guards.insert(conjunct).first;
635 m_guard_names.push_back(data::pp(conjunct));
637 }
638 }
639 if (use_conjunct_as_guard) {
640 // add the guard index to the list of guards of this summand.
641 guard_info.push_back(at);
642 }
643 }
644
645 // set which guards belong to which transition group
646 m_guard_info.push_back(guard_info);
647
648 // add the new summand to the list of summands.
649 reduced_summands.push_back(lps::action_summand(summand.summation_variables(), reduced_condition, summand.multi_action(), summand.assignments()));
650 }
651
652 // create a new LPS
653 lps::linear_process lps_reduced(process().process_parameters(), process().deadlock_summands(), reduced_summands);
654
655 // create a new spec
657 return specification_reduced;
658 }
659
663 pins(const std::string& filename, const std::string& rewriter_strategy)
665 m_generator(m_specification, data::parse_rewrite_strategy(rewriter_strategy)),
666 m_parameters_list(process().process_parameters().begin(), process().process_parameters().end()),
668 m_generator_reduced(m_specification_reduced, data::parse_rewrite_strategy(rewriter_strategy))
669 {
671
672 // store the process parameter names in a vector, to have random access to them
674 for (const auto & param : params)
675 {
676 m_process_parameter_names.push_back(param.name());
677 }
678
679 // Each state parameter type gets it's own pins_data_type. State parameters of the same
680 // type share the pins_data_type.
681 std::map<data::sort_expression, pins_data_type*> existing_type_maps;
682 std::vector<data::variable> parameters(process().process_parameters().begin(),process().process_parameters().end());
683 for (std::size_t i = 0; i < params.size(); i++)
684 {
685 data::sort_expression s = parameters[i].sort();
686 std::map<data::sort_expression, pins_data_type*>::const_iterator j = existing_type_maps.find(s);
687 if (j == existing_type_maps.end())
688 {
690 m_data_types.push_back(dt);
691 m_unique_data_types.push_back(dt);
692 existing_type_maps[s] = dt;
693 }
694 else
695 {
696 m_data_types.push_back(j->second);
697 }
698 }
700 m_data_types.push_back(dt);
701 m_unique_data_types.push_back(dt);
702
703 for (auto m_data_type : m_data_types)
704 {
705 std::vector<pins_data_type*>::const_iterator j = std::find(m_unique_data_types.begin(), m_unique_data_types.end(), m_data_type);
706 assert(j != m_unique_data_types.end());
707 m_unique_data_type_index.push_back(j - m_unique_data_types.begin());
708 }
709 }
710
712 {
713 // make sure the pins data types are not deleted twice
714 std::set<pins_data_type*> deleted;
715 for (auto& data_type_ptr: m_data_types)
716 {
717 if (deleted.find(data_type_ptr) == deleted.end())
718 {
719 delete data_type_ptr;
720 deleted.insert(data_type_ptr);
721 }
722 }
723 }
724
727 std::size_t datatype_count() const
728 {
729 return m_unique_data_types.size();
730 }
731
734 pins_data_type& data_type(std::size_t i)
735 {
736 assert (i < m_data_types.size());
737 return *m_unique_data_types[i];
738 }
739
744 const std::vector<std::size_t>& read_group(std::size_t index) const
745 {
746 return m_read_group[index];
747 }
748
753 const std::vector<std::size_t>& write_group(std::size_t index) const
754 {
755 return m_write_group[index];
756 }
757
762 const std::vector<std::size_t>& update_group(std::size_t index) const
763 {
764 return m_update_group[index];
765 }
766
767 const std::vector<std::size_t>& guard_parameters(std::size_t index) const
768 {
769 return guard_parameters_list[index];
770 }
771
772 const std::vector<std::size_t>& guard_info(std::size_t index) const
773 {
774 return m_guard_info[index];
775 }
776
777 std::size_t guard_count() const
778 {
779 return m_guards.size();
780 }
781
782 const std::string& guard_name(std::size_t index) {
783 return m_guard_names[index];
784 }
785
787 std::string process_parameter_name(std::size_t i) const
788 {
790 }
791
795 {
796 return m_unique_data_type_index[i];
797 }
798
800 std::size_t edge_label_count() const
801 {
802 return 1;
803 }
804
808 {
809 return m_unique_data_types.size() - 1;
810 }
811
814 std::string edge_label_name(std::size_t) const
815 {
816 return action_label_type_map().name();
817 }
818
821 {
823 for (std::size_t i = 0; i < m_state_length; i++)
824 {
825 s[i] = state_type_map(i)[initial_state[i]];
826 }
827 }
828
831 std::set<std::string> summand_action_names(std::size_t i) const
832 {
833 std::set<std::string> result;
834 auto const l = process().action_summands()[i].multi_action().actions(); // Using a reference in whatever this type
835 // is, leads to a failing lps_ltsmin_test.
836 for (const auto & i : l)
837 {
838 result.insert(std::string(i.label().name()));
839 }
840 return result;
841 }
842
856 template <typename StateFunction>
857 void next_state_all(ltsmin_state_type const& src, StateFunction& f, ltsmin_state_type const& dest, int* const& labels)
858 {
859 std::size_t nparams = process_parameter_count();
860 data::data_expression_vector state_arguments(nparams);
861 for (std::size_t i = 0; i < nparams; i++)
862 {
863 state_arguments[i] = static_cast<data::data_expression>(state_type_map(i).get(src[i]));
864 }
865 // data::data_expression_vector source = state_arguments;
866 state source(state_arguments.begin(),nparams);
867
868 std::list<generator_type::transition> transitions = m_generator.out_edges(source);
869 for (const generator_type::transition& t: transitions)
870 {
871 state destination = t.state;
872 for (std::size_t j = 0; j < nparams; j++)
873 {
874 dest[j] = state_type_map(j)[destination[j]];
875 }
876 labels[0] = action_label_type_map()[t.action];
877 f(dest, labels);
878 }
879 }
880
881 template <typename StateFunction>
882 void next_state_long(ltsmin_state_type const& src, std::size_t group, StateFunction& f, ltsmin_state_type const& dest, int* const& labels)
883 {
884 _long(src, group, f, dest, labels, &m_generator);
885 }
886
887 template <typename StateFunction>
888 void update_long(ltsmin_state_type const& src, std::size_t group, StateFunction& f, ltsmin_state_type const& dest, int* const& labels)
889 {
890 _long(src, group, f, dest, labels, &m_generator_reduced);
891 }
892
912 template <typename StateFunction>
913 void _long(ltsmin_state_type const& src,
914 std::size_t group,
915 StateFunction& f,
916 const ltsmin_state_type& dest,
917 int* const& labels,
918 generator_type* generator)
919 {
920 std::size_t nparams = process_parameter_count();
921 data::data_expression_vector state_arguments(nparams);
922 for (std::size_t i = 0; i < nparams; i++)
923 {
924 state_arguments[i] = static_cast<data::data_expression>(state_type_map(i).get(src[i]));
925 }
926 state source(state_arguments.begin(),nparams);
927
928 std::list<generator_type::transition> transitions = generator->out_edges(source, group);
929
930 for (const generator_type::transition& t: transitions)
931 {
932 state destination = t.state;
933 for (std::size_t j = 0; j < nparams; j++)
934 {
935 dest[j] = state_type_map(j)[destination[j]];
936 }
937 labels[0] = action_label_type_map()[t.action];
938 f(dest, labels);
939 }
940 }
941
942 guard_evaluation_t eval_guard_long(ltsmin_state_type const& src, std::size_t guard) {
943 std::size_t nparams = process_parameter_count();
944 substitution_t substitution;
945 for (std::size_t i = 0; i < nparams; i++)
946 {
947 data::data_expression value(static_cast<data::data_expression>(state_type_map(i).get(src[i])));
948 substitution[m_parameters_list[i]] = value;
949 }
950
951 // get the result by rewriting the guard with the substitution.
953 static_cast<data::data_expression>(m_guards.at(guard)),
954 substitution);
955
956 if(result == data::sort_bool::false_()) { // the guard rewrites to false.
957 return GUARD_FALSE;
958 } else if(result == data::sort_bool::true_()) { // the guard rewrites to true.
959 return GUARD_TRUE;
960 } else { // the guard does not rewrite to true or false, so maybe...
961 return GUARD_MAYBE;
962 }
963 }
964
966 std::string info()
967 {
968 std::ostringstream out;
969
970 out << "\n--- EDGE LABELS ---\n";
971 out << "edge_label_count() = " << edge_label_count() << std::endl;
972 for (std::size_t i = 0; i < edge_label_count(); i++)
973 {
974 out << "\n";
975 out << "edge_label_name(" << i << ") = " << edge_label_name(i) << std::endl;
976 out << "edge_label_type(" << i << ") = " << edge_label_type(i) << std::endl;
977 }
978
979 out << "\n--- PROCESS PARAMETERS ---\n";
980 out << "process_parameter_count() = " << process_parameter_count() << std::endl;
981 for (std::size_t i = 0; i < process_parameter_count(); i++)
982 {
983 out << "\n";
984 out << "process_parameter_name(" << i << ") = " << process_parameter_name(i) << std::endl;
985 out << "process_parameter_type(" << i << ") = " << process_parameter_type(i) << std::endl;
986 }
987
988 out << "\n--- SUMMANDS ---\n";
989 out << "group_count() = " << group_count() << std::endl;
990 for (std::size_t i = 0; i < group_count(); i++)
991 {
992 out << std::endl;
993 out << " read_group(" << i << ") = " << print_vector(read_group(i)) << std::endl;
994 out << " write_group(" << i << ") = " << print_vector(write_group(i)) << std::endl;
995 out << "update_group(" << i << ") = " << print_vector(update_group(i)) << std::endl;
996 }
997
998 out << "\n--- GUARDS ---\n";
999 out << "guard_count() = " << guard_count() << std::endl;
1000 for (std::size_t i = 0; i < guard_count(); i++)
1001 {
1002 out << "guard(" << i << ") = " << print_vector(guard_parameters(i)) << std::endl;
1003 }
1004
1005 out << "\n--- INITIAL STATE ---\n";
1008 out << "initial state = " << print_vector(init, init + process_parameter_count()) << std::endl;
1009 delete[] init;
1010
1011 out << "\n--- DATA TYPE MAPS ---\n";
1012 out << "datatype_count() = " << datatype_count() << std::endl;
1013 for (std::size_t i = 0; i < datatype_count(); i++)
1014 {
1015 const pins_data_type& type = data_type(i);
1016 out << "\n";
1017 out << "datatype " << i << "\n"
1018 << " name = " << type.name() << "\n"
1019 << " size = " << type.size() << "\n"
1020 << " bounded = " << std::boolalpha << type.is_bounded() << "\n";
1021 if (type.is_bounded())
1022 {
1023 out << " possible values: " << core::detail::print_set(type.generate_values(10)) << std::endl;
1024 }
1025 out << std::endl;
1026 }
1027
1028 return out.str();
1029 }
1030};
1031
1032} // namespace lps
1033
1034} // namespace mcrl2
1035
1036#endif // MCRL2_LPS_LTSMIN_H
Read-only balanced binary tree of terms.
size_type size() const
Returns the size of the term_list.
Definition aterm_list.h:256
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the term_list.
Definition aterm_list.h:275
bool is_certainly_finite(const sort_expression &s) const
Checks whether a sort is certainly finite.
An enumerator algorithm that generates solutions of a condition.
Definition enumerator.h:601
An element for the todo list of the enumerator that collects the substitution corresponding to the ex...
Definition enumerator.h:348
Rewriter that operates on data expressions.
Definition rewriter.h:81
basic_rewriter< data_expression >::substitution_type substitution_type
Definition rewriter.h:114
\brief A sort expression
\brief A data variable
Definition variable.h:28
Class for logging messages.
Definition logger.h:129
Models the mapping of mCRL2 action labels to integers.
Definition ltsmin.h:270
const std::string & name() const override
Returns the name of the data type.
Definition ltsmin.h:302
std::size_t parse(const std::string &s) override
Parses a string to a data value, and returns the corresponding index. If the value is not in the mapp...
Definition ltsmin.h:296
std::string print(int i) const override
Returns a human readable representation of the value with index i. N.B. It is not guaranteed that par...
Definition ltsmin.h:291
action_label_data_type(const data::data_specification &data, const process::action_label_list &action_labels)
Definition ltsmin.h:275
std::string serialize(int i) const override
Serializes the i-th value of the data type to a binary string. It is guaranteed that serialize(deseri...
Definition ltsmin.h:281
std::vector< std::string > generate_values(std::size_t) const override
Generates possible values of the data type (at most max_size).
Definition ltsmin.h:308
std::size_t deserialize(const std::string &s) override
Deserializes a string to a data value, and returns the corresponding index. If the value is not in th...
Definition ltsmin.h:286
LPS summand containing a multi-action.
const data::data_expression_list & initial_state() const
Definition explorer.h:1022
const data::rewriter & get_rewriter() const
Definition explorer.h:1028
std::list< transition > out_edges(const state &s, const SummandSequence &regular_summands, const SummandSequence &confluent_summands, data::mutable_indexed_substitution<> &sigma, data::rewriter &rewr, data::enumerator_algorithm<> &enumerator, data::enumerator_identifier_generator &id_generator)
Definition explorer.h:838
const std::vector< ActionSummand > & action_summands() const
Returns the sequence of action summands.
const data::variable_list & process_parameters() const
Returns the sequence of process parameters.
\brief A timed multi-action
Forward iterator used for iterating over indices.
Definition ltsmin.h:81
std::ptrdiff_t distance_to(const index_iterator &other) const
Definition ltsmin.h:105
const std::size_t & dereference() const
Definition ltsmin.h:100
bool equal(const index_iterator &other) const
Definition ltsmin.h:95
index_iterator(std::size_t index=0)
Definition ltsmin.h:83
friend class boost::iterator_core_access
Definition ltsmin.h:88
Models a pins data type. A pins data type maintains a mapping between known values of a data type and...
Definition ltsmin.h:70
utilities::indexed_set< atermpp::aterm > & indexed_set()
Returns the indexed_set holding the values.
Definition ltsmin.h:192
utilities::indexed_set< atermpp::aterm > m_indexed_set
Definition ltsmin.h:72
const utilities::indexed_set< atermpp::aterm > & indexed_set() const
Returns the indexed_set holding the values.
Definition ltsmin.h:198
virtual std::vector< std::string > generate_values(std::size_t max_size) const =0
Generates possible values of the data type (at most max_size).
bool is_bounded() const
Returns true if the number of elements is bounded. If this property can not be computed for a data ty...
Definition ltsmin.h:156
virtual const std::string & name() const =0
Returns the name of the data type.
const data::data_specification & m_data
Definition ltsmin.h:73
virtual std::size_t parse(const std::string &s)=0
Parses a string to a data value, and returns the corresponding index. If the value is not in the mapp...
virtual std::string serialize(int i) const =0
Serializes the i-th value of the data type to a binary string. It is guaranteed that serialize(deseri...
std::size_t size() const
Returns the number of values that are stored in the map.
Definition ltsmin.h:162
virtual std::size_t deserialize(const std::string &s)=0
Deserializes a string to a data value, and returns the corresponding index. If the value is not in th...
pins_data_type(const data::data_specification &data, const process::action_label_list &action_labels, bool is_bounded=false)
Constructor.
Definition ltsmin.h:114
virtual std::string print(int i) const =0
Returns a human readable representation of the value with index i. N.B. It is not guaranteed that par...
index_iterator index_begin() const
Returns an iterator to the beginning of the indices.
Definition ltsmin.h:168
virtual ~pins_data_type()=default
Destructor.
index_iterator index_end() const
Returns an iterator to the end of the indices.
Definition ltsmin.h:174
atermpp::aterm get(std::size_t i)
Returns the value at index i.
Definition ltsmin.h:186
std::size_t operator[](const atermpp::aterm &x)
Returns the index of the value x.
Definition ltsmin.h:180
const process::action_label_list & m_action_labels
Definition ltsmin.h:74
generator_type m_generator
Definition ltsmin.h:333
const std::vector< std::size_t > & guard_parameters(std::size_t index) const
Definition ltsmin.h:767
guard_evaluation_t
guard evaluations have ternary logic. A guard may not always rewrite to true or false
Definition ltsmin.h:321
const linear_process & process() const
Returns the process of the LPS specification.
Definition ltsmin.h:385
int * ltsmin_state_type
Definition ltsmin.h:317
const std::vector< std::size_t > & write_group(std::size_t index) const
Indices of process parameters that influence event or next state of a summand by being written.
Definition ltsmin.h:753
void get_initial_state(ltsmin_state_type &s)
Assigns the initial state to s.
Definition ltsmin.h:820
datatype_index edge_label_type(std::size_t) const
Returns the datatype map index corresponding to edge label i.
Definition ltsmin.h:807
std::string process_parameter_name(std::size_t i) const
Returns a human-readable, unique name for process parameter i.
Definition ltsmin.h:787
std::vector< std::vector< std::size_t > > m_write_group
Definition ltsmin.h:329
std::size_t m_group_count
Definition ltsmin.h:326
std::size_t process_parameter_count() const
Returns the number of process parameters of the LPS.
Definition ltsmin.h:540
pins(const std::string &filename, const std::string &rewriter_strategy)
Constructor.
Definition ltsmin.h:663
void next_state_long(ltsmin_state_type const &src, std::size_t group, StateFunction &f, ltsmin_state_type const &dest, int *const &labels)
Definition ltsmin.h:882
lps::specification m_specification_reduced
Definition ltsmin.h:345
generator_type m_generator_reduced
Definition ltsmin.h:346
std::vector< pins_data_type * > m_unique_data_types
The unique type mappings (is contained in m_data_types).
Definition ltsmin.h:355
data::rewriter::substitution_type substitution_t
Definition ltsmin.h:323
std::size_t edge_label_count() const
Returns the number of labels per edge.
Definition ltsmin.h:800
std::size_t m_state_length
Definition ltsmin.h:327
std::string print_vector(Iter first, Iter last) const
Definition ltsmin.h:404
std::string print_vector(const Container &c) const
Definition ltsmin.h:421
std::size_t datatype_count() const
Returns the number of unique datatype maps. Note that the datatype map for action labels is included,...
Definition ltsmin.h:727
utilities::indexed_set< atermpp::aterm > m_guards
Definition ltsmin.h:338
void update_long(ltsmin_state_type const &src, std::size_t group, StateFunction &f, ltsmin_state_type const &dest, int *const &labels)
Definition ltsmin.h:888
std::set< std::string > summand_action_names(std::size_t i) const
Returns the names of the actions that appear in the summand with index i, with 0 <= i < group_count()...
Definition ltsmin.h:831
lps::specification reduce_specification(const lps::specification &spec)
extracts all guards from the original specification and returns a new one with the guards removed.
Definition ltsmin.h:560
std::size_t guard_count() const
Definition ltsmin.h:777
void next_state_all(ltsmin_state_type const &src, StateFunction &f, ltsmin_state_type const &dest, int *const &labels)
Iterates over the 'next states' of state src, and invokes a callback function for each discovered sta...
Definition ltsmin.h:857
std::vector< std::vector< std::size_t > > m_read_group
Definition ltsmin.h:328
std::string info()
Prints an overview of several relevant attributes.
Definition ltsmin.h:966
static lps::specification load_specification(const std::string &filename)
Definition ltsmin.h:551
guard_evaluation_t eval_guard_long(ltsmin_state_type const &src, std::size_t guard)
Definition ltsmin.h:942
pins_data_type & action_label_type_map()
Returns the action data type.
Definition ltsmin.h:361
const linear_process & process_reduced() const
Returns the reduced process of the LPS specification, i.e. with conditions with guards removed.
Definition ltsmin.h:392
std::vector< std::size_t > m_unique_data_type_index
Definition ltsmin.h:358
pins_data_type & data_type(std::size_t i)
Returns a reference to the datatype map with index i.
Definition ltsmin.h:734
std::vector< std::string > m_guard_names
Definition ltsmin.h:341
const std::vector< std::size_t > & guard_info(std::size_t index) const
Definition ltsmin.h:772
const pins_data_type & action_label_type_map() const
Returns the action data type.
Definition ltsmin.h:367
std::vector< pins_data_type * > m_data_types
Definition ltsmin.h:352
std::vector< data::variable > m_parameters_list
Definition ltsmin.h:335
const pins_data_type & state_type_map(std::size_t i) const
Returns the data type of the i-th state parameter.
Definition ltsmin.h:379
pins_data_type & state_type_map(std::size_t i)
Returns the data type of the i-th state parameter.
Definition ltsmin.h:373
std::vector< std::vector< std::size_t > > m_update_group
Definition ltsmin.h:330
datatype_index process_parameter_type(std::size_t i) const
Returns the datatype map index corresponding to process parameter i.
Definition ltsmin.h:794
const std::vector< std::size_t > & read_group(std::size_t index) const
Indices of process parameters that influence event or next state of a summand by being read.
Definition ltsmin.h:744
std::string edge_label_name(std::size_t) const
Returns the name of the i-th action label (always "action").
Definition ltsmin.h:814
std::size_t datatype_index
Definition ltsmin.h:537
std::vector< std::vector< std::size_t > > m_guard_info
Definition ltsmin.h:340
void initialize_read_write_groups()
Definition ltsmin.h:426
const std::string & guard_name(std::size_t index)
Definition ltsmin.h:782
const std::vector< std::size_t > & update_group(std::size_t index) const
Indices of process parameters that influence event or next state of a summand by being read except fr...
Definition ltsmin.h:762
void _long(ltsmin_state_type const &src, std::size_t group, StateFunction &f, const ltsmin_state_type &dest, int *const &labels, generator_type *generator)
Iterates over the 'next states' of a particular summand of state src that are generated by a group of...
Definition ltsmin.h:913
const data::data_specification & data() const
Returns the data specification of the LPS specification.
Definition ltsmin.h:398
lps::explorer< false, false, lps::specification > generator_type
Definition ltsmin.h:332
std::vector< std::string > m_process_parameter_names
Definition ltsmin.h:336
std::vector< std::vector< std::size_t > > guard_parameters_list
Definition ltsmin.h:339
std::size_t group_count() const
Returns the number of available groups. This equals the number of action summands of the LPS.
Definition ltsmin.h:546
lps::specification m_specification
Definition ltsmin.h:331
const std::set< data::variable > & global_variables() const
Returns the declared free variables of the LPS.
const process::action_label_list & action_labels() const
Returns a sequence of action labels. This sequence contains all action labels occurring in the specif...
const InitialProcessExpression & initial_process() const
Returns the initial process.
const LinearProcess & process() const
Returns the linear process of the specification.
const data::data_specification & data() const
Returns the data specification.
Linear process specification.
Models the mapping of mCRL2 state values to integers.
Definition ltsmin.h:206
std::size_t expression2index(const data::data_expression &x)
Definition ltsmin.h:211
data::data_expression index2expression(std::size_t i) const
Definition ltsmin.h:216
std::size_t parse(const std::string &s) override
Parses a string to a data value, and returns the corresponding index. If the value is not in the mapp...
Definition ltsmin.h:252
std::string print(int i) const override
Returns a human readable representation of the value with index i. N.B. It is not guaranteed that par...
Definition ltsmin.h:247
data::sort_expression m_sort
Definition ltsmin.h:209
std::size_t deserialize(const std::string &s) override
Deserializes a string to a data value, and returns the corresponding index. If the value is not in th...
Definition ltsmin.h:241
std::string serialize(int i) const override
Serializes the i-th value of the data type to a binary string. It is guaranteed that serialize(deseri...
Definition ltsmin.h:234
std::vector< std::string > generate_values(std::size_t max_size) const override
Generates possible values of the data type (at most max_size).
Definition ltsmin.h:262
const std::string & name() const override
Returns the name of the data type.
Definition ltsmin.h:257
state_data_type(const data::data_specification &data, const process::action_label_list &action_labels, const data::sort_expression &sort, bool sort_is_finite)
Definition ltsmin.h:222
A set that assigns each element an unique index.
Definition indexed_set.h:33
Join and split functions for data expressions.
add your file description here.
MCRL2_EXPORT bool init(rewriter_interface *i, RewriterCompilingJitty *this_rewriter)
static RewriterCompilingJitty::substitution_type & sigma(RewriterCompilingJitty *this_rewriter)
@ proc
Definition linearise.cpp:79
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:391
IO routines for linear process specifications.
add your file description here.
mcrl2::log::log_level_t mcrl2_log_level_t
Definition ltsmin.h:24
aterm read_term_from_string(const std::string &s)
Reads an aterm from a string. The string can be in either binary or text format.
std::string print_set(const Container &v, const std::string &message="", bool print_index=false, bool boundary_spaces=true)
Creates a string representation of a container.
atermpp::aterm add_index(const atermpp::aterm &x)
Definition io.h:55
atermpp::aterm remove_index(const atermpp::aterm &x)
Definition io.h:61
const function_symbol & and_()
Constructor for function symbol &&.
Definition bool.h:235
const function_symbol & false_()
Constructor for function symbol false.
Definition bool.h:109
const function_symbol & true_()
Constructor for function symbol true.
Definition bool.h:77
data_expression parse_data_expression(std::istream &in, const VariableContainer &variables, const data_specification &dataspec=detail::default_specification(), bool type_check=true, bool translate_user_notation=true, bool normalize_sorts=true)
Parses and type checks a data expression.
Definition parse.h:276
std::set< data::variable > find_all_variables(const data::data_expression &x)
Definition data.cpp:94
std::vector< data_expression > data_expression_vector
\brief vector of data_expressions
std::string pp(const abstraction &x)
Definition data.cpp:39
std::set< data::variable > find_free_variables(const data::data_expression &x)
Definition data.cpp:99
std::set< data_expression > split_and(const data_expression &expr)
Splits a conjunction into a sequence of operands Given a data expression of the form p1 && p2 && ....
Definition join.h:68
log_level_t
Log levels that are supported.
Definition logger.h:31
@ verbose
Definition logger.h:37
std::string pp(const action_summand &x)
Definition lps.cpp:26
std::set< data::variable > find_free_variables(const lps::deadlock &x)
Definition lps.cpp:54
std::vector< std::string > generate_values(const data::data_specification &dataspec, const data::sort_expression &s, std::size_t max_size=1000)
Generates possible values of the data type (at most max_size).
Definition ltsmin.h:41
multi_action parse_multi_action(std::stringstream &in, const process::action_label_list &action_decls, const data::data_specification &data_spec=data::detail::default_specification())
Parses a multi_action from an input stream.
Definition parse.h:42
void load_lps(Specification &spec, std::istream &stream, const std::string &source="")
Load LPS from file.
Definition io.h:54
std::set< data::variable > used_read_variables(const action_summand &summand)
Definition confluence.h:85
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72