mCRL2
Loading...
Searching...
No Matches
bool.h
Go to the documentation of this file.
1// Author(s): 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//
14
15#ifndef MCRL2_DATA_BOOL_H
16#define MCRL2_DATA_BOOL_H
17
18#include "functional" // std::function
25#include "mcrl2/data/standard.h"
26
27namespace mcrl2 {
28
29 namespace data {
30
32 namespace sort_bool {
33
34 inline
36 {
38 return bool_name;
39 }
40
43 inline
45 {
47 return bool_;
48 }
49
53 inline
54 bool is_bool(const sort_expression& e)
55 {
56 if (is_basic_sort(e))
57 {
58 return basic_sort(e) == bool_();
59 }
60 return false;
61 }
62
63
66 inline
68 {
70 return true_name;
71 }
72
74
76 inline
78 {
80 return true_;
81 }
82
86 inline
88 {
89 if (is_function_symbol(e))
90 {
91 return atermpp::down_cast<function_symbol>(e) == true_();
92 }
93 return false;
94 }
95
98 inline
100 {
102 return false_name;
103 }
104
106
108 inline
110 {
112 return false_;
113 }
114
118 inline
120 {
121 if (is_function_symbol(e))
122 {
123 return atermpp::down_cast<function_symbol>(e) == false_();
124 }
125 return false;
126 }
129 inline
131 {
133 result.push_back(sort_bool::true_());
134 result.push_back(sort_bool::false_());
135
136 return result;
137 }
140 inline
142 {
144 result.push_back(sort_bool::true_());
145 result.push_back(sort_bool::false_());
146
147 return result;
148 }
149 // The typedef is the sort that maps a function symbol to an function that rewrites it as well as a string of a function that can be used to implement it
150 typedef std::map<function_symbol,std::pair<std::function<void(data_expression&, const data_expression&)>, std::string> > implementation_map;
153 inline
155 {
156 implementation_map result;
157 return result;
158 }
159
162 inline
164 {
166 return not_name;
167 }
168
170
172 inline
174 {
176 return not_;
177 }
178
182 inline
184 {
185 if (is_function_symbol(e))
186 {
187 return atermpp::down_cast<function_symbol>(e) == not_();
188 }
189 return false;
190 }
191
193
196 inline
198 {
199 return sort_bool::not_()(arg0);
200 }
201
204
206 inline
207 void make_not_(data_expression& result, const data_expression& arg0)
208 {
209 make_application(result, sort_bool::not_(),arg0);
210 }
211
216 inline
218 {
219 return is_application(e) && is_not_function_symbol(atermpp::down_cast<application>(e).head());
220 }
221
224 inline
226 {
228 return and_name;
229 }
230
232
234 inline
236 {
238 return and_;
239 }
240
244 inline
246 {
247 if (is_function_symbol(e))
248 {
249 return atermpp::down_cast<function_symbol>(e) == and_();
250 }
251 return false;
252 }
253
255
259 inline
261 {
262 return sort_bool::and_()(arg0, arg1);
263 }
264
267
270 inline
272 {
273 make_application(result, sort_bool::and_(),arg0, arg1);
274 }
275
280 inline
282 {
283 return is_application(e) && is_and_function_symbol(atermpp::down_cast<application>(e).head());
284 }
285
288 inline
290 {
292 return or_name;
293 }
294
296
298 inline
300 {
302 return or_;
303 }
304
308 inline
310 {
311 if (is_function_symbol(e))
312 {
313 return atermpp::down_cast<function_symbol>(e) == or_();
314 }
315 return false;
316 }
317
319
323 inline
325 {
326 return sort_bool::or_()(arg0, arg1);
327 }
328
331
334 inline
336 {
337 make_application(result, sort_bool::or_(),arg0, arg1);
338 }
339
344 inline
346 {
347 return is_application(e) && is_or_function_symbol(atermpp::down_cast<application>(e).head());
348 }
349
352 inline
354 {
356 return implies_name;
357 }
358
360
362 inline
364 {
366 return implies;
367 }
368
372 inline
374 {
375 if (is_function_symbol(e))
376 {
377 return atermpp::down_cast<function_symbol>(e) == implies();
378 }
379 return false;
380 }
381
383
387 inline
389 {
390 return sort_bool::implies()(arg0, arg1);
391 }
392
395
398 inline
400 {
402 }
403
408 inline
410 {
411 return is_application(e) && is_implies_function_symbol(atermpp::down_cast<application>(e).head());
412 }
415 inline
417 {
419 result.push_back(sort_bool::not_());
420 result.push_back(sort_bool::and_());
421 result.push_back(sort_bool::or_());
422 result.push_back(sort_bool::implies());
423 return result;
424 }
425
428 inline
430 {
433 {
434 result.push_back(f);
435 }
436 return result;
437 }
438
441 inline
443 {
445 result.push_back(sort_bool::not_());
446 result.push_back(sort_bool::and_());
447 result.push_back(sort_bool::or_());
448 result.push_back(sort_bool::implies());
449 return result;
450 }
451
452
453 // The typedef is the sort that maps a function symbol to an function that rewrites it as well as a string of a function that can be used to implement it
454 typedef std::map<function_symbol,std::pair<std::function<void(data_expression&, const data_expression&)>, std::string> > implementation_map;
457 inline
459 {
460 implementation_map result;
461 return result;
462 }
468 inline
470 {
471 assert(is_not_application(e));
472 return atermpp::down_cast<application>(e)[0];
473 }
474
480 inline
482 {
484 return atermpp::down_cast<application>(e)[0];
485 }
486
492 inline
494 {
496 return atermpp::down_cast<application>(e)[1];
497 }
498
501 inline
503 {
504 variable vb("b",bool_());
505
507 result.push_back(data_equation(variable_list(), not_(true_()), false_()));
508 result.push_back(data_equation(variable_list(), not_(false_()), true_()));
509 result.push_back(data_equation(variable_list({vb}), not_(not_(vb)), vb));
510 result.push_back(data_equation(variable_list({vb}), and_(vb, true_()), vb));
511 result.push_back(data_equation(variable_list({vb}), and_(vb, false_()), false_()));
512 result.push_back(data_equation(variable_list({vb}), and_(true_(), vb), vb));
513 result.push_back(data_equation(variable_list({vb}), and_(false_(), vb), false_()));
514 result.push_back(data_equation(variable_list({vb}), or_(vb, true_()), true_()));
515 result.push_back(data_equation(variable_list({vb}), or_(vb, false_()), vb));
516 result.push_back(data_equation(variable_list({vb}), or_(true_(), vb), true_()));
517 result.push_back(data_equation(variable_list({vb}), or_(false_(), vb), vb));
518 result.push_back(data_equation(variable_list({vb}), implies(vb, true_()), true_()));
519 result.push_back(data_equation(variable_list({vb}), implies(vb, false_()), not_(vb)));
520 result.push_back(data_equation(variable_list({vb}), implies(true_(), vb), vb));
521 result.push_back(data_equation(variable_list({vb}), implies(false_(), vb), true_()));
522 result.push_back(data_equation(variable_list({vb}), equal_to(true_(), vb), vb));
523 result.push_back(data_equation(variable_list({vb}), equal_to(false_(), vb), not_(vb)));
524 result.push_back(data_equation(variable_list({vb}), equal_to(vb, true_()), vb));
525 result.push_back(data_equation(variable_list({vb}), equal_to(vb, false_()), not_(vb)));
526 result.push_back(data_equation(variable_list({vb}), less(false_(), vb), vb));
527 result.push_back(data_equation(variable_list({vb}), less(true_(), vb), false_()));
528 result.push_back(data_equation(variable_list({vb}), less(vb, false_()), false_()));
529 result.push_back(data_equation(variable_list({vb}), less(vb, true_()), not_(vb)));
530 result.push_back(data_equation(variable_list({vb}), less_equal(false_(), vb), true_()));
531 result.push_back(data_equation(variable_list({vb}), less_equal(true_(), vb), vb));
532 result.push_back(data_equation(variable_list({vb}), less_equal(vb, false_()), not_(vb)));
533 result.push_back(data_equation(variable_list({vb}), less_equal(vb, true_()), true_()));
534 return result;
535 }
536
537 } // namespace sort_bool_
538
539 } // namespace data
540
541} // namespace mcrl2
542
543#endif // MCRL2_DATA_BOOL_H
The class application.
The class basic_sort.
Term containing a string.
An application of a data expression to a number of arguments.
\brief A basic sort
Definition basic_sort.h:26
\brief A data equation
\brief A function symbol
\brief A sort expression
\brief A data variable
Definition variable.h:28
The class function symbol.
The class data_equation.
Exception classes for use in libraries and tools.
The class function_sort.
atermpp::aterm_string identifier_string
String type of the LPS library. Identifier strings are represented internally as ATerms.
data_equation_vector bool_generate_equations_code()
Give all system defined equations for bool_.
Definition bool.h:502
bool is_false_function_symbol(const atermpp::aterm &e)
Recogniser for function false.
Definition bool.h:119
const data_expression & arg(const data_expression &e)
Function for projecting out argument. arg from an application.
Definition bool.h:469
function_symbol_vector bool_mCRL2_usable_mappings()
Give all system defined mappings that can be used in mCRL2 specs for bool_.
Definition bool.h:442
function_symbol_vector bool_mCRL2_usable_constructors()
Give all defined constructors which can be used in mCRL2 specs for bool_.
Definition bool.h:141
bool is_or_application(const atermpp::aterm &e)
Recogniser for application of ||.
Definition bool.h:345
bool is_bool(const sort_expression &e)
Recogniser for sort expression Bool.
Definition bool.h:54
const core::identifier_string & implies_name()
Generate identifier =>.
Definition bool.h:353
const basic_sort & bool_()
Constructor for sort expression Bool.
Definition bool.h:44
const core::identifier_string & or_name()
Generate identifier ||.
Definition bool.h:289
implementation_map bool_cpp_implementable_constructors()
Give all system defined constructors which have an implementation in C++ and not in rewrite rules for...
Definition bool.h:154
const function_symbol & implies()
Constructor for function symbol =>.
Definition bool.h:363
const data_expression & right(const data_expression &e)
Function for projecting out argument. right from an application.
Definition bool.h:493
bool is_not_function_symbol(const atermpp::aterm &e)
Recogniser for function !.
Definition bool.h:183
bool is_implies_application(const atermpp::aterm &e)
Recogniser for application of =>.
Definition bool.h:409
const function_symbol & and_()
Constructor for function symbol &&.
Definition bool.h:235
std::map< function_symbol, std::pair< std::function< void(data_expression &, const data_expression &)>, std::string > > implementation_map
Definition bool.h:150
function_symbol_vector bool_generate_constructors_and_functions_code()
Give all system defined mappings and constructors for bool_.
Definition bool.h:429
const core::identifier_string & not_name()
Generate identifier !.
Definition bool.h:163
function_symbol_vector bool_generate_constructors_code()
Give all system defined constructors for bool_.
Definition bool.h:130
implementation_map bool_cpp_implementable_mappings()
Give all system defined mappings that are to be implemented in C++ code for bool_.
Definition bool.h:458
const function_symbol & false_()
Constructor for function symbol false.
Definition bool.h:109
const core::identifier_string & bool_name()
Definition bool.h:35
bool is_and_function_symbol(const atermpp::aterm &e)
Recogniser for function &&.
Definition bool.h:245
bool is_and_application(const atermpp::aterm &e)
Recogniser for application of &&.
Definition bool.h:281
const function_symbol & or_()
Constructor for function symbol ||.
Definition bool.h:299
bool is_or_function_symbol(const atermpp::aterm &e)
Recogniser for function ||.
Definition bool.h:309
bool is_true_function_symbol(const atermpp::aterm &e)
Recogniser for function true.
Definition bool.h:87
const core::identifier_string & false_name()
Generate identifier false.
Definition bool.h:99
const core::identifier_string & true_name()
Generate identifier true.
Definition bool.h:67
bool is_not_application(const atermpp::aterm &e)
Recogniser for application of !.
Definition bool.h:217
function_symbol_vector bool_generate_functions_code()
Give all system defined mappings for bool_.
Definition bool.h:416
const function_symbol & not_()
Constructor for function symbol !.
Definition bool.h:173
void make_not_(data_expression &result, const data_expression &arg0)
Make an application of function symbol !.
Definition bool.h:207
void make_and_(data_expression &result, const data_expression &arg0, const data_expression &arg1)
Make an application of function symbol &&.
Definition bool.h:271
const function_symbol & true_()
Constructor for function symbol true.
Definition bool.h:77
bool is_implies_function_symbol(const atermpp::aterm &e)
Recogniser for function =>.
Definition bool.h:373
void make_or_(data_expression &result, const data_expression &arg0, const data_expression &arg1)
Make an application of function symbol ||.
Definition bool.h:335
void make_implies(data_expression &result, const data_expression &arg0, const data_expression &arg1)
Make an application of function symbol =>.
Definition bool.h:399
const data_expression & left(const data_expression &e)
Function for projecting out argument. left from an application.
Definition bool.h:481
const core::identifier_string & and_name()
Generate identifier &&.
Definition bool.h:225
function_symbol less_equal(const sort_expression &s)
Constructor for function symbol <=.
Definition standard.h:277
const data_expression & arg1(const data_expression &e)
Function for projecting out argument. arg1 from an application.
function_symbol less(const sort_expression &s)
Constructor for function symbol <.
Definition standard.h:240
std::vector< data_equation > data_equation_vector
\brief vector of data_equations
function_sort make_function_sort_(const sort_expression &dom1, const sort_expression &codomain)
Convenience constructor for function sort with domain size 1.
bool is_function_symbol(const atermpp::aterm &x)
Returns true if the term t is a function symbol.
bool is_basic_sort(const atermpp::aterm &x)
Returns true if the term t is a basic sort.
atermpp::term_list< variable > variable_list
\brief list of variables
function_symbol equal_to(const sort_expression &s)
Constructor for function symbol ==.
Definition standard.h:126
bool is_application(const atermpp::aterm &x)
Returns true if the term t is an application.
std::vector< function_symbol > function_symbol_vector
\brief vector of function_symbols
void make_application(atermpp::aterm &result)
Make function for an application.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
Standard functions that are available for all sorts.