mCRL2
Loading...
Searching...
No Matches
action_rename.h
Go to the documentation of this file.
1// Author(s): Jan Friso Groote, 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/action_rename.h
10/// \brief Action rename specifications.
11
12#ifndef MCRL2_LPS_ACTION_RENAME_H
13#define MCRL2_LPS_ACTION_RENAME_H
14
15#include <regex>
16
17#include "mcrl2/core/parse.h"
18
19#include "mcrl2/data/rewriter.h"
20#include "mcrl2/data/substitutions/mutable_map_substitution.h"
21
22#include "mcrl2/lps/stochastic_specification.h"
23#include "mcrl2/process/normalize_sorts.h"
24#include "mcrl2/process/replace.h"
25#include "mcrl2/process/translate_user_notation.h"
26
27// //Action rename rules
28// <ActionRenameRules>
29// ::= ActionRenameRules(<ActionRenameRule>*)
30//
31// //Action rename rule
32// <ActionRenameRule>
33// ::= ActionRenameRule(<DataVarId>*, <DataExprOrNil>,
34// <ParamIdOrAction>, <ActionRenameRuleRHS>)
35//
36// //Right-hand side of an action rename rule
37// <ActionRenameRuleRHS>
38// ::= <ParamId> [- tc]
39// | <Action> [+ tc]
40// | Delta
41// | Tau
42//
43// //Action rename action_rename_specification
44// <ActionRenameSpec>
45// ::= ActionRenameSpec(<DataSpec>, <ActSpec>, <ActionRenameRules>)
46
47namespace mcrl2
48{
49
50namespace lps
51{
52
53// ::= ActionRenameRule(<DataVarId>*, <DataExprOrNil>,
54// <ParamIdOrAction>, <ActionRenameRuleRHS>)
55
56/// \brief Action rename rule
58{
59 protected:
60 /// \brief The data variables of the rule
62
63 /// \brief The condition of the rule
65
66 /// \brief The left hand side of the rule
68
69 /// \brief right hand side of the rule. Can only be an action, tau or delta.
71
73 {
75 }
76
77 public:
78 /// \brief Constructor.
80 { }
81
82 /// \brief Constructor.
83 /// \param t A term
85 {
86 assert(core::detail::check_rule_ActionRenameRule(t));
87 atermpp::aterm::iterator i = t.begin();
88 m_variables = atermpp::down_cast<data::variable_list>(*i++);
89 m_condition = data::data_expression(*i++);
90 m_lhs = process::action(*i++);
91 m_rhs = process::process_expression(*i);
93 }
94
95 /// \brief Constructor.
97 const data::data_expression& condition,
98 const process::action& lhs,
99 const process::process_expression& rhs)
101 {
103 }
104
105 /// \brief Returns the variables of the rule.
106 /// \return The variables of the rule.
108 {
109 return m_variables;
110 }
111
112 /// \brief Returns the variables of the rule.
113 /// \return The variables of the rule.
115 {
116 return m_variables;
117 }
118
119 /// \brief Returns the condition of the rule.
120 /// \return The condition of the rule.
122 {
123 return m_condition;
124 }
125
126 /// \brief Returns the condition of the rule.
127 /// \return The condition of the rule.
129 {
130 return m_condition;
131 }
132
133 /// \brief Returns the left hand side of the rule.
134 /// \return The left hand side of the rule.
135 const process::action& lhs() const // Type should be action, but as it can be a ParamId(identifier_string,data_expression_list),
136 // which is not accepted by the typechecker, this is a temporary fix, until this option
137 // is added to an action.
138 {
139 return m_lhs;
140 }
141
142 /// \brief Returns the right hand side of the rule.
143 /// \return The right hand side of the rule.
145 {
147 return m_rhs;
148 }
149};
150
151
152/// \brief Read-only singly linked list of action rename rules
153// typedef atermpp::term_list<action_rename_rule> action_rename_rule_list;
154
155/// \brief Action rename specification
157{
158 protected:
159
160 /// \brief The data specification of the action rename specification
162
163 /// \brief The action labels of the action rename specification
165
166 /// \brief The action rename rules of the action rename specification
168
169 public:
170 /// \brief Constructor.
172 { }
173
174 /// \brief Constructor.
175 /// \param t A term
177 {
178 assert(core::detail::check_rule_ActionRenameSpec(t));
179 atermpp::aterm::iterator i = t.begin();
180 m_data = *i++;
181 m_action_labels = atermpp::down_cast<process::action_label_list>((*i++)[0]);
182
183 atermpp::aterm_list rules_list = atermpp::down_cast<atermpp::aterm_list>((*i)[0]);
184 for (const atermpp::aterm& r: rules_list)
185 {
186 m_rules.push_back(action_rename_rule(r));
187 }
188 }
189
190 /// \brief Constructor.
191 /// \param data A data specification
192 /// \param action_labels A sequence of action labels
193 /// \param rules A sequence of action rename rules
195 const data::data_specification& data,
196 const process::action_label_list& action_labels,
197 const std::vector <action_rename_rule>& rules)
198 :
199 m_data(data),
202 { }
203
204 /// \brief Returns the data action_rename_specification.
205 /// \return The data action_rename_specification.
206 const data::data_specification& data() const
207 {
208 return m_data;
209 }
210
211 /// \brief Returns the data specification.
213 {
214 return m_data;
215 }
216
217 /// \brief Returns the sequence of action labels
218 /// \return A sequence of action labels containing all action
219 /// labels occurring in the action_rename_specification (but it can have more).
221 {
222 return m_action_labels;
223 }
224
225 /// \brief Returns the sequence of action labels
227 {
228 return m_action_labels;
229 }
230
231 /// \brief Returns the action rename rules.
232 /// \return The action rename rules.
234 {
235 return m_rules;
236 }
237
238 /// \brief Returns the action rename rules.
240 {
241 return m_rules;
242 }
243
244 /// \brief Indicates whether the action_rename_specification is well typed.
245 /// \return Always returns true.
246 bool is_well_typed() const
247 {
248 return true;
249 }
250};
251
252inline
254{
256}
257
258inline
260{
261 std::vector<atermpp::aterm> rules;
262 for (const action_rename_rule& r: spec.rules())
263 {
264 rules.push_back(action_rename_rule_to_aterm(r));
265 }
266 return atermpp::aterm(core::detail::function_symbol_ActionRenameSpec(),
267 data::detail::data_specification_to_aterm(spec.data()),
268 atermpp::aterm(core::detail::function_symbol_ActSpec(), spec.action_labels()),
269 atermpp::aterm(core::detail::function_symbol_ActionRenameRules(), atermpp::aterm_list(rules.begin(), rules.end()))
270 );
271}
272
273}
274}
275
276
277namespace mcrl2
278{
279
280namespace lps
281{
282
283/// \cond INTERNAL_DOCS
284namespace detail
285{
286// Put the equalities t==u in the replacement map as u:=t.
287inline void fill_replacement_map(const data::data_expression& equalities_in_conjunction,
288 std::map<data::data_expression, data::data_expression>& replacement_map)
289{
290 if (equalities_in_conjunction==data::sort_bool::true_())
291 {
292 return;
293 }
294 if (data::sort_bool::is_and_application(equalities_in_conjunction))
295 {
296 fill_replacement_map(data::sort_bool::left(equalities_in_conjunction),replacement_map);
297 fill_replacement_map(data::sort_bool::right(equalities_in_conjunction),replacement_map);
298 return;
299 }
300 if(is_equal_to_application(equalities_in_conjunction))
301 {
302 const data::application a=atermpp::down_cast<data::application>(equalities_in_conjunction);
303 if (a[1]!=a[0])
304 {
305 replacement_map[a[1]]=a[0];
306 }
307 }
308}
309
310// Replace expressions in e according to the replacement map.
311// Assume that e only consists of and, not and equality applied to terms.
312inline data::data_expression replace_expressions(const data::data_expression& e,
313 const std::map<data::data_expression, data::data_expression>& replacement_map)
314{
316 {
317 return data::sort_bool::and_(replace_expressions(data::sort_bool::left(e),replacement_map),
318 replace_expressions(data::sort_bool::right(e),replacement_map));
319 }
321 {
322 return data::sort_bool::not_(replace_expressions(data::sort_bool::arg(e),replacement_map));
323 }
324 if (is_equal_to_application(e))
325 {
326 const data::application a=atermpp::down_cast<data::application>(e);
327 return data::application(a.head(),
328 replace_expressions(a[0],replacement_map),
329 replace_expressions(a[1],replacement_map));
330 }
331 const std::map<data::data_expression, data::data_expression>::const_iterator i=replacement_map.find(e);
332 if (i!=replacement_map.end()) // found;
333 {
334 return i->second;
335 }
336 return e;
337}
338
339// Substitute the equalities in equalities_in_conjunction from right to left in e.
340inline data::data_expression substitute_equalities(const data::data_expression& e, const data::data_expression& equalities_in_conjunction)
341{
342 std::map<data::data_expression, data::data_expression> replacement_map;
343 fill_replacement_map(equalities_in_conjunction, replacement_map);
344 return replace_expressions(e,replacement_map);
345}
346
347/// \brief Renames variables
348/// \param rcond A data expression
349/// \param rleft An action
350/// \param rright An action
351/// \param generator A generator for fresh identifiers
352template <typename IdentifierGenerator>
353void rename_renamerule_variables(data::data_expression& rcond, process::action& rleft, process::action& rright, IdentifierGenerator& generator)
354{
355 data::mutable_map_substitution<> renamings;
356
357 std::set< data::variable > new_vars = data::find_all_variables(rleft.arguments());
358
359 for (const data::variable& v: new_vars)
360 {
361 mcrl2::core::identifier_string new_name = generator(std::string(v.name()));
362
363 if (new_name != v.name())
364 {
365 renamings[v] = data::variable(new_name, v.sort());
366 }
367 }
368
369 data::set_identifier_generator id_generator;
370 for (const data::variable& v: data::substitution_variables(renamings))
371 {
372 id_generator.add_identifier(v.name());
373 }
374 rcond = data::replace_variables_capture_avoiding(rcond, renamings, id_generator);
375 rleft = process::replace_variables_capture_avoiding(rleft, renamings, id_generator);
376 rright = process::replace_variables_capture_avoiding(rright, renamings, id_generator);
377}
378
379/* ------------------------------------------ Normalise sorts ------------------------------------------ */
380
381inline
382void normalize_sorts(action_rename_specification& arspec)
383{
384 arspec.action_labels()=process::normalize_sorts(arspec.action_labels(), arspec.data());
385
386 for (action_rename_rule& rule: arspec.rules())
387 {
388 rule = action_rename_rule(data::normalize_sorts(rule.variables(), arspec.data()),
389 data::normalize_sorts(rule.condition(), arspec.data()),
390 process::normalize_sorts(rule.lhs(), arspec.data()),
391 process::normalize_sorts(rule.rhs(), arspec.data()));
392 }
393}
394
395
396/* ------------------------------------------ Translate user notation ------------------------------------------ */
397
398inline
399void translate_user_notation(action_rename_specification& arspec)
400{
401 for (action_rename_rule& rule: arspec.rules())
402 {
403 rule = action_rename_rule(rule.variables(),
404 data::translate_user_notation(rule.condition()),
405 process::translate_user_notation(rule.lhs()),
406 process::translate_user_notation(rule.rhs()));
407 }
408}
409
410} // namespace detail
411/// \endcond
412
413/// \brief Rename the actions in a linear specification using a given action_rename_spec
414/// \details The actions in a linear specification are renamed according to a given
415/// action rename specification.
416/// Note that the rules are applied in the order they appear in the specification.
417/// This yield quite elaborate conditions in the resulting lps, as a latter rule
418/// can only be applied if an earlier rule is not applicable. Note also that
419/// there is always a default summand, where the action is not renamed. Using
420/// sum elimination and rewriting a substantial reduction of the conditions that
421/// are generated can be obtained, often allowing many summands to be removed.
422/// \param action_rename_spec The action_rename_specification to be used.
423/// \param lps_old_spec The input linear specification.
424/// \param rewr A data rewriter.
425/// \return The lps_old_spec where all actions have been renamed according
426/// to action_rename_spec.
427inline
429 const action_rename_specification& action_rename_spec,
430 const lps::stochastic_specification& lps_old_spec,
431 const data::rewriter& rewr,
432 const bool enable_rewriting)
433{
434 using namespace mcrl2::core;
435 using namespace mcrl2::data;
436 using namespace mcrl2::lps;
437
438 const std::vector <action_rename_rule>& rename_rules = action_rename_spec.rules();
439 stochastic_action_summand_vector lps_old_action_summands = lps_old_spec.process().action_summands();
440 deadlock_summand_vector lps_deadlock_summands = lps_old_spec.process().deadlock_summands();
441 process::action_list lps_new_actions;
442
444 generator.add_identifiers(lps::find_identifiers(lps_old_spec));
445 generator.add_identifiers(data::function_and_mapping_identifiers(lps_old_spec.data()));
446
447 //go through the rename rules of the rename file
448 mCRL2log(log::debug) << "Rename rules found: " << rename_rules.size() << "\n";
449 for (const action_rename_rule& r: rename_rules)
450 {
451 stochastic_action_summand_vector lps_new_action_summands;
452
453 data_expression rule_condition = r.condition();
454 process::action rule_old_action = r.lhs();
455 process::action rule_new_action;
456 process::process_expression new_element = r.rhs();
457 if (!is_tau(new_element) && !is_delta(new_element))
458 {
459 rule_new_action = atermpp::down_cast<process::action>(new_element);
460 }
461
462 const bool to_tau = is_tau(new_element);
463 const bool to_delta = is_delta(new_element);
464
465 // Check here that the arguments of the rule_old_action only consist
466 // of uniquely occurring variables or closed terms. Furthermore, check that the variables
467 // in rule_new_action and in rule_condition are a subset of those in
468 // rule_old_action. This check ought to be done in the static checking
469 // part of the renaming rules, but as yet it has nog been done. Ultimately
470 // this check should be moved there.
471
472 // first check that the arguments of rule_old_action are variables or closed
473 // terms.
474
475 for (const data_expression& rule_old_argument_i: rule_old_action.arguments())
476 {
477 if (!is_variable(rule_old_argument_i) &&
478 (!(data::find_all_variables(rule_old_argument_i).empty())))
479 {
480 throw mcrl2::runtime_error("The arguments of the lhs " + process::pp(rule_old_action) +
481 " are not variables or closed expressions");
482 }
483 }
484
485 // Check whether the variables in rhs are included in the lefthandside.
486 std::set < variable > variables_in_old_rule = process::find_free_variables(rule_old_action);
487 std::set < variable > variables_in_new_rule = process::find_free_variables(rule_new_action);
488
489 if (!includes(variables_in_old_rule.begin(),variables_in_old_rule.end(),
490 variables_in_new_rule.begin(),variables_in_new_rule.end()))
491 {
492 throw mcrl2::runtime_error("There are variables occurring in rhs " + process::pp(rule_new_action) +
493 " of a rename rule not occurring in lhs " + process::pp(rule_old_action));
494 }
495
496 // Check whether the variables in condition are included in the lefthandside.
497 std::set < variable > variables_in_condition = data::find_free_variables(rule_condition);
498 if (!includes(variables_in_old_rule.begin(),variables_in_old_rule.end(),
499 variables_in_condition.begin(),variables_in_condition.end()))
500 {
501 throw mcrl2::runtime_error("There are variables occurring in the condition " + data::pp(rule_condition) +
502 " of a rename rule not occurring in lhs " + process::pp(rule_old_action));
503 }
504
505 // check for double occurrences of variables in the lhs. Note that variables_in_old_rule
506 // is empty at the end.
507 for (const data_expression& d: rule_old_action.arguments())
508 {
509 if (is_variable(d))
510 {
511 const variable& v = atermpp::down_cast<variable>(d);
512 if (variables_in_old_rule.find(v)==variables_in_old_rule.end())
513 {
514 throw mcrl2::runtime_error("Variable " + data::pp(v) + " occurs more than once in lhs " +
515 process::pp(rule_old_action) + " of an action rename rule");
516 }
517 else
518 {
519 variables_in_old_rule.erase(v);
520 }
521 }
522 }
523 assert(variables_in_old_rule.empty());
524
525
526 //go through the summands of the old lps
527 mCRL2log(log::debug) << "Action summands found: " << lps_old_action_summands.size() << "\n";
528 for (const stochastic_action_summand& lps_old_action_summand: lps_old_action_summands)
529 {
530 process::action_list lps_old_actions = lps_old_action_summand.multi_action().actions();
531
532 /* For each individual action in the multi-action, for which the
533 rename rule applies, two new summands must be made, namely one
534 where the rule does not match with the parameters of the action,
535 and one where it actually does. This means that for a multiaction
536 with k summands 2^k new summands can result. */
537
538 std::vector < variable_list >
539 lps_new_sum_vars(1,lps_old_action_summand.summation_variables());
540 std::vector < data_expression > lps_new_condition(1,lps_old_action_summand.condition());
541 std::vector < process::action_list >
542 lps_new_actions(1,process::action_list());
543 std::vector < bool > lps_new_actions_is_delta(1,false);
544
545 mCRL2log(log::debug) << "Actions in summand found: " << lps_old_actions.size() << "\n";
546 for (const process::action& lps_old_action: lps_old_actions)
547 {
548 if (equal_signatures(lps_old_action, rule_old_action))
549 {
550 mCRL2log(log::debug) << "Renaming action " << rule_old_action << "\n";
551
552 //rename all previously used variables.
553 data_expression renamed_rule_condition=rule_condition;
554 process::action renamed_rule_old_action=rule_old_action;
555 process::action renamed_rule_new_action=rule_new_action;
556 detail::rename_renamerule_variables(renamed_rule_condition, renamed_rule_old_action, renamed_rule_new_action, generator);
557
558 //go through the arguments of the action.
559 data_expression_list::iterator lps_old_argument_i = lps_old_action.arguments().begin();
560 data_expression new_equalities_condition=sort_bool::true_();
561 for (const data_expression& rule_old_argument_i: renamed_rule_old_action.arguments())
562 {
563 if (is_variable(rule_old_argument_i))
564 {
565 new_equalities_condition=lazy::and_(new_equalities_condition,
566 data::equal_to(rule_old_argument_i, *lps_old_argument_i));
567 }
568 else
569 {
570 assert((data::find_all_variables(rule_old_argument_i).empty())); // the argument must be closed, which is checked above.
571 renamed_rule_condition=
572 lazy::and_(renamed_rule_condition,
573 data::equal_to(rule_old_argument_i, *lps_old_argument_i));
574 if (enable_rewriting) renamed_rule_condition=rewr(renamed_rule_condition); // Make sure that renamed_rule_condition is as simple as possible.
575 }
576 lps_old_argument_i++;
577 }
578
579 /* insert the new equality condition in all the newly generated summands */
580 for (data_expression& d: lps_new_condition)
581 {
582 d=lazy::and_(d,new_equalities_condition);
583 }
584
585 /* insert the new sum variables in all the newly generated summands */
586 std::set<variable> new_vars = find_all_variables(renamed_rule_old_action);
587 for (const variable& sdvi: new_vars)
588 {
589 for (variable_list& l: lps_new_sum_vars)
590 {
591 l.push_front(sdvi);
592 }
593 }
594
595 if (enable_rewriting) renamed_rule_condition=rewr(renamed_rule_condition); // Make sure that renamed_rule_condition is as simple as possible.
596 if (renamed_rule_condition==sort_bool::true_())
597 {
598 if (to_delta)
599 {
600 std::vector < bool >::iterator i_is_delta=lps_new_actions_is_delta.begin();
601 for (process::action_list& l: lps_new_actions)
602 {
603 l=process::action_list(); // the action becomes delta
604 *i_is_delta=true;
605 ++i_is_delta;
606 }
607 }
608 else if (!to_tau)
609 {
610 std::vector < bool >::iterator i_is_delta=lps_new_actions_is_delta.begin();
611 for (process::action_list& l: lps_new_actions)
612 {
613 if (!*i_is_delta) // the action is not delta
614 {
615 l.push_front(renamed_rule_new_action);
616 }
617 ++i_is_delta;
618 }
619 }
620 }
621 else if (renamed_rule_condition==sort_bool::false_())
622 {
623 std::vector < bool >::iterator i_is_delta=lps_new_actions_is_delta.begin();
624 for (process::action_list& l: lps_new_actions)
625 {
626 if (!*i_is_delta) // The action does not equal delta.
627 {
628 l.push_front(lps_old_action);
629 }
630 ++i_is_delta;
631 }
632
633 }
634 else
635 {
636 /* Duplicate summands, one where the renaming is applied, and one where it is not
637 applied. */
638
639 std::vector < process::action_list > lps_new_actions_temp(lps_new_actions);
640
641 if (!to_tau) // if the new element is tau, we do not insert it in the multi-action.
642 {
643 std::vector < bool >::iterator i_is_delta=lps_new_actions_is_delta.begin();
644 for (process::action_list& l: lps_new_actions)
645 {
646 if (to_delta)
647 {
648 l=process::action_list();
649 *i_is_delta=true;
650 }
651 else
652 {
653 l.push_front(renamed_rule_new_action);
654 *i_is_delta=false;
655 }
656 ++i_is_delta;
657 }
658 }
659
660 for (process::action_list& l: lps_new_actions_temp)
661 {
662 lps_new_actions_is_delta.push_back(false); // A non renamed action is not delta;
663 l.push_front(lps_old_action);
664 }
665
666 lps_new_actions.insert(lps_new_actions.end(),
667 lps_new_actions_temp.begin(),
668 lps_new_actions_temp.end());
669 assert(lps_new_actions_is_delta.size()==lps_new_actions.size());
670
671 /* lps_new_condition_temp will contain the conditions in conjunction with
672 the negated new_condition. It will be concatenated to lps_new_condition,
673 in which the terms will be conjoined with the non-negated new_condition */
674
675 std::vector < data_expression > lps_new_condition_temp(lps_new_condition);
676
677 for (data_expression& d: lps_new_condition)
678 {
679 // substitute the equalities in d in renamed_rule_condition.
680 d=lazy::and_(renamed_rule_condition,detail::substitute_equalities(d,renamed_rule_condition));
681 }
682
683 for (const data_expression& d: lps_new_condition_temp)
684 {
685
686 lps_new_condition.push_back(lazy::and_(d,sort_bool::not_(renamed_rule_condition)));
687 }
688
689 // Replace lps_new_sum_vars with two consecutive copies of itself.
690 // The clumsily looking method below is required, to avoid problems with vector reallocation.
691 std::size_t size=lps_new_sum_vars.size();
692 lps_new_sum_vars.reserve(2*size);
693 for(std::size_t i=0; i<size; ++i)
694 {
695 lps_new_sum_vars.push_back(lps_new_sum_vars[i]);
696 }
697 }
698 }//end if(equal_signatures(...))
699 else
700 {
701 for (process::action_list& l: lps_new_actions)
702 {
703 l.push_front(lps_old_action);
704 }
705 }
706 mCRL2log(log::debug) << "Action done\n";
707
708 } //end of action list iterator
709
710 /* Add the summands to lps_new_action_summands or to the deadlock summands*/
711
712 std::vector < process::action_list > :: iterator i_act=lps_new_actions.begin();
713 std::vector < bool > :: iterator i_act_is_delta=lps_new_actions_is_delta.begin();
714 std::vector < variable_list > :: iterator i_sumvars=lps_new_sum_vars.begin();
715 for (const data_expression& cond: lps_new_condition)
716 {
717 //create a summand for the new lps
718 if (*i_act_is_delta)
719 {
720 // Create a deadlock summand.
721 const deadlock_summand d(*i_sumvars,
722 cond,
723 deadlock(lps_old_action_summand.multi_action().time()));
724 lps_deadlock_summands.push_back(d);
725 }
726 else
727 {
728 // create an action summand.
729 stochastic_action_summand lps_new_summand(*i_sumvars,
730 cond,
731 multi_action(reverse(*i_act), lps_old_action_summand.multi_action().time()),
732 lps_old_action_summand.assignments(),
733 lps_old_action_summand.distribution());
734 lps_new_action_summands.push_back(lps_new_summand);
735 }
736 i_act++;
737 i_sumvars++;
738 ++i_act_is_delta;
739 }
740 } // end of summand list iterator
741 lps_old_action_summands = lps_new_action_summands;
742 } //end of rename rule iterator
743
744 mCRL2log(log::debug) << "Simplifying the result...\n";
745
746 stochastic_linear_process new_process(lps_old_spec.process().process_parameters(),
747 lps_deadlock_summands,
748 lps_old_action_summands);
749
750 // add action_rename_spec.action_labels to action_rename_spec.action_labels without adding duplicates.
751 process::action_label_list all=action_rename_spec.action_labels();
752 for (const process::action_label& a: lps_old_spec.action_labels())
753 {
754 if (std::find(action_rename_spec.action_labels().begin(),
755 action_rename_spec.action_labels().end(),a)==action_rename_spec.action_labels().end())
756 {
757 // Not found;
758 all.push_front(a);
759 }
760 }
761 stochastic_specification lps_new_spec(action_rename_spec.data(), // This contains the data of the lps and the rename file.
762 all,
763 lps_old_spec.global_variables(),
764 new_process,
765 lps_old_spec.initial_process());
766
767 mCRL2log(log::debug) << "New lps complete\n";
768 return lps_new_spec;
769} //end of rename(...)
770
771namespace detail
772{
773
774inline
775process::action_label rename_action_label(const process::action_label& act, const std::regex& matching_regex, const std::string& replacing_fmt)
776{
777 return process::action_label(std::regex_replace(std::string(act.name()), matching_regex, replacing_fmt), act.sorts());
778}
779
780} // namespace detail
781
782/**
783 * \brief Rename actions in given specification based on a regular expression and
784 * a string that specifies how the replacement should be formatted.
785 */
786inline
788 const std::regex& matching_regex,
789 const std::string& replacing_fmt,
790 const stochastic_specification& lps_old_spec)
791{
792 // Use a set to store the new action labels to avoid duplicates
793 std::set<process::action_label> new_actions_set;
794 process::action_label_list new_actions;
795 for(const process::action_label& act: lps_old_spec.action_labels())
796 {
797 process::action_label new_action_label(detail::rename_action_label(act, matching_regex, replacing_fmt));
798 if (std::string(new_action_label.name()).empty())
799 {
800 throw mcrl2::runtime_error("After renaming the action " + std::string(act.name()) + " becomes empty, which is not allowed.");
801 }
802 if(std::string(new_action_label.name()) != "delta" && std::string(new_action_label.name()) != "tau" &&
803 new_actions_set.find(new_action_label) == new_actions_set.end())
804 {
805 // The list of actions should not contain delta and tau actions and also no duplicates.
806 new_actions_set.insert(new_action_label);
807 new_actions.push_front(new_action_label);
808 }
809 }
810 new_actions = reverse(new_actions);
811
812 // The list of new actions summands is initially empty
813 std::vector<stochastic_action_summand> new_action_summands;
814 // The list of new deadlock summands is initialised to the existing list, we will only add new deadlock summands
815 std::vector<deadlock_summand> new_deadlock_summands(lps_old_spec.process().deadlock_summands());
816 for(const stochastic_action_summand& as: lps_old_spec.process().action_summands())
817 {
818 process::action_list new_action_list;
819 bool becomes_deadlock_summand = false;
820 for(const process::action& act: as.multi_action().actions())
821 {
822 process::action_label new_action_label(detail::rename_action_label(act.label(), matching_regex, replacing_fmt));
823 if(std::string(new_action_label.name()) == "delta")
824 {
825 // delta is the absorbing element for multi action concatenation
826 // Therefore, this summand now becomes a deadlock summand
827 becomes_deadlock_summand = true;
828 break;
829 }
830 // tau is the identity for multi action concatenation
831 // therefore, we should not add it to a multi action
832 if(std::string(new_action_label.name()) != "tau")
833 {
834 new_action_list.push_front(process::action(new_action_label, act.arguments()));
835 }
836 }
837
838 if(!becomes_deadlock_summand)
839 {
840 new_action_list = reverse(new_action_list);
841 multi_action new_multi_action(new_action_list, as.multi_action().time());
842
843 // Copy most of the old information, only the multi action has changed
844 stochastic_action_summand new_summand(as.summation_variables(), as.condition(), new_multi_action, as.assignments(), as.distribution());
845 new_action_summands.push_back(new_summand);
846 }
847 else
848 {
849 // Add a new deadlock summand, copying most of the information for the old action summand
850 new_deadlock_summands.push_back(deadlock_summand(as.summation_variables(), as.condition(), deadlock(as.multi_action().time())));
851 }
852 }
853
854 stochastic_linear_process new_process(lps_old_spec.process().process_parameters(),
855 new_deadlock_summands,
856 new_action_summands);
857 stochastic_specification lps_new_spec(lps_old_spec.data(),
858 new_actions,
859 lps_old_spec.global_variables(),
860 new_process,
861 lps_old_spec.initial_process());
862 return lps_new_spec;
863}
864
865} // namespace lps
866
867} // namespace mcrl2
868
869namespace std
870{
871/// \brief Output an action_rename_rule to ostream.
872/// \param out An output stream
873/// \return The output stream
874// Currently, the variables are not printed. The shape is also not parseable. This may be mended.
875inline
876std::ostream& operator<<(std::ostream& out, const mcrl2::lps::action_rename_rule& r)
877{
878 return out << "(" << r.condition() << ") -> " << r.lhs() << " => " << r.rhs();
879}
880
881/// \brief Output a action_rename_rule to ostream.
882/// \param out An output stream
883/// \return The output stream
884// Currently, the data declaration and the action declaration are not printed.
885inline
886std::ostream& operator<<(std::ostream& out, const mcrl2::lps::action_rename_specification& s)
887{
888 for(const mcrl2::lps::action_rename_rule& r: s.rules())
889 {
890 out << r << "\n";
891 }
892 return out;
893}
894
895
896} // end namespace std
897
898
899#endif // MCRL2_LPS_ACTION_RENAME_H
term_appl_iterator< aterm > iterator
Iterator used to iterate through an term_appl.
Definition aterm.h:42
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
parse_node_unexpected_exception(const parser &p, const parse_node &node)
Definition parse.h:78
\brief Assignment of a data expression to a variable
Definition assignment.h:91
const data_expression & rhs() const
Definition assignment.h:122
const variable & lhs() const
Definition assignment.h:117
data_expression & operator=(const data_expression &) noexcept=default
data_expression & operator=(data_expression &&) noexcept=default
sort_expression sort() const
Returns the sort of the data expression.
Definition data.cpp:108
data_expression(const data_expression &) noexcept=default
Move semantics.
void translate_user_notation()
Translate user notation within the equations of the data specification.
data_specification()
Default constructor. Generate a data specification that contains only booleans and positive numbers.
Rewriter that operates on data expressions.
Definition rewriter.h:81
Identifier generator that stores the identifiers of the context in a set. Using the operator()() and ...
\brief A sort expression
\brief A data variable
Definition variable.h:28
const sort_expression & sort() const
Definition variable.h:43
logger(const log_level_t l)
Default constructor.
Definition logger.h:164
const data::data_expression & condition() const
Returns the condition of the rule.
const process::process_expression & rhs() const
Returns the right hand side of the rule.
data::data_expression & condition()
Returns the condition of the rule.
action_rename_rule(const data::variable_list &variables, const data::data_expression &condition, const process::action &lhs, const process::process_expression &rhs)
Constructor.
process::process_expression m_rhs
right hand side of the rule. Can only be an action, tau or delta.
data::variable_list m_variables
The data variables of the rule.
bool check_that_rhs_is_tau_delta_or_an_action() const
data::variable_list & variables()
Returns the variables of the rule.
process::action m_lhs
The left hand side of the rule.
action_rename_rule(const atermpp::aterm &t)
Constructor.
data::data_expression m_condition
The condition of the rule.
const data::variable_list & variables() const
Returns the variables of the rule.
const process::action & lhs() const
Returns the left hand side of the rule.
Read-only singly linked list of action rename rules.
const std::vector< action_rename_rule > & rules() const
Returns the action rename rules.
data::data_specification m_data
The data specification of the action rename specification.
process::action_label_list & action_labels()
Returns the sequence of action labels.
std::vector< action_rename_rule > m_rules
The action rename rules of the action rename specification.
action_rename_specification(const data::data_specification &data, const process::action_label_list &action_labels, const std::vector< action_rename_rule > &rules)
Constructor.
std::vector< action_rename_rule > & rules()
Returns the action rename rules.
process::action_label_list m_action_labels
The action labels of the action rename specification.
const process::action_label_list & action_labels() const
Returns the sequence of action labels.
action_rename_specification(atermpp::aterm t)
Constructor.
bool is_well_typed() const
Indicates whether the action_rename_specification is well typed.
action_rename_specification operator()(const action_rename_specification &arspec, const stochastic_specification &lpsspec)
Type check an action_rename_specification.
Definition typecheck.h:100
process::detail::action_context m_action_context
Definition typecheck.h:75
action_rename_rule typecheck_action_rename_rule(const action_rename_rule &x, const process::action_label_list &action_labels)
Definition typecheck.h:77
data::data_type_checker m_data_type_checker
Definition typecheck.h:74
action_rename_type_checker()
Default constructor for an action rename type checker.
Definition typecheck.h:91
LPS summand containing a multi-action.
data::data_expression_list next_state(const data::variable_list &process_parameters) const
Returns the next state corresponding to this summand.
Definition lps.cpp:68
const data::assignment_list & assignments() const
Returns the sequence of assignments.
LPS summand containing a deadlock.
Represents a deadlock.
Definition deadlock.h:26
deadlock(data::data_expression time=data::undefined_real())
Constructor.
Definition deadlock.h:36
bool has_time() const
Returns true if time is available.
Definition deadlock.h:42
const data::data_expression & time() const
Returns the time.
Definition deadlock.h:49
data::data_expression & time()
Returns the time.
Definition deadlock.h:56
linear_process(const data::variable_list &process_parameters, const deadlock_summand_vector &deadlock_summands, const action_summand_vector &action_summands)
Constructor.
multi_action_type_checker(const data::data_specification &dataspec=data::data_specification())
Default constructor.
Definition typecheck.h:44
multi_action operator()(const process::untyped_multi_action &x)
Type check a multi action. Throws a mcrl2::runtime_error exception if the expression is not well type...
Definition typecheck.h:53
data::detail::variable_context m_variable_context
Definition typecheck.h:29
process::detail::action_context m_action_context
Definition typecheck.h:28
data::data_type_checker m_data_type_checker
Definition typecheck.h:27
multi_action_type_checker(const data::data_specification &dataspec, const VariableContainer &variables, const ActionLabelContainer &action_labels)
Definition typecheck.h:33
\brief A timed multi-action
bool has_time() const
Returns true if time is available.
const process::action_list & actions() const
multi_action(const process::action &l)
Constructor.
multi_action operator+(const multi_action &other) const
Joins the actions of both multi actions.
multi_action & operator=(multi_action &&) noexcept=default
const data::data_expression & time() const
multi_action(const process::action_list &actions=process::action_list(), data::data_expression time=data::undefined_real())
Constructor.
process_initializer & operator=(process_initializer &&) noexcept=default
Linear process specification.
LPS summand containing a multi-action.
\brief A stochastic distribution
stochastic_distribution & operator=(stochastic_distribution &&) noexcept=default
stochastic_distribution()
\brief Default constructor X3.
stochastic_distribution(const data::variable_list &variables, const data::data_expression &distribution)
\brief Constructor Z12.
stochastic_linear_process(const data::variable_list &process_parameters, const deadlock_summand_vector &deadlock_summands, const stochastic_action_summand_vector &action_summands)
Constructor.
stochastic_process_initializer(const data::data_expression_list &expressions, const stochastic_distribution &distribution)
Constructor.
\brief An action label
const data::sort_expression_list & sorts() const
const core::identifier_string & name() const
action(const action_label &label, const data::data_expression_list &arguments)
\brief Constructor Z14.
const data::data_expression_list & arguments() const
action(const action &) noexcept=default
Move semantics.
const action_label & label() const
\brief The allow operator
\brief The at operator
const data::data_expression & time_stamp() const
const process_expression & operand() const
\brief The block operator
\brief The bounded initialization
\brief The choice operator
const process_expression & left() const
const process_expression & right() const
\brief The communication operator
\brief The value delta
delta()
\brief Default constructor X3.
\brief The hide operator
\brief The if-then-else operator
\brief The if-then operator
const process_expression & then_case() const
const data::data_expression & condition() const
\brief The left merge operator
\brief The merge operator
\brief A process equation
process_equation()
\brief Default constructor X3.
process_equation(const process_equation &) noexcept=default
Move semantics.
const data::variable_list & formal_parameters() const
const process_identifier & identifier() const
const process_expression & expression() const
\brief A process expression
process_expression(const process_expression &) noexcept=default
Move semantics.
const process_identifier & identifier() const
const data::data_expression_list & actual_parameters() const
const process_identifier & identifier() const
Process specification consisting of a data specification, action labels, a sequence of process equati...
const process_expression & init() const
Returns the initialization of the process specification.
const process::action_label_list & action_labels() const
Returns the action label specification.
\brief The rename operator
\brief The sequential composition
const process_expression & right() const
const process_expression & left() const
\brief The distribution operator
const data::variable_list & variables() const
const data::data_expression & distribution() const
\brief The sum operator
const process_expression & operand() const
const data::variable_list & variables() const
\brief The synchronization operator
const process_expression & left() const
const process_expression & right() const
\brief The value tau
tau()
\brief Default constructor X3.
\brief An untyped multi action or data application
untyped_multi_action()
\brief Default constructor X3.
Standard exception class for reporting runtime errors.
Definition exception.h:27
runtime_error(const std::string &message)
Constructor.
Definition exception.h:31
D_ParserTables parser_tables_mcrl2
Definition dparser.cpp:20
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:391
The main namespace for the aterm++ library.
Definition algorithm.h:21
term_list< aterm > aterm_list
A term_list with elements of type aterm.
Definition aterm_list.h:497
void syntax_error_fn(struct D_Parser *ap)
Custom syntax error function that prints both the line number and the column.
Definition dparser.cpp:463
D_ParseNode * ambiguity_fn(struct D_Parser *, int n, struct D_ParseNode **v)
Function for resolving parser ambiguities.
Definition dparser.cpp:332
const atermpp::function_symbol & function_symbol_ActionRenameRule()
bool sequence_empty_intersection(Sequence s1, Sequence s2)
Determines if the unordered sequences s1 and s2 have an empty intersection.
bool sequence_contains_duplicates(Iterator first, Iterator last)
Returns true if the sequence [first, last) contains duplicates.
static data_specification const & default_specification()
Definition parse.h:31
bool sequence_is_subset_of_set(Iterator first, Iterator last, const std::set< T > &s)
Returns true if all elements of the range [first, last) are element of the set s.
bool check_assignment_variables(assignment_list const &assignments, variable_list const &variables)
Returns true if the left hand sides of assignments are contained in variables.
bool sequences_do_overlap(Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2)
Returns true if the two sequences [first1, last1) and [first2, last2) have a non empty intersection.
std::set< typename Container::value_type > make_set(const Container &c)
Makes a set of the given container.
Namespace for system defined sort bool_.
Definition bool.h:32
bool is_bool(const sort_expression &e)
Recogniser for sort expression Bool.
Definition bool.h:54
bool is_and_application(const atermpp::aterm &e)
Recogniser for application of &&.
Definition bool.h:281
bool is_not_application(const atermpp::aterm &e)
Recogniser for application of !.
Definition bool.h:217
const function_symbol & true_()
Constructor for function symbol true.
Definition bool.h:77
Namespace for system defined sort real_.
bool is_real(const sort_expression &e)
Recogniser for sort expression Real.
Definition real1.h:58
Namespace for all data library functionality.
Definition data.cpp:22
atermpp::term_list< data_expression > data_expression_list
\brief list of data_expressions
atermpp::term_list< variable > variable_list
\brief list of variables
atermpp::term_list< assignment > assignment_list
\brief list of assignments
Definition assignment.h:146
std::string pp(const data::variable_list &x)
Definition data.cpp:31
std::string pp(const data::data_expression &x)
Definition data.cpp:52
@ verbose
Definition logger.h:37
bool is_well_typed(const T &x)
Checks well typedness of an LPS object.
bool check_action_labels(const process::action_list &actions, const std::set< process::action_label > &labels)
Returns true if the labels of the given actions are contained in labels.
multi_action complete_multi_action(process::untyped_multi_action &x, const process::action_label_list &action_decls, const data::data_specification &data_spec=data::detail::default_specification())
Definition lps.cpp:132
process::action_label rename_action_label(const process::action_label &act, const std::regex &matching_regex, const std::string &replacing_fmt)
bool check_action_label_sorts(const process::action_label_list &action_labels, const std::set< data::sort_expression > &sorts)
Returns true if the sorts of the given action labels are contained in sorts.
bool check_well_typedness(const T &x)
Checks well typedness of an LPS object, and will print error messages to stderr.
bool check_action_sorts(const process::action_list &actions, const std::set< data::sort_expression > &sorts)
Returns true if the sorts of the given actions are contained in sorts.
void complete_action_rename_specification(action_rename_specification &x, const lps::stochastic_specification &spec)
Definition lps.cpp:150
process::untyped_multi_action parse_multi_action_new(const std::string &text)
Definition lps.cpp:114
multi_action complete_multi_action(process::untyped_multi_action &x, multi_action_type_checker &typechecker, const data::data_specification &data_spec=data::detail::default_specification())
Definition lps.cpp:124
action_rename_specification parse_action_rename_specification_new(const std::string &text)
Definition lps.cpp:140
The main namespace for the LPS library.
Definition constelm.h:21
std::string pp(const lps::stochastic_process_initializer &x)
Definition lps.cpp:36
std::string pp(const lps::stochastic_distribution &x)
Definition lps.cpp:34
std::set< data::variable > find_all_variables(const lps::linear_process &x)
Definition lps.cpp:44
std::set< data::sort_expression > find_sort_expressions(const lps::stochastic_specification &x)
Definition lps.cpp:43
std::set< process::action_label > find_action_labels(const lps::stochastic_specification &x)
Definition lps.cpp:65
std::set< data::variable > find_free_variables(const lps::stochastic_specification &x)
Definition lps.cpp:53
std::vector< stochastic_action_summand > stochastic_action_summand_vector
\brief vector of stochastic_action_summands
std::string pp_with_summand_numbers(const specification &x)
Definition lps.cpp:74
std::string pp(const lps::process_initializer &x)
Definition lps.cpp:31
std::set< data::variable > find_all_variables(const lps::stochastic_specification &x)
Definition lps.cpp:47
bool check_well_typedness(const specification &x)
Definition lps.cpp:102
std::set< data::variable > find_free_variables(const lps::linear_process &x)
Definition lps.cpp:50
std::string pp(const lps::stochastic_specification &x)
Definition lps.cpp:37
bool check_well_typedness(const linear_process &x)
Definition lps.cpp:92
std::set< data::function_symbol > find_function_symbols(const lps::stochastic_specification &x)
Definition lps.cpp:59
std::string pp(const lps::linear_process &x)
Definition lps.cpp:29
std::vector< deadlock_summand > deadlock_summand_vector
\brief vector of deadlock_summands
lps::stochastic_specification action_rename(const action_rename_specification &action_rename_spec, const lps::stochastic_specification &lps_old_spec, const data::rewriter &rewr, const bool enable_rewriting)
Rename the actions in a linear specification using a given action_rename_spec.
std::string pp(const lps::deadlock &x)
Definition lps.cpp:27
std::set< process::action_label > find_action_labels(const lps::process_initializer &x)
Definition lps.cpp:63
std::string pp(const lps::multi_action &x)
Definition lps.cpp:30
std::set< data::variable > find_free_variables(const lps::specification &x)
Definition lps.cpp:52
multi_action typecheck_multi_action(process::untyped_multi_action &mult_act, const data::data_specification &data_spec, const process::action_label_list &action_decls)
Type check a multi action Throws an exception if something went wrong.
Definition typecheck.h:128
std::string pp(const lps::specification &x)
Definition lps.cpp:32
void normalize_sorts(lps::specification &x, const data::sort_specification &)
Definition lps.cpp:39
std::set< data::variable > find_free_variables(const lps::deadlock &x)
Definition lps.cpp:54
std::set< process::action_label > find_action_labels(const lps::linear_process &x)
Definition lps.cpp:62
lps::multi_action normalize_sorts(const lps::multi_action &x, const data::sort_specification &sortspec)
Definition lps.cpp:38
std::set< data::variable > find_free_variables(const lps::stochastic_linear_process &x)
Definition lps.cpp:51
multi_action typecheck_multi_action(process::untyped_multi_action &mult_act, multi_action_type_checker &typechecker)
Type check a multi action Throws an exception if something went wrong.
Definition typecheck.h:144
std::set< data::function_symbol > find_function_symbols(const lps::specification &x)
Definition lps.cpp:58
std::set< data::variable > find_free_variables(const lps::stochastic_process_initializer &x)
Definition lps.cpp:57
void normalize_sorts(T &x, const data::sort_specification &sortspec, typename std::enable_if< !std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
std::set< data::variable > find_free_variables(const lps::multi_action &x)
Definition lps.cpp:55
std::string pp(const lps::deadlock_summand &x)
Definition lps.cpp:28
void normalize_sorts(lps::stochastic_specification &x, const data::sort_specification &)
Definition lps.cpp:40
std::set< data::variable > find_free_variables(const lps::process_initializer &x)
Definition lps.cpp:56
std::string pp(const lps::stochastic_linear_process &x)
Definition lps.cpp:35
atermpp::aterm action_rename_specification_to_aterm(const action_rename_specification &spec)
atermpp::aterm action_rename_rule_to_aterm(const action_rename_rule &rule)
std::set< data::variable > find_all_variables(const lps::multi_action &x)
Definition lps.cpp:49
T normalize_sorts(const T &x, const data::sort_specification &sortspec, typename std::enable_if< std::is_base_of< atermpp::aterm, T >::value >::type *=0)
std::set< data::sort_expression > find_sort_expressions(const lps::specification &x)
Definition lps.cpp:42
std::vector< action_summand > action_summand_vector
\brief vector of action_summands
std::string pp(const lps::stochastic_action_summand &x)
Definition lps.cpp:33
std::set< data::variable > find_all_variables(const lps::specification &x)
Definition lps.cpp:46
stochastic_specification action_rename(const std::regex &matching_regex, const std::string &replacing_fmt, const stochastic_specification &lps_old_spec)
Rename actions in given specification based on a regular expression and a string that specifies how t...
bool check_well_typedness(const stochastic_specification &x)
Definition lps.cpp:107
std::set< data::variable > find_all_variables(const lps::deadlock &x)
Definition lps.cpp:48
action_rename_specification typecheck_action_rename_specification(const action_rename_specification &arspec, const lps::stochastic_specification &lpsspec)
Type checks an action rename specification.
Definition typecheck.h:157
std::set< data::variable > find_all_variables(const lps::stochastic_linear_process &x)
Definition lps.cpp:45
bool check_well_typedness(const stochastic_linear_process &x)
Definition lps.cpp:97
lps::multi_action translate_user_notation(const lps::multi_action &x)
Definition lps.cpp:41
std::set< core::identifier_string > find_identifiers(const lps::stochastic_specification &x)
Definition lps.cpp:61
std::string pp(const lps::action_summand &x)
Definition lps.cpp:26
std::set< core::identifier_string > find_identifiers(const lps::specification &x)
Definition lps.cpp:60
std::string pp_with_summand_numbers(const stochastic_specification &x)
Definition lps.cpp:83
std::set< process::action_label > find_action_labels(const lps::specification &x)
Definition lps.cpp:64
bool check_process_instance_assignment(const process_equation &eq, const process_instance_assignment &inst)
Returns true if the process instance assignment a matches with the process equation eq.
Definition is_linear.h:28
bool is_process(const process_expression &x)
Returns true if the argument is a process instance.
Definition is_linear.h:71
bool is_conditional_deadlock(const process_expression &x)
Returns true if the argument is a conditional deadlock.
Definition is_linear.h:131
bool is_linear_process_term(const process_expression &x)
Returns true if the argument is a linear process.
Definition is_linear.h:157
bool check_process_instance(const process_equation &eq, const process_instance &init)
Returns true if the process instance a matches with the process equation eq.
Definition is_linear.h:49
bool is_alternative(const process_expression &x)
Returns true if the argument is an alternative composition.
Definition is_linear.h:147
bool is_timed_deadlock(const process_expression &x)
Returns true if the argument is a deadlock.
Definition is_linear.h:96
bool is_action_prefix(const process_expression &x)
Returns true if the argument is an action prefix.
Definition is_linear.h:123
bool is_stochastic_process(const process_expression &x)
Returns true if the argument is a process instance, optionally wrapped in a stochastic distribution.
Definition is_linear.h:81
bool is_multiaction(const process_expression &x)
Returns true if the argument is a multi-action.
Definition is_linear.h:105
bool is_conditional_action_prefix(const process_expression &x)
Returns true if the argument is a conditional action prefix.
Definition is_linear.h:139
bool is_timed_multiaction(const process_expression &x)
Returns true if the argument is a multi-action.
Definition is_linear.h:115
The main namespace for the Process library.
bool is_at(const atermpp::aterm &x)
bool is_linear(const process_specification &p, bool verbose=false)
Returns true if the process specification is linear.
Definition is_linear.h:347
std::string pp(const process::comm &x)
Definition process.cpp:43
std::string pp(const process::untyped_multi_action &x)
Definition process.cpp:64
bool is_linear(const process_expression &x, const process_equation &eqn)
Returns true if the process expression is linear.
Definition is_linear.h:392
bool is_process_instance(const atermpp::aterm &x)
std::string pp(const process::block &x)
Definition process.cpp:40
bool is_process_instance_assignment(const atermpp::aterm &x)
bool is_tau(const atermpp::aterm &x)
std::string pp(const process::process_instance &x)
Definition process.cpp:54
bool is_seq(const atermpp::aterm &x)
std::string pp(const process::process_instance_assignment &x)
Definition process.cpp:55
bool is_delta(const atermpp::aterm &x)
bool is_linear(const process_equation &eqn)
Returns true if the process equation is linear.
Definition is_linear.h:382
bool is_sum(const atermpp::aterm &x)
bool is_action(const atermpp::aterm &x)
std::string pp(const process::left_merge &x)
Definition process.cpp:49
std::string pp(const process::hide &x)
Definition process.cpp:46
atermpp::term_list< action_label > action_label_list
\brief list of action_labels
std::string pp(const process::allow &x)
Definition process.cpp:38
std::string pp(const process::if_then_else &x)
Definition process.cpp:48
atermpp::term_list< action > action_list
\brief list of actions
std::string pp(const process::rename &x)
Definition process.cpp:57
std::string pp(const process::process_expression &x)
Definition process.cpp:52
bool is_if_then(const atermpp::aterm &x)
std::string pp(const process::merge &x)
Definition process.cpp:50
std::string pp(const process::bounded_init &x)
Definition process.cpp:41
bool is_choice(const atermpp::aterm &x)
bool is_stochastic_operator(const atermpp::aterm &x)
std::string pp(const process::if_then &x)
Definition process.cpp:47
bool is_sync(const atermpp::aterm &x)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
core::identifier_string parse_Id(const parse_node &node) const
Definition parse.h:233
Wrapper for D_ParseNode.
Definition dparser.h:86
parse_node child(int i) const
Definition dparser.cpp:43
int child_count() const
Definition dparser.cpp:37
std::string symbol_name(const parse_node &node) const
Definition parse.h:205
const parser & m_parser
Definition parse.h:85
Wrapper for D_Parser and its corresponding D_ParserTables.
Definition dparser.h:148
parse_node parse(const std::string &text, unsigned int start_symbol_index=0, bool partial_parses=false)
Parses a string. N.B. The user is responsible for destruction of the returned value by calling destro...
Definition dparser.cpp:209
parser(D_ParserTables &tables, D_AmbiguityFn ambiguity_fn=nullptr, D_SyntaxErrorFn syntax_error_fn=nullptr, std::size_t max_error_message_count=1)
Definition dparser.cpp:174
unsigned int start_symbol_index(const std::string &name) const
Definition dparser.cpp:204
Substitution that maps data variables to data expressions. The substitution is stored as an assignmen...
assignment_sequence_substitution(const assignment_list &assignments_)
data::data_expression parse_DataExpr(const core::parse_node &node) const
Definition parse_impl.h:211
bool callback_DataSpecElement(const core::parse_node &node, untyped_data_specification &result) const
Definition parse_impl.h:413
normalize_sorts_function(const sort_specification &sort_spec)
std::vector< lps::action_rename_rule > parse_ActionRenameRuleList(const core::parse_node &node) const
Definition parse_impl.h:75
process::action parse_Action_as_action(const core::parse_node &node) const
Definition parse_impl.h:51
bool callback_ActionRenameSpec(const core::parse_node &node, data::untyped_data_specification &dataspec_result, lps::action_rename_specification &result) const
Definition parse_impl.h:91
std::vector< lps::action_rename_rule > parse_ActionRenameRuleSpec(const core::parse_node &node) const
Definition parse_impl.h:80
lps::action_rename_specification parse_ActionRenameSpec(const core::parse_node &node) const
Definition parse_impl.h:123
process::process_expression parse_ActionRenameRuleRHS(const core::parse_node &node) const
Definition parse_impl.h:57
action_rename_actions(const core::parser &parser_)
Definition parse_impl.h:46
lps::action_rename_rule parse_ActionRenameRule(const core::parse_node &node) const
Definition parse_impl.h:65
Function object for applying a substitution to LPS data types.
bool is_well_typed(const linear_process_base< ActionSummand > &p) const
Checks well typedness of a linear process.
bool is_well_typed(const process::action &a) const
Traverses an action.
bool is_well_typed(const action_summand &s) const
Checks well typedness of a summand.
bool check_time(const data::data_expression &t, const std::string &type) const
Checks if the sort of t has type real.
bool is_well_typed(const data::assignment &a) const
Traverses an assignment.
bool check_condition(const data::data_expression &t, const std::string &type) const
Checks if the sort of t has type bool.
bool is_well_typed(const stochastic_specification &spec) const
bool is_well_typed(const data::variable &d) const
Checks well typedness of a variable.
bool check_assignments(const data::assignment_list &l, const std::string &type) const
Checks if the assignments are well typed and have unique left hand sides.
bool is_well_typed(const specification &spec) const
bool is_well_typed(const data::sort_expression &d) const
Checks well typedness of a sort expression.
bool is_well_typed_container(const Container &c) const
Checks well typedness of the elements of a container.
bool is_well_typed(const process::action_label &d) const
Traverses an action label.
bool is_well_typed(const specification_base< LinearProcess, InitialProcessExpression > &spec, const std::set< data::variable > &free_variables) const
Checks well typedness of a linear process specification.
bool is_well_typed(const deadlock &d) const
Checks well typedness of a deadlock.
bool is_well_typed(const data::data_expression &d) const
Checks well typedness of a data expression.
bool is_well_typed(const deadlock_summand &s) const
Checks well typedness of a summand.
bool is_well_typed(const multi_action &a) const
Checks well typedness of a multi-action.
process::untyped_multi_action parse_MultAct(const core::parse_node &node) const
Definition parse_impl.h:33
multi_action_actions(const core::parser &parser_)
Definition parse_impl.h:29
action_actions(const core::parser &parser_)
Definition parse_impl.h:47
Converts a process expression into linear process format. Use the convert member functions for this.
process_expression_traverser< linear_process_conversion_traverser > super
lps::deadlock_summand_vector m_deadlock_summands
The result of the conversion.
process_equation m_equation
The process equation that is checked.
lps::specification convert(const process_specification &p)
Converts a process_specification into a specification. Throws non_linear_process if a non-linear sub-...
void leave(const process::left_merge &x)
Visit left_merge node.
lps::action_summand_vector m_action_summands
The result of the conversion.
void leave(const process::bounded_init &x)
Visit bounded_init node.
void convert(const process_equation &)
Returns true if the process equation e is linear.
void leave(const process::if_then_else &x)
Visit if_then_else node.
Exception that is thrown by linear_process_expression_traverser.
Definition is_linear.h:178
Checks if a process equation is linear. Use the is_linear() member function for this.
Definition is_linear.h:167
process_expression_traverser< linear_process_expression_traverser > super
Definition is_linear.h:168
linear_process_expression_traverser(const process_equation &eqn_=process_equation())
Definition is_linear.h:184
void enter(const process::process_instance &x)
Definition is_linear.h:189
process_equation eqn
The process equation that is checked.
Definition is_linear.h:174
bool is_linear(const process_expression &x, bool verbose=false)
Returns true if the process equation e is linear.
Definition is_linear.h:325
void enter(const process::process_instance_assignment &x)
Definition is_linear.h:197
Converts a process expression into linear process format. Use the convert member functions for this.
void leave(const process::stochastic_operator &x)
Visit stochastic operator node.
void convert(const process_equation &)
Returns true if the process equation e is linear.
lps::stochastic_action_summand_vector m_action_summands
The result of the conversion.
lps::deadlock_summand_vector m_deadlock_summands
The result of the conversion.
process_expression_traverser< stochastic_linear_process_conversion_traverser > super
lps::stochastic_specification convert(const process_specification &p)
Converts a process_specification into a stochastic_specification. Throws non_linear_process if a non-...
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const