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//
9/// \file mcrl2/lps/ltsmin.h
10/// \brief add your file description here.
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
25using mcrl2::log::logger;
26
27namespace mcrl2::log {
28 using mcrl2_logger = mcrl2::log::logger;
29}
30
31#ifdef MCRL2_ENABLE_JITTYC
32#define MCRL2_JITTYC_AVAILABLE
33#endif
34
35namespace mcrl2 {
36
37namespace lps {
38
39/// \brief Generates possible values of the data type (at most max_size).
40inline
42{
43 typedef data::enumerator_list_element_with_substitution<> enumerator_element;
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);
51 data::mutable_indexed_substitution<> sigma;
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
67/// \brief Models a pins data type. A pins data type maintains a mapping between known values
68/// of a data type and integers.
70{
71 protected:
76
77 public:
78
79 /// \brief Forward iterator used for iterating over indices.
81 {
82 public:
83 explicit index_iterator(std::size_t index = 0)
84 : m_index(index)
85 {}
86
87 private:
88 friend class boost::iterator_core_access;
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
113 /// \brief Constructor
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),
120 m_is_bounded(is_bounded)
121 {}
122
123 /// \brief Destructor.
124 virtual ~pins_data_type() = default;
125
126 /// \brief Serializes the i-th value of the data type to a binary string.
127 /// It is guaranteed that serialize(deserialize(i)) == i.
128 /// \pre i is a valid index
129 virtual std::string serialize(int i) const = 0;
130
131 /// \brief Deserializes a string to a data value, and returns the corresponding index.
132 /// If the value is not in the mapping, it will be added.
133 /// \return The index of the data value.
134 /// \throw <std::runtime_error> { if deserialization failed }
135 virtual std::size_t deserialize(const std::string& s) = 0;
136
137 /// \brief Returns a human readable representation of the value with index i.
138 /// N.B. It is not guaranteed that parse(print(i)) == i.
139 /// \pre i is a valid index
140 virtual std::string print(int i) const = 0;
141
142 /// \brief Parses a string to a data value, and returns the corresponding index.
143 /// If the value is not in the mapping, it will be added.
144 /// \return The index of the data value.
145 /// \throw <std::runtime_error> { if parsing failed }
146 virtual std::size_t parse(const std::string& s) = 0;
147
148 /// \brief Returns the name of the data type.
149 virtual const std::string& name() const = 0;
150
151 /// \brief Generates possible values of the data type (at most max_size).
153
154 /// \brief Returns true if the number of elements is bounded. If this property can
155 /// not be computed for a data type, false is returned.
156 bool is_bounded() const
157 {
158 return m_is_bounded;
159 }
160
161 /// \brief Returns the number of values that are stored in the map.
162 std::size_t size() const
163 {
164 return m_indexed_set.size();
165 }
166
167 /// \brief Returns an iterator to the beginning of the indices
169 {
170 return index_iterator(0);
171 }
172
173 /// \brief Returns an iterator to the end of the indices
175 {
177 }
178
179 /// \brief Returns the index of the value x
180 std::size_t operator[](const atermpp::aterm& x)
181 {
182 return m_indexed_set.insert(x).first;
183 }
184
185 /// \brief Returns the value at index i
186 atermpp::aterm get(std::size_t i)
187 {
188 return m_indexed_set.at(i);
189 }
190
191 /// \brief Returns the indexed_set holding the values
193 {
194 return m_indexed_set;
195 }
196
197 /// \brief Returns the indexed_set holding the values
199 {
200 return m_indexed_set;
201 }
202};
203
204/// \brief Models the mapping of mCRL2 state values to integers.
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 {
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
263 {
264 return lps::generate_values(m_data, m_sort, max_size);
265 }
266};
267
268/// \brief Models the mapping of mCRL2 action labels to integers.
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 {
293 return lps::pp(lps::multi_action(m_indexed_set.at(i)));
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
309 {
310 return std::vector<std::string>();
311 }
312};
313
314class pins
315{
316 public:
317 typedef int* ltsmin_state_type; /**< the state type used by LTSMin */
318
319 /// \brief guard evaluations have ternary logic. A guard may not always rewrite
320 /// to true or false
322
324
325 protected:
327 std::size_t m_state_length; /**< the number of process parameters */
332 typedef lps::explorer<false, false, lps::specification> generator_type;
334
337
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
353
354 /// The unique type mappings (is contained in m_data_types).
356
357 // maps process parameter index to the corresponding index in m_unique_data_types
359
360 /// \brief Returns the action data type
362 {
363 return *m_data_types.back();
364 }
365
366 /// \brief Returns the action data type
368 {
369 return *m_data_types.back();
370 }
371
372 /// \brief Returns the data type of the i-th state parameter
374 {
375 return *m_data_types[i];
376 }
377
378 /// \brief Returns the data type of the i-th state parameter
379 const pins_data_type& state_type_map(std::size_t i) const
380 {
381 return *m_data_types[i];
382 }
383
384 /// \brief Returns the process of the LPS specification
385 const linear_process& process() const
386 {
387 return m_specification.process();
388 }
389
390 /// \brief Returns the reduced process of the LPS specification,
391 /// i.e. with conditions with guards removed.
393 {
394 return m_specification_reduced.process();
395 }
396
397 /// \brief Returns the data specification of the LPS specification
398 const data::data_specification& data() const
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
430 const lps::linear_process& proc = process();
431
432 m_group_count = proc.action_summands().size();
433 m_state_length = proc.process_parameters().size();
434
435 m_read_group.resize(m_group_count);
436 m_write_group.resize(m_group_count);
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(),
463 used_read_variables.end(),
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
492 m_update_group.resize(m_group_count);
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; /**< the index type for datatype maps */
538
539 /// \brief Returns the number of process parameters of the LPS
541 {
542 return m_specification.process().process_parameters().size();
543 }
544
545 /// \brief Returns the number of available groups. This equals the number of action summands of the LPS.
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 {
553 lps::specification specification;
554 load_lps(specification, filename);
555 return specification;
556 }
557
558 /// \brief extracts all guards from the original specification and
559 /// returns a new one with the guards removed.
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);
580 bool is_new = (at == utilities::indexed_set<atermpp::aterm>::npos);
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));
603 mCRL2log(log::verbose)
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));
636 guard_parameters_list.push_back(guard_parameters);
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
656 lps::specification specification_reduced(m_specification.data(), m_specification.action_labels(), m_specification.global_variables(), lps_reduced, m_specification.initial_process());
657 return specification_reduced;
658 }
659
660 /// \brief Constructor
661 /// \param filename The name of a file containing an mCRL2 specification
662 /// \param rewriter_strategy The rewriter strategy used for generating next states
663 pins(const std::string& filename, const std::string& rewriter_strategy)
664 : m_specification(load_specification(filename)),
665 m_generator(m_specification, data::parse_rewrite_strategy(rewriter_strategy)),
666 m_parameters_list(process().process_parameters().begin(), process().process_parameters().end()),
667 m_specification_reduced(reduce_specification(m_specification)),
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
673 data::variable_list params = m_specification.process().process_parameters();
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 {
689 pins_data_type* dt = new state_data_type(m_specification.data(), m_specification.action_labels(), s, m_specification.data().is_certainly_finite(s));
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 }
699 pins_data_type* dt = new action_label_data_type(m_specification.data(), m_specification.action_labels());
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
725 /// \brief Returns the number of unique datatype maps. Note that the datatype map for action labels is included,
726 /// so this number equals the number of different process parameter types + 1.
727 std::size_t datatype_count() const
728 {
729 return m_unique_data_types.size();
730 }
731
732 /// \brief Returns a reference to the datatype map with index i.
733 /// \pre 0 <= i < datatype_count()
735 {
736 assert (i < m_data_types.size());
737 return *m_unique_data_types[i];
738 }
739
740 /// \brief Indices of process parameters that influence event or next state of a summand by being read
741 /// \param[in] index the selected summand
742 /// \returns reference to a vector of indices of parameters
743 /// \pre 0 <= i < group_count()
745 {
746 return m_read_group[index];
747 }
748
749 /// \brief Indices of process parameters that influence event or next state of a summand by being written
750 /// \param[in] index the selected summand
751 /// \returns reference to a vector of indices of parameters
752 /// \pre 0 <= i < group_count()
754 {
755 return m_write_group[index];
756 }
757
758 /// \brief Indices of process parameters that influence event or next state of a summand by being read except from the guards.
759 /// \param[in] index the selected summand
760 /// \returns reference to a vector of indices of parameters
761 /// \pre 0 <= i < group_count()
763 {
764 return m_update_group[index];
765 }
766
768 {
769 return guard_parameters_list[index];
770 }
771
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
786 /// \brief Returns a human-readable, unique name for process parameter i
787 std::string process_parameter_name(std::size_t i) const
788 {
789 return m_process_parameter_names[i];
790 }
791
792 /// \brief Returns the datatype map index corresponding to process parameter i
793 /// \pre 0 <= i < process_parameter_count()
795 {
796 return m_unique_data_type_index[i];
797 }
798
799 /// \brief Returns the number of labels per edge.
800 std::size_t edge_label_count() const
801 {
802 return 1;
803 }
804
805 /// \brief Returns the datatype map index corresponding to edge label i
806 /// \pre 0 <= i < edge_label_count()
808 {
809 return m_unique_data_types.size() - 1;
810 }
811
812 /// \brief Returns the name of the i-th action label (always "action").
813 /// \pre 0 <= i < edge_label_count()
814 std::string edge_label_name(std::size_t) const
815 {
817 }
818
819 /// \brief Assigns the initial state to s.
821 {
822 state initial_state(m_generator.initial_state().begin(), m_generator.initial_state().size());
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
829 /// \brief Returns the names of the actions that appear in the summand with index i,
830 /// with 0 <= i < group_count().
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
843 /// \brief Iterates over the 'next states' of state src, and invokes a callback function for each discovered state.
844 ///
845 /// StateFunction is a callback function that must provide the function operator() with the following interface:
846 /// <code>void operator()(ltsmin_state_type const& next_state, int* const& edge_labels, int group=-1);</code>
847 /// where
848 /// - \a next_state is the target state of the transition
849 /// - \a edge_labels is an array of edge labels
850 /// - \a group is the number of the summand from which the next state was generated, or -1 if it is unknown which summand
851 ///
852 /// \param src An LTSMin state
853 /// \param f A 'callback' function object
854 /// \param dest A destination state, which is modified and passed to the callback. Must provide space for at least process_parameter_count() items.
855 /// \param labels An array of labels, which is modified and passed to the callback. Must provide space for at least edge_label_count() items.
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
893 /// \brief Iterates over the 'next states' of a particular summand
894 /// of state src that are generated by a group of summands, and
895 /// invokes a callback function for each discovered state.
896 ///
897 /// StateFunction is a callback function that must provide the function operator() with the following interface:
898 /// <code>void operator()(ltsmin_state_type const& next_state, int* const& edge_labels, int group);</code>
899 /// where
900 /// - next_state is the target state of the transition
901 /// - edge_labels is an array of edge labels
902 /// - group is the number of the summand from which the next state was generated, or -1 if it is unknown which summand
903 ///
904 /// \param src An LTSMin state.
905 /// \param group the number of the summand.
906 /// \param f A state function.
907 /// \param dest A destination state, which is modified and passed to the callback.
908 /// Must provide space for at least process_parameter_count() items.
909 /// \param labels An array of labels, which is modified and passed to the callback.
910 /// Must provide space for at least edge_label_count() items.
911 /// \param generator The next state generator to use.
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
943 std::size_t nparams = process_parameter_count();
944 substitution_t substitution;
945 for (std::size_t i = 0; i < nparams; i++)
946 {
948 substitution[m_parameters_list[i]] = value;
949 }
950
951 // get the result by rewriting the guard with the substitution.
952 data::data_expression result = m_generator_reduced.get_rewriter()(
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
965 /// \brief Prints an overview of several relevant attributes.
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
aterm_string(const std::string &s)
Constructor that allows construction from a string.
aterm(const aterm &other) noexcept=default
This class has user-declared copy constructor so declare default copy and move operators.
bool operator==(const unprotected_aterm_core &t) const
Comparison operator.
Definition aterm_core.h:83
bool operator!=(const unprotected_aterm_core &t) const
Inequality operator on two unprotected aterms.
Definition aterm_core.h:92
data_expression(const atermpp::aterm &term)
An enumerator algorithm that generates solutions of a condition.
Definition enumerator.h:601
Components for generating an arbitrary element of a sort.
representative_generator(const data_specification &specification)
Constructor with data specification as context.
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
sort_expression(const sort_expression &) noexcept=default
Move semantics.
\brief A data variable
Definition variable.h:28
const core::identifier_string & name() const
Definition variable.h:38
const sort_expression & sort() const
Definition variable.h:43
Class for logging messages.
Definition logger.h:129
logger(const log_level_t l)
Default constructor.
Definition logger.h:164
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::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
\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
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::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
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
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::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
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
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
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::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::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
\brief The and operator for pbes expressions
and_(const pbes_expression &left, const pbes_expression &right)
\brief Constructor Z14.
std::set< pbes_expression > get_successors(const pbes_expression &phi)
Returns the successors of a state, which is a instantiated propositional variable....
virtual std::string print_successors(const std::set< pbes_expression > &successors)
Prints the set of successors states.
pbes_greybox_interface(pbes &p, bool true_false_dependencies=false, bool is_min_parity=true, data::rewriter::strategy rewrite_strategy=data::jitty)
Constructor.
pbes_system::enumerate_quantifiers_rewriter pbes_rewriter
pbes_equation get_pbes_equation(const core::identifier_string &s)
Returns the equation for variable s.
propositional_variable_instantiation get_initial_state()
Returns the initial state, rewritten and simplified.
pbes_expression rewrite_and_simplify_expression(const pbes_expression &e, const bool=true)
Rewrites and simplifies an expression.
virtual pbes_expression expand_group(const pbes_expression &psi, const pbes_expression &expr)
Expands a formula expr for a instantiated state variable psi, which means substituting the variables ...
virtual bool visit_inner_bounded_exists(const pbes_expression &e)
Visits a bounded existential quantifier expression within a disjunctive expression.
Definition ppg_visitor.h:97
virtual bool visit_inner_implies(const pbes_expression &e)
Visits a disjunctive expression within an inner universal quantifier expression.
virtual bool visit_or(const pbes_expression &e)
Visits a disjunctive expression.
static std::string print_brief(const pbes_expression &e)
Returns a string representation of the type of the root node of the expression.
Definition ppg_visitor.h:43
virtual bool visit_and(const pbes_expression &e)
Visits a conjunctive expression.
virtual bool visit_propositional_variable(const pbes_expression &e)
Visits a propositional variable expression.
Definition ppg_visitor.h:62
bqnf_visitor bqnf
The BQNF visitor type.
Definition ppg_visitor.h:30
virtual bool visit_inner_and(const pbes_expression &e)
Visits a conjunctive expression within an inner existential quantifier expression.
Definition ppg_visitor.h:76
virtual bool visit_ppg_expression(const pbes_expression &e)
Visits a PPG expression.
virtual bool visit_inner_bounded_forall(const pbes_expression &e)
Visits a bounded universal quantifier expression within a conjunctive expression.
virtual bool visit_simple_expression(const pbes_expression &e)
Visits a simple expression. An expression is simple if it does not contain propositional variables.
Definition ppg_visitor.h:52
\brief The existential quantification operator for pbes expressions
static ltsmin_state false_state()
Returns the state representing false.
ltsmin_state get_state(const propositional_variable_instantiation &expr) const
Returns a PBES_State object for expr.
std::vector< std::vector< data_expression > > localmaps_int2data
std::vector< ltsmin_state > get_successors(const ltsmin_state &state, int group)
Computes successor states for a state as defined in transition group group. Serves as a wrapper aroun...
std::string data_to_string(const data::data_expression &e)
Returns a string representation for the data expression e.
int get_index(int type_no, const std::string &s)
Returns the index of value in the local store for the data type with number type_no....
std::vector< std::string > localmap_int2string
ltsmin_state get_initial_state() const
Returns the initial state.
static ltsmin_state true_state()
Returns the state representing true.
void to_state_vector(const ltsmin_state &dst_state, int *dst, const ltsmin_state &src_state, int *const &src)
Transforms a PBES state to a state vector, represented by an array of integers.
std::string get_value(int type_no, int index)
Returns the value at position index in the local store for the data type with number type_no....
int get_value_index(int type_no, const data_expression &value)
Returns the index of value in the local store for the data type with number type_no....
explorer(const std::string &filename, const std::string &rewrite_strategy, bool reset_flag, bool always_split_flag)
Constructor.
std::map< std::string, int > localmap_string2int
void next_state_long(int *const &src, int group, callback &cb)
Iterates over the successors of a state for a certain transition group and invokes a callback functio...
explorer(const pbes &p_, const std::string &rewrite_strategy, bool reset_flag, bool always_split_flag)
Constructor.
std::vector< std::map< data_expression, int > > localmaps_data2int
ltsmin_state from_state_vector(int *const &src)
Transforms a state vector src into a PBES_State object object containing the variable and parameter v...
int get_string_index(const std::string &s)
Returns the index of s in the local store for string values. This store is reserved for the string re...
const std::string & get_string_value(int index)
Returns the string at position index in the local store for string values. An exception is thrown if ...
std::vector< ltsmin_state > get_successors(const ltsmin_state &state)
Computes successor states for a state. Serves as a wrapper around the get_successors function of the ...
data::data_expression string_to_data(const std::string &s)
Returns a data expression for the string representation s.
lts_info * get_info() const
Returns the PBES_Info object.
const data_expression & get_data_value(int type_no, int index)
Returns the value at position index in the local store for the data type with number type_no....
void next_state_all(int *const &src, callback &cb)
Iterates over the successors of a state and invokes a callback function for each successor state.
detail::pbes_greybox_interface * pgg
the PBES greybox interface
static fixpoint_symbol nu()
Returns the nu symbol.
fixpoint_symbol & operator=(fixpoint_symbol &&) noexcept=default
static fixpoint_symbol mu()
Returns the mu symbol.
\brief The universal quantification operator for pbes expressions
\brief The implication operator for pbes expressions
bool is_write_dependent_propvar(int group)
Determines if group is write dependent on the propositional variable. Returns true if propositional v...
const std::map< std::string, std::map< int, int > > & get_variable_parameter_index_positions() const
Returns the map from variable names to the map from indices of parameter signatures for the variable ...
std::map< std::string, int > variable_priority
const std::map< int, std::vector< bool > > & get_read_matrix() const
Returns the read dependency matrix.
const std::map< int, std::vector< bool > > & get_write_matrix() const
Returns the write dependency matrix.
static std::vector< std::string > get_param_sequence(const data::variable_list &params)
Converts a variable_sequence_type into a sequence of parameter signatures.
bool is_read_dependent_parameter(int group, int part)
Determines if group is read dependent on part part of the state vector. Returns true if the parameter...
std::vector< int > get_param_indices(const data::variable_list &params)
Converts a variable_sequence_type into a sequence of indices of parameter signatures in the list of p...
std::vector< std::string > transition_variable_name
bool is_pass_through_state(const propositional_variable_instantiation &propvar)
Determines if the propositional variable instantiation is one that only copies parameters from the cu...
const std::map< std::string, fixpoint_symbol > & get_variable_symbols() const
Returns the map from variable names to the fixpoint operator of the equation for the variable.
static std::map< variable, std::string > variable_signatures
std::map< std::string, fixpoint_symbol > variable_symbol
const std::map< std::string, data::variable_list > & get_variable_parameters() const
Returns the map from variable names to the sequence of parameters for the variable.
const std::map< std::string, std::vector< std::string > > & get_variable_parameter_signatures() const
Returns the map from variable names to the list of parameters signatures for the variable.
const std::map< std::string, propositional_variable > & get_variables() const
Returns the map from variable names to the variable object for the variable.
int get_index(const std::string &signature)
Returns the index for a parameter signature in the list of parameter signatures for the system.
const lts_type & get_lts_type() const
Returns the LTS Type.
std::map< std::string, int > param_index
bool get_reset_option() const
Returns if the reset option is set.
std::set< std::string > copied(const pbes_expression &expr, const std::set< std::string > &L)
Computes the free variables which are copied/passed through (to a recursive variable) in an expressio...
std::map< std::string, std::vector< std::string > > variable_parameter_signatures
const std::vector< pbes_expression > & get_transition_expressions() const
Returns the map from transition group number to the expression of the transition group.
std::set< std::string > copied(const pbes_expression &expr)
Computes the free variables which are copied/passed through (to a recursive variable) in an expressio...
std::map< int, std::vector< bool > > read_matrix
std::vector< data_expression > param_default_values
detail::pbes_greybox_interface * pgg
bool is_read_dependent_propvar(int group)
Determines if group is read dependent on the propositional variable. Returns true,...
std::vector< pbes_expression > transition_expression
const std::map< int, std::vector< bool > > & get_dependency_matrix() const
Returns the dependency matrix.
const std::vector< operation_type > & get_transition_types() const
Returns the map from transition group number to the type of the right hand side of the equation to wh...
std::set< std::string > used(const pbes_expression &expr, const std::set< std::string > &L)
Computes the free variables actually used, not only passed through, in an expression.
std::set< std::string > used(const pbes_expression &expr)
Computes the free variables actually used, not only passed through, in an expression.
std::map< std::string, std::map< int, int > > variable_parameter_index_positions
static std::string get_param_signature(const variable &param)
Returns a signature for parameter param.
const std::map< std::string, operation_type > & get_variable_types() const
Returns the map from variable names to the type of the right hand side of the equation for the variab...
void compute_dependency_matrix()
Computes dependency matrix from PBES.
lts_info(pbes &p, detail::pbes_greybox_interface *pgg, bool reset, bool always_split)
Constructor.
static bool tf(const pbes_expression &phi)
Determines if the term phi contains a branch that directly results in true or false (not a variable).
std::vector< pbes_expression > split_expression_and_substitute_variables(const pbes_expression &e, int current_priority, operation_type current_type, std::set< std::string > vars_stack)
Splits the expression into parts (disjuncts or conjuncts) and recursively tries to substitute the pro...
std::map< std::string, propositional_variable > variables
int get_number_of_groups() const
Returns the number of transition groups.
static std::set< std::string > get_param_set(const data::variable_list &params)
Converts a variable_sequence_type into a set of parameter signatures.
std::map< int, int > get_param_index_positions(const data::variable_list &params)
Converts a variable_sequence_type into a map from indices of parameter signatures (in the list of par...
static std::set< std::string > occ(const pbes_expression &expr)
Computes the propositional variables used in an expression.
std::map< std::string, operation_type > variable_type
int count_variables(const pbes_expression &e)
Counts the number of propositional variables in an expression.
void compute_lts_type()
Computes LTS Type from PBES.
std::vector< operation_type > transition_type
std::set< std::string > changed(const pbes_expression &phi, const std::set< std::string > &L)
Computes the set of parameters changed in the expression.
std::string state_to_string(const ltsmin_state &state)
Returns a string representation for state state.
const std::map< std::string, int > & get_variable_priorities() const
Returns the map from variable names to the priority of the equation for the variable.
std::map< std::string, data::variable_list > variable_parameters
const data_expression & get_default_value(int index)
Returns a default value for the sort of a parameter signature.
const std::vector< std::string > & get_transition_variable_names() const
Returns the map from transition group number to the variable name of the equation to which the transi...
std::map< int, std::vector< bool > > matrix
std::set< std::string > reset(const pbes_expression &phi, const std::set< std::string > &d)
Computes the set of parameters reset in the expression.
static std::string get_param_signature(const std::string &paramname, const std::string &paramtype)
Returns a signature using name and type of a parameter.
static std::set< std::string > free(const pbes_expression &expr)
Computes the free variables read in an expression.
std::vector< pbes_expression > transition_expression_plain
std::map< int, std::vector< bool > > write_matrix
bool is_write_dependent_parameter(int group, int part)
Determines if group is read dependent on part part of the state vector. Returns true if the parameter...
std::map< std::string, pbes_expression > variable_expression
std::set< std::string > changed(const pbes_expression &phi)
Computes the set of parameters changed in the expression.
std::map< std::string, std::vector< int > > variable_parameter_indices
void compute_transition_groups()
Computes transition groups from PBES.
const std::map< std::string, std::vector< int > > & get_variable_parameter_indices() const
Returns the map from variable names to the list of indices of the parameters signatures for the varia...
const std::vector< std::string > & get_edge_label_types() const
Returns the sequence of edge label types.
std::size_t get_number_of_state_types() const
Returns the number of state types.
const std::vector< std::string > & get_edge_labels() const
Returns the sequence of edge labels.
int get_state_type_no(int part) const
Returns the state type index for the state part part.
std::vector< std::string > state_type_list
std::vector< std::string > state_label_types
std::vector< std::string > state_names
std::vector< int > state_type_no
void add_state(const std::string &name, const std::string &type)
Adds a state part of type type with name name.
void add_state_label(const std::string &name, const std::string &type)
Adds a state label of type type with name name.
lts_type(int state_length)
Contructor.
std::string get_state_type_name(int type_no) const
Returns the name of the state type with number type_no.
int get_state_length() const
Returns the state length.
std::map< std::string, int > state_type_index
std::vector< std::string > edge_label_names
const std::vector< std::string > & get_state_label_types() const
Returns the sequence of state label types.
std::vector< std::string > edge_label_types
std::vector< std::string > state_types
std::size_t get_number_of_edge_labels() const
Returns the number of edge labels.
std::vector< std::string > state_label_names
const std::vector< std::string > & get_state_types() const
Returns the sequence of state part types.
void add_edge_label(const std::string &name, const std::string &type)
Adds an edge label of type type with name name.
const std::vector< std::string > & get_state_labels() const
Returns the sequence of state labels.
const std::vector< std::string > & get_state_names() const
Returns the sequence of state part names.
std::size_t get_number_of_state_labels() const
Returns the number of state labels.
void add_parameter_value(const data_expression &)
Adds a parameter value to the list of parameter values.
pbes_expression to_pbes_expression() const
Returns a PBES expression representing the state.
std::vector< data_expression > param_values
std::string state_to_string() const
Returns the player or type of the state (And/Or, Abelard/Eloise, Odd/Even).
bool operator<(const ltsmin_state &other) const
Compares two PBES_State objects. Uses lexicographical ordering on priority, type, variable and parame...
ltsmin_state(const std::string &varname)
Constructor.
bool operator==(const ltsmin_state &other) const
Checks if two PBES_State objects are equal.
ltsmin_state(const std::string &varname, const pbes_expression &e)
Constructor.
std::string get_variable() const
Returns the priority for the state, which depends on the fixpoint operator of the equation of the pro...
const std::vector< data_expression > & get_parameter_values() const
Returns the list of parameter values.
\brief The not operator for pbes expressions
\brief The or operator for pbes expressions
or_(const pbes_expression &left, const pbes_expression &right)
\brief Constructor Z14.
Class for generating a BES from a PBES. This BES can be interpreted as a graph corresponding to a par...
void compute_priorities(const std::vector< pbes_equation > &equations)
Compute priorities of PBES propositional variables.
std::vector< std::pair< pbes_expression, std::size_t > > m_bes
Contains intermediate results of the BES that is being generated. m_bes[i] represents a BES equation ...
virtual operation_type get_expression_operation(const pbes_expression &phi)
Returns the vertex type.
parity_game_generator(pbes &p, bool true_false_dependencies=false, bool is_min_parity=true, data::rewriter::strategy rewrite_strategy=data::jitty)
Constructor.
virtual void print_variable_mapping()
Prints the mapping from BES variables to the corresponding PBES expressions.
std::map< core::identifier_string, std::size_t > m_priorities
Maps propositional variables to corresponding priorities.
void compute_equation_index_map()
Compute equation index map.
pbes_expression expand_rhs(const pbes_expression &psi)
virtual operation_type get_operation(std::size_t index)
Returns the vertex type.
bool m_true_false_dependencies
Determines what kind of BES equations are generated for true and false.
virtual propositional_variable_instantiation get_initial_state()
Returns the (rewritten) initial state.
std::string print_equation_count(std::size_t size, std::size_t step=1000) const
Prints a log message for every step-th equation.
std::map< core::identifier_string, std::vector< pbes_equation >::const_iterator > m_pbes_equation_index
Maps propositional variables to corresponding PBES equations.
std::map< pbes_expression, std::size_t > m_pbes_expression_index
Maps PBES closed expressions to corresponding BES variables.
std::size_t m_max_priority
The maximum priority value of the game.
pbes_system::enumerate_quantifiers_rewriter R
PBES rewriter.
void make_substitution(const data::variable_list &v, const data::data_expression_list &e, substitution_function &sigma) const
Generates a substitution function for the pbesinst rewriter.
pbes & m_pbes
The PBES that is being solved.
virtual std::size_t get_priority(std::size_t index)
Returns the priority of a vertex. The priority of the first equation is 0 if it is a maximal fixpoint...
virtual std::set< std::size_t > get_initial_values()
Returns the vertices for which a solution is requested. By default a set containing the values 0,...
virtual std::string print_bes_equation(std::size_t index, const std::set< std::size_t > &rhs)
operation_type
The operation type of the vertices.
data::rewriter::substitution_type substitution_function
Substitution function type used by the PBES rewriter.
bool m_is_min_parity_game
True if it is a min-parity game.
std::size_t add_bes_equation(pbes_expression t, std::size_t priority)
Adds a BES equation for a given PBES expression, if it not already exists.
bool m_initialized
Mark whether initialization has been initialized. Needed to properly cope with virtual inheritance!
virtual std::set< std::size_t > get_dependencies(std::size_t index)
Returns the successors of a vertex in the graph.
const pbes_expression & formula() const
Returns the predicate formula on the right hand side of the equation.
const fixpoint_symbol & symbol() const
Returns the fixpoint symbol of the equation.
const propositional_variable & variable() const
Returns the pbes variable of the equation.
pbes_expression & operator=(pbes_expression &&) noexcept=default
pbes_expression & operator=(const pbes_expression &) noexcept=default
parameterized boolean equation system
Definition pbes.h:58
propositional_variable_instantiation & initial_state()
Returns the initial state.
Definition pbes.h:199
\brief A propositional variable instantiation
const data::data_expression_list & parameters() const
\brief A propositional variable declaration
const data::variable_list & parameters() const
const core::identifier_string & name() const
propositional_variable(const core::identifier_string &name, const data::variable_list &parameters)
\brief Constructor Z12.
Standard exception class for reporting runtime errors.
Definition exception.h:27
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:391
mcrl2::log::log_level_t mcrl2_log_level_t
Definition ltsmin.h:24
The main namespace for the aterm++ library.
Definition algorithm.h:21
std::string pp(const atermpp::aterm &t)
Transform an aterm to an ascii string.
Definition aterm.h:440
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.
atermpp::aterm_string identifier_string
String type of the LPS library. Identifier strings are represented internally as ATerms.
atermpp::aterm add_index(const atermpp::aterm &x)
Definition io.h:55
atermpp::aterm remove_index(const atermpp::aterm &x)
Definition io.h:61
Namespace for system defined sort bool_.
Definition bool.h:32
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
Namespace for all data library functionality.
Definition data.cpp:22
std::vector< data_expression > data_expression_vector
\brief vector of data_expressions
atermpp::term_list< data_expression > data_expression_list
\brief list of data_expressions
data_expression parse_data_expression(const std::string &text, const data_specification &data_spec=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:354
atermpp::term_list< variable > variable_list
\brief list of variables
std::string pp(const data::sort_expression &x)
Definition data.cpp:69
std::string pp(const data::data_expression &x)
Definition data.cpp:52
log_level_t
Log levels that are supported.
Definition logger.h:31
@ verbose
Definition logger.h:37
The main namespace for the LPS library.
Definition constelm.h:21
multi_action parse_multi_action(const std::string &text, const process::action_label_list &action_decls, const data::data_specification &data_spec=data::detail::default_specification())
Parses a multi_action from a string.
Definition parse.h:70
atermpp::term_balanced_tree< data::data_expression > state
Definition state.h:24
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
The namespace for accessor functions on pbes expressions.
const pbes_expression & arg(const pbes_expression &t)
Returns the pbes expression argument of expressions of type not, exists and forall.
const pbes_expression & left(const pbes_expression &t)
Returns the left hand side of an expression of type and, or or imp.
const pbes_expression & right(const pbes_expression &t)
Returns the right hand side of an expression of type and, or or imp.
void instantiate_global_variables(pbes &p)
Attempts to eliminate the free variables of a PBES, by substituting a constant value for them....
Definition pbes.cpp:65
void normalize(pbes &x)
The function normalize brings (embedded) pbes expressions into positive normal form,...
static void inc_indent()
Increases the current indent level.
static void indent()
Indents according to the current indent level.
static void dec_indent()
Decreases the current indent level.
void check_bes_equation_limit(std::size_t size)
static int indent_count
The current indent level. Used for debug output.
void set_bes_equation_limit(std::size_t size)
MapContainer::mapped_type map_at(const MapContainer &m, typename MapContainer::key_type key)
The main namespace for the PBES library.
pbes_expression join_or(FwdIt first, FwdIt last)
Returns or applied to the sequence of pbes expressions [first, last)
Definition join.h:26
bool is_data(const pbes_expression &t)
Returns true if the term t is a data expression.
std::set< pbes_expression > split_and(const pbes_expression &expr, bool split_data_expressions=false)
Splits a conjunction into a sequence of operands Given a pbes expression of the form p1 && p2 && ....
Definition join.h:76
const pbes_expression & true_()
bool is_not(const atermpp::aterm &x)
pbes_expression optimized_join_and(FwdIt first, FwdIt last)
Returns and applied to the sequence of pbes expressions [first, last)
Definition join.h:116
pbes_expression optimized_join_or(FwdIt first, FwdIt last)
Returns or applied to the sequence of pbes expressions [first, last)
Definition join.h:98
pbes_expression join_and(FwdIt first, FwdIt last)
Returns and applied to the sequence of pbes expressions [first, last)
Definition join.h:36
bool is_exists(const atermpp::aterm &x)
bool is_or(const atermpp::aterm &x)
bool is_non_simple_conjunct(const pbes_expression &t)
Test for a conjunction.
bool is_forall(const atermpp::aterm &x)
std::string pp(const pbes_system::pbes_expression &x)
Definition pbes.cpp:44
bool is_pbes_or(const pbes_expression &t)
Returns true if the term t is an or expression.
bool is_false(const pbes_expression &t)
Test for the value false.
std::vector< pbes_expression > split_disjuncts(const pbes_expression &expr, bool split_simple_expr=false)
Splits a disjunction into a sequence of operands. Given a pbes expression of the form p1 || p2 || ....
bool is_pbes_and(const pbes_expression &t)
Returns true if the term t is an and expression.
std::vector< pbes_expression > split_conjuncts(const pbes_expression &expr, bool split_simple_expr=false)
Splits a conjunction into a sequence of operands Given a pbes expression of the form p1 && p2 && ....
bool is_propositional_variable_instantiation(const atermpp::aterm &x)
bool is_and(const atermpp::aterm &x)
std::string print_brief(const T &x)
Returns a string representation of the root node of a PBES.
std::set< pbes_expression > split_or(const pbes_expression &expr, bool split_data_expressions=false)
Splits a disjunction into a sequence of operands Given a pbes expression of the form p1 || p2 || ....
Definition join.h:50
bool is_non_simple_disjunct(const pbes_expression &t)
Test for a disjunction.
bool is_imp(const atermpp::aterm &x)
bool is_simple_expression(const T &x)
Determines if an expression is a simple expression. An expression is simple if it is free of proposit...
bool is_true(const pbes_expression &t)
Test for the value true.
const pbes_expression & false_()
The main namespace for the Process library.
atermpp::term_list< action_label > action_label_list
\brief list of action_labels
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
A visitor class for PBES equations in BQNF. There is a visit_<node> function for each type of node....
bool debug
flag that indicates if debug output should be printed.
virtual bool visit_bqnf_equation(const pbes_equation &eqn)
Visits a BQNF equation.
virtual bool visit_inner_bounded_exists(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a bounded existential quantifier expression within a disjunctive expression.
static std::string print_brief(const pbes_expression &e)
Returns a string representation of the type of the root node of the expression.
virtual bool visit_bounded_forall(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a bounded universal quantifier expression.
virtual bool visit_bounded_quantifier(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a bounded quantifier expression.
virtual bool visit_inner_and(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a conjunctive expression within an inner existential quantifier expression.
virtual bool visit_propositional_variable(const fixpoint_symbol &, const propositional_variable &, const pbes_expression &e)
Visits a propositional variable expression.
static bool is_inner_implies(const pbes_expression &e)
Determines if an expression if of the form phi => psi or of the form phi \/ psi where phi is a simple...
virtual bool visit_simple_expression(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a simple expression. An expression is simple if it does not contain propositional variables.
virtual bool visit_bqnf_expression(const pbes_expression &e)
Visits a BQNF expression. In the current BQNF visitor sigma and var parameters are added for use in b...
virtual bool visit_and(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a conjunctive expression.
virtual bool visit_bqnf_expression(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a BQNF expression.
static bool is_inner_and(const pbes_expression &e)
Determines if an expression if of the form phi /\ psi where phi is a simple expression and psi is an ...
virtual bool visit_or(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a disjunctive expression.
virtual bool visit_bqnf_equation_debug(const pbes_equation &eqn)
Visits a BQNF equation in debug mode.
virtual bool visit_bounded_exists(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a bounded existential quantifier expression.
virtual bool visit_inner_bounded_forall(const fixpoint_symbol &sigma, const propositional_variable &var, const pbes_expression &e)
Visits a bounded universal quantifier expression within a conjunctive expression.
Visitor for printing the root node of a PBES.
void apply(const pbes_equation &x)
void apply(const propositional_variable_instantiation &x)
pbes_expression_traverser< print_brief_traverser > super
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const