mCRL2
Loading...
Searching...
No Matches
linearise_utility.h
Go to the documentation of this file.
1// Author(s): Jan Friso Groote, Jeroen Keiren
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
11
12#ifndef MCRL2_LPS_LINEARISE_UTILITY_H
13#define MCRL2_LPS_LINEARISE_UTILITY_H
14
19
20
21namespace mcrl2
22{
23
24namespace lps
25{
26
28{
30 {
31 return std::string(s1) < std::string(s2);
32 }
33};
34
38{
39
41 {
42 /* first compare the strings in the actions */
43 const core::identifier_string& a1_name = a1.name();
44 const core::identifier_string& a2_name = a2.name();
45
46 return action_name_compare()(a1_name, a2_name) ||
47 (a1_name == a2_name && a1.sorts() < a2.sorts());
48 }
49};
50
51
60{
61 bool operator()(const process::action& a1, const process::action& a2) const
62 {
63 const process::action_label& a1_label = a1.label();
64 const process::action_label& a2_label = a2.label();
65
66 return action_label_compare()(a1_label, a2_label);
67 }
68};
69
72inline
74 const process::action& act,
76{
77 if (l.empty())
78 {
79 return process::action_list({ act });
80 }
81 const process::action& head = l.front();
82
83 if (action_compare()(act, head))
84 {
85 l.push_front(act);
86 return l;
87 }
88
89 process::action_list result = insert(act, l.tail());
90 result.push_front(head);
91 return result;
92}
93
95inline
99{
100 if (l.empty())
101 {
102 return core::identifier_string_list({ s });
103 }
104 const core::identifier_string& head = l.front();
105
106 if (action_name_compare()(s, head))
107 {
108 l.push_front(s);
109 return l;
110 }
111
113 result.push_front(head);
114 return result;
115}
116
117inline
119 const std::function<bool(const core::identifier_string&, const core::identifier_string&)>& cmp
120 = [](const core::identifier_string& t1, const core::identifier_string& t2){ return action_name_compare()(t1, t2);})
121{
122 return process::action_name_multiset(atermpp::sort_list(action_labels.names(), cmp));
123}
124
125inline
127{
128 return process::action_name_multiset_list(l.begin(),l.end(),[](const process::action_name_multiset& al){ return sort_action_names(al); });
129}
130
131inline
133 const std::function<bool(const process::action&, const process::action&)>& cmp
134 = [](const process::action& t1, const process::action& t2){ return action_compare()(t1, t2);})
135{
136 return process::action_list(atermpp::sort_list(actions, cmp));
137}
138
139
143inline
145{
147
148 for (const process::communication_expression& comm: communications)
149 {
150 result.push_front(process::communication_expression(sort_action_names(comm.action_name()),comm.name()));
151 }
152
153 return result;
154}
155
156inline
158{
159 if (c2==data::sort_bool::true_())
160 {
161 return true;
162 }
163
164 if (c1==data::sort_bool::false_())
165 {
166 return true;
167 }
168
169 if (c1==data::sort_bool::true_())
170 {
171 return false;
172 }
173
174 if (c2==data::sort_bool::false_())
175 {
176 return false;
177 }
178
179 if (c1==c2)
180 {
181 return true;
182 }
183
184 /* Dealing with the conjunctions (&&) first and then the disjunctions (||)
185 yields a 10-fold speed increase compared to the case where first the
186 || occur, and then the &&. This result was measured on the alternating
187 bit protocol, with --regular. */
188
190 {
191 return implies_condition(c1,data::binary_left(atermpp::down_cast<data::application>(c2))) &&
192 implies_condition(c1,data::binary_right(atermpp::down_cast<data::application>(c2)));
193 }
194
196 {
197 return implies_condition(data::binary_left(atermpp::down_cast<data::application>(c1)),c2) &&
198 implies_condition(data::binary_right(atermpp::down_cast<data::application>(c1)),c2);
199 }
200
202 {
203 return implies_condition(data::binary_left(atermpp::down_cast<data::application>(c1)),c2) ||
204 implies_condition(data::binary_right(atermpp::down_cast<data::application>(c1)),c2);
205 }
206
208 {
209 return implies_condition(c1,data::binary_left(atermpp::down_cast<data::application>(c2))) ||
210 implies_condition(c1,data::binary_right(atermpp::down_cast<data::application>(c2)));
211 }
212
213 return false;
214}
215
220inline
222{
223 return (!as.multi_action().has_time() || ds.deadlock().time() == as.multi_action().time())
225}
226
228inline
229bool subsumes(const deadlock_summand& ds1, const deadlock_summand& ds2)
230{
231 return (!ds1.deadlock().has_time() || ds2.deadlock().time() == ds1.deadlock().time())
232 && implies_condition(ds2.condition(), ds1.condition());
233}
234
235
236inline
238 const stochastic_action_summand_vector& action_summands,
239 deadlock_summand_vector& deadlock_summands,
240 const deadlock_summand& s,
241 const bool ignore_time)
242{
243 if (ignore_time)
244 {
245 deadlock_summands.push_back(s);
246 return;
247 }
248
249 assert(!ignore_time);
250
251 // First check whether the delta summand is subsumed by an action summand.
252 if (std::any_of(action_summands.begin(), action_summands.end(),
253 [&s](const stochastic_action_summand& as) { return subsumes(as, s); }))
254 {
255 return;
256 }
257
259
260 for (deadlock_summand_vector::iterator i=deadlock_summands.begin(); i!=deadlock_summands.end(); ++i)
261 {
262 if (subsumes(*i, s))
263 {
264 /* put the summand that was effective in removing
265 this delta summand to the front, such that it
266 is encountered early later on, removing a next
267 delta summand */
268
269 copy(i,deadlock_summands.end(),back_inserter(result));
270 deadlock_summands.swap(result);
271 return;
272 }
273 if (!subsumes(s, *i))
274 {
275 result.push_back(*i);
276 }
277 }
278
279 result.push_back(s);
280 deadlock_summands.swap(result);
281}
282
283inline
285{
286 return data::search_free_variable(t, var);
287}
288
289} // namespace lps
290
291} // namespace mcrl2
292
293
294
295#endif // MCRL2_LPS_LINEARISE_RENAME_H
Term containing a string.
A list of aterm objects.
Definition aterm_list.h:24
const_iterator end() const
Returns a const_iterator pointing to the end of the term_list.
Definition aterm_list.h:282
const term_list< Term > & tail() const
Returns the tail of the list.
Definition aterm_list.h:225
const Term & front() const
Returns the first element of the list.
Definition aterm_list.h:239
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the term_list.
Definition aterm_list.h:275
bool empty() const
Returns true if the list's size is 0.
Definition aterm_list.h:268
void push_front(const Term &el)
Inserts a new element at the beginning of the current list.
\brief A data variable
Definition variable.h:28
const lps::multi_action & multi_action() const
Returns the multi-action of this summand.
LPS summand containing a deadlock.
const lps::deadlock & deadlock() const
Returns the deadlock of this summand.
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
bool has_time() const
Returns true if time is available.
const data::data_expression & time() const
LPS summand containing a multi-action.
const data::data_expression & condition() const
Returns the condition expression.
Definition summand.h:60
\brief An action label
const data::sort_expression_list & sorts() const
const core::identifier_string & name() const
\brief A multiset of action names
const core::identifier_string_list & names() const
const action_label & label() const
The class data_expression.
add your file description here.
@ act
Definition linearise.cpp:83
term_list< Term > sort_list(const term_list< Term > &l, const std::function< bool(const Term &, const Term &)> &ordering=[](const Term &t1, const Term &t2){ return t1< t2;})
Returns the list with the elements sorted according to the <-operator on the addresses of terms.
atermpp::term_list< identifier_string > identifier_string_list
\brief list of identifier_strings
bool is_or_application(const atermpp::aterm &e)
Recogniser for application of ||.
Definition bool.h:345
const function_symbol & false_()
Constructor for function symbol false.
Definition bool.h:109
bool is_and_application(const atermpp::aterm &e)
Recogniser for application of &&.
Definition bool.h:281
const function_symbol & true_()
Constructor for function symbol true.
Definition bool.h:77
const data_expression & binary_right(const application &x)
bool search_free_variable(const T &x, const variable &v)
Returns true if the term has a given free variable as subterm.
Definition find.h:456
const data_expression & binary_left(const application &x)
std::vector< stochastic_action_summand > stochastic_action_summand_vector
\brief vector of stochastic_action_summands
process::communication_expression_list sort_communications(const process::communication_expression_list &communications)
process::action_list insert(const process::action &act, process::action_list l)
bool implies_condition(const data::data_expression &c1, const data::data_expression &c2)
bool occursinterm(const data::data_expression &t, const data::variable &var)
std::vector< deadlock_summand > deadlock_summand_vector
\brief vector of deadlock_summands
process::action_list sort_actions(const process::action_list &actions, const std::function< bool(const process::action &, const process::action &)> &cmp=[](const process::action &t1, const process::action &t2){ return action_compare()(t1, t2);})
void insert_timed_delta_summand(const stochastic_action_summand_vector &action_summands, deadlock_summand_vector &deadlock_summands, const deadlock_summand &s, const bool ignore_time)
process::action_name_multiset_list sort_multi_action_labels(const process::action_name_multiset_list &l)
bool subsumes(const stochastic_action_summand &as, const deadlock_summand &ds)
process::action_name_multiset sort_action_names(const process::action_name_multiset &action_labels, const std::function< bool(const core::identifier_string &, const core::identifier_string &)> &cmp=[](const core::identifier_string &t1, const core::identifier_string &t2){ return action_name_compare()(t1, t2);})
atermpp::term_list< action > action_list
\brief list of actions
atermpp::term_list< action_name_multiset > action_name_multiset_list
\brief list of action_name_multisets
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
add your file description here.
add your file description here.
bool operator()(const process::action &a1, const process::action &a2) const
bool operator()(const process::action_label &a1, const process::action_label &a2) const
bool operator()(const core::identifier_string &s1, const core::identifier_string &s2) const